修改了Staging环境的部署参数
This commit is contained in:
parent
3e0a731420
commit
118ca26461
|
|
@ -101,7 +101,7 @@ module.exports = function (webpackEnv) {
|
||||||
// staging 把mode改为none,其他跟production一样
|
// staging 把mode改为none,其他跟production一样
|
||||||
const isEnvStaging = webpackEnv === 'staging';
|
const isEnvStaging = webpackEnv === 'staging';
|
||||||
const isEnvDevelopment = webpackEnv === 'development';
|
const isEnvDevelopment = webpackEnv === 'development';
|
||||||
const isEnvProduction = webpackEnv === 'production' || isEnvStaging;
|
const isEnvProduction = webpackEnv === 'production';
|
||||||
|
|
||||||
// Variable used for enabling profiling in Production
|
// Variable used for enabling profiling in Production
|
||||||
// passed into alias object. Uses a flag if passed into the build command
|
// passed into alias object. Uses a flag if passed into the build command
|
||||||
|
|
@ -120,7 +120,7 @@ module.exports = function (webpackEnv) {
|
||||||
const getStyleLoaders = (cssOptions, preProcessor, preProcessOptions) => {
|
const getStyleLoaders = (cssOptions, preProcessor, preProcessOptions) => {
|
||||||
const loaders = [
|
const loaders = [
|
||||||
isEnvDevelopment && require.resolve('style-loader'),
|
isEnvDevelopment && require.resolve('style-loader'),
|
||||||
isEnvProduction && {
|
(isEnvProduction || isEnvStaging) && {
|
||||||
loader: MiniCssExtractPlugin.loader,
|
loader: MiniCssExtractPlugin.loader,
|
||||||
// css is located in `static/css`, use '../../' to locate index.html folder
|
// css is located in `static/css`, use '../../' to locate index.html folder
|
||||||
// in production `paths.publicUrlOrPath` can be a relative path
|
// in production `paths.publicUrlOrPath` can be a relative path
|
||||||
|
|
@ -174,9 +174,7 @@ module.exports = function (webpackEnv) {
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
sourceMap: isEnvProduction
|
sourceMap: isEnvDevelopment,
|
||||||
? shouldUseSourceMap
|
|
||||||
: isEnvDevelopment,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
].filter(Boolean);
|
].filter(Boolean);
|
||||||
|
|
@ -185,9 +183,7 @@ module.exports = function (webpackEnv) {
|
||||||
{
|
{
|
||||||
loader: require.resolve('resolve-url-loader'),
|
loader: require.resolve('resolve-url-loader'),
|
||||||
options: {
|
options: {
|
||||||
sourceMap: isEnvProduction
|
sourceMap: isEnvDevelopment,
|
||||||
? shouldUseSourceMap
|
|
||||||
: isEnvDevelopment,
|
|
||||||
root: paths.appRootSrc,
|
root: paths.appRootSrc,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -195,7 +191,7 @@ module.exports = function (webpackEnv) {
|
||||||
loader: require.resolve(preProcessor),
|
loader: require.resolve(preProcessor),
|
||||||
options: Object.assign(
|
options: Object.assign(
|
||||||
{
|
{
|
||||||
sourceMap: true,
|
sourceMap: isEnvDevelopment,
|
||||||
},
|
},
|
||||||
preProcessOptions
|
preProcessOptions
|
||||||
),
|
),
|
||||||
|
|
@ -233,11 +229,9 @@ module.exports = function (webpackEnv) {
|
||||||
: isEnvDevelopment && 'development'),
|
: isEnvDevelopment && 'development'),
|
||||||
// Stop compilation early in production
|
// Stop compilation early in production
|
||||||
bail: isEnvProduction,
|
bail: isEnvProduction,
|
||||||
devtool: isEnvProduction
|
devtool: (!isEnvProduction || shouldUseSourceMap)
|
||||||
? shouldUseSourceMap
|
? (isEnvDevelopment ? 'source-map' : 'cheap-module-source-map')
|
||||||
? 'source-map'
|
: false,
|
||||||
: false
|
|
||||||
: isEnvDevelopment && 'cheap-module-source-map',
|
|
||||||
// These are the "entry points" to our application.
|
// These are the "entry points" to our application.
|
||||||
// This means they will be the "root" imports that are included in JS bundle.
|
// This means they will be the "root" imports that are included in JS bundle.
|
||||||
entry: paths.appIndexJs,
|
entry: paths.appIndexJs,
|
||||||
|
|
@ -250,11 +244,11 @@ module.exports = function (webpackEnv) {
|
||||||
// In development, it does not produce real files.
|
// In development, it does not produce real files.
|
||||||
filename: isEnvProduction
|
filename: isEnvProduction
|
||||||
? 'static/js/[name].[contenthash:8].js'
|
? 'static/js/[name].[contenthash:8].js'
|
||||||
: isEnvDevelopment && 'static/js/bundle.js',
|
: 'static/js/bundle.js',
|
||||||
// There are also additional JS chunk files if you use code splitting.
|
// There are also additional JS chunk files if you use code splitting.
|
||||||
chunkFilename: isEnvProduction
|
chunkFilename: isEnvProduction
|
||||||
? 'static/js/[name].[contenthash:8].chunk.js'
|
? 'static/js/[name].[contenthash:8].chunk.js'
|
||||||
: isEnvDevelopment && 'static/js/[name].chunk.js',
|
: 'static/js/[name].chunk.js',
|
||||||
assetModuleFilename: 'static/media/[name].[hash][ext]',
|
assetModuleFilename: 'static/media/[name].[hash][ext]',
|
||||||
// webpack uses `publicPath` to determine where the app is being served from.
|
// webpack uses `publicPath` to determine where the app is being served from.
|
||||||
// It requires a trailing slash, or the file assets will get an incorrect path.
|
// It requires a trailing slash, or the file assets will get an incorrect path.
|
||||||
|
|
@ -266,8 +260,7 @@ module.exports = function (webpackEnv) {
|
||||||
path
|
path
|
||||||
.relative(paths.appSrc, info.absoluteResourcePath)
|
.relative(paths.appSrc, info.absoluteResourcePath)
|
||||||
.replace(/\\/g, '/')
|
.replace(/\\/g, '/')
|
||||||
: isEnvDevelopment &&
|
: ((info) =>
|
||||||
((info) =>
|
|
||||||
path
|
path
|
||||||
.resolve(info.absoluteResourcePath)
|
.resolve(info.absoluteResourcePath)
|
||||||
.replace(/\\/g, '/')),
|
.replace(/\\/g, '/')),
|
||||||
|
|
@ -643,9 +636,7 @@ module.exports = function (webpackEnv) {
|
||||||
exclude: cssModuleRegex,
|
exclude: cssModuleRegex,
|
||||||
use: getStyleLoaders({
|
use: getStyleLoaders({
|
||||||
importLoaders: 1,
|
importLoaders: 1,
|
||||||
sourceMap: isEnvProduction
|
sourceMap: isEnvDevelopment,
|
||||||
? shouldUseSourceMap
|
|
||||||
: isEnvDevelopment,
|
|
||||||
modules: {
|
modules: {
|
||||||
mode: 'icss',
|
mode: 'icss',
|
||||||
},
|
},
|
||||||
|
|
@ -662,9 +653,7 @@ module.exports = function (webpackEnv) {
|
||||||
test: cssModuleRegex,
|
test: cssModuleRegex,
|
||||||
use: getStyleLoaders({
|
use: getStyleLoaders({
|
||||||
importLoaders: 1,
|
importLoaders: 1,
|
||||||
sourceMap: isEnvProduction
|
sourceMap: isEnvDevelopment,
|
||||||
? shouldUseSourceMap
|
|
||||||
: isEnvDevelopment,
|
|
||||||
modules: {
|
modules: {
|
||||||
mode: 'local',
|
mode: 'local',
|
||||||
getLocalIdent: getCSSModuleLocalIdent,
|
getLocalIdent: getCSSModuleLocalIdent,
|
||||||
|
|
@ -680,9 +669,7 @@ module.exports = function (webpackEnv) {
|
||||||
use: getStyleLoaders(
|
use: getStyleLoaders(
|
||||||
{
|
{
|
||||||
importLoaders: 3,
|
importLoaders: 3,
|
||||||
sourceMap: isEnvProduction
|
sourceMap: isEnvDevelopment,
|
||||||
? shouldUseSourceMap
|
|
||||||
: isEnvDevelopment,
|
|
||||||
modules: {
|
modules: {
|
||||||
mode: 'icss',
|
mode: 'icss',
|
||||||
},
|
},
|
||||||
|
|
@ -702,9 +689,7 @@ module.exports = function (webpackEnv) {
|
||||||
use: getStyleLoaders(
|
use: getStyleLoaders(
|
||||||
{
|
{
|
||||||
importLoaders: 3,
|
importLoaders: 3,
|
||||||
sourceMap: isEnvProduction
|
sourceMap: isEnvDevelopment,
|
||||||
? shouldUseSourceMap
|
|
||||||
: isEnvDevelopment,
|
|
||||||
modules: {
|
modules: {
|
||||||
mode: 'local',
|
mode: 'local',
|
||||||
getLocalIdent: getCSSModuleLocalIdent,
|
getLocalIdent: getCSSModuleLocalIdent,
|
||||||
|
|
@ -719,9 +704,7 @@ module.exports = function (webpackEnv) {
|
||||||
use: getStyleLoaders(
|
use: getStyleLoaders(
|
||||||
{
|
{
|
||||||
importLoaders: 3,
|
importLoaders: 3,
|
||||||
sourceMap: isEnvProduction
|
sourceMap: isEnvDevelopment,
|
||||||
? shouldUseSourceMap
|
|
||||||
: isEnvDevelopment,
|
|
||||||
modules: {
|
modules: {
|
||||||
mode: 'icss',
|
mode: 'icss',
|
||||||
},
|
},
|
||||||
|
|
@ -744,9 +727,7 @@ module.exports = function (webpackEnv) {
|
||||||
use: getStyleLoaders(
|
use: getStyleLoaders(
|
||||||
{
|
{
|
||||||
importLoaders: 3,
|
importLoaders: 3,
|
||||||
sourceMap: isEnvProduction
|
sourceMap: isEnvDevelopment,
|
||||||
? shouldUseSourceMap
|
|
||||||
: isEnvDevelopment,
|
|
||||||
modules: {
|
modules: {
|
||||||
mode: 'local',
|
mode: 'local',
|
||||||
getLocalIdent: getCSSModuleLocalIdent,
|
getLocalIdent: getCSSModuleLocalIdent,
|
||||||
|
|
@ -858,7 +839,7 @@ module.exports = function (webpackEnv) {
|
||||||
// a plugin that prints an error when you attempt to do this.
|
// a plugin that prints an error when you attempt to do this.
|
||||||
// See https://github.com/facebook/create-react-app/issues/240
|
// See https://github.com/facebook/create-react-app/issues/240
|
||||||
isEnvDevelopment && new CaseSensitivePathsPlugin(),
|
isEnvDevelopment && new CaseSensitivePathsPlugin(),
|
||||||
isEnvProduction &&
|
(isEnvProduction || isEnvStaging) &&
|
||||||
new MiniCssExtractPlugin({
|
new MiniCssExtractPlugin({
|
||||||
// Options similar to the same options in webpackOptions.output
|
// Options similar to the same options in webpackOptions.output
|
||||||
// both options are optional
|
// both options are optional
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
/// <reference path="../../src/typings/polyfill.d.ts" />
|
/// <reference path="../../src/typings/polyfill.d.ts" />
|
||||||
import './polyfill';
|
import './polyfill';
|
||||||
|
import { BackendRuntimeContext } from 'oak-frontend-base/lib/context/BackendRuntimeContext';
|
||||||
import { Connector, EntityDict } from 'oak-domain/lib/types';
|
import { Connector, EntityDict } from 'oak-domain/lib/types';
|
||||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||||
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
||||||
export declare function startup<ED extends EntityDict & BaseEntityDict, FrontCxt extends SyncContext<ED>>(path: string, connector: Connector<ED, FrontCxt>, omitWatchers?: boolean, omitTimers?: boolean, routine?: (context: AsyncContext<EntityDict & BaseEntityDict>) => Promise<void>): Promise<void>;
|
export declare function startup<ED extends EntityDict & BaseEntityDict, FrontCxt extends SyncContext<ED>, Cxt extends BackendRuntimeContext<ED>>(path: string, connector: Connector<ED, FrontCxt>, omitWatchers?: boolean, omitTimers?: boolean, routine?: (context: AsyncContext<ED>) => Promise<void>): Promise<void>;
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ async function startup(path, connector, omitWatchers, omitTimers, routine) {
|
||||||
}));
|
}));
|
||||||
const router = new koa_router_1.default();
|
const router = new koa_router_1.default();
|
||||||
// 如果是开发环境,允许options
|
// 如果是开发环境,允许options
|
||||||
if (['development'].includes(process.env.NODE_ENV)) {
|
if (['development', 'staging'].includes(process.env.NODE_ENV)) {
|
||||||
koa.use(async (ctx, next) => {
|
koa.use(async (ctx, next) => {
|
||||||
ctx.set('Access-Control-Allow-Origin', '*');
|
ctx.set('Access-Control-Allow-Origin', '*');
|
||||||
ctx.set('Access-Control-Allow-Headers', corsHeaders);
|
ctx.set('Access-Control-Allow-Headers', corsHeaders);
|
||||||
|
|
|
||||||
|
|
@ -114,10 +114,10 @@ function packageJsonContent({ name, version, description, cliName, cliBinName, i
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
${oakDependencyStr}
|
${oakDependencyStr}
|
||||||
"react": "^18.2.0",
|
"react": "~18.2.0",
|
||||||
"react-dom": "^18.1.0",
|
"react-dom": "~18.2.0",
|
||||||
"react-image-gallery": "^1.2.11",
|
"react-image-gallery": "^1.2.11",
|
||||||
"react-native": "0.72.7",
|
"react-native": "~0.72.7",
|
||||||
"react-native-exception-handler": "^2.10.10",
|
"react-native-exception-handler": "^2.10.10",
|
||||||
"react-native-gesture-handler": "^2.14.0",
|
"react-native-gesture-handler": "^2.14.0",
|
||||||
"react-native-localize": "^3.0.4",
|
"react-native-localize": "^3.0.4",
|
||||||
|
|
@ -131,7 +131,6 @@ function packageJsonContent({ name, version, description, cliName, cliBinName, i
|
||||||
"react-router-dom": "^6.4.0",
|
"react-router-dom": "^6.4.0",
|
||||||
"react-slick": "^0.29.0",
|
"react-slick": "^0.29.0",
|
||||||
"rmc-pull-to-refresh": "^1.0.13",
|
"rmc-pull-to-refresh": "^1.0.13",
|
||||||
"slick-carousel": "^1.8.1",
|
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import Koa from 'koa';
|
||||||
import KoaRouter from 'koa-router';
|
import KoaRouter from 'koa-router';
|
||||||
import KoaBody from 'koa-body';
|
import KoaBody from 'koa-body';
|
||||||
import { AppLoader, getClusterInfo, ClusterAppLoader } from 'oak-backend-base';
|
import { AppLoader, getClusterInfo, ClusterAppLoader } from 'oak-backend-base';
|
||||||
|
import { BackendRuntimeContext } from 'oak-frontend-base/lib/context/BackendRuntimeContext';
|
||||||
import { OakException, Connector, EntityDict, ClusterInfo } from 'oak-domain/lib/types';
|
import { OakException, Connector, EntityDict, ClusterInfo } from 'oak-domain/lib/types';
|
||||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
import { AsyncRowStore, AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
import { AsyncRowStore, AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||||
|
|
@ -30,12 +31,12 @@ function concat(...paths: string[]) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function startup<ED extends EntityDict & BaseEntityDict, FrontCxt extends SyncContext<ED>>(
|
export async function startup<ED extends EntityDict & BaseEntityDict, FrontCxt extends SyncContext<ED>, Cxt extends BackendRuntimeContext<ED>>(
|
||||||
path: string,
|
path: string,
|
||||||
connector: Connector<ED, FrontCxt>,
|
connector: Connector<ED, FrontCxt>,
|
||||||
omitWatchers?: boolean,
|
omitWatchers?: boolean,
|
||||||
omitTimers?: boolean,
|
omitTimers?: boolean,
|
||||||
routine?: (context: AsyncContext<EntityDict & BaseEntityDict>) => Promise<void>,
|
routine?: (context: AsyncContext<ED>) => Promise<void>,
|
||||||
) {
|
) {
|
||||||
const serverConfiguration: ServerConfiguration = require(join(
|
const serverConfiguration: ServerConfiguration = require(join(
|
||||||
path,
|
path,
|
||||||
|
|
@ -88,13 +89,13 @@ export async function startup<ED extends EntityDict & BaseEntityDict, FrontCxt e
|
||||||
}
|
}
|
||||||
|
|
||||||
const appLoader = clusterInfo.usingCluster
|
const appLoader = clusterInfo.usingCluster
|
||||||
? new ClusterAppLoader(
|
? new ClusterAppLoader<ED, Cxt>(
|
||||||
path,
|
path,
|
||||||
io.of(DATA_SUBSCRIBER_NAMESPACE),
|
io.of(DATA_SUBSCRIBER_NAMESPACE),
|
||||||
io.of(SERVER_SUBSCRIBER_NAMESPACE),
|
io.of(SERVER_SUBSCRIBER_NAMESPACE),
|
||||||
connector.getSubscribeRouter()
|
connector.getSubscribeRouter()
|
||||||
)
|
)
|
||||||
: new AppLoader(path, io.of(DATA_SUBSCRIBER_NAMESPACE));
|
: new AppLoader<ED, Cxt>(path, io.of(DATA_SUBSCRIBER_NAMESPACE));
|
||||||
await appLoader.mount();
|
await appLoader.mount();
|
||||||
await appLoader.execStartRoutines();
|
await appLoader.execStartRoutines();
|
||||||
if (routine) {
|
if (routine) {
|
||||||
|
|
@ -113,7 +114,7 @@ export async function startup<ED extends EntityDict & BaseEntityDict, FrontCxt e
|
||||||
const exception =
|
const exception =
|
||||||
err instanceof OakException
|
err instanceof OakException
|
||||||
? err
|
? err
|
||||||
: new OakException(
|
: new OakException<ED>(
|
||||||
serverConfiguration?.internalExceptionMask ||
|
serverConfiguration?.internalExceptionMask ||
|
||||||
ExceptionMask
|
ExceptionMask
|
||||||
);
|
);
|
||||||
|
|
@ -134,7 +135,7 @@ export async function startup<ED extends EntityDict & BaseEntityDict, FrontCxt e
|
||||||
const router = new KoaRouter();
|
const router = new KoaRouter();
|
||||||
|
|
||||||
// 如果是开发环境,允许options
|
// 如果是开发环境,允许options
|
||||||
if (['development'].includes(process.env.NODE_ENV!)) {
|
if (['development', 'staging'].includes(process.env.NODE_ENV!)) {
|
||||||
koa.use(async (ctx, next) => {
|
koa.use(async (ctx, next) => {
|
||||||
ctx.set('Access-Control-Allow-Origin', '*');
|
ctx.set('Access-Control-Allow-Origin', '*');
|
||||||
ctx.set('Access-Control-Allow-Headers', corsHeaders);
|
ctx.set('Access-Control-Allow-Headers', corsHeaders);
|
||||||
|
|
|
||||||
50
test.ts
50
test.ts
|
|
@ -11,4 +11,52 @@ if (matches) {
|
||||||
console.log(codeContent);
|
console.log(codeContent);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Module = any;
|
||||||
|
type Exception = any;
|
||||||
|
|
||||||
|
type TestResult = {
|
||||||
|
desc: string;
|
||||||
|
cost: number;
|
||||||
|
error?: {
|
||||||
|
code: 'exception' | 'mistake',
|
||||||
|
exception?: Exception;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 一个测试用例
|
||||||
|
* api是传入的api函数入口,
|
||||||
|
* modules是所有依赖的包
|
||||||
|
*/
|
||||||
|
type TestUnit = (api: Function, modules: Record<string, Module>) => TestResult[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试用例注册:
|
||||||
|
* moduleName: 要测试的模块名
|
||||||
|
* apiName: 要测试的接口名
|
||||||
|
* unit: 测试用例
|
||||||
|
* dependencies: 依赖的其它包及包中的接口
|
||||||
|
*/
|
||||||
|
type Registery = (moduleName: string, apiName: string, unit: TestUnit, dependencies?: {
|
||||||
|
[M: string]: string[]
|
||||||
|
}) => void;
|
||||||
|
|
||||||
|
type RunResult = {
|
||||||
|
moduleResults: {
|
||||||
|
[M: string]: {
|
||||||
|
apiResults: {
|
||||||
|
[API: string]: {
|
||||||
|
result: TestResult[];
|
||||||
|
weight: number;
|
||||||
|
mark: number;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
weight: number;
|
||||||
|
mark: number;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mark: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Run = () => RunResult;
|
||||||
Loading…
Reference in New Issue