react-native-update-cli 2.24.2 → 2.25.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/README.md +11 -4
- package/README.zh-CN.md +11 -4
- package/cli.json +7 -1
- package/lib/api.d.ts +2 -0
- package/lib/api.js +63 -18
- package/lib/app.js +25 -3
- package/lib/bin.js +39 -45
- package/lib/bundle-runner.d.ts +27 -0
- package/lib/bundle-runner.js +240 -21
- package/lib/bundle.d.ts +1 -1
- package/lib/bundle.js +19 -6
- package/lib/commands.d.ts +6 -0
- package/lib/commands.js +65 -0
- package/lib/locales/en.d.ts +5 -14
- package/lib/locales/en.js +5 -14
- package/lib/locales/zh.d.ts +5 -13
- package/lib/locales/zh.js +5 -13
- package/lib/package.js +4 -0
- package/lib/provider.d.ts +1 -1
- package/lib/provider.js +3 -1
- package/lib/symbolicate.js +7 -2
- package/lib/types.d.ts +1 -0
- package/lib/user.js +6 -0
- package/lib/utils/add-gitignore.js +7 -1
- package/lib/utils/dep-versions.d.ts +7 -0
- package/lib/utils/dep-versions.js +78 -26
- package/lib/utils/git.js +9 -6
- package/lib/utils/hermes-base.js +2 -1
- package/lib/utils/i18n.d.ts +5 -0
- package/lib/utils/i18n.js +14 -1
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +9 -4
- package/lib/utils/latest-version/index.js +8 -0
- package/lib/utils/runtime.d.ts +21 -0
- package/lib/utils/runtime.js +138 -5
- package/lib/utils/zip-range.js +3 -2
- package/lib/versions.js +7 -4
- package/package.json +4 -2
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -17
- package/src/api.ts +0 -470
- package/src/app.ts +0 -241
- package/src/auto-update.ts +0 -647
- package/src/bin-cresc.ts +0 -8
- package/src/bin.ts +0 -115
- package/src/bundle-pack.ts +0 -61
- package/src/bundle-runner.ts +0 -1430
- package/src/bundle.ts +0 -371
- package/src/cache.ts +0 -20
- package/src/diff.ts +0 -1010
- package/src/exports.ts +0 -17
- package/src/index.ts +0 -1
- package/src/install.ts +0 -50
- package/src/locales/en.ts +0 -257
- package/src/locales/zh.ts +0 -234
- package/src/native-package.ts +0 -338
- package/src/package.ts +0 -482
- package/src/provider.ts +0 -294
- package/src/symbolicate.ts +0 -164
- package/src/types.ts +0 -150
- package/src/user.ts +0 -39
- package/src/utils/add-gitignore.ts +0 -35
- package/src/utils/app-info-parser/aab.ts +0 -241
- package/src/utils/app-info-parser/apk.ts +0 -92
- package/src/utils/app-info-parser/app.ts +0 -7
- package/src/utils/app-info-parser/index.ts +0 -54
- package/src/utils/app-info-parser/ipa.ts +0 -109
- package/src/utils/app-info-parser/resource-finder.ts +0 -508
- package/src/utils/app-info-parser/utils.ts +0 -161
- package/src/utils/app-info-parser/xml-parser/binary.ts +0 -693
- package/src/utils/app-info-parser/xml-parser/manifest.ts +0 -228
- package/src/utils/app-info-parser/zip.ts +0 -108
- package/src/utils/check-lockfile.ts +0 -93
- package/src/utils/check-plugin.ts +0 -38
- package/src/utils/command-result.ts +0 -24
- package/src/utils/constants.ts +0 -25
- package/src/utils/dep-versions.ts +0 -83
- package/src/utils/git.ts +0 -71
- package/src/utils/hbcTransform.ts +0 -649
- package/src/utils/hermes-base.ts +0 -1137
- package/src/utils/http-helper.ts +0 -152
- package/src/utils/i18n.ts +0 -39
- package/src/utils/index.ts +0 -698
- package/src/utils/latest-version/index.ts +0 -573
- package/src/utils/options.ts +0 -78
- package/src/utils/plugin-config.ts +0 -32
- package/src/utils/runtime.ts +0 -187
- package/src/utils/slim-sourcemap.ts +0 -105
- package/src/utils/zip-entries.ts +0 -209
- package/src/utils/zip-options.ts +0 -178
- package/src/utils/zip-range.ts +0 -727
- package/src/utils/zip-raw-writer.ts +0 -247
- package/src/versions.ts +0 -892
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
// From https://github.com/openstf/adbkit-apkreader
|
|
2
|
-
import { BinaryXmlParser } from './binary';
|
|
3
|
-
|
|
4
|
-
const INTENT_MAIN = 'android.intent.action.MAIN';
|
|
5
|
-
const CATEGORY_LAUNCHER = 'android.intent.category.LAUNCHER';
|
|
6
|
-
|
|
7
|
-
export class ManifestParser {
|
|
8
|
-
private buffer: Buffer;
|
|
9
|
-
private xmlParser: BinaryXmlParser;
|
|
10
|
-
|
|
11
|
-
constructor(buffer: Buffer, options: Record<string, any> = {}) {
|
|
12
|
-
this.buffer = buffer;
|
|
13
|
-
this.xmlParser = new BinaryXmlParser(this.buffer, options);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
private collapseAttributes(element: any) {
|
|
17
|
-
const collapsed: Record<string, any> = Object.create(null);
|
|
18
|
-
const attributes = element.attributes as Array<{
|
|
19
|
-
name: string;
|
|
20
|
-
typedValue: { value: any };
|
|
21
|
-
}>;
|
|
22
|
-
for (let i = 0, len = attributes.length; i < len; i++) {
|
|
23
|
-
const attr = attributes[i];
|
|
24
|
-
collapsed[attr.name] = attr.typedValue.value;
|
|
25
|
-
}
|
|
26
|
-
return collapsed;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private parseIntents(element: any, target: any) {
|
|
30
|
-
target.intentFilters = [];
|
|
31
|
-
target.metaData = [];
|
|
32
|
-
|
|
33
|
-
for (const child of element.childNodes) {
|
|
34
|
-
switch (child.nodeName) {
|
|
35
|
-
case 'intent-filter': {
|
|
36
|
-
const intentFilter = this.collapseAttributes(child);
|
|
37
|
-
|
|
38
|
-
intentFilter.actions = [];
|
|
39
|
-
intentFilter.categories = [];
|
|
40
|
-
intentFilter.data = [];
|
|
41
|
-
|
|
42
|
-
for (const item of child.childNodes) {
|
|
43
|
-
switch (item.nodeName) {
|
|
44
|
-
case 'action':
|
|
45
|
-
intentFilter.actions.push(this.collapseAttributes(item));
|
|
46
|
-
break;
|
|
47
|
-
case 'category':
|
|
48
|
-
intentFilter.categories.push(this.collapseAttributes(item));
|
|
49
|
-
break;
|
|
50
|
-
case 'data':
|
|
51
|
-
intentFilter.data.push(this.collapseAttributes(item));
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
target.intentFilters.push(intentFilter);
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
case 'meta-data':
|
|
60
|
-
target.metaData.push(this.collapseAttributes(child));
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private parseApplication(element: any) {
|
|
67
|
-
const app = this.collapseAttributes(element);
|
|
68
|
-
|
|
69
|
-
app.activities = [];
|
|
70
|
-
app.activityAliases = [];
|
|
71
|
-
app.launcherActivities = [];
|
|
72
|
-
app.services = [];
|
|
73
|
-
app.receivers = [];
|
|
74
|
-
app.providers = [];
|
|
75
|
-
app.usesLibraries = [];
|
|
76
|
-
app.metaData = [];
|
|
77
|
-
|
|
78
|
-
for (const child of element.childNodes) {
|
|
79
|
-
switch (child.nodeName) {
|
|
80
|
-
case 'activity': {
|
|
81
|
-
const activity = this.collapseAttributes(child);
|
|
82
|
-
this.parseIntents(child, activity);
|
|
83
|
-
app.activities.push(activity);
|
|
84
|
-
if (this.isLauncherActivity(activity)) {
|
|
85
|
-
app.launcherActivities.push(activity);
|
|
86
|
-
}
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
case 'activity-alias': {
|
|
90
|
-
const activityAlias = this.collapseAttributes(child);
|
|
91
|
-
this.parseIntents(child, activityAlias);
|
|
92
|
-
app.activityAliases.push(activityAlias);
|
|
93
|
-
if (this.isLauncherActivity(activityAlias)) {
|
|
94
|
-
app.launcherActivities.push(activityAlias);
|
|
95
|
-
}
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
case 'service': {
|
|
99
|
-
const service = this.collapseAttributes(child);
|
|
100
|
-
this.parseIntents(child, service);
|
|
101
|
-
app.services.push(service);
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
case 'receiver': {
|
|
105
|
-
const receiver = this.collapseAttributes(child);
|
|
106
|
-
this.parseIntents(child, receiver);
|
|
107
|
-
app.receivers.push(receiver);
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
case 'provider': {
|
|
111
|
-
const provider = this.collapseAttributes(child);
|
|
112
|
-
|
|
113
|
-
provider.grantUriPermissions = [];
|
|
114
|
-
provider.metaData = [];
|
|
115
|
-
provider.pathPermissions = [];
|
|
116
|
-
|
|
117
|
-
for (const item of child.childNodes) {
|
|
118
|
-
switch (item.nodeName) {
|
|
119
|
-
case 'grant-uri-permission':
|
|
120
|
-
provider.grantUriPermissions.push(
|
|
121
|
-
this.collapseAttributes(item),
|
|
122
|
-
);
|
|
123
|
-
break;
|
|
124
|
-
case 'meta-data':
|
|
125
|
-
provider.metaData.push(this.collapseAttributes(item));
|
|
126
|
-
break;
|
|
127
|
-
case 'path-permission':
|
|
128
|
-
provider.pathPermissions.push(this.collapseAttributes(item));
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
app.providers.push(provider);
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
case 'uses-library':
|
|
137
|
-
app.usesLibraries.push(this.collapseAttributes(child));
|
|
138
|
-
break;
|
|
139
|
-
case 'meta-data':
|
|
140
|
-
app.metaData.push(this.collapseAttributes(child));
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return app;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
private isLauncherActivity(activity: any) {
|
|
149
|
-
return activity.intentFilters.some((filter: any) => {
|
|
150
|
-
const hasMain = filter.actions.some(
|
|
151
|
-
(action: any) => action.name === INTENT_MAIN,
|
|
152
|
-
);
|
|
153
|
-
if (!hasMain) {
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
return filter.categories.some(
|
|
157
|
-
(category: any) => category.name === CATEGORY_LAUNCHER,
|
|
158
|
-
);
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
parse() {
|
|
163
|
-
const document = this.xmlParser.parse();
|
|
164
|
-
const manifest = this.collapseAttributes(document);
|
|
165
|
-
|
|
166
|
-
manifest.usesPermissions = [];
|
|
167
|
-
manifest.usesPermissionsSDK23 = [];
|
|
168
|
-
manifest.permissions = [];
|
|
169
|
-
manifest.permissionTrees = [];
|
|
170
|
-
manifest.permissionGroups = [];
|
|
171
|
-
manifest.instrumentation = null;
|
|
172
|
-
manifest.usesSdk = null;
|
|
173
|
-
manifest.usesConfiguration = null;
|
|
174
|
-
manifest.usesFeatures = [];
|
|
175
|
-
manifest.supportsScreens = null;
|
|
176
|
-
manifest.compatibleScreens = [];
|
|
177
|
-
manifest.supportsGlTextures = [];
|
|
178
|
-
manifest.application = Object.create(null);
|
|
179
|
-
|
|
180
|
-
for (const element of document.childNodes) {
|
|
181
|
-
switch (element.nodeName) {
|
|
182
|
-
case 'uses-permission':
|
|
183
|
-
manifest.usesPermissions.push(this.collapseAttributes(element));
|
|
184
|
-
break;
|
|
185
|
-
case 'uses-permission-sdk-23':
|
|
186
|
-
manifest.usesPermissionsSDK23.push(this.collapseAttributes(element));
|
|
187
|
-
break;
|
|
188
|
-
case 'permission':
|
|
189
|
-
manifest.permissions.push(this.collapseAttributes(element));
|
|
190
|
-
break;
|
|
191
|
-
case 'permission-tree':
|
|
192
|
-
manifest.permissionTrees.push(this.collapseAttributes(element));
|
|
193
|
-
break;
|
|
194
|
-
case 'permission-group':
|
|
195
|
-
manifest.permissionGroups.push(this.collapseAttributes(element));
|
|
196
|
-
break;
|
|
197
|
-
case 'instrumentation':
|
|
198
|
-
manifest.instrumentation = this.collapseAttributes(element);
|
|
199
|
-
break;
|
|
200
|
-
case 'uses-sdk':
|
|
201
|
-
manifest.usesSdk = this.collapseAttributes(element);
|
|
202
|
-
break;
|
|
203
|
-
case 'uses-configuration':
|
|
204
|
-
manifest.usesConfiguration = this.collapseAttributes(element);
|
|
205
|
-
break;
|
|
206
|
-
case 'uses-feature':
|
|
207
|
-
manifest.usesFeatures.push(this.collapseAttributes(element));
|
|
208
|
-
break;
|
|
209
|
-
case 'supports-screens':
|
|
210
|
-
manifest.supportsScreens = this.collapseAttributes(element);
|
|
211
|
-
break;
|
|
212
|
-
case 'compatible-screens':
|
|
213
|
-
for (const screen of element.childNodes) {
|
|
214
|
-
manifest.compatibleScreens.push(this.collapseAttributes(screen));
|
|
215
|
-
}
|
|
216
|
-
break;
|
|
217
|
-
case 'supports-gl-texture':
|
|
218
|
-
manifest.supportsGlTextures.push(this.collapseAttributes(element));
|
|
219
|
-
break;
|
|
220
|
-
case 'application':
|
|
221
|
-
manifest.application = this.parseApplication(element);
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return manifest;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { enumZipEntries, readEntry } from '../zip-entries';
|
|
3
|
-
import { decodeNullUnicode } from './utils';
|
|
4
|
-
|
|
5
|
-
export class Zip {
|
|
6
|
-
file: string | File;
|
|
7
|
-
|
|
8
|
-
constructor(file: string | File) {
|
|
9
|
-
this.file = typeof file === 'string' ? path.resolve(file) : file;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* get entries by regexps, the return format is: { <filename>: <Buffer|Blob> }
|
|
14
|
-
* @param {Array} regexps // regexps for matching files
|
|
15
|
-
* @param {String} type // return type, can be buffer or blob, default buffer
|
|
16
|
-
*/
|
|
17
|
-
getEntries(
|
|
18
|
-
regexps: Array<RegExp | string>,
|
|
19
|
-
type: 'buffer' | 'blob' = 'buffer',
|
|
20
|
-
) {
|
|
21
|
-
const decoded = regexps.map((regex) => decodeNullUnicode(regex));
|
|
22
|
-
return this.readEntries(decoded, type);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* get entry by regex, return an instance of Buffer or Blob
|
|
27
|
-
* @param {Regex} regex // regex for matching file
|
|
28
|
-
* @param {String} type // return type, can be buffer or blob, default buffer
|
|
29
|
-
*/
|
|
30
|
-
getEntry(regex: RegExp | string, type: 'buffer' | 'blob' = 'buffer') {
|
|
31
|
-
const decoded = decodeNullUnicode(regex);
|
|
32
|
-
return this.readEntries([decoded], type).then(
|
|
33
|
-
(buffers) => buffers[decoded as any],
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async getEntryFromHarmonyApp(
|
|
38
|
-
regex: RegExp,
|
|
39
|
-
): Promise<Buffer | Blob | undefined> {
|
|
40
|
-
return (await this.getEntriesFromHarmonyApp([regex]))[0];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Read multiple entries in a single pass over the archive (including
|
|
45
|
-
* nested .hap extraction), instead of one full scan per entry.
|
|
46
|
-
* Returns buffers in the same order as the given regexps.
|
|
47
|
-
*/
|
|
48
|
-
async getEntriesFromHarmonyApp(
|
|
49
|
-
regexps: RegExp[],
|
|
50
|
-
): Promise<(Buffer | undefined)[]> {
|
|
51
|
-
const results: (Buffer | undefined)[] = new Array(regexps.length);
|
|
52
|
-
try {
|
|
53
|
-
if (typeof this.file !== 'string') {
|
|
54
|
-
throw new Error('Param error: [file] must be file path in Node.');
|
|
55
|
-
}
|
|
56
|
-
await enumZipEntries(this.file, async (entry, zipFile) => {
|
|
57
|
-
for (let i = 0; i < regexps.length; i++) {
|
|
58
|
-
if (regexps[i].test(entry.fileName)) {
|
|
59
|
-
results[i] = await readEntry(entry, zipFile);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
} catch (error) {
|
|
64
|
-
console.error('Error in getEntriesFromHarmonyApp:', error);
|
|
65
|
-
}
|
|
66
|
-
return results;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private async readEntries(
|
|
70
|
-
decoded: Array<RegExp | string>,
|
|
71
|
-
type: 'buffer' | 'blob',
|
|
72
|
-
): Promise<Record<string, Buffer | Blob>> {
|
|
73
|
-
if (typeof this.file !== 'string') {
|
|
74
|
-
throw new Error('Param error: [file] must be file path in Node.');
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const buffers: Record<string, Buffer | Blob> = {};
|
|
78
|
-
await enumZipEntries(this.file, async (entry, zipFile) => {
|
|
79
|
-
if (entry.fileName.endsWith('/')) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const entryName = decodeNullUnicode(entry.fileName).toString();
|
|
84
|
-
const lowerEntryName = entryName.toLowerCase();
|
|
85
|
-
const matched = decoded.find((pattern) => {
|
|
86
|
-
if (typeof pattern === 'string') {
|
|
87
|
-
return pattern === entryName || pattern === lowerEntryName;
|
|
88
|
-
}
|
|
89
|
-
pattern.lastIndex = 0;
|
|
90
|
-
if (pattern.test(entryName)) {
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
pattern.lastIndex = 0;
|
|
94
|
-
return pattern.test(lowerEntryName);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
if (!matched) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const buffer = await readEntry(entry, zipFile);
|
|
102
|
-
buffers[matched as any] =
|
|
103
|
-
type === 'blob' ? new Blob([buffer as any]) : buffer;
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
return buffers;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { t } from './i18n';
|
|
4
|
-
|
|
5
|
-
const lockFiles = [
|
|
6
|
-
'package-lock.json',
|
|
7
|
-
'yarn.lock',
|
|
8
|
-
'pnpm-lock.yaml',
|
|
9
|
-
'bun.lockb',
|
|
10
|
-
'bun.lock',
|
|
11
|
-
];
|
|
12
|
-
|
|
13
|
-
// Function to check if a directory is a monorepo root
|
|
14
|
-
// (package.json workspaces field, or pnpm-workspace.yaml)
|
|
15
|
-
function hasWorkspaces(dir: string): boolean {
|
|
16
|
-
if (fs.existsSync(path.join(dir, 'pnpm-workspace.yaml'))) {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
const pkgPath = path.join(dir, 'package.json');
|
|
20
|
-
if (fs.existsSync(pkgPath)) {
|
|
21
|
-
try {
|
|
22
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
23
|
-
return !!pkg.workspaces;
|
|
24
|
-
} catch (_e) {
|
|
25
|
-
// Ignore parsing errors
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Helper function to find lock files in a specific directory
|
|
32
|
-
function findLockFilesInDir(directory: string): string[] {
|
|
33
|
-
const found: string[] = [];
|
|
34
|
-
for (const file of lockFiles) {
|
|
35
|
-
const filePath = path.join(directory, file);
|
|
36
|
-
if (fs.existsSync(filePath)) {
|
|
37
|
-
found.push(filePath);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return found;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function checkLockFiles() {
|
|
44
|
-
const cwd = process.cwd();
|
|
45
|
-
let searchDir = cwd;
|
|
46
|
-
let foundLockFiles = findLockFilesInDir(searchDir);
|
|
47
|
-
|
|
48
|
-
// If no lock file in cwd, try to find monorepo root and check there
|
|
49
|
-
if (foundLockFiles.length === 0) {
|
|
50
|
-
// Search upwards for package.json with workspaces
|
|
51
|
-
let currentDir = path.dirname(cwd); // Start searching from parent
|
|
52
|
-
let projectRootDir: string | null = null;
|
|
53
|
-
|
|
54
|
-
while (true) {
|
|
55
|
-
if (hasWorkspaces(currentDir)) {
|
|
56
|
-
projectRootDir = currentDir;
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
const parentDir = path.dirname(currentDir);
|
|
60
|
-
if (parentDir === currentDir) {
|
|
61
|
-
// Reached the filesystem root
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
currentDir = parentDir;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// If a potential root was found, switch search directory and re-check
|
|
68
|
-
if (projectRootDir) {
|
|
69
|
-
searchDir = projectRootDir;
|
|
70
|
-
foundLockFiles = findLockFilesInDir(searchDir);
|
|
71
|
-
}
|
|
72
|
-
// If no projectRootDir found, foundLockFiles remains empty and searchDir remains cwd
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Handle results based on findings in the final searchDir
|
|
76
|
-
if (foundLockFiles.length === 1) {
|
|
77
|
-
// Successfully found one lock file in the determined searchDir
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (foundLockFiles.length > 1) {
|
|
82
|
-
// Found multiple lock files in the determined searchDir
|
|
83
|
-
console.warn(t('lockBestPractice'));
|
|
84
|
-
throw new Error(
|
|
85
|
-
t('multipleLocksFound', { lockFiles: foundLockFiles.join(', ') }),
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// If we reach here, foundLockFiles.length === 0
|
|
90
|
-
console.warn(t('lockBestPractice'));
|
|
91
|
-
// Warn instead of throwing an error if no lock file is found
|
|
92
|
-
console.warn(t('lockNotFound'));
|
|
93
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { t } from './i18n';
|
|
2
|
-
import { plugins } from './plugin-config';
|
|
3
|
-
|
|
4
|
-
interface BundleParams {
|
|
5
|
-
sentry: boolean;
|
|
6
|
-
sourcemap: boolean;
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export async function checkPlugins(): Promise<BundleParams> {
|
|
11
|
-
const params: BundleParams = {
|
|
12
|
-
sentry: false,
|
|
13
|
-
sourcemap: false,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const results = await Promise.all(
|
|
17
|
-
plugins.map(async (plugin) => {
|
|
18
|
-
try {
|
|
19
|
-
const isEnabled = await plugin.detect();
|
|
20
|
-
return { isEnabled, error: null };
|
|
21
|
-
} catch (error) {
|
|
22
|
-
return { isEnabled: false, error };
|
|
23
|
-
}
|
|
24
|
-
}),
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
results.forEach(({ isEnabled, error }, index) => {
|
|
28
|
-
const plugin = plugins[index];
|
|
29
|
-
if (error) {
|
|
30
|
-
console.warn(t('pluginDetectionError', { name: plugin.name, error }));
|
|
31
|
-
} else if (isEnabled && plugin.bundleParams) {
|
|
32
|
-
Object.assign(params, plugin.bundleParams);
|
|
33
|
-
console.log(t('pluginDetected', { name: plugin.name }));
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return params;
|
|
38
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { CommandResult } from '../types';
|
|
2
|
-
|
|
3
|
-
export function toErrorMessage(error: unknown, fallback: string): string {
|
|
4
|
-
return error instanceof Error ? error.message : fallback;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export async function runAsCommandResult<T>(
|
|
8
|
-
task: () => Promise<T>,
|
|
9
|
-
fallbackError: string,
|
|
10
|
-
mapSuccess?: (result: T) => unknown,
|
|
11
|
-
): Promise<CommandResult> {
|
|
12
|
-
try {
|
|
13
|
-
const result = await task();
|
|
14
|
-
return {
|
|
15
|
-
success: true,
|
|
16
|
-
data: mapSuccess ? mapSuccess(result) : result,
|
|
17
|
-
};
|
|
18
|
-
} catch (error) {
|
|
19
|
-
return {
|
|
20
|
-
success: false,
|
|
21
|
-
error: toErrorMessage(error, fallbackError),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
package/src/utils/constants.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
|
|
3
|
-
export const scriptName =
|
|
4
|
-
process.env.RNU_BRAND === 'cresc' ||
|
|
5
|
-
path.basename(process.argv[1] ?? '') === 'cresc'
|
|
6
|
-
? 'cresc'
|
|
7
|
-
: 'pushy';
|
|
8
|
-
export const IS_CRESC = scriptName === 'cresc';
|
|
9
|
-
|
|
10
|
-
export const ppkBundleFileNames = ['index.bundlejs', 'bundle.harmony.js'];
|
|
11
|
-
export const isPPKBundleFileName = (fileName: string) =>
|
|
12
|
-
ppkBundleFileNames.includes(fileName);
|
|
13
|
-
|
|
14
|
-
export const credentialFile = IS_CRESC ? '.cresc.token' : '.update';
|
|
15
|
-
// Both brands select apps in update.json: the cresc docs and the client SDK
|
|
16
|
-
// (`import _updateConfig from './update.json'`) read that name too.
|
|
17
|
-
export const updateJson = 'update.json';
|
|
18
|
-
export const tempDir = IS_CRESC ? '.cresc.temp' : '.pushy';
|
|
19
|
-
export const pricingPageUrl = IS_CRESC
|
|
20
|
-
? 'https://cresc.dev/pricing'
|
|
21
|
-
: 'https://pushy.reactnative.cn/pricing.html';
|
|
22
|
-
|
|
23
|
-
export const defaultEndpoints = IS_CRESC
|
|
24
|
-
? ['https://api.cresc.dev', 'https://api.cresc.app']
|
|
25
|
-
: ['https://update.reactnative.cn/api', 'https://update.react-native.cn/api'];
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
// Installed versions of every dependency/devDependency of the project in cwd.
|
|
2
|
-
// Resolving them means reading one package.json per dependency, so this is
|
|
3
|
-
// done lazily (on first use) and memoized rather than at import time, which
|
|
4
|
-
// used to cost every command ~3-30 ms before it even parsed its arguments.
|
|
5
|
-
|
|
6
|
-
let cached: Record<string, string> | undefined;
|
|
7
|
-
|
|
8
|
-
function readDepVersions(): Record<string, string> {
|
|
9
|
-
let currentPackage: {
|
|
10
|
-
dependencies?: Record<string, string>;
|
|
11
|
-
devDependencies?: Record<string, string>;
|
|
12
|
-
} | null = null;
|
|
13
|
-
try {
|
|
14
|
-
currentPackage = require(`${process.cwd()}/package.json`);
|
|
15
|
-
} catch (_e) {
|
|
16
|
-
// console.warn('No package.json file were found');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const versions: Record<string, string> = {};
|
|
20
|
-
if (currentPackage) {
|
|
21
|
-
const depKeys = currentPackage.dependencies
|
|
22
|
-
? Object.keys(currentPackage.dependencies)
|
|
23
|
-
: [];
|
|
24
|
-
const devDepKeys = currentPackage.devDependencies
|
|
25
|
-
? Object.keys(currentPackage.devDependencies)
|
|
26
|
-
: [];
|
|
27
|
-
const dedupedDeps = [...new Set([...depKeys, ...devDepKeys])];
|
|
28
|
-
|
|
29
|
-
for (const dep of dedupedDeps) {
|
|
30
|
-
try {
|
|
31
|
-
const packageJsonPath = require.resolve(`${dep}/package.json`, {
|
|
32
|
-
paths: [process.cwd()],
|
|
33
|
-
});
|
|
34
|
-
versions[dep] = require(packageJsonPath).version;
|
|
35
|
-
} catch (_e) {}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// sorted keys: the object is sent to the server as-is and diffed
|
|
40
|
-
return Object.keys(versions)
|
|
41
|
-
.sort()
|
|
42
|
-
.reduce(
|
|
43
|
-
(obj, key) => {
|
|
44
|
-
obj[key] = versions[key];
|
|
45
|
-
return obj;
|
|
46
|
-
},
|
|
47
|
-
{} as Record<string, string>,
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** Installed versions of the cwd project's dependencies, keys sorted. */
|
|
52
|
-
export function getDepVersions(): Record<string, string> {
|
|
53
|
-
if (!cached) {
|
|
54
|
-
cached = readDepVersions();
|
|
55
|
-
}
|
|
56
|
-
return cached;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Same data as `getDepVersions()` but as a lazily populated object, for the
|
|
61
|
-
* remaining property-access call sites (`depVersions['react-native']`).
|
|
62
|
-
* Nothing is resolved until the first property access.
|
|
63
|
-
*/
|
|
64
|
-
export const depVersions: Record<string, string> = new Proxy(
|
|
65
|
-
{} as Record<string, string>,
|
|
66
|
-
{
|
|
67
|
-
get: (_target, key) =>
|
|
68
|
-
typeof key === 'string' ? getDepVersions()[key] : undefined,
|
|
69
|
-
has: (_target, key) => typeof key === 'string' && key in getDepVersions(),
|
|
70
|
-
ownKeys: () => Object.keys(getDepVersions()),
|
|
71
|
-
getOwnPropertyDescriptor: (_target, key) => {
|
|
72
|
-
if (typeof key !== 'string' || !(key in getDepVersions())) {
|
|
73
|
-
return undefined;
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
value: getDepVersions()[key],
|
|
77
|
-
writable: false,
|
|
78
|
-
enumerable: true,
|
|
79
|
-
configurable: true,
|
|
80
|
-
};
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
);
|
package/src/utils/git.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { execFile as execFileCallback, spawnSync } from 'child_process';
|
|
2
|
-
import { promisify } from 'util';
|
|
3
|
-
|
|
4
|
-
export interface CommitInfo {
|
|
5
|
-
hash: string;
|
|
6
|
-
message: string;
|
|
7
|
-
author: string;
|
|
8
|
-
timestamp: string;
|
|
9
|
-
origin?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const execFile = promisify(execFileCallback);
|
|
13
|
-
|
|
14
|
-
export function getCurrentCommit() {
|
|
15
|
-
const result = spawnSync('git', ['rev-parse', 'HEAD']);
|
|
16
|
-
if (result.status !== 0) {
|
|
17
|
-
throw new Error('Not a git repository');
|
|
18
|
-
}
|
|
19
|
-
return result.stdout.toString().trim();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async function gitOutput(args: string[], cwd = process.cwd()): Promise<string> {
|
|
23
|
-
const { stdout } = await execFile('git', args, {
|
|
24
|
-
cwd,
|
|
25
|
-
encoding: 'utf8',
|
|
26
|
-
windowsHide: true,
|
|
27
|
-
});
|
|
28
|
-
return stdout.trimEnd();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async function getRemoteOrigin(cwd: string) {
|
|
32
|
-
const origin = await gitOutput(['remote', 'get-url', 'origin'], cwd).catch(
|
|
33
|
-
() => '',
|
|
34
|
-
);
|
|
35
|
-
if (origin) {
|
|
36
|
-
return origin;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const remotes = await gitOutput(['remote'], cwd).catch(() => '');
|
|
40
|
-
const firstRemote = remotes.split(/\r?\n/).find(Boolean);
|
|
41
|
-
if (!firstRemote) {
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return gitOutput(['remote', 'get-url', firstRemote], cwd).catch(
|
|
46
|
-
() => undefined,
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export async function getCommitInfo(): Promise<CommitInfo | undefined> {
|
|
51
|
-
try {
|
|
52
|
-
const gitRoot = await gitOutput(['rev-parse', '--show-toplevel']);
|
|
53
|
-
const [hash, message, author, timestamp, origin] = await Promise.all([
|
|
54
|
-
gitOutput(['rev-parse', 'HEAD'], gitRoot),
|
|
55
|
-
gitOutput(['log', '-1', '--format=%B'], gitRoot),
|
|
56
|
-
gitOutput(['log', '-1', '--format=%an'], gitRoot),
|
|
57
|
-
gitOutput(['log', '-1', '--format=%ct'], gitRoot),
|
|
58
|
-
getRemoteOrigin(gitRoot),
|
|
59
|
-
]);
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
hash,
|
|
63
|
-
message,
|
|
64
|
-
author,
|
|
65
|
-
timestamp,
|
|
66
|
-
origin,
|
|
67
|
-
};
|
|
68
|
-
} catch (_error) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
}
|