react-native-update-cli 2.18.0 → 2.20.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/lib/api.d.ts +1 -1
- package/lib/api.js +143 -134
- package/lib/app.d.ts +2 -2
- package/lib/app.js +60 -107
- package/lib/bin.js +38 -35
- package/lib/bundle-pack.js +57 -77
- package/lib/bundle-runner.js +249 -312
- package/lib/bundle.js +71 -89
- package/lib/diff.js +190 -240
- package/lib/exports.js +14 -37
- package/lib/index.js +16 -17
- package/lib/install.js +24 -37
- package/lib/locales/en.js +3 -11
- package/lib/locales/zh.js +3 -11
- package/lib/native-package.d.ts +17 -0
- package/lib/native-package.js +232 -0
- package/lib/package.js +180 -225
- package/lib/provider.js +85 -107
- package/lib/types.js +1 -3
- package/lib/user.d.ts +1 -1
- package/lib/user.js +26 -39
- package/lib/utils/add-gitignore.js +16 -29
- package/lib/utils/app-info-parser/aab.js +133 -157
- package/lib/utils/app-info-parser/apk.js +42 -39
- package/lib/utils/app-info-parser/app.js +5 -11
- package/lib/utils/app-info-parser/index.js +21 -31
- package/lib/utils/app-info-parser/ipa.js +35 -35
- package/lib/utils/app-info-parser/resource-finder.js +84 -71
- package/lib/utils/app-info-parser/utils.js +52 -77
- package/lib/utils/app-info-parser/xml-parser/binary.js +82 -90
- package/lib/utils/app-info-parser/xml-parser/manifest.js +88 -98
- package/lib/utils/app-info-parser/zip.js +43 -51
- package/lib/utils/check-lockfile.js +28 -37
- package/lib/utils/check-plugin.js +16 -32
- package/lib/utils/command-result.js +7 -20
- package/lib/utils/constants.js +23 -63
- package/lib/utils/dep-versions.js +21 -27
- package/lib/utils/git.js +20 -64
- package/lib/utils/hbcTransform.js +133 -246
- package/lib/utils/http-helper.js +33 -44
- package/lib/utils/i18n.js +17 -26
- package/lib/utils/index.js +137 -179
- package/lib/utils/latest-version/index.js +128 -137
- package/lib/utils/options.js +13 -34
- package/lib/utils/plugin-config.js +43 -56
- package/lib/utils/runtime.js +50 -108
- package/lib/utils/zip-entries.js +70 -97
- package/lib/utils/zip-options.js +80 -181
- package/lib/versions.js +231 -265
- package/package.json +19 -21
- package/src/api.ts +47 -3
- package/src/diff.ts +12 -20
- package/src/native-package.ts +248 -0
- package/src/package.ts +29 -19
- package/src/user.ts +1 -1
- package/src/versions.ts +1 -1
|
@@ -1,63 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
11
|
-
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
12
|
-
const _zipentries = require("../zip-entries");
|
|
13
|
-
const _utils = require("./utils");
|
|
14
|
-
function _interop_require_default(obj) {
|
|
15
|
-
return obj && obj.__esModule ? obj : {
|
|
16
|
-
default: obj
|
|
17
|
-
};
|
|
18
|
-
}
|
|
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.Zip = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const zip_entries_1 = require("../zip-entries");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
19
10
|
class Zip {
|
|
11
|
+
file;
|
|
12
|
+
constructor(file) {
|
|
13
|
+
this.file = typeof file === 'string' ? path_1.default.resolve(file) : file;
|
|
14
|
+
}
|
|
20
15
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
* get entries by regexps, the return format is: { <filename>: <Buffer|Blob> }
|
|
17
|
+
* @param {Array} regexps // regexps for matching files
|
|
18
|
+
* @param {String} type // return type, can be buffer or blob, default buffer
|
|
19
|
+
*/
|
|
20
|
+
getEntries(regexps, type = 'buffer') {
|
|
21
|
+
const decoded = regexps.map((regex) => (0, utils_1.decodeNullUnicode)(regex));
|
|
26
22
|
return this.readEntries(decoded, type);
|
|
27
23
|
}
|
|
28
24
|
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
], type).then((buffers)=>buffers[decoded]);
|
|
25
|
+
* get entry by regex, return an instance of Buffer or Blob
|
|
26
|
+
* @param {Regex} regex // regex for matching file
|
|
27
|
+
* @param {String} type // return type, can be buffer or blob, default buffer
|
|
28
|
+
*/
|
|
29
|
+
getEntry(regex, type = 'buffer') {
|
|
30
|
+
const decoded = (0, utils_1.decodeNullUnicode)(regex);
|
|
31
|
+
return this.readEntries([decoded], type).then((buffers) => buffers[decoded]);
|
|
37
32
|
}
|
|
38
33
|
async getEntryFromHarmonyApp(regex) {
|
|
39
|
-
return (await this.getEntriesFromHarmonyApp([
|
|
40
|
-
regex
|
|
41
|
-
]))[0];
|
|
34
|
+
return (await this.getEntriesFromHarmonyApp([regex]))[0];
|
|
42
35
|
}
|
|
43
36
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
* Read multiple entries in a single pass over the archive (including
|
|
38
|
+
* nested .hap extraction), instead of one full scan per entry.
|
|
39
|
+
* Returns buffers in the same order as the given regexps.
|
|
40
|
+
*/
|
|
41
|
+
async getEntriesFromHarmonyApp(regexps) {
|
|
48
42
|
const results = new Array(regexps.length);
|
|
49
43
|
try {
|
|
50
44
|
if (typeof this.file !== 'string') {
|
|
51
45
|
throw new Error('Param error: [file] must be file path in Node.');
|
|
52
46
|
}
|
|
53
|
-
await (0,
|
|
54
|
-
for(let i = 0; i < regexps.length; i++){
|
|
47
|
+
await (0, zip_entries_1.enumZipEntries)(this.file, async (entry, zipFile) => {
|
|
48
|
+
for (let i = 0; i < regexps.length; i++) {
|
|
55
49
|
if (regexps[i].test(entry.fileName)) {
|
|
56
|
-
results[i] = await (0,
|
|
50
|
+
results[i] = await (0, zip_entries_1.readEntry)(entry, zipFile);
|
|
57
51
|
}
|
|
58
52
|
}
|
|
59
53
|
});
|
|
60
|
-
}
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
61
56
|
console.error('Error in getEntriesFromHarmonyApp:', error);
|
|
62
57
|
}
|
|
63
58
|
return results;
|
|
@@ -67,13 +62,13 @@ class Zip {
|
|
|
67
62
|
throw new Error('Param error: [file] must be file path in Node.');
|
|
68
63
|
}
|
|
69
64
|
const buffers = {};
|
|
70
|
-
await (0,
|
|
65
|
+
await (0, zip_entries_1.enumZipEntries)(this.file, async (entry, zipFile) => {
|
|
71
66
|
if (entry.fileName.endsWith('/')) {
|
|
72
67
|
return;
|
|
73
68
|
}
|
|
74
|
-
const entryName = (0,
|
|
69
|
+
const entryName = (0, utils_1.decodeNullUnicode)(entry.fileName).toString();
|
|
75
70
|
const lowerEntryName = entryName.toLowerCase();
|
|
76
|
-
const matched = decoded.find((pattern)=>{
|
|
71
|
+
const matched = decoded.find((pattern) => {
|
|
77
72
|
if (typeof pattern === 'string') {
|
|
78
73
|
return pattern === entryName || pattern === lowerEntryName;
|
|
79
74
|
}
|
|
@@ -87,14 +82,11 @@ class Zip {
|
|
|
87
82
|
if (!matched) {
|
|
88
83
|
return;
|
|
89
84
|
}
|
|
90
|
-
const buffer = await (0,
|
|
91
|
-
buffers[matched] =
|
|
92
|
-
buffer
|
|
93
|
-
]) : buffer;
|
|
85
|
+
const buffer = await (0, zip_entries_1.readEntry)(entry, zipFile);
|
|
86
|
+
buffers[matched] =
|
|
87
|
+
type === 'blob' ? new Blob([buffer]) : buffer;
|
|
94
88
|
});
|
|
95
89
|
return buffers;
|
|
96
90
|
}
|
|
97
|
-
constructor(file){
|
|
98
|
-
this.file = typeof file === 'string' ? _path.default.resolve(file) : file;
|
|
99
|
-
}
|
|
100
91
|
}
|
|
92
|
+
exports.Zip = Zip;
|
|
@@ -1,41 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
11
|
-
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
-
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
|
-
const _i18n = require("./i18n");
|
|
14
|
-
function _interop_require_default(obj) {
|
|
15
|
-
return obj && obj.__esModule ? obj : {
|
|
16
|
-
default: obj
|
|
17
|
-
};
|
|
18
|
-
}
|
|
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.checkLockFiles = checkLockFiles;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const i18n_1 = require("./i18n");
|
|
19
10
|
const lockFiles = [
|
|
20
11
|
'package-lock.json',
|
|
21
12
|
'yarn.lock',
|
|
22
13
|
'pnpm-lock.yaml',
|
|
23
14
|
'bun.lockb',
|
|
24
|
-
'bun.lock'
|
|
15
|
+
'bun.lock',
|
|
25
16
|
];
|
|
26
17
|
// Function to check if a directory is a monorepo root
|
|
27
18
|
// (package.json workspaces field, or pnpm-workspace.yaml)
|
|
28
19
|
function hasWorkspaces(dir) {
|
|
29
|
-
if (
|
|
20
|
+
if (fs_1.default.existsSync(path_1.default.join(dir, 'pnpm-workspace.yaml'))) {
|
|
30
21
|
return true;
|
|
31
22
|
}
|
|
32
|
-
const pkgPath =
|
|
33
|
-
if (
|
|
23
|
+
const pkgPath = path_1.default.join(dir, 'package.json');
|
|
24
|
+
if (fs_1.default.existsSync(pkgPath)) {
|
|
34
25
|
try {
|
|
35
|
-
const pkg = JSON.parse(
|
|
26
|
+
const pkg = JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf-8'));
|
|
36
27
|
return !!pkg.workspaces;
|
|
37
|
-
}
|
|
38
|
-
|
|
28
|
+
}
|
|
29
|
+
catch (_e) {
|
|
30
|
+
// Ignore parsing errors
|
|
39
31
|
}
|
|
40
32
|
}
|
|
41
33
|
return false;
|
|
@@ -43,9 +35,9 @@ function hasWorkspaces(dir) {
|
|
|
43
35
|
// Helper function to find lock files in a specific directory
|
|
44
36
|
function findLockFilesInDir(directory) {
|
|
45
37
|
const found = [];
|
|
46
|
-
for (const file of lockFiles){
|
|
47
|
-
const filePath =
|
|
48
|
-
if (
|
|
38
|
+
for (const file of lockFiles) {
|
|
39
|
+
const filePath = path_1.default.join(directory, file);
|
|
40
|
+
if (fs_1.default.existsSync(filePath)) {
|
|
49
41
|
found.push(filePath);
|
|
50
42
|
}
|
|
51
43
|
}
|
|
@@ -58,15 +50,16 @@ function checkLockFiles() {
|
|
|
58
50
|
// If no lock file in cwd, try to find monorepo root and check there
|
|
59
51
|
if (foundLockFiles.length === 0) {
|
|
60
52
|
// Search upwards for package.json with workspaces
|
|
61
|
-
let currentDir =
|
|
53
|
+
let currentDir = path_1.default.dirname(cwd); // Start searching from parent
|
|
62
54
|
let projectRootDir = null;
|
|
63
|
-
while(true){
|
|
55
|
+
while (true) {
|
|
64
56
|
if (hasWorkspaces(currentDir)) {
|
|
65
57
|
projectRootDir = currentDir;
|
|
66
58
|
break;
|
|
67
59
|
}
|
|
68
|
-
const parentDir =
|
|
60
|
+
const parentDir = path_1.default.dirname(currentDir);
|
|
69
61
|
if (parentDir === currentDir) {
|
|
62
|
+
// Reached the filesystem root
|
|
70
63
|
break;
|
|
71
64
|
}
|
|
72
65
|
currentDir = parentDir;
|
|
@@ -76,7 +69,7 @@ function checkLockFiles() {
|
|
|
76
69
|
searchDir = projectRootDir;
|
|
77
70
|
foundLockFiles = findLockFilesInDir(searchDir);
|
|
78
71
|
}
|
|
79
|
-
|
|
72
|
+
// If no projectRootDir found, foundLockFiles remains empty and searchDir remains cwd
|
|
80
73
|
}
|
|
81
74
|
// Handle results based on findings in the final searchDir
|
|
82
75
|
if (foundLockFiles.length === 1) {
|
|
@@ -85,13 +78,11 @@ function checkLockFiles() {
|
|
|
85
78
|
}
|
|
86
79
|
if (foundLockFiles.length > 1) {
|
|
87
80
|
// Found multiple lock files in the determined searchDir
|
|
88
|
-
console.warn((0,
|
|
89
|
-
throw new Error((0,
|
|
90
|
-
lockFiles: foundLockFiles.join(', ')
|
|
91
|
-
}));
|
|
81
|
+
console.warn((0, i18n_1.t)('lockBestPractice'));
|
|
82
|
+
throw new Error((0, i18n_1.t)('multipleLocksFound', { lockFiles: foundLockFiles.join(', ') }));
|
|
92
83
|
}
|
|
93
84
|
// If we reach here, foundLockFiles.length === 0
|
|
94
|
-
console.warn((0,
|
|
85
|
+
console.warn((0, i18n_1.t)('lockBestPractice'));
|
|
95
86
|
// Warn instead of throwing an error if no lock file is found
|
|
96
|
-
console.warn((0,
|
|
87
|
+
console.warn((0, i18n_1.t)('lockNotFound'));
|
|
97
88
|
}
|
|
@@ -1,46 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return checkPlugins;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _i18n = require("./i18n");
|
|
12
|
-
const _pluginconfig = require("./plugin-config");
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkPlugins = checkPlugins;
|
|
4
|
+
const i18n_1 = require("./i18n");
|
|
5
|
+
const plugin_config_1 = require("./plugin-config");
|
|
13
6
|
async function checkPlugins() {
|
|
14
7
|
const params = {
|
|
15
8
|
sentry: false,
|
|
16
|
-
sourcemap: false
|
|
9
|
+
sourcemap: false,
|
|
17
10
|
};
|
|
18
|
-
const results = await Promise.all(
|
|
11
|
+
const results = await Promise.all(plugin_config_1.plugins.map(async (plugin) => {
|
|
19
12
|
try {
|
|
20
13
|
const isEnabled = await plugin.detect();
|
|
21
|
-
return {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
} catch (error) {
|
|
26
|
-
return {
|
|
27
|
-
isEnabled: false,
|
|
28
|
-
error
|
|
29
|
-
};
|
|
14
|
+
return { isEnabled, error: null };
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
return { isEnabled: false, error };
|
|
30
18
|
}
|
|
31
19
|
}));
|
|
32
|
-
results.forEach(({ isEnabled, error }, index)=>{
|
|
33
|
-
const plugin =
|
|
20
|
+
results.forEach(({ isEnabled, error }, index) => {
|
|
21
|
+
const plugin = plugin_config_1.plugins[index];
|
|
34
22
|
if (error) {
|
|
35
|
-
console.warn((0,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}));
|
|
39
|
-
} else if (isEnabled && plugin.bundleParams) {
|
|
23
|
+
console.warn((0, i18n_1.t)('pluginDetectionError', { name: plugin.name, error }));
|
|
24
|
+
}
|
|
25
|
+
else if (isEnabled && plugin.bundleParams) {
|
|
40
26
|
Object.assign(params, plugin.bundleParams);
|
|
41
|
-
console.log((0,
|
|
42
|
-
name: plugin.name
|
|
43
|
-
}));
|
|
27
|
+
console.log((0, i18n_1.t)('pluginDetected', { name: plugin.name }));
|
|
44
28
|
}
|
|
45
29
|
});
|
|
46
30
|
return params;
|
|
@@ -1,21 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
get runAsCommandResult () {
|
|
13
|
-
return runAsCommandResult;
|
|
14
|
-
},
|
|
15
|
-
get toErrorMessage () {
|
|
16
|
-
return toErrorMessage;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toErrorMessage = toErrorMessage;
|
|
4
|
+
exports.runAsCommandResult = runAsCommandResult;
|
|
19
5
|
function toErrorMessage(error, fallback) {
|
|
20
6
|
return error instanceof Error ? error.message : fallback;
|
|
21
7
|
}
|
|
@@ -24,12 +10,13 @@ async function runAsCommandResult(task, fallbackError, mapSuccess) {
|
|
|
24
10
|
const result = await task();
|
|
25
11
|
return {
|
|
26
12
|
success: true,
|
|
27
|
-
data: mapSuccess ? mapSuccess(result) : result
|
|
13
|
+
data: mapSuccess ? mapSuccess(result) : result,
|
|
28
14
|
};
|
|
29
|
-
}
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
30
17
|
return {
|
|
31
18
|
success: false,
|
|
32
|
-
error: toErrorMessage(error, fallbackError)
|
|
19
|
+
error: toErrorMessage(error, fallbackError),
|
|
33
20
|
};
|
|
34
21
|
}
|
|
35
22
|
}
|
package/lib/utils/constants.js
CHANGED
|
@@ -1,64 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return ppkBundleFileNames;
|
|
26
|
-
},
|
|
27
|
-
get pricingPageUrl () {
|
|
28
|
-
return pricingPageUrl;
|
|
29
|
-
},
|
|
30
|
-
get scriptName () {
|
|
31
|
-
return scriptName;
|
|
32
|
-
},
|
|
33
|
-
get tempDir () {
|
|
34
|
-
return tempDir;
|
|
35
|
-
},
|
|
36
|
-
get updateJson () {
|
|
37
|
-
return updateJson;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
41
|
-
function _interop_require_default(obj) {
|
|
42
|
-
return obj && obj.__esModule ? obj : {
|
|
43
|
-
default: obj
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
var _process_argv_;
|
|
47
|
-
const scriptName = process.env.RNU_BRAND === 'cresc' || _path.default.basename((_process_argv_ = process.argv[1]) != null ? _process_argv_ : '') === 'cresc' ? 'cresc' : 'pushy';
|
|
48
|
-
const IS_CRESC = scriptName === 'cresc';
|
|
49
|
-
const ppkBundleFileNames = [
|
|
50
|
-
'index.bundlejs',
|
|
51
|
-
'bundle.harmony.js'
|
|
52
|
-
];
|
|
53
|
-
const isPPKBundleFileName = (fileName)=>ppkBundleFileNames.includes(fileName);
|
|
54
|
-
const credentialFile = IS_CRESC ? '.cresc.token' : '.update';
|
|
55
|
-
const updateJson = IS_CRESC ? 'cresc.config.json' : 'update.json';
|
|
56
|
-
const tempDir = IS_CRESC ? '.cresc.temp' : '.pushy';
|
|
57
|
-
const pricingPageUrl = IS_CRESC ? 'https://cresc.dev/pricing' : 'https://pushy.reactnative.cn/pricing.html';
|
|
58
|
-
const defaultEndpoints = IS_CRESC ? [
|
|
59
|
-
'https://api.cresc.dev',
|
|
60
|
-
'https://api.cresc.app'
|
|
61
|
-
] : [
|
|
62
|
-
'https://update.reactnative.cn/api',
|
|
63
|
-
'https://update.react-native.cn/api'
|
|
64
|
-
];
|
|
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.IS_CRESC = exports.scriptName = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
exports.scriptName = process.env.RNU_BRAND === 'cresc' ||
|
|
9
|
+
path_1.default.basename(process.argv[1] ?? '') === 'cresc'
|
|
10
|
+
? 'cresc'
|
|
11
|
+
: 'pushy';
|
|
12
|
+
exports.IS_CRESC = exports.scriptName === 'cresc';
|
|
13
|
+
exports.ppkBundleFileNames = ['index.bundlejs', 'bundle.harmony.js'];
|
|
14
|
+
const isPPKBundleFileName = (fileName) => exports.ppkBundleFileNames.includes(fileName);
|
|
15
|
+
exports.isPPKBundleFileName = isPPKBundleFileName;
|
|
16
|
+
exports.credentialFile = exports.IS_CRESC ? '.cresc.token' : '.update';
|
|
17
|
+
exports.updateJson = exports.IS_CRESC ? 'cresc.config.json' : 'update.json';
|
|
18
|
+
exports.tempDir = exports.IS_CRESC ? '.cresc.temp' : '.pushy';
|
|
19
|
+
exports.pricingPageUrl = exports.IS_CRESC
|
|
20
|
+
? 'https://cresc.dev/pricing'
|
|
21
|
+
: 'https://pushy.reactnative.cn/pricing.html';
|
|
22
|
+
exports.defaultEndpoints = exports.IS_CRESC
|
|
23
|
+
? ['https://api.cresc.dev', 'https://api.cresc.app']
|
|
24
|
+
: ['https://update.reactnative.cn/api', 'https://update.react-native.cn/api'];
|
|
@@ -1,43 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "depVersions", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return depVersions;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.depVersions = void 0;
|
|
11
4
|
let currentPackage = null;
|
|
12
5
|
try {
|
|
13
6
|
currentPackage = require(`${process.cwd()}/package.json`);
|
|
14
|
-
}
|
|
15
|
-
|
|
7
|
+
}
|
|
8
|
+
catch (_e) {
|
|
9
|
+
// console.warn('No package.json file were found');
|
|
16
10
|
}
|
|
17
11
|
const _depVersions = {};
|
|
18
12
|
if (currentPackage) {
|
|
19
|
-
const depKeys = currentPackage.dependencies
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
for (const dep of dedupedDeps){
|
|
13
|
+
const depKeys = currentPackage.dependencies
|
|
14
|
+
? Object.keys(currentPackage.dependencies)
|
|
15
|
+
: [];
|
|
16
|
+
const devDepKeys = currentPackage.devDependencies
|
|
17
|
+
? Object.keys(currentPackage.devDependencies)
|
|
18
|
+
: [];
|
|
19
|
+
const dedupedDeps = [...new Set([...depKeys, ...devDepKeys])];
|
|
20
|
+
for (const dep of dedupedDeps) {
|
|
28
21
|
try {
|
|
29
22
|
const packageJsonPath = require.resolve(`${dep}/package.json`, {
|
|
30
|
-
paths: [
|
|
31
|
-
process.cwd()
|
|
32
|
-
]
|
|
23
|
+
paths: [process.cwd()],
|
|
33
24
|
});
|
|
34
25
|
const version = require(packageJsonPath).version;
|
|
35
26
|
_depVersions[dep] = version;
|
|
36
|
-
}
|
|
27
|
+
}
|
|
28
|
+
catch (_e) { }
|
|
37
29
|
}
|
|
38
30
|
}
|
|
39
|
-
|
|
40
|
-
.
|
|
31
|
+
exports.depVersions = Object.keys(_depVersions)
|
|
32
|
+
.sort() // Sort the keys alphabetically
|
|
33
|
+
.reduce((obj, key) => {
|
|
41
34
|
obj[key] = _depVersions[key]; // Rebuild the object with sorted keys
|
|
42
35
|
return obj;
|
|
43
|
-
}, {});
|
|
36
|
+
}, {});
|
|
37
|
+
// console.log({ depVersions });
|
package/lib/utils/git.js
CHANGED
|
@@ -1,29 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
get getCommitInfo () {
|
|
13
|
-
return getCommitInfo;
|
|
14
|
-
},
|
|
15
|
-
get getCurrentCommit () {
|
|
16
|
-
return getCurrentCommit;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _child_process = require("child_process");
|
|
20
|
-
const _util = require("util");
|
|
21
|
-
const execFile = (0, _util.promisify)(_child_process.execFile);
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCurrentCommit = getCurrentCommit;
|
|
4
|
+
exports.getCommitInfo = getCommitInfo;
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const util_1 = require("util");
|
|
7
|
+
const execFile = (0, util_1.promisify)(child_process_1.execFile);
|
|
22
8
|
function getCurrentCommit() {
|
|
23
|
-
const result = (0,
|
|
24
|
-
'rev-parse',
|
|
25
|
-
'HEAD'
|
|
26
|
-
]);
|
|
9
|
+
const result = (0, child_process_1.spawnSync)('git', ['rev-parse', 'HEAD']);
|
|
27
10
|
if (result.status !== 0) {
|
|
28
11
|
throw new Error('Not a git repository');
|
|
29
12
|
}
|
|
@@ -33,68 +16,41 @@ async function gitOutput(args, cwd = process.cwd()) {
|
|
|
33
16
|
const { stdout } = await execFile('git', args, {
|
|
34
17
|
cwd,
|
|
35
18
|
encoding: 'utf8',
|
|
36
|
-
windowsHide: true
|
|
19
|
+
windowsHide: true,
|
|
37
20
|
});
|
|
38
21
|
return stdout.trimEnd();
|
|
39
22
|
}
|
|
40
23
|
async function getRemoteOrigin(cwd) {
|
|
41
|
-
const origin = await gitOutput([
|
|
42
|
-
'remote',
|
|
43
|
-
'get-url',
|
|
44
|
-
'origin'
|
|
45
|
-
], cwd).catch(()=>'');
|
|
24
|
+
const origin = await gitOutput(['remote', 'get-url', 'origin'], cwd).catch(() => '');
|
|
46
25
|
if (origin) {
|
|
47
26
|
return origin;
|
|
48
27
|
}
|
|
49
|
-
const remotes = await gitOutput([
|
|
50
|
-
'remote'
|
|
51
|
-
], cwd).catch(()=>'');
|
|
28
|
+
const remotes = await gitOutput(['remote'], cwd).catch(() => '');
|
|
52
29
|
const firstRemote = remotes.split(/\r?\n/).find(Boolean);
|
|
53
30
|
if (!firstRemote) {
|
|
54
31
|
return undefined;
|
|
55
32
|
}
|
|
56
|
-
return gitOutput([
|
|
57
|
-
'remote',
|
|
58
|
-
'get-url',
|
|
59
|
-
firstRemote
|
|
60
|
-
], cwd).catch(()=>undefined);
|
|
33
|
+
return gitOutput(['remote', 'get-url', firstRemote], cwd).catch(() => undefined);
|
|
61
34
|
}
|
|
62
35
|
async function getCommitInfo() {
|
|
63
36
|
try {
|
|
64
|
-
const gitRoot = await gitOutput([
|
|
65
|
-
'rev-parse',
|
|
66
|
-
'--show-toplevel'
|
|
67
|
-
]);
|
|
37
|
+
const gitRoot = await gitOutput(['rev-parse', '--show-toplevel']);
|
|
68
38
|
const [hash, message, author, timestamp, origin] = await Promise.all([
|
|
69
|
-
gitOutput([
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
], gitRoot),
|
|
73
|
-
|
|
74
|
-
'log',
|
|
75
|
-
'-1',
|
|
76
|
-
'--format=%B'
|
|
77
|
-
], gitRoot),
|
|
78
|
-
gitOutput([
|
|
79
|
-
'log',
|
|
80
|
-
'-1',
|
|
81
|
-
'--format=%an'
|
|
82
|
-
], gitRoot),
|
|
83
|
-
gitOutput([
|
|
84
|
-
'log',
|
|
85
|
-
'-1',
|
|
86
|
-
'--format=%ct'
|
|
87
|
-
], gitRoot),
|
|
88
|
-
getRemoteOrigin(gitRoot)
|
|
39
|
+
gitOutput(['rev-parse', 'HEAD'], gitRoot),
|
|
40
|
+
gitOutput(['log', '-1', '--format=%B'], gitRoot),
|
|
41
|
+
gitOutput(['log', '-1', '--format=%an'], gitRoot),
|
|
42
|
+
gitOutput(['log', '-1', '--format=%ct'], gitRoot),
|
|
43
|
+
getRemoteOrigin(gitRoot),
|
|
89
44
|
]);
|
|
90
45
|
return {
|
|
91
46
|
hash,
|
|
92
47
|
message,
|
|
93
48
|
author,
|
|
94
49
|
timestamp,
|
|
95
|
-
origin
|
|
50
|
+
origin,
|
|
96
51
|
};
|
|
97
|
-
}
|
|
52
|
+
}
|
|
53
|
+
catch (_error) {
|
|
98
54
|
return;
|
|
99
55
|
}
|
|
100
56
|
}
|