修改了Staging环境的部署参数
This commit is contained in:
parent
3e0a731420
commit
118ca26461
|
|
@ -101,7 +101,7 @@ module.exports = function (webpackEnv) {
|
|||
// staging 把mode改为none,其他跟production一样
|
||||
const isEnvStaging = webpackEnv === 'staging';
|
||||
const isEnvDevelopment = webpackEnv === 'development';
|
||||
const isEnvProduction = webpackEnv === 'production' || isEnvStaging;
|
||||
const isEnvProduction = webpackEnv === 'production';
|
||||
|
||||
// Variable used for enabling profiling in Production
|
||||
// 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 loaders = [
|
||||
isEnvDevelopment && require.resolve('style-loader'),
|
||||
isEnvProduction && {
|
||||
(isEnvProduction || isEnvStaging) && {
|
||||
loader: MiniCssExtractPlugin.loader,
|
||||
// css is located in `static/css`, use '../../' to locate index.html folder
|
||||
// in production `paths.publicUrlOrPath` can be a relative path
|
||||
|
|
@ -174,9 +174,7 @@ module.exports = function (webpackEnv) {
|
|||
],
|
||||
],
|
||||
},
|
||||
sourceMap: isEnvProduction
|
||||
? shouldUseSourceMap
|
||||
: isEnvDevelopment,
|
||||
sourceMap: isEnvDevelopment,
|
||||
},
|
||||
},
|
||||
].filter(Boolean);
|
||||
|
|
@ -185,9 +183,7 @@ module.exports = function (webpackEnv) {
|
|||
{
|
||||
loader: require.resolve('resolve-url-loader'),
|
||||
options: {
|
||||
sourceMap: isEnvProduction
|
||||
? shouldUseSourceMap
|
||||
: isEnvDevelopment,
|
||||
sourceMap: isEnvDevelopment,
|
||||
root: paths.appRootSrc,
|
||||
},
|
||||
},
|
||||
|
|
@ -195,7 +191,7 @@ module.exports = function (webpackEnv) {
|
|||
loader: require.resolve(preProcessor),
|
||||
options: Object.assign(
|
||||
{
|
||||
sourceMap: true,
|
||||
sourceMap: isEnvDevelopment,
|
||||
},
|
||||
preProcessOptions
|
||||
),
|
||||
|
|
@ -233,11 +229,9 @@ module.exports = function (webpackEnv) {
|
|||
: isEnvDevelopment && 'development'),
|
||||
// Stop compilation early in production
|
||||
bail: isEnvProduction,
|
||||
devtool: isEnvProduction
|
||||
? shouldUseSourceMap
|
||||
? 'source-map'
|
||||
: false
|
||||
: isEnvDevelopment && 'cheap-module-source-map',
|
||||
devtool: (!isEnvProduction || shouldUseSourceMap)
|
||||
? (isEnvDevelopment ? 'source-map' : 'cheap-module-source-map')
|
||||
: false,
|
||||
// These are the "entry points" to our application.
|
||||
// This means they will be the "root" imports that are included in JS bundle.
|
||||
entry: paths.appIndexJs,
|
||||
|
|
@ -250,11 +244,11 @@ module.exports = function (webpackEnv) {
|
|||
// In development, it does not produce real files.
|
||||
filename: isEnvProduction
|
||||
? '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.
|
||||
chunkFilename: isEnvProduction
|
||||
? 'static/js/[name].[contenthash:8].chunk.js'
|
||||
: isEnvDevelopment && 'static/js/[name].chunk.js',
|
||||
: 'static/js/[name].chunk.js',
|
||||
assetModuleFilename: 'static/media/[name].[hash][ext]',
|
||||
// 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.
|
||||
|
|
@ -266,8 +260,7 @@ module.exports = function (webpackEnv) {
|
|||
path
|
||||
.relative(paths.appSrc, info.absoluteResourcePath)
|
||||
.replace(/\\/g, '/')
|
||||
: isEnvDevelopment &&
|
||||
((info) =>
|
||||
: ((info) =>
|
||||
path
|
||||
.resolve(info.absoluteResourcePath)
|
||||
.replace(/\\/g, '/')),
|
||||
|
|
@ -643,9 +636,7 @@ module.exports = function (webpackEnv) {
|
|||
exclude: cssModuleRegex,
|
||||
use: getStyleLoaders({
|
||||
importLoaders: 1,
|
||||
sourceMap: isEnvProduction
|
||||
? shouldUseSourceMap
|
||||
: isEnvDevelopment,
|
||||
sourceMap: isEnvDevelopment,
|
||||
modules: {
|
||||
mode: 'icss',
|
||||
},
|
||||
|
|
@ -662,9 +653,7 @@ module.exports = function (webpackEnv) {
|
|||
test: cssModuleRegex,
|
||||
use: getStyleLoaders({
|
||||
importLoaders: 1,
|
||||
sourceMap: isEnvProduction
|
||||
? shouldUseSourceMap
|
||||
: isEnvDevelopment,
|
||||
sourceMap: isEnvDevelopment,
|
||||
modules: {
|
||||
mode: 'local',
|
||||
getLocalIdent: getCSSModuleLocalIdent,
|
||||
|
|
@ -680,9 +669,7 @@ module.exports = function (webpackEnv) {
|
|||
use: getStyleLoaders(
|
||||
{
|
||||
importLoaders: 3,
|
||||
sourceMap: isEnvProduction
|
||||
? shouldUseSourceMap
|
||||
: isEnvDevelopment,
|
||||
sourceMap: isEnvDevelopment,
|
||||
modules: {
|
||||
mode: 'icss',
|
||||
},
|
||||
|
|
@ -702,9 +689,7 @@ module.exports = function (webpackEnv) {
|
|||
use: getStyleLoaders(
|
||||
{
|
||||
importLoaders: 3,
|
||||
sourceMap: isEnvProduction
|
||||
? shouldUseSourceMap
|
||||
: isEnvDevelopment,
|
||||
sourceMap: isEnvDevelopment,
|
||||
modules: {
|
||||
mode: 'local',
|
||||
getLocalIdent: getCSSModuleLocalIdent,
|
||||
|
|
@ -719,9 +704,7 @@ module.exports = function (webpackEnv) {
|
|||
use: getStyleLoaders(
|
||||
{
|
||||
importLoaders: 3,
|
||||
sourceMap: isEnvProduction
|
||||
? shouldUseSourceMap
|
||||
: isEnvDevelopment,
|
||||
sourceMap: isEnvDevelopment,
|
||||
modules: {
|
||||
mode: 'icss',
|
||||
},
|
||||
|
|
@ -744,9 +727,7 @@ module.exports = function (webpackEnv) {
|
|||
use: getStyleLoaders(
|
||||
{
|
||||
importLoaders: 3,
|
||||
sourceMap: isEnvProduction
|
||||
? shouldUseSourceMap
|
||||
: isEnvDevelopment,
|
||||
sourceMap: isEnvDevelopment,
|
||||
modules: {
|
||||
mode: 'local',
|
||||
getLocalIdent: getCSSModuleLocalIdent,
|
||||
|
|
@ -858,7 +839,7 @@ module.exports = function (webpackEnv) {
|
|||
// a plugin that prints an error when you attempt to do this.
|
||||
// See https://github.com/facebook/create-react-app/issues/240
|
||||
isEnvDevelopment && new CaseSensitivePathsPlugin(),
|
||||
isEnvProduction &&
|
||||
(isEnvProduction || isEnvStaging) &&
|
||||
new MiniCssExtractPlugin({
|
||||
// Options similar to the same options in webpackOptions.output
|
||||
// both options are optional
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
/// <reference path="../../src/typings/polyfill.d.ts" />
|
||||
import './polyfill';
|
||||
import { BackendRuntimeContext } from 'oak-frontend-base/lib/context/BackendRuntimeContext';
|
||||
import { Connector, EntityDict } from 'oak-domain/lib/types';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
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();
|
||||
// 如果是开发环境,允许options
|
||||
if (['development'].includes(process.env.NODE_ENV)) {
|
||||
if (['development', 'staging'].includes(process.env.NODE_ENV)) {
|
||||
koa.use(async (ctx, next) => {
|
||||
ctx.set('Access-Control-Allow-Origin', '*');
|
||||
ctx.set('Access-Control-Allow-Headers', corsHeaders);
|
||||
|
|
|
|||
|
|
@ -114,10 +114,10 @@ function packageJsonContent({ name, version, description, cliName, cliBinName, i
|
|||
"lodash": "^4.17.21",
|
||||
"nprogress": "^0.2.0",
|
||||
${oakDependencyStr}
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.1.0",
|
||||
"react": "~18.2.0",
|
||||
"react-dom": "~18.2.0",
|
||||
"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-gesture-handler": "^2.14.0",
|
||||
"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-slick": "^0.29.0",
|
||||
"rmc-pull-to-refresh": "^1.0.13",
|
||||
"slick-carousel": "^1.8.1",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import Koa from 'koa';
|
|||
import KoaRouter from 'koa-router';
|
||||
import KoaBody from 'koa-body';
|
||||
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 { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
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,
|
||||
connector: Connector<ED, FrontCxt>,
|
||||
omitWatchers?: boolean,
|
||||
omitTimers?: boolean,
|
||||
routine?: (context: AsyncContext<EntityDict & BaseEntityDict>) => Promise<void>,
|
||||
routine?: (context: AsyncContext<ED>) => Promise<void>,
|
||||
) {
|
||||
const serverConfiguration: ServerConfiguration = require(join(
|
||||
path,
|
||||
|
|
@ -88,13 +89,13 @@ export async function startup<ED extends EntityDict & BaseEntityDict, FrontCxt e
|
|||
}
|
||||
|
||||
const appLoader = clusterInfo.usingCluster
|
||||
? new ClusterAppLoader(
|
||||
? new ClusterAppLoader<ED, Cxt>(
|
||||
path,
|
||||
io.of(DATA_SUBSCRIBER_NAMESPACE),
|
||||
io.of(SERVER_SUBSCRIBER_NAMESPACE),
|
||||
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.execStartRoutines();
|
||||
if (routine) {
|
||||
|
|
@ -113,7 +114,7 @@ export async function startup<ED extends EntityDict & BaseEntityDict, FrontCxt e
|
|||
const exception =
|
||||
err instanceof OakException
|
||||
? err
|
||||
: new OakException(
|
||||
: new OakException<ED>(
|
||||
serverConfiguration?.internalExceptionMask ||
|
||||
ExceptionMask
|
||||
);
|
||||
|
|
@ -134,7 +135,7 @@ export async function startup<ED extends EntityDict & BaseEntityDict, FrontCxt e
|
|||
const router = new KoaRouter();
|
||||
|
||||
// 如果是开发环境,允许options
|
||||
if (['development'].includes(process.env.NODE_ENV!)) {
|
||||
if (['development', 'staging'].includes(process.env.NODE_ENV!)) {
|
||||
koa.use(async (ctx, next) => {
|
||||
ctx.set('Access-Control-Allow-Origin', '*');
|
||||
ctx.set('Access-Control-Allow-Headers', corsHeaders);
|
||||
|
|
|
|||
48
test.ts
48
test.ts
|
|
@ -12,3 +12,51 @@ if (matches) {
|
|||
}
|
||||
)
|
||||
}
|
||||
|
||||
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