@tuya-sat/micro-script 2.2.19 → 2.2.20
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.
|
@@ -7,4 +7,11 @@ export default function getFakeSaas(config: DebuggerConfig): Promise<{
|
|
|
7
7
|
_SDF_CONFIG: anyObject;
|
|
8
8
|
__MAIN_APP_PUBLIC_PATH: string;
|
|
9
9
|
}>;
|
|
10
|
+
export declare function getFakeUser(config: DebuggerConfig): {
|
|
11
|
+
user_name: string;
|
|
12
|
+
roles: {
|
|
13
|
+
role_code: string;
|
|
14
|
+
role_name: string;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
10
17
|
export {};
|
|
@@ -12,6 +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.getFakeUser = void 0;
|
|
15
16
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
16
17
|
const axios_1 = __importDefault(require("axios"));
|
|
17
18
|
const chalk_1 = __importDefault(require("chalk"));
|
|
@@ -44,15 +45,7 @@ function getFakeSaas(config) {
|
|
|
44
45
|
const __MAIN_APP_PUBLIC_PATH = parse__MAIN_APP_PUBLIC_PATH(data);
|
|
45
46
|
const saas = {
|
|
46
47
|
_SDF_CONFIG: JSON.parse(_SDF_CONFIG),
|
|
47
|
-
_SDF:
|
|
48
|
-
user_name: config.username || "admin@tuya.com",
|
|
49
|
-
roles: [
|
|
50
|
-
{
|
|
51
|
-
role_code: "FAKE_ROLE_CODE",
|
|
52
|
-
role_name: "FAKE_ROLE_NAME",
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
} }),
|
|
48
|
+
_SDF: JSON.parse(_SDF),
|
|
56
49
|
__MAIN_APP_PUBLIC_PATH: JSON.parse(__MAIN_APP_PUBLIC_PATH),
|
|
57
50
|
};
|
|
58
51
|
fs_extra_1.default.writeJSONSync(paths_1.default.saasCache, saas);
|
|
@@ -62,3 +55,15 @@ function getFakeSaas(config) {
|
|
|
62
55
|
});
|
|
63
56
|
}
|
|
64
57
|
exports.default = getFakeSaas;
|
|
58
|
+
function getFakeUser(config) {
|
|
59
|
+
return {
|
|
60
|
+
user_name: config.username || "admin@tuya.com",
|
|
61
|
+
roles: [
|
|
62
|
+
{
|
|
63
|
+
role_code: "FAKE_ROLE_CODE",
|
|
64
|
+
role_name: "FAKE_ROLE_NAME",
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
exports.getFakeUser = getFakeUser;
|
|
@@ -18,4 +18,6 @@ export declare type CustomConfig = {
|
|
|
18
18
|
platform: string;
|
|
19
19
|
config_id: string;
|
|
20
20
|
};
|
|
21
|
-
export default function staticMain(app: Express
|
|
21
|
+
export default function staticMain(app: Express & {
|
|
22
|
+
_isLogin?: Promise<void>;
|
|
23
|
+
}, debuggerConfig: DebuggerConfig): void;
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -14,7 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
38
|
const cheerio_1 = __importDefault(require("cheerio"));
|
|
16
39
|
const axios_1 = __importDefault(require("axios"));
|
|
17
|
-
const fakeSaas_1 =
|
|
40
|
+
const fakeSaas_1 = __importStar(require("./fakeSaas"));
|
|
18
41
|
const paths_1 = __importDefault(require("../../config/paths"));
|
|
19
42
|
const defaultBase = "https://static1.tuyacn.com/static/sdf-gw/v1.0.1.352/";
|
|
20
43
|
function staticMain(app, debuggerConfig) {
|
|
@@ -26,6 +49,9 @@ function staticMain(app, debuggerConfig) {
|
|
|
26
49
|
"/application",
|
|
27
50
|
"/application/*",
|
|
28
51
|
], (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
if (app._isLogin) {
|
|
53
|
+
yield app._isLogin;
|
|
54
|
+
}
|
|
29
55
|
const base = debuggerConfig.base || defaultBase;
|
|
30
56
|
const { data } = yield axios_1.default.get(new URL("index.html", base).href);
|
|
31
57
|
const $ = cheerio_1.default.load(data);
|
|
@@ -58,6 +84,7 @@ function insertScript($, debuggerConfig) {
|
|
|
58
84
|
var _a;
|
|
59
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
86
|
const { _SDF_CONFIG, _SDF, __MAIN_APP_PUBLIC_PATH } = yield (0, fakeSaas_1.default)(debuggerConfig);
|
|
87
|
+
_SDF.user = (0, fakeSaas_1.getFakeUser)(debuggerConfig);
|
|
61
88
|
const { saas } = _SDF;
|
|
62
89
|
(_a = saas.custom_configs) !== null && _a !== void 0 ? _a : (saas.custom_configs = []);
|
|
63
90
|
let themeConfig = saas.custom_configs.find((item) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuya-sat/micro-script",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.20",
|
|
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.2.
|
|
24
|
-
"@tuya-sat/micro-dev-proxy": "2.2.
|
|
25
|
-
"@tuya-sat/micro-utils": "2.2.
|
|
23
|
+
"@tuya-sat/micro-dev-loader": "2.2.20",
|
|
24
|
+
"@tuya-sat/micro-dev-proxy": "2.2.20",
|
|
25
|
+
"@tuya-sat/micro-utils": "2.2.20",
|
|
26
26
|
"babel-loader": "8.2.4",
|
|
27
27
|
"babel-plugin-import": "1.13.3",
|
|
28
28
|
"chalk": "4.1.2",
|