@cloudbase/cals 0.3.35 → 0.4.0

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.
Files changed (92) hide show
  1. package/lib/parser/cals/index.d.ts +1 -0
  2. package/lib/parser/cals/index.d.ts.map +1 -1
  3. package/lib/parser/cals/index.js +8 -4
  4. package/lib/parser/cals/utils/block/index.d.ts +0 -0
  5. package/lib/parser/cals/utils/block/index.d.ts.map +0 -0
  6. package/lib/parser/cals/utils/block/index.js +0 -0
  7. package/lib/parser/cals/utils/code/index.d.ts +31 -0
  8. package/lib/parser/cals/utils/code/index.d.ts.map +1 -0
  9. package/lib/parser/cals/utils/code/index.js +376 -0
  10. package/lib/parser/cals/utils/common.d.ts +0 -0
  11. package/lib/parser/cals/utils/common.d.ts.map +0 -0
  12. package/lib/parser/cals/utils/common.js +0 -0
  13. package/lib/parser/cals/utils/runtime.d.ts +0 -0
  14. package/lib/parser/cals/utils/runtime.d.ts.map +0 -0
  15. package/lib/parser/cals/utils/runtime.js +2 -2
  16. package/lib/parser/cals/utils/spinoff/index.d.ts +0 -0
  17. package/lib/parser/cals/utils/spinoff/index.d.ts.map +0 -0
  18. package/lib/parser/cals/utils/spinoff/index.js +0 -0
  19. package/lib/parser/cals/utils/style.d.ts +0 -0
  20. package/lib/parser/cals/utils/style.d.ts.map +0 -0
  21. package/lib/parser/cals/utils/style.js +0 -0
  22. package/lib/parser/cals/utils/version/common.d.ts +0 -0
  23. package/lib/parser/cals/utils/version/common.d.ts.map +0 -0
  24. package/lib/parser/cals/utils/version/common.js +5 -1
  25. package/lib/parser/cals/utils/version/config.d.ts +0 -0
  26. package/lib/parser/cals/utils/version/config.d.ts.map +0 -0
  27. package/lib/parser/cals/utils/version/config.js +0 -0
  28. package/lib/parser/cals/utils/version/index.d.ts +0 -0
  29. package/lib/parser/cals/utils/version/index.d.ts.map +0 -0
  30. package/lib/parser/cals/utils/version/index.js +5 -1
  31. package/lib/parser/cals/utils/version/parses.d.ts +0 -0
  32. package/lib/parser/cals/utils/version/parses.d.ts.map +0 -0
  33. package/lib/parser/cals/utils/version/parses.js +5 -1
  34. package/lib/parser/cals/utils/version/utils.d.ts +0 -0
  35. package/lib/parser/cals/utils/version/utils.d.ts.map +0 -0
  36. package/lib/parser/cals/utils/version/utils.js +0 -0
  37. package/lib/parser/expression/index.d.ts +0 -0
  38. package/lib/parser/expression/index.d.ts.map +0 -0
  39. package/lib/parser/expression/index.js +0 -0
  40. package/lib/parser/index.d.ts +1 -0
  41. package/lib/parser/index.d.ts.map +1 -1
  42. package/lib/parser/index.js +11 -2
  43. package/lib/types/basic/app.d.ts +0 -0
  44. package/lib/types/basic/app.d.ts.map +0 -0
  45. package/lib/types/basic/app.js +0 -0
  46. package/lib/types/basic/common.d.ts +0 -0
  47. package/lib/types/basic/common.d.ts.map +0 -0
  48. package/lib/types/basic/common.js +0 -0
  49. package/lib/types/basic/component.d.ts +0 -0
  50. package/lib/types/basic/component.d.ts.map +0 -0
  51. package/lib/types/basic/component.js +0 -0
  52. package/lib/types/basic/datasource.d.ts +0 -0
  53. package/lib/types/basic/datasource.d.ts.map +0 -0
  54. package/lib/types/basic/datasource.js +0 -0
  55. package/lib/types/index.d.ts +0 -0
  56. package/lib/types/index.d.ts.map +0 -0
  57. package/lib/types/index.js +5 -1
  58. package/lib/types/lcds.d.ts +0 -0
  59. package/lib/types/lcds.d.ts.map +0 -0
  60. package/lib/types/lcds.js +0 -0
  61. package/lib/types/platform/app.d.ts +4 -0
  62. package/lib/types/platform/app.d.ts.map +1 -1
  63. package/lib/types/platform/app.js +0 -0
  64. package/lib/types/platform/common.d.ts +0 -0
  65. package/lib/types/platform/common.d.ts.map +0 -0
  66. package/lib/types/platform/common.js +0 -0
  67. package/lib/types/platform/component.d.ts +0 -0
  68. package/lib/types/platform/component.d.ts.map +0 -0
  69. package/lib/types/platform/component.js +0 -0
  70. package/lib/types/platform/datasource.d.ts +0 -0
  71. package/lib/types/platform/datasource.d.ts.map +0 -0
  72. package/lib/types/platform/datasource.js +0 -0
  73. package/lib/types/platform/widget/form.d.ts +0 -0
  74. package/lib/types/platform/widget/form.d.ts.map +0 -0
  75. package/lib/types/platform/widget/form.js +0 -0
  76. package/lib/types/platform/widget/meta.d.ts +0 -0
  77. package/lib/types/platform/widget/meta.d.ts.map +0 -0
  78. package/lib/types/platform/widget/meta.js +0 -0
  79. package/lib/utils/build.d.ts +0 -0
  80. package/lib/utils/build.d.ts.map +0 -0
  81. package/lib/utils/build.js +5 -1
  82. package/lib/utils/constant.d.ts +0 -0
  83. package/lib/utils/constant.d.ts.map +0 -0
  84. package/lib/utils/constant.js +0 -0
  85. package/lib/utils/index.d.ts +0 -0
  86. package/lib/utils/index.d.ts.map +0 -0
  87. package/lib/utils/index.js +5 -1
  88. package/package.json +2 -3
  89. package/lib/parser/cals/utils/transform/index.d.ts +0 -4
  90. package/lib/parser/cals/utils/transform/index.d.ts.map +0 -1
  91. package/lib/parser/cals/utils/transform/index.js +0 -247
  92. package/lib/tsconfig.tsbuildinfo +0 -1
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -10,12 +14,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
15
  };
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.PropBindType = exports.ActionType = exports.parseComponentCals = exports.processComponentModule = exports.upgrageToVersion2 = void 0;
17
+ exports.PropBindType = exports.ActionType = exports.parseComponentCals = exports.autoResolveConflicts = exports.checkForConflicts = exports.codeToCals = exports.calsToCode = exports.processComponentModule = exports.upgrageToVersion2 = void 0;
14
18
  __exportStar(require("./cals/index"), exports);
15
19
  var version_1 = require("./cals/utils/version");
16
20
  Object.defineProperty(exports, "upgrageToVersion2", { enumerable: true, get: function () { return version_1.upgrageToVersion2; } });
17
21
  var spinoff_1 = require("./cals/utils/spinoff");
18
22
  Object.defineProperty(exports, "processComponentModule", { enumerable: true, get: function () { return spinoff_1.processComponentModule; } });
23
+ var code_1 = require("./cals/utils/code");
24
+ Object.defineProperty(exports, "calsToCode", { enumerable: true, get: function () { return code_1.calsToCode; } });
25
+ Object.defineProperty(exports, "codeToCals", { enumerable: true, get: function () { return code_1.codeToCals; } });
26
+ Object.defineProperty(exports, "checkForConflicts", { enumerable: true, get: function () { return code_1.checkForConflicts; } });
27
+ Object.defineProperty(exports, "autoResolveConflicts", { enumerable: true, get: function () { return code_1.autoResolveConflicts; } });
19
28
  var block_1 = require("./cals/utils/block");
20
29
  Object.defineProperty(exports, "parseComponentCals", { enumerable: true, get: function () { return block_1.parseComponentCals; } });
21
30
  var index_1 = require("./expression/index");
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
File without changes
File without changes
package/lib/types/lcds.js CHANGED
File without changes
@@ -132,6 +132,10 @@ export interface IPlatformAppExtra {
132
132
  compHiddenConfig?: {
133
133
  [pageId: string]: string[];
134
134
  };
135
+ /**
136
+ * 基准历史ID
137
+ */
138
+ originHistoryId?: string;
135
139
  }
136
140
  export interface IPlatformAppLifeCycle extends IEvents {
137
141
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/types/platform/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAuC,MAAM,UAAU,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,WAAW,CAAC;IACnH;;OAEG;IACH,KAAK,EAAE,cAAc,EAAE,CAAC;IAExB;;OAEG;IACH,WAAW,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAEpC;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAE3B;;;;OAIG;IACH,aAAa,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAEtC;;OAEG;IACH,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAE1B;;;;OAIG;IACH,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;IAE5B;;;OAGG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC;IAe7B,eAAe;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY;IACZ,EAAE,CAAC,EA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1B;AAED,MAAM,WAAW,qBAAsB,SAAQ,OAAO;IACpD;;OAEG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC;;OAEG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC;;OAEG;IACH,0BAA0B,CAAC,EAAE,MAAM,CAAC;CACrC"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cals",
3
- "version": "0.3.35",
3
+ "version": "0.4.0",
4
4
  "description": "Common application specifications",
5
5
  "main": "lib/utils/index.js",
6
6
  "typedocMain": "src/types/index.ts",
@@ -35,8 +35,7 @@
35
35
  "jest": "^27.1.0",
36
36
  "ts-jest": "^27.0.5",
37
37
  "ts-node": "^10.4.0",
38
- "typedoc-neo-theme": "^1.0.10",
39
- "typescript": "^4.4.4",
38
+ "typescript": "^4.7.4",
40
39
  "typescript-json-schema": "^0.53.0"
41
40
  }
42
41
  }
@@ -1,4 +0,0 @@
1
- import { IPlatformApp } from '../../../../types/index';
2
- export declare function generateLocalFromCals(cals: IPlatformApp, options?: any): Promise<void>;
3
- export declare function generateCalsFromLocal(dir: any): Promise<any>;
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../parser/cals/utils/transform/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAA4B,MAAM,yBAAyB,CAAC;AAEjF,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,KAAA,iBAkDvE;AAED,wBAAsB,qBAAqB,CAAC,GAAG,KAAA,gBAmD9C"}
@@ -1,247 +0,0 @@
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 __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
- var __importDefault = (this && this.__importDefault) || function (mod) {
23
- return (mod && mod.__esModule) ? mod : { "default": mod };
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.generateCalsFromLocal = exports.generateLocalFromCals = void 0;
27
- const path_1 = require("path");
28
- const fs_extra_1 = __importDefault(require("fs-extra"));
29
- const index_1 = require("../../../../types/index");
30
- function generateLocalFromCals(cals, options) {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- const { outputDir } = options || { outputDir: './' };
33
- const { id, label, dataSources, envId, dependencies, items = [], resources = [], extra = {} } = cals, restCals = __rest(cals, ["id", "label", "dataSources", "envId", "dependencies", "items", "resources", "extra"]);
34
- const _a = extra || {}, { npmDependencies = {} } = _a, restExtra = __rest(_a, ["npmDependencies"]);
35
- // 补充json数据
36
- if (Object.keys(restExtra).length) {
37
- restCals['extra'] = restExtra;
38
- }
39
- const { localResources, jsonResourcces } = splitCodeResources(resources);
40
- if (jsonResourcces.length) {
41
- restCals['resources'] = jsonResourcces;
42
- }
43
- yield Promise.all([
44
- // generate app meta
45
- ensureWriteFile((0, path_1.join)(outputDir, 'meta.json'), JSON.stringify(restCals, undefined, 2)),
46
- // generate app package.json
47
- ensureWriteFile((0, path_1.join)(outputDir, 'package.json'), JSON.stringify({
48
- name: id,
49
- // version: '1.0.0',
50
- description: label,
51
- scripts: {},
52
- license: 'MIT',
53
- dependencies: Object.assign(Object.assign({}, dependencies), npmDependencies),
54
- }, undefined, 2)),
55
- // generate app code resource
56
- ...localResources.map((resource) => localizeCodeResources(resource, { base: outputDir })),
57
- ]);
58
- yield Promise.all(items.reduce((list, page) => {
59
- const { id, type, resources = [], directives, component } = page, restPage = __rest(page, ["id", "type", "resources", "directives", "component"]);
60
- const { localResources, jsonResourcces } = splitCodeResources(resources);
61
- if (jsonResourcces.length) {
62
- restPage['resources'] = jsonResourcces;
63
- }
64
- const pageRootDir = (0, path_1.join)(outputDir, 'pages', id);
65
- // generate page meta json
66
- list.push(ensureWriteFile((0, path_1.join)(pageRootDir, 'meta.json'), JSON.stringify(restPage, undefined, 2)));
67
- // generate page code resources
68
- list.push(...localResources.map((resource) => localizeCodeResources(resource, { base: pageRootDir })));
69
- return list;
70
- }, []));
71
- });
72
- }
73
- exports.generateLocalFromCals = generateLocalFromCals;
74
- function generateCalsFromLocal(dir) {
75
- return __awaiter(this, void 0, void 0, function* () {
76
- const rootDir = (0, path_1.resolve)(process.cwd(), dir);
77
- const [appMeta, packageJson] = yield Promise.all([
78
- fs_extra_1.default.readJSON((0, path_1.resolve)(rootDir, 'meta.json')),
79
- fs_extra_1.default.readJson((0, path_1.resolve)(rootDir, 'package.json')),
80
- ]);
81
- const { name: id, description: label, dependencies = {} } = packageJson;
82
- const npmDependencies = {};
83
- Object.entries(dependencies).forEach(([key, value]) => {
84
- if (!/^weda:/.test(value)) {
85
- npmDependencies[key] = value;
86
- delete dependencies[key];
87
- }
88
- });
89
- Object.assign(appMeta, {
90
- id,
91
- label,
92
- dependencies,
93
- });
94
- if (!appMeta.extra) {
95
- appMeta.extra = {};
96
- }
97
- appMeta.extra.npmDependencies = npmDependencies;
98
- // 处理 resource
99
- appMeta.resources = yield generateCodeResourcesJson((0, path_1.resolve)(rootDir, 'resources'), appMeta.resources || [], 'global');
100
- const pageNames = yield fs_extra_1.default.readdir((0, path_1.resolve)(rootDir, 'pages'));
101
- appMeta.items = yield Promise.all(pageNames.map((pageName) => __awaiter(this, void 0, void 0, function* () {
102
- const pageRootDir = (0, path_1.resolve)(rootDir, 'pages', pageName);
103
- const pageMeta = yield fs_extra_1.default.readJSON((0, path_1.resolve)(pageRootDir, 'meta.json'));
104
- Object.assign(pageMeta, {
105
- id: pageName,
106
- type: 'PAGE',
107
- directives: { ':if': true },
108
- component: 'PAGE',
109
- });
110
- pageMeta.resource = yield generateCodeResourcesJson((0, path_1.resolve)(pageRootDir, 'resources'), pageMeta.resources || [], pageName);
111
- return pageMeta;
112
- })));
113
- return appMeta;
114
- });
115
- }
116
- exports.generateCalsFromLocal = generateCalsFromLocal;
117
- function splitCodeResources(resources) {
118
- // resource 分组,部分存储于文件,部分存储于json
119
- const localResources = [];
120
- const jsonResourcces = [];
121
- for (const resource of resources) {
122
- switch (resource.codeType) {
123
- case index_1.ECodeType.STATE:
124
- case index_1.ECodeType.COMPUTEDN: {
125
- jsonResourcces.push(resource);
126
- break;
127
- }
128
- default:
129
- localResources.push(resource);
130
- }
131
- }
132
- return {
133
- localResources,
134
- jsonResourcces,
135
- };
136
- }
137
- const TYPE_EXT_MAP = {
138
- [index_1.ECodeType.THEME]: 'less',
139
- [index_1.ECodeType.STYLE]: 'less',
140
- [index_1.ECodeType.RENDERER]: 'jsx',
141
- };
142
- function localizeCodeResources(resource, options) {
143
- return __awaiter(this, void 0, void 0, function* () {
144
- const { base } = options || { base: './' };
145
- if (!resource || (resource === null || resource === void 0 ? void 0 : resource.type) !== 'CODE' || (resource === null || resource === void 0 ? void 0 : resource.name) === '____index____') {
146
- return;
147
- }
148
- const ext = TYPE_EXT_MAP[resource.codeType] || 'js';
149
- return ensureWriteFile((0, path_1.join)(base, `${resource.path.replace(/^(.*?)\//, './resources/')}.${ext}`), resource.code);
150
- });
151
- }
152
- function ensureWriteFile(_filePath, content) {
153
- return __awaiter(this, void 0, void 0, function* () {
154
- const filePath = (0, path_1.resolve)(process.cwd(), _filePath);
155
- console.log(`write file: ${filePath}`);
156
- yield fs_extra_1.default.ensureFile(filePath);
157
- return fs_extra_1.default.writeFile(filePath, content);
158
- });
159
- }
160
- const readDir = function (src, base) {
161
- return __awaiter(this, void 0, void 0, function* () {
162
- const state = yield fs_extra_1.default.stat(src);
163
- if (state.isDirectory()) {
164
- const list = yield fs_extra_1.default.readdir(src);
165
- const res = yield Promise.all(list.map((name) => readDir((0, path_1.join)(src, name), base)));
166
- return res.reduce((list, item) => {
167
- list.push(...item);
168
- return list;
169
- }, []);
170
- }
171
- else {
172
- const code = yield fs_extra_1.default.readFile(src);
173
- const extName = (0, path_1.extname)(src);
174
- const baseName = (0, path_1.basename)(src, extName);
175
- const codePath = (0, path_1.relative)(base, src).replace(new RegExp(`${extName}$`), '');
176
- const meta = {
177
- type: 'CODE',
178
- name: baseName,
179
- code: code.toString(),
180
- path: codePath,
181
- };
182
- switch (extName) {
183
- case '.less': {
184
- if (baseName === 'theme') {
185
- meta.codeType = index_1.ECodeType.THEME;
186
- }
187
- else {
188
- meta.codeType = index_1.ECodeType.STYLE;
189
- }
190
- break;
191
- }
192
- case '.jsx': {
193
- meta.codeType = index_1.ECodeType.RENDERER;
194
- }
195
- default: {
196
- switch (baseName) {
197
- case 'lifecycle':
198
- meta.codeType = index_1.ECodeType.LIFECYCLE;
199
- break;
200
- case 'state':
201
- meta.codeType = index_1.ECodeType.RENDERER;
202
- break;
203
- case 'computed':
204
- meta.codeType = index_1.ECodeType.RENDERER;
205
- break;
206
- default: {
207
- if (/^common\//.test(codePath)) {
208
- if (baseName === 'mp_config') {
209
- meta.codeType = index_1.ECodeType.MPCONFIG;
210
- }
211
- else {
212
- meta.codeType = index_1.ECodeType.NORMAL_MODULE;
213
- }
214
- }
215
- else if (/^handler\//.test(codePath)) {
216
- meta.codeType = index_1.ECodeType.HANDLER_FN;
217
- }
218
- else {
219
- // 跳过意义不明的文件
220
- return [];
221
- }
222
- }
223
- }
224
- break;
225
- }
226
- }
227
- return [meta];
228
- }
229
- });
230
- };
231
- function generateCodeResourcesJson(dir, currentResources = [], prefix = '') {
232
- return __awaiter(this, void 0, void 0, function* () {
233
- const resources = yield readDir(dir, dir);
234
- const currentResourceMap = currentResources.reduce((map, current) => {
235
- map[current.path] = current;
236
- return map;
237
- }, {});
238
- for (const meta of resources) {
239
- const processPath = (0, path_1.join)(prefix, meta.path);
240
- if (currentResourceMap[processPath]) {
241
- continue;
242
- }
243
- currentResources.push(Object.assign(Object.assign({}, meta), { path: processPath }));
244
- }
245
- return currentResources;
246
- });
247
- }