修改了对module类项目初始化的过程
This commit is contained in:
parent
3b1ae9a27b
commit
25e4d022e0
|
|
@ -6,7 +6,6 @@ const cross_spawn_1 = tslib_1.__importDefault(require("cross-spawn"));
|
|||
const path_1 = require("path");
|
||||
const makeLocale_1 = tslib_1.__importDefault(require("./makeLocale"));
|
||||
const makeRouter_1 = tslib_1.__importDefault(require("./makeRouter"));
|
||||
const makeDependency_1 = tslib_1.__importDefault(require("./makeDependency"));
|
||||
const fs_1 = require("fs");
|
||||
async function build(cmd) {
|
||||
const mode = (cmd.mode || 'development');
|
||||
|
|
@ -24,11 +23,13 @@ async function build(cmd) {
|
|||
: 'web';
|
||||
}
|
||||
// 先makeLocale
|
||||
(0, makeLocale_1.default)('', mode === 'development');
|
||||
(0, makeLocale_1.default)({
|
||||
watch: mode === 'development',
|
||||
});
|
||||
// 再尝试makeRouter
|
||||
(0, makeRouter_1.default)({ subdir }, mode === 'development');
|
||||
// makeDependency
|
||||
(0, makeDependency_1.default)('');
|
||||
// makeDependency 放到npm install之后做一次
|
||||
// makeDep('');
|
||||
//ts类型检查 waring 还是error,
|
||||
//主要web受影响,error级别的话 控制台和网页都报错,warning级别的话 控制台报错
|
||||
// development/staging/production
|
||||
|
|
|
|||
|
|
@ -139,16 +139,8 @@ async function create(dirName, cmd) {
|
|||
};
|
||||
prompt.unshift(nameOption);
|
||||
const isDev = cmd.dev ? true : false;
|
||||
const isModule = cmd.module ? true : false;
|
||||
const { name, version, title, description } = await inquirer_1.default.prompt(prompt);
|
||||
// 获取package.json内容
|
||||
const packageJson = (0, template_1.packageJsonContent)({
|
||||
name: DEFAULT_PROJECT_NAME,
|
||||
version,
|
||||
description,
|
||||
cliName: config_1.CLI_NAME,
|
||||
cliBinName: config_1.CLI_BIN_NAME,
|
||||
isDev,
|
||||
});
|
||||
// 获取tsconfig.json内容
|
||||
const tsconfigJson = (0, template_1.tsConfigJsonContent)();
|
||||
const tsConfigBuildJson = (0, template_1.tsConfigBuildJsonContent)();
|
||||
|
|
@ -183,8 +175,6 @@ async function create(dirName, cmd) {
|
|||
try {
|
||||
// 创建根目录
|
||||
(0, file_handle_1.checkFileExistsAndCreate)(rootPath);
|
||||
// 创建package.json
|
||||
(0, file_handle_1.checkFileExistsAndCreate)(packageJsonPath, packageJson, enum_1.checkFileExistsAndCreateType.FILE);
|
||||
// 创建tsconfig.json
|
||||
(0, file_handle_1.checkFileExistsAndCreate)(tsconfigJsonPath, tsconfigJson, enum_1.checkFileExistsAndCreateType.FILE);
|
||||
// 创建tsconfig.build.json
|
||||
|
|
@ -198,17 +188,24 @@ async function create(dirName, cmd) {
|
|||
// 创建tsconfig.web.json
|
||||
(0, file_handle_1.checkFileExistsAndCreate)(tsConfigWebJsonPath, tsConfigWebJson, enum_1.checkFileExistsAndCreateType.FILE);
|
||||
// 复制项目文件
|
||||
(0, file_handle_1.copyFolder)(currentPath, rootPath);
|
||||
await createWechatMpBoilplate(weChatMpRootPath, isDev);
|
||||
await createWebBoilplate(webRootPath, isDev);
|
||||
if (!shelljs_1.default.which('npm')) {
|
||||
(0, tip_style_1.Warn)((0, tip_style_1.warn)('Sorry, this script requires npm! Please install npm!'));
|
||||
shelljs_1.default.exit(1);
|
||||
if (isModule) {
|
||||
// 模块化的项目,只拷贝src和typings目录
|
||||
(0, file_handle_1.copyFolder)((0, path_1.join)(currentPath, 'src'), (0, path_1.join)(rootPath, 'src'));
|
||||
(0, file_handle_1.copyFolder)((0, path_1.join)(currentPath, 'typings'), (0, path_1.join)(rootPath, 'typings'));
|
||||
}
|
||||
else {
|
||||
(0, file_handle_1.copyFolder)(currentPath, rootPath);
|
||||
await createWechatMpBoilplate(weChatMpRootPath, isDev);
|
||||
await createWebBoilplate(webRootPath, isDev);
|
||||
if (!shelljs_1.default.which('npm')) {
|
||||
(0, tip_style_1.Warn)((0, tip_style_1.warn)('Sorry, this script requires npm! Please install npm!'));
|
||||
shelljs_1.default.exit(1);
|
||||
}
|
||||
/* Success(`${success(`Waiting...`)}`);
|
||||
Success(`${success(`Dependencies are now being installed`)}`);
|
||||
shell.cd(dirName).exec('npm install'); */
|
||||
(0, rename_1.renameProject)(rootPath, name, title, DEFAULT_PROJECT_NAME, DEFAULT_PROJECT_TITLE);
|
||||
}
|
||||
/* Success(`${success(`Waiting...`)}`);
|
||||
Success(`${success(`Dependencies are now being installed`)}`);
|
||||
shell.cd(dirName).exec('npm install'); */
|
||||
(0, rename_1.renameProject)(rootPath, name, title, DEFAULT_PROJECT_NAME, DEFAULT_PROJECT_TITLE);
|
||||
(0, tip_style_1.Success)(`${(0, tip_style_1.success)(`Successfully created project ${(0, tip_style_1.primary)(name)}, directory name is ${(0, tip_style_1.primary)(dirName)}`)}`);
|
||||
const { useOgb, moreDeps } = await inquirer_1.default.prompt([{
|
||||
name: 'useOgb',
|
||||
|
|
@ -228,10 +225,23 @@ async function create(dirName, cmd) {
|
|||
if (moreDeps) {
|
||||
deps.push(...(moreDeps.split(',').map(ele => ele.trim()).filter(ele => !!ele)));
|
||||
}
|
||||
shelljs_1.default.cd(dirName);
|
||||
if (deps.length > 0) {
|
||||
shelljs_1.default.cd(dirName);
|
||||
addDependencies(deps);
|
||||
}
|
||||
// 获取package.json内容
|
||||
const packageJson = (0, template_1.packageJsonContent)({
|
||||
name: DEFAULT_PROJECT_NAME,
|
||||
version,
|
||||
description,
|
||||
cliName: config_1.CLI_NAME,
|
||||
cliBinName: config_1.CLI_BIN_NAME,
|
||||
isDev,
|
||||
isModule,
|
||||
dependencies: deps,
|
||||
});
|
||||
// 创建package.json
|
||||
(0, file_handle_1.checkFileExistsAndCreate)(packageJsonPath, packageJson, enum_1.checkFileExistsAndCreateType.FILE);
|
||||
(0, tip_style_1.Success)(`${(0, tip_style_1.success)(`Ok, type 'npm install' to install libs, then start!`)}`);
|
||||
}
|
||||
catch (err) {
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ commander_1.default
|
|||
commander_1.default
|
||||
.command('make:locale')
|
||||
.description('make locales')
|
||||
.option('-a --asLib', 'asLib')
|
||||
.option('-w --watch', 'watch')
|
||||
.action(makeLocale_1.default);
|
||||
commander_1.default
|
||||
.command('make:dependency')
|
||||
|
|
@ -85,6 +87,7 @@ commander_1.default
|
|||
.command('create <name>')
|
||||
.usage('<name>')
|
||||
.option('-d, --dev', 'dev')
|
||||
.option('-m, --module', 'module')
|
||||
.description(`create a new project powered by ${config_1.CLI_NAME}`)
|
||||
.action(create_1.create);
|
||||
commander_1.default
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ export interface PackageJsonInput {
|
|||
cliName: string;
|
||||
cliBinName: string;
|
||||
isDev?: boolean;
|
||||
dependencies?: string[];
|
||||
isModule: boolean;
|
||||
}
|
||||
/**
|
||||
* @name Prompt需要输入的参数
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
export default function make(cmd: any, watch?: boolean): Promise<void>;
|
||||
export default function make(cmd: any): Promise<void>;
|
||||
|
|
|
|||
|
|
@ -2,34 +2,20 @@
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
const tip_style_1 = require("./tip-style");
|
||||
const cross_spawn_1 = tslib_1.__importDefault(require("cross-spawn"));
|
||||
const path_1 = require("path");
|
||||
async function make(cmd, watch) {
|
||||
const localeBuilder_1 = tslib_1.__importDefault(require("oak-domain/lib/compiler/localeBuilder"));
|
||||
async function make(cmd) {
|
||||
(0, tip_style_1.Success)(`${(0, tip_style_1.success)(`make locales`)}`);
|
||||
// ts-node scripts/build-app-domain & npm link ./app-domain
|
||||
const args = [(0, path_1.resolve)(__dirname, '../scripts/make-locale.js')];
|
||||
if (watch) {
|
||||
args.push('true');
|
||||
const asLib = cmd.asLib;
|
||||
const watch = cmd.watch;
|
||||
try {
|
||||
const builder = new localeBuilder_1.default(!!asLib);
|
||||
builder.build(!!watch);
|
||||
(0, tip_style_1.Success)(`${(0, tip_style_1.success)(`make 执行完成`)}`);
|
||||
}
|
||||
if (!watch) {
|
||||
const result = cross_spawn_1.default.sync('ts-node', args, {
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
});
|
||||
// const result2 = spawn.sync('npm -v', [], { stdio: 'inherit', shell: true });
|
||||
if (result.status === 0) {
|
||||
(0, tip_style_1.Success)(`${(0, tip_style_1.success)(`make 执行完成`)}`);
|
||||
}
|
||||
else {
|
||||
(0, tip_style_1.Error)(`${(0, tip_style_1.error)(`make 执行失败`)}`);
|
||||
process.exit(-1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
(0, cross_spawn_1.default)('ts-node', args, {
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
});
|
||||
catch (err) {
|
||||
(0, tip_style_1.Error)(`${(0, tip_style_1.error)(`make 执行失败`)}`);
|
||||
console.error(err);
|
||||
process.exit(-1);
|
||||
}
|
||||
}
|
||||
exports.default = make;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { PackageJsonInput } from './interface';
|
||||
export declare function packageJsonContent({ name, version, description, cliName, cliBinName, isDev, }: PackageJsonInput): string;
|
||||
export declare function packageJsonContent({ name, version, description, cliName, cliBinName, isDev, isModule, dependencies }: PackageJsonInput): string;
|
||||
export declare function tsConfigJsonContent(): string;
|
||||
export declare function tsConfigBuildJsonContent(): string;
|
||||
export declare function tsConfigBuildPathsJsonContent(): string;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.oakConfigContentWithWeb = exports.oakConfigContentWithWeChatMp = exports.appJsonContentWithWeChatMp = exports.projectConfigContentWithWeChatMp = exports.tsConfigWebJsonContent = exports.tsConfigMpJsonContent = exports.tsConfigPathsJsonContent = exports.tsConfigBuildPathsJsonContent = exports.tsConfigBuildJsonContent = exports.tsConfigJsonContent = exports.packageJsonContent = void 0;
|
||||
const child_process_1 = require("child_process");
|
||||
const fs_1 = require("fs");
|
||||
const path_1 = require("path");
|
||||
/**
|
||||
* 利用npm info获得相应库的最新版本
|
||||
* @param name
|
||||
|
|
@ -12,9 +14,9 @@ function getPackageLatestVersion(name) {
|
|||
const data = result.match(/latest: \d\.\d\.\d\s*published/g);
|
||||
return data[0].slice(8, 13);
|
||||
}
|
||||
function packageJsonContent({ name, version, description, cliName, cliBinName, isDev, }) {
|
||||
let oakDependencyStr;
|
||||
let oakDevDependencyStr;
|
||||
function packageJsonContent({ name, version, description, cliName, cliBinName, isDev, isModule, dependencies }) {
|
||||
let oakDependencyStr = '';
|
||||
let oakDevDependencyStr = '';
|
||||
if (isDev) {
|
||||
oakDependencyStr = `
|
||||
"oak-backend-base": "file:../oak-backend-base",
|
||||
|
|
@ -23,8 +25,17 @@ function packageJsonContent({ name, version, description, cliName, cliBinName, i
|
|||
"oak-domain": "file:../oak-domain",
|
||||
"oak-external-sdk": "file:../oak-external-sdk",
|
||||
"oak-frontend-base": "file:../oak-frontend-base",
|
||||
"oak-general-business": "file:../oak-general-business",
|
||||
"oak-memory-tree-store": "file:../oak-memory-tree-store",`;
|
||||
if (dependencies?.length) {
|
||||
dependencies?.forEach((dep) => {
|
||||
if ((0, fs_1.existsSync)((0, path_1.join)(process.cwd(), '..', dep))) {
|
||||
oakDependencyStr += `\n"${dep}": "file:../${dep}",`;
|
||||
}
|
||||
else {
|
||||
oakDependencyStr += `\n"${dep}": "^${getPackageLatestVersion(dep)}"`;
|
||||
}
|
||||
});
|
||||
}
|
||||
oakDevDependencyStr = `"${cliName}": "file:../oak-cli",`;
|
||||
}
|
||||
else {
|
||||
|
|
@ -36,8 +47,12 @@ function packageJsonContent({ name, version, description, cliName, cliBinName, i
|
|||
"oak-domain": "^${getPackageLatestVersion('oak-domain')}",
|
||||
"oak-external-sdk": "^${getPackageLatestVersion('oak-external-sdk')}",
|
||||
"oak-frontend-base": "^${getPackageLatestVersion('oak-frontend-base')}",
|
||||
"oak-general-business": "^${getPackageLatestVersion('oak-general-business')}",
|
||||
"oak-memory-tree-store": "^${getPackageLatestVersion('oak-memory-tree-store')}",`;
|
||||
if (dependencies?.length) {
|
||||
dependencies?.forEach((dep) => {
|
||||
oakDependencyStr += `\n"${dep}": "^${getPackageLatestVersion(dep)}"`;
|
||||
});
|
||||
}
|
||||
oakDevDependencyStr = `"${cliName}": "^${getPackageLatestVersion(cliName)}",`;
|
||||
}
|
||||
const serverInitScript = isDev ? "cross-env NODE_ENV=development cross-env OAK_PLATFORM=server node scripts/initServer.js" : "cross-env OAK_PLATFORM=server node scripts/initServer.js";
|
||||
|
|
@ -47,8 +62,8 @@ function packageJsonContent({ name, version, description, cliName, cliBinName, i
|
|||
"version": "${version}",
|
||||
"description": "${description}",
|
||||
"scripts": {
|
||||
"make:domain": "${cliBinName} make:domain",
|
||||
"make:locale": "${cliBinName} make:locale",
|
||||
"make:domain": "${isModule ? `cross-env COMPLING_AS_LIB=yes ${cliBinName}` : cliBinName} make:domain",
|
||||
"make:locale": "${cliBinName} make:locale ${isModule ? '-m' : ''}",
|
||||
"make:dep": "${cliBinName} make:dependency",
|
||||
"clean:cache": "rimraf node_modules/.cache",
|
||||
"copy-config-json": "copyfiles -u 1 src/config/*.json lib/",
|
||||
|
|
@ -68,12 +83,12 @@ function packageJsonContent({ name, version, description, cliName, cliBinName, i
|
|||
"build-analyze:web": "${cliBinName} build --target web --mode production --analyze",
|
||||
"build-sourcemap-analyze:web": "${cliBinName} build --target web --mode production --sourcemap --analyze",
|
||||
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && npm run copy-config-json",
|
||||
"prebuild": "npm run make:locale && npm run make:dep",
|
||||
"prebuild": "npm run make:locale",
|
||||
"run:ios": "oak-cli run -p ios",
|
||||
"run:android": "oak-cli run -p android",
|
||||
"server:init": "${serverInitScript}",
|
||||
"server:start": "${serverStartScript}",
|
||||
"postinstall": "npm run make:domain"
|
||||
"postinstall": "npm run make:dep"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
const watch = process.argv[2];
|
||||
const watch = new Boolean(process.argv[2]);
|
||||
const asLib = new Boolean(process.argv[3]);
|
||||
const LocaleBuilder = require('oak-domain/lib/compiler/localeBuilder').default;
|
||||
const builder = new LocaleBuilder(false);
|
||||
const builder = new LocaleBuilder(!!asLib);
|
||||
|
||||
builder.build(!!watch);
|
||||
|
|
@ -37,7 +37,9 @@ export default async function build(cmd: any) {
|
|||
: 'web';
|
||||
}
|
||||
// 先makeLocale
|
||||
makeLocale('', mode === 'development');
|
||||
makeLocale({
|
||||
watch: mode === 'development',
|
||||
});
|
||||
// 再尝试makeRouter
|
||||
makeRouter({ subdir }, mode === 'development');
|
||||
// makeDependency 放到npm install之后做一次
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ function addDependencies(dependencies: string[]) {
|
|||
|
||||
const stmt1 = statements[1];
|
||||
assert(ts.isVariableStatement(stmt1));
|
||||
const { declarationList: { declarations: [ vd ]}} = stmt1;
|
||||
const { declarationList: { declarations: [vd] } } = stmt1;
|
||||
const { name, initializer } = vd;
|
||||
assert(ts.isIdentifier(name) && name.text === 'dependencyConfiguration');
|
||||
assert(ts.isArrayLiteralExpression(initializer!));
|
||||
|
|
@ -222,19 +222,11 @@ export async function create(dirName: string, cmd: any) {
|
|||
};
|
||||
prompt.unshift(nameOption);
|
||||
const isDev = cmd.dev ? true : false;
|
||||
const isModule = cmd.module ? true : false;
|
||||
|
||||
const { name, version, title, description }: PromptInput = await inquirer.prompt(
|
||||
prompt
|
||||
);
|
||||
// 获取package.json内容
|
||||
const packageJson = packageJsonContent({
|
||||
name: DEFAULT_PROJECT_NAME, // 后面再统一rename
|
||||
version,
|
||||
description,
|
||||
cliName: CLI_NAME,
|
||||
cliBinName: CLI_BIN_NAME,
|
||||
isDev,
|
||||
});
|
||||
|
||||
// 获取tsconfig.json内容
|
||||
const tsconfigJson = tsConfigJsonContent();
|
||||
|
|
@ -272,12 +264,6 @@ export async function create(dirName: string, cmd: any) {
|
|||
try {
|
||||
// 创建根目录
|
||||
checkFileExistsAndCreate(rootPath);
|
||||
// 创建package.json
|
||||
checkFileExistsAndCreate(
|
||||
packageJsonPath,
|
||||
packageJson,
|
||||
checkFileExistsAndCreateType.FILE
|
||||
);
|
||||
// 创建tsconfig.json
|
||||
checkFileExistsAndCreate(
|
||||
tsconfigJsonPath,
|
||||
|
|
@ -315,20 +301,28 @@ export async function create(dirName: string, cmd: any) {
|
|||
checkFileExistsAndCreateType.FILE
|
||||
);
|
||||
// 复制项目文件
|
||||
copyFolder(currentPath, rootPath);
|
||||
if (isModule) {
|
||||
// 模块化的项目,只拷贝src和typings目录
|
||||
copyFolder(join(currentPath, 'src'), join(rootPath, 'src'));
|
||||
copyFolder(join(currentPath, 'typings'), join(rootPath, 'typings'));
|
||||
}
|
||||
else {
|
||||
copyFolder(currentPath, rootPath);
|
||||
|
||||
await createWechatMpBoilplate(weChatMpRootPath, isDev);
|
||||
await createWebBoilplate(webRootPath, isDev);
|
||||
if (!shell.which('npm')) {
|
||||
Warn(warn('Sorry, this script requires npm! Please install npm!'));
|
||||
shell.exit(1);
|
||||
await createWechatMpBoilplate(weChatMpRootPath, isDev);
|
||||
await createWebBoilplate(webRootPath, isDev);
|
||||
if (!shell.which('npm')) {
|
||||
Warn(warn('Sorry, this script requires npm! Please install npm!'));
|
||||
shell.exit(1);
|
||||
}
|
||||
|
||||
/* Success(`${success(`Waiting...`)}`);
|
||||
Success(`${success(`Dependencies are now being installed`)}`);
|
||||
shell.cd(dirName).exec('npm install'); */
|
||||
|
||||
renameProject(rootPath, name, title, DEFAULT_PROJECT_NAME, DEFAULT_PROJECT_TITLE);
|
||||
}
|
||||
|
||||
/* Success(`${success(`Waiting...`)}`);
|
||||
Success(`${success(`Dependencies are now being installed`)}`);
|
||||
shell.cd(dirName).exec('npm install'); */
|
||||
|
||||
renameProject(rootPath, name, title, DEFAULT_PROJECT_NAME, DEFAULT_PROJECT_TITLE);
|
||||
|
||||
Success(
|
||||
`${success(
|
||||
|
|
@ -362,11 +356,31 @@ export async function create(dirName: string, cmd: any) {
|
|||
))
|
||||
);
|
||||
}
|
||||
|
||||
shell.cd(dirName);
|
||||
if (deps.length > 0) {
|
||||
shell.cd(dirName);
|
||||
addDependencies(deps);
|
||||
}
|
||||
|
||||
// 获取package.json内容
|
||||
const packageJson = packageJsonContent({
|
||||
name: DEFAULT_PROJECT_NAME, // 后面再统一rename
|
||||
version,
|
||||
description,
|
||||
cliName: CLI_NAME,
|
||||
cliBinName: CLI_BIN_NAME,
|
||||
isDev,
|
||||
isModule,
|
||||
dependencies: deps,
|
||||
});
|
||||
|
||||
// 创建package.json
|
||||
checkFileExistsAndCreate(
|
||||
packageJsonPath,
|
||||
packageJson,
|
||||
checkFileExistsAndCreateType.FILE
|
||||
);
|
||||
|
||||
Success(
|
||||
`${success(
|
||||
`Ok, type 'npm install' to install libs, then start!`
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ program
|
|||
program
|
||||
.command('make:locale')
|
||||
.description('make locales')
|
||||
.option('-a --asLib', 'asLib')
|
||||
.option('-w --watch', 'watch')
|
||||
.action(makeLocale);
|
||||
|
||||
|
||||
|
|
@ -94,6 +96,7 @@ program
|
|||
.command('create <name>')
|
||||
.usage('<name>')
|
||||
.option('-d, --dev', 'dev')
|
||||
.option('-m, --module', 'module')
|
||||
.description(`create a new project powered by ${CLI_NAME}`)
|
||||
.action(create);
|
||||
program
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ export interface PackageJsonInput {
|
|||
cliName: string;
|
||||
cliBinName: string;
|
||||
isDev?: boolean;
|
||||
dependencies?: string[];
|
||||
isModule: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,40 +9,22 @@ import {
|
|||
} from './tip-style';
|
||||
import spawn from 'cross-spawn';
|
||||
import { resolve } from 'path';
|
||||
import LocaleBuilder from 'oak-domain/lib/compiler/localeBuilder';
|
||||
|
||||
export default async function make(cmd: any, watch?: boolean) {
|
||||
export default async function make(cmd: any) {
|
||||
Success(`${success(`make locales`)}`);
|
||||
// ts-node scripts/build-app-domain & npm link ./app-domain
|
||||
const args = [resolve(__dirname, '../scripts/make-locale.js')];
|
||||
if (watch) {
|
||||
args.push('true');
|
||||
}
|
||||
if (!watch) {
|
||||
const result = spawn.sync(
|
||||
'ts-node',
|
||||
args,
|
||||
{
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
}
|
||||
);
|
||||
// const result2 = spawn.sync('npm -v', [], { stdio: 'inherit', shell: true });
|
||||
const asLib = cmd.asLib;
|
||||
const watch = cmd.watch;
|
||||
|
||||
try {
|
||||
const builder = new LocaleBuilder(!!asLib);
|
||||
|
||||
if (result.status === 0) {
|
||||
Success(`${success(`make 执行完成`)}`);
|
||||
} else {
|
||||
Error(`${error(`make 执行失败`)}`);
|
||||
process.exit(-1);
|
||||
}
|
||||
builder.build(!!watch);
|
||||
Success(`${success(`make 执行完成`)}`);
|
||||
}
|
||||
else {
|
||||
spawn(
|
||||
'ts-node',
|
||||
args,
|
||||
{
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
}
|
||||
);
|
||||
catch (err: any) {
|
||||
Error(`${error(`make 执行失败`)}`);
|
||||
console.error(err);
|
||||
process.exit(-1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import { execSync } from 'child_process';
|
||||
import { existsSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { PackageJsonInput } from './interface';
|
||||
|
||||
/**
|
||||
|
|
@ -20,9 +22,11 @@ export function packageJsonContent({
|
|||
cliName,
|
||||
cliBinName,
|
||||
isDev,
|
||||
isModule,
|
||||
dependencies
|
||||
}: PackageJsonInput) {
|
||||
let oakDependencyStr;
|
||||
let oakDevDependencyStr;
|
||||
let oakDependencyStr = '';
|
||||
let oakDevDependencyStr = '';
|
||||
if (isDev) {
|
||||
oakDependencyStr = `
|
||||
"oak-backend-base": "file:../oak-backend-base",
|
||||
|
|
@ -31,8 +35,20 @@ export function packageJsonContent({
|
|||
"oak-domain": "file:../oak-domain",
|
||||
"oak-external-sdk": "file:../oak-external-sdk",
|
||||
"oak-frontend-base": "file:../oak-frontend-base",
|
||||
"oak-general-business": "file:../oak-general-business",
|
||||
"oak-memory-tree-store": "file:../oak-memory-tree-store",`;
|
||||
if (dependencies?.length) {
|
||||
dependencies?.forEach(
|
||||
(dep) => {
|
||||
if (existsSync(join(process.cwd(), '..', dep))) {
|
||||
oakDependencyStr += `\n"${dep}": "file:../${dep}",`;
|
||||
}
|
||||
else {
|
||||
oakDependencyStr += `\n"${dep}": "^${getPackageLatestVersion(dep)}"`;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
oakDevDependencyStr = `"${cliName}": "file:../oak-cli",`
|
||||
}
|
||||
else {
|
||||
|
|
@ -44,8 +60,14 @@ export function packageJsonContent({
|
|||
"oak-domain": "^${getPackageLatestVersion('oak-domain')}",
|
||||
"oak-external-sdk": "^${getPackageLatestVersion('oak-external-sdk')}",
|
||||
"oak-frontend-base": "^${getPackageLatestVersion('oak-frontend-base')}",
|
||||
"oak-general-business": "^${getPackageLatestVersion('oak-general-business')}",
|
||||
"oak-memory-tree-store": "^${getPackageLatestVersion('oak-memory-tree-store')}",`;
|
||||
if (dependencies?.length) {
|
||||
dependencies?.forEach(
|
||||
(dep) => {
|
||||
oakDependencyStr += `\n"${dep}": "^${getPackageLatestVersion(dep)}"`;
|
||||
}
|
||||
);
|
||||
}
|
||||
oakDevDependencyStr = `"${cliName}": "^${getPackageLatestVersion(cliName)}",`
|
||||
}
|
||||
|
||||
|
|
@ -56,8 +78,8 @@ export function packageJsonContent({
|
|||
"version": "${version}",
|
||||
"description": "${description}",
|
||||
"scripts": {
|
||||
"make:domain": "${cliBinName} make:domain",
|
||||
"make:locale": "${cliBinName} make:locale",
|
||||
"make:domain": "${isModule ? `cross-env COMPLING_AS_LIB=yes ${cliBinName}` : cliBinName} make:domain",
|
||||
"make:locale": "${cliBinName} make:locale ${isModule ? '-m' : ''}",
|
||||
"make:dep": "${cliBinName} make:dependency",
|
||||
"clean:cache": "rimraf node_modules/.cache",
|
||||
"copy-config-json": "copyfiles -u 1 src/config/*.json lib/",
|
||||
|
|
@ -77,12 +99,12 @@ export function packageJsonContent({
|
|||
"build-analyze:web": "${cliBinName} build --target web --mode production --analyze",
|
||||
"build-sourcemap-analyze:web": "${cliBinName} build --target web --mode production --sourcemap --analyze",
|
||||
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && npm run copy-config-json",
|
||||
"prebuild": "npm run make:locale && npm run make:dep",
|
||||
"prebuild": "npm run make:locale",
|
||||
"run:ios": "oak-cli run -p ios",
|
||||
"run:android": "oak-cli run -p android",
|
||||
"server:init": "${serverInitScript}",
|
||||
"server:start": "${serverStartScript}",
|
||||
"postinstall": "${cliBinName} make:dependency"
|
||||
"postinstall": "npm run make:dep"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
|
|
|
|||
Loading…
Reference in New Issue