@tuya-sat/micro-script 2.0.0-rc.7 → 2.0.0
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/config/webpack.common.js +1 -1
- package/dist/framework/react.config.js +0 -13
- package/dist/framework/vue.config.js +0 -13
- package/dist/module/bundleServer.d.ts +1 -1
- package/dist/module/main/fakeSaasInfo.js +3 -3
- package/dist/module/main/staticMain.d.ts +1 -0
- package/dist/scripts/start.js +10 -14
- package/dist/scripts/startInMain.js +3 -0
- package/package.json +49 -54
|
@@ -139,7 +139,7 @@ function getCommonConfig({ isDev, isBuild, }) {
|
|
|
139
139
|
filename: "static/css/[name].[contenthash:8].css",
|
|
140
140
|
chunkFilename: "static/css/[name].[contenthash:8].chunk.css",
|
|
141
141
|
}),
|
|
142
|
-
].filter(Boolean),
|
|
142
|
+
].filter((value) => Boolean(value)),
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
exports.default = getCommonConfig;
|
|
@@ -52,19 +52,6 @@ const reactConfig = ({ isDev, isBuild, currentFramework, isTs, }) => {
|
|
|
52
52
|
},
|
|
53
53
|
],
|
|
54
54
|
},
|
|
55
|
-
isDev &&
|
|
56
|
-
process.env.START_IN_MAIN !== "true" && {
|
|
57
|
-
test: isTs ? paths_1.default.ReactTsEntryFile : paths_1.default.ReactJsEntryFile,
|
|
58
|
-
include: paths_1.default.appSrc,
|
|
59
|
-
use: [
|
|
60
|
-
{
|
|
61
|
-
loader: require.resolve("@tuya-sat/micro-dev-loader"),
|
|
62
|
-
options: {
|
|
63
|
-
microFramework: currentFramework,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
55
|
].filter((value) => Boolean(value)),
|
|
69
56
|
},
|
|
70
57
|
plugins: [
|
|
@@ -50,19 +50,6 @@ const vueConfig = ({ isDev, isBuild, currentFramework, isTs, }) => {
|
|
|
50
50
|
},
|
|
51
51
|
],
|
|
52
52
|
},
|
|
53
|
-
isDev &&
|
|
54
|
-
process.env.START_IN_MAIN !== "true" && {
|
|
55
|
-
test: isTs ? paths_js_1.default.vueTsEntryFile : paths_js_1.default.vueJsEntryFile,
|
|
56
|
-
include: paths_js_1.default.appSrc,
|
|
57
|
-
use: [
|
|
58
|
-
{
|
|
59
|
-
loader: require.resolve("@tuya-sat/micro-dev-loader"),
|
|
60
|
-
options: {
|
|
61
|
-
microFramework: currentFramework,
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
53
|
].filter((value) => Boolean(value)),
|
|
67
54
|
},
|
|
68
55
|
plugins: [
|
|
@@ -5,5 +5,5 @@ export declare function createServerCompiler(): webpack.Compiler;
|
|
|
5
5
|
export declare function runBundleServer({ port, compiler, internalDevConfig, }: {
|
|
6
6
|
port: number;
|
|
7
7
|
compiler: Compiler;
|
|
8
|
-
internalDevConfig?: Pick<Configuration, "open" | "setupMiddlewares">;
|
|
8
|
+
internalDevConfig?: Pick<Configuration, "open" | "setupMiddlewares" | "allowedHosts">;
|
|
9
9
|
}): Promise<void>;
|
|
@@ -7,10 +7,10 @@ const micro_utils_1 = require("@tuya-sat/micro-utils");
|
|
|
7
7
|
const uuid_1 = require("uuid");
|
|
8
8
|
const paths_1 = __importDefault(require("../../config/paths"));
|
|
9
9
|
function mockSaasInfo(app, microPort) {
|
|
10
|
-
const
|
|
10
|
+
const manifest = (0, micro_utils_1.parseManifest)();
|
|
11
11
|
const entry_id = (0, uuid_1.v4)();
|
|
12
|
+
const oem_micro_app_id = manifest.universalId;
|
|
12
13
|
const baseUrl = `/apps/${oem_micro_app_id}`;
|
|
13
|
-
const manifest = (0, micro_utils_1.parseManifest)();
|
|
14
14
|
app.get("/api/saas-info", (req, res) => {
|
|
15
15
|
const lang = parseCookie(req.headers["cookie"], "main-i18next");
|
|
16
16
|
const app = consturctApp(manifest, oem_micro_app_id, baseUrl, lang, microPort);
|
|
@@ -68,7 +68,7 @@ function consturctApp(manifest, oem_micro_app_id, baseUrl, lang, port) {
|
|
|
68
68
|
function consturctPermissions() {
|
|
69
69
|
delete require.cache[paths_1.default.microConfig];
|
|
70
70
|
const { mockPermissions = [] } = require(paths_1.default.microConfig).debuggerConfig || {};
|
|
71
|
-
return mockPermissions;
|
|
71
|
+
return mockPermissions.map((code) => ({ permission_group: code }));
|
|
72
72
|
}
|
|
73
73
|
function pickText(texts, lang) {
|
|
74
74
|
return lang === "en" ? texts[1] : texts[0];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Express } from "express";
|
|
2
2
|
import type { Config } from "@tuya-sat/micro-dev-proxy";
|
|
3
3
|
export interface DebuggerConfig extends Config {
|
|
4
|
+
mockPermissions?: string[];
|
|
4
5
|
base?: string;
|
|
5
6
|
}
|
|
6
7
|
export default function staticMain(app: Express, debuggerConfig: DebuggerConfig): void;
|
package/dist/scripts/start.js
CHANGED
|
@@ -12,35 +12,31 @@ 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"));
|
|
15
16
|
const portfinder_1 = __importDefault(require("portfinder"));
|
|
16
|
-
const micro_dev_loader_1 = require("@tuya-sat/micro-dev-loader");
|
|
17
|
-
const micro_utils_1 = require("@tuya-sat/micro-utils");
|
|
18
17
|
const mock_1 = __importDefault(require("../module/mock"));
|
|
19
18
|
const bundleServer_1 = require("../module/bundleServer");
|
|
20
19
|
const proxy_1 = __importDefault(require("../module/proxy"));
|
|
21
|
-
const needLayout = !(0, micro_utils_1.isMobile)();
|
|
22
|
-
const internalDevConfig = {
|
|
23
|
-
open: true,
|
|
24
|
-
setupMiddlewares(middleware, { app }) {
|
|
25
|
-
needLayout && micro_dev_loader_1.LayoutMockPlugin.useLayoutStatic(app);
|
|
26
|
-
(0, mock_1.default)(app);
|
|
27
|
-
(0, proxy_1.default)(app);
|
|
28
|
-
return middleware;
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
20
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
21
|
let defaultPort = 9000;
|
|
22
|
+
console.log(chalk_1.default.yellow("如果是pc端的微应用调试,请勿使用该命令,考虑使用`start --main`或`start --main --proxy`"));
|
|
33
23
|
//检测端口占用情况
|
|
34
24
|
const port = yield portfinder_1.default.getPortPromise({
|
|
35
25
|
port: defaultPort,
|
|
36
26
|
stopPort: defaultPort + 100,
|
|
37
27
|
});
|
|
38
28
|
const compiler = (0, bundleServer_1.createServerCompiler)();
|
|
39
|
-
needLayout && new micro_dev_loader_1.LayoutMockPlugin().apply(compiler);
|
|
40
29
|
(0, bundleServer_1.runBundleServer)({
|
|
41
30
|
port,
|
|
42
31
|
compiler,
|
|
43
|
-
internalDevConfig
|
|
32
|
+
internalDevConfig: {
|
|
33
|
+
open: true,
|
|
34
|
+
setupMiddlewares(middleware, { app }) {
|
|
35
|
+
(0, mock_1.default)(app);
|
|
36
|
+
(0, proxy_1.default)(app);
|
|
37
|
+
return middleware;
|
|
38
|
+
},
|
|
39
|
+
},
|
|
44
40
|
});
|
|
45
41
|
}))().catch((err) => {
|
|
46
42
|
console.log(err);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuya-sat/micro-script",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"bin": "./dist/bin/cli.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,61 +15,57 @@
|
|
|
15
15
|
"prepublish": "yarn build"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@babel/core": "
|
|
19
|
-
"@babel/preset-env": "
|
|
20
|
-
"@babel/preset-react": "
|
|
21
|
-
"@babel/preset-typescript": "
|
|
22
|
-
"@pmmmwh/react-refresh-webpack-plugin": "
|
|
23
|
-
"@tuya-sat/micro-dev-loader": "2.0.0
|
|
24
|
-
"@tuya-sat/micro-dev-proxy": "2.0.0
|
|
25
|
-
"@tuya-sat/micro-utils": "2.0.0
|
|
26
|
-
"babel-loader": "
|
|
27
|
-
"babel-plugin-import": "
|
|
18
|
+
"@babel/core": "7.17.8",
|
|
19
|
+
"@babel/preset-env": "7.16.11",
|
|
20
|
+
"@babel/preset-react": "7.16.7",
|
|
21
|
+
"@babel/preset-typescript": "7.16.7",
|
|
22
|
+
"@pmmmwh/react-refresh-webpack-plugin": "0.5.4",
|
|
23
|
+
"@tuya-sat/micro-dev-loader": "2.0.0",
|
|
24
|
+
"@tuya-sat/micro-dev-proxy": "2.0.0",
|
|
25
|
+
"@tuya-sat/micro-utils": "2.0.0",
|
|
26
|
+
"babel-loader": "8.2.4",
|
|
27
|
+
"babel-plugin-import": "1.13.3",
|
|
28
28
|
"chalk": "4.1.2",
|
|
29
|
-
"cheerio": "
|
|
30
|
-
"copy-webpack-plugin": "
|
|
31
|
-
"css-loader": "
|
|
32
|
-
"css-minimizer-webpack-plugin": "
|
|
33
|
-
"express": "
|
|
34
|
-
"fork-ts-checker-webpack-plugin": "
|
|
35
|
-
"html-webpack-plugin": "
|
|
36
|
-
"http-proxy-middleware": "
|
|
37
|
-
"joi": "
|
|
38
|
-
"less": "
|
|
39
|
-
"less-loader": "
|
|
40
|
-
"mini-css-extract-plugin": "
|
|
41
|
-
"open": "
|
|
29
|
+
"cheerio": "1.0.0-rc.10",
|
|
30
|
+
"copy-webpack-plugin": "10.2.4",
|
|
31
|
+
"css-loader": "6.7.1",
|
|
32
|
+
"css-minimizer-webpack-plugin": "3.4.1",
|
|
33
|
+
"express": "4.17.3",
|
|
34
|
+
"fork-ts-checker-webpack-plugin": "7.2.1",
|
|
35
|
+
"html-webpack-plugin": "5.5.0",
|
|
36
|
+
"http-proxy-middleware": "2.0.4",
|
|
37
|
+
"joi": "17.6.0",
|
|
38
|
+
"less": "4.1.2",
|
|
39
|
+
"less-loader": "10.2.0",
|
|
40
|
+
"mini-css-extract-plugin": "2.6.0",
|
|
41
|
+
"open": "8.4.0",
|
|
42
42
|
"ora": "5.4.1",
|
|
43
|
-
"path-to-regexp": "
|
|
44
|
-
"portfinder": "
|
|
45
|
-
"postcss": "
|
|
46
|
-
"postcss-loader": "
|
|
47
|
-
"postcss-preset-env": "
|
|
48
|
-
"react-refresh": "
|
|
49
|
-
"resolve-url-loader": "
|
|
50
|
-
"sass": "
|
|
51
|
-
"sass-loader": "
|
|
52
|
-
"style-loader": "
|
|
53
|
-
"svg-url-loader": "
|
|
54
|
-
"tsconfig-paths-webpack-plugin": "
|
|
55
|
-
"url-loader": "
|
|
56
|
-
"uuid": "
|
|
57
|
-
"vue-loader": "
|
|
58
|
-
"webpack": "
|
|
59
|
-
"webpack-dev-server": "
|
|
60
|
-
"webpack-merge": "
|
|
43
|
+
"path-to-regexp": "6.2.0",
|
|
44
|
+
"portfinder": "1.0.28",
|
|
45
|
+
"postcss": "8.4.12",
|
|
46
|
+
"postcss-loader": "6.2.1",
|
|
47
|
+
"postcss-preset-env": "7.4.3",
|
|
48
|
+
"react-refresh": "0.11.0",
|
|
49
|
+
"resolve-url-loader": "5.0.0",
|
|
50
|
+
"sass": "1.49.9",
|
|
51
|
+
"sass-loader": "12.6.0",
|
|
52
|
+
"style-loader": "3.3.1",
|
|
53
|
+
"svg-url-loader": "7.1.1",
|
|
54
|
+
"tsconfig-paths-webpack-plugin": "3.5.2",
|
|
55
|
+
"url-loader": "4.1.1",
|
|
56
|
+
"uuid": "8.3.2",
|
|
57
|
+
"vue-loader": "17.0.0",
|
|
58
|
+
"webpack": "5.70.0",
|
|
59
|
+
"webpack-dev-server": "4.7.4",
|
|
60
|
+
"webpack-merge": "5.8.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@types/express": "
|
|
64
|
-
"@types/jest": "
|
|
65
|
-
"@types/uuid": "
|
|
66
|
-
"
|
|
67
|
-
"jest": "
|
|
68
|
-
"
|
|
69
|
-
"typescript": "^4.4.4"
|
|
70
|
-
},
|
|
71
|
-
"peerDependencies": {
|
|
72
|
-
"@tuya-sat/micro-dev-component": "^2.0.0-rc.7"
|
|
63
|
+
"@types/express": "4.17.13",
|
|
64
|
+
"@types/jest": "27.4.1",
|
|
65
|
+
"@types/uuid": "8.3.4",
|
|
66
|
+
"jest": "27.5.1",
|
|
67
|
+
"ts-jest": "27.1.3",
|
|
68
|
+
"typescript": "4.6.2"
|
|
73
69
|
},
|
|
74
70
|
"keywords": [
|
|
75
71
|
"saturn-project",
|
|
@@ -79,6 +75,5 @@
|
|
|
79
75
|
"saas",
|
|
80
76
|
"cloud",
|
|
81
77
|
"tuya"
|
|
82
|
-
]
|
|
83
|
-
"stableVersion": "1.1.4"
|
|
78
|
+
]
|
|
84
79
|
}
|