nsgm-cli 2.0.6 → 2.0.7
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/LICENSE +201 -201
- package/README.md +161 -161
- package/client/layout/index.tsx +248 -245
- package/client/redux/reducers.ts +4 -4
- package/client/redux/store.ts +50 -50
- package/client/redux/template/manage/actions.ts +190 -190
- package/client/redux/template/manage/reducers.ts +118 -118
- package/client/redux/template/manage/types.ts +24 -24
- package/client/service/template/manage.ts +96 -96
- package/client/styled/common.ts +30 -26
- package/client/styled/layout/index.ts +25 -25
- package/client/styled/template/manage.ts +51 -51
- package/client/utils/common.ts +89 -86
- package/client/utils/cookie.ts +51 -51
- package/client/utils/fetch.ts +25 -25
- package/client/utils/menu.tsx +27 -27
- package/client/utils/sso.ts +205 -0
- package/generation/README.md +19 -19
- package/generation/app.js +2 -2
- package/generation/client/redux/reducers.ts +4 -4
- package/generation/client/utils/menu.tsx +27 -27
- package/generation/gitignore +4 -4
- package/generation/mysql.config.js +12 -13
- package/generation/next.config.js +6 -6
- package/generation/package.json +21 -26
- package/generation/project.config.js +13 -12
- package/generation/server/rest.js +23 -20
- package/generation/tsconfig.json +30 -30
- package/index.js +10 -10
- package/lib/args.d.ts +6 -6
- package/lib/args.js +53 -53
- package/lib/generate.d.ts +3 -3
- package/lib/generate.js +751 -736
- package/lib/index.d.ts +2 -2
- package/lib/index.js +272 -272
- package/lib/server/db.d.ts +5 -5
- package/lib/server/db.js +110 -110
- package/lib/server/graphql.d.ts +7 -7
- package/lib/server/graphql.js +119 -119
- package/lib/server/plugins/date.d.ts +5 -5
- package/lib/server/plugins/date.js +16 -16
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/mysql.config.js +14 -14
- package/next-env.d.ts +6 -6
- package/next.config.js +2 -2
- package/package.json +126 -126
- package/pages/_app.tsx +54 -44
- package/pages/login.tsx +65 -0
- package/pages/template/manage.tsx +278 -278
- package/project.config.js +16 -14
- package/public/slbhealthcheck.html +9 -9
- package/scripts/shutdown.sh +9 -9
- package/scripts/startup.sh +34 -34
- package/server/apis/sso.js +44 -0
- package/server/apis/template.js +17 -17
- package/server/modules/template/schema.js +33 -33
- package/server/rest.js +24 -20
- package/server/sql/template.sql +8 -8
- package/generation/.DS_Store +0 -0
package/lib/generate.js
CHANGED
|
@@ -1,736 +1,751 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.deleteFiles = exports.createFiles = exports.initFiles = void 0;
|
|
7
|
-
var fs_1 = __importDefault(require("fs"));
|
|
8
|
-
var path_1 = __importDefault(require("path"));
|
|
9
|
-
var shelljs_1 = __importDefault(require("shelljs"));
|
|
10
|
-
var db_1 = __importDefault(require("./server/db"));
|
|
11
|
-
var replace_1 = __importDefault(require("replace"));
|
|
12
|
-
var replace_in_file_1 = require("replace-in-file");
|
|
13
|
-
var resolve = path_1.default.resolve;
|
|
14
|
-
var getMysqlConfig = db_1.default.getMysqlConfig;
|
|
15
|
-
var mysqlOptions = getMysqlConfig().mysqlOptions;
|
|
16
|
-
var mysqlUser = mysqlOptions.user, mysqlPassword = mysqlOptions.password, mysqlHost = mysqlOptions.host, mysqlPort = mysqlOptions.port, mysqlDatabase = mysqlOptions.database;
|
|
17
|
-
var mkdirFlag = true;
|
|
18
|
-
var copyFileFlag = true;
|
|
19
|
-
var replaceFlag = true;
|
|
20
|
-
var replaceInFileFlag = true;
|
|
21
|
-
var rmdirFlag = true;
|
|
22
|
-
var rmfileFlag = true;
|
|
23
|
-
var firstUpperCase = function (word) {
|
|
24
|
-
return word.substring(0, 1).toUpperCase() + word.substring(1);
|
|
25
|
-
};
|
|
26
|
-
var mkdirSync = function (dirPath) {
|
|
27
|
-
if (mkdirFlag) {
|
|
28
|
-
if (!fs_1.default.existsSync(dirPath)) {
|
|
29
|
-
fs_1.default.mkdirSync(dirPath);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
var rmFileSync = function (filePath) {
|
|
34
|
-
if (rmfileFlag) {
|
|
35
|
-
if (fs_1.default.existsSync(filePath)) {
|
|
36
|
-
fs_1.default.unlinkSync(filePath);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
var rmdirSync = function (dirPath) {
|
|
41
|
-
if (rmdirFlag) {
|
|
42
|
-
if (fs_1.default.existsSync(dirPath)) {
|
|
43
|
-
var list = fs_1.default.readdirSync(dirPath);
|
|
44
|
-
list.forEach(function (item) {
|
|
45
|
-
var resolverPath = resolve(dirPath + '/' + item);
|
|
46
|
-
var stat = fs_1.default.statSync(resolverPath);
|
|
47
|
-
var isDir = stat.isDirectory();
|
|
48
|
-
var isFile = stat.isFile();
|
|
49
|
-
if (isDir) {
|
|
50
|
-
rmdirSync(resolverPath);
|
|
51
|
-
}
|
|
52
|
-
else if (isFile) {
|
|
53
|
-
rmFileSync(resolverPath);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
fs_1.default.rmdirSync(dirPath);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
var copyFileSync = function (source, dest, upgradeFlag) {
|
|
61
|
-
if (upgradeFlag === void 0) { upgradeFlag = false; }
|
|
62
|
-
if (copyFileFlag) {
|
|
63
|
-
if (!upgradeFlag) {
|
|
64
|
-
if (!fs_1.default.existsSync(dest) && fs_1.default.existsSync(source)) {
|
|
65
|
-
fs_1.default.copyFileSync(source, dest);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
if (fs_1.default.existsSync(source)) {
|
|
70
|
-
fs_1.default.copyFileSync(source, dest);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
var handleReplace = function (_a) {
|
|
76
|
-
var regex = _a.regex, replacement = _a.replacement, paths = _a.paths;
|
|
77
|
-
if (replaceFlag) {
|
|
78
|
-
(0, replace_1.default)({
|
|
79
|
-
regex: regex,
|
|
80
|
-
replacement: replacement,
|
|
81
|
-
paths: paths,
|
|
82
|
-
recursive: true,
|
|
83
|
-
silent: true
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
var replaceInFileAll = function (array, index, callback) {
|
|
88
|
-
if (index === void 0) { index = 0; }
|
|
89
|
-
if (replaceInFileFlag) {
|
|
90
|
-
console.log('replaceInFileAll', index);
|
|
91
|
-
var arrayLen = array.length;
|
|
92
|
-
if (index < arrayLen) {
|
|
93
|
-
var item = array[index];
|
|
94
|
-
(0, replace_in_file_1.replaceInFile)(item, function (error, changedFiles) {
|
|
95
|
-
if (error) {
|
|
96
|
-
console.error('Error occurred:', error);
|
|
97
|
-
}
|
|
98
|
-
console.log('Modified files:', changedFiles);
|
|
99
|
-
replaceInFileAll(array, ++index, callback);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
return callback && callback();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
return callback && callback();
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
var sourceFolder = __dirname;
|
|
111
|
-
var destFolder = process.cwd();
|
|
112
|
-
var isLocal = sourceFolder === resolve(destFolder + '/lib');
|
|
113
|
-
var generationPath = '../generation';
|
|
114
|
-
var clientPathSource = '../client';
|
|
115
|
-
var clientPath = './client';
|
|
116
|
-
var serverPathSource = '../server';
|
|
117
|
-
var serverPath = './server';
|
|
118
|
-
var pagesPathSource = '../pages';
|
|
119
|
-
var pagesPath = './pages';
|
|
120
|
-
var publicPathSource = '../public';
|
|
121
|
-
var publicPath = './public';
|
|
122
|
-
var scriptsPathSource = '../scripts';
|
|
123
|
-
var scriptsPath = './scripts';
|
|
124
|
-
var reduxPath = '/redux';
|
|
125
|
-
var servicePath = '/service';
|
|
126
|
-
var styledPath = '/styled';
|
|
127
|
-
var styledLayoutPath = '/layout';
|
|
128
|
-
var utilsPath = '/utils';
|
|
129
|
-
var layoutPath = '/layout';
|
|
130
|
-
var modulesPath = '/modules';
|
|
131
|
-
var apisPath = '/apis';
|
|
132
|
-
var sqlPath = '/sql';
|
|
133
|
-
var utilsMenuPath = '/menu.tsx';
|
|
134
|
-
var reduxReducersPath = '/reducers.ts';
|
|
135
|
-
var slbHealthCheckPath = '/slbhealthcheck.html';
|
|
136
|
-
var packagePath = '/package.json';
|
|
137
|
-
var restPath = '/rest.js';
|
|
138
|
-
var sourceGenerationPath = path_1.default.join(sourceFolder, generationPath);
|
|
139
|
-
var sourceClientPath = path_1.default.join(sourceFolder, clientPathSource);
|
|
140
|
-
var sourceClientPathGeneration = path_1.default.join(sourceGenerationPath, clientPath);
|
|
141
|
-
var sourceServerPath = path_1.default.join(sourceFolder, serverPathSource);
|
|
142
|
-
var sourceServerPathGeneration = path_1.default.join(sourceGenerationPath, serverPath);
|
|
143
|
-
var sourcePagesPath = path_1.default.join(sourceFolder, pagesPathSource);
|
|
144
|
-
var sourcePublicPath = path_1.default.join(sourceFolder, publicPathSource);
|
|
145
|
-
var sourceScriptsPath = path_1.default.join(sourceFolder, scriptsPathSource);
|
|
146
|
-
var destClientPath = path_1.default.join(destFolder, clientPath);
|
|
147
|
-
var destClientReduxPath = resolve(destClientPath + reduxPath);
|
|
148
|
-
var destClientServicePath = resolve(destClientPath + servicePath);
|
|
149
|
-
var destClientStyledPath = resolve(destClientPath + styledPath);
|
|
150
|
-
var destClientStyledLayoutPath = resolve(destClientStyledPath + styledLayoutPath);
|
|
151
|
-
var destClientUtilsPath = resolve(destClientPath + utilsPath);
|
|
152
|
-
var destClientLayoutPath = resolve(destClientPath + layoutPath);
|
|
153
|
-
var destServerPath = path_1.default.join(destFolder, serverPath);
|
|
154
|
-
var destServerModulesPath = resolve(destServerPath + modulesPath);
|
|
155
|
-
var destServerApisPath = resolve(destServerPath + apisPath);
|
|
156
|
-
var destServerSqlPath = resolve(destServerPath + sqlPath);
|
|
157
|
-
var destServerUtilsPath = resolve(destServerPath + utilsPath);
|
|
158
|
-
var destPagesPath = path_1.default.join(destFolder, pagesPath);
|
|
159
|
-
var destPublicPath = path_1.default.join(destFolder, publicPath);
|
|
160
|
-
var destScriptsPath = path_1.default.join(destFolder, scriptsPath);
|
|
161
|
-
var destClientUtilsMenuPath = resolve(destClientUtilsPath + utilsMenuPath);
|
|
162
|
-
var destClientReduxReducersAllPath = resolve(destClientReduxPath + reduxReducersPath);
|
|
163
|
-
var destPublicHealthCheckPath = resolve(destPublicPath + slbHealthCheckPath);
|
|
164
|
-
var destPackagePath = resolve(destFolder + packagePath);
|
|
165
|
-
var destServerRestPath = resolve(destServerPath + restPath);
|
|
166
|
-
var initFiles = function (dictionary, upgradeFlag) {
|
|
167
|
-
if (upgradeFlag === void 0) { upgradeFlag = false; }
|
|
168
|
-
if (isLocal) {
|
|
169
|
-
upgradeFlag = false;
|
|
170
|
-
}
|
|
171
|
-
var newDestFolder = '';
|
|
172
|
-
if (dictionary !== '') {
|
|
173
|
-
newDestFolder = resolve(destFolder + '/' + dictionary);
|
|
174
|
-
mkdirSync(newDestFolder);
|
|
175
|
-
}
|
|
176
|
-
console.log('initFiles', dictionary === '' ? '.' : dictionary, upgradeFlag);
|
|
177
|
-
var initClientFiles = function () {
|
|
178
|
-
var clientReduxPath = reduxPath;
|
|
179
|
-
var clientReduxReducersPath = reduxReducersPath;
|
|
180
|
-
var clientReduxStorePath = '/store.ts';
|
|
181
|
-
var clientStyledPath = styledPath;
|
|
182
|
-
var clientStyledCommonPath = '/common.ts';
|
|
183
|
-
var clientStyledLayoutPath = styledLayoutPath;
|
|
184
|
-
var clientStyledLayoutIndexPath = '/index.ts';
|
|
185
|
-
var clientUtilsPath = utilsPath;
|
|
186
|
-
var clientUtilsCommonPath = '/common.ts';
|
|
187
|
-
var clientUtilsFetchPath = '/fetch.ts';
|
|
188
|
-
var clientUtilsCookiePath = '/cookie.ts';
|
|
189
|
-
var
|
|
190
|
-
var
|
|
191
|
-
var
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
var
|
|
195
|
-
var
|
|
196
|
-
var
|
|
197
|
-
var
|
|
198
|
-
var
|
|
199
|
-
var
|
|
200
|
-
var
|
|
201
|
-
|
|
202
|
-
var
|
|
203
|
-
|
|
204
|
-
var
|
|
205
|
-
var
|
|
206
|
-
var
|
|
207
|
-
var
|
|
208
|
-
var
|
|
209
|
-
var
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
mkdirSync(
|
|
215
|
-
mkdirSync(
|
|
216
|
-
mkdirSync(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
var
|
|
223
|
-
var
|
|
224
|
-
var
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
mkdirSync(
|
|
229
|
-
mkdirSync(
|
|
230
|
-
mkdirSync(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
copyFileSync(
|
|
246
|
-
copyFileSync(
|
|
247
|
-
copyFileSync(
|
|
248
|
-
copyFileSync(
|
|
249
|
-
copyFileSync(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
var
|
|
258
|
-
var
|
|
259
|
-
var
|
|
260
|
-
var
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
mkdirSync(
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
var
|
|
347
|
-
var
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
var
|
|
362
|
-
var
|
|
363
|
-
var
|
|
364
|
-
var
|
|
365
|
-
var
|
|
366
|
-
var
|
|
367
|
-
var
|
|
368
|
-
var
|
|
369
|
-
var
|
|
370
|
-
var
|
|
371
|
-
var
|
|
372
|
-
var
|
|
373
|
-
var
|
|
374
|
-
var
|
|
375
|
-
var
|
|
376
|
-
var
|
|
377
|
-
var
|
|
378
|
-
var
|
|
379
|
-
var
|
|
380
|
-
var
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
mkdirSync(
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
var
|
|
455
|
-
var
|
|
456
|
-
var
|
|
457
|
-
|
|
458
|
-
copyFileSync(
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
var
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
mkdirSync(
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
var
|
|
471
|
-
var
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
var
|
|
479
|
-
var
|
|
480
|
-
|
|
481
|
-
mkdirSync(
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
var
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
var
|
|
496
|
-
mkdirSync(
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
});
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
controller +
|
|
562
|
-
firstUpperCase(action) +
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
'
|
|
598
|
-
|
|
599
|
-
'
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
{
|
|
691
|
-
from:
|
|
692
|
-
to: '
|
|
693
|
-
files: [
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.deleteFiles = exports.createFiles = exports.initFiles = void 0;
|
|
7
|
+
var fs_1 = __importDefault(require("fs"));
|
|
8
|
+
var path_1 = __importDefault(require("path"));
|
|
9
|
+
var shelljs_1 = __importDefault(require("shelljs"));
|
|
10
|
+
var db_1 = __importDefault(require("./server/db"));
|
|
11
|
+
var replace_1 = __importDefault(require("replace"));
|
|
12
|
+
var replace_in_file_1 = require("replace-in-file");
|
|
13
|
+
var resolve = path_1.default.resolve;
|
|
14
|
+
var getMysqlConfig = db_1.default.getMysqlConfig;
|
|
15
|
+
var mysqlOptions = getMysqlConfig().mysqlOptions;
|
|
16
|
+
var mysqlUser = mysqlOptions.user, mysqlPassword = mysqlOptions.password, mysqlHost = mysqlOptions.host, mysqlPort = mysqlOptions.port, mysqlDatabase = mysqlOptions.database;
|
|
17
|
+
var mkdirFlag = true;
|
|
18
|
+
var copyFileFlag = true;
|
|
19
|
+
var replaceFlag = true;
|
|
20
|
+
var replaceInFileFlag = true;
|
|
21
|
+
var rmdirFlag = true;
|
|
22
|
+
var rmfileFlag = true;
|
|
23
|
+
var firstUpperCase = function (word) {
|
|
24
|
+
return word.substring(0, 1).toUpperCase() + word.substring(1);
|
|
25
|
+
};
|
|
26
|
+
var mkdirSync = function (dirPath) {
|
|
27
|
+
if (mkdirFlag) {
|
|
28
|
+
if (!fs_1.default.existsSync(dirPath)) {
|
|
29
|
+
fs_1.default.mkdirSync(dirPath);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var rmFileSync = function (filePath) {
|
|
34
|
+
if (rmfileFlag) {
|
|
35
|
+
if (fs_1.default.existsSync(filePath)) {
|
|
36
|
+
fs_1.default.unlinkSync(filePath);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var rmdirSync = function (dirPath) {
|
|
41
|
+
if (rmdirFlag) {
|
|
42
|
+
if (fs_1.default.existsSync(dirPath)) {
|
|
43
|
+
var list = fs_1.default.readdirSync(dirPath);
|
|
44
|
+
list.forEach(function (item) {
|
|
45
|
+
var resolverPath = resolve(dirPath + '/' + item);
|
|
46
|
+
var stat = fs_1.default.statSync(resolverPath);
|
|
47
|
+
var isDir = stat.isDirectory();
|
|
48
|
+
var isFile = stat.isFile();
|
|
49
|
+
if (isDir) {
|
|
50
|
+
rmdirSync(resolverPath);
|
|
51
|
+
}
|
|
52
|
+
else if (isFile) {
|
|
53
|
+
rmFileSync(resolverPath);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
fs_1.default.rmdirSync(dirPath);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var copyFileSync = function (source, dest, upgradeFlag) {
|
|
61
|
+
if (upgradeFlag === void 0) { upgradeFlag = false; }
|
|
62
|
+
if (copyFileFlag) {
|
|
63
|
+
if (!upgradeFlag) {
|
|
64
|
+
if (!fs_1.default.existsSync(dest) && fs_1.default.existsSync(source)) {
|
|
65
|
+
fs_1.default.copyFileSync(source, dest);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
if (fs_1.default.existsSync(source)) {
|
|
70
|
+
fs_1.default.copyFileSync(source, dest);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
var handleReplace = function (_a) {
|
|
76
|
+
var regex = _a.regex, replacement = _a.replacement, paths = _a.paths;
|
|
77
|
+
if (replaceFlag) {
|
|
78
|
+
(0, replace_1.default)({
|
|
79
|
+
regex: regex,
|
|
80
|
+
replacement: replacement,
|
|
81
|
+
paths: paths,
|
|
82
|
+
recursive: true,
|
|
83
|
+
silent: true
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
var replaceInFileAll = function (array, index, callback) {
|
|
88
|
+
if (index === void 0) { index = 0; }
|
|
89
|
+
if (replaceInFileFlag) {
|
|
90
|
+
console.log('replaceInFileAll', index);
|
|
91
|
+
var arrayLen = array.length;
|
|
92
|
+
if (index < arrayLen) {
|
|
93
|
+
var item = array[index];
|
|
94
|
+
(0, replace_in_file_1.replaceInFile)(item, function (error, changedFiles) {
|
|
95
|
+
if (error) {
|
|
96
|
+
console.error('Error occurred:', error);
|
|
97
|
+
}
|
|
98
|
+
console.log('Modified files:', changedFiles);
|
|
99
|
+
replaceInFileAll(array, ++index, callback);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
return callback && callback();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
return callback && callback();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var sourceFolder = __dirname;
|
|
111
|
+
var destFolder = process.cwd();
|
|
112
|
+
var isLocal = sourceFolder === resolve(destFolder + '/lib');
|
|
113
|
+
var generationPath = '../generation';
|
|
114
|
+
var clientPathSource = '../client';
|
|
115
|
+
var clientPath = './client';
|
|
116
|
+
var serverPathSource = '../server';
|
|
117
|
+
var serverPath = './server';
|
|
118
|
+
var pagesPathSource = '../pages';
|
|
119
|
+
var pagesPath = './pages';
|
|
120
|
+
var publicPathSource = '../public';
|
|
121
|
+
var publicPath = './public';
|
|
122
|
+
var scriptsPathSource = '../scripts';
|
|
123
|
+
var scriptsPath = './scripts';
|
|
124
|
+
var reduxPath = '/redux';
|
|
125
|
+
var servicePath = '/service';
|
|
126
|
+
var styledPath = '/styled';
|
|
127
|
+
var styledLayoutPath = '/layout';
|
|
128
|
+
var utilsPath = '/utils';
|
|
129
|
+
var layoutPath = '/layout';
|
|
130
|
+
var modulesPath = '/modules';
|
|
131
|
+
var apisPath = '/apis';
|
|
132
|
+
var sqlPath = '/sql';
|
|
133
|
+
var utilsMenuPath = '/menu.tsx';
|
|
134
|
+
var reduxReducersPath = '/reducers.ts';
|
|
135
|
+
var slbHealthCheckPath = '/slbhealthcheck.html';
|
|
136
|
+
var packagePath = '/package.json';
|
|
137
|
+
var restPath = '/rest.js';
|
|
138
|
+
var sourceGenerationPath = path_1.default.join(sourceFolder, generationPath);
|
|
139
|
+
var sourceClientPath = path_1.default.join(sourceFolder, clientPathSource);
|
|
140
|
+
var sourceClientPathGeneration = path_1.default.join(sourceGenerationPath, clientPath);
|
|
141
|
+
var sourceServerPath = path_1.default.join(sourceFolder, serverPathSource);
|
|
142
|
+
var sourceServerPathGeneration = path_1.default.join(sourceGenerationPath, serverPath);
|
|
143
|
+
var sourcePagesPath = path_1.default.join(sourceFolder, pagesPathSource);
|
|
144
|
+
var sourcePublicPath = path_1.default.join(sourceFolder, publicPathSource);
|
|
145
|
+
var sourceScriptsPath = path_1.default.join(sourceFolder, scriptsPathSource);
|
|
146
|
+
var destClientPath = path_1.default.join(destFolder, clientPath);
|
|
147
|
+
var destClientReduxPath = resolve(destClientPath + reduxPath);
|
|
148
|
+
var destClientServicePath = resolve(destClientPath + servicePath);
|
|
149
|
+
var destClientStyledPath = resolve(destClientPath + styledPath);
|
|
150
|
+
var destClientStyledLayoutPath = resolve(destClientStyledPath + styledLayoutPath);
|
|
151
|
+
var destClientUtilsPath = resolve(destClientPath + utilsPath);
|
|
152
|
+
var destClientLayoutPath = resolve(destClientPath + layoutPath);
|
|
153
|
+
var destServerPath = path_1.default.join(destFolder, serverPath);
|
|
154
|
+
var destServerModulesPath = resolve(destServerPath + modulesPath);
|
|
155
|
+
var destServerApisPath = resolve(destServerPath + apisPath);
|
|
156
|
+
var destServerSqlPath = resolve(destServerPath + sqlPath);
|
|
157
|
+
var destServerUtilsPath = resolve(destServerPath + utilsPath);
|
|
158
|
+
var destPagesPath = path_1.default.join(destFolder, pagesPath);
|
|
159
|
+
var destPublicPath = path_1.default.join(destFolder, publicPath);
|
|
160
|
+
var destScriptsPath = path_1.default.join(destFolder, scriptsPath);
|
|
161
|
+
var destClientUtilsMenuPath = resolve(destClientUtilsPath + utilsMenuPath);
|
|
162
|
+
var destClientReduxReducersAllPath = resolve(destClientReduxPath + reduxReducersPath);
|
|
163
|
+
var destPublicHealthCheckPath = resolve(destPublicPath + slbHealthCheckPath);
|
|
164
|
+
var destPackagePath = resolve(destFolder + packagePath);
|
|
165
|
+
var destServerRestPath = resolve(destServerPath + restPath);
|
|
166
|
+
var initFiles = function (dictionary, upgradeFlag) {
|
|
167
|
+
if (upgradeFlag === void 0) { upgradeFlag = false; }
|
|
168
|
+
if (isLocal) {
|
|
169
|
+
upgradeFlag = false;
|
|
170
|
+
}
|
|
171
|
+
var newDestFolder = '';
|
|
172
|
+
if (dictionary !== '') {
|
|
173
|
+
newDestFolder = resolve(destFolder + '/' + dictionary);
|
|
174
|
+
mkdirSync(newDestFolder);
|
|
175
|
+
}
|
|
176
|
+
console.log('initFiles', dictionary === '' ? '.' : dictionary, upgradeFlag);
|
|
177
|
+
var initClientFiles = function () {
|
|
178
|
+
var clientReduxPath = reduxPath;
|
|
179
|
+
var clientReduxReducersPath = reduxReducersPath;
|
|
180
|
+
var clientReduxStorePath = '/store.ts';
|
|
181
|
+
var clientStyledPath = styledPath;
|
|
182
|
+
var clientStyledCommonPath = '/common.ts';
|
|
183
|
+
var clientStyledLayoutPath = styledLayoutPath;
|
|
184
|
+
var clientStyledLayoutIndexPath = '/index.ts';
|
|
185
|
+
var clientUtilsPath = utilsPath;
|
|
186
|
+
var clientUtilsCommonPath = '/common.ts';
|
|
187
|
+
var clientUtilsFetchPath = '/fetch.ts';
|
|
188
|
+
var clientUtilsCookiePath = '/cookie.ts';
|
|
189
|
+
var clientUtilsSsoPath = '/sso.ts';
|
|
190
|
+
var clientUtilsMenuPath = utilsMenuPath;
|
|
191
|
+
var clientLayoutPath = layoutPath;
|
|
192
|
+
var clientLayoutIndexPath = '/index.tsx';
|
|
193
|
+
// 仍旧使用 generation/client/redux/reducers.ts
|
|
194
|
+
var sourceClientReduxReducersAllPath = resolve(sourceClientPathGeneration + clientReduxPath + clientReduxReducersPath);
|
|
195
|
+
var sourceClientReduxStorePath = resolve(sourceClientPath + clientReduxPath + clientReduxStorePath);
|
|
196
|
+
var sourceClientLayoutIndexPath = resolve(sourceClientPath + clientLayoutPath + clientLayoutIndexPath);
|
|
197
|
+
var sourceClientStyledLayoutIndexPath = resolve(sourceClientPath + clientStyledPath + clientStyledLayoutPath + clientStyledLayoutIndexPath);
|
|
198
|
+
var sourceClientStyledCommonPath = resolve(sourceClientPath + clientStyledPath + clientStyledCommonPath);
|
|
199
|
+
var sourceClientUtilsCommonPath = resolve(sourceClientPath + clientUtilsPath + clientUtilsCommonPath);
|
|
200
|
+
var sourceClientUtilsFetchPath = resolve(sourceClientPath + clientUtilsPath + clientUtilsFetchPath);
|
|
201
|
+
var sourceClientUtilsCookiePath = resolve(sourceClientPath + clientUtilsPath + clientUtilsCookiePath);
|
|
202
|
+
var sourceClientUtilsSsoPath = resolve(sourceClientPath + clientUtilsPath + clientUtilsSsoPath);
|
|
203
|
+
// 仍旧使用 generation/client/utils/menu.tsx
|
|
204
|
+
var sourceClientUtilsMenuPath = resolve(sourceClientPathGeneration + clientUtilsPath + clientUtilsMenuPath);
|
|
205
|
+
var destClientReduxStorePath = resolve(destClientReduxPath + clientReduxStorePath);
|
|
206
|
+
var destClientLayoutIndexPath = resolve(destClientLayoutPath + clientLayoutIndexPath);
|
|
207
|
+
var destClientStyledLayoutIndexPath = resolve(destClientStyledLayoutPath + clientStyledLayoutIndexPath);
|
|
208
|
+
var destClientStyledCommonPath = resolve(destClientStyledPath + clientStyledCommonPath);
|
|
209
|
+
var destClientUtilsCommonPath = resolve(destClientUtilsPath + clientUtilsCommonPath);
|
|
210
|
+
var destClientUtilsFetchPath = resolve(destClientUtilsPath + clientUtilsFetchPath);
|
|
211
|
+
var destClientUtilsCookiePath = resolve(destClientUtilsPath + clientUtilsCookiePath);
|
|
212
|
+
var destClientUtilsSsoPath = resolve(destClientUtilsPath + clientUtilsSsoPath);
|
|
213
|
+
if (dictionary === '') {
|
|
214
|
+
mkdirSync(destClientPath);
|
|
215
|
+
mkdirSync(destClientReduxPath);
|
|
216
|
+
mkdirSync(destClientStyledPath);
|
|
217
|
+
mkdirSync(destClientStyledLayoutPath);
|
|
218
|
+
mkdirSync(destClientUtilsPath);
|
|
219
|
+
mkdirSync(destClientLayoutPath);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
var newDestClientPath = path_1.default.join(newDestFolder, clientPath);
|
|
223
|
+
var newDestClientReduxPath = resolve(newDestClientPath + clientReduxPath);
|
|
224
|
+
var newDestClientStyledPath = resolve(newDestClientPath + clientStyledPath);
|
|
225
|
+
var newDestClientStyledLayoutPath = resolve(newDestClientStyledPath + clientStyledLayoutPath);
|
|
226
|
+
var newDestClientUtilsPath = resolve(newDestClientPath + clientUtilsPath);
|
|
227
|
+
var newDestClientLayoutPath = resolve(newDestClientPath + clientLayoutPath);
|
|
228
|
+
mkdirSync(newDestClientPath);
|
|
229
|
+
mkdirSync(newDestClientReduxPath);
|
|
230
|
+
mkdirSync(newDestClientStyledPath);
|
|
231
|
+
mkdirSync(newDestClientUtilsPath);
|
|
232
|
+
mkdirSync(newDestClientLayoutPath);
|
|
233
|
+
mkdirSync(newDestClientStyledLayoutPath);
|
|
234
|
+
destClientReduxReducersAllPath = resolve(newDestClientReduxPath + clientReduxReducersPath);
|
|
235
|
+
destClientReduxStorePath = resolve(newDestClientReduxPath + clientReduxStorePath);
|
|
236
|
+
destClientLayoutIndexPath = resolve(newDestClientLayoutPath + clientLayoutIndexPath);
|
|
237
|
+
destClientStyledLayoutIndexPath = resolve(newDestClientStyledLayoutPath + clientStyledLayoutIndexPath);
|
|
238
|
+
destClientStyledCommonPath = resolve(newDestClientStyledPath + clientStyledCommonPath);
|
|
239
|
+
destClientUtilsCommonPath = resolve(newDestClientUtilsPath + clientUtilsCommonPath);
|
|
240
|
+
destClientUtilsFetchPath = resolve(newDestClientUtilsPath + clientUtilsFetchPath);
|
|
241
|
+
destClientUtilsCookiePath = resolve(newDestClientUtilsPath + clientUtilsCookiePath);
|
|
242
|
+
destClientUtilsSsoPath = resolve(newDestClientUtilsPath + clientUtilsSsoPath);
|
|
243
|
+
destClientUtilsMenuPath = resolve(newDestClientUtilsPath + clientUtilsMenuPath);
|
|
244
|
+
}
|
|
245
|
+
copyFileSync(sourceClientReduxStorePath, destClientReduxStorePath, upgradeFlag);
|
|
246
|
+
copyFileSync(sourceClientStyledCommonPath, destClientStyledCommonPath, upgradeFlag);
|
|
247
|
+
copyFileSync(sourceClientStyledLayoutIndexPath, destClientStyledLayoutIndexPath, upgradeFlag);
|
|
248
|
+
copyFileSync(sourceClientUtilsCookiePath, destClientUtilsCookiePath, upgradeFlag);
|
|
249
|
+
copyFileSync(sourceClientUtilsSsoPath, destClientUtilsSsoPath, upgradeFlag);
|
|
250
|
+
copyFileSync(sourceClientUtilsCommonPath, destClientUtilsCommonPath, upgradeFlag);
|
|
251
|
+
copyFileSync(sourceClientUtilsFetchPath, destClientUtilsFetchPath, upgradeFlag);
|
|
252
|
+
copyFileSync(sourceClientLayoutIndexPath, destClientLayoutIndexPath, upgradeFlag);
|
|
253
|
+
copyFileSync(sourceClientReduxReducersAllPath, destClientReduxReducersAllPath);
|
|
254
|
+
copyFileSync(sourceClientUtilsMenuPath, destClientUtilsMenuPath);
|
|
255
|
+
};
|
|
256
|
+
var initPagesFiles = function () {
|
|
257
|
+
var pageIndexPath = '/index.tsx';
|
|
258
|
+
var pageAppPath = '/_app.tsx';
|
|
259
|
+
var pageDocumentPath = '/_document.tsx';
|
|
260
|
+
var pageLoginPath = '/login.tsx';
|
|
261
|
+
var sourcePagesIndexPath = resolve(sourcePagesPath + pageIndexPath);
|
|
262
|
+
var sourcePagesAppPath = resolve(sourcePagesPath + pageAppPath);
|
|
263
|
+
var sourcePagesDocumentPath = resolve(sourcePagesPath + pageDocumentPath);
|
|
264
|
+
var sourcePagesLoginPath = resolve(sourcePagesPath + pageLoginPath);
|
|
265
|
+
var destPagesIndexPath = resolve(destPagesPath + pageIndexPath);
|
|
266
|
+
var destPagesAppPath = resolve(destPagesPath + pageAppPath);
|
|
267
|
+
var destPagesDocumentPath = resolve(destPagesPath + pageDocumentPath);
|
|
268
|
+
var destPagesLoginPath = resolve(destPagesPath + pageLoginPath);
|
|
269
|
+
if (dictionary === '') {
|
|
270
|
+
mkdirSync(destPagesPath);
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
var newDestPagesPath = path_1.default.join(newDestFolder, pagesPath);
|
|
274
|
+
mkdirSync(newDestPagesPath);
|
|
275
|
+
destPagesIndexPath = resolve(newDestPagesPath + pageIndexPath);
|
|
276
|
+
destPagesAppPath = resolve(newDestPagesPath + pageAppPath);
|
|
277
|
+
destPagesDocumentPath = resolve(newDestPagesPath + pageDocumentPath);
|
|
278
|
+
destPagesLoginPath = resolve(newDestPagesPath + pageLoginPath);
|
|
279
|
+
}
|
|
280
|
+
copyFileSync(sourcePagesIndexPath, destPagesIndexPath, upgradeFlag);
|
|
281
|
+
copyFileSync(sourcePagesAppPath, destPagesAppPath, upgradeFlag);
|
|
282
|
+
copyFileSync(sourcePagesDocumentPath, destPagesDocumentPath, upgradeFlag);
|
|
283
|
+
copyFileSync(sourcePagesLoginPath, destPagesLoginPath, upgradeFlag);
|
|
284
|
+
};
|
|
285
|
+
var initServerFiles = function () {
|
|
286
|
+
var serverRestPath = restPath;
|
|
287
|
+
var serverApisPath = apisPath;
|
|
288
|
+
var serverApisSsoPath = '/sso.js';
|
|
289
|
+
var serverUtilsPath = utilsPath;
|
|
290
|
+
var serverUtilsCommonPath = '/common.js';
|
|
291
|
+
// 仍旧使用 generation/server/rest.js
|
|
292
|
+
var sourceServerRestPath = resolve(sourceServerPathGeneration + serverRestPath);
|
|
293
|
+
// 仍旧使用 generation/server/utils/common.js
|
|
294
|
+
var sourceServerUtilsCommonPath = resolve(sourceServerPathGeneration + serverUtilsPath + serverUtilsCommonPath);
|
|
295
|
+
var sourceServerApisSsoPath = resolve(sourceServerPath + serverApisPath + serverApisSsoPath);
|
|
296
|
+
var destServerApisSsoPath = resolve(destServerApisPath + serverApisSsoPath);
|
|
297
|
+
var destServerUtilsCommonPath = resolve(destServerUtilsPath + serverUtilsCommonPath);
|
|
298
|
+
if (dictionary === '') {
|
|
299
|
+
mkdirSync(destServerPath);
|
|
300
|
+
mkdirSync(destServerApisPath);
|
|
301
|
+
mkdirSync(destServerUtilsPath);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
var newDestServerPath = path_1.default.join(newDestFolder, serverPath);
|
|
305
|
+
var newDestServerApisPath = resolve(newDestServerPath + serverApisPath);
|
|
306
|
+
var newDestServerUtilsPath = resolve(newDestServerPath + serverUtilsPath);
|
|
307
|
+
mkdirSync(newDestServerPath);
|
|
308
|
+
mkdirSync(newDestServerApisPath);
|
|
309
|
+
mkdirSync(newDestServerUtilsPath);
|
|
310
|
+
destServerRestPath = resolve(newDestServerPath + serverRestPath);
|
|
311
|
+
destServerApisSsoPath = resolve(newDestServerApisPath + serverApisSsoPath);
|
|
312
|
+
destServerUtilsCommonPath = resolve(newDestServerUtilsPath + serverUtilsCommonPath);
|
|
313
|
+
}
|
|
314
|
+
copyFileSync(sourceServerApisSsoPath, destServerApisSsoPath, upgradeFlag);
|
|
315
|
+
copyFileSync(sourceServerUtilsCommonPath, destServerUtilsCommonPath, upgradeFlag);
|
|
316
|
+
copyFileSync(sourceServerRestPath, destServerRestPath);
|
|
317
|
+
};
|
|
318
|
+
var initPublicFiles = function () {
|
|
319
|
+
var publicImagesPath = '/images';
|
|
320
|
+
var publicImagesZhizuotuPath = '/zhizuotu_1.png';
|
|
321
|
+
var publicSlbHealthcheckPath = slbHealthCheckPath;
|
|
322
|
+
var destPublicImagesPath = resolve(destPublicPath + publicImagesPath);
|
|
323
|
+
var sourcePublicImages1Path = resolve(sourcePublicPath + publicImagesPath + publicImagesZhizuotuPath);
|
|
324
|
+
var sourcePublicHealthCheckPath = resolve(sourcePublicPath + publicSlbHealthcheckPath);
|
|
325
|
+
var destPublicImages1Path = resolve(destPublicImagesPath + publicImagesZhizuotuPath);
|
|
326
|
+
if (dictionary === '') {
|
|
327
|
+
mkdirSync(destPublicPath);
|
|
328
|
+
mkdirSync(destPublicImagesPath);
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
var newDestPublicPath = path_1.default.join(newDestFolder, publicPath);
|
|
332
|
+
var newDestPublicImagesPath = resolve(newDestPublicPath + publicImagesPath);
|
|
333
|
+
mkdirSync(newDestPublicPath);
|
|
334
|
+
mkdirSync(newDestPublicImagesPath);
|
|
335
|
+
destPublicHealthCheckPath = resolve(newDestPublicPath + publicSlbHealthcheckPath);
|
|
336
|
+
destPublicImages1Path = resolve(newDestPublicImagesPath + publicImagesZhizuotuPath);
|
|
337
|
+
}
|
|
338
|
+
copyFileSync(sourcePublicHealthCheckPath, destPublicHealthCheckPath, upgradeFlag);
|
|
339
|
+
copyFileSync(sourcePublicImages1Path, destPublicImages1Path, upgradeFlag);
|
|
340
|
+
};
|
|
341
|
+
var initScriptsFiles = function () {
|
|
342
|
+
var scriptsStartupPath = '/startup.sh';
|
|
343
|
+
var scriptsShutdownPath = '/shutdown.sh';
|
|
344
|
+
var sourceScriptsStartupPath = resolve(sourceScriptsPath + scriptsStartupPath);
|
|
345
|
+
var sourceScriptsShutdownPath = resolve(sourceScriptsPath + scriptsShutdownPath);
|
|
346
|
+
var destScriptsStartupPath = resolve(destScriptsPath + scriptsStartupPath);
|
|
347
|
+
var destScriptsShutdownPath = resolve(destScriptsPath + scriptsShutdownPath);
|
|
348
|
+
if (dictionary === '') {
|
|
349
|
+
mkdirSync(destScriptsPath);
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
var newDestScriptsPath = path_1.default.join(newDestFolder, scriptsPath);
|
|
353
|
+
mkdirSync(newDestScriptsPath);
|
|
354
|
+
destScriptsStartupPath = resolve(newDestScriptsPath + scriptsStartupPath);
|
|
355
|
+
destScriptsShutdownPath = resolve(newDestScriptsPath + scriptsShutdownPath);
|
|
356
|
+
}
|
|
357
|
+
copyFileSync(sourceScriptsStartupPath, destScriptsStartupPath);
|
|
358
|
+
copyFileSync(sourceScriptsShutdownPath, destScriptsShutdownPath);
|
|
359
|
+
};
|
|
360
|
+
var initRootFiles = function () {
|
|
361
|
+
var rootNextConfigPath = '/next.config.js';
|
|
362
|
+
var rootMysqlConfigPath = '/mysql.config.js';
|
|
363
|
+
var rootProjectConfigPath = '/project.config.js';
|
|
364
|
+
var rootPackagePath = packagePath;
|
|
365
|
+
var rootTsconfigPath = '/tsconfig.json';
|
|
366
|
+
var rootBabelrcPath = '/.babelrc';
|
|
367
|
+
var rootGitignorePathSource = '/gitignore';
|
|
368
|
+
var rootGitignorePath = '/.gitignore';
|
|
369
|
+
var rootNextEnvPathSource = '../next-env.d.ts';
|
|
370
|
+
var rootNextEnvPath = '/next-env.d.ts';
|
|
371
|
+
var rootReadmePath = '/README.md';
|
|
372
|
+
var rootAppConfigPathSource = '../app.config.js';
|
|
373
|
+
var rootAppConfigPath = '/app.config.js';
|
|
374
|
+
var rootAppPath = '/app.js';
|
|
375
|
+
var sourceNextConfigPath = resolve(sourceGenerationPath + rootNextConfigPath);
|
|
376
|
+
var sourceMysqlConfigPath = resolve(sourceGenerationPath + rootMysqlConfigPath);
|
|
377
|
+
var sourceProjectConfigPath = resolve(sourceGenerationPath + rootProjectConfigPath);
|
|
378
|
+
var sourceTsConfigPath = resolve(sourceGenerationPath + rootTsconfigPath);
|
|
379
|
+
var sourceBabelrcPath = path_1.default.join(sourceGenerationPath, rootBabelrcPath);
|
|
380
|
+
var sourceGitignorePath = resolve(sourceGenerationPath + rootGitignorePathSource);
|
|
381
|
+
var sourceNextEnvPath = path_1.default.join(sourceFolder, rootNextEnvPathSource);
|
|
382
|
+
var sourceReadmePath = resolve(sourceGenerationPath + rootReadmePath);
|
|
383
|
+
var sourceAppConfigPath = path_1.default.join(sourceFolder, rootAppConfigPathSource);
|
|
384
|
+
var sourceAppath = resolve(sourceGenerationPath + rootAppPath);
|
|
385
|
+
var sourcePackagePath = resolve(sourceGenerationPath + rootPackagePath);
|
|
386
|
+
var destNextConfigPath = resolve(destFolder + rootNextConfigPath);
|
|
387
|
+
var destMysqlConfigPath = resolve(destFolder + rootMysqlConfigPath);
|
|
388
|
+
var destProjectConfigPath = resolve(destFolder + rootProjectConfigPath);
|
|
389
|
+
var destTsConfigPath = resolve(destFolder + rootTsconfigPath);
|
|
390
|
+
var destBabelrcPath = resolve(destFolder + rootBabelrcPath);
|
|
391
|
+
var destGitignorePath = resolve(destFolder + rootGitignorePath);
|
|
392
|
+
var destNextEnvPath = resolve(destFolder + rootNextEnvPath);
|
|
393
|
+
var destReadmePath = resolve(destFolder + rootReadmePath);
|
|
394
|
+
var destAppConfigPath = resolve(destFolder + rootAppConfigPath);
|
|
395
|
+
var destAppath = resolve(destFolder + rootAppPath);
|
|
396
|
+
if (dictionary !== '') {
|
|
397
|
+
destNextConfigPath = resolve(newDestFolder + rootNextConfigPath);
|
|
398
|
+
destMysqlConfigPath = resolve(newDestFolder + rootMysqlConfigPath);
|
|
399
|
+
destProjectConfigPath = resolve(newDestFolder + rootProjectConfigPath);
|
|
400
|
+
destTsConfigPath = resolve(newDestFolder + rootTsconfigPath);
|
|
401
|
+
destBabelrcPath = resolve(newDestFolder + rootBabelrcPath);
|
|
402
|
+
destGitignorePath = resolve(newDestFolder + rootGitignorePath);
|
|
403
|
+
destNextEnvPath = resolve(newDestFolder + rootNextEnvPath);
|
|
404
|
+
destReadmePath = resolve(newDestFolder + rootReadmePath);
|
|
405
|
+
destAppConfigPath = resolve(newDestFolder + rootAppConfigPath);
|
|
406
|
+
destAppath = resolve(newDestFolder + rootAppPath);
|
|
407
|
+
destPackagePath = resolve(newDestFolder + rootPackagePath);
|
|
408
|
+
}
|
|
409
|
+
copyFileSync(sourceNextConfigPath, destNextConfigPath, upgradeFlag);
|
|
410
|
+
copyFileSync(sourceMysqlConfigPath, destMysqlConfigPath, upgradeFlag);
|
|
411
|
+
copyFileSync(sourceProjectConfigPath, destProjectConfigPath, upgradeFlag);
|
|
412
|
+
copyFileSync(sourcePackagePath, destPackagePath, upgradeFlag);
|
|
413
|
+
copyFileSync(sourceTsConfigPath, destTsConfigPath);
|
|
414
|
+
copyFileSync(sourceBabelrcPath, destBabelrcPath);
|
|
415
|
+
copyFileSync(sourceGitignorePath, destGitignorePath);
|
|
416
|
+
copyFileSync(sourceNextEnvPath, destNextEnvPath);
|
|
417
|
+
copyFileSync(sourceReadmePath, destReadmePath);
|
|
418
|
+
copyFileSync(sourceAppConfigPath, destAppConfigPath);
|
|
419
|
+
copyFileSync(sourceAppath, destAppath);
|
|
420
|
+
};
|
|
421
|
+
initClientFiles();
|
|
422
|
+
initPagesFiles();
|
|
423
|
+
initServerFiles();
|
|
424
|
+
initPublicFiles();
|
|
425
|
+
initScriptsFiles();
|
|
426
|
+
initRootFiles();
|
|
427
|
+
if (!isLocal && !upgradeFlag) {
|
|
428
|
+
if (dictionary !== '') {
|
|
429
|
+
shelljs_1.default.sed('-i', eval('/nsgm-cli-project/'), dictionary + '-project', destPackagePath);
|
|
430
|
+
shelljs_1.default.sed('-i', eval('/NSGM-CLI/'), dictionary, destPublicHealthCheckPath);
|
|
431
|
+
shelljs_1.default.exec('cd ' + dictionary + ' && npm install --save nsgm-cli');
|
|
432
|
+
shelljs_1.default.exec('cd ' + dictionary + ' && npm install --save-dev @types/node');
|
|
433
|
+
shelljs_1.default.exec('cd ' + dictionary + ' && npm install --save-dev @types/react@18.0.1');
|
|
434
|
+
shelljs_1.default.exec('cd ' + dictionary + ' && npm install --save-dev @types/lodash');
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
shelljs_1.default.sed('-i', eval('/nsgm-cli-project/'), path_1.default.basename(destFolder) + '-project', destPackagePath);
|
|
438
|
+
shelljs_1.default.sed('-i', eval('/NSGM-CLI/'), path_1.default.basename(destFolder), destPublicHealthCheckPath);
|
|
439
|
+
shelljs_1.default.exec('npm install --save nsgm-cli');
|
|
440
|
+
shelljs_1.default.exec('npm install --save-dev @types/node');
|
|
441
|
+
shelljs_1.default.exec('npm install --save-dev @types/react@18.0.1');
|
|
442
|
+
shelljs_1.default.exec('npm install --save-dev @types/lodash');
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
console.log('initFiles finished');
|
|
446
|
+
};
|
|
447
|
+
exports.initFiles = initFiles;
|
|
448
|
+
var createFiles = function (controller, action) {
|
|
449
|
+
console.log('createFiles', sourceFolder, destFolder, isLocal, controller, action);
|
|
450
|
+
mkdirSync(destClientPath);
|
|
451
|
+
mkdirSync(destServerPath);
|
|
452
|
+
mkdirSync(destPagesPath);
|
|
453
|
+
// pages
|
|
454
|
+
var sourcePagesActionPath = resolve(sourcePagesPath + '/template/manage.tsx');
|
|
455
|
+
var destPagesControllerPath = resolve(destPagesPath + '/' + controller);
|
|
456
|
+
var destPagesActionPath = resolve(destPagesControllerPath + '/' + action + '.tsx');
|
|
457
|
+
mkdirSync(destPagesControllerPath);
|
|
458
|
+
copyFileSync(sourcePagesActionPath, destPagesActionPath);
|
|
459
|
+
console.log('pages finished');
|
|
460
|
+
// client redux
|
|
461
|
+
var destClientReduxControllerPath = resolve(destClientReduxPath + '/' + controller);
|
|
462
|
+
var destClientReduxControllerActionPath = resolve(destClientReduxControllerPath + '/' + action);
|
|
463
|
+
mkdirSync(destClientReduxPath);
|
|
464
|
+
mkdirSync(destClientReduxControllerPath);
|
|
465
|
+
mkdirSync(destClientReduxControllerActionPath);
|
|
466
|
+
var sourceClientReduxActionsPath = resolve(sourceClientPath + '/redux/template/manage/actions.ts');
|
|
467
|
+
var sourceClientReduxReducersPath = resolve(sourceClientPath + '/redux/template/manage/reducers.ts');
|
|
468
|
+
var sourceClientReduxTypesPath = resolve(sourceClientPath + '/redux/template/manage/types.ts');
|
|
469
|
+
var destClientReduxActionsPath = resolve(destClientReduxControllerActionPath + '/actions.ts');
|
|
470
|
+
var destClientReduxReducersPath = resolve(destClientReduxControllerActionPath + '/reducers.ts');
|
|
471
|
+
var destClientReduxTypesPath = resolve(destClientReduxControllerActionPath + '/types.ts');
|
|
472
|
+
copyFileSync(sourceClientReduxActionsPath, destClientReduxActionsPath);
|
|
473
|
+
copyFileSync(sourceClientReduxReducersPath, destClientReduxReducersPath);
|
|
474
|
+
copyFileSync(sourceClientReduxTypesPath, destClientReduxTypesPath);
|
|
475
|
+
console.log('client redux finished');
|
|
476
|
+
// client service
|
|
477
|
+
var sourceClientActionPath = resolve(sourceClientPath + '/service/template/manage.ts');
|
|
478
|
+
var destClientServiceControllerPath = resolve(destClientServicePath + '/' + controller);
|
|
479
|
+
var destClientActionPath = resolve(destClientServiceControllerPath + '/' + action + '.ts');
|
|
480
|
+
mkdirSync(destClientServicePath);
|
|
481
|
+
mkdirSync(destClientServiceControllerPath);
|
|
482
|
+
copyFileSync(sourceClientActionPath, destClientActionPath);
|
|
483
|
+
console.log('client service finished');
|
|
484
|
+
// client styled
|
|
485
|
+
var sourceClientStyledActionPath = resolve(sourceClientPath + '/styled/template/manage.ts');
|
|
486
|
+
var destClientStyledControllerPath = resolve(destClientStyledPath + '/' + controller);
|
|
487
|
+
mkdirSync(destClientStyledPath);
|
|
488
|
+
mkdirSync(destClientStyledControllerPath);
|
|
489
|
+
var destClientStyledActionPath = resolve(destClientStyledControllerPath + '/' + action + '.ts');
|
|
490
|
+
copyFileSync(sourceClientStyledActionPath, destClientStyledActionPath);
|
|
491
|
+
console.log('client styled finished');
|
|
492
|
+
// server modules
|
|
493
|
+
var sourceServerModulesResolverPath = resolve(sourceServerPath + '/modules/template/resolver.js');
|
|
494
|
+
var sourceServerModulesSchemaPath = resolve(sourceServerPath + '/modules/template/schema.js');
|
|
495
|
+
var destServerModulesControllerPath = resolve(destServerModulesPath + '/' + controller);
|
|
496
|
+
mkdirSync(destServerModulesPath);
|
|
497
|
+
mkdirSync(destServerModulesControllerPath);
|
|
498
|
+
var destServerModulesResolverPath = resolve(destServerModulesControllerPath + '/resolver.js');
|
|
499
|
+
var destServerModulesSchemaPath = resolve(destServerModulesControllerPath + '/schema.js');
|
|
500
|
+
copyFileSync(sourceServerModulesResolverPath, destServerModulesResolverPath);
|
|
501
|
+
copyFileSync(sourceServerModulesSchemaPath, destServerModulesSchemaPath);
|
|
502
|
+
console.log('server modules finished');
|
|
503
|
+
// server apis
|
|
504
|
+
var sourceServerApisControllerPath = resolve(sourceServerPath + '/apis/template.js');
|
|
505
|
+
mkdirSync(destServerApisPath);
|
|
506
|
+
var destServerApisControllerPath = resolve(destServerApisPath + '/' + controller + '.js');
|
|
507
|
+
copyFileSync(sourceServerApisControllerPath, destServerApisControllerPath);
|
|
508
|
+
console.log('server apis finished');
|
|
509
|
+
// server sql
|
|
510
|
+
var sourceServerSqlControllerPath = resolve(sourceServerPath + '/sql/template.sql');
|
|
511
|
+
mkdirSync(destServerSqlPath);
|
|
512
|
+
var destServerSqlControllerPath = resolve(destServerSqlPath + '/' + controller + '.sql');
|
|
513
|
+
copyFileSync(sourceServerSqlControllerPath, destServerSqlControllerPath);
|
|
514
|
+
console.log('server sql finished');
|
|
515
|
+
// replace dest files
|
|
516
|
+
handleReplace({
|
|
517
|
+
regex: 'template',
|
|
518
|
+
replacement: controller,
|
|
519
|
+
paths: [
|
|
520
|
+
destPagesActionPath,
|
|
521
|
+
destClientActionPath,
|
|
522
|
+
destClientReduxActionsPath,
|
|
523
|
+
destClientReduxReducersPath,
|
|
524
|
+
destServerModulesResolverPath,
|
|
525
|
+
destServerModulesSchemaPath,
|
|
526
|
+
destServerApisControllerPath
|
|
527
|
+
]
|
|
528
|
+
});
|
|
529
|
+
handleReplace({
|
|
530
|
+
regex: 'Template',
|
|
531
|
+
replacement: firstUpperCase(controller),
|
|
532
|
+
paths: [
|
|
533
|
+
destPagesActionPath,
|
|
534
|
+
destClientActionPath,
|
|
535
|
+
destClientReduxActionsPath,
|
|
536
|
+
destServerModulesSchemaPath,
|
|
537
|
+
destServerApisControllerPath
|
|
538
|
+
]
|
|
539
|
+
});
|
|
540
|
+
handleReplace({
|
|
541
|
+
regex: 'TEMPLATE',
|
|
542
|
+
replacement: controller.toUpperCase(),
|
|
543
|
+
paths: [destClientReduxActionsPath, destClientReduxReducersPath, destClientReduxTypesPath]
|
|
544
|
+
});
|
|
545
|
+
handleReplace({
|
|
546
|
+
regex: 'manage',
|
|
547
|
+
replacement: action,
|
|
548
|
+
paths: [destPagesActionPath, destClientReduxActionsPath]
|
|
549
|
+
});
|
|
550
|
+
handleReplace({
|
|
551
|
+
regex: 'Manage',
|
|
552
|
+
replacement: firstUpperCase(action),
|
|
553
|
+
paths: [destPagesActionPath, destClientReduxReducersPath]
|
|
554
|
+
});
|
|
555
|
+
console.log('replace dest files finished');
|
|
556
|
+
// special replace dest files
|
|
557
|
+
var optionsArr = [
|
|
558
|
+
{
|
|
559
|
+
from: /\n\s*\n/,
|
|
560
|
+
to: '\nimport { ' +
|
|
561
|
+
controller +
|
|
562
|
+
firstUpperCase(action) +
|
|
563
|
+
"Reducer } from './" +
|
|
564
|
+
controller +
|
|
565
|
+
'/' +
|
|
566
|
+
action +
|
|
567
|
+
"/reducers'\n\n",
|
|
568
|
+
files: [destClientReduxReducersAllPath]
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
from: /Reducer,\s*\n/,
|
|
572
|
+
to: 'Reducer,\n ' +
|
|
573
|
+
controller +
|
|
574
|
+
firstUpperCase(action) +
|
|
575
|
+
': ' +
|
|
576
|
+
controller +
|
|
577
|
+
firstUpperCase(action) +
|
|
578
|
+
'Reducer,\n',
|
|
579
|
+
files: [destClientReduxReducersAllPath]
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
from: /'(.\/apis\/template.*?)'\)\s*\n/,
|
|
583
|
+
to: "'./apis/template')\nconst " + controller + " = require('./apis/" + controller + "')\n",
|
|
584
|
+
files: [destServerRestPath]
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
from: /template\)\s*\n/,
|
|
588
|
+
to: "template)\nrouter.use('/" + controller + "', " + controller + ')\n',
|
|
589
|
+
files: [destServerRestPath]
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
from: /null\s*\n/,
|
|
593
|
+
to: 'null\n },\n {\n // ' +
|
|
594
|
+
controller +
|
|
595
|
+
'_' +
|
|
596
|
+
action +
|
|
597
|
+
"_start\n key: (++key).toString(),\n text: '" +
|
|
598
|
+
controller +
|
|
599
|
+
"',\n url: '/" +
|
|
600
|
+
controller +
|
|
601
|
+
'/' +
|
|
602
|
+
action +
|
|
603
|
+
"',\n icon: <SolutionOutlined rev={undefined} />,\n " +
|
|
604
|
+
"subMenus: [\n {\n key: key + '_1',\n text: '" +
|
|
605
|
+
action +
|
|
606
|
+
"',\n url: '/" +
|
|
607
|
+
controller +
|
|
608
|
+
'/' +
|
|
609
|
+
action +
|
|
610
|
+
"'\n }\n ]\n // " +
|
|
611
|
+
controller +
|
|
612
|
+
'_' +
|
|
613
|
+
action +
|
|
614
|
+
'_end\n',
|
|
615
|
+
files: [destClientUtilsMenuPath]
|
|
616
|
+
}
|
|
617
|
+
];
|
|
618
|
+
if (isLocal) {
|
|
619
|
+
optionsArr.push({
|
|
620
|
+
from: /'nsgm-cli'\)/,
|
|
621
|
+
to: "'../../../index')",
|
|
622
|
+
files: [destServerModulesResolverPath]
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
shelljs_1.default.sed('-i', eval('/.*' + controller + firstUpperCase(action) + 'Reducer.*/'), '', destClientReduxReducersAllPath);
|
|
626
|
+
shelljs_1.default.sed('-i', eval('/.*' + controller + '.*/'), '', destServerRestPath);
|
|
627
|
+
shelljs_1.default.sed('-i', eval('/template/'), controller, destServerSqlControllerPath);
|
|
628
|
+
shelljs_1.default.sed('-i', eval('/crm_demo/'), mysqlDatabase, destServerSqlControllerPath);
|
|
629
|
+
shelljs_1.default.exec('mysql -u' +
|
|
630
|
+
mysqlUser +
|
|
631
|
+
' -p' +
|
|
632
|
+
mysqlPassword +
|
|
633
|
+
' -h' +
|
|
634
|
+
mysqlHost +
|
|
635
|
+
' -P' +
|
|
636
|
+
mysqlPort +
|
|
637
|
+
' < ' +
|
|
638
|
+
destServerSqlControllerPath);
|
|
639
|
+
setTimeout(function () {
|
|
640
|
+
replaceInFileAll(optionsArr, 0, function () {
|
|
641
|
+
console.log('special replace dest files finished');
|
|
642
|
+
});
|
|
643
|
+
}, 1000);
|
|
644
|
+
};
|
|
645
|
+
exports.createFiles = createFiles;
|
|
646
|
+
var deleteFiles = function (controller, action, deleteDBFlag) {
|
|
647
|
+
if (deleteDBFlag === void 0) { deleteDBFlag = false; }
|
|
648
|
+
console.log('deleteFiles', sourceFolder, destFolder, isLocal, controller, action, deleteDBFlag);
|
|
649
|
+
// pages
|
|
650
|
+
var destPagesControllerPath = resolve(destPagesPath + '/' + controller);
|
|
651
|
+
// client redux
|
|
652
|
+
var destClientReduxControllerPath = resolve(destClientReduxPath + '/' + controller);
|
|
653
|
+
// client service
|
|
654
|
+
var destClientServiceControllerPath = resolve(destClientServicePath + '/' + controller);
|
|
655
|
+
// client styled
|
|
656
|
+
var destClientStyledControllerPath = resolve(destClientStyledPath + '/' + controller);
|
|
657
|
+
// server modules
|
|
658
|
+
var destServerModulesControllerPath = resolve(destServerModulesPath + '/' + controller);
|
|
659
|
+
// server apis
|
|
660
|
+
var destServerApisControllerPath = resolve(destServerApisPath + '/' + controller + '.js');
|
|
661
|
+
// server sql
|
|
662
|
+
var destServerSqlControllerPath = resolve(destServerSqlPath + '/' + controller + '.sql');
|
|
663
|
+
if (action === 'all') {
|
|
664
|
+
rmdirSync(destPagesControllerPath);
|
|
665
|
+
rmdirSync(destClientReduxControllerPath);
|
|
666
|
+
rmdirSync(destClientServiceControllerPath);
|
|
667
|
+
rmdirSync(destClientStyledControllerPath);
|
|
668
|
+
rmdirSync(destServerModulesControllerPath);
|
|
669
|
+
rmFileSync(destServerApisControllerPath);
|
|
670
|
+
shelljs_1.default.sed('-i', eval('/.*' + controller + '.*' + 'Reducer.*/'), '', destClientReduxReducersAllPath);
|
|
671
|
+
shelljs_1.default.sed('-i', eval('/.*' + controller + '.*/'), '', destServerRestPath);
|
|
672
|
+
shelljs_1.default.sed('-i', eval('/.*' + controller + '_.*_start.*/'), ' /*', destClientUtilsMenuPath);
|
|
673
|
+
shelljs_1.default.sed('-i', eval('/.*' + controller + '_.*_end.*/'), ' */', destClientUtilsMenuPath);
|
|
674
|
+
if (deleteDBFlag) {
|
|
675
|
+
shelljs_1.default.sed('-i', eval('/' + mysqlDatabase + ';/'), mysqlDatabase + ';\nDROP TABLE `' + controller + '`;\n/*', destServerSqlControllerPath);
|
|
676
|
+
shelljs_1.default.sed('-i', eval('/utf8mb4;/'), 'utf8mb4;\n*/', destServerSqlControllerPath);
|
|
677
|
+
shelljs_1.default.exec('mysql -u' +
|
|
678
|
+
mysqlUser +
|
|
679
|
+
' -p' +
|
|
680
|
+
mysqlPassword +
|
|
681
|
+
' -h' +
|
|
682
|
+
mysqlHost +
|
|
683
|
+
' -P' +
|
|
684
|
+
mysqlPort +
|
|
685
|
+
' < ' +
|
|
686
|
+
destServerSqlControllerPath);
|
|
687
|
+
}
|
|
688
|
+
rmFileSync(destServerSqlControllerPath);
|
|
689
|
+
var optionsArr_1 = [
|
|
690
|
+
{
|
|
691
|
+
from: /\n\s*\n/,
|
|
692
|
+
to: '\n\n',
|
|
693
|
+
files: [destClientReduxReducersAllPath]
|
|
694
|
+
},
|
|
695
|
+
{
|
|
696
|
+
from: /Reducer,\s*\n/,
|
|
697
|
+
to: 'Reducer,\n',
|
|
698
|
+
files: [destClientReduxReducersAllPath]
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
from: /'(.\/apis\/template.*?)'\)\s*\n/,
|
|
702
|
+
to: "'./apis/template')\n\n",
|
|
703
|
+
files: [destServerRestPath]
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
from: /template\)\s*\n/,
|
|
707
|
+
to: 'template)\n\n',
|
|
708
|
+
files: [destServerRestPath]
|
|
709
|
+
}
|
|
710
|
+
];
|
|
711
|
+
setTimeout(function () {
|
|
712
|
+
replaceInFileAll(optionsArr_1, 0, function () {
|
|
713
|
+
console.log('special replace dest files finished');
|
|
714
|
+
});
|
|
715
|
+
}, 1000);
|
|
716
|
+
}
|
|
717
|
+
else {
|
|
718
|
+
// pages
|
|
719
|
+
var destPagesActionPath = resolve(destPagesControllerPath + '/' + action + '.tsx');
|
|
720
|
+
// client redux
|
|
721
|
+
var destClientReduxControllerActionPath = resolve(destClientReduxControllerPath + '/' + action);
|
|
722
|
+
// client service
|
|
723
|
+
var destClientActionPath = resolve(destClientServiceControllerPath + '/' + action + '.ts');
|
|
724
|
+
// client styled
|
|
725
|
+
var destClientStyledActionPath = resolve(destClientStyledControllerPath + '/' + action + '.ts');
|
|
726
|
+
rmFileSync(destPagesActionPath);
|
|
727
|
+
rmdirSync(destClientReduxControllerActionPath);
|
|
728
|
+
rmFileSync(destClientActionPath);
|
|
729
|
+
rmFileSync(destClientStyledActionPath);
|
|
730
|
+
shelljs_1.default.sed('-i', eval('/.*' + controller + firstUpperCase(action) + 'Reducer.*/'), '', destClientReduxReducersAllPath);
|
|
731
|
+
var optionsArr_2 = [
|
|
732
|
+
{
|
|
733
|
+
from: /\n\s*\n/,
|
|
734
|
+
to: '\n\n',
|
|
735
|
+
files: [destClientReduxReducersAllPath]
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
from: /Reducer,\s*\n/,
|
|
739
|
+
to: 'Reducer,\n',
|
|
740
|
+
files: [destClientReduxReducersAllPath]
|
|
741
|
+
}
|
|
742
|
+
];
|
|
743
|
+
setTimeout(function () {
|
|
744
|
+
replaceInFileAll(optionsArr_2, 0, function () {
|
|
745
|
+
console.log('special replace dest files finished');
|
|
746
|
+
});
|
|
747
|
+
}, 1000);
|
|
748
|
+
}
|
|
749
|
+
console.log('delFiles finished');
|
|
750
|
+
};
|
|
751
|
+
exports.deleteFiles = deleteFiles;
|