@react-native/core-cli-utils 0.76.0-nightly-20240715-2eb7bcb8d → 0.76.0-nightly-20240720-3a5eb1973
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/dist/index.d.ts +22 -0
- package/dist/index.js +66 -0
- package/dist/index.js.flow +26 -0
- package/dist/private/android.d.ts +29 -0
- package/dist/private/android.js +74 -0
- package/dist/private/android.js.flow +42 -0
- package/dist/private/app.d.ts +37 -0
- package/dist/private/app.js +176 -0
- package/dist/private/app.js.flow +72 -0
- package/dist/private/apple.d.ts +54 -0
- package/dist/private/apple.js +148 -0
- package/dist/private/apple.js.flow +71 -0
- package/dist/private/clean.d.ts +59 -0
- package/dist/private/clean.js +141 -0
- package/dist/private/clean.js.flow +77 -0
- package/dist/private/types.d.ts +16 -0
- package/dist/private/types.js +1 -0
- package/dist/private/utils.d.ts +28 -0
- package/dist/private/utils.js +53 -0
- package/dist/private/utils.js.flow +38 -0
- package/dist/public/version.d.ts +27 -0
- package/dist/public/version.js +31 -0
- package/{src/public/version.flow.js → dist/public/version.js.flow} +12 -19
- package/package.json +2 -2
- package/src/index.flow.js +0 -26
- package/src/index.js +0 -20
- package/src/private/android.js +0 -121
- package/src/private/app.js +0 -250
- package/src/private/apple.js +0 -196
- package/src/private/clean.js +0 -203
- package/src/private/utils.js +0 -66
- package/src/public/version.js +0 -20
- /package/{src/private/types.js → dist/private/types.js.flow} +0 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
* @oncall react_native
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { tasks as _android } from "./private/android.js";
|
|
13
|
+
import { tasks as _app } from "./private/app.js";
|
|
14
|
+
import { tasks as _apple } from "./private/apple.js";
|
|
15
|
+
import { tasks as _clean } from "./private/clean.js";
|
|
16
|
+
import * as _version from "./public/version.js";
|
|
17
|
+
export declare const android: typeof _android;
|
|
18
|
+
export declare const app: typeof _app;
|
|
19
|
+
export declare const apple: typeof _apple;
|
|
20
|
+
export declare const clean: typeof _clean;
|
|
21
|
+
export declare const version: typeof _version;
|
|
22
|
+
export type { Task } from "./private/types";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.version =
|
|
7
|
+
exports.clean =
|
|
8
|
+
exports.apple =
|
|
9
|
+
exports.app =
|
|
10
|
+
exports.android =
|
|
11
|
+
void 0;
|
|
12
|
+
var _android2 = require("./private/android.js");
|
|
13
|
+
var _app2 = require("./private/app.js");
|
|
14
|
+
var _apple2 = require("./private/apple.js");
|
|
15
|
+
var _clean2 = require("./private/clean.js");
|
|
16
|
+
var _version = _interopRequireWildcard(require("./public/version.js"));
|
|
17
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
18
|
+
if (typeof WeakMap !== "function") return null;
|
|
19
|
+
var cacheBabelInterop = new WeakMap();
|
|
20
|
+
var cacheNodeInterop = new WeakMap();
|
|
21
|
+
return (_getRequireWildcardCache = function (nodeInterop) {
|
|
22
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
23
|
+
})(nodeInterop);
|
|
24
|
+
}
|
|
25
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
26
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
27
|
+
return obj;
|
|
28
|
+
}
|
|
29
|
+
if (obj === null || (typeof obj !== "object" && typeof obj !== "function")) {
|
|
30
|
+
return { default: obj };
|
|
31
|
+
}
|
|
32
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
33
|
+
if (cache && cache.has(obj)) {
|
|
34
|
+
return cache.get(obj);
|
|
35
|
+
}
|
|
36
|
+
var newObj = {};
|
|
37
|
+
var hasPropertyDescriptor =
|
|
38
|
+
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
39
|
+
for (var key in obj) {
|
|
40
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
41
|
+
var desc = hasPropertyDescriptor
|
|
42
|
+
? Object.getOwnPropertyDescriptor(obj, key)
|
|
43
|
+
: null;
|
|
44
|
+
if (desc && (desc.get || desc.set)) {
|
|
45
|
+
Object.defineProperty(newObj, key, desc);
|
|
46
|
+
} else {
|
|
47
|
+
newObj[key] = obj[key];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
newObj.default = obj;
|
|
52
|
+
if (cache) {
|
|
53
|
+
cache.set(obj, newObj);
|
|
54
|
+
}
|
|
55
|
+
return newObj;
|
|
56
|
+
}
|
|
57
|
+
const android = _android2.tasks;
|
|
58
|
+
exports.android = android;
|
|
59
|
+
const app = _app2.tasks;
|
|
60
|
+
exports.app = app;
|
|
61
|
+
const apple = _apple2.tasks;
|
|
62
|
+
exports.apple = apple;
|
|
63
|
+
const clean = _clean2.tasks;
|
|
64
|
+
exports.clean = clean;
|
|
65
|
+
const version = _version;
|
|
66
|
+
exports.version = version;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
* @oncall react_native
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// @babel/register doesn't like export {foo} from './bar'; statements,
|
|
13
|
+
// so we have to jump through hoops here.
|
|
14
|
+
import { tasks as _android } from "./private/android.js";
|
|
15
|
+
import { tasks as _app } from "./private/app.js";
|
|
16
|
+
import { tasks as _apple } from "./private/apple.js";
|
|
17
|
+
import { tasks as _clean } from "./private/clean.js";
|
|
18
|
+
import * as _version from "./public/version.js";
|
|
19
|
+
|
|
20
|
+
declare export const android: typeof _android;
|
|
21
|
+
declare export const app: typeof _app;
|
|
22
|
+
declare export const apple: typeof _apple;
|
|
23
|
+
declare export const clean: typeof _clean;
|
|
24
|
+
declare export const version: typeof _version;
|
|
25
|
+
|
|
26
|
+
export type { Task } from "./private/types";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
* @oncall react_native
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { Task } from "./types";
|
|
13
|
+
import type { ExecaPromise } from "execa";
|
|
14
|
+
type AndroidBuildMode = "Debug" | "Release";
|
|
15
|
+
type Path = string;
|
|
16
|
+
type Args = ReadonlyArray<string>;
|
|
17
|
+
type Config = {
|
|
18
|
+
cwd: Path;
|
|
19
|
+
hermes?: boolean;
|
|
20
|
+
mode: AndroidBuildMode;
|
|
21
|
+
name: string;
|
|
22
|
+
newArchitecture?: boolean;
|
|
23
|
+
sdk?: Path;
|
|
24
|
+
};
|
|
25
|
+
export declare const tasks: (config: Config) => {
|
|
26
|
+
assemble: (...gradleArgs: Args) => { run: Task<ExecaPromise> };
|
|
27
|
+
build: (...gradleArgs: Args) => { run: Task<ExecaPromise> };
|
|
28
|
+
install: (...gradleArgs: Args) => { run: Task<ExecaPromise> };
|
|
29
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.tasks = void 0;
|
|
7
|
+
var _utils = require("./utils");
|
|
8
|
+
var _execa = _interopRequireDefault(require("execa"));
|
|
9
|
+
function _interopRequireDefault(obj) {
|
|
10
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
11
|
+
}
|
|
12
|
+
function gradle(taskName, args, options) {
|
|
13
|
+
const gradlew = _utils.isWindows ? "gradlew.bat" : "./gradlew";
|
|
14
|
+
return (0, _execa.default)(gradlew, [taskName, ...args], {
|
|
15
|
+
cwd: options.cwd,
|
|
16
|
+
env: options.env,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function androidSdkPath(sdk) {
|
|
20
|
+
return sdk ?? process.env.ANDROID_HOME ?? process.env.ANDROID_SDK ?? "";
|
|
21
|
+
}
|
|
22
|
+
function boolToStr(value) {
|
|
23
|
+
return value ? "true" : "false";
|
|
24
|
+
}
|
|
25
|
+
const FIRST = 1;
|
|
26
|
+
const tasks = (config) => ({
|
|
27
|
+
assemble: (...gradleArgs) => ({
|
|
28
|
+
run: (0, _utils.task)(FIRST, "Assemble Android App", () => {
|
|
29
|
+
const args = [];
|
|
30
|
+
if (config.hermes != null) {
|
|
31
|
+
args.push(`-PhermesEnabled=${boolToStr(config.hermes)}`);
|
|
32
|
+
}
|
|
33
|
+
if (config.newArchitecture != null) {
|
|
34
|
+
args.push(`-PnewArchEnabled=${boolToStr(config.newArchitecture)}`);
|
|
35
|
+
}
|
|
36
|
+
args.push(...gradleArgs);
|
|
37
|
+
return gradle(`${config.name}:assemble${config.mode}`, gradleArgs, {
|
|
38
|
+
cwd: config.cwd,
|
|
39
|
+
env: {
|
|
40
|
+
ANDROID_HOME: androidSdkPath(config.sdk),
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}),
|
|
44
|
+
}),
|
|
45
|
+
build: (...gradleArgs) => ({
|
|
46
|
+
run: (0, _utils.task)(FIRST, "Assembles and tests Android App", () => {
|
|
47
|
+
const args = [];
|
|
48
|
+
if (config.hermes != null) {
|
|
49
|
+
args.push(`-PhermesEnabled=${boolToStr(config.hermes)}`);
|
|
50
|
+
}
|
|
51
|
+
if (config.newArchitecture != null) {
|
|
52
|
+
args.push(`-PnewArchEnabled=${boolToStr(config.newArchitecture)}`);
|
|
53
|
+
}
|
|
54
|
+
args.push(...gradleArgs);
|
|
55
|
+
return gradle(`${config.name}:bundle${config.mode}`, args, {
|
|
56
|
+
cwd: config.cwd,
|
|
57
|
+
env: {
|
|
58
|
+
ANDROID_HOME: androidSdkPath(config.sdk),
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}),
|
|
62
|
+
}),
|
|
63
|
+
install: (...gradleArgs) => ({
|
|
64
|
+
run: (0, _utils.task)(FIRST, "Installs the assembled Android App", () =>
|
|
65
|
+
gradle(`${config.name}:install${config.mode}`, gradleArgs, {
|
|
66
|
+
cwd: config.cwd,
|
|
67
|
+
env: {
|
|
68
|
+
ANDROID_HOME: androidSdkPath(config.sdk),
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
),
|
|
72
|
+
}),
|
|
73
|
+
});
|
|
74
|
+
exports.tasks = tasks;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
* @oncall react_native
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { Task } from "./types";
|
|
13
|
+
import type { ExecaPromise } from "execa";
|
|
14
|
+
|
|
15
|
+
type AndroidBuildMode = "Debug" | "Release";
|
|
16
|
+
|
|
17
|
+
type Path = string;
|
|
18
|
+
type Args = $ReadOnlyArray<string>;
|
|
19
|
+
|
|
20
|
+
type Config = {
|
|
21
|
+
cwd: Path,
|
|
22
|
+
hermes?: boolean,
|
|
23
|
+
mode: AndroidBuildMode,
|
|
24
|
+
name: string,
|
|
25
|
+
newArchitecture?: boolean,
|
|
26
|
+
sdk?: Path,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//
|
|
30
|
+
// Android Tasks
|
|
31
|
+
//
|
|
32
|
+
declare export const tasks: (config: Config) => {
|
|
33
|
+
assemble: (...gradleArgs: Args) => {
|
|
34
|
+
run: Task<ExecaPromise>,
|
|
35
|
+
},
|
|
36
|
+
build: (...gradleArgs: Args) => {
|
|
37
|
+
run: Task<ExecaPromise>,
|
|
38
|
+
},
|
|
39
|
+
install: (...gradleArgs: Args) => {
|
|
40
|
+
run: Task<ExecaPromise>,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
* @oncall react_native
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { Task } from "./types";
|
|
13
|
+
import type { ExecaPromise } from "execa";
|
|
14
|
+
type BundlerOptions =
|
|
15
|
+
/**
|
|
16
|
+
* > 39 | ...Bundler,
|
|
17
|
+
* | ^^^^^^^^^^ Unsupported feature: Translating "object types with spreads in the middle or at the end" is currently not supported.
|
|
18
|
+
**/
|
|
19
|
+
any;
|
|
20
|
+
type HermesConfig = { path: string; hermesc: string };
|
|
21
|
+
type BundlerWatch = {
|
|
22
|
+
readonly mode: "watch";
|
|
23
|
+
callback?: (metro: ExecaPromise) => void;
|
|
24
|
+
};
|
|
25
|
+
type BundlerBuild = { readonly mode: "bundle" };
|
|
26
|
+
type Bundler = BundlerWatch | BundlerBuild;
|
|
27
|
+
export declare const tasks: {
|
|
28
|
+
bundle: (options: BundlerOptions, ...args: ReadonlyArray<string>) => Bundle;
|
|
29
|
+
};
|
|
30
|
+
type Bundle = {
|
|
31
|
+
validate?: Task<void>;
|
|
32
|
+
javascript: Task<ExecaPromise>;
|
|
33
|
+
sourcemap?: Task<void>;
|
|
34
|
+
validateHermesc?: Task<ExecaPromise>;
|
|
35
|
+
convert?: Task<ExecaPromise>;
|
|
36
|
+
compose?: Task<ExecaPromise>;
|
|
37
|
+
};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.tasks = void 0;
|
|
7
|
+
var _utils = require("./utils");
|
|
8
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
+
var _execa = _interopRequireDefault(require("execa"));
|
|
10
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
11
|
+
var _path = _interopRequireDefault(require("path"));
|
|
12
|
+
function _interopRequireDefault(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
14
|
+
}
|
|
15
|
+
const log = (0, _debug.default)("core-cli-utils");
|
|
16
|
+
const FIRST = 1,
|
|
17
|
+
SECOND = 2,
|
|
18
|
+
THIRD = 3,
|
|
19
|
+
FOURTH = 4;
|
|
20
|
+
function getNodePackagePath(packageName) {
|
|
21
|
+
return require.resolve(packageName, {
|
|
22
|
+
cwd: [process.cwd(), ...module.paths],
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function metro(...args) {
|
|
26
|
+
const metroPath = getNodePackagePath(
|
|
27
|
+
_path.default.join("metro", "src", "cli.js")
|
|
28
|
+
);
|
|
29
|
+
log(`🚇 ${metroPath} ${args.join(" ")} `);
|
|
30
|
+
return (0, _execa.default)("node", [metroPath, ...args]);
|
|
31
|
+
}
|
|
32
|
+
const tasks = {
|
|
33
|
+
bundle: (options, ...args) => {
|
|
34
|
+
const steps = {
|
|
35
|
+
validate: (0, _utils.task)(FIRST, "Check if Metro is available", () => {
|
|
36
|
+
try {
|
|
37
|
+
require("metro");
|
|
38
|
+
} catch {
|
|
39
|
+
throw new Error("Metro is not available");
|
|
40
|
+
}
|
|
41
|
+
}),
|
|
42
|
+
javascript: (0, _utils.task)(SECOND, "Metro watching for changes", () =>
|
|
43
|
+
metro("serve", ...args)
|
|
44
|
+
),
|
|
45
|
+
};
|
|
46
|
+
return options.mode === "bundle"
|
|
47
|
+
? Object.assign(steps, bundleApp(options, ...args))
|
|
48
|
+
: steps;
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
exports.tasks = tasks;
|
|
52
|
+
const bundleApp = (options, ...metroArgs) => {
|
|
53
|
+
if (options.outputJsBundle === options.outputBundle) {
|
|
54
|
+
throw new Error("outputJsBundle and outputBundle cannot be the same.");
|
|
55
|
+
}
|
|
56
|
+
let output =
|
|
57
|
+
options.jsvm === "hermes" ? options.outputJsBundle : options.outputBundle;
|
|
58
|
+
if (output === options.outputJsBundle && !output.endsWith(".js")) {
|
|
59
|
+
log(
|
|
60
|
+
`Appending .js to outputBundle (because metro cli does it if it's missing): ${output}`
|
|
61
|
+
);
|
|
62
|
+
output += ".js";
|
|
63
|
+
}
|
|
64
|
+
const isSourceMaps = options.outputSourceMap != null;
|
|
65
|
+
const bundle = {
|
|
66
|
+
javascript: (0, _utils.task)(
|
|
67
|
+
SECOND,
|
|
68
|
+
"Metro generating an .jsbundle",
|
|
69
|
+
() => {
|
|
70
|
+
const args = [
|
|
71
|
+
"--platform",
|
|
72
|
+
options.platform,
|
|
73
|
+
"--dev",
|
|
74
|
+
options.dev ? "true" : "false",
|
|
75
|
+
"--reset-cache",
|
|
76
|
+
"--out",
|
|
77
|
+
output,
|
|
78
|
+
];
|
|
79
|
+
if (options.jsvm === "hermes" && !options.dev) {
|
|
80
|
+
args.push("--minify", "false");
|
|
81
|
+
} else {
|
|
82
|
+
args.push("--minify", options.minify ? "true" : "false");
|
|
83
|
+
}
|
|
84
|
+
if (isSourceMaps) {
|
|
85
|
+
args.push("--source-map");
|
|
86
|
+
}
|
|
87
|
+
return metro("build", options.entryFile, ...args, ...metroArgs);
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
};
|
|
91
|
+
if (options.jsvm === "jsc") {
|
|
92
|
+
return bundle;
|
|
93
|
+
}
|
|
94
|
+
if (options.hermes?.path == null || options.hermes?.hermesc == null) {
|
|
95
|
+
throw new Error('If jsvm == "hermes", hermes config must be provided.');
|
|
96
|
+
}
|
|
97
|
+
const hermes = options.hermes;
|
|
98
|
+
const isHermesInstalled = _fs.default.existsSync(hermes.path);
|
|
99
|
+
if (!isHermesInstalled) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
"Hermes Pod must be installed before bundling.\n" +
|
|
102
|
+
"Did you forget to bootstrap?"
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
const hermesc = _path.default.join(hermes.path, hermes.hermesc);
|
|
106
|
+
let composeSourceMaps;
|
|
107
|
+
if (isSourceMaps) {
|
|
108
|
+
bundle.sourcemap = (0, _utils.task)(
|
|
109
|
+
FIRST,
|
|
110
|
+
"Check if SourceMap script available",
|
|
111
|
+
() => {
|
|
112
|
+
composeSourceMaps = getNodePackagePath(
|
|
113
|
+
"react-native/scripts/compose-source-maps.js"
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
bundle.validateHermesc = (0, _utils.task)(
|
|
119
|
+
FIRST,
|
|
120
|
+
"Check if Hermesc is available",
|
|
121
|
+
() => (0, _execa.default)(hermesc, ["--version"])
|
|
122
|
+
);
|
|
123
|
+
bundle.convert = (0, _utils.task)(
|
|
124
|
+
THIRD,
|
|
125
|
+
"Hermesc converting .jsbundle → bytecode",
|
|
126
|
+
() => {
|
|
127
|
+
const args = [
|
|
128
|
+
"-emit-binary",
|
|
129
|
+
"-max-diagnostic-width=80",
|
|
130
|
+
options.dev === true ? "-Og" : "-O",
|
|
131
|
+
];
|
|
132
|
+
if (isSourceMaps) {
|
|
133
|
+
args.push("-output-source-map");
|
|
134
|
+
}
|
|
135
|
+
args.push(`-out=${options.outputBundle}`, output);
|
|
136
|
+
return (0, _execa.default)(hermesc, args, {
|
|
137
|
+
cwd: options.cwd,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
bundle.compose = (0, _utils.task)(
|
|
142
|
+
FOURTH,
|
|
143
|
+
"Compose Hermes and Metro source maps",
|
|
144
|
+
() => {
|
|
145
|
+
if (composeSourceMaps == null) {
|
|
146
|
+
throw new Error(
|
|
147
|
+
"Unable to find the compose-source-map.js script in react-native"
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
const metroSourceMap = output.replace(/(\.js)?$/, ".map");
|
|
151
|
+
const hermesSourceMap = options.outputBundle + ".map";
|
|
152
|
+
const compose = (0, _execa.default)(
|
|
153
|
+
"node",
|
|
154
|
+
[
|
|
155
|
+
composeSourceMaps,
|
|
156
|
+
metroSourceMap,
|
|
157
|
+
hermesSourceMap,
|
|
158
|
+
`-o ${options.outputSourceMap}`,
|
|
159
|
+
],
|
|
160
|
+
{
|
|
161
|
+
cwd: options.cwd,
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
compose.finally(() => {
|
|
165
|
+
_fs.default.rmSync(metroSourceMap, {
|
|
166
|
+
force: true,
|
|
167
|
+
});
|
|
168
|
+
_fs.default.rmSync(hermesSourceMap, {
|
|
169
|
+
force: true,
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
return compose;
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
return bundle;
|
|
176
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
* @oncall react_native
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { Task } from "./types";
|
|
13
|
+
import type { ExecaPromise } from "execa";
|
|
14
|
+
|
|
15
|
+
type BundlerOptions = {
|
|
16
|
+
// Metro's config: https://metrobundler.dev/docs/configuration/
|
|
17
|
+
config?: string,
|
|
18
|
+
// Typically index.{ios,android}.js
|
|
19
|
+
entryFile: string,
|
|
20
|
+
+platform: "ios" | "android" | string,
|
|
21
|
+
dev: boolean,
|
|
22
|
+
// Metro built main bundle
|
|
23
|
+
outputJsBundle: string,
|
|
24
|
+
minify: boolean,
|
|
25
|
+
optimize: boolean,
|
|
26
|
+
// Generate a source map file
|
|
27
|
+
outputSourceMap: string,
|
|
28
|
+
// Where to pass the final bundle. Typically this is the App's resource
|
|
29
|
+
// folder, however this is app specific. React Native will need to know where
|
|
30
|
+
// this is to bootstrap your application. See:
|
|
31
|
+
// - Android: https://reactnative.dev/docs/integration-with-existing-apps?language=kotlin#creating-a-release-build-in-android-studio
|
|
32
|
+
// - iOS: https://reactnative.dev/docs/integration-with-existing-apps?language=swift#2-event-handler
|
|
33
|
+
outputBundle: string,
|
|
34
|
+
cwd: string,
|
|
35
|
+
|
|
36
|
+
jsvm: "hermes" | "jsc",
|
|
37
|
+
hermes?: HermesConfig,
|
|
38
|
+
|
|
39
|
+
...Bundler,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
type HermesConfig = {
|
|
43
|
+
// Path where hermes is is installed
|
|
44
|
+
// iOS: Pods/hermes-engine
|
|
45
|
+
path: string,
|
|
46
|
+
// iOS: <hermes.path>/destroot/bin/hermesc
|
|
47
|
+
hermesc: string,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
type BundlerWatch = {
|
|
51
|
+
+mode: "watch",
|
|
52
|
+
callback?: (metro: ExecaPromise) => void,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
type BundlerBuild = {
|
|
56
|
+
+mode: "bundle",
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
type Bundler = BundlerWatch | BundlerBuild;
|
|
60
|
+
|
|
61
|
+
declare export const tasks: {
|
|
62
|
+
bundle: (options: BundlerOptions, ...args: $ReadOnlyArray<string>) => Bundle,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
type Bundle = {
|
|
66
|
+
validate?: Task<void>,
|
|
67
|
+
javascript: Task<ExecaPromise>,
|
|
68
|
+
sourcemap?: Task<void>,
|
|
69
|
+
validateHermesc?: Task<ExecaPromise>,
|
|
70
|
+
convert?: Task<ExecaPromise>,
|
|
71
|
+
compose?: Task<ExecaPromise>,
|
|
72
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
* @oncall react_native
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { Task } from "./types";
|
|
13
|
+
import type { ExecaPromise } from "execa";
|
|
14
|
+
type AppleBuildMode = "Debug" | "Release";
|
|
15
|
+
type AppleBuildOptions =
|
|
16
|
+
/**
|
|
17
|
+
* > 23 | ...AppleOptions,
|
|
18
|
+
* | ^^^^^^^^^^^^^^^ Unsupported feature: Translating "object types with spreads in the middle or at the end" is currently not supported.
|
|
19
|
+
**/
|
|
20
|
+
any;
|
|
21
|
+
type AppleBootstrapOption =
|
|
22
|
+
/**
|
|
23
|
+
* > 31 | ...AppleOptions,
|
|
24
|
+
* | ^^^^^^^^^^^^^^^ Unsupported feature: Translating "object types with spreads in the middle or at the end" is currently not supported.
|
|
25
|
+
**/
|
|
26
|
+
any;
|
|
27
|
+
type AppleInstallApp =
|
|
28
|
+
/**
|
|
29
|
+
* > 40 | ...AppleOptions,
|
|
30
|
+
* | ^^^^^^^^^^^^^^^ Unsupported feature: Translating "object types with spreads in the middle or at the end" is currently not supported.
|
|
31
|
+
**/
|
|
32
|
+
any;
|
|
33
|
+
type AppleOptions = { cwd: string; env?: { [key: string]: string | void } };
|
|
34
|
+
export declare const tasks: {
|
|
35
|
+
bootstrap: (options: AppleBootstrapOption) => {
|
|
36
|
+
validate: Task<void>;
|
|
37
|
+
installRubyGems: Task<ExecaPromise>;
|
|
38
|
+
installDependencies: Task<ExecaPromise>;
|
|
39
|
+
};
|
|
40
|
+
build: (
|
|
41
|
+
options: AppleBuildOptions,
|
|
42
|
+
...args: ReadonlyArray<string>
|
|
43
|
+
) => {
|
|
44
|
+
validate: Task<void>;
|
|
45
|
+
hasPodsInstalled: Task<void>;
|
|
46
|
+
build: Task<ExecaPromise>;
|
|
47
|
+
};
|
|
48
|
+
ios: {
|
|
49
|
+
install: (options: AppleInstallApp) => {
|
|
50
|
+
validate: Task<void>;
|
|
51
|
+
install: Task<ExecaPromise>;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|