@tuya-sat/micro-script 3.0.27-beta.2 → 3.0.27-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/framework/react.config.js +11 -12
- package/dist/module/bundleServer.js +2 -5
- package/dist/module/main/fakeSaas.js +74 -10
- package/dist/module/main/fakeSaasInfo.js +55 -5
- package/dist/module/main/staticMain.js +13 -0
- package/dist/module/mainServer.js +1 -1
- package/dist/module/proxy.d.ts +1 -1
- package/dist/module/proxy.js +12 -3
- package/dist/scripts/build.js +18 -2
- package/dist/scripts/start.js +34 -20
- package/dist/scripts/startInMain.js +1 -2
- package/dist/template/index.js +2 -2
- package/dist/template/micro-app/index.tsx +1 -1
- package/dist/template/micro-app/interfaces.ts +3 -2
- package/dist/template/micro-app/lang.ts +2 -2
- package/package.json +5 -4
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.reactJsConfig = exports.reactTsConfig = void 0;
|
|
7
7
|
const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
|
|
8
8
|
const tsconfig_paths_webpack_plugin_1 = __importDefault(require("tsconfig-paths-webpack-plugin"));
|
|
9
|
-
const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
|
|
10
9
|
const paths_1 = __importDefault(require("../config/paths"));
|
|
11
10
|
const reactConfig = ({ isDev, isBuild, currentFramework, isTs, }) => {
|
|
12
11
|
return {
|
|
@@ -56,17 +55,17 @@ const reactConfig = ({ isDev, isBuild, currentFramework, isTs, }) => {
|
|
|
56
55
|
},
|
|
57
56
|
plugins: [
|
|
58
57
|
isDev && new react_refresh_webpack_plugin_1.default(),
|
|
59
|
-
isTs &&
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
// isTs &&
|
|
59
|
+
// new ForkTsCheckerWebpackPlugin({
|
|
60
|
+
// //https://github.com/TypeStrong/fork-ts-checker-webpack-plugin#typescript-options
|
|
61
|
+
// typescript: {
|
|
62
|
+
// diagnosticOptions: {
|
|
63
|
+
// semantic: true,
|
|
64
|
+
// syntactic: true,
|
|
65
|
+
// },
|
|
66
|
+
// mode: 'write-references',
|
|
67
|
+
// },
|
|
68
|
+
// }),
|
|
70
69
|
].filter((value) => Boolean(value)),
|
|
71
70
|
};
|
|
72
71
|
};
|
|
@@ -27,7 +27,6 @@ exports.runBundleServer = exports.createServerCompiler = void 0;
|
|
|
27
27
|
const webpack_1 = __importDefault(require("webpack"));
|
|
28
28
|
const webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
|
|
29
29
|
const ora_1 = __importDefault(require("ora"));
|
|
30
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
31
30
|
const paths_1 = __importDefault(require("../config/paths"));
|
|
32
31
|
const webpack_config_1 = __importDefault(require("../config/webpack.config"));
|
|
33
32
|
const options_1 = __importDefault(require("./options"));
|
|
@@ -67,11 +66,9 @@ function runBundleServer({ port, compiler, internalDevConfig = {}, }) {
|
|
|
67
66
|
console.log(`compiled time ~${endTime - startTime}ms`);
|
|
68
67
|
});
|
|
69
68
|
//临时提示
|
|
70
|
-
compiler.hooks.done.tap('once-tip', (0, onceFactory_1.onceFactory)(() => {
|
|
71
|
-
console.log(chalk_1.default.yellow(`Tip: 如果HMR失效且保存文件时造成多次compile,请考虑调高aggregateTimeout参数(可以尝试100)`));
|
|
72
|
-
}));
|
|
69
|
+
compiler.hooks.done.tap('once-tip', (0, onceFactory_1.onceFactory)(() => { }));
|
|
73
70
|
yield server.start();
|
|
74
|
-
console.log('
|
|
71
|
+
console.log('The local application server has started');
|
|
75
72
|
});
|
|
76
73
|
}
|
|
77
74
|
exports.runBundleServer = runBundleServer;
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -15,6 +38,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
38
|
exports.getFakeUser = void 0;
|
|
16
39
|
const axios_1 = __importDefault(require("axios"));
|
|
17
40
|
const chalk_1 = __importDefault(require("chalk"));
|
|
41
|
+
const fs = __importStar(require("fs-extra"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
18
43
|
function parse_SDF_CONFIG(html) {
|
|
19
44
|
var _a;
|
|
20
45
|
const REGEX = /(?<=window._SDF_CONFIG=).*?(?=;)/;
|
|
@@ -36,16 +61,55 @@ function getFakeSaas(config) {
|
|
|
36
61
|
console.log(chalk_1.default.red('没有配置target'));
|
|
37
62
|
process.exit(1);
|
|
38
63
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
64
|
+
if (config.isMainApp && fs.existsSync(path.join(process.cwd(), 'apps'))) {
|
|
65
|
+
const saasInfo = fs.readJSONSync(path.join(process.cwd(), 'saas-info.config.json'));
|
|
66
|
+
let saas = {
|
|
67
|
+
_SDF: {
|
|
68
|
+
base: '',
|
|
69
|
+
env: '',
|
|
70
|
+
region: '',
|
|
71
|
+
isOpenCode: true,
|
|
72
|
+
saas: {
|
|
73
|
+
background_image: 'https://images.tuyacn.com/rms-static/537a3fd0-1b5a-11ec-b7af-2d39f353debc-1632283530317.jpg?tyName=login.jpg',
|
|
74
|
+
charge_status: 'TRIAL',
|
|
75
|
+
entries: { entry_mode: 'normal' },
|
|
76
|
+
favicon: 'https://images.tuyacn.com/rms-static/ae9ba1b0-41d4-11ec-89bb-d7b7de210e4b-1636514225995.png?tyName=favicon.png',
|
|
77
|
+
host_filing: '备案:fast-cn.wgine',
|
|
78
|
+
is_custom: false,
|
|
79
|
+
is_need_jiyan: true,
|
|
80
|
+
is_support_mobile: true,
|
|
81
|
+
message_switch: true,
|
|
82
|
+
label: '',
|
|
83
|
+
legal_notice: 'https://ruomu-abc-001.fast-cn.wgine.com/policies/legal',
|
|
84
|
+
logo: 'https://images.tuyacn.com/rms-static/bc42adb0-6f86-11ec-b5fa-7deb2a111a61-1641538501643.png?tyName=%E9%BB%98%E8%AE%A4logo%2056X56%20.png',
|
|
85
|
+
privacy_policy: 'https://ruomu-abc-001.fast-cn.wgine.com/policies/privacy',
|
|
86
|
+
service_terms: 'https://ruomu-abc-001.fast-cn.wgine.com/policies/service',
|
|
87
|
+
supported_language: { en: 'English', zh: '简体中文' },
|
|
88
|
+
tenant_register_support: false,
|
|
89
|
+
tenant_type: 'SINGLE_TENANT',
|
|
90
|
+
title: '物联网开放平台',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
_SDF_CONFIG: {},
|
|
94
|
+
__MAIN_APP_PUBLIC_PATH: 'https://static1.tuyacn.com/static/sdf-main-app/0.0.0-123/',
|
|
95
|
+
};
|
|
96
|
+
Object.keys(saasInfo).forEach((key) => {
|
|
97
|
+
saas._SDF.saas[key] = saasInfo[key] ? saasInfo[key] : saas._SDF.saas[key];
|
|
98
|
+
});
|
|
99
|
+
return saas;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
const { data } = yield axios_1.default.get(new URL('/login?disable_third_login=true', config.target).href);
|
|
103
|
+
const _SDF_CONFIG = parse_SDF_CONFIG(data);
|
|
104
|
+
const _SDF = parse_SDF(data);
|
|
105
|
+
const __MAIN_APP_PUBLIC_PATH = parse__MAIN_APP_PUBLIC_PATH(data);
|
|
106
|
+
const saas = {
|
|
107
|
+
_SDF_CONFIG: JSON.parse(_SDF_CONFIG),
|
|
108
|
+
_SDF: JSON.parse(_SDF),
|
|
109
|
+
__MAIN_APP_PUBLIC_PATH: JSON.parse(__MAIN_APP_PUBLIC_PATH),
|
|
110
|
+
};
|
|
111
|
+
return saas;
|
|
112
|
+
}
|
|
49
113
|
});
|
|
50
114
|
}
|
|
51
115
|
exports.default = getFakeSaas;
|
|
@@ -34,13 +34,55 @@ const path = __importStar(require("path"));
|
|
|
34
34
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
35
35
|
const utils_1 = require("../../utils");
|
|
36
36
|
function mockSaasInfo(app, microPort) {
|
|
37
|
-
let { multiApps, debuggerConfig: { isMainApp }, } = require(paths_1.default.microConfig);
|
|
37
|
+
let { multiApps, microApps, debuggerConfig: { isMainApp }, } = require(paths_1.default.microConfig);
|
|
38
38
|
const idsMap = new Map();
|
|
39
39
|
multiApps = (0, utils_1.processMultiApps)(multiApps);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
if (isMainApp && fs_extra_1.default.existsSync(path.join(process.cwd(), 'apps'))) {
|
|
41
|
+
const dirs = ((microApps === null || microApps === void 0 ? void 0 : microApps.length) > 0 && microApps) ||
|
|
42
|
+
fs_extra_1.default.readdirSync(path.join(process.cwd(), 'apps'));
|
|
43
|
+
dirs === null || dirs === void 0 ? void 0 : dirs.forEach((dir) => {
|
|
44
|
+
idsMap.set(dir, { entry_id: (0, uuid_1.v4)(), oem_micro_app_id: (0, uid_1.uid)(16) });
|
|
45
|
+
});
|
|
46
|
+
app.get('/api/saas-info', (req, res) => {
|
|
47
|
+
const lang = 'zh';
|
|
48
|
+
const result = {
|
|
49
|
+
apps: [],
|
|
50
|
+
entry_info: { entries: [], entry_mode: 'normal' },
|
|
51
|
+
permissions: {},
|
|
52
|
+
saas_id_info_list: [],
|
|
53
|
+
};
|
|
54
|
+
dirs.forEach((dir) => {
|
|
55
|
+
const entry_id = idsMap.get(dir).entry_id;
|
|
56
|
+
const manifest = fs_extra_1.default.readJSONSync(path.join(process.cwd(), 'apps', dir, 'manifest.json'), 'utf-8');
|
|
57
|
+
const oem_micro_app_id = idsMap.get(dir).oem_micro_app_id;
|
|
58
|
+
const baseUrl = `/apps/${oem_micro_app_id}`;
|
|
59
|
+
result.saas_id_info_list.push({
|
|
60
|
+
oem_micro_app_id: oem_micro_app_id,
|
|
61
|
+
universal_id: '',
|
|
62
|
+
});
|
|
63
|
+
const appConfig = fs_extra_1.default.readJSONSync(path.join(process.cwd(), 'node_modules', '.micro', 'app.config.json'));
|
|
64
|
+
const micoApp = consturctApp(manifest, oem_micro_app_id, baseUrl, lang, appConfig[dir]);
|
|
65
|
+
const entryInfo = consturctEntry(manifest, oem_micro_app_id, entry_id, baseUrl, lang, `apps/${dir}`);
|
|
66
|
+
const permission = (manifest === null || manifest === void 0 ? void 0 : manifest.privileges.map((item) => {
|
|
67
|
+
return { permission_group: item.code };
|
|
68
|
+
})) || [];
|
|
69
|
+
result.apps.push(micoApp);
|
|
70
|
+
result.entry_info.entries.push(entryInfo);
|
|
71
|
+
result.permissions[oem_micro_app_id] = permission;
|
|
72
|
+
});
|
|
73
|
+
res.send({
|
|
74
|
+
code: null,
|
|
75
|
+
errorMsg: null,
|
|
76
|
+
msg: null,
|
|
77
|
+
result,
|
|
78
|
+
success: true,
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
43
82
|
if (!isMainApp) {
|
|
83
|
+
multiApps === null || multiApps === void 0 ? void 0 : multiApps.forEach((app) => {
|
|
84
|
+
idsMap.set(app.name, { entry_id: (0, uuid_1.v4)(), oem_micro_app_id: (0, uid_1.uid)(16) });
|
|
85
|
+
});
|
|
44
86
|
app.get('/api/saas-info', (req, res) => {
|
|
45
87
|
const lang = parseCookie(req.headers['cookie'], 'main-i18next');
|
|
46
88
|
if ((0, utils_1.isMonorepo)() || (multiApps && multiApps.length > 0)) {
|
|
@@ -103,7 +145,13 @@ function mockSaasInfo(app, microPort) {
|
|
|
103
145
|
}
|
|
104
146
|
exports.default = mockSaasInfo;
|
|
105
147
|
function consturctEntry(manifest, oem_micro_app_id, entry_id, baseUrl, lang, dir) {
|
|
106
|
-
|
|
148
|
+
let fakeMenu;
|
|
149
|
+
if (dir === 'apps/iot-suite-device') {
|
|
150
|
+
fakeMenu = (0, micro_utils_1.getFakeMenu)(Object.assign(Object.assign({}, manifest), { entries: [] }), dir);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
fakeMenu = (0, micro_utils_1.getFakeMenu)(manifest, dir);
|
|
154
|
+
}
|
|
107
155
|
let stack = [fakeMenu];
|
|
108
156
|
while (stack.length) {
|
|
109
157
|
const menu = stack.shift();
|
|
@@ -121,6 +169,8 @@ function consturctEntry(manifest, oem_micro_app_id, entry_id, baseUrl, lang, dir
|
|
|
121
169
|
if (menu.sub_entry_list.length) {
|
|
122
170
|
stack.push(...menu.sub_entry_list);
|
|
123
171
|
}
|
|
172
|
+
menu.icon =
|
|
173
|
+
'https://images.tuyacn.com/rms-static/5d202fa0-e909-11eb-815d-e39234ce96ff-1626751199130.png?tyName=space-manage.png';
|
|
124
174
|
}
|
|
125
175
|
return fakeMenu;
|
|
126
176
|
}
|
|
@@ -41,6 +41,8 @@ const fakeSaas_1 = __importStar(require("./fakeSaas"));
|
|
|
41
41
|
const paths_1 = __importDefault(require("../../config/paths"));
|
|
42
42
|
const webpack_common_1 = require("../../config/webpack.common");
|
|
43
43
|
const undici_1 = require("undici");
|
|
44
|
+
const fs = __importStar(require("fs-extra"));
|
|
45
|
+
const path = __importStar(require("path"));
|
|
44
46
|
function parse_SDF(html) {
|
|
45
47
|
var _a;
|
|
46
48
|
const REGEX = /(?<=window._SDF=).*?}(?=;)/;
|
|
@@ -117,6 +119,17 @@ function insertScript($, debuggerConfig) {
|
|
|
117
119
|
}
|
|
118
120
|
: {})), readThemeConfig()));
|
|
119
121
|
overrideNotification(saas);
|
|
122
|
+
if (fs.existsSync(path.join(process.cwd(), 'saas-info.config.json'))) {
|
|
123
|
+
const saasInfo = fs.readJSONSync(path.join(process.cwd(), 'saas-info.config.json'));
|
|
124
|
+
let $favicon = $('link[rel="icon"]');
|
|
125
|
+
if (!$favicon.length) {
|
|
126
|
+
$('head').prepend('<link rel="icon" />');
|
|
127
|
+
$favicon = $('link[rel="icon"]');
|
|
128
|
+
}
|
|
129
|
+
const favicon = (saasInfo === null || saasInfo === void 0 ? void 0 : saasInfo.favicon) ? saasInfo.favicon : 'https://images.tuyacn.com/rms-static/ae9ba1b0-41d4-11ec-89bb-d7b7de210e4b-1636514225995.png?tyName=favicon.png';
|
|
130
|
+
$favicon
|
|
131
|
+
.attr('href', favicon);
|
|
132
|
+
}
|
|
120
133
|
// 本地开发态多语言剥离多语言平台,走本地多语言兜底逻辑
|
|
121
134
|
delete _SDF.saas.saas_locales;
|
|
122
135
|
$('head').append($('<script>').text(`window._SDF_CONFIG=${JSON.stringify(_SDF_CONFIG)};window._SDF=${JSON.stringify(_SDF)};window.__MAIN_APP_PUBLIC_PATH=${JSON.stringify(__MAIN_APP_PUBLIC_PATH)};
|
package/dist/module/proxy.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Application } from
|
|
1
|
+
import { Application } from 'express';
|
|
2
2
|
export default function useProxy(app: Application): void;
|
package/dist/module/proxy.js
CHANGED
|
@@ -4,12 +4,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const paths_1 = __importDefault(require("../config/paths"));
|
|
7
|
+
const http_proxy_middleware_1 = require("http-proxy-middleware");
|
|
7
8
|
function useProxy(app) {
|
|
8
|
-
const isProxy = process.env.MICRO_PROXY ===
|
|
9
|
+
const isProxy = process.env.MICRO_PROXY === 'true';
|
|
10
|
+
const { debuggerConfig } = require(paths_1.default.microConfig);
|
|
9
11
|
if (isProxy) {
|
|
10
|
-
const createProxy = require(
|
|
11
|
-
const { debuggerConfig } = require(paths_1.default.microConfig);
|
|
12
|
+
const createProxy = require('@tuya-sat/micro-dev-proxy').default;
|
|
12
13
|
createProxy(debuggerConfig)(app);
|
|
13
14
|
}
|
|
15
|
+
const customApiUrl = debuggerConfig === null || debuggerConfig === void 0 ? void 0 : debuggerConfig.customApiUrl;
|
|
16
|
+
if (customApiUrl) {
|
|
17
|
+
app.use('/custom-api', (0, http_proxy_middleware_1.createProxyMiddleware)({
|
|
18
|
+
target: customApiUrl,
|
|
19
|
+
pathRewrite: { '^/custom-api': '' },
|
|
20
|
+
changeOrigin: true,
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
14
23
|
}
|
|
15
24
|
exports.default = useProxy;
|
package/dist/scripts/build.js
CHANGED
|
@@ -17,13 +17,16 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
17
17
|
const ora_1 = __importDefault(require("ora"));
|
|
18
18
|
const webpack_config_1 = __importDefault(require("../config/webpack.config"));
|
|
19
19
|
const template_1 = __importDefault(require("../template"));
|
|
20
|
-
const
|
|
20
|
+
const paths_1 = __importDefault(require("../config/paths"));
|
|
21
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
22
|
+
const path_1 = __importDefault(require("path"));
|
|
21
23
|
const BUILD_FAIL_TIP = '糟糕:打包失败了,下面是具体信息';
|
|
22
24
|
const spinner = (0, ora_1.default)('building').start();
|
|
25
|
+
let { debuggerConfig: { isMainApp }, } = require(paths_1.default.microConfig);
|
|
23
26
|
const config = (0, webpack_config_1.default)();
|
|
24
27
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
-
yield (0, apis_1.default)();
|
|
26
28
|
yield (0, template_1.default)();
|
|
29
|
+
// await apis();
|
|
27
30
|
(0, webpack_1.default)(config).run((err, stats) => {
|
|
28
31
|
if (err) {
|
|
29
32
|
spinner.fail();
|
|
@@ -39,6 +42,19 @@ const config = (0, webpack_config_1.default)();
|
|
|
39
42
|
process.exit(1);
|
|
40
43
|
}
|
|
41
44
|
spinner.succeed();
|
|
45
|
+
// 修复主应用 manifest.json资源丢失问题
|
|
46
|
+
if (isMainApp) {
|
|
47
|
+
const files = fs_extra_1.default.readdirSync(path_1.default.join(process.cwd(), 'dist/static/img')) || [];
|
|
48
|
+
const manifest = fs_extra_1.default.readJSONSync(path_1.default.join(process.cwd(), 'dist/manifest.json'));
|
|
49
|
+
const result = files.reduce((acc, file) => {
|
|
50
|
+
if (file) {
|
|
51
|
+
const key = file.split('.')[0];
|
|
52
|
+
acc[key] = `static/img/${file}`;
|
|
53
|
+
}
|
|
54
|
+
return acc;
|
|
55
|
+
}, {});
|
|
56
|
+
fs_extra_1.default.writeJSONSync(path_1.default.join(process.cwd(), 'dist/manifest.json'), Object.assign(Object.assign({}, manifest), result));
|
|
57
|
+
}
|
|
42
58
|
if (stats.hasWarnings()) {
|
|
43
59
|
console.log(chalk_1.default.yellow('难受:有告警信息,下面是具体信息'));
|
|
44
60
|
console.log(warnings.map((item) => item.message).join('\n'));
|
package/dist/scripts/start.js
CHANGED
|
@@ -12,36 +12,50 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
16
15
|
const portfinder_1 = __importDefault(require("portfinder"));
|
|
17
16
|
const mock_1 = __importDefault(require("../module/mock"));
|
|
18
17
|
const bundleServer_1 = require("../module/bundleServer");
|
|
19
18
|
const proxy_1 = __importDefault(require("../module/proxy"));
|
|
20
19
|
const template_1 = __importDefault(require("../template"));
|
|
21
|
-
const apis_1 = __importDefault(require("../apis"));
|
|
22
20
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
-
yield (0, apis_1.default)();
|
|
24
21
|
yield (0, template_1.default)();
|
|
22
|
+
// await apis();
|
|
25
23
|
let defaultPort = 9000;
|
|
26
|
-
console.log(chalk_1.default.yellow('如果是pc端的微应用调试,请勿使用该命令,考虑使用`start --main`或`start --main --proxy`'));
|
|
27
24
|
//检测端口占用情况
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
(0, proxy_1.default)(app);
|
|
41
|
-
return middleware;
|
|
25
|
+
if (process.env.PROT) {
|
|
26
|
+
const compiler = (0, bundleServer_1.createServerCompiler)();
|
|
27
|
+
(0, bundleServer_1.runBundleServer)({
|
|
28
|
+
port: Number(process.env.PROT),
|
|
29
|
+
compiler,
|
|
30
|
+
internalDevConfig: {
|
|
31
|
+
open: false,
|
|
32
|
+
setupMiddlewares(middleware, { app }) {
|
|
33
|
+
(0, mock_1.default)(app);
|
|
34
|
+
(0, proxy_1.default)(app);
|
|
35
|
+
return middleware;
|
|
36
|
+
},
|
|
42
37
|
},
|
|
43
|
-
}
|
|
44
|
-
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const port = yield portfinder_1.default.getPortPromise({
|
|
42
|
+
port: defaultPort,
|
|
43
|
+
stopPort: defaultPort + 100,
|
|
44
|
+
});
|
|
45
|
+
const compiler = (0, bundleServer_1.createServerCompiler)();
|
|
46
|
+
(0, bundleServer_1.runBundleServer)({
|
|
47
|
+
port,
|
|
48
|
+
compiler,
|
|
49
|
+
internalDevConfig: {
|
|
50
|
+
open: true,
|
|
51
|
+
setupMiddlewares(middleware, { app }) {
|
|
52
|
+
(0, mock_1.default)(app);
|
|
53
|
+
(0, proxy_1.default)(app);
|
|
54
|
+
return middleware;
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
45
59
|
}))().catch((err) => {
|
|
46
60
|
console.log(err);
|
|
47
61
|
});
|
|
@@ -18,10 +18,9 @@ const mainServer_1 = __importDefault(require("../module/mainServer"));
|
|
|
18
18
|
const bundleServer_1 = require("../module/bundleServer");
|
|
19
19
|
const kill_port_1 = __importDefault(require("kill-port"));
|
|
20
20
|
const template_1 = __importDefault(require("../template"));
|
|
21
|
-
const apis_1 = __importDefault(require("../apis"));
|
|
22
21
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
-
yield (0, apis_1.default)();
|
|
24
22
|
yield (0, template_1.default)();
|
|
23
|
+
// await apis();
|
|
25
24
|
let defaultPort = 9000;
|
|
26
25
|
//检测端口占用情况
|
|
27
26
|
const bundledServerPort = yield portfinder_1.default.getPortPromise({
|
package/dist/template/index.js
CHANGED
|
@@ -86,8 +86,8 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
86
86
|
let langContent = fs.readFileSync(path.join(__dirname, './micro-app/lang.ts'), {
|
|
87
87
|
encoding: 'utf8',
|
|
88
88
|
});
|
|
89
|
-
langContent = langContent.replace("import en from './en';", `import en from '../../src/lang/en'`);
|
|
90
|
-
langContent = langContent.replace("import zh from './zh';", `import zh from '../../src/lang/zh'`);
|
|
89
|
+
langContent = langContent.replace("import en from './en.json';", `import en from '../../src/lang/en.json'`);
|
|
90
|
+
langContent = langContent.replace("import zh from './zh.json';", `import zh from '../../src/lang/zh.json'`);
|
|
91
91
|
fs.writeFileSync(microPath + '/lang.ts', langContent);
|
|
92
92
|
}
|
|
93
93
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { CaptureContext, Event, Severity } from '@sentry/types';
|
|
2
2
|
|
|
3
|
+
type IState = { [k in string]: string | number | null };
|
|
3
4
|
interface mainHistory {
|
|
4
|
-
push: (path, state
|
|
5
|
-
replace: (path, state
|
|
5
|
+
push: (path: string, state?: IState) => void;
|
|
6
|
+
replace: (path: string, state?: IState) => void;
|
|
6
7
|
go: (n: number) => void;
|
|
7
8
|
goBack: () => void;
|
|
8
9
|
goForward: () => void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import i18n from 'i18next';
|
|
2
2
|
import { initReactI18next } from 'react-i18next';
|
|
3
3
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
4
|
-
import en from './en';
|
|
5
|
-
import zh from './zh';
|
|
4
|
+
import en from './en.json';
|
|
5
|
+
import zh from './zh.json';
|
|
6
6
|
|
|
7
7
|
i18n
|
|
8
8
|
.use(LanguageDetector)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuya-sat/micro-script",
|
|
3
|
-
"version": "3.0.27-beta.
|
|
3
|
+
"version": "3.0.27-beta.20",
|
|
4
4
|
"bin": "./dist/bin/cli.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"@babel/preset-typescript": "7.16.7",
|
|
24
24
|
"@babel/traverse": "^7.20.13",
|
|
25
25
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.4",
|
|
26
|
-
"@tuya-sat/micro-dev-loader": "3.0.27-beta.
|
|
27
|
-
"@tuya-sat/micro-dev-proxy": "3.0.27-beta.
|
|
28
|
-
"@tuya-sat/micro-utils": "3.0.27-beta.
|
|
26
|
+
"@tuya-sat/micro-dev-loader": "3.0.27-beta.20",
|
|
27
|
+
"@tuya-sat/micro-dev-proxy": "3.0.27-beta.20",
|
|
28
|
+
"@tuya-sat/micro-utils": "3.0.27-beta.20",
|
|
29
29
|
"@types/kill-port": "^2.0.0",
|
|
30
30
|
"babel-loader": "8.2.4",
|
|
31
31
|
"babel-plugin-import": "1.13.3",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"kill-port": "^2.0.1",
|
|
45
45
|
"less": "4.1.2",
|
|
46
46
|
"less-loader": "10.2.0",
|
|
47
|
+
"mime": "^3.0.0",
|
|
47
48
|
"mini-css-extract-plugin": "2.6.0",
|
|
48
49
|
"open": "8.4.0",
|
|
49
50
|
"ora": "5.4.1",
|