rn run 增加appIdSuffix,支持多applicationid

This commit is contained in:
wkj 2024-01-07 11:15:28 +08:00
parent ccceb306c0
commit 8dd174b771
4 changed files with 18 additions and 16 deletions

View File

@ -92,7 +92,8 @@ commander_1.default
.option('-p, --platform <platform>', 'platform')
.option('-d, --subDir <subDirName>', 'subDirName')
.option('-m, --mode <mode>', 'mode')
.description(`run backend server by ${config_1.CLI_NAME}`)
.option('-suffix, --appIdSuffix <appIdSuffix>', 'appIdSuffix')
.description(`run rn by ${config_1.CLI_NAME}`)
.action(run_1.default);
commander_1.default
.command('clean')

View File

@ -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`)}`);
}

View File

@ -98,7 +98,8 @@ program
.option('-p, --platform <platform>', 'platform')
.option('-d, --subDir <subDirName>', 'subDirName')
.option('-m, --mode <mode>', 'mode')
.description(`run backend server by ${CLI_NAME}`)
.option('-suffix, --appIdSuffix <appIdSuffix>', 'appIdSuffix')
.description(`run rn by ${CLI_NAME}`)
.action(run);
program
.command('clean')

View File

@ -14,6 +14,7 @@ export default async function run(options: any): Promise<void> {
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<void> {
'react-native',
'run-android',
`--variant=${variant}`,
appIdSuffix ? `--appIdSuffix=${appIdSuffix}` : '',
].filter(Boolean),
{
cwd,