@tuya-sat/micro-script 3.0.18 → 3.0.19-beta.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.
|
@@ -240,6 +240,11 @@ function getCommonConfig({ isDev, isBuild, }) {
|
|
|
240
240
|
entry: multiAppsWebpackConfig.entry,
|
|
241
241
|
});
|
|
242
242
|
}
|
|
243
|
+
if (isMainApp) {
|
|
244
|
+
return (0, webpack_merge_1.merge)(getWebpackConfig([]), {
|
|
245
|
+
entry: `${path_1.default.join(process.cwd(), 'node_modules/.micro')}/index.tsx`,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
243
248
|
return getWebpackConfig([]);
|
|
244
249
|
}
|
|
245
250
|
exports.default = getCommonConfig;
|
package/dist/template/index.js
CHANGED
|
@@ -31,14 +31,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
34
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
38
|
const fs = __importStar(require("fs"));
|
|
36
39
|
const path = __importStar(require("path"));
|
|
40
|
+
const paths_1 = __importDefault(require("../config/paths"));
|
|
37
41
|
const isMonorepo = () => {
|
|
38
42
|
return (fs.existsSync(path.join(process.cwd(), 'apps')) &&
|
|
39
43
|
fs.existsSync(path.join(process.cwd(), 'packages')));
|
|
40
44
|
};
|
|
45
|
+
const isMainApp = () => {
|
|
46
|
+
const { debuggerConfig: { isMainApp }, } = require(paths_1.default.microConfig);
|
|
47
|
+
return isMainApp;
|
|
48
|
+
};
|
|
41
49
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
if (isMainApp()) {
|
|
51
|
+
const microPath = path.join(process.cwd(), 'node_modules/.micro');
|
|
52
|
+
!fs.existsSync(microPath) && fs.mkdirSync(microPath, { recursive: true });
|
|
53
|
+
fs.copyFileSync(path.join(__dirname, './main-app/index.tsx'), path.join(microPath, 'index.tsx'));
|
|
54
|
+
}
|
|
42
55
|
if (isMonorepo()) {
|
|
43
56
|
fs.readdirSync(path.join(process.cwd(), 'apps')).forEach((dir) => {
|
|
44
57
|
console.log('directory ' + dir);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import '@tuya-sat/sdf-main-sdk/dist/main.css';
|
|
2
|
+
import 'react';
|
|
3
|
+
import { bootStrapSDF } from '@tuya-sat/sdf-main-sdk';
|
|
4
|
+
import { reWriteUI } from './utils';
|
|
5
|
+
import lang from '../../src/lang';
|
|
6
|
+
import hooks from '../../src/hooks';
|
|
7
|
+
|
|
8
|
+
bootStrapSDF({ lang, hooks, ui: reWriteUI() });
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { IUI } from '@tuya-sat/sdf-main-sdk';
|
|
2
|
+
|
|
3
|
+
const bindCmp = (result, cmp, name) => {
|
|
4
|
+
cmp.keys().forEach((key) => {
|
|
5
|
+
if (key.includes('index.tsx')) {
|
|
6
|
+
result[name] = cmp(key).default;
|
|
7
|
+
} else {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const reWriteUI = () => {
|
|
14
|
+
const result = { pages: {} };
|
|
15
|
+
const pages = (require as any).context('../pages', true, /\.([tj]sx)|[tj]s$/);
|
|
16
|
+
pages.keys().forEach((key) => {
|
|
17
|
+
if (key.includes('index.tsx')) {
|
|
18
|
+
const name = key.split('/')[1];
|
|
19
|
+
result.pages[name.charAt(0).toUpperCase() + name.slice(1)] =
|
|
20
|
+
pages(key).default;
|
|
21
|
+
} else {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const bdb = (require as any).context(
|
|
27
|
+
'../../src/bdb',
|
|
28
|
+
true,
|
|
29
|
+
/\.([tj]sx)|[tj]s$/
|
|
30
|
+
);
|
|
31
|
+
bindCmp(result, bdb, 'bdb');
|
|
32
|
+
|
|
33
|
+
const menu = (require as any).context(
|
|
34
|
+
'../../src/menu',
|
|
35
|
+
true,
|
|
36
|
+
/\.([tj]sx)|[tj]s$/
|
|
37
|
+
);
|
|
38
|
+
bindCmp(result, menu, 'menu');
|
|
39
|
+
|
|
40
|
+
const nav = (require as any).context(
|
|
41
|
+
'../../src/nav',
|
|
42
|
+
true,
|
|
43
|
+
/\.([tj]sx)|[tj]s$/
|
|
44
|
+
);
|
|
45
|
+
bindCmp(result, nav, 'nav');
|
|
46
|
+
return result as IUI;
|
|
47
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuya-sat/micro-script",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.19-beta.2",
|
|
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
|
-
"@tuya-sat/micro-dev-proxy": "3.0.
|
|
28
|
-
"@tuya-sat/micro-utils": "3.0.
|
|
26
|
+
"@tuya-sat/micro-dev-loader": "3.0.19-beta.2",
|
|
27
|
+
"@tuya-sat/micro-dev-proxy": "3.0.19-beta.2",
|
|
28
|
+
"@tuya-sat/micro-utils": "3.0.19-beta.2",
|
|
29
29
|
"@types/kill-port": "^2.0.0",
|
|
30
30
|
"babel-loader": "8.2.4",
|
|
31
31
|
"babel-plugin-import": "1.13.3",
|
package/scripts/copyTemplate.js
CHANGED