@tuya-sat/micro-script 3.0.21-beta.2 → 3.0.21-beta.4

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.
@@ -32,16 +32,23 @@ const paths_1 = __importDefault(require("../../config/paths"));
32
32
  const uid_1 = require("uid");
33
33
  const path = __importStar(require("path"));
34
34
  const fs_extra_1 = __importDefault(require("fs-extra"));
35
+ const utils_1 = require("../../utils");
35
36
  function mockSaasInfo(app, microPort) {
36
- const { multiApps, debuggerConfig: { isMainApp }, } = require(paths_1.default.microConfig);
37
+ let { multiApps, debuggerConfig: { isMainApp }, } = require(paths_1.default.microConfig);
37
38
  const idsMap = new Map();
39
+ if (!multiApps) {
40
+ multiApps = [];
41
+ fs_extra_1.default.readdirSync(path.join(process.cwd(), 'apps')).forEach((dir) => {
42
+ multiApps = [...multiApps, [{ name: dir }]];
43
+ });
44
+ }
38
45
  multiApps === null || multiApps === void 0 ? void 0 : multiApps.forEach((app) => {
39
46
  idsMap.set(app.name, { entry_id: (0, uuid_1.v4)(), oem_micro_app_id: (0, uid_1.uid)(16) });
40
47
  });
41
48
  if (!isMainApp) {
42
49
  app.get('/api/saas-info', (req, res) => {
43
50
  const lang = parseCookie(req.headers['cookie'], 'main-i18next');
44
- if (multiApps && multiApps.length > 0) {
51
+ if ((0, utils_1.isMonorepo)() || (multiApps && multiApps.length > 0)) {
45
52
  const result = {
46
53
  apps: [],
47
54
  entry_info: { entries: [], entry_mode: 'normal' },
@@ -50,7 +57,7 @@ function mockSaasInfo(app, microPort) {
50
57
  };
51
58
  multiApps.forEach((app) => {
52
59
  const entry_id = idsMap.get(app.name).entry_id;
53
- const manifest = fs_extra_1.default.readJSONSync(path.join(process.cwd(), `${app.dir}/manifest.json`), 'utf-8');
60
+ const manifest = fs_extra_1.default.readJSONSync(path.join(process.cwd(), (0, utils_1.isMonorepo)() ? `apps/${app.name}` : `${app.dir}`, 'manifest.json'), 'utf-8');
54
61
  const oem_micro_app_id = idsMap.get(app.name).oem_micro_app_id;
55
62
  const baseUrl = `/apps/${oem_micro_app_id}`;
56
63
  result.saas_id_info_list.push({
@@ -34,7 +34,7 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
34
34
  const getAnnotations = () => {
35
35
  let { multiApps } = require(paths_1.default.microConfig);
36
36
  if ((0, exports.isMonorepo)()) {
37
- return fs_extra_1.default.readJSONSync(path.join(process.cwd(), fs_extra_1.default.readdirSync(path.join(process.cwd(), 'apps'))[0], 'manifest.json')).annotations;
37
+ return fs_extra_1.default.readJSONSync(path.join(process.cwd(), 'apps', fs_extra_1.default.readdirSync(path.join(process.cwd(), 'apps'))[0], 'manifest.json')).annotations;
38
38
  }
39
39
  else if (multiApps && multiApps.length > 0) {
40
40
  return fs_extra_1.default.readJSONSync(path.join(process.cwd(), multiApps[0].dir, 'manifest.json')).annotations;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-script",
3
- "version": "3.0.21-beta.2",
3
+ "version": "3.0.21-beta.4",
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.21-beta.2",
27
- "@tuya-sat/micro-dev-proxy": "3.0.21-beta.2",
28
- "@tuya-sat/micro-utils": "3.0.21-beta.2",
26
+ "@tuya-sat/micro-dev-loader": "3.0.21-beta.4",
27
+ "@tuya-sat/micro-dev-proxy": "3.0.21-beta.4",
28
+ "@tuya-sat/micro-utils": "3.0.21-beta.4",
29
29
  "@types/kill-port": "^2.0.0",
30
30
  "babel-loader": "8.2.4",
31
31
  "babel-plugin-import": "1.13.3",