@tuya-sat/micro-script 2.0.0-rc.3 → 2.0.0-rc.6
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.
|
@@ -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.
|
|
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
|
"/",
|
|
@@ -26,7 +26,7 @@ function staticMain(app, debuggerConfig) {
|
|
|
26
26
|
"/application/*",
|
|
27
27
|
], (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
28
28
|
const base = debuggerConfig.base || defaultBase;
|
|
29
|
-
const { data } = yield axios_1.default.get(new URL("index.html",
|
|
29
|
+
const { data } = yield axios_1.default.get(new URL("index.html", base).href);
|
|
30
30
|
const $ = cheerio_1.default.load(data);
|
|
31
31
|
modifySrcAttr($, base);
|
|
32
32
|
insertLocalStorage($);
|
|
@@ -20,9 +20,11 @@ const paths_1 = __importDefault(require("../config/paths"));
|
|
|
20
20
|
const fakeSaasInfo_1 = __importDefault(require("./main/fakeSaasInfo"));
|
|
21
21
|
const staticMain_1 = __importDefault(require("./main/staticMain"));
|
|
22
22
|
const proxy_1 = __importDefault(require("../module/proxy"));
|
|
23
|
+
const validate_1 = require("../utils/validate");
|
|
23
24
|
function runMain({ port, microPort, }) {
|
|
24
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
26
|
const { debuggerConfig } = require(paths_1.default.microConfig);
|
|
27
|
+
(0, validate_1.validateDebuggerConfig)(debuggerConfig);
|
|
26
28
|
const app = (0, express_1.default)();
|
|
27
29
|
(0, staticMain_1.default)(app, debuggerConfig);
|
|
28
30
|
(0, fakeSaasInfo_1.default)(app, microPort);
|
package/dist/utils/validate.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { DebuggerConfig } from "../module/main/staticMain";
|
|
1
2
|
interface anyObject {
|
|
2
3
|
[key: string]: any;
|
|
3
4
|
}
|
|
4
5
|
export declare const validate: (manifest: anyObject, microConfig: anyObject) => void;
|
|
6
|
+
export declare const validateDebuggerConfig: (value: DebuggerConfig) => Promise<void>;
|
|
5
7
|
export {};
|
package/dist/utils/validate.js
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validate = void 0;
|
|
15
|
+
exports.validateDebuggerConfig = exports.validate = void 0;
|
|
16
|
+
const joi_1 = __importDefault(require("joi"));
|
|
4
17
|
const validate = (manifest, microConfig) => { };
|
|
5
18
|
exports.validate = validate;
|
|
19
|
+
const validateDebuggerConfig = (value) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
const schema = joi_1.default.object({
|
|
21
|
+
target: joi_1.default.string()
|
|
22
|
+
.regex(/^(http|https):\/\//)
|
|
23
|
+
.message("请配置正确的saas地址,在micro.config.js->debuggerConfig->target"),
|
|
24
|
+
}).unknown();
|
|
25
|
+
try {
|
|
26
|
+
yield schema.validateAsync(value);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
console.error(err);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
exports.validateDebuggerConfig = validateDebuggerConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuya-sat/micro-script",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.6",
|
|
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.14.5",
|
|
21
21
|
"@babel/preset-typescript": "^7.15.0",
|
|
22
22
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.1",
|
|
23
|
-
"@tuya-sat/micro-dev-loader": "2.0.0-rc.
|
|
24
|
-
"@tuya-sat/micro-dev-proxy": "2.0.0-rc.
|
|
25
|
-
"@tuya-sat/micro-utils": "2.0.0-rc.
|
|
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
26
|
"babel-loader": "^8.2.2",
|
|
27
27
|
"babel-plugin-import": "^1.13.3",
|
|
28
28
|
"chalk": "4.1.2",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"fork-ts-checker-webpack-plugin": "^6.4.0",
|
|
35
35
|
"html-webpack-plugin": "^5.3.2",
|
|
36
36
|
"http-proxy-middleware": "^2.0.1",
|
|
37
|
+
"joi": "^17.6.0",
|
|
37
38
|
"less": "^4.1.2",
|
|
38
39
|
"less-loader": "^10.1.0",
|
|
39
40
|
"mini-css-extract-plugin": "^2.4.2",
|
|
@@ -60,12 +61,15 @@
|
|
|
60
61
|
},
|
|
61
62
|
"devDependencies": {
|
|
62
63
|
"@types/express": "^4.17.13",
|
|
64
|
+
"@types/jest": "^27.4.1",
|
|
63
65
|
"@types/uuid": "^8.3.4",
|
|
64
66
|
"@types/webpack-dev-server": "^4.5.0",
|
|
67
|
+
"jest": "^27.5.1",
|
|
68
|
+
"ts-jest": "^27.1.3",
|
|
65
69
|
"typescript": "^4.4.4"
|
|
66
70
|
},
|
|
67
71
|
"peerDependencies": {
|
|
68
|
-
"@tuya-sat/micro-dev-component": "^2.0.0-rc.
|
|
72
|
+
"@tuya-sat/micro-dev-component": "^2.0.0-rc.6"
|
|
69
73
|
},
|
|
70
74
|
"keywords": [
|
|
71
75
|
"saturn-project",
|