react-native-update-cli 2.9.1 → 2.9.3
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/bundle-runner.d.ts +7 -0
- package/lib/bundle-runner.js +73 -29
- package/lib/exports.d.ts +1 -0
- package/lib/exports.js +4 -0
- package/package.json +11 -1
- package/src/bundle-runner.ts +87 -34
- package/src/exports.ts +1 -0
package/lib/bundle-runner.d.ts
CHANGED
|
@@ -15,6 +15,13 @@ export interface RunBundleCommandOptions {
|
|
|
15
15
|
cli: BundleCliOptions;
|
|
16
16
|
isSentry: boolean;
|
|
17
17
|
}
|
|
18
|
+
type ResolvedExpoCli = {
|
|
19
|
+
cliPath: string;
|
|
20
|
+
usingExpo: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare function hasProjectDependency(dependencyName: string, projectRoot?: string): boolean;
|
|
23
|
+
export declare function resolveExpoCli(projectRoot?: string): ResolvedExpoCli;
|
|
18
24
|
export declare function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, forceHermes, cli, isSentry, }: RunBundleCommandOptions): Promise<void>;
|
|
19
25
|
export declare function copyDebugidForSentry(bundleName: string, outputFolder: string, sourcemapOutput: string): Promise<void>;
|
|
20
26
|
export declare function uploadSourcemapForSentry(bundleName: string, outputFolder: string, sourcemapOutput: string, version: string): Promise<void>;
|
|
27
|
+
export {};
|
package/lib/bundle-runner.js
CHANGED
|
@@ -12,6 +12,12 @@ _export(exports, {
|
|
|
12
12
|
copyDebugidForSentry: function() {
|
|
13
13
|
return copyDebugidForSentry;
|
|
14
14
|
},
|
|
15
|
+
hasProjectDependency: function() {
|
|
16
|
+
return hasProjectDependency;
|
|
17
|
+
},
|
|
18
|
+
resolveExpoCli: function() {
|
|
19
|
+
return resolveExpoCli;
|
|
20
|
+
},
|
|
15
21
|
runReactNativeBundleCommand: function() {
|
|
16
22
|
return runReactNativeBundleCommand;
|
|
17
23
|
},
|
|
@@ -73,6 +79,70 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
73
79
|
}
|
|
74
80
|
const g2js = require('gradle-to-js/lib/parser');
|
|
75
81
|
const properties = require('properties');
|
|
82
|
+
const dependencyFields = [
|
|
83
|
+
'dependencies',
|
|
84
|
+
'devDependencies',
|
|
85
|
+
'peerDependencies',
|
|
86
|
+
'optionalDependencies'
|
|
87
|
+
];
|
|
88
|
+
function hasProjectDependency(dependencyName, projectRoot = process.cwd()) {
|
|
89
|
+
try {
|
|
90
|
+
const packageJson = JSON.parse(_fsextra.readFileSync(_path.default.join(projectRoot, 'package.json'), 'utf8'));
|
|
91
|
+
return dependencyFields.some((field)=>{
|
|
92
|
+
const dependencies = packageJson[field];
|
|
93
|
+
if (typeof dependencies !== 'object' || dependencies === null) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
return dependencyName in dependencies;
|
|
97
|
+
});
|
|
98
|
+
} catch (e) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function resolveExpoCli(projectRoot = process.cwd()) {
|
|
103
|
+
if (!hasProjectDependency('expo', projectRoot)) {
|
|
104
|
+
return {
|
|
105
|
+
cliPath: '',
|
|
106
|
+
usingExpo: false
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
const searchPaths = [
|
|
111
|
+
projectRoot
|
|
112
|
+
];
|
|
113
|
+
try {
|
|
114
|
+
const expoPackageJsonPath = require.resolve('expo/package.json', {
|
|
115
|
+
paths: [
|
|
116
|
+
projectRoot
|
|
117
|
+
]
|
|
118
|
+
});
|
|
119
|
+
searchPaths.push(_path.default.dirname(expoPackageJsonPath));
|
|
120
|
+
} catch (e) {
|
|
121
|
+
// expo 包不存在,忽略
|
|
122
|
+
}
|
|
123
|
+
const cliPath = require.resolve('@expo/cli', {
|
|
124
|
+
paths: searchPaths
|
|
125
|
+
});
|
|
126
|
+
const expoCliVersion = JSON.parse(_fsextra.readFileSync(require.resolve('@expo/cli/package.json', {
|
|
127
|
+
paths: searchPaths
|
|
128
|
+
}), 'utf8')).version;
|
|
129
|
+
if (!(0, _compareversions.satisfies)(expoCliVersion, '>= 0.10.17')) {
|
|
130
|
+
return {
|
|
131
|
+
cliPath: '',
|
|
132
|
+
usingExpo: false
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
cliPath,
|
|
137
|
+
usingExpo: true
|
|
138
|
+
};
|
|
139
|
+
} catch (e) {
|
|
140
|
+
return {
|
|
141
|
+
cliPath: '',
|
|
142
|
+
usingExpo: false
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
76
146
|
async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, forceHermes, cli, isSentry }) {
|
|
77
147
|
let gradleConfig = {};
|
|
78
148
|
if (platform === 'android') {
|
|
@@ -90,35 +160,9 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
|
|
|
90
160
|
let cliPath = '';
|
|
91
161
|
let usingExpo = false;
|
|
92
162
|
const getExpoCli = ()=>{
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
];
|
|
97
|
-
try {
|
|
98
|
-
const expoPath = require.resolve('expo/package.json', {
|
|
99
|
-
paths: [
|
|
100
|
-
process.cwd()
|
|
101
|
-
]
|
|
102
|
-
});
|
|
103
|
-
const expoDir = expoPath.replace(/\/package\.json$/, '');
|
|
104
|
-
searchPaths.push(expoDir);
|
|
105
|
-
} catch (e) {
|
|
106
|
-
// expo 包不存在,忽略
|
|
107
|
-
}
|
|
108
|
-
cliPath = require.resolve('@expo/cli', {
|
|
109
|
-
paths: searchPaths
|
|
110
|
-
});
|
|
111
|
-
const expoCliVersion = JSON.parse(_fsextra.readFileSync(require.resolve('@expo/cli/package.json', {
|
|
112
|
-
paths: searchPaths
|
|
113
|
-
})).toString()).version;
|
|
114
|
-
if ((0, _compareversions.satisfies)(expoCliVersion, '>= 0.10.17')) {
|
|
115
|
-
usingExpo = true;
|
|
116
|
-
} else {
|
|
117
|
-
cliPath = '';
|
|
118
|
-
}
|
|
119
|
-
} catch (e) {
|
|
120
|
-
// fallback 到 RN CLI
|
|
121
|
-
}
|
|
163
|
+
const resolvedExpoCli = resolveExpoCli();
|
|
164
|
+
cliPath = resolvedExpoCli.cliPath;
|
|
165
|
+
usingExpo = resolvedExpoCli.usingExpo;
|
|
122
166
|
};
|
|
123
167
|
const getRnCli = ()=>{
|
|
124
168
|
try {
|
package/lib/exports.d.ts
CHANGED
|
@@ -9,4 +9,5 @@ export { userModule } from './modules/user-module';
|
|
|
9
9
|
export { packageModule } from './modules/package-module';
|
|
10
10
|
export { loadSession, getSession } from './api';
|
|
11
11
|
export { getPlatform, getSelectedApp } from './app';
|
|
12
|
+
export { diffCommands } from './diff';
|
|
12
13
|
export { question, saveToLocal } from './utils';
|
package/lib/exports.js
CHANGED
|
@@ -21,6 +21,9 @@ _export(exports, {
|
|
|
21
21
|
bundleModule: function() {
|
|
22
22
|
return _bundlemodule.bundleModule;
|
|
23
23
|
},
|
|
24
|
+
diffCommands: function() {
|
|
25
|
+
return _diff.diffCommands;
|
|
26
|
+
},
|
|
24
27
|
getPlatform: function() {
|
|
25
28
|
return _app.getPlatform;
|
|
26
29
|
},
|
|
@@ -62,4 +65,5 @@ const _usermodule = require("./modules/user-module");
|
|
|
62
65
|
const _packagemodule = require("./modules/package-module");
|
|
63
66
|
const _api = require("./api");
|
|
64
67
|
const _app = require("./app");
|
|
68
|
+
const _diff = require("./diff");
|
|
65
69
|
const _utils = require("./utils");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-update-cli",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.3",
|
|
4
4
|
"description": "command line tool for react-native-update (remote updates for react native)",
|
|
5
5
|
"main": "lib/exports.js",
|
|
6
6
|
"types": "lib/exports.d.ts",
|
|
@@ -18,6 +18,16 @@
|
|
|
18
18
|
"types": "./lib/index.d.ts",
|
|
19
19
|
"require": "./lib/index.js",
|
|
20
20
|
"default": "./lib/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./diff": {
|
|
23
|
+
"types": "./lib/diff.d.ts",
|
|
24
|
+
"require": "./lib/diff.js",
|
|
25
|
+
"default": "./lib/diff.js"
|
|
26
|
+
},
|
|
27
|
+
"./lib/diff": {
|
|
28
|
+
"types": "./lib/diff.d.ts",
|
|
29
|
+
"require": "./lib/diff.js",
|
|
30
|
+
"default": "./lib/diff.js"
|
|
21
31
|
}
|
|
22
32
|
},
|
|
23
33
|
"files": [
|
package/src/bundle-runner.ts
CHANGED
|
@@ -32,6 +32,90 @@ interface GradleConfig {
|
|
|
32
32
|
enableHermes?: boolean;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
const dependencyFields = [
|
|
36
|
+
'dependencies',
|
|
37
|
+
'devDependencies',
|
|
38
|
+
'peerDependencies',
|
|
39
|
+
'optionalDependencies',
|
|
40
|
+
] as const;
|
|
41
|
+
|
|
42
|
+
type ResolvedExpoCli = {
|
|
43
|
+
cliPath: string;
|
|
44
|
+
usingExpo: boolean;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export function hasProjectDependency(
|
|
48
|
+
dependencyName: string,
|
|
49
|
+
projectRoot = process.cwd(),
|
|
50
|
+
): boolean {
|
|
51
|
+
try {
|
|
52
|
+
const packageJson = JSON.parse(
|
|
53
|
+
fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'),
|
|
54
|
+
) as Record<string, unknown>;
|
|
55
|
+
|
|
56
|
+
return dependencyFields.some((field) => {
|
|
57
|
+
const dependencies = packageJson[field];
|
|
58
|
+
if (typeof dependencies !== 'object' || dependencies === null) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return dependencyName in dependencies;
|
|
62
|
+
});
|
|
63
|
+
} catch {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function resolveExpoCli(projectRoot = process.cwd()): ResolvedExpoCli {
|
|
69
|
+
if (!hasProjectDependency('expo', projectRoot)) {
|
|
70
|
+
return {
|
|
71
|
+
cliPath: '',
|
|
72
|
+
usingExpo: false,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
const searchPaths = [projectRoot];
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
const expoPackageJsonPath = require.resolve('expo/package.json', {
|
|
81
|
+
paths: [projectRoot],
|
|
82
|
+
});
|
|
83
|
+
searchPaths.push(path.dirname(expoPackageJsonPath));
|
|
84
|
+
} catch {
|
|
85
|
+
// expo 包不存在,忽略
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const cliPath = require.resolve('@expo/cli', {
|
|
89
|
+
paths: searchPaths,
|
|
90
|
+
});
|
|
91
|
+
const expoCliVersion = JSON.parse(
|
|
92
|
+
fs.readFileSync(
|
|
93
|
+
require.resolve('@expo/cli/package.json', {
|
|
94
|
+
paths: searchPaths,
|
|
95
|
+
}),
|
|
96
|
+
'utf8',
|
|
97
|
+
),
|
|
98
|
+
).version;
|
|
99
|
+
|
|
100
|
+
if (!satisfies(expoCliVersion, '>= 0.10.17')) {
|
|
101
|
+
return {
|
|
102
|
+
cliPath: '',
|
|
103
|
+
usingExpo: false,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
cliPath,
|
|
109
|
+
usingExpo: true,
|
|
110
|
+
};
|
|
111
|
+
} catch {
|
|
112
|
+
return {
|
|
113
|
+
cliPath: '',
|
|
114
|
+
usingExpo: false,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
35
119
|
export async function runReactNativeBundleCommand({
|
|
36
120
|
bundleName,
|
|
37
121
|
dev,
|
|
@@ -65,40 +149,9 @@ export async function runReactNativeBundleCommand({
|
|
|
65
149
|
let usingExpo = false;
|
|
66
150
|
|
|
67
151
|
const getExpoCli = () => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
const expoPath = require.resolve('expo/package.json', {
|
|
73
|
-
paths: [process.cwd()],
|
|
74
|
-
});
|
|
75
|
-
const expoDir = expoPath.replace(/\/package\.json$/, '');
|
|
76
|
-
searchPaths.push(expoDir);
|
|
77
|
-
} catch {
|
|
78
|
-
// expo 包不存在,忽略
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
cliPath = require.resolve('@expo/cli', {
|
|
82
|
-
paths: searchPaths,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const expoCliVersion = JSON.parse(
|
|
86
|
-
fs
|
|
87
|
-
.readFileSync(
|
|
88
|
-
require.resolve('@expo/cli/package.json', {
|
|
89
|
-
paths: searchPaths,
|
|
90
|
-
}),
|
|
91
|
-
)
|
|
92
|
-
.toString(),
|
|
93
|
-
).version;
|
|
94
|
-
if (satisfies(expoCliVersion, '>= 0.10.17')) {
|
|
95
|
-
usingExpo = true;
|
|
96
|
-
} else {
|
|
97
|
-
cliPath = '';
|
|
98
|
-
}
|
|
99
|
-
} catch {
|
|
100
|
-
// fallback 到 RN CLI
|
|
101
|
-
}
|
|
152
|
+
const resolvedExpoCli = resolveExpoCli();
|
|
153
|
+
cliPath = resolvedExpoCli.cliPath;
|
|
154
|
+
usingExpo = resolvedExpoCli.usingExpo;
|
|
102
155
|
};
|
|
103
156
|
|
|
104
157
|
const getRnCli = () => {
|
package/src/exports.ts
CHANGED