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/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<img src="https://github.com/nodefony/nodefony/raw/master/src/nodefony/bundles/framework-bundle/Resources/public/images/nodefony-logo.png"><br>
|
|
3
3
|
</p>
|
|
4
|
-
<h1 align="center">NODEFONY
|
|
4
|
+
<h1 align="center">NODEFONY V7</h1>
|
|
5
5
|
|
|
6
6
|
[](https://nodei.co/npm/nodefony)
|
|
7
7
|
|
|
8
8
|
[](https://github.com/nodefony/nodefony/issues) [](https://github.com/nodefony/nodefony/actions) [](https://bestpractices.coreinfrastructure.org/projects/495)
|
|
9
9
|
|
|
10
|
-
Nodefony is Node.js full-stack web framework.
|
|
10
|
+
Nodefony is Node.js full-stack web framework.
|
|
11
11
|
|
|
12
12
|
Nodefony can be used to develop a complete solution to create a Fullstack Web Application, Secure Api, or Microservices.
|
|
13
13
|
|
|
@@ -64,7 +64,7 @@ Nodefony can be used to develop a complete solution to create a Fullstack Web Ap
|
|
|
64
64
|
- [Passport](http://passportjs.org/) Simple, unobtrusive authentication for Node.js .
|
|
65
65
|
- ~~[Angular](https://github.com/angular/angular-cli) Experimental Bundle Generator ( Angular cli no longer allows the ejection of a webpack config)~~
|
|
66
66
|
|
|
67
|
-
**Nodefony
|
|
67
|
+
**Nodefony 7 adds the following features** :
|
|
68
68
|
|
|
69
69
|
- [React](https://github.com/facebookincubator/create-react-app) Experimental Bundle Generator ( Now an React Project can be merge into a Nodefony Bundle )
|
|
70
70
|
- [Vue.js](https://vuejs.org) Experimental Bundle Generator ( Now an Vue.js Project can be merge into a Nodefony Bundle )
|
|
@@ -74,10 +74,12 @@ Nodefony can be used to develop a complete solution to create a Fullstack Web Ap
|
|
|
74
74
|
|
|
75
75
|
Evolution priorities for the next version will focus on robustness, unit testing, documentation and security.
|
|
76
76
|
|
|
77
|
+
You can follow Nodefony build with github actions at **<https://github.com/nodefony/nodefony/actions>**
|
|
77
78
|
|
|
78
|
-
|
|
79
|
+
## Nodefony implement modules with CommonJS and ECMAScript 6 ( Class, Inheritance ).
|
|
80
|
+
The development framework will not be ported to typescript, but will wait for the version with type syntax in Emacsript
|
|
79
81
|
|
|
80
|
-
|
|
82
|
+
**[proposal-type-annotations](https://github.com/tc39/proposal-type-annotations)**
|
|
81
83
|
|
|
82
84
|
## **Resources for Newcomers**
|
|
83
85
|
|
|
@@ -97,7 +99,7 @@ You can follow Nodefony build with github actions at **<https://github.com/nodef
|
|
|
97
99
|
|
|
98
100
|
- **[Node.js](https://nodejs.org/)** ® is a Platform built on Chrome's JavaScript runtime ( >= 8 )
|
|
99
101
|
|
|
100
|
-
- **[npm](https://www.npmjs.com/)** or **[yarn](https://yarnpkg.com/lang/en/)** Packages Manager for javascript application
|
|
102
|
+
- **[npm](https://www.npmjs.com/)** or **[yarn](https://yarnpkg.com/lang/en/)** or **[pnpm](https://pnpm.io/cli/install)** Packages Manager for javascript application
|
|
101
103
|
|
|
102
104
|
- **[nvm](https://github.com/nvm-sh/nvm/)** Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
|
|
103
105
|
|
|
@@ -125,9 +127,9 @@ You can follow Nodefony build with github actions at **<https://github.com/nodef
|
|
|
125
127
|
|
|
126
128
|
- ~~[ELECTRON](https://github.com/nodefony/nodefony-electron) Experimental Nodefony Electron ( Now an Electron Context can be use in Nodefony Project )~~
|
|
127
129
|
|
|
128
|
-
- EMBEDDED SYSTEM ( Very difficult : large memory footprint )
|
|
130
|
+
- EMBEDDED SYSTEM ( Very difficult : large memory footprint )
|
|
129
131
|
|
|
130
|
-
## <a name="install"></a> Linux or OSX Installation
|
|
132
|
+
## <a name="install"></a> Linux or OSX Installation
|
|
131
133
|
|
|
132
134
|
**[NVM](https://github.com/nvm-sh/nvm#installation-and-update) Installation (Node Version Manager )** :
|
|
133
135
|
- [NVM](https://github.com/creationix/nvm) Node Version Manager - Simple bash script to manage multiple active node.js versions
|
|
@@ -139,7 +141,7 @@ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
|
|
|
139
141
|
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
|
|
140
142
|
|
|
141
143
|
$ source ~/.bashrc # or source ~/.bash_profile
|
|
142
|
-
$ nvm ls-remote # show all remote versions
|
|
144
|
+
$ nvm ls-remote # show all remote versions
|
|
143
145
|
$ nvm ls # show local versions
|
|
144
146
|
```
|
|
145
147
|
|
|
@@ -195,7 +197,7 @@ C:\Users\myuser\AppData\Roaming\npm\bin
|
|
|
195
197
|
**Cli command when use Global installation**
|
|
196
198
|
```bash
|
|
197
199
|
$ nodefony -v
|
|
198
|
-
|
|
200
|
+
7.0.0
|
|
199
201
|
```
|
|
200
202
|
|
|
201
203
|
**Cli command when By using yarn or npm in trunk**
|
|
@@ -209,7 +211,8 @@ npm run nodefony
|
|
|
209
211
|
**By using npx**
|
|
210
212
|
***note: npx is included with npm > v5.2 or can be installed separately.***
|
|
211
213
|
```bash
|
|
212
|
-
npx nodefony
|
|
214
|
+
npx nodefony -v
|
|
215
|
+
7.0.0-beta.10
|
|
213
216
|
```
|
|
214
217
|
|
|
215
218
|
**The long way with the full path**
|
|
@@ -242,17 +245,17 @@ YOU CAN USE CLI NO INTERACTIVE (nodefony with args) :
|
|
|
242
245
|
```bash
|
|
243
246
|
# CLI generate project name : myproject
|
|
244
247
|
|
|
245
|
-
$ nodefony create myproject
|
|
248
|
+
$ npx nodefony create myproject
|
|
246
249
|
$ cd myproject
|
|
247
250
|
```
|
|
248
251
|
|
|
249
252
|
**Cli Help** :
|
|
250
253
|
|
|
251
254
|
```bash
|
|
252
|
-
$ nodefony -h
|
|
255
|
+
$ npx nodefony -h
|
|
253
256
|
|
|
254
|
-
nodefony
|
|
255
|
-
create [-i] name [path] Create New Nodefony Project
|
|
257
|
+
nodefony
|
|
258
|
+
create [-i] name [path] Create New Nodefony Project
|
|
256
259
|
```
|
|
257
260
|
|
|
258
261
|
## <a name="buildstarter"></a> Build Project with Github Starter :
|
|
@@ -263,7 +266,7 @@ nodefony
|
|
|
263
266
|
```bash
|
|
264
267
|
$ git clone https://github.com/nodefony/nodefony-starter.git
|
|
265
268
|
$ cd nodefony
|
|
266
|
-
$ nodefony build
|
|
269
|
+
$ npx nodefony build
|
|
267
270
|
...
|
|
268
271
|
...
|
|
269
272
|
$ npm start
|
|
@@ -287,7 +290,7 @@ nodefony
|
|
|
287
290
|
drwxr-xr-x 12 cci staff 384 29 mar 11:01 web
|
|
288
291
|
-rw-r--r-- 1 cci staff 542660 27 mar 19:24 yarn.lock
|
|
289
292
|
|
|
290
|
-
$ nodefony
|
|
293
|
+
$ npx nodefony
|
|
291
294
|
|
|
292
295
|
? Nodefony CLI : (Use arrow keys)
|
|
293
296
|
❯ Build Project
|
|
@@ -304,7 +307,7 @@ nodefony
|
|
|
304
307
|
**Starting Development Servers** :
|
|
305
308
|
|
|
306
309
|
```bash
|
|
307
|
-
$ nodefony dev
|
|
310
|
+
$ npx nodefony dev
|
|
308
311
|
|
|
309
312
|
# TO STOP
|
|
310
313
|
$ <ctrl-c>
|
|
@@ -312,7 +315,7 @@ $ <ctrl-c>
|
|
|
312
315
|
**Starting Development Servers in Debug Mode (-d)** :
|
|
313
316
|
|
|
314
317
|
```bash
|
|
315
|
-
$ nodefony -d dev
|
|
318
|
+
$ npx nodefony -d dev
|
|
316
319
|
|
|
317
320
|
# TO STOP
|
|
318
321
|
$ <ctrl-c>
|
|
@@ -323,14 +326,14 @@ OR YOU CAN USE CLI INTERACTIVE MODE (nodefony without args)
|
|
|
323
326
|
_ _ ___ ____ _____ _____ ___ _ _ __ __
|
|
324
327
|
| \ | | / _ \ | _ \ | ____| | ___| / _ \ | \ | | \ \ / /
|
|
325
328
|
| \| | | | | | | | | | | _| | |_ | | | | | \| | \ V /
|
|
326
|
-
| |\ | | |_| | | |_| | | |___ | _| | |_| | | |\ | | |
|
|
327
|
-
|_| \_| \___/ |____/ |_____| |_| \___/ |_| \_| |_|
|
|
329
|
+
| |\ | | |_| | | |_| | | |___ | _| | |_| | | |\ | | |
|
|
330
|
+
|_| \_| \___/ |____/ |_____| |_| \___/ |_| \_| |_|
|
|
328
331
|
|
|
329
332
|
Version : 4.0.0 Platform : linux Process : nodefony PID : 31635
|
|
330
333
|
|
|
331
334
|
Fri Jul 27 2018 17:01:11 INFO nodefony : WELCOME PROJECT : myproject 1.0.0
|
|
332
335
|
|
|
333
|
-
? Nodefony CLI :
|
|
336
|
+
? Nodefony CLI :
|
|
334
337
|
❯ Start Servers Development
|
|
335
338
|
Start Servers Pre-Production
|
|
336
339
|
Start Servers Production
|
|
@@ -362,23 +365,23 @@ $ npx --node-options=--inspect nodefony dev
|
|
|
362
365
|
|
|
363
366
|
**Starting a Nodefony project with [PM2](http://pm2.keymetrics.io/)** :
|
|
364
367
|
```bash
|
|
365
|
-
$ nodefony prod
|
|
368
|
+
$ npx nodefony prod
|
|
366
369
|
or
|
|
367
|
-
$ nodefony start
|
|
370
|
+
$ npx nodefony start
|
|
368
371
|
```
|
|
369
372
|
Tools PM2 You can see PM2 config : config/pm2.config.js
|
|
370
373
|
```bash
|
|
371
374
|
# To See log
|
|
372
|
-
$ nodefony logs
|
|
375
|
+
$ npx nodefony logs
|
|
373
376
|
|
|
374
377
|
# To List Status of Production projects
|
|
375
|
-
$ nodefony list
|
|
378
|
+
$ npx nodefony list
|
|
376
379
|
|
|
377
380
|
# TO KILL PM2 DEAMON
|
|
378
|
-
$ nodefony kill
|
|
381
|
+
$ npx nodefony kill
|
|
379
382
|
|
|
380
383
|
# TO STOP APPLICATION WITHOUT KILL PM2 DEAMON
|
|
381
|
-
$ nodefony stop
|
|
384
|
+
$ npx nodefony stop
|
|
382
385
|
|
|
383
386
|
# YOU can use all pm2 command by using
|
|
384
387
|
$ yarn pm2 monit
|
|
@@ -390,7 +393,7 @@ $ npm run pm2 logs --lines 200
|
|
|
390
393
|
|
|
391
394
|
**Checking a Nodefony Project Pre-Production (Usefull to check Clusters Node)** :
|
|
392
395
|
```bash
|
|
393
|
-
$ nodefony preprod
|
|
396
|
+
$ npx nodefony preprod
|
|
394
397
|
```
|
|
395
398
|
|
|
396
399
|
## <a name="https"></a>Serving a Nodefony project with HTTPS or WSS
|
|
@@ -591,7 +594,7 @@ class defaultController extends nodefony.Controller {
|
|
|
591
594
|
indexAction() {
|
|
592
595
|
return this.render("hello-bundle::index.html.twig", {
|
|
593
596
|
name: this.bundle.name,
|
|
594
|
-
description: this.bundle.package.description
|
|
597
|
+
description: this.bundle.package.description
|
|
595
598
|
});
|
|
596
599
|
}
|
|
597
600
|
}
|
package/autoloader.es6
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
const vm = require("vm");
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const Module = require("module");
|
|
4
|
-
const fs = require(
|
|
5
|
-
const pm2 = require(
|
|
6
|
-
//console.log(require.resolve("pm2"))
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const pm2 = require("pm2");
|
|
6
|
+
// console.log(require.resolve("pm2"))
|
|
7
7
|
const Nodefony = require(path.resolve(__dirname, "nodefony.es6"));
|
|
8
8
|
|
|
9
|
-
module.exports = function () {
|
|
9
|
+
module.exports = (function () {
|
|
10
10
|
// Create Context copy library in context see load runInThisContext
|
|
11
11
|
const context = vm.createContext(this);
|
|
12
12
|
|
|
13
|
-
//context.require = require;
|
|
14
|
-
//context.module = module;
|
|
15
|
-
//context.exports = exports;
|
|
16
|
-
//context.__dirname = __dirname;
|
|
17
|
-
//context.__filename = __filename;
|
|
13
|
+
// context.require = require;
|
|
14
|
+
// context.module = module;
|
|
15
|
+
// context.exports = exports;
|
|
16
|
+
// context.__dirname = __dirname;
|
|
17
|
+
// context.__filename = __filename;
|
|
18
18
|
context.path = require("path");
|
|
19
19
|
context.fs = require("fs");
|
|
20
20
|
context.yaml = require("js-yaml");
|
|
21
|
-
context.util = require(
|
|
22
|
-
context.cluster = require(
|
|
21
|
+
context.util = require("util");
|
|
22
|
+
context.cluster = require("cluster");
|
|
23
23
|
context.url = require("url");
|
|
24
|
-
context.xmlParser = require(
|
|
25
|
-
context.dns = require(
|
|
26
|
-
//context.async = require('async');
|
|
27
|
-
//context.nodedomain = require('domain');
|
|
28
|
-
context.Promise = require(
|
|
29
|
-
//context.inquirer = require('inquirer');
|
|
30
|
-
context.clc = require(
|
|
24
|
+
context.xmlParser = require("xml2js").Parser;
|
|
25
|
+
context.dns = require("dns");
|
|
26
|
+
// context.async = require('async');
|
|
27
|
+
// context.nodedomain = require('domain');
|
|
28
|
+
context.Promise = require("promise");
|
|
29
|
+
// context.inquirer = require('inquirer');
|
|
30
|
+
context.clc = require("cli-color");
|
|
31
31
|
context.shell = require("shelljs");
|
|
32
32
|
context.twig = require("twig");
|
|
33
|
-
context.crypto =
|
|
33
|
+
// context.crypto = crypto;
|
|
34
34
|
context.BlueBird = require("bluebird");
|
|
35
35
|
context.pm2 = pm2;
|
|
36
|
-
//context.Rx = require("rxjs");
|
|
36
|
+
// context.Rx = require("rxjs");
|
|
37
37
|
const nodefony = new Nodefony(context);
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -47,8 +47,7 @@ module.exports = function () {
|
|
|
47
47
|
const regJs = /.*\.js$|.*\.es6$|.*\.es7$|.*\.(mjs)$/;
|
|
48
48
|
|
|
49
49
|
class Autoload {
|
|
50
|
-
|
|
51
|
-
constructor() {
|
|
50
|
+
constructor () {
|
|
52
51
|
this.versions = this.getVersion();
|
|
53
52
|
this.timeout = 20000;
|
|
54
53
|
this.displayError = true;
|
|
@@ -59,7 +58,7 @@ module.exports = function () {
|
|
|
59
58
|
|
|
60
59
|
try {
|
|
61
60
|
nodefony.Error = require(path.resolve(__dirname, "error.es6"));
|
|
62
|
-
//this.load(path.resolve(__dirname, "error.es6"));
|
|
61
|
+
// this.load(path.resolve(__dirname, "error.es6"));
|
|
63
62
|
nodefony.Container = require(path.resolve(__dirname, "container.es6"));
|
|
64
63
|
require(path.resolve(__dirname, "notificationsCenter.es6"));
|
|
65
64
|
nodefony.PDU = require(path.resolve(__dirname, "syslog", "pdu.es6"));
|
|
@@ -75,7 +74,7 @@ module.exports = function () {
|
|
|
75
74
|
nodefony.Watcher = require(path.resolve(__dirname, "watcher.es6"));
|
|
76
75
|
nodefony.cli = require(path.resolve(__dirname, "cli.es6"));
|
|
77
76
|
|
|
78
|
-
//builders
|
|
77
|
+
// builders
|
|
79
78
|
nodefony.Builder = require(path.resolve(__dirname, "builder.es6"));
|
|
80
79
|
require(path.resolve(__dirname, "cli", "builder", "bundles", "bundle.js"));
|
|
81
80
|
require(path.resolve(__dirname, "cli", "builder", "microService", "microService.js"));
|
|
@@ -88,9 +87,9 @@ module.exports = function () {
|
|
|
88
87
|
this.loadDirectory(path.resolve(__dirname, "kernel"), /^tests$|^tasks$/);
|
|
89
88
|
this.loadDirectory(path.resolve(__dirname, "protocols"), /^tests$/);
|
|
90
89
|
context.nodefony.cliStart = require(path.resolve(__dirname, "cli", "start.js"));
|
|
91
|
-
context.nodefony.appKernel = this.loadAppKernel();
|
|
90
|
+
context.nodefony.appKernel = this.loadAppKernel(undefined, true);
|
|
92
91
|
|
|
93
|
-
//services
|
|
92
|
+
// services
|
|
94
93
|
} catch (e) {
|
|
95
94
|
throw e;
|
|
96
95
|
}
|
|
@@ -98,11 +97,11 @@ module.exports = function () {
|
|
|
98
97
|
this.setEnv();
|
|
99
98
|
}
|
|
100
99
|
|
|
101
|
-
getVersion() {
|
|
100
|
+
getVersion () {
|
|
102
101
|
return process.versions;
|
|
103
102
|
}
|
|
104
103
|
|
|
105
|
-
fileExist(file) {
|
|
104
|
+
fileExist (file) {
|
|
106
105
|
try {
|
|
107
106
|
fs.statSync(file);
|
|
108
107
|
} catch (e) {
|
|
@@ -110,11 +109,11 @@ module.exports = function () {
|
|
|
110
109
|
}
|
|
111
110
|
}
|
|
112
111
|
|
|
113
|
-
isElectron() {
|
|
112
|
+
isElectron () {
|
|
114
113
|
return this.versions.electron || null;
|
|
115
114
|
}
|
|
116
115
|
|
|
117
|
-
loadAppKernel() {
|
|
116
|
+
loadAppKernel () {
|
|
118
117
|
try {
|
|
119
118
|
return require(path.resolve("app", "appKernel.js"));
|
|
120
119
|
} catch (e) {
|
|
@@ -122,11 +121,11 @@ module.exports = function () {
|
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
123
|
|
|
125
|
-
createContext(sandbox) {
|
|
124
|
+
createContext (sandbox) {
|
|
126
125
|
return vm.createContext(sandbox);
|
|
127
126
|
}
|
|
128
127
|
|
|
129
|
-
setEnv(environment) {
|
|
128
|
+
setEnv (environment) {
|
|
130
129
|
this.environment = environment;
|
|
131
130
|
switch (this.environment) {
|
|
132
131
|
case "production":
|
|
@@ -153,18 +152,18 @@ module.exports = function () {
|
|
|
153
152
|
* @param {String} file Path to load
|
|
154
153
|
*
|
|
155
154
|
*/
|
|
156
|
-
load(file, force) {
|
|
155
|
+
load (file, force) {
|
|
157
156
|
let filename = null;
|
|
158
157
|
try {
|
|
159
158
|
filename = Module._resolveFilename(file, module, false);
|
|
160
|
-
|
|
159
|
+
const cachedModule = Module._cache[filename];
|
|
161
160
|
if (cachedModule && !force) {
|
|
162
161
|
return cachedModule.exports;
|
|
163
162
|
}
|
|
164
163
|
if (cachedModule && force) {
|
|
165
164
|
delete Module._cache[filename];
|
|
166
165
|
}
|
|
167
|
-
|
|
166
|
+
const myModule = new Module(filename, module);
|
|
168
167
|
Module._cache[filename] = myModule;
|
|
169
168
|
myModule.load(filename);
|
|
170
169
|
return myModule.exports;
|
|
@@ -172,10 +171,10 @@ module.exports = function () {
|
|
|
172
171
|
if (Module._cache[filename]) {
|
|
173
172
|
delete Module._cache[filename];
|
|
174
173
|
}
|
|
175
|
-
console.error(e);
|
|
176
|
-
if (this.kernel) {
|
|
174
|
+
// console.error(e);
|
|
175
|
+
/* if (this.kernel) {
|
|
177
176
|
this.kernel.terminate(1);
|
|
178
|
-
}
|
|
177
|
+
}*/
|
|
179
178
|
throw e;
|
|
180
179
|
}
|
|
181
180
|
}
|
|
@@ -188,14 +187,14 @@ module.exports = function () {
|
|
|
188
187
|
* @param {String} msgid informations for message. example(Name of function for debug)
|
|
189
188
|
* @param {String} msg message to add in log. example (I18N)
|
|
190
189
|
*/
|
|
191
|
-
log(pci, severity, msgid, msg) {
|
|
190
|
+
log (pci, severity, msgid, msg) {
|
|
192
191
|
if (this.syslog) {
|
|
193
192
|
if (!msgid) {
|
|
194
193
|
msgid = "AUTOLOADER ";
|
|
195
194
|
}
|
|
196
195
|
return this.syslog.log(pci, severity, msgid, msg);
|
|
197
196
|
}
|
|
198
|
-
//console.log(pci);
|
|
197
|
+
// console.log(pci);
|
|
199
198
|
}
|
|
200
199
|
|
|
201
200
|
/**
|
|
@@ -204,10 +203,10 @@ module.exports = function () {
|
|
|
204
203
|
* @param {String} path Path to directory to autoload
|
|
205
204
|
*
|
|
206
205
|
*/
|
|
207
|
-
loadDirectory(path, exclude) {
|
|
206
|
+
loadDirectory (path, exclude) {
|
|
208
207
|
let finder = null;
|
|
209
|
-
|
|
210
|
-
path
|
|
208
|
+
const settings = {
|
|
209
|
+
path,
|
|
211
210
|
onFinish: (error, res) => {
|
|
212
211
|
if (error) {
|
|
213
212
|
throw error;
|
|
@@ -233,9 +232,9 @@ module.exports = function () {
|
|
|
233
232
|
throw new Error("AUTOLOADER finder not found Load nodefony finder ");
|
|
234
233
|
}
|
|
235
234
|
|
|
236
|
-
autoloadEach(ele) {
|
|
235
|
+
autoloadEach (ele) {
|
|
237
236
|
if (!ele.isDirectory()) {
|
|
238
|
-
|
|
237
|
+
const res = regJs.exec(ele.path);
|
|
239
238
|
if (res) {
|
|
240
239
|
this.load.call(this, ele.path);
|
|
241
240
|
this.log(ele.path, "DEBUG");
|
|
@@ -243,13 +242,12 @@ module.exports = function () {
|
|
|
243
242
|
}
|
|
244
243
|
}
|
|
245
244
|
|
|
246
|
-
setKernel(kernel) {
|
|
245
|
+
setKernel (kernel) {
|
|
247
246
|
context.kernel = kernel;
|
|
248
247
|
this.syslog = kernel.syslog;
|
|
249
248
|
}
|
|
250
|
-
|
|
251
249
|
}
|
|
252
250
|
|
|
253
251
|
nodefony.autoloader = new Autoload();
|
|
254
252
|
return nodefony;
|
|
255
|
-
}();
|
|
253
|
+
}());
|