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.
- package/LICENSE +21 -0
- package/README.md +167 -0
- package/README.zh-CN.md +167 -0
- package/cli.json +525 -0
- package/lib/api.d.ts +56 -0
- package/lib/api.js +671 -0
- package/lib/app.d.ts +107 -0
- package/lib/app.js +329 -0
- package/lib/auto-update.d.ts +35 -0
- package/lib/auto-update.js +507 -0
- package/lib/bin.d.ts +2 -0
- package/lib/bin.js +133 -0
- package/lib/bundle-pack.d.ts +6 -0
- package/lib/bundle-pack.js +91 -0
- package/lib/bundle-runner.d.ts +168 -0
- package/lib/bundle-runner.js +1305 -0
- package/lib/bundle.d.ts +45 -0
- package/lib/bundle.js +226 -0
- package/lib/cache.d.ts +10 -0
- package/lib/cache.js +25 -0
- package/lib/commands.d.ts +11 -0
- package/lib/commands.js +72 -0
- package/lib/diff.d.ts +18 -0
- package/lib/diff.js +690 -0
- package/lib/exports.d.ts +11 -0
- package/lib/exports.js +20 -0
- package/lib/install.d.ts +9 -0
- package/lib/install.js +51 -0
- package/lib/locales/en.d.ts +187 -0
- package/lib/locales/en.js +194 -0
- package/lib/locales/zh.d.ts +187 -0
- package/lib/locales/zh.js +194 -0
- package/lib/native-package.d.ts +21 -0
- package/lib/native-package.js +298 -0
- package/lib/package.d.ts +68 -0
- package/lib/package.js +487 -0
- package/lib/provider.d.ts +24 -0
- package/lib/provider.js +244 -0
- package/lib/standalone-publish.d.ts +17 -0
- package/lib/standalone-publish.js +433 -0
- package/lib/symbolicate.d.ts +35 -0
- package/lib/symbolicate.js +130 -0
- package/lib/types.d.ts +152 -0
- package/lib/types.js +2 -0
- package/lib/user.d.ts +8 -0
- package/lib/user.js +50 -0
- package/lib/utils/add-gitignore.d.ts +6 -0
- package/lib/utils/add-gitignore.js +44 -0
- package/lib/utils/app-info-parser/aab.d.ts +27 -0
- package/lib/utils/app-info-parser/aab.js +256 -0
- package/lib/utils/app-info-parser/apk.d.ts +19 -0
- package/lib/utils/app-info-parser/apk.js +95 -0
- package/lib/utils/app-info-parser/app.d.ts +9 -0
- package/lib/utils/app-info-parser/app.js +15 -0
- package/lib/utils/app-info-parser/index.d.ts +21 -0
- package/lib/utils/app-info-parser/index.js +51 -0
- package/lib/utils/app-info-parser/ipa.d.ts +19 -0
- package/lib/utils/app-info-parser/ipa.js +101 -0
- package/lib/utils/app-info-parser/resource-finder.d.ts +49 -0
- package/lib/utils/app-info-parser/resource-finder.js +429 -0
- package/lib/utils/app-info-parser/utils.d.ts +36 -0
- package/lib/utils/app-info-parser/utils.js +140 -0
- package/lib/utils/app-info-parser/xml-parser/binary.d.ts +61 -0
- package/lib/utils/app-info-parser/xml-parser/binary.js +577 -0
- package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +15 -0
- package/lib/utils/app-info-parser/xml-parser/manifest.js +207 -0
- package/lib/utils/app-info-parser/zip.d.ts +29 -0
- package/lib/utils/app-info-parser/zip.js +97 -0
- package/lib/utils/check-lockfile.d.ts +6 -0
- package/lib/utils/check-lockfile.js +93 -0
- package/lib/utils/check-plugin.d.ts +12 -0
- package/lib/utils/check-plugin.js +36 -0
- package/lib/utils/command-result.d.ts +8 -0
- package/lib/utils/command-result.js +27 -0
- package/lib/utils/constants.d.ts +10 -0
- package/lib/utils/constants.js +39 -0
- package/lib/utils/dep-versions.d.ts +20 -0
- package/lib/utils/dep-versions.js +129 -0
- package/lib/utils/git.d.ts +14 -0
- package/lib/utils/git.js +64 -0
- package/lib/utils/hbcTransform.d.ts +111 -0
- package/lib/utils/hbcTransform.js +561 -0
- package/lib/utils/hermes-base.d.ts +227 -0
- package/lib/utils/hermes-base.js +1287 -0
- package/lib/utils/hermes-literals.d.ts +64 -0
- package/lib/utils/hermes-literals.js +260 -0
- package/lib/utils/http-helper.d.ts +10 -0
- package/lib/utils/http-helper.js +150 -0
- package/lib/utils/i18n.d.ts +22 -0
- package/lib/utils/i18n.js +46 -0
- package/lib/utils/index.d.ts +67 -0
- package/lib/utils/index.js +545 -0
- package/lib/utils/latest-version/index.d.ts +154 -0
- package/lib/utils/latest-version/index.js +331 -0
- package/lib/utils/options.d.ts +10 -0
- package/lib/utils/options.js +68 -0
- package/lib/utils/plugin-config.d.ts +14 -0
- package/lib/utils/plugin-config.js +66 -0
- package/lib/utils/runtime.d.ts +54 -0
- package/lib/utils/runtime.js +263 -0
- package/lib/utils/slim-sourcemap.d.ts +28 -0
- package/lib/utils/slim-sourcemap.js +106 -0
- package/lib/utils/zip-entries.d.ts +10 -0
- package/lib/utils/zip-entries.js +211 -0
- package/lib/utils/zip-options.d.ts +17 -0
- package/lib/utils/zip-options.js +190 -0
- package/lib/utils/zip-range.d.ts +148 -0
- package/lib/utils/zip-range.js +581 -0
- package/lib/utils/zip-raw-writer.d.ts +52 -0
- package/lib/utils/zip-raw-writer.js +209 -0
- package/lib/version-operations.d.ts +21 -0
- package/lib/version-operations.js +320 -0
- package/lib/versions.d.ts +66 -0
- package/lib/versions.js +402 -0
- package/package.json +113 -0
- package/proto/Configuration.proto +183 -0
- package/proto/Resources.proto +569 -0
package/lib/bundle.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [INPUT]: 依赖 CLI 参数/应用选择、Metro/Hermes bundle runner、PPK packer、版本 API 与本地构建工具
|
|
3
|
+
* [OUTPUT]: 对外提供 bundleCommands 及标准化 bundle 选项/发布编排,并传递 Hermes 校验元数据
|
|
4
|
+
* [POS]: CLI bundle 领域入口,串联打包、源码映射、Hermes base、应用绑定和版本发布,不实现底层压缩与网络协议
|
|
5
|
+
*/
|
|
6
|
+
type NormalizedBundleOptions = {
|
|
7
|
+
bundleName: string;
|
|
8
|
+
entryFile: string;
|
|
9
|
+
intermediaDir: string;
|
|
10
|
+
output: string;
|
|
11
|
+
dev: string;
|
|
12
|
+
sourcemap: boolean;
|
|
13
|
+
taro: boolean;
|
|
14
|
+
expo: boolean;
|
|
15
|
+
rncli: boolean;
|
|
16
|
+
hermes: boolean;
|
|
17
|
+
hermesBase: string;
|
|
18
|
+
verifyHermesBase: boolean;
|
|
19
|
+
resetCache: boolean;
|
|
20
|
+
cacheMaxMb?: number;
|
|
21
|
+
appId?: string;
|
|
22
|
+
config?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
metaInfo?: string;
|
|
26
|
+
packageId?: string;
|
|
27
|
+
packageVersion?: string;
|
|
28
|
+
minPackageVersion?: string;
|
|
29
|
+
maxPackageVersion?: string;
|
|
30
|
+
packageVersionRange?: string;
|
|
31
|
+
rollout?: string;
|
|
32
|
+
dryRun: boolean;
|
|
33
|
+
sentryRelease?: string;
|
|
34
|
+
sentryDist?: string;
|
|
35
|
+
};
|
|
36
|
+
/** Normalize translated CLI values into the bundle command's typed options. */
|
|
37
|
+
export declare function normalizeBundleOptions(translatedOptions: Record<string, unknown>, platform: string): NormalizedBundleOptions;
|
|
38
|
+
export declare const bundleCommands: {
|
|
39
|
+
/** Build a bundle and optionally publish it to one operation-scoped app. */
|
|
40
|
+
bundle: ({ args, options, }: {
|
|
41
|
+
args?: string[];
|
|
42
|
+
options: Record<string, unknown>;
|
|
43
|
+
}) => Promise<void>;
|
|
44
|
+
};
|
|
45
|
+
export {};
|
package/lib/bundle.js
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* [INPUT]: 依赖 CLI 参数/应用选择、Metro/Hermes bundle runner、PPK packer、版本 API 与本地构建工具
|
|
4
|
+
* [OUTPUT]: 对外提供 bundleCommands 及标准化 bundle 选项/发布编排,并传递 Hermes 校验元数据
|
|
5
|
+
* [POS]: CLI bundle 领域入口,串联打包、源码映射、Hermes base、应用绑定和版本发布,不实现底层压缩与网络协议
|
|
6
|
+
*/
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.bundleCommands = void 0;
|
|
12
|
+
exports.normalizeBundleOptions = normalizeBundleOptions;
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const app_1 = require("./app");
|
|
15
|
+
const bundle_pack_1 = require("./bundle-pack");
|
|
16
|
+
const bundle_runner_1 = require("./bundle-runner");
|
|
17
|
+
const utils_1 = require("./utils");
|
|
18
|
+
const add_gitignore_1 = require("./utils/add-gitignore");
|
|
19
|
+
const check_lockfile_1 = require("./utils/check-lockfile");
|
|
20
|
+
const constants_1 = require("./utils/constants");
|
|
21
|
+
const dep_versions_1 = require("./utils/dep-versions");
|
|
22
|
+
const hermes_base_1 = require("./utils/hermes-base");
|
|
23
|
+
const i18n_1 = require("./utils/i18n");
|
|
24
|
+
const options_1 = require("./utils/options");
|
|
25
|
+
const versions_1 = require("./versions");
|
|
26
|
+
/** `--no-<flag>` as parsed by cli-arguments: the key is present without a value. */
|
|
27
|
+
function isClearedFlag(options, key) {
|
|
28
|
+
return key in options && options[key] === undefined;
|
|
29
|
+
}
|
|
30
|
+
/** Parse a positive cache-size option expressed in megabytes. */
|
|
31
|
+
function parseCacheMaxMb(value) {
|
|
32
|
+
const parsed = typeof value === 'string' ? Number(value) : value;
|
|
33
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
|
|
34
|
+
}
|
|
35
|
+
/** Read either spelling of an aliased optional CLI string option. */
|
|
36
|
+
function getAliasedOptionalStringOption(options, key, alias) {
|
|
37
|
+
return ((0, options_1.getOptionalStringOption)(options, key) ??
|
|
38
|
+
(0, options_1.getOptionalStringOption)(options, alias));
|
|
39
|
+
}
|
|
40
|
+
/** Normalize translated CLI values into the bundle command's typed options. */
|
|
41
|
+
function normalizeBundleOptions(translatedOptions, platform) {
|
|
42
|
+
return {
|
|
43
|
+
// harmony bundles always use this fixed name (runReactNativeBundleCommand
|
|
44
|
+
// forces it), so sourcemap paths and Sentry uploads must match
|
|
45
|
+
bundleName: platform === 'harmony'
|
|
46
|
+
? 'bundle.harmony.js'
|
|
47
|
+
: (0, options_1.getStringOption)(translatedOptions, 'bundleName', 'index.bundlejs'),
|
|
48
|
+
entryFile: (0, options_1.getStringOption)(translatedOptions, 'entryFile', 'index.js'),
|
|
49
|
+
intermediaDir: (0, options_1.getStringOption)(translatedOptions, 'intermediaDir', `${constants_1.tempDir}/intermedia/${platform}`),
|
|
50
|
+
output: (0, options_1.getStringOption)(translatedOptions, 'output', `${constants_1.tempDir}/output/${platform}.\${time}.ppk`),
|
|
51
|
+
dev: (0, options_1.getBooleanOption)(translatedOptions, 'dev', false) ? 'true' : 'false',
|
|
52
|
+
// On by default since 2.23: the map is archived with the published
|
|
53
|
+
// version (pakta symbolicate). `--no-sourcemap` opts out: cli-arguments
|
|
54
|
+
// implements `--no-<flag>` by clearing the flag's value, so a key that is
|
|
55
|
+
// present but undefined is the opt-out and only a missing key means
|
|
56
|
+
// "default" (`--sourcemap false` would leave the flag on, see `bundle`).
|
|
57
|
+
sourcemap: isClearedFlag(translatedOptions, 'sourcemap')
|
|
58
|
+
? false
|
|
59
|
+
: (0, options_1.getBooleanOption)(translatedOptions, 'sourcemap', true),
|
|
60
|
+
taro: (0, options_1.getBooleanOption)(translatedOptions, 'taro', false),
|
|
61
|
+
expo: (0, options_1.getBooleanOption)(translatedOptions, 'expo', false),
|
|
62
|
+
rncli: (0, options_1.getBooleanOption)(translatedOptions, 'rncli', false),
|
|
63
|
+
hermes: (0, options_1.getBooleanOption)(translatedOptions, 'hermes', false),
|
|
64
|
+
hermesBase: (0, options_1.getStringOption)(translatedOptions, 'hermesBase', 'auto'),
|
|
65
|
+
verifyHermesBase: (0, options_1.getBooleanOption)(translatedOptions, 'verifyHermesBase', true),
|
|
66
|
+
resetCache: (0, options_1.getBooleanOption)(translatedOptions, 'resetCache', true),
|
|
67
|
+
cacheMaxMb: parseCacheMaxMb(translatedOptions.cacheMaxMb),
|
|
68
|
+
appId: (0, options_1.getOptionalStringOption)(translatedOptions, 'appId'),
|
|
69
|
+
config: (0, options_1.getOptionalStringOption)(translatedOptions, 'config'),
|
|
70
|
+
name: (0, options_1.getOptionalStringOption)(translatedOptions, 'name'),
|
|
71
|
+
description: (0, options_1.getOptionalStringOption)(translatedOptions, 'description'),
|
|
72
|
+
metaInfo: (0, options_1.getOptionalStringOption)(translatedOptions, 'metaInfo'),
|
|
73
|
+
packageId: (0, options_1.getOptionalStringOption)(translatedOptions, 'packageId'),
|
|
74
|
+
packageVersion: (0, options_1.getOptionalStringOption)(translatedOptions, 'packageVersion'),
|
|
75
|
+
minPackageVersion: (0, options_1.getOptionalStringOption)(translatedOptions, 'minPackageVersion'),
|
|
76
|
+
maxPackageVersion: (0, options_1.getOptionalStringOption)(translatedOptions, 'maxPackageVersion'),
|
|
77
|
+
packageVersionRange: (0, options_1.getOptionalStringOption)(translatedOptions, 'packageVersionRange'),
|
|
78
|
+
rollout: (0, options_1.getOptionalStringOption)(translatedOptions, 'rollout'),
|
|
79
|
+
dryRun: (0, options_1.getBooleanOption)(translatedOptions, 'dryRun', false),
|
|
80
|
+
sentryRelease: getAliasedOptionalStringOption(translatedOptions, 'sentry-release', 'sentryRelease'),
|
|
81
|
+
sentryDist: getAliasedOptionalStringOption(translatedOptions, 'sentry-dist', 'sentryDist'),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/** Upload generated Sentry artifacts when the detected plugin requires them. */
|
|
85
|
+
async function uploadSentryArtifactsIfNeeded(shouldUpload, bundleName, intermediaDir, sourcemapOutput, platform, sentryOptions) {
|
|
86
|
+
if (!shouldUpload) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
await (0, bundle_runner_1.copyDebugidForSentry)(bundleName, intermediaDir, sourcemapOutput);
|
|
90
|
+
await (0, bundle_runner_1.uploadSourcemapForSentry)(bundleName, intermediaDir, sourcemapOutput, platform, sentryOptions);
|
|
91
|
+
}
|
|
92
|
+
/** Publish a packed bundle through the version command implementation. */
|
|
93
|
+
async function publishBundleVersion(outputPath, platform, payload) {
|
|
94
|
+
return versions_1.versionCommands.publish({
|
|
95
|
+
args: [outputPath],
|
|
96
|
+
options: {
|
|
97
|
+
platform,
|
|
98
|
+
...payload,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
exports.bundleCommands = {
|
|
103
|
+
/** Build a bundle and optionally publish it to one operation-scoped app. */
|
|
104
|
+
bundle: async ({ args = [], options, }) => {
|
|
105
|
+
// Boolean flags take no value: `--sourcemap false` leaves the flag on and
|
|
106
|
+
// turns "false" into a stray argument. Refuse it rather than silently
|
|
107
|
+
// bundling with the wrong settings (a flag is switched off with
|
|
108
|
+
// `--no-<flag>`).
|
|
109
|
+
if (args.length > 0) {
|
|
110
|
+
throw new Error((0, i18n_1.t)('bundleUnexpectedArgs', { args: args.join(' ') }));
|
|
111
|
+
}
|
|
112
|
+
const platform = await (0, app_1.getPlatform)(typeof options.platform === 'string' ? options.platform : undefined);
|
|
113
|
+
const translatedOptions = (0, utils_1.translateOptions)({
|
|
114
|
+
...options,
|
|
115
|
+
tempDir: constants_1.tempDir,
|
|
116
|
+
platform,
|
|
117
|
+
});
|
|
118
|
+
const normalized = normalizeBundleOptions(translatedOptions, platform);
|
|
119
|
+
// One app per operation: the Hermes base lookup and the publish step must
|
|
120
|
+
// never see different apps, so the target is resolved once and reused.
|
|
121
|
+
let appId;
|
|
122
|
+
const getAppId = async () => (appId ??= await (0, app_1.resolveAppId)({
|
|
123
|
+
appId: normalized.appId,
|
|
124
|
+
config: normalized.config,
|
|
125
|
+
platform,
|
|
126
|
+
}));
|
|
127
|
+
const hermesBase = normalized.dev === 'true'
|
|
128
|
+
? undefined
|
|
129
|
+
: {
|
|
130
|
+
option: normalized.hermesBase,
|
|
131
|
+
verify: normalized.verifyHermesBase,
|
|
132
|
+
cacheMaxMb: normalized.cacheMaxMb,
|
|
133
|
+
};
|
|
134
|
+
// Resolve before any side effect or expensive work. A named bundle is
|
|
135
|
+
// published, so a missing app fails right here; a bundle-only run only
|
|
136
|
+
// needs the app for the remote Hermes base lookup and may go on without
|
|
137
|
+
// one (it then compiles a full bundle). Any other config error (e.g.
|
|
138
|
+
// malformed JSON) is reported immediately either way.
|
|
139
|
+
if (normalized.name) {
|
|
140
|
+
await getAppId();
|
|
141
|
+
}
|
|
142
|
+
else if (hermesBase?.option === 'auto') {
|
|
143
|
+
try {
|
|
144
|
+
await getAppId();
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
if (!(error instanceof app_1.AppNotSelectedError)) {
|
|
148
|
+
throw error;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
(0, check_lockfile_1.checkLockFiles)();
|
|
153
|
+
(0, add_gitignore_1.addGitIgnore)();
|
|
154
|
+
const [bundleParams] = await Promise.all([
|
|
155
|
+
(0, utils_1.checkPlugins)(),
|
|
156
|
+
(0, hermes_base_1.cleanStaleTmp)().catch(() => { }),
|
|
157
|
+
]);
|
|
158
|
+
const sourcemapOutput = path_1.default.join(normalized.intermediaDir, `${normalized.bundleName}.map`);
|
|
159
|
+
const realOutput = normalized.output.replace(/\$\{time\}/g, `${Date.now()}`);
|
|
160
|
+
console.log((0, i18n_1.t)('bundlingWithRN', { version: dep_versions_1.depVersions['react-native'] }));
|
|
161
|
+
const hermesResult = await (0, bundle_runner_1.runReactNativeBundleCommand)({
|
|
162
|
+
bundleName: normalized.bundleName,
|
|
163
|
+
dev: normalized.dev,
|
|
164
|
+
entryFile: normalized.entryFile,
|
|
165
|
+
outputFolder: normalized.intermediaDir,
|
|
166
|
+
platform,
|
|
167
|
+
sourcemapOutput: normalized.sourcemap || bundleParams.sourcemap ? sourcemapOutput : '',
|
|
168
|
+
forceHermes: normalized.hermes,
|
|
169
|
+
hermesBase: hermesBase ? { ...hermesBase, appId } : undefined,
|
|
170
|
+
resetCache: normalized.resetCache,
|
|
171
|
+
cli: {
|
|
172
|
+
taro: normalized.taro,
|
|
173
|
+
expo: normalized.expo,
|
|
174
|
+
rncli: normalized.rncli,
|
|
175
|
+
},
|
|
176
|
+
isSentry: bundleParams.sentry,
|
|
177
|
+
});
|
|
178
|
+
await (0, bundle_pack_1.packBundle)(path_1.default.resolve(normalized.intermediaDir), realOutput, normalized.bundleName);
|
|
179
|
+
const baseMeta = hermesResult
|
|
180
|
+
? (0, hermes_base_1.hermesBaseMeta)(hermesResult.base, hermesResult.bytecodeVersion, {
|
|
181
|
+
outcome: hermesResult.outcome,
|
|
182
|
+
detail: hermesResult.outcomeDetail,
|
|
183
|
+
})
|
|
184
|
+
: undefined;
|
|
185
|
+
if (normalized.name) {
|
|
186
|
+
await publishBundleVersion(realOutput, platform, {
|
|
187
|
+
appId: await getAppId(),
|
|
188
|
+
name: normalized.name,
|
|
189
|
+
description: normalized.description,
|
|
190
|
+
metaInfo: normalized.metaInfo,
|
|
191
|
+
packageId: normalized.packageId,
|
|
192
|
+
packageVersion: normalized.packageVersion,
|
|
193
|
+
minPackageVersion: normalized.minPackageVersion,
|
|
194
|
+
maxPackageVersion: normalized.maxPackageVersion,
|
|
195
|
+
packageVersionRange: normalized.packageVersionRange,
|
|
196
|
+
rollout: normalized.rollout,
|
|
197
|
+
dryRun: normalized.dryRun,
|
|
198
|
+
hermesBase: baseMeta,
|
|
199
|
+
sourcemap: normalized.sourcemap || bundleParams.sourcemap
|
|
200
|
+
? sourcemapOutput
|
|
201
|
+
: undefined,
|
|
202
|
+
});
|
|
203
|
+
await uploadSentryArtifactsIfNeeded(bundleParams.sentry, normalized.bundleName, normalized.intermediaDir, sourcemapOutput, platform, {
|
|
204
|
+
sentryRelease: normalized.sentryRelease,
|
|
205
|
+
sentryDist: normalized.sentryDist,
|
|
206
|
+
});
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (!(0, options_1.getBooleanOption)(options, 'no-interactive', false)) {
|
|
210
|
+
const v = await (0, utils_1.question)((0, i18n_1.t)('uploadBundlePrompt'));
|
|
211
|
+
if (v.toLowerCase() === 'y') {
|
|
212
|
+
await publishBundleVersion(realOutput, platform, {
|
|
213
|
+
appId: await getAppId(),
|
|
214
|
+
hermesBase: baseMeta,
|
|
215
|
+
sourcemap: normalized.sourcemap || bundleParams.sourcemap
|
|
216
|
+
? sourcemapOutput
|
|
217
|
+
: undefined,
|
|
218
|
+
});
|
|
219
|
+
await uploadSentryArtifactsIfNeeded(bundleParams.sentry, normalized.bundleName, normalized.intermediaDir, sourcemapOutput, platform, {
|
|
220
|
+
sentryRelease: normalized.sentryRelease,
|
|
221
|
+
sentryDist: normalized.sentryDist,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
};
|
package/lib/cache.d.ts
ADDED
package/lib/cache.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* [INPUT]: 依赖 Hermes base 缓存统计/清理能力与本地化文案
|
|
4
|
+
* [OUTPUT]: 对外提供 cacheCommands,暴露 CLI 缓存查询和清理命令
|
|
5
|
+
* [POS]: CLI 缓存命令适配层,只编排用户输出,不持有缓存实现细节
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.cacheCommands = void 0;
|
|
9
|
+
const hermes_base_1 = require("./utils/hermes-base");
|
|
10
|
+
const i18n_1 = require("./utils/i18n");
|
|
11
|
+
exports.cacheCommands = {
|
|
12
|
+
cache: async ({ args }) => {
|
|
13
|
+
if (args?.[0] === 'clean') {
|
|
14
|
+
const removed = await (0, hermes_base_1.cleanCache)();
|
|
15
|
+
console.log((0, i18n_1.t)('cacheCleaned', { count: removed }));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const stats = await (0, hermes_base_1.cacheStats)();
|
|
19
|
+
console.log((0, i18n_1.t)('cacheStats', {
|
|
20
|
+
dir: stats.dir,
|
|
21
|
+
files: stats.files,
|
|
22
|
+
mb: (stats.bytes / 1024 / 1024).toFixed(1),
|
|
23
|
+
}));
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [INPUT]: 依赖各 CLI 命令组的惰性加载器与命令名/参数约定
|
|
3
|
+
* [OUTPUT]: 对外提供 commandNames、loadCommandHandler 与命令处理器类型
|
|
4
|
+
* [POS]: CLI 命令注册表,以按需加载隔离各命令依赖,避免入口提前加载完整工具链
|
|
5
|
+
*/
|
|
6
|
+
type CliCommandHandler = (argv: any) => Promise<unknown> | unknown;
|
|
7
|
+
/** names of all commands, in the order they are listed by `help` */
|
|
8
|
+
export declare const commandNames: readonly string[];
|
|
9
|
+
/** the handler of `name`, loading its module now; undefined for unknown names */
|
|
10
|
+
export declare function loadCommandHandler(name: string): CliCommandHandler | undefined;
|
|
11
|
+
export {};
|
package/lib/commands.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* [INPUT]: 依赖各 CLI 命令组的惰性加载器与命令名/参数约定
|
|
4
|
+
* [OUTPUT]: 对外提供 commandNames、loadCommandHandler 与命令处理器类型
|
|
5
|
+
* [POS]: CLI 命令注册表,以按需加载隔离各命令依赖,避免入口提前加载完整工具链
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.commandNames = void 0;
|
|
9
|
+
exports.loadCommandHandler = loadCommandHandler;
|
|
10
|
+
const groups = {
|
|
11
|
+
app: () => require('./app').getAppCommands(),
|
|
12
|
+
bundle: () => require('./bundle').bundleCommands,
|
|
13
|
+
cache: () => require('./cache').cacheCommands,
|
|
14
|
+
diff: () => require('./diff').diffCommands,
|
|
15
|
+
install: () => require('./install').installCommands,
|
|
16
|
+
package: () => require('./package').packageCommands,
|
|
17
|
+
symbolicate: () => require('./symbolicate').symbolicateCommands,
|
|
18
|
+
user: () => require('./user').userCommands,
|
|
19
|
+
versions: () => require('./versions').versionCommands,
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* command name → group. Kept in sync with cli.json by tests/commands.test.ts,
|
|
23
|
+
* so a command added to one place but not the other fails the suite.
|
|
24
|
+
*/
|
|
25
|
+
const commandGroups = {
|
|
26
|
+
login: 'user',
|
|
27
|
+
logout: 'user',
|
|
28
|
+
me: 'user',
|
|
29
|
+
createApp: 'app',
|
|
30
|
+
apps: 'app',
|
|
31
|
+
channels: 'app',
|
|
32
|
+
createChannel: 'app',
|
|
33
|
+
updateChannel: 'app',
|
|
34
|
+
deleteChannel: 'app',
|
|
35
|
+
deleteApp: 'app',
|
|
36
|
+
selectApp: 'app',
|
|
37
|
+
uploadIpa: 'package',
|
|
38
|
+
uploadApk: 'package',
|
|
39
|
+
uploadAab: 'package',
|
|
40
|
+
uploadApp: 'package',
|
|
41
|
+
parseApp: 'package',
|
|
42
|
+
parseIpa: 'package',
|
|
43
|
+
parseApk: 'package',
|
|
44
|
+
parseAab: 'package',
|
|
45
|
+
extractApk: 'package',
|
|
46
|
+
packages: 'package',
|
|
47
|
+
deletePackage: 'package',
|
|
48
|
+
registerPdiff: 'versions',
|
|
49
|
+
publish: 'versions',
|
|
50
|
+
versions: 'versions',
|
|
51
|
+
update: 'versions',
|
|
52
|
+
updateVersionInfo: 'versions',
|
|
53
|
+
deleteVersion: 'versions',
|
|
54
|
+
bundle: 'bundle',
|
|
55
|
+
hdiff: 'diff',
|
|
56
|
+
hdiffFromApk: 'diff',
|
|
57
|
+
hdiffFromApp: 'diff',
|
|
58
|
+
hdiffFromIpa: 'diff',
|
|
59
|
+
install: 'install',
|
|
60
|
+
cache: 'cache',
|
|
61
|
+
symbolicate: 'symbolicate',
|
|
62
|
+
};
|
|
63
|
+
/** names of all commands, in the order they are listed by `help` */
|
|
64
|
+
exports.commandNames = Object.keys(commandGroups);
|
|
65
|
+
/** the handler of `name`, loading its module now; undefined for unknown names */
|
|
66
|
+
function loadCommandHandler(name) {
|
|
67
|
+
const group = commandGroups[name];
|
|
68
|
+
if (!group) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
return groups[group]()[name];
|
|
72
|
+
}
|
package/lib/diff.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Entry } from 'yauzl';
|
|
2
|
+
import type { CommandContext } from './types';
|
|
3
|
+
import { enumZipEntries, readEntry } from './utils/zip-entries';
|
|
4
|
+
type ZipEntryContent = Pick<Entry, 'crc32' | 'uncompressedSize'>;
|
|
5
|
+
export { enumZipEntries, readEntry };
|
|
6
|
+
/**
|
|
7
|
+
* 判定两个 zip entry 内容相同的键:crc32 单独并不足以证明内容一致(32 位
|
|
8
|
+
* 校验和碰撞并不罕见,尤其是长度不同的文件),必须同时要求解压后长度相等。
|
|
9
|
+
* 仅用于生成端匹配,manifest 里的 copies / copiesCrc 格式不变。
|
|
10
|
+
*/
|
|
11
|
+
export declare function zipEntryContentKey(entry: ZipEntryContent): string;
|
|
12
|
+
export declare function zipEntriesHaveSameContent(left: ZipEntryContent, right: ZipEntryContent): boolean;
|
|
13
|
+
export declare const diffCommands: {
|
|
14
|
+
hdiff: ({ args, options }: CommandContext) => Promise<void>;
|
|
15
|
+
hdiffFromApk: ({ args, options }: CommandContext) => Promise<void>;
|
|
16
|
+
hdiffFromApp: ({ args, options }: CommandContext) => Promise<void>;
|
|
17
|
+
hdiffFromIpa: ({ args, options }: CommandContext) => Promise<void>;
|
|
18
|
+
};
|