From 8dd174b7710e95f114b5b91930a6faec71f96e13 Mon Sep 17 00:00:00 2001 From: wkj <278599135@.com> Date: Sun, 7 Jan 2024 11:15:28 +0800 Subject: [PATCH] =?UTF-8?q?rn=20run=20=E5=A2=9E=E5=8A=A0appIdSuffix?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81=E5=A4=9Aapplicationid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/index.js | 3 ++- lib/run.js | 26 ++++++++++++-------------- src/index.ts | 3 ++- src/run.ts | 2 ++ 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/index.js b/lib/index.js index 71732a0..d9072fd 100755 --- a/lib/index.js +++ b/lib/index.js @@ -92,7 +92,8 @@ commander_1.default .option('-p, --platform ', 'platform') .option('-d, --subDir ', 'subDirName') .option('-m, --mode ', 'mode') - .description(`run backend server by ${config_1.CLI_NAME}`) + .option('-suffix, --appIdSuffix ', 'appIdSuffix') + .description(`run rn by ${config_1.CLI_NAME}`) .action(run_1.default); commander_1.default .command('clean') diff --git a/lib/run.js b/lib/run.js index 9f3bede..4d431e1 100644 --- a/lib/run.js +++ b/lib/run.js @@ -9,6 +9,7 @@ async function run(options) { const prjDir = process.cwd(); const cwd = (0, path_1.resolve)(process.cwd(), options.subDir || 'native'); const mode = (options.mode || 'development'); + const appIdSuffix = options.appIdSuffix; if (options.platform === 'ios') { (0, fs_1.copyFileSync)((0, path_1.resolve)(prjDir, 'package.json'), (0, path_1.resolve)(cwd, 'package.json')); (0, tip_style_1.Success)(`${(0, tip_style_1.primary)('run react-native run-ios')}`); @@ -34,20 +35,17 @@ async function run(options) { production: 'release', }; const variant = variantMap[mode]; - const result = cross_spawn_1.default.sync( - 'cross-env', - [ - `NODE_ENV=${mode}`, - 'react-native', - 'run-android', - `--variant=${variant}`, - ].filter(Boolean), - { - cwd, - stdio: 'inherit', - shell: true, - } - ); + const result = cross_spawn_1.default.sync('cross-env', [ + `NODE_ENV=${mode}`, + 'react-native', + 'run-android', + `--variant=${variant}`, + appIdSuffix ? `--appIdSuffix=${appIdSuffix}` : '', + ].filter(Boolean), { + cwd, + stdio: 'inherit', + shell: true, + }); if (result.status === 0) { (0, tip_style_1.Success)(`${(0, tip_style_1.success)(`react-native run-android success`)}`); } diff --git a/src/index.ts b/src/index.ts index 9680e87..a6b753a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -98,7 +98,8 @@ program .option('-p, --platform ', 'platform') .option('-d, --subDir ', 'subDirName') .option('-m, --mode ', 'mode') - .description(`run backend server by ${CLI_NAME}`) + .option('-suffix, --appIdSuffix ', 'appIdSuffix') + .description(`run rn by ${CLI_NAME}`) .action(run); program .command('clean') diff --git a/src/run.ts b/src/run.ts index cc12852..13e32c0 100644 --- a/src/run.ts +++ b/src/run.ts @@ -14,6 +14,7 @@ export default async function run(options: any): Promise { const prjDir = process.cwd(); const cwd = resolve(process.cwd(), options.subDir || 'native'); const mode = (options.mode || 'development') as 'development' | 'staging' |'production'; + const appIdSuffix = options.appIdSuffix; if (options.platform === 'ios') { copyFileSync(resolve(prjDir, 'package.json'), resolve(cwd, 'package.json')); Success(`${primary('run react-native run-ios')}`); @@ -50,6 +51,7 @@ export default async function run(options: any): Promise { 'react-native', 'run-android', `--variant=${variant}`, + appIdSuffix ? `--appIdSuffix=${appIdSuffix}` : '', ].filter(Boolean), { cwd,