@tuya-sat/micro-script 3.0.27-beta.4 → 3.0.27-beta.6
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.
|
@@ -38,7 +38,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
38
|
exports.getFakeUser = void 0;
|
|
39
39
|
const axios_1 = __importDefault(require("axios"));
|
|
40
40
|
const chalk_1 = __importDefault(require("chalk"));
|
|
41
|
-
const fs = __importStar(require("fs"));
|
|
41
|
+
const fs = __importStar(require("fs-extra"));
|
|
42
42
|
const path = __importStar(require("path"));
|
|
43
43
|
function parse_SDF_CONFIG(html) {
|
|
44
44
|
var _a;
|
|
@@ -62,7 +62,8 @@ function getFakeSaas(config) {
|
|
|
62
62
|
process.exit(1);
|
|
63
63
|
}
|
|
64
64
|
if (config.isMainApp && fs.existsSync(path.join(process.cwd(), 'apps'))) {
|
|
65
|
-
const
|
|
65
|
+
const saasInfo = fs.readJSONSync(path.join(process.cwd(), 'saas-info.config.json'));
|
|
66
|
+
let saas = {
|
|
66
67
|
_SDF: {
|
|
67
68
|
base: '',
|
|
68
69
|
env: '',
|
|
@@ -85,12 +86,15 @@ function getFakeSaas(config) {
|
|
|
85
86
|
supported_language: { en: 'English', zh: '简体中文' },
|
|
86
87
|
tenant_register_support: false,
|
|
87
88
|
tenant_type: "SINGLE_TENANT",
|
|
88
|
-
title: "
|
|
89
|
+
title: "物联网开放平台"
|
|
89
90
|
},
|
|
90
91
|
},
|
|
91
92
|
_SDF_CONFIG: {},
|
|
92
93
|
__MAIN_APP_PUBLIC_PATH: 'https://static1.tuyacn.com/static/sdf-main-app/0.0.0-123/',
|
|
93
94
|
};
|
|
95
|
+
Object.keys(saasInfo).forEach(key => {
|
|
96
|
+
saas._SDF.saas[key] = saasInfo[key] ? saasInfo[key] : saas._SDF.saas[key];
|
|
97
|
+
});
|
|
94
98
|
return saas;
|
|
95
99
|
}
|
|
96
100
|
else {
|
|
@@ -37,10 +37,11 @@ function mockSaasInfo(app, microPort) {
|
|
|
37
37
|
let { multiApps, debuggerConfig: { isMainApp }, } = require(paths_1.default.microConfig);
|
|
38
38
|
const idsMap = new Map();
|
|
39
39
|
multiApps = (0, utils_1.processMultiApps)(multiApps);
|
|
40
|
-
multiApps === null || multiApps === void 0 ? void 0 : multiApps.forEach((app) => {
|
|
41
|
-
idsMap.set(app.name, { entry_id: (0, uuid_1.v4)(), oem_micro_app_id: (0, uid_1.uid)(16) });
|
|
42
|
-
});
|
|
43
40
|
if (isMainApp && fs_extra_1.default.existsSync(path.join(process.cwd(), 'apps'))) {
|
|
41
|
+
const dirs = fs_extra_1.default.readdirSync(path.join(process.cwd(), 'apps'));
|
|
42
|
+
dirs === null || dirs === void 0 ? void 0 : dirs.forEach(dir => {
|
|
43
|
+
idsMap.set(dir, { entry_id: (0, uuid_1.v4)(), oem_micro_app_id: (0, uid_1.uid)(16) });
|
|
44
|
+
});
|
|
44
45
|
app.get('/api/saas-info', (req, res) => {
|
|
45
46
|
const lang = 'zh';
|
|
46
47
|
const result = {
|
|
@@ -49,11 +50,10 @@ function mockSaasInfo(app, microPort) {
|
|
|
49
50
|
permissions: {},
|
|
50
51
|
saas_id_info_list: [],
|
|
51
52
|
};
|
|
52
|
-
const dirs = fs_extra_1.default.readdirSync(path.join(process.cwd(), 'apps'));
|
|
53
53
|
dirs.forEach((dir) => {
|
|
54
|
-
const entry_id =
|
|
54
|
+
const entry_id = idsMap.get(dir).entry_id;
|
|
55
55
|
const manifest = fs_extra_1.default.readJSONSync(path.join(process.cwd(), 'apps', dir, 'manifest.json'), 'utf-8');
|
|
56
|
-
const oem_micro_app_id =
|
|
56
|
+
const oem_micro_app_id = idsMap.get(dir).oem_micro_app_id;
|
|
57
57
|
const baseUrl = `/apps/${oem_micro_app_id}`;
|
|
58
58
|
result.saas_id_info_list.push({
|
|
59
59
|
oem_micro_app_id: oem_micro_app_id,
|
|
@@ -79,6 +79,9 @@ function mockSaasInfo(app, microPort) {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
if (!isMainApp) {
|
|
82
|
+
multiApps === null || multiApps === void 0 ? void 0 : multiApps.forEach((app) => {
|
|
83
|
+
idsMap.set(app.name, { entry_id: (0, uuid_1.v4)(), oem_micro_app_id: (0, uid_1.uid)(16) });
|
|
84
|
+
});
|
|
82
85
|
app.get('/api/saas-info', (req, res) => {
|
|
83
86
|
const lang = parseCookie(req.headers['cookie'], 'main-i18next');
|
|
84
87
|
if ((0, utils_1.isMonorepo)() || (multiApps && multiApps.length > 0)) {
|
|
@@ -159,6 +162,7 @@ function consturctEntry(manifest, oem_micro_app_id, entry_id, baseUrl, lang, dir
|
|
|
159
162
|
if (menu.sub_entry_list.length) {
|
|
160
163
|
stack.push(...menu.sub_entry_list);
|
|
161
164
|
}
|
|
165
|
+
menu.icon = 'https://images.tuyacn.com/rms-static/5d202fa0-e909-11eb-815d-e39234ce96ff-1626751199130.png?tyName=space-manage.png';
|
|
162
166
|
}
|
|
163
167
|
return fakeMenu;
|
|
164
168
|
}
|
|
@@ -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,15 @@ function insertScript($, debuggerConfig) {
|
|
|
117
119
|
}
|
|
118
120
|
: {})), readThemeConfig()));
|
|
119
121
|
overrideNotification(saas);
|
|
122
|
+
const saasInfo = fs.readJSONSync(path.join(process.cwd(), 'saas-info.config.json'));
|
|
123
|
+
let $favicon = $('link[rel="icon"]');
|
|
124
|
+
if (!$favicon.length) {
|
|
125
|
+
$('head').prepend('<link rel="icon" />');
|
|
126
|
+
$favicon = $('link[rel="icon"]');
|
|
127
|
+
}
|
|
128
|
+
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';
|
|
129
|
+
$favicon
|
|
130
|
+
.attr('href', favicon);
|
|
120
131
|
// 本地开发态多语言剥离多语言平台,走本地多语言兜底逻辑
|
|
121
132
|
delete _SDF.saas.saas_locales;
|
|
122
133
|
$('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/scripts/start.js
CHANGED
|
@@ -24,14 +24,14 @@ const template_1 = __importDefault(require("../template"));
|
|
|
24
24
|
let defaultPort = 9000;
|
|
25
25
|
console.log(chalk_1.default.yellow('如果是pc端的微应用调试,请勿使用该命令,考虑使用`start --main`或`start --main --proxy`'));
|
|
26
26
|
//检测端口占用情况
|
|
27
|
-
console.log("process.env.
|
|
28
|
-
if (process.env.
|
|
27
|
+
console.log("process.env.PROT", process.env.PROT);
|
|
28
|
+
if (process.env.PROT) {
|
|
29
29
|
const compiler = (0, bundleServer_1.createServerCompiler)();
|
|
30
30
|
(0, bundleServer_1.runBundleServer)({
|
|
31
|
-
port: Number(process.env.
|
|
31
|
+
port: Number(process.env.PROT),
|
|
32
32
|
compiler,
|
|
33
33
|
internalDevConfig: {
|
|
34
|
-
open:
|
|
34
|
+
open: false,
|
|
35
35
|
setupMiddlewares(middleware, { app }) {
|
|
36
36
|
(0, mock_1.default)(app);
|
|
37
37
|
(0, proxy_1.default)(app);
|
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.6",
|
|
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.6",
|
|
27
|
+
"@tuya-sat/micro-dev-proxy": "3.0.27-beta.6",
|
|
28
|
+
"@tuya-sat/micro-utils": "3.0.27-beta.6",
|
|
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",
|