@ng-zen/cli 19.3.0 → 19.4.0-next.1

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +1 -1
  3. package/schematics/collection.json +5 -0
  4. package/schematics/components/components-generator.js.map +1 -1
  5. package/schematics/components/components-generator.ts +10 -1
  6. package/schematics/components/files/icon/icon.component.ts +35 -0
  7. package/schematics/components/files/icon/icon.stories.ts +21 -0
  8. package/schematics/components/files/icon/index.ts +1 -0
  9. package/schematics/components/index.js +1 -1
  10. package/schematics/components/index.js.map +1 -1
  11. package/schematics/components/index.ts +2 -2
  12. package/schematics/components/schema.json +1 -1
  13. package/schematics/dependency-manager/dependencies.constant.js +12 -0
  14. package/schematics/dependency-manager/dependencies.constant.js.map +1 -0
  15. package/schematics/dependency-manager/dependencies.constant.ts +10 -0
  16. package/schematics/dependency-manager/index.js +24 -0
  17. package/schematics/dependency-manager/index.js.map +1 -0
  18. package/schematics/dependency-manager/index.ts +27 -0
  19. package/schematics/dependency-manager/schema.json +12 -0
  20. package/schematics/dependency-manager/utils/get-dependencies.js +26 -0
  21. package/schematics/dependency-manager/utils/get-dependencies.js.map +1 -0
  22. package/schematics/dependency-manager/utils/get-dependencies.ts +31 -0
  23. package/services/selected-elements.js +6 -0
  24. package/services/selected-elements.js.map +1 -0
  25. package/services/selected-elements.ts +4 -0
  26. package/types/{schematics-folder.type.js → files-config.js} +1 -1
  27. package/types/files-config.js.map +1 -0
  28. package/types/files-config.ts +7 -0
  29. package/types/{generator-schema-base.interface.js → generator-schema-base.js} +1 -1
  30. package/types/generator-schema-base.js.map +1 -0
  31. package/types/index.js +3 -1
  32. package/types/index.js.map +1 -1
  33. package/types/index.ts +3 -1
  34. package/types/schematics-folder.js +3 -0
  35. package/types/schematics-folder.js.map +1 -0
  36. package/utils/apply-file-template.util.js +2 -0
  37. package/utils/apply-file-template.util.js.map +1 -1
  38. package/utils/apply-file-template.util.ts +3 -2
  39. package/types/generator-schema-base.interface.js.map +0 -1
  40. package/types/schematics-folder.type.js.map +0 -1
  41. /package/types/{generator-schema-base.interface.ts → generator-schema-base.ts} +0 -0
  42. /package/types/{schematics-folder.type.ts → schematics-folder.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [19.4.0-next.1](https://github.com/kstepien3/ng-zen/compare/v19.3.0...v19.4.0-next.1) (2025-06-22)
2
+
3
+ ### 🚀 New Features
4
+
5
+ * **dependency-manager:** add prompt for necessary dependencies ([#221](https://github.com/kstepien3/ng-zen/issues/221)) ([4fd4984](https://github.com/kstepien3/ng-zen/commit/4fd4984cfc52f96b5f915bbc4550185125792c50))
6
+ * **icon:** add component ([#215](https://github.com/kstepien3/ng-zen/issues/215)) ([61d93ad](https://github.com/kstepien3/ng-zen/commit/61d93ad67022f465e77e71c4dcf465aaf5ab0648))
7
+
1
8
  ## [19.3.0](https://github.com/kstepien3/ng-zen/compare/v19.2.0...v19.3.0) (2025-06-12)
2
9
 
3
10
  ### 🚀 New Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-zen/cli",
3
- "version": "19.3.0",
3
+ "version": "19.4.0-next.1",
4
4
  "description": "A CLI tool for generating customizable, modern Angular UI components using schematics.",
5
5
  "license": "BSD-2-Clause",
6
6
  "private": false,
@@ -11,6 +11,11 @@
11
11
  "factory": "./components/index#componentGenerator",
12
12
  "schema": "./components/schema.json",
13
13
  "aliases": ["c"]
14
+ },
15
+ "dependency-manager": {
16
+ "description": "Manage dependencies for selected elements",
17
+ "factory": "./dependency-manager/index#dependencyManager",
18
+ "schema": "./dependency-manager/schema.json"
14
19
  }
15
20
  }
16
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"components-generator.js","sourceRoot":"","sources":["../../../../../src/schematics/components/components-generator.ts"],"names":[],"mappings":"","sourcesContent":["import { GeneratorSchemaBase } from '../../types';\n\nexport type ComponentType = 'avatar' | 'button' | 'checkbox' | 'divider' | 'input' | 'skeleton' | 'switch' | 'textarea';\n\nexport interface ComponentGeneratorSchema extends GeneratorSchemaBase {\n components: ComponentType[];\n}\n"]}
1
+ {"version":3,"file":"components-generator.js","sourceRoot":"","sources":["../../../../../src/schematics/components/components-generator.ts"],"names":[],"mappings":"","sourcesContent":["import { GeneratorSchemaBase } from '../../types';\n\nexport type ComponentType =\n | 'avatar'\n | 'button'\n | 'checkbox'\n | 'divider'\n | 'icon'\n | 'input'\n | 'skeleton'\n | 'switch'\n | 'textarea';\n\nexport interface ComponentGeneratorSchema extends GeneratorSchemaBase {\n components: ComponentType[];\n}\n"]}
@@ -1,6 +1,15 @@
1
1
  import { GeneratorSchemaBase } from '../../types';
2
2
 
3
- export type ComponentType = 'avatar' | 'button' | 'checkbox' | 'divider' | 'input' | 'skeleton' | 'switch' | 'textarea';
3
+ export type ComponentType =
4
+ | 'avatar'
5
+ | 'button'
6
+ | 'checkbox'
7
+ | 'divider'
8
+ | 'icon'
9
+ | 'input'
10
+ | 'skeleton'
11
+ | 'switch'
12
+ | 'textarea';
4
13
 
5
14
  export interface ComponentGeneratorSchema extends GeneratorSchemaBase {
6
15
  components: ComponentType[];
@@ -0,0 +1,35 @@
1
+ import { ChangeDetectionStrategy, Component, input } from '@angular/core';
2
+ import { HugeiconsIconComponent } from '@hugeicons/angular';
3
+ import * as icons from '@hugeicons/core-free-icons';
4
+
5
+ type Icon = keyof typeof icons;
6
+
7
+ /**
8
+ * A reusable Angular component for rendering icons from the Hugeicons library.
9
+ *
10
+ * This component acts as a wrapper around the `<hugeicons-icon>` component, allowing you to display any icon from the
11
+ * `@hugeicons/core-free-icons` collection by specifying its name. The icon, size, and stroke width are fully configurable
12
+ * via inputs.
13
+ *
14
+ * @example
15
+ * <zen-icon icon="Tree02Icon" />
16
+ *
17
+ * @author Konrad Stępień
18
+ * @license {@link https://github.com/kstepien3/ng-zen/blob/master/LICENSE|BSD-2-Clause}
19
+ * @see [GitHub](https://github.com/kstepien3/ng-zen)
20
+ * @see [Hugeicons](https://hugeicons.com)
21
+ */
22
+ @Component({
23
+ selector: 'zen-icon',
24
+ template: `
25
+ <hugeicons-icon [icon]="icon()" [size]="size()" [strokeWidth]="strokeWidth()" color="currentColor" />
26
+ `,
27
+ imports: [HugeiconsIconComponent],
28
+ changeDetection: ChangeDetectionStrategy.OnPush,
29
+ })
30
+ export class ZenIconComponent {
31
+ /** Icon file names from HugeIcons */
32
+ readonly icon = input.required({ transform: (icon: Icon) => icons[icon] });
33
+ readonly size = input<number>(24);
34
+ readonly strokeWidth = input<number>(1.5);
35
+ }
@@ -0,0 +1,21 @@
1
+ import { Meta, StoryObj } from '@storybook/angular';
2
+
3
+ import { ZenIconComponent } from './icon.component';
4
+
5
+ type Options = ZenIconComponent;
6
+
7
+ export default {
8
+ title: 'Components/Icon',
9
+ component: ZenIconComponent,
10
+ tags: ['autodocs'],
11
+ } satisfies Meta<Options>;
12
+
13
+ type Story = StoryObj<Options>;
14
+
15
+ export const Default: Story = {
16
+ render: () => ({
17
+ template: `
18
+ <zen-icon icon="Tree02Icon" [size]="64"/>
19
+ `,
20
+ }),
21
+ };
@@ -0,0 +1 @@
1
+ export * from './icon.component';
@@ -5,7 +5,7 @@ const schematics_1 = require("@angular-devkit/schematics");
5
5
  const utils_1 = require("../../utils");
6
6
  function componentGenerator({ components, ...config }) {
7
7
  return () => {
8
- return (0, schematics_1.chain)((0, utils_1.applyFileTemplateUtil)(components, config));
8
+ return (0, schematics_1.chain)([...(0, utils_1.applyFileTemplateUtil)(components, config), (0, schematics_1.schematic)('dependency-manager', {})]);
9
9
  };
10
10
  }
11
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/schematics/components/index.ts"],"names":[],"mappings":";;AAKA,gDAIC;AATD,2DAAyD;AAEzD,uCAAoD;AAGpD,SAAgB,kBAAkB,CAAC,EAAE,UAAU,EAAE,GAAG,MAAM,EAA4B;IACpF,OAAO,GAAG,EAAE;QACV,OAAO,IAAA,kBAAK,EAAC,IAAA,6BAAqB,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { chain, Rule } from '@angular-devkit/schematics';\n\nimport { applyFileTemplateUtil } from '../../utils';\nimport { ComponentGeneratorSchema } from './components-generator';\n\nexport function componentGenerator({ components, ...config }: ComponentGeneratorSchema): Rule {\n return () => {\n return chain(applyFileTemplateUtil(components, config));\n };\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/schematics/components/index.ts"],"names":[],"mappings":";;AAKA,gDAIC;AATD,2DAAoE;AAEpE,uCAAoD;AAGpD,SAAgB,kBAAkB,CAAC,EAAE,UAAU,EAAE,GAAG,MAAM,EAA4B;IACpF,OAAO,GAAG,EAAE;QACV,OAAO,IAAA,kBAAK,EAAC,CAAC,GAAG,IAAA,6BAAqB,EAAC,UAAU,EAAE,MAAM,CAAC,EAAE,IAAA,sBAAS,EAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACpG,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { chain, Rule, schematic } from '@angular-devkit/schematics';\n\nimport { applyFileTemplateUtil } from '../../utils';\nimport { ComponentGeneratorSchema } from './components-generator';\n\nexport function componentGenerator({ components, ...config }: ComponentGeneratorSchema): Rule {\n return () => {\n return chain([...applyFileTemplateUtil(components, config), schematic('dependency-manager', {})]);\n };\n}\n"]}
@@ -1,10 +1,10 @@
1
- import { chain, Rule } from '@angular-devkit/schematics';
1
+ import { chain, Rule, schematic } from '@angular-devkit/schematics';
2
2
 
3
3
  import { applyFileTemplateUtil } from '../../utils';
4
4
  import { ComponentGeneratorSchema } from './components-generator';
5
5
 
6
6
  export function componentGenerator({ components, ...config }: ComponentGeneratorSchema): Rule {
7
7
  return () => {
8
- return chain(applyFileTemplateUtil(components, config));
8
+ return chain([...applyFileTemplateUtil(components, config), schematic('dependency-manager', {})]);
9
9
  };
10
10
  }
@@ -10,7 +10,7 @@
10
10
  "type": "array",
11
11
  "items": {
12
12
  "type": "string",
13
- "enum": ["avatar", "button", "checkbox", "divider", "input", "skeleton", "switch", "textarea"]
13
+ "enum": ["avatar", "button", "checkbox", "divider", "icon", "input", "skeleton", "switch", "textarea"]
14
14
  },
15
15
  "multiselect": true,
16
16
  "x-prompt": "Which component should be generated?"
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEPENDENCIES_CONFIG = void 0;
4
+ exports.DEPENDENCIES_CONFIG = {
5
+ icon: {
6
+ dependencies: {
7
+ '@hugeicons/angular': 'latest',
8
+ '@hugeicons/core-free-icons': 'latest',
9
+ },
10
+ },
11
+ };
12
+ //# sourceMappingURL=dependencies.constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencies.constant.js","sourceRoot":"","sources":["../../../../../src/schematics/dependency-manager/dependencies.constant.ts"],"names":[],"mappings":";;;AAEa,QAAA,mBAAmB,GAAyB;IACvD,IAAI,EAAE;QACJ,YAAY,EAAE;YACZ,oBAAoB,EAAE,QAAQ;YAC9B,4BAA4B,EAAE,QAAQ;SACvC;KACF;CACF,CAAC","sourcesContent":["import { FilesConfig } from '../../types';\n\nexport const DEPENDENCIES_CONFIG: Partial<FilesConfig> = {\n icon: {\n dependencies: {\n '@hugeicons/angular': 'latest',\n '@hugeicons/core-free-icons': 'latest',\n },\n },\n};\n"]}
@@ -0,0 +1,10 @@
1
+ import { FilesConfig } from '../../types';
2
+
3
+ export const DEPENDENCIES_CONFIG: Partial<FilesConfig> = {
4
+ icon: {
5
+ dependencies: {
6
+ '@hugeicons/angular': 'latest',
7
+ '@hugeicons/core-free-icons': 'latest',
8
+ },
9
+ },
10
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dependencyManager = dependencyManager;
4
+ const tasks_1 = require("@angular-devkit/schematics/tasks");
5
+ const dependencies_1 = require("@schematics/angular/utility/dependencies");
6
+ const selected_elements_1 = require("../../services/selected-elements");
7
+ const dependencies_constant_1 = require("./dependencies.constant");
8
+ const get_dependencies_1 = require("./utils/get-dependencies");
9
+ function dependencyManager() {
10
+ return (tree, context) => {
11
+ const dependenciesToInstall = (0, get_dependencies_1.getDependencies)(selected_elements_1.selectedElements, dependencies_constant_1.DEPENDENCIES_CONFIG);
12
+ if (!dependenciesToInstall.length) {
13
+ context.logger.info('✅ No dependencies to install for the selected components.');
14
+ return tree;
15
+ }
16
+ context.logger.info(`📦 Installing ${dependenciesToInstall.length} dependencies...`);
17
+ for (const dependency of dependenciesToInstall) {
18
+ (0, dependencies_1.addPackageJsonDependency)(tree, dependency);
19
+ }
20
+ context.addTask(new tasks_1.NodePackageInstallTask());
21
+ return tree;
22
+ };
23
+ }
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/schematics/dependency-manager/index.ts"],"names":[],"mappings":";;AAQA,8CAkBC;AAzBD,4DAA0E;AAC1E,2EAAoG;AAEpG,wEAAoE;AACpE,mEAA8D;AAC9D,+DAA2D;AAE3D,SAAgB,iBAAiB;IAC/B,OAAO,CAAC,IAAU,EAAE,OAAO,EAAE,EAAE;QAC7B,MAAM,qBAAqB,GAAqB,IAAA,kCAAe,EAAC,oCAAgB,EAAE,2CAAmB,CAAC,CAAC;QAEvG,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,CAAC;YAClC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC;YACjF,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,qBAAqB,CAAC,MAAM,kBAAkB,CAAC,CAAC;QAErF,KAAK,MAAM,UAAU,IAAI,qBAAqB,EAAE,CAAC;YAC/C,IAAA,uCAAwB,EAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,CAAC,OAAO,CAAC,IAAI,8BAAsB,EAAE,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { Rule, Tree } from '@angular-devkit/schematics';\nimport { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';\nimport { addPackageJsonDependency, NodeDependency } from '@schematics/angular/utility/dependencies';\n\nimport { selectedElements } from '../../services/selected-elements';\nimport { DEPENDENCIES_CONFIG } from './dependencies.constant';\nimport { getDependencies } from './utils/get-dependencies';\n\nexport function dependencyManager(): Rule {\n return (tree: Tree, context) => {\n const dependenciesToInstall: NodeDependency[] = getDependencies(selectedElements, DEPENDENCIES_CONFIG);\n\n if (!dependenciesToInstall.length) {\n context.logger.info('✅ No dependencies to install for the selected components.');\n return tree;\n }\n\n context.logger.info(`📦 Installing ${dependenciesToInstall.length} dependencies...`);\n\n for (const dependency of dependenciesToInstall) {\n addPackageJsonDependency(tree, dependency);\n }\n\n context.addTask(new NodePackageInstallTask());\n return tree;\n };\n}\n"]}
@@ -0,0 +1,27 @@
1
+ import { Rule, Tree } from '@angular-devkit/schematics';
2
+ import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
3
+ import { addPackageJsonDependency, NodeDependency } from '@schematics/angular/utility/dependencies';
4
+
5
+ import { selectedElements } from '../../services/selected-elements';
6
+ import { DEPENDENCIES_CONFIG } from './dependencies.constant';
7
+ import { getDependencies } from './utils/get-dependencies';
8
+
9
+ export function dependencyManager(): Rule {
10
+ return (tree: Tree, context) => {
11
+ const dependenciesToInstall: NodeDependency[] = getDependencies(selectedElements, DEPENDENCIES_CONFIG);
12
+
13
+ if (!dependenciesToInstall.length) {
14
+ context.logger.info('✅ No dependencies to install for the selected components.');
15
+ return tree;
16
+ }
17
+
18
+ context.logger.info(`📦 Installing ${dependenciesToInstall.length} dependencies...`);
19
+
20
+ for (const dependency of dependenciesToInstall) {
21
+ addPackageJsonDependency(tree, dependency);
22
+ }
23
+
24
+ context.addTask(new NodePackageInstallTask());
25
+ return tree;
26
+ };
27
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "NgZenDependencyManager",
4
+ "title": "NgZen Dependency Manager",
5
+ "properties": {
6
+ "installation": {
7
+ "type": "boolean",
8
+ "x-prompt": "Some elements require additional packages. Would you like to install them?",
9
+ "description": "Determines whether the required additional npm packages for the selected elements should be installed automatically."
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDependencies = getDependencies;
4
+ const dependencies_1 = require("@schematics/angular/utility/dependencies");
5
+ function getDependencies(selectedElements, dependenciesConfig) {
6
+ const dependencies = [];
7
+ for (const component of selectedElements) {
8
+ if (!dependenciesConfig[component])
9
+ continue;
10
+ for (const type of Object.values(dependencies_1.NodeDependencyType)) {
11
+ const typeDeps = dependenciesConfig[component][type];
12
+ if (!typeDeps)
13
+ continue;
14
+ for (const [name, version] of Object.entries(typeDeps)) {
15
+ dependencies.push({
16
+ type,
17
+ name,
18
+ version,
19
+ overwrite: false,
20
+ });
21
+ }
22
+ }
23
+ }
24
+ return dependencies;
25
+ }
26
+ //# sourceMappingURL=get-dependencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-dependencies.js","sourceRoot":"","sources":["../../../../../../src/schematics/dependency-manager/utils/get-dependencies.ts"],"names":[],"mappings":";;AAKA,0CAyBC;AA9BD,2EAA8F;AAK9F,SAAgB,eAAe,CAC7B,gBAAiC,EACjC,kBAAwC;IAExC,MAAM,YAAY,GAAqB,EAAE,CAAC;IAE1C,KAAK,MAAM,SAAS,IAAI,gBAAgB,EAAE,CAAC;QACzC,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC;YAAE,SAAS;QAE7C,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,iCAAkB,CAAC,EAAE,CAAC;YACrD,MAAM,QAAQ,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC;YACrD,IAAI,CAAC,QAAQ;gBAAE,SAAS;YAExB,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACvD,YAAY,CAAC,IAAI,CAAC;oBAChB,IAAI;oBACJ,IAAI;oBACJ,OAAO;oBACP,SAAS,EAAE,KAAK;iBACjB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import { NodeDependency, NodeDependencyType } from '@schematics/angular/utility/dependencies';\n\nimport { FilesConfig } from '../../../types';\nimport { ComponentType } from '../../components/components-generator';\n\nexport function getDependencies(\n selectedElements: ComponentType[],\n dependenciesConfig: Partial<FilesConfig>\n): NodeDependency[] {\n const dependencies: NodeDependency[] = [];\n\n for (const component of selectedElements) {\n if (!dependenciesConfig[component]) continue;\n\n for (const type of Object.values(NodeDependencyType)) {\n const typeDeps = dependenciesConfig[component][type];\n if (!typeDeps) continue;\n\n for (const [name, version] of Object.entries(typeDeps)) {\n dependencies.push({\n type,\n name,\n version,\n overwrite: false,\n });\n }\n }\n }\n\n return dependencies;\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import { NodeDependency, NodeDependencyType } from '@schematics/angular/utility/dependencies';
2
+
3
+ import { FilesConfig } from '../../../types';
4
+ import { ComponentType } from '../../components/components-generator';
5
+
6
+ export function getDependencies(
7
+ selectedElements: ComponentType[],
8
+ dependenciesConfig: Partial<FilesConfig>
9
+ ): NodeDependency[] {
10
+ const dependencies: NodeDependency[] = [];
11
+
12
+ for (const component of selectedElements) {
13
+ if (!dependenciesConfig[component]) continue;
14
+
15
+ for (const type of Object.values(NodeDependencyType)) {
16
+ const typeDeps = dependenciesConfig[component][type];
17
+ if (!typeDeps) continue;
18
+
19
+ for (const [name, version] of Object.entries(typeDeps)) {
20
+ dependencies.push({
21
+ type,
22
+ name,
23
+ version,
24
+ overwrite: false,
25
+ });
26
+ }
27
+ }
28
+ }
29
+
30
+ return dependencies;
31
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.selectedElements = void 0;
4
+ // add selected elements to this array, then values are available in other schematics
5
+ exports.selectedElements = [];
6
+ //# sourceMappingURL=selected-elements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selected-elements.js","sourceRoot":"","sources":["../../../../src/services/selected-elements.ts"],"names":[],"mappings":";;;AAEA,qFAAqF;AACxE,QAAA,gBAAgB,GAAoB,EAAE,CAAC","sourcesContent":["import { ComponentType } from '../schematics/components/components-generator';\n\n// add selected elements to this array, then values are available in other schematics\nexport const selectedElements: ComponentType[] = [];\n"]}
@@ -0,0 +1,4 @@
1
+ import { ComponentType } from '../schematics/components/components-generator';
2
+
3
+ // add selected elements to this array, then values are available in other schematics
4
+ export const selectedElements: ComponentType[] = [];
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=schematics-folder.type.js.map
3
+ //# sourceMappingURL=files-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files-config.js","sourceRoot":"","sources":["../../../../src/types/files-config.ts"],"names":[],"mappings":"","sourcesContent":["import { NodeDependencyType } from '@schematics/angular/utility/dependencies';\n\nimport { ComponentType } from '../schematics/components/components-generator';\n\ntype Kind = Record<NodeDependencyType, Record<string, string>>;\n\nexport type FilesConfig = Record<ComponentType, Partial<Kind>>;\n"]}
@@ -0,0 +1,7 @@
1
+ import { NodeDependencyType } from '@schematics/angular/utility/dependencies';
2
+
3
+ import { ComponentType } from '../schematics/components/components-generator';
4
+
5
+ type Kind = Record<NodeDependencyType, Record<string, string>>;
6
+
7
+ export type FilesConfig = Record<ComponentType, Partial<Kind>>;
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=generator-schema-base.interface.js.map
3
+ //# sourceMappingURL=generator-schema-base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator-schema-base.js","sourceRoot":"","sources":["../../../../src/types/generator-schema-base.ts"],"names":[],"mappings":"","sourcesContent":["export interface GeneratorSchemaBase {\n path: string;\n stories: boolean;\n}\n"]}
package/types/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./generator-schema-base.interface"), exports);
4
+ tslib_1.__exportStar(require("./files-config"), exports);
5
+ tslib_1.__exportStar(require("./generator-schema-base"), exports);
6
+ tslib_1.__exportStar(require("./schematics-folder"), exports);
5
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":";;;AAAA,4EAAkD","sourcesContent":["export * from './generator-schema-base.interface';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B;AAC/B,kEAAwC;AACxC,8DAAoC","sourcesContent":["export * from './files-config';\nexport * from './generator-schema-base';\nexport * from './schematics-folder';\n"]}
package/types/index.ts CHANGED
@@ -1 +1,3 @@
1
- export * from './generator-schema-base.interface';
1
+ export * from './files-config';
2
+ export * from './generator-schema-base';
3
+ export * from './schematics-folder';
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schematics-folder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schematics-folder.js","sourceRoot":"","sources":["../../../../src/types/schematics-folder.ts"],"names":[],"mappings":"","sourcesContent":["import { ComponentType } from '../schematics/components/components-generator';\n\nexport type SchematicsFolder = ComponentType;\n"]}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.applyFileTemplateUtil = applyFileTemplateUtil;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const selected_elements_1 = require("../services/selected-elements");
6
7
  const createTemplateRules = (folder, path) => [
7
8
  (0, schematics_1.applyTemplates)({
8
9
  name: folder,
@@ -14,6 +15,7 @@ const createTemplateRules = (folder, path) => [
14
15
  const getTemplates = (rules) => (0, schematics_1.apply)((0, schematics_1.url)(`./templates`), rules);
15
16
  const includeStories = (include) => (0, schematics_1.filter)(filePath => include || !filePath.endsWith('.stories.ts'));
16
17
  function applyFileTemplateUtil(folders, config) {
18
+ selected_elements_1.selectedElements.push(...folders);
17
19
  return folders.map(folder => {
18
20
  const RULES = createTemplateRules(folder, config.path);
19
21
  const folderSource = (0, schematics_1.apply)((0, schematics_1.url)(`./files/${folder}`), [includeStories(config.stories), ...RULES]);
@@ -1 +1 @@
1
- {"version":3,"file":"apply-file-template.util.js","sourceRoot":"","sources":["../../../../src/utils/apply-file-template.util.ts"],"names":[],"mappings":";;AAkBA,sDAQC;AA1BD,+CAA0D;AAC1D,2DAA8G;AAK9G,MAAM,mBAAmB,GAAG,CAAC,MAAc,EAAE,IAAY,EAAU,EAAE,CAAC;IACpE,IAAA,2BAAc,EAAC;QACb,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,cAAc,EAAE;QACvC,GAAG,cAAO;KACX,CAAC;IACF,IAAA,iBAAI,EAAC,IAAA,gBAAS,EAAC,GAAG,IAAI,IAAI,MAAM,EAAE,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,aAAa,CAAC,EAAE,KAAK,CAAC,CAAC;AACzE,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,IAAA,mBAAM,EAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;AAE9G,SAAgB,qBAAqB,CAAC,OAA2B,EAAE,MAA2B;IAC5F,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;QAC1B,MAAM,KAAK,GAAG,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAEvD,MAAM,YAAY,GAAG,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,WAAW,MAAM,EAAE,CAAC,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;QAEjG,OAAO,IAAA,kBAAK,EAAC,CAAC,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,sBAAS,CAAC,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { normalize, strings } from '@angular-devkit/core';\nimport { apply, applyTemplates, chain, filter, mergeWith, move, Rule, url } from '@angular-devkit/schematics';\n\nimport { GeneratorSchemaBase } from '../types';\nimport { SchematicsFolder } from '../types/schematics-folder.type';\n\nconst createTemplateRules = (folder: string, path: string): Rule[] => [\n applyTemplates({\n name: folder,\n localeDate: new Date().toLocaleString(),\n ...strings,\n }),\n move(normalize(`${path}/${folder}`)),\n];\n\nconst getTemplates = (rules: Rule[]) => apply(url(`./templates`), rules);\nconst includeStories = (include: boolean) => filter(filePath => include || !filePath.endsWith('.stories.ts'));\n\nexport function applyFileTemplateUtil(folders: SchematicsFolder[], config: GeneratorSchemaBase): Rule[] {\n return folders.map(folder => {\n const RULES = createTemplateRules(folder, config.path);\n\n const folderSource = apply(url(`./files/${folder}`), [includeStories(config.stories), ...RULES]);\n\n return chain([folderSource, getTemplates(RULES)].map(mergeWith));\n });\n}\n"]}
1
+ {"version":3,"file":"apply-file-template.util.js","sourceRoot":"","sources":["../../../../src/utils/apply-file-template.util.ts"],"names":[],"mappings":";;AAkBA,sDASC;AA3BD,+CAA0D;AAC1D,2DAA8G;AAE9G,qEAAiE;AAGjE,MAAM,mBAAmB,GAAG,CAAC,MAAc,EAAE,IAAY,EAAU,EAAE,CAAC;IACpE,IAAA,2BAAc,EAAC;QACb,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,cAAc,EAAE;QACvC,GAAG,cAAO;KACX,CAAC;IACF,IAAA,iBAAI,EAAC,IAAA,gBAAS,EAAC,GAAG,IAAI,IAAI,MAAM,EAAE,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,aAAa,CAAC,EAAE,KAAK,CAAC,CAAC;AACzE,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,IAAA,mBAAM,EAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;AAE9G,SAAgB,qBAAqB,CAAC,OAA2B,EAAE,MAA2B;IAC5F,oCAAgB,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC;IAClC,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;QAC1B,MAAM,KAAK,GAAG,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAEvD,MAAM,YAAY,GAAG,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,WAAW,MAAM,EAAE,CAAC,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;QAEjG,OAAO,IAAA,kBAAK,EAAC,CAAC,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,sBAAS,CAAC,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { normalize, strings } from '@angular-devkit/core';\nimport { apply, applyTemplates, chain, filter, mergeWith, move, Rule, url } from '@angular-devkit/schematics';\n\nimport { selectedElements } from '../services/selected-elements';\nimport { GeneratorSchemaBase, SchematicsFolder } from '../types';\n\nconst createTemplateRules = (folder: string, path: string): Rule[] => [\n applyTemplates({\n name: folder,\n localeDate: new Date().toLocaleString(),\n ...strings,\n }),\n move(normalize(`${path}/${folder}`)),\n];\n\nconst getTemplates = (rules: Rule[]) => apply(url(`./templates`), rules);\nconst includeStories = (include: boolean) => filter(filePath => include || !filePath.endsWith('.stories.ts'));\n\nexport function applyFileTemplateUtil(folders: SchematicsFolder[], config: GeneratorSchemaBase): Rule[] {\n selectedElements.push(...folders);\n return folders.map(folder => {\n const RULES = createTemplateRules(folder, config.path);\n\n const folderSource = apply(url(`./files/${folder}`), [includeStories(config.stories), ...RULES]);\n\n return chain([folderSource, getTemplates(RULES)].map(mergeWith));\n });\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  import { normalize, strings } from '@angular-devkit/core';
2
2
  import { apply, applyTemplates, chain, filter, mergeWith, move, Rule, url } from '@angular-devkit/schematics';
3
3
 
4
- import { GeneratorSchemaBase } from '../types';
5
- import { SchematicsFolder } from '../types/schematics-folder.type';
4
+ import { selectedElements } from '../services/selected-elements';
5
+ import { GeneratorSchemaBase, SchematicsFolder } from '../types';
6
6
 
7
7
  const createTemplateRules = (folder: string, path: string): Rule[] => [
8
8
  applyTemplates({
@@ -17,6 +17,7 @@ const getTemplates = (rules: Rule[]) => apply(url(`./templates`), rules);
17
17
  const includeStories = (include: boolean) => filter(filePath => include || !filePath.endsWith('.stories.ts'));
18
18
 
19
19
  export function applyFileTemplateUtil(folders: SchematicsFolder[], config: GeneratorSchemaBase): Rule[] {
20
+ selectedElements.push(...folders);
20
21
  return folders.map(folder => {
21
22
  const RULES = createTemplateRules(folder, config.path);
22
23
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"generator-schema-base.interface.js","sourceRoot":"","sources":["../../../../src/types/generator-schema-base.interface.ts"],"names":[],"mappings":"","sourcesContent":["export interface GeneratorSchemaBase {\n path: string;\n stories: boolean;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"schematics-folder.type.js","sourceRoot":"","sources":["../../../../src/types/schematics-folder.type.ts"],"names":[],"mappings":"","sourcesContent":["import { ComponentType } from '../schematics/components/components-generator';\n\nexport type SchematicsFolder = ComponentType;\n"]}