@capawesome/cli 0.0.8 → 0.0.9-dev.6ab2d3a.1720599121
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/commands/apps/bundles/create.js +38 -15
- package/dist/utils/buffer.js +28 -0
- package/dist/utils/hash.js +40 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [0.0.9](https://github.com/capawesome-team/cli/compare/v0.0.8...v0.0.9) (2024-07-04)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **bundles:** add `url` argument ([bf7b213](https://github.com/capawesome-team/cli/commit/bf7b21346813543992128f54e9a6bde283c38446))
|
|
11
|
+
|
|
5
12
|
## [0.0.8](https://github.com/capawesome-team/cli/compare/v0.0.7...v0.0.8) (2024-06-10)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -22,6 +22,8 @@ const authorization_service_1 = __importDefault(require("../../../services/autho
|
|
|
22
22
|
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
23
23
|
const app_bundles_1 = __importDefault(require("../../../services/app-bundles"));
|
|
24
24
|
const error_1 = require("../../../utils/error");
|
|
25
|
+
const hash_1 = require("../../../utils/hash");
|
|
26
|
+
const buffer_1 = require("../../../utils/buffer");
|
|
25
27
|
exports.default = (0, citty_1.defineCommand)({
|
|
26
28
|
meta: {
|
|
27
29
|
description: 'Create a new app bundle.',
|
|
@@ -43,6 +45,14 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
43
45
|
type: 'string',
|
|
44
46
|
description: 'Channel to associate the bundle with.',
|
|
45
47
|
},
|
|
48
|
+
iosMax: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
description: 'The maximum iOS bundle version (`CFBundleVersion`) that the bundle supports.',
|
|
51
|
+
},
|
|
52
|
+
iosMin: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'The minimum iOS bundle version (`CFBundleVersion`) that the bundle supports.',
|
|
55
|
+
},
|
|
46
56
|
path: {
|
|
47
57
|
type: 'string',
|
|
48
58
|
description: 'Path to the bundle to upload. Must be a folder (e.g. `www` or `dist`) or a zip file.',
|
|
@@ -51,13 +61,9 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
51
61
|
type: 'string',
|
|
52
62
|
description: 'The percentage of devices to deploy the bundle to. Must be a number between 0 and 1 (e.g. 0.5).',
|
|
53
63
|
},
|
|
54
|
-
|
|
55
|
-
type: 'string',
|
|
56
|
-
description: 'The maximum iOS bundle version (`CFBundleVersion`) that the bundle supports.',
|
|
57
|
-
},
|
|
58
|
-
iosMin: {
|
|
64
|
+
url: {
|
|
59
65
|
type: 'string',
|
|
60
|
-
description: 'The
|
|
66
|
+
description: 'The url to the self-hosted bundle file.',
|
|
61
67
|
},
|
|
62
68
|
},
|
|
63
69
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -67,9 +73,10 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
67
73
|
}
|
|
68
74
|
const { androidMax, androidMin, rollout, iosMax, iosMin } = ctx.args;
|
|
69
75
|
let appId = ctx.args.appId;
|
|
70
|
-
let path = ctx.args.path;
|
|
71
76
|
let channelName = ctx.args.channel;
|
|
72
|
-
|
|
77
|
+
let path = ctx.args.path;
|
|
78
|
+
let url = ctx.args.url;
|
|
79
|
+
if (!path && !url) {
|
|
73
80
|
path = yield (0, prompt_1.prompt)('Enter the path to the app bundle:', {
|
|
74
81
|
type: 'text',
|
|
75
82
|
});
|
|
@@ -99,13 +106,24 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
99
106
|
}
|
|
100
107
|
// Create form data
|
|
101
108
|
const formData = new form_data_1.default();
|
|
102
|
-
if (
|
|
103
|
-
|
|
109
|
+
if (path) {
|
|
110
|
+
if (zip_1.default.isZipped(path)) {
|
|
111
|
+
const readStream = (0, node_fs_1.createReadStream)(path);
|
|
112
|
+
const buffer = yield (0, buffer_1.createBuffer)(readStream);
|
|
113
|
+
const hash = yield (0, hash_1.createHash)(buffer);
|
|
114
|
+
formData.append('file', buffer, { filename: 'bundle.zip' });
|
|
115
|
+
formData.append('checksum', hash);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
consola_1.default.start('Zipping folder...');
|
|
119
|
+
const zipBuffer = yield zip_1.default.zipFolder(path);
|
|
120
|
+
const hash = yield (0, hash_1.createHash)(zipBuffer);
|
|
121
|
+
formData.append('file', zipBuffer, { filename: 'bundle.zip' });
|
|
122
|
+
formData.append('checksum', hash);
|
|
123
|
+
}
|
|
104
124
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const zipBuffer = yield zip_1.default.zipFolder(path);
|
|
108
|
-
formData.append('file', zipBuffer, { filename: 'bundle.zip' });
|
|
125
|
+
if (url) {
|
|
126
|
+
formData.append('url', url);
|
|
109
127
|
}
|
|
110
128
|
if (channelName) {
|
|
111
129
|
formData.append('channelName', channelName);
|
|
@@ -130,7 +148,12 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
130
148
|
if (iosMin) {
|
|
131
149
|
formData.append('minIosAppVersionCode', iosMin);
|
|
132
150
|
}
|
|
133
|
-
|
|
151
|
+
if (path) {
|
|
152
|
+
consola_1.default.start('Uploading...');
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
consola_1.default.start('Creating...');
|
|
156
|
+
}
|
|
134
157
|
// Upload the bundle
|
|
135
158
|
try {
|
|
136
159
|
const response = yield app_bundles_1.default.create({ appId: appId, formData: formData });
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createBuffer = void 0;
|
|
13
|
+
const createBuffer = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
const chunks = [];
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
data.on('readable', () => {
|
|
17
|
+
let chunk;
|
|
18
|
+
while ((chunk = data.read())) {
|
|
19
|
+
chunks.push(chunk);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
data.on('end', () => {
|
|
23
|
+
resolve(Buffer.concat(chunks));
|
|
24
|
+
});
|
|
25
|
+
data.on('error', reject);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
exports.createBuffer = createBuffer;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.createHash = void 0;
|
|
36
|
+
const createHash = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
const crypto = yield Promise.resolve().then(() => __importStar(require('crypto')));
|
|
38
|
+
return crypto.createHash('sha256').update(data).digest('hex');
|
|
39
|
+
});
|
|
40
|
+
exports.createHash = createHash;
|
package/package.json
CHANGED