@tuya-sat/micro-script 2.3.0 → 2.3.3

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.
@@ -1,9 +1,5 @@
1
1
  import { Configuration } from "webpack";
2
- import { ThemeCat } from "@tuya-sat/micro-dev-loader/dist/less/utils/index";
3
- declare type ThemeEnv = ThemeCat | undefined;
4
- export declare const validateMicroTheme: () => ThemeEnv;
5
2
  export default function getCommonConfig({ isDev, isBuild, }: {
6
3
  isDev: boolean;
7
4
  isBuild: boolean;
8
5
  }): Configuration;
9
- export {};
@@ -12,7 +12,7 @@ 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
- exports.validateMicroTheme = void 0;
15
+ const path_1 = __importDefault(require("path"));
16
16
  //@ts-ignore
17
17
  const copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
18
18
  //@ts-ignore
@@ -23,25 +23,14 @@ const micro_dev_loader_1 = require("@tuya-sat/micro-dev-loader");
23
23
  const index_1 = require("@tuya-sat/micro-dev-loader/dist/less/utils/index");
24
24
  const micro_utils_1 = require("@tuya-sat/micro-utils");
25
25
  const paths_1 = __importDefault(require("./paths"));
26
+ const theme_1 = require("../utils/theme");
26
27
  const toArray = (value) => {
27
28
  return Array.isArray(value) ? value : [value];
28
29
  };
29
- const validateMicroTheme = () => {
30
- const microTheme = process.env.MICRO_THEME;
31
- if (microTheme && ![index_1.DARK_THEME, index_1.LIGHT_THEME].includes(microTheme)) {
32
- console.error(`请设置正确的MICRO_THEME环境变量,当前值为${microTheme},请修改为${index_1.LIGHT_THEME}或${index_1.DARK_THEME}`);
33
- return process.exit(1);
34
- }
35
- return microTheme;
36
- };
37
- exports.validateMicroTheme = validateMicroTheme;
38
30
  function getCommonConfig({ isDev, isBuild, }) {
39
31
  const { name: packageName } = require(paths_1.default.appPkg);
40
32
  const { annotations } = (0, micro_utils_1.parseManifest)();
41
- const devMicroTheme = (0, exports.validateMicroTheme)();
42
- const enableThemeCompile = isDev
43
- ? !!devMicroTheme
44
- : annotations["sdf.feat:colorTheme"];
33
+ const enableThemeCompile = annotations["sdf.feat:colorTheme"];
45
34
  //获取style处理的loader
46
35
  const getStyleLoaders = (extraLoader = []) => {
47
36
  extraLoader = toArray(extraLoader);
@@ -94,19 +83,18 @@ function getCommonConfig({ isDev, isBuild, }) {
94
83
  {
95
84
  loader: require.resolve("less-loader"),
96
85
  options: {
97
- lessOptions: Object.assign(Object.assign({}, (isDev
98
- ? enableThemeCompile
99
- ? (0, index_1.getLessOptions)(devMicroTheme)
100
- : {}
101
- : annotations["sdf.feat:colorTheme"]
102
- ? (0, index_1.getLessOptions)(index_1.LIGHT_THEME)
103
- : {})), { javascriptEnabled: true }),
86
+ lessOptions: Object.assign(Object.assign({}, (enableThemeCompile
87
+ ? isDev
88
+ ? (0, index_1.getLessOptions)((0, theme_1.getBaseTheme)())
89
+ : (0, index_1.getLessOptions)(index_1.LIGHT_THEME)
90
+ : {})), { javascriptEnabled: true }),
104
91
  },
105
92
  },
106
93
  enableThemeCompile &&
107
94
  require("@tuya-sat/micro-dev-loader").changeAntdGlobalImport,
108
95
  enableThemeCompile &&
109
- require("@tuya-sat/micro-dev-loader").changeTuyaSatComponentImport
96
+ require("@tuya-sat/micro-dev-loader")
97
+ .changeTuyaSatComponentImport,
110
98
  ].filter(Boolean)),
111
99
  },
112
100
  {
@@ -162,7 +150,8 @@ function getCommonConfig({ isDev, isBuild, }) {
162
150
  patterns: [
163
151
  {
164
152
  from: paths_1.default.publicDir,
165
- filter: (resourcePath) => __awaiter(this, void 0, void 0, function* () { return !resourcePath.includes(".html"); }),
153
+ // 使用path.resolve纠正resourcePath,因为这个resourcePath值在windows平台显示的是POSIX值;
154
+ filter: (resourcePath) => __awaiter(this, void 0, void 0, function* () { return path_1.default.resolve(resourcePath) !== paths_1.default.spaHtml; }),
166
155
  noErrorOnMissing: true,
167
156
  },
168
157
  ],
@@ -39,7 +39,7 @@ const cheerio_1 = __importDefault(require("cheerio"));
39
39
  const axios_1 = __importDefault(require("axios"));
40
40
  const fakeSaas_1 = __importStar(require("./fakeSaas"));
41
41
  const paths_1 = __importDefault(require("../../config/paths"));
42
- const webpack_common_1 = require("../../config/webpack.common");
42
+ const theme_1 = require("../../utils/theme");
43
43
  const defaultBase = "https://static1.tuyacn.com/static/sdf-gw/v1.0.1.516/";
44
44
  function staticMain(app, debuggerConfig) {
45
45
  app.get([
@@ -95,7 +95,7 @@ function insertScript($, debuggerConfig) {
95
95
  let themeConfig = saas.custom_configs.find((item) => {
96
96
  return item.config_key === "dynamic_theme";
97
97
  }) || initalCustom_configs(saas);
98
- const theme = (0, webpack_common_1.validateMicroTheme)();
98
+ const theme = (0, theme_1.getBaseTheme)();
99
99
  themeConfig.config_value_json = JSON.stringify(Object.assign(Object.assign(Object.assign({}, JSON.parse(themeConfig.config_value_json)), (theme ? {
100
100
  supportedTheme: theme,
101
101
  } : {})), readThemeConfig()));
@@ -30,11 +30,16 @@ const config = (0, webpack_config_1.default)();
30
30
  console.log(warnings.map((item) => item.message).join("\n"));
31
31
  }
32
32
  console.log(chalk_1.default.yellow(`当前打包工具:webpack@${version}`));
33
- console.log(chalk_1.default.blue("资源清单:"));
34
- const assetsInfo = assets.map(({ size, name }) => {
35
- return ` ${name} ${chalk_1.default.white(size > 1024 ? `~${Math.floor(size / 1024)}KB` : `${size}B`)}`;
36
- });
37
- assetsInfo.map((item) => {
38
- console.log(chalk_1.default.blue(item));
39
- });
33
+ if (assets) {
34
+ console.log(chalk_1.default.blue("资源清单:"));
35
+ const assetsInfo = assets.map(({ size, name }) => {
36
+ return ` ${name} ${chalk_1.default.white(size > 1024 ? `~${Math.floor(size / 1024)}KB` : `${size}B`)}`;
37
+ });
38
+ assetsInfo.map((item) => {
39
+ console.log(chalk_1.default.blue(item));
40
+ });
41
+ }
42
+ else {
43
+ console.log(chalk_1.default.blue("无资源清单"));
44
+ }
40
45
  });
@@ -0,0 +1,2 @@
1
+ import { ThemeCat } from "@tuya-sat/micro-dev-loader/dist/less/utils/index";
2
+ export declare const getBaseTheme: () => ThemeCat;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBaseTheme = void 0;
4
+ const index_1 = require("@tuya-sat/micro-dev-loader/dist/less/utils/index");
5
+ const getBaseTheme = () => {
6
+ const microTheme = process.env.MICRO_THEME;
7
+ if (!microTheme || ![index_1.DARK_THEME, index_1.LIGHT_THEME].includes(microTheme))
8
+ return index_1.LIGHT_THEME;
9
+ return microTheme;
10
+ };
11
+ exports.getBaseTheme = getBaseTheme;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-script",
3
- "version": "2.3.0",
3
+ "version": "2.3.3",
4
4
  "bin": "./dist/bin/cli.js",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
@@ -20,9 +20,9 @@
20
20
  "@babel/preset-react": "7.16.7",
21
21
  "@babel/preset-typescript": "7.16.7",
22
22
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.4",
23
- "@tuya-sat/micro-dev-loader": "2.3.0",
24
- "@tuya-sat/micro-dev-proxy": "2.3.0",
25
- "@tuya-sat/micro-utils": "2.3.0",
23
+ "@tuya-sat/micro-dev-loader": "2.3.3",
24
+ "@tuya-sat/micro-dev-proxy": "2.3.3",
25
+ "@tuya-sat/micro-utils": "2.3.3",
26
26
  "babel-loader": "8.2.4",
27
27
  "babel-plugin-import": "1.13.3",
28
28
  "chalk": "4.1.2",