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,207 @@
1
+ "use strict";
2
+ /**
3
+ * [INPUT]: 依赖 BinaryXmlParser 与 Android manifest 的 intent/category 常量
4
+ * [OUTPUT]: 对外提供 ManifestParser,将二进制清单压平为应用包所需元数据
5
+ * [POS]: Android manifest 解析适配层,被 APK/AAB 解析器调用,不读取归档本身
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.ManifestParser = void 0;
9
+ // From https://github.com/openstf/adbkit-apkreader
10
+ const binary_1 = require("./binary");
11
+ const INTENT_MAIN = 'android.intent.action.MAIN';
12
+ const CATEGORY_LAUNCHER = 'android.intent.category.LAUNCHER';
13
+ class ManifestParser {
14
+ buffer;
15
+ xmlParser;
16
+ constructor(buffer, options = {}) {
17
+ this.buffer = buffer;
18
+ this.xmlParser = new binary_1.BinaryXmlParser(this.buffer, options);
19
+ }
20
+ collapseAttributes(element) {
21
+ const collapsed = Object.create(null);
22
+ const attributes = element.attributes;
23
+ for (let i = 0, len = attributes.length; i < len; i++) {
24
+ const attr = attributes[i];
25
+ collapsed[attr.name] = attr.typedValue.value;
26
+ }
27
+ return collapsed;
28
+ }
29
+ parseIntents(element, target) {
30
+ target.intentFilters = [];
31
+ target.metaData = [];
32
+ for (const child of element.childNodes) {
33
+ switch (child.nodeName) {
34
+ case 'intent-filter': {
35
+ const intentFilter = this.collapseAttributes(child);
36
+ intentFilter.actions = [];
37
+ intentFilter.categories = [];
38
+ intentFilter.data = [];
39
+ for (const item of child.childNodes) {
40
+ switch (item.nodeName) {
41
+ case 'action':
42
+ intentFilter.actions.push(this.collapseAttributes(item));
43
+ break;
44
+ case 'category':
45
+ intentFilter.categories.push(this.collapseAttributes(item));
46
+ break;
47
+ case 'data':
48
+ intentFilter.data.push(this.collapseAttributes(item));
49
+ break;
50
+ }
51
+ }
52
+ target.intentFilters.push(intentFilter);
53
+ break;
54
+ }
55
+ case 'meta-data':
56
+ target.metaData.push(this.collapseAttributes(child));
57
+ break;
58
+ }
59
+ }
60
+ }
61
+ parseApplication(element) {
62
+ const app = this.collapseAttributes(element);
63
+ app.activities = [];
64
+ app.activityAliases = [];
65
+ app.launcherActivities = [];
66
+ app.services = [];
67
+ app.receivers = [];
68
+ app.providers = [];
69
+ app.usesLibraries = [];
70
+ app.metaData = [];
71
+ for (const child of element.childNodes) {
72
+ switch (child.nodeName) {
73
+ case 'activity': {
74
+ const activity = this.collapseAttributes(child);
75
+ this.parseIntents(child, activity);
76
+ app.activities.push(activity);
77
+ if (this.isLauncherActivity(activity)) {
78
+ app.launcherActivities.push(activity);
79
+ }
80
+ break;
81
+ }
82
+ case 'activity-alias': {
83
+ const activityAlias = this.collapseAttributes(child);
84
+ this.parseIntents(child, activityAlias);
85
+ app.activityAliases.push(activityAlias);
86
+ if (this.isLauncherActivity(activityAlias)) {
87
+ app.launcherActivities.push(activityAlias);
88
+ }
89
+ break;
90
+ }
91
+ case 'service': {
92
+ const service = this.collapseAttributes(child);
93
+ this.parseIntents(child, service);
94
+ app.services.push(service);
95
+ break;
96
+ }
97
+ case 'receiver': {
98
+ const receiver = this.collapseAttributes(child);
99
+ this.parseIntents(child, receiver);
100
+ app.receivers.push(receiver);
101
+ break;
102
+ }
103
+ case 'provider': {
104
+ const provider = this.collapseAttributes(child);
105
+ provider.grantUriPermissions = [];
106
+ provider.metaData = [];
107
+ provider.pathPermissions = [];
108
+ for (const item of child.childNodes) {
109
+ switch (item.nodeName) {
110
+ case 'grant-uri-permission':
111
+ provider.grantUriPermissions.push(this.collapseAttributes(item));
112
+ break;
113
+ case 'meta-data':
114
+ provider.metaData.push(this.collapseAttributes(item));
115
+ break;
116
+ case 'path-permission':
117
+ provider.pathPermissions.push(this.collapseAttributes(item));
118
+ break;
119
+ }
120
+ }
121
+ app.providers.push(provider);
122
+ break;
123
+ }
124
+ case 'uses-library':
125
+ app.usesLibraries.push(this.collapseAttributes(child));
126
+ break;
127
+ case 'meta-data':
128
+ app.metaData.push(this.collapseAttributes(child));
129
+ break;
130
+ }
131
+ }
132
+ return app;
133
+ }
134
+ isLauncherActivity(activity) {
135
+ return activity.intentFilters.some((filter) => {
136
+ const hasMain = filter.actions.some((action) => action.name === INTENT_MAIN);
137
+ if (!hasMain) {
138
+ return false;
139
+ }
140
+ return filter.categories.some((category) => category.name === CATEGORY_LAUNCHER);
141
+ });
142
+ }
143
+ parse() {
144
+ const document = this.xmlParser.parse();
145
+ const manifest = this.collapseAttributes(document);
146
+ manifest.usesPermissions = [];
147
+ manifest.usesPermissionsSDK23 = [];
148
+ manifest.permissions = [];
149
+ manifest.permissionTrees = [];
150
+ manifest.permissionGroups = [];
151
+ manifest.instrumentation = null;
152
+ manifest.usesSdk = null;
153
+ manifest.usesConfiguration = null;
154
+ manifest.usesFeatures = [];
155
+ manifest.supportsScreens = null;
156
+ manifest.compatibleScreens = [];
157
+ manifest.supportsGlTextures = [];
158
+ manifest.application = Object.create(null);
159
+ for (const element of document.childNodes) {
160
+ switch (element.nodeName) {
161
+ case 'uses-permission':
162
+ manifest.usesPermissions.push(this.collapseAttributes(element));
163
+ break;
164
+ case 'uses-permission-sdk-23':
165
+ manifest.usesPermissionsSDK23.push(this.collapseAttributes(element));
166
+ break;
167
+ case 'permission':
168
+ manifest.permissions.push(this.collapseAttributes(element));
169
+ break;
170
+ case 'permission-tree':
171
+ manifest.permissionTrees.push(this.collapseAttributes(element));
172
+ break;
173
+ case 'permission-group':
174
+ manifest.permissionGroups.push(this.collapseAttributes(element));
175
+ break;
176
+ case 'instrumentation':
177
+ manifest.instrumentation = this.collapseAttributes(element);
178
+ break;
179
+ case 'uses-sdk':
180
+ manifest.usesSdk = this.collapseAttributes(element);
181
+ break;
182
+ case 'uses-configuration':
183
+ manifest.usesConfiguration = this.collapseAttributes(element);
184
+ break;
185
+ case 'uses-feature':
186
+ manifest.usesFeatures.push(this.collapseAttributes(element));
187
+ break;
188
+ case 'supports-screens':
189
+ manifest.supportsScreens = this.collapseAttributes(element);
190
+ break;
191
+ case 'compatible-screens':
192
+ for (const screen of element.childNodes) {
193
+ manifest.compatibleScreens.push(this.collapseAttributes(screen));
194
+ }
195
+ break;
196
+ case 'supports-gl-texture':
197
+ manifest.supportsGlTextures.push(this.collapseAttributes(element));
198
+ break;
199
+ case 'application':
200
+ manifest.application = this.parseApplication(element);
201
+ break;
202
+ }
203
+ }
204
+ return manifest;
205
+ }
206
+ }
207
+ exports.ManifestParser = ManifestParser;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * [INPUT]: 依赖文件路径、ZIP 条目枚举/读取与归档元数据辅助函数
3
+ * [OUTPUT]: 对外提供 Zip 基类,统一平台应用包的条目访问和路径解析
4
+ * [POS]: 应用包解析子域的共享归档边界,隐藏文件路径与 ZIP 流细节
5
+ */
6
+ export declare class Zip {
7
+ file: string | File;
8
+ constructor(file: string | File);
9
+ /**
10
+ * get entries by regexps, the return format is: { <filename>: <Buffer|Blob> }
11
+ * @param {Array} regexps // regexps for matching files
12
+ * @param {String} type // return type, can be buffer or blob, default buffer
13
+ */
14
+ getEntries(regexps: Array<RegExp | string>, type?: 'buffer' | 'blob'): Promise<Record<string, Blob | Buffer<ArrayBufferLike>>>;
15
+ /**
16
+ * get entry by regex, return an instance of Buffer or Blob
17
+ * @param {Regex} regex // regex for matching file
18
+ * @param {String} type // return type, can be buffer or blob, default buffer
19
+ */
20
+ getEntry(regex: RegExp | string, type?: 'buffer' | 'blob'): Promise<Blob | Buffer<ArrayBufferLike>>;
21
+ getEntryFromHarmonyApp(regex: RegExp): Promise<Buffer | Blob | undefined>;
22
+ /**
23
+ * Read multiple entries in a single pass over the archive (including
24
+ * nested .hap extraction), instead of one full scan per entry.
25
+ * Returns buffers in the same order as the given regexps.
26
+ */
27
+ getEntriesFromHarmonyApp(regexps: RegExp[]): Promise<(Buffer | undefined)[]>;
28
+ private readEntries;
29
+ }
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ /**
3
+ * [INPUT]: 依赖文件路径、ZIP 条目枚举/读取与归档元数据辅助函数
4
+ * [OUTPUT]: 对外提供 Zip 基类,统一平台应用包的条目访问和路径解析
5
+ * [POS]: 应用包解析子域的共享归档边界,隐藏文件路径与 ZIP 流细节
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.Zip = void 0;
12
+ const path_1 = __importDefault(require("path"));
13
+ const zip_entries_1 = require("../zip-entries");
14
+ const utils_1 = require("./utils");
15
+ class Zip {
16
+ file;
17
+ constructor(file) {
18
+ this.file = typeof file === 'string' ? path_1.default.resolve(file) : file;
19
+ }
20
+ /**
21
+ * get entries by regexps, the return format is: { <filename>: <Buffer|Blob> }
22
+ * @param {Array} regexps // regexps for matching files
23
+ * @param {String} type // return type, can be buffer or blob, default buffer
24
+ */
25
+ getEntries(regexps, type = 'buffer') {
26
+ const decoded = regexps.map((regex) => (0, utils_1.decodeNullUnicode)(regex));
27
+ return this.readEntries(decoded, type);
28
+ }
29
+ /**
30
+ * get entry by regex, return an instance of Buffer or Blob
31
+ * @param {Regex} regex // regex for matching file
32
+ * @param {String} type // return type, can be buffer or blob, default buffer
33
+ */
34
+ getEntry(regex, type = 'buffer') {
35
+ const decoded = (0, utils_1.decodeNullUnicode)(regex);
36
+ return this.readEntries([decoded], type).then((buffers) => buffers[decoded]);
37
+ }
38
+ async getEntryFromHarmonyApp(regex) {
39
+ return (await this.getEntriesFromHarmonyApp([regex]))[0];
40
+ }
41
+ /**
42
+ * Read multiple entries in a single pass over the archive (including
43
+ * nested .hap extraction), instead of one full scan per entry.
44
+ * Returns buffers in the same order as the given regexps.
45
+ */
46
+ async getEntriesFromHarmonyApp(regexps) {
47
+ const results = new Array(regexps.length);
48
+ try {
49
+ if (typeof this.file !== 'string') {
50
+ throw new Error('Param error: [file] must be file path in Node.');
51
+ }
52
+ await (0, zip_entries_1.enumZipEntries)(this.file, async (entry, zipFile) => {
53
+ for (let i = 0; i < regexps.length; i++) {
54
+ if (regexps[i].test(entry.fileName)) {
55
+ results[i] = await (0, zip_entries_1.readEntry)(entry, zipFile);
56
+ }
57
+ }
58
+ });
59
+ }
60
+ catch (error) {
61
+ console.error('Error in getEntriesFromHarmonyApp:', error);
62
+ }
63
+ return results;
64
+ }
65
+ async readEntries(decoded, type) {
66
+ if (typeof this.file !== 'string') {
67
+ throw new Error('Param error: [file] must be file path in Node.');
68
+ }
69
+ const buffers = {};
70
+ await (0, zip_entries_1.enumZipEntries)(this.file, async (entry, zipFile) => {
71
+ if (entry.fileName.endsWith('/')) {
72
+ return;
73
+ }
74
+ const entryName = (0, utils_1.decodeNullUnicode)(entry.fileName).toString();
75
+ const lowerEntryName = entryName.toLowerCase();
76
+ const matched = decoded.find((pattern) => {
77
+ if (typeof pattern === 'string') {
78
+ return pattern === entryName || pattern === lowerEntryName;
79
+ }
80
+ pattern.lastIndex = 0;
81
+ if (pattern.test(entryName)) {
82
+ return true;
83
+ }
84
+ pattern.lastIndex = 0;
85
+ return pattern.test(lowerEntryName);
86
+ });
87
+ if (!matched) {
88
+ return;
89
+ }
90
+ const buffer = await (0, zip_entries_1.readEntry)(entry, zipFile);
91
+ buffers[matched] =
92
+ type === 'blob' ? new Blob([buffer]) : buffer;
93
+ });
94
+ return buffers;
95
+ }
96
+ }
97
+ exports.Zip = Zip;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * [INPUT]: 依赖文件系统、项目路径、workspace 结构与本地化文案
3
+ * [OUTPUT]: 对外提供 checkLockFiles,检查项目包管理器锁文件并给出一致性提示
4
+ * [POS]: CLI 构建前环境检查层,只报告锁文件状态,不修改依赖解析结果
5
+ */
6
+ export declare function checkLockFiles(): void;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ /**
3
+ * [INPUT]: 依赖文件系统、项目路径、workspace 结构与本地化文案
4
+ * [OUTPUT]: 对外提供 checkLockFiles,检查项目包管理器锁文件并给出一致性提示
5
+ * [POS]: CLI 构建前环境检查层,只报告锁文件状态,不修改依赖解析结果
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.checkLockFiles = checkLockFiles;
12
+ const fs_1 = __importDefault(require("fs"));
13
+ const path_1 = __importDefault(require("path"));
14
+ const i18n_1 = require("./i18n");
15
+ const lockFiles = [
16
+ 'package-lock.json',
17
+ 'yarn.lock',
18
+ 'pnpm-lock.yaml',
19
+ 'bun.lockb',
20
+ 'bun.lock',
21
+ ];
22
+ // Function to check if a directory is a monorepo root
23
+ // (package.json workspaces field, or pnpm-workspace.yaml)
24
+ function hasWorkspaces(dir) {
25
+ if (fs_1.default.existsSync(path_1.default.join(dir, 'pnpm-workspace.yaml'))) {
26
+ return true;
27
+ }
28
+ const pkgPath = path_1.default.join(dir, 'package.json');
29
+ if (fs_1.default.existsSync(pkgPath)) {
30
+ try {
31
+ const pkg = JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf-8'));
32
+ return !!pkg.workspaces;
33
+ }
34
+ catch (_e) {
35
+ // Ignore parsing errors
36
+ }
37
+ }
38
+ return false;
39
+ }
40
+ // Helper function to find lock files in a specific directory
41
+ function findLockFilesInDir(directory) {
42
+ const found = [];
43
+ for (const file of lockFiles) {
44
+ const filePath = path_1.default.join(directory, file);
45
+ if (fs_1.default.existsSync(filePath)) {
46
+ found.push(filePath);
47
+ }
48
+ }
49
+ return found;
50
+ }
51
+ function checkLockFiles() {
52
+ const cwd = process.cwd();
53
+ let searchDir = cwd;
54
+ let foundLockFiles = findLockFilesInDir(searchDir);
55
+ // If no lock file in cwd, try to find monorepo root and check there
56
+ if (foundLockFiles.length === 0) {
57
+ // Search upwards for package.json with workspaces
58
+ let currentDir = path_1.default.dirname(cwd); // Start searching from parent
59
+ let projectRootDir = null;
60
+ while (true) {
61
+ if (hasWorkspaces(currentDir)) {
62
+ projectRootDir = currentDir;
63
+ break;
64
+ }
65
+ const parentDir = path_1.default.dirname(currentDir);
66
+ if (parentDir === currentDir) {
67
+ // Reached the filesystem root
68
+ break;
69
+ }
70
+ currentDir = parentDir;
71
+ }
72
+ // If a potential root was found, switch search directory and re-check
73
+ if (projectRootDir) {
74
+ searchDir = projectRootDir;
75
+ foundLockFiles = findLockFilesInDir(searchDir);
76
+ }
77
+ // If no projectRootDir found, foundLockFiles remains empty and searchDir remains cwd
78
+ }
79
+ // Handle results based on findings in the final searchDir
80
+ if (foundLockFiles.length === 1) {
81
+ // Successfully found one lock file in the determined searchDir
82
+ return;
83
+ }
84
+ if (foundLockFiles.length > 1) {
85
+ // Found multiple lock files in the determined searchDir
86
+ console.warn((0, i18n_1.t)('lockBestPractice'));
87
+ throw new Error((0, i18n_1.t)('multipleLocksFound', { lockFiles: foundLockFiles.join(', ') }));
88
+ }
89
+ // If we reach here, foundLockFiles.length === 0
90
+ console.warn((0, i18n_1.t)('lockBestPractice'));
91
+ // Warn instead of throwing an error if no lock file is found
92
+ console.warn((0, i18n_1.t)('lockNotFound'));
93
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * [INPUT]: 依赖本地化文案与已登记的 CLI 插件配置
3
+ * [OUTPUT]: 对外提供 checkPlugins,校验插件组合并返回 bundle 参数
4
+ * [POS]: CLI 插件兼容性检查边界,连接配置声明与 bundle 编排,不执行插件安装
5
+ */
6
+ interface BundleParams {
7
+ sentry: boolean;
8
+ sourcemap: boolean;
9
+ [key: string]: any;
10
+ }
11
+ export declare function checkPlugins(): Promise<BundleParams>;
12
+ export {};
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ /**
3
+ * [INPUT]: 依赖本地化文案与已登记的 CLI 插件配置
4
+ * [OUTPUT]: 对外提供 checkPlugins,校验插件组合并返回 bundle 参数
5
+ * [POS]: CLI 插件兼容性检查边界,连接配置声明与 bundle 编排,不执行插件安装
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.checkPlugins = checkPlugins;
9
+ const i18n_1 = require("./i18n");
10
+ const plugin_config_1 = require("./plugin-config");
11
+ async function checkPlugins() {
12
+ const params = {
13
+ sentry: false,
14
+ sourcemap: false,
15
+ };
16
+ const results = await Promise.all(plugin_config_1.plugins.map(async (plugin) => {
17
+ try {
18
+ const isEnabled = await plugin.detect();
19
+ return { isEnabled, error: null };
20
+ }
21
+ catch (error) {
22
+ return { isEnabled: false, error };
23
+ }
24
+ }));
25
+ results.forEach(({ isEnabled, error }, index) => {
26
+ const plugin = plugin_config_1.plugins[index];
27
+ if (error) {
28
+ console.warn((0, i18n_1.t)('pluginDetectionError', { name: plugin.name, error }));
29
+ }
30
+ else if (isEnabled && plugin.bundleParams) {
31
+ Object.assign(params, plugin.bundleParams);
32
+ console.log((0, i18n_1.t)('pluginDetected', { name: plugin.name }));
33
+ }
34
+ });
35
+ return params;
36
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * [INPUT]: 依赖 CLI CommandResult 公共类型与未知错误值
3
+ * [OUTPUT]: 对外提供错误归一化与 runAsCommandResult,统一命令层结果形状
4
+ * [POS]: CLI 命令边界的错误适配器,隔离异常来源与顶层输出协议
5
+ */
6
+ import type { CommandResult } from '../types';
7
+ export declare function toErrorMessage(error: unknown, fallback: string): string;
8
+ export declare function runAsCommandResult<T>(task: () => Promise<T>, fallbackError: string, mapSuccess?: (result: T) => unknown): Promise<CommandResult>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ /**
3
+ * [INPUT]: 依赖 CLI CommandResult 公共类型与未知错误值
4
+ * [OUTPUT]: 对外提供错误归一化与 runAsCommandResult,统一命令层结果形状
5
+ * [POS]: CLI 命令边界的错误适配器,隔离异常来源与顶层输出协议
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.toErrorMessage = toErrorMessage;
9
+ exports.runAsCommandResult = runAsCommandResult;
10
+ function toErrorMessage(error, fallback) {
11
+ return error instanceof Error ? error.message : fallback;
12
+ }
13
+ async function runAsCommandResult(task, fallbackError, mapSuccess) {
14
+ try {
15
+ const result = await task();
16
+ return {
17
+ success: true,
18
+ data: mapSuccess ? mapSuccess(result) : result,
19
+ };
20
+ }
21
+ catch (error) {
22
+ return {
23
+ success: false,
24
+ error: toErrorMessage(error, fallbackError),
25
+ };
26
+ }
27
+ }
@@ -0,0 +1,10 @@
1
+ export declare const scriptName = "pakta";
2
+ export declare const ppkBundleFileNames: string[];
3
+ export declare const isPPKBundleFileName: (fileName: string) => boolean;
4
+ export declare const credentialFile = ".pakta.token";
5
+ /** Standalone service credentials never share a token across service URLs. */
6
+ export declare function credentialFileForService(serviceUrl?: string): string;
7
+ export declare const updateJson = "update.json";
8
+ export declare const tempDir = ".pakta";
9
+ export declare const pricingPageUrl = "https://pakta.dev/pricing";
10
+ export declare const defaultEndpoints: string[];
@@ -0,0 +1,39 @@
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.defaultEndpoints = exports.pricingPageUrl = exports.tempDir = exports.updateJson = exports.credentialFile = exports.isPPKBundleFileName = exports.ppkBundleFileNames = exports.scriptName = void 0;
7
+ exports.credentialFileForService = credentialFileForService;
8
+ /**
9
+ * [INPUT]: 依赖进程环境与操作系统用户目录
10
+ * [OUTPUT]: 对外提供品牌、默认端点、凭据文件和临时目录常量
11
+ * [POS]: CLI 全局常量层,确保不同独立服务地址的凭据不互相覆盖
12
+ */
13
+ const path_1 = __importDefault(require("path"));
14
+ const os_1 = __importDefault(require("os"));
15
+ const crypto_1 = require("crypto");
16
+ exports.scriptName = 'pakta';
17
+ exports.ppkBundleFileNames = ['index.bundlejs', 'bundle.harmony.js'];
18
+ const isPPKBundleFileName = (fileName) => exports.ppkBundleFileNames.includes(fileName);
19
+ exports.isPPKBundleFileName = isPPKBundleFileName;
20
+ exports.credentialFile = '.pakta.token';
21
+ /** Standalone service credentials never share a token across service URLs. */
22
+ function credentialFileForService(serviceUrl) {
23
+ const normalized = serviceUrl?.trim().replace(/\/+$/, '');
24
+ if (!normalized) {
25
+ return exports.credentialFile;
26
+ }
27
+ const suffix = (0, crypto_1.createHash)('sha256').update(normalized).digest('hex').slice(0, 16);
28
+ return path_1.default.join(os_1.default.homedir(), `.${exports.scriptName}-${suffix}.token`);
29
+ }
30
+ // update.json 是 CLI 与客户端 SDK 共同读取的应用配置入口。
31
+ exports.updateJson = 'update.json';
32
+ exports.tempDir = '.pakta';
33
+ exports.pricingPageUrl = 'https://pakta.dev/pricing';
34
+ exports.defaultEndpoints = [
35
+ 'https://api.pakta.dev',
36
+ 'https://api.pakta.app',
37
+ 'https://update.react-native.cn/api',
38
+ 'https://update.reactnative.cn/api',
39
+ ];
@@ -0,0 +1,20 @@
1
+ /**
2
+ * [INPUT]: 依赖项目 package.json、已安装依赖目录、文件系统与路径解析
3
+ * [OUTPUT]: 对外提供 getDepVersions、getDepVersion 与惰性 depVersions 代理
4
+ * [POS]: CLI 运行时版本信息边界,按需读取依赖版本并缓存,供诊断和命令编排消费
5
+ */
6
+ /** Installed versions of the cwd project's dependencies, keys sorted. */
7
+ export declare function getDepVersions(): Record<string, string>;
8
+ /**
9
+ * Installed version of one direct (dev)dependency of the cwd project, or
10
+ * undefined when the project does not declare it or it is not installed.
11
+ * Two file reads instead of one per dependency: the version banner printed
12
+ * before every command must not scale with the size of the project.
13
+ */
14
+ export declare function getDepVersion(name: string, cwd?: string): string | undefined;
15
+ /**
16
+ * Same data as `getDepVersions()` but as a lazily populated object, for the
17
+ * remaining property-access call sites (`depVersions['react-native']`).
18
+ * Nothing is resolved until the first property access.
19
+ */
20
+ export declare const depVersions: Record<string, string>;