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.
- package/CHANGELOG.md +534 -8028
- package/README.md +33 -30
- package/autoloader.es6 +46 -48
- package/builder.es6 +66 -76
- package/cli/builder/bundles/bundle.js +57 -63
- package/cli/builder/bundles/controller.js +34 -38
- package/cli/builder/bundles/users-bundle/Command/fixtureTask.js +11 -12
- package/cli/builder/bundles/users-bundle/Command/usersCommand.js +23 -24
- package/cli/builder/bundles/users-bundle/Entity/mongoose/userEntity.js +25 -30
- package/cli/builder/bundles/users-bundle/Entity/sequelize/userEntity.js +42 -31
- package/cli/builder/bundles/users-bundle/Fixtures/users.js +24 -26
- package/cli/builder/bundles/users-bundle/Fixtures/usersFixtures.js +28 -29
- package/cli/builder/bundles/users-bundle/Resources/config/config.js +4 -3
- package/cli/builder/bundles/users-bundle/Resources/config/routing.js +2 -2
- package/cli/builder/bundles/users-bundle/Resources/config/security.js +9 -8
- package/cli/builder/bundles/users-bundle/Resources/config/webpack/webpack.dev.config.js +3 -3
- package/cli/builder/bundles/users-bundle/Resources/config/webpack/webpack.prod.config.js +4 -3
- package/cli/builder/bundles/users-bundle/Resources/config/webpack.config.js +74 -75
- package/cli/builder/bundles/users-bundle/Resources/scss/awesome/font-awesome.config.js +9 -9
- package/cli/builder/bundles/users-bundle/Resources/swagger/openapi/login.js +13 -13
- package/cli/builder/bundles/users-bundle/Resources/swagger/openapi/users.js +14 -14
- package/cli/builder/bundles/users-bundle/controller/api/graphql/graphqlController.js +13 -15
- package/cli/builder/bundles/users-bundle/controller/api/graphql/userResolver.js +29 -29
- package/cli/builder/bundles/users-bundle/controller/api/graphql/usertype.js +2 -2
- package/cli/builder/bundles/users-bundle/controller/api/openapi/loginApiController.js +34 -36
- package/cli/builder/bundles/users-bundle/controller/api/openapi/restUserController.js +32 -36
- package/cli/builder/bundles/users-bundle/controller/loginController.js +30 -34
- package/cli/builder/bundles/users-bundle/controller/usersController.js +54 -60
- package/cli/builder/bundles/users-bundle/package.json +27 -25
- package/cli/builder/bundles/users-bundle/pnpm-lock.yaml +4262 -0
- package/cli/builder/bundles/users-bundle/readme.md +7 -7
- package/cli/builder/bundles/users-bundle/services/usersService.js +97 -102
- package/cli/builder/bundles/users-bundle/src/providers/mongoose/userProvider.js +6 -8
- package/cli/builder/bundles/users-bundle/src/providers/sequelize/userProvider.js +9 -10
- package/cli/builder/bundles/users-bundle/tests/loginTest.js +119 -70
- package/cli/builder/bundles/users-bundle/usersBundle.js +2 -3
- package/cli/builder/microService/microService.js +139 -141
- package/cli/builder/microService/skeletons/package.json +23 -22
- package/cli/builder/project/project.js +228 -181
- package/cli/builder/project/skeletons/README.md +33 -30
- package/cli/builder/project/skeletons/bin/dev-deploy.sh +5 -0
- package/cli/builder/project/skeletons/bin/prod-deploy.sh +3 -0
- package/cli/builder/project/skeletons/config/config.js.skeleton +1 -0
- package/cli/builder/project/skeletons/config/pm2.config.js.skeleton +41 -17
- package/cli/builder/project/skeletons/eslintignore.skeleton +15 -0
- package/cli/builder/project/skeletons/eslintrc.js.skeleton +97 -0
- package/cli/builder/project/skeletons/gitignore.skeleton +1 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.37.entity-user.js +137 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.38.entity-session.js +97 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.39.entity-requests.js +115 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.40.entity-jwts.js +97 -0
- package/cli/builder/project/skeletons/migrations/migrations.skeleton.js +0 -2
- package/cli/builder/project/skeletons/package.json.twig +70 -0
- package/cli/builder/react/reactBuilder.js +59 -65
- package/cli/builder/sandbox/sandBoxBuilder.js +132 -134
- package/cli/builder/skeletons/app/appKernel.js +120 -2
- package/cli/builder/skeletons/config/config.js +1 -1
- package/cli/builder/skeletons/config/nodefony/framework-bundle.js +2 -1
- package/cli/builder/skeletons/config/nodefony/http-bundle.js +1 -0
- package/cli/builder/skeletons/config/nodefony/mongoose-bundle.js +38 -12
- package/cli/builder/skeletons/config/nodefony/monitoring-bundle.js +21 -2
- package/cli/builder/skeletons/config/nodefony/sequelize-bundle.js +122 -13
- package/cli/builder/skeletons/package.json.twig +57 -0
- package/cli/builder/skeletons/unittest/testFile.js +44 -45
- package/cli/builder/vue/skeletons/vue.config.js +84 -10
- package/cli/builder/vue/vueBuilder.js +116 -114
- package/cli/generate/generate.es6 +38 -39
- package/cli/install/install.js +45 -58
- package/cli/sequelize/sequelize.js +50 -39
- package/cli/start.js +353 -347
- package/cli/tools/pm2.es6 +55 -57
- package/cli/tools/tools.es6 +36 -37
- package/cli.es6 +280 -228
- package/container.es6 +51 -59
- package/error.es6 +25 -27
- package/fileClass.es6 +53 -55
- package/finder/file.es6 +5 -4
- package/finder/fileResult.es6 +23 -22
- package/finder/finder2.es6 +46 -54
- package/finder.es6 +88 -97
- package/kernel/annotations/annotations.es6 +44 -46
- package/kernel/api/api.es6 +6 -8
- package/kernel/api/graphqlApi.es6 +21 -21
- package/kernel/api/jsonApi.es6 +40 -45
- package/kernel/api/openApi.es6 +9 -11
- package/kernel/api/schemas/openApiSchema.js +61 -32
- package/kernel/babylon.es6 +31 -38
- package/kernel/bundle.es6 +252 -220
- package/kernel/cliKernel.es6 +157 -170
- package/kernel/command.es6 +17 -20
- package/kernel/commands/nodefonyCommand.es6 +111 -58
- package/kernel/commands/tasks/bundlesTask.es6 +14 -19
- package/kernel/controllers/controller.es6 +167 -180
- package/kernel/fixture.es6 +4 -7
- package/kernel/injections/injections.es6 +97 -103
- package/kernel/kernel.es6 +476 -384
- package/kernel/kernelWatcher.es6 +64 -54
- package/kernel/orm/entity.es6 +10 -12
- package/kernel/orm/orm.es6 +68 -48
- package/kernel/reader.es6 +45 -47
- package/kernel/security/encoder.es6 +8 -6
- package/kernel/security/factories/factory.es6 +34 -37
- package/kernel/security/factories/passeportFactory.es6 +13 -14
- package/kernel/security/provider.es6 +11 -13
- package/kernel/security/providers/chainProvider.es6 +13 -28
- package/kernel/security/providers/memoryProvider.es6 +7 -11
- package/kernel/security/providers/providerManager.es6 +11 -14
- package/kernel/security/providers/userEntityProvider.es6 +7 -8
- package/kernel/security/role.es6 +3 -3
- package/kernel/security/secureArea.es6 +143 -149
- package/kernel/security/tokens/token.es6 +30 -32
- package/kernel/security/user.es6 +19 -19
- package/kernel/serviceRealTime.es6 +5 -7
- package/kernel/services/connectionsService.es6 +20 -22
- package/kernel/services/cron/cronService.es6 +14 -16
- package/kernel/task.es6 +20 -26
- package/kernel/templates.es6 +4 -5
- package/kernel/templating/twig.es6 +56 -47
- package/kernel/tests/cliTest.js +7 -11
- package/kernel/tests/containerTest.js +25 -37
- package/kernel/tests/kernelTest.js +9 -16
- package/nodefony.es6 +279 -256
- package/notificationsCenter.es6 +28 -20
- package/package.json +40 -40
- package/protocol.es6 +19 -21
- package/protocols/bayeux.es6 +35 -38
- package/protocols/jsonRpc/jsonrpc.es6 +12 -14
- package/result.es6 +11 -12
- package/service.es6 +62 -62
- package/syslog/pdu.es6 +99 -91
- package/syslog/syslog.es6 +101 -102
- package/watcher.es6 +21 -20
- package/cli/builder/project/skeletons/jshintignore.skeleton +0 -1
- package/cli/builder/project/skeletons/jshintrc.skeleton +0 -60
- package/cli/builder/project/skeletons/package.json.skeleton +0 -52
- package/cli/builder/skeletons/package.json +0 -61
package/kernel/cliKernel.es6
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
const simpleGit = require(
|
|
2
|
-
//const npm = require("npm");
|
|
1
|
+
const simpleGit = require("simple-git");
|
|
2
|
+
// const npm = require("npm");
|
|
3
3
|
|
|
4
4
|
const charsTable = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
"top": "",
|
|
6
|
+
"top-mid": "",
|
|
7
|
+
"top-left": "",
|
|
8
|
+
"top-right": "",
|
|
9
|
+
"bottom": "",
|
|
10
|
+
"bottom-mid": "",
|
|
11
|
+
"bottom-left": "",
|
|
12
|
+
"bottom-right": "",
|
|
13
|
+
"left": "",
|
|
14
|
+
"left-mid": "",
|
|
15
|
+
"mid": "",
|
|
16
|
+
"mid-mid": "",
|
|
17
|
+
"right": "",
|
|
18
|
+
"right-mid": "",
|
|
19
|
+
"middle": " "
|
|
20
20
|
};
|
|
21
21
|
const styleTable = {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
"padding-left": 0,
|
|
23
|
+
"padding-right": 0
|
|
24
24
|
};
|
|
25
25
|
const optionsTaskTables = {
|
|
26
26
|
colWidths: [8, 55, 120],
|
|
@@ -38,12 +38,11 @@ const createAssetDirectory = function (myPath, callback) {
|
|
|
38
38
|
if (fs.existsSync(myPath)) {
|
|
39
39
|
return callback(fs.statSync(myPath));
|
|
40
40
|
}
|
|
41
|
-
throw new Error(myPath
|
|
41
|
+
throw new Error(`${myPath} don't exist`);
|
|
42
42
|
} catch (e) {
|
|
43
|
-
|
|
44
|
-
this.log("Create directory : " + myPath);
|
|
43
|
+
this.log(`Create directory : ${myPath}`);
|
|
45
44
|
fs.mkdir(myPath, (e) => {
|
|
46
|
-
if (!e ||
|
|
45
|
+
if (!e || e && e.code === "EEXIST") {
|
|
47
46
|
callback(fs.statSync(myPath));
|
|
48
47
|
} else {
|
|
49
48
|
this.log(e, "ERROR");
|
|
@@ -53,22 +52,21 @@ const createAssetDirectory = function (myPath, callback) {
|
|
|
53
52
|
};
|
|
54
53
|
|
|
55
54
|
const parseAssetsBundles = async function (table) {
|
|
56
|
-
|
|
55
|
+
const bundles = this.kernel.getBundles();
|
|
57
56
|
let result = null;
|
|
58
57
|
let name = null;
|
|
59
|
-
|
|
60
|
-
for (
|
|
58
|
+
const files = [];
|
|
59
|
+
for (const bundle in bundles) {
|
|
61
60
|
try {
|
|
62
61
|
result = await bundles[bundle].getPublicDirectory();
|
|
63
|
-
|
|
64
62
|
} catch (e) {
|
|
65
63
|
this.log(e, "ERROR");
|
|
66
64
|
}
|
|
67
65
|
if (result && result.length) {
|
|
68
66
|
name = bundles[bundle].bundleName;
|
|
69
67
|
try {
|
|
70
|
-
//let file = new nodefony.fileClass(bundles[bundle].publicPath);
|
|
71
|
-
|
|
68
|
+
// let file = new nodefony.fileClass(bundles[bundle].publicPath);
|
|
69
|
+
const file = result[0];
|
|
72
70
|
this.createSymlink(file.path, path.resolve(this.publicPath, name), (Srcpath, dstpath) => {
|
|
73
71
|
let size = "not Defined";
|
|
74
72
|
let sizeAssets = "not Defined";
|
|
@@ -76,7 +74,7 @@ const parseAssetsBundles = async function (table) {
|
|
|
76
74
|
size = nodefony.niceBytes(this.getSizeDirectory(Srcpath, /^docs$|^tests|^node_modules|^assets$/));
|
|
77
75
|
sizeAssets = nodefony.niceBytes(this.getSizeDirectory(path.resolve(Srcpath, "assets")));
|
|
78
76
|
} catch (e) {
|
|
79
|
-
//this.log(e, "ERROR");
|
|
77
|
+
// this.log(e, "ERROR");
|
|
80
78
|
}
|
|
81
79
|
table.push([
|
|
82
80
|
bundle,
|
|
@@ -90,10 +88,9 @@ const parseAssetsBundles = async function (table) {
|
|
|
90
88
|
this.log(e, "DEBUG");
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
|
-
|
|
94
91
|
}
|
|
95
92
|
try {
|
|
96
|
-
this.log(
|
|
93
|
+
this.log(`INSTALL LINK IN /web TOTAL SIZE : ${nodefony.niceBytes(this.getSizeDirectory(this.publicPath, /^docs$|^tests|^node_modules|^assets$/))}`, "DEBUG");
|
|
97
94
|
return files;
|
|
98
95
|
} catch (e) {
|
|
99
96
|
this.log(e, "WARNING");
|
|
@@ -111,14 +108,14 @@ const defaultOptions = {
|
|
|
111
108
|
captureRejections: true
|
|
112
109
|
}
|
|
113
110
|
};
|
|
111
|
+
|
|
114
112
|
/*
|
|
115
113
|
*
|
|
116
114
|
* CLI KERNEL
|
|
117
115
|
*
|
|
118
116
|
*/
|
|
119
117
|
class cliKernel extends nodefony.cli {
|
|
120
|
-
|
|
121
|
-
constructor(name, container, notificationsCenter, options) {
|
|
118
|
+
constructor (name, container, notificationsCenter, options) {
|
|
122
119
|
super(name, container, notificationsCenter, nodefony.extend(true, defaultOptions, options));
|
|
123
120
|
this.type = this.options.type;
|
|
124
121
|
this.optionsTables = optionsTaskTables;
|
|
@@ -136,16 +133,19 @@ class cliKernel extends nodefony.cli {
|
|
|
136
133
|
this.publicPath = null;
|
|
137
134
|
this.keepAlive = false;
|
|
138
135
|
switch (nodefony.packageManager) {
|
|
139
|
-
case
|
|
136
|
+
case "yarn":
|
|
140
137
|
this.packageManager = this.yarn;
|
|
141
138
|
break;
|
|
139
|
+
case "pnpm":
|
|
140
|
+
this.packageManager = this.pnpm;
|
|
141
|
+
break;
|
|
142
142
|
default:
|
|
143
143
|
this.packageManager = this.npm;
|
|
144
144
|
}
|
|
145
145
|
this.parseNodefonyCommand();
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
setKernel(kernel) {
|
|
148
|
+
setKernel (kernel) {
|
|
149
149
|
this.kernel = kernel;
|
|
150
150
|
if (this.kernel) {
|
|
151
151
|
this.publicPath = this.kernel.publicPath;
|
|
@@ -159,7 +159,7 @@ class cliKernel extends nodefony.cli {
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
setType(type) {
|
|
162
|
+
setType (type) {
|
|
163
163
|
switch (type) {
|
|
164
164
|
case "console":
|
|
165
165
|
case "CONSOLE":
|
|
@@ -174,21 +174,21 @@ class cliKernel extends nodefony.cli {
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
showBanner(data) {
|
|
177
|
+
showBanner (data) {
|
|
178
178
|
if (this.commander && this.commander.opts().json) {
|
|
179
179
|
return;
|
|
180
180
|
}
|
|
181
181
|
return super.showBanner(data);
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
async showAsciify(name = null) {
|
|
184
|
+
async showAsciify (name = null) {
|
|
185
185
|
if (this.commander && this.commander.opts().json) {
|
|
186
186
|
return Promise.resolve();
|
|
187
187
|
}
|
|
188
188
|
return await super.showAsciify(name);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
clearNodefonyCommand() {
|
|
191
|
+
clearNodefonyCommand () {
|
|
192
192
|
this.pattern = null;
|
|
193
193
|
this.command = null;
|
|
194
194
|
this.task = null;
|
|
@@ -199,10 +199,10 @@ class cliKernel extends nodefony.cli {
|
|
|
199
199
|
* PARSER
|
|
200
200
|
* command:task:action
|
|
201
201
|
*/
|
|
202
|
-
parseNodefonyCommand(cmd, args) {
|
|
202
|
+
parseNodefonyCommand (cmd, args) {
|
|
203
203
|
this.clearNodefonyCommand();
|
|
204
204
|
if (cmd) {
|
|
205
|
-
/*if (typeof this.commander.args[0] === "string") {
|
|
205
|
+
/* if (typeof this.commander.args[0] === "string") {
|
|
206
206
|
this.pattern = cmd.split(":");
|
|
207
207
|
} else {
|
|
208
208
|
this.pattern = cmd.split(":");
|
|
@@ -211,16 +211,14 @@ class cliKernel extends nodefony.cli {
|
|
|
211
211
|
if (args) {
|
|
212
212
|
this.args = args;
|
|
213
213
|
}
|
|
214
|
-
} else {
|
|
215
|
-
if (
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
this.args = this.commander.args[1];
|
|
223
|
-
}
|
|
214
|
+
} else if (this.commander && this.commander.args && this.commander.args.length) {
|
|
215
|
+
if (typeof this.commander.args[0] === "string") {
|
|
216
|
+
this.pattern = this.commander.args[0].split(":");
|
|
217
|
+
} else {
|
|
218
|
+
this.pattern = null;
|
|
219
|
+
}
|
|
220
|
+
if (this.commander.args[1]) {
|
|
221
|
+
this.args = this.commander.args[1];
|
|
224
222
|
}
|
|
225
223
|
}
|
|
226
224
|
if (this.pattern) {
|
|
@@ -239,19 +237,19 @@ class cliKernel extends nodefony.cli {
|
|
|
239
237
|
}
|
|
240
238
|
}
|
|
241
239
|
|
|
242
|
-
loadNodefonyCommand() {
|
|
240
|
+
loadNodefonyCommand () {
|
|
243
241
|
if (!this.commands) {
|
|
244
242
|
this.commands = {};
|
|
245
243
|
}
|
|
246
244
|
if (!this.commands.nodefony) {
|
|
247
245
|
this.commands.nodefony = {};
|
|
248
246
|
}
|
|
249
|
-
for (
|
|
247
|
+
for (const cmd in nodefony.commands) {
|
|
250
248
|
try {
|
|
251
|
-
|
|
249
|
+
const instance = new nodefony.commands[cmd](this, this.kernel);
|
|
252
250
|
this.commands.nodefony[instance.name] = instance;
|
|
253
251
|
if (this.commander.opts().debug) {
|
|
254
|
-
this.log(`Register Command ${instance.name}`, "DEBUG",
|
|
252
|
+
this.log(`Register Command ${instance.name}`, "DEBUG", "Nodefony");
|
|
255
253
|
}
|
|
256
254
|
} catch (e) {
|
|
257
255
|
this.log(e, "ERROR");
|
|
@@ -260,13 +258,13 @@ class cliKernel extends nodefony.cli {
|
|
|
260
258
|
}
|
|
261
259
|
}
|
|
262
260
|
|
|
263
|
-
loadCommand() {
|
|
261
|
+
loadCommand () {
|
|
264
262
|
return new Promise(async (resolve, reject) => {
|
|
265
|
-
|
|
263
|
+
const error = [];
|
|
266
264
|
if (!this.commands) {
|
|
267
265
|
this.commands = {};
|
|
268
266
|
}
|
|
269
|
-
for (
|
|
267
|
+
for (const bundle in this.kernel.bundles) {
|
|
270
268
|
if (!this.commands[bundle]) {
|
|
271
269
|
this.commands[bundle] = {};
|
|
272
270
|
}
|
|
@@ -282,7 +280,7 @@ class cliKernel extends nodefony.cli {
|
|
|
282
280
|
}
|
|
283
281
|
for (let i = 0; i < this.classCommand[bundle].length; i++) {
|
|
284
282
|
try {
|
|
285
|
-
|
|
283
|
+
const instance = new this.classCommand[bundle][i](this, this.kernel.bundles[bundle]);
|
|
286
284
|
this.commands[bundle][instance.name] = instance;
|
|
287
285
|
if (this.commander.opts().debug) {
|
|
288
286
|
this.log(`Register Command ${instance.name}`, "DEBUG", `Bundle ${bundle}`);
|
|
@@ -301,23 +299,21 @@ class cliKernel extends nodefony.cli {
|
|
|
301
299
|
});
|
|
302
300
|
}
|
|
303
301
|
|
|
304
|
-
getCommand(command, bundle = null) {
|
|
305
|
-
|
|
302
|
+
getCommand (command, bundle = null) {
|
|
303
|
+
const commands = [];
|
|
306
304
|
if (!command) {
|
|
307
305
|
throw new Error("getCommand Bad command argument");
|
|
308
306
|
}
|
|
309
307
|
if (bundle) {
|
|
310
308
|
if (!this.commands[bundle]) {
|
|
311
309
|
throw new Error(`getCommand command : ${command} Bundle : ${bundle} don't exist`);
|
|
310
|
+
} else if (this.commands[bundle][command]) {
|
|
311
|
+
return this.commands[bundle][command];
|
|
312
312
|
} else {
|
|
313
|
-
|
|
314
|
-
return this.commands[bundle][command];
|
|
315
|
-
} else {
|
|
316
|
-
throw new Error(`getCommand command : ${command} don't exist in Bundle ${bundle}`);
|
|
317
|
-
}
|
|
313
|
+
throw new Error(`getCommand command : ${command} don't exist in Bundle ${bundle}`);
|
|
318
314
|
}
|
|
319
315
|
} else {
|
|
320
|
-
for (
|
|
316
|
+
for (const bundle in this.commands) {
|
|
321
317
|
if (this.commands[bundle][command]) {
|
|
322
318
|
commands.push(this.commands[bundle][command]);
|
|
323
319
|
} else {
|
|
@@ -328,7 +324,7 @@ class cliKernel extends nodefony.cli {
|
|
|
328
324
|
return commands;
|
|
329
325
|
}
|
|
330
326
|
|
|
331
|
-
logCommand() {
|
|
327
|
+
logCommand () {
|
|
332
328
|
let txt = "";
|
|
333
329
|
if (this.command) {
|
|
334
330
|
if (this.task) {
|
|
@@ -338,97 +334,87 @@ class cliKernel extends nodefony.cli {
|
|
|
338
334
|
} else {
|
|
339
335
|
txt = `${this.command}:${this.task}:${this.action}`;
|
|
340
336
|
}
|
|
337
|
+
} else if (this.args.length) {
|
|
338
|
+
txt = `${this.command}:${this.task} ${this.args}`;
|
|
341
339
|
} else {
|
|
342
|
-
|
|
343
|
-
txt = `${this.command}:${this.task} ${this.args}`;
|
|
344
|
-
} else {
|
|
345
|
-
txt = `${this.command}:${this.task}`;
|
|
346
|
-
}
|
|
340
|
+
txt = `${this.command}:${this.task}`;
|
|
347
341
|
}
|
|
342
|
+
} else if (this.args.length) {
|
|
343
|
+
txt = `${this.command}: ${this.args}`;
|
|
348
344
|
} else {
|
|
349
|
-
|
|
350
|
-
txt = `${this.command}: ${this.args}`;
|
|
351
|
-
} else {
|
|
352
|
-
txt = `${this.command}`;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
} else {
|
|
356
|
-
if (this.args.length) {
|
|
357
|
-
txt = `${this.args}`;
|
|
345
|
+
txt = `${this.command}`;
|
|
358
346
|
}
|
|
347
|
+
} else if (this.args.length) {
|
|
348
|
+
txt = `${this.args}`;
|
|
359
349
|
}
|
|
360
350
|
return txt;
|
|
361
|
-
//this.log(txt, "INFO", "COMMAND");
|
|
351
|
+
// this.log(txt, "INFO", "COMMAND");
|
|
362
352
|
}
|
|
363
353
|
|
|
364
|
-
matchCommand() {
|
|
365
|
-
//console.log(this.command, ":", this.task, ":", this.action)
|
|
354
|
+
matchCommand () {
|
|
355
|
+
// console.log(this.command, ":", this.task, ":", this.action)
|
|
366
356
|
if (this.command) {
|
|
367
|
-
for (
|
|
357
|
+
for (const bundle in this.commands) {
|
|
368
358
|
if (Object.keys(this.commands[bundle]).length) {
|
|
369
359
|
if (this.command in this.commands[bundle]) {
|
|
370
|
-
|
|
360
|
+
const myCommand = this.commands[bundle][this.command];
|
|
371
361
|
if (!this.action) {
|
|
372
362
|
if (myCommand[this.task]) {
|
|
373
|
-
|
|
363
|
+
const myAction = myCommand[this.task];
|
|
374
364
|
try {
|
|
375
365
|
return myCommand.showBanner()
|
|
376
366
|
.then(async () => {
|
|
377
367
|
this.log(this.logCommand(), "INFO", "COMMAND");
|
|
378
|
-
|
|
368
|
+
const res = await myAction.apply(myCommand, this.args);
|
|
379
369
|
if (nodefony.isPromise(res)) {
|
|
380
|
-
res.then(() =>
|
|
381
|
-
return myCommand;
|
|
382
|
-
});
|
|
370
|
+
res.then(() => myCommand);
|
|
383
371
|
}
|
|
384
372
|
return myCommand;
|
|
385
373
|
})
|
|
386
374
|
.catch((e) => {
|
|
387
375
|
throw e;
|
|
388
|
-
//return Promise.reject(e);
|
|
376
|
+
// return Promise.reject(e);
|
|
389
377
|
});
|
|
390
378
|
} catch (e) {
|
|
391
379
|
throw e;
|
|
392
|
-
//myCommand.logger(e, "ERROR");
|
|
393
|
-
//return Promise.reject(e);
|
|
380
|
+
// myCommand.logger(e, "ERROR");
|
|
381
|
+
// return Promise.reject(e);
|
|
394
382
|
}
|
|
395
383
|
}
|
|
396
384
|
}
|
|
397
385
|
if (Object.keys(this.commands[bundle][this.command].tasks).length) {
|
|
398
|
-
|
|
386
|
+
const myCommand = this.commands[bundle][this.command];
|
|
399
387
|
if (this.task in myCommand.tasks) {
|
|
400
|
-
|
|
388
|
+
const myTask = myCommand.tasks[this.task];
|
|
401
389
|
if (this.action) {
|
|
402
390
|
if (myTask[this.action]) {
|
|
403
|
-
|
|
391
|
+
const myAction = myTask[this.action];
|
|
404
392
|
try {
|
|
405
393
|
return myTask.showBanner()
|
|
406
394
|
.then(async () => {
|
|
407
395
|
this.log(this.logCommand(), "INFO", "COMMAND");
|
|
408
|
-
|
|
396
|
+
const res = await myAction.apply(myTask, this.args);
|
|
409
397
|
if (nodefony.isPromise(res)) {
|
|
410
|
-
res.then(() =>
|
|
411
|
-
return myTask;
|
|
412
|
-
});
|
|
398
|
+
res.then(() => myTask);
|
|
413
399
|
}
|
|
414
400
|
return myTask;
|
|
415
401
|
})
|
|
416
402
|
.catch((e) => {
|
|
417
403
|
throw e;
|
|
418
|
-
//myTask.logger(e, "ERROR");
|
|
419
|
-
//return Promise.reject(e);
|
|
404
|
+
// myTask.logger(e, "ERROR");
|
|
405
|
+
// return Promise.reject(e);
|
|
420
406
|
});
|
|
421
407
|
} catch (e) {
|
|
422
408
|
throw e;
|
|
423
|
-
//myTask.logger(e, "ERROR");
|
|
424
|
-
//return Promise.reject(e);
|
|
409
|
+
// myTask.logger(e, "ERROR");
|
|
410
|
+
// return Promise.reject(e);
|
|
425
411
|
}
|
|
426
412
|
} else {
|
|
427
413
|
myTask.showHelp();
|
|
428
|
-
|
|
429
|
-
//this.log(error, "ERROR", "COMMAND");
|
|
414
|
+
const error = new Error(`${this.logCommand()} Action Not Found`);
|
|
415
|
+
// this.log(error, "ERROR", "COMMAND");
|
|
430
416
|
throw error;
|
|
431
|
-
//return Promise.reject(error);
|
|
417
|
+
// return Promise.reject(error);
|
|
432
418
|
}
|
|
433
419
|
} else {
|
|
434
420
|
// hook run
|
|
@@ -436,23 +422,21 @@ class cliKernel extends nodefony.cli {
|
|
|
436
422
|
.then(async () => {
|
|
437
423
|
this.log(this.logCommand(), "INFO", "COMMAND");
|
|
438
424
|
return await myTask.run.call(myCommand.tasks[this.task], this.args)
|
|
439
|
-
.then(() =>
|
|
440
|
-
return myCommand;
|
|
441
|
-
});
|
|
425
|
+
.then(() => myCommand);
|
|
442
426
|
})
|
|
443
427
|
.catch((e) => {
|
|
444
|
-
//myTask.logger(e, "ERROR");
|
|
445
|
-
//myTask.showHelp();
|
|
428
|
+
// myTask.logger(e, "ERROR");
|
|
429
|
+
// myTask.showHelp();
|
|
446
430
|
throw e;
|
|
447
|
-
//return Promise.reject(e);
|
|
431
|
+
// return Promise.reject(e);
|
|
448
432
|
});
|
|
449
433
|
}
|
|
450
434
|
} else {
|
|
451
435
|
myCommand.showHelp();
|
|
452
|
-
|
|
453
|
-
//this.log(error, "ERROR", "COMMAND");
|
|
436
|
+
const error = new Error(`${this.logCommand()} Task Not Found`);
|
|
437
|
+
// this.log(error, "ERROR", "COMMAND");
|
|
454
438
|
throw error;
|
|
455
|
-
//return Promise.reject(error);
|
|
439
|
+
// return Promise.reject(error);
|
|
456
440
|
}
|
|
457
441
|
} else {
|
|
458
442
|
continue;
|
|
@@ -465,7 +449,7 @@ class cliKernel extends nodefony.cli {
|
|
|
465
449
|
}
|
|
466
450
|
}
|
|
467
451
|
try {
|
|
468
|
-
|
|
452
|
+
const res = require(path.resolve(this.command));
|
|
469
453
|
if (typeof res === "function" && res.name === "appKernel") {
|
|
470
454
|
this.keepAlive = true;
|
|
471
455
|
this.parseNodefonyCommand();
|
|
@@ -479,37 +463,42 @@ class cliKernel extends nodefony.cli {
|
|
|
479
463
|
}
|
|
480
464
|
}
|
|
481
465
|
} else {
|
|
466
|
+
if (this.commander && this.commander.rawArgs.length) {
|
|
467
|
+
if (this.commander.rawArgs[2] === "help" || this.commander.rawArgs[2] === "-h" || this.commander.rawArgs[2] === "--help") {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
482
471
|
throw new Error("No Command found");
|
|
483
472
|
}
|
|
484
473
|
}
|
|
485
474
|
|
|
486
|
-
setHelp(info, command, descrption, options) {
|
|
475
|
+
setHelp (info, command, descrption, options) {
|
|
487
476
|
this.displayTable([
|
|
488
477
|
[info, this.clc.green(command), descrption]
|
|
489
478
|
], options || this.optionsTables);
|
|
490
479
|
}
|
|
491
480
|
|
|
492
|
-
setTitleHelp(title, options) {
|
|
481
|
+
setTitleHelp (title, options) {
|
|
493
482
|
this.displayTable([
|
|
494
483
|
[title, "", ""]
|
|
495
484
|
], options || this.optionsTitleTables);
|
|
496
485
|
}
|
|
497
486
|
|
|
498
|
-
showHelp() {
|
|
487
|
+
showHelp () {
|
|
499
488
|
super.showHelp();
|
|
500
489
|
this.blankLine();
|
|
501
490
|
if (nodefony.isTrunk) {
|
|
502
491
|
nodefony.showHelp(this);
|
|
503
492
|
}
|
|
504
493
|
if (this.commands) {
|
|
505
|
-
for (
|
|
494
|
+
for (const cmd in this.commands.nodefony) {
|
|
506
495
|
this.commands.nodefony[cmd].showHelp();
|
|
507
496
|
}
|
|
508
497
|
}
|
|
509
498
|
if (nodefony.isTrunk) {
|
|
510
499
|
this.setTitleHelp(`${this.clc.cyan("Bundles")}`);
|
|
511
500
|
}
|
|
512
|
-
for (
|
|
501
|
+
for (const bundle in this.commands) {
|
|
513
502
|
if (bundle === "nodefony") {
|
|
514
503
|
continue;
|
|
515
504
|
}
|
|
@@ -518,34 +507,34 @@ class cliKernel extends nodefony.cli {
|
|
|
518
507
|
} else {
|
|
519
508
|
continue;
|
|
520
509
|
}
|
|
521
|
-
for (
|
|
510
|
+
for (const command in this.commands[bundle]) {
|
|
522
511
|
this.commands[bundle][command].showHelp();
|
|
523
512
|
}
|
|
524
513
|
}
|
|
525
|
-
//this.terminate(0);
|
|
514
|
+
// this.terminate(0);
|
|
526
515
|
}
|
|
527
516
|
|
|
528
|
-
getSimpleGit(gitPath) {
|
|
517
|
+
getSimpleGit (gitPath) {
|
|
529
518
|
if (gitPath) {
|
|
530
519
|
return simpleGit(gitPath);
|
|
531
520
|
}
|
|
532
521
|
return simpleGit;
|
|
533
522
|
}
|
|
534
523
|
|
|
535
|
-
setGitPath(gitPath) {
|
|
524
|
+
setGitPath (gitPath) {
|
|
536
525
|
this.git = this.getSimpleGit(gitPath);
|
|
537
526
|
return this.git;
|
|
538
527
|
}
|
|
539
528
|
|
|
540
|
-
initSyslog(environment, debug, options = null) {
|
|
529
|
+
initSyslog (environment, debug, options = null) {
|
|
541
530
|
if (!this.kernel) {
|
|
542
531
|
return super.initSyslog(environment, debug, options);
|
|
543
532
|
}
|
|
544
533
|
if (this.commander && this.commander.opts().json) {
|
|
545
534
|
return;
|
|
546
535
|
}
|
|
547
|
-
|
|
548
|
-
|
|
536
|
+
const {syslog} = this;
|
|
537
|
+
const data = [6];
|
|
549
538
|
if (debug || this.debug) {
|
|
550
539
|
// INFO , DEBUG , WARNING
|
|
551
540
|
data.push(7);
|
|
@@ -565,27 +554,25 @@ class cliKernel extends nodefony.cli {
|
|
|
565
554
|
data.push(2);
|
|
566
555
|
data.push(3);
|
|
567
556
|
}
|
|
568
|
-
|
|
557
|
+
const conditions = {
|
|
569
558
|
severity: {
|
|
570
|
-
data
|
|
559
|
+
data
|
|
571
560
|
}
|
|
572
561
|
};
|
|
573
562
|
const format = nodefony.Syslog.formatDebug(debug || this.debug);
|
|
574
563
|
if (typeof format === "object") {
|
|
575
564
|
conditions.msgid = {
|
|
576
565
|
data: debug
|
|
577
|
-
}
|
|
566
|
+
};
|
|
578
567
|
}
|
|
579
|
-
syslog.listenWithConditions(
|
|
580
|
-
return nodefony.Syslog.normalizeLog.call(this, pdu, this.cluster);
|
|
581
|
-
});
|
|
568
|
+
syslog.listenWithConditions(conditions, (pdu) => nodefony.Syslog.normalizeLog.call(this, pdu, this.cluster));
|
|
582
569
|
}
|
|
583
570
|
|
|
584
571
|
// ASSETS LINK
|
|
585
|
-
assetInstall() {
|
|
572
|
+
assetInstall () {
|
|
586
573
|
return new Promise((resolve, reject) => {
|
|
587
574
|
try {
|
|
588
|
-
|
|
575
|
+
const table = this.displayTable([], {
|
|
589
576
|
head: [
|
|
590
577
|
"BUNDLES",
|
|
591
578
|
"DESTINATION PATH",
|
|
@@ -594,38 +581,37 @@ class cliKernel extends nodefony.cli {
|
|
|
594
581
|
"ASSETS COMPILE"
|
|
595
582
|
]
|
|
596
583
|
});
|
|
597
|
-
this.log(
|
|
584
|
+
this.log(`INSTALL ASSETS LINK IN WEB PUBLIC DIRECTORY : ${this.publicPath}`, "DEBUG");
|
|
598
585
|
createAssetDirectory.call(this, this.publicPath, async () => {
|
|
599
|
-
|
|
600
|
-
this.log(
|
|
586
|
+
const res = await parseAssetsBundles.call(this, table);
|
|
587
|
+
this.log(`\n${table.toString()}`, "DEBUG");
|
|
601
588
|
return resolve(res);
|
|
602
589
|
});
|
|
603
|
-
|
|
604
590
|
} catch (e) {
|
|
605
591
|
return reject(e);
|
|
606
592
|
}
|
|
607
593
|
});
|
|
608
594
|
}
|
|
609
595
|
|
|
610
|
-
getSizeDirectory(dir, exclude) {
|
|
596
|
+
getSizeDirectory (dir, exclude) {
|
|
611
597
|
let stat = null;
|
|
612
598
|
try {
|
|
613
599
|
if (exclude) {
|
|
614
|
-
|
|
600
|
+
const basename = path.basename(dir);
|
|
615
601
|
if (basename.match(exclude)) {
|
|
616
602
|
return 0;
|
|
617
603
|
}
|
|
618
604
|
}
|
|
619
605
|
stat = fs.lstatSync(dir);
|
|
620
606
|
} catch (e) {
|
|
621
|
-
//this.log(e, "WARNING");
|
|
607
|
+
// this.log(e, "WARNING");
|
|
622
608
|
return 0;
|
|
623
609
|
}
|
|
624
610
|
|
|
625
611
|
let files = null;
|
|
626
612
|
switch (true) {
|
|
627
613
|
case stat.isFile():
|
|
628
|
-
throw new Error(dir
|
|
614
|
+
throw new Error(`${dir} is not a directory`);
|
|
629
615
|
case stat.isDirectory():
|
|
630
616
|
files = fs.readdirSync(dir);
|
|
631
617
|
break;
|
|
@@ -633,12 +619,12 @@ class cliKernel extends nodefony.cli {
|
|
|
633
619
|
files = fs.realpathSync(dir);
|
|
634
620
|
break;
|
|
635
621
|
default:
|
|
636
|
-
throw new Error(dir
|
|
622
|
+
throw new Error(`${dir} is not a directory`);
|
|
637
623
|
}
|
|
638
624
|
let totalSizeBytes = 0;
|
|
639
625
|
let dirSize = null;
|
|
640
626
|
for (let i = 0; i < files.length; i++) {
|
|
641
|
-
|
|
627
|
+
const myPath = `${dir}/${files[i]}`;
|
|
642
628
|
try {
|
|
643
629
|
stat = fs.lstatSync(myPath);
|
|
644
630
|
} catch (e) {
|
|
@@ -655,7 +641,7 @@ class cliKernel extends nodefony.cli {
|
|
|
655
641
|
totalSizeBytes += dirSize;
|
|
656
642
|
break;
|
|
657
643
|
case stat.isSymbolicLink():
|
|
658
|
-
//console.log("isSymbolicLink")
|
|
644
|
+
// console.log("isSymbolicLink")
|
|
659
645
|
try {
|
|
660
646
|
dirSize = this.getSizeDirectory(fs.realpathSync(myPath), exclude);
|
|
661
647
|
totalSizeBytes += dirSize;
|
|
@@ -666,7 +652,7 @@ class cliKernel extends nodefony.cli {
|
|
|
666
652
|
return totalSizeBytes;
|
|
667
653
|
}
|
|
668
654
|
|
|
669
|
-
createSymlink(srcpath, dstpath, callback) {
|
|
655
|
+
createSymlink (srcpath, dstpath, callback) {
|
|
670
656
|
let res = null;
|
|
671
657
|
try {
|
|
672
658
|
res = fs.statSync(srcpath);
|
|
@@ -677,13 +663,14 @@ class cliKernel extends nodefony.cli {
|
|
|
677
663
|
fs.unlinkSync(dstpath);
|
|
678
664
|
}
|
|
679
665
|
} catch (e) {
|
|
680
|
-
//console.log("PASS CATCH")
|
|
681
|
-
//console.log(e ,"ERROR")
|
|
666
|
+
// console.log("PASS CATCH")
|
|
667
|
+
// console.log(e ,"ERROR")
|
|
682
668
|
}
|
|
683
|
-
//console.log(srcpath+" : "+ dstpath);
|
|
669
|
+
// console.log(srcpath+" : "+ dstpath);
|
|
684
670
|
res = shell.ln("-sf", srcpath, dstpath);
|
|
685
671
|
return callback(srcpath, dstpath);
|
|
686
|
-
|
|
672
|
+
|
|
673
|
+
/* res = fs.symlink(srcpath, dstpath, (e) => {
|
|
687
674
|
if (!e || (e && e.code === 'EEXIST')) {
|
|
688
675
|
callback(srcpath, dstpath);
|
|
689
676
|
} else {
|
|
@@ -692,12 +679,12 @@ class cliKernel extends nodefony.cli {
|
|
|
692
679
|
});
|
|
693
680
|
callback(srcpath, dstpath);*/
|
|
694
681
|
} catch (e) {
|
|
695
|
-
this.log(
|
|
682
|
+
this.log(`FILE :${srcpath} not exist: ${e}`, "ERROR");
|
|
696
683
|
}
|
|
697
684
|
}
|
|
698
685
|
|
|
699
686
|
// deprecated
|
|
700
|
-
/*async listPackage(myPath) {
|
|
687
|
+
/* async listPackage(myPath) {
|
|
701
688
|
let tab = [];
|
|
702
689
|
let ele = [];
|
|
703
690
|
try {
|
|
@@ -788,7 +775,7 @@ class cliKernel extends nodefony.cli {
|
|
|
788
775
|
});
|
|
789
776
|
}*/
|
|
790
777
|
|
|
791
|
-
async installPackage(bundle, env) {
|
|
778
|
+
async installPackage (bundle, env) {
|
|
792
779
|
try {
|
|
793
780
|
if (bundle instanceof nodefony.Bundle) {
|
|
794
781
|
return await this.packageManager(["install"], bundle.path, env);
|
|
@@ -799,7 +786,7 @@ class cliKernel extends nodefony.cli {
|
|
|
799
786
|
throw new Error("installPackage bundle must be an instance of nodefony.Bundle");
|
|
800
787
|
} catch (e) {
|
|
801
788
|
if (e.code !== "ENOENT") {
|
|
802
|
-
this.log(
|
|
789
|
+
this.log(`Install Package BUNDLE : ${bundle.name}:`, "ERROR");
|
|
803
790
|
this.log(e, "ERROR");
|
|
804
791
|
throw e;
|
|
805
792
|
}
|
|
@@ -807,10 +794,10 @@ class cliKernel extends nodefony.cli {
|
|
|
807
794
|
}
|
|
808
795
|
}
|
|
809
796
|
|
|
810
|
-
async rebuildPackage(bundle, env = "
|
|
797
|
+
async rebuildPackage (bundle, env = "production") {
|
|
811
798
|
let cmd = null;
|
|
812
799
|
switch (nodefony.packageManager) {
|
|
813
|
-
case
|
|
800
|
+
case "yarn":
|
|
814
801
|
cmd = ["install", "--force"];
|
|
815
802
|
break;
|
|
816
803
|
default:
|
|
@@ -828,7 +815,7 @@ class cliKernel extends nodefony.cli {
|
|
|
828
815
|
throw new Error("rebuildPackage bundle must be an instance of nodefony.Bundle");
|
|
829
816
|
} catch (e) {
|
|
830
817
|
if (e.code !== "ENOENT") {
|
|
831
|
-
this.log(
|
|
818
|
+
this.log(`rebuild Package BUNDLE : ${bundle.name}:`, "ERROR");
|
|
832
819
|
this.log(e, "ERROR");
|
|
833
820
|
throw e;
|
|
834
821
|
}
|
|
@@ -836,7 +823,7 @@ class cliKernel extends nodefony.cli {
|
|
|
836
823
|
}
|
|
837
824
|
}
|
|
838
825
|
|
|
839
|
-
async outdatedPackage(bundle) {
|
|
826
|
+
async outdatedPackage (bundle) {
|
|
840
827
|
try {
|
|
841
828
|
if (bundle instanceof nodefony.Bundle) {
|
|
842
829
|
return await this.packageManager(["outdated"], bundle.path);
|
|
@@ -847,7 +834,7 @@ class cliKernel extends nodefony.cli {
|
|
|
847
834
|
throw new Error("Method outdatedPackage bundle must be an instance of nodefony.Bundle");
|
|
848
835
|
} catch (e) {
|
|
849
836
|
if (e.code !== "ENOENT") {
|
|
850
|
-
this.log(
|
|
837
|
+
this.log(`Outdated Package BUNDLE : ${bundle.name}:`, "ERROR");
|
|
851
838
|
this.log(e, "ERROR");
|
|
852
839
|
throw e;
|
|
853
840
|
}
|
|
@@ -855,13 +842,13 @@ class cliKernel extends nodefony.cli {
|
|
|
855
842
|
}
|
|
856
843
|
}
|
|
857
844
|
|
|
858
|
-
listenRejection() {
|
|
859
|
-
process.on(
|
|
845
|
+
listenRejection () {
|
|
846
|
+
process.on("rejectionHandled", (promise) => {
|
|
860
847
|
this.log("PROMISE REJECTION EVENT ", "CRITIC");
|
|
861
848
|
this.unhandledRejections.delete(promise);
|
|
862
849
|
});
|
|
863
|
-
process.on(
|
|
864
|
-
this.log(
|
|
850
|
+
process.on("unhandledRejection", (reason, promise) => {
|
|
851
|
+
this.log(`WARNING !!! PROMISE CHAIN BREAKING : ${reason}`, "WARNING");
|
|
865
852
|
this.unhandledRejections.set(promise, reason);
|
|
866
853
|
if (this.kernel && this.kernel.type === "SERVER") {
|
|
867
854
|
console.trace(promise);
|
|
@@ -869,7 +856,7 @@ class cliKernel extends nodefony.cli {
|
|
|
869
856
|
});
|
|
870
857
|
}
|
|
871
858
|
|
|
872
|
-
terminate(code) {
|
|
859
|
+
terminate (code) {
|
|
873
860
|
if (this.kernel) {
|
|
874
861
|
return this.kernel.terminate(code);
|
|
875
862
|
}
|