nodefony 7.0.0-beta.2 → 7.0.0-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/CHANGELOG.md +534 -8028
  2. package/README.md +33 -30
  3. package/autoloader.es6 +46 -48
  4. package/builder.es6 +66 -76
  5. package/cli/builder/bundles/bundle.js +57 -63
  6. package/cli/builder/bundles/controller.js +34 -38
  7. package/cli/builder/bundles/users-bundle/Command/fixtureTask.js +11 -12
  8. package/cli/builder/bundles/users-bundle/Command/usersCommand.js +23 -24
  9. package/cli/builder/bundles/users-bundle/Entity/mongoose/userEntity.js +25 -30
  10. package/cli/builder/bundles/users-bundle/Entity/sequelize/userEntity.js +42 -31
  11. package/cli/builder/bundles/users-bundle/Fixtures/users.js +24 -26
  12. package/cli/builder/bundles/users-bundle/Fixtures/usersFixtures.js +28 -29
  13. package/cli/builder/bundles/users-bundle/Resources/config/config.js +4 -3
  14. package/cli/builder/bundles/users-bundle/Resources/config/routing.js +2 -2
  15. package/cli/builder/bundles/users-bundle/Resources/config/security.js +9 -8
  16. package/cli/builder/bundles/users-bundle/Resources/config/webpack/webpack.dev.config.js +3 -3
  17. package/cli/builder/bundles/users-bundle/Resources/config/webpack/webpack.prod.config.js +4 -3
  18. package/cli/builder/bundles/users-bundle/Resources/config/webpack.config.js +74 -75
  19. package/cli/builder/bundles/users-bundle/Resources/scss/awesome/font-awesome.config.js +9 -9
  20. package/cli/builder/bundles/users-bundle/Resources/swagger/openapi/login.js +13 -13
  21. package/cli/builder/bundles/users-bundle/Resources/swagger/openapi/users.js +14 -14
  22. package/cli/builder/bundles/users-bundle/controller/api/graphql/graphqlController.js +13 -15
  23. package/cli/builder/bundles/users-bundle/controller/api/graphql/userResolver.js +29 -29
  24. package/cli/builder/bundles/users-bundle/controller/api/graphql/usertype.js +2 -2
  25. package/cli/builder/bundles/users-bundle/controller/api/openapi/loginApiController.js +34 -36
  26. package/cli/builder/bundles/users-bundle/controller/api/openapi/restUserController.js +32 -36
  27. package/cli/builder/bundles/users-bundle/controller/loginController.js +30 -34
  28. package/cli/builder/bundles/users-bundle/controller/usersController.js +54 -60
  29. package/cli/builder/bundles/users-bundle/package.json +27 -25
  30. package/cli/builder/bundles/users-bundle/pnpm-lock.yaml +4262 -0
  31. package/cli/builder/bundles/users-bundle/readme.md +7 -7
  32. package/cli/builder/bundles/users-bundle/services/usersService.js +97 -102
  33. package/cli/builder/bundles/users-bundle/src/providers/mongoose/userProvider.js +6 -8
  34. package/cli/builder/bundles/users-bundle/src/providers/sequelize/userProvider.js +9 -10
  35. package/cli/builder/bundles/users-bundle/tests/loginTest.js +119 -70
  36. package/cli/builder/bundles/users-bundle/usersBundle.js +2 -3
  37. package/cli/builder/microService/microService.js +139 -141
  38. package/cli/builder/microService/skeletons/package.json +23 -22
  39. package/cli/builder/project/project.js +228 -181
  40. package/cli/builder/project/skeletons/README.md +33 -30
  41. package/cli/builder/project/skeletons/bin/dev-deploy.sh +5 -0
  42. package/cli/builder/project/skeletons/bin/prod-deploy.sh +3 -0
  43. package/cli/builder/project/skeletons/config/config.js.skeleton +1 -0
  44. package/cli/builder/project/skeletons/config/pm2.config.js.skeleton +41 -17
  45. package/cli/builder/project/skeletons/eslintignore.skeleton +15 -0
  46. package/cli/builder/project/skeletons/eslintrc.js.skeleton +97 -0
  47. package/cli/builder/project/skeletons/gitignore.skeleton +1 -0
  48. package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.37.entity-user.js +137 -0
  49. package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.38.entity-session.js +97 -0
  50. package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.39.entity-requests.js +115 -0
  51. package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.40.entity-jwts.js +97 -0
  52. package/cli/builder/project/skeletons/migrations/migrations.skeleton.js +0 -2
  53. package/cli/builder/project/skeletons/package.json.twig +70 -0
  54. package/cli/builder/react/reactBuilder.js +59 -65
  55. package/cli/builder/sandbox/sandBoxBuilder.js +132 -134
  56. package/cli/builder/skeletons/app/appKernel.js +120 -2
  57. package/cli/builder/skeletons/config/config.js +1 -1
  58. package/cli/builder/skeletons/config/nodefony/framework-bundle.js +2 -1
  59. package/cli/builder/skeletons/config/nodefony/http-bundle.js +1 -0
  60. package/cli/builder/skeletons/config/nodefony/mongoose-bundle.js +38 -12
  61. package/cli/builder/skeletons/config/nodefony/monitoring-bundle.js +21 -2
  62. package/cli/builder/skeletons/config/nodefony/sequelize-bundle.js +122 -13
  63. package/cli/builder/skeletons/package.json.twig +57 -0
  64. package/cli/builder/skeletons/unittest/testFile.js +44 -45
  65. package/cli/builder/vue/skeletons/vue.config.js +84 -10
  66. package/cli/builder/vue/vueBuilder.js +116 -114
  67. package/cli/generate/generate.es6 +38 -39
  68. package/cli/install/install.js +45 -58
  69. package/cli/sequelize/sequelize.js +50 -39
  70. package/cli/start.js +353 -347
  71. package/cli/tools/pm2.es6 +55 -57
  72. package/cli/tools/tools.es6 +36 -37
  73. package/cli.es6 +280 -228
  74. package/container.es6 +51 -59
  75. package/error.es6 +25 -27
  76. package/fileClass.es6 +53 -55
  77. package/finder/file.es6 +5 -4
  78. package/finder/fileResult.es6 +23 -22
  79. package/finder/finder2.es6 +46 -54
  80. package/finder.es6 +88 -97
  81. package/kernel/annotations/annotations.es6 +44 -46
  82. package/kernel/api/api.es6 +6 -8
  83. package/kernel/api/graphqlApi.es6 +21 -21
  84. package/kernel/api/jsonApi.es6 +40 -45
  85. package/kernel/api/openApi.es6 +9 -11
  86. package/kernel/api/schemas/openApiSchema.js +61 -32
  87. package/kernel/babylon.es6 +31 -38
  88. package/kernel/bundle.es6 +252 -220
  89. package/kernel/cliKernel.es6 +157 -170
  90. package/kernel/command.es6 +17 -20
  91. package/kernel/commands/nodefonyCommand.es6 +111 -58
  92. package/kernel/commands/tasks/bundlesTask.es6 +14 -19
  93. package/kernel/controllers/controller.es6 +167 -180
  94. package/kernel/fixture.es6 +4 -7
  95. package/kernel/injections/injections.es6 +97 -103
  96. package/kernel/kernel.es6 +476 -384
  97. package/kernel/kernelWatcher.es6 +64 -54
  98. package/kernel/orm/entity.es6 +10 -12
  99. package/kernel/orm/orm.es6 +68 -48
  100. package/kernel/reader.es6 +45 -47
  101. package/kernel/security/encoder.es6 +8 -6
  102. package/kernel/security/factories/factory.es6 +34 -37
  103. package/kernel/security/factories/passeportFactory.es6 +13 -14
  104. package/kernel/security/provider.es6 +11 -13
  105. package/kernel/security/providers/chainProvider.es6 +13 -28
  106. package/kernel/security/providers/memoryProvider.es6 +7 -11
  107. package/kernel/security/providers/providerManager.es6 +11 -14
  108. package/kernel/security/providers/userEntityProvider.es6 +7 -8
  109. package/kernel/security/role.es6 +3 -3
  110. package/kernel/security/secureArea.es6 +143 -149
  111. package/kernel/security/tokens/token.es6 +30 -32
  112. package/kernel/security/user.es6 +19 -19
  113. package/kernel/serviceRealTime.es6 +5 -7
  114. package/kernel/services/connectionsService.es6 +20 -22
  115. package/kernel/services/cron/cronService.es6 +14 -16
  116. package/kernel/task.es6 +20 -26
  117. package/kernel/templates.es6 +4 -5
  118. package/kernel/templating/twig.es6 +56 -47
  119. package/kernel/tests/cliTest.js +7 -11
  120. package/kernel/tests/containerTest.js +25 -37
  121. package/kernel/tests/kernelTest.js +9 -16
  122. package/nodefony.es6 +279 -256
  123. package/notificationsCenter.es6 +28 -20
  124. package/package.json +40 -40
  125. package/protocol.es6 +19 -21
  126. package/protocols/bayeux.es6 +35 -38
  127. package/protocols/jsonRpc/jsonrpc.es6 +12 -14
  128. package/result.es6 +11 -12
  129. package/service.es6 +62 -62
  130. package/syslog/pdu.es6 +99 -91
  131. package/syslog/syslog.es6 +101 -102
  132. package/watcher.es6 +21 -20
  133. package/cli/builder/project/skeletons/jshintignore.skeleton +0 -1
  134. package/cli/builder/project/skeletons/jshintrc.skeleton +0 -60
  135. package/cli/builder/project/skeletons/package.json.skeleton +0 -52
  136. package/cli/builder/skeletons/package.json +0 -61
package/cli/start.js CHANGED
@@ -4,7 +4,7 @@ let builderTools = null;
4
4
  let builderPM2 = null;
5
5
  let builderSequelize = null;
6
6
  try {
7
- builderInstall = require(path.resolve(__dirname , "install", "install.js"));
7
+ builderInstall = require(path.resolve(__dirname, "install", "install.js"));
8
8
  builderGenerater = require(path.resolve(__dirname, "generate", "generate.es6"));
9
9
  builderTools = require(path.resolve(__dirname, "tools", "tools.es6"));
10
10
  builderPM2 = require(path.resolve(__dirname, "tools", "pm2.es6"));
@@ -14,18 +14,18 @@ try {
14
14
  }
15
15
 
16
16
  module.exports = class cliStart extends nodefony.cliKernel {
17
-
18
- constructor() {
17
+ constructor () {
19
18
  super("nodefony", null, null, {
20
19
  asciify: false,
21
20
  autostart: false,
22
21
  signals: true,
22
+ commander: true,
23
23
  clean: true,
24
24
  promiseRejection: true,
25
25
  version: nodefony.version,
26
- events:{
26
+ events: {
27
27
  nbListeners: 60,
28
- captureRejections:true
28
+ captureRejections: true
29
29
  }
30
30
  });
31
31
  this.choices = [];
@@ -39,21 +39,24 @@ module.exports = class cliStart extends nodefony.cliKernel {
39
39
  [options] <command:action> [args...]
40
40
  [options] <action> [args...]`);
41
41
  // EVENTS ACTION
42
- this.commander.arguments(`[cmd] [args...]`)
42
+ this.commander.arguments("[cmd] [args...]")
43
43
  .action((cmd, args, commander) => {
44
- //this.log(`Commnand : ${cmd} Arguments : ${args}`, "DEBUG", "CLI EVENT ACTION");
45
- //this.cmd = cmd ? cmd.toLowerCase() : null;
44
+ // this.log(`Commnand : ${cmd} Arguments : ${args}`, "DEBUG", "CLI EVENT ACTION");
45
+ // this.cmd = cmd ? cmd.toLowerCase() : null;
46
46
  this.cmd = cmd;
47
47
  this.rawCommand = cmd;
48
48
  this.args = args;
49
49
  return commander;
50
50
  });
51
51
  // INIT
52
- this.initialize();
52
+ this.initialize()
53
+ .catch((e) => {
54
+ this.terminate(e.code || 1);
55
+ });
53
56
  }
54
57
 
55
- async setCommand(cmd, args = []) {
56
- //this.log(`Commnand : ${cmd} Arguments : ${args}`, "DEBUG", "COMMAND");
58
+ async setCommand (cmd, args = []) {
59
+ // this.log(`Commnand : ${cmd} Arguments : ${args}`, "DEBUG", "COMMAND");
57
60
  this.clearCommand();
58
61
  if (cmd) {
59
62
  process.argv.push(cmd);
@@ -62,10 +65,10 @@ module.exports = class cliStart extends nodefony.cliKernel {
62
65
  return await this.onStart(this.cmd, this.args);
63
66
  }
64
67
 
65
- async onStart(cmd = this.cmd, args = this.args) {
66
- //this.log(`Commnand : ${cmd} Arguments : ${args}`, "DEBUG", "CLI ONSTART");
67
- this.interactive = this.commander.opts().interactive|| false;
68
- if (!cmd && !process.argv.slice(2).length && (!process.argv[2])) {
68
+ async onStart (cmd = this.cmd, args = this.args) {
69
+ // this.log(`Commnand : ${cmd} Arguments : ${args}`, "DEBUG", "CLI ONSTART");
70
+ this.interactive = this.commander.opts().interactive || false;
71
+ if (!cmd && !process.argv.slice(2).length && !process.argv[2]) {
69
72
  this.buildMenu();
70
73
  this.interactive = true;
71
74
  return this.showMenu()
@@ -122,32 +125,35 @@ module.exports = class cliStart extends nodefony.cliKernel {
122
125
  }
123
126
  return this.terminate(1);
124
127
  }
128
+ throw e;
125
129
  });
126
130
  }
127
131
 
128
- async initialize() {
129
- await super.start()
132
+ async initialize () {
133
+ await super.start();
130
134
  this.initHelp();
131
135
  this.initOptions();
132
136
  await this.parseCommand(process.argv);
133
- let res = null;
134
- if (res = process.argv.slice(2).length && process.argv[2]) {
135
- // event action not fire when help command
136
- if (res === "--help" || res === "-h") {
137
- return await this.onStart("help");
138
- }
137
+ if (process.argv.slice(2).includes("--help") || process.argv.slice(2).includes("-h")) {
138
+ return await this.onStart("help")
139
+ .catch((e) => {
140
+ throw e;
141
+ });
139
142
  }
140
- return await this.onStart();
143
+ return await this.onStart()
144
+ .catch((e) => {
145
+ throw e;
146
+ });
141
147
  }
142
148
 
143
- /*async onCommand(cmd = this.cmd, args = this.args) {
149
+ /* async onCommand(cmd = this.cmd, args = this.args) {
144
150
  //this.cmd = cmd ? cmd.toLowerCase() : null;
145
151
  //this.args = args;
146
152
  this.parseNodefonyCommand();
147
153
  return await this.onStart(cmd, args);
148
154
  }*/
149
155
 
150
- clearCommand() {
156
+ clearCommand () {
151
157
  this.cmd = null;
152
158
  this.args.length = 0;
153
159
  this.clearNodefonyCommand();
@@ -156,8 +162,8 @@ module.exports = class cliStart extends nodefony.cliKernel {
156
162
  }
157
163
  }
158
164
 
159
- initHelp() {
160
- this.commander.on('--help', () => {
165
+ initHelp () {
166
+ this.commander.on("--help", () => {
161
167
  if (!nodefony.isTrunk) {
162
168
  this.setTitleHelp(this.clc.cyan("nodefony"));
163
169
  this.setHelp("", "create [-i] name [path]", "Create New Nodefony Project");
@@ -173,17 +179,17 @@ module.exports = class cliStart extends nodefony.cliKernel {
173
179
  });
174
180
  }
175
181
 
176
- initOptions() {
177
- this.setOption('-d, --debug ', 'Nodefony debug');
178
- this.setOption('--no-daemon', 'Nodefony Deamon off for production mode (usefull for docker)', true);
179
- this.setOption('--no-dump', 'Nodefony Start don\'t run Webpack Production Mode', true);
180
- this.setOption('-h, --help ', 'Nodefony help');
181
- this.setOption('-f, --force ', 'Force disable interactive mode');
182
- this.setOption('-i, --interactive ', 'Nodefony cli Interactive Mode');
183
- this.setOption('-j, --json', 'Nodefony json response');
182
+ initOptions () {
183
+ this.setOption("-d, --debug ", "Nodefony debug");
184
+ this.setOption("--no-daemon", "Nodefony Deamon off for production mode (usefull for docker)", true);
185
+ this.setOption("--no-dump", "Nodefony Start don't run Webpack Production Mode", true);
186
+ this.setOption("-h, --help ", "Nodefony help");
187
+ this.setOption("-f, --force ", "Force disable interactive mode");
188
+ this.setOption("-i, --interactive ", "Nodefony cli Interactive Mode");
189
+ this.setOption("-j, --json", "Nodefony json response");
184
190
  }
185
191
 
186
- showBanner(data) {
192
+ showBanner (data) {
187
193
  super.showBanner(data);
188
194
  if (nodefony.projectName !== "nodefony") {
189
195
  this.log(`WELCOME PROJECT : ${nodefony.projectName} ${nodefony.projectVersion}`);
@@ -192,16 +198,16 @@ module.exports = class cliStart extends nodefony.cliKernel {
192
198
  }
193
199
  }
194
200
 
195
- reloadPromt(clear) {
201
+ reloadPromt (clear) {
196
202
  if (clear) {
197
203
  this.clear();
198
204
  }
199
205
  this.reloadMenu = true;
200
- //this.clearCommand();
206
+ // this.clearCommand();
201
207
  return Promise.resolve();
202
208
  }
203
209
 
204
- showMenu(noAscii = false, reload = false) {
210
+ showMenu (noAscii = false, reload = false) {
205
211
  if (!noAscii) {
206
212
  return this.showAsciify("NODEFONY")
207
213
  .then((data) => {
@@ -215,273 +221,278 @@ module.exports = class cliStart extends nodefony.cliKernel {
215
221
  return this.runMenu(reload);
216
222
  }
217
223
 
218
- async start(command, args) {
219
- //this.log(`Commnand : ${command} Arguments : ${args}`, "DEBUG", "CLI START");
224
+ // eslint-disable-next-line max-lines-per-function, complexity
225
+ async start (command, args) {
226
+ // this.log(`Commnand : ${command} Arguments : ${args}`, "DEBUG", "CLI START");
220
227
  this.started = true;
221
228
  switch (command) {
222
- case "showmenu":
223
- return this.reloadPromt();
224
- case "create":
225
- try {
226
- return this.createProject(command, args, this.interactive);
227
- } catch (e) {
228
- throw e;
229
- }
230
- break;
231
- case "rebuild":
232
- try {
233
- if (nodefony.isTrunk) {
234
- return this.rebuild()
235
- .then((cwd) => {
236
- this.parseNodefonyCommand("nodefony:rebuild", [cwd]);
237
- return nodefony.start(command, args, this);
238
- })
239
- .then(() => {
240
- return this.installProject()
241
- .then(() => {
242
- return this.buildProject()
243
- .then((cwd) => {
244
- this.parseNodefonyCommand("nodefony:build", [cwd]);
245
- return nodefony.start(command, args, this);
246
- });
247
- });
248
- });
249
- }
250
- this.showHelp();
251
- this.log("No nodefony trunk detected !", "WARNING");
252
- break;
253
- } catch (e) {
254
- throw e;
255
- }
256
- break;
257
- case "build":
258
- try {
259
- if (nodefony.isTrunk) {
260
- return this.installProject()
261
- .then(() => {
262
- return this.buildProject()
263
- .then((cwd) => {
264
- this.parseNodefonyCommand("nodefony:build", [cwd]);
265
- return nodefony.start(command, args, this);
266
- });
267
- });
268
- }
269
- this.showHelp();
270
- this.log("No nodefony trunk detected !", "WARNING");
271
- break;
272
- } catch (e) {
273
- throw e;
274
- }
275
- break;
276
- case "install":
229
+ case "showmenu":
230
+ return this.reloadPromt();
231
+ case "create":
232
+ try {
233
+ return this.createProject(command, args, this.interactive);
234
+ } catch (e) {
235
+ throw e;
236
+ }
237
+ case "rebuild":
238
+ try {
277
239
  if (nodefony.isTrunk) {
278
- return this.installProject()
279
- .then((...args) => {
240
+ return this.rebuild(path.resolve("."), args, this.interactive)
241
+ .then((cwd) => {
242
+ this.parseNodefonyCommand("nodefony:rebuild", [cwd, args, this.interactive]);
280
243
  return nodefony.start(command, args, this)
281
- .then((...args) => {
282
- return args;
283
- })
284
244
  .catch((e) => {
285
245
  throw e;
286
246
  });
287
- });
247
+ })
248
+ .then(() => this.installProject(path.resolve("."), args, this.interactive)
249
+ .then(() => this.buildProject(path.resolve("."), args, this.interactive)
250
+ .then((cwd) => {
251
+ this.parseNodefonyCommand("nodefony:build", [cwd, args, this.interactive]);
252
+ return nodefony.start(command, args, this)
253
+ .catch((e) => {
254
+ throw e;
255
+ });
256
+ })));
288
257
  }
289
258
  this.showHelp();
290
259
  this.log("No nodefony trunk detected !", "WARNING");
291
260
  break;
292
- case "version":
293
- try {
294
- return process.stdout.write(nodefony.version);
295
- } catch (e) {
296
- throw e;
261
+ } catch (e) {
262
+ throw e;
263
+ }
264
+ break;
265
+ case "build":
266
+ try {
267
+ if (nodefony.isTrunk) {
268
+ return this.installProject(path.resolve("."), args, this.interactive)
269
+ .then(() => this.buildProject(path.resolve("."), args, this.interactive)
270
+ .then((cwd) => {
271
+ this.parseNodefonyCommand("nodefony:build", [cwd, args, this.interactive]);
272
+ return nodefony.start(command, args, this)
273
+ .catch((e) => {
274
+ throw e;
275
+ });
276
+ }));
297
277
  }
278
+ this.showHelp();
279
+ this.log("No nodefony trunk detected !", "WARNING");
298
280
  break;
299
- case "help":
300
- if (!nodefony.isTrunk) {
301
- return this.showHelp();
302
- } else {
281
+ } catch (e) {
282
+ throw e;
283
+ }
284
+ break;
285
+ case "install":
286
+ if (nodefony.isTrunk) {
287
+ return this.installProject(path.resolve("."), args, this.interactive)
288
+ .then((...args) => nodefony.start(command, args, this)
289
+ .then((...args) => args)
290
+ .catch((e) => {
291
+ throw e;
292
+ }));
293
+ }
294
+ this.showHelp();
295
+ this.log("No nodefony trunk detected !", "WARNING");
296
+ break;
297
+ case "version":
298
+ try {
299
+ return process.stdout.write(nodefony.version);
300
+ } catch (e) {
301
+ throw e;
302
+ }
303
+ break;
304
+ case "help":
305
+ if (!nodefony.isTrunk) {
306
+ return this.showHelp();
307
+ }
308
+ return await nodefony.start(command, args, this)
309
+ .then(() => this.showHelp())
310
+ .catch((e) => {
311
+ this.showHelp();
312
+ if (command === "help") {
313
+ return;
314
+ }
315
+ throw e;
316
+ });
317
+
318
+ break;
319
+ case "certificates":
320
+ return this.generateCertificates();
321
+ default:
322
+ this.parseNodefonyCommand(command, args);
323
+ if (nodefony.isTrunk) {
324
+ try {
325
+ if (this.kernel) {
326
+ return this.matchCommand();
327
+ }
303
328
  return await nodefony.start(command, args, this)
304
- .then(() => {
305
- return this.showHelp();
306
- })
307
- .catch(() => {
308
- return this.showHelp();
329
+ .catch((e) => {
330
+ throw e;
309
331
  });
310
- }
311
- break;
312
- case "certificates":
313
- return this.generateCertificates();
314
- default:
315
- this.parseNodefonyCommand(command, args);
316
- if (nodefony.isTrunk) {
332
+ } catch (e) {
317
333
  try {
318
- if (this.kernel) {
319
- return this.matchCommand();
334
+ if (this.rawCommand) {
335
+ // return require(path.resolve(this.rawCommand));
336
+ } else {
337
+ // this.showHelp();
320
338
  }
321
- return await nodefony.start(command, args, this);
339
+ throw e;
322
340
  } catch (e) {
323
- try {
324
- if (this.rawCommand) {
325
- //return require(path.resolve(this.rawCommand));
326
- } else {
327
- //this.showHelp();
328
- }
329
- throw e;
330
- } catch (e) {
331
- //this.showHelp();
332
- //this.log(`Command Not Found ${this.cmd} ${this.args}`, "ERROR");
333
- //this.log(e, "ERROR", "MODULE");
334
- //this.terminate(1);
335
- throw e;
336
- }
341
+ // this.showHelp();
342
+ // this.log(`Command Not Found ${this.cmd} ${this.args}`, "ERROR");
343
+ // this.log(e, "ERROR", "MODULE");
344
+ // this.terminate(1);
345
+ throw e;
337
346
  }
338
- } else {
339
- try {
340
- return await nodefony.start(this.rawCommand, args, this);
341
- } catch (e) {
342
- try {
343
- if (this.rawCommand) {
344
- //return require(path.resolve(this.rawCommand));
345
- } else {
346
- //return this.showHelp();
347
- }
348
- throw e;
349
- } catch (e) {
350
- //this.showHelp();
351
- //this.log(`Command Not Found ${this.cmd} ${this.args}`, "ERROR");
352
- //this.log(e, "ERROR", "MODULE");
353
- //this.terminate(1);
347
+ }
348
+ } else {
349
+ try {
350
+ return await nodefony.start(this.rawCommand, args, this)
351
+ .catch((e) => {
354
352
  throw e;
353
+ });
354
+ } catch (e) {
355
+ try {
356
+ if (this.rawCommand) {
357
+ // return require(path.resolve(this.rawCommand));
358
+ } else {
359
+ // return this.showHelp();
355
360
  }
361
+ throw e;
362
+ } catch (e) {
363
+ // this.showHelp();
364
+ // this.log(`Command Not Found ${this.cmd} ${this.args}`, "ERROR");
365
+ // this.log(e, "ERROR", "MODULE");
366
+ // this.terminate(1);
367
+ throw e;
356
368
  }
357
369
  }
370
+ }
358
371
  }
359
372
  }
360
373
 
361
- buildMenu() {
362
- this.generateString = `Generater`;
374
+ buildMenu () {
375
+ this.generateString = "Generater";
363
376
  this.startString = "Start Servers";
364
377
  if (nodefony.isTrunk) {
365
378
  if (nodefony.builded) {
366
379
  this.choices.push(`${this.startString} Development`);
367
380
  this.choices.push(`${this.startString} Pre-Production`);
368
381
  this.choices.push(`${this.startString} Production`);
369
- this.choices.push(`Install Project`);
370
- this.choices.push(`Build Project`);
371
- this.choices.push(`Rebuild Project`);
372
- this.choices.push(`Sequelize`);
382
+ this.choices.push("Install Project");
383
+ this.choices.push("Build Project");
384
+ this.choices.push("Rebuild Project");
385
+ this.choices.push("Sequelize");
373
386
  this.choices.push(`${this.generateString}`);
374
- this.choices.push(`Tools`);
375
- this.choices.push(`PM2 Tools`);
376
- this.choices.push(`Run Test`);
387
+ this.choices.push("Tools");
388
+ this.choices.push("PM2 Tools");
389
+ this.choices.push("Run Test");
377
390
  } else {
378
- this.choices.push(`Build Project`);
391
+ this.choices.push("Build Project");
379
392
  this.choices.push(`${this.generateString}`);
380
- this.choices.push(`Tools`);
381
- this.choices.push(`PM2 Tools`);
393
+ this.choices.push("Tools");
394
+ this.choices.push("PM2 Tools");
382
395
  }
383
396
  } else {
384
- this.choices.push(`Create Nodefony Web Project`);
385
- this.choices.push(`Create Micro Service Project`);
386
- this.choices.push(`PM2 Tools`);
397
+ this.choices.push("Create Nodefony Web Project");
398
+ this.choices.push("Create Micro Service Project");
399
+ this.choices.push("PM2 Tools");
387
400
  }
388
401
  this.choices.push(this.getSeparator());
389
402
  this.choices.push("Help");
390
403
  this.choices.push("Quit");
391
404
  }
392
405
 
393
- interaction(choices) {
406
+ interaction (choices) {
394
407
  return this.prompt([{
395
- type: 'list',
396
- name: 'command',
397
- message: ' Nodefony CLI : ',
398
- default: 0, //(choices.length - 1),
399
- pageSize: choices.length,
400
- choices: choices,
401
- filter: (val) => {
402
- switch (val) {
403
- case "Quit":
404
- return "exit";
405
- case "Help":
406
- return "help";
407
- case `${this.startString} Development`:
408
- return "development";
409
- case `${this.startString} Production`:
410
- return "production";
411
- case `${this.startString} Pre-Production`:
412
- return "pre-production";
413
- case `Create Nodefony Web Project`:
414
- return "project";
415
- case `Create Micro Service Project`:
416
- return "microservice";
417
- case `${this.generateString}`:
418
- return "generate";
419
- case `Sequelize`:
420
- return "sequelize";
421
- case `Run Test`:
422
- return "test";
423
- case `Install`:
424
- case `Install Framework`:
425
- case `Install Project`:
426
- return "install";
427
- case `Build`:
428
- case `Build Project`:
429
- return "build";
430
- case `Rebuild Project`:
431
- return "rebuild";
432
- case `PM2 Tools`:
433
- return "pm2";
434
- case `Tools`:
435
- return "tools";
436
- default:
437
- console.log("\n");
438
- this.log(`command not found : ${val}`, "INFO");
439
- this.terminate(1);
440
- }
408
+ type: "list",
409
+ name: "command",
410
+ message: " Nodefony CLI : ",
411
+ default: 0, // (choices.length - 1),
412
+ pageSize: choices.length,
413
+ choices,
414
+ filter: (val) => {
415
+ switch (val) {
416
+ case "Quit":
417
+ return "exit";
418
+ case "Help":
419
+ return "help";
420
+ case `${this.startString} Development`:
421
+ return "development";
422
+ case `${this.startString} Production`:
423
+ return "production";
424
+ case `${this.startString} Pre-Production`:
425
+ return "pre-production";
426
+ case "Create Nodefony Web Project":
427
+ return "project";
428
+ case "Create Micro Service Project":
429
+ return "microservice";
430
+ case `${this.generateString}`:
431
+ return "generate";
432
+ case "Sequelize":
433
+ return "sequelize";
434
+ case "Run Test":
435
+ return "test";
436
+ case "Install":
437
+ case "Install Framework":
438
+ case "Install Project":
439
+ return "install";
440
+ case "Build":
441
+ case "Build Project":
442
+ return "build";
443
+ case "Rebuild Project":
444
+ return "rebuild";
445
+ case "PM2 Tools":
446
+ return "pm2";
447
+ case "Tools":
448
+ return "tools";
449
+ default:
450
+ console.log("\n");
451
+ this.log(`command not found : ${val}`, "INFO");
452
+ this.terminate(1);
441
453
  }
442
- }])
443
- .then((response) => {
444
- return nodefony.extend(this.response, response);
445
- });
454
+ }
455
+ }])
456
+ .then((response) => nodefony.extend(this.response, response));
446
457
  }
447
458
 
448
- runMenu(reload = false) {
459
+ runMenu (reload = false) {
449
460
  return this.interaction(this.choices)
450
461
  .then(() => {
451
462
  this.reloadMenu = reload || this.reloadMenu;
452
463
  switch (this.response.command) {
453
- case "project":
454
- return this.createProject(null, null, true);
455
- case "microservice":
456
- return this.createMicroService(null, null, true);
457
- case "rebuild":
458
- return this.setCommand("rebuild");
459
- case "build":
460
- return this.setCommand("build");
461
- case "install":
462
- return this.setCommand("install");
463
- case "generate":
464
- return this.generateCli(true);
465
- case "sequelize":
466
- return this.sequelizeCli(true);
467
- case "pm2":
468
- return this.pm2Cli(true);
469
- case "tools":
470
- return this.toolsCli(true);
471
- case "development":
472
- return this.setCommand("development");
473
- case "production":
474
- return this.setCommand("production");
475
- case "pre-production":
476
- return this.setCommand("preprod");
477
- case "test":
478
- return this.setCommand("unitest:launch:all");
479
- case "exit":
480
- this.log("QUIT");
481
- return this.terminate(0);
482
- default:
483
- return this.setCommand("help");
484
- //return this.setCommand(null, ["-h"]);
464
+ case "project":
465
+ return this.createProject(null, null, true);
466
+ case "microservice":
467
+ return this.createMicroService(null, null, true);
468
+ case "rebuild":
469
+ return this.setCommand("rebuild");
470
+ case "build":
471
+ return this.setCommand("build");
472
+ case "install":
473
+ return this.setCommand("install");
474
+ case "generate":
475
+ return this.generateCli(true);
476
+ case "sequelize":
477
+ return this.sequelizeCli(true);
478
+ case "pm2":
479
+ return this.pm2Cli(true);
480
+ case "tools":
481
+ return this.toolsCli(true);
482
+ case "development":
483
+ return this.setCommand("development");
484
+ case "production":
485
+ return this.setCommand("production");
486
+ case "pre-production":
487
+ return this.setCommand("preprod");
488
+ case "test":
489
+ return this.setCommand("unitest:launch:all");
490
+ case "exit":
491
+ this.log("QUIT");
492
+ return this.terminate(0);
493
+ default:
494
+ return this.setCommand("help");
495
+ // return this.setCommand(null, ["-h"]);
485
496
  }
486
497
  })
487
498
  .catch((e) => {
@@ -489,73 +500,67 @@ module.exports = class cliStart extends nodefony.cliKernel {
489
500
  });
490
501
  }
491
502
 
492
- gitInit(project, response) {
503
+ gitInit (project, response) {
493
504
  let gitP, cwd, git;
494
505
  try {
495
506
  cwd = path.resolve(project.location, project.name);
496
- gitP = require('simple-git');
507
+ gitP = require("simple-git");
497
508
  git = gitP(cwd);
498
509
  } catch (e) {
499
510
  throw e;
500
511
  }
501
512
  return git.init()
502
- .then(() => {
503
- return git.add(path.resolve(cwd, '*'))
504
- .then(() => {
505
- return git.addConfig('user.name', response.authorFullName)
506
- .then(() => {
507
- return git.addConfig('user.email', response.authorMail)
508
- .then(() => {
509
- return git.commit("first commit!");
510
- });
511
- });
512
- });
513
- });
513
+ .then(() => git.add(path.resolve(cwd, "*"))
514
+ .then(() => git.addConfig("user.name", response.authorFullName)
515
+ .then(() => git.addConfig("user.email", response.authorMail)
516
+ .then(() => git.commit("first commit!")))));
514
517
  }
515
518
 
516
- createProject(command, args, interactive = false) {
519
+ createProject (command, args, interactive = false) {
517
520
  try {
518
521
  if (command === "create") {
519
522
  if (!args[0]) {
520
523
  args[0] = "nodefony-starter";
521
524
  }
522
525
  }
523
- let project = new nodefony.builders.project(this, command, args);
526
+ const project = new nodefony.builders.project(this, command, args);
524
527
  return project.run(interactive)
525
- .then((obj) => {
526
- return this.gitInit(project, obj.response)
527
- .then(() => {
528
- let cwd = path.resolve(project.location, project.name);
529
- this.log(`Create Project ${obj.response.name} complete`, "INFO");
530
- this.cd(cwd);
531
- return this.installProject(cwd)
532
- .then(() => {
533
- return this.buildProject(cwd)
534
- .then((cwd) => {
535
- try {
536
- nodefony.checkTrunk(cwd);
537
- this.parseNodefonyCommand("nodefony:build", [cwd]);
538
- return nodefony.start(command, args, this);
539
- } catch (e) {
528
+ .then((obj) => this.gitInit(project, obj.response)
529
+ .then(() => {
530
+ const cwd = path.resolve(project.location, project.name);
531
+ this.log(`Create Project ${obj.response.name} complete`, "INFO");
532
+ this.cd(cwd);
533
+ return this.installProject(cwd, args, interactive)
534
+ .then(() => this.buildProject(cwd, args, interactive)
535
+ .then((cwd) => {
536
+ try {
537
+ nodefony.checkTrunk(cwd);
538
+ this.parseNodefonyCommand("nodefony:build", [cwd, args, interactive]);
539
+ return nodefony.start(command, args, this)
540
+ .catch((e) => {
540
541
  throw e;
541
- }
542
- }).catch((e) => {
543
- this.log(e, "ERROR");
544
- throw e;
545
- });
546
- }).catch((e) => {
542
+ });
543
+ } catch (e) {
544
+ throw e;
545
+ }
546
+ })
547
+ .catch((e) => {
547
548
  this.log(e, "ERROR");
548
549
  throw e;
549
- });
550
- }).catch((e) => {
551
- if (e.code || e.code === 0) {
552
- this.log(e, "INFO");
553
- this.terminate(e.code);
554
- }
555
- this.log(e, "ERROR");
556
- this.terminate(e.code || 1);
557
- });
558
- })
550
+ }))
551
+ .catch((e) => {
552
+ this.log(e, "ERROR");
553
+ throw e;
554
+ });
555
+ })
556
+ .catch((e) => {
557
+ if (e.code || e.code === 0) {
558
+ this.log(e, "INFO");
559
+ this.terminate(e.code);
560
+ }
561
+ this.log(e, "ERROR");
562
+ this.terminate(e.code || 1);
563
+ }))
559
564
  .catch((e) => {
560
565
  throw e;
561
566
  });
@@ -564,33 +569,31 @@ module.exports = class cliStart extends nodefony.cliKernel {
564
569
  }
565
570
  }
566
571
 
567
- createMicroService(command, args, interactive = false){
568
- let microService = new nodefony.builders.microService(this, command, args);
572
+ createMicroService (command, args, interactive = false) {
573
+ const microService = new nodefony.builders.microService(this, command, args);
569
574
  return microService.run(interactive)
570
- .then((obj) => {
571
- return this.gitInit(microService, obj.response)
572
- .then(()=>{
573
- let cwd = path.resolve(microService.location, microService.name);
575
+ .then((obj) => this.gitInit(microService, obj.response)
576
+ .then(() => {
577
+ const cwd = path.resolve(microService.location, microService.name);
574
578
  this.log(`Nodefony Micro Service ${obj.response.name} complete`, "INFO");
575
579
  this.cd(cwd);
576
580
  return this.npm(["install"], cwd)
577
- .then(()=>{
578
- return this.generateCertificates(cwd)
579
- .then(()=>{
580
- this.log(`cd ${obj.response.name}`);
581
- this.log(`npm start`);
582
- return cwd;
583
- });
584
- });
585
- }).catch(e =>{
581
+ .then(() => this.generateCertificates(cwd)
582
+ .then(() => {
583
+ this.log(`cd ${obj.response.name}`);
584
+ this.log("npm start");
585
+ return cwd;
586
+ }));
587
+ })
588
+ .catch((e) => {
586
589
  if (e.code || e.code === 0) {
587
590
  this.log(e, "INFO");
588
591
  this.terminate(e.code);
589
592
  }
590
593
  this.log(e, "ERROR");
591
594
  this.terminate(e.code || 1);
592
- });
593
- }).catch(e =>{
595
+ }))
596
+ .catch((e) => {
594
597
  if (e.code || e.code === 0) {
595
598
  this.log(e, "INFO");
596
599
  this.terminate(e.code);
@@ -600,14 +603,15 @@ module.exports = class cliStart extends nodefony.cliKernel {
600
603
  });
601
604
  }
602
605
 
603
- installProject(cwd = path.resolve(".")) {
606
+ installProject (cwd = path.resolve("."), args, interactive = false) {
604
607
  try {
605
- let installer = new builderInstall(this);
606
- return installer.install(cwd)
608
+ const installer = new builderInstall(this);
609
+ return installer.install(cwd, args, interactive)
607
610
  .then((ret) => {
608
611
  this.log("Install Complete");
609
612
  return ret;
610
- }).catch((e) => {
613
+ })
614
+ .catch((e) => {
611
615
  this.log(e, "ERROR");
612
616
  throw e;
613
617
  });
@@ -617,14 +621,15 @@ module.exports = class cliStart extends nodefony.cliKernel {
617
621
  }
618
622
  }
619
623
 
620
- rebuild(cwd = path.resolve(".")) {
624
+ rebuild (cwd = path.resolve("."), args, interactive = false) {
621
625
  try {
622
- let installer = new builderInstall(this);
623
- return installer.rebuild(cwd)
626
+ const installer = new builderInstall(this);
627
+ return installer.rebuild(cwd, args, interactive)
624
628
  .then((ret) => {
625
629
  this.log(`Rebuild Complete : ${cwd}`);
626
630
  return ret;
627
- }).catch((e) => {
631
+ })
632
+ .catch((e) => {
628
633
  this.log(e, "ERROR");
629
634
  throw e;
630
635
  });
@@ -634,14 +639,15 @@ module.exports = class cliStart extends nodefony.cliKernel {
634
639
  }
635
640
  }
636
641
 
637
- buildProject(cwd = path.resolve(".")) {
642
+ buildProject (cwd = path.resolve("."), args, interactive) {
638
643
  try {
639
- let installer = new builderInstall(this);
640
- return installer.build(cwd)
644
+ const installer = new builderInstall(this);
645
+ return installer.build(cwd, args, interactive)
641
646
  .then((ret) => {
642
647
  this.log("Build Complete");
643
648
  return ret;
644
- }).catch((e) => {
649
+ })
650
+ .catch((e) => {
645
651
  this.log(e, "ERROR");
646
652
  throw e;
647
653
  });
@@ -651,39 +657,40 @@ module.exports = class cliStart extends nodefony.cliKernel {
651
657
  }
652
658
  }
653
659
 
654
- generateCli(interactive) {
655
- let generater = new builderGenerater(this);
660
+ generateCli (interactive) {
661
+ const generater = new builderGenerater(this);
656
662
  return generater.run(interactive);
657
663
  }
658
664
 
659
- toolsCli(interactive) {
660
- let generater = new builderTools(this);
665
+ toolsCli (interactive) {
666
+ const generater = new builderTools(this);
661
667
  return generater.run(interactive);
662
668
  }
663
669
 
664
- pm2Cli(interactive) {
665
- let generater = new builderPM2(this);
670
+ pm2Cli (interactive) {
671
+ const generater = new builderPM2(this);
666
672
  return generater.run(interactive);
667
673
  }
668
674
 
669
- sequelizeCli(interactive){
670
- let generater = new builderSequelize(this);
675
+ sequelizeCli (interactive) {
676
+ const generater = new builderSequelize(this);
671
677
  return generater.run(interactive);
672
678
  }
673
679
 
674
- generateCertificates(cwd = path.resolve(".")) {
680
+ generateCertificates (cwd = path.resolve(".")) {
675
681
  try {
676
- let installer = new builderInstall(this);
682
+ const installer = new builderInstall(this);
677
683
  return installer.generateCertificates(cwd)
678
684
  .then(() => {
679
- let directory = path.resolve(cwd, "config", "certificates");
680
- let config = path.resolve(cwd, "config", "openssl");
685
+ const directory = path.resolve(cwd, "config", "certificates");
686
+ const config = path.resolve(cwd, "config", "openssl");
681
687
  this.log(`Certificates build with config : ${config}`);
682
- let res = this.ls(directory);
688
+ const res = this.ls(directory);
683
689
  this.log(`See Generated Certificates in directory : ${directory} \n${res.stdout}`);
684
690
  this.log("Generate Certificates Complete");
685
691
  return cwd;
686
- }).catch((e) => {
692
+ })
693
+ .catch((e) => {
687
694
  this.log(e, "ERROR");
688
695
  throw e;
689
696
  });
@@ -692,5 +699,4 @@ module.exports = class cliStart extends nodefony.cliKernel {
692
699
  throw e;
693
700
  }
694
701
  }
695
-
696
702
  };