增加了templateFiles,在build的时候增加了make:dep过程
This commit is contained in:
parent
8e54c9e71c
commit
95adca90d3
|
|
@ -6,6 +6,7 @@ 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');
|
||||
|
|
@ -26,6 +27,8 @@ async function build(cmd) {
|
|||
(0, makeLocale_1.default)('', mode === 'development');
|
||||
// 再尝试makeRouter
|
||||
(0, makeRouter_1.default)({ subdir }, mode === 'development');
|
||||
// makeDependency
|
||||
(0, makeDependency_1.default)('');
|
||||
//ts类型检查 waring 还是error,
|
||||
//主要web受影响,error级别的话 控制台和网页都报错,warning级别的话 控制台报错
|
||||
// development/staging/production
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ const create_1 = require("./create");
|
|||
const build_1 = tslib_1.__importDefault(require("./build"));
|
||||
const makeDomain_1 = tslib_1.__importDefault(require("./makeDomain"));
|
||||
const makeLocale_1 = tslib_1.__importDefault(require("./makeLocale"));
|
||||
const makeDependency_1 = tslib_1.__importDefault(require("./makeDependency"));
|
||||
const run_1 = tslib_1.__importDefault(require("./run"));
|
||||
const clean_1 = tslib_1.__importDefault(require("./clean"));
|
||||
const config_1 = require("./config");
|
||||
|
|
@ -50,6 +51,10 @@ commander_1.default
|
|||
.command('make:locale')
|
||||
.description('make locales')
|
||||
.action(makeLocale_1.default);
|
||||
commander_1.default
|
||||
.command('make:dependency')
|
||||
.description('make dependency')
|
||||
.action(makeDependency_1.default);
|
||||
commander_1.default
|
||||
.command('start')
|
||||
.option('--sourceMap', 'sourceMap')
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
export default function make(): Promise<void>;
|
||||
47
lib/make.js
47
lib/make.js
|
|
@ -1,47 +0,0 @@
|
|||
"use strict";
|
||||
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"));
|
||||
async function make() {
|
||||
(0, tip_style_1.Success)(`${(0, tip_style_1.success)(`build oak-app-domain`)}`);
|
||||
// ts-node scripts/build-app-domain & npm link ./app-domain
|
||||
const result = cross_spawn_1.default.sync('ts-node', [require.resolve('../scripts/' + 'build-app-domain.js')], {
|
||||
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)(`build 执行完成`)}`);
|
||||
}
|
||||
else {
|
||||
(0, tip_style_1.Error)(`${(0, tip_style_1.error)(`build 执行失败`)}`);
|
||||
process.exit(1);
|
||||
}
|
||||
/* Success(`${success(`npm link oak-app-domain`)}`);
|
||||
|
||||
const isWin = process.platform === 'win32';
|
||||
const result2 = !isWin ? spawn.sync(
|
||||
'sudo',
|
||||
[`npm link ${process.cwd()}/src/oak-app-domain`],
|
||||
{
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
}
|
||||
) : spawn.sync(
|
||||
'npm',
|
||||
[`link ${process.cwd()}/src/oak-app-domain`],
|
||||
{
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
}
|
||||
);
|
||||
|
||||
if (result2.status === 0) {
|
||||
Success(`${success(`link 执行完成`)}`);
|
||||
} else {
|
||||
Error(`${error(`link 执行失败`)}`);
|
||||
process.exit(1);
|
||||
} */
|
||||
}
|
||||
exports.default = make;
|
||||
|
|
@ -0,0 +1 @@
|
|||
export default function make(cmd: any, rebuild?: boolean): Promise<void>;
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
"use strict";
|
||||
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, rebuild) {
|
||||
(0, tip_style_1.Success)(`${(0, tip_style_1.success)(`make dependecy`)}`);
|
||||
// ts-node scripts/build-app-domain & npm link ./app-domain
|
||||
const args = [(0, path_1.resolve)(__dirname, '../scripts/make-dependency.js')];
|
||||
if (rebuild) {
|
||||
args.push('true');
|
||||
}
|
||||
const result = cross_spawn_1.default.sync('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 dependency 执行完成`)}`);
|
||||
}
|
||||
else {
|
||||
(0, tip_style_1.Error)(`${(0, tip_style_1.error)(`make dependency 执行失败`)}`);
|
||||
process.exit(-1);
|
||||
}
|
||||
}
|
||||
exports.default = make;
|
||||
|
|
@ -16,7 +16,8 @@
|
|||
"lib/**/*",
|
||||
"plugins/**/*",
|
||||
"scripts/**/*",
|
||||
"template/**/*"
|
||||
"template/**/*",
|
||||
"templateFiles/**/*"
|
||||
],
|
||||
"author": "",
|
||||
"license": "",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
const watch = process.argv[2];
|
||||
const startUpBuilder = require('oak-domain/lib/compiler/dependencyBuilder').default;
|
||||
startUpBuilder(watch);
|
||||
|
|
@ -11,6 +11,7 @@ import spawn from 'cross-spawn';
|
|||
import { resolve } from 'path';
|
||||
import makeLocale from './makeLocale';
|
||||
import makeRouter from './makeRouter';
|
||||
import makeDep from './makeDependency';
|
||||
import { copyFileSync } from 'fs';
|
||||
|
||||
type Mode = 'development' | 'staging' | 'production';
|
||||
|
|
@ -39,6 +40,8 @@ export default async function build(cmd: any) {
|
|||
makeLocale('', mode === 'development');
|
||||
// 再尝试makeRouter
|
||||
makeRouter({ subdir }, mode === 'development');
|
||||
// makeDependency
|
||||
makeDep('');
|
||||
//ts类型检查 waring 还是error,
|
||||
//主要web受影响,error级别的话 控制台和网页都报错,warning级别的话 控制台报错
|
||||
// development/staging/production
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { create, update } from './create';
|
|||
import build from './build';
|
||||
import makeDomain from './makeDomain';
|
||||
import makeLocale from './makeLocale';
|
||||
import makeDependency from './makeDependency';
|
||||
import run from './run';
|
||||
import clean from './clean';
|
||||
import { CLI_VERSION, CLI_NAME } from './config';
|
||||
|
|
@ -56,6 +57,13 @@ program
|
|||
.description('make locales')
|
||||
.action(makeLocale);
|
||||
|
||||
|
||||
program
|
||||
.command('make:dependency')
|
||||
.description('make dependency')
|
||||
.action(makeDependency);
|
||||
|
||||
|
||||
program
|
||||
.command('start')
|
||||
.option('--sourceMap', 'sourceMap')
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
import {
|
||||
Success,
|
||||
Error,
|
||||
error,
|
||||
primary,
|
||||
success,
|
||||
warn,
|
||||
Warn,
|
||||
} from './tip-style';
|
||||
import spawn from 'cross-spawn';
|
||||
import { resolve } from 'path';
|
||||
|
||||
export default async function make(cmd: any, rebuild?: boolean) {
|
||||
Success(`${success(`make dependecy`)}`);
|
||||
// ts-node scripts/build-app-domain & npm link ./app-domain
|
||||
const args = [resolve(__dirname, '../scripts/make-dependency.js')];
|
||||
if (rebuild) {
|
||||
args.push('true');
|
||||
}
|
||||
|
||||
const result = spawn.sync(
|
||||
'node',
|
||||
args,
|
||||
{
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
}
|
||||
);
|
||||
// const result2 = spawn.sync('npm -v', [], { stdio: 'inherit', shell: true });
|
||||
|
||||
if (result.status === 0) {
|
||||
Success(`${success(`make dependency 执行完成`)}`);
|
||||
} else {
|
||||
Error(`${error(`make dependency 执行失败`)}`);
|
||||
process.exit(-1);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
"use oak router builder"; // 这行备注说明是用oak的router builder来生成allRouters
|
||||
import React from 'react';
|
||||
import { IRouter } from '../../../types/router';
|
||||
let allRouters: IRouter[] = [];
|
||||
export default allRouters;
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
import { mergeConcatMany } from 'oak-domain/lib/utils/lodash';
|
||||
import BackendRuntimeContext from '@project/context/BackendRuntimeContext';
|
||||
import FrontendRuntimeContext from '@project/context/FrontendRuntimeContext';
|
||||
|
||||
import { EntityDict, storageSchema } from '@project/oak-app-domain';
|
||||
import triggers from '@project/triggers';
|
||||
import checkers from '@project/checkers';
|
||||
import watchers from '@project/watchers';
|
||||
import timers from '@project/timers';
|
||||
import data from '@project/data';
|
||||
import startRoutines from '@project/routines/start';
|
||||
import { importations, exportations } from '@project/ports';
|
||||
import { create as createFeatures, FeatureDict } from '@project/features';
|
||||
import aspects, { AspectDict } from '@project/aspects';
|
||||
import common from '@project/configuration';
|
||||
import render from '@project/configuration/render';
|
||||
|
||||
import { initialize as initFrontend } from 'oak-frontend-base/es/initialize';
|
||||
import { BasicFeatures } from 'oak-frontend-base/es/features';
|
||||
import DebugConnector from 'oak-frontend-base/es/utils/DebugConnector';
|
||||
|
||||
export default function initialize() {
|
||||
const totalTriggers = mergeConcatMany([triggers] as Array<typeof triggers>),
|
||||
totalAspects = mergeConcatMany([aspects] as Array<typeof aspects>),
|
||||
totalCheckers = mergeConcatMany([checkers] as Array<typeof checkers>),
|
||||
totalWatchers = mergeConcatMany([watchers] as Array<typeof watchers>),
|
||||
totalTimers = mergeConcatMany([timers] as Array<typeof timers>),
|
||||
totalStartRoutines = mergeConcatMany([startRoutines] as Array<typeof startRoutines>),
|
||||
totalData = mergeConcatMany([data] as Array<typeof data>),
|
||||
totalImportations = mergeConcatMany([importations] as Array<typeof importations>),
|
||||
totalExportations = mergeConcatMany([exportations] as Array<typeof exportations>),
|
||||
totalCommon = mergeConcatMany([common] as Array<typeof common>),
|
||||
totalRender = mergeConcatMany([render] as Array<typeof render>);
|
||||
|
||||
const debugConnector = new DebugConnector<EntityDict, BackendRuntimeContext, FrontendRuntimeContext>(
|
||||
storageSchema,
|
||||
(store) => new BackendRuntimeContext(store),
|
||||
totalAspects,
|
||||
totalTriggers,
|
||||
totalCheckers,
|
||||
totalWatchers,
|
||||
totalTimers,
|
||||
totalStartRoutines,
|
||||
totalData,
|
||||
totalCommon,
|
||||
totalImportations,
|
||||
totalExportations
|
||||
);
|
||||
|
||||
const totalFeatures = {} as FeatureDict & BasicFeatures<EntityDict>;
|
||||
const { features } = initFrontend<EntityDict, BackendRuntimeContext, FrontendRuntimeContext, AspectDict>(
|
||||
storageSchema,
|
||||
(store) => new FrontendRuntimeContext(store, totalFeatures),
|
||||
debugConnector,
|
||||
totalCheckers,
|
||||
totalCommon,
|
||||
totalRender
|
||||
);
|
||||
|
||||
Object.assign(totalFeatures, features);
|
||||
const appFeatures = createFeatures(totalFeatures);
|
||||
Object.assign(totalFeatures, appFeatures);
|
||||
|
||||
return {
|
||||
features: totalFeatures,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
import { mergeConcatMany } from 'oak-domain/lib/utils/lodash';
|
||||
import BackendRuntimeContext from '@project/context/BackendRuntimeContext';
|
||||
import FrontendRuntimeContext from '@project/context/FrontendRuntimeContext';
|
||||
import Connector from '@project/connector';
|
||||
|
||||
import { EntityDict, storageSchema } from '@project/oak-app-domain';
|
||||
import checkers from '@project/checkers';
|
||||
import { create as createFeatures, FeatureDict } from '@project/features';
|
||||
import common from '@project/configuration';
|
||||
import render from '@project/configuration/render';
|
||||
|
||||
|
||||
// import ogbCheckers from 'oak-general-business/es/checkers';
|
||||
// import { create as createOgbFeatures, FeatureDict as OgbFeatureDict } from 'oak-general-business/es/features';
|
||||
// import ogbCommon from 'oak-general-business/es/configuration';
|
||||
// import ogbRender from 'oak-general-business/es/configuration/render';
|
||||
|
||||
import { initialize as initFrontend } from 'oak-frontend-base/es/initialize';
|
||||
import { BasicFeatures } from 'oak-frontend-base/es/features';
|
||||
import { AspectDict } from './aspects';
|
||||
|
||||
export default function initialize() {
|
||||
const totalCheckers = mergeConcatMany([checkers] as Array<typeof checkers>),
|
||||
totalCommon = mergeConcatMany([common] as Array<typeof common>),
|
||||
totalRender = mergeConcatMany([render] as Array<typeof render>);
|
||||
|
||||
const totalFeatures = {} as FeatureDict & BasicFeatures<EntityDict>;
|
||||
const { features } = initFrontend<EntityDict, BackendRuntimeContext, FrontendRuntimeContext, AspectDict>(
|
||||
storageSchema,
|
||||
(store) => new FrontendRuntimeContext(store, totalFeatures),
|
||||
Connector,
|
||||
totalCheckers,
|
||||
totalCommon,
|
||||
totalRender
|
||||
);
|
||||
|
||||
Object.assign(totalFeatures, features);
|
||||
const appFeatures = createFeatures(totalFeatures);
|
||||
Object.assign(totalFeatures, appFeatures);
|
||||
|
||||
return {
|
||||
features: totalFeatures,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
import { FeatureDict } from '@project/features';
|
||||
import { BasicFeatures } from 'oak-frontend-base/es/features';
|
||||
import { EntityDict } from '@project/oak-app-domain';
|
||||
|
||||
|
||||
export default async function initialize(features: FeatureDict & BasicFeatures<EntityDict>) {
|
||||
// 项目自己的features如果有初始化写在这里
|
||||
}
|
||||
Loading…
Reference in New Issue