@tuya-sat/micro-script 2.0.0-rc.6 → 2.1.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.
@@ -18,6 +18,7 @@ const copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
18
18
  const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
19
19
  const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
20
20
  const css_minimizer_webpack_plugin_1 = __importDefault(require("css-minimizer-webpack-plugin"));
21
+ const micro_dev_loader_1 = require("@tuya-sat/micro-dev-loader");
21
22
  const paths_1 = __importDefault(require("./paths"));
22
23
  function getCommonConfig({ isDev, isBuild, }) {
23
24
  const { name: packageName } = require(paths_1.default.appPkg);
@@ -104,6 +105,12 @@ function getCommonConfig({ isDev, isBuild, }) {
104
105
  runtimeChunk: "single",
105
106
  splitChunks: {
106
107
  cacheGroups: {
108
+ // vendorCss: {
109
+ // test: /(\/node_modules\/[\s\S]+(.less|.css)$)|(\/src\/styles\/global.less)/,
110
+ // name: "light",
111
+ // chunks: "all",
112
+ // priority: 2,
113
+ // },
107
114
  vendor: {
108
115
  test: /[\\/]node_modules[\\/]/,
109
116
  name: "vendors-others",
@@ -139,7 +146,8 @@ function getCommonConfig({ isDev, isBuild, }) {
139
146
  filename: "static/css/[name].[contenthash:8].css",
140
147
  chunkFilename: "static/css/[name].[contenthash:8].chunk.css",
141
148
  }),
142
- ].filter(Boolean),
149
+ isBuild && false && new micro_dev_loader_1.ThemePlugin(),
150
+ ].filter((value) => Boolean(value)),
143
151
  };
144
152
  }
145
153
  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 oem_micro_app_id = (0, uuid_1.v4)();
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;
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const cheerio_1 = __importDefault(require("cheerio"));
16
16
  const axios_1 = __importDefault(require("axios"));
17
17
  const fakeSaas_1 = __importDefault(require("./fakeSaas"));
18
- const defaultBase = "https://static1.tuyacn.com/static/sdf-gw/v1.0.1.22";
18
+ const defaultBase = "https://static1.tuyacn.com/static/sdf-gw/v1.0.1.22/";
19
19
  function staticMain(app, debuggerConfig) {
20
20
  app.get([
21
21
  "/",
@@ -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);
@@ -36,6 +36,9 @@ const bundleServer_1 = require("../module/bundleServer");
36
36
  (0, bundleServer_1.runBundleServer)({
37
37
  port: bundledServerPort,
38
38
  compiler,
39
+ internalDevConfig: {
40
+ allowedHosts: "all",
41
+ },
39
42
  });
40
43
  }))().catch((err) => {
41
44
  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-rc.6",
3
+ "version": "2.1.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": "^7.15.8",
19
- "@babel/preset-env": "^7.15.8",
20
- "@babel/preset-react": "^7.14.5",
21
- "@babel/preset-typescript": "^7.15.0",
22
- "@pmmmwh/react-refresh-webpack-plugin": "^0.5.1",
23
- "@tuya-sat/micro-dev-loader": "2.0.0-rc.6",
24
- "@tuya-sat/micro-dev-proxy": "2.0.0-rc.6",
25
- "@tuya-sat/micro-utils": "2.0.0-rc.6",
26
- "babel-loader": "^8.2.2",
27
- "babel-plugin-import": "^1.13.3",
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.1.0",
24
+ "@tuya-sat/micro-dev-proxy": "2.1.0",
25
+ "@tuya-sat/micro-utils": "2.1.0",
26
+ "babel-loader": "8.2.4",
27
+ "babel-plugin-import": "1.13.3",
28
28
  "chalk": "4.1.2",
29
- "cheerio": "^1.0.0-rc.10",
30
- "copy-webpack-plugin": "^9.0.1",
31
- "css-loader": "^6.4.0",
32
- "css-minimizer-webpack-plugin": "^3.2.0",
33
- "express": "^4.17.2",
34
- "fork-ts-checker-webpack-plugin": "^6.4.0",
35
- "html-webpack-plugin": "^5.3.2",
36
- "http-proxy-middleware": "^2.0.1",
37
- "joi": "^17.6.0",
38
- "less": "^4.1.2",
39
- "less-loader": "^10.1.0",
40
- "mini-css-extract-plugin": "^2.4.2",
41
- "open": "^8.4.0",
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": "^6.2.0",
44
- "portfinder": "^1.0.28",
45
- "postcss": "^8.4.5",
46
- "postcss-loader": "^6.2.1",
47
- "postcss-preset-env": "^7.4.2",
48
- "react-refresh": "^0.10.0",
49
- "resolve-url-loader": "^4.0.0",
50
- "sass": "^1.42.1",
51
- "sass-loader": "^12.1.0",
52
- "style-loader": "^3.3.0",
53
- "svg-url-loader": "^7.1.1",
54
- "tsconfig-paths-webpack-plugin": "^3.5.1",
55
- "url-loader": "^4.1.1",
56
- "uuid": "^8.3.2",
57
- "vue-loader": "16.8.2",
58
- "webpack": "^5.58.1",
59
- "webpack-dev-server": "^4.3.1",
60
- "webpack-merge": "^5.8.0"
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": "^4.17.13",
64
- "@types/jest": "^27.4.1",
65
- "@types/uuid": "^8.3.4",
66
- "@types/webpack-dev-server": "^4.5.0",
67
- "jest": "^27.5.1",
68
- "ts-jest": "^27.1.3",
69
- "typescript": "^4.4.4"
70
- },
71
- "peerDependencies": {
72
- "@tuya-sat/micro-dev-component": "^2.0.0-rc.6"
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
  }