@revopush/code-push-cli 0.0.3 → 0.0.5
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/bin/script/command-executor.js +7 -3
- package/bin/script/command-parser.js +8 -0
- package/bin/test/cli.js +32 -0
- package/package.json +6 -4
- package/script/command-executor.ts +10 -3
- package/script/command-parser.ts +9 -0
- package/script/types/cli.ts +1 -0
- package/test/cli.ts +44 -0
|
@@ -237,11 +237,12 @@ function deploymentHistoryClear(command) {
|
|
|
237
237
|
const deploymentList = (command, showPackage = true) => {
|
|
238
238
|
throwForInvalidOutputFormat(command.format);
|
|
239
239
|
let deployments;
|
|
240
|
+
const DEPLOYMENTS_MAX_LENGTH = 10; // do not take metrics if number of deployment higher than this
|
|
240
241
|
return exports.sdk
|
|
241
242
|
.getDeployments(command.appName)
|
|
242
243
|
.then((retrievedDeployments) => {
|
|
243
244
|
deployments = retrievedDeployments;
|
|
244
|
-
if (showPackage) {
|
|
245
|
+
if (showPackage && deployments.length < DEPLOYMENTS_MAX_LENGTH) {
|
|
245
246
|
const metricsPromises = deployments.map((deployment) => {
|
|
246
247
|
if (deployment.package) {
|
|
247
248
|
return exports.sdk.getDeploymentMetrics(command.appName, deployment.name).then((metrics) => {
|
|
@@ -1082,7 +1083,7 @@ const releaseReact = (command) => {
|
|
|
1082
1083
|
// This is needed to clear the react native bundler cache:
|
|
1083
1084
|
// https://github.com/facebook/react-native/issues/4289
|
|
1084
1085
|
.then(() => deleteFolder(`${os.tmpdir()}/react-*`))
|
|
1085
|
-
.then(() => (0, exports.runReactNativeBundleCommand)(bundleName, command.development || false, entryFile, outputFolder, platform, command.sourcemapOutput))
|
|
1086
|
+
.then(() => (0, exports.runReactNativeBundleCommand)(bundleName, command.development || false, entryFile, outputFolder, platform, command.sourcemapOutput, command.extraBundlerOptions))
|
|
1086
1087
|
.then(async () => {
|
|
1087
1088
|
const isHermesEnabled = command.useHermes ||
|
|
1088
1089
|
(platform === "android" && (await (0, react_native_utils_1.getAndroidHermesEnabled)(command.gradleFile))) || // Check if we have to run hermes to compile JS to Byte Code if Hermes is enabled in build.gradle and we're releasing an Android build
|
|
@@ -1148,7 +1149,7 @@ function requestAccessKey() {
|
|
|
1148
1149
|
});
|
|
1149
1150
|
});
|
|
1150
1151
|
}
|
|
1151
|
-
const runReactNativeBundleCommand = (bundleName, development, entryFile, outputFolder, platform, sourcemapOutput) => {
|
|
1152
|
+
const runReactNativeBundleCommand = (bundleName, development, entryFile, outputFolder, platform, sourcemapOutput, extraBundlerOptions) => {
|
|
1152
1153
|
const reactNativeBundleArgs = [];
|
|
1153
1154
|
const envNodeArgs = process.env.CODE_PUSH_NODE_ARGS;
|
|
1154
1155
|
if (typeof envNodeArgs !== "undefined") {
|
|
@@ -1172,6 +1173,9 @@ const runReactNativeBundleCommand = (bundleName, development, entryFile, outputF
|
|
|
1172
1173
|
if (sourcemapOutput) {
|
|
1173
1174
|
reactNativeBundleArgs.push("--sourcemap-output", sourcemapOutput);
|
|
1174
1175
|
}
|
|
1176
|
+
if (extraBundlerOptions.length > 0) {
|
|
1177
|
+
reactNativeBundleArgs.push(...extraBundlerOptions);
|
|
1178
|
+
}
|
|
1175
1179
|
(0, exports.log)(chalk.cyan('Running "react-native bundle" command:\n'));
|
|
1176
1180
|
const reactNativeBundleProcess = (0, exports.spawn)("node", reactNativeBundleArgs);
|
|
1177
1181
|
(0, exports.log)(`node ${reactNativeBundleArgs.join(" ")}`);
|
|
@@ -718,6 +718,13 @@ yargs
|
|
|
718
718
|
demand: false,
|
|
719
719
|
description: "Name of build configuration which specifies the binary version you want to target this release at. For example, 'Debug' or 'Release' (iOS only)",
|
|
720
720
|
type: "string",
|
|
721
|
+
})
|
|
722
|
+
.option("extraBundlerOption", {
|
|
723
|
+
alias: "eo",
|
|
724
|
+
default: [],
|
|
725
|
+
demand: false,
|
|
726
|
+
description: "Option that gets passed to react-native bundler. Can be specified multiple times.",
|
|
727
|
+
type: "array",
|
|
721
728
|
})
|
|
722
729
|
.check((argv, aliases) => {
|
|
723
730
|
return checkValidReleaseOptions(argv);
|
|
@@ -1045,6 +1052,7 @@ function createCommand() {
|
|
|
1045
1052
|
releaseReactCommand.xcodeProjectFile = argv["xcodeProjectFile"];
|
|
1046
1053
|
releaseReactCommand.xcodeTargetName = argv["xcodeTargetName"];
|
|
1047
1054
|
releaseReactCommand.buildConfigurationName = argv["buildConfigurationName"];
|
|
1055
|
+
releaseReactCommand.extraBundlerOptions = argv["extraBundlerOption"];
|
|
1048
1056
|
}
|
|
1049
1057
|
break;
|
|
1050
1058
|
case "rollback":
|
package/bin/test/cli.js
CHANGED
|
@@ -1264,6 +1264,38 @@ describe("CLI", () => {
|
|
|
1264
1264
|
})
|
|
1265
1265
|
.done();
|
|
1266
1266
|
});
|
|
1267
|
+
it("release-react applies extraBundlerOptions to bundler command", (done) => {
|
|
1268
|
+
var bundleName = "bundle.js";
|
|
1269
|
+
var command = {
|
|
1270
|
+
type: cli.CommandType.releaseReact,
|
|
1271
|
+
appName: "a",
|
|
1272
|
+
appStoreVersion: null,
|
|
1273
|
+
bundleName: bundleName,
|
|
1274
|
+
deploymentName: "Staging",
|
|
1275
|
+
description: "Test default entry file",
|
|
1276
|
+
mandatory: false,
|
|
1277
|
+
rollout: null,
|
|
1278
|
+
platform: "ios",
|
|
1279
|
+
extraBundlerOptions: ["--foo=bar", "--baz"],
|
|
1280
|
+
};
|
|
1281
|
+
ensureInTestAppDirectory();
|
|
1282
|
+
var release = sandbox.stub(cmdexec, "release");
|
|
1283
|
+
cmdexec
|
|
1284
|
+
.execute(command)
|
|
1285
|
+
.then(() => {
|
|
1286
|
+
var releaseCommand = command;
|
|
1287
|
+
releaseCommand.package = path.join(os.tmpdir(), "CodePush");
|
|
1288
|
+
releaseCommand.appStoreVersion = "1.2.3";
|
|
1289
|
+
sinon.assert.calledOnce(spawn);
|
|
1290
|
+
var spawnCommand = spawn.args[0][0];
|
|
1291
|
+
var spawnCommandArgs = spawn.args[0][1].join(" ");
|
|
1292
|
+
assert.equal(spawnCommand, "node");
|
|
1293
|
+
assert.equal(spawnCommandArgs, `${path.join("node_modules", "react-native", "local-cli", "cli.js")} bundle --assets-dest ${path.join(os.tmpdir(), "CodePush")} --bundle-output ${path.join(os.tmpdir(), "CodePush", bundleName)} --dev false --entry-file index.ios.js --platform ios --foo=bar --baz`);
|
|
1294
|
+
assertJsonDescribesObject(JSON.stringify(release.args[0][0], /*replacer=*/ null, /*spacing=*/ 2), releaseCommand);
|
|
1295
|
+
done();
|
|
1296
|
+
})
|
|
1297
|
+
.done();
|
|
1298
|
+
});
|
|
1267
1299
|
it("sessionList lists session name and expires fields", (done) => {
|
|
1268
1300
|
var command = {
|
|
1269
1301
|
type: cli.CommandType.sessionList,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revopush/code-push-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Management CLI for the CodePush service",
|
|
5
5
|
"main": "./script/cli.js",
|
|
6
6
|
"scripts": {
|
|
@@ -53,20 +53,22 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/express": "^4.17.17",
|
|
56
|
-
"@types/jest": "^29.5.
|
|
57
|
-
"@types/mocha": "^10.0.
|
|
56
|
+
"@types/jest": "^29.5.14",
|
|
57
|
+
"@types/mocha": "^10.0.10",
|
|
58
58
|
"@types/node": "^20.3.1",
|
|
59
|
-
"@types/q": "^1.5.
|
|
59
|
+
"@types/q": "^1.5.8",
|
|
60
60
|
"@types/sinon": "^10.0.15",
|
|
61
61
|
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
62
62
|
"@typescript-eslint/parser": "^6.0.0",
|
|
63
63
|
"eslint": "^8.45.0",
|
|
64
64
|
"express": "^4.19.2",
|
|
65
65
|
"mkdirp": "^3.0.1",
|
|
66
|
+
"mocha": "^11.1.0",
|
|
66
67
|
"prettier": "^2.8.8",
|
|
67
68
|
"sinon": "15.1.2",
|
|
68
69
|
"superagent-mock": "^4.0.0",
|
|
69
70
|
"typescript": "^5.1.3",
|
|
71
|
+
"ts-node": "^10.9.2",
|
|
70
72
|
"which": "^3.0.1"
|
|
71
73
|
}
|
|
72
74
|
}
|
|
@@ -323,12 +323,13 @@ function deploymentHistoryClear(command: cli.IDeploymentHistoryClearCommand): Pr
|
|
|
323
323
|
export const deploymentList = (command: cli.IDeploymentListCommand, showPackage: boolean = true): Promise<void> => {
|
|
324
324
|
throwForInvalidOutputFormat(command.format);
|
|
325
325
|
let deployments: Deployment[];
|
|
326
|
+
const DEPLOYMENTS_MAX_LENGTH = 10; // do not take metrics if number of deployment higher than this
|
|
326
327
|
|
|
327
328
|
return sdk
|
|
328
329
|
.getDeployments(command.appName)
|
|
329
330
|
.then((retrievedDeployments: Deployment[]) => {
|
|
330
331
|
deployments = retrievedDeployments;
|
|
331
|
-
if (showPackage) {
|
|
332
|
+
if (showPackage && deployments.length < DEPLOYMENTS_MAX_LENGTH) {
|
|
332
333
|
const metricsPromises: Promise<void>[] = deployments.map((deployment: Deployment) => {
|
|
333
334
|
if (deployment.package) {
|
|
334
335
|
return sdk.getDeploymentMetrics(command.appName, deployment.name).then((metrics: DeploymentMetrics): void => {
|
|
@@ -1340,7 +1341,8 @@ export const releaseReact = (command: cli.IReleaseReactCommand): Promise<void> =
|
|
|
1340
1341
|
entryFile,
|
|
1341
1342
|
outputFolder,
|
|
1342
1343
|
platform,
|
|
1343
|
-
command.sourcemapOutput
|
|
1344
|
+
command.sourcemapOutput,
|
|
1345
|
+
command.extraBundlerOptions
|
|
1344
1346
|
)
|
|
1345
1347
|
)
|
|
1346
1348
|
.then(async () => {
|
|
@@ -1431,7 +1433,8 @@ export const runReactNativeBundleCommand = (
|
|
|
1431
1433
|
entryFile: string,
|
|
1432
1434
|
outputFolder: string,
|
|
1433
1435
|
platform: string,
|
|
1434
|
-
sourcemapOutput: string
|
|
1436
|
+
sourcemapOutput: string,
|
|
1437
|
+
extraBundlerOptions: string[]
|
|
1435
1438
|
): Promise<void> => {
|
|
1436
1439
|
const reactNativeBundleArgs: string[] = [];
|
|
1437
1440
|
const envNodeArgs: string = process.env.CODE_PUSH_NODE_ARGS;
|
|
@@ -1461,6 +1464,10 @@ export const runReactNativeBundleCommand = (
|
|
|
1461
1464
|
reactNativeBundleArgs.push("--sourcemap-output", sourcemapOutput);
|
|
1462
1465
|
}
|
|
1463
1466
|
|
|
1467
|
+
if (extraBundlerOptions.length > 0) {
|
|
1468
|
+
reactNativeBundleArgs.push(...extraBundlerOptions);
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1464
1471
|
log(chalk.cyan('Running "react-native bundle" command:\n'));
|
|
1465
1472
|
const reactNativeBundleProcess = spawn("node", reactNativeBundleArgs);
|
|
1466
1473
|
log(`node ${reactNativeBundleArgs.join(" ")}`);
|
package/script/command-parser.ts
CHANGED
|
@@ -840,6 +840,14 @@ yargs
|
|
|
840
840
|
"Name of build configuration which specifies the binary version you want to target this release at. For example, 'Debug' or 'Release' (iOS only)",
|
|
841
841
|
type: "string",
|
|
842
842
|
})
|
|
843
|
+
.option("extraBundlerOption", {
|
|
844
|
+
alias: "eo",
|
|
845
|
+
default: [],
|
|
846
|
+
demand: false,
|
|
847
|
+
description:
|
|
848
|
+
"Option that gets passed to react-native bundler. Can be specified multiple times.",
|
|
849
|
+
type: "array",
|
|
850
|
+
})
|
|
843
851
|
.check((argv: any, aliases: { [aliases: string]: string }): any => {
|
|
844
852
|
return checkValidReleaseOptions(argv);
|
|
845
853
|
});
|
|
@@ -1245,6 +1253,7 @@ export function createCommand(): cli.ICommand {
|
|
|
1245
1253
|
releaseReactCommand.xcodeProjectFile = argv["xcodeProjectFile"] as any;
|
|
1246
1254
|
releaseReactCommand.xcodeTargetName = argv["xcodeTargetName"] as any;
|
|
1247
1255
|
releaseReactCommand.buildConfigurationName = argv["buildConfigurationName"] as any;
|
|
1256
|
+
releaseReactCommand.extraBundlerOptions = argv["extraBundlerOption"] as any;
|
|
1248
1257
|
}
|
|
1249
1258
|
break;
|
|
1250
1259
|
|
package/script/types/cli.ts
CHANGED
|
@@ -206,6 +206,7 @@ export interface IReleaseReactCommand extends IReleaseBaseCommand {
|
|
|
206
206
|
xcodeProjectFile?: string;
|
|
207
207
|
xcodeTargetName?: string;
|
|
208
208
|
buildConfigurationName?: string;
|
|
209
|
+
extraBundlerOptions?: string[];
|
|
209
210
|
}
|
|
210
211
|
|
|
211
212
|
export interface IRollbackCommand extends ICommand {
|
package/test/cli.ts
CHANGED
|
@@ -1595,6 +1595,50 @@ describe("CLI", () => {
|
|
|
1595
1595
|
.done();
|
|
1596
1596
|
});
|
|
1597
1597
|
|
|
1598
|
+
it("release-react applies extraBundlerOptions to bundler command", (done: Mocha.Done): void => {
|
|
1599
|
+
var bundleName = "bundle.js";
|
|
1600
|
+
var command: cli.IReleaseReactCommand = {
|
|
1601
|
+
type: cli.CommandType.releaseReact,
|
|
1602
|
+
appName: "a",
|
|
1603
|
+
appStoreVersion: null,
|
|
1604
|
+
bundleName: bundleName,
|
|
1605
|
+
deploymentName: "Staging",
|
|
1606
|
+
description: "Test default entry file",
|
|
1607
|
+
mandatory: false,
|
|
1608
|
+
rollout: null,
|
|
1609
|
+
platform: "ios",
|
|
1610
|
+
extraBundlerOptions: ["--foo=bar", "--baz"],
|
|
1611
|
+
};
|
|
1612
|
+
|
|
1613
|
+
ensureInTestAppDirectory();
|
|
1614
|
+
|
|
1615
|
+
var release: sinon.SinonSpy = sandbox.stub(cmdexec, "release");
|
|
1616
|
+
|
|
1617
|
+
cmdexec
|
|
1618
|
+
.execute(command)
|
|
1619
|
+
.then(() => {
|
|
1620
|
+
var releaseCommand: cli.IReleaseCommand = <any>command;
|
|
1621
|
+
releaseCommand.package = path.join(os.tmpdir(), "CodePush");
|
|
1622
|
+
releaseCommand.appStoreVersion = "1.2.3";
|
|
1623
|
+
|
|
1624
|
+
sinon.assert.calledOnce(spawn);
|
|
1625
|
+
var spawnCommand: string = spawn.args[0][0];
|
|
1626
|
+
var spawnCommandArgs: string = spawn.args[0][1].join(" ");
|
|
1627
|
+
assert.equal(spawnCommand, "node");
|
|
1628
|
+
assert.equal(
|
|
1629
|
+
spawnCommandArgs,
|
|
1630
|
+
`${path.join("node_modules", "react-native", "local-cli", "cli.js")} bundle --assets-dest ${path.join(
|
|
1631
|
+
os.tmpdir(),
|
|
1632
|
+
"CodePush"
|
|
1633
|
+
)} --bundle-output ${path.join(os.tmpdir(), "CodePush", bundleName)} --dev false --entry-file index.ios.js --platform ios --foo=bar --baz`
|
|
1634
|
+
);
|
|
1635
|
+
assertJsonDescribesObject(JSON.stringify(release.args[0][0], /*replacer=*/ null, /*spacing=*/ 2), releaseCommand);
|
|
1636
|
+
|
|
1637
|
+
done();
|
|
1638
|
+
})
|
|
1639
|
+
.done();
|
|
1640
|
+
});
|
|
1641
|
+
|
|
1598
1642
|
it("sessionList lists session name and expires fields", (done: Mocha.Done): void => {
|
|
1599
1643
|
var command: cli.IAccessKeyListCommand = {
|
|
1600
1644
|
type: cli.CommandType.sessionList,
|