create项目时的一些模板相关改动
This commit is contained in:
parent
490e9076f7
commit
38c1142016
|
|
@ -121,7 +121,6 @@ async function create(dirName, cmd) {
|
|||
name: DEFAULT_PROJECT_NAME,
|
||||
version,
|
||||
description,
|
||||
cliVersion: config_1.CLI_VERSION,
|
||||
cliName: config_1.CLI_NAME,
|
||||
cliBinName: config_1.CLI_BIN_NAME,
|
||||
isDev,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ export interface PackageJsonInput {
|
|||
name: string;
|
||||
version?: string;
|
||||
description?: string;
|
||||
cliVersion: string;
|
||||
cliName: string;
|
||||
cliBinName: string;
|
||||
isDev?: boolean;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { PackageJsonInput } from './interface';
|
||||
export declare function packageJsonContent({ name, version, description, cliVersion, cliName, cliBinName, isDev, }: PackageJsonInput): string;
|
||||
export declare function packageJsonContent({ name, version, description, cliName, cliBinName, isDev, }: PackageJsonInput): string;
|
||||
export declare function tsConfigJsonContent(): string;
|
||||
export declare function tsConfigBuildJsonContent(): string;
|
||||
export declare function tsConfigBuildPathsJsonContent(): string;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,18 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.oakConfigContentWithWeb = exports.appJsonContentWithWeb = exports.oakConfigContentWithWeChatMp = exports.appJsonContentWithWeChatMp = exports.projectConfigContentWithWeChatMp = exports.tsConfigWebJsonContent = exports.tsConfigMpJsonContent = exports.tsConfigPathsJsonContent = exports.tsConfigBuildPathsJsonContent = exports.tsConfigBuildJsonContent = exports.tsConfigJsonContent = exports.packageJsonContent = void 0;
|
||||
function packageJsonContent({ name, version, description, cliVersion, cliName, cliBinName, isDev, }) {
|
||||
const child_process_1 = require("child_process");
|
||||
/**
|
||||
* 利用npm info获得相应库的最新版本
|
||||
* @param name
|
||||
* @returns
|
||||
*/
|
||||
function getPackageLatestVersion(name) {
|
||||
const result = (0, child_process_1.execSync)(`npm info ${name}`).toString('utf-8');
|
||||
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;
|
||||
if (isDev) {
|
||||
|
|
@ -19,18 +30,18 @@ function packageJsonContent({ name, version, description, cliVersion, cliName, c
|
|||
else {
|
||||
// todo,这里从npmjs.org上获取最新版本
|
||||
oakDependencyStr = `
|
||||
"oak-backend-base": "^3.2.0",
|
||||
"oak-common-aspect": "^2.1.0",
|
||||
"oak-db": "^2.1.1",
|
||||
"oak-domain": "^2.1.0",
|
||||
"oak-external-sdk": "^1.0.5",
|
||||
"oak-frontend-base": "^2.1.0",
|
||||
"oak-general-business": "^2.1.0",
|
||||
"oak-memory-tree-store": "^2.1.0",`;
|
||||
oakDevDependencyStr = `"${cliName}": "^${cliVersion}",`;
|
||||
"oak-backend-base": "^${getPackageLatestVersion('oak-backend-base')}",
|
||||
"oak-common-aspect": "^${getPackageLatestVersion('oak-common-aspect')}",
|
||||
"oak-db": "^${getPackageLatestVersion('oak-db')}",
|
||||
"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')}",`;
|
||||
oakDevDependencyStr = `"${cliName}": "^${getPackageLatestVersion(cliName)}",`;
|
||||
}
|
||||
const serverInitScript = isDev ? "cross-env OAK_PLATFORM=server ts-node scripts/initServer.js" : "cross-env OAK_PLATFORM=server ts-node scripts/initServer.js";
|
||||
const serverStartScript = isDev ? "cross-env NODE_ENV=development cross-env OAK_PLATFORM=server ts-node scripts/startServer.js" : "cross-env OAK_PLATFORM=server ts-node scripts/startServer.js";
|
||||
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";
|
||||
const serverStartScript = isDev ? "cross-env NODE_ENV=development cross-env OAK_PLATFORM=server node scripts/startServer.js" : "cross-env OAK_PLATFORM=server node scripts/startServer.js";
|
||||
return `{
|
||||
"name": "${name}",
|
||||
"version": "${version}",
|
||||
|
|
@ -65,11 +76,11 @@ function packageJsonContent({ name, version, description, cliVersion, cliName, c
|
|||
"dependencies": {
|
||||
"@ant-design/cssinjs": "^1.16.2",
|
||||
"@ant-design/icons": "^5.2.6",
|
||||
"@react-native-async-storage/async-storage": "^1.19.8",
|
||||
"@react-native-masked-view/masked-view": "^0.3.0",
|
||||
"@react-navigation/bottom-tabs": "^6.5.11",
|
||||
"@react-navigation/native": "^6.1.9",
|
||||
"@react-navigation/stack": "^6.3.20",
|
||||
"@react-native-async-storage/async-storage": "^1.19.8",
|
||||
"@react-native-masked-view/masked-view": "^0.3.0",
|
||||
"@react-navigation/bottom-tabs": "^6.5.11",
|
||||
"@react-navigation/native": "^6.1.9",
|
||||
"@react-navigation/stack": "^6.3.20",
|
||||
"@wangeditor/basic-modules": "^1.1.3",
|
||||
"@wangeditor/editor": "^5.1.14",
|
||||
"@wangeditor/editor-for-react": "^1.0.4",
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
"scripts": {
|
||||
"build": "tsc",
|
||||
"dev": "tsc --watch",
|
||||
"test": "node test.js"
|
||||
"test": "ts-node test.ts"
|
||||
},
|
||||
"bin": {
|
||||
"oak-cli": "lib/index.js"
|
||||
|
|
@ -34,8 +34,6 @@
|
|||
"@types/uuid": "^8.3.4",
|
||||
"babel-plugin-module-resolver": "^5.0.0",
|
||||
"fork-ts-checker-webpack-plugin": "^8.0.0",
|
||||
"node-watch": "^0.7.4",
|
||||
"querystring-es3": "^0.2.1",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^5.2.2"
|
||||
},
|
||||
|
|
@ -95,6 +93,7 @@
|
|||
"loader-utils": "^3.2.0",
|
||||
"lodash": "^4.17.21",
|
||||
"mini-css-extract-plugin": "^2.5.3",
|
||||
"node-watch": "^0.7.4",
|
||||
"oak-backend-base": "file:../oak-backend-base",
|
||||
"oak-domain": "file:../oak-domain",
|
||||
"oak-frontend-base": "file:../oak-frontend-base",
|
||||
|
|
@ -106,6 +105,7 @@
|
|||
"postcss-preset-env": "^7.0.1",
|
||||
"progress-bar-webpack-plugin": "^2.1.0",
|
||||
"prompts": "^2.4.2",
|
||||
"querystring-es3": "^0.2.1",
|
||||
"react-app-polyfill": "^3.0.0",
|
||||
"react-dev-utils": "^12.0.1",
|
||||
"react-native": "^0.72.7",
|
||||
|
|
|
|||
|
|
@ -198,7 +198,6 @@ export async function create(dirName: string, cmd: any) {
|
|||
name: DEFAULT_PROJECT_NAME, // 后面再统一rename
|
||||
version,
|
||||
description,
|
||||
cliVersion: CLI_VERSION,
|
||||
cliName: CLI_NAME,
|
||||
cliBinName: CLI_BIN_NAME,
|
||||
isDev,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ export interface PackageJsonInput {
|
|||
name: string;
|
||||
version?: string;
|
||||
description?: string;
|
||||
cliVersion: string;
|
||||
cliName: string;
|
||||
cliBinName: string;
|
||||
isDev?: boolean;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,22 @@
|
|||
import { PackageJsonInput } from './interface'
|
||||
import { execSync } from 'child_process';
|
||||
import { PackageJsonInput } from './interface';
|
||||
|
||||
/**
|
||||
* 利用npm info获得相应库的最新版本
|
||||
* @param name
|
||||
* @returns
|
||||
*/
|
||||
function getPackageLatestVersion(name: string) {
|
||||
const result = execSync(`npm info ${name}`).toString('utf-8');
|
||||
const data = result.match(/latest: \d\.\d\.\d\s*published/g);
|
||||
return data![0].slice(8, 13);
|
||||
}
|
||||
|
||||
|
||||
export function packageJsonContent({
|
||||
name,
|
||||
version,
|
||||
description,
|
||||
cliVersion,
|
||||
cliName,
|
||||
cliBinName,
|
||||
isDev,
|
||||
|
|
@ -25,19 +38,19 @@ export function packageJsonContent({
|
|||
else {
|
||||
// todo,这里从npmjs.org上获取最新版本
|
||||
oakDependencyStr = `
|
||||
"oak-backend-base": "^3.2.0",
|
||||
"oak-common-aspect": "^2.1.0",
|
||||
"oak-db": "^2.1.1",
|
||||
"oak-domain": "^2.1.0",
|
||||
"oak-external-sdk": "^1.0.5",
|
||||
"oak-frontend-base": "^2.1.0",
|
||||
"oak-general-business": "^2.1.0",
|
||||
"oak-memory-tree-store": "^2.1.0",`;
|
||||
oakDevDependencyStr = `"${cliName}": "^${cliVersion}",`
|
||||
"oak-backend-base": "^${getPackageLatestVersion('oak-backend-base')}",
|
||||
"oak-common-aspect": "^${getPackageLatestVersion('oak-common-aspect')}",
|
||||
"oak-db": "^${getPackageLatestVersion('oak-db')}",
|
||||
"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')}",`;
|
||||
oakDevDependencyStr = `"${cliName}": "^${getPackageLatestVersion(cliName)}",`
|
||||
}
|
||||
|
||||
const serverInitScript = isDev ? "cross-env OAK_PLATFORM=server ts-node scripts/initServer.js" : "cross-env OAK_PLATFORM=server ts-node scripts/initServer.js";
|
||||
const serverStartScript = isDev ? "cross-env NODE_ENV=development cross-env OAK_PLATFORM=server ts-node scripts/startServer.js" : "cross-env OAK_PLATFORM=server ts-node scripts/startServer.js";
|
||||
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";
|
||||
const serverStartScript = isDev ? "cross-env NODE_ENV=development cross-env OAK_PLATFORM=server node scripts/startServer.js" : "cross-env OAK_PLATFORM=server node scripts/startServer.js";
|
||||
return `{
|
||||
"name": "${name}",
|
||||
"version": "${version}",
|
||||
|
|
@ -72,11 +85,11 @@ export function packageJsonContent({
|
|||
"dependencies": {
|
||||
"@ant-design/cssinjs": "^1.16.2",
|
||||
"@ant-design/icons": "^5.2.6",
|
||||
"@react-native-async-storage/async-storage": "^1.19.8",
|
||||
"@react-native-masked-view/masked-view": "^0.3.0",
|
||||
"@react-navigation/bottom-tabs": "^6.5.11",
|
||||
"@react-navigation/native": "^6.1.9",
|
||||
"@react-navigation/stack": "^6.3.20",
|
||||
"@react-native-async-storage/async-storage": "^1.19.8",
|
||||
"@react-native-masked-view/masked-view": "^0.3.0",
|
||||
"@react-navigation/bottom-tabs": "^6.5.11",
|
||||
"@react-navigation/native": "^6.1.9",
|
||||
"@react-navigation/stack": "^6.3.20",
|
||||
"@wangeditor/basic-modules": "^1.1.3",
|
||||
"@wangeditor/editor": "^5.1.14",
|
||||
"@wangeditor/editor-for-react": "^1.0.4",
|
||||
|
|
|
|||
|
|
@ -12,10 +12,9 @@ export class BackendRuntimeContext
|
|||
const data = str && JSON.parse(str);
|
||||
|
||||
return async (
|
||||
store: AsyncRowStore<EntityDict, BackendRuntimeContext>,
|
||||
headers?: IncomingHttpHeaders
|
||||
store: AsyncRowStore<EntityDict, BackendRuntimeContext>
|
||||
) => {
|
||||
const context = new BackendRuntimeContext(store, headers);
|
||||
const context = new BackendRuntimeContext(store);
|
||||
await context.initialize(data);
|
||||
return context;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import {
|
|||
FrontendRuntimeContext as GeneralFrontendRuntimeContext,
|
||||
GeneralAspectDict,
|
||||
} from 'oak-general-business';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { CommonAspectDict } from 'oak-common-aspect/lib/AspectDict';
|
||||
import { RuntimeContext } from './RuntimeContext';
|
||||
import { AspectDict } from '../aspects/AspectDict';
|
||||
import { BackendRuntimeContext } from './BackendRuntimeContext';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { EntityDict } from '@oak-app-domain';
|
||||
import { BasicFeatures, Feature } from 'oak-frontend-base';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { CommonAspectDict } from 'oak-common-aspect/lib/AspectDict';
|
||||
import { AspectDict } from '../aspects/AspectDict';
|
||||
import { BackendRuntimeContext } from '@project/context/BackendRuntimeContext';
|
||||
import { FrontendRuntimeContext } from '@project/context/FrontendRuntimeContext';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { EntityDict } from '@oak-app-domain';
|
||||
import { BasicFeatures } from 'oak-frontend-base';
|
||||
import { GeneralFeatures, GeneralAspectDict } from 'oak-general-business';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { CommonAspectDict } from 'oak-common-aspect/lib/AspectDict';
|
||||
import { AspectDict } from '../aspects/AspectDict';
|
||||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useFeatures as useCommonFeatures } from '@oak-frontend-base/platforms/web';
|
||||
import { useFeatures as useCommonFeatures } from 'oak-frontend-base/es/platforms/web';
|
||||
import { AFD } from '@project/types/RuntimeCxt';
|
||||
|
||||
// react 独有
|
||||
|
|
|
|||
|
|
@ -3,12 +3,24 @@ import { EntityDict } from '@oak-app-domain';
|
|||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
|
||||
|
||||
const startRoutines: Array<Routine<EntityDict, BackendRuntimeContext>> = [
|
||||
const startRoutines: Array<Routine<EntityDict, keyof EntityDict, BackendRuntimeContext>> = [
|
||||
{
|
||||
name: '示例性routine',
|
||||
fn: async (context) => {
|
||||
entity: 'extraFile',
|
||||
filter: {
|
||||
uploadState: 'uploading',
|
||||
},
|
||||
projection: {
|
||||
id: 1,
|
||||
uploadMeta: 1,
|
||||
uploadState: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
objectId: 1,
|
||||
},
|
||||
fn: async (context, data) => {
|
||||
console.log('示例性routine执行,请在src/routine/start.ts中关闭');
|
||||
return '示例性routine执行完成';
|
||||
return context.opResult;
|
||||
},
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -2,17 +2,29 @@ import { Timer } from 'oak-domain/lib/types/Timer';
|
|||
import { EntityDict } from '@oak-app-domain';
|
||||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
|
||||
const timers: Array<Timer<EntityDict, BackendRuntimeContext>> = [
|
||||
// {
|
||||
// name: '示例timer',
|
||||
// cron: '30 * * * * *',
|
||||
// fn: async (context) => {
|
||||
// console.log(
|
||||
// '这是示例timer程序,每30秒执行一次,请在src/timer/index中关闭'
|
||||
// );
|
||||
// return '示例timer完成了';
|
||||
// },
|
||||
// },
|
||||
const timers: Array<Timer<EntityDict, keyof EntityDict, BackendRuntimeContext>> = [
|
||||
{
|
||||
name: '示例timer',
|
||||
cron: '30 * * * * *',
|
||||
entity: 'extraFile',
|
||||
filter: {
|
||||
uploadState: 'uploading',
|
||||
},
|
||||
projection: {
|
||||
id: 1,
|
||||
uploadMeta: 1,
|
||||
uploadState: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
objectId: 1,
|
||||
},
|
||||
fn: async (context, data) => {
|
||||
console.log(
|
||||
'这是示例timer程序,每30秒执行一次,请在src/timer/index中关闭'
|
||||
);
|
||||
return context.opResult;
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export default timers;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import React, { lazy } from 'react';
|
||||
const Message = lazy(() => import('@oak-general-business/components/message'));
|
||||
const Message = lazy(() => import('oak-general-business/es/components/message'));
|
||||
const DebugPanel = lazy(
|
||||
() => import('@oak-general-business/components/func/debugPanel')
|
||||
() => import('oak-general-business/es/components/func/debugPanel')
|
||||
);
|
||||
|
||||
type AppContainerProps = {
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ import {
|
|||
OakServerProxyException,
|
||||
} from 'oak-domain/lib/types/Exception';
|
||||
import { OakTokenExpiredException } from 'oak-general-business';
|
||||
import { ECode } from '@oak-general-business/types/ErrorPage';
|
||||
import { ECode } from 'oak-general-business/es/types/ErrorPage';
|
||||
const ErrorPage = lazy(
|
||||
() => import('@oak-general-business/components/common/errorPage')
|
||||
() => import('oak-general-business/es/components/common/errorPage')
|
||||
);
|
||||
|
||||
interface ErrorProps {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import zhCN from 'antd/locale/zh_CN';
|
|||
import {
|
||||
ResponsiveProvider,
|
||||
FeaturesProvider,
|
||||
} from '@oak-frontend-base/platforms/web';
|
||||
} from 'oak-frontend-base/es/platforms/web';
|
||||
import './index.less';
|
||||
import App from './App';
|
||||
import reportWebVitals from './reportWebVitals';
|
||||
|
|
|
|||
Loading…
Reference in New Issue