@rnx-kit/cli 0.18.7 → 0.18.9
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/bin/rnx-cli.js +8 -3
- package/lib/build/watcher.js +6 -2
- package/lib/clean.js +109 -79
- package/package.json +9 -9
package/lib/bin/rnx-cli.js
CHANGED
|
@@ -38,6 +38,10 @@ const commander_1 = require("commander");
|
|
|
38
38
|
const path = __importStar(require("node:path"));
|
|
39
39
|
const context_1 = require("./context");
|
|
40
40
|
const externalCommands_1 = require("./externalCommands");
|
|
41
|
+
function parseDefaultValue(defaultValue, context) {
|
|
42
|
+
const value = typeof defaultValue === "function" ? defaultValue(context) : defaultValue;
|
|
43
|
+
return typeof value === "number" ? value.toString() : value;
|
|
44
|
+
}
|
|
41
45
|
async function main() {
|
|
42
46
|
const [, , userCommand] = process.argv;
|
|
43
47
|
const context = await (0, context_1.loadContextForCommand)(userCommand);
|
|
@@ -51,12 +55,13 @@ async function main() {
|
|
|
51
55
|
else {
|
|
52
56
|
command.action((args, command) => func(command.args, context, args));
|
|
53
57
|
}
|
|
54
|
-
for (const { name, description, parse, default:
|
|
58
|
+
for (const { name, description, parse, default: defaultValue } of options) {
|
|
59
|
+
const value = parseDefaultValue(defaultValue, context);
|
|
55
60
|
if (parse) {
|
|
56
|
-
command.option(name, description ?? name,
|
|
61
|
+
command.option(name, description ?? name, parse, value);
|
|
57
62
|
}
|
|
58
63
|
else {
|
|
59
|
-
command.option(name, description,
|
|
64
|
+
command.option(name, description, value);
|
|
60
65
|
}
|
|
61
66
|
}
|
|
62
67
|
}
|
package/lib/build/watcher.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.watch = watch;
|
|
4
4
|
function watch(subproc, logger, onSuccess) {
|
|
5
5
|
return new Promise((resolve) => {
|
|
6
|
+
const step = "Building";
|
|
6
7
|
const errors = [];
|
|
7
8
|
const isCI = Boolean(process.env.CI);
|
|
8
9
|
if (isCI) {
|
|
@@ -10,7 +11,10 @@ function watch(subproc, logger, onSuccess) {
|
|
|
10
11
|
subproc.stderr.on("data", (chunk) => process.stderr.write(chunk));
|
|
11
12
|
}
|
|
12
13
|
else {
|
|
13
|
-
|
|
14
|
+
let i = 0;
|
|
15
|
+
subproc.stdout.on("data", () => {
|
|
16
|
+
logger.text = step + ".".repeat(++i % 6);
|
|
17
|
+
});
|
|
14
18
|
subproc.stderr.on("data", (data) => errors.push(data));
|
|
15
19
|
}
|
|
16
20
|
subproc.on("close", (code) => {
|
|
@@ -25,7 +29,7 @@ function watch(subproc, logger, onSuccess) {
|
|
|
25
29
|
}
|
|
26
30
|
});
|
|
27
31
|
logger.info(`Command: ${subproc.spawnargs.join(" ")}`);
|
|
28
|
-
logger.start(
|
|
32
|
+
logger.start(step);
|
|
29
33
|
});
|
|
30
34
|
}
|
|
31
35
|
//# sourceMappingURL=watcher.js.map
|
package/lib/clean.js
CHANGED
|
@@ -49,9 +49,8 @@ async function rnxClean(_argv, { root = process.cwd() }, cliOptions) {
|
|
|
49
49
|
if (!(0, node_fs_1.existsSync)(root)) {
|
|
50
50
|
throw new Error(`Invalid project root: ${root}`);
|
|
51
51
|
}
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const execute = (command, args, cwd = root) => {
|
|
52
|
+
const isWindows = os.platform() === "win32";
|
|
53
|
+
const execute = (command, args, cwd = root, onError) => {
|
|
55
54
|
return new Promise((resolve, reject) => {
|
|
56
55
|
const process = (0, node_child_process_1.spawn)(command, args, {
|
|
57
56
|
cwd,
|
|
@@ -60,92 +59,123 @@ async function rnxClean(_argv, { root = process.cwd() }, cliOptions) {
|
|
|
60
59
|
});
|
|
61
60
|
process.on("error", (e) => {
|
|
62
61
|
const code = "code" in e ? e.code : "errno" in e ? e.errno : "1";
|
|
63
|
-
|
|
62
|
+
switch (code) {
|
|
63
|
+
case "ENOENT":
|
|
64
|
+
reject(`Unknown command: ${command}`);
|
|
65
|
+
break;
|
|
66
|
+
default:
|
|
67
|
+
reject(`${e.message} (code: ${code})`);
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
64
70
|
});
|
|
65
71
|
process.on("close", (code) => {
|
|
66
72
|
if (code === 0) {
|
|
67
73
|
resolve();
|
|
68
74
|
}
|
|
75
|
+
else if (onError) {
|
|
76
|
+
onError(code);
|
|
77
|
+
resolve();
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
reject(code);
|
|
81
|
+
}
|
|
69
82
|
});
|
|
70
83
|
});
|
|
71
84
|
};
|
|
72
85
|
const COMMANDS = {
|
|
73
|
-
android
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
cocoapods: [
|
|
92
|
-
{
|
|
93
|
-
label: "Clean CocoaPods cache",
|
|
94
|
-
action: () => execute("pod", ["cache", "clean", "--all"]),
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
metro: [
|
|
98
|
-
{
|
|
99
|
-
label: "Clean Metro cache",
|
|
100
|
-
action: () => cleanDir(`${os.tmpdir()}/metro-*`),
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
label: "Clean Haste cache",
|
|
104
|
-
action: () => cleanDir(`${os.tmpdir()}/haste-map-*`),
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
label: "Clean React Native cache",
|
|
108
|
-
action: () => cleanDir(`${os.tmpdir()}/react-*`),
|
|
109
|
-
},
|
|
110
|
-
],
|
|
111
|
-
npm: [
|
|
112
|
-
{
|
|
113
|
-
label: "Remove node_modules",
|
|
114
|
-
action: () => cleanDir(`${root}/node_modules`),
|
|
115
|
-
},
|
|
116
|
-
...(cliOptions.verifyCache
|
|
117
|
-
? [
|
|
118
|
-
{
|
|
119
|
-
label: "Verify npm cache",
|
|
120
|
-
action: () => execute(npm, ["cache", "verify"]),
|
|
86
|
+
get android() {
|
|
87
|
+
return [
|
|
88
|
+
{
|
|
89
|
+
label: "Clean Gradle cache",
|
|
90
|
+
action: () => {
|
|
91
|
+
const candidates = isWindows
|
|
92
|
+
? ["android/gradlew.bat", "gradlew.bat"]
|
|
93
|
+
: ["android/gradlew", "gradlew"];
|
|
94
|
+
const gradlew = findPath(root, candidates);
|
|
95
|
+
if (gradlew) {
|
|
96
|
+
const script = path.basename(gradlew);
|
|
97
|
+
return execute(isWindows ? script : `./${script}`, ["clean"], path.dirname(gradlew));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
return Promise.resolve();
|
|
101
|
+
}
|
|
121
102
|
},
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
"
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
},
|
|
106
|
+
get cocoapods() {
|
|
107
|
+
return [
|
|
108
|
+
{
|
|
109
|
+
label: "Clean CocoaPods cache",
|
|
110
|
+
action: () => execute("pod", ["cache", "clean", "--all"]),
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
},
|
|
114
|
+
get metro() {
|
|
115
|
+
const tmpdir = os.tmpdir();
|
|
116
|
+
return [
|
|
117
|
+
{
|
|
118
|
+
label: "Clean Metro cache",
|
|
119
|
+
action: () => cleanDir(`${tmpdir}/metro-*`),
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
label: "Clean Haste cache",
|
|
123
|
+
action: () => cleanDir(`${tmpdir}/haste-map-*`),
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
label: "Clean React Native cache",
|
|
127
|
+
action: () => cleanDir(`${tmpdir}/react-*`),
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
|
+
},
|
|
131
|
+
get npm() {
|
|
132
|
+
const npm = isWindows ? "npm.cmd" : "npm";
|
|
133
|
+
return [
|
|
134
|
+
{
|
|
135
|
+
label: "Remove node_modules",
|
|
136
|
+
action: () => cleanDir(`${root}/node_modules`),
|
|
137
|
+
},
|
|
138
|
+
...(cliOptions.verifyCache
|
|
139
|
+
? [
|
|
140
|
+
{
|
|
141
|
+
label: "Verify npm cache",
|
|
142
|
+
action: () => execute(npm, ["cache", "verify"]),
|
|
143
|
+
},
|
|
144
|
+
]
|
|
145
|
+
: []),
|
|
146
|
+
];
|
|
147
|
+
},
|
|
148
|
+
get watchman() {
|
|
149
|
+
const kill = isWindows ? "tskill" : "killall";
|
|
150
|
+
const ignoreError = () => void 0;
|
|
151
|
+
return [
|
|
152
|
+
{
|
|
153
|
+
label: "Stop Watchman",
|
|
154
|
+
action: () => execute(kill, ["watchman"], root, ignoreError),
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
label: "Delete Watchman cache",
|
|
158
|
+
action: () => execute("watchman", ["watch-del-all"]),
|
|
159
|
+
},
|
|
160
|
+
];
|
|
161
|
+
},
|
|
162
|
+
get xcode() {
|
|
163
|
+
return [
|
|
164
|
+
{
|
|
165
|
+
label: "Clean Xcode Simulator cache",
|
|
166
|
+
action: () => cleanDir(`${os.homedir()}/Library/Developer/CoreSimulator/Caches`),
|
|
167
|
+
},
|
|
168
|
+
];
|
|
169
|
+
},
|
|
170
|
+
get yarn() {
|
|
171
|
+
const yarn = isWindows ? "yarn.cmd" : "yarn";
|
|
172
|
+
return [
|
|
173
|
+
{
|
|
174
|
+
label: "Clean Yarn cache",
|
|
175
|
+
action: () => execute(yarn, ["cache", "clean"]),
|
|
176
|
+
},
|
|
177
|
+
];
|
|
178
|
+
},
|
|
149
179
|
};
|
|
150
180
|
const categories = cliOptions.include?.split(",") ?? ["metro", "watchman"];
|
|
151
181
|
const spinner = (0, ora_1.default)();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnx-kit/cli",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.9",
|
|
4
4
|
"description": "Command-line interface for working with kit packages in your repo",
|
|
5
5
|
"homepage": "https://github.com/microsoft/rnx-kit/tree/main/packages/cli#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"test": "rnx-kit-scripts test"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@rnx-kit/align-deps": "^3.0.
|
|
42
|
+
"@rnx-kit/align-deps": "^3.0.6",
|
|
43
43
|
"@rnx-kit/config": "^0.7.0",
|
|
44
44
|
"@rnx-kit/console": "^2.0.0",
|
|
45
45
|
"@rnx-kit/metro-plugin-cyclic-dependencies-detector": "^2.0.0",
|
|
@@ -73,21 +73,21 @@
|
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/core": "^7.20.0",
|
|
75
75
|
"@babel/preset-env": "^7.20.0",
|
|
76
|
-
"@react-native-community/cli-types": "^15.0.
|
|
76
|
+
"@react-native-community/cli-types": "^15.0.1",
|
|
77
77
|
"@rnx-kit/eslint-config": "*",
|
|
78
78
|
"@rnx-kit/jest-preset": "*",
|
|
79
79
|
"@rnx-kit/scripts": "*",
|
|
80
80
|
"@rnx-kit/tools-filesystem": "*",
|
|
81
81
|
"@rnx-kit/tsconfig": "*",
|
|
82
82
|
"@types/connect": "^3.4.36",
|
|
83
|
-
"@types/node": "^
|
|
83
|
+
"@types/node": "^22.0.0",
|
|
84
84
|
"@types/qrcode": "^1.4.2",
|
|
85
85
|
"markdown-table": "^3.0.0",
|
|
86
|
-
"metro": "^0.81.
|
|
87
|
-
"metro-babel-transformer": "^0.81.
|
|
88
|
-
"metro-config": "^0.81.
|
|
89
|
-
"react": "
|
|
90
|
-
"react-native": "^0.
|
|
86
|
+
"metro": "^0.81.3",
|
|
87
|
+
"metro-babel-transformer": "^0.81.3",
|
|
88
|
+
"metro-config": "^0.81.3",
|
|
89
|
+
"react": "19.0.0",
|
|
90
|
+
"react-native": "^0.78.0",
|
|
91
91
|
"tsx": "^4.15.0",
|
|
92
92
|
"type-fest": "^4.0.0"
|
|
93
93
|
},
|