@decaf-ts/for-angular 0.1.1 → 0.1.4
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/.editorconfig +31 -0
- package/.gitlab-ci.yml +197 -0
- package/.hintrc +19 -0
- package/.prettierrc +49 -0
- package/.snyk +13 -0
- package/LICENSE.md +260 -0
- package/angular.json +274 -0
- package/bs-config.json +5 -0
- package/cli-module.js.map +1 -0
- package/dist/for-angular/cli/cli-module.d.ts +22 -0
- package/dist/for-angular/cli/cli-module.d.ts.map +1 -0
- package/dist/for-angular/cli/cli-module.js +131 -0
- package/dist/for-angular/cli/cli-module.js.map +1 -0
- package/dist/lib/README.md +117 -0
- package/{fesm2022 → dist/lib/fesm2022}/decaf-ts-for-angular.mjs +93 -109
- package/dist/lib/fesm2022/decaf-ts-for-angular.mjs.map +1 -0
- package/{index.d.ts → dist/lib/index.d.ts} +6 -5
- package/eslint.config.mjs +101 -0
- package/ionic.config.json +14 -0
- package/jest.config.ts +52 -0
- package/jest.setup.ts +50 -0
- package/karma.conf.js +50 -0
- package/ng-package.json +16 -0
- package/ngsw-config.json +30 -0
- package/package.json +86 -17
- package/playwright.config.ts +80 -0
- package/resources/favicon.png +0 -0
- package/resources/favicon.svg +29 -0
- package/resources/icon-background.png +0 -0
- package/resources/icon-foreground.png +0 -0
- package/resources/icon-only.png +0 -0
- package/resources/icon-only.svg +29 -0
- package/resources/splash-dark.png +0 -0
- package/resources/splash-dark2.png +0 -0
- package/resources/splash.png +0 -0
- package/resources/splash2.png +0 -0
- package/resources/touch-icon.svg +29 -0
- package/schematics/README.md +28 -0
- package/schematics/collection.json +20 -0
- package/schematics/package-lock.json +1501 -0
- package/schematics/package.json +37 -0
- package/schematics/src/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.__style__.template +0 -0
- package/schematics/src/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.html.template +3 -0
- package/schematics/src/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.spec.ts.template +40 -0
- package/schematics/src/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template +37 -0
- package/schematics/src/component/files/__name@dasherize@if-flat__/__name@dasherize__.module.ts.template +14 -0
- package/schematics/src/component/index.js +146 -0
- package/schematics/src/component/schema.js +2 -0
- package/schematics/src/component/schema.json +101 -0
- package/schematics/src/page/files/__name@dasherize__.page.html.template +15 -0
- package/schematics/src/page/files/__name@dasherize__.page.scss.template +0 -0
- package/schematics/src/page/files/__name@dasherize__.page.ts.template +19 -0
- package/schematics/src/page/index.js +71 -0
- package/schematics/src/page/schema.json +87 -0
- package/schematics/src/schematics/index.js +11 -0
- package/schematics/src/schematics/index_spec.js +13 -0
- package/schematics/src/util/ast-util.js +517 -0
- package/schematics/src/util/change.js +96 -0
- package/schematics/src/util/index.js +14 -0
- package/settings.json +112 -0
- package/tsconfig.app.json +22 -0
- package/tsconfig.cli.json +82 -0
- package/tsconfig.lib.json +14 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +22 -0
- package/webpack.config.js +10 -0
- package/workdocs/1-Header.md +5 -0
- package/workdocs/2-Badges.md +30 -0
- package/workdocs/4-Description.md +4 -0
- package/workdocs/5-HowToUse.md +27 -0
- package/workdocs/6-Related.md +7 -0
- package/workdocs/7-Social.md +5 -0
- package/workdocs/99-Footer.md +28 -0
- package/workdocs/Readme.md +12 -0
- package/workdocs/assets/apple-touch-icon.png +0 -0
- package/workdocs/assets/decaf-logo.svg +54 -0
- package/workdocs/assets/favicon.png +0 -0
- package/workdocs/assets/slogans.json +182 -0
- package/workdocs/confluence/.markdown-confluence.template.json +6 -0
- package/workdocs/confluence/Angular Module.md +5 -0
- package/workdocs/drawings/diagram.drawio +24 -0
- package/workdocs/prompts/bulk.md +122 -0
- package/workdocs/prompts/code.md +47 -0
- package/workdocs/prompts/documentation.md +146 -0
- package/workdocs/prompts/uml.md +11 -0
- package/workdocs/readme-md.json +6 -0
- package/workdocs/reports/CHANGELOG.md +12 -0
- package/workdocs/reports/DEPENDENCIES.md +213 -0
- package/workdocs/reports/RELEASE_NOTES.md +24 -0
- package/workdocs/reports/coverage/.gitkeep +0 -0
- package/workdocs/reports/coverage/clover.xml +4110 -0
- package/workdocs/reports/coverage/coverage-final.json +76 -0
- package/workdocs/reports/coverage/lcov-report/base.css +224 -0
- package/workdocs/reports/coverage/lcov-report/block-navigation.js +87 -0
- package/workdocs/reports/coverage/lcov-report/favicon.png +0 -0
- package/workdocs/reports/coverage/lcov-report/index.html +551 -0
- package/workdocs/reports/coverage/lcov-report/prettify.css +1 -0
- package/workdocs/reports/coverage/lcov-report/prettify.js +2 -0
- package/workdocs/reports/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/workdocs/reports/coverage/lcov-report/sorter.js +210 -0
- package/workdocs/reports/coverage/lcov-report/src/app/models/CategoryModel.ts.html +277 -0
- package/workdocs/reports/coverage/lcov-report/src/app/models/DemoModel.ts.html +427 -0
- package/workdocs/reports/coverage/lcov-report/src/app/models/UserModel.ts.html +226 -0
- package/workdocs/reports/coverage/lcov-report/src/app/models/index.html +146 -0
- package/workdocs/reports/coverage/lcov-report/src/cli-module.ts.html +502 -0
- package/workdocs/reports/coverage/lcov-report/src/environments/environment.ts.html +166 -0
- package/workdocs/reports/coverage/lcov-report/src/environments/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/index.html +191 -0
- package/workdocs/reports/coverage/lcov-report/src/karma-test.ts.html +121 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/card/card.component.ts.html +625 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/card/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/component-renderer/component-renderer.component.ts.html +772 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/component-renderer/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/crud-field/crud-field.component.ts.html +2698 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/crud-field/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/crud-form/constants.ts.html +133 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/crud-form/crud-form.component.ts.html +346 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/crud-form/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/empty-state/empty-state.component.ts.html +1264 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/empty-state/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/fieldset/fieldset.component.ts.html +2965 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/fieldset/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/file-upload/file-upload.component.ts.html +2263 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/file-upload/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/filter/filter.component.ts.html +2485 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/filter/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/for-angular-components.module.ts.html +259 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/icon/icon.component.ts.html +358 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/icon/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/index.html +131 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/index.ts.html +181 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/layout/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/layout/layout.component.ts.html +943 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/list/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/list/list.component.ts.html +4261 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/list-item/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/list-item/list-item.component.ts.html +1741 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/modal/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/modal/modal.component.ts.html +1984 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/model-renderer/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/model-renderer/model-renderer.component.ts.html +373 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/pagination/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/pagination/pagination.component.ts.html +1165 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/searchbar/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/searchbar/searchbar.component.ts.html +1774 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/stepped-form/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/stepped-form/stepped-form.component.ts.html +1219 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/table/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/components/table/table.component.ts.html +988 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/directives/NgxSvgDirective.ts.html +163 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/directives/collapsable.directive.ts.html +268 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/directives/index.html +131 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/directives/index.ts.html +91 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/DynamicModule.ts.html +133 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/MediaService.ts.html +142 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/NgxBaseComponent.ts.html +2194 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/NgxComponentDirective.ts.html +3430 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/NgxCrudFormField.ts.html +721 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/NgxDecafComponentDirective.ts.html +1864 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/NgxDecafFormFieldDirective.ts.html +952 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/NgxDecafFormService.ts.html +3211 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/NgxEventHandler.ts.html +307 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/NgxFormDirective.ts.html +1366 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/NgxFormFieldDirective.ts.html +1960 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/NgxFormService.ts.html +3004 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/NgxModelPageDirective.ts.html +1672 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/NgxPageDirective.ts.html +748 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/NgxParentComponentDirective.ts.html +775 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/NgxRenderableComponentDirective.ts.html +727 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/NgxRenderingEngine.ts.html +2005 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/NgxRepositoryDirective.ts.html +1561 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/ValidatorFactory.ts.html +817 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/constants.ts.html +1120 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/decorators.ts.html +376 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/helpers.ts.html +676 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/index.html +356 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/index.ts.html +160 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/engine/overrides.ts.html +499 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/for-angular-common.module.ts.html +298 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/helpers/index.html +131 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/helpers/index.ts.html +121 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/helpers/utils.ts.html +1603 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/i18n/FakeLoader.ts.html +157 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/i18n/Loader.ts.html +826 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/i18n/index.html +146 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/i18n/index.ts.html +91 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/index.html +131 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/public-apis.ts.html +157 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/services/NgxFormService.ts.html +3460 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/services/NgxMediaService.ts.html +1420 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/services/NgxRouterService.ts.html +1231 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/services/NgxTranslateService.ts.html +214 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/services/index.html +176 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/services/index.ts.html +91 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/utils/DecafFakerRepository.ts.html +571 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/utils/helpers.ts.html +1663 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/utils/index.html +146 -0
- package/workdocs/reports/coverage/lcov-report/src/lib/utils/index.ts.html +124 -0
- package/workdocs/reports/coverage/lcov-report/src/main.ts.html +100 -0
- package/workdocs/reports/coverage/lcov-report/src/polyfills.ts.html +271 -0
- package/workdocs/reports/coverage/lcov-report/src/stories/Configure.stories.ts.html +1156 -0
- package/workdocs/reports/coverage/lcov-report/src/stories/button.component.ts.html +229 -0
- package/workdocs/reports/coverage/lcov-report/src/stories/button.stories.ts.html +235 -0
- package/workdocs/reports/coverage/lcov-report/src/stories/crud-field.stories.ts.html +325 -0
- package/workdocs/reports/coverage/lcov-report/src/stories/header.stories.ts.html +181 -0
- package/workdocs/reports/coverage/lcov-report/src/stories/index.html +281 -0
- package/workdocs/reports/coverage/lcov-report/src/stories/list.stories.ts.html +289 -0
- package/workdocs/reports/coverage/lcov-report/src/stories/login.page.stories.ts.html +175 -0
- package/workdocs/reports/coverage/lcov-report/src/stories/model-renderer.stories.ts.html +259 -0
- package/workdocs/reports/coverage/lcov-report/src/stories/page.component.ts.html +331 -0
- package/workdocs/reports/coverage/lcov-report/src/stories/page.stories.ts.html +193 -0
- package/workdocs/reports/coverage/lcov-report/src/stories/setup.ts.html +127 -0
- package/workdocs/reports/coverage/lcov-report/src/stories/utils.ts.html +247 -0
- package/workdocs/reports/coverage/lcov-report/src/tests/index.html +116 -0
- package/workdocs/reports/coverage/lcov-report/src/tests/karmaErrorParser.ts.html +190 -0
- package/workdocs/reports/coverage/lcov-report/src/typings.d.ts.html +88 -0
- package/workdocs/reports/coverage/lcov-report/src/zone-flags.ts.html +103 -0
- package/workdocs/reports/coverage/lcov.info +7917 -0
- package/workdocs/reports/data/.gitkeep +1 -0
- package/workdocs/reports/html/.gitkeep +0 -0
- package/workdocs/reports/html/jest-html-reporters-attach/test-report/index.js +3 -0
- package/workdocs/reports/html/jest-html-reporters-attach/test-report/result.js +1 -0
- package/workdocs/reports/html/test-report.html +1 -0
- package/workdocs/reports/images/.gitkeep +1 -0
- package/workdocs/reports/jest.coverage.config.ts +43 -0
- package/workdocs/reports/junit/junit-report.xml +91 -0
- package/workdocs/resources/.gitlock +0 -0
- package/workdocs/resources/diagram-Actor.png +0 -0
- package/workdocs/resources/diagram-banner.png +0 -0
- package/workdocs/resources/diagram.png +0 -0
- package/workdocs/tutorials/Contributing.md +64 -0
- package/workdocs/tutorials/Documentation.md +340 -0
- package/workdocs/tutorials/For Developers.md +337 -0
- package/workdocs/uml/diagram.puml +11 -0
- package/www/1049.10b030f0de36543b.js +1 -0
- package/www/1102.67cedfb3e29f0a05.js +1 -0
- package/www/1107.6454396befef800d.js +1 -0
- package/www/1459.cabc18e941afa5d7.js +1 -0
- package/www/1577.5221deebe3501e43.js +1 -0
- package/www/2075.b6dc4fbb89dd6afc.js +1 -0
- package/www/2348.c4cc27dadbec70ec.js +1 -0
- package/www/2375.318d0b24ab346271.js +1 -0
- package/www/2415.618d6968ffda319c.js +1 -0
- package/www/2460.1d97c6f48b898ee2.js +1 -0
- package/www/2560.2e7000dcf80b6b2c.js +1 -0
- package/www/2585.dffa5649fffafb44.js +1 -0
- package/www/2885.d99b86afd1ff7aa8.js +1 -0
- package/www/3162.bbc401f4a5f82460.js +1 -0
- package/www/323.f64c512be5c8d797.js +1 -0
- package/www/3238.a3e7e8004c6b6667.js +1 -0
- package/www/3506.8c03f5589b33a4a6.js +1 -0
- package/www/3511.56b7e49bb6c2c936.js +1 -0
- package/www/3519.84fbb67dc803f702.js +1 -0
- package/www/3675.7ebfdcf145052232.js +1 -0
- package/www/3814.765c1794e1be63de.js +1 -0
- package/www/3rdpartylicenses.txt +1344 -0
- package/www/4171.a974bdbf9c97e4e1.js +1 -0
- package/www/4183.41ef1def450a2cc0.js +1 -0
- package/www/4406.0b2dd3839b8c1417.js +1 -0
- package/www/441.e1031657c7e5f0ff.js +1 -0
- package/www/4463.6ad7b857e5f34009.js +1 -0
- package/www/4591.42f34534d38b9b31.js +1 -0
- package/www/4699.8df8ea9806163d4c.js +1 -0
- package/www/5100.ed6483c55a157d67.js +1 -0
- package/www/5193.15ea6938534eceb1.js +1 -0
- package/www/5197.6733853529768a45.js +1 -0
- package/www/5222.8439a641c2c4b1c1.js +1 -0
- package/www/5373.d7878f708309f038.js +1 -0
- package/www/5467.53f5cce977c2e28b.js +1 -0
- package/www/5712.b08cf436ee8145ce.js +1 -0
- package/www/5887.3d038f564e925abb.js +1 -0
- package/www/5949.37330f20e95dee79.js +1 -0
- package/www/6024.c10cc3d1b341c748.js +1 -0
- package/www/6433.360fcff952bde822.js +1 -0
- package/www/6499.60169da9869db697.js +1 -0
- package/www/6521.fab1f34bfe6b8200.js +1 -0
- package/www/6631.eaa711da6e0aeed9.js +1 -0
- package/www/6717.b4731255038304cd.js +1 -0
- package/www/6840.7317cd962ab23932.js +1 -0
- package/www/7030.d115d82ca7468a4e.js +1 -0
- package/www/7076.cce20ed5c79ff305.js +1 -0
- package/www/7179.c0545989ce869b3d.js +1 -0
- package/www/7240.69aeb484d78eb24d.js +1 -0
- package/www/7372.94c62459e34f7303.js +1 -0
- package/www/7402.983a5ecff61e9a5d.js +1 -0
- package/www/7428.527ac48035a2f915.js +1 -0
- package/www/7676.d7db23d350e4b096.js +1 -0
- package/www/770.80af87d5eb0075d3.js +1 -0
- package/www/7720.0701576cb9966779.js +1 -0
- package/www/7927.ee869d0dc478250a.js +1 -0
- package/www/8066.894688fbb2e5c832.js +1 -0
- package/www/8193.7f09ecd40b6d42c2.js +1 -0
- package/www/8255.158098a6302c91c2.js +1 -0
- package/www/8314.596c1ccf26b9c93a.js +1 -0
- package/www/8357.c5406b92e6933d7a.js +1 -0
- package/www/8477.a3ccc11c25a642d3.js +1 -0
- package/www/8487.93b6f7465ae1b7ac.js +1 -0
- package/www/8584.b77ad478a5a7ac2a.js +1 -0
- package/www/8805.a87413652185ff8f.js +1 -0
- package/www/8814.b489a78ae8e926c4.js +1 -0
- package/www/8970.234b3db1f97528fe.js +1 -0
- package/www/9013.c2e6ba17a915bdd6.js +1 -0
- package/www/9073.16c4e42482d55a3c.js +1 -0
- package/www/9344.7d2d24b194b794e2.js +1 -0
- package/www/9364.9a028036dd89e3e7.js +1 -0
- package/www/944.7e4317348c48d4f4.js +1 -0
- package/www/964.9a979e1c1aad0f5b.js +1 -0
- package/www/9657.8c3589a0aff521c0.js +1 -0
- package/www/9956.2d00a2153e9a7799.js +1 -0
- package/www/9977.068cd5561462bc99.js +1 -0
- package/www/assets/i18n/en.json +210 -0
- package/www/assets/i18n/ew/en.json +346 -0
- package/www/assets/i18n/pt.json +186 -0
- package/www/assets/icons/icon-128.webp +0 -0
- package/www/assets/icons/icon-192.webp +0 -0
- package/www/assets/icons/icon-256.webp +0 -0
- package/www/assets/icons/icon-48.webp +0 -0
- package/www/assets/icons/icon-512.webp +0 -0
- package/www/assets/icons/icon-72.webp +0 -0
- package/www/assets/icons/icon-96.webp +0 -0
- package/www/assets/images/angular-logo.svg +45 -0
- package/www/assets/images/apple-touch-icon.png +0 -0
- package/www/assets/images/decaf-logo-black.svg +22 -0
- package/www/assets/images/decaf-logo-contrast.svg +54 -0
- package/www/assets/images/decaf-logo-white.svg +22 -0
- package/www/assets/images/decaf-logo.svg +54 -0
- package/www/assets/images/ew/product.txt +1 -0
- package/www/assets/images/favicon-contrast.svg +7 -0
- package/www/assets/images/favicon.png +0 -0
- package/www/assets/images/favicon.svg +29 -0
- package/www/assets/images/icons/document.svg +7 -0
- package/www/assets/images/icons/edit.svg +1 -0
- package/www/assets/images/icons/logout.svg +4 -0
- package/www/assets/images/icons/menu-collapse.svg +5 -0
- package/www/assets/images/icons/menu.svg +3 -0
- package/www/assets/images/icons/moon-stars.svg +5 -0
- package/www/assets/images/icons/trash.svg +1 -0
- package/www/cli-module.ts +139 -0
- package/www/common.e50b5f8708aca9a5.js +1 -0
- package/www/index.html +29 -0
- package/www/main.6144bf417dec1977.js +1 -0
- package/www/polyfills.4c1e087fffe784e8.js +1 -0
- package/www/runtime.d8dcb0932f88fe3c.js +1 -0
- package/www/styles.5a3cd83eba16afc9.css +4 -0
- package/www/tabler-icons.bfabe54eef86ae62.woff +0 -0
- package/www/tabler-icons.d9f65ab9439b4ffc.ttf +0 -0
- package/www/tabler-icons.f17d2c3b34a5deaa.woff2 +0 -0
- package/fesm2022/decaf-ts-for-angular.mjs.map +0 -1
- /package/{assets → dist/lib/assets}/i18n/en.json +0 -0
- /package/{assets → dist/lib/assets}/i18n/ew/en.json +0 -0
- /package/{assets → dist/lib/assets}/i18n/pt.json +0 -0
- /package/{assets → dist/lib/assets}/icons/icon-128.webp +0 -0
- /package/{assets → dist/lib/assets}/icons/icon-192.webp +0 -0
- /package/{assets → dist/lib/assets}/icons/icon-256.webp +0 -0
- /package/{assets → dist/lib/assets}/icons/icon-48.webp +0 -0
- /package/{assets → dist/lib/assets}/icons/icon-512.webp +0 -0
- /package/{assets → dist/lib/assets}/icons/icon-72.webp +0 -0
- /package/{assets → dist/lib/assets}/icons/icon-96.webp +0 -0
- /package/{assets → dist/lib/assets}/images/angular-logo.svg +0 -0
- /package/{assets → dist/lib/assets}/images/apple-touch-icon.png +0 -0
- /package/{assets → dist/lib/assets}/images/decaf-logo-black.svg +0 -0
- /package/{assets → dist/lib/assets}/images/decaf-logo-contrast.svg +0 -0
- /package/{assets → dist/lib/assets}/images/decaf-logo-white.svg +0 -0
- /package/{assets → dist/lib/assets}/images/decaf-logo.svg +0 -0
- /package/{assets → dist/lib/assets}/images/ew/product.txt +0 -0
- /package/{assets → dist/lib/assets}/images/favicon-contrast.svg +0 -0
- /package/{assets → dist/lib/assets}/images/favicon.png +0 -0
- /package/{assets → dist/lib/assets}/images/favicon.svg +0 -0
- /package/{assets → dist/lib/assets}/images/icons/document.svg +0 -0
- /package/{assets → dist/lib/assets}/images/icons/edit.svg +0 -0
- /package/{assets → dist/lib/assets}/images/icons/logout.svg +0 -0
- /package/{assets → dist/lib/assets}/images/icons/menu-collapse.svg +0 -0
- /package/{assets → dist/lib/assets}/images/icons/menu.svg +0 -0
- /package/{assets → dist/lib/assets}/images/icons/moon-stars.svg +0 -0
- /package/{assets → dist/lib/assets}/images/icons/trash.svg +0 -0
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.insertImport = insertImport;
|
|
4
|
+
exports.findNodes = findNodes;
|
|
5
|
+
exports.getSourceNodes = getSourceNodes;
|
|
6
|
+
exports.findNode = findNode;
|
|
7
|
+
exports.insertAfterLastOccurrence = insertAfterLastOccurrence;
|
|
8
|
+
exports.getContentOfKeyLiteral = getContentOfKeyLiteral;
|
|
9
|
+
exports.getDecoratorMetadata = getDecoratorMetadata;
|
|
10
|
+
exports.getFirstNgModuleName = getFirstNgModuleName;
|
|
11
|
+
exports.getMetadataField = getMetadataField;
|
|
12
|
+
exports.addSymbolToNgModuleMetadata = addSymbolToNgModuleMetadata;
|
|
13
|
+
exports.addDeclarationToModule = addDeclarationToModule;
|
|
14
|
+
exports.addImportToModule = addImportToModule;
|
|
15
|
+
exports.addProviderToModule = addProviderToModule;
|
|
16
|
+
exports.addExportToModule = addExportToModule;
|
|
17
|
+
exports.addBootstrapToModule = addBootstrapToModule;
|
|
18
|
+
exports.addEntryComponentToModule = addEntryComponentToModule;
|
|
19
|
+
exports.isImported = isImported;
|
|
20
|
+
exports.getEnvironmentExportName = getEnvironmentExportName;
|
|
21
|
+
exports.getRouterModuleDeclaration = getRouterModuleDeclaration;
|
|
22
|
+
exports.addRouteDeclarationToModule = addRouteDeclarationToModule;
|
|
23
|
+
const ts = require("typescript");
|
|
24
|
+
const change_1 = require("./change");
|
|
25
|
+
function insertImport(source, fileToEdit, symbolName, fileName, isDefault = false) {
|
|
26
|
+
const rootNode = source;
|
|
27
|
+
const allImports = findNodes(rootNode, ts.SyntaxKind.ImportDeclaration);
|
|
28
|
+
// get nodes that map to import statements from the file fileName
|
|
29
|
+
const relevantImports = allImports.filter((node) => {
|
|
30
|
+
// StringLiteral of the ImportDeclaration is the import file (fileName in this case).
|
|
31
|
+
const importFiles = node
|
|
32
|
+
.getChildren()
|
|
33
|
+
.filter((child) => child.kind === ts.SyntaxKind.StringLiteral)
|
|
34
|
+
.map((n) => n.text);
|
|
35
|
+
return importFiles.filter((file) => file === fileName).length === 1;
|
|
36
|
+
});
|
|
37
|
+
if (relevantImports.length > 0) {
|
|
38
|
+
let importsAsterisk = false;
|
|
39
|
+
// imports from import file
|
|
40
|
+
const imports = [];
|
|
41
|
+
relevantImports.forEach((n) => {
|
|
42
|
+
Array.prototype.push.apply(imports, findNodes(n, ts.SyntaxKind.Identifier));
|
|
43
|
+
if (findNodes(n, ts.SyntaxKind.AsteriskToken).length > 0) {
|
|
44
|
+
importsAsterisk = true;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
// if imports * from fileName, don't add symbolName
|
|
48
|
+
if (importsAsterisk) {
|
|
49
|
+
return new change_1.NoopChange();
|
|
50
|
+
}
|
|
51
|
+
const importTextNodes = imports.filter((n) => n.text === symbolName);
|
|
52
|
+
// insert import if it's not there
|
|
53
|
+
if (importTextNodes.length === 0) {
|
|
54
|
+
const fallbackPos = findNodes(relevantImports[0], ts.SyntaxKind.CloseBraceToken)[0].getStart() ||
|
|
55
|
+
findNodes(relevantImports[0], ts.SyntaxKind.FromKeyword)[0].getStart();
|
|
56
|
+
return insertAfterLastOccurrence(imports, `, ${symbolName}`, fileToEdit, fallbackPos);
|
|
57
|
+
}
|
|
58
|
+
return new change_1.NoopChange();
|
|
59
|
+
}
|
|
60
|
+
// no such import declaration exists
|
|
61
|
+
const useStrict = findNodes(rootNode, ts.SyntaxKind.StringLiteral).filter((n) => n.getText() === 'use strict');
|
|
62
|
+
let fallbackPos = 0;
|
|
63
|
+
if (useStrict.length > 0) {
|
|
64
|
+
fallbackPos = useStrict[0].end;
|
|
65
|
+
}
|
|
66
|
+
const open = isDefault ? '' : '{ ';
|
|
67
|
+
const close = isDefault ? '' : ' }';
|
|
68
|
+
// if there are no imports or 'use strict' statement, insert import at beginning of file
|
|
69
|
+
const insertAtBeginning = allImports.length === 0 && useStrict.length === 0;
|
|
70
|
+
const separator = insertAtBeginning ? '' : ';\n';
|
|
71
|
+
const toInsert = `${separator}import ${open}${symbolName}${close}` + ` from '${fileName}'${insertAtBeginning ? ';\n' : ''}`;
|
|
72
|
+
return insertAfterLastOccurrence(allImports, toInsert, fileToEdit, fallbackPos, ts.SyntaxKind.StringLiteral);
|
|
73
|
+
}
|
|
74
|
+
//Safe
|
|
75
|
+
function findNodes(node, kind, max = Infinity, recursive = false) {
|
|
76
|
+
if (!node || max == 0) {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
const arr = [];
|
|
80
|
+
if (node.kind === kind) {
|
|
81
|
+
arr.push(node);
|
|
82
|
+
max--;
|
|
83
|
+
}
|
|
84
|
+
if (max > 0 && (recursive || node.kind !== kind)) {
|
|
85
|
+
for (const child of node.getChildren()) {
|
|
86
|
+
findNodes(child, kind, max).forEach((node) => {
|
|
87
|
+
if (max > 0) {
|
|
88
|
+
arr.push(node);
|
|
89
|
+
}
|
|
90
|
+
max--;
|
|
91
|
+
});
|
|
92
|
+
if (max <= 0) {
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return arr;
|
|
98
|
+
}
|
|
99
|
+
function getSourceNodes(sourceFile) {
|
|
100
|
+
const nodes = [sourceFile];
|
|
101
|
+
const result = [];
|
|
102
|
+
while (nodes.length > 0) {
|
|
103
|
+
const node = nodes.shift();
|
|
104
|
+
if (node) {
|
|
105
|
+
result.push(node);
|
|
106
|
+
if (node.getChildCount(sourceFile) >= 0) {
|
|
107
|
+
nodes.unshift(...node.getChildren());
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
function findNode(node, kind, text) {
|
|
114
|
+
if (node.kind === kind && node.getText() === text) {
|
|
115
|
+
// throw new Error(node.getText());
|
|
116
|
+
return node;
|
|
117
|
+
}
|
|
118
|
+
let foundNode = null;
|
|
119
|
+
ts.forEachChild(node, (childNode) => {
|
|
120
|
+
foundNode = foundNode || findNode(childNode, kind, text);
|
|
121
|
+
});
|
|
122
|
+
return foundNode;
|
|
123
|
+
}
|
|
124
|
+
function nodesByPosition(first, second) {
|
|
125
|
+
return first.getStart() - second.getStart();
|
|
126
|
+
}
|
|
127
|
+
function insertAfterLastOccurrence(nodes, toInsert, file, fallbackPos, syntaxKind) {
|
|
128
|
+
let lastItem;
|
|
129
|
+
for (const node of nodes) {
|
|
130
|
+
if (!lastItem || lastItem.getStart() < node.getStart()) {
|
|
131
|
+
lastItem = node;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (syntaxKind && lastItem) {
|
|
135
|
+
lastItem = findNodes(lastItem, syntaxKind).sort(nodesByPosition).pop();
|
|
136
|
+
}
|
|
137
|
+
if (!lastItem && fallbackPos == undefined) {
|
|
138
|
+
throw new Error(`tried to insert ${toInsert} as first occurence with no fallback position`);
|
|
139
|
+
}
|
|
140
|
+
const lastItemPosition = lastItem ? lastItem.getEnd() : fallbackPos;
|
|
141
|
+
return new change_1.InsertChange(file, lastItemPosition, toInsert);
|
|
142
|
+
}
|
|
143
|
+
function getContentOfKeyLiteral(_source, node) {
|
|
144
|
+
if (node.kind == ts.SyntaxKind.Identifier) {
|
|
145
|
+
return node.text;
|
|
146
|
+
}
|
|
147
|
+
else if (node.kind == ts.SyntaxKind.StringLiteral) {
|
|
148
|
+
return node.text;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function _angularImportsFromNode(node) {
|
|
155
|
+
const ms = node.moduleSpecifier;
|
|
156
|
+
let modulePath;
|
|
157
|
+
switch (ms.kind) {
|
|
158
|
+
case ts.SyntaxKind.StringLiteral:
|
|
159
|
+
modulePath = ms.text;
|
|
160
|
+
break;
|
|
161
|
+
default:
|
|
162
|
+
return {};
|
|
163
|
+
}
|
|
164
|
+
if (!modulePath.startsWith('@angular/')) {
|
|
165
|
+
return {};
|
|
166
|
+
}
|
|
167
|
+
if (node.importClause) {
|
|
168
|
+
if (node.importClause.name) {
|
|
169
|
+
// This is of the form `import Name from 'path'`. Ignore.
|
|
170
|
+
return {};
|
|
171
|
+
}
|
|
172
|
+
else if (node.importClause.namedBindings) {
|
|
173
|
+
const nb = node.importClause.namedBindings;
|
|
174
|
+
if (nb.kind == ts.SyntaxKind.NamespaceImport) {
|
|
175
|
+
// This is of the form `import * as name from 'path'`. Return `name.`.
|
|
176
|
+
return {
|
|
177
|
+
[nb.name.text + '.']: modulePath,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
// This is of the form `import {a,b,c} from 'path'`
|
|
182
|
+
const namedImports = nb;
|
|
183
|
+
return namedImports.elements
|
|
184
|
+
.map((is) => (is.propertyName ? is.propertyName.text : is.name.text))
|
|
185
|
+
.reduce((acc, curr) => {
|
|
186
|
+
acc[curr] = modulePath;
|
|
187
|
+
return acc;
|
|
188
|
+
}, {});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return {};
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
// This is of the form `import 'path';`. Nothing to do.
|
|
195
|
+
return {};
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function getDecoratorMetadata(source, identifier, module) {
|
|
199
|
+
const angularImports = findNodes(source, ts.SyntaxKind.ImportDeclaration)
|
|
200
|
+
.map((node) => _angularImportsFromNode(node))
|
|
201
|
+
.reduce((acc, current) => {
|
|
202
|
+
for (const key of Object.keys(current)) {
|
|
203
|
+
acc[key] = current[key];
|
|
204
|
+
}
|
|
205
|
+
return acc;
|
|
206
|
+
}, {});
|
|
207
|
+
return getSourceNodes(source)
|
|
208
|
+
.filter((node) => {
|
|
209
|
+
return (node.kind == ts.SyntaxKind.Decorator && node.expression.kind == ts.SyntaxKind.CallExpression);
|
|
210
|
+
})
|
|
211
|
+
.map((node) => node.expression)
|
|
212
|
+
.filter((expr) => {
|
|
213
|
+
if (expr.expression.kind == ts.SyntaxKind.Identifier) {
|
|
214
|
+
const id = expr.expression;
|
|
215
|
+
return id.text == identifier && angularImports[id.text] === module;
|
|
216
|
+
}
|
|
217
|
+
else if (expr.expression.kind == ts.SyntaxKind.PropertyAccessExpression) {
|
|
218
|
+
// This covers foo.NgModule when importing * as foo.
|
|
219
|
+
const paExpr = expr.expression;
|
|
220
|
+
// If the left expression is not an identifier, just give up at that point.
|
|
221
|
+
if (paExpr.expression.kind !== ts.SyntaxKind.Identifier) {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
const id = paExpr.name.text;
|
|
225
|
+
const moduleId = paExpr.expression.text;
|
|
226
|
+
return id === identifier && angularImports[moduleId + '.'] === module;
|
|
227
|
+
}
|
|
228
|
+
return false;
|
|
229
|
+
})
|
|
230
|
+
.filter((expr) => expr.arguments[0] && expr.arguments[0].kind == ts.SyntaxKind.ObjectLiteralExpression)
|
|
231
|
+
.map((expr) => expr.arguments[0]);
|
|
232
|
+
}
|
|
233
|
+
function findClassDeclarationParent(node) {
|
|
234
|
+
if (ts.isClassDeclaration(node)) {
|
|
235
|
+
return node;
|
|
236
|
+
}
|
|
237
|
+
return node.parent && findClassDeclarationParent(node.parent);
|
|
238
|
+
}
|
|
239
|
+
function getFirstNgModuleName(source) {
|
|
240
|
+
// First, find the @NgModule decorators.
|
|
241
|
+
const ngModulesMetadata = getDecoratorMetadata(source, 'NgModule', '@angular/core');
|
|
242
|
+
if (ngModulesMetadata.length === 0) {
|
|
243
|
+
return undefined;
|
|
244
|
+
}
|
|
245
|
+
// Then walk parent pointers up the AST, looking for the ClassDeclaration parent of the NgModule
|
|
246
|
+
// metadata.
|
|
247
|
+
const moduleClass = findClassDeclarationParent(ngModulesMetadata[0]);
|
|
248
|
+
if (!moduleClass || !moduleClass.name) {
|
|
249
|
+
return undefined;
|
|
250
|
+
}
|
|
251
|
+
// Get the class name of the module ClassDeclaration.
|
|
252
|
+
return moduleClass.name.text;
|
|
253
|
+
}
|
|
254
|
+
function getMetadataField(node, metadataField) {
|
|
255
|
+
return (node.properties
|
|
256
|
+
.filter((prop) => ts.isPropertyAssignment(prop))
|
|
257
|
+
// Filter out every fields that's not "metadataField". Also handles string literals
|
|
258
|
+
// (but not expressions).
|
|
259
|
+
.filter(({ name }) => {
|
|
260
|
+
return ((ts.isIdentifier(name) || ts.isStringLiteral(name)) && (name === null || name === void 0 ? void 0 : name.getText()) === metadataField);
|
|
261
|
+
}));
|
|
262
|
+
}
|
|
263
|
+
function addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, symbolName, importPath = null) {
|
|
264
|
+
const nodes = getDecoratorMetadata(source, 'NgModule', '@angular/core');
|
|
265
|
+
let node = nodes[0];
|
|
266
|
+
// Find the decorator declaration.
|
|
267
|
+
if (!node) {
|
|
268
|
+
return [];
|
|
269
|
+
}
|
|
270
|
+
// Get all the children property assignment of object literals.
|
|
271
|
+
const matchingProperties = getMetadataField(node, metadataField);
|
|
272
|
+
// Get the last node of the array literal.
|
|
273
|
+
if (!matchingProperties) {
|
|
274
|
+
return [];
|
|
275
|
+
}
|
|
276
|
+
if (matchingProperties.length == 0) {
|
|
277
|
+
// We haven't found the field in the metadata declaration. Insert a new field.
|
|
278
|
+
const expr = node;
|
|
279
|
+
let position;
|
|
280
|
+
let toInsert;
|
|
281
|
+
if (expr.properties.length == 0) {
|
|
282
|
+
position = expr.getEnd() - 1;
|
|
283
|
+
toInsert = ` ${metadataField}: [${symbolName}]\n`;
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
node = expr.properties[expr.properties.length - 1];
|
|
287
|
+
position = node.getEnd();
|
|
288
|
+
// Get the indentation of the last element, if any.
|
|
289
|
+
const text = node.getFullText(source);
|
|
290
|
+
const matches = text.match(/^\r?\n\s*/);
|
|
291
|
+
if (matches && matches.length > 0) {
|
|
292
|
+
toInsert = `,${matches[0]}${metadataField}: [${symbolName}]`;
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
toInsert = `, ${metadataField}: [${symbolName}]`;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (importPath !== null) {
|
|
299
|
+
return [
|
|
300
|
+
new change_1.InsertChange(ngModulePath, position, toInsert),
|
|
301
|
+
insertImport(source, ngModulePath, symbolName.replace(/\..*$/, ''), importPath),
|
|
302
|
+
];
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
return [new change_1.InsertChange(ngModulePath, position, toInsert)];
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
const assignment = matchingProperties[0];
|
|
309
|
+
// If it's not an array, nothing we can do really.
|
|
310
|
+
if (assignment.initializer.kind !== ts.SyntaxKind.ArrayLiteralExpression) {
|
|
311
|
+
return [];
|
|
312
|
+
}
|
|
313
|
+
const arrLiteral = assignment.initializer;
|
|
314
|
+
if (arrLiteral.elements.length == 0) {
|
|
315
|
+
// Forward the property.
|
|
316
|
+
node = arrLiteral;
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
node = arrLiteral.elements;
|
|
320
|
+
}
|
|
321
|
+
if (!node) {
|
|
322
|
+
console.error('No app module found. Please add your new class to your component.');
|
|
323
|
+
return [];
|
|
324
|
+
}
|
|
325
|
+
if (Array.isArray(node)) {
|
|
326
|
+
const nodeArray = node;
|
|
327
|
+
const symbolsArray = nodeArray.map((node) => node.getText());
|
|
328
|
+
if (symbolsArray.includes(symbolName)) {
|
|
329
|
+
return [];
|
|
330
|
+
}
|
|
331
|
+
node = node[node.length - 1];
|
|
332
|
+
}
|
|
333
|
+
let toInsert;
|
|
334
|
+
let position = node.getEnd();
|
|
335
|
+
if (node.kind == ts.SyntaxKind.ObjectLiteralExpression) {
|
|
336
|
+
// We haven't found the field in the metadata declaration. Insert a new
|
|
337
|
+
// field.
|
|
338
|
+
const expr = node;
|
|
339
|
+
if (expr.properties.length == 0) {
|
|
340
|
+
position = expr.getEnd() - 1;
|
|
341
|
+
toInsert = ` ${symbolName}\n`;
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
// Get the indentation of the last element, if any.
|
|
345
|
+
const text = node.getFullText(source);
|
|
346
|
+
if (text.match(/^\r?\r?\n/)) {
|
|
347
|
+
toInsert = `,${text.match(/^\r?\n\s*/)[0]}${symbolName}`;
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
toInsert = `, ${symbolName}`;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
else if (node.kind == ts.SyntaxKind.ArrayLiteralExpression) {
|
|
355
|
+
// We found the field but it's empty. Insert it just before the `]`.
|
|
356
|
+
position--;
|
|
357
|
+
toInsert = `${symbolName}`;
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
// Get the indentation of the last element, if any.
|
|
361
|
+
const text = node.getFullText(source);
|
|
362
|
+
if (text.match(/^\r?\n/)) {
|
|
363
|
+
toInsert = `,${text.match(/^\r?\n(\r?)\s*/)[0]}${symbolName}`;
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
toInsert = `, ${symbolName}`;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (importPath !== null) {
|
|
370
|
+
return [
|
|
371
|
+
new change_1.InsertChange(ngModulePath, position, toInsert),
|
|
372
|
+
insertImport(source, ngModulePath, symbolName.replace(/\..*$/, ''), importPath),
|
|
373
|
+
];
|
|
374
|
+
}
|
|
375
|
+
return [new change_1.InsertChange(ngModulePath, position, toInsert)];
|
|
376
|
+
}
|
|
377
|
+
function addDeclarationToModule(source, modulePath, classifiedName, importPath) {
|
|
378
|
+
return addSymbolToNgModuleMetadata(source, modulePath, 'declarations', classifiedName, importPath);
|
|
379
|
+
}
|
|
380
|
+
function addImportToModule(source, modulePath, classifiedName, importPath) {
|
|
381
|
+
return addSymbolToNgModuleMetadata(source, modulePath, 'imports', classifiedName, importPath);
|
|
382
|
+
}
|
|
383
|
+
function addProviderToModule(source, modulePath, classifiedName, importPath) {
|
|
384
|
+
return addSymbolToNgModuleMetadata(source, modulePath, 'providers', classifiedName, importPath);
|
|
385
|
+
}
|
|
386
|
+
function addExportToModule(source, modulePath, classifiedName, importPath) {
|
|
387
|
+
return addSymbolToNgModuleMetadata(source, modulePath, 'exports', classifiedName, importPath);
|
|
388
|
+
}
|
|
389
|
+
function addBootstrapToModule(source, modulePath, classifiedName, importPath) {
|
|
390
|
+
return addSymbolToNgModuleMetadata(source, modulePath, 'bootstrap', classifiedName, importPath);
|
|
391
|
+
}
|
|
392
|
+
function addEntryComponentToModule(source, modulePath, classifiedName, importPath) {
|
|
393
|
+
return addSymbolToNgModuleMetadata(source, modulePath, 'entryComponents', classifiedName, importPath);
|
|
394
|
+
}
|
|
395
|
+
function isImported(source, classifiedName, importPath) {
|
|
396
|
+
const allNodes = getSourceNodes(source);
|
|
397
|
+
const matchingNodes = allNodes
|
|
398
|
+
.filter((node) => node.kind === ts.SyntaxKind.ImportDeclaration)
|
|
399
|
+
.filter((imp) => imp.moduleSpecifier.kind === ts.SyntaxKind.StringLiteral)
|
|
400
|
+
.filter((imp) => {
|
|
401
|
+
return imp.moduleSpecifier.text === importPath;
|
|
402
|
+
})
|
|
403
|
+
.filter((imp) => {
|
|
404
|
+
if (!imp.importClause) {
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
const nodes = findNodes(imp.importClause, ts.SyntaxKind.ImportSpecifier).filter((n) => n.getText() === classifiedName);
|
|
408
|
+
return nodes.length > 0;
|
|
409
|
+
});
|
|
410
|
+
return matchingNodes.length > 0;
|
|
411
|
+
}
|
|
412
|
+
function getEnvironmentExportName(source) {
|
|
413
|
+
// Initial value is `null` as we don't know yet if the user
|
|
414
|
+
// has imported `environment` into the root module or not.
|
|
415
|
+
let environmentExportName = null;
|
|
416
|
+
const allNodes = getSourceNodes(source);
|
|
417
|
+
allNodes
|
|
418
|
+
.filter((node) => node.kind === ts.SyntaxKind.ImportDeclaration)
|
|
419
|
+
.filter((declaration) => declaration.moduleSpecifier.kind === ts.SyntaxKind.StringLiteral &&
|
|
420
|
+
declaration.importClause !== undefined)
|
|
421
|
+
.map((declaration) =>
|
|
422
|
+
// If `importClause` property is defined then the first
|
|
423
|
+
// child will be `NamedImports` object (or `namedBindings`).
|
|
424
|
+
declaration.importClause.getChildAt(0))
|
|
425
|
+
// Find those `NamedImports` object that contains `environment` keyword
|
|
426
|
+
// in its text. E.g. `{ environment as env }`.
|
|
427
|
+
.filter((namedImports) => namedImports.getText().includes('environment'))
|
|
428
|
+
.forEach((namedImports) => {
|
|
429
|
+
for (const specifier of namedImports.elements) {
|
|
430
|
+
// `propertyName` is defined if the specifier
|
|
431
|
+
// has an aliased import.
|
|
432
|
+
const name = specifier.propertyName || specifier.name;
|
|
433
|
+
// Find specifier that contains `environment` keyword in its text.
|
|
434
|
+
// Whether it's `environment` or `environment as env`.
|
|
435
|
+
if (name.text.includes('environment')) {
|
|
436
|
+
environmentExportName = specifier.name.text;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
return environmentExportName;
|
|
441
|
+
}
|
|
442
|
+
function getRouterModuleDeclaration(source) {
|
|
443
|
+
const result = getDecoratorMetadata(source, 'NgModule', '@angular/core');
|
|
444
|
+
const node = result[0];
|
|
445
|
+
const matchingProperties = getMetadataField(node, 'imports');
|
|
446
|
+
if (!matchingProperties) {
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
const assignment = matchingProperties[0];
|
|
450
|
+
if (assignment.initializer.kind !== ts.SyntaxKind.ArrayLiteralExpression) {
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
const arrLiteral = assignment.initializer;
|
|
454
|
+
return arrLiteral.elements
|
|
455
|
+
.filter((el) => el.kind === ts.SyntaxKind.CallExpression)
|
|
456
|
+
.find((el) => el.getText().startsWith('RouterModule'));
|
|
457
|
+
}
|
|
458
|
+
function addRouteDeclarationToModule(source, fileToAdd, routeLiteral) {
|
|
459
|
+
const routerModuleExpr = getRouterModuleDeclaration(source);
|
|
460
|
+
if (!routerModuleExpr) {
|
|
461
|
+
throw new Error(`Couldn't find a route declaration in ${fileToAdd}.`);
|
|
462
|
+
}
|
|
463
|
+
const scopeConfigMethodArgs = routerModuleExpr.arguments;
|
|
464
|
+
if (!scopeConfigMethodArgs.length) {
|
|
465
|
+
const { line } = source.getLineAndCharacterOfPosition(routerModuleExpr.getStart());
|
|
466
|
+
throw new Error(`The router module method doesn't have arguments ` + `at line ${line} in ${fileToAdd}`);
|
|
467
|
+
}
|
|
468
|
+
let routesArr;
|
|
469
|
+
const routesArg = scopeConfigMethodArgs[0];
|
|
470
|
+
// Check if the route declarations array is
|
|
471
|
+
// an inlined argument of RouterModule or a standalone variable
|
|
472
|
+
if (ts.isArrayLiteralExpression(routesArg)) {
|
|
473
|
+
routesArr = routesArg;
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
const routesVarName = routesArg.getText();
|
|
477
|
+
let routesVar;
|
|
478
|
+
if (routesArg.kind === ts.SyntaxKind.Identifier) {
|
|
479
|
+
routesVar = source.statements
|
|
480
|
+
.filter((s) => s.kind === ts.SyntaxKind.VariableStatement)
|
|
481
|
+
.find((v) => {
|
|
482
|
+
return v.declarationList.declarations[0].name.getText() === routesVarName;
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
if (!routesVar) {
|
|
486
|
+
const { line } = source.getLineAndCharacterOfPosition(routesArg.getStart());
|
|
487
|
+
throw new Error(`No route declaration array was found that corresponds ` + `to router module at line ${line} in ${fileToAdd}`);
|
|
488
|
+
}
|
|
489
|
+
routesArr = findNodes(routesVar, ts.SyntaxKind.ArrayLiteralExpression, 1)[0];
|
|
490
|
+
}
|
|
491
|
+
const occurrencesCount = routesArr.elements.length;
|
|
492
|
+
const text = routesArr.getFullText(source);
|
|
493
|
+
let route = routeLiteral;
|
|
494
|
+
let insertPos = routesArr.elements.pos;
|
|
495
|
+
if (occurrencesCount > 0) {
|
|
496
|
+
const lastRouteLiteral = [...routesArr.elements].pop();
|
|
497
|
+
const lastRouteIsWildcard = ts.isObjectLiteralExpression(lastRouteLiteral) &&
|
|
498
|
+
lastRouteLiteral.properties.some((n) => ts.isPropertyAssignment(n) &&
|
|
499
|
+
ts.isIdentifier(n.name) &&
|
|
500
|
+
n.name.text === 'path' &&
|
|
501
|
+
ts.isStringLiteral(n.initializer) &&
|
|
502
|
+
n.initializer.text === '**');
|
|
503
|
+
const indentation = text.match(/\r?\n(\r?)\s*/) || [];
|
|
504
|
+
const routeText = `${indentation[0] || ' '}${routeLiteral}`;
|
|
505
|
+
// Add the new route before the wildcard route
|
|
506
|
+
// otherwise we'll always redirect to the wildcard route
|
|
507
|
+
if (lastRouteIsWildcard) {
|
|
508
|
+
insertPos = lastRouteLiteral.pos;
|
|
509
|
+
route = `${routeText},`;
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
insertPos = lastRouteLiteral.end;
|
|
513
|
+
route = `,${routeText}`;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return new change_1.InsertChange(fileToAdd, insertPos, route);
|
|
517
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReplaceChange = exports.RemoveChange = exports.InsertChange = exports.NoopChange = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* An operation that does nothing.
|
|
6
|
+
*/
|
|
7
|
+
class NoopChange {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.description = 'No operation.';
|
|
10
|
+
this.order = Infinity;
|
|
11
|
+
this.path = null;
|
|
12
|
+
}
|
|
13
|
+
apply() {
|
|
14
|
+
return Promise.resolve();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.NoopChange = NoopChange;
|
|
18
|
+
/**
|
|
19
|
+
* Will add text to the source code.
|
|
20
|
+
*/
|
|
21
|
+
class InsertChange {
|
|
22
|
+
constructor(path, pos, toAdd) {
|
|
23
|
+
this.path = path;
|
|
24
|
+
this.pos = pos;
|
|
25
|
+
this.toAdd = toAdd;
|
|
26
|
+
if (pos < 0) {
|
|
27
|
+
throw new Error('Negative positions are invalid');
|
|
28
|
+
}
|
|
29
|
+
this.description = `Inserted ${toAdd} into position ${pos} of ${path}`;
|
|
30
|
+
this.order = pos;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* This method does not insert spaces if there is none in the original string.
|
|
34
|
+
*/
|
|
35
|
+
apply(host) {
|
|
36
|
+
return host.read(this.path).then((content) => {
|
|
37
|
+
const prefix = content.substring(0, this.pos);
|
|
38
|
+
const suffix = content.substring(this.pos);
|
|
39
|
+
return host.write(this.path, `${prefix}${this.toAdd}${suffix}`);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.InsertChange = InsertChange;
|
|
44
|
+
/**
|
|
45
|
+
* Will remove text from the source code.
|
|
46
|
+
*/
|
|
47
|
+
class RemoveChange {
|
|
48
|
+
constructor(path, pos, toRemove) {
|
|
49
|
+
this.path = path;
|
|
50
|
+
this.pos = pos;
|
|
51
|
+
this.toRemove = toRemove;
|
|
52
|
+
if (pos < 0) {
|
|
53
|
+
throw new Error('Negative positions are invalid');
|
|
54
|
+
}
|
|
55
|
+
this.description = `Removed ${toRemove} into position ${pos} of ${path}`;
|
|
56
|
+
this.order = pos;
|
|
57
|
+
}
|
|
58
|
+
apply(host) {
|
|
59
|
+
return host.read(this.path).then((content) => {
|
|
60
|
+
const prefix = content.substring(0, this.pos);
|
|
61
|
+
const suffix = content.substring(this.pos + this.toRemove.length);
|
|
62
|
+
// TODO: throw error if toRemove doesn't match removed string.
|
|
63
|
+
return host.write(this.path, `${prefix}${suffix}`);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.RemoveChange = RemoveChange;
|
|
68
|
+
/**
|
|
69
|
+
* Will replace text from the source code.
|
|
70
|
+
*/
|
|
71
|
+
class ReplaceChange {
|
|
72
|
+
constructor(path, pos, oldText, newText) {
|
|
73
|
+
this.path = path;
|
|
74
|
+
this.pos = pos;
|
|
75
|
+
this.oldText = oldText;
|
|
76
|
+
this.newText = newText;
|
|
77
|
+
if (pos < 0) {
|
|
78
|
+
throw new Error('Negative positions are invalid');
|
|
79
|
+
}
|
|
80
|
+
this.description = `Replaced ${oldText} into position ${pos} of ${path} with ${newText}`;
|
|
81
|
+
this.order = pos;
|
|
82
|
+
}
|
|
83
|
+
apply(host) {
|
|
84
|
+
return host.read(this.path).then((content) => {
|
|
85
|
+
const prefix = content.substring(0, this.pos);
|
|
86
|
+
const suffix = content.substring(this.pos + this.oldText.length);
|
|
87
|
+
const text = content.substring(this.pos, this.pos + this.oldText.length);
|
|
88
|
+
if (text !== this.oldText) {
|
|
89
|
+
return Promise.reject(new Error(`Invalid replace: "${text}" != "${this.oldText}".`));
|
|
90
|
+
}
|
|
91
|
+
// TODO: throw error if oldText doesn't match removed string.
|
|
92
|
+
return host.write(this.path, `${prefix}${this.newText}${suffix}`);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.ReplaceChange = ReplaceChange;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildSelector = buildSelector;
|
|
4
|
+
const core_1 = require("@angular-devkit/core");
|
|
5
|
+
function buildSelector(options, projectPrefix) {
|
|
6
|
+
let selector = core_1.strings.dasherize(options.name);
|
|
7
|
+
if (options.prefix) {
|
|
8
|
+
selector = `${options.prefix}-${selector}`;
|
|
9
|
+
}
|
|
10
|
+
else if (options.prefix === undefined && projectPrefix) {
|
|
11
|
+
selector = `${projectPrefix}-${selector}`;
|
|
12
|
+
}
|
|
13
|
+
return selector;
|
|
14
|
+
}
|