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,91 @@
1
+ "use strict";
2
+ /**
3
+ * [INPUT]: 依赖文件系统、路径、yazl ZIP 写入器、本地化文案与 ZIP 条目压缩策略
4
+ * [OUTPUT]: 对外提供 packBundle,将 bundle 目录打包为 CLI 发布制品
5
+ * [POS]: CLI PPK 制品打包器,只决定条目边界和压缩方式,不负责 bundle 生成与上传
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ var __importDefault = (this && this.__importDefault) || function (mod) {
41
+ return (mod && mod.__esModule) ? mod : { "default": mod };
42
+ };
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ exports.packBundle = packBundle;
45
+ const fs = __importStar(require("fs-extra"));
46
+ const path_1 = __importDefault(require("path"));
47
+ const yazl_1 = require("yazl");
48
+ const i18n_1 = require("./utils/i18n");
49
+ const zip_options_1 = require("./utils/zip-options");
50
+ const ignorePackingExtensions = ['DS_Store', 'txt.map'];
51
+ async function packBundle(dir, output, bundleName) {
52
+ const ignorePackingFileNames = [
53
+ 'index.bundlejs.map',
54
+ 'bundle.harmony.js.map',
55
+ ];
56
+ if (bundleName) {
57
+ ignorePackingFileNames.push(`${bundleName}.map`);
58
+ }
59
+ console.log((0, i18n_1.t)('packing'));
60
+ fs.ensureDirSync(path_1.default.dirname(output));
61
+ await new Promise((resolve, reject) => {
62
+ const zipfile = new yazl_1.ZipFile();
63
+ function addDirectory(root, rel) {
64
+ if (rel) {
65
+ zipfile.addEmptyDirectory(rel);
66
+ }
67
+ const children = fs.readdirSync(root);
68
+ for (const name of children) {
69
+ if (ignorePackingFileNames.includes(name) ||
70
+ ignorePackingExtensions.some((ext) => name.endsWith(`.${ext}`))) {
71
+ continue;
72
+ }
73
+ const fullPath = path_1.default.join(root, name);
74
+ const stat = fs.statSync(fullPath);
75
+ if (stat.isFile()) {
76
+ zipfile.addFile(fullPath, rel + name, (0, zip_options_1.zipOptionsForPayloadFile)(fullPath, rel + name));
77
+ }
78
+ else if (stat.isDirectory()) {
79
+ addDirectory(fullPath, `${rel}${name}/`);
80
+ }
81
+ }
82
+ }
83
+ addDirectory(dir, '');
84
+ zipfile.outputStream.on('error', (err) => reject(err));
85
+ zipfile.outputStream.pipe(fs.createWriteStream(output)).on('close', () => {
86
+ resolve();
87
+ });
88
+ zipfile.end();
89
+ });
90
+ console.log((0, i18n_1.t)('fileGenerated', { file: output }));
91
+ }
@@ -0,0 +1,168 @@
1
+ import { type HermesBaseOption, type HermesBaseOutcome, type HermesBaseSelection } from './utils/hermes-base';
2
+ export interface BundleCliOptions {
3
+ taro?: boolean;
4
+ expo?: boolean;
5
+ rncli?: boolean;
6
+ }
7
+ export interface RunBundleCommandOptions {
8
+ bundleName: string;
9
+ dev: string;
10
+ entryFile: string;
11
+ outputFolder: string;
12
+ platform: string;
13
+ sourcemapOutput: string;
14
+ config?: string;
15
+ forceHermes?: boolean;
16
+ /** Hermes -base-bytecode settings; omitted → compile without a base */
17
+ hermesBase?: HermesBaseRequest;
18
+ /** pass --reset-cache to Metro (default true); false reuses its transform cache */
19
+ resetCache?: boolean;
20
+ cli: BundleCliOptions;
21
+ isSentry: boolean;
22
+ }
23
+ export interface HermesBaseRequest {
24
+ option: HermesBaseOption;
25
+ appId?: string;
26
+ verify: boolean;
27
+ cacheMaxMb?: number;
28
+ }
29
+ export interface HermesCompileResult {
30
+ bytecodeVersion: number | null;
31
+ base: HermesBaseSelection | null;
32
+ /** true when --verifyHermesBase ran and passed; false when it failed (base dropped) */
33
+ verified?: boolean;
34
+ /**
35
+ * What became of the base, for version/create. Kept apart from `base`
36
+ * (null whenever nothing shipped with a base) so a rejected base and "no
37
+ * base found" stay distinguishable on the server.
38
+ */
39
+ outcome: HermesBaseOutcome;
40
+ /** first difference / failure reason behind `outcome`, when there is one */
41
+ outcomeDetail?: string;
42
+ }
43
+ /** Outcome of picking a base: what to compile with, plus the log lines. */
44
+ export interface HermesBaseSelectionResult {
45
+ base: HermesBaseSelection | null;
46
+ bytecodeVersion: number | null;
47
+ /** messages to print when the compile phase starts (kept out of Metro's output) */
48
+ logs: string[];
49
+ /** the hermesc the selection was made with (the compile reuses it) */
50
+ hermesCommand?: string;
51
+ /** hermesc could not be resolved; the compile phase will report it */
52
+ commandUnavailable?: boolean;
53
+ }
54
+ interface GradleConfig {
55
+ crunchPngs?: boolean;
56
+ enableHermes?: boolean;
57
+ }
58
+ type ResolvedExpoCli = {
59
+ cliPath: string;
60
+ usingExpo: boolean;
61
+ };
62
+ type SentryUploadArtifacts = {
63
+ bundlePath: string;
64
+ sourcemapPath: string;
65
+ };
66
+ type BuildSentrySourcemapsUploadArgsOptions = {
67
+ sentryCliPath: string;
68
+ bundlePath: string;
69
+ sourcemapPath: string;
70
+ release?: string;
71
+ dist?: string;
72
+ stripPrefix?: string;
73
+ debugIdReference?: boolean;
74
+ useStandaloneSourcemapsCommand?: boolean;
75
+ };
76
+ export interface SentryUploadOptions {
77
+ sentryRelease?: string;
78
+ sentryDist?: string;
79
+ }
80
+ type SentryUploadMode = {
81
+ type: 'debug-id';
82
+ debugId: string;
83
+ } | {
84
+ type: 'release';
85
+ release: string;
86
+ dist?: string;
87
+ };
88
+ export declare function hasProjectDependency(dependencyName: string, projectRoot?: string): boolean;
89
+ export declare function resolveExpoCli(projectRoot?: string): ResolvedExpoCli;
90
+ export declare function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, forceHermes, hermesBase, resetCache, cli, isSentry, }: RunBundleCommandOptions): Promise<HermesCompileResult | null>;
91
+ /**
92
+ * Validate the intermediate directory before it is emptied and return the
93
+ * canonical path that was validated. The caller must use this returned path:
94
+ * validating one spelling and deleting through another re-opens symlink
95
+ * redirection.
96
+ */
97
+ export declare function assertSafeToEmpty(dir: string, cwd?: string): string;
98
+ /**
99
+ * Whether the app runs Hermes, i.e. whether the bundle must be compiled to
100
+ * bytecode. A JS bundle shipped to a Hermes app still runs, but starts slower
101
+ * and cannot use the Hermes base delta, so false negatives are what this
102
+ * guards against.
103
+ *
104
+ * Android: `hermesEnabled` in gradle.properties wins; then the legacy
105
+ * `project.ext.react.enableHermes` of build.gradle; with neither, the React
106
+ * Native gradle plugin (0.71+) defaults to Hermes and older versions to JSC.
107
+ * iOS: an installed `Pods/hermes-engine`; when `pod install` has not run on
108
+ * this machine (CI), Expo's `Podfile.properties.json` or the pod listed in
109
+ * `Podfile.lock` tell the same.
110
+ */
111
+ export declare function detectHermesEnabled(platform: string, forceHermes: boolean | undefined, gradleConfig: GradleConfig, projectRoot?: string): Promise<boolean>;
112
+ /** Hermes on iOS: explicit configuration first, installed artifacts second. */
113
+ export declare function detectIosHermes(projectRoot: string): boolean;
114
+ export declare function resolveHermesCommand(projectRoot?: string): string;
115
+ /**
116
+ * hermesc argument policy. `-output-source-map` is always passed: hermesc then
117
+ * strips the debug info section from the bytecode (like React Native's own
118
+ * release builds, 15-40% smaller bytecode and smaller hot-update patches) and
119
+ * writes its own `<bundle>.map` next to the output. When the user asked for a
120
+ * sourcemap that file is composed with the packager map as before; otherwise it
121
+ * simply stays in the intermediate directory (never packed into the ppk) so
122
+ * `address at` stack frames can still be symbolicated later.
123
+ */
124
+ /**
125
+ * hermesc echoes every diagnostic as three lines (header, the offending source
126
+ * line, a caret line). Minified bundles put a whole module on one line, so a
127
+ * single warning can be 100k+ characters and blindly keeping the tail of stderr
128
+ * buries the actual error under warning noise. Keep the diagnostic headers,
129
+ * prefer errors over warnings, and cap the length of whatever survives.
130
+ */
131
+ export declare function summarizeHermescStderr(stderr: string): string;
132
+ /** hermesc arguments writing `bundlePath` from `input` (in place by default) */
133
+ export declare function buildHermescArgs(bundlePath: string, input?: string): string[];
134
+ export interface CompileHermesOptions {
135
+ bundleName: string;
136
+ outputFolder: string;
137
+ sourcemapOutput: string;
138
+ shouldCleanSourcemap: boolean;
139
+ baseRequest?: HermesBaseRequest;
140
+ /** base selection started alongside Metro (see startHermesBaseSelection) */
141
+ pendingBase?: Promise<HermesBaseSelectionResult>;
142
+ /** defaults to the hermesc the selection used, else the project's */
143
+ hermesCommand?: string;
144
+ }
145
+ export declare function compileHermesByteCode({ bundleName, outputFolder, sourcemapOutput, shouldCleanSourcemap, baseRequest, pendingBase, hermesCommand, }: CompileHermesOptions): Promise<HermesCompileResult>;
146
+ /** where a failed base attempt's full hermesc output goes (never packed) */
147
+ export declare function hermesBaseErrorLogPath(outputFolder: string): string;
148
+ /**
149
+ * With PAKTA_HERMES_BASE_DEBUG set, both disassemblies of the equivalence
150
+ * check are kept next to the intermediate directory (never packed) so a
151
+ * rejected base can be reported with the exact difference.
152
+ */
153
+ export declare function hermesBaseDumpPaths(outputFolder: string, env?: NodeJS.ProcessEnv): {
154
+ withBase: string;
155
+ plain: string;
156
+ } | undefined;
157
+ /**
158
+ * Begin resolving the base right away (before Metro); the compile phase awaits
159
+ * the result. Never rejects: any failure is reported there instead.
160
+ */
161
+ export declare function startHermesBaseSelection(request: HermesBaseRequest): Promise<HermesBaseSelectionResult>;
162
+ export declare function copyDebugidForSentry(bundleName: string, outputFolder: string, sourcemapOutput: string): Promise<void>;
163
+ export declare function prepareSentryUploadArtifacts(bundleName: string, outputFolder: string, platform: string): Promise<SentryUploadArtifacts>;
164
+ export declare function readSourcemapDebugId(sourcemapPath: string): Promise<string | undefined>;
165
+ export declare function resolveSentryUploadMode(sourcemapPath: string, options?: SentryUploadOptions): Promise<SentryUploadMode>;
166
+ export declare function buildSentrySourcemapsUploadArgs({ sentryCliPath, bundlePath, sourcemapPath, release, dist, stripPrefix, debugIdReference, useStandaloneSourcemapsCommand, }: BuildSentrySourcemapsUploadArgsOptions): string[];
167
+ export declare function uploadSourcemapForSentry(bundleName: string, outputFolder: string, sourcemapOutput: string, platform?: string, sentryOptions?: SentryUploadOptions): Promise<void>;
168
+ export {};