@tuya-sat/micro-script 3.0.27-beta.8 → 3.0.27-beta.9
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.
package/dist/scripts/build.js
CHANGED
|
@@ -17,12 +17,17 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
17
17
|
const ora_1 = __importDefault(require("ora"));
|
|
18
18
|
const webpack_config_1 = __importDefault(require("../config/webpack.config"));
|
|
19
19
|
const template_1 = __importDefault(require("../template"));
|
|
20
|
+
const apis_1 = __importDefault(require("../apis"));
|
|
21
|
+
const paths_1 = __importDefault(require("../config/paths"));
|
|
22
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
23
|
+
const path_1 = __importDefault(require("path"));
|
|
20
24
|
const BUILD_FAIL_TIP = '糟糕:打包失败了,下面是具体信息';
|
|
21
25
|
const spinner = (0, ora_1.default)('building').start();
|
|
26
|
+
let { debuggerConfig: { isMainApp }, } = require(paths_1.default.microConfig);
|
|
22
27
|
const config = (0, webpack_config_1.default)();
|
|
23
28
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
-
// await apis();
|
|
25
29
|
yield (0, template_1.default)();
|
|
30
|
+
yield (0, apis_1.default)();
|
|
26
31
|
(0, webpack_1.default)(config).run((err, stats) => {
|
|
27
32
|
if (err) {
|
|
28
33
|
spinner.fail();
|
|
@@ -38,6 +43,15 @@ const config = (0, webpack_config_1.default)();
|
|
|
38
43
|
process.exit(1);
|
|
39
44
|
}
|
|
40
45
|
spinner.succeed();
|
|
46
|
+
// 修复主应用 manifest.json资源丢失问题
|
|
47
|
+
if (isMainApp) {
|
|
48
|
+
const files = fs_extra_1.default.readdirSync(path_1.default.join(process.cwd(), 'dist/static/img')) || [];
|
|
49
|
+
const manifest = fs_extra_1.default.readJSONSync(path_1.default.join(process.cwd(), 'dist/manifest.json'));
|
|
50
|
+
const result = files.reduce((acc, file) => {
|
|
51
|
+
acc[file] = file;
|
|
52
|
+
}, {});
|
|
53
|
+
fs_extra_1.default.writeJSONSync(path_1.default.join(process.cwd(), 'dist/manifest.json'), Object.assign(Object.assign({}, manifest), result));
|
|
54
|
+
}
|
|
41
55
|
if (stats.hasWarnings()) {
|
|
42
56
|
console.log(chalk_1.default.yellow('难受:有告警信息,下面是具体信息'));
|
|
43
57
|
console.log(warnings.map((item) => item.message).join('\n'));
|
package/dist/scripts/start.js
CHANGED
|
@@ -18,13 +18,14 @@ const mock_1 = __importDefault(require("../module/mock"));
|
|
|
18
18
|
const bundleServer_1 = require("../module/bundleServer");
|
|
19
19
|
const proxy_1 = __importDefault(require("../module/proxy"));
|
|
20
20
|
const template_1 = __importDefault(require("../template"));
|
|
21
|
+
const apis_1 = __importDefault(require("../apis"));
|
|
21
22
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
-
// await apis();
|
|
23
23
|
yield (0, template_1.default)();
|
|
24
|
+
yield (0, apis_1.default)();
|
|
24
25
|
let defaultPort = 9000;
|
|
25
26
|
console.log(chalk_1.default.yellow('如果是pc端的微应用调试,请勿使用该命令,考虑使用`start --main`或`start --main --proxy`'));
|
|
26
27
|
//检测端口占用情况
|
|
27
|
-
console.log(
|
|
28
|
+
console.log('process.env.PROT', process.env.PROT);
|
|
28
29
|
if (process.env.PROT) {
|
|
29
30
|
const compiler = (0, bundleServer_1.createServerCompiler)();
|
|
30
31
|
(0, bundleServer_1.runBundleServer)({
|
|
@@ -18,9 +18,10 @@ const mainServer_1 = __importDefault(require("../module/mainServer"));
|
|
|
18
18
|
const bundleServer_1 = require("../module/bundleServer");
|
|
19
19
|
const kill_port_1 = __importDefault(require("kill-port"));
|
|
20
20
|
const template_1 = __importDefault(require("../template"));
|
|
21
|
+
const apis_1 = __importDefault(require("../apis"));
|
|
21
22
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
-
// await apis();
|
|
23
23
|
yield (0, template_1.default)();
|
|
24
|
+
yield (0, apis_1.default)();
|
|
24
25
|
let defaultPort = 9000;
|
|
25
26
|
//检测端口占用情况
|
|
26
27
|
const bundledServerPort = yield portfinder_1.default.getPortPromise({
|
package/dist/template/index.js
CHANGED
|
@@ -86,8 +86,8 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
86
86
|
let langContent = fs.readFileSync(path.join(__dirname, './micro-app/lang.ts'), {
|
|
87
87
|
encoding: 'utf8',
|
|
88
88
|
});
|
|
89
|
-
langContent = langContent.replace("import en from './en';", `import en from '../../src/lang/en'`);
|
|
90
|
-
langContent = langContent.replace("import zh from './zh';", `import zh from '../../src/lang/zh'`);
|
|
89
|
+
langContent = langContent.replace("import en from './en.json';", `import en from '../../src/lang/en.json'`);
|
|
90
|
+
langContent = langContent.replace("import zh from './zh.json';", `import zh from '../../src/lang/zh.json'`);
|
|
91
91
|
fs.writeFileSync(microPath + '/lang.ts', langContent);
|
|
92
92
|
}
|
|
93
93
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import i18n from 'i18next';
|
|
2
2
|
import { initReactI18next } from 'react-i18next';
|
|
3
3
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
4
|
-
import en from './en';
|
|
5
|
-
import zh from './zh';
|
|
4
|
+
import en from './en.json';
|
|
5
|
+
import zh from './zh.json';
|
|
6
6
|
|
|
7
7
|
i18n
|
|
8
8
|
.use(LanguageDetector)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuya-sat/micro-script",
|
|
3
|
-
"version": "3.0.27-beta.
|
|
3
|
+
"version": "3.0.27-beta.9",
|
|
4
4
|
"bin": "./dist/bin/cli.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"@babel/preset-typescript": "7.16.7",
|
|
24
24
|
"@babel/traverse": "^7.20.13",
|
|
25
25
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.4",
|
|
26
|
-
"@tuya-sat/micro-dev-loader": "3.0.27-beta.
|
|
27
|
-
"@tuya-sat/micro-dev-proxy": "3.0.27-beta.
|
|
28
|
-
"@tuya-sat/micro-utils": "3.0.27-beta.
|
|
26
|
+
"@tuya-sat/micro-dev-loader": "3.0.27-beta.9",
|
|
27
|
+
"@tuya-sat/micro-dev-proxy": "3.0.27-beta.9",
|
|
28
|
+
"@tuya-sat/micro-utils": "3.0.27-beta.9",
|
|
29
29
|
"@types/kill-port": "^2.0.0",
|
|
30
30
|
"babel-loader": "8.2.4",
|
|
31
31
|
"babel-plugin-import": "1.13.3",
|