@ng-doc/add 22.0.0-beta.2 → 22.1.0

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 (67) hide show
  1. package/README.md +19 -29
  2. package/package.json +23 -21
  3. package/schematics/collection.json +14 -14
  4. package/schematics/ng-add/constants/modules.d.ts +22 -0
  5. package/schematics/ng-add/constants/modules.js +25 -11
  6. package/schematics/ng-add/constants/modules.js.map +1 -1
  7. package/schematics/ng-add/constants/styles.d.ts +4 -0
  8. package/schematics/ng-add/constants/styles.js +8 -1
  9. package/schematics/ng-add/constants/styles.js.map +1 -1
  10. package/schematics/ng-add/index.d.ts +6 -2
  11. package/schematics/ng-add/index.js +49 -14
  12. package/schematics/ng-add/index.js.map +1 -1
  13. package/schematics/ng-add/schema.d.ts +8 -0
  14. package/schematics/ng-add/schema.json +19 -14
  15. package/schematics/ng-add/steps/add-assets.d.ts +2 -3
  16. package/schematics/ng-add/steps/add-assets.js +11 -5
  17. package/schematics/ng-add/steps/add-assets.js.map +1 -1
  18. package/schematics/ng-add/steps/add-git-ignore.d.ts +1 -3
  19. package/schematics/ng-add/steps/add-git-ignore.js +9 -4
  20. package/schematics/ng-add/steps/add-git-ignore.js.map +1 -1
  21. package/schematics/ng-add/steps/add-js-dependencies.js +2 -1
  22. package/schematics/ng-add/steps/add-js-dependencies.js.map +1 -1
  23. package/schematics/ng-add/steps/add-layout.d.ts +2 -2
  24. package/schematics/ng-add/steps/add-layout.js +9 -3
  25. package/schematics/ng-add/steps/add-layout.js.map +1 -1
  26. package/schematics/ng-add/steps/add-ng-doc-app-config.d.ts +5 -1
  27. package/schematics/ng-add/steps/add-ng-doc-app-config.js +201 -55
  28. package/schematics/ng-add/steps/add-ng-doc-app-config.js.map +1 -1
  29. package/schematics/ng-add/steps/add-styles.js +2 -1
  30. package/schematics/ng-add/steps/add-styles.js.map +1 -1
  31. package/schematics/ng-add/steps/add-tsconfig-paths.js +2 -1
  32. package/schematics/ng-add/steps/add-tsconfig-paths.js.map +1 -1
  33. package/schematics/ng-add/steps/post-install.d.ts +5 -2
  34. package/schematics/ng-add/steps/post-install.js +10 -3
  35. package/schematics/ng-add/steps/post-install.js.map +1 -1
  36. package/schematics/ng-add/steps/raise-initial-budget.d.ts +23 -0
  37. package/schematics/ng-add/steps/raise-initial-budget.js +72 -0
  38. package/schematics/ng-add/steps/raise-initial-budget.js.map +1 -0
  39. package/schematics/ng-add/steps/replace-builders.d.ts +2 -2
  40. package/schematics/ng-add/steps/replace-builders.js +12 -4
  41. package/schematics/ng-add/steps/replace-builders.js.map +1 -1
  42. package/schematics/ng-add/steps/update-app-ts-config.js +2 -1
  43. package/schematics/ng-add/steps/update-app-ts-config.js.map +1 -1
  44. package/schematics/ng-add/utils/add-array-entry.d.ts +56 -0
  45. package/schematics/ng-add/utils/add-array-entry.js +325 -0
  46. package/schematics/ng-add/utils/add-array-entry.js.map +1 -0
  47. package/schematics/ng-add/utils/add-unique-import.d.ts +7 -3
  48. package/schematics/ng-add/utils/add-unique-import.js +21 -16
  49. package/schematics/ng-add/utils/add-unique-import.js.map +1 -1
  50. package/schematics/ng-add/utils/get-app-component.d.ts +4 -3
  51. package/schematics/ng-add/utils/get-app-component.js +7 -5
  52. package/schematics/ng-add/utils/get-app-component.js.map +1 -1
  53. package/schematics/ng-add/utils/get-app-template-path.d.ts +4 -8
  54. package/schematics/ng-add/utils/get-app-template-path.js +4 -4
  55. package/schematics/ng-add/utils/get-app-template-path.js.map +1 -1
  56. package/schematics/ng-add/utils/get-build-options-target.d.ts +18 -0
  57. package/schematics/ng-add/utils/get-build-options-target.js +62 -0
  58. package/schematics/ng-add/utils/get-build-options-target.js.map +1 -0
  59. package/schematics/ng-add/utils/get-main-path.d.ts +12 -2
  60. package/schematics/ng-add/utils/get-main-path.js +35 -3
  61. package/schematics/ng-add/utils/get-main-path.js.map +1 -1
  62. package/schematics/ng-add/utils/get-root-module.d.ts +14 -0
  63. package/schematics/ng-add/utils/get-root-module.js +31 -0
  64. package/schematics/ng-add/utils/get-root-module.js.map +1 -0
  65. package/schematics/ng-add/utils/select-engine.d.ts +58 -0
  66. package/schematics/ng-add/utils/select-engine.js +139 -0
  67. package/schematics/ng-add/utils/select-engine.js.map +1 -0
package/README.md CHANGED
@@ -1,37 +1,27 @@
1
- <!-- PROJECT LOGO -->
2
- <br />
3
- <div align="center">
4
- <a href="https://github.com/ng-doc/ng-doc">
5
- <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px">
6
- </a>
7
-
8
- <h1 align="center" style="margin-bottom: 0; border-bottom: 0">NgDoc</h1>
9
- <p align="center">
10
- Create user-friendly documentation for your projects with ease!
11
- <br />
12
- <a href="https://ng-doc.com/">Documentation</a>
13
- ·
14
- <a href="https://github.com/ng-doc/ng-doc/issues/new/choose">Report Bug</a>
15
- ·
16
- <a href="https://github.com/ng-doc/ng-doc/issues/new/choose">Request Feature</a>
17
-
18
- [![GitHub Workflow Status][build-shield]][build-url]
1
+ # 🪄 @ng-doc/add
2
+
3
+ The `ng add` schematics that install NgDoc and configure your project.
4
+
5
+ It's part of [NgDoc](https://ng-doc.com/) 📚, the documentation engine for Angular projects.
6
+
19
7
  [![NPM][npm-shield]][npm-url]
20
8
  [![MIT License][license-shield]][license-url]
21
9
 
22
- </p>
23
- </div>
10
+ ## 🚀 Getting started
11
+
12
+ Run it in your Angular project to install and configure NgDoc:
24
13
 
25
- <!-- ABOUT THE PROJECT -->
14
+ ```bash
15
+ ng add @ng-doc/add
16
+ ```
26
17
 
27
- ## About The Project
18
+ ## 📖 Learn more
28
19
 
29
- This library is a part of NgDoc project, that uses to create documentation
30
- for Angular projects, please check our [repo](https://github.com/ng-doc/ng-doc) for more details.
20
+ - [Documentation](https://ng-doc.com/)
21
+ - [GitHub repository](https://github.com/ng-doc/ng-doc)
22
+ - [Report a bug or request a feature](https://github.com/ng-doc/ng-doc/issues/new/choose)
31
23
 
32
- [npm-shield]: https://img.shields.io/npm/v/@ng-doc/builder.svg?style=for-the-badge
33
- [npm-url]: https://www.npmjs.com/package/@ng-doc/builder
24
+ [npm-shield]: https://img.shields.io/npm/v/%40ng-doc%2Fadd.svg?style=for-the-badge
25
+ [npm-url]: https://www.npmjs.com/package/@ng-doc/add
34
26
  [license-shield]: https://img.shields.io/github/license/ng-doc/ng-doc.svg?style=for-the-badge
35
- [license-url]: https://github.com/othneildrew/Best-README-Template/blob/master/LICENSE.txt
36
- [build-shield]: https://img.shields.io/github/actions/workflow/status/ng-doc/ng-doc/release.yml?style=for-the-badge&branch=release
37
- [build-url]: https://github.com/ng-doc/ng-doc/actions
27
+ [license-url]: https://github.com/ng-doc/ng-doc/blob/main/LICENSE
package/package.json CHANGED
@@ -1,21 +1,7 @@
1
1
  {
2
2
  "name": "@ng-doc/add",
3
- "version": "22.0.0-beta.2",
4
- "type": "commonjs",
5
- "schematics": "./schematics/collection.json",
6
- "ng-add": {
7
- "save": true
8
- },
9
- "publishConfig": {
10
- "access": "public"
11
- },
12
- "dependencies": {
13
- "@angular/cdk": ">=22.0.0 < 23.0.0",
14
- "@angular-devkit/schematics": ">=22.0.0 < 23.0.0",
15
- "ng-morph": "4.8.4"
16
- },
17
- "types": "./schematics/index.d.ts",
18
- "main": "./schematics/index.js",
3
+ "version": "22.1.0",
4
+ "description": "Adds NgDoc to an Angular or Nx project with `ng add` and sets everything up for you.",
19
5
  "keywords": [
20
6
  "angular",
21
7
  "documentation",
@@ -26,14 +12,30 @@
26
12
  "demo",
27
13
  "ng-doc"
28
14
  ],
29
- "author": "Skoropad Aleksandr <alex@skoropad.dev>",
15
+ "homepage": "https://ng-doc.com",
16
+ "bugs": {
17
+ "url": "https://github.com/ng-doc/ng-doc/issues"
18
+ },
30
19
  "repository": {
31
20
  "type": "git",
32
21
  "url": "git+https://github.com/ng-doc/ng-doc.git"
33
22
  },
34
- "bugs": {
35
- "url": "https://github.com/ng-doc/ng-doc/issues"
23
+ "license": "MIT",
24
+ "type": "commonjs",
25
+ "schematics": "./schematics/collection.json",
26
+ "ng-add": {
27
+ "save": true
36
28
  },
37
- "homepage": "https://ng-doc.com",
38
- "license": "MIT"
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "dependencies": {
33
+ "@ng-doc/builder": "22.1.0",
34
+ "@angular/cdk": ">=22.0.0 < 23.0.0",
35
+ "@angular-devkit/schematics": ">=22.0.0 < 23.0.0",
36
+ "ng-morph": "4.9.0"
37
+ },
38
+ "types": "./schematics/index.d.ts",
39
+ "main": "./schematics/index.js",
40
+ "author": "Skoropad Aleksandr <alex@skoropad.dev>"
39
41
  }
@@ -1,16 +1,16 @@
1
1
  {
2
- "$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
3
- "schematics": {
4
- "ng-add": {
5
- "description": "Add NgDoc library to the project.",
6
- "factory": "./ng-add/index#ngAdd",
7
- "schema": "./ng-add/schema.json"
8
- },
9
- "ng-add-setup-project": {
10
- "private": true,
11
- "description": "Sets up the project after dependencies have been installed",
12
- "factory": "./ng-add/index#ngAddSetupProject",
13
- "schema": "./ng-add/schema.json"
14
- }
15
- }
2
+ "$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
3
+ "schematics": {
4
+ "ng-add": {
5
+ "description": "Add NgDoc library to the project.",
6
+ "factory": "./ng-add/index#ngAdd",
7
+ "schema": "./ng-add/schema.json"
8
+ },
9
+ "ng-add-setup-project": {
10
+ "private": true,
11
+ "description": "Sets up the project; runs before the dependencies added by ng-add are installed",
12
+ "factory": "./ng-add/index#ngAddSetupProject",
13
+ "schema": "./ng-add/schema.json"
14
+ }
15
+ }
16
16
  }
@@ -3,9 +3,25 @@ export interface EntityImport {
3
3
  name: string;
4
4
  path: string;
5
5
  }
6
+ /**
7
+ * One entry that `ng add` puts into an `imports` or `providers` array.
8
+ *
9
+ * An array entry is matched by its function or identifier name (the text of `initializer` before
10
+ * its first `(`). When the application already has such an entry, `ng add` extends it with
11
+ * `routes`, `features` and `options` instead of adding a second one, so the router and the HTTP
12
+ * client are never registered twice and a second `ng add` run changes nothing.
13
+ */
6
14
  export interface ImportConstant {
15
+ /** Expression added when the array has no entry with the same name yet. */
7
16
  initializer: string;
17
+ /** Named imports that the expression needs. */
8
18
  imports: EntityImport[];
19
+ /** Routes that the first argument of an existing call must include. */
20
+ routes?: string;
21
+ /** Feature calls that an existing call must pass, matched by their function name. */
22
+ features?: string[];
23
+ /** Properties that the options object (second argument) of an existing call must set. */
24
+ options?: Array<[name: string, initializer: string]>;
9
25
  }
10
26
  export interface AppImports {
11
27
  imports: ImportConstant[];
@@ -13,4 +29,10 @@ export interface AppImports {
13
29
  }
14
30
  export declare const NG_DOC_COMPONENT_IMPORTS: ImportConstant[];
15
31
  export declare const MODULE_APP: AppImports;
32
+ /**
33
+ * Features that earlier versions of `ng add` added and that are deprecated now. They are dropped
34
+ * when `ng add` merges the duplicate calls those versions left behind; a call that the
35
+ * application wrote itself keeps them.
36
+ */
37
+ export declare const DROPPED_FEATURES: string[];
16
38
  export declare const STANDALONE_APP: AppImports;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STANDALONE_APP = exports.MODULE_APP = exports.NG_DOC_COMPONENT_IMPORTS = exports.GENERATED_PATH = void 0;
3
+ exports.STANDALONE_APP = exports.DROPPED_FEATURES = exports.MODULE_APP = exports.NG_DOC_COMPONENT_IMPORTS = exports.GENERATED_PATH = void 0;
4
4
  exports.GENERATED_PATH = '@ng-doc/generated';
5
5
  exports.NG_DOC_COMPONENT_IMPORTS = [
6
6
  {
@@ -16,14 +16,20 @@ exports.NG_DOC_COMPONENT_IMPORTS = [
16
16
  imports: [{ name: 'NgDocSidebarComponent', path: '@ng-doc/app' }],
17
17
  },
18
18
  ];
19
+ /*
20
+ * No change-detection provider on purpose: NgDoc works with and without zone.js, so `ng add`
21
+ * keeps whatever the application uses (zoneless by default since Angular 21). No `withFetch()`
22
+ * either: the fetch backend is the default since Angular 22 and the feature is deprecated.
23
+ */
19
24
  const NG_DOC_PROVIDERS = [
20
25
  {
21
- initializer: 'provideHttpClient(withInterceptorsFromDi(), withFetch())',
26
+ initializer: 'provideHttpClient(withInterceptorsFromDi())',
22
27
  imports: [
23
28
  { name: 'provideHttpClient', path: '@angular/common/http' },
24
29
  { name: 'withInterceptorsFromDi', path: '@angular/common/http' },
25
- { name: 'withFetch', path: '@angular/common/http' },
26
30
  ],
31
+ // NgDoc registers class-based interceptors through `HTTP_INTERCEPTORS`.
32
+ features: ['withInterceptorsFromDi()'],
27
33
  },
28
34
  {
29
35
  initializer: 'provideNgDocContext()',
@@ -66,28 +72,36 @@ exports.MODULE_APP = {
66
72
  path: exports.GENERATED_PATH,
67
73
  },
68
74
  ],
75
+ routes: 'NG_DOC_ROUTING',
76
+ options: [
77
+ ['scrollPositionRestoration', "'enabled'"],
78
+ ['anchorScrolling', "'enabled'"],
79
+ ['scrollOffset', '[0, 70]'],
80
+ ],
69
81
  },
70
82
  ...exports.NG_DOC_COMPONENT_IMPORTS,
71
83
  ],
72
84
  providers: NG_DOC_PROVIDERS,
73
85
  };
86
+ /**
87
+ * Features that earlier versions of `ng add` added and that are deprecated now. They are dropped
88
+ * when `ng add` merges the duplicate calls those versions left behind; a call that the
89
+ * application wrote itself keeps them.
90
+ */
91
+ exports.DROPPED_FEATURES = ['withFetch'];
92
+ const IN_MEMORY_SCROLLING = 'withInMemoryScrolling({scrollPositionRestoration: "enabled", anchorScrolling: "enabled"})';
74
93
  exports.STANDALONE_APP = {
75
94
  imports: exports.NG_DOC_COMPONENT_IMPORTS,
76
95
  providers: [
77
96
  {
78
- initializer: 'provideHttpClient(withInterceptorsFromDi())',
79
- imports: [
80
- { name: 'provideHttpClient', path: '@angular/common/http' },
81
- { name: 'withInterceptorsFromDi', path: '@angular/common/http' },
82
- ],
83
- },
84
- {
85
- initializer: 'provideRouter(NG_DOC_ROUTING, withInMemoryScrolling({scrollPositionRestoration: "enabled", anchorScrolling: "enabled"}))',
97
+ initializer: `provideRouter(NG_DOC_ROUTING, ${IN_MEMORY_SCROLLING})`,
86
98
  imports: [
87
99
  { name: 'provideRouter', path: '@angular/router' },
88
100
  { name: 'NG_DOC_ROUTING', path: exports.GENERATED_PATH },
89
101
  { name: 'withInMemoryScrolling', path: '@angular/router' },
90
102
  ],
103
+ routes: 'NG_DOC_ROUTING',
104
+ features: [IN_MEMORY_SCROLLING],
91
105
  },
92
106
  ...NG_DOC_PROVIDERS,
93
107
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"modules.js","sourceRoot":"","sources":["../../../../../../libs/add/schematics/ng-add/constants/modules.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAW,mBAAmB,CAAC;AAiB7C,QAAA,wBAAwB,GAAqB;IACxD;QACE,WAAW,EAAE,oBAAoB;QACjC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;KAC/D;IACD;QACE,WAAW,EAAE,sBAAsB;QACnC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;KACjE;IACD;QACE,WAAW,EAAE,uBAAuB;QACpC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;KAClE;CACF,CAAC;AAEF,MAAM,gBAAgB,GAAqB;IACzC;QACE,WAAW,EAAE,0DAA0D;QACvE,OAAO,EAAE;YACP,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,sBAAsB,EAAE;YAC3D,EAAE,IAAI,EAAE,wBAAwB,EAAE,IAAI,EAAE,sBAAsB,EAAE;YAChE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,sBAAsB,EAAE;SACpD;KACF;IACD;QACE,WAAW,EAAE,uBAAuB;QACpC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,sBAAc,EAAE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AAsB,EAAE;aACjE;SACF;QACD;YACE,WAAW,EACT,0HAA0H;YAC5H,OAAO,EAAE;gBACP,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,iBAAiB,EAAE;gBAClD,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,sBAAc,EAAE;gBAChD,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,iBAAiB,EAAE;aAC3D;SACF;QACD,GAAG,gBAAgB;KACpB;CACF,CAAC"}
1
+ {"version":3,"file":"modules.js","sourceRoot":"","sources":["../../../../../../libs/add/schematics/ng-add/constants/modules.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAW,mBAAmB,CAAC;AAiC7C,QAAA,wBAAwB,GAAqB;IACxD;QACE,WAAW,EAAE,oBAAoB;QACjC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;KAC/D;IACD;QACE,WAAW,EAAE,sBAAsB;QACnC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;KACjE;IACD;QACE,WAAW,EAAE,uBAAuB;QACpC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;KAClE;CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,gBAAgB,GAAqB;IACzC;QACE,WAAW,EAAE,6CAA6C;QAC1D,OAAO,EAAE;YACP,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,sBAAsB,EAAE;YAC3D,EAAE,IAAI,EAAE,wBAAwB,EAAE,IAAI,EAAE,sBAAsB,EAAE;SACjE;QACD,wEAAwE;QACxE,QAAQ,EAAE,CAAC,0BAA0B,CAAC;KACvC;IACD;QACE,WAAW,EAAE,uBAAuB;QACpC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,IA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AW,CAAC,CAAC;AAExD,MAAM,mBAAmB,GACvB,2FAA2F,CAAC;AAEjF,QAAA,cAAc,GAAe;IACxC,OAAO,EAAE,gCAAwB;IACjC,SAAS,EAAE;QACT;YACE,WAAW,EAAE,iCAAiC,mBAAmB,GAAG;YACpE,OAAO,EAAE;gBACP,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,iBAAiB,EAAE;gBAClD,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,sBAAc,EAAE;gBAChD,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,iBAAiB,EAAE;aAC3D;YACD,MAAM,EAAE,gBAAgB;YACxB,QAAQ,EAAE,CAAC,mBAAmB,CAAC;SAChC;QACD,GAAG,gBAAgB;KACpB;CACF,CAAC"}
@@ -1 +1,5 @@
1
+ /**
2
+ * The NgDoc stylesheets `ng-doc add` puts first in the build's `styles`: the global styles and the
3
+ * dark theme, which the theme toggle's Dark and Auto options switch to.
4
+ */
1
5
  export declare const NG_DOC_STYLES: string[];
@@ -1,5 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NG_DOC_STYLES = void 0;
4
- exports.NG_DOC_STYLES = ['node_modules/@ng-doc/app/styles/global.css'];
4
+ /**
5
+ * The NgDoc stylesheets `ng-doc add` puts first in the build's `styles`: the global styles and the
6
+ * dark theme, which the theme toggle's Dark and Auto options switch to.
7
+ */
8
+ exports.NG_DOC_STYLES = [
9
+ 'node_modules/@ng-doc/app/styles/global.css',
10
+ 'node_modules/@ng-doc/app/styles/themes/dark.css',
11
+ ];
5
12
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../../../libs/add/schematics/ng-add/constants/styles.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAa,CAAC,4CAA4C,CAAC,CAAC"}
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../../../libs/add/schematics/ng-add/constants/styles.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,aAAa,GAAa;IACrC,4CAA4C;IAC5C,iDAAiD;CAClD,CAAC"}
@@ -6,7 +6,11 @@ import { Schema } from './schema';
6
6
  */
7
7
  export declare function ngAdd(options: Schema): Rule;
8
8
  /**
9
- *
10
- * @param options
9
+ * Sets up the project. It runs as a task before the install task of `ngAdd`, while `@ng-doc/add` is
10
+ * still installed. The styles, assets and providers are the same for both engines. The Vite engine then reads the build target, as it now is, into
11
+ * `vite.config.mjs` and the Vite targets (`@ng-doc/builder:vite-setup`); the legacy engine swaps
12
+ * the builders of the build and serve targets. A builder that is neither Angular's nor NgDoc's is
13
+ * kept, and the project generates its documentation with the `ng-doc` command.
14
+ * @param options - The `ng add` options.
11
15
  */
12
16
  export declare function ngAddSetupProject(options: Schema): Rule;
@@ -4,6 +4,7 @@ exports.ngAdd = ngAdd;
4
4
  exports.ngAddSetupProject = ngAddSetupProject;
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
6
  const tasks_1 = require("@angular-devkit/schematics/tasks");
7
+ const workspace_1 = require("@schematics/angular/utility/workspace");
7
8
  const ng_morph_1 = require("ng-morph");
8
9
  const version_1 = require("./constants/version");
9
10
  const add_assets_1 = require("./steps/add-assets");
@@ -14,8 +15,12 @@ const add_ng_doc_app_config_1 = require("./steps/add-ng-doc-app-config");
14
15
  const add_styles_1 = require("./steps/add-styles");
15
16
  const add_tsconfig_paths_1 = require("./steps/add-tsconfig-paths");
16
17
  const post_install_1 = require("./steps/post-install");
18
+ const raise_initial_budget_1 = require("./steps/raise-initial-budget");
17
19
  const replace_builders_1 = require("./steps/replace-builders");
18
20
  const update_app_ts_config_1 = require("./steps/update-app-ts-config");
21
+ const get_project_1 = require("./utils/get-project");
22
+ const get_project_name_1 = require("./utils/get-project-name");
23
+ const select_engine_1 = require("./utils/select-engine");
19
24
  /**
20
25
  *
21
26
  * @param options
@@ -34,21 +39,51 @@ function ngAdd(options) {
34
39
  };
35
40
  }
36
41
  /**
37
- *
38
- * @param options
42
+ * Sets up the project. It runs as a task before the install task of `ngAdd`, while `@ng-doc/add` is
43
+ * still installed. The styles, assets and providers are the same for both engines. The Vite engine then reads the build target, as it now is, into
44
+ * `vite.config.mjs` and the Vite targets (`@ng-doc/builder:vite-setup`); the legacy engine swaps
45
+ * the builders of the build and serve targets. A builder that is neither Angular's nor NgDoc's is
46
+ * kept, and the project generates its documentation with the `ng-doc` command.
47
+ * @param options - The `ng add` options.
39
48
  */
40
49
  function ngAddSetupProject(options) {
41
- return (0, schematics_1.chain)([
42
- (0, replace_builders_1.replaceBuilders)(options),
43
- (0, add_styles_1.addStyles)(options),
44
- (0, add_assets_1.addAssets)(options),
45
- (0, add_js_dependencies_1.addJsDependencies)(options),
46
- (0, add_ng_doc_app_config_1.addNgDocAppConfig)(options),
47
- (0, add_layout_1.addLayout)(options),
48
- (0, add_tsconfig_paths_1.addTsconfigPaths)(options),
49
- (0, update_app_ts_config_1.updateAppTsConfig)(options),
50
- (0, add_git_ignore_1.addGitIgnore)(),
51
- (0, post_install_1.postInstall)(),
52
- ]);
50
+ return async (tree, context) => {
51
+ const workspace = await (0, workspace_1.getWorkspace)(tree);
52
+ const project = (0, get_project_1.getProject)(options, workspace);
53
+ if (!project) {
54
+ throw new schematics_1.SchematicsException(`[NGDOC_ADD_PROJECT] Project "${(0, get_project_name_1.getProjectName)(options, workspace)}" was not found. Pass --project.`);
55
+ }
56
+ const choice = (0, select_engine_1.selectEngine)(tree, project, options.engine, context.logger);
57
+ // The Vite targets hold no Angular build options: a second run must not add any to them.
58
+ const editBuildTarget = !(choice.engine === 'vite' && choice.existing);
59
+ context.logger.info(`[INFO]: Engine: ${choice.keptBuilder
60
+ ? `the "ng-doc" command, next to "${choice.keptBuilder}"`
61
+ : choice.engine === 'vite'
62
+ ? 'Vite (@ng-doc/builder:vite-application)'
63
+ : 'legacy (@ng-doc/builder:application)'}`);
64
+ return (0, schematics_1.chain)([
65
+ choice.engine === 'legacy' && choice.replaceBuilders ? (0, replace_builders_1.replaceBuilders)(options) : (0, schematics_1.noop)(),
66
+ // Only a project new to NgDoc: an existing one chose its budgets. A kept builder runs
67
+ // Angular's builder with its budgets too.
68
+ choice.engine === 'legacy' && !choice.existing ? (0, raise_initial_budget_1.raiseInitialBudget)(options) : (0, schematics_1.noop)(),
69
+ editBuildTarget ? (0, add_styles_1.addStyles)(options) : (0, schematics_1.noop)(),
70
+ editBuildTarget ? (0, add_assets_1.addAssets)(options) : (0, schematics_1.noop)(),
71
+ editBuildTarget ? (0, add_js_dependencies_1.addJsDependencies)(options) : (0, schematics_1.noop)(),
72
+ (0, add_ng_doc_app_config_1.addNgDocAppConfig)(options),
73
+ (0, add_layout_1.addLayout)(options),
74
+ (0, add_tsconfig_paths_1.addTsconfigPaths)(options),
75
+ (0, update_app_ts_config_1.updateAppTsConfig)(options),
76
+ (0, add_git_ignore_1.addGitIgnore)(),
77
+ // `@ng-doc/add` depends on `@ng-doc/builder`, so the schematic is there before the install
78
+ // that follows this one. That install also installs the Vite dependencies it adds.
79
+ choice.engine === 'vite'
80
+ ? (0, schematics_1.externalSchematic)('@ng-doc/builder', 'vite-setup', {
81
+ project: (0, get_project_name_1.getProjectName)(options, workspace),
82
+ skipInstall: true,
83
+ })
84
+ : (0, schematics_1.noop)(),
85
+ (0, post_install_1.postInstall)(choice.engine, choice.keptBuilder),
86
+ ]);
87
+ };
53
88
  }
54
89
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/add/schematics/ng-add/index.ts"],"names":[],"mappings":";;AA0BA,sBAcC;AAMD,8CAaC;AA3DD,2DAAiF;AACjF,4DAA4F;AAC5F,uCAKkB;AAElB,iDAAqD;AAErD,mDAA+C;AAC/C,2DAAsD;AACtD,qEAAgE;AAChE,mDAA+C;AAC/C,yEAAkE;AAClE,mDAA+C;AAC/C,mEAA8D;AAC9D,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C,CAAC,CAAC,IAAA,iBAAI,GAAE;YACxF,sFAAsF;YACtF,0CAA0C;YAC1C,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,yCAAkB,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE;YACrF,eAAe,CAAC,CAAC,CAAC,IAAA,sBAAS,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE;YAC7C,eAAe,CAAC,CAAC,CAAC,IAAA,sBAAS,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE;YAC7C,eAAe,CAAC,CAAC,CAAC,IAAA,uCAAiB,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE;YACrD,IAAA,yCAAiB,EAAC,OAAO,CAAC;YAC1B,IAAA,sBAAS,EAAC,OAAO,CAAC;YAClB,IAAA,qCAAgB,EAAC,OAAO,CAAC;YACzB,IAAA,wCAAiB,EAAC,OAAO,CAAC;YAC1B,IAAA,6BAAY,GAAE;YACd,2FAA2F;YAC3F,mFAAmF;YACnF,MAAM,CAAC,MAAM,KAAK,MAAM;gBACtB,CAAC,CAAC,IAAA,8BAAiB,EAAC,iBAAiB,EAAE,YAAY,EAAE;oBACjD,OAAO,EAAE,IAAA,iCAAc,EAAC,OAAO,EAAE,SAAS,CAAC;oBAC3C,WAAW,EAAE,IAAI;iBAClB,CAAC;gBACJ,CAAC,CAAC,IAAA,iBAAI,GAAE;YACV,IAAA,0BAAW,EAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC;SAC/C,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -1,3 +1,11 @@
1
+ /** The NgDoc engine that `ng add` sets up. */
2
+ export type NgDocEngine = 'vite' | 'legacy';
1
3
  export interface Schema {
2
4
  readonly project: string;
5
+ /**
6
+ * `vite` (the Vite engine) or `legacy` (the legacy builders). Without it, a standalone
7
+ * application gets the Vite engine, and an NgModule application or a project that already uses
8
+ * NgDoc keeps or gets the legacy builders.
9
+ */
10
+ readonly engine?: NgDocEngine;
3
11
  }
@@ -1,16 +1,21 @@
1
1
  {
2
- "$schema": "http://json-schema.org/draft-07/schema",
3
- "$id": "ng-doc-ng-add",
4
- "title": "NgDoc ng-add",
5
- "type": "object",
6
- "properties": {
7
- "project": {
8
- "type": "string",
9
- "description": "The name of the project.",
10
- "$default": {
11
- "$source": "projectName"
12
- }
13
- }
14
- },
15
- "required": []
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "ng-doc-ng-add",
4
+ "title": "NgDoc ng-add",
5
+ "type": "object",
6
+ "properties": {
7
+ "project": {
8
+ "type": "string",
9
+ "description": "The name of the project.",
10
+ "$default": {
11
+ "$source": "projectName"
12
+ }
13
+ },
14
+ "engine": {
15
+ "type": "string",
16
+ "enum": ["vite", "legacy"],
17
+ "description": "The engine to set up: \"vite\" (the @ng-doc/builder:vite-application and vite-dev-server builders) or \"legacy\" (the @ng-doc/builder:application and dev-server builders). By default a standalone application on Angular's application builder (or Nx's @nx/angular:application executor) gets the Vite engine; an NgModule application, or one on another builder, gets the legacy builders. A project that already uses NgDoc keeps its builders."
18
+ }
19
+ },
20
+ "required": []
16
21
  }
@@ -1,8 +1,7 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
2
  import { Schema } from '../schema';
3
3
  /**
4
- *
5
- * @param options
6
- * @param context
4
+ * Adds the NgDoc assets to the target with the Angular build options (`getBuildOptionsTarget`). Entries that are already there are not added again.
5
+ * @param options - The `ng add` options.
7
6
  */
8
7
  export declare function addAssets(options: Schema): Rule;
@@ -4,11 +4,11 @@ exports.addAssets = addAssets;
4
4
  const schematics_1 = require("@angular/cdk/schematics");
5
5
  const workspace_1 = require("@schematics/angular/utility/workspace");
6
6
  const assets_1 = require("../constants/assets");
7
+ const get_build_options_target_1 = require("../utils/get-build-options-target");
7
8
  const get_project_1 = require("../utils/get-project");
8
9
  /**
9
- *
10
- * @param options
11
- * @param context
10
+ * Adds the NgDoc assets to the target with the Angular build options (`getBuildOptionsTarget`). Entries that are already there are not added again.
11
+ * @param options - The `ng add` options.
12
12
  */
13
13
  function addAssets(options) {
14
14
  return async (tree, context) => {
@@ -22,9 +22,15 @@ function addAssets(options) {
22
22
  logger.error(`❌ Target project not found. Please add assets manually.`);
23
23
  return;
24
24
  }
25
- const targetOptions = (0, schematics_1.getProjectTargetOptions)(project, 'build');
25
+ const targetOptions = (0, schematics_1.getProjectTargetOptions)(project, (0, get_build_options_target_1.getBuildOptionsTarget)(project));
26
26
  const assets = targetOptions['assets'];
27
- targetOptions['assets'] = Array.from(new Set([...(0, assets_1.getNgDocAssets)(options, workspace), ...(assets ?? [])]));
27
+ // Asset entries are objects, so they are compared by content: a second `ng add` run must
28
+ // not add them again.
29
+ const existing = new Set((assets ?? []).map((asset) => JSON.stringify(asset)));
30
+ targetOptions['assets'] = [
31
+ ...(0, assets_1.getNgDocAssets)(options, workspace).filter((asset) => !existing.has(JSON.stringify(asset))),
32
+ ...(assets ?? []),
33
+ ];
28
34
  logger.info('✅ Done!');
29
35
  }
30
36
  catch (e) {
@@ -1 +1 @@
1
- {"version":3,"file":"add-assets.js","sourceRoot":"","sources":["../../../../../../libs/add/schematics/ng-add/steps/add-assets.ts"],"names":[],"mappings":";;AAkBA,8BAkCC;AApDD,wDAAkE;AAGlE,qEAI+C;AAE/C,gDAAqD;AAErD,sDAAkD;AAElD;;;;GAIG;AACH,SAAgB,SAAS,CAAC,OAAe;IACvC,OAAO,KAAK,EAAE,IAAU,EAAE,OAAyB,EAAE,EAAE;QACrD,OAAO,IAAA,2BAAe,EAAC,CAAC,SAA8B,EAAE,EAAE;YACxD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;YAExD,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAA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  import { Rule } from '@angular-devkit/schematics';
2
2
  /**
3
- *
4
- * @param options
5
- * @param context
3
+ * Adds the generated `ng-doc` folder to `.gitignore` unless it is already ignored.
6
4
  */
7
5
  export declare function addGitIgnore(): Rule;
@@ -3,9 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addGitIgnore = addGitIgnore;
4
4
  const workspace_1 = require("@schematics/angular/utility/workspace");
5
5
  /**
6
- *
7
- * @param options
8
- * @param context
6
+ * Adds the generated `ng-doc` folder to `.gitignore` unless it is already ignored.
9
7
  */
10
8
  function addGitIgnore() {
11
9
  return async (tree, context) => {
@@ -19,7 +17,14 @@ function addGitIgnore() {
19
17
  logger.warn(`⚠️ ".gitignore" file was not found, please add "/ng-doc" folder into it manually.`);
20
18
  return;
21
19
  }
22
- tree.overwrite('.gitignore', `${gitignore}\n\n# NgDoc files\n/ng-doc`);
20
+ // A second `ng add` run must not append the entry again.
21
+ const ignored = gitignore
22
+ .toString()
23
+ .split(/\r?\n/)
24
+ .some((line) => /^\/?ng-doc\/?$/.test(line.trim()));
25
+ if (!ignored) {
26
+ tree.overwrite('.gitignore', `${gitignore}\n\n# NgDoc files\n/ng-doc`);
27
+ }
23
28
  logger.info('✅ Done!');
24
29
  }
25
30
  catch (e) {
@@ -1 +1 @@
1
- {"version":3,"file":"add-git-ignore.js","sourceRoot":"","sources":["../../../../../../libs/add/schematics/ng-add/steps/add-git-ignore.ts"],"names":[],"mappings":";;AAQA,oCA2BC;AAlCD,qEAAwE;AAExE;;;;GAIG;AACH,SAAgB,YAAY;IAC1B,OAAO,KAAK,EAAE,IAAU,EAAE,OAAyB,EAAE,EAAE;QACrD,OAAO,IAAA,2BAAe,EAAC,GAAG,EAAE;YAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;YAE3D,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YAC1C,MAAM,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;YAE/D,IAAI,CAAC;gBACH,MAAM,SAAS,GAAkB,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;gBAEzD,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,MAAM,CAAC,IAAI,CACT,mFAAmF,CACpF,CAAC;oBAEF,OAAO;gBACT,CAAC;gBAED,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,GAAG,SAAS,4BAA4B,CAAC,CAAC;gBAEvE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACzB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;YAChC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"add-git-ignore.js","sourceRoot":"","sources":["../../../../../../libs/add/schematics/ng-add/steps/add-git-ignore.ts"],"names":[],"mappings":";;AAMA,oCAmCC;AAxCD,qEAAwE;AAExE;;GAEG;AACH,SAAgB,YAAY;IAC1B,OAAO,KAAK,EAAE,IAAU,EAAE,OAAyB,EAAE,EAAE;QACrD,OAAO,IAAA,2BAAe,EAAC,GAAG,EAAE;YAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;YAE3D,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YAC1C,MAAM,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;YAE/D,IAAI,CAAC;gBACH,MAAM,SAAS,GAAkB,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;gBAEzD,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,MAAM,CAAC,IAAI,CACT,mFAAmF,CACpF,CAAC;oBAEF,OAAO;gBACT,CAAC;gBAED,yDAAyD;gBACzD,MAAM,OAAO,GAAY,SAAS;qBAC/B,QAAQ,EAAE;qBACV,KAAK,CAAC,OAAO,CAAC;qBACd,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;gBAE9D,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,GAAG,SAAS,4BAA4B,CAAC,CAAC;gBACzE,CAAC;gBAED,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACzB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;YAChC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addJsDependencies = addJsDependencies;
4
4
  const schematics_1 = require("@angular/cdk/schematics");
5
5
  const workspace_1 = require("@schematics/angular/utility/workspace");
6
+ const get_build_options_target_1 = require("../utils/get-build-options-target");
6
7
  const get_project_1 = require("../utils/get-project");
7
8
  /**
8
9
  *
@@ -21,7 +22,7 @@ function addJsDependencies(options) {
21
22
  logger.error(`❌ Target project not found. Please add "@ng-doc/core" library to "allowedCommonJsDependencies" manually.`);
22
23
  return;
23
24
  }
24
- const targetOptions = (0, schematics_1.getProjectTargetOptions)(project, 'build');
25
+ const targetOptions = (0, schematics_1.getProjectTargetOptions)(project, (0, get_build_options_target_1.getBuildOptionsTarget)(project));
25
26
  const jsDependencies = targetOptions['allowedCommonJsDependencies'];
26
27
  targetOptions['allowedCommonJsDependencies'] = Array.from(new Set([...(jsDependencies ?? []), '@ng-doc/core']));
27
28
  logger.info('✅ Done!');
@@ -1 +1 @@
1
- {"version":3,"file":"add-js-dependencies.js","sourceRoot":"","sources":["../../../../../../libs/add/schematics/ng-add/steps/add-js-dependencies.ts"],"names":[],"mappings":";;AAiBA,8CAqCC;AAtDD,wDAAkE;AAGlE,qEAI+C;AAG/C,sDAAkD;AAElD;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,OAAe;IAC/C,OAAO,KAAK,EAAE,IAAU,EAAE,OAAyB,EAAE,EAAE;QACrD,OAAO,IAAA,2BAAe,EAAC,CAAC,SAA8B,EAAE,EAAE;YACxD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;YAEjE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;YACtD,MAAM,CAAC,IAAI,CAAC,sEAAsE,CAAC,CAAC;YAEpF,IAAI,CAAC;gBACH,MAAM,OAAO,GAAkC,IAAA,wBAAU,EAAC,OAAO,EAAE,SAAS,CAAC,CAAC;gBAE9E,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,MAAM,CAAC,KAAK,CACV,0GAA0G,CAC3G,CAAC;oBAEF,OAAO;gBACT,CAAC;gBAED,MAAM,aAAa,GAA0C,IAAA,oCAAuB,EAClF,OAAO,EACP,OAAO,CACR,CAAC;gBACF,MAAM,cAAc,GAA0B,aAAa,CACzD,6BAA6B,CACL,CAAC;gBAE3B,aAAa,CAAC,6BAA6B,CAAC,GAAG,KAAK,CAAC,IAAI,CACvD,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC,EAAE,cAAc,CAAC,CAAC,CACrD,CAAC;gBAEF,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACzB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;YAChC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"add-js-dependencies.js","sourceRoot":"","sources":["../../../../../../libs/add/schematics/ng-add/steps/add-js-dependencies.ts"],"names":[],"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schematics';
2
2
  import { Schema } from '../schema';
3
3
  /**
4
- *
5
- * @param options
4
+ * Replaces the root component's template with the NgDoc layout.
5
+ * @param options - The `ng add` options.
6
6
  */
7
7
  export declare function addLayout(options: Schema): Rule;