gina 0.0.9-p91c → 0.1.1-alpha.3
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/INSTALL.md +46 -0
- package/{core/asset/html/static.html → Icon/r} +0 -0
- package/LICENSE +1 -1
- package/README-4Contributors.md +96 -0
- package/README.md +296 -104
- package/bin/cli +287 -0
- package/bin/cli-debug +60 -0
- package/bin/cmd +184 -0
- package/bin/gina +180 -0
- package/config/logger.json +17 -0
- package/doc/framework/cli/doc.json +9 -0
- package/doc/framework/index.md +60 -0
- package/framework/v0.1.1-alpha.3/AUTHORS +7 -0
- package/{core/utils/lib/inherits → framework/v0.1.1-alpha.3}/LICENSE +1 -1
- package/framework/v0.1.1-alpha.3/VERSION +1 -0
- package/{core/locales/dist/language/en.json → framework/v0.1.1-alpha.3/core/asset/html/nolayout.html} +0 -0
- package/{core/locales/dist/language/fr.json → framework/v0.1.1-alpha.3/core/asset/html/static.html} +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/asset/img/android-chrome-192x192.png +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/asset/img/android-chrome-512x512.png +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/asset/img/apple-touch-icon.png +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/asset/img/favicon-16x16.png +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/asset/img/favicon-32x32.png +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/asset/img/favicon.ico +0 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/dist/gina.js +20904 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/dist/gina.js.map +56 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/dist/gina.min.css +1 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/dist/gina.min.css.map +1 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/dist/gina.min.js +736 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/dist/gina.min.js.map +56 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/dist/gina.onload.min.js +5 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/dist/gina.onload.min.js.map +8 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/readme.md +192 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/uuid.json +23 -0
- package/framework/v0.1.1-alpha.3/core/config.js +2308 -0
- package/framework/v0.1.1-alpha.3/core/connectors/couchbase/index.js +757 -0
- package/framework/v0.1.1-alpha.3/core/connectors/couchbase/lib/connector.js +20 -0
- package/framework/v0.1.1-alpha.3/core/connectors/couchbase/lib/connector.v2.js +429 -0
- package/framework/v0.1.1-alpha.3/core/connectors/couchbase/lib/connector.v3.js +432 -0
- package/framework/v0.1.1-alpha.3/core/connectors/couchbase/lib/n1ql.js +14 -0
- package/framework/v0.1.1-alpha.3/core/connectors/couchbase/lib/session-store.js +21 -0
- package/framework/v0.1.1-alpha.3/core/connectors/couchbase/lib/session-store.v2.js +258 -0
- package/framework/v0.1.1-alpha.3/core/connectors/couchbase/lib/session-store.v3.js +341 -0
- package/{core → framework/v0.1.1-alpha.3/core}/controller/controller.framework.js +3 -2
- package/framework/v0.1.1-alpha.3/core/controller/controller.js +3990 -0
- package/{core → framework/v0.1.1-alpha.3/core}/controller/index.js +5 -5
- package/framework/v0.1.1-alpha.3/core/deps/busboy/.travis.yml +17 -0
- package/framework/v0.1.1-alpha.3/core/deps/busboy/LICENSE +19 -0
- package/framework/v0.1.1-alpha.3/core/deps/busboy/README.md +225 -0
- package/framework/v0.1.1-alpha.3/core/deps/busboy/deps/encoding/encoding-indexes.js +73 -0
- package/framework/v0.1.1-alpha.3/core/deps/busboy/deps/encoding/encoding.js +2391 -0
- package/framework/v0.1.1-alpha.3/core/deps/busboy/lib/main.js +89 -0
- package/framework/v0.1.1-alpha.3/core/deps/busboy/lib/types/multipart.js +328 -0
- package/framework/v0.1.1-alpha.3/core/deps/busboy/lib/types/urlencoded.js +214 -0
- package/framework/v0.1.1-alpha.3/core/deps/busboy/lib/utils.js +191 -0
- package/framework/v0.1.1-alpha.3/core/deps/busboy/package.json +69 -0
- package/framework/v0.1.1-alpha.3/core/deps/swig-client/swig-2.0.0.min.js +5 -0
- package/{core → framework/v0.1.1-alpha.3/core}/dev/index.js +5 -5
- package/{core → framework/v0.1.1-alpha.3/core}/dev/lib/class.js +1 -1
- package/{core → framework/v0.1.1-alpha.3/core}/dev/lib/factory.js +1 -1
- package/{core → framework/v0.1.1-alpha.3/core}/dev/lib/tools.js +0 -0
- package/framework/v0.1.1-alpha.3/core/gna.js +1070 -0
- package/{core → framework/v0.1.1-alpha.3/core}/locales/README.md +41 -2
- package/{core → framework/v0.1.1-alpha.3/core}/locales/currency.json +0 -0
- package/{core/plugins/README.md → framework/v0.1.1-alpha.3/core/locales/dist/language/en.json} +0 -0
- package/{core/plugins/lib/intl/README.md → framework/v0.1.1-alpha.3/core/locales/dist/language/fr.json} +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/locales/dist/region/en.json +0 -0
- package/framework/v0.1.1-alpha.3/core/locales/dist/region/fr.json +9492 -0
- package/{core → framework/v0.1.1-alpha.3/core}/locales/index.js +5 -4
- package/{core → framework/v0.1.1-alpha.3/core}/locales/src/make.js +15 -12
- package/{core → framework/v0.1.1-alpha.3/core}/locales/src/resources/currency.csv +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/locales/src/resources/region.csv +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/locales/src/resources/region.mapping.json +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/mime.types +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/model/entity.js +156 -196
- package/{core → framework/v0.1.1-alpha.3/core}/model/index.js +67 -48
- package/{core → framework/v0.1.1-alpha.3/core}/model/template/entityFactory.js +2 -2
- package/{core → framework/v0.1.1-alpha.3/core}/model/template/index.js +8 -10
- package/{core/plugins/lib/storage → framework/v0.1.1-alpha.3/core/plugins}/README.md +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/plugins/index.js +3 -3
- package/{core/plugins/lib/validator → framework/v0.1.1-alpha.3/core/plugins/lib/file}/README.md +0 -0
- package/{core/plugins/lib/intl → framework/v0.1.1-alpha.3/core/plugins/lib/file}/build.json +0 -0
- package/framework/v0.1.1-alpha.3/core/plugins/lib/file/package.json +25 -0
- package/{core/utils/lib/collection → framework/v0.1.1-alpha.3/core/plugins/lib/intl}/README.md +0 -0
- package/{core/plugins/lib/storage → framework/v0.1.1-alpha.3/core/plugins/lib/intl}/build.json +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/plugins/lib/intl/package.json +3 -3
- package/{core → framework/v0.1.1-alpha.3/core}/plugins/lib/intl/src/main.js +17 -1
- package/{core/utils/lib/routing → framework/v0.1.1-alpha.3/core/plugins/lib/storage}/README.md +0 -0
- package/{core/plugins/lib/validator → framework/v0.1.1-alpha.3/core/plugins/lib/storage}/build.json +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/plugins/lib/storage/package.json +2 -2
- package/{core → framework/v0.1.1-alpha.3/core}/plugins/lib/storage/src/main.js +91 -85
- package/{core/utils/lib/url → framework/v0.1.1-alpha.3/core/plugins/lib/validator}/README.md +0 -0
- package/{core/utils/lib/collection → framework/v0.1.1-alpha.3/core/plugins/lib/validator}/build.json +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/plugins/lib/validator/package.json +3 -3
- package/framework/v0.1.1-alpha.3/core/plugins/lib/validator/src/form-validator.js +1762 -0
- package/framework/v0.1.1-alpha.3/core/plugins/lib/validator/src/main.js +6917 -0
- package/framework/v0.1.1-alpha.3/core/router.js +664 -0
- package/framework/v0.1.1-alpha.3/core/server.express.js +213 -0
- package/framework/v0.1.1-alpha.3/core/server.isaac.js +386 -0
- package/framework/v0.1.1-alpha.3/core/server.js +3010 -0
- package/{core → framework/v0.1.1-alpha.3/core}/status.codes +8 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle/config/app.json +6 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle/config/routing.json +11 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle/config/settings.json +9 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle/config/settings.server.json +30 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle/config/templates.json +42 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle/controllers/controller.content.js +39 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle/controllers/controller.js +30 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle/controllers/setup.js +111 -0
- package/{core/template/samples → framework/v0.1.1-alpha.3/core/template/boilerplate}/bundle/index.js +0 -0
- package/{core/template/samples/bundle → framework/v0.1.1-alpha.3/core/template/boilerplate/bundle_namespace}/controllers/controller.js +9 -7
- package/{core/template/views → framework/v0.1.1-alpha.3/core/template/boilerplate/bundle_public}/css/default.css +0 -0
- package/{core/template/views → framework/v0.1.1-alpha.3/core/template/boilerplate/bundle_public}/css/vendor/readme.md +0 -0
- package/{core/template/views → framework/v0.1.1-alpha.3/core/template/boilerplate/bundle_public}/favicon.ico +0 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle_public/js/vendor/readme.md +1 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle_public/readme.md +1 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle_templates/handlers/main.js +24 -0
- package/{core/template/views/html/default.html → framework/v0.1.1-alpha.3/core/template/boilerplate/bundle_templates/html/homepage.html} +0 -0
- package/{core/template/views/html/layout.html → framework/v0.1.1-alpha.3/core/template/boilerplate/bundle_templates/html/layout/main.html} +2 -2
- package/{core → framework/v0.1.1-alpha.3/core}/template/command/gina.bat.tpl +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/template/command/gina.tpl +1 -1
- package/framework/v0.1.1-alpha.3/core/template/conf/env.json +76 -0
- package/{core/template/conf/project.json → framework/v0.1.1-alpha.3/core/template/conf/manifest.json} +1 -0
- package/{core → framework/v0.1.1-alpha.3/core}/template/conf/package.json +2 -2
- package/framework/v0.1.1-alpha.3/core/template/conf/settings.json +92 -0
- package/framework/v0.1.1-alpha.3/core/template/conf/statics.json +10 -0
- package/framework/v0.1.1-alpha.3/core/template/conf/templates.json +37 -0
- package/{core → framework/v0.1.1-alpha.3/core}/template/error/client/json/401.json +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/template/error/client/json/403.json +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/template/error/client/json/404.json +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/template/error/server/html/50x.html +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/template/error/server/json/500.json +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/template/error/server/json/503.json +0 -0
- package/{core/utils/lib/routing/build.json → framework/v0.1.1-alpha.3/core/template/extensions/logger/config.json} +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/helpers/console.js +3 -3
- package/{core/utils → framework/v0.1.1-alpha.3}/helpers/context.js +240 -49
- package/framework/v0.1.1-alpha.3/helpers/dateFormat.js +528 -0
- package/framework/v0.1.1-alpha.3/helpers/index.js +79 -0
- package/framework/v0.1.1-alpha.3/helpers/json/README.md +0 -0
- package/framework/v0.1.1-alpha.3/helpers/json/package.json +20 -0
- package/framework/v0.1.1-alpha.3/helpers/json/src/main.js +97 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/helpers/path.js +342 -140
- package/framework/v0.1.1-alpha.3/helpers/plugins/README.md +4 -0
- package/framework/v0.1.1-alpha.3/helpers/plugins/package.json +20 -0
- package/framework/v0.1.1-alpha.3/helpers/plugins/src/api-error.js +160 -0
- package/framework/v0.1.1-alpha.3/helpers/plugins/src/main.js +32 -0
- package/framework/v0.1.1-alpha.3/helpers/prototypes.js +218 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/helpers/task.js +49 -29
- package/{core/utils → framework/v0.1.1-alpha.3}/helpers/text.js +7 -7
- package/framework/v0.1.1-alpha.3/lib/archiver/README.md +0 -0
- package/framework/v0.1.1-alpha.3/lib/archiver/build.json +0 -0
- package/framework/v0.1.1-alpha.3/lib/archiver/package.json +20 -0
- package/framework/v0.1.1-alpha.3/lib/archiver/src/dep/jszip.min.js +15 -0
- package/framework/v0.1.1-alpha.3/lib/archiver/src/main.js +499 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/aliases.json +13 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/add.js +507 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/arguments.json +4 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/copy.js +15 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/cp.js +2 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/help.js +28 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/help.txt +67 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/list.js +129 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/remove.js +229 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/rename.js +4 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/restart.js +235 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/rm.js +2 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/start.js +394 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/status.js +3 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/stop.js +232 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/add.js +436 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/get.js +62 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/help.js +28 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/help.txt +33 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/link-dev.js +80 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/list.js +111 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/remove.js +150 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/rm.js +2 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/set.js +57 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/unset.js +44 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/use.js +79 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/dot.js +70 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/get.js +0 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/help.js +39 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/help.txt +31 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/init.js +514 -0
- package/{core/utils/lib/cmd → framework/v0.1.1-alpha.3/lib/cmd/framework}/msg.json +3 -3
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/open.js +50 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/restart.js +124 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/set.js +161 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/start.js +96 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/status.js +72 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/stop.js +159 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/tail.js +183 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/update.js +0 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/version.js +44 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/gina-dev.1.md +66 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/gina-framework.1.md +100 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/gina.1.md +79 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/helper.js +1147 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/index.js +170 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/msg.json +20 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/port/help.js +28 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/port/help.txt +31 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/port/inc/scan.js +108 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/port/list.js +176 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/port/set.js +0 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/add.js +528 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/arguments.json +9 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/build.js +115 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/help.js +28 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/help.txt +76 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/import.js +2 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/list.js +55 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/move.js +0 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/remove.js +144 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/rename.js +162 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/restart.js +0 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/rm.js +2 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/start.js +0 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/status.js +3 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/stop.js +0 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/protocol/help.js +27 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/protocol/help.txt +57 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/protocol/list.js +239 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/protocol/set.js +631 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/scope/help.js +28 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/scope/help.txt +33 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/scope/link-local.js +80 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/scope/list.js +116 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/scope/remove.js +150 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/scope/rm.js +2 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/scope/set.js +57 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/scope/unset.js +44 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/scope/use.js +79 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/view/add.js +311 -0
- package/framework/v0.1.1-alpha.3/lib/collection/README.md +5 -0
- package/framework/v0.1.1-alpha.3/lib/collection/build.json +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/collection/package.json +2 -2
- package/framework/v0.1.1-alpha.3/lib/collection/src/main.js +1459 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/config.js +49 -34
- package/framework/v0.1.1-alpha.3/lib/cron/README.md +7 -0
- package/framework/v0.1.1-alpha.3/lib/cron/package.json +20 -0
- package/framework/v0.1.1-alpha.3/lib/cron/src/main.js +176 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/generator/index.js +8 -4
- package/framework/v0.1.1-alpha.3/lib/index.js +116 -0
- package/framework/v0.1.1-alpha.3/lib/inherits/LICENSE +19 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/inherits/README.md +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/inherits/example/inheriting_eventemitter.js +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/inherits/example/protected_inheritance.js +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/inherits/example/simple_inheritance.js +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/inherits/example/super_attribute_overridden_by_child_on_init.js +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/inherits/package.json +2 -2
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/inherits/src/main.js +18 -19
- package/framework/v0.1.1-alpha.3/lib/logger/README.md +7 -0
- package/framework/v0.1.1-alpha.3/lib/logger/package.json +20 -0
- package/framework/v0.1.1-alpha.3/lib/logger/src/containers/default/index.js +55 -0
- package/framework/v0.1.1-alpha.3/lib/logger/src/containers/file/index.js +251 -0
- package/framework/v0.1.1-alpha.3/lib/logger/src/containers/file/lib/logrotator/README.md +100 -0
- package/framework/v0.1.1-alpha.3/lib/logger/src/containers/file/lib/logrotator/index.js +274 -0
- package/framework/v0.1.1-alpha.3/lib/logger/src/containers/mq/index.js +52 -0
- package/framework/v0.1.1-alpha.3/lib/logger/src/containers/mq/listener.js +302 -0
- package/framework/v0.1.1-alpha.3/lib/logger/src/containers/mq/speaker.js +118 -0
- package/framework/v0.1.1-alpha.3/lib/logger/src/helper.js +131 -0
- package/framework/v0.1.1-alpha.3/lib/logger/src/main.js +739 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/math/index.js +58 -35
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/merge/README.md +5 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/merge/example/merge.js +1 -1
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/merge/example/merge_2_literal objects.js +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/merge/example/merge_and_preserve_first.js +2 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/merge/package.json +2 -2
- package/framework/v0.1.1-alpha.3/lib/merge/src/main.js +531 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/model.js +42 -19
- package/framework/v0.1.1-alpha.3/lib/proc.js +518 -0
- package/framework/v0.1.1-alpha.3/lib/routing/README.md +0 -0
- package/framework/v0.1.1-alpha.3/lib/routing/build.json +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/routing/package.json +2 -2
- package/framework/v0.1.1-alpha.3/lib/routing/src/main.js +1492 -0
- package/framework/v0.1.1-alpha.3/lib/session-store.js +33 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/shell.js +43 -30
- package/framework/v0.1.1-alpha.3/lib/swig-filters/README.md +0 -0
- package/framework/v0.1.1-alpha.3/lib/swig-filters/package.json +20 -0
- package/framework/v0.1.1-alpha.3/lib/swig-filters/src/main.js +322 -0
- package/framework/v0.1.1-alpha.3/lib/url/README.md +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/url/index.js +2 -1
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/url/mocks.json +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/url/routing.json +9 -9
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/url/test.js +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/validator.js +7 -7
- package/framework/v0.1.1-alpha.3/package.json +14 -0
- package/package.json +35 -33
- package/resources/etc/init.d/debian/gina +117 -0
- package/resources/home/framework/env.json +34 -0
- package/resources/home/framework/locals.json +14 -0
- package/resources/home/framework/project.json +48 -0
- package/resources/home/framework/projects.json +6 -0
- package/resources/home/main.json +47 -0
- package/resources/home/settings.json +22 -0
- package/resources/home/user/extensions/logger/default/config.json +77 -0
- package/resources/home/user/extensions/logger/file/config.json +11 -0
- package/resources/img/android-chrome-192x192.png +0 -0
- package/resources/img/android-chrome-512x512.png +0 -0
- package/resources/img/apple-touch-icon.png +0 -0
- package/resources/img/favicon-16x16.png +0 -0
- package/resources/img/favicon-32x32.png +0 -0
- package/resources/img/favicon.ico +0 -0
- package/resources/package.json.template +50 -0
- package/script/lib.js +24 -0
- package/script/post_install.js +449 -157
- package/script/pre_install.js +277 -36
- package/script/prepare_version.js +425 -0
- package/utils/helper.js +438 -0
- package/utils/prototypes.js +239 -0
- package/utils/prototypes.json_clone.js +175 -0
- package/.npmignore +0 -6
- package/MIDDLEWARE +0 -1
- package/SUCCESS +0 -1
- package/VERSION +0 -1
- package/core/asset/html/nolayout.html +0 -1
- package/core/asset/js/plugin/build.dev.json +0 -28
- package/core/asset/js/plugin/build.json +0 -31
- package/core/asset/js/plugin/dist/gina.min.css +0 -1
- package/core/asset/js/plugin/dist/gina.min.css.map +0 -1
- package/core/asset/js/plugin/dist/gina.min.js +0 -13732
- package/core/asset/js/plugin/dist/gina.min.js.map +0 -42
- package/core/asset/js/plugin/dist/gina.onload.min.js +0 -3
- package/core/asset/js/plugin/dist/gina.onload.min.js.map +0 -8
- package/core/asset/js/plugin/readme.md +0 -152
- package/core/asset/js/plugin/src/gina/main.js +0 -132
- package/core/asset/js/plugin/src/gina/popin/css/design.css +0 -23
- package/core/asset/js/plugin/src/gina/popin/css/main.css +0 -1112
- package/core/asset/js/plugin/src/gina/popin/css/popin.css +0 -3
- package/core/asset/js/plugin/src/gina/popin/css/popin.css.map +0 -1
- package/core/asset/js/plugin/src/gina/popin/doc/TOC.md +0 -29
- package/core/asset/js/plugin/src/gina/popin/doc/css.md +0 -162
- package/core/asset/js/plugin/src/gina/popin/doc/extend.md +0 -663
- package/core/asset/js/plugin/src/gina/popin/doc/faq.md +0 -46
- package/core/asset/js/plugin/src/gina/popin/doc/html.md +0 -227
- package/core/asset/js/plugin/src/gina/popin/doc/js.md +0 -37
- package/core/asset/js/plugin/src/gina/popin/doc/misc.md +0 -178
- package/core/asset/js/plugin/src/gina/popin/doc/usage.md +0 -130
- package/core/asset/js/plugin/src/gina/popin/main.js +0 -783
- package/core/asset/js/plugin/src/gina/popin/sass/config.sass +0 -37
- package/core/asset/js/plugin/src/gina/popin/sass/gina-design.sass +0 -622
- package/core/asset/js/plugin/src/gina/popin/sass/gina-popin.sass +0 -54
- package/core/asset/js/plugin/src/gina/popin/sass/helper.scss +0 -73
- package/core/asset/js/plugin/src/gina/toolbar/.npmignore +0 -19
- package/core/asset/js/plugin/src/gina/toolbar/css/toolbar.css +0 -433
- package/core/asset/js/plugin/src/gina/toolbar/css/toolbar.css.map +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/index.html +0 -285
- package/core/asset/js/plugin/src/gina/toolbar/index.kit +0 -120
- package/core/asset/js/plugin/src/gina/toolbar/jquery-3.1.0.min.js +0 -4
- package/core/asset/js/plugin/src/gina/toolbar/main.js +0 -693
- package/core/asset/js/plugin/src/gina/toolbar/mock.gina.json +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/mock.user.json +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/readme.md +0 -7
- package/core/asset/js/plugin/src/gina/toolbar/sass/toolbar.sass +0 -563
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/Info-color.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/Info-grey.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/error-color.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/error-grey.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/info-optim.svg +0 -13
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/logo-gina.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/settings-big.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/settings.afdesign +0 -0
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/settings.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/stripe-calendar-optim.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/stripe-calendar.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/stripe-card-optim.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/stripe-card.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/stripe-lock-optim.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/stripe-lock.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/warning-color.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/warning-grey.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/test.jpg +0 -0
- package/core/asset/js/plugin/src/gina/toolbar/toolbar.html +0 -104
- package/core/asset/js/plugin/src/gina/utils/dom.js +0 -24
- package/core/asset/js/plugin/src/gina/utils/events.js +0 -201
- package/core/asset/js/plugin/src/gina/utils/loader.js +0 -57
- package/core/asset/js/plugin/src/main.js +0 -235
- package/core/asset/js/plugin/src/vendor/jquery/1.11.1-css-event_alias.min.js +0 -5
- package/core/asset/js/plugin/src/vendor/jquery/1.12.4.min.js +0 -5
- package/core/asset/js/plugin/src/vendor/jquery/2.1.1-css-event_alias-sizzle.min.js +0 -4
- package/core/asset/js/plugin/src/vendor/jquery/README.md +0 -14
- package/core/asset/js/plugin/src/vendor/jquery/slim-3.1.1.min.js +0 -4
- package/core/config.js +0 -1225
- package/core/controller/controller.js +0 -1860
- package/core/gna.js +0 -908
- package/core/plugins/lib/validator/src/form-validator.js +0 -789
- package/core/plugins/lib/validator/src/main.js +0 -2056
- package/core/router.js +0 -717
- package/core/server.js +0 -1363
- package/core/template/conf/env.json +0 -70
- package/core/template/conf/settings.json +0 -48
- package/core/template/conf/statics.json +0 -6
- package/core/template/conf/views.json +0 -16
- package/core/template/samples/bundle/config/app.json +0 -4
- package/core/template/samples/bundle/config/routing.json +0 -9
- package/core/template/samples/bundle/controllers/setup.js +0 -33
- package/core/template/views/js/vendor/readme.md +0 -1
- package/core/template/views/readme.md +0 -1
- package/core/utils/helpers/dateFormat.js +0 -264
- package/core/utils/helpers/index.js +0 -202
- package/core/utils/index.js +0 -75
- package/core/utils/lib/cmd/app.js +0 -686
- package/core/utils/lib/cmd/basic.help.txt +0 -40
- package/core/utils/lib/cmd/basic.js +0 -141
- package/core/utils/lib/cmd/gina-add-bundle.js +0 -328
- package/core/utils/lib/cmd/gina-add-views.js +0 -99
- package/core/utils/lib/cmd/gina-build.js +0 -218
- package/core/utils/lib/cmd/gina-clean.js +0 -26
- package/core/utils/lib/cmd/gina-connect.js +0 -176
- package/core/utils/lib/cmd/gina-delete-bundle.js +0 -176
- package/core/utils/lib/cmd/gina-deploy.js +0 -452
- package/core/utils/lib/cmd/gina-init-project.js +0 -83
- package/core/utils/lib/cmd/gina-start-bundle.js +0 -3
- package/core/utils/lib/cmd/gina-start.js +0 -3
- package/core/utils/lib/cmd/index.js +0 -157
- package/core/utils/lib/cmd/project.js +0 -14
- package/core/utils/lib/collection/src/main.js +0 -650
- package/core/utils/lib/logger/containers/file.js +0 -11
- package/core/utils/lib/logger/index.js +0 -260
- package/core/utils/lib/merge/src/main.js +0 -344
- package/core/utils/lib/proc.js +0 -416
- package/core/utils/lib/routing/src/main.js +0 -165
- package/documentation/css/default.css +0 -3
- package/documentation/html/home.html +0 -6
- package/documentation/html/inc/_footer.html +0 -5
- package/documentation/html/layout.html +0 -21
- package/documentation/img/debug-conf1.png +0 -0
- package/documentation/img/debug-conf2.png +0 -0
- package/documentation/img/debug-conf3.png +0 -0
- package/documentation/img/debug-conf4.png +0 -0
- package/documentation/img/debug-conf5.png +0 -0
- package/documentation/img/debug-conf6.png +0 -0
- package/documentation/img/debug-conf7.png +0 -0
- package/documentation/img/debug-new1.png +0 -0
- package/documentation/img/debug-new2.png +0 -0
- package/documentation/img/debug-start.png +0 -0
- package/documentation/md/api/controller/main.md +0 -74
- package/migration_note.md +0 -7
- package/package-lock.json +0 -611
- package/script/pre_publish.js +0 -207
- package/tutorial/Commands/README.md +0 -56
- package/tutorial/Commands/add-bundle-result.png +0 -0
- package/tutorial/Commands/add-bundle.png +0 -0
- package/tutorial/Commands/delete-bundle.png +0 -0
- package/tutorial/Commands/help.png +0 -0
- package/tutorial/Commands/init-project.png +0 -0
- package/tutorial/Commands/start-bundle-result.png +0 -0
- package/tutorial/Commands/start-bundle-stop.png +0 -0
- package/tutorial/Commands/start-bundle.png +0 -0
- package/tutorial/Commands/version.png +0 -0
- package/tutorial/ETC/README.md +0 -74
- package/tutorial/ETC/add-bundle-result.png +0 -0
- package/tutorial/ETC/add-bundle.png +0 -0
- package/tutorial/ETC/init-project.png +0 -0
- package/tutorial/Install/README.md +0 -54
- package/tutorial/Install/git-get.png +0 -0
- package/tutorial/Install/git-install-end.png +0 -0
- package/tutorial/Install/git-install-result.png +0 -0
- package/tutorial/Install/git-install-start.png +0 -0
- package/tutorial/Install/install-end.png +0 -0
- package/tutorial/Install/install-result.png +0 -0
- package/tutorial/Install/install-start.png +0 -0
- package/tutorial/WebStorm/README.md +0 -30
- package/tutorial/WebStorm/closure-compiler.png +0 -0
- package/tutorial/WebStorm/sass.png +0 -0
|
@@ -0,0 +1,2308 @@
|
|
|
1
|
+
//"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This file is part of the gina package.
|
|
4
|
+
* Copyright (c) 2009-2022 Rhinostone <contact@gina.io>
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
//Imports.
|
|
10
|
+
var fs = require('fs');
|
|
11
|
+
var dns = require('dns');
|
|
12
|
+
var util = require('util');
|
|
13
|
+
var Events = require('events');
|
|
14
|
+
var EventEmitter = require('events').EventEmitter;
|
|
15
|
+
var locales = require('./locales');
|
|
16
|
+
var lib = require('./../lib');
|
|
17
|
+
var merge = lib.merge;
|
|
18
|
+
var inherits = lib.inherits;
|
|
19
|
+
var console = lib.logger;
|
|
20
|
+
var Collection = lib.Collection;
|
|
21
|
+
var modelUtil = new lib.Model();
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @class Config
|
|
26
|
+
*
|
|
27
|
+
*
|
|
28
|
+
* @package Gina
|
|
29
|
+
* @namespace
|
|
30
|
+
* @author Rhinostone <contact@gina.io>
|
|
31
|
+
* @api Public
|
|
32
|
+
*
|
|
33
|
+
* TODO - split Config.Env & Config.Host
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
function Config(opt) {
|
|
37
|
+
|
|
38
|
+
var self = this;
|
|
39
|
+
// framework settings from homedir
|
|
40
|
+
var framework = {
|
|
41
|
+
ports : _( GINA_HOMEDIR +'/ports.json', true),
|
|
42
|
+
portsReverse : _( GINA_HOMEDIR +'/ports.reverse.json', true),
|
|
43
|
+
project : _( GINA_HOMEDIR +'/projects.json', true)
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
this.bundles = [];
|
|
47
|
+
this.allBundles = [];
|
|
48
|
+
this.allEnvs = getContext('envs');
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Config Constructor
|
|
52
|
+
* @constructor
|
|
53
|
+
* */
|
|
54
|
+
var init = function(opt) {
|
|
55
|
+
|
|
56
|
+
if ( !Config.initialized) {
|
|
57
|
+
var env = opt.env;
|
|
58
|
+
|
|
59
|
+
self.projectName = opt.projectName || getContext('projectName');
|
|
60
|
+
self.startingApp = opt.startingApp;
|
|
61
|
+
self.executionPath = opt.executionPath; // project path
|
|
62
|
+
|
|
63
|
+
self.task = opt.task || 'run'; // to be aible to filter later on non run task
|
|
64
|
+
|
|
65
|
+
self.userConf = false;
|
|
66
|
+
var path = _(self.executionPath + '/env.json');
|
|
67
|
+
|
|
68
|
+
if ( fs.existsSync(path) ) {
|
|
69
|
+
|
|
70
|
+
self.userConf = requireJSON(path);
|
|
71
|
+
console.debug('Application config file loaded [' + path + ']');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
self.Env.parent = self;
|
|
75
|
+
if (env != 'undefined') self.Env.set(env);
|
|
76
|
+
|
|
77
|
+
self.Host.parent = self;
|
|
78
|
+
|
|
79
|
+
//Do some checking please.. like already has a PID ?.
|
|
80
|
+
//if yes, join in case of standalone.. or create a new thread.
|
|
81
|
+
self.Host.setMaster(opt.startingApp);
|
|
82
|
+
|
|
83
|
+
getConf(env)
|
|
84
|
+
} else {
|
|
85
|
+
if (!opt) {
|
|
86
|
+
return Config.instance
|
|
87
|
+
} else {
|
|
88
|
+
return self.getInstance(opt.startingApp)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
var getConf = function(env) {
|
|
94
|
+
|
|
95
|
+
self.env = env;
|
|
96
|
+
console.debug('[ config ] Loading conf...');
|
|
97
|
+
|
|
98
|
+
// framework settings
|
|
99
|
+
var filename = null, content = null;
|
|
100
|
+
|
|
101
|
+
for (var file in framework) {
|
|
102
|
+
|
|
103
|
+
filename = framework[file];
|
|
104
|
+
|
|
105
|
+
if ( self.isCacheless() ) {
|
|
106
|
+
delete require.cache[require.resolve(filename)];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (file == 'project') {
|
|
110
|
+
content = require(filename)[self.projectName] // get only related project infos
|
|
111
|
+
} else {
|
|
112
|
+
content = require(filename);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
setContext('gina.'+ file, content)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
self.Env.load( function(err, envConf) {
|
|
120
|
+
|
|
121
|
+
if ( typeof(self.Env.loaded) == 'undefined') {
|
|
122
|
+
// Need to globalize some of them.
|
|
123
|
+
self.envConf = envConf;
|
|
124
|
+
|
|
125
|
+
// getting server core config
|
|
126
|
+
var statusCodes = null
|
|
127
|
+
, mime = null
|
|
128
|
+
;
|
|
129
|
+
|
|
130
|
+
try {
|
|
131
|
+
var corePath = getPath('gina').core;
|
|
132
|
+
//statusCodes = fs.readFileSync( _( corePath + '/status.codes') ).toString();
|
|
133
|
+
//statusCodes = JSON.parse(statusCodes);
|
|
134
|
+
statusCodes = requireJSON( _( corePath + '/status.codes') );
|
|
135
|
+
if ( typeof(statusCodes['_comment']) != 'undefined' )
|
|
136
|
+
delete statusCodes['_comment'];
|
|
137
|
+
|
|
138
|
+
mime = fs.readFileSync(corePath + '/mime.types').toString();
|
|
139
|
+
mime = JSON.parse(mime);
|
|
140
|
+
if ( typeof(mime['_comment']) != 'undefined' )
|
|
141
|
+
delete mime['_comment'];
|
|
142
|
+
|
|
143
|
+
self.envConf.core = {
|
|
144
|
+
statusCodes : statusCodes,
|
|
145
|
+
mime : mime,
|
|
146
|
+
locales : locales
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
} catch(err) {
|
|
150
|
+
console.error(err.stack||err.message);
|
|
151
|
+
process.exit(1)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
loadBundlesConfiguration( function(err, file, routing) {
|
|
155
|
+
|
|
156
|
+
if (err) {
|
|
157
|
+
console.error(err.stack||err.message);
|
|
158
|
+
|
|
159
|
+
setTimeout(() => {
|
|
160
|
+
process.exit(1);
|
|
161
|
+
}, 0);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if ( typeof(Config.initialized) == 'undefined' ) {
|
|
166
|
+
Config.initialized = true;
|
|
167
|
+
self.isStandalone = self.Host.isStandalone();
|
|
168
|
+
self.bundle = self.startingApp;
|
|
169
|
+
Config.instance = self
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
//logger.debug('gina', 'CONFIG:DEBUG:42', 'CONF LOADED 43', __stack);
|
|
174
|
+
self.bundlesConfiguration = {
|
|
175
|
+
env : self.Env.get(),
|
|
176
|
+
version : self.version,
|
|
177
|
+
conf : self.getInstance(),
|
|
178
|
+
bundles : self.getBundles(),
|
|
179
|
+
allBundles : self.getAllBundles(),
|
|
180
|
+
isStandalone : self.Host.isStandalone()
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
//console.error("found bundles ", self.bundlesConfiguration.bundles);
|
|
184
|
+
|
|
185
|
+
//TODO - Don't override if syntax is ok - no mixed paths.
|
|
186
|
+
//Set paths for utils. Override for now.
|
|
187
|
+
//To reset it, just delete the hidden folder.
|
|
188
|
+
var ginaPath = opt.ginaPath;
|
|
189
|
+
var utilsConfig = new lib.Config();
|
|
190
|
+
|
|
191
|
+
utilsConfig.set('gina', 'locals.json', {
|
|
192
|
+
project : utilsConfig.getProjectName(),
|
|
193
|
+
paths : {
|
|
194
|
+
project : self.projectName,
|
|
195
|
+
gina : ginaPath,
|
|
196
|
+
utils : utilsConfig.__dirname,
|
|
197
|
+
root : opt.executionPath,
|
|
198
|
+
env : opt.executionPath + '/env.json',
|
|
199
|
+
tmp : opt.executionPath + '/tmp'
|
|
200
|
+
},
|
|
201
|
+
//TODO - Replace property by bundle.
|
|
202
|
+
bundles : self.bundlesConfiguration.allBundles
|
|
203
|
+
//envs :
|
|
204
|
+
}, function(err) {
|
|
205
|
+
self.Env.loaded = true;
|
|
206
|
+
if (err != null && err != false)
|
|
207
|
+
console.error('Error found while settings up locals' + err);
|
|
208
|
+
|
|
209
|
+
self.emit('config#complete', err, self.bundlesConfiguration)
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
}, self.startingApp);//by default.
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Get Instance
|
|
220
|
+
*
|
|
221
|
+
* @param {string} [bundle]
|
|
222
|
+
* @returns {(Object|Undefined)} configuration|"undefined"
|
|
223
|
+
* */
|
|
224
|
+
|
|
225
|
+
this.getInstance = function(bundle) {
|
|
226
|
+
|
|
227
|
+
if ( typeof(Config.instance) == 'undefined' && typeof(getContext('gina')) != 'undefined' ) {
|
|
228
|
+
Config.instance = merge( self, getContext('gina').config, true );
|
|
229
|
+
self.envConf = Config.instance.envConf
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
var configuration = Config.instance.envConf;
|
|
233
|
+
|
|
234
|
+
var env = self.env || Config.instance.env;
|
|
235
|
+
|
|
236
|
+
Config.instance.Env.parent = Config.instance;
|
|
237
|
+
|
|
238
|
+
if (env != 'undefined')
|
|
239
|
+
Config.instance.Env.set(Config.instance.env);
|
|
240
|
+
|
|
241
|
+
Config.instance.Host.parent = Config.instance;
|
|
242
|
+
|
|
243
|
+
//Do some checking please.. like already has a PID ?.
|
|
244
|
+
//if yes, join in case of standalone.. or create a new thread.
|
|
245
|
+
Config.instance.Host.setMaster(bundle);
|
|
246
|
+
|
|
247
|
+
self = Config.instance;
|
|
248
|
+
|
|
249
|
+
if ( typeof(bundle) != 'undefined' && typeof(configuration) != 'undefined' ) {
|
|
250
|
+
try {
|
|
251
|
+
//return configuration[bundle][env];
|
|
252
|
+
return Config.instance || configuration[bundle][env];
|
|
253
|
+
} catch (err) {
|
|
254
|
+
//logger.error('gina', 'CONFIG:ERR:1', err, __stack);
|
|
255
|
+
console.error(err.stack||err.message);
|
|
256
|
+
return undefined
|
|
257
|
+
}
|
|
258
|
+
} else if ( typeof(configuration) != 'undefined' ) {
|
|
259
|
+
return configuration
|
|
260
|
+
} else {
|
|
261
|
+
return undefined
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Set server core conf
|
|
267
|
+
*
|
|
268
|
+
* Status Code, Mime Types etc ...
|
|
269
|
+
* */
|
|
270
|
+
this.setServerCoreConf = function(bundle, env, conf) {
|
|
271
|
+
self.envConf[bundle][env].server['coreConfiguration'] = conf
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
this.getServerCoreConf = function(bundle, env) {
|
|
275
|
+
try {
|
|
276
|
+
return self.envConf[bundle][env].server['coreConfiguration']
|
|
277
|
+
} catch(err) {
|
|
278
|
+
console.debug('Could not get server core configuration for <'+ bundle +'>:<'+ env +'>');
|
|
279
|
+
console.error(err.stack||err.message);
|
|
280
|
+
process.exit(1)
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* @class Env Sub class
|
|
286
|
+
*
|
|
287
|
+
*
|
|
288
|
+
* @package Gina.Config
|
|
289
|
+
* @namespace Gina.Config.Env
|
|
290
|
+
* @author Rhinostone <contact@gina.io>
|
|
291
|
+
*/
|
|
292
|
+
this.Env = {
|
|
293
|
+
template : requireJSON(GINA_FRAMEWORK_DIR +'/core/template/conf/env.json'),
|
|
294
|
+
load : function(callback) {
|
|
295
|
+
loadWithTemplate(this.parent.userConf, this.template, function(err, envConf) {
|
|
296
|
+
self.envConf = envConf;
|
|
297
|
+
envConf.env = self.env;
|
|
298
|
+
envConf.isStandalone = self.isStandalone;
|
|
299
|
+
|
|
300
|
+
callback(false, envConf);
|
|
301
|
+
});
|
|
302
|
+
},
|
|
303
|
+
|
|
304
|
+
set : function(env) {
|
|
305
|
+
this.current = env || this.template.defEnv;
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Get active env
|
|
310
|
+
* @returns {String} env
|
|
311
|
+
**/
|
|
312
|
+
get : function() {
|
|
313
|
+
return this.current
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Get env config
|
|
318
|
+
*
|
|
319
|
+
* @param {string} bundle
|
|
320
|
+
* @param {string} env
|
|
321
|
+
*
|
|
322
|
+
* @returns {Object} json conf
|
|
323
|
+
**/
|
|
324
|
+
getConf : function(bundle, env) {
|
|
325
|
+
|
|
326
|
+
if ( !self.isStandalone ) {
|
|
327
|
+
if ( !bundle && typeof(self.bundle) != 'undefined' ) {
|
|
328
|
+
bundle = self.bundle
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
return ( typeof(self.envConf) != 'undefined' ) ? self.envConf[bundle][env] : null;
|
|
333
|
+
|
|
334
|
+
} else {
|
|
335
|
+
|
|
336
|
+
if (!bundle) { // if getContext().bundle is lost .. eg.: worker context
|
|
337
|
+
var model = (arguments.length == 1) ? bundle : model
|
|
338
|
+
, file = ( !/node_modules/.test(__stack[1].getFileName()) ) ? __stack[1].getFileName() : __stack[2].getFileName()
|
|
339
|
+
, a = file.replace('.js', '').split('/')
|
|
340
|
+
, i = a.length-1
|
|
341
|
+
, bundles = getContext('gina').config.bundles
|
|
342
|
+
, index = 0;
|
|
343
|
+
|
|
344
|
+
for (; i >= 0; --i) {
|
|
345
|
+
index = bundles.indexOf(a[i]);
|
|
346
|
+
if ( index > -1 ) {
|
|
347
|
+
bundle = bundles[index];
|
|
348
|
+
break
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
if ( typeof(self.envConf) != 'undefined' ) {
|
|
355
|
+
|
|
356
|
+
var protocol = self.envConf[self.startingApp][env].content.settings.server.protocol || self.envConf[self.startingApp][env].server.protocol;
|
|
357
|
+
var scheme = self.envConf[self.startingApp][env].content.settings.server.scheme || self.envConf[self.startingApp][env].server.scheme;
|
|
358
|
+
|
|
359
|
+
self.envConf[self.startingApp][env].hostname = scheme + '://' + self.envConf[self.startingApp][env].host + ':' + self.envConf[self.startingApp][env].server.port;
|
|
360
|
+
|
|
361
|
+
self.envConf[bundle][env].hostname = self.envConf[self.startingApp][env].hostname;
|
|
362
|
+
self.envConf[bundle][env].content.routing = self.envConf[self.startingApp][env].content.routing;
|
|
363
|
+
|
|
364
|
+
if ( bundle && env ) {
|
|
365
|
+
return self.envConf[bundle][env]
|
|
366
|
+
} else if ( bundle && !env ) {
|
|
367
|
+
return self.envConf[bundle]
|
|
368
|
+
} else {
|
|
369
|
+
return self.envConf
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return null
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
getDefault : function() {
|
|
377
|
+
return {
|
|
378
|
+
"env" : this.template.defEnv,
|
|
379
|
+
"ext" : this.template.defExt,
|
|
380
|
+
"registeredEnvs" : this.template.registeredEnvs
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Host Class
|
|
386
|
+
*
|
|
387
|
+
* @package Gina.Config
|
|
388
|
+
* @author Rhinostone <contact@gina.io>
|
|
389
|
+
*/
|
|
390
|
+
this.Host = {
|
|
391
|
+
//By default.
|
|
392
|
+
standaloneMode : self.isStandalone || true,
|
|
393
|
+
/**
|
|
394
|
+
* Set Master instance
|
|
395
|
+
* @param {String} appName Application name
|
|
396
|
+
* @returns {Object} instance Instance of the master node
|
|
397
|
+
* */
|
|
398
|
+
setMaster : function(appName) {
|
|
399
|
+
if(typeof(this.master) == "undefined" && this.master !== "") {
|
|
400
|
+
this.master = appName
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
/**
|
|
404
|
+
* Get Master instance
|
|
405
|
+
* @returns {Object} instance Instance of the master node
|
|
406
|
+
* */
|
|
407
|
+
getMaster : function() {
|
|
408
|
+
return this.master
|
|
409
|
+
},
|
|
410
|
+
isStandalone : function() {
|
|
411
|
+
return this.standaloneMode
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
var mergeConfig = function(confObject, section, content, i) {
|
|
416
|
+
|
|
417
|
+
if (!Array.isArray(section)) {
|
|
418
|
+
if (section != '') {
|
|
419
|
+
section = section.split(/\./g);
|
|
420
|
+
} else {
|
|
421
|
+
section = []
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if ( typeof(i) == 'undefined' ) {
|
|
426
|
+
i = 0
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
if (!section.length) { // nothing to do here
|
|
430
|
+
confObject = merge(content, confObject);
|
|
431
|
+
return
|
|
432
|
+
}
|
|
433
|
+
// done
|
|
434
|
+
if (i == section.length) {
|
|
435
|
+
return
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
if ( typeof(confObject[ section[i] ]) == 'undefined' ) {
|
|
439
|
+
confObject[ section[i] ] = {};
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
if (i == section.length-1) {
|
|
443
|
+
confObject[ section[i] ] = merge(content, confObject[ section[i] ])
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
mergeConfig(confObject[ section[i] ], section, content, i+1)
|
|
447
|
+
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Load config according to specific template
|
|
453
|
+
* @param {String} filename Path of source config file
|
|
454
|
+
* @param {String} template Path of the template to merge with
|
|
455
|
+
* @returns {Oject} JSON of the merged config
|
|
456
|
+
**/
|
|
457
|
+
var loadWithTemplate = function(userConf, template, callback) {
|
|
458
|
+
|
|
459
|
+
var content = userConf,
|
|
460
|
+
//if nothing to merge.
|
|
461
|
+
newContent = JSON.parse( JSON.stringify(content) );
|
|
462
|
+
|
|
463
|
+
var isStandalone = true,
|
|
464
|
+
masterPort = null,
|
|
465
|
+
appPort = null,
|
|
466
|
+
env = self.Env.get(),
|
|
467
|
+
appsPath = '',
|
|
468
|
+
modelsPath = '',
|
|
469
|
+
projectPath = '',
|
|
470
|
+
ctx = getContext('gina'),
|
|
471
|
+
projectConf = ctx.project,
|
|
472
|
+
portsReverse = ctx.portsReverse
|
|
473
|
+
;
|
|
474
|
+
|
|
475
|
+
if (!self.projectName) {
|
|
476
|
+
self.projectName = ctx.config.projectName
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
//Pushing default app first.
|
|
480
|
+
self.bundles.push(self.startingApp);//This is a JSON.push.
|
|
481
|
+
var root = new _(self.executionPath).toUnixStyle();
|
|
482
|
+
var pkg = null;
|
|
483
|
+
try {
|
|
484
|
+
pkg = require(_(root + '/manifest.json')).bundles;
|
|
485
|
+
// by default but may be overriden
|
|
486
|
+
masterPort = portsReverse[self.startingApp+'@'+self.projectName][env][projectConf.def_protocol][projectConf.def_scheme]
|
|
487
|
+
} catch (err) {
|
|
488
|
+
console.error(err.stack);
|
|
489
|
+
|
|
490
|
+
callback(err);
|
|
491
|
+
} //bundlesPath will be default.
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
//For each app.
|
|
495
|
+
var cacheless = self.isCacheless()
|
|
496
|
+
, bundleSettings = null
|
|
497
|
+
, bundHasSettings = true
|
|
498
|
+
, bundlesPath = getPath('bundles') // symlink handled
|
|
499
|
+
, protocol = null
|
|
500
|
+
, scheme = null
|
|
501
|
+
, p = null
|
|
502
|
+
;
|
|
503
|
+
|
|
504
|
+
// getting bundle config files
|
|
505
|
+
|
|
506
|
+
var configFiles = null
|
|
507
|
+
, appPath = null
|
|
508
|
+
, jsonFile = null
|
|
509
|
+
, e = null
|
|
510
|
+
, tmpSettings = null
|
|
511
|
+
, filesList = {}
|
|
512
|
+
, files = {}
|
|
513
|
+
;
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
var version = null, middleware = null;
|
|
517
|
+
try {
|
|
518
|
+
self.version = version = require(_(getPath('gina').root +'/package.json' )).version;
|
|
519
|
+
self.middleware = middleware = fs.readFileSync(_(GINA_FRAMEWORK_DIR + '/MIDDLEWARE')).toString() || 'none';
|
|
520
|
+
|
|
521
|
+
setContext('gina.version', version);
|
|
522
|
+
setContext('gina.middleware', middleware);
|
|
523
|
+
|
|
524
|
+
} catch (err) {
|
|
525
|
+
console.debug(err.stack)
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
for (let app in content) {
|
|
529
|
+
//Checking if genuine app.
|
|
530
|
+
console.debug('Checking if application [ '+ app +' ] is registered ');
|
|
531
|
+
|
|
532
|
+
appPath = _(bundlesPath + '/' + app);
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
// if ( self.task == 'run' && !self.isCacheless() ) {
|
|
537
|
+
// appPath = _(newContent[app][env].bundlesPath + '/' + app)
|
|
538
|
+
// } else { //getting src path instead
|
|
539
|
+
// appPath = _(newContent[app][env].sources + '/' + app);
|
|
540
|
+
// newContent[app][env].bundlesPath = newContent[app][env].sources;
|
|
541
|
+
// }
|
|
542
|
+
tmpSettings = {};
|
|
543
|
+
newContent[app][env].bundlesPath = bundlesPath;
|
|
544
|
+
|
|
545
|
+
if ( typeof(content[app][env]) != "undefined" ) {
|
|
546
|
+
try {
|
|
547
|
+
configFiles = fs.readdirSync(_(appPath + '/config'));
|
|
548
|
+
} catch (mountingError) {
|
|
549
|
+
//console.emerg('Dependency bundle config not found for `'+ app +'/'+ env +'`: trying to load on the fly from src');
|
|
550
|
+
console.warn('Dependency bundle config not found for `'+ app +'/'+ env +'`: trying to load on the fly from src');
|
|
551
|
+
let appSrcPath = _(root +'/'+ pkg[app].src, true);
|
|
552
|
+
configFiles = fs.readdirSync(_(appSrcPath + '/config'));
|
|
553
|
+
setPath('bundles', _(appSrcPath, true));
|
|
554
|
+
appPath = appSrcPath;
|
|
555
|
+
newContent[app][env].bundlesPath = bundlesPath = appSrcPath.replace( new RegExp('/'+ app), '' );
|
|
556
|
+
console.warn('Dependency bundle config loaded from '+ appSrcPath);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
appsPath = (typeof(content[app][env]['bundlesPath']) != 'undefined')
|
|
561
|
+
? content[app][env].bundlesPath
|
|
562
|
+
: template["{bundle}"]["{env}"].bundlesPath
|
|
563
|
+
;
|
|
564
|
+
// Preprocessing settings
|
|
565
|
+
for (let c = 0, cLen = configFiles.length; c < cLen; ++c) {
|
|
566
|
+
let foundEnvVersion = false;
|
|
567
|
+
let fName = configFiles[c];
|
|
568
|
+
// settings only !
|
|
569
|
+
if ( !/^settings\./.test(fName) ) {
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
if (
|
|
575
|
+
/^\./.test(fName)
|
|
576
|
+
// || new RegExp('\.'+ env +'\.json$').test(fName)
|
|
577
|
+
|| !/\.json$/.test(fName)
|
|
578
|
+
) {
|
|
579
|
+
continue;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
let name = fName.replace(new RegExp('\.'+ env +'\.json$'), '').replace(new RegExp('\.json$'), '');
|
|
584
|
+
let fNameWithNoExt = fName.replace(/.json$/, '');
|
|
585
|
+
let section = fNameWithNoExt.replace(/(^settings\.|^settings$)/, '').replace(new RegExp('\.'+ env +'$'), '').replace(new RegExp('\.json$'), '');
|
|
586
|
+
|
|
587
|
+
if (/\-/.test(name)) {
|
|
588
|
+
name = name.replace(/-([a-z])/g, function(g) { return g[1].toUpperCase(); })
|
|
589
|
+
}
|
|
590
|
+
filesList[name] = fName;
|
|
591
|
+
// handle registered config files
|
|
592
|
+
let main = fName;
|
|
593
|
+
// let tmp = fName.replace(/.json/, '.' + env + '.json'); // env version
|
|
594
|
+
files[name] = ( typeof(files[name]) != 'undefined' ) ? files[name] : {};
|
|
595
|
+
let fileContent = files[name];
|
|
596
|
+
// let filename = _(appPath + '/config/' + tmp);
|
|
597
|
+
let filename = _(appPath + '/config/' + main);
|
|
598
|
+
|
|
599
|
+
exists = fs.existsSync(_(filename, true));
|
|
600
|
+
// loading env if exists
|
|
601
|
+
if ( self.isCacheless() ) {
|
|
602
|
+
if (exists) {
|
|
603
|
+
delete require.cache[require.resolve(_(filename, true))];
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
// if (new RegExp('\.'+ env +'\.json$').test(fName)) {
|
|
607
|
+
// foundEnvVersion = true;
|
|
608
|
+
// }
|
|
609
|
+
try {
|
|
610
|
+
if (exists) {
|
|
611
|
+
jsonFile = requireJSON(_(filename, true));
|
|
612
|
+
if (Array.isArray(jsonFile) && !Array.isArray(fileContent) && !Object.keys(fileContent).length) {
|
|
613
|
+
fileContent = []
|
|
614
|
+
}
|
|
615
|
+
// Fixed priority to env version and/or extended.description if found
|
|
616
|
+
fileContent = merge(jsonFile, fileContent);
|
|
617
|
+
}
|
|
618
|
+
} catch (_err) {
|
|
619
|
+
if (exists) {
|
|
620
|
+
callback(new Error('[ ' + filename + ' ] is malformed !!'))
|
|
621
|
+
} else {
|
|
622
|
+
fileContent = undefined
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
// loading main
|
|
626
|
+
filename = _(appPath + '/config/' + main);
|
|
627
|
+
//Can't do anything without.
|
|
628
|
+
try {
|
|
629
|
+
exists = fs.existsSync(_(filename, true));
|
|
630
|
+
if (cacheless && exists) {
|
|
631
|
+
delete require.cache[require.resolve(_(filename, true))];
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
if (exists) {
|
|
635
|
+
jsonFile = requireJSON(_(filename, true));
|
|
636
|
+
if (Array.isArray(jsonFile) && !Array.isArray(fileContent) && !Object.keys(fileContent).length) {
|
|
637
|
+
fileContent = []
|
|
638
|
+
}
|
|
639
|
+
//fileContent = merge(fileContent, jsonFile);
|
|
640
|
+
// Fixed priority to env version and/or extended.description if found
|
|
641
|
+
fileContent = merge(jsonFile, fileContent);
|
|
642
|
+
} else {
|
|
643
|
+
console.warn('[ ' + app + ' ] [ ' + env + ' ]' + new Error('[ ' + filename + ' ] not found'));
|
|
644
|
+
}
|
|
645
|
+
} catch (_err) {
|
|
646
|
+
|
|
647
|
+
if (fs.existsSync(filename)) {
|
|
648
|
+
let e = '[ ' + filename + ' ] is malformed !!\n\r' + (_err.stack || _err.message);
|
|
649
|
+
console.error(e);
|
|
650
|
+
callback(new Error(e))
|
|
651
|
+
} else {
|
|
652
|
+
fileContent = undefined
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// tmp settings - because we need it now
|
|
657
|
+
if (section != '' ) {
|
|
658
|
+
if (/\-/.test(section)) {
|
|
659
|
+
section = section.replace(/-([a-z])/g, function(g) { return g[1].toUpperCase(); })
|
|
660
|
+
}
|
|
661
|
+
mergeConfig(tmpSettings, section, fileContent );
|
|
662
|
+
} else {
|
|
663
|
+
tmpSettings = merge(tmpSettings, fileContent);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
} //EO for (let c = 0, cLen = configFiles.length; c < cLen; ++c) {
|
|
668
|
+
|
|
669
|
+
bundleSettings = tmpSettings;
|
|
670
|
+
// reused and deleted in `loadBundleConfig()`
|
|
671
|
+
bundleSettings.tmpSettingFileContent = JSON.clone(bundleSettings);
|
|
672
|
+
newContent[app][env] = merge(bundleSettings, newContent[app][env]);
|
|
673
|
+
// completing with missing props
|
|
674
|
+
var defaultSettings = requireJSON(GINA_FRAMEWORK_DIR +'/core/template/conf/settings.json');
|
|
675
|
+
newContent[app][env] = merge(newContent[app][env], defaultSettings);
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
// setting protocol & port
|
|
679
|
+
if ( typeof(portsReverse[app+'@'+self.projectName]) == 'undefined' )
|
|
680
|
+
continue;
|
|
681
|
+
|
|
682
|
+
if (
|
|
683
|
+
pkg[app] != 'undefined' && pkg[app]['src'] != 'undefined' && self.isCacheless()
|
|
684
|
+
) {
|
|
685
|
+
p = _(pkg[app].src);
|
|
686
|
+
content[app][env]['bundlesPath'] = "{executionPath}/"+ p.replace('/' + app, '');
|
|
687
|
+
} else {
|
|
688
|
+
p = ( typeof(pkg[app].link) != 'undefined' ) ? _(pkg[app].link) : _(pkg[app].releases[env].target);
|
|
689
|
+
content[app][env]['bundlesPath'] = "{executionPath}/"+ p.replace('/' + app, '');
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
appsPath = (typeof(content[app][env]['bundlesPath']) != 'undefined')
|
|
693
|
+
? content[app][env].bundlesPath
|
|
694
|
+
: template["{bundle}"]["{env}"].bundlesPath;
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
modelsPath = (typeof(content[app][env]['modelsPath']) != 'undefined')
|
|
699
|
+
? content[app][env].modelsPath
|
|
700
|
+
: template["{bundle}"]["{env}"].modelsPath;
|
|
701
|
+
|
|
702
|
+
projectPath = (typeof(content[app][env]['projectPath']) != 'undefined')
|
|
703
|
+
? content[app][env].projectPath
|
|
704
|
+
: template["{bundle}"]["{env}"].projectPath;
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
// TODO - remove this after the tests
|
|
708
|
+
// if ( typeof(content[app][env].server ) != 'undefined' ) {
|
|
709
|
+
// newContent[app][env].server = content[app][env].server;
|
|
710
|
+
|
|
711
|
+
// }
|
|
712
|
+
// else if ( bundHasSettings && typeof(bundleSettings.server) != 'undefined') {
|
|
713
|
+
// newContent[app][env].server = bundleSettings.server;
|
|
714
|
+
// }
|
|
715
|
+
// else {
|
|
716
|
+
// if ( typeof(content[app][env].server ) != 'undefined' ) {
|
|
717
|
+
// newContent[app][env].server = template["{bundle}"]["{env}"].server
|
|
718
|
+
// }
|
|
719
|
+
// if ( typeof(newContent[app][env].server ) != 'undefined' ) {
|
|
720
|
+
// newContent[app][env].server = template["{bundle}"]["{env}"].server
|
|
721
|
+
// }
|
|
722
|
+
|
|
723
|
+
// just in case someone removes the settings.server.json
|
|
724
|
+
if ( typeof(newContent[app][env].server ) == 'undefined' ) {
|
|
725
|
+
newContent[app][env].server = {}
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
// getting server protocol: bundle settings first, if not available ->W project's config
|
|
729
|
+
// If the users has set a different protocol in its /config/settings.json, it will override the project protocol
|
|
730
|
+
// at server init (see server.js)
|
|
731
|
+
|
|
732
|
+
// by default
|
|
733
|
+
if ( typeof(newContent[app][env].server.scope) == 'undefined' ) {
|
|
734
|
+
newContent[app][env].server.scope = projectConf.def_scope; // from ~/.gina/projects.json
|
|
735
|
+
newContent[app][env].server.scopeIsLocal = (projectConf.def_scope == projectConf.local_scope) ? true : false; // from ~/.gina/projects.json
|
|
736
|
+
}
|
|
737
|
+
if ( typeof(newContent[app][env].server.protocol) == 'undefined' ) {
|
|
738
|
+
//newContent[app][env].server.protocol = ( bundHasSettings && typeof(bundleSettings.server) != 'undefined' && typeof(bundleSettings.server.protocol) != 'undefined' ) ? bundleSettings.server.protocol : projectConf.def_protocol; // from ~/.gina/projects.json
|
|
739
|
+
newContent[app][env].server.protocol = projectConf.def_protocol; // from ~/.gina/projects.json
|
|
740
|
+
}
|
|
741
|
+
newContent[app][env].server.protocolShort = newContent[app][env].server.protocol.split(/\./)[0];
|
|
742
|
+
|
|
743
|
+
if ( typeof(newContent[app][env].server.scheme) == 'undefined' ) {
|
|
744
|
+
//newContent[app][env].server.scheme = ( bundHasSettings && typeof(bundleSettings.server) != 'undefined' && typeof(bundleSettings.server.scheme) != 'undefined' ) ? bundleSettings.server.scheme : projectConf.def_scheme; // from ~/.gina/projects.json
|
|
745
|
+
newContent[app][env].server.scheme = projectConf.def_scheme; // from ~/.gina/projects.json
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
// getting server port
|
|
749
|
+
if ( typeof (newContent[app][env].port) == 'undefined' ) {
|
|
750
|
+
newContent[app][env].port = {}
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
if ( typeof (newContent[app][env].port[ newContent[app][env].server.protocol ]) == 'undefined' ) {
|
|
754
|
+
newContent[app][env].port[ newContent[app][env].server.protocol ] = {}
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
if ( typeof (newContent[app][env].port[ newContent[app][env].server.protocol ][ newContent[app][env].server.scheme ]) == 'undefined' ) {
|
|
758
|
+
newContent[app][env].port[ newContent[app][env].server.protocol ][ newContent[app][env].server.scheme ] = {}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
newContent[app][env].server.port = portsReverse[ app +'@'+ self.projectName ][env][projectConf.def_protocol][projectConf.def_scheme];
|
|
762
|
+
try {
|
|
763
|
+
appPort = portsReverse[app+'@'+self.projectName][env][ newContent[app][env].server.protocol ][ newContent[app][env].server.scheme ];
|
|
764
|
+
} catch (err) {
|
|
765
|
+
console.emerg('[ config ][ settings.server.protocol ] Protocol or scheme settings inconsistency found in `'+ app +'/config/settings`. To fix this, try to run `gina project:import @'+ self.projectName +' --path='+ projectConf.path +'`\n\r'+ err.stack);
|
|
766
|
+
process.exit(1)
|
|
767
|
+
}
|
|
768
|
+
//I had to for this one...
|
|
769
|
+
appsPath = appsPath.replace(/\{executionPath\}/g, root);
|
|
770
|
+
|
|
771
|
+
//console.log("My env ", env, self.executionPath, JSON.stringify(template, null, '\t') );
|
|
772
|
+
//Existing app and port sharing => != isStandalone.
|
|
773
|
+
if ( !fs.existsSync(appsPath) ) {
|
|
774
|
+
new _(appsPath).mkdirSync()
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
newContent[app][env].port[ newContent[app][env].server.protocol ][ newContent[app][env].server.scheme ] = appPort;
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
//Check if isStandalone or shared instance
|
|
783
|
+
if (appPort != masterPort) {
|
|
784
|
+
isStandalone = false;
|
|
785
|
+
self.Host.standaloneMode = isStandalone
|
|
786
|
+
} else if (app != self.startingApp) {
|
|
787
|
+
self.bundles.push(app)
|
|
788
|
+
}
|
|
789
|
+
self.allBundles.push(app);
|
|
790
|
+
|
|
791
|
+
//Mergin user's & template.
|
|
792
|
+
newContent[app][env] = merge(
|
|
793
|
+
newContent[app][env],
|
|
794
|
+
JSON.parse( JSON.stringify(template["{bundle}"]["{env}"]))//only copy of it.
|
|
795
|
+
);
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
if (!newContent[app][env].executionPath) {
|
|
799
|
+
newContent[app][env].executionPath = root
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
//Constants to be exposed in configuration files.
|
|
803
|
+
//Variables replace. Compare with gina/core/template/conf/env.json.
|
|
804
|
+
let reps = {
|
|
805
|
+
"frameworkDir" : GINA_FRAMEWORK_DIR,
|
|
806
|
+
"executionPath" : root,
|
|
807
|
+
"projectPath" : projectPath,
|
|
808
|
+
"bundlesPath" : appsPath,
|
|
809
|
+
"modelsPath" : modelsPath,
|
|
810
|
+
"tmpPath" : newContent[app][env].tmpPath,
|
|
811
|
+
"scope" : newContent[app][env].server.scope,
|
|
812
|
+
"host" : newContent[app][env].host,
|
|
813
|
+
"env" : env,
|
|
814
|
+
"bundle" : app,
|
|
815
|
+
"version" : version
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
for (let _contant in process.gina) {
|
|
819
|
+
reps[_contant] = process.gina[_contant];
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
bundleSettings = null;
|
|
823
|
+
//console.error("reps ", reps);
|
|
824
|
+
try {
|
|
825
|
+
newContent = whisper(reps, newContent);
|
|
826
|
+
} catch(contentErr) {
|
|
827
|
+
console.emerg(contentErr.stack)
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
}
|
|
831
|
+
//Else not in the scenario.
|
|
832
|
+
|
|
833
|
+
}//EO for.
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
console.debug('[ '+ self.startingApp +' ][ '+ env +' ] Env configuration loaded');
|
|
837
|
+
|
|
838
|
+
// TRUE means that all apps sharing the same process will merge into one.
|
|
839
|
+
if (!isStandalone) self.Host.standaloneMode = isStandalone;
|
|
840
|
+
|
|
841
|
+
console.debug('Is server running as a standalone instance ? ' + isStandalone);
|
|
842
|
+
|
|
843
|
+
callback(false, newContent)
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
var isFileInProject = function(file) {
|
|
847
|
+
|
|
848
|
+
try {
|
|
849
|
+
var usrConf = require(self.executionPath +'/'+ file +'.json');
|
|
850
|
+
return true
|
|
851
|
+
} catch(err) {
|
|
852
|
+
console.warn('CONF:HOST:WARN:1', err.stack||err.message);
|
|
853
|
+
return false
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* Get Registered bundles sharing the same port #
|
|
859
|
+
*
|
|
860
|
+
* @returns {Array} bundles
|
|
861
|
+
* */
|
|
862
|
+
this.getBundles = function() {
|
|
863
|
+
//Registered apps only.
|
|
864
|
+
return self.bundles
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
this.getAllBundles = function() {
|
|
868
|
+
//Registered apps only.
|
|
869
|
+
return self.allBundles
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
this.getAllEnvs = function() {
|
|
873
|
+
//Registered apps only.
|
|
874
|
+
return self.allEnvs
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* Get original rule
|
|
879
|
+
*
|
|
880
|
+
* @param {string} rule
|
|
881
|
+
* @param {object} routing
|
|
882
|
+
*
|
|
883
|
+
* @returns {string} originalRule
|
|
884
|
+
* */
|
|
885
|
+
this.getOriginalRule = function(rule, routing) {
|
|
886
|
+
|
|
887
|
+
var currentRouting = routing[rule];
|
|
888
|
+
|
|
889
|
+
for (var f in routing) {
|
|
890
|
+
if (
|
|
891
|
+
routing[f].param.action == currentRouting.param.action
|
|
892
|
+
&& routing[f].bundle == currentRouting.bundle
|
|
893
|
+
&& f != rule
|
|
894
|
+
&& new RegExp(f+"$").test(rule)
|
|
895
|
+
) {
|
|
896
|
+
return f
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
return undefined
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
var deepFreeze = function (obj) {
|
|
904
|
+
|
|
905
|
+
// On récupère les noms des propriétés définies sur obj
|
|
906
|
+
var propNames = Object.getOwnPropertyNames(obj);
|
|
907
|
+
|
|
908
|
+
// On gèle les propriétés avant de geler l'objet
|
|
909
|
+
for(let name of propNames){
|
|
910
|
+
let value = obj[name];
|
|
911
|
+
obj[name] = value && typeof value === "object" ?
|
|
912
|
+
deepFreeze(value) : value;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
// On gèle l'objet initial
|
|
916
|
+
return Object.freeze(obj);
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
var parseFileConf = function(root, arr, obj, len, i, content, pathname) {
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
key = arr[i];
|
|
923
|
+
if (/\-/.test(key)) {
|
|
924
|
+
key = key.replace(/-([a-z])/g, function(g) { return g[1].toUpperCase(); })
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
if ( i == 0 && Array.isArray(content)) {
|
|
928
|
+
var _key = '';
|
|
929
|
+
for (let _i = 0; _i < len; _i++) {
|
|
930
|
+
_key += arr[_i]
|
|
931
|
+
if (_i < len-1)
|
|
932
|
+
_key += '.';
|
|
933
|
+
}
|
|
934
|
+
pathname = _key;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
if (i == len - 1) { // end
|
|
938
|
+
if ( typeof(global._jsonConfig) == 'undefined' ) {
|
|
939
|
+
global._jsonConfig = {}
|
|
940
|
+
}
|
|
941
|
+
if ( typeof(global._jsonConfig[pathname]) == 'undefined' ) {
|
|
942
|
+
global._jsonConfig[pathname] = {}
|
|
943
|
+
}
|
|
944
|
+
// getConfig('app.key') should equal getConfig('app').key
|
|
945
|
+
if (root.hasOwnProperty(pathname)) {
|
|
946
|
+
//
|
|
947
|
+
if (!obj.hasOwnProperty(key)) {
|
|
948
|
+
//root[pathname] = content;
|
|
949
|
+
content = deepFreeze(content);
|
|
950
|
+
//global._jsonConfig[pathname] = content;
|
|
951
|
+
//Object.freeze(global._jsonConfig[pathname]);
|
|
952
|
+
root.__defineGetter__(pathname, function(){ return content });
|
|
953
|
+
} else {
|
|
954
|
+
//root[pathname] = merge(content, root[pathname]);
|
|
955
|
+
var _content = merge(content, root[pathname]);
|
|
956
|
+
_content = deepFreeze(_content);
|
|
957
|
+
//global._jsonConfig[pathname] = _content;
|
|
958
|
+
//Object.freeze(global._jsonConfig[pathname]);
|
|
959
|
+
root.__defineGetter__(pathname, function(){ return _content });
|
|
960
|
+
}
|
|
961
|
+
//obj[key] = root[pathname]
|
|
962
|
+
obj.__defineGetter__(key, function() {
|
|
963
|
+
return root[pathname]
|
|
964
|
+
//return global._jsonConfig[pathname]
|
|
965
|
+
});
|
|
966
|
+
deepFreeze(obj[key]);
|
|
967
|
+
} else {
|
|
968
|
+
// getConfig('app').key
|
|
969
|
+
if (!obj.hasOwnProperty(key)) {
|
|
970
|
+
obj[key] = content;
|
|
971
|
+
} else { // overiding exiting
|
|
972
|
+
obj[key] = merge(content, obj[key]);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
return root
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
if (typeof (obj[key]) == 'undefined') {
|
|
979
|
+
|
|
980
|
+
obj[key] = (Array.isArray(content)) ? [] : {};
|
|
981
|
+
++i;
|
|
982
|
+
|
|
983
|
+
return parseFileConf(root, arr, obj[key], len, i, content, pathname);
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
|
|
987
|
+
for (var k in obj) {
|
|
988
|
+
|
|
989
|
+
if (k == key) {
|
|
990
|
+
++i;
|
|
991
|
+
return parseFileConf(root, arr, obj[key], len, i, content, pathname);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
var loadBundleConfig = function(bundles, b, callback, reload, collectedRules) {
|
|
997
|
+
|
|
998
|
+
// current bundle
|
|
999
|
+
var bundle = null;
|
|
1000
|
+
if ( typeof(bundles[b]) == 'undefined' ) {
|
|
1001
|
+
bundle = self.startingApp
|
|
1002
|
+
} else {
|
|
1003
|
+
bundle = bundles[b]
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
// environment
|
|
1007
|
+
var cacheless = self.isCacheless()
|
|
1008
|
+
, isStandalone = self.Host.isStandalone()
|
|
1009
|
+
, env = self.env || self.Env.get() // env
|
|
1010
|
+
, conf = self.envConf // env conf
|
|
1011
|
+
;
|
|
1012
|
+
console.debug('[ CONFIG ] loading `'+ bundle +'/'+ env +'` configuration, please wait ...');
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
self.setServerCoreConf(bundle, env, conf.core);
|
|
1016
|
+
|
|
1017
|
+
// bundle paths, ports, protocols
|
|
1018
|
+
var appPath = ''
|
|
1019
|
+
, appPort = null
|
|
1020
|
+
, masterPort = null
|
|
1021
|
+
, portsReverse = getContext('gina').portsReverse
|
|
1022
|
+
, exists = false
|
|
1023
|
+
, protocol = null
|
|
1024
|
+
, scheme = null
|
|
1025
|
+
;
|
|
1026
|
+
|
|
1027
|
+
|
|
1028
|
+
conf[bundle][env].projectName = getContext('projectName');
|
|
1029
|
+
conf[bundle][env].allBundles = bundles;
|
|
1030
|
+
conf[bundle][env].cacheless = cacheless;
|
|
1031
|
+
conf[bundle][env].isStandalone = isStandalone;
|
|
1032
|
+
conf[bundle][env].executionPath = getContext('paths').root;
|
|
1033
|
+
|
|
1034
|
+
if ( self.task == 'run' && !self.isCacheless() ) {
|
|
1035
|
+
appPath = _(conf[bundle][env].bundlesPath + '/' + bundle)
|
|
1036
|
+
} else { //getting src path instead
|
|
1037
|
+
appPath = _(conf[bundle][env].sources + '/' + bundle);
|
|
1038
|
+
conf[bundle][env].bundlesPath = conf[bundle][env].sources;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
|
|
1042
|
+
// bundle web root
|
|
1043
|
+
var wroot = ( !conf[bundle][env].server.webroot || conf[bundle][env].server.webroot == '' ) ? '/' : conf[bundle][env].server.webroot
|
|
1044
|
+
// default `webrootAutoredirect` is true
|
|
1045
|
+
, webrootAutoredirect = conf[bundle][env].server.webrootAutoredirect
|
|
1046
|
+
, localWroot = null
|
|
1047
|
+
, localHasWebRoot = null
|
|
1048
|
+
;
|
|
1049
|
+
// formating wroot to have /mywebroot/
|
|
1050
|
+
wroot = ( !/^\//.test(wroot) ) ? '/' + wroot : wroot;
|
|
1051
|
+
wroot = ( !/\/$/.test(wroot) ) ? wroot + '/' : wroot;
|
|
1052
|
+
if (wroot == '/' || wroot == '' ) {
|
|
1053
|
+
// disable webrootAutoredirect
|
|
1054
|
+
webrootAutoredirect = conf[bundle][env].server.webrootAutoredirect = false
|
|
1055
|
+
}
|
|
1056
|
+
// standalone setup
|
|
1057
|
+
if ( isStandalone && bundle != self.startingApp && wroot == '/') {
|
|
1058
|
+
wroot += bundle + '/';
|
|
1059
|
+
}
|
|
1060
|
+
conf[bundle][env].server.webroot = wroot;
|
|
1061
|
+
var hasWebRoot = (wroot.length >1) ? true : false;
|
|
1062
|
+
|
|
1063
|
+
// bundle routing
|
|
1064
|
+
if ( !collectedRules || typeof(collectedRules) == 'undefined' ) {
|
|
1065
|
+
collectedRules = {}
|
|
1066
|
+
}
|
|
1067
|
+
var standaloneRouting = {}
|
|
1068
|
+
, originalRules = []
|
|
1069
|
+
, oRuleCount = 0
|
|
1070
|
+
, routing = {}
|
|
1071
|
+
, reverseRouting = {}
|
|
1072
|
+
, allowPreflight
|
|
1073
|
+
;
|
|
1074
|
+
|
|
1075
|
+
|
|
1076
|
+
var tmp = ''
|
|
1077
|
+
, err = false
|
|
1078
|
+
// template file
|
|
1079
|
+
, file = null
|
|
1080
|
+
, filename = null
|
|
1081
|
+
// files to be ignored while parsing config dir
|
|
1082
|
+
, defaultConfigFiles = (conf[bundle][env].files.join(".json,") + '.json').split(',')
|
|
1083
|
+
;
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
var fName = null, fNameWithNoExt = null;
|
|
1087
|
+
var files = { "routing": {} }, filesList = {};
|
|
1088
|
+
var main = '';
|
|
1089
|
+
var name = null;
|
|
1090
|
+
|
|
1091
|
+
var fileContent = null
|
|
1092
|
+
, allEnvs = self.getAllEnvs()
|
|
1093
|
+
, foundEnvVersion = null
|
|
1094
|
+
;
|
|
1095
|
+
|
|
1096
|
+
// getting bundle config files
|
|
1097
|
+
var configFiles = fs.readdirSync(_(appPath + '/config'))
|
|
1098
|
+
, c = 0
|
|
1099
|
+
, cLen = configFiles.length
|
|
1100
|
+
, jsonFile = null
|
|
1101
|
+
, e = null
|
|
1102
|
+
;
|
|
1103
|
+
for (; c < cLen; ++c) {
|
|
1104
|
+
foundEnvVersion = false;
|
|
1105
|
+
fName = configFiles[c];
|
|
1106
|
+
fNameWithNoExt = fName.replace(/.json/, '');
|
|
1107
|
+
|
|
1108
|
+
// do we need it ?
|
|
1109
|
+
// if (conf[bundle][env].files.indexOf(fNameWithNoExt) < 0) {
|
|
1110
|
+
// conf[bundle][env].files.push(fNameWithNoExt)
|
|
1111
|
+
// }
|
|
1112
|
+
|
|
1113
|
+
// e.g: if env == `dev` and we have app.prod.json, we should skip it
|
|
1114
|
+
let skipIt = false;
|
|
1115
|
+
for (let e = 0, eLen = allEnvs.length; e < eLen; e++) {
|
|
1116
|
+
let re = new RegExp('\.'+ allEnvs[e] +'\.json$');
|
|
1117
|
+
if ( re.test(fName) && allEnvs[e] != env ) {
|
|
1118
|
+
// we should skip it
|
|
1119
|
+
skipIt = true;
|
|
1120
|
+
break;
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
if (skipIt) continue;
|
|
1124
|
+
|
|
1125
|
+
if ( /^settings\./.test(fName) ) {
|
|
1126
|
+
// already defined before by `loadWithTemplate()`
|
|
1127
|
+
continue;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
if (/^\./.test(fName) || new RegExp('\.'+ env +'\.json$').test(fName) || !/\.json$/.test(fName) )
|
|
1131
|
+
continue;
|
|
1132
|
+
|
|
1133
|
+
// e.g: if env == `dev` and we have app.dev.json
|
|
1134
|
+
if (new RegExp('\.'+ env +'\.json$').test(fName) ) {
|
|
1135
|
+
foundEnvVersion = true;
|
|
1136
|
+
}
|
|
1137
|
+
//name = fName.replace(/\.json$/, '');
|
|
1138
|
+
// we just want the main name .. not the extended description fullname
|
|
1139
|
+
name = fName.replace(/\..*/g, '');
|
|
1140
|
+
let section = fNameWithNoExt
|
|
1141
|
+
.replace(/^\w+\./g, '')
|
|
1142
|
+
.replace(new RegExp('\.'+ env +'\.json$'), '');
|
|
1143
|
+
if (section == fNameWithNoExt) {
|
|
1144
|
+
section = '';
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
if (/\-/.test(name)) {
|
|
1148
|
+
name = name.replace(/-([a-z])/g, function(g) { return g[1].toUpperCase(); })
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
filesList[name] = fName;
|
|
1152
|
+
// handle registered config files
|
|
1153
|
+
main = fName;
|
|
1154
|
+
tmp = fName.replace(/.json/, '.' + env + '.json'); // dev
|
|
1155
|
+
|
|
1156
|
+
files[name] = ( typeof(files[name]) != 'undefined' ) ? files[name] : {};
|
|
1157
|
+
fileContent = files[name];
|
|
1158
|
+
filename = _(appPath + '/config/' + tmp);
|
|
1159
|
+
exists = fs.existsSync(_(filename, true));
|
|
1160
|
+
// loading dev if exists
|
|
1161
|
+
if ( self.isCacheless() ) {
|
|
1162
|
+
if (exists) {
|
|
1163
|
+
delete require.cache[require.resolve(_(filename, true))];
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
try {
|
|
1168
|
+
if (exists) {
|
|
1169
|
+
jsonFile = requireJSON(_(filename, true));
|
|
1170
|
+
if (Array.isArray(jsonFile) && !Array.isArray(fileContent) && !Object.keys(fileContent).length) {
|
|
1171
|
+
fileContent = []
|
|
1172
|
+
}
|
|
1173
|
+
// Fixed priority to env version and/or extended.description if found
|
|
1174
|
+
fileContent = merge(jsonFile, fileContent);
|
|
1175
|
+
}
|
|
1176
|
+
} catch (_err) {
|
|
1177
|
+
if (exists) {
|
|
1178
|
+
callback(new Error('[ ' + filename + ' ] is malformed !!'))
|
|
1179
|
+
} else {
|
|
1180
|
+
fileContent = undefined
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
// loading main
|
|
1184
|
+
filename = _(appPath + '/config/' + main);
|
|
1185
|
+
//Can't do anything without.
|
|
1186
|
+
try {
|
|
1187
|
+
exists = fs.existsSync(_(filename, true));
|
|
1188
|
+
if (cacheless && exists) {
|
|
1189
|
+
delete require.cache[require.resolve(_(filename, true))];
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
if (exists) {
|
|
1193
|
+
jsonFile = requireJSON(_(filename, true));
|
|
1194
|
+
if (Array.isArray(jsonFile) && !Array.isArray(fileContent) && !Object.keys(fileContent).length) {
|
|
1195
|
+
fileContent = []
|
|
1196
|
+
}
|
|
1197
|
+
//fileContent = merge(fileContent, jsonFile);
|
|
1198
|
+
// Fixed priority to env version and/or extended.description if found
|
|
1199
|
+
fileContent = merge(jsonFile, fileContent);
|
|
1200
|
+
} else {
|
|
1201
|
+
console.warn('[ ' + app + ' ] [ ' + env + ' ]' + new Error('[ ' + filename + ' ] not found'));
|
|
1202
|
+
}
|
|
1203
|
+
} catch (_err) {
|
|
1204
|
+
|
|
1205
|
+
if (fs.existsSync(filename)) {
|
|
1206
|
+
e = '[ ' + filename + ' ] is malformed !!\n\r' + (_err.stack || _err.message);
|
|
1207
|
+
console.error(e);
|
|
1208
|
+
callback(new Error(e))
|
|
1209
|
+
} else {
|
|
1210
|
+
fileContent = undefined
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
// if (/\./.test(fNameWithNoExt)) {
|
|
1215
|
+
// let nameArr = fNameWithNoExt.split(/\./g);
|
|
1216
|
+
// if ( typeof(files[nameArr[0]]) == 'undefined')
|
|
1217
|
+
// files[nameArr[0]] = {};
|
|
1218
|
+
|
|
1219
|
+
// try {
|
|
1220
|
+
// files = parseFileConf(files, nameArr, files, nameArr.length, 0, fileContent);
|
|
1221
|
+
// continue;
|
|
1222
|
+
// } catch (_err) {
|
|
1223
|
+
// e = '[ ' + nameArr + ' ] could not parse file conf !!\n\r' + (_err.stack || _err.message);
|
|
1224
|
+
// console.error(e);
|
|
1225
|
+
// callback(new Error(e))
|
|
1226
|
+
// }
|
|
1227
|
+
|
|
1228
|
+
|
|
1229
|
+
// } else {
|
|
1230
|
+
// files[name] = fileContent;
|
|
1231
|
+
// }
|
|
1232
|
+
|
|
1233
|
+
if (section != '' ) {
|
|
1234
|
+
if (/\-/.test(section)) {
|
|
1235
|
+
section = section.replace(/-([a-z])/g, function(g) { return g[1].toUpperCase(); })
|
|
1236
|
+
}
|
|
1237
|
+
mergeConfig(files[name], section, fileContent );
|
|
1238
|
+
} else {
|
|
1239
|
+
files[name] = merge(files[name], fileContent);
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
|
|
1243
|
+
} // EO for (var c = 0, cLen = configFiles.length; c < cLen; ++c)
|
|
1244
|
+
conf[bundle][env] = merge(files, conf[bundle][env]);
|
|
1245
|
+
|
|
1246
|
+
// building file list
|
|
1247
|
+
conf[bundle][env].configFiles = filesList;
|
|
1248
|
+
|
|
1249
|
+
var hasViews = (typeof(files['templates']) != 'undefined' && typeof(files['templates']['_common']) != 'undefined') ? true : false;
|
|
1250
|
+
|
|
1251
|
+
// e.g.: 404 rendering for JSON APIs by checking `env.template`: JSON response can be forced even if the bundle has views
|
|
1252
|
+
if ( hasViews && typeof(self.userConf[bundle][env].template) != 'undefined' && self.userConf[bundle][env].template == false) {
|
|
1253
|
+
conf[bundle][env].template = false
|
|
1254
|
+
} else if (hasViews) {
|
|
1255
|
+
conf[bundle][env].template = true;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
|
|
1259
|
+
name = 'routing';
|
|
1260
|
+
routing = files[name];
|
|
1261
|
+
var r = null, rLen = null;
|
|
1262
|
+
//setting app param
|
|
1263
|
+
var urls = null;
|
|
1264
|
+
// bundle status
|
|
1265
|
+
routing['status'] = {
|
|
1266
|
+
url: '/status',
|
|
1267
|
+
method: 'GET',
|
|
1268
|
+
param: {
|
|
1269
|
+
control: 'getBundleStatus'
|
|
1270
|
+
}
|
|
1271
|
+
};
|
|
1272
|
+
|
|
1273
|
+
// custom error page
|
|
1274
|
+
routing['custom-error-page'] = {
|
|
1275
|
+
// url will be modified on error
|
|
1276
|
+
url: '/custom-error',
|
|
1277
|
+
method: 'GET',
|
|
1278
|
+
middleware: [],
|
|
1279
|
+
param: {
|
|
1280
|
+
control: 'renderCustomError',
|
|
1281
|
+
// default data : will be fed on error
|
|
1282
|
+
error: {}
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
|
|
1286
|
+
// creating default rule for auto redirect: / => /webroot
|
|
1287
|
+
if (
|
|
1288
|
+
hasWebRoot
|
|
1289
|
+
&& wroot != '/'
|
|
1290
|
+
&& typeof(routing['webroot@'+ bundle]) == 'undefined'
|
|
1291
|
+
) {
|
|
1292
|
+
routing['webroot@'+ bundle] = {
|
|
1293
|
+
method: 'GET, POST, PUT, DELETE, HEAD',
|
|
1294
|
+
// by default
|
|
1295
|
+
url: wroot.substring(0, wroot.length-1),
|
|
1296
|
+
middleware: [],
|
|
1297
|
+
param: {
|
|
1298
|
+
control: "redirect",
|
|
1299
|
+
ignoreWebRoot: true,
|
|
1300
|
+
path: wroot,
|
|
1301
|
+
code: 302
|
|
1302
|
+
},
|
|
1303
|
+
bundle: bundle,
|
|
1304
|
+
host: conf[bundle][env].host,
|
|
1305
|
+
hostname: conf[bundle][env].server.scheme +'://'+ conf[bundle][env].host +':'+ conf[bundle][env].port[conf[bundle][env].server.protocol][conf[bundle][env].server.scheme],
|
|
1306
|
+
webroot: wroot
|
|
1307
|
+
};
|
|
1308
|
+
// default hostname
|
|
1309
|
+
if ( /^true$/i.test(webrootAutoredirect) ) {
|
|
1310
|
+
routing['webroot@'+ bundle].url = '/,'+ wroot.substring(0, wroot.length-1);
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
// upload routes
|
|
1315
|
+
if (
|
|
1316
|
+
typeof(conf[bundle][env].upload) != 'undefined'
|
|
1317
|
+
&& typeof(conf[bundle][env].upload.groups) != 'undefined'
|
|
1318
|
+
&& conf[bundle][env].upload.groups.count() > 0
|
|
1319
|
+
) {
|
|
1320
|
+
if ( typeof(routing['upload-to-tmp-xml@'+ bundle]) == 'undefined' ) {
|
|
1321
|
+
routing['upload-to-tmp-xml'] = {
|
|
1322
|
+
"_comment": "Will store file to the project tmp dir",
|
|
1323
|
+
"url": "/upload",
|
|
1324
|
+
"method": "POST",
|
|
1325
|
+
"param": {
|
|
1326
|
+
"control": "uploadToTmp",
|
|
1327
|
+
"title": "Upload file"
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
if ( typeof(routing['upload-delete-from-tmp-xml@'+ bundle]) == 'undefined' ) {
|
|
1333
|
+
routing['upload-delete-from-tmp-xml'] = {
|
|
1334
|
+
"_comment": "Will remove file from the project tmp dir",
|
|
1335
|
+
"url": "/upload/delete",
|
|
1336
|
+
"method": "POST",
|
|
1337
|
+
"param": {
|
|
1338
|
+
"control": "deleteFromTmp",
|
|
1339
|
+
"title": "Delete uploaded file"
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
|
|
1346
|
+
for (let rule in routing) {
|
|
1347
|
+
|
|
1348
|
+
// checking requirements syntax
|
|
1349
|
+
if ( typeof(routing[rule].requirements) != 'undefined' && routing[rule].requirements.count() > 0 ) {
|
|
1350
|
+
for ( let r in routing[rule].requirements) {
|
|
1351
|
+
if (
|
|
1352
|
+
!/^\//.test(routing[rule].requirements[r])
|
|
1353
|
+
&& !/^validator\:\:/.test(routing[rule].requirements[r])
|
|
1354
|
+
) {
|
|
1355
|
+
let ruleName = ( !/\@/.test(rule) ) ? rule +'@'+ bundle : rule;
|
|
1356
|
+
err = new Error('['+ruleName+'] Bad routing syntax for `'+r+'` in requirements : must start with `/` or `validator::`');
|
|
1357
|
+
console.emerg(err.stack||err.message);
|
|
1358
|
+
process.exit(1);
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
if (rule == 'webroot@'+ bundle) continue;
|
|
1365
|
+
|
|
1366
|
+
localWroot = wroot; // by default
|
|
1367
|
+
|
|
1368
|
+
if ( typeof(routing[rule].bundle) != 'undefined' && routing[rule].bundle != bundle ) {
|
|
1369
|
+
localWroot = conf[routing[rule].bundle][env].server.webroot;//conf[bundle][env].server.webroot
|
|
1370
|
+
// formating localWroot to have /mywebroot/
|
|
1371
|
+
localWroot = ( !/^\//.test(localWroot) ) ? '/' + localWroot : localWroot;
|
|
1372
|
+
localWroot = ( !/\/$/.test(localWroot) ) ? localWroot + '/' : localWroot;
|
|
1373
|
+
|
|
1374
|
+
// standalone setup
|
|
1375
|
+
if ( isStandalone && bundle != self.startingApp && localWroot == '/') {
|
|
1376
|
+
localWroot += bundle + '/';
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
conf[routing[rule].bundle][env].server.webroot = localWroot
|
|
1380
|
+
} else {
|
|
1381
|
+
routing[rule].bundle = bundle;
|
|
1382
|
+
}
|
|
1383
|
+
localHasWebRoot = (localWroot.length >1) ? true : false;
|
|
1384
|
+
|
|
1385
|
+
|
|
1386
|
+
// default hostname
|
|
1387
|
+
if (
|
|
1388
|
+
typeof(routing[rule].hostname) == 'undefined' && !/^redirect$/.test(routing[rule].param.control)
|
|
1389
|
+
|| !routing[rule].hostname && !/^redirect$/.test(routing[rule].param.control)
|
|
1390
|
+
) {
|
|
1391
|
+
routing[rule].host = conf[routing[rule].bundle][env].host
|
|
1392
|
+
routing[rule].hostname = conf[routing[rule].bundle][env].server.scheme +'://'+ routing[rule].host +':'+ conf[routing[rule].bundle][env].port[conf[routing[rule].bundle][env].server.protocol][conf[routing[rule].bundle][env].server.scheme];
|
|
1393
|
+
// default webroot
|
|
1394
|
+
routing[rule].webroot = localWroot;
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
|
|
1398
|
+
// default method
|
|
1399
|
+
if ( typeof(routing[rule].method) == 'undefined' || !routing[rule].method )
|
|
1400
|
+
routing[rule].method = 'GET';
|
|
1401
|
+
|
|
1402
|
+
if ( /\,/.test(routing[rule].method) )
|
|
1403
|
+
routing[rule].method = routing[rule].method.replace(/\s+/g, '');
|
|
1404
|
+
|
|
1405
|
+
// default middleware
|
|
1406
|
+
if ( typeof(routing[rule].middleware) == 'undefined' || !routing[rule].middleware )
|
|
1407
|
+
routing[rule].middleware = [];
|
|
1408
|
+
|
|
1409
|
+
// default url
|
|
1410
|
+
if ( typeof(routing[rule].url) == 'undefined' || !routing[rule].url )
|
|
1411
|
+
routing[rule].url = '/'+ rule;
|
|
1412
|
+
|
|
1413
|
+
try {
|
|
1414
|
+
if ( /\,/.test(routing[rule].url) )
|
|
1415
|
+
routing[rule].url = routing[rule].url.replace(/\s+/g, '');
|
|
1416
|
+
|
|
1417
|
+
} catch (err) {
|
|
1418
|
+
throw new Error('[ ROUTING ] Error found in your route description: \nbundle: `'+ routing[rule].bundle +'`\nroute: `'+ rule +'`\nurl: `'+ routing[rule].url +'`.\nPlease check your routing configuration: `'+ routing[rule].bundle +'/config/'+ name+'.json` or `'+ routing[rule].bundle +'/config/'+ name+'.'+ env +'.json`');
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
// link route & template if hasViews - inly for GET methods
|
|
1422
|
+
if ( hasViews && /get/i.test(routing[rule].method) && typeof(files['templates'][rule.toLowerCase()]) == 'undefined' ) {
|
|
1423
|
+
files['templates'][rule.toLowerCase()] = {}
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
routing[rule.toLowerCase() +'@'+ bundle] = routing[rule];
|
|
1427
|
+
delete routing[rule];
|
|
1428
|
+
|
|
1429
|
+
// default file name
|
|
1430
|
+
file = rule.toLowerCase();
|
|
1431
|
+
rule = rule.toLowerCase() +'@'+ bundle;
|
|
1432
|
+
|
|
1433
|
+
|
|
1434
|
+
routing[rule].bundle = (routing[rule].bundle) ? routing[rule].bundle : bundle; // for reverse lookup
|
|
1435
|
+
// route file
|
|
1436
|
+
if (!routing[rule].param) continue;
|
|
1437
|
+
//routing[rule].param.file = ( typeof(routing[rule].param) != 'undefined' && typeof(routing[rule].param.file) != 'undefined' ) ? routing[rule].param.file: file; // get template file
|
|
1438
|
+
if ( typeof(routing[rule].param) != 'undefined' && typeof(routing[rule].param.file) != 'undefined' && /delete/i.test(routing[rule].method )) {
|
|
1439
|
+
console.warn('`DELETE` method result should not be rendered into a file');
|
|
1440
|
+
} else if ( typeof(routing[rule].param) != 'undefined' && typeof(routing[rule].param.file) == 'undefined' /**&& !/delete/i.test(routing[rule].method)*/) {
|
|
1441
|
+
routing[rule].param.file = file
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
// by default, method is inherited from the request.method
|
|
1445
|
+
if (
|
|
1446
|
+
localHasWebRoot && typeof(routing[rule].param.path) != 'undefined' && typeof(routing[rule].param.ignoreWebRoot) == 'undefined'
|
|
1447
|
+
|| localHasWebRoot && typeof(routing[rule].param.path) != 'undefined' && !routing[rule].param.ignoreWebRoot
|
|
1448
|
+
) {
|
|
1449
|
+
routing[rule].param.path = localWroot + ( /^\//.test(routing[rule].param.path) ) ? routing[rule].param.path.substr(1) : routing[rule].param.path
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
// ignoreWebRoot test to rewrite url webroot
|
|
1455
|
+
if ( typeof(routing[rule].param.ignoreWebRoot) == 'undefined' || !routing[rule].param.ignoreWebRoot ) {
|
|
1456
|
+
//routing[rule].url = (routing[rule].url.length > 1) ? localWroot + routing[rule].url : routing[rule].url;
|
|
1457
|
+
if ( /\,/.test(routing[rule].url) ) {
|
|
1458
|
+
urls = routing[rule].url.split(/\,/g);
|
|
1459
|
+
r = 0; rLen = urls.length;
|
|
1460
|
+
for (; r < rLen; ++r) {
|
|
1461
|
+
urls[r] = ( localHasWebRoot && urls[r].length > 1) ? localWroot + urls[r].substr(1) : ((localHasWebRoot && urls[r].length == 1) ? localWroot : urls[r]);
|
|
1462
|
+
}
|
|
1463
|
+
routing[rule].url = urls.join(',');
|
|
1464
|
+
} else {
|
|
1465
|
+
routing[rule].url = ( localHasWebRoot && routing[rule].url.length > 1) ? localWroot + routing[rule].url.substr(1) : ((localHasWebRoot && routing[rule].url.length == 1) ? localWroot : routing[rule].url);
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
self.setRouting(bundle, env, routing);
|
|
1471
|
+
// reverse routing
|
|
1472
|
+
for (let rule in routing) {
|
|
1473
|
+
|
|
1474
|
+
if ( /\,/.test(routing[rule].url) ) {
|
|
1475
|
+
urls = routing[rule].url.split(/\,/g);
|
|
1476
|
+
r = 0; rLen = urls.length;
|
|
1477
|
+
for (; r < rLen; ++r) {
|
|
1478
|
+
reverseRouting[ urls[r] ] = rule
|
|
1479
|
+
}
|
|
1480
|
+
} else {
|
|
1481
|
+
reverseRouting[ routing[rule].url ] = rule
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
self.setReverseRouting(bundle, env, reverseRouting);
|
|
1485
|
+
|
|
1486
|
+
if (!conf[bundle][env].executionPath) {
|
|
1487
|
+
conf[bundle][env].executionPath = self.executionPath
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
//Constants to be exposed in configuration files.
|
|
1491
|
+
var reps = {
|
|
1492
|
+
"gina" : getPath('gina').root,
|
|
1493
|
+
"frameworkDir" : GINA_FRAMEWORK_DIR,
|
|
1494
|
+
"scope" : conf[bundle][env].server.scope,
|
|
1495
|
+
"host" : conf[bundle][env].host,
|
|
1496
|
+
"env" : env,
|
|
1497
|
+
"bundle" : bundle,
|
|
1498
|
+
// "server.engine" : conf[bundle][env].engine,
|
|
1499
|
+
// "server.protocol" : conf[bundle][env].protocol,
|
|
1500
|
+
// "server.scheme" : conf[bundle][env].scheme,
|
|
1501
|
+
"project" : getPath('project'),
|
|
1502
|
+
"root" : conf[bundle][env].executionPath,
|
|
1503
|
+
"executionPath" : conf[bundle][env].executionPath,
|
|
1504
|
+
"source" : conf[bundle][env].sources,
|
|
1505
|
+
"projectPath" : conf[bundle][env].projectPath,
|
|
1506
|
+
"bundlesPath" : conf[bundle][env].bundlesPath,
|
|
1507
|
+
"mountPath" : conf[bundle][env].mountPath,
|
|
1508
|
+
"bundlePath" : conf[bundle][env].bundlePath,
|
|
1509
|
+
"templatesPath" : conf[bundle][env].templatesPath,
|
|
1510
|
+
"publicPath" : conf[bundle][env].publicPath,
|
|
1511
|
+
"modelsPath" : conf[bundle][env].modelsPath,
|
|
1512
|
+
"libPath" : conf[bundle][env].libPath,
|
|
1513
|
+
"handlersPath" : conf[bundle][env].handlersPath,
|
|
1514
|
+
"sharedPath" : conf[bundle][env].sharedPath,
|
|
1515
|
+
"logsPath" : conf[bundle][env].logsPath,
|
|
1516
|
+
"tmpPath" : conf[bundle][env].tmpPath,
|
|
1517
|
+
"version" : getContext('gina').version
|
|
1518
|
+
};
|
|
1519
|
+
|
|
1520
|
+
for (let _contant in process.gina) {
|
|
1521
|
+
reps[_contant] = process.gina[_contant];
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
var corePath = getPath('gina').core;
|
|
1525
|
+
var settingsPath = _(corePath +'/template/conf/settings.json', true);
|
|
1526
|
+
var staticsPath = _(corePath +'/template/conf/statics.json', true);
|
|
1527
|
+
var viewsPath = _(corePath +'/template/conf/templates.json', true);
|
|
1528
|
+
|
|
1529
|
+
var defaultViews = requireJSON(viewsPath);
|
|
1530
|
+
if (hasViews && typeof(files['templates']._common) != 'undefined') {
|
|
1531
|
+
reps['templates'] = files['templates']._common.templates || defaultViews._common.templates;
|
|
1532
|
+
reps['html'] = files['templates']._common.html || defaultViews._common.html;
|
|
1533
|
+
reps['theme'] = files['templates']._common.theme || defaultViews._common.theme;
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
var ports = conf[bundle][env].port;
|
|
1537
|
+
for (var p in ports) {
|
|
1538
|
+
reps[p+'Port'] = ports[p]
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
var localEnv = conf[bundle][env].executionPath + '/env.local.json';
|
|
1542
|
+
if ( self.isCacheless() && fs.existsSync(localEnv) ) {
|
|
1543
|
+
conf[bundle][env] = merge(conf[bundle][env], requireJSON(localEnv), true);
|
|
1544
|
+
}
|
|
1545
|
+
var envKeys = conf[bundle][env];
|
|
1546
|
+
for (var k in envKeys) {
|
|
1547
|
+
if ( typeof(envKeys[k]) != 'object' && typeof(envKeys[k]) != 'array' ) {
|
|
1548
|
+
reps[k] = envKeys[k]
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
|
|
1553
|
+
try {
|
|
1554
|
+
|
|
1555
|
+
// we only need to retrieve the tmpFiles (files[settings])
|
|
1556
|
+
files['settings'] = JSON.clone(conf[bundle][env].tmpSettingFileContent) || {};
|
|
1557
|
+
delete conf[bundle][env].tmpSettingFileContent;
|
|
1558
|
+
|
|
1559
|
+
if ( files['settings'].count() == 0 ) {
|
|
1560
|
+
files['settings'] = requireJSON(settingsPath)
|
|
1561
|
+
} else {
|
|
1562
|
+
var defaultSettings = requireJSON(settingsPath);
|
|
1563
|
+
files['settings'] = merge( JSON.clone(files['settings']), defaultSettings)
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
if (fs.existsSync(staticsPath))
|
|
1567
|
+
delete require.cache[require.resolve(staticsPath)];
|
|
1568
|
+
|
|
1569
|
+
|
|
1570
|
+
if (hasViews && typeof(files['statics']) == 'undefined') {
|
|
1571
|
+
files['statics'] = requireJSON(staticsPath)
|
|
1572
|
+
} else if ( typeof(files['statics']) != 'undefined' ) {
|
|
1573
|
+
var defaultAliases = requireJSON(staticsPath);
|
|
1574
|
+
files['statics'] = merge(defaultAliases, files['statics'], true)
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
|
|
1578
|
+
// public resources ref
|
|
1579
|
+
if ( typeof(conf[bundle][env].publicResources) == 'undefined') {
|
|
1580
|
+
conf[bundle][env].publicResources = []
|
|
1581
|
+
}
|
|
1582
|
+
// static resources
|
|
1583
|
+
if ( typeof(conf[bundle][env].staticResources) == 'undefined') {
|
|
1584
|
+
conf[bundle][env].staticResources = []
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
// templates root directories
|
|
1588
|
+
var d = 0
|
|
1589
|
+
, dirs = null
|
|
1590
|
+
, pCount = 0
|
|
1591
|
+
, sCount = 0
|
|
1592
|
+
;
|
|
1593
|
+
if (conf[bundle][env].publicPath && fs.existsSync(conf[bundle][env].publicPath) ) {
|
|
1594
|
+
var publicResources = []
|
|
1595
|
+
, lStat = null
|
|
1596
|
+
;
|
|
1597
|
+
|
|
1598
|
+
d = 0;
|
|
1599
|
+
dirs = fs.readdirSync(conf[bundle][env].publicPath);
|
|
1600
|
+
// ignoring html (template files) directory
|
|
1601
|
+
//dirs.splice(dirs.indexOf(new _(reps.html, true).toArray().last()), 1);
|
|
1602
|
+
|
|
1603
|
+
// making statics allowed directories
|
|
1604
|
+
while ( d < dirs.length) {
|
|
1605
|
+
lStat = fs.lstatSync(_(conf[bundle][env].publicPath +'/'+ dirs[d], true));
|
|
1606
|
+
if ( !/^\./.test(dirs[d]) && lStat.isDirectory() ) {
|
|
1607
|
+
// regular path
|
|
1608
|
+
publicResources[pCount] = '/'+ dirs[d] +'/';
|
|
1609
|
+
++pCount;
|
|
1610
|
+
// handle resources from public with webroot in url
|
|
1611
|
+
publicResources[pCount] = conf[bundle][env].server.webroot + dirs[d] +'/';
|
|
1612
|
+
++pCount
|
|
1613
|
+
} else if ( !/^\./.test(dirs[d]) && lStat.isFile() ) {
|
|
1614
|
+
// regular path
|
|
1615
|
+
publicResources[pCount] = '/'+ dirs[d];
|
|
1616
|
+
++pCount;
|
|
1617
|
+
// handle resources from public with webroot in url
|
|
1618
|
+
publicResources[pCount] = conf[bundle][env].server.webroot + dirs[d];
|
|
1619
|
+
++pCount
|
|
1620
|
+
}
|
|
1621
|
+
++d
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
if (hasWebRoot) {
|
|
1625
|
+
var staticToPublicPath = null;
|
|
1626
|
+
for (let p in files['statics']) {
|
|
1627
|
+
staticToPublicPath = wroot + p.replace( new RegExp('^'+ wroot), '/');
|
|
1628
|
+
|
|
1629
|
+
if ( !/\./.test(staticToPublicPath.substr(staticToPublicPath.lastIndexOf('/') )) && !/\/$/.test(staticToPublicPath) )
|
|
1630
|
+
staticToPublicPath += '/';
|
|
1631
|
+
|
|
1632
|
+
if ( publicResources.indexOf(staticToPublicPath) < 0 )
|
|
1633
|
+
publicResources.push( staticToPublicPath )
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
conf[bundle][env].publicResources = publicResources
|
|
1638
|
+
} else if (hasViews) {
|
|
1639
|
+
console.warn('['+bundle+'] No public dir to scan...')
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
|
|
1643
|
+
if (hasViews && typeof(files['templates']) == 'undefined') {
|
|
1644
|
+
files['templates'] = JSON.clone(defaultViews)
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
|
|
1648
|
+
if ( typeof(files['templates']) != 'undefined' ) {
|
|
1649
|
+
|
|
1650
|
+
var css = {
|
|
1651
|
+
name : '',
|
|
1652
|
+
media : 'all',
|
|
1653
|
+
rel : 'stylesheet',
|
|
1654
|
+
type : 'text/css',
|
|
1655
|
+
url : '',
|
|
1656
|
+
isCommon : false,
|
|
1657
|
+
},
|
|
1658
|
+
js = {
|
|
1659
|
+
name : '',
|
|
1660
|
+
type : 'text/javascript',
|
|
1661
|
+
url : '',
|
|
1662
|
+
isCommon : false
|
|
1663
|
+
}
|
|
1664
|
+
;
|
|
1665
|
+
|
|
1666
|
+
var excluded = {}
|
|
1667
|
+
, excludedType = null
|
|
1668
|
+
, excludedStr = null
|
|
1669
|
+
, excludedUrl = null
|
|
1670
|
+
, currentCollection = null
|
|
1671
|
+
, noneDefaultJs = null
|
|
1672
|
+
, noneDefaultCss = null
|
|
1673
|
+
, reWebroot = new RegExp('^'+conf[bundle][env].server.webroot)
|
|
1674
|
+
;
|
|
1675
|
+
var t = null
|
|
1676
|
+
, tLen = null
|
|
1677
|
+
, tTmp = null
|
|
1678
|
+
, url = null
|
|
1679
|
+
;
|
|
1680
|
+
|
|
1681
|
+
// formating _common def for javascripts & stylesheets
|
|
1682
|
+
for (let section in files['templates']) {
|
|
1683
|
+
if (!/^_common$/.test(section) ) continue;
|
|
1684
|
+
|
|
1685
|
+
// inheriting from defaultViews - gina _common
|
|
1686
|
+
files['templates'][section] = merge(files['templates'][section], defaultViews[section]);
|
|
1687
|
+
// updating javascripts & css order
|
|
1688
|
+
noneDefaultJs = (files['templates'][section].javascripts) ? JSON.clone(files['templates'][section].javascripts) : [];
|
|
1689
|
+
noneDefaultCss = (files['templates'][section].stylesheets) ? JSON.clone(files['templates'][section].stylesheets) : [];
|
|
1690
|
+
|
|
1691
|
+
if ( Array.isArray(noneDefaultJs) && noneDefaultJs.length > 0 /**&& typeof(noneDefaultJs[0].url) == 'undefined'*/ ) {
|
|
1692
|
+
tTmp = JSON.clone(noneDefaultJs);
|
|
1693
|
+
t = 0;
|
|
1694
|
+
tLen = tTmp.length;
|
|
1695
|
+
noneDefaultJs = [];
|
|
1696
|
+
for (; t < tLen; ++t) {
|
|
1697
|
+
noneDefaultJs[t] = JSON.clone(js);
|
|
1698
|
+
url = tTmp[t];
|
|
1699
|
+
if ( typeof(url) == 'string') {
|
|
1700
|
+
noneDefaultJs[t].url = url;
|
|
1701
|
+
noneDefaultJs[t].name = url.substring(url.lastIndexOf('/')+1, url.lastIndexOf('.')).replace(/\W+/g, '-');
|
|
1702
|
+
noneDefaultJs[t].isCommon = ( /^_common$/.test(section) ) ? true : false;
|
|
1703
|
+
} else {
|
|
1704
|
+
noneDefaultJs[t] = merge(url, noneDefaultJs[t]);
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
if ( Array.isArray(noneDefaultCss) && noneDefaultCss.length > 0 /**&& typeof(noneDefaultCss[0].url) == 'undefined'*/ ) {
|
|
1710
|
+
tTmp = JSON.clone(noneDefaultCss);
|
|
1711
|
+
t = 0;
|
|
1712
|
+
tLen = tTmp.length;
|
|
1713
|
+
noneDefaultCss = [];
|
|
1714
|
+
for (; t < tLen; ++t) {
|
|
1715
|
+
noneDefaultCss[t] = JSON.clone(css);
|
|
1716
|
+
url = tTmp[t];
|
|
1717
|
+
if ( typeof(url) == 'string') {
|
|
1718
|
+
noneDefaultCss[t].url = url;
|
|
1719
|
+
noneDefaultCss[t].name = url.substring(url.lastIndexOf('/')+1, url.lastIndexOf('.')).replace(/\W+/g, '-');
|
|
1720
|
+
noneDefaultCss[t].isCommon = ( /^_common$/.test(section) ) ? true : false;
|
|
1721
|
+
} else {
|
|
1722
|
+
noneDefaultCss[t] = merge(url, noneDefaultCss[t]);
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
files['templates'][section].javascripts = JSON.clone(noneDefaultJs);
|
|
1728
|
+
files['templates'][section].stylesheets = JSON.clone(noneDefaultCss);
|
|
1729
|
+
}
|
|
1730
|
+
// process other sections
|
|
1731
|
+
for (let section in files['templates']) {
|
|
1732
|
+
// skip _common section
|
|
1733
|
+
if (/^_common$/.test(section) ) continue;
|
|
1734
|
+
|
|
1735
|
+
// updating javascripts & css order
|
|
1736
|
+
noneDefaultJs = (files['templates'][section].javascripts) ? JSON.clone(files['templates'][section].javascripts) : [];
|
|
1737
|
+
noneDefaultCss = (files['templates'][section].stylesheets) ? JSON.clone(files['templates'][section].stylesheets) : [];
|
|
1738
|
+
|
|
1739
|
+
if ( Array.isArray(noneDefaultJs) && noneDefaultJs.length > 0 /**&& typeof(noneDefaultJs[0].url) == 'undefined'*/ ) {
|
|
1740
|
+
tTmp = JSON.clone(noneDefaultJs);
|
|
1741
|
+
t = 0;
|
|
1742
|
+
tLen = tTmp.length;
|
|
1743
|
+
noneDefaultJs = [];
|
|
1744
|
+
for (; t < tLen; ++t) {
|
|
1745
|
+
noneDefaultJs[t] = JSON.clone(js);
|
|
1746
|
+
url = tTmp[t];
|
|
1747
|
+
if ( typeof(url) == 'string') {
|
|
1748
|
+
noneDefaultJs[t].url = url;
|
|
1749
|
+
noneDefaultJs[t].name = url.substring(url.lastIndexOf('/')+1, url.lastIndexOf('.')).replace(/\W+/g, '-');
|
|
1750
|
+
noneDefaultJs[t].isCommon = ( /^_common$/.test(section) ) ? true : false;
|
|
1751
|
+
} else {
|
|
1752
|
+
noneDefaultJs[t] = merge(url, noneDefaultJs[t]);
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
if ( Array.isArray(noneDefaultCss) && noneDefaultCss.length > 0 /**&& typeof(noneDefaultCss[0].url) == 'undefined'*/ ) {
|
|
1758
|
+
tTmp = JSON.clone(noneDefaultCss);
|
|
1759
|
+
t = 0;
|
|
1760
|
+
tLen = tTmp.length;
|
|
1761
|
+
noneDefaultCss = [];
|
|
1762
|
+
for (; t < tLen; ++t) {
|
|
1763
|
+
noneDefaultCss[t] = JSON.clone(css);
|
|
1764
|
+
url = tTmp[t];
|
|
1765
|
+
if ( typeof(url) == 'string') {
|
|
1766
|
+
noneDefaultCss[t].url = url;
|
|
1767
|
+
noneDefaultCss[t].name = url.substring(url.lastIndexOf('/')+1, url.lastIndexOf('.')).replace(/\W+/g, '-');
|
|
1768
|
+
noneDefaultCss[t].isCommon = ( /^_common$/.test(section) ) ? true : false;
|
|
1769
|
+
} else {
|
|
1770
|
+
noneDefaultCss[t] = merge(url, noneDefaultCss[t]);
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
|
|
1776
|
+
|
|
1777
|
+
|
|
1778
|
+
if (!files['templates'][section].javascriptsExcluded) {
|
|
1779
|
+
// merging with common javascript def
|
|
1780
|
+
noneDefaultJs = merge.setKeyComparison('url')(files['templates']._common.javascripts, noneDefaultJs, true);
|
|
1781
|
+
}
|
|
1782
|
+
// adding gina def
|
|
1783
|
+
if ( !files['templates'][section].javascriptsExcluded || files['templates'][section].javascriptsExcluded != '**' ) {
|
|
1784
|
+
noneDefaultJs = merge.setKeyComparison('url')(defaultViews._common.javascripts, noneDefaultJs);
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
|
|
1788
|
+
if (!files['templates'][section].stylesheetsExcluded) {
|
|
1789
|
+
// merging with common stylesheets def
|
|
1790
|
+
noneDefaultCss = merge.setKeyComparison('url')(files['templates']._common.stylesheets, noneDefaultCss, true);
|
|
1791
|
+
}
|
|
1792
|
+
// adding gina def
|
|
1793
|
+
if ( !files['templates'][section].stylesheetsExcluded || files['templates'][section].stylesheetsExcluded != '**' ) {
|
|
1794
|
+
noneDefaultCss = merge.setKeyComparison('url')(defaultViews._common.stylesheets, noneDefaultCss);
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
|
|
1798
|
+
// force js rechecking on `name` & `url`
|
|
1799
|
+
t = 0;
|
|
1800
|
+
tLen = noneDefaultJs.length;
|
|
1801
|
+
|
|
1802
|
+
for (; t < tLen; ++t) {
|
|
1803
|
+
|
|
1804
|
+
if (!noneDefaultJs[t].url) continue;
|
|
1805
|
+
|
|
1806
|
+
url = noneDefaultJs[t].url;
|
|
1807
|
+
if ( typeof(noneDefaultJs[t].name) == 'undefined' || noneDefaultJs[t].name == '' ) {
|
|
1808
|
+
noneDefaultJs[t].name = url.substring(url.lastIndexOf('/')+1, url.lastIndexOf('.')).replace(/\W+/g, '-');
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
noneDefaultJs[t].type = ( typeof(noneDefaultJs[t].type) != 'undefined' ) ? noneDefaultJs[t].type : js.type;
|
|
1812
|
+
noneDefaultJs[t].isCommon = ( typeof(noneDefaultJs[t].isCommon) != 'undefined' ) ? noneDefaultJs[t].isCommon : ( ( /^_common$/.test(section) ) ? true : false );
|
|
1813
|
+
}
|
|
1814
|
+
// force css rechecking on `name` & `url`
|
|
1815
|
+
t = 0;
|
|
1816
|
+
tLen = noneDefaultCss.length;
|
|
1817
|
+
for (; t < tLen; ++t) {
|
|
1818
|
+
if (!noneDefaultCss[t].url) continue;
|
|
1819
|
+
|
|
1820
|
+
url = noneDefaultCss[t].url;
|
|
1821
|
+
if ( typeof(noneDefaultCss[t].name) == 'undefined' || noneDefaultCss[t].name == '' ) {
|
|
1822
|
+
noneDefaultCss[t].name = url.substring(url.lastIndexOf('/')+1, url.lastIndexOf('.')).replace(/\W+/g, '-');
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
|
|
1826
|
+
noneDefaultCss[t].rel = ( typeof(noneDefaultCss[t].rel) != 'undefined' ) ? noneDefaultCss[t].rel : css.rel;
|
|
1827
|
+
noneDefaultCss[t].type = ( typeof(noneDefaultCss[t].type) != 'undefined' ) ? noneDefaultCss[t].type : css.type;
|
|
1828
|
+
noneDefaultCss[t].isCommon = ( typeof(noneDefaultCss[t].isCommon) != 'undefined' ) ? noneDefaultCss[t].isCommon : ( ( /^_common$/.test(section) ) ? true : false );
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
|
|
1832
|
+
files['templates'][section].javascripts = noneDefaultJs;
|
|
1833
|
+
files['templates'][section].stylesheets = noneDefaultCss;
|
|
1834
|
+
|
|
1835
|
+
|
|
1836
|
+
excludedType = [];
|
|
1837
|
+
for (let ref in files['templates'][section]) {
|
|
1838
|
+
if ( /^(javascriptsExcluded|stylesheetsExcluded)$/.test(ref) ) {
|
|
1839
|
+
excludedType.push(ref);
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
// merging other common properties
|
|
1843
|
+
for (let ref in files['templates']._common) {
|
|
1844
|
+
if ( /^(javascripts|stylesheets)$/.test(ref) ) {
|
|
1845
|
+
continue;
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
if ( typeof(files['templates'][section][ref]) == 'undefined' ) {
|
|
1849
|
+
files['templates'][section][ref] = files['templates']._common[ref];
|
|
1850
|
+
} else {
|
|
1851
|
+
files['templates'][section][ref] = merge(files['templates'][section][ref], files['templates']._common[ref]);
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
// removes common definitions from the common definitions of the current section
|
|
1856
|
+
r = 0;
|
|
1857
|
+
rLen = excludedType.length;
|
|
1858
|
+
if (rLen > 0) {
|
|
1859
|
+
for (; r < rLen; ++r) {
|
|
1860
|
+
//excludedStr = excludedType[r] +'Excluded';
|
|
1861
|
+
excludedStr = excludedType[r];
|
|
1862
|
+
if ( typeof(files['templates'][section][excludedStr]) != 'undefined' ) {
|
|
1863
|
+
|
|
1864
|
+
let allFilesCollection = new Collection(files['templates'][section][excludedStr.replace(/Excluded$/, '')]);
|
|
1865
|
+
let currentCollectionRaw = allFilesCollection.toRaw();
|
|
1866
|
+
// must be `url` list
|
|
1867
|
+
excluded = ( /string/.test( typeof(files['templates'][section][excludedStr]) ) && !/^(\*|\*\*|all)$/i.test(files['templates'][section][excludedStr]) ) ? files['templates'][section][excludedStr].split(/(\,|\;)/g) : files['templates'][section][excludedStr];
|
|
1868
|
+
if (!Array.isArray(excluded) && !/^(\*|\*\*|all)$/i.test(files['templates'][section][excludedStr])) {
|
|
1869
|
+
// '/path/to.file' -> ['/path/to.file']
|
|
1870
|
+
excluded = [excluded];
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
if (/^(\*|\*\*|all)$/i.test(files['templates'][section][excludedStr])) {
|
|
1874
|
+
//currentCollection = allFilesCollection.notIn({ name: 'gina'}, 'name').toRaw();
|
|
1875
|
+
currentCollection = allFilesCollection.toRaw();
|
|
1876
|
+
|
|
1877
|
+
excluded = [];
|
|
1878
|
+
for (let e = 0, eLen = currentCollectionRaw.length; e < eLen; e++) {
|
|
1879
|
+
if (currentCollectionRaw[e].name == 'gina' ) continue;
|
|
1880
|
+
excluded.push(currentCollectionRaw[e].url);
|
|
1881
|
+
}
|
|
1882
|
+
} else {
|
|
1883
|
+
// must be `url` list
|
|
1884
|
+
currentCollection = new Collection(excluded);
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
|
|
1888
|
+
|
|
1889
|
+
t = 0; tLen = excluded.length;
|
|
1890
|
+
for (; t < tLen; ++t) {
|
|
1891
|
+
excludedUrl = excluded[t].trim();
|
|
1892
|
+
for (let e = 0, eLen = currentCollectionRaw.length; e < eLen; e++) {
|
|
1893
|
+
if (currentCollectionRaw[e].url != excludedUrl[t]) continue;
|
|
1894
|
+
currentCollection = currentCollection.delete({ 'url': excludedUrl }, 'url');
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
files['templates'][section][excludedStr.replace(/Excluded$/, '')] = currentCollection.toRaw();
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
} // EO for section
|
|
1903
|
+
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
} catch (err) {
|
|
1907
|
+
console.error(err.stack||err.message||err);
|
|
1908
|
+
callback(err);
|
|
1909
|
+
return;
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
|
|
1913
|
+
|
|
1914
|
+
|
|
1915
|
+
if ( typeof(files['statics']) != 'undefined' ) {
|
|
1916
|
+
pCount = conf[bundle][env].publicResources.length || 0;
|
|
1917
|
+
sCount = conf[bundle][env].staticResources.length || 0;
|
|
1918
|
+
|
|
1919
|
+
for (var i in files['statics']) {
|
|
1920
|
+
if (!/^\//.test(i) ) {
|
|
1921
|
+
files['statics'][ '/'+ i ] = files['statics'][i];
|
|
1922
|
+
delete files['statics'][i];
|
|
1923
|
+
i = '/'+ i
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
if ( !/\.(.*)$/.test(i) && !/\/$/.test(i) ) {
|
|
1927
|
+
files['statics'][ i + '/' ] = files['statics'][i];
|
|
1928
|
+
delete files['statics'][i];
|
|
1929
|
+
i += '/'
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
// adding to public resources
|
|
1933
|
+
if ( conf[bundle][env].publicResources.indexOf(i) < 0 ) {
|
|
1934
|
+
conf[bundle][env].publicResources[pCount] = i;
|
|
1935
|
+
++pCount;
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
// adding to static resources
|
|
1939
|
+
if ( conf[bundle][env].staticResources.indexOf(i) < 0 ) {
|
|
1940
|
+
conf[bundle][env].staticResources[sCount] = i;
|
|
1941
|
+
++sCount;
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
|
|
1948
|
+
files = whisper(reps, files);
|
|
1949
|
+
|
|
1950
|
+
// favicons rewrite - Not needed anymore
|
|
1951
|
+
// var faviconsPath = files['statics'][ ( (_wroot) ? _wroot +'/' : '' ) + 'favicons'];
|
|
1952
|
+
// if ( hasViews && typeof(files['statics']) != 'undefiened' && fs.existsSync( faviconsPath ) ) {
|
|
1953
|
+
// var favFiles = fs.readdirSync(faviconsPath);
|
|
1954
|
+
// for (var f = 0, fLen = favFiles.length; f < fLen; ++f) {
|
|
1955
|
+
// if ( !/^\./.test(favFiles[f]) )
|
|
1956
|
+
// files['statics'][ ( (_wroot) ? _wroot +'/' : '' ) + favFiles[f] ] = faviconsPath +'/'+ favFiles[f];
|
|
1957
|
+
// }
|
|
1958
|
+
// }
|
|
1959
|
+
|
|
1960
|
+
|
|
1961
|
+
if (hasViews) {
|
|
1962
|
+
// loading forms rules
|
|
1963
|
+
if (typeof(files['templates']._common.forms) != 'undefined') {
|
|
1964
|
+
try {
|
|
1965
|
+
files['forms'] = loadForms(files['templates']._common.forms)
|
|
1966
|
+
} catch (err) {
|
|
1967
|
+
callback(err)
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
// get error pages
|
|
1972
|
+
if (typeof(files['templates']._common.html) != 'undefined') {
|
|
1973
|
+
var htmlErrorsFromPath = function(htmlErrorsPath) {
|
|
1974
|
+
var htmlErrorsObj = new _(htmlErrorsPath);
|
|
1975
|
+
if ( htmlErrorsObj.existsSync() ) {
|
|
1976
|
+
var errorFiles = fs.readdirSync( htmlErrorsObj.toUnixStyle() );
|
|
1977
|
+
for (let f = 0, fLen = errorFiles.length; f < fLen; f++) {
|
|
1978
|
+
let errorFilename = _(htmlErrorsPath +'/'+errorFiles[f], true);
|
|
1979
|
+
if (
|
|
1980
|
+
/^\./.test(errorFiles[f])
|
|
1981
|
+
||
|
|
1982
|
+
fs.statSync(errorFilename).isDirectory()
|
|
1983
|
+
) {
|
|
1984
|
+
continue;
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
let eCode = errorFiles[f].replace(/\.(.*)$/, '');
|
|
1988
|
+
if ( typeof(files['templates']._common.errorFiles) == 'undefined' ) {
|
|
1989
|
+
files['templates']._common.errorFiles = {};
|
|
1990
|
+
}
|
|
1991
|
+
if ( typeof(files['templates']._common.errorFiles[eCode]) == 'undefined' ) {
|
|
1992
|
+
files['templates']._common.errorFiles[eCode] = errorFilename;
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
errorFiles = null;
|
|
1996
|
+
}
|
|
1997
|
+
htmlErrorsObj = null;
|
|
1998
|
+
htmlErrorsPath = null;
|
|
1999
|
+
};
|
|
2000
|
+
// first, look into bundles
|
|
2001
|
+
htmlErrorsFromPath(files['templates']._common.html+ '/errors');
|
|
2002
|
+
// Then, look into shared without overriding existing
|
|
2003
|
+
htmlErrorsFromPath(conf[bundle][env].sharedPath + '/errors');
|
|
2004
|
+
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
// plugin loader (frontend framework)
|
|
2009
|
+
if ( hasViews && typeof(files['templates']._common.pluginLoader) != 'undefined' ) {
|
|
2010
|
+
var loaderSrcPath = null, scriptTag = null;
|
|
2011
|
+
loaderSrcPath = files['templates']._common.pluginLoader.replace(/(\{src\:|\}$)/g, '');
|
|
2012
|
+
try {
|
|
2013
|
+
// will get a buffer
|
|
2014
|
+
if (cacheless) {
|
|
2015
|
+
delete require.cache[require.resolve(_(loaderSrcPath, true))]
|
|
2016
|
+
}
|
|
2017
|
+
// Attention - ginaLoader cannot be deferred !
|
|
2018
|
+
scriptTag = '\n\t\t<script type="text/javascript">'
|
|
2019
|
+
scriptTag = scriptTag
|
|
2020
|
+
+ '\n\t\t<!--'
|
|
2021
|
+
+ '\n\t\t' + fs.readFileSync( _(loaderSrcPath, true)).toString()
|
|
2022
|
+
+ '\n\t\t//-->'
|
|
2023
|
+
+ '\n\t\t</script>';
|
|
2024
|
+
|
|
2025
|
+
files['templates']._common.ginaLoader = scriptTag;
|
|
2026
|
+
|
|
2027
|
+
} catch (err) {
|
|
2028
|
+
callback(err)
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
conf[bundle][env].content = files;
|
|
2033
|
+
if ( typeof(conf[bundle][env].content) == 'undefined') {
|
|
2034
|
+
conf[bundle][env].content = {}
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
|
|
2038
|
+
conf[bundle][env].bundle = bundle;
|
|
2039
|
+
if (bundle == self.startingApp)
|
|
2040
|
+
conf[bundle][env].bundles = self.getBundles();
|
|
2041
|
+
|
|
2042
|
+
conf[bundle][env].env = env;
|
|
2043
|
+
|
|
2044
|
+
// this setting is replace on http requests by the value extracted form the request header
|
|
2045
|
+
if (
|
|
2046
|
+
typeof(conf[bundle][env].content.settings) != 'undefined'
|
|
2047
|
+
&& typeof(conf[bundle][env].content.settings.server) != 'undefined'
|
|
2048
|
+
&& typeof(conf[bundle][env].content.settings.server.protocol) != 'undefined'
|
|
2049
|
+
&& typeof(conf[bundle][env].content.settings.server.scheme) != 'undefined'
|
|
2050
|
+
) {
|
|
2051
|
+
protocol = conf[bundle][env].server.protocol = conf[bundle][env].content.settings.server.protocol; // from user's bundle/config/settings.json
|
|
2052
|
+
scheme = conf[bundle][env].server.scheme = conf[bundle][env].content.settings.server.scheme; // from user's bundle/config/settings.json
|
|
2053
|
+
|
|
2054
|
+
// getting server port
|
|
2055
|
+
conf[bundle][env].server.port = portsReverse[ bundle +'@'+ self.projectName ][env][protocol][scheme];
|
|
2056
|
+
appPort = portsReverse[bundle+'@'+self.projectName][env][protocol][scheme];
|
|
2057
|
+
conf[bundle][env].port[ protocol ][ scheme ] = appPort;
|
|
2058
|
+
|
|
2059
|
+
|
|
2060
|
+
} else {
|
|
2061
|
+
protocol = conf[bundle][env].server.protocol;
|
|
2062
|
+
scheme = conf[bundle][env].server.scheme;
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
conf[bundle][env].server.supportedRequestMethods = conf[bundle][env].content.settings.server.supportedRequestMethods;
|
|
2066
|
+
conf[bundle][env].hostname = scheme + '://' + conf[bundle][env].host + ':' + conf[bundle][env].server.port;
|
|
2067
|
+
|
|
2068
|
+
|
|
2069
|
+
self.envConf[bundle][env] = conf[bundle][env];
|
|
2070
|
+
|
|
2071
|
+
++b;
|
|
2072
|
+
if (b < bundles.length) {
|
|
2073
|
+
loadBundleConfig(bundles, b, callback, reload, collectedRules)
|
|
2074
|
+
} else {
|
|
2075
|
+
callback(err, files, collectedRules)
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
// Todo - browseDirectory -> returns a collection of files & folders paths, unless it is handled by http/2
|
|
2080
|
+
// Will be useful to generate cache
|
|
2081
|
+
// var browseDirectory = function(filename, list, i, len) {
|
|
2082
|
+
|
|
2083
|
+
// var name = filename.substring(filename.lastIndexOf('/') +1)
|
|
2084
|
+
// , location = filename.replace( new RegExp(name+'$'))
|
|
2085
|
+
// , obj = {
|
|
2086
|
+
// name: name,
|
|
2087
|
+
// location: location,
|
|
2088
|
+
// isDir: fs.statSync(filename).isDirectory()
|
|
2089
|
+
// }
|
|
2090
|
+
// , list = (typeof(list) != 'undefined') ? list : []
|
|
2091
|
+
// , i = (typeof(i) != 'undefined') ? i : 0
|
|
2092
|
+
// , len = (typeof(len) != 'undefined') ? len : 0
|
|
2093
|
+
// ;
|
|
2094
|
+
|
|
2095
|
+
// if (i == 0 && obj.isDir) { //root
|
|
2096
|
+
// var files = fs.readdirSync(filename);
|
|
2097
|
+
// len = files.length;
|
|
2098
|
+
// }
|
|
2099
|
+
|
|
2100
|
+
// }
|
|
2101
|
+
|
|
2102
|
+
var loadForms = function(formsDir) {
|
|
2103
|
+
var forms = { rules: {}}, cacheless = self.isCacheless(), root = '';
|
|
2104
|
+
|
|
2105
|
+
if ( fs.existsSync(formsDir) ) {
|
|
2106
|
+
root = ''+formsDir;
|
|
2107
|
+
// browsing dir
|
|
2108
|
+
var readDir = function (dir, forms, key, previousKey) {
|
|
2109
|
+
var files = fs.readdirSync(dir)
|
|
2110
|
+
, filename = ''
|
|
2111
|
+
, k = null;
|
|
2112
|
+
|
|
2113
|
+
for (var i = 0, len = files.length; i < len; ++i) {
|
|
2114
|
+
if ( !/^\./.test(files[i]) ) {
|
|
2115
|
+
filename = _(dir + '/' + files[i], true);
|
|
2116
|
+
|
|
2117
|
+
if ( fs.statSync(filename).isDirectory() ) {
|
|
2118
|
+
key += dir.replace(root, '') +'/'+ files[i] + '/';
|
|
2119
|
+
k = key.split(/\//g);
|
|
2120
|
+
forms[k[k.length-2]] = {};
|
|
2121
|
+
// special case for user validators/* directories
|
|
2122
|
+
if ( /validators\/(.*)$/i.test(filename) ) {
|
|
2123
|
+
readDir( filename, forms, key, k[k.length-2] );
|
|
2124
|
+
} else {
|
|
2125
|
+
readDir( filename, forms[ k[k.length-2] ], key );
|
|
2126
|
+
}
|
|
2127
|
+
} else {
|
|
2128
|
+
|
|
2129
|
+
key = files[i].replace('.json', '').replace(/\-/g, '.');
|
|
2130
|
+
try {
|
|
2131
|
+
|
|
2132
|
+
if (cacheless) {
|
|
2133
|
+
delete require.cache[require.resolve(_(filename, true))];
|
|
2134
|
+
}
|
|
2135
|
+
|
|
2136
|
+
k = key.split(/\//g);
|
|
2137
|
+
//forms[ k[k.length-1] ] = requireJSON(_(filename, true))
|
|
2138
|
+
if ( /\.json$/.test(filename) && !/validators\/(.*)$/i.test(filename) ) {
|
|
2139
|
+
forms[ k[k.length-1] ] = requireJSON(_(filename, true))
|
|
2140
|
+
} else if (/\main.js$/.test(filename)) { // ignore other files
|
|
2141
|
+
forms[ previousKey ] = fs.readFileSync(_(filename, true));
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
} catch(err) {
|
|
2145
|
+
throw new Error('[ ' +filename + ' ] is malformed !!')
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
};
|
|
2151
|
+
|
|
2152
|
+
readDir(formsDir, forms, '/')
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
return forms
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
/**
|
|
2159
|
+
* Load Apps Configuration
|
|
2160
|
+
*
|
|
2161
|
+
* TODO - simplify / optimize
|
|
2162
|
+
* */
|
|
2163
|
+
var loadBundlesConfiguration = function(callback) {
|
|
2164
|
+
//var bundles = self.getBundles();
|
|
2165
|
+
var bundles = self.getAllBundles();
|
|
2166
|
+
|
|
2167
|
+
loadBundleConfig(bundles, 0, callback)
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
/**
|
|
2171
|
+
* Check is cache is disabled
|
|
2172
|
+
*
|
|
2173
|
+
* @returns {boolean} isUsingCache
|
|
2174
|
+
* */
|
|
2175
|
+
this.isCacheless = function() {
|
|
2176
|
+
//Also defined in core/gna.
|
|
2177
|
+
return (/^true$/i.test(process.env.NODE_ENV_IS_DEV)) ? true : false;
|
|
2178
|
+
}
|
|
2179
|
+
/**
|
|
2180
|
+
* Refresh for cachless mode
|
|
2181
|
+
*
|
|
2182
|
+
* @param {string} bundle
|
|
2183
|
+
*
|
|
2184
|
+
* @callback callback
|
|
2185
|
+
* @param {boolean|string} err
|
|
2186
|
+
* */
|
|
2187
|
+
this.refresh = function(bundle, callback) {
|
|
2188
|
+
//Reload conf. who likes repetition ?
|
|
2189
|
+
loadBundleConfig(
|
|
2190
|
+
self.allBundles,
|
|
2191
|
+
0,
|
|
2192
|
+
function doneLoadingBundleConfig(err, files, routing) {
|
|
2193
|
+
if (!err) {
|
|
2194
|
+
callback(false, routing)
|
|
2195
|
+
} else {
|
|
2196
|
+
callback(err)
|
|
2197
|
+
}
|
|
2198
|
+
}, true)
|
|
2199
|
+
}//EO refresh.
|
|
2200
|
+
|
|
2201
|
+
/**
|
|
2202
|
+
* Reloading bundle model
|
|
2203
|
+
*
|
|
2204
|
+
* @param {string} bundle - bundle name
|
|
2205
|
+
* @callback {function} callback
|
|
2206
|
+
* @param {boolean} error
|
|
2207
|
+
* */
|
|
2208
|
+
this.refreshModels = function(bundle, env, callback) {
|
|
2209
|
+
var conf = self.envConf[bundle][env]
|
|
2210
|
+
//Reload models.
|
|
2211
|
+
, modelsPath = _(conf.modelsPath);
|
|
2212
|
+
|
|
2213
|
+
|
|
2214
|
+
fs.exists(modelsPath, function(exists){
|
|
2215
|
+
if (exists && self.startingApp == conf.bundle) {
|
|
2216
|
+
modelUtil.reloadModels(
|
|
2217
|
+
conf,
|
|
2218
|
+
function doneReloadingModel(err) {
|
|
2219
|
+
callback(err)
|
|
2220
|
+
})
|
|
2221
|
+
} else {
|
|
2222
|
+
callback(false)
|
|
2223
|
+
}
|
|
2224
|
+
})
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
/**
|
|
2228
|
+
* Setting routing for non dev env
|
|
2229
|
+
*
|
|
2230
|
+
* @param {object} routing
|
|
2231
|
+
* */
|
|
2232
|
+
this.setRouting = function(bundle, env, routing) {
|
|
2233
|
+
|
|
2234
|
+
if (!self.envConf.routing)
|
|
2235
|
+
self.envConf.routing = {};
|
|
2236
|
+
|
|
2237
|
+
if (!self.envConf[bundle][env].content)
|
|
2238
|
+
self.envConf[bundle][env].content = {};
|
|
2239
|
+
|
|
2240
|
+
self.envConf[bundle][env].content.routing = routing;
|
|
2241
|
+
self.envConf.routing = merge(self.envConf.routing, routing);
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
/**
|
|
2245
|
+
* Get routing
|
|
2246
|
+
*
|
|
2247
|
+
* @param {string} [bundle]
|
|
2248
|
+
* @param {string} [env]
|
|
2249
|
+
*
|
|
2250
|
+
*/
|
|
2251
|
+
this.getRouting = function(bundle, env) {
|
|
2252
|
+
|
|
2253
|
+
if (typeof(env) == 'undefined') {
|
|
2254
|
+
env = self.env || self.Env.get()
|
|
2255
|
+
}
|
|
2256
|
+
|
|
2257
|
+
if ( typeof(bundle) != 'undefined' ) {
|
|
2258
|
+
return self.envConf[bundle][env].content.routing
|
|
2259
|
+
}
|
|
2260
|
+
|
|
2261
|
+
return self.envConf.routing;
|
|
2262
|
+
}
|
|
2263
|
+
|
|
2264
|
+
this.setReverseRouting = function(bundle, env, reverseRouting) {
|
|
2265
|
+
|
|
2266
|
+
if (!self.envConf.reverseRouting)
|
|
2267
|
+
self.envConf.reverseRouting = {};
|
|
2268
|
+
|
|
2269
|
+
if (!self.envConf[bundle][env].content)
|
|
2270
|
+
self.envConf[bundle][env].content = {};
|
|
2271
|
+
|
|
2272
|
+
self.envConf[bundle][env].content.reverseRouting = reverseRouting;
|
|
2273
|
+
self.envConf.reverseRouting = merge(self.envConf.reverseRouting, reverseRouting);
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
|
|
2277
|
+
if (!opt) {
|
|
2278
|
+
|
|
2279
|
+
this.setBundles = function(bundles) {
|
|
2280
|
+
self.bundles = bundles
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
if (Config.instance)
|
|
2284
|
+
return Config.instance;
|
|
2285
|
+
|
|
2286
|
+
} else {
|
|
2287
|
+
|
|
2288
|
+
//Defined before init.
|
|
2289
|
+
var env = opt.env, _ready = {err:'not ready', val: null};
|
|
2290
|
+
|
|
2291
|
+
this.env = opt.env;
|
|
2292
|
+
|
|
2293
|
+
|
|
2294
|
+
this.onReady = function(callback) {
|
|
2295
|
+
self.once('config#complete', function(err, config) {
|
|
2296
|
+
callback(err, config)
|
|
2297
|
+
})
|
|
2298
|
+
return self
|
|
2299
|
+
};
|
|
2300
|
+
|
|
2301
|
+
init(opt)
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
return this
|
|
2305
|
+
};
|
|
2306
|
+
|
|
2307
|
+
Config = inherits(Config, EventEmitter);
|
|
2308
|
+
module.exports = Config
|