easy-soft-develop 2.1.82 → 2.1.88

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/bin/cli.js CHANGED
@@ -14,6 +14,7 @@ const clearAllDependence = require('../src/cliCollection/clear-all-dependence');
14
14
  const updatePackageFromPackage = require('../src/cliCollection/update-package-from-package');
15
15
  const createProjectWithTemplate = require('../src/cliCollection/create-project-with-template');
16
16
  const createProjectWithMasterTemplate = require('../src/cliCollection/create-project-with-master-template');
17
+ const updateProjectWithMasterTemplate = require('../src/cliCollection/update-project-with-master-template');
17
18
  const prompt = require('../src/cliCollection/prompt');
18
19
  const code = require('../src/cliCollection/createCode');
19
20
 
@@ -145,6 +146,18 @@ program
145
146
  createProjectWithMasterTemplate.run(a, o);
146
147
  });
147
148
 
149
+ program
150
+ .command('update-project-with-master-template')
151
+ .description('update from master template repository')
152
+ .option('--projectPath <string>', 'target project path that will be updated')
153
+ .option(
154
+ '--agent <string>',
155
+ 'web agent for remote , if it has value, will use the agent to access remote url',
156
+ )
157
+ .action((a, o) => {
158
+ updateProjectWithMasterTemplate.run(a, o);
159
+ });
160
+
148
161
  program
149
162
  .command('code')
150
163
  .description('generate code source with code.json')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-soft-develop",
3
- "version": "2.1.82",
3
+ "version": "2.1.88",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/kityandhero/easy-soft-develop#readme",
6
6
  "bugs": {
@@ -36,6 +36,7 @@
36
36
  "test:bin:publish": "node ./bin/cli.js publish --packages ss --otp true",
37
37
  "test:bin:sleep": "node ./bin/cli.js sleep --second 2 --showInfo true",
38
38
  "test:bin:update-all-package-version": "node ./bin/cli.js update-all-package-version",
39
+ "test:bin:update-project-with-master-template": "node ./bin/cli.js update-project-with-master-template --projectPath E:\\temp\\2\\test",
39
40
  "test:commitRefresh": "node ./test/commitRefresh.test.js",
40
41
  "test:createCleanScriptFile": "node ./test/createCleanScriptFile.test.js",
41
42
  "test:createCommitRefreshScriptFile": "node ./test/createCommitRefreshScriptFile.test.js",
@@ -70,6 +71,7 @@
70
71
  },
71
72
  "dependencies": {
72
73
  "commander": "^12.0.0",
74
+ "cross-zip": "^4.0.1",
73
75
  "download": "^8.0.0",
74
76
  "download-git-repo": "^3.0.2",
75
77
  "enquirer": "^2.4.1",
@@ -0,0 +1,11 @@
1
+ const {
2
+ updateProjectFromRepository,
3
+ } = require('../tools/update.project.from.master.template');
4
+
5
+ exports.run = async function (s, o) {
6
+ const {
7
+ _optionValues: { projectPath = '.', agent },
8
+ } = o;
9
+
10
+ await updateProjectFromRepository({ projectPath, agent });
11
+ };
@@ -0,0 +1,321 @@
1
+ const download = require('download');
2
+ const agent = require('hpagent');
3
+ const fs = require('fs');
4
+ const zip = require('cross-zip');
5
+
6
+ const {
7
+ promptSuccess,
8
+ promptLine,
9
+ promptError,
10
+ promptWarn,
11
+ exit,
12
+ resolvePath,
13
+ checkStringIsEmpty,
14
+ promptInfo,
15
+ exec,
16
+ } = require('./meta');
17
+
18
+ const { HttpsProxyAgent } = agent;
19
+
20
+ function copyFile({
21
+ sourceMainPath,
22
+ targetMainPath,
23
+ filepath,
24
+ callback = null,
25
+ }) {
26
+ promptInfo(`copy file: "${filepath}".`);
27
+
28
+ fs.cp(
29
+ resolvePath(`${sourceMainPath}${filepath}`),
30
+ resolvePath(`${targetMainPath}${filepath}`),
31
+ {
32
+ force: true,
33
+ recursive: true,
34
+ },
35
+ (error) => {
36
+ if (error) {
37
+ promptError(error);
38
+ } else {
39
+ if (callback != null) {
40
+ callback();
41
+ }
42
+ }
43
+ },
44
+ );
45
+ }
46
+
47
+ function copyFolder({
48
+ sourceMainPath,
49
+ targetMainPath,
50
+ filepath,
51
+ callback = null,
52
+ }) {
53
+ promptInfo(`copy folder: "${filepath}".`);
54
+
55
+ fs.cp(
56
+ resolvePath(`${sourceMainPath}${filepath}`),
57
+ resolvePath(`${targetMainPath}${filepath}`),
58
+ {
59
+ force: true,
60
+ recursive: true,
61
+ },
62
+ (error) => {
63
+ if (error) {
64
+ promptError(error);
65
+ } else {
66
+ if (callback != null) {
67
+ callback();
68
+ }
69
+ }
70
+ },
71
+ );
72
+ }
73
+
74
+ function clearResource() {
75
+ const removeSourceFolderCmd = `npx rimraf ${resolvePath(`./temp/source/`)}`;
76
+
77
+ promptInfo(`remove folder: "./temp/source/"`);
78
+
79
+ exec(removeSourceFolderCmd);
80
+
81
+ const removeZipFolderCmd = `npx rimraf ${resolvePath(`./temp/zip/`)}`;
82
+
83
+ promptInfo(`remove folder: "./temp/zip/"`);
84
+
85
+ exec(removeZipFolderCmd);
86
+ }
87
+
88
+ function handlePackage(projectPath, zipPath) {
89
+ const unzipPath = resolvePath(`./temp/source/`);
90
+
91
+ zip.unzip(zipPath, unzipPath, () => {
92
+ promptSuccess(`unzip success.`);
93
+
94
+ promptInfo(
95
+ `master template zip unzip to path: "${resolvePath(`./temp/source/mono-antd-management-fast-master-template-main`)}".`,
96
+ );
97
+
98
+ const projectPathAdjust = resolvePath(projectPath);
99
+
100
+ promptInfo(`target project path: "${projectPathAdjust}".`);
101
+
102
+ const sourceMainPath = `./temp/source/mono-antd-management-fast-master-template-main/packages/master-management/`;
103
+ const targetMainPath = `${projectPath}/packages/master-management/`;
104
+
105
+ promptLine();
106
+
107
+ copyFile({
108
+ sourceMainPath,
109
+ targetMainPath,
110
+ filepath: 'generatorConfig/function.data.extra.json',
111
+ callback: () => {
112
+ copyFile({
113
+ sourceMainPath,
114
+ targetMainPath,
115
+ filepath: 'src/commonAssist/Action/actionGeneral.js',
116
+ callback: () => {
117
+ copyFolder({
118
+ sourceMainPath,
119
+ targetMainPath,
120
+ filepath: 'src/components/PageLoading/',
121
+ callback: () => {
122
+ copyFolder({
123
+ sourceMainPath,
124
+ targetMainPath,
125
+ filepath: 'src/customConfig/general/',
126
+ callback: () => {
127
+ copyFolder({
128
+ sourceMainPath,
129
+ targetMainPath,
130
+ filepath:
131
+ 'src/customSpecialComponents/BaseUpdateRoleModal/',
132
+ callback: () => {
133
+ copyFile({
134
+ sourceMainPath,
135
+ targetMainPath,
136
+ filepath:
137
+ 'src/customSpecialComponents/CustomAssembly/menuHeader.js',
138
+ callback: () => {
139
+ copyFolder({
140
+ sourceMainPath,
141
+ targetMainPath,
142
+ filepath:
143
+ 'src/customSpecialComponents/UpdateModuleModalBase/',
144
+ callback: () => {
145
+ copyFolder({
146
+ sourceMainPath,
147
+ targetMainPath,
148
+ filepath: 'src/pages/',
149
+ callback: () => {
150
+ copyFile({
151
+ sourceMainPath,
152
+ targetMainPath,
153
+ filepath: 'src/utils/init.js',
154
+ callback: () => {
155
+ copyFile({
156
+ sourceMainPath,
157
+ targetMainPath,
158
+ filepath: 'src/utils/tools.js',
159
+ callback: () => {
160
+ copyFile({
161
+ sourceMainPath,
162
+ targetMainPath,
163
+ filepath: 'src/access.js',
164
+ callback: () => {
165
+ copyFile({
166
+ sourceMainPath,
167
+ targetMainPath,
168
+ filepath: 'src/app.core.jsx',
169
+ callback: () => {
170
+ copyFile({
171
+ sourceMainPath,
172
+ targetMainPath,
173
+ filepath:
174
+ 'src/global.less',
175
+ callback: () => {
176
+ copyFile({
177
+ sourceMainPath,
178
+ targetMainPath,
179
+ filepath:
180
+ 'src/overrides.less',
181
+ callback: () => {
182
+ copyFile({
183
+ sourceMainPath,
184
+ targetMainPath,
185
+ filepath:
186
+ 'plugin.ts',
187
+ callback: () => {
188
+ copyFile({
189
+ sourceMainPath,
190
+ targetMainPath,
191
+ filepath:
192
+ 'tsconfig.json',
193
+ callback:
194
+ () => {
195
+ clearResource();
196
+ },
197
+ });
198
+ },
199
+ });
200
+ },
201
+ });
202
+ },
203
+ });
204
+ },
205
+ });
206
+ },
207
+ });
208
+ },
209
+ });
210
+ },
211
+ });
212
+ },
213
+ });
214
+ },
215
+ });
216
+ },
217
+ });
218
+ },
219
+ });
220
+ },
221
+ });
222
+ },
223
+ });
224
+ },
225
+ });
226
+ },
227
+ });
228
+ });
229
+ }
230
+
231
+ async function handleTempPackagePath({ agent, packageUrl, repo }) {
232
+ let zipPath = '';
233
+
234
+ let agentInfo = '';
235
+
236
+ if (checkStringIsEmpty(agent)) {
237
+ agentInfo = `download with none agent`;
238
+ } else {
239
+ agentInfo = `download with agent "${agent}"`;
240
+ }
241
+
242
+ promptInfo(
243
+ `try master management template ${repo} repository, ${agentInfo}.`,
244
+ );
245
+
246
+ if (agent) {
247
+ promptSuccess(`agent: ${agent}`);
248
+ }
249
+
250
+ promptInfo(`${repo} repository: "${packageUrl}".`);
251
+
252
+ await download(packageUrl, resolvePath(`./temp/zip`), {
253
+ ...(agent
254
+ ? {
255
+ agent: {
256
+ https: new HttpsProxyAgent({
257
+ keepAlive: true,
258
+ keepAliveMsecs: 1000,
259
+ maxSockets: 256,
260
+ maxFreeSockets: 256,
261
+ scheduling: 'lifo',
262
+ proxy: agent,
263
+ }),
264
+ },
265
+ }
266
+ : {}),
267
+ });
268
+
269
+ promptSuccess(`download zip from ${repo} repository success!`);
270
+
271
+ zipPath = resolvePath(
272
+ `./temp/zip/mono-antd-management-fast-master-template-main.zip`,
273
+ );
274
+
275
+ promptInfo(`master template zip file Path: "${zipPath}".`);
276
+
277
+ return zipPath;
278
+ }
279
+
280
+ async function updateProjectFromRepository({ projectPath = '.', agent }) {
281
+ clearResource();
282
+
283
+ const repositoryRemoteUrl =
284
+ 'https://codeload.github.com/kityandhero/mono-antd-management-fast-master-template/zip/refs/heads/main';
285
+
286
+ if (checkStringIsEmpty(repositoryRemoteUrl)) {
287
+ promptError('please input primary remote package.json url');
288
+
289
+ exit();
290
+ }
291
+
292
+ let zipPath = '';
293
+
294
+ promptSuccess(`prepare to update from master template: `);
295
+
296
+ promptLine();
297
+
298
+ try {
299
+ zipPath = await handleTempPackagePath({
300
+ agent,
301
+ packageUrl: repositoryRemoteUrl,
302
+ repo: 'github',
303
+ });
304
+ } catch (error) {
305
+ if (checkStringIsEmpty(repositoryRemoteUrl)) {
306
+ promptError('please input repository remote url');
307
+
308
+ exit();
309
+ }
310
+
311
+ promptLine();
312
+
313
+ promptWarn(`use github repository failure! `);
314
+
315
+ promptLine();
316
+ }
317
+
318
+ handlePackage(projectPath, zipPath);
319
+ }
320
+
321
+ module.exports = { updateProjectFromRepository };
@@ -0,0 +1 @@
1
+ export function run(s: any, o: any): Promise<void>;
@@ -0,0 +1,7 @@
1
+ export function updateProjectFromRepository({
2
+ projectPath,
3
+ agent,
4
+ }: {
5
+ projectPath?: string | undefined;
6
+ agent: any;
7
+ }): Promise<void>;