@gadmin2n/schematics 0.0.55
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/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/collection.json +122 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +18 -0
- package/dist/lib/application/application.factory.d.ts +3 -0
- package/dist/lib/application/application.factory.js +92 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/.dockerignore +33 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/Dockerfile +14 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/Jenkinsfile +44 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/build.sh +18 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/.types.d.ts +143 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/prisma/sample.prisma +65 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/Game.ts +58 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/Log.ts +56 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/Role.ts +58 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/Source.ts +76 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/Tasklog.ts +76 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/_common.ts +16 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/readme.md +49 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/.env +20 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/.eslintrc.js +25 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/.prettierrc +4 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/README.md +71 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/config/ac.config.ts +24 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/config/index.ts +60 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/gadmin-cli.json +17 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/package.json +106 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/prisma/.generator.prisma +32 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/games.ts +71 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/index.ts +27 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/roles.ts +4 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/app.controller.spec.ts +22 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/app.controller.ts +52 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/app.module.ts +75 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/app.service.ts +50 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/lib/auth.guard.ts +108 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/lib/roles.guard.ts +47 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/lib/utils.ts +54 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/lib/woaAuth.ts +82 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/lib/yufuid.ts +160 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/main.ts +119 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/index.ts +3 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/test/app.e2e-spec.ts +24 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/test/jest-e2e.json +9 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/tsconfig.build.json +4 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/tsconfig.json +21 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/README.MD +48 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/craco.config.js +27 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/package.json +81 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/public/favicon.ico +0 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/public/images/flags/en.svg +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/public/images/flags/zh_CN.svg +11 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/public/index.html +53 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/public/locales/en/common.json +128 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/public/locales/zh_CN/common.json +130 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/App.tsx +185 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/auditLogProvider.ts +87 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/authProvider.ts +124 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/BulkActions.tsx +236 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/ListPageHeader.tsx +56 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/RowActions.tsx +292 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/SearchBar.tsx +294 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/VanillaJSONEditor/index.css +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/VanillaJSONEditor/index.js +53 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/agentPanel/AgentContext.tsx +201 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/agentPanel/AgentPanel.tsx +497 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/agentPanel/ElementInspector.tsx +282 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/agentPanel/agentAttributes.ts +61 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/agentPanel/index.ts +18 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/agentPanel/inspectorActions.ts +111 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/agentPanel/promptGenerator.ts +75 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/agentPanel/skills.ts +464 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/auditLog/components/eventList/index.tsx +62 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/auditLog/components/index.ts +4 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/auditLog/components/logButton/index.tsx +96 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/auditLog/components/logList/index.tsx +73 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/auditLog/components/modalDiffViewer/index.tsx +104 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/auditLog/index.tsx +2 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/contexts/business/index.tsx +65 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/contexts/color-mode/index.tsx +60 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/index.ts +4 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/header/index.tsx +130 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/index.ts +2 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/sider.tsx +218 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/styles.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/offLayoutArea/index.tsx +5 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/form.tsx +419 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/index.tsx +3 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/list.tsx +465 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/login.ts +124 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/show.tsx +182 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/utils.ts +76 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/index.ts +7 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/types.ts +138 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useBatchDelete.ts +191 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useBatchOperations.ts +152 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useBatchOperationsCore.ts +193 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useBatchUpdate.ts +182 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useListPageState.ts +303 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useRowSelection.ts +38 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/i18n.ts +19 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/index.tsx +28 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/meta.json +4 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/react-app-env.d.ts +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/reportWebVitals.ts +15 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/setupTests.ts +5 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/styles/antd.less +79 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/tsconfig.json +27 -0
- package/dist/lib/application/schema.json +99 -0
- package/dist/lib/class/class.factory.d.ts +3 -0
- package/dist/lib/class/class.factory.js +42 -0
- package/dist/lib/class/files/js/__name__.js +1 -0
- package/dist/lib/class/files/js/__name__.spec.js +7 -0
- package/dist/lib/class/files/ts/__name__.spec.ts +7 -0
- package/dist/lib/class/files/ts/__name__.ts +1 -0
- package/dist/lib/class/schema.json +45 -0
- package/dist/lib/client-app/angular/angular.factory.d.ts +3 -0
- package/dist/lib/client-app/angular/angular.factory.js +98 -0
- package/dist/lib/client-app/angular/files/angular.constants.ts +4 -0
- package/dist/lib/client-app/angular/files/angular.module.ts +41 -0
- package/dist/lib/client-app/angular/files/angular.providers.ts +27 -0
- package/dist/lib/client-app/angular/files/angular.utils.ts +19 -0
- package/dist/lib/client-app/angular/files/interfaces/angular-options.interface.ts +87 -0
- package/dist/lib/client-app/angular/files/loaders/abstract.loader.ts +16 -0
- package/dist/lib/client-app/angular/files/loaders/express.loader.ts +25 -0
- package/dist/lib/client-app/angular/files/loaders/fastify.loader.ts +34 -0
- package/dist/lib/client-app/angular/files/loaders/noop.loader.ts +12 -0
- package/dist/lib/client-app/angular/schema.json +24 -0
- package/dist/lib/configuration/configuration.factory.d.ts +3 -0
- package/dist/lib/configuration/configuration.factory.js +24 -0
- package/dist/lib/configuration/files/js/nest-cli.json +6 -0
- package/dist/lib/configuration/files/ts/nest-cli.json +5 -0
- package/dist/lib/controller/controller.factory.d.ts +3 -0
- package/dist/lib/controller/controller.factory.js +118 -0
- package/dist/lib/controller/files/js/__name__.controller.js +4 -0
- package/dist/lib/controller/files/js/__name__.controller.spec.js +18 -0
- package/dist/lib/controller/files/ts/__name__.controller.spec.ts +18 -0
- package/dist/lib/controller/files/ts/__name__.controller.ts +137 -0
- package/dist/lib/controller/schema.json +51 -0
- package/dist/lib/decorator/decorator.factory.d.ts +3 -0
- package/dist/lib/decorator/decorator.factory.js +33 -0
- package/dist/lib/decorator/files/js/__name__.decorator.js +3 -0
- package/dist/lib/decorator/files/ts/__name__.decorator.ts +3 -0
- package/dist/lib/decorator/schema.json +36 -0
- package/dist/lib/defaults.d.ts +16 -0
- package/dist/lib/defaults.js +19 -0
- package/dist/lib/filter/files/js/__name__.filter.js +6 -0
- package/dist/lib/filter/files/js/__name__.filter.spec.js +7 -0
- package/dist/lib/filter/files/ts/__name__.filter.spec.ts +7 -0
- package/dist/lib/filter/files/ts/__name__.filter.ts +6 -0
- package/dist/lib/filter/filter.factory.d.ts +3 -0
- package/dist/lib/filter/filter.factory.js +34 -0
- package/dist/lib/filter/schema.json +41 -0
- package/dist/lib/gateway/files/js/__name__.gateway.js +9 -0
- package/dist/lib/gateway/files/js/__name__.gateway.spec.js +18 -0
- package/dist/lib/gateway/files/ts/__name__.gateway.spec.ts +18 -0
- package/dist/lib/gateway/files/ts/__name__.gateway.ts +9 -0
- package/dist/lib/gateway/gateway.factory.d.ts +3 -0
- package/dist/lib/gateway/gateway.factory.js +62 -0
- package/dist/lib/gateway/schema.json +41 -0
- package/dist/lib/guard/files/js/__name__.guard.js +8 -0
- package/dist/lib/guard/files/js/__name__.guard.spec.js +7 -0
- package/dist/lib/guard/files/ts/__name__.guard.spec.ts +7 -0
- package/dist/lib/guard/files/ts/__name__.guard.ts +11 -0
- package/dist/lib/guard/guard.factory.d.ts +3 -0
- package/dist/lib/guard/guard.factory.js +34 -0
- package/dist/lib/guard/schema.json +41 -0
- package/dist/lib/interceptor/files/js/__name__.interceptor.js +8 -0
- package/dist/lib/interceptor/files/js/__name__.interceptor.spec.js +7 -0
- package/dist/lib/interceptor/files/ts/default/__name__.interceptor.spec.ts +7 -0
- package/dist/lib/interceptor/files/ts/default/__name__.interceptor.ts +9 -0
- package/dist/lib/interceptor/files/ts/generated/__name__.interceptor.spec.ts +7 -0
- package/dist/lib/interceptor/files/ts/generated/__name__.interceptor.ts +13 -0
- package/dist/lib/interceptor/interceptor.factory.d.ts +3 -0
- package/dist/lib/interceptor/interceptor.factory.js +116 -0
- package/dist/lib/interceptor/schema.json +50 -0
- package/dist/lib/interface/files/__name__.interface.ts +1 -0
- package/dist/lib/interface/interface.factory.d.ts +3 -0
- package/dist/lib/interface/interface.factory.js +32 -0
- package/dist/lib/interface/schema.json +32 -0
- package/dist/lib/library/files/js/.babelrc +4 -0
- package/dist/lib/library/files/js/jsconfig.json +9 -0
- package/dist/lib/library/files/js/src/__name__.module.js +8 -0
- package/dist/lib/library/files/js/src/__name__.service.js +4 -0
- package/dist/lib/library/files/js/src/__name__.service.spec.js +18 -0
- package/dist/lib/library/files/js/src/index.js +2 -0
- package/dist/lib/library/files/ts/src/__name__.module.ts +8 -0
- package/dist/lib/library/files/ts/src/__name__.service.spec.ts +18 -0
- package/dist/lib/library/files/ts/src/__name__.service.ts +4 -0
- package/dist/lib/library/files/ts/src/index.ts +2 -0
- package/dist/lib/library/files/ts/tsconfig.lib.json +9 -0
- package/dist/lib/library/library.factory.d.ts +3 -0
- package/dist/lib/library/library.factory.js +190 -0
- package/dist/lib/library/schema.json +37 -0
- package/dist/lib/middleware/files/js/__name__.middleware.js +8 -0
- package/dist/lib/middleware/files/js/__name__.middleware.spec.js +7 -0
- package/dist/lib/middleware/files/ts/__name__.middleware.spec.ts +7 -0
- package/dist/lib/middleware/files/ts/__name__.middleware.ts +8 -0
- package/dist/lib/middleware/middleware.factory.d.ts +3 -0
- package/dist/lib/middleware/middleware.factory.js +34 -0
- package/dist/lib/middleware/schema.json +41 -0
- package/dist/lib/module/files/js/__name__.module.js +4 -0
- package/dist/lib/module/files/ts/__name__.module.ts +4 -0
- package/dist/lib/module/module.factory.d.ts +3 -0
- package/dist/lib/module/module.factory.js +58 -0
- package/dist/lib/module/schema.json +46 -0
- package/dist/lib/pipe/files/js/__name__.pipe.js +8 -0
- package/dist/lib/pipe/files/js/__name__.pipe.spec.js +7 -0
- package/dist/lib/pipe/files/ts/__name__.pipe.spec.ts +7 -0
- package/dist/lib/pipe/files/ts/__name__.pipe.ts +8 -0
- package/dist/lib/pipe/pipe.factory.d.ts +3 -0
- package/dist/lib/pipe/pipe.factory.js +34 -0
- package/dist/lib/pipe/schema.json +41 -0
- package/dist/lib/prisma-resource/files/ts/__name__.controller.spec.ts +20 -0
- package/dist/lib/prisma-resource/files/ts/__name__.controller.ts +63 -0
- package/dist/lib/prisma-resource/files/ts/__name__.module.ts +9 -0
- package/dist/lib/prisma-resource/files/ts/__name__.service.spec.ts +18 -0
- package/dist/lib/prisma-resource/files/ts/__name__.service.ts +28 -0
- package/dist/lib/prisma-resource/files/ts/dto/create-__name@singular__.dto.ts +1 -0
- package/dist/lib/prisma-resource/files/ts/dto/create-__name@singular__.input.ts +7 -0
- package/dist/lib/prisma-resource/files/ts/dto/update-__name@singular__.dto.ts +6 -0
- package/dist/lib/prisma-resource/files/ts/dto/update-__name@singular__.input.ts +13 -0
- package/dist/lib/prisma-resource/files/ts/entities/__name@singular@ent__.ts +7 -0
- package/dist/lib/prisma-resource/prisma-resource.factory.d.ts +3 -0
- package/dist/lib/prisma-resource/prisma-resource.factory.js +131 -0
- package/dist/lib/prisma-resource/schema.json +91 -0
- package/dist/lib/provider/files/js/__name__.js +4 -0
- package/dist/lib/provider/files/js/__name__.spec.js +18 -0
- package/dist/lib/provider/files/ts/__name__.spec.ts +18 -0
- package/dist/lib/provider/files/ts/__name__.ts +4 -0
- package/dist/lib/provider/provider.factory.d.ts +3 -0
- package/dist/lib/provider/provider.factory.js +67 -0
- package/dist/lib/provider/schema.json +45 -0
- package/dist/lib/resolver/files/js/__name__.resolver.js +4 -0
- package/dist/lib/resolver/files/js/__name__.resolver.spec.js +18 -0
- package/dist/lib/resolver/files/ts/__name__.resolver.spec.ts +18 -0
- package/dist/lib/resolver/files/ts/__name__.resolver.ts +4 -0
- package/dist/lib/resolver/resolver.factory.d.ts +3 -0
- package/dist/lib/resolver/resolver.factory.js +62 -0
- package/dist/lib/resolver/schema.json +41 -0
- package/dist/lib/resource/files/ts/__name__.controller.spec.ts +20 -0
- package/dist/lib/resource/files/ts/__name__.controller.ts +63 -0
- package/dist/lib/resource/files/ts/__name__.gateway.spec.ts +19 -0
- package/dist/lib/resource/files/ts/__name__.gateway.ts +34 -0
- package/dist/lib/resource/files/ts/__name__.graphql +24 -0
- package/dist/lib/resource/files/ts/__name__.module.ts +9 -0
- package/dist/lib/resource/files/ts/__name__.resolver.spec.ts +19 -0
- package/dist/lib/resource/files/ts/__name__.resolver.ts +60 -0
- package/dist/lib/resource/files/ts/__name__.service.spec.ts +18 -0
- package/dist/lib/resource/files/ts/__name__.service.ts +28 -0
- package/dist/lib/resource/files/ts/dto/create-__name@singular__.dto.ts +1 -0
- package/dist/lib/resource/files/ts/dto/create-__name@singular__.input.ts +7 -0
- package/dist/lib/resource/files/ts/dto/update-__name@singular__.dto.ts +6 -0
- package/dist/lib/resource/files/ts/dto/update-__name@singular__.input.ts +13 -0
- package/dist/lib/resource/files/ts/entities/__name@singular@ent__.ts +7 -0
- package/dist/lib/resource/resource.factory.d.ts +3 -0
- package/dist/lib/resource/resource.factory.js +131 -0
- package/dist/lib/resource/schema.json +90 -0
- package/dist/lib/service/files/js/__name__.service.js +4 -0
- package/dist/lib/service/files/js/__name__.service.spec.js +18 -0
- package/dist/lib/service/files/ts/__name__.service.spec.ts +18 -0
- package/dist/lib/service/files/ts/__name__.service.ts +4 -0
- package/dist/lib/service/schema.json +41 -0
- package/dist/lib/service/service.factory.d.ts +3 -0
- package/dist/lib/service/service.factory.js +63 -0
- package/dist/lib/sub-app/files/js/.babelrc +4 -0
- package/dist/lib/sub-app/files/js/index.js +2 -0
- package/dist/lib/sub-app/files/js/jsconfig.json +10 -0
- package/dist/lib/sub-app/files/js/src/app.controller.js +15 -0
- package/dist/lib/sub-app/files/js/src/app.controller.spec.js +22 -0
- package/dist/lib/sub-app/files/js/src/app.module.js +10 -0
- package/dist/lib/sub-app/files/js/src/app.service.js +8 -0
- package/dist/lib/sub-app/files/js/src/main.js +8 -0
- package/dist/lib/sub-app/files/js/test/app.e2e-spec.js +23 -0
- package/dist/lib/sub-app/files/js/test/jest-e2e.json +5 -0
- package/dist/lib/sub-app/files/ts/src/__name__.controller.spec.ts +22 -0
- package/dist/lib/sub-app/files/ts/src/__name__.controller.ts +12 -0
- package/dist/lib/sub-app/files/ts/src/__name__.module.ts +10 -0
- package/dist/lib/sub-app/files/ts/src/__name__.service.ts +8 -0
- package/dist/lib/sub-app/files/ts/src/main.ts +8 -0
- package/dist/lib/sub-app/files/ts/test/app.e2e-spec.ts +24 -0
- package/dist/lib/sub-app/files/ts/test/jest-e2e.json +9 -0
- package/dist/lib/sub-app/files/ts/tsconfig.app.json +9 -0
- package/dist/lib/sub-app/schema.json +32 -0
- package/dist/lib/sub-app/sub-app.factory.d.ts +3 -0
- package/dist/lib/sub-app/sub-app.factory.js +245 -0
- package/dist/lib/sub-app/workspace/js/.babelrc +4 -0
- package/dist/lib/sub-app/workspace/js/index.js +2 -0
- package/dist/lib/sub-app/workspace/js/jsconfig.json +10 -0
- package/dist/lib/sub-app/workspace/ts/tsconfig.app.json +9 -0
- package/dist/utils/change.d.ts +46 -0
- package/dist/utils/change.js +95 -0
- package/dist/utils/dependencies.utils.d.ts +15 -0
- package/dist/utils/dependencies.utils.js +42 -0
- package/dist/utils/export-from.declarator.d.ts +10 -0
- package/dist/utils/export-from.declarator.js +39 -0
- package/dist/utils/formatting.d.ts +1 -0
- package/dist/utils/formatting.js +12 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.js +25 -0
- package/dist/utils/json-file.util.d.ts +15 -0
- package/dist/utils/json-file.util.js +68 -0
- package/dist/utils/metadata.manager.d.ts +13 -0
- package/dist/utils/metadata.manager.js +162 -0
- package/dist/utils/module-import.declarator.d.ts +10 -0
- package/dist/utils/module-import.declarator.js +39 -0
- package/dist/utils/module-metadata.declarator.d.ts +4 -0
- package/dist/utils/module-metadata.declarator.js +12 -0
- package/dist/utils/module.declarator.d.ts +23 -0
- package/dist/utils/module.declarator.js +32 -0
- package/dist/utils/module.finder.d.ts +13 -0
- package/dist/utils/module.finder.js +24 -0
- package/dist/utils/name.parser.d.ts +12 -0
- package/dist/utils/name.parser.js +17 -0
- package/dist/utils/path.solver.d.ts +4 -0
- package/dist/utils/path.solver.js +14 -0
- package/dist/utils/source-root.helpers.d.ts +8 -0
- package/dist/utils/source-root.helpers.js +35 -0
- package/package.json +99 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.main = void 0;
|
|
4
|
+
const core_1 = require("@angular-devkit/core");
|
|
5
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
+
const fse = require("fs-extra");
|
|
7
|
+
const jsonc_parser_1 = require("jsonc-parser");
|
|
8
|
+
const formatting_1 = require("../../utils/formatting");
|
|
9
|
+
const defaults_1 = require("../defaults");
|
|
10
|
+
function main(options) {
|
|
11
|
+
const appName = getAppNameFromPackageJson();
|
|
12
|
+
options = transform(options);
|
|
13
|
+
return (0, schematics_1.chain)([
|
|
14
|
+
updateTsConfig(),
|
|
15
|
+
updatePackageJson(options, appName),
|
|
16
|
+
(tree, context) => isMonorepo(tree)
|
|
17
|
+
? (0, schematics_1.noop)()(tree, context)
|
|
18
|
+
: (0, schematics_1.chain)([
|
|
19
|
+
(0, schematics_1.branchAndMerge)((0, schematics_1.mergeWith)(generateWorkspace(options, appName))),
|
|
20
|
+
moveDefaultAppToApps(options.path, appName, options.sourceRoot),
|
|
21
|
+
])(tree, context),
|
|
22
|
+
addAppsToCliOptions(options.path, options.name, appName),
|
|
23
|
+
(0, schematics_1.branchAndMerge)((0, schematics_1.mergeWith)(generate(options))),
|
|
24
|
+
]);
|
|
25
|
+
}
|
|
26
|
+
exports.main = main;
|
|
27
|
+
function getAppNameFromPackageJson() {
|
|
28
|
+
try {
|
|
29
|
+
if (!fse.existsSync('./package.json')) {
|
|
30
|
+
return defaults_1.DEFAULT_DIR_ENTRY_APP;
|
|
31
|
+
}
|
|
32
|
+
const packageJson = fse.readJsonSync('./package.json');
|
|
33
|
+
if (!packageJson.name) {
|
|
34
|
+
return defaults_1.DEFAULT_DIR_ENTRY_APP;
|
|
35
|
+
}
|
|
36
|
+
let name = packageJson.name;
|
|
37
|
+
name = name.replace(/[^\w.]+/g, '-').replace(/\-+/g, '-');
|
|
38
|
+
return name[0] === '-' ? name.substr(1) : name;
|
|
39
|
+
}
|
|
40
|
+
catch (_a) {
|
|
41
|
+
return defaults_1.DEFAULT_DIR_ENTRY_APP;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function transform(options) {
|
|
45
|
+
const target = Object.assign({}, options);
|
|
46
|
+
const defaultSourceRoot = options.rootDir !== undefined ? options.rootDir : defaults_1.DEFAULT_APPS_PATH;
|
|
47
|
+
if (!target.name) {
|
|
48
|
+
target.name = defaults_1.DEFAULT_APP_NAME;
|
|
49
|
+
}
|
|
50
|
+
target.language = !!target.language ? target.language : defaults_1.DEFAULT_LANGUAGE;
|
|
51
|
+
target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(target.name);
|
|
52
|
+
target.path =
|
|
53
|
+
target.path !== undefined
|
|
54
|
+
? (0, core_1.join)((0, core_1.normalize)(defaultSourceRoot), target.path)
|
|
55
|
+
: (0, core_1.normalize)(defaultSourceRoot);
|
|
56
|
+
return target;
|
|
57
|
+
}
|
|
58
|
+
function isMonorepo(host) {
|
|
59
|
+
const nestFileExists = host.exists('nest.json');
|
|
60
|
+
const nestCliFileExists = host.exists('nest-cli.json');
|
|
61
|
+
if (!nestFileExists && !nestCliFileExists) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const filename = nestCliFileExists ? 'nest-cli.json' : 'nest.json';
|
|
65
|
+
const source = host.read(filename);
|
|
66
|
+
if (!source) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
const sourceText = source.toString('utf-8');
|
|
70
|
+
const optionsObj = (0, jsonc_parser_1.parse)(sourceText);
|
|
71
|
+
return !!optionsObj.monorepo;
|
|
72
|
+
}
|
|
73
|
+
function updateJsonFile(host, path, callback) {
|
|
74
|
+
const source = host.read(path);
|
|
75
|
+
if (source) {
|
|
76
|
+
const sourceText = source.toString('utf-8');
|
|
77
|
+
const json = (0, jsonc_parser_1.parse)(sourceText);
|
|
78
|
+
callback(json);
|
|
79
|
+
host.overwrite(path, JSON.stringify(json, null, 2));
|
|
80
|
+
}
|
|
81
|
+
return host;
|
|
82
|
+
}
|
|
83
|
+
function updateTsConfig() {
|
|
84
|
+
return (host) => {
|
|
85
|
+
if (!host.exists('tsconfig.json')) {
|
|
86
|
+
return host;
|
|
87
|
+
}
|
|
88
|
+
return updateJsonFile(host, 'tsconfig.json', (tsconfig) => {
|
|
89
|
+
if (!tsconfig.compilerOptions) {
|
|
90
|
+
tsconfig.compilerOptions = {};
|
|
91
|
+
}
|
|
92
|
+
if (!tsconfig.compilerOptions.baseUrl) {
|
|
93
|
+
tsconfig.compilerOptions.baseUrl = './';
|
|
94
|
+
}
|
|
95
|
+
if (!tsconfig.compilerOptions.paths) {
|
|
96
|
+
tsconfig.compilerOptions.paths = {};
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function updatePackageJson(options, defaultAppName) {
|
|
102
|
+
return (host) => {
|
|
103
|
+
if (!host.exists('package.json')) {
|
|
104
|
+
return host;
|
|
105
|
+
}
|
|
106
|
+
return updateJsonFile(host, 'package.json', (packageJson) => {
|
|
107
|
+
updateNpmScripts(packageJson.scripts, options, defaultAppName);
|
|
108
|
+
updateJestOptions(packageJson.jest, options);
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function updateNpmScripts(scripts, options, defaultAppName) {
|
|
113
|
+
if (!scripts) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const defaultFormatScriptName = 'format';
|
|
117
|
+
const defaultTestScriptName = 'test:e2e';
|
|
118
|
+
if (!scripts[defaultTestScriptName] && !scripts[defaultFormatScriptName]) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (scripts[defaultTestScriptName] &&
|
|
122
|
+
scripts[defaultTestScriptName].indexOf(options.path) < 0) {
|
|
123
|
+
const defaultTestDir = 'test';
|
|
124
|
+
const newTestDir = (0, core_1.join)(options.path, defaultAppName, defaultTestDir);
|
|
125
|
+
scripts[defaultTestScriptName] = scripts[defaultTestScriptName].replace(defaultTestDir, newTestDir);
|
|
126
|
+
}
|
|
127
|
+
if (scripts[defaultFormatScriptName] &&
|
|
128
|
+
scripts[defaultFormatScriptName].indexOf(defaults_1.DEFAULT_PATH_NAME) >= 0) {
|
|
129
|
+
const defaultSourceRoot = options.rootDir !== undefined ? options.rootDir : defaults_1.DEFAULT_APPS_PATH;
|
|
130
|
+
scripts[defaultFormatScriptName] = `prettier --write "${defaultSourceRoot}/**/*.ts" "${defaults_1.DEFAULT_LIB_PATH}/**/*.ts"`;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function updateJestOptions(jestOptions, options) {
|
|
134
|
+
if (!jestOptions) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (jestOptions.rootDir === defaults_1.DEFAULT_PATH_NAME) {
|
|
138
|
+
jestOptions.rootDir = '.';
|
|
139
|
+
jestOptions.coverageDirectory = './coverage';
|
|
140
|
+
}
|
|
141
|
+
const defaultSourceRoot = options.rootDir !== undefined ? options.rootDir : defaults_1.DEFAULT_APPS_PATH;
|
|
142
|
+
const jestSourceRoot = `<rootDir>/${defaultSourceRoot}/`;
|
|
143
|
+
if (!jestOptions.roots) {
|
|
144
|
+
jestOptions.roots = [jestSourceRoot];
|
|
145
|
+
}
|
|
146
|
+
else if (jestOptions.roots.indexOf(jestSourceRoot) < 0) {
|
|
147
|
+
jestOptions.roots.push(jestSourceRoot);
|
|
148
|
+
const originalSourceRoot = `<rootDir>/src/`;
|
|
149
|
+
const originalSourceRootIndex = jestOptions.roots.indexOf(originalSourceRoot);
|
|
150
|
+
if (originalSourceRootIndex >= 0) {
|
|
151
|
+
jestOptions.roots.splice(originalSourceRootIndex, 1);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function moveDefaultAppToApps(projectRoot, appName, sourceRoot = defaults_1.DEFAULT_PATH_NAME) {
|
|
156
|
+
return (host) => {
|
|
157
|
+
if (process.env.NODE_ENV === defaults_1.TEST_ENV) {
|
|
158
|
+
return host;
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
if (fse.existsSync(sourceRoot)) {
|
|
162
|
+
fse.moveSync(sourceRoot, (0, core_1.join)(projectRoot, appName, sourceRoot));
|
|
163
|
+
}
|
|
164
|
+
const testDir = 'test';
|
|
165
|
+
if (fse.existsSync(testDir)) {
|
|
166
|
+
fse.moveSync(testDir, (0, core_1.join)(projectRoot, appName, testDir));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
catch (err) {
|
|
170
|
+
throw new schematics_1.SchematicsException(`The "${projectRoot}" directory exists already.`);
|
|
171
|
+
}
|
|
172
|
+
return host;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function addAppsToCliOptions(projectRoot, projectName, appName) {
|
|
176
|
+
const rootPath = (0, core_1.join)(projectRoot, projectName);
|
|
177
|
+
const project = {
|
|
178
|
+
type: defaults_1.PROJECT_TYPE.APPLICATION,
|
|
179
|
+
root: rootPath,
|
|
180
|
+
entryFile: 'main',
|
|
181
|
+
sourceRoot: (0, core_1.join)(rootPath, defaults_1.DEFAULT_PATH_NAME),
|
|
182
|
+
compilerOptions: {
|
|
183
|
+
tsConfigPath: (0, core_1.join)(rootPath, 'tsconfig.app.json'),
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
return (host) => {
|
|
187
|
+
const nestFileExists = host.exists('nest.json');
|
|
188
|
+
let nestCliFileExists = host.exists('nest-cli.json');
|
|
189
|
+
if (!nestCliFileExists && !nestFileExists) {
|
|
190
|
+
host.create('nest-cli.json', '{}');
|
|
191
|
+
nestCliFileExists = true;
|
|
192
|
+
}
|
|
193
|
+
return updateJsonFile(host, nestCliFileExists ? 'nest-cli.json' : 'nest.json', (optionsFile) => {
|
|
194
|
+
updateMainAppOptions(optionsFile, projectRoot, appName);
|
|
195
|
+
if (!optionsFile.projects) {
|
|
196
|
+
optionsFile.projects = {};
|
|
197
|
+
}
|
|
198
|
+
if (optionsFile.projects[projectName]) {
|
|
199
|
+
throw new schematics_1.SchematicsException(`Project "${projectName}" exists in this workspace already.`);
|
|
200
|
+
}
|
|
201
|
+
optionsFile.projects[projectName] = project;
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function updateMainAppOptions(optionsFile, projectRoot, appName) {
|
|
206
|
+
if (optionsFile.monorepo) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const rootFilePath = (0, core_1.join)(projectRoot, appName);
|
|
210
|
+
const tsConfigPath = (0, core_1.join)(rootFilePath, 'tsconfig.app.json');
|
|
211
|
+
optionsFile.monorepo = true;
|
|
212
|
+
optionsFile.root = rootFilePath;
|
|
213
|
+
optionsFile.sourceRoot = (0, core_1.join)(projectRoot, appName, optionsFile.sourceRoot || defaults_1.DEFAULT_PATH_NAME);
|
|
214
|
+
if (!optionsFile.compilerOptions) {
|
|
215
|
+
optionsFile.compilerOptions = {};
|
|
216
|
+
}
|
|
217
|
+
optionsFile.compilerOptions.webpack = true;
|
|
218
|
+
optionsFile.compilerOptions.tsConfigPath = tsConfigPath;
|
|
219
|
+
if (!optionsFile.projects) {
|
|
220
|
+
optionsFile.projects = {};
|
|
221
|
+
}
|
|
222
|
+
optionsFile.projects[appName] = {
|
|
223
|
+
type: defaults_1.PROJECT_TYPE.APPLICATION,
|
|
224
|
+
root: rootFilePath,
|
|
225
|
+
entryFile: optionsFile.entryFile || 'main',
|
|
226
|
+
sourceRoot: (0, core_1.join)(rootFilePath, defaults_1.DEFAULT_PATH_NAME),
|
|
227
|
+
compilerOptions: {
|
|
228
|
+
tsConfigPath,
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function generateWorkspace(options, appName) {
|
|
233
|
+
const path = (0, core_1.join)(options.path, appName);
|
|
234
|
+
return (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./workspace', options.language)), [
|
|
235
|
+
(0, schematics_1.template)(Object.assign(Object.assign(Object.assign({}, core_1.strings), options), { name: appName })),
|
|
236
|
+
(0, schematics_1.move)(path),
|
|
237
|
+
]);
|
|
238
|
+
}
|
|
239
|
+
function generate(options) {
|
|
240
|
+
const path = (0, core_1.join)(options.path, options.name);
|
|
241
|
+
return (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
242
|
+
(0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
243
|
+
(0, schematics_1.move)(path),
|
|
244
|
+
]);
|
|
245
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { UpdateRecorder } from '@angular-devkit/schematics';
|
|
2
|
+
export interface Host {
|
|
3
|
+
write(path: string, content: string): Promise<void>;
|
|
4
|
+
read(path: string): Promise<string>;
|
|
5
|
+
}
|
|
6
|
+
export interface Change {
|
|
7
|
+
apply(host: Host): Promise<void>;
|
|
8
|
+
readonly path: string | null;
|
|
9
|
+
readonly order: number;
|
|
10
|
+
readonly description: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class NoopChange implements Change {
|
|
13
|
+
description: string;
|
|
14
|
+
order: number;
|
|
15
|
+
path: any;
|
|
16
|
+
apply(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export declare class InsertChange implements Change {
|
|
19
|
+
path: string;
|
|
20
|
+
pos: number;
|
|
21
|
+
toAdd: string;
|
|
22
|
+
order: number;
|
|
23
|
+
description: string;
|
|
24
|
+
constructor(path: string, pos: number, toAdd: string);
|
|
25
|
+
apply(host: Host): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export declare class RemoveChange implements Change {
|
|
28
|
+
path: string;
|
|
29
|
+
private pos;
|
|
30
|
+
toRemove: string;
|
|
31
|
+
order: number;
|
|
32
|
+
description: string;
|
|
33
|
+
constructor(path: string, pos: number, toRemove: string);
|
|
34
|
+
apply(host: Host): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
export declare class ReplaceChange implements Change {
|
|
37
|
+
path: string;
|
|
38
|
+
private pos;
|
|
39
|
+
oldText: string;
|
|
40
|
+
newText: string;
|
|
41
|
+
order: number;
|
|
42
|
+
description: string;
|
|
43
|
+
constructor(path: string, pos: number, oldText: string, newText: string);
|
|
44
|
+
apply(host: Host): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
export declare function applyToUpdateRecorder(recorder: UpdateRecorder, changes: Change[]): void;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyToUpdateRecorder = exports.ReplaceChange = exports.RemoveChange = exports.InsertChange = exports.NoopChange = void 0;
|
|
4
|
+
class NoopChange {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.description = 'No operation.';
|
|
7
|
+
this.order = Infinity;
|
|
8
|
+
this.path = null;
|
|
9
|
+
}
|
|
10
|
+
apply() { return Promise.resolve(); }
|
|
11
|
+
}
|
|
12
|
+
exports.NoopChange = NoopChange;
|
|
13
|
+
class InsertChange {
|
|
14
|
+
constructor(path, pos, toAdd) {
|
|
15
|
+
this.path = path;
|
|
16
|
+
this.pos = pos;
|
|
17
|
+
this.toAdd = toAdd;
|
|
18
|
+
if (pos < 0) {
|
|
19
|
+
throw new Error('Negative positions are invalid');
|
|
20
|
+
}
|
|
21
|
+
this.description = `Inserted ${toAdd} into position ${pos} of ${path}`;
|
|
22
|
+
this.order = pos;
|
|
23
|
+
}
|
|
24
|
+
apply(host) {
|
|
25
|
+
return host.read(this.path).then(content => {
|
|
26
|
+
const prefix = content.substring(0, this.pos);
|
|
27
|
+
const suffix = content.substring(this.pos);
|
|
28
|
+
return host.write(this.path, `${prefix}${this.toAdd}${suffix}`);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.InsertChange = InsertChange;
|
|
33
|
+
class RemoveChange {
|
|
34
|
+
constructor(path, pos, toRemove) {
|
|
35
|
+
this.path = path;
|
|
36
|
+
this.pos = pos;
|
|
37
|
+
this.toRemove = toRemove;
|
|
38
|
+
if (pos < 0) {
|
|
39
|
+
throw new Error('Negative positions are invalid');
|
|
40
|
+
}
|
|
41
|
+
this.description = `Removed ${toRemove} into position ${pos} of ${path}`;
|
|
42
|
+
this.order = pos;
|
|
43
|
+
}
|
|
44
|
+
apply(host) {
|
|
45
|
+
return host.read(this.path).then(content => {
|
|
46
|
+
const prefix = content.substring(0, this.pos);
|
|
47
|
+
const suffix = content.substring(this.pos + this.toRemove.length);
|
|
48
|
+
return host.write(this.path, `${prefix}${suffix}`);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.RemoveChange = RemoveChange;
|
|
53
|
+
class ReplaceChange {
|
|
54
|
+
constructor(path, pos, oldText, newText) {
|
|
55
|
+
this.path = path;
|
|
56
|
+
this.pos = pos;
|
|
57
|
+
this.oldText = oldText;
|
|
58
|
+
this.newText = newText;
|
|
59
|
+
if (pos < 0) {
|
|
60
|
+
throw new Error('Negative positions are invalid');
|
|
61
|
+
}
|
|
62
|
+
this.description = `Replaced ${oldText} into position ${pos} of ${path} with ${newText}`;
|
|
63
|
+
this.order = pos;
|
|
64
|
+
}
|
|
65
|
+
apply(host) {
|
|
66
|
+
return host.read(this.path).then(content => {
|
|
67
|
+
const prefix = content.substring(0, this.pos);
|
|
68
|
+
const suffix = content.substring(this.pos + this.oldText.length);
|
|
69
|
+
const text = content.substring(this.pos, this.pos + this.oldText.length);
|
|
70
|
+
if (text !== this.oldText) {
|
|
71
|
+
return Promise.reject(new Error(`Invalid replace: "${text}" != "${this.oldText}".`));
|
|
72
|
+
}
|
|
73
|
+
return host.write(this.path, `${prefix}${this.newText}${suffix}`);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.ReplaceChange = ReplaceChange;
|
|
78
|
+
function applyToUpdateRecorder(recorder, changes) {
|
|
79
|
+
for (const change of changes) {
|
|
80
|
+
if (change instanceof InsertChange) {
|
|
81
|
+
recorder.insertLeft(change.pos, change.toAdd);
|
|
82
|
+
}
|
|
83
|
+
else if (change instanceof RemoveChange) {
|
|
84
|
+
recorder.remove(change.order, change.toRemove.length);
|
|
85
|
+
}
|
|
86
|
+
else if (change instanceof ReplaceChange) {
|
|
87
|
+
recorder.remove(change.order, change.oldText.length);
|
|
88
|
+
recorder.insertLeft(change.order, change.newText);
|
|
89
|
+
}
|
|
90
|
+
else if (!(change instanceof NoopChange)) {
|
|
91
|
+
throw new Error('Unknown Change type encountered when updating a recorder.');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.applyToUpdateRecorder = applyToUpdateRecorder;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Tree } from '@angular-devkit/schematics';
|
|
2
|
+
export declare enum NodeDependencyType {
|
|
3
|
+
Default = "dependencies",
|
|
4
|
+
Dev = "devDependencies",
|
|
5
|
+
Peer = "peerDependencies",
|
|
6
|
+
Optional = "optionalDependencies"
|
|
7
|
+
}
|
|
8
|
+
export interface NodeDependency {
|
|
9
|
+
type: NodeDependencyType;
|
|
10
|
+
name: string;
|
|
11
|
+
version: string;
|
|
12
|
+
overwrite?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function addPackageJsonDependency(tree: Tree, dependency: NodeDependency, pkgJsonPath?: string): void;
|
|
15
|
+
export declare function getPackageJsonDependency(tree: Tree, name: string, pkgJsonPath?: string): NodeDependency | null;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPackageJsonDependency = exports.addPackageJsonDependency = exports.NodeDependencyType = void 0;
|
|
4
|
+
const json_file_util_1 = require("./json-file.util");
|
|
5
|
+
const PKG_JSON_PATH = '/package.json';
|
|
6
|
+
var NodeDependencyType;
|
|
7
|
+
(function (NodeDependencyType) {
|
|
8
|
+
NodeDependencyType["Default"] = "dependencies";
|
|
9
|
+
NodeDependencyType["Dev"] = "devDependencies";
|
|
10
|
+
NodeDependencyType["Peer"] = "peerDependencies";
|
|
11
|
+
NodeDependencyType["Optional"] = "optionalDependencies";
|
|
12
|
+
})(NodeDependencyType = exports.NodeDependencyType || (exports.NodeDependencyType = {}));
|
|
13
|
+
const ALL_DEPENDENCY_TYPE = [
|
|
14
|
+
NodeDependencyType.Default,
|
|
15
|
+
NodeDependencyType.Dev,
|
|
16
|
+
NodeDependencyType.Optional,
|
|
17
|
+
NodeDependencyType.Peer,
|
|
18
|
+
];
|
|
19
|
+
function addPackageJsonDependency(tree, dependency, pkgJsonPath = PKG_JSON_PATH) {
|
|
20
|
+
const json = new json_file_util_1.JSONFile(tree, pkgJsonPath);
|
|
21
|
+
const { overwrite, type, name, version } = dependency;
|
|
22
|
+
const path = [type, name];
|
|
23
|
+
if (overwrite || !json.get(path)) {
|
|
24
|
+
json.modify(path, version);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.addPackageJsonDependency = addPackageJsonDependency;
|
|
28
|
+
function getPackageJsonDependency(tree, name, pkgJsonPath = PKG_JSON_PATH) {
|
|
29
|
+
const json = new json_file_util_1.JSONFile(tree, pkgJsonPath);
|
|
30
|
+
for (const depType of ALL_DEPENDENCY_TYPE) {
|
|
31
|
+
const version = json.get([depType, name]);
|
|
32
|
+
if (typeof version === 'string') {
|
|
33
|
+
return {
|
|
34
|
+
type: depType,
|
|
35
|
+
name: name,
|
|
36
|
+
version,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
exports.getPackageJsonDependency = getPackageJsonDependency;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DeclarationOptions } from './module.declarator';
|
|
2
|
+
import { PathSolver } from './path.solver';
|
|
3
|
+
export declare class ExportFromDeclarator {
|
|
4
|
+
private solver;
|
|
5
|
+
constructor(solver?: PathSolver);
|
|
6
|
+
declare(content: string, options: DeclarationOptions): string;
|
|
7
|
+
private findImportsEndpoint;
|
|
8
|
+
private buildLineToInsert;
|
|
9
|
+
private computeRelativePath;
|
|
10
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExportFromDeclarator = void 0;
|
|
4
|
+
const core_1 = require("@angular-devkit/core");
|
|
5
|
+
const path_solver_1 = require("./path.solver");
|
|
6
|
+
class ExportFromDeclarator {
|
|
7
|
+
constructor(solver = new path_solver_1.PathSolver()) {
|
|
8
|
+
this.solver = solver;
|
|
9
|
+
}
|
|
10
|
+
declare(content, options) {
|
|
11
|
+
const toInsert = this.buildLineToInsert(options);
|
|
12
|
+
const contentLines = content.split('\n');
|
|
13
|
+
const finalImportIndex = this.findImportsEndpoint(contentLines);
|
|
14
|
+
contentLines.splice(finalImportIndex + 1, 0, toInsert);
|
|
15
|
+
return contentLines.join('\n');
|
|
16
|
+
}
|
|
17
|
+
findImportsEndpoint(contentLines) {
|
|
18
|
+
const reversedContent = Array.from(contentLines).reverse();
|
|
19
|
+
const reverseImports = reversedContent.filter(line => line.match(/\} from ('|")/));
|
|
20
|
+
if (reverseImports.length <= 0) {
|
|
21
|
+
return -1;
|
|
22
|
+
}
|
|
23
|
+
return contentLines.indexOf(reverseImports[0]);
|
|
24
|
+
}
|
|
25
|
+
buildLineToInsert(options) {
|
|
26
|
+
return `export * from '${this.computeRelativePath(options)}';`;
|
|
27
|
+
}
|
|
28
|
+
computeRelativePath(options) {
|
|
29
|
+
let importModulePath;
|
|
30
|
+
if (options.type !== undefined) {
|
|
31
|
+
importModulePath = (0, core_1.normalize)(`/${options.path}/${options.name}.${options.type}`);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
importModulePath = (0, core_1.normalize)(`/${options.path}/${options.name}`);
|
|
35
|
+
}
|
|
36
|
+
return this.solver.relative(options.module, importModulePath);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.ExportFromDeclarator = ExportFromDeclarator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function normalizeToKebabOrSnakeCase(str: string): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeToKebabOrSnakeCase = void 0;
|
|
4
|
+
function normalizeToKebabOrSnakeCase(str) {
|
|
5
|
+
const STRING_DASHERIZE_REGEXP = /\s/g;
|
|
6
|
+
const STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g;
|
|
7
|
+
return str
|
|
8
|
+
.replace(STRING_DECAMELIZE_REGEXP, '$1-$2')
|
|
9
|
+
.toLowerCase()
|
|
10
|
+
.replace(STRING_DASHERIZE_REGEXP, '-');
|
|
11
|
+
}
|
|
12
|
+
exports.normalizeToKebabOrSnakeCase = normalizeToKebabOrSnakeCase;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './metadata.manager';
|
|
2
|
+
export * from './module-import.declarator';
|
|
3
|
+
export * from './module-metadata.declarator';
|
|
4
|
+
export * from './module.declarator';
|
|
5
|
+
export * from './module.finder';
|
|
6
|
+
export * from './name.parser';
|
|
7
|
+
export * from './path.solver';
|
|
8
|
+
export * from './source-root.helpers';
|
|
9
|
+
export * from './export-from.declarator';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./metadata.manager"), exports);
|
|
18
|
+
__exportStar(require("./module-import.declarator"), exports);
|
|
19
|
+
__exportStar(require("./module-metadata.declarator"), exports);
|
|
20
|
+
__exportStar(require("./module.declarator"), exports);
|
|
21
|
+
__exportStar(require("./module.finder"), exports);
|
|
22
|
+
__exportStar(require("./name.parser"), exports);
|
|
23
|
+
__exportStar(require("./path.solver"), exports);
|
|
24
|
+
__exportStar(require("./source-root.helpers"), exports);
|
|
25
|
+
__exportStar(require("./export-from.declarator"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { JsonValue } from '@angular-devkit/core';
|
|
2
|
+
import { Tree } from '@angular-devkit/schematics';
|
|
3
|
+
export declare type InsertionIndex = (properties: string[]) => number;
|
|
4
|
+
export declare type JSONPath = (string | number)[];
|
|
5
|
+
export declare class JSONFile {
|
|
6
|
+
private readonly host;
|
|
7
|
+
private readonly path;
|
|
8
|
+
content: string;
|
|
9
|
+
constructor(host: Tree, path: string);
|
|
10
|
+
private _jsonAst;
|
|
11
|
+
private get JsonAst();
|
|
12
|
+
get(jsonPath: JSONPath): unknown;
|
|
13
|
+
modify(jsonPath: JSONPath, value: JsonValue | undefined, insertInOrder?: InsertionIndex | false): void;
|
|
14
|
+
remove(jsonPath: JSONPath): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JSONFile = void 0;
|
|
4
|
+
const jsonc_parser_1 = require("jsonc-parser");
|
|
5
|
+
class JSONFile {
|
|
6
|
+
constructor(host, path) {
|
|
7
|
+
this.host = host;
|
|
8
|
+
this.path = path;
|
|
9
|
+
const buffer = this.host.read(this.path);
|
|
10
|
+
if (buffer) {
|
|
11
|
+
this.content = buffer.toString();
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
throw new Error(`Could not read '${path}'.`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
get JsonAst() {
|
|
18
|
+
if (this._jsonAst) {
|
|
19
|
+
return this._jsonAst;
|
|
20
|
+
}
|
|
21
|
+
const errors = [];
|
|
22
|
+
this._jsonAst = (0, jsonc_parser_1.parseTree)(this.content, errors, {
|
|
23
|
+
allowTrailingComma: true,
|
|
24
|
+
});
|
|
25
|
+
if (errors.length) {
|
|
26
|
+
const { error, offset } = errors[0];
|
|
27
|
+
throw new Error(`Failed to parse "${this.path}" as JSON AST Object. ${(0, jsonc_parser_1.printParseErrorCode)(error)} at location: ${offset}.`);
|
|
28
|
+
}
|
|
29
|
+
return this._jsonAst;
|
|
30
|
+
}
|
|
31
|
+
get(jsonPath) {
|
|
32
|
+
const jsonAstNode = this.JsonAst;
|
|
33
|
+
if (!jsonAstNode) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
if (jsonPath.length === 0) {
|
|
37
|
+
return (0, jsonc_parser_1.getNodeValue)(jsonAstNode);
|
|
38
|
+
}
|
|
39
|
+
const node = (0, jsonc_parser_1.findNodeAtLocation)(jsonAstNode, jsonPath);
|
|
40
|
+
return node === undefined ? undefined : (0, jsonc_parser_1.getNodeValue)(node);
|
|
41
|
+
}
|
|
42
|
+
modify(jsonPath, value, insertInOrder) {
|
|
43
|
+
let getInsertionIndex;
|
|
44
|
+
if (insertInOrder === undefined) {
|
|
45
|
+
const property = jsonPath.slice(-1)[0];
|
|
46
|
+
getInsertionIndex = (properties) => [...properties, property].sort().findIndex((p) => p === property);
|
|
47
|
+
}
|
|
48
|
+
else if (insertInOrder !== false) {
|
|
49
|
+
getInsertionIndex = insertInOrder;
|
|
50
|
+
}
|
|
51
|
+
const edits = (0, jsonc_parser_1.modify)(this.content, jsonPath, value, {
|
|
52
|
+
getInsertionIndex,
|
|
53
|
+
formattingOptions: {
|
|
54
|
+
insertSpaces: true,
|
|
55
|
+
tabSize: 2,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
this.content = (0, jsonc_parser_1.applyEdits)(this.content, edits);
|
|
59
|
+
this.host.overwrite(this.path, this.content);
|
|
60
|
+
this._jsonAst = undefined;
|
|
61
|
+
}
|
|
62
|
+
remove(jsonPath) {
|
|
63
|
+
if (this.get(jsonPath) !== undefined) {
|
|
64
|
+
this.modify(jsonPath, undefined);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.JSONFile = JSONFile;
|