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/bundle.es6
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const Module = require("module");
|
|
2
2
|
|
|
3
|
-
const colorLogEvent = clc.cyan.bgBlue(
|
|
3
|
+
const colorLogEvent = clc.cyan.bgBlue("EVENT BUNDLE");
|
|
4
4
|
const regFixtures = /^(\w+)Fixtures.js$/;
|
|
5
5
|
const regController = /^(\w+)Controller\.[m]?js$/;
|
|
6
6
|
const regClassController = /^(\w+)Controller$/;
|
|
@@ -11,6 +11,7 @@ const regI18nFile = /^(.*)\.(.._..)\.(.*)$/;
|
|
|
11
11
|
const regConfigFile = /^(.*)\..*$/;
|
|
12
12
|
const regRoutingFile = /^(routing)\..*$/;
|
|
13
13
|
const regWebpackCongig = /^(webpack)\.(dev\.|prod\.)?config\.js$/;
|
|
14
|
+
const semver = require("semver");
|
|
14
15
|
|
|
15
16
|
const checkIngnoreFile = function (string, basename) {
|
|
16
17
|
let file = null;
|
|
@@ -32,7 +33,7 @@ const checkIngnoreFile = function (string, basename) {
|
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
const moduleFindDependencies = class moduleFindDependencies {
|
|
35
|
-
constructor(Path, type, bundle) {
|
|
36
|
+
constructor (Path, type, bundle) {
|
|
36
37
|
this.container = {};
|
|
37
38
|
this.bundle = bundle;
|
|
38
39
|
this.childs = [];
|
|
@@ -54,48 +55,52 @@ const moduleFindDependencies = class moduleFindDependencies {
|
|
|
54
55
|
this.loader = this.bundle.reloadService;
|
|
55
56
|
break;
|
|
56
57
|
default:
|
|
57
|
-
throw new Error(
|
|
58
|
+
throw new Error(`moduleFindDependencies type not valid : ${type}`);
|
|
58
59
|
}
|
|
59
60
|
this.cache = Module._cache;
|
|
60
61
|
if (Path) {
|
|
61
62
|
this.findRequire(Path);
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
+
|
|
66
|
+
set (ele, val) {
|
|
65
67
|
return this.container[ele] = val;
|
|
66
68
|
}
|
|
67
|
-
|
|
69
|
+
|
|
70
|
+
get (ele) {
|
|
68
71
|
return this.container[ele];
|
|
69
72
|
}
|
|
70
|
-
|
|
73
|
+
|
|
74
|
+
setChild (path) {
|
|
71
75
|
this.childs.push(path);
|
|
72
76
|
}
|
|
73
|
-
|
|
77
|
+
|
|
78
|
+
length () {
|
|
74
79
|
return Object.keys(this.container).length;
|
|
75
80
|
}
|
|
76
|
-
|
|
81
|
+
|
|
82
|
+
findRequire (Path, check) {
|
|
77
83
|
if (check === undefined) {
|
|
78
84
|
check = true;
|
|
79
85
|
}
|
|
80
|
-
for (
|
|
86
|
+
for (const module in this.cache) {
|
|
81
87
|
if (this.cache[module].filename.indexOf(this.path) >= 0) {
|
|
82
|
-
|
|
88
|
+
const basename = path.basename(this.cache[module].filename);
|
|
83
89
|
if (check && this.cache[module].filename.indexOf(Path) >= 0) {
|
|
84
90
|
if (path.basename(Path) === basename) {
|
|
85
91
|
this.setChild(this.cache[module].filename);
|
|
86
92
|
}
|
|
87
93
|
}
|
|
88
94
|
if (this.cache[module].children.length) {
|
|
89
|
-
for (
|
|
95
|
+
for (const child in this.cache[module].children) {
|
|
90
96
|
if (this.cache[module].children[child].filename.indexOf(Path) >= 0) {
|
|
91
|
-
|
|
97
|
+
const res = this.reg.exec(basename);
|
|
92
98
|
if (res) {
|
|
93
99
|
this.set(res[1], this.cache[module].filename);
|
|
94
100
|
return this;
|
|
95
|
-
} else {
|
|
96
|
-
this.setChild(this.cache[module].filename);
|
|
97
|
-
return this.findRequire(this.cache[module].filename, false);
|
|
98
101
|
}
|
|
102
|
+
this.setChild(this.cache[module].filename);
|
|
103
|
+
return this.findRequire(this.cache[module].filename, false);
|
|
99
104
|
}
|
|
100
105
|
}
|
|
101
106
|
}
|
|
@@ -103,26 +108,27 @@ const moduleFindDependencies = class moduleFindDependencies {
|
|
|
103
108
|
}
|
|
104
109
|
return this;
|
|
105
110
|
}
|
|
106
|
-
|
|
111
|
+
|
|
112
|
+
reload () {
|
|
107
113
|
if (this.length()) {
|
|
108
114
|
for (let i = 0; i < this.childs.length; i++) {
|
|
109
|
-
this.bundle.log(
|
|
115
|
+
this.bundle.log(`Reload ${this.type} Dependency : ${this.childs[i]}`);
|
|
110
116
|
this.bundle.loadFile(this.childs[i], true);
|
|
111
117
|
}
|
|
112
|
-
for (
|
|
118
|
+
for (const control in this.container) {
|
|
113
119
|
this.loader.call(this.bundle, control, this.container[control], true);
|
|
114
120
|
}
|
|
115
121
|
}
|
|
116
122
|
}
|
|
117
123
|
};
|
|
118
124
|
|
|
119
|
-
const defaultWatcher = function (reg
|
|
125
|
+
const defaultWatcher = function (reg /* , settings*/) {
|
|
120
126
|
return {
|
|
121
127
|
ignoreInitial: true,
|
|
122
128
|
ignored: [
|
|
123
129
|
(string) => {
|
|
124
|
-
|
|
125
|
-
|
|
130
|
+
const basename = path.basename(string);
|
|
131
|
+
const file = checkIngnoreFile(string, basename);
|
|
126
132
|
if (file === true) {
|
|
127
133
|
return true;
|
|
128
134
|
}
|
|
@@ -146,46 +152,50 @@ const defaultOptions = {
|
|
|
146
152
|
captureRejections: true
|
|
147
153
|
}
|
|
148
154
|
};
|
|
155
|
+
|
|
149
156
|
/*
|
|
150
157
|
* BUNDLE CLASS
|
|
151
158
|
*/
|
|
152
159
|
class Bundle extends nodefony.Service {
|
|
153
|
-
constructor(name, kernel, container) {
|
|
160
|
+
constructor (name, kernel, container) {
|
|
154
161
|
super(name, container, null, nodefony.extend(true, {}, defaultOptions));
|
|
155
|
-
this.log(
|
|
162
|
+
this.log(`\x1b[36m REGISTER BUNDLE : ${this.name} \x1b[0m`, "DEBUG", this.kernel.cli.clc.magenta("KERNEL"));
|
|
156
163
|
this.bundleName = path.basename(this.path);
|
|
157
164
|
this.location = path.dirname(this.path);
|
|
158
165
|
this.publicPath = path.resolve(this.path, "Resources", "public");
|
|
159
166
|
this.environment = this.kernel.environment;
|
|
160
167
|
this.waitBundleReady = false;
|
|
161
|
-
this.setParameters(
|
|
162
|
-
this.production =
|
|
168
|
+
this.setParameters(`bundles.${this.name}`, this.getParameters(`bundles.${this.name}`) || {});
|
|
169
|
+
this.production = this.kernel.environment === "prod";
|
|
163
170
|
this.package = require(path.resolve(this.path, "package.json"));
|
|
171
|
+
this.ckeckSemver(this.package.version);
|
|
164
172
|
this.version = this.package.version;
|
|
165
173
|
this.packageName = this.package.name;
|
|
166
174
|
this.isCore = this.kernel.isBundleCore(this.name);
|
|
175
|
+
this.ready = false;
|
|
176
|
+
this.booted = false;
|
|
167
177
|
|
|
168
178
|
// services
|
|
169
179
|
this.injectionService = this.get("injection");
|
|
170
180
|
this.reader = this.kernel.reader;
|
|
171
181
|
|
|
172
182
|
// webpack
|
|
173
|
-
this.webPackConfig = null;
|
|
174
183
|
this.webpackWatch = false;
|
|
175
184
|
this.webpackCompiler = null;
|
|
176
185
|
this.webPackConfig = null;
|
|
177
186
|
this.watching = null;
|
|
187
|
+
this.lastWebpackStats = null;
|
|
178
188
|
|
|
179
189
|
// config
|
|
180
190
|
this.regConfigFile = regConfigFile;
|
|
181
191
|
this.configPath = path.resolve(this.path, "Resources", "config");
|
|
182
|
-
//views
|
|
192
|
+
// views
|
|
183
193
|
this.views = {};
|
|
184
194
|
this.views["."] = {};
|
|
185
195
|
this.watcherView = null;
|
|
186
196
|
// views
|
|
187
197
|
this.serviceTemplate = this.get("templating");
|
|
188
|
-
this.regTemplateExt = new RegExp(
|
|
198
|
+
this.regTemplateExt = new RegExp(`^(.+)\.${this.serviceTemplate.extention}$`);
|
|
189
199
|
this.viewsPath = path.resolve(this.path, "Resources", "views");
|
|
190
200
|
|
|
191
201
|
// controllers
|
|
@@ -226,8 +236,8 @@ class Bundle extends nodefony.Service {
|
|
|
226
236
|
try {
|
|
227
237
|
this.router = this.get("router");
|
|
228
238
|
this.sockjs = this.get("sockjs");
|
|
229
|
-
//this.orm = this.get("orm");
|
|
230
|
-
//console.log("PASSS",this.orm)
|
|
239
|
+
// this.orm = this.get("orm");
|
|
240
|
+
// console.log("PASSS",this.orm)
|
|
231
241
|
this.webpackService = this.get("webpack");
|
|
232
242
|
this.translation = this.get("translation");
|
|
233
243
|
// Register internationalisation
|
|
@@ -235,7 +245,7 @@ class Bundle extends nodefony.Service {
|
|
|
235
245
|
this.locale = this.translation.defaultLocale;
|
|
236
246
|
}
|
|
237
247
|
// I18n
|
|
238
|
-
this.i18nFiles =
|
|
248
|
+
this.i18nFiles = await this.findI18nFiles();
|
|
239
249
|
|
|
240
250
|
// Register Entity
|
|
241
251
|
await this.registerEntities();
|
|
@@ -250,31 +260,45 @@ class Bundle extends nodefony.Service {
|
|
|
250
260
|
});
|
|
251
261
|
|
|
252
262
|
this.kernel.once("onPostReady", async () => {
|
|
253
|
-
switch(this.kernel.environment){
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
263
|
+
switch (this.kernel.environment) {
|
|
264
|
+
case "production":
|
|
265
|
+
case "prod":
|
|
266
|
+
case "preprod":
|
|
267
|
+
case "preproduction":
|
|
268
|
+
this.clean();
|
|
269
|
+
break;
|
|
260
270
|
}
|
|
261
271
|
});
|
|
262
272
|
// BUNDLE EVENTS
|
|
263
|
-
this.register()
|
|
273
|
+
this.register();
|
|
264
274
|
}
|
|
265
275
|
|
|
266
|
-
|
|
276
|
+
ckeckSemver (version) {
|
|
277
|
+
try {
|
|
278
|
+
const res = semver.valid(version);
|
|
279
|
+
if (!res) {
|
|
280
|
+
this.log(`Bad Bundle Semantic Versioning : ${version} Check http://semver.org `, "WARNING");
|
|
281
|
+
}
|
|
282
|
+
return res;
|
|
283
|
+
} catch (e) {
|
|
284
|
+
this.log(e, "ERROR");
|
|
285
|
+
throw e;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
async register () {
|
|
267
290
|
return await this.emitAsync("onRegister", this);
|
|
268
291
|
}
|
|
269
292
|
|
|
270
|
-
static excludeDir() {
|
|
293
|
+
static excludeDir () {
|
|
271
294
|
return /^public$|^node_modules$|^clones$|^\.git|assets$|tmp$|doc$|build$|css$|scss$|public$/;
|
|
272
295
|
}
|
|
273
|
-
|
|
274
|
-
|
|
296
|
+
|
|
297
|
+
static exclude () {
|
|
298
|
+
return /yarn.lock$|package-lock.json$|pnpm-lock.yaml|yarn-error.log$|package.json$/;
|
|
275
299
|
}
|
|
276
300
|
|
|
277
|
-
async initialize() {
|
|
301
|
+
async initialize () {
|
|
278
302
|
// Register services before boot
|
|
279
303
|
return await this.registerServices()
|
|
280
304
|
.then(async (results) => {
|
|
@@ -286,38 +310,37 @@ class Bundle extends nodefony.Service {
|
|
|
286
310
|
dir = this.resourcesFiles;
|
|
287
311
|
}
|
|
288
312
|
// config
|
|
289
|
-
|
|
313
|
+
const conf = dir.find("config")[0];
|
|
290
314
|
if (conf) {
|
|
291
315
|
this.kernel.readConfig.call(this, null, conf.children, (result) => {
|
|
292
|
-
//console.log(result)
|
|
293
316
|
this.parseConfig(result);
|
|
294
317
|
});
|
|
295
318
|
} else {
|
|
296
319
|
throw new Error("Bundle must have config directory");
|
|
297
320
|
}
|
|
298
|
-
//EVENT BOOT BUNDLE
|
|
321
|
+
// EVENT BOOT BUNDLE
|
|
299
322
|
await this.emitAsync("onInitialize", this);
|
|
300
323
|
return results;
|
|
301
324
|
});
|
|
302
325
|
}
|
|
303
326
|
|
|
304
|
-
async find() {
|
|
327
|
+
async find () {
|
|
305
328
|
return this.findResult = await this.finder
|
|
306
329
|
.in(this.path)
|
|
307
330
|
.then((result) => {
|
|
308
|
-
//this.log(result[0].children.length ,'WARNING', `FINDER ${this.name}`);
|
|
331
|
+
// this.log(result[0].children.length ,'WARNING', `FINDER ${this.name}`);
|
|
309
332
|
this.resourcesFiles = result[0].children.find("Resources");
|
|
310
333
|
return result[0].children;
|
|
311
334
|
})
|
|
312
|
-
.catch(e => {
|
|
335
|
+
.catch((e) => {
|
|
313
336
|
this.log(e, "ERROR");
|
|
314
337
|
});
|
|
315
338
|
}
|
|
316
339
|
|
|
317
|
-
boot() {
|
|
340
|
+
boot () {
|
|
318
341
|
return new Promise(async (resolve, reject) => {
|
|
319
342
|
try {
|
|
320
|
-
//EVENT BOOT BUNDLE
|
|
343
|
+
// EVENT BOOT BUNDLE
|
|
321
344
|
await this.emitAsync("onBoot", this);
|
|
322
345
|
// finder controller
|
|
323
346
|
await this.findControllerFiles();
|
|
@@ -335,14 +358,18 @@ class Bundle extends nodefony.Service {
|
|
|
335
358
|
} catch (e) {
|
|
336
359
|
return reject(e);
|
|
337
360
|
}
|
|
361
|
+
this.booted = true;
|
|
338
362
|
if (this.waitBundleReady === false) {
|
|
339
363
|
await this.emitAsync("onReady", this);
|
|
364
|
+
this.ready = true;
|
|
365
|
+
} else if (this.ready) {
|
|
366
|
+
await this.emitAsync("onReady", this);
|
|
340
367
|
}
|
|
341
368
|
return resolve(this);
|
|
342
369
|
});
|
|
343
370
|
}
|
|
344
371
|
|
|
345
|
-
clean() {
|
|
372
|
+
clean () {
|
|
346
373
|
this.log(`CLEAN MEMORY BUNDLE : ${this.name}`);
|
|
347
374
|
this.findResult = null;
|
|
348
375
|
delete this.findResult;
|
|
@@ -354,8 +381,8 @@ class Bundle extends nodefony.Service {
|
|
|
354
381
|
delete this.watching;
|
|
355
382
|
this.viewFiles = null;
|
|
356
383
|
delete this.viewFiles;
|
|
357
|
-
//this.i18nFiles = null;
|
|
358
|
-
//delete this.i18nFiles;
|
|
384
|
+
// this.i18nFiles = null;
|
|
385
|
+
// delete this.i18nFiles;
|
|
359
386
|
this.controllerFiles = null;
|
|
360
387
|
delete this.controllerFiles;
|
|
361
388
|
this.commandFiles = null;
|
|
@@ -366,14 +393,16 @@ class Bundle extends nodefony.Service {
|
|
|
366
393
|
delete this.fixtureFiles;
|
|
367
394
|
this.entityFiles = null;
|
|
368
395
|
delete this.entityFiles;
|
|
396
|
+
this.lastWebpackStats = null;
|
|
397
|
+
delete this.lastWebpackStats;
|
|
369
398
|
}
|
|
370
399
|
|
|
371
|
-
emitAsync() {
|
|
400
|
+
emitAsync () {
|
|
372
401
|
this.log(`${colorLogEvent} ${arguments[0]}`, "DEBUG");
|
|
373
402
|
return super.emitAsync.apply(this, arguments);
|
|
374
403
|
}
|
|
375
404
|
|
|
376
|
-
initWebpack() {
|
|
405
|
+
initWebpack () {
|
|
377
406
|
try {
|
|
378
407
|
return this.findWebPackConfig()
|
|
379
408
|
.then((compiler) => {
|
|
@@ -401,14 +430,12 @@ class Bundle extends nodefony.Service {
|
|
|
401
430
|
}
|
|
402
431
|
}
|
|
403
432
|
|
|
404
|
-
compileWebpack() {
|
|
433
|
+
compileWebpack () {
|
|
405
434
|
return new Promise((resolve, reject) => {
|
|
406
435
|
if (this.webpackCompiler) {
|
|
407
436
|
try {
|
|
408
|
-
return this.webpackService.runCompiler(this.webpackCompiler, this.name
|
|
409
|
-
.catch(e =>
|
|
410
|
-
return reject(e);
|
|
411
|
-
});
|
|
437
|
+
return this.webpackService.runCompiler(this.webpackCompiler, `${this.name}_${this.webpackCompiler.name}`, this.name, this.webpackCompiler.name)
|
|
438
|
+
.catch((e) => reject(e));
|
|
412
439
|
} catch (e) {
|
|
413
440
|
return reject(e);
|
|
414
441
|
}
|
|
@@ -417,7 +444,7 @@ class Bundle extends nodefony.Service {
|
|
|
417
444
|
});
|
|
418
445
|
}
|
|
419
446
|
|
|
420
|
-
findWebPackConfig() {
|
|
447
|
+
findWebPackConfig () {
|
|
421
448
|
return new Promise((resolve, reject) => {
|
|
422
449
|
let res = null;
|
|
423
450
|
let file = null;
|
|
@@ -437,12 +464,13 @@ class Bundle extends nodefony.Service {
|
|
|
437
464
|
case "react":
|
|
438
465
|
file = null;
|
|
439
466
|
try {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
467
|
+
file = path.resolve(this.path, "config", "webpack.config.js");
|
|
468
|
+
|
|
469
|
+
/* switch (process.env.NODE_ENV) {
|
|
470
|
+
case "development":
|
|
471
|
+
case "production":
|
|
472
|
+
break;
|
|
473
|
+
}*/
|
|
446
474
|
res = new nodefony.fileClass(file);
|
|
447
475
|
process.env.PUBLIC_URL = path.resolve("/", this.bundleName, "dist");
|
|
448
476
|
return resolve(this.loadWebpackConfig(res));
|
|
@@ -452,7 +480,14 @@ class Bundle extends nodefony.Service {
|
|
|
452
480
|
}
|
|
453
481
|
break;
|
|
454
482
|
case "vue":
|
|
455
|
-
|
|
483
|
+
try {
|
|
484
|
+
file = path.resolve(this.path, "node_modules", "@vue", "cli-service", "webpack.config.js");
|
|
485
|
+
new nodefony.fileClass(file);
|
|
486
|
+
} catch (e) {
|
|
487
|
+
const cliService = require.resolve("@vue/cli-service");
|
|
488
|
+
file = path.resolve(path.dirname(cliService), "..", "webpack.config.js");
|
|
489
|
+
}
|
|
490
|
+
// console.log(file , require.resolve("@vue/cli-service"))
|
|
456
491
|
try {
|
|
457
492
|
this.webpackConfigFile = new nodefony.fileClass(file);
|
|
458
493
|
process.env.VUE_CLI_CONTEXT = this.path;
|
|
@@ -477,18 +512,19 @@ class Bundle extends nodefony.Service {
|
|
|
477
512
|
});
|
|
478
513
|
}
|
|
479
514
|
|
|
480
|
-
loadWebpackConfig(conf) {
|
|
515
|
+
loadWebpackConfig (conf) {
|
|
481
516
|
return this.webpackService.loadConfig(conf, this)
|
|
482
517
|
.then((compiler) => {
|
|
483
518
|
shell.cd(this.kernel.rootDir);
|
|
484
519
|
return compiler;
|
|
485
|
-
})
|
|
520
|
+
})
|
|
521
|
+
.catch((e) => {
|
|
486
522
|
shell.cd(this.kernel.rootDir);
|
|
487
523
|
throw e;
|
|
488
524
|
});
|
|
489
525
|
}
|
|
490
526
|
|
|
491
|
-
initWatchers() {
|
|
527
|
+
initWatchers () {
|
|
492
528
|
if (!this.settings.watch) {
|
|
493
529
|
return;
|
|
494
530
|
}
|
|
@@ -497,8 +533,8 @@ class Bundle extends nodefony.Service {
|
|
|
497
533
|
let i18n = false;
|
|
498
534
|
let config = false;
|
|
499
535
|
let services = false;
|
|
500
|
-
//let entities = false;
|
|
501
|
-
|
|
536
|
+
// let entities = false;
|
|
537
|
+
const regJs = new RegExp(".*\.js$|.*\.es6$|.*\.es7$|.*\.mjs$");
|
|
502
538
|
try {
|
|
503
539
|
switch (typeof this.settings.watch) {
|
|
504
540
|
case "object":
|
|
@@ -527,7 +563,7 @@ class Bundle extends nodefony.Service {
|
|
|
527
563
|
this.watcherController.setSockjsServer(this.sockjs);
|
|
528
564
|
this.watcherController.listenWatcherController();
|
|
529
565
|
this.kernel.on("onTerminate", () => {
|
|
530
|
-
this.log(
|
|
566
|
+
this.log(`Watching Ended : ${this.watcherController.path}`, "INFO");
|
|
531
567
|
this.watcherController.close();
|
|
532
568
|
});
|
|
533
569
|
}
|
|
@@ -537,7 +573,7 @@ class Bundle extends nodefony.Service {
|
|
|
537
573
|
this.watcherView.listenWatcherView();
|
|
538
574
|
this.watcherView.setSockjsServer(this.sockjs);
|
|
539
575
|
this.kernel.on("onTerminate", () => {
|
|
540
|
-
this.log(
|
|
576
|
+
this.log(`Watching Ended : ${this.watcherView.path}`, "INFO");
|
|
541
577
|
this.watcherView.close();
|
|
542
578
|
});
|
|
543
579
|
}
|
|
@@ -547,7 +583,7 @@ class Bundle extends nodefony.Service {
|
|
|
547
583
|
this.watcherI18n.listenWatcherI18n();
|
|
548
584
|
this.watcherI18n.setSockjsServer(this.sockjs);
|
|
549
585
|
this.kernel.on("onTerminate", () => {
|
|
550
|
-
this.log(
|
|
586
|
+
this.log(`Watching Ended : ${this.watcherI18n.path}`, "INFO");
|
|
551
587
|
this.watcherI18n.close();
|
|
552
588
|
});
|
|
553
589
|
}
|
|
@@ -557,35 +593,34 @@ class Bundle extends nodefony.Service {
|
|
|
557
593
|
this.watcherConfig.listenWatcherConfig();
|
|
558
594
|
this.watcherConfig.setSockjsServer(this.sockjs);
|
|
559
595
|
this.kernel.on("onTerminate", () => {
|
|
560
|
-
this.log(
|
|
596
|
+
this.log(`Watching Ended : ${this.watcherConfig.path}`, "INFO");
|
|
561
597
|
this.watcherConfig.close();
|
|
562
598
|
});
|
|
563
599
|
}
|
|
564
|
-
//services
|
|
600
|
+
// services
|
|
565
601
|
if (services) {
|
|
566
602
|
this.watcherService = new nodefony.kernelWatcher(this.servicesPath, defaultWatcher.call(this, regJs), this);
|
|
567
603
|
this.watcherService.listenWatcherServices();
|
|
568
604
|
this.watcherService.setSockjsServer(this.sockjs);
|
|
569
605
|
this.kernel.on("onTerminate", () => {
|
|
570
|
-
this.log(
|
|
606
|
+
this.log(`Watching Ended : ${this.watcherService.path}`, "INFO");
|
|
571
607
|
this.watcherService.close();
|
|
572
608
|
});
|
|
573
609
|
}
|
|
574
|
-
//entities
|
|
575
|
-
|
|
610
|
+
// entities
|
|
576
611
|
} catch (e) {
|
|
577
612
|
throw e;
|
|
578
613
|
}
|
|
579
614
|
}
|
|
580
615
|
|
|
581
|
-
reloadRouting(name, Path) {
|
|
616
|
+
reloadRouting (name, Path) {
|
|
582
617
|
try {
|
|
583
618
|
if (name === null) {
|
|
584
|
-
|
|
619
|
+
const find = new moduleFindDependencies(Path, "routing", this);
|
|
585
620
|
find.reload();
|
|
586
621
|
} else {
|
|
587
|
-
|
|
588
|
-
this.log(
|
|
622
|
+
const fileClass = new nodefony.fileClass(Path);
|
|
623
|
+
this.log(`Reload Routing : ${Path}`);
|
|
589
624
|
if (this.router) {
|
|
590
625
|
this.router.reader(fileClass.path, this.name);
|
|
591
626
|
}
|
|
@@ -595,69 +630,59 @@ class Bundle extends nodefony.Service {
|
|
|
595
630
|
}
|
|
596
631
|
}
|
|
597
632
|
|
|
598
|
-
parseConfig(result) {
|
|
633
|
+
parseConfig (result) {
|
|
599
634
|
if (result) {
|
|
600
635
|
let config = null;
|
|
601
|
-
for (
|
|
636
|
+
for (const ele in result) {
|
|
602
637
|
let ext = null;
|
|
603
638
|
switch (true) {
|
|
604
639
|
case this.kernel.regBundleName.test(ele):
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
config = this.getParameters(
|
|
640
|
+
const myname = this.kernel.regBundleName.exec(ele);
|
|
641
|
+
const name = myname[1] || myname[2];
|
|
642
|
+
config = this.getParameters(`bundles.${name}`);
|
|
608
643
|
if (config) {
|
|
609
644
|
ext = nodefony.extend(true, {}, config, result[ele]);
|
|
610
|
-
this.log(
|
|
645
|
+
this.log(`\x1b[32m OVERRIDING\x1b[0m CONFIG bundle : ${name}`, "DEBUG");
|
|
611
646
|
} else {
|
|
612
647
|
ext = result[ele];
|
|
613
|
-
this.log(
|
|
648
|
+
this.log(`\x1b[32m OVERRIDING\x1b[0m CONFIG bundle : ${name} BUT BUNDLE ${name} NOT YET REGISTERED `, "WARNING");
|
|
614
649
|
}
|
|
615
650
|
if (this.kernel.bundles[name]) {
|
|
616
651
|
this.kernel.bundles[name].settings = ext;
|
|
617
|
-
this.setParameters(
|
|
652
|
+
this.setParameters(`bundles.${name}`, this.kernel.bundles[name].settings);
|
|
618
653
|
} else {
|
|
619
|
-
this.setParameters(
|
|
654
|
+
this.setParameters(`bundles.${name}`, ext || {});
|
|
620
655
|
}
|
|
621
656
|
break;
|
|
622
|
-
|
|
623
|
-
try {
|
|
624
|
-
let res = semver.valid(result[ele]);
|
|
625
|
-
if (!res) {
|
|
626
|
-
this.log("Bad Bundle Semantic Versioning : " + result[ele] + " Check http://semver.org ", "WARNING");
|
|
627
|
-
}
|
|
628
|
-
} catch (e) {
|
|
629
|
-
this.log(e, "ERROR");
|
|
630
|
-
}
|
|
631
|
-
break;*/
|
|
632
|
-
case /^locale$/.test(ele):
|
|
657
|
+
case (/^locale$/).test(ele):
|
|
633
658
|
if (result[ele]) {
|
|
634
659
|
this.locale = result[ele];
|
|
635
660
|
}
|
|
636
661
|
break;
|
|
637
662
|
}
|
|
638
663
|
}
|
|
639
|
-
config = this.getParameters(
|
|
664
|
+
config = this.getParameters(`bundles.${this.name}`);
|
|
640
665
|
if (config && Object.keys(config).length) {
|
|
641
|
-
this.log(
|
|
666
|
+
this.log(`\x1b[32m BUNDLE IS ALREADY OVERRIDING BY AN OTHERONE INVERT\x1b[0m CONFIG ${util.inspect(config)}`, "WARNING");
|
|
642
667
|
this.settings = nodefony.extend(true, {}, result, config);
|
|
643
|
-
this.setParameters(
|
|
668
|
+
this.setParameters(`bundles.${this.name}`, this.settings);
|
|
644
669
|
} else {
|
|
645
670
|
this.settings = result;
|
|
646
|
-
this.setParameters(
|
|
671
|
+
this.setParameters(`bundles.${this.name}`, this.settings);
|
|
647
672
|
}
|
|
648
673
|
this.settings.version = this.version;
|
|
649
|
-
//console.log(this.settings)
|
|
674
|
+
// console.log(this.settings)
|
|
650
675
|
}
|
|
651
676
|
}
|
|
652
677
|
|
|
653
|
-
log(pci, severity, msgid, msg) {
|
|
678
|
+
log (pci, severity, msgid, msg) {
|
|
654
679
|
if (!msgid) {
|
|
655
|
-
msgid =
|
|
680
|
+
msgid = `bundle-${this.name}`;
|
|
656
681
|
}
|
|
657
682
|
return super.log(pci, severity, msgid, msg);
|
|
658
683
|
}
|
|
659
684
|
|
|
660
|
-
loadFile(Path, force) {
|
|
685
|
+
loadFile (Path, force) {
|
|
661
686
|
try {
|
|
662
687
|
return this.autoLoader.load(Path, force);
|
|
663
688
|
} catch (e) {
|
|
@@ -666,19 +691,19 @@ class Bundle extends nodefony.Service {
|
|
|
666
691
|
}
|
|
667
692
|
}
|
|
668
693
|
|
|
669
|
-
getName() {
|
|
694
|
+
getName () {
|
|
670
695
|
return this.name;
|
|
671
696
|
}
|
|
672
697
|
|
|
673
|
-
getController(name) {
|
|
698
|
+
getController (name) {
|
|
674
699
|
return this.controllers[name];
|
|
675
700
|
}
|
|
676
701
|
|
|
677
|
-
async registerServices() {
|
|
678
|
-
|
|
702
|
+
async registerServices () {
|
|
703
|
+
const service = await this.findResult.find("services")
|
|
679
704
|
.find(regService);
|
|
680
705
|
if (!service.length) {
|
|
681
|
-
this.log(
|
|
706
|
+
this.log(`Bundle ${this.name} No Services Found`, "DEBUG");
|
|
682
707
|
}
|
|
683
708
|
service.forEach((ele) => {
|
|
684
709
|
try {
|
|
@@ -690,9 +715,9 @@ class Bundle extends nodefony.Service {
|
|
|
690
715
|
return service;
|
|
691
716
|
}
|
|
692
717
|
|
|
693
|
-
loadService(ele, force) {
|
|
718
|
+
loadService (ele, force) {
|
|
694
719
|
try {
|
|
695
|
-
|
|
720
|
+
const Class = this.loadFile(ele.path, force);
|
|
696
721
|
if (typeof Class === "function") {
|
|
697
722
|
Class.prototype.bundle = this;
|
|
698
723
|
if (force) {
|
|
@@ -701,30 +726,29 @@ class Bundle extends nodefony.Service {
|
|
|
701
726
|
}
|
|
702
727
|
}
|
|
703
728
|
nodefony.services[Class.name] = Class;
|
|
704
|
-
this.log(
|
|
729
|
+
this.log(`Register Service : ${Class.name}`, "DEBUG");
|
|
705
730
|
return Class;
|
|
706
|
-
} else {
|
|
707
|
-
throw new Error("Bundle Register Service : " + ele.path + " error Service bad format " + typeof Class);
|
|
708
731
|
}
|
|
732
|
+
throw new Error(`Bundle Register Service : ${ele.path} error Service bad format ${typeof Class}`);
|
|
709
733
|
} catch (e) {
|
|
710
734
|
throw e;
|
|
711
735
|
}
|
|
712
736
|
}
|
|
713
737
|
|
|
714
|
-
async reloadService(name, Path, force) {
|
|
738
|
+
async reloadService (name, Path, force) {
|
|
715
739
|
try {
|
|
716
|
-
|
|
740
|
+
const File = new nodefony.fileClass(Path);
|
|
717
741
|
await this.reloadWatcherService(File, Path, force);
|
|
718
742
|
} catch (e) {
|
|
719
743
|
throw e;
|
|
720
744
|
}
|
|
721
745
|
}
|
|
722
746
|
|
|
723
|
-
async reloadWatcherService(File, Path, force) {
|
|
747
|
+
async reloadWatcherService (File, Path, force) {
|
|
724
748
|
try {
|
|
725
749
|
if (File) {
|
|
726
|
-
|
|
727
|
-
|
|
750
|
+
const Class = this.loadService(File, force);
|
|
751
|
+
const injector = this.injectionService.getInjector(Class.name);
|
|
728
752
|
if (injector) {
|
|
729
753
|
injector.getServiceClass({
|
|
730
754
|
class: Class
|
|
@@ -732,47 +756,45 @@ class Bundle extends nodefony.Service {
|
|
|
732
756
|
injector.getServiceName();
|
|
733
757
|
await injector.restartService();
|
|
734
758
|
} else {
|
|
735
|
-
|
|
759
|
+
const error = new Error(`${Class.name} Service is not found or not register reboot server or check config file `);
|
|
736
760
|
throw error;
|
|
737
761
|
}
|
|
738
|
-
} else {
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
find.reload();
|
|
742
|
-
}
|
|
762
|
+
} else if (File === null) {
|
|
763
|
+
const find = new moduleFindDependencies(Path, "service", this);
|
|
764
|
+
find.reload();
|
|
743
765
|
}
|
|
744
766
|
} catch (e) {
|
|
745
767
|
throw e;
|
|
746
768
|
}
|
|
747
769
|
}
|
|
748
770
|
|
|
749
|
-
async findControllerFiles() {
|
|
771
|
+
async findControllerFiles () {
|
|
750
772
|
this.controllerFiles = await this.findResult.find("controller").find(this.regController);
|
|
751
773
|
if (!this.controllerFiles.length) {
|
|
752
|
-
this.log(
|
|
774
|
+
this.log(`Bundle ${this.name} controller directory not found`, "DEBUG");
|
|
753
775
|
}
|
|
754
776
|
return this.controllerFiles;
|
|
755
777
|
}
|
|
756
778
|
|
|
757
|
-
async registerControllers(result) {
|
|
779
|
+
async registerControllers (result) {
|
|
758
780
|
if (result) {
|
|
759
781
|
this.controllerFiles = result;
|
|
760
782
|
}
|
|
761
783
|
if (this.controllerFiles.length) {
|
|
762
784
|
this.controllerFiles.forEach((ele) => {
|
|
763
|
-
|
|
785
|
+
const res = this.regController.exec(ele.name);
|
|
764
786
|
if (res) {
|
|
765
|
-
|
|
787
|
+
const name = res[1];
|
|
766
788
|
this.loadController(name, ele.path, false);
|
|
767
789
|
}
|
|
768
790
|
});
|
|
769
791
|
}
|
|
770
792
|
}
|
|
771
793
|
|
|
772
|
-
reloadWatcherControleur(name, Path) {
|
|
794
|
+
reloadWatcherControleur (name, Path) {
|
|
773
795
|
try {
|
|
774
796
|
if (name === null) {
|
|
775
|
-
|
|
797
|
+
const find = new moduleFindDependencies(Path, "controller", this);
|
|
776
798
|
find.reload();
|
|
777
799
|
} else {
|
|
778
800
|
this.loadController(name, Path, true);
|
|
@@ -782,7 +804,7 @@ class Bundle extends nodefony.Service {
|
|
|
782
804
|
}
|
|
783
805
|
}
|
|
784
806
|
|
|
785
|
-
loadController(name, Path, force) {
|
|
807
|
+
loadController (name, Path, force) {
|
|
786
808
|
if (this.controllers[name]) {
|
|
787
809
|
delete this.controllers[name];
|
|
788
810
|
this.controllers[name] = null;
|
|
@@ -790,12 +812,12 @@ class Bundle extends nodefony.Service {
|
|
|
790
812
|
let Class = null;
|
|
791
813
|
try {
|
|
792
814
|
Class = this.loadFile(Path, force);
|
|
793
|
-
|
|
815
|
+
const res = regClassController.exec(Class.name);
|
|
794
816
|
if (res) {
|
|
795
817
|
name = res[1];
|
|
796
818
|
} else {
|
|
797
|
-
this.log(
|
|
798
|
-
this.log(
|
|
819
|
+
this.log(`Controller Bad Class name :${Class.name} file : ${Path}`, "ERROR");
|
|
820
|
+
this.log(`Controller take the file name !!! ${name}`, "WARNING");
|
|
799
821
|
}
|
|
800
822
|
if (typeof Class === "function") {
|
|
801
823
|
Class.prototype.name = name;
|
|
@@ -807,12 +829,12 @@ class Bundle extends nodefony.Service {
|
|
|
807
829
|
if (force) {
|
|
808
830
|
severity = "INFO";
|
|
809
831
|
}
|
|
810
|
-
this.log(
|
|
811
|
-
if (this.router && true /*Class.prototype.annotation*/
|
|
832
|
+
this.log(`Load ${name} Controller : '${Path}'`, severity);
|
|
833
|
+
if (this.router && true /* Class.prototype.annotation*/) {
|
|
812
834
|
this.router.reader(Path, this.name);
|
|
813
835
|
}
|
|
814
836
|
} else {
|
|
815
|
-
throw new Error(
|
|
837
|
+
throw new Error(`Bundle ${this.name} Load Controller : ${Path} Controller bad format module.exports must return a class `);
|
|
816
838
|
}
|
|
817
839
|
} catch (e) {
|
|
818
840
|
throw e;
|
|
@@ -820,15 +842,15 @@ class Bundle extends nodefony.Service {
|
|
|
820
842
|
return Class;
|
|
821
843
|
}
|
|
822
844
|
|
|
823
|
-
async findViewFiles() {
|
|
845
|
+
async findViewFiles () {
|
|
824
846
|
this.viewFiles = await this.resourcesFiles.find("views");
|
|
825
847
|
if (!this.viewFiles.length) {
|
|
826
|
-
this.log(
|
|
848
|
+
this.log(`Bundle ${this.name} No views Found`, "DEBUG");
|
|
827
849
|
}
|
|
828
850
|
return this.viewFiles;
|
|
829
851
|
}
|
|
830
852
|
|
|
831
|
-
async compileTemplate(file, basename, name) {
|
|
853
|
+
async compileTemplate (file, basename, name) {
|
|
832
854
|
return new Promise(async (resolve, reject) => {
|
|
833
855
|
if (this.views[basename] && this.views[basename][name] && this.views[basename][name].template) {
|
|
834
856
|
this.views[basename][name].template = null;
|
|
@@ -837,7 +859,6 @@ class Bundle extends nodefony.Service {
|
|
|
837
859
|
let template = null;
|
|
838
860
|
try {
|
|
839
861
|
template = await this.serviceTemplate.compile(file);
|
|
840
|
-
|
|
841
862
|
} catch (e) {
|
|
842
863
|
return reject(e);
|
|
843
864
|
}
|
|
@@ -847,16 +868,15 @@ class Bundle extends nodefony.Service {
|
|
|
847
868
|
}
|
|
848
869
|
return resolve(null);
|
|
849
870
|
});
|
|
850
|
-
|
|
851
871
|
}
|
|
852
872
|
|
|
853
|
-
setView(file) {
|
|
873
|
+
setView (file) {
|
|
854
874
|
let basename = path.basename(file.dirName);
|
|
855
875
|
let res = null;
|
|
856
876
|
let name = null;
|
|
857
877
|
if (basename !== "views") {
|
|
858
878
|
let dir = new nodefony.fileClass(file.dirName);
|
|
859
|
-
|
|
879
|
+
const tab = [dir.name];
|
|
860
880
|
while (path.basename(dir.dirName) !== "views") {
|
|
861
881
|
dir = new nodefony.fileClass(dir.dirName);
|
|
862
882
|
tab.push(dir.name);
|
|
@@ -878,16 +898,16 @@ class Bundle extends nodefony.Service {
|
|
|
878
898
|
delete this.views[basename][name];
|
|
879
899
|
}
|
|
880
900
|
return this.views[basename][name] = {
|
|
881
|
-
name
|
|
882
|
-
basename
|
|
883
|
-
file
|
|
901
|
+
name,
|
|
902
|
+
basename,
|
|
903
|
+
file,
|
|
884
904
|
template: null
|
|
885
905
|
};
|
|
886
906
|
}
|
|
887
907
|
return null;
|
|
888
908
|
}
|
|
889
909
|
|
|
890
|
-
async recompileTemplate(file, force) {
|
|
910
|
+
async recompileTemplate (file, force) {
|
|
891
911
|
return new Promise(async (resolve, reject) => {
|
|
892
912
|
let bundle = this;
|
|
893
913
|
// OVERRIDE VIEWS BUNDLE in APP DIRECTORY
|
|
@@ -896,26 +916,24 @@ class Bundle extends nodefony.Service {
|
|
|
896
916
|
if (this.kernel.platform === "win32") {
|
|
897
917
|
let prefix = path.resolve(this.viewsPath);
|
|
898
918
|
prefix = prefix.replace(/\\/g, "\\\\");
|
|
899
|
-
pattern = prefix
|
|
919
|
+
pattern = `${prefix}\\\\(\\w+)-bundle\\\\views\\\\(.+\\.twig)`;
|
|
900
920
|
} else {
|
|
901
921
|
pattern = path.resolve(this.viewsPath, "(\\w+)-bundle", "views", "(.+\\.twig)");
|
|
902
922
|
}
|
|
903
|
-
|
|
904
|
-
|
|
923
|
+
const reg = new RegExp(`^${pattern}$`);
|
|
924
|
+
const res = reg.exec(file.path);
|
|
905
925
|
if (res && res[1]) {
|
|
906
926
|
bundle = this.kernel.getBundle(res[1]);
|
|
907
927
|
this.log(`\x1b[32m APP OVERRIDING VIEWS\x1b[0m Bundle : ${bundle.name} File : ${file.name}`, "DEBUG");
|
|
908
928
|
}
|
|
909
929
|
}
|
|
910
930
|
try {
|
|
911
|
-
|
|
931
|
+
const ele = bundle.setView(file);
|
|
912
932
|
if (ele) {
|
|
913
933
|
if (force) {
|
|
914
934
|
await bundle.compileTemplate(ele.file, ele.basename, ele.name);
|
|
915
|
-
} else {
|
|
916
|
-
|
|
917
|
-
await bundle.compileTemplate(ele.file, ele.basename, ele.name);
|
|
918
|
-
}
|
|
935
|
+
} else if (this.kernel.type !== "CONSOLE") {
|
|
936
|
+
await bundle.compileTemplate(ele.file, ele.basename, ele.name);
|
|
919
937
|
}
|
|
920
938
|
} else {
|
|
921
939
|
this.log(` DROP VIEW TEMPLATE : ${file.path}`, "DEBUG");
|
|
@@ -925,10 +943,9 @@ class Bundle extends nodefony.Service {
|
|
|
925
943
|
return reject(e);
|
|
926
944
|
}
|
|
927
945
|
});
|
|
928
|
-
|
|
929
946
|
}
|
|
930
947
|
|
|
931
|
-
async registerViews(result) {
|
|
948
|
+
async registerViews (result) {
|
|
932
949
|
return new Promise(async (resolve, reject) => {
|
|
933
950
|
let views = null;
|
|
934
951
|
if (result) {
|
|
@@ -936,7 +953,23 @@ class Bundle extends nodefony.Service {
|
|
|
936
953
|
} else {
|
|
937
954
|
views = this.viewFiles;
|
|
938
955
|
}
|
|
939
|
-
views.getFiles()
|
|
956
|
+
for await (const file of views.getFiles()) {
|
|
957
|
+
try {
|
|
958
|
+
const ele = await this.recompileTemplate(file, true);
|
|
959
|
+
if (ele) {
|
|
960
|
+
if (ele.basename === ".") {
|
|
961
|
+
this.log(`${String(`Register Template : '${this.name}Bundle:`)}:${ele.name}'`, "DEBUG");
|
|
962
|
+
} else {
|
|
963
|
+
this.log(`Register Template : '${this.name}Bundle:${ele.basename}:${ele.name}'`, "DEBUG");
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
} catch (e) {
|
|
967
|
+
return reject(e);
|
|
968
|
+
// throw e;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
/* views.getFiles().forEach(async (file) => {
|
|
940
973
|
try {
|
|
941
974
|
let ele = await this.recompileTemplate(file, true);
|
|
942
975
|
if (ele) {
|
|
@@ -950,46 +983,46 @@ class Bundle extends nodefony.Service {
|
|
|
950
983
|
return reject(e);
|
|
951
984
|
//throw e;
|
|
952
985
|
}
|
|
953
|
-
})
|
|
986
|
+
});*/
|
|
954
987
|
return resolve(views);
|
|
955
988
|
});
|
|
956
989
|
}
|
|
957
990
|
|
|
958
|
-
getView(viewDirectory, viewName) {
|
|
991
|
+
getView (viewDirectory, viewName) {
|
|
959
992
|
if (this.views[viewDirectory]) {
|
|
960
|
-
|
|
993
|
+
const res = this.regTemplateExt.exec(viewName);
|
|
961
994
|
if (res) {
|
|
962
|
-
|
|
995
|
+
const name = res[1];
|
|
963
996
|
if (this.views[viewDirectory][name]) {
|
|
964
997
|
return this.views[viewDirectory][name].file;
|
|
965
998
|
}
|
|
966
|
-
throw new Error(
|
|
999
|
+
throw new Error(`Bundle ${this.name} directory : ${viewDirectory} GET view file Name : ${viewName} Not Found`);
|
|
967
1000
|
} else {
|
|
968
|
-
throw new Error(
|
|
1001
|
+
throw new Error(`Bundle ${this.name} directory : ${viewDirectory} GET view file Name : ${viewName} Not Found`);
|
|
969
1002
|
}
|
|
970
1003
|
} else {
|
|
971
|
-
throw new Error(
|
|
1004
|
+
throw new Error(`Bundle ${this.name} GET view directory : ${viewDirectory} Not Found`);
|
|
972
1005
|
}
|
|
973
1006
|
}
|
|
974
1007
|
|
|
975
|
-
getTemplate(viewDirectory, viewName) {
|
|
1008
|
+
getTemplate (viewDirectory, viewName) {
|
|
976
1009
|
if (this.views[viewDirectory]) {
|
|
977
|
-
|
|
1010
|
+
const res = this.regTemplateExt.exec(viewName);
|
|
978
1011
|
if (res) {
|
|
979
|
-
|
|
1012
|
+
const name = res[1];
|
|
980
1013
|
if (this.views[viewDirectory][name]) {
|
|
981
1014
|
return this.views[viewDirectory][name].template;
|
|
982
1015
|
}
|
|
983
|
-
throw new Error(
|
|
1016
|
+
throw new Error(`Bundle ${this.name} directory : ${viewDirectory} GET view file Name : ${viewName} Not Found`);
|
|
984
1017
|
} else {
|
|
985
|
-
throw new Error(
|
|
1018
|
+
throw new Error(`Bundle ${this.name} directory : ${viewDirectory} GET view file Name : ${viewName} Not Found`);
|
|
986
1019
|
}
|
|
987
1020
|
} else {
|
|
988
|
-
throw new Error(
|
|
1021
|
+
throw new Error(`Bundle ${this.name} GET view directory : ${viewDirectory} Not Found`);
|
|
989
1022
|
}
|
|
990
1023
|
}
|
|
991
1024
|
|
|
992
|
-
async findI18nFiles(result) {
|
|
1025
|
+
async findI18nFiles (result) {
|
|
993
1026
|
let trans = null;
|
|
994
1027
|
if (result) {
|
|
995
1028
|
trans = await result.find("translations");
|
|
@@ -997,26 +1030,25 @@ class Bundle extends nodefony.Service {
|
|
|
997
1030
|
trans = await this.resourcesFiles.find("translations");
|
|
998
1031
|
}
|
|
999
1032
|
if (!trans.length || !trans[0]) {
|
|
1000
|
-
this.log(
|
|
1033
|
+
this.log(`Bundle ${this.name} No Translation Found`, "DEBUG");
|
|
1001
1034
|
return trans;
|
|
1002
1035
|
}
|
|
1003
1036
|
return trans[0].children;
|
|
1004
1037
|
}
|
|
1005
1038
|
|
|
1006
|
-
getfilesByLocal(locale, dir) {
|
|
1007
|
-
|
|
1039
|
+
getfilesByLocal (locale, dir) {
|
|
1040
|
+
const reg = new RegExp(`^(.*)\.(${locale})\.(.*)$`);
|
|
1008
1041
|
return dir.find(reg);
|
|
1009
1042
|
}
|
|
1010
1043
|
|
|
1011
|
-
async registerI18n(locale, result) {
|
|
1012
|
-
|
|
1044
|
+
async registerI18n (locale, result) {
|
|
1013
1045
|
let dir = null;
|
|
1014
1046
|
if (result) {
|
|
1015
1047
|
dir = await this.findI18nFiles(result);
|
|
1016
1048
|
} else {
|
|
1017
1049
|
dir = this.i18nFiles;
|
|
1018
1050
|
}
|
|
1019
|
-
//console.trace(dir)
|
|
1051
|
+
// console.trace(dir)
|
|
1020
1052
|
if (!dir || !dir.length) {
|
|
1021
1053
|
return;
|
|
1022
1054
|
}
|
|
@@ -1026,7 +1058,7 @@ class Bundle extends nodefony.Service {
|
|
|
1026
1058
|
} else {
|
|
1027
1059
|
files = this.getfilesByLocal(this.translation.defaultLocale, dir);
|
|
1028
1060
|
if (!files.length) {
|
|
1029
|
-
|
|
1061
|
+
const bundleLocal = this.getParameters(`bundles.${this.name}.locale`);
|
|
1030
1062
|
files = this.getfilesByLocal(bundleLocal || this.translation.defaultLocale, dir);
|
|
1031
1063
|
if (bundleLocal && !files.length) {
|
|
1032
1064
|
this.log(`Translation File Locale : ${bundleLocal} not found`, "DEBUG");
|
|
@@ -1034,14 +1066,14 @@ class Bundle extends nodefony.Service {
|
|
|
1034
1066
|
}
|
|
1035
1067
|
}
|
|
1036
1068
|
files.getFiles().forEach((file) => {
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
this.log(`Read I18n file : ${file.path}`,
|
|
1069
|
+
const domain = file.match[1];
|
|
1070
|
+
const Locale = file.match[2];
|
|
1071
|
+
this.log(`Read I18n file : ${file.path}`, "DEBUG");
|
|
1040
1072
|
this.translation.reader(file.path, this.name, Locale, domain);
|
|
1041
1073
|
});
|
|
1042
1074
|
}
|
|
1043
1075
|
|
|
1044
|
-
async registerCommand(store) {
|
|
1076
|
+
async registerCommand (store) {
|
|
1045
1077
|
this.commandFiles = await this.findResult.find("Command")
|
|
1046
1078
|
.find(regCommand);
|
|
1047
1079
|
if (!this.commandFiles.length) {
|
|
@@ -1050,39 +1082,39 @@ class Bundle extends nodefony.Service {
|
|
|
1050
1082
|
}
|
|
1051
1083
|
let command = null;
|
|
1052
1084
|
this.commandFiles.getFiles().forEach((file) => {
|
|
1053
|
-
|
|
1085
|
+
const res = regCommand.exec(file.name);
|
|
1054
1086
|
if (res) {
|
|
1055
1087
|
try {
|
|
1056
1088
|
command = this.loadFile(file.path);
|
|
1057
1089
|
command.prototype.bundle = this;
|
|
1058
1090
|
store.push(command);
|
|
1059
1091
|
} catch (e) {
|
|
1060
|
-
throw new Error(e
|
|
1092
|
+
throw new Error(`${e} FILE COMMAND : ${file.path}`);
|
|
1061
1093
|
}
|
|
1062
1094
|
if (!command) {
|
|
1063
|
-
throw new Error(
|
|
1095
|
+
throw new Error(`Command : ${file} BAD FORMAT`);
|
|
1064
1096
|
}
|
|
1065
|
-
|
|
1097
|
+
const name = command.name || res[1];
|
|
1066
1098
|
if (!name) {
|
|
1067
|
-
throw new Error(
|
|
1099
|
+
throw new Error(`Command : ${name}BAD FORMAT NANE `);
|
|
1068
1100
|
}
|
|
1069
1101
|
}
|
|
1070
1102
|
});
|
|
1071
1103
|
}
|
|
1072
1104
|
|
|
1073
|
-
async getPublicDirectory() {
|
|
1105
|
+
async getPublicDirectory () {
|
|
1074
1106
|
try {
|
|
1075
1107
|
return await new nodefony.Finder2({
|
|
1076
1108
|
excludeDir: /^docs$|^tests|^node_modules|^assets$/
|
|
1077
1109
|
})
|
|
1078
|
-
|
|
1110
|
+
.in(path.resolve(this.path, "Resources", "public"));
|
|
1079
1111
|
} catch (e) {
|
|
1080
1112
|
return null;
|
|
1081
1113
|
}
|
|
1082
1114
|
return null;
|
|
1083
1115
|
}
|
|
1084
1116
|
|
|
1085
|
-
async registerEntities() {
|
|
1117
|
+
async registerEntities () {
|
|
1086
1118
|
this.entityFiles = await this.findResult.find("Entity")
|
|
1087
1119
|
.find(this.kernel.getOrm())
|
|
1088
1120
|
.find(regEntity);
|
|
@@ -1091,72 +1123,72 @@ class Bundle extends nodefony.Service {
|
|
|
1091
1123
|
return this.entityFiles;
|
|
1092
1124
|
}
|
|
1093
1125
|
this.entityFiles.forEach((file) => {
|
|
1094
|
-
|
|
1126
|
+
const res = regEntity.exec(file.name);
|
|
1095
1127
|
let Class = null;
|
|
1096
1128
|
if (res) {
|
|
1097
1129
|
try {
|
|
1098
1130
|
Class = this.loadFile(file.path);
|
|
1099
1131
|
} catch (e) {
|
|
1100
|
-
this.log(
|
|
1132
|
+
this.log(`LOAD ENTITY ${file.path}`, "ERROR");
|
|
1101
1133
|
throw e;
|
|
1102
1134
|
}
|
|
1103
1135
|
try {
|
|
1104
1136
|
this.entities[Class.name] = new Class(this);
|
|
1105
|
-
this.log(
|
|
1137
|
+
this.log(`LOAD ENTITY ${Class.name} : ${file.name}`, "DEBUG");
|
|
1106
1138
|
} catch (e) {
|
|
1107
1139
|
this.log(e, "WARNING");
|
|
1108
1140
|
}
|
|
1109
1141
|
} else {
|
|
1110
|
-
this.log(
|
|
1142
|
+
this.log(`Drop Entity file ${file.name}`, "WARNING");
|
|
1111
1143
|
}
|
|
1112
1144
|
});
|
|
1113
1145
|
}
|
|
1114
1146
|
|
|
1115
|
-
getEntity(name) {
|
|
1147
|
+
getEntity (name) {
|
|
1116
1148
|
if (this.entities[name]) {
|
|
1117
1149
|
return this.entities[name];
|
|
1118
1150
|
}
|
|
1119
1151
|
return null;
|
|
1120
1152
|
}
|
|
1121
1153
|
|
|
1122
|
-
getEntities() {
|
|
1154
|
+
getEntities () {
|
|
1123
1155
|
if (this.entities) {
|
|
1124
1156
|
return this.entities;
|
|
1125
1157
|
}
|
|
1126
1158
|
return null;
|
|
1127
1159
|
}
|
|
1128
1160
|
|
|
1129
|
-
async registerFixtures() {
|
|
1161
|
+
async registerFixtures () {
|
|
1130
1162
|
this.fixtureFiles = await this.findResult.find("Fixtures")
|
|
1131
1163
|
.find(regFixtures);
|
|
1132
1164
|
if (!this.fixtureFiles.length) {
|
|
1133
|
-
this.log(
|
|
1165
|
+
this.log(`Bundle ${this.name} No Fixutures Found`, "DEBUG");
|
|
1134
1166
|
return this.entityFiles;
|
|
1135
1167
|
}
|
|
1136
1168
|
this.fixtureFiles.forEach((file) => {
|
|
1137
|
-
|
|
1169
|
+
const res = regFixtures.exec(file.name);
|
|
1138
1170
|
if (res) {
|
|
1139
|
-
|
|
1140
|
-
|
|
1171
|
+
const name = res[1];
|
|
1172
|
+
const Class = this.loadFile(file.path);
|
|
1141
1173
|
if (typeof Class === "function") {
|
|
1142
1174
|
Class.prototype.bundle = this;
|
|
1143
1175
|
this.fixtures[name] = Class;
|
|
1144
|
-
this.log(
|
|
1176
|
+
this.log(`LOAD FIXTURE : ${file.name}`, "DEBUG");
|
|
1145
1177
|
} else {
|
|
1146
|
-
this.log(
|
|
1178
|
+
this.log(`Register FIXTURE : ${name} error FIXTURE bad format`);
|
|
1147
1179
|
}
|
|
1148
1180
|
}
|
|
1149
1181
|
});
|
|
1150
1182
|
}
|
|
1151
1183
|
|
|
1152
|
-
getFixture(name) {
|
|
1184
|
+
getFixture (name) {
|
|
1153
1185
|
if (this.fixtures[name]) {
|
|
1154
1186
|
return this.fixtures[name];
|
|
1155
1187
|
}
|
|
1156
1188
|
return null;
|
|
1157
1189
|
}
|
|
1158
1190
|
|
|
1159
|
-
getFixtures() {
|
|
1191
|
+
getFixtures () {
|
|
1160
1192
|
if (this.fixtures) {
|
|
1161
1193
|
return this.fixtures;
|
|
1162
1194
|
}
|