rn-update-cli 1.0.0

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.
Files changed (117) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +167 -0
  3. package/README.zh-CN.md +167 -0
  4. package/cli.json +525 -0
  5. package/lib/api.d.ts +56 -0
  6. package/lib/api.js +671 -0
  7. package/lib/app.d.ts +107 -0
  8. package/lib/app.js +329 -0
  9. package/lib/auto-update.d.ts +35 -0
  10. package/lib/auto-update.js +507 -0
  11. package/lib/bin.d.ts +2 -0
  12. package/lib/bin.js +133 -0
  13. package/lib/bundle-pack.d.ts +6 -0
  14. package/lib/bundle-pack.js +91 -0
  15. package/lib/bundle-runner.d.ts +168 -0
  16. package/lib/bundle-runner.js +1305 -0
  17. package/lib/bundle.d.ts +45 -0
  18. package/lib/bundle.js +226 -0
  19. package/lib/cache.d.ts +10 -0
  20. package/lib/cache.js +25 -0
  21. package/lib/commands.d.ts +11 -0
  22. package/lib/commands.js +72 -0
  23. package/lib/diff.d.ts +18 -0
  24. package/lib/diff.js +690 -0
  25. package/lib/exports.d.ts +11 -0
  26. package/lib/exports.js +20 -0
  27. package/lib/install.d.ts +9 -0
  28. package/lib/install.js +51 -0
  29. package/lib/locales/en.d.ts +187 -0
  30. package/lib/locales/en.js +194 -0
  31. package/lib/locales/zh.d.ts +187 -0
  32. package/lib/locales/zh.js +194 -0
  33. package/lib/native-package.d.ts +21 -0
  34. package/lib/native-package.js +298 -0
  35. package/lib/package.d.ts +68 -0
  36. package/lib/package.js +487 -0
  37. package/lib/provider.d.ts +24 -0
  38. package/lib/provider.js +244 -0
  39. package/lib/standalone-publish.d.ts +17 -0
  40. package/lib/standalone-publish.js +433 -0
  41. package/lib/symbolicate.d.ts +35 -0
  42. package/lib/symbolicate.js +130 -0
  43. package/lib/types.d.ts +152 -0
  44. package/lib/types.js +2 -0
  45. package/lib/user.d.ts +8 -0
  46. package/lib/user.js +50 -0
  47. package/lib/utils/add-gitignore.d.ts +6 -0
  48. package/lib/utils/add-gitignore.js +44 -0
  49. package/lib/utils/app-info-parser/aab.d.ts +27 -0
  50. package/lib/utils/app-info-parser/aab.js +256 -0
  51. package/lib/utils/app-info-parser/apk.d.ts +19 -0
  52. package/lib/utils/app-info-parser/apk.js +95 -0
  53. package/lib/utils/app-info-parser/app.d.ts +9 -0
  54. package/lib/utils/app-info-parser/app.js +15 -0
  55. package/lib/utils/app-info-parser/index.d.ts +21 -0
  56. package/lib/utils/app-info-parser/index.js +51 -0
  57. package/lib/utils/app-info-parser/ipa.d.ts +19 -0
  58. package/lib/utils/app-info-parser/ipa.js +101 -0
  59. package/lib/utils/app-info-parser/resource-finder.d.ts +49 -0
  60. package/lib/utils/app-info-parser/resource-finder.js +429 -0
  61. package/lib/utils/app-info-parser/utils.d.ts +36 -0
  62. package/lib/utils/app-info-parser/utils.js +140 -0
  63. package/lib/utils/app-info-parser/xml-parser/binary.d.ts +61 -0
  64. package/lib/utils/app-info-parser/xml-parser/binary.js +577 -0
  65. package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +15 -0
  66. package/lib/utils/app-info-parser/xml-parser/manifest.js +207 -0
  67. package/lib/utils/app-info-parser/zip.d.ts +29 -0
  68. package/lib/utils/app-info-parser/zip.js +97 -0
  69. package/lib/utils/check-lockfile.d.ts +6 -0
  70. package/lib/utils/check-lockfile.js +93 -0
  71. package/lib/utils/check-plugin.d.ts +12 -0
  72. package/lib/utils/check-plugin.js +36 -0
  73. package/lib/utils/command-result.d.ts +8 -0
  74. package/lib/utils/command-result.js +27 -0
  75. package/lib/utils/constants.d.ts +10 -0
  76. package/lib/utils/constants.js +39 -0
  77. package/lib/utils/dep-versions.d.ts +20 -0
  78. package/lib/utils/dep-versions.js +129 -0
  79. package/lib/utils/git.d.ts +14 -0
  80. package/lib/utils/git.js +64 -0
  81. package/lib/utils/hbcTransform.d.ts +111 -0
  82. package/lib/utils/hbcTransform.js +561 -0
  83. package/lib/utils/hermes-base.d.ts +227 -0
  84. package/lib/utils/hermes-base.js +1287 -0
  85. package/lib/utils/hermes-literals.d.ts +64 -0
  86. package/lib/utils/hermes-literals.js +260 -0
  87. package/lib/utils/http-helper.d.ts +10 -0
  88. package/lib/utils/http-helper.js +150 -0
  89. package/lib/utils/i18n.d.ts +22 -0
  90. package/lib/utils/i18n.js +46 -0
  91. package/lib/utils/index.d.ts +67 -0
  92. package/lib/utils/index.js +545 -0
  93. package/lib/utils/latest-version/index.d.ts +154 -0
  94. package/lib/utils/latest-version/index.js +331 -0
  95. package/lib/utils/options.d.ts +10 -0
  96. package/lib/utils/options.js +68 -0
  97. package/lib/utils/plugin-config.d.ts +14 -0
  98. package/lib/utils/plugin-config.js +66 -0
  99. package/lib/utils/runtime.d.ts +54 -0
  100. package/lib/utils/runtime.js +263 -0
  101. package/lib/utils/slim-sourcemap.d.ts +28 -0
  102. package/lib/utils/slim-sourcemap.js +106 -0
  103. package/lib/utils/zip-entries.d.ts +10 -0
  104. package/lib/utils/zip-entries.js +211 -0
  105. package/lib/utils/zip-options.d.ts +17 -0
  106. package/lib/utils/zip-options.js +190 -0
  107. package/lib/utils/zip-range.d.ts +148 -0
  108. package/lib/utils/zip-range.js +581 -0
  109. package/lib/utils/zip-raw-writer.d.ts +52 -0
  110. package/lib/utils/zip-raw-writer.js +209 -0
  111. package/lib/version-operations.d.ts +21 -0
  112. package/lib/version-operations.js +320 -0
  113. package/lib/versions.d.ts +66 -0
  114. package/lib/versions.js +402 -0
  115. package/package.json +113 -0
  116. package/proto/Configuration.proto +183 -0
  117. package/proto/Resources.proto +569 -0
@@ -0,0 +1,402 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.versionCommands = exports.describePpkBundleForTests = exports.normalizeDeps = exports.fetchVersions = exports.bindVersionToPackages = void 0;
7
+ /**
8
+ * [INPUT]: 依赖 Hermes bundle 摘要、对象上传、渠道版本组 API 与旧绑定 API
9
+ * [OUTPUT]: 对外提供 full 发布、批量渠道组投放、逐构建 pdiff 登记、版本查询和兼容绑定命令,并上报 Hermes 校验结果
10
+ * [POS]: CLI 发布编排层,独立服务按 (channel, packageVersion) 原子生成草稿并发布,pdiff 始终绑定精确 nativeVersion
11
+ */
12
+ const chalk_1 = __importDefault(require("chalk"));
13
+ const compare_versions_1 = require("compare-versions");
14
+ const fs_1 = __importDefault(require("fs"));
15
+ const os_1 = __importDefault(require("os"));
16
+ const path_1 = __importDefault(require("path"));
17
+ const api_1 = require("./api");
18
+ const app_1 = require("./app");
19
+ const package_1 = require("./package");
20
+ const standalone_publish_1 = require("./standalone-publish");
21
+ const utils_1 = require("./utils");
22
+ const dep_versions_1 = require("./utils/dep-versions");
23
+ const git_1 = require("./utils/git");
24
+ const hbcTransform_1 = require("./utils/hbcTransform");
25
+ const hermes_base_1 = require("./utils/hermes-base");
26
+ const http_helper_1 = require("./utils/http-helper");
27
+ const i18n_1 = require("./utils/i18n");
28
+ const options_1 = require("./utils/options");
29
+ const slim_sourcemap_1 = require("./utils/slim-sourcemap");
30
+ const zip_range_1 = require("./utils/zip-range");
31
+ const version_operations_1 = require("./version-operations");
32
+ var version_operations_2 = require("./version-operations");
33
+ Object.defineProperty(exports, "bindVersionToPackages", { enumerable: true, get: function () { return version_operations_2.bindVersionToPackages; } });
34
+ Object.defineProperty(exports, "fetchVersions", { enumerable: true, get: function () { return version_operations_2.fetchVersions; } });
35
+ Object.defineProperty(exports, "normalizeDeps", { enumerable: true, get: function () { return version_operations_2.normalizeDeps; } });
36
+ /**
37
+ * Content identity of the ppk's bundle for the server (bundleHash, HBC version)
38
+ * plus the base used to compile it, and a copy of the bundle in the local
39
+ * cache so it can serve as a future base without a download.
40
+ */
41
+ async function describePpkBundle(ppkPath, base) {
42
+ // Only known values are sent: the server's optional-field parsers treat an
43
+ // explicit JSON null as invalid (that contract broke 2.22.0/2.22.1 publishes
44
+ // with "Expected baseHash string"), and omitting a field is what every
45
+ // server version — strict, tolerant or too old to know the field — accepts.
46
+ const meta = {};
47
+ try {
48
+ // one pass over the ppk: the bundle itself plus where its compressed
49
+ // bytes live, so the next build can fetch just them with one HTTP Range
50
+ // request
51
+ const found = ppkPath.toLowerCase().endsWith('.ppk')
52
+ ? await (0, zip_range_1.readZipEntryWithLocation)(ppkPath, (name) => hermes_base_1.BUNDLE_ENTRY_NAMES.includes(name)).catch(() => null)
53
+ : null;
54
+ const bundle = found?.data ?? (await (0, hermes_base_1.extractBundleFromArchive)(ppkPath));
55
+ if (bundle) {
56
+ const bundleHash = (0, hermes_base_1.sha256Hex)(bundle);
57
+ meta.bundleHash = bundleHash;
58
+ const hbcVersion = (0, hbcTransform_1.getHbcVersion)(bundle) ?? base?.bytecodeVersion;
59
+ if (hbcVersion != null)
60
+ meta.bytecodeVersion = hbcVersion;
61
+ await (0, hermes_base_1.cachePut)(bundle, undefined, bundleHash).catch(() => { });
62
+ Object.assign(meta, (0, zip_range_1.bundleLocationFields)(found?.location));
63
+ }
64
+ }
65
+ catch {
66
+ // best effort: metadata never blocks a publish
67
+ }
68
+ if (base?.baseVersionId != null)
69
+ meta.baseVersionId = base.baseVersionId;
70
+ if (base?.baseHash)
71
+ meta.baseHash = base.baseHash;
72
+ if (base?.hermesBaseOutcome)
73
+ meta.hermesBaseOutcome = base.hermesBaseOutcome;
74
+ if (base?.hermesBaseDetail) {
75
+ meta.hermesBaseDetail = (0, hermes_base_1.truncateHermesBaseDetail)(base.hermesBaseDetail);
76
+ }
77
+ return meta;
78
+ }
79
+ /** Exported for tests: the version/create fields derived from a ppk + base. */
80
+ exports.describePpkBundleForTests = describePpkBundle;
81
+ exports.versionCommands = {
82
+ registerPdiff: async ({ args, options }) => {
83
+ return (0, standalone_publish_1.registerStandalonePdiff)(args[0] || '', options);
84
+ },
85
+ publish: async ({ args, options, }) => {
86
+ if ((0, http_helper_1.isStandaloneService)() && (options.deploymentIds || options.releaseIds)) {
87
+ const appId = await (0, app_1.resolveAppId)(options);
88
+ return (0, standalone_publish_1.retryStandalonePublish)(appId, String(options.deploymentIds || options.releaseIds), options.dryRun);
89
+ }
90
+ const fn = args[0];
91
+ const { name, description, metaInfo, diffFromHash, channel } = options;
92
+ if (!fn?.endsWith('.ppk')) {
93
+ throw new Error((0, i18n_1.t)('publishUsage'));
94
+ }
95
+ if ((0, http_helper_1.isStandaloneService)()) {
96
+ // The Go service resolves the application directly from --appId. A
97
+ // platform prompt is only needed by the legacy numeric service; keeping
98
+ // it out of this branch makes CI publish/dry-run usable with targets.json
99
+ // and an explicit app id.
100
+ const appId = await (0, app_1.resolveAppId)(options);
101
+ return (0, standalone_publish_1.publishStandalone)(fn, appId, options);
102
+ }
103
+ const platform = await (0, app_1.getPlatform)(options.platform);
104
+ const appId = await (0, app_1.resolveAppId)({ ...options, platform });
105
+ const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
106
+ // The source map is archived with the version so `pakta symbolicate` can
107
+ // map crashes back to source. An explicit path that does not exist is a
108
+ // publish error; no path at all is a loud warning (custom pipelines that
109
+ // never produced a map keep working).
110
+ const sourcemapPath = typeof options.sourcemap === 'string' && options.sourcemap
111
+ ? options.sourcemap
112
+ : undefined;
113
+ if (sourcemapPath && !fs_1.default.existsSync(sourcemapPath)) {
114
+ throw new Error((0, i18n_1.t)('sourceMapNotFound', { path: sourcemapPath }));
115
+ }
116
+ if (!sourcemapPath) {
117
+ console.log(chalk_1.default.yellow((0, i18n_1.t)('sourceMapMissingWarning')));
118
+ }
119
+ // Archive a slimmed, gzipped copy (see packSourceMap): relative paths, no
120
+ // dependency sourcesContent, ~5x smaller on the wire. Frames keep
121
+ // symbolicating everywhere; only inline snippets of node_modules code are
122
+ // dropped. The temp file keeps the .map extension because /upload routes
123
+ // by extension; readers detect gzip by magic bytes.
124
+ let uploadSourcemapPath = sourcemapPath;
125
+ let packTempDir;
126
+ if (sourcemapPath) {
127
+ packTempDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'rnu-sourcemap-'));
128
+ uploadSourcemapPath = path_1.default.join(packTempDir, path_1.default.basename(sourcemapPath));
129
+ fs_1.default.writeFileSync(uploadSourcemapPath, (0, slim_sourcemap_1.packSourceMap)(fs_1.default.readFileSync(sourcemapPath, 'utf8'), process.cwd()));
130
+ }
131
+ // Hashing/caching the bundle and asking git for the commit are independent
132
+ // of the upload, so they overlap with it instead of running afterwards.
133
+ // describePpkBundle never rejects (best effort); a failed upload still
134
+ // fails the publish exactly as before.
135
+ // A server that predates source-map archiving (self-hosted, or a SaaS
136
+ // region not yet rolled) rejects the .map upload with 400; that must not
137
+ // fail the publish, only lose the archive.
138
+ let sourceMapUploadError;
139
+ const [{ hash }, bundleMeta, commit, sourceMapUpload] = await Promise.all([
140
+ (0, api_1.uploadFile)(fn, undefined, appId),
141
+ describePpkBundle(fn, options.hermesBase),
142
+ (0, git_1.getCommitInfo)(),
143
+ uploadSourcemapPath
144
+ ? (0, api_1.uploadFile)(uploadSourcemapPath, undefined, appId).catch((error) => {
145
+ sourceMapUploadError = error;
146
+ return undefined;
147
+ })
148
+ : Promise.resolve(undefined),
149
+ ]).finally(() => {
150
+ // the packed copy only exists for the upload; a failed ppk upload must
151
+ // not leave it behind in the OS temp dir
152
+ if (packTempDir) {
153
+ fs_1.default.rmSync(packTempDir, { recursive: true, force: true });
154
+ }
155
+ });
156
+ const sourceMapKey = sourceMapUpload?.hash;
157
+ if (sourcemapPath && !sourceMapKey) {
158
+ console.log(chalk_1.default.yellow((0, i18n_1.t)('sourceMapUploadFailedWarning', {
159
+ error: sourceMapUploadError instanceof Error
160
+ ? sourceMapUploadError.message
161
+ : String(sourceMapUploadError),
162
+ })));
163
+ }
164
+ const depVersions = (0, dep_versions_1.getDepVersions)();
165
+ const versionName = name ||
166
+ (nonInteractive ? '' : await (0, utils_1.question)((0, i18n_1.t)('versionNameQuestion'))) ||
167
+ (0, i18n_1.t)('unnamed');
168
+ const { id } = await (0, api_1.post)(`/app/${appId}/version/create`, {
169
+ name: versionName,
170
+ hash,
171
+ description: description ??
172
+ (nonInteractive ? '' : await (0, utils_1.question)((0, i18n_1.t)('versionDescriptionQuestion'))),
173
+ metaInfo: metaInfo ??
174
+ (nonInteractive ? '' : await (0, utils_1.question)((0, i18n_1.t)('versionMetaInfoQuestion'))),
175
+ ...(diffFromHash ? { diffFromHash } : {}),
176
+ deps: depVersions,
177
+ commit,
178
+ ...(channel ? { channel } : {}),
179
+ // Hermes delta-mode chain metadata (old servers drop unknown fields)
180
+ ...bundleMeta,
181
+ // archived source map (old servers drop unknown fields)
182
+ ...(sourceMapKey ? { sourceMapKey } : {}),
183
+ });
184
+ console.log((0, i18n_1.t)('packageUploadSuccess', { id }));
185
+ if (sourceMapKey) {
186
+ console.log((0, i18n_1.t)('sourceMapArchived', { id }));
187
+ }
188
+ const { packageId, packageVersion, packageVersionRange, minPackageVersion, maxPackageVersion, rollout, dryRun, } = options;
189
+ if (packageId ||
190
+ packageVersion ||
191
+ packageVersionRange ||
192
+ minPackageVersion ||
193
+ maxPackageVersion) {
194
+ await exports.versionCommands.update({
195
+ options: {
196
+ versionId: id,
197
+ platform,
198
+ appId,
199
+ packageId,
200
+ packageVersion,
201
+ packageVersionRange,
202
+ minPackageVersion,
203
+ maxPackageVersion,
204
+ rollout,
205
+ channel,
206
+ dryRun,
207
+ versionDeps: depVersions,
208
+ warnDepsChanges: true,
209
+ },
210
+ });
211
+ }
212
+ else if (!nonInteractive) {
213
+ const q = await (0, utils_1.question)((0, i18n_1.t)('updateNativePackageQuestion'));
214
+ if (q.toLowerCase() === 'y') {
215
+ await exports.versionCommands.update({
216
+ options: {
217
+ versionId: id,
218
+ platform,
219
+ appId,
220
+ versionDeps: depVersions,
221
+ warnDepsChanges: true,
222
+ },
223
+ });
224
+ }
225
+ }
226
+ return versionName;
227
+ },
228
+ versions: async ({ options }) => {
229
+ const appId = await (0, app_1.resolveAppId)(options);
230
+ const interactive = !((0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)());
231
+ await (0, version_operations_1.listVersions)(appId, interactive);
232
+ },
233
+ update: async ({ options }) => {
234
+ const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
235
+ const appId = await (0, app_1.resolveAppId)(options);
236
+ let versionId = options.versionId;
237
+ if (!versionId) {
238
+ if (nonInteractive) {
239
+ throw new Error((0, i18n_1.t)('versionIdRequired'));
240
+ }
241
+ versionId = String((await (0, version_operations_1.chooseVersion)(appId)).id);
242
+ }
243
+ if (versionId === 'null') {
244
+ versionId = null;
245
+ }
246
+ let pkgId = options.packageId;
247
+ let pkgVersion = options.packageVersion;
248
+ let minPkgVersion = options.minPackageVersion;
249
+ let maxPkgVersion = options.maxPackageVersion;
250
+ let packageVersionRange = options.packageVersionRange;
251
+ let rollout;
252
+ if (options.rollout !== undefined) {
253
+ rollout = Number.parseInt(String(options.rollout), 10);
254
+ if (Number.isNaN(rollout) || rollout < 1 || rollout > 100) {
255
+ throw new Error((0, i18n_1.t)('rolloutRangeError'));
256
+ }
257
+ }
258
+ const allPkgs = await (0, api_1.getAllPackages)(appId);
259
+ if (!allPkgs) {
260
+ throw new Error((0, i18n_1.t)('noPackagesFound', { appId }));
261
+ }
262
+ const pkgMap = new Map(allPkgs.map((pkg) => [String(pkg.id), pkg]));
263
+ let pkgsToBind = [];
264
+ const selectorGroups = [
265
+ pkgId,
266
+ pkgVersion,
267
+ packageVersionRange,
268
+ minPkgVersion || maxPkgVersion,
269
+ ].filter(Boolean);
270
+ if (selectorGroups.length > 1) {
271
+ throw new Error((0, i18n_1.t)('conflictingPackageSelectors'));
272
+ }
273
+ if (minPkgVersion || maxPkgVersion) {
274
+ minPkgVersion = minPkgVersion && String(minPkgVersion).trim();
275
+ maxPkgVersion = maxPkgVersion && String(maxPkgVersion).trim();
276
+ pkgsToBind = allPkgs.filter((pkg) => {
277
+ const aboveMin = !minPkgVersion || (0, compare_versions_1.compare)(pkg.name, minPkgVersion, '>=');
278
+ const belowMax = !maxPkgVersion || (0, compare_versions_1.compare)(pkg.name, maxPkgVersion, '<=');
279
+ return aboveMin && belowMax;
280
+ });
281
+ if (pkgsToBind.length === 0) {
282
+ if (minPkgVersion && maxPkgVersion) {
283
+ throw new Error((0, i18n_1.t)('nativeVersionNotFoundBetween', {
284
+ min: minPkgVersion,
285
+ max: maxPkgVersion,
286
+ }));
287
+ }
288
+ if (minPkgVersion) {
289
+ throw new Error((0, i18n_1.t)('nativeVersionNotFoundGte', { version: minPkgVersion }));
290
+ }
291
+ throw new Error((0, i18n_1.t)('nativeVersionNotFoundLte', { version: maxPkgVersion }));
292
+ }
293
+ }
294
+ else if (pkgVersion) {
295
+ pkgVersion = pkgVersion.trim();
296
+ const pkg = allPkgs.find((pkg) => pkg.name === pkgVersion);
297
+ if (pkg) {
298
+ pkgsToBind = [pkg];
299
+ }
300
+ else {
301
+ throw new Error((0, i18n_1.t)('nativeVersionNotFoundMatch', { version: pkgVersion }));
302
+ }
303
+ }
304
+ else if (packageVersionRange) {
305
+ packageVersionRange = packageVersionRange.trim();
306
+ pkgsToBind = allPkgs.filter((pkg) => (0, compare_versions_1.satisfies)(pkg.name, packageVersionRange));
307
+ if (pkgsToBind.length === 0) {
308
+ throw new Error((0, i18n_1.t)('nativeVersionNotFoundMatch', { version: packageVersionRange }));
309
+ }
310
+ }
311
+ else {
312
+ if (!pkgId) {
313
+ if (nonInteractive) {
314
+ throw new Error((0, i18n_1.t)('packageIdRequired'));
315
+ }
316
+ // the package list was already fetched above: no second round trip
317
+ pkgId = String((await (0, package_1.choosePackage)(appId, allPkgs)).id);
318
+ }
319
+ if (!pkgId) {
320
+ throw new Error((0, i18n_1.t)('packageIdRequired'));
321
+ }
322
+ const pkg = pkgMap.get(String(pkgId));
323
+ if (pkg) {
324
+ pkgsToBind = [pkg];
325
+ }
326
+ else {
327
+ throw new Error((0, i18n_1.t)('nativePackageIdNotFound', { id: pkgId }));
328
+ }
329
+ }
330
+ if (options.warnDepsChanges && versionId) {
331
+ await (0, version_operations_1.printDepsChangesForPublish)({
332
+ appId,
333
+ versionId: String(versionId),
334
+ pkgs: pkgsToBind,
335
+ providedVersionDeps: options.versionDeps,
336
+ });
337
+ }
338
+ await (0, version_operations_1.bindVersionToPackages)({
339
+ appId,
340
+ // keep null as-is: `--versionId null` means unbinding the version
341
+ versionId: versionId ?? null,
342
+ pkgs: pkgsToBind,
343
+ rollout,
344
+ dryRun: options.dryRun,
345
+ });
346
+ },
347
+ updateVersionInfo: async ({ options, }) => {
348
+ const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
349
+ const appId = await (0, app_1.resolveAppId)(options);
350
+ let versionId = options.versionId;
351
+ if (!versionId) {
352
+ if (nonInteractive) {
353
+ throw new Error((0, i18n_1.t)('versionIdRequired'));
354
+ }
355
+ versionId = String((await (0, version_operations_1.chooseVersion)(appId)).id);
356
+ }
357
+ const updateParams = {};
358
+ if (options.name)
359
+ updateParams.name = options.name;
360
+ if (options.description)
361
+ updateParams.description = options.description;
362
+ if (options.metaInfo)
363
+ updateParams.metaInfo = options.metaInfo;
364
+ await (0, api_1.put)(`/app/${appId}/version/${versionId}`, updateParams);
365
+ console.log((0, i18n_1.t)('operationSuccess'));
366
+ },
367
+ deleteVersion: async ({ options }) => {
368
+ const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
369
+ const appId = await (0, app_1.resolveAppId)(options);
370
+ const parsedVersionIds = (0, options_1.getStringListOption)(options, 'versionIds') ??
371
+ (0, options_1.getStringListOption)(options, 'versionId');
372
+ let versionIds = parsedVersionIds;
373
+ if (!versionIds) {
374
+ if (nonInteractive) {
375
+ throw new Error((0, i18n_1.t)('versionIdRequired'));
376
+ }
377
+ versionIds = [String((await (0, version_operations_1.chooseVersion)(appId)).id)];
378
+ }
379
+ try {
380
+ if (versionIds.length === 1) {
381
+ const [versionId] = versionIds;
382
+ await (0, api_1.doDelete)(`/app/${appId}/version/${versionId}`);
383
+ console.log((0, i18n_1.t)('deleteVersionSuccess', { versionId }));
384
+ }
385
+ else {
386
+ await (0, api_1.doDelete)(`/app/${appId}/version`, {
387
+ versionIds: (0, version_operations_1.toNumericIds)(versionIds),
388
+ });
389
+ console.log((0, i18n_1.t)('deleteVersionsSuccess', {
390
+ count: versionIds.length,
391
+ versionIds: versionIds.join(', '),
392
+ }));
393
+ }
394
+ }
395
+ catch (error) {
396
+ throw new Error((0, i18n_1.t)('deleteVersionError', {
397
+ versionId: versionIds.join(', '),
398
+ error: error.message,
399
+ }));
400
+ }
401
+ },
402
+ };
package/package.json ADDED
@@ -0,0 +1,113 @@
1
+ {
2
+ "name": "rn-update-cli",
3
+ "version": "1.0.0",
4
+ "description": "command line tool for rn-update (remote updates for react native)",
5
+ "main": "lib/exports.js",
6
+ "types": "lib/exports.d.ts",
7
+ "bin": {
8
+ "pakta": "lib/bin.js"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "types": "./lib/exports.d.ts",
13
+ "require": "./lib/exports.js",
14
+ "default": "./lib/exports.js"
15
+ },
16
+ "./diff": {
17
+ "types": "./lib/diff.d.ts",
18
+ "require": "./lib/diff.js",
19
+ "default": "./lib/diff.js"
20
+ },
21
+ "./lib/diff": {
22
+ "types": "./lib/diff.d.ts",
23
+ "require": "./lib/diff.js",
24
+ "default": "./lib/diff.js"
25
+ }
26
+ },
27
+ "files": [
28
+ "lib",
29
+ "proto",
30
+ "cli.json",
31
+ "LICENSE"
32
+ ],
33
+ "scripts": {
34
+ "build": "node scripts/build.js",
35
+ "prepublishOnly": "bun run build",
36
+ "typecheck": "tsc --noEmit",
37
+ "typecheck:build": "tsc -p tsconfig.build.json",
38
+ "lint": "bun run typecheck && biome check .",
39
+ "lint:fix": "bun run typecheck && biome check --write .",
40
+ "test": "bun test",
41
+ "smoke": "node scripts/smoke-lib.js",
42
+ "test:coverage": "bun test --coverage --coverage-reporter=text --coverage-reporter=lcov",
43
+ "benchmark:diff-stream": "bun scripts/benchmark-diff-stream.ts",
44
+ "fuzz:hermes-base": "bun scripts/fuzz-hermes-base.ts"
45
+ },
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/pakta-team/rn-update-cli.git"
49
+ },
50
+ "keywords": [
51
+ "react-native",
52
+ "ios",
53
+ "android",
54
+ "harmony",
55
+ "update"
56
+ ],
57
+ "author": "Yoghourt Technology(BeiJing) Company Limited",
58
+ "license": "MIT",
59
+ "bugs": {
60
+ "url": "https://github.com/pakta-team/rn-update-cli/issues"
61
+ },
62
+ "homepage": "https://pakta.site",
63
+ "dependencies": {
64
+ "bplist-parser": "^0.3.2",
65
+ "bytebuffer": "^5.0.1",
66
+ "cgbi-to-png": "^1.0.7",
67
+ "chalk": "4",
68
+ "cli-arguments": "^0.2.1",
69
+ "compare-versions": "^6.1.1",
70
+ "filesize-parser": "^1.5.2",
71
+ "form-data": "^4.0.6",
72
+ "fs-extra": "^11.4.0",
73
+ "global-dirs": "^4.0.0",
74
+ "gradle-to-js": "^2.0.1",
75
+ "https-proxy-agent": "^7.0.6",
76
+ "i18next": "^26.4.0",
77
+ "node-fetch": "^2.6.1",
78
+ "plist": "^5.0.0",
79
+ "progress": "^2.0.3",
80
+ "properties": "^1.2.1",
81
+ "protobufjs": "^8.7.2",
82
+ "read": "^4.1.0",
83
+ "registry-auth-token": "^5.1.1",
84
+ "source-map": "0.6.1",
85
+ "tty-table": "5.0",
86
+ "undici": "^6.28.0",
87
+ "yauzl": "^3.4.0",
88
+ "yazl": "3.3.1"
89
+ },
90
+ "overrides": {
91
+ "@xmldom/xmldom": "0.8.13"
92
+ },
93
+ "engines": {
94
+ "node": ">= 18.17.0"
95
+ },
96
+ "devDependencies": {
97
+ "@babel/parser": "^8.0.4",
98
+ "@biomejs/biome": "^2.5.10",
99
+ "@types/bun": "^1.4.0",
100
+ "@types/filesize-parser": "^1.5.3",
101
+ "@types/fs-extra": "^11.0.4",
102
+ "@types/node": "^26.3.0",
103
+ "@types/node-fetch": "^2.6.13",
104
+ "@types/progress": "^2.0.7",
105
+ "@types/yauzl": "^3.4.0",
106
+ "@types/yazl": "^3.3.1",
107
+ "node-hdiffpatch": "^2.4.0",
108
+ "typescript": "^7.0.2"
109
+ },
110
+ "trustedDependencies": [
111
+ "@biomejs/biome"
112
+ ]
113
+ }
@@ -0,0 +1,183 @@
1
+ syntax = "proto3";
2
+
3
+ package aapt.pb;
4
+
5
+ option java_package = "com.android.aapt";
6
+
7
+ message Configuration {
8
+ enum LayoutDirection {
9
+ LAYOUT_DIRECTION_UNSET = 0;
10
+ LAYOUT_DIRECTION_LTR = 1;
11
+ LAYOUT_DIRECTION_RTL = 2;
12
+ }
13
+
14
+ enum ScreenLayoutSize {
15
+ SCREEN_LAYOUT_SIZE_UNSET = 0;
16
+ SCREEN_LAYOUT_SIZE_SMALL = 1;
17
+ SCREEN_LAYOUT_SIZE_NORMAL = 2;
18
+ SCREEN_LAYOUT_SIZE_LARGE = 3;
19
+ SCREEN_LAYOUT_SIZE_XLARGE = 4;
20
+ }
21
+
22
+ enum ScreenLayoutLong {
23
+ SCREEN_LAYOUT_LONG_UNSET = 0;
24
+ SCREEN_LAYOUT_LONG_LONG = 1;
25
+ SCREEN_LAYOUT_LONG_NOTLONG = 2;
26
+ }
27
+
28
+ enum ScreenRound {
29
+ SCREEN_ROUND_UNSET = 0;
30
+ SCREEN_ROUND_ROUND = 1;
31
+ SCREEN_ROUND_NOTROUND = 2;
32
+ }
33
+
34
+ enum WideColorGamut {
35
+ WIDE_COLOR_GAMUT_UNSET = 0;
36
+ WIDE_COLOR_GAMUT_WIDECG = 1;
37
+ WIDE_COLOR_GAMUT_NOWIDECG = 2;
38
+ }
39
+
40
+ enum Hdr {
41
+ HDR_UNSET = 0;
42
+ HDR_HIGHDR = 1;
43
+ HDR_LOWDR = 2;
44
+ }
45
+
46
+ enum Orientation {
47
+ ORIENTATION_UNSET = 0;
48
+ ORIENTATION_PORT = 1;
49
+ ORIENTATION_LAND = 2;
50
+ ORIENTATION_SQUARE = 3;
51
+ }
52
+
53
+ enum UiModeType {
54
+ UI_MODE_TYPE_UNSET = 0;
55
+ UI_MODE_TYPE_NORMAL = 1;
56
+ UI_MODE_TYPE_DESK = 2;
57
+ UI_MODE_TYPE_CAR = 3;
58
+ UI_MODE_TYPE_TELEVISION = 4;
59
+ UI_MODE_TYPE_APPLIANCE = 5;
60
+ UI_MODE_TYPE_WATCH = 6;
61
+ UI_MODE_TYPE_VR_HEADSET = 7;
62
+ }
63
+
64
+ enum UiModeNight {
65
+ UI_MODE_NIGHT_UNSET = 0;
66
+ UI_MODE_NIGHT_NIGHT = 1;
67
+ UI_MODE_NIGHT_NOTNIGHT = 2;
68
+ }
69
+
70
+ enum Touchscreen {
71
+ TOUCHSCREEN_UNSET = 0;
72
+ TOUCHSCREEN_NOTOUCH = 1;
73
+ TOUCHSCREEN_STYLUS = 2;
74
+ TOUCHSCREEN_FINGER = 3;
75
+ }
76
+
77
+ enum KeysHidden {
78
+ KEYS_HIDDEN_UNSET = 0;
79
+ KEYS_HIDDEN_KEYSEXPOSED = 1;
80
+ KEYS_HIDDEN_KEYSHIDDEN = 2;
81
+ KEYS_HIDDEN_KEYSSOFT = 3;
82
+ }
83
+
84
+ enum Keyboard {
85
+ KEYBOARD_UNSET = 0;
86
+ KEYBOARD_NOKEYS = 1;
87
+ KEYBOARD_QWERTY = 2;
88
+ KEYBOARD_12KEY = 3;
89
+ }
90
+
91
+ enum NavHidden {
92
+ NAV_HIDDEN_UNSET = 0;
93
+ NAV_HIDDEN_NAVEXPOSED = 1;
94
+ NAV_HIDDEN_NAVHIDDEN = 2;
95
+ }
96
+
97
+ enum Navigation {
98
+ NAVIGATION_UNSET = 0;
99
+ NAVIGATION_NONAV = 1;
100
+ NAVIGATION_DPAD = 2;
101
+ NAVIGATION_TRACKBALL = 3;
102
+ NAVIGATION_WHEEL = 4;
103
+ }
104
+
105
+ enum GrammaticalGender {
106
+ GRAMMATICAL_GENDER_UNSET = 0;
107
+ GRAMMATICAL_GENDER_NEUTER = 1;
108
+ GRAMMATICAL_GENDER_FEMININE = 2;
109
+ GRAMMATICAL_GENDER_MASCULINE = 3;
110
+ }
111
+
112
+ // Mobile country code.
113
+ uint32 mcc = 1;
114
+
115
+ // Mobile network code.
116
+ uint32 mnc = 2;
117
+
118
+ // Locale.
119
+ string locale = 3;
120
+
121
+ // Layout direction.
122
+ LayoutDirection layout_direction = 4;
123
+
124
+ // Screen width in dp.
125
+ uint32 screen_width = 5;
126
+
127
+ // Screen height in dp.
128
+ uint32 screen_height = 6;
129
+
130
+ // Smallest screen width in dp.
131
+ uint32 smallest_screen_width = 7;
132
+
133
+ // Screen layout size.
134
+ ScreenLayoutSize screen_layout_size = 8;
135
+
136
+ // Screen layout long.
137
+ ScreenLayoutLong screen_layout_long = 9;
138
+
139
+ // Screen round.
140
+ ScreenRound screen_round = 10;
141
+
142
+ // Wide color gamut.
143
+ WideColorGamut wide_color_gamut = 11;
144
+
145
+ // HDR.
146
+ Hdr hdr = 12;
147
+
148
+ // Orientation.
149
+ Orientation orientation = 13;
150
+
151
+ // UI mode type.
152
+ UiModeType ui_mode_type = 14;
153
+
154
+ // UI mode night.
155
+ UiModeNight ui_mode_night = 15;
156
+
157
+ // Density in dpi.
158
+ uint32 density = 16;
159
+
160
+ // Touchscreen.
161
+ Touchscreen touchscreen = 17;
162
+
163
+ // Keys hidden.
164
+ KeysHidden keys_hidden = 18;
165
+
166
+ // Keyboard.
167
+ Keyboard keyboard = 19;
168
+
169
+ // Nav hidden.
170
+ NavHidden nav_hidden = 20;
171
+
172
+ // Navigation.
173
+ Navigation navigation = 21;
174
+
175
+ // SDK version.
176
+ uint32 sdk_version = 22;
177
+
178
+ // Product.
179
+ string product = 23;
180
+
181
+ // Grammatical gender.
182
+ GrammaticalGender grammatical_gender = 24;
183
+ }