nsgm-cli 2.1.8 → 2.1.9

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