Merge branch 'dev' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-cli into dev
This commit is contained in:
commit
72f6cc7e65
|
|
@ -118,7 +118,7 @@ async function create(dirName, cmd) {
|
|||
const { name, version, title, description } = await inquirer_1.default.prompt(prompt);
|
||||
// 获取package.json内容
|
||||
const packageJson = (0, template_1.packageJsonContent)({
|
||||
name: DEFAULT_PROJECT_NAME,
|
||||
name: DEFAULT_PROJECT_NAME, // 后面再统一rename
|
||||
version,
|
||||
description,
|
||||
cliName: config_1.CLI_NAME,
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
12
lib/run.js
12
lib/run.js
|
|
@ -8,7 +8,8 @@ const fs_1 = require("fs");
|
|||
async function run(options) {
|
||||
const prjDir = process.cwd();
|
||||
const cwd = (0, path_1.resolve)(process.cwd(), options.subDir || 'native');
|
||||
const mode = options.mode || 'development'; //development/staging/production
|
||||
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')}`);
|
||||
|
|
@ -28,11 +29,18 @@ async function run(options) {
|
|||
else if (options.platform === 'android') {
|
||||
(0, tip_style_1.Success)(`${(0, tip_style_1.primary)('run react-native run-android')}`);
|
||||
(0, fs_1.copyFileSync)((0, path_1.resolve)(prjDir, 'package.json'), (0, path_1.resolve)(cwd, 'package.json'));
|
||||
const variantMap = {
|
||||
development: 'debug',
|
||||
staging: 'staging',
|
||||
production: 'release',
|
||||
};
|
||||
const variant = variantMap[mode];
|
||||
const result = cross_spawn_1.default.sync('cross-env', [
|
||||
`NODE_ENV=${mode}`,
|
||||
'react-native',
|
||||
'run-android',
|
||||
mode === 'production' ? '--variant=release' : '',
|
||||
`--variant=${variant}`,
|
||||
appIdSuffix ? `--appIdSuffix=${appIdSuffix}` : '',
|
||||
].filter(Boolean), {
|
||||
cwd,
|
||||
stdio: 'inherit',
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ async function startup(path, contextBuilder, connector, omitWatchers, omitTimers
|
|||
path: connector.getSubscribeRouter(),
|
||||
};
|
||||
socketOption.cors = {
|
||||
origin: '*',
|
||||
origin: '*', // 允许跨域访问
|
||||
allowedHeaders: ["oak-cxt"],
|
||||
};
|
||||
const io = new socket_io_1.Server(httpServer, socketOption);
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
12
src/run.ts
12
src/run.ts
|
|
@ -13,7 +13,8 @@ import { copyFileSync, unlinkSync } from 'fs';
|
|||
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'; //development/staging/production
|
||||
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')}`);
|
||||
|
|
@ -37,13 +38,20 @@ export default async function run(options: any): Promise<void> {
|
|||
else if (options.platform === 'android') {
|
||||
Success(`${primary('run react-native run-android')}`);
|
||||
copyFileSync(resolve(prjDir, 'package.json'), resolve(cwd, 'package.json'));
|
||||
const variantMap = {
|
||||
development: 'debug',
|
||||
staging: 'staging',
|
||||
production: 'release',
|
||||
};
|
||||
const variant = variantMap[mode];
|
||||
const result = spawn.sync(
|
||||
'cross-env',
|
||||
[
|
||||
`NODE_ENV=${mode}`,
|
||||
'react-native',
|
||||
'run-android',
|
||||
mode === 'production' ? '--variant=release' : '',
|
||||
`--variant=${variant}`,
|
||||
appIdSuffix ? `--appIdSuffix=${appIdSuffix}` : '',
|
||||
].filter(Boolean),
|
||||
{
|
||||
cwd,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
/**
|
||||
* 初始化,App也必须输入访问的目标域名,系统根据domain和system的关系来判定appId
|
||||
*/
|
||||
const env = process.env.NODE_ENV;
|
||||
|
||||
const URL = {
|
||||
// 服务器地址数组,和application的domain中要保持一致以确定application
|
||||
development: 'localhost',
|
||||
staging: 'test.com',
|
||||
production: 'test.com',
|
||||
};
|
||||
|
||||
const host = URL[env];
|
||||
|
||||
export {
|
||||
host,
|
||||
};
|
||||
Loading…
Reference in New Issue