@rnx-kit/cli 0.11.1 → 0.12.1

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.
@@ -0,0 +1,353 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.rnxCopyAssetsCommand = exports.copyProjectAssets = exports.gatherConfigs = exports.copyAssets = exports.versionOf = void 0;
36
+ const console_1 = require("@rnx-kit/console");
37
+ const array_1 = require("@rnx-kit/tools-language/array");
38
+ const package_1 = require("@rnx-kit/tools-node/package");
39
+ const tools_react_native_1 = require("@rnx-kit/tools-react-native");
40
+ const child_process_1 = require("child_process");
41
+ const fs = __importStar(require("fs-extra"));
42
+ const os = __importStar(require("os"));
43
+ const path = __importStar(require("path"));
44
+ function ensureOption(options, opt, flag = opt) {
45
+ if (options[opt] == null) {
46
+ (0, console_1.error)(`Missing required option: --${flag}`);
47
+ process.exit(1);
48
+ }
49
+ }
50
+ function findGradleProject(projectRoot) {
51
+ if (fs.existsSync(path.join(projectRoot, "android", "build.gradle"))) {
52
+ return path.join(projectRoot, "android");
53
+ }
54
+ if (fs.existsSync(path.join(projectRoot, "build.gradle"))) {
55
+ return projectRoot;
56
+ }
57
+ return undefined;
58
+ }
59
+ function isAssetsConfig(config) {
60
+ return typeof config === "object" && config !== null && "getAssets" in config;
61
+ }
62
+ function keysOf(record) {
63
+ return record ? Object.keys(record) : [];
64
+ }
65
+ function versionOf(pkgName) {
66
+ const { version } = (0, package_1.readPackage)(require.resolve(`${pkgName}/package.json`));
67
+ return version;
68
+ }
69
+ exports.versionOf = versionOf;
70
+ function getAndroidPaths(context, packageName, { targetName, version, output }) {
71
+ const projectRoot = path.dirname(require.resolve(`${packageName}/package.json`));
72
+ switch (packageName) {
73
+ case "hermes-engine":
74
+ return {
75
+ projectRoot,
76
+ output: path.join(projectRoot, "android", "hermes-release.aar"),
77
+ destination: path.join(context.options.assetsDest, "aar", `hermes-release-${versionOf(packageName)}.aar`),
78
+ };
79
+ case "react-native":
80
+ return {
81
+ projectRoot,
82
+ output: path.join(projectRoot, "android"),
83
+ destination: path.join(context.options.assetsDest, "aar", "react-native"),
84
+ };
85
+ default: {
86
+ const androidProject = findGradleProject(projectRoot);
87
+ return {
88
+ projectRoot,
89
+ androidProject,
90
+ output: output ||
91
+ (androidProject &&
92
+ path.join(androidProject, "build", "outputs", "aar", `${targetName}-release.aar`)),
93
+ destination: path.join(context.options.assetsDest, "aar", `${targetName}-${version || versionOf(packageName)}.aar`),
94
+ };
95
+ }
96
+ }
97
+ }
98
+ function assembleAarBundle(context, packageName, { aar }) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ if (!aar) {
101
+ return;
102
+ }
103
+ const findUp = require("find-up");
104
+ const gradlew = yield findUp(os.platform() === "win32" ? "gradlew.bat" : "gradlew");
105
+ if (!gradlew) {
106
+ (0, console_1.warn)(`Skipped \`${packageName}\`: cannot find \`gradlew\``);
107
+ return;
108
+ }
109
+ const { androidProject, output } = getAndroidPaths(context, packageName, aar);
110
+ if (!androidProject || !output) {
111
+ (0, console_1.warn)(`Skipped \`${packageName}\`: cannot find \`build.gradle\``);
112
+ return;
113
+ }
114
+ const { targetName, version, env, dependencies } = aar;
115
+ const targets = [`:${targetName}:assembleRelease`];
116
+ const targetsToCopy = [];
117
+ if (dependencies) {
118
+ for (const [dependencyName, aar] of Object.entries(dependencies)) {
119
+ const { output, destination } = getAndroidPaths(context, dependencyName, aar);
120
+ if (output) {
121
+ if (!fs.existsSync(output)) {
122
+ targets.push(`:${aar.targetName}:assembleRelease`);
123
+ targetsToCopy.push([output, destination]);
124
+ }
125
+ else if (!fs.existsSync(destination)) {
126
+ targetsToCopy.push([output, destination]);
127
+ }
128
+ }
129
+ }
130
+ }
131
+ // Run only one Gradle task at a time
132
+ (0, child_process_1.spawnSync)(gradlew, targets, {
133
+ cwd: androidProject,
134
+ stdio: "inherit",
135
+ env: Object.assign(Object.assign({ ENABLE_HERMES: "true", NODE_MODULES_PATH: path.join(process.cwd(), "node_modules"), REACT_NATIVE_VERSION: versionOf("react-native") }, process.env), env),
136
+ });
137
+ const destination = path.join(context.options.assetsDest, "aar");
138
+ yield fs.ensureDir(destination);
139
+ const aarVersion = version || versionOf(packageName);
140
+ const dest = path.join(destination, `${targetName}-${aarVersion}.aar`);
141
+ yield Promise.all([
142
+ fs.copy(output, dest),
143
+ ...targetsToCopy.map(([src, dest]) => fs.copy(src, dest)),
144
+ ]);
145
+ });
146
+ }
147
+ function copyFiles(files, destination) {
148
+ return __awaiter(this, void 0, void 0, function* () {
149
+ if (!(0, array_1.isNonEmptyArray)(files)) {
150
+ return;
151
+ }
152
+ yield fs.ensureDir(destination);
153
+ yield Promise.all(files.map((file) => {
154
+ const basename = path.basename(file);
155
+ return fs.copy(file, `${destination}/${basename}`);
156
+ }));
157
+ });
158
+ }
159
+ function copyXcodeAssets(xcassets, destination) {
160
+ return __awaiter(this, void 0, void 0, function* () {
161
+ if (!(0, array_1.isNonEmptyArray)(xcassets)) {
162
+ return;
163
+ }
164
+ yield fs.ensureDir(destination);
165
+ yield Promise.all(xcassets.map((catalog) => {
166
+ const dest = `${destination}/${path.basename(catalog)}`;
167
+ return fs.copy(catalog, dest);
168
+ }));
169
+ });
170
+ }
171
+ function copyAssets({ options: { assetsDest, xcassetsDest } }, packageName, { assets, strings, xcassets }) {
172
+ return __awaiter(this, void 0, void 0, function* () {
173
+ const tasks = [
174
+ copyFiles(assets, `${assetsDest}/assets/${packageName}`),
175
+ copyFiles(strings, `${assetsDest}/strings/${packageName}`),
176
+ ];
177
+ if (typeof xcassetsDest === "string") {
178
+ tasks.push(copyXcodeAssets(xcassets, xcassetsDest));
179
+ }
180
+ yield Promise.all(tasks);
181
+ });
182
+ }
183
+ exports.copyAssets = copyAssets;
184
+ function gatherConfigs({ projectRoot, manifest, }) {
185
+ return __awaiter(this, void 0, void 0, function* () {
186
+ const { dependencies, devDependencies } = manifest;
187
+ const packages = [...keysOf(dependencies), ...keysOf(devDependencies)];
188
+ if (packages.length === 0) {
189
+ return;
190
+ }
191
+ const resolveOptions = { paths: [projectRoot] };
192
+ const assetsConfigs = {};
193
+ for (const pkg of packages) {
194
+ try {
195
+ const pkgPath = path.dirname(require.resolve(`${pkg}/package.json`, resolveOptions));
196
+ const reactNativeConfig = `${pkgPath}/react-native.config.js`;
197
+ if (fs.existsSync(reactNativeConfig)) {
198
+ const { nativeAssets } = require(reactNativeConfig);
199
+ if (nativeAssets) {
200
+ assetsConfigs[pkg] = nativeAssets;
201
+ }
202
+ }
203
+ }
204
+ catch (err) {
205
+ (0, console_1.warn)(err);
206
+ }
207
+ }
208
+ // Overrides from project config
209
+ const reactNativeConfig = `${projectRoot}/react-native.config.js`;
210
+ if (fs.existsSync(reactNativeConfig)) {
211
+ const { nativeAssets } = require(reactNativeConfig);
212
+ const overrides = Object.entries(nativeAssets);
213
+ for (const [pkgName, config] of overrides) {
214
+ if (config === null || isAssetsConfig(config)) {
215
+ assetsConfigs[pkgName] = config;
216
+ }
217
+ }
218
+ }
219
+ return assetsConfigs;
220
+ });
221
+ }
222
+ exports.gatherConfigs = gatherConfigs;
223
+ /**
224
+ * Copies additional assets not picked by bundlers into desired directory.
225
+ *
226
+ * The way this works is by scanning all direct dependencies of the current
227
+ * project for a file, `react-native.config.js`, whose contents include a
228
+ * field, `nativeAssets`, and a function that returns assets to copy:
229
+ *
230
+ * ```js
231
+ * // react-native.config.js
232
+ * module.exports = {
233
+ * nativeAssets: {
234
+ * getAssets: (context) => {
235
+ * return {
236
+ * assets: [],
237
+ * strings: [],
238
+ * xcassets: [],
239
+ * };
240
+ * }
241
+ * }
242
+ * };
243
+ * ```
244
+ *
245
+ * We also allow the project itself to override this where applicable. The
246
+ * format is similar and looks like this:
247
+ *
248
+ * ```js
249
+ * // react-native.config.js
250
+ * module.exports = {
251
+ * nativeAssets: {
252
+ * "some-library": {
253
+ * getAssets: (context) => {
254
+ * return {
255
+ * assets: [],
256
+ * strings: [],
257
+ * xcassets: [],
258
+ * };
259
+ * }
260
+ * },
261
+ * "another-library": {
262
+ * getAssets: (context) => {
263
+ * return {
264
+ * assets: [],
265
+ * strings: [],
266
+ * xcassets: [],
267
+ * };
268
+ * }
269
+ * }
270
+ * }
271
+ * };
272
+ * ```
273
+ *
274
+ * @param options Options dictate what gets copied where
275
+ */
276
+ function copyProjectAssets(options) {
277
+ return __awaiter(this, void 0, void 0, function* () {
278
+ const projectRoot = (0, package_1.findPackageDir)() || process.cwd();
279
+ const content = yield fs.readFile(`${projectRoot}/package.json`, {
280
+ encoding: "utf-8",
281
+ });
282
+ const manifest = JSON.parse(content);
283
+ const context = { projectRoot, manifest, options };
284
+ const assetConfigs = yield gatherConfigs(context);
285
+ if (!assetConfigs) {
286
+ return;
287
+ }
288
+ const dependencies = Object.entries(assetConfigs);
289
+ for (const [packageName, config] of dependencies) {
290
+ if (!isAssetsConfig(config)) {
291
+ continue;
292
+ }
293
+ const { getAssets } = config;
294
+ if (typeof getAssets !== "function") {
295
+ (0, console_1.warn)(`Skipped \`${packageName}\`: getAssets is not a function`);
296
+ continue;
297
+ }
298
+ const assets = yield getAssets(context);
299
+ if (options.bundleAar && assets.aar) {
300
+ (0, console_1.info)(`Assembling "${packageName}"`);
301
+ yield assembleAarBundle(context, packageName, assets);
302
+ }
303
+ else {
304
+ (0, console_1.info)(`Copying assets for "${packageName}"`);
305
+ yield copyAssets(context, packageName, assets);
306
+ }
307
+ }
308
+ if (options.bundleAar) {
309
+ const dummyAar = { targetName: "dummy" };
310
+ const copyTasks = [];
311
+ for (const dependencyName of ["hermes-engine", "react-native"]) {
312
+ const { output, destination } = getAndroidPaths(context, dependencyName, dummyAar);
313
+ if (output &&
314
+ (!fs.existsSync(destination) || fs.statSync(destination).isDirectory())) {
315
+ (0, console_1.info)(`Copying Android Archive of "${dependencyName}"`);
316
+ copyTasks.push(fs.copy(output, destination));
317
+ }
318
+ }
319
+ yield Promise.all(copyTasks);
320
+ }
321
+ });
322
+ }
323
+ exports.copyProjectAssets = copyProjectAssets;
324
+ exports.rnxCopyAssetsCommand = {
325
+ name: "rnx-copy-assets",
326
+ description: "Copies additional assets not picked by bundlers into desired directory.",
327
+ func: (_argv, _config, options) => {
328
+ ensureOption(options, "platform");
329
+ ensureOption(options, "assetsDest", "assets-dest");
330
+ return copyProjectAssets(options);
331
+ },
332
+ options: [
333
+ {
334
+ name: "--platform <string>",
335
+ description: "platform to target",
336
+ parse: tools_react_native_1.parsePlatform,
337
+ },
338
+ {
339
+ name: "--assets-dest <string>",
340
+ description: "path of the directory to copy assets into",
341
+ },
342
+ {
343
+ name: "--bundle-aar <boolean>",
344
+ description: "whether to bundle AARs of dependencies",
345
+ default: false,
346
+ },
347
+ {
348
+ name: "--xcassets-dest <string>",
349
+ description: "path of the directory to copy Xcode asset catalogs into. Asset catalogs will only be copied if a destination path is specified.",
350
+ },
351
+ ],
352
+ };
353
+ //# sourceMappingURL=copy-assets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy-assets.js","sourceRoot":"","sources":["../src/copy-assets.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,8CAAqD;AACrD,yDAAgE;AAEhE,yDAA0E;AAE1E,oEAA4D;AAC5D,iDAA0C;AAC1C,6CAA+B;AAC/B,uCAAyB;AACzB,2CAA6B;AAoC7B,SAAS,YAAY,CAAC,OAAgB,EAAE,GAAW,EAAE,IAAI,GAAG,GAAG;IAC7D,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE;QACxB,IAAA,eAAK,EAAC,8BAA8B,IAAI,EAAE,CAAC,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,WAAmB;IAC5C,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC,EAAE;QACpE,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;KAC1C;IACD,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,EAAE;QACzD,OAAO,WAAW,CAAC;KACpB;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,cAAc,CAAC,MAAe;IACrC,OAA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CAAC,WAAW,EAAE,CAAC,EACvE;oBACA,IAAA,cAAI,EAAC,+BAA+B,cAAc,GAAG,CAAC,CAAC;oBACvD,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;iBAC9C;aACF;YACD,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;SAC9B;IACH,CAAC;CAAA;AArDD,8CAqDC;AAEY,QAAA,oBAAoB,GAAG;IAClC,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACT,yEAAyE;IAC3E,IAAI,EAAE,CAAC,KAAe,EAAE,OAAkB,EAAE,OAAgB,EAAE,EAAE;QAC9D,YAAY,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAClC,YAAY,CAAC,OAAO,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;QACnD,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,EAAE;QACP;YACE,IAAI,EAAE,qBAAqB;YAC3B,WAAW,EAAE,oBAAoB;YACjC,KAAK,EAAE,kCAAa;SACrB;QACD;YACE,IAAI,EAAE,wBAAwB;YAC9B,WAAW,EAAE,2CAA2C;SACzD;QACD;YACE,IAAI,EAAE,wBAAwB;YAC9B,WAAW,EAAE,wCAAwC;YACrD,OAAO,EAAE,KAAK;SACf;QACD;YACE,IAAI,EAAE,0BAA0B;YAChC,WAAW,EACT,iIAAiI;SACpI;KACF;CACF,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { rnxBundle } from "./bundle";
2
+ export { copyProjectAssets, rnxCopyAssetsCommand } from "./copy-assets";
2
3
  export { rnxDepCheck, rnxDepCheckCommand } from "./dep-check";
3
4
  export { rnxStart } from "./start";
4
5
  export { rnxTest, rnxTestCommand } from "./test";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC"}
package/lib/index.js CHANGED
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rnxClean = exports.parseBoolean = exports.rnxWriteThirdPartyNotices = exports.rnxTestCommand = exports.rnxTest = exports.rnxStart = exports.rnxDepCheckCommand = exports.rnxDepCheck = exports.rnxBundle = void 0;
3
+ exports.rnxClean = exports.parseBoolean = exports.rnxWriteThirdPartyNotices = exports.rnxTestCommand = exports.rnxTest = exports.rnxStart = exports.rnxDepCheckCommand = exports.rnxDepCheck = exports.rnxCopyAssetsCommand = exports.copyProjectAssets = exports.rnxBundle = void 0;
4
4
  var bundle_1 = require("./bundle");
5
5
  Object.defineProperty(exports, "rnxBundle", { enumerable: true, get: function () { return bundle_1.rnxBundle; } });
6
+ var copy_assets_1 = require("./copy-assets");
7
+ Object.defineProperty(exports, "copyProjectAssets", { enumerable: true, get: function () { return copy_assets_1.copyProjectAssets; } });
8
+ Object.defineProperty(exports, "rnxCopyAssetsCommand", { enumerable: true, get: function () { return copy_assets_1.rnxCopyAssetsCommand; } });
6
9
  var dep_check_1 = require("./dep-check");
7
10
  Object.defineProperty(exports, "rnxDepCheck", { enumerable: true, get: function () { return dep_check_1.rnxDepCheck; } });
8
11
  Object.defineProperty(exports, "rnxDepCheckCommand", { enumerable: true, get: function () { return dep_check_1.rnxDepCheckCommand; } });
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AAA5B,mGAAA,SAAS,OAAA;AAClB,yCAA8D;AAArD,wGAAA,WAAW,OAAA;AAAE,+GAAA,kBAAkB,OAAA;AACxC,iCAAmC;AAA1B,iGAAA,QAAQ,OAAA;AACjB,+BAAiD;AAAxC,+FAAA,OAAO,OAAA;AAAE,sGAAA,cAAc,OAAA;AAChC,yEAAwE;AAA/D,sIAAA,yBAAyB,OAAA;AAClC,qCAAyC;AAAhC,uGAAA,YAAY,OAAA;AACrB,iCAAmC;AAA1B,iGAAA,QAAQ,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AAA5B,mGAAA,SAAS,OAAA;AAClB,6CAAwE;AAA/D,gHAAA,iBAAiB,OAAA;AAAE,mHAAA,oBAAoB,OAAA;AAChD,yCAA8D;AAArD,wGAAA,WAAW,OAAA;AAAE,+GAAA,kBAAkB,OAAA;AACxC,iCAAmC;AAA1B,iGAAA,QAAQ,OAAA;AACjB,+BAAiD;AAAxC,+FAAA,OAAO,OAAA;AAAE,sGAAA,cAAc,OAAA;AAChC,yEAAwE;AAA/D,sIAAA,yBAAyB,OAAA;AAClC,qCAAyC;AAAhC,uGAAA,YAAY,OAAA;AACrB,iCAAmC;AAA1B,iGAAA,QAAQ,OAAA"}
@@ -9,7 +9,7 @@ import type { InputConfigT } from "metro-config";
9
9
  * @param detectCyclicDependencies When true, cyclic dependency checking is enabled with a default set of options. Otherwise the object allows for fine-grained control over the detection process.
10
10
  * @param detectDuplicateDependencies When true, duplicate dependency checking is enabled with a default set of options. Otherwise, the object allows for fine-grained control over the detection process.
11
11
  * @param typescriptValidation When true, TypeScript type-checking is enabled with a default set of options. Otherwise, the object allows for fine-grained control over the type-checking process.
12
- * @param experimental_treeShake When true, experimental tree-shaking is enabled.
12
+ * @param experimental_treeShake When true, experimental tree shaking is enabled.
13
13
  */
14
14
  export declare function customizeMetroConfig(metroConfigReadonly: InputConfigT, detectCyclicDependencies: boolean | CyclicDetectorOptions, detectDuplicateDependencies: boolean | DuplicateDetectorOptions, typescriptValidation: boolean | TypeScriptValidationOptions, experimental_treeShake: boolean): void;
15
15
  //# sourceMappingURL=metro-config.d.ts.map
@@ -73,7 +73,7 @@ const emptySerializerHook = (_graph, _delta) => {
73
73
  * @param detectCyclicDependencies When true, cyclic dependency checking is enabled with a default set of options. Otherwise the object allows for fine-grained control over the detection process.
74
74
  * @param detectDuplicateDependencies When true, duplicate dependency checking is enabled with a default set of options. Otherwise, the object allows for fine-grained control over the detection process.
75
75
  * @param typescriptValidation When true, TypeScript type-checking is enabled with a default set of options. Otherwise, the object allows for fine-grained control over the type-checking process.
76
- * @param experimental_treeShake When true, experimental tree-shaking is enabled.
76
+ * @param experimental_treeShake When true, experimental tree shaking is enabled.
77
77
  */
78
78
  function customizeMetroConfig(metroConfigReadonly, detectCyclicDependencies, detectDuplicateDependencies, typescriptValidation, experimental_treeShake) {
79
79
  // We will be making changes to the Metro configuration. Coerce from a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnx-kit/cli",
3
- "version": "0.11.1",
3
+ "version": "0.12.1",
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",
6
6
  "license": "MIT",
@@ -28,12 +28,14 @@
28
28
  "@rnx-kit/metro-serializer-esbuild": "^0.1.0",
29
29
  "@rnx-kit/metro-service": "^1.1.13",
30
30
  "@rnx-kit/third-party-notices": "^1.2.13",
31
- "@rnx-kit/tools-language": "^1.2.6",
31
+ "@rnx-kit/tools-language": "^1.3.0",
32
32
  "@rnx-kit/tools-node": "^1.2.6",
33
33
  "@rnx-kit/tools-react-native": "^1.2.0",
34
34
  "@rnx-kit/typescript-react-native-resolver": "^0.2.0",
35
35
  "@rnx-kit/typescript-service": "^1.5.3",
36
36
  "chalk": "^4.1.0",
37
+ "find-up": "^5.0.0",
38
+ "fs-extra": "^10.0.0",
37
39
  "ora": "^5.4.1",
38
40
  "qrcode": "^1.5.0",
39
41
  "readline": "^1.3.0"
@@ -54,10 +56,12 @@
54
56
  "@types/metro-config": "^0.66.0",
55
57
  "@types/qrcode": "^1.4.2",
56
58
  "jest-extended": "^0.11.5",
59
+ "memfs": "^3.4.1",
57
60
  "typescript": "^4.0.0"
58
61
  },
59
62
  "depcheck": {
60
63
  "ignoreMatches": [
64
+ "@react-native-community/cli-clean",
61
65
  "metro",
62
66
  "metro-config",
63
67
  "readline"
@@ -3,6 +3,7 @@ const path = require("path");
3
3
  const {
4
4
  parseBoolean,
5
5
  rnxBundle,
6
+ rnxCopyAssetsCommand,
6
7
  rnxStart,
7
8
  rnxDepCheckCommand,
8
9
  rnxTestCommand,
@@ -181,6 +182,7 @@ module.exports = {
181
182
  },
182
183
  ],
183
184
  },
185
+ rnxCopyAssetsCommand,
184
186
  rnxDepCheckCommand,
185
187
  rnxTestCommand,
186
188
  {
package/src/clean.ts CHANGED
@@ -31,6 +31,16 @@ export async function rnxClean(
31
31
  throw new Error(`Invalid path provided! ${projectRoot}`);
32
32
  }
33
33
 
34
+ const spinner = ora();
35
+ try {
36
+ require.resolve("@react-native-community/cli-clean");
37
+ spinner.warn(
38
+ "`rnx-clean` has been upstreamed to `@react-native-community/cli`. Please use `npx react-native clean` instead."
39
+ );
40
+ } catch (_) {
41
+ // Ignore
42
+ }
43
+
34
44
  const npm = os.platform() === "win32" ? "npm.cmd" : "npm";
35
45
  const yarn = os.platform() === "win32" ? "yarn.cmd" : "yarn";
36
46
 
@@ -121,7 +131,6 @@ export async function rnxClean(
121
131
  "yarn",
122
132
  ];
123
133
 
124
- const spinner = ora();
125
134
  for (const category of categories) {
126
135
  const commands = COMMANDS[category];
127
136
  if (!commands) {