diff --git a/config/web/webpack.config.js b/config/web/webpack.config.js
index 51c8c2d..101800a 100644
--- a/config/web/webpack.config.js
+++ b/config/web/webpack.config.js
@@ -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
diff --git a/lib/server/start.d.ts b/lib/server/start.d.ts
index 8c0934e..db13f31 100644
--- a/lib/server/start.d.ts
+++ b/lib/server/start.d.ts
@@ -1,7 +1,8 @@
///
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>(path: string, connector: Connector, omitWatchers?: boolean, omitTimers?: boolean, routine?: (context: AsyncContext) => Promise): Promise;
+export declare function startup, Cxt extends BackendRuntimeContext>(path: string, connector: Connector, omitWatchers?: boolean, omitTimers?: boolean, routine?: (context: AsyncContext) => Promise): Promise;
diff --git a/lib/server/start.js b/lib/server/start.js
index 3c811eb..336562f 100644
--- a/lib/server/start.js
+++ b/lib/server/start.js
@@ -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);
diff --git a/lib/template.js b/lib/template.js
index 3c1b925..345c02b 100644
--- a/lib/template.js
+++ b/lib/template.js
@@ -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": {
diff --git a/src/server/start.ts b/src/server/start.ts
index a601967..385bc18 100644
--- a/src/server/start.ts
+++ b/src/server/start.ts
@@ -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>(
+export async function startup, Cxt extends BackendRuntimeContext>(
path: string,
connector: Connector,
omitWatchers?: boolean,
omitTimers?: boolean,
- routine?: (context: AsyncContext) => Promise,
+ routine?: (context: AsyncContext) => Promise,
) {
const serverConfiguration: ServerConfiguration = require(join(
path,
@@ -88,13 +89,13 @@ export async function startup(
path,
io.of(DATA_SUBSCRIBER_NAMESPACE),
io.of(SERVER_SUBSCRIBER_NAMESPACE),
connector.getSubscribeRouter()
)
- : new AppLoader(path, io.of(DATA_SUBSCRIBER_NAMESPACE));
+ : new AppLoader(path, io.of(DATA_SUBSCRIBER_NAMESPACE));
await appLoader.mount();
await appLoader.execStartRoutines();
if (routine) {
@@ -113,7 +114,7 @@ export async function startup(
serverConfiguration?.internalExceptionMask ||
ExceptionMask
);
@@ -134,7 +135,7 @@ export async function startup {
ctx.set('Access-Control-Allow-Origin', '*');
ctx.set('Access-Control-Allow-Headers', corsHeaders);
diff --git a/test.ts b/test.ts
index bcf1232..e43ff02 100644
--- a/test.ts
+++ b/test.ts
@@ -11,4 +11,52 @@ if (matches) {
console.log(codeContent);
}
)
-}
\ No newline at end of file
+}
+
+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) => 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;
\ No newline at end of file