Use @rnx-kit/cli for metro bundling and serving (#614)
* Remove metro logic from FURN, replacing it with calls to the @rnx-kit CLI. Use rnx-bundle for bundling, and rnx-start for running a bundle server. * Change files * Fix type in win32 test app bundle config * Fix win32 platform designation in bundle config * Update bundle name in wdio config * Fix start command
This commit is contained in:
Родитель
1f9af24a64
Коммит
5300d6216a
|
@ -12,10 +12,10 @@
|
|||
"code-style": "fluentui-scripts code-style",
|
||||
"depcheck": "fluentui-scripts depcheck",
|
||||
"lint": "fluentui-scripts eslint",
|
||||
"start": "react-native start",
|
||||
"start": "react-native rnx-start",
|
||||
"test": "fluentui-scripts jest",
|
||||
"bundle": "fluentui-scripts metro --cli",
|
||||
"bundle-dev": "fluentui-scripts metro --dev --cli",
|
||||
"bundle": "react-native rnx-bundle --dev false",
|
||||
"bundle-dev": "react-native rnx-bundle",
|
||||
"android": "react-native run-android "
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -28,6 +28,7 @@
|
|||
"@babel/core": "^7.6.2",
|
||||
"@babel/runtime": "^7.6.2",
|
||||
"@react-native-community/eslint-config": "^1.1.0",
|
||||
"@rnx-kit/cli": "^0.0.3",
|
||||
"@uifabricshared/build-native": "^0.1.1",
|
||||
"@uifabricshared/eslint-config-rules": "^0.1.1",
|
||||
"babel-jest": "^24.9.0",
|
||||
|
@ -38,14 +39,13 @@
|
|||
"jest": {
|
||||
"preset": "react-native"
|
||||
},
|
||||
"metroBundles": {
|
||||
"targets": [
|
||||
"android"
|
||||
],
|
||||
"entry": "index.js",
|
||||
"outputPath": "./dist",
|
||||
"bundleName": "index.bundle",
|
||||
"noPlatformSuffix": true
|
||||
"rnx-kit": {
|
||||
"bundle": {
|
||||
"targets": [
|
||||
"android"
|
||||
],
|
||||
"entryPath": "index.js"
|
||||
}
|
||||
},
|
||||
"depcheck": {
|
||||
"ignoreMatches": [
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
"code-style": "fluentui-scripts code-style",
|
||||
"depcheck": "fluentui-scripts depcheck",
|
||||
"lint": "fluentui-scripts eslint",
|
||||
"start": "fluentui-scripts metro --server",
|
||||
"start": "react-native rnx-start",
|
||||
"test": "fluentui-scripts jest",
|
||||
"bundle": "fluentui-scripts bundle"
|
||||
"bundle": "react-native rnx-bundle --dev false"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fluentui-react-native/apple-theme": ">=0.1.1 <1.0.0",
|
||||
|
@ -44,6 +44,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@react-native-community/eslint-config": "^1.1.0",
|
||||
"@rnx-kit/cli": "^0.0.3",
|
||||
"@types/jasmine": "3.5.10",
|
||||
"@types/react": "^16.9.34",
|
||||
"@types/react-native": "^0.62.0",
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
"code-style": "fluentui-scripts code-style",
|
||||
"depcheck": "fluentui-scripts depcheck",
|
||||
"lint": "fluentui-scripts eslint",
|
||||
"start": "react-native start",
|
||||
"start": "react-native rnx-start",
|
||||
"test": "fluentui-scripts jest",
|
||||
"bundle": "fluentui-scripts metro --cli",
|
||||
"bundle-dev": "fluentui-scripts metro --dev --cli",
|
||||
"bundle": "react-native rnx-bundle --dev false",
|
||||
"bundle-dev": "react-native rnx-bundle",
|
||||
"ios": "react-native run-ios --scheme ReactTestApp --project-path src"
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -28,6 +28,7 @@
|
|||
"@babel/core": "^7.6.2",
|
||||
"@babel/runtime": "^7.6.2",
|
||||
"@react-native-community/eslint-config": "^1.1.0",
|
||||
"@rnx-kit/cli": "^0.0.3",
|
||||
"@uifabricshared/build-native": "^0.1.1",
|
||||
"@uifabricshared/eslint-config-rules": "^0.1.1",
|
||||
"babel-jest": "^24.9.0",
|
||||
|
@ -38,14 +39,13 @@
|
|||
"jest": {
|
||||
"preset": "react-native"
|
||||
},
|
||||
"metroBundles": {
|
||||
"targets": [
|
||||
"ios"
|
||||
],
|
||||
"entry": "index.js",
|
||||
"outputPath": "./dist",
|
||||
"bundleName": "index.bundle",
|
||||
"noPlatformSuffix": true
|
||||
"rnx-kit": {
|
||||
"bundle": {
|
||||
"targets": [
|
||||
"ios"
|
||||
],
|
||||
"entryPath": "index.js"
|
||||
}
|
||||
},
|
||||
"depcheck": {
|
||||
"ignoreMatches": [
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
"typings": "lib/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "fluentui-scripts build",
|
||||
"bundle": "fluentui-scripts metro --cli",
|
||||
"bundle": "react-native rnx-bundle --dev false",
|
||||
"just": "fluentui-scripts",
|
||||
"clean": "fluentui-scripts clean",
|
||||
"code-style": "fluentui-scripts code-style",
|
||||
"depcheck": "fluentui-scripts depcheck",
|
||||
"lint": "fluentui-scripts eslint",
|
||||
"start": "react-native start",
|
||||
"start": "react-native rnx-start",
|
||||
"test": "fluentui-scripts jest",
|
||||
"macos": "react-native run-macos --scheme FluentTester --project-path src"
|
||||
},
|
||||
|
@ -28,6 +28,7 @@
|
|||
"@uifabricshared/build-native": "^0.1.1",
|
||||
"@uifabricshared/eslint-config-rules": "^0.1.1",
|
||||
"@react-native-community/eslint-config": "^1.1.0",
|
||||
"@rnx-kit/cli": "^0.0.3",
|
||||
"babel-jest": "^24.9.0",
|
||||
"jest": "^24.9.0",
|
||||
"metro-config": "^0.58.0",
|
||||
|
@ -41,14 +42,13 @@
|
|||
"jest": {
|
||||
"preset": "react-native"
|
||||
},
|
||||
"metroBundles": {
|
||||
"targets": [
|
||||
"macos"
|
||||
],
|
||||
"entry": "index.js",
|
||||
"outputPath": "./dist",
|
||||
"bundleName": "index.bundle",
|
||||
"noPlatformSuffix": true
|
||||
"rnx-kit": {
|
||||
"bundle": {
|
||||
"targets": [
|
||||
"macos"
|
||||
],
|
||||
"entryPath": "index.js"
|
||||
}
|
||||
},
|
||||
"depcheck": {
|
||||
"ignoreMatches": [
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
"code-style": "fluentui-scripts code-style",
|
||||
"depcheck": "fluentui-scripts depcheck",
|
||||
"lint": "fluentui-scripts eslint",
|
||||
"start": "fluentui-scripts metro --server --cli --port 8081",
|
||||
"start": "react-native rnx-start --server --port 8081",
|
||||
"test": "fluentui-scripts jest",
|
||||
"bundle": "fluentui-scripts metro --platform win32 --cli",
|
||||
"bundle-dev": "fluentui-scripts metro -platform win32 --dev --cli",
|
||||
"bundle": "react-native rnx-bundle --dev false",
|
||||
"bundle-dev": "react-native rnx-bundle",
|
||||
"run-win32": "rex-win32 --bundle index --component FluentTester --windowTitle \"FluentUI Tester\" --basePath ./dist --pluginProps",
|
||||
"run-win32-web": "rex-win32 --bundle index --component FluentTester --basePath ./dist --useWebDebugger --windowTitle \"FluentUI Tester\" --useFastRefresh --pluginProps",
|
||||
"run-win32-devmain": "rex-win32 --bundle index --component FluentTester --basePath ./dist --useDevMain --windowTitle \"FluentUI Tester\" --pluginProps",
|
||||
|
@ -36,6 +36,7 @@
|
|||
"@office-iss/rex-win32": "0.62.12-devmain.13420.10000",
|
||||
"@office-iss/react-native-win32": "0.62.6",
|
||||
"@react-native-community/eslint-config": "^1.1.0",
|
||||
"@rnx-kit/cli": "^0.0.3",
|
||||
"@types/jasmine": "3.5.10",
|
||||
"@types/react": "^16.9.34",
|
||||
"@types/react-native": "^0.62.0",
|
||||
|
@ -66,13 +67,12 @@
|
|||
"jest": {
|
||||
"preset": "react-native"
|
||||
},
|
||||
"metroBundles": {
|
||||
"targets": [
|
||||
"win32"
|
||||
],
|
||||
"entry": "index.js",
|
||||
"outputPath": "./dist",
|
||||
"bundleName": "index.bundle",
|
||||
"noPlatformSuffix": true
|
||||
"rnx-kit": {
|
||||
"bundle": {
|
||||
"targets": [
|
||||
"win32"
|
||||
],
|
||||
"entryPath": "index.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ const fs = require('fs');
|
|||
const rimraf = require('rimraf');
|
||||
|
||||
const appPath = path.resolve(path.dirname(require.resolve('@office-iss/rex-win32/rex-win32.js')), 'ReactTest.exe');
|
||||
const appArgs = 'basePath ' + path.resolve('dist') + ' plugin defaultplugin bundle index component FluentTester';
|
||||
const appArgs = 'basePath ' + path.resolve('dist') + ' plugin defaultplugin bundle index.win32 component FluentTester';
|
||||
const appDir = path.dirname(require.resolve('@office-iss/rex-win32/rex-win32.js'));
|
||||
|
||||
const defaultWaitForTimeout = 10000;
|
||||
|
@ -123,7 +123,7 @@ exports.config = {
|
|||
* @param {Array.<Object>} capabilities list of capabilities details
|
||||
* @param {Array.<String>} specs List of spec file paths that are to be run
|
||||
*/
|
||||
before: function() {
|
||||
before: function () {
|
||||
// not needed for Cucumber
|
||||
require('ts-node').register({ files: true });
|
||||
browser.maximizeWindow();
|
||||
|
@ -217,7 +217,7 @@ exports.config = {
|
|||
* @param {Array.<Object>} capabilities list of capabilities details
|
||||
* @param {<Object>} results object containing test results
|
||||
*/
|
||||
onComplete: function(exitCode, config, capabilities, results) {
|
||||
onComplete: function (exitCode, config, capabilities, results) {
|
||||
console.log('<<< TESTING FINISHED >>>');
|
||||
},
|
||||
/**
|
||||
|
@ -227,4 +227,4 @@ exports.config = {
|
|||
*/
|
||||
//onReload: function(oldSessionId, newSessionId) {
|
||||
//}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"bundle": "fluentui-scripts metro --cli",
|
||||
"bundle": "react-native rnx-bundle --dev false",
|
||||
"depcheck": "fluentui-scripts depcheck",
|
||||
"e2etest": "rimraf reports/* && wdio",
|
||||
"generate-report": "allure generate allure-results --clean && allure open",
|
||||
"lint": "eslint .",
|
||||
"report": "allure generate allure-results --clean",
|
||||
"start": "react-native start",
|
||||
"start": "react-native rnx-start",
|
||||
"test": "jest",
|
||||
"windows": "react-native run-windows"
|
||||
},
|
||||
|
@ -23,6 +23,7 @@
|
|||
"@babel/core": "^7.6.2",
|
||||
"@babel/runtime": "^7.6.2",
|
||||
"@react-native-community/eslint-config": "^1.1.0",
|
||||
"@rnx-kit/cli": "^0.0.3",
|
||||
"@uifabricshared/build-native": "0.1.1",
|
||||
"babel-jest": "^24.9.0",
|
||||
"eslint": "^6.5.1",
|
||||
|
@ -54,14 +55,13 @@
|
|||
"jest": {
|
||||
"preset": "react-native"
|
||||
},
|
||||
"metroBundles": {
|
||||
"targets": [
|
||||
"windows"
|
||||
],
|
||||
"entry": "index.js",
|
||||
"outputPath": "./dist",
|
||||
"bundleName": "index.bundle",
|
||||
"noPlatformSuffix": true
|
||||
"rnx-kit": {
|
||||
"bundle": {
|
||||
"targets": [
|
||||
"windows"
|
||||
],
|
||||
"entryPath": "index.js"
|
||||
}
|
||||
},
|
||||
"depcheck": {
|
||||
"ignoreMatches": [
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"type": "patch",
|
||||
"comment": "Remove metro logic from FURN, replacing it with calls to the @rnx-kit CLI. Use rnx-bundle for bundling, and rnx-start for running a bundle server.",
|
||||
"packageName": "@fluentui-react-native/tester",
|
||||
"email": "afoxman@microsoft.com",
|
||||
"dependentChangeType": "patch",
|
||||
"date": "2021-02-25T00:44:55.752Z"
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"type": "patch",
|
||||
"comment": "Remove metro logic from FURN, replacing it with calls to the @rnx-kit CLI. Use rnx-bundle for bundling, and rnx-start for running a bundle server.",
|
||||
"packageName": "@fluentui-react-native/tester-win32",
|
||||
"email": "afoxman@microsoft.com",
|
||||
"dependentChangeType": "patch",
|
||||
"date": "2021-02-25T00:44:58.938Z"
|
||||
}
|
|
@ -58,7 +58,6 @@
|
|||
"just-repo-utils": "^0.2.0",
|
||||
"just-scripts": "^0.38.0",
|
||||
"just-task": "^0.14.3",
|
||||
"metro": "^0.58.0",
|
||||
"metro-config": "^0.58.0",
|
||||
"metro-react-native-babel-transformer": "^0.58.0",
|
||||
"prettier": "~1.17.0",
|
||||
|
|
|
@ -15,8 +15,6 @@ const { depcheckTask } = require('./tasks/depcheck');
|
|||
const { verifyApiExtractor, updateApiExtractor } = require('./tasks/api-extractor');
|
||||
const checkForModifiedFiles = require('./tasks/check-for-modified-files');
|
||||
|
||||
import { metroTask } from './tasks/metroTask';
|
||||
|
||||
export function preset() {
|
||||
// this add s a resolve path for the build tooling deps like TS from the scripts folder
|
||||
addResolvePath(__dirname);
|
||||
|
@ -31,15 +29,6 @@ export function preset() {
|
|||
// Build only commonjs (not other TS variants) but still run other tasks
|
||||
option('commonjs');
|
||||
|
||||
// use Metro for bundling task instead of the default webpack
|
||||
option('useMetro');
|
||||
option('dev');
|
||||
option('platform', { string: true });
|
||||
option('bundleName', { string: true });
|
||||
option('server');
|
||||
option('port', { number: true });
|
||||
option('cli');
|
||||
|
||||
// for options that have a check/fix switch this puts them into fix mode
|
||||
option('fix');
|
||||
|
||||
|
@ -67,18 +56,7 @@ export function preset() {
|
|||
|
||||
task('build:node-lib', series('clean', 'copy', series(condition('validate', () => !argv().min), 'ts:commonjs-only')));
|
||||
|
||||
task('metro', () =>
|
||||
metroTask({
|
||||
dev: !!argv().dev,
|
||||
...(argv().cli && { cli: true }),
|
||||
...(argv().platform && { platform: argv().platform }),
|
||||
...(argv().bundleName && { bundleName: argv().bundleName }),
|
||||
...(argv().server && { server: true }),
|
||||
...(argv().server && argv().port && { port: argv().port }),
|
||||
}),
|
||||
);
|
||||
|
||||
task('bundle', series(condition('metro', () => !!argv().useMetro), condition('webpack', () => !argv().useMetro)));
|
||||
task('bundle', series('webpack'));
|
||||
|
||||
task('build', series('clean', 'copy', 'ts'));
|
||||
|
||||
|
|
|
@ -1,247 +0,0 @@
|
|||
// @ts-check
|
||||
import Metro from 'metro';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import { logger, TaskFunction } from 'just-task';
|
||||
import { AllPlatforms } from '../utils/platforms';
|
||||
import { addPlatformMetroConfig } from '../configs/configureMetro';
|
||||
import { spawnSync } from 'child_process';
|
||||
|
||||
export interface BundleDetails {
|
||||
/**
|
||||
* entry file such as './src/index.ts'
|
||||
*/
|
||||
entry?: string;
|
||||
outputPath?: string;
|
||||
bundleName?: string;
|
||||
noPlatformSuffix?: boolean;
|
||||
}
|
||||
|
||||
export type BundleDefinition = BundleDetails & {
|
||||
name?: string;
|
||||
targets?: AllPlatforms[];
|
||||
platforms?: { [K in AllPlatforms]: BundleDetails };
|
||||
};
|
||||
|
||||
export type MetroBundles = BundleDefinition | BundleDefinition[];
|
||||
|
||||
function asArray<T>(opt: T | T[]): T[] {
|
||||
return Array.isArray(opt) ? opt : [opt || ({} as T)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a bundle definition from package.json. The bundle definition should be of type BundleDefinition and would
|
||||
* typically look something like:
|
||||
* "metroBundles": {
|
||||
* "targets": ["win32", "windows"],
|
||||
* "entryFile": "./src/index.ts",
|
||||
* "outputPath": "./dist",
|
||||
* "outputFile": "myBundleName"
|
||||
* }
|
||||
*
|
||||
* Platform specific overrides can be specified by using a platforms which works as a selector. In this case
|
||||
* add:
|
||||
* "metroBundles": {
|
||||
* ...stuff
|
||||
* "platforms": {
|
||||
* "ios": {
|
||||
* "outputFile": "myIOSName"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* @param bundleName - optional name of the bundle, use if there are multiple bundles defined in package JSON
|
||||
*/
|
||||
function loadBundleDefinition(bundleName?: string): BundleDefinition {
|
||||
const packageConfigPath = path.resolve(process.cwd(), 'package.json');
|
||||
const packageConfig = JSON.parse(fs.readFileSync(packageConfigPath, 'utf8'));
|
||||
|
||||
const metroBundles = asArray<BundleDefinition>(packageConfig.metroBundles);
|
||||
if (bundleName) {
|
||||
return metroBundles.find(bundle => bundle.name === bundleName) || {};
|
||||
}
|
||||
|
||||
if (metroBundles.length > 1) {
|
||||
logger.error('Multiple bundles are specified in the package, so bundle is ambiguous');
|
||||
} else if (metroBundles.length === 0) {
|
||||
logger.error('The package must contain a bundle definition');
|
||||
}
|
||||
return metroBundles[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the platform selector for each bundle target
|
||||
* @param bundle - bundle definition, potentially including a platform selector
|
||||
* @param platform - current platform target
|
||||
*/
|
||||
function getOptionsForPlatform(bundle: BundleDefinition, platform: AllPlatforms): BundleDefinition {
|
||||
const platformValues = bundle.platforms && bundle.platforms[platform];
|
||||
return platformValues ? { ...bundle, ...platformValues } : bundle;
|
||||
}
|
||||
|
||||
/**
|
||||
* options for the metro task
|
||||
*/
|
||||
export interface MetroTaskOptions {
|
||||
/**
|
||||
* name of the bundle to target, can be blank if the package.json only includes one bundle
|
||||
*/
|
||||
bundleName?: string;
|
||||
|
||||
/**
|
||||
* platform to bundle for, if blank will bundle for all platforms in this folder
|
||||
*/
|
||||
platform?: AllPlatforms;
|
||||
|
||||
/**
|
||||
* whether to bundle in development mode
|
||||
*/
|
||||
dev?: boolean;
|
||||
|
||||
/**
|
||||
* run metro in server mode
|
||||
*/
|
||||
server?: boolean;
|
||||
|
||||
/**
|
||||
* port override for server mode
|
||||
*/
|
||||
port?: number;
|
||||
|
||||
/**
|
||||
* route the task to the CLI
|
||||
*/
|
||||
cli?: boolean;
|
||||
}
|
||||
|
||||
function runMetroFromCli(platform: AllPlatforms, entry: string, out: string, assetsOut: string, dev: boolean, server: boolean, port?: number): void {
|
||||
const options = { cwd: process.cwd(), stdio: 'inherit' } as any;
|
||||
const yarnCmd = os.platform() === 'win32' ? 'yarn.cmd' : 'yarn';
|
||||
if (server) {
|
||||
spawnSync(yarnCmd, ['react-native', 'start', ...(port && ['--port', port.toString()])], options);
|
||||
} else {
|
||||
logger.info(`Starting metro bundling for ${platform}.`);
|
||||
logger.info(`Entry file ${entry}.`);
|
||||
logger.info(`Output file ${out}.`);
|
||||
const sourceMap = dev && out + '.map';
|
||||
const devValue = dev ? 'true' : 'false';
|
||||
spawnSync(
|
||||
yarnCmd,
|
||||
[
|
||||
'react-native',
|
||||
'bundle',
|
||||
'--platform',
|
||||
platform,
|
||||
'--entry-file',
|
||||
entry,
|
||||
'--bundle-output',
|
||||
out,
|
||||
'--dev',
|
||||
devValue,
|
||||
'--assets-dest',
|
||||
assetsOut,
|
||||
...((sourceMap && ['--sourcemap-output', sourceMap]) || []),
|
||||
],
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function runMetroDirect(
|
||||
platform: AllPlatforms,
|
||||
entry: string,
|
||||
out: string,
|
||||
dev: boolean,
|
||||
server: boolean,
|
||||
port?: number,
|
||||
): Promise<void> {
|
||||
// get the config file, checking if there is a platform specific override
|
||||
let configName = `metro.config.${platform}.js`;
|
||||
configName = fs.existsSync(path.join(process.cwd(), configName)) ? configName : 'metro.config.js';
|
||||
const configBase = await Metro.loadConfig({ config: configName });
|
||||
|
||||
// add platform specific details for bundling this config
|
||||
const config = addPlatformMetroConfig(platform, configBase) as any;
|
||||
if (server) {
|
||||
config.server = config.server || {};
|
||||
config.server.port = port;
|
||||
}
|
||||
|
||||
if (server) {
|
||||
// for server start up the server, note that this is for only one platform, at least by configuration
|
||||
logger.info(`Starting metro server for ${platform} platform on port ${port}.`);
|
||||
|
||||
await Metro.runServer(config, { port: port });
|
||||
} else {
|
||||
// log out what is about to happen
|
||||
logger.info(`Starting metro bundling for ${platform}.`);
|
||||
logger.info(`Entry file ${entry}.`);
|
||||
logger.info(`Output file ${out}.`);
|
||||
const sourceMap = dev && out + '.map';
|
||||
|
||||
// now run the bundle task itself
|
||||
await Metro.runBuild(config, {
|
||||
platform: platform,
|
||||
entry,
|
||||
minify: !dev,
|
||||
out,
|
||||
optimize: !dev,
|
||||
sourceMap,
|
||||
});
|
||||
}
|
||||
|
||||
// optionally rename the output to remove the JS extension if requested
|
||||
if (!out.endsWith('.js')) {
|
||||
const metroBundlePath = out + '.js';
|
||||
if (fs.existsSync(metroBundlePath)) {
|
||||
if (fs.existsSync(out)) {
|
||||
logger.verbose(`Deleting existing output file at ${out}...`);
|
||||
fs.unlinkSync(out);
|
||||
}
|
||||
|
||||
logger.verbose(`Renaming ${metroBundlePath} to ${out}...`);
|
||||
fs.renameSync(metroBundlePath, out);
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(`Finished bundling ${out} for ${platform}.`);
|
||||
}
|
||||
|
||||
export function metroTask(options: MetroTaskOptions = {}): TaskFunction {
|
||||
const { bundleName, platform, dev = false, server, cli, port } = options;
|
||||
|
||||
return async function metroPack(done) {
|
||||
logger.verbose(`Starting metropack task with platform ${bundleName}...`);
|
||||
|
||||
// get the bundle definition
|
||||
const definition = loadBundleDefinition(bundleName);
|
||||
const targets = (platform && [platform]) || definition.targets || [];
|
||||
|
||||
for (const targetPlatform of targets) {
|
||||
// get the options specified for the platform
|
||||
const platformDefinition = getOptionsForPlatform(definition, targetPlatform);
|
||||
|
||||
// set up file input and output
|
||||
const { entry = './lib/index.js', outputPath = './dist', bundleName, noPlatformSuffix } = platformDefinition;
|
||||
let out = path.join(outputPath, bundleName);
|
||||
if (!noPlatformSuffix) {
|
||||
out = `${out}.${targetPlatform}`;
|
||||
}
|
||||
|
||||
// ensure the parent directory exists for the target output
|
||||
const parentDirectory = path.dirname(path.resolve(process.cwd(), out));
|
||||
if (!fs.existsSync(parentDirectory)) {
|
||||
fs.mkdirSync(parentDirectory);
|
||||
}
|
||||
|
||||
if (cli) {
|
||||
runMetroFromCli(targetPlatform, entry, out, outputPath, !!dev, server, port);
|
||||
} else {
|
||||
await runMetroDirect(targetPlatform, entry, out, !!dev, server, port);
|
||||
}
|
||||
}
|
||||
if (done) {
|
||||
done();
|
||||
}
|
||||
};
|
||||
}
|
81
yarn.lock
81
yarn.lock
|
@ -2242,6 +2242,24 @@
|
|||
resolved "https://registry.yarnpkg.com/@react-native-community/eslint-plugin/-/eslint-plugin-1.1.0.tgz#e42b1bef12d2415411519fd528e64b593b1363dc"
|
||||
integrity sha512-W/J0fNYVO01tioHjvYWQ9m6RgndVtbElzYozBq1ZPrHO/iCzlqoySHl4gO/fpCl9QEFjvJfjPgtPMTMlsoq5DQ==
|
||||
|
||||
"@rnx-kit/cli@^0.0.3":
|
||||
version "0.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@rnx-kit/cli/-/cli-0.0.3.tgz#4802437bcfd9ef598080e1e7a12d387df0334ecb"
|
||||
integrity sha512-wlN4BsxVGTYMsHp3fmKpQcS/9x+BlVwSQeXEX3ufkF8vbpykODQbf38VAFqW8VgoPOmQRz9pMOAC5aEFTxwYPw==
|
||||
dependencies:
|
||||
"@rnx-kit/config" "0.1.2"
|
||||
chalk "^4.1.0"
|
||||
|
||||
"@rnx-kit/config@0.1.2":
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@rnx-kit/config/-/config-0.1.2.tgz#ff2699bdd31d976289204c0d664ff0d32f2d85ca"
|
||||
integrity sha512-fjKI7hZZN73D4wlIVAM4t/dx04zXWF/iqp5bXwqJaNQFDpTr/KuQvEt9h73ZUfEgyEUcsNHNA/P3d4a5p5QSdg==
|
||||
dependencies:
|
||||
cosmiconfig "^7.0.0"
|
||||
fs "^0.0.1-security"
|
||||
path "^0.12.7"
|
||||
workspace-tools "^0.10.2"
|
||||
|
||||
"@rushstack/node-core-library@3.25.0":
|
||||
version "3.25.0"
|
||||
resolved "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-3.25.0.tgz#ba40bc1b188ab5d31f5705999cd2b3b56b8a32cf"
|
||||
|
@ -6072,6 +6090,17 @@ cosmiconfig@^6.0.0:
|
|||
path-type "^4.0.0"
|
||||
yaml "^1.7.2"
|
||||
|
||||
cosmiconfig@^7.0.0:
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.0.0.tgz#ef9b44d773959cae63ddecd122de23853b60f8d3"
|
||||
integrity sha512-pondGvTuVYDk++upghXJabWzL6Kxu6f26ljFw64Swq9v6sQPUL3EUlVDV56diOjpCayKihL6hVe8exIACU4XcA==
|
||||
dependencies:
|
||||
"@types/parse-json" "^4.0.0"
|
||||
import-fresh "^3.2.1"
|
||||
parse-json "^5.0.0"
|
||||
path-type "^4.0.0"
|
||||
yaml "^1.10.0"
|
||||
|
||||
crc32-stream@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/crc32-stream/-/crc32-stream-3.0.1.tgz#cae6eeed003b0e44d739d279de5ae63b171b4e85"
|
||||
|
@ -8521,6 +8550,11 @@ fs.realpath@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
|
||||
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
|
||||
|
||||
fs@^0.0.1-security:
|
||||
version "0.0.1-security"
|
||||
resolved "https://registry.yarnpkg.com/fs/-/fs-0.0.1-security.tgz#8a7bd37186b6dddf3813f23858b57ecaaf5e41d4"
|
||||
integrity sha1-invTcYa23d84E/I4WLV+yq9eQdQ=
|
||||
|
||||
fsevents@2.x, fsevents@~2.1.2:
|
||||
version "2.1.3"
|
||||
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e"
|
||||
|
@ -9342,6 +9376,14 @@ import-fresh@^3.0.0, import-fresh@^3.1.0:
|
|||
parent-module "^1.0.0"
|
||||
resolve-from "^4.0.0"
|
||||
|
||||
import-fresh@^3.2.1:
|
||||
version "3.3.0"
|
||||
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b"
|
||||
integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==
|
||||
dependencies:
|
||||
parent-module "^1.0.0"
|
||||
resolve-from "^4.0.0"
|
||||
|
||||
import-lazy@~4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/import-lazy/-/import-lazy-4.0.0.tgz#e8eb627483a0a43da3c03f3e35548be5cb0cc153"
|
||||
|
@ -13297,6 +13339,14 @@ path-type@^4.0.0:
|
|||
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
|
||||
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
|
||||
|
||||
path@^0.12.7:
|
||||
version "0.12.7"
|
||||
resolved "https://registry.yarnpkg.com/path/-/path-0.12.7.tgz#d4dc2a506c4ce2197eb481ebfcd5b36c0140b10f"
|
||||
integrity sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=
|
||||
dependencies:
|
||||
process "^0.11.1"
|
||||
util "^0.10.3"
|
||||
|
||||
pbkdf2@^3.0.3:
|
||||
version "3.0.17"
|
||||
resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.17.tgz#976c206530617b14ebb32114239f7b09336e93a6"
|
||||
|
@ -13595,7 +13645,7 @@ process-nextick-args@^2.0.0, process-nextick-args@~2.0.0:
|
|||
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
|
||||
integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==
|
||||
|
||||
process@^0.11.10:
|
||||
process@^0.11.1, process@^0.11.10:
|
||||
version "0.11.10"
|
||||
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
|
||||
integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI=
|
||||
|
@ -16564,6 +16614,13 @@ util@0.10.3:
|
|||
dependencies:
|
||||
inherits "2.0.1"
|
||||
|
||||
util@^0.10.3:
|
||||
version "0.10.4"
|
||||
resolved "https://registry.yarnpkg.com/util/-/util-0.10.4.tgz#3aa0125bfe668a4672de58857d3ace27ecb76901"
|
||||
integrity sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==
|
||||
dependencies:
|
||||
inherits "2.0.3"
|
||||
|
||||
util@^0.11.0:
|
||||
version "0.11.1"
|
||||
resolved "https://registry.yarnpkg.com/util/-/util-0.11.1.tgz#3236733720ec64bb27f6e26f421aaa2e1b588d61"
|
||||
|
@ -17204,6 +17261,23 @@ workspace-tools@^0.10.1:
|
|||
multimatch "^4.0.0"
|
||||
read-yaml-file "^2.0.0"
|
||||
|
||||
workspace-tools@^0.10.2:
|
||||
version "0.10.3"
|
||||
resolved "https://registry.yarnpkg.com/workspace-tools/-/workspace-tools-0.10.3.tgz#1517ecd97bc4f34c586be6a160da6d8a3a6c3c87"
|
||||
integrity sha512-5DV0C38UBwDRQ9GDINatw2UELbaK/IeBgEpvERpf7vNIfiG0GHInrNhm0jXfiS8sLOpp340m64+tF4L3UHpVrw==
|
||||
dependencies:
|
||||
"@pnpm/lockfile-file" "^3.0.7"
|
||||
"@pnpm/logger" "^3.2.2"
|
||||
"@yarnpkg/lockfile" "^1.1.0"
|
||||
find-up "^4.1.0"
|
||||
find-yarn-workspace-root "^1.2.1"
|
||||
fs-extra "^9.0.0"
|
||||
git-url-parse "^11.1.2"
|
||||
globby "^11.0.0"
|
||||
jju "^1.4.0"
|
||||
multimatch "^4.0.0"
|
||||
read-yaml-file "^2.0.0"
|
||||
|
||||
workspace-tools@^0.9.0, workspace-tools@^0.9.3:
|
||||
version "0.9.4"
|
||||
resolved "https://registry.yarnpkg.com/workspace-tools/-/workspace-tools-0.9.4.tgz#5d74592a380710177cd82b9806e6df7aedf9abf7"
|
||||
|
@ -17464,6 +17538,11 @@ yallist@^3.0.0, yallist@^3.0.2, yallist@^3.0.3:
|
|||
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd"
|
||||
integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==
|
||||
|
||||
yaml@^1.10.0:
|
||||
version "1.10.0"
|
||||
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e"
|
||||
integrity sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg==
|
||||
|
||||
yaml@^1.7.2:
|
||||
version "1.9.2"
|
||||
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.9.2.tgz#f0cfa865f003ab707663e4f04b3956957ea564ed"
|
||||
|
|
Загрузка…
Ссылка в новой задаче