@tuya-sat/micro-script 2.3.1 → 2.3.2
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,6 @@ 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;
|
|
16
15
|
//@ts-ignore
|
|
17
16
|
const copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
|
|
18
17
|
//@ts-ignore
|
|
@@ -23,25 +22,14 @@ const micro_dev_loader_1 = require("@tuya-sat/micro-dev-loader");
|
|
|
23
22
|
const index_1 = require("@tuya-sat/micro-dev-loader/dist/less/utils/index");
|
|
24
23
|
const micro_utils_1 = require("@tuya-sat/micro-utils");
|
|
25
24
|
const paths_1 = __importDefault(require("./paths"));
|
|
25
|
+
const theme_1 = require("../utils/theme");
|
|
26
26
|
const toArray = (value) => {
|
|
27
27
|
return Array.isArray(value) ? value : [value];
|
|
28
28
|
};
|
|
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
29
|
function getCommonConfig({ isDev, isBuild, }) {
|
|
39
30
|
const { name: packageName } = require(paths_1.default.appPkg);
|
|
40
31
|
const { annotations } = (0, micro_utils_1.parseManifest)();
|
|
41
|
-
const
|
|
42
|
-
const enableThemeCompile = isDev
|
|
43
|
-
? !!devMicroTheme
|
|
44
|
-
: annotations["sdf.feat:colorTheme"];
|
|
32
|
+
const enableThemeCompile = annotations["sdf.feat:colorTheme"];
|
|
45
33
|
//获取style处理的loader
|
|
46
34
|
const getStyleLoaders = (extraLoader = []) => {
|
|
47
35
|
extraLoader = toArray(extraLoader);
|
|
@@ -94,19 +82,18 @@ function getCommonConfig({ isDev, isBuild, }) {
|
|
|
94
82
|
{
|
|
95
83
|
loader: require.resolve("less-loader"),
|
|
96
84
|
options: {
|
|
97
|
-
lessOptions: Object.assign(Object.assign({}, (
|
|
98
|
-
?
|
|
99
|
-
? (0, index_1.getLessOptions)(
|
|
100
|
-
:
|
|
101
|
-
:
|
|
102
|
-
? (0, index_1.getLessOptions)(index_1.LIGHT_THEME)
|
|
103
|
-
: {})), { javascriptEnabled: true }),
|
|
85
|
+
lessOptions: Object.assign(Object.assign({}, (enableThemeCompile
|
|
86
|
+
? isDev
|
|
87
|
+
? (0, index_1.getLessOptions)((0, theme_1.getBaseTheme)())
|
|
88
|
+
: (0, index_1.getLessOptions)(index_1.LIGHT_THEME)
|
|
89
|
+
: {})), { javascriptEnabled: true }),
|
|
104
90
|
},
|
|
105
91
|
},
|
|
106
92
|
enableThemeCompile &&
|
|
107
93
|
require("@tuya-sat/micro-dev-loader").changeAntdGlobalImport,
|
|
108
94
|
enableThemeCompile &&
|
|
109
|
-
require("@tuya-sat/micro-dev-loader")
|
|
95
|
+
require("@tuya-sat/micro-dev-loader")
|
|
96
|
+
.changeTuyaSatComponentImport,
|
|
110
97
|
].filter(Boolean)),
|
|
111
98
|
},
|
|
112
99
|
{
|
|
@@ -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
|
|
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,
|
|
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()));
|
|
@@ -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.
|
|
3
|
+
"version": "2.3.2",
|
|
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.
|
|
24
|
-
"@tuya-sat/micro-dev-proxy": "2.3.
|
|
25
|
-
"@tuya-sat/micro-utils": "2.3.
|
|
23
|
+
"@tuya-sat/micro-dev-loader": "2.3.2",
|
|
24
|
+
"@tuya-sat/micro-dev-proxy": "2.3.2",
|
|
25
|
+
"@tuya-sat/micro-utils": "2.3.2",
|
|
26
26
|
"babel-loader": "8.2.4",
|
|
27
27
|
"babel-plugin-import": "1.13.3",
|
|
28
28
|
"chalk": "4.1.2",
|