react-native-update-cli 1.45.3 → 1.45.4

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/cli.json CHANGED
@@ -92,6 +92,9 @@
92
92
  },
93
93
  "rollout": {
94
94
  "hasValue": true
95
+ },
96
+ "dryRun": {
97
+ "default": false
95
98
  }
96
99
  }
97
100
  },
package/lib/locales/en.js CHANGED
@@ -112,5 +112,6 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
112
112
  versionDescriptionQuestion: 'Enter version description:',
113
113
  versionMetaInfoQuestion: 'Enter custom meta info:',
114
114
  updateNativePackageQuestion: 'Bind to native package now?(Y/N)',
115
- unnamed: '(Unnamed)'
115
+ unnamed: '(Unnamed)',
116
+ dryRun: 'Below is the dry-run result, no actual operation will be performed:'
116
117
  };
package/lib/locales/zh.js CHANGED
@@ -111,5 +111,6 @@ const _default = {
111
111
  versionDescriptionQuestion: '输入版本描述:',
112
112
  versionMetaInfoQuestion: '输入自定义的 meta info:',
113
113
  updateNativePackageQuestion: '是否现在将此热更应用到原生包上?(Y/N)',
114
- unnamed: '(未命名)'
114
+ unnamed: '(未命名)',
115
+ dryRun: '以下是 dry-run 模拟运行结果,不会实际执行任何操作:'
115
116
  };
package/lib/versions.js CHANGED
@@ -24,6 +24,12 @@ const _package = require("./package");
24
24
  const _depversions = require("./utils/dep-versions");
25
25
  const _git = require("./utils/git");
26
26
  const _compareversions = require("compare-versions");
27
+ const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk"));
28
+ function _interop_require_default(obj) {
29
+ return obj && obj.__esModule ? obj : {
30
+ default: obj
31
+ };
32
+ }
27
33
  async function showVersion(appId, offset) {
28
34
  const { data, count } = await (0, _api.get)(`/app/${appId}/version/list`);
29
35
  console.log((0, _i18n.t)('offset', {
@@ -94,26 +100,33 @@ async function chooseVersion(appId) {
94
100
  }
95
101
  }
96
102
  }
97
- const bindVersionToPackages = async ({ appId, versionId, pkgs, rollout })=>{
103
+ const bindVersionToPackages = async ({ appId, versionId, pkgs, rollout, dryRun })=>{
104
+ if (dryRun) {
105
+ console.log(_chalk.default.yellow((0, _i18n.t)('dryRun')));
106
+ }
98
107
  if (rollout !== undefined) {
99
108
  const rolloutConfig = {};
100
109
  for (const pkg of pkgs){
101
110
  rolloutConfig[pkg.name] = rollout;
102
111
  }
103
- await (0, _api.put)(`/app/${appId}/version/${versionId}`, {
104
- config: {
105
- rollout: rolloutConfig
106
- }
107
- });
112
+ if (!dryRun) {
113
+ await (0, _api.put)(`/app/${appId}/version/${versionId}`, {
114
+ config: {
115
+ rollout: rolloutConfig
116
+ }
117
+ });
118
+ }
108
119
  console.log(`${(0, _i18n.t)('rolloutConfigSet', {
109
120
  versions: pkgs.map((pkg)=>pkg.name).join(', '),
110
121
  rollout: rollout
111
122
  })}`);
112
123
  }
113
124
  for (const pkg of pkgs){
114
- await (0, _api.put)(`/app/${appId}/package/${pkg.id}`, {
115
- versionId
116
- });
125
+ if (!dryRun) {
126
+ await (0, _api.put)(`/app/${appId}/package/${pkg.id}`, {
127
+ versionId
128
+ });
129
+ }
117
130
  console.log(`${(0, _i18n.t)('versionBind', {
118
131
  version: versionId,
119
132
  nativeVersion: pkg.name,
@@ -253,7 +266,8 @@ const commands = {
253
266
  appId,
254
267
  versionId,
255
268
  pkgs: pkgsToBind,
256
- rollout
269
+ rollout,
270
+ dryRun: options.dryRun
257
271
  });
258
272
  console.log((0, _i18n.t)('operationSuccess'));
259
273
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "1.45.3",
3
+ "version": "1.45.4",
4
4
  "description": "command line tool for react-native-update (remote updates for react native)",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/locales/en.ts CHANGED
@@ -129,4 +129,5 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
129
129
  versionMetaInfoQuestion: 'Enter custom meta info:',
130
130
  updateNativePackageQuestion: 'Bind to native package now?(Y/N)',
131
131
  unnamed: '(Unnamed)',
132
+ dryRun: 'Below is the dry-run result, no actual operation will be performed:',
132
133
  };
package/src/locales/zh.ts CHANGED
@@ -122,4 +122,5 @@ export default {
122
122
  versionMetaInfoQuestion: '输入自定义的 meta info:',
123
123
  updateNativePackageQuestion: '是否现在将此热更应用到原生包上?(Y/N)',
124
124
  unnamed: '(未命名)',
125
+ dryRun: '以下是 dry-run 模拟运行结果,不会实际执行任何操作:',
125
126
  };
package/src/versions.ts CHANGED
@@ -8,6 +8,7 @@ import { depVersions } from './utils/dep-versions';
8
8
  import { getCommitInfo } from './utils/git';
9
9
  import type { Package, Platform, Version } from 'types';
10
10
  import { satisfies } from 'compare-versions';
11
+ import chalk from 'chalk';
11
12
 
12
13
  interface CommandOptions {
13
14
  name?: string;
@@ -21,6 +22,7 @@ interface CommandOptions {
21
22
  maxPackageVersion?: string;
22
23
  packageVersionRange?: string;
23
24
  rollout?: string;
25
+ dryRun?: boolean;
24
26
  }
25
27
 
26
28
  async function showVersion(appId: string, offset: number) {
@@ -107,22 +109,29 @@ export const bindVersionToPackages = async ({
107
109
  versionId,
108
110
  pkgs,
109
111
  rollout,
112
+ dryRun,
110
113
  }: {
111
114
  appId: string;
112
115
  versionId: string;
113
116
  pkgs: Package[];
114
117
  rollout?: number;
118
+ dryRun?: boolean;
115
119
  }) => {
120
+ if (dryRun) {
121
+ console.log(chalk.yellow(t('dryRun')));
122
+ }
116
123
  if (rollout !== undefined) {
117
124
  const rolloutConfig: Record<string, number> = {};
118
125
  for (const pkg of pkgs) {
119
126
  rolloutConfig[pkg.name] = rollout;
120
127
  }
121
- await put(`/app/${appId}/version/${versionId}`, {
122
- config: {
123
- rollout: rolloutConfig,
124
- },
125
- });
128
+ if (!dryRun) {
129
+ await put(`/app/${appId}/version/${versionId}`, {
130
+ config: {
131
+ rollout: rolloutConfig,
132
+ },
133
+ });
134
+ }
126
135
  console.log(
127
136
  `${t('rolloutConfigSet', {
128
137
  versions: pkgs.map((pkg: Package) => pkg.name).join(', '),
@@ -131,9 +140,11 @@ export const bindVersionToPackages = async ({
131
140
  );
132
141
  }
133
142
  for (const pkg of pkgs) {
134
- await put(`/app/${appId}/package/${pkg.id}`, {
135
- versionId,
136
- });
143
+ if (!dryRun) {
144
+ await put(`/app/${appId}/package/${pkg.id}`, {
145
+ versionId,
146
+ });
147
+ }
137
148
  console.log(
138
149
  `${t('versionBind', {
139
150
  version: versionId,
@@ -294,6 +305,7 @@ export const commands = {
294
305
  versionId,
295
306
  pkgs: pkgsToBind,
296
307
  rollout,
308
+ dryRun: options.dryRun,
297
309
  });
298
310
  console.log(t('operationSuccess'));
299
311
  },