@ldsg/cli 0.1.0-alpha.9 → 0.3.25

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 (63) hide show
  1. package/.rush/temp/chunked-rush-logs/cli.build.chunks.jsonl +1 -0
  2. package/.rush/temp/package-deps_build.json +18 -0
  3. package/.rush/temp/shrinkwrap-deps.json +373 -0
  4. package/CHANGELOG.json +31 -0
  5. package/CHANGELOG.md +11 -0
  6. package/Dockerfile +21 -0
  7. package/README.md +61 -2
  8. package/dist/cli.d.ts +2 -0
  9. package/dist/cli.js +54 -0
  10. package/dist/cli.js.map +1 -0
  11. package/dist/commands/fetch-app-data.d.ts +2 -0
  12. package/dist/commands/fetch-app-data.js +40 -0
  13. package/dist/commands/fetch-app-data.js.map +1 -0
  14. package/dist/commands/prepare-app-code.d.ts +2 -0
  15. package/dist/commands/prepare-app-code.js +42 -0
  16. package/dist/commands/prepare-app-code.js.map +1 -0
  17. package/dist/constants.d.ts +1 -0
  18. package/dist/constants.js +5 -0
  19. package/dist/constants.js.map +1 -0
  20. package/dist/debug/constants.d.ts +2 -0
  21. package/dist/debug/constants.js +10 -0
  22. package/dist/debug/constants.js.map +1 -0
  23. package/dist/tsconfig.build.tsbuildinfo +1 -0
  24. package/dist/tsconfig.tsbuildinfo +1 -0
  25. package/dist/types/get-extend-app-data-params.d.ts +7 -0
  26. package/dist/types/get-extend-app-data-params.js +3 -0
  27. package/dist/types/get-extend-app-data-params.js.map +1 -0
  28. package/dist/utils/get-extend-app-data-params-using-npm-ldsg-module.d.ts +2 -0
  29. package/dist/utils/get-extend-app-data-params-using-npm-ldsg-module.js +43 -0
  30. package/dist/utils/get-extend-app-data-params-using-npm-ldsg-module.js.map +1 -0
  31. package/dist/utils/get-extend-app-data-params-using-npm-module.d.ts +2 -0
  32. package/dist/utils/get-extend-app-data-params-using-npm-module.js +30 -0
  33. package/dist/utils/get-extend-app-data-params-using-npm-module.js.map +1 -0
  34. package/dist/utils/get-extend-app-data-params-using-workspace-ldsg-module/constants.d.ts +1 -0
  35. package/dist/utils/get-extend-app-data-params-using-workspace-ldsg-module/constants.js +9 -0
  36. package/dist/utils/get-extend-app-data-params-using-workspace-ldsg-module/constants.js.map +1 -0
  37. package/dist/utils/get-extend-app-data-params-using-workspace-ldsg-module/index.d.ts +2 -0
  38. package/dist/utils/get-extend-app-data-params-using-workspace-ldsg-module/index.js +88 -0
  39. package/dist/utils/get-extend-app-data-params-using-workspace-ldsg-module/index.js.map +1 -0
  40. package/dist/utils/get-extend-app-data-params-using-workspace-module/constants.d.ts +1 -0
  41. package/dist/utils/get-extend-app-data-params-using-workspace-module/constants.js +9 -0
  42. package/dist/utils/get-extend-app-data-params-using-workspace-module/constants.js.map +1 -0
  43. package/dist/utils/get-extend-app-data-params-using-workspace-module/index.d.ts +2 -0
  44. package/dist/utils/get-extend-app-data-params-using-workspace-module/index.js +105 -0
  45. package/dist/utils/get-extend-app-data-params-using-workspace-module/index.js.map +1 -0
  46. package/dist/utils/get-extend-app-data-params-using-workspace-module.d.ts +2 -0
  47. package/dist/utils/get-extend-app-data-params-using-workspace-module.js +105 -0
  48. package/dist/utils/get-extend-app-data-params-using-workspace-module.js.map +1 -0
  49. package/package.json +32 -25
  50. package/rush-logs/cli.build.log +1 -0
  51. package/src/cli.ts +68 -0
  52. package/src/constants.ts +1 -0
  53. package/src/types/get-extend-app-data-params.ts +8 -0
  54. package/src/utils/get-extend-app-data-params-using-npm-ldsg-module.ts +45 -0
  55. package/src/utils/get-extend-app-data-params-using-workspace-ldsg-module/constants.ts +3 -0
  56. package/src/utils/get-extend-app-data-params-using-workspace-ldsg-module/index.ts +130 -0
  57. package/tsconfig.build.json +4 -0
  58. package/tsconfig.json +24 -0
  59. package/LICENSE +0 -22
  60. package/dist/index.d.ts +0 -2
  61. package/dist/index.d.ts.map +0 -1
  62. package/dist/index.js +0 -3
  63. package/dist/index.js.LICENSE.txt +0 -24
@@ -0,0 +1,130 @@
1
+ import { FILES_IN_APP_TEMPLATE_MODULE } from '@ldsg/constants';
2
+ import { ExtendAppDataParams } from '@ldsg/utils';
3
+ import fs from 'fs-extra';
4
+ import _ from 'lodash';
5
+ import { GetExtendAppDataParams } from '../../types/get-extend-app-data-params';
6
+ import { RUSH_JSON_PATH } from './constants';
7
+
8
+ const DEBUG_APP_PACKAGE_NAME = '@ldsg/app';
9
+
10
+ /**
11
+ * 主函数,用于准备调试应用环境
12
+ *
13
+ * 主要功能包括:
14
+ * 1. 清理并重建应用目录
15
+ * 2. 配置workspace模式的ldsg模块依赖
16
+ * 3. 更新rush.json中的项目配置
17
+ * 4. 生成调试应用的package.json和入口文件
18
+ *
19
+ * @async
20
+ * @function main
21
+ * @throws {Error} 当文件读写操作失败时抛出错误
22
+ */
23
+ export const getExtendAppDataParamsUsingWorkspaceLdsgModule: GetExtendAppDataParams = async (params) => {
24
+ const { appData: paramsAppData } = params;
25
+
26
+ let appData = paramsAppData;
27
+
28
+ /**
29
+ * 相对于普通应用准备,增加了如下操作
30
+ * 1. ldsg 模块使用 workspace 模式
31
+ * 2. 在 rush.json 中增加 projects
32
+ */
33
+ {
34
+ const { resourceRecords: appDataResourceRecords } = appData;
35
+
36
+ const subspaceProjects: {
37
+ packageName: string;
38
+ projectFolder: string;
39
+ }[] = [
40
+ {
41
+ packageName: DEBUG_APP_PACKAGE_NAME,
42
+ projectFolder: 'generated/app'
43
+ }
44
+ ];
45
+
46
+ /**
47
+ * 替换资源记录中的依赖
48
+ */
49
+ const resourceRecords = appDataResourceRecords.map((resourceRecord) => {
50
+ const { id, kind } = resourceRecord;
51
+
52
+ if (kind === 'handler') {
53
+ subspaceProjects.push({
54
+ packageName: `${id}`,
55
+ projectFolder: `generated/${id}`
56
+ });
57
+
58
+ let dependencies = resourceRecord.settings.dependencies.map((dependency) => {
59
+ const res = dependency;
60
+
61
+ if (_.startsWith(dependency.name, '@ldsg/')) {
62
+ return {
63
+ ...dependency,
64
+ version: 'workspace:*'
65
+ };
66
+ }
67
+
68
+ return res;
69
+ });
70
+
71
+ dependencies = dependencies.concat([
72
+ {
73
+ name: '@types/node',
74
+ version: '^24.1.0'
75
+ },
76
+ {
77
+ name: 'typescript',
78
+ version: '^5.3.3'
79
+ }
80
+ ]);
81
+
82
+ return {
83
+ ...resourceRecord,
84
+ settings: {
85
+ ...resourceRecord.settings,
86
+ dependencies
87
+ }
88
+ };
89
+ }
90
+
91
+ return resourceRecord;
92
+ });
93
+
94
+ appData = {
95
+ ...appData,
96
+ resourceRecords
97
+ };
98
+
99
+ const debugProjects = subspaceProjects.map((item) => {
100
+ const res = {
101
+ ...item
102
+ };
103
+
104
+ return res;
105
+ });
106
+
107
+ const rushJson = await fs.readJson(RUSH_JSON_PATH);
108
+
109
+ const newRushJson = {
110
+ ...rushJson,
111
+ projects: _.sortBy(_.uniqBy(rushJson.projects.concat(debugProjects), 'projectFolder'), 'projectFolder')
112
+ };
113
+
114
+ await fs.writeJson(RUSH_JSON_PATH, newRushJson, { spaces: 2 });
115
+ }
116
+
117
+ const packageJsonFile = FILES_IN_APP_TEMPLATE_MODULE.find((file) => file.path === 'package.json');
118
+
119
+ _.set(packageJsonFile, 'data.name', DEBUG_APP_PACKAGE_NAME);
120
+
121
+ const res: ExtendAppDataParams = {
122
+ appData,
123
+ extraAppData: {
124
+ // reuseMainAppDependencies: ['graphql', 'graphql-middleware', 'graphql-shield'],
125
+ filesInAppModele: [...FILES_IN_APP_TEMPLATE_MODULE, packageJsonFile]
126
+ }
127
+ };
128
+
129
+ return res;
130
+ };
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "include": ["src"]
4
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "declaration": true,
5
+ "removeComments": true,
6
+ "emitDecoratorMetadata": true,
7
+ "experimentalDecorators": true,
8
+ "allowSyntheticDefaultImports": true,
9
+ "target": "ES2021",
10
+ "sourceMap": true,
11
+ "outDir": "./dist",
12
+ "baseUrl": "./",
13
+ "incremental": true,
14
+ "skipLibCheck": true,
15
+ "strictNullChecks": false,
16
+ "noImplicitAny": false,
17
+ "strictBindCallApply": false,
18
+ "forceConsistentCasingInFileNames": false,
19
+ "noFallthroughCasesInSwitch": false,
20
+ "resolveJsonModule": true,
21
+ "esModuleInterop": true,
22
+ "types": ["jest", "node"]
23
+ }
24
+ }
package/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2014-present Sebastian McKenzie and other contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}