@o3r/schematics 10.0.0-prerelease.11 → 10.0.0-prerelease.111

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. package/README.md +2 -1
  2. package/{src/cli → cli}/environment.d.ts.map +1 -1
  3. package/{src/cli → cli}/environment.js +1 -1
  4. package/cli/package.json +3 -0
  5. package/package.json +44 -36
  6. package/schematics/ng-add/index.d.ts +2 -1
  7. package/schematics/ng-add/index.d.ts.map +1 -1
  8. package/schematics/ng-add/index.js +30 -27
  9. package/schematics/ng-add/schema.d.ts +1 -1
  10. package/schematics/ng-add/schema.d.ts.map +1 -1
  11. package/src/interfaces/angular-workspace.d.ts.map +1 -1
  12. package/src/interfaces/index.d.ts +1 -0
  13. package/src/interfaces/index.d.ts.map +1 -1
  14. package/src/interfaces/index.js +1 -0
  15. package/src/interfaces/index.js.map +1 -1
  16. package/src/{rule-factories/interfaces.d.ts → interfaces/rule-factories.d.ts} +2 -2
  17. package/src/interfaces/rule-factories.d.ts.map +1 -0
  18. package/src/{rule-factories/interfaces.js → interfaces/rule-factories.js} +1 -1
  19. package/src/interfaces/rule-factories.js.map +1 -0
  20. package/src/modules/modules.display.rule.d.ts.map +1 -1
  21. package/src/modules/modules.display.rule.js +3 -4
  22. package/src/modules/modules.display.rule.js.map +1 -1
  23. package/src/modules/modules.helpers.d.ts +1 -1
  24. package/src/modules/modules.helpers.d.ts.map +1 -1
  25. package/src/modules/modules.helpers.js +2 -2
  26. package/src/modules/modules.helpers.js.map +1 -1
  27. package/src/public_api.d.ts +6 -1
  28. package/src/public_api.d.ts.map +1 -1
  29. package/src/public_api.js +6 -1
  30. package/src/public_api.js.map +1 -1
  31. package/src/rule-factories/add-imports/index.js.map +1 -1
  32. package/src/rule-factories/dev-tools/devtools-registration.js +7 -7
  33. package/src/rule-factories/dev-tools/devtools-registration.js.map +1 -1
  34. package/src/rule-factories/eslint-fix/index.d.ts +1 -1
  35. package/src/rule-factories/eslint-fix/index.d.ts.map +1 -1
  36. package/src/rule-factories/eslint-fix/index.js +5 -3
  37. package/src/rule-factories/eslint-fix/index.js.map +1 -1
  38. package/src/rule-factories/get-test-frameworks/index.js +2 -2
  39. package/src/rule-factories/get-test-frameworks/index.js.map +1 -1
  40. package/src/rule-factories/index.d.ts +1 -1
  41. package/src/rule-factories/index.d.ts.map +1 -1
  42. package/src/rule-factories/index.js +1 -1
  43. package/src/rule-factories/index.js.map +1 -1
  44. package/src/rule-factories/ng-add/dependencies.d.ts +78 -0
  45. package/src/rule-factories/ng-add/dependencies.d.ts.map +1 -0
  46. package/src/rule-factories/ng-add/dependencies.js +156 -0
  47. package/src/rule-factories/ng-add/dependencies.js.map +1 -0
  48. package/src/rule-factories/ng-add/index.d.ts +3 -36
  49. package/src/rule-factories/ng-add/index.d.ts.map +1 -1
  50. package/src/rule-factories/ng-add/index.js +4 -218
  51. package/src/rule-factories/ng-add/index.js.map +1 -1
  52. package/src/rule-factories/ng-add/ng-add.helpers.d.ts +22 -0
  53. package/src/rule-factories/ng-add/ng-add.helpers.d.ts.map +1 -0
  54. package/src/rule-factories/ng-add/ng-add.helpers.js +162 -0
  55. package/src/rule-factories/ng-add/ng-add.helpers.js.map +1 -0
  56. package/src/rule-factories/ng-add/schematics-register.d.ts +17 -0
  57. package/src/rule-factories/ng-add/schematics-register.d.ts.map +1 -0
  58. package/src/rule-factories/ng-add/schematics-register.js +64 -0
  59. package/src/rule-factories/ng-add/schematics-register.js.map +1 -0
  60. package/src/rule-factories/update-imports/index.d.ts +0 -1
  61. package/src/rule-factories/update-imports/index.d.ts.map +1 -1
  62. package/src/rule-factories/update-imports/index.js +0 -1
  63. package/src/rule-factories/update-imports/index.js.map +1 -1
  64. package/src/rule-factories/update-imports/list-of-vars.d.ts +4 -5
  65. package/src/rule-factories/update-imports/list-of-vars.d.ts.map +1 -1
  66. package/src/rule-factories/update-imports/list-of-vars.js.map +1 -1
  67. package/src/rule-factories/update-imports/update-imports-with-scope.d.ts +1 -1
  68. package/src/rule-factories/update-imports/update-imports-with-scope.js +3 -3
  69. package/src/rule-factories/update-imports/update-imports-with-scope.js.map +1 -1
  70. package/src/rule-factories/update-imports/update-ts-imports.d.ts +1 -1
  71. package/src/rule-factories/update-imports/update-ts-imports.d.ts.map +1 -1
  72. package/src/rule-factories/update-imports/update-ts-imports.js +7 -6
  73. package/src/rule-factories/update-imports/update-ts-imports.js.map +1 -1
  74. package/src/rules/install.d.ts +8 -4
  75. package/src/rules/install.d.ts.map +1 -1
  76. package/src/rules/install.js +10 -8
  77. package/src/rules/install.js.map +1 -1
  78. package/src/tasks/ng-add/index.d.ts +1 -0
  79. package/src/tasks/ng-add/index.d.ts.map +1 -1
  80. package/src/tasks/ng-add/index.js +1 -0
  81. package/src/tasks/ng-add/index.js.map +1 -1
  82. package/src/tasks/package-manager/add-dev-dependency.d.ts +1 -0
  83. package/src/tasks/package-manager/add-dev-dependency.d.ts.map +1 -1
  84. package/src/tasks/package-manager/add-dev-dependency.js +4 -3
  85. package/src/tasks/package-manager/add-dev-dependency.js.map +1 -1
  86. package/src/tasks/package-manager/interfaces.d.ts +1 -1
  87. package/src/tasks/package-manager/interfaces.d.ts.map +1 -1
  88. package/src/tasks/package-manager/npm-install.js +3 -3
  89. package/src/tasks/package-manager/npm-install.js.map +1 -1
  90. package/src/utility/collection.d.ts.map +1 -1
  91. package/src/utility/collection.js +1 -1
  92. package/src/utility/collection.js.map +1 -1
  93. package/src/utility/component.d.ts +1 -1
  94. package/src/utility/component.d.ts.map +1 -1
  95. package/src/utility/dependencies.d.ts.map +1 -1
  96. package/src/utility/dependencies.js +1 -1
  97. package/src/utility/dependencies.js.map +1 -1
  98. package/src/utility/environment.d.ts +1 -0
  99. package/src/utility/environment.d.ts.map +1 -1
  100. package/src/utility/file-info.d.ts +1 -2
  101. package/src/utility/file-info.d.ts.map +1 -1
  102. package/src/utility/file-info.js.map +1 -1
  103. package/src/utility/generation.d.ts +1 -1
  104. package/src/utility/generation.d.ts.map +1 -1
  105. package/src/utility/gitignore.d.ts +1 -1
  106. package/src/utility/gitignore.d.ts.map +1 -1
  107. package/src/utility/index.d.ts +1 -0
  108. package/src/utility/index.d.ts.map +1 -1
  109. package/src/utility/index.js +1 -0
  110. package/src/utility/index.js.map +1 -1
  111. package/src/utility/loaders.d.ts +6 -1
  112. package/src/utility/loaders.d.ts.map +1 -1
  113. package/src/utility/loaders.js +10 -2
  114. package/src/utility/loaders.js.map +1 -1
  115. package/src/utility/matching-peers.d.ts.map +1 -1
  116. package/src/utility/matching-peers.js +1 -1
  117. package/src/utility/matching-peers.js.map +1 -1
  118. package/src/utility/monorepo.d.ts +1 -1
  119. package/src/utility/monorepo.d.ts.map +1 -1
  120. package/src/utility/package-manager-runner.d.ts +1 -1
  121. package/src/utility/package-manager-runner.d.ts.map +1 -1
  122. package/src/utility/routes.d.ts +1 -1
  123. package/src/utility/routes.d.ts.map +1 -1
  124. package/src/utility/sub-entry.d.ts +1 -1
  125. package/src/utility/sub-entry.d.ts.map +1 -1
  126. package/src/utility/template-property.helper.js.map +1 -1
  127. package/src/utility/update-imports.d.ts.map +1 -1
  128. package/src/utility/update-imports.js +17 -7
  129. package/src/utility/update-imports.js.map +1 -1
  130. package/src/utility/update-pipes.d.ts +15 -0
  131. package/src/utility/update-pipes.d.ts.map +1 -0
  132. package/src/utility/update-pipes.js +82 -0
  133. package/src/utility/update-pipes.js.map +1 -0
  134. package/src/utility/wrapper.d.ts.map +1 -1
  135. package/src/utility/wrapper.js +49 -3
  136. package/src/utility/wrapper.js.map +1 -1
  137. package/src/cli/environment.js.map +0 -1
  138. package/src/index.d.ts +0 -7
  139. package/src/index.d.ts.map +0 -1
  140. package/src/index.js +0 -10
  141. package/src/index.js.map +0 -1
  142. package/src/rule-factories/interfaces.d.ts.map +0 -1
  143. package/src/rule-factories/interfaces.js.map +0 -1
  144. package/src/rule-factories/update-imports/v7-to-v8-map-object.d.ts +0 -8
  145. package/src/rule-factories/update-imports/v7-to-v8-map-object.d.ts.map +0 -1
  146. package/src/rule-factories/update-imports/v7-to-v8-map-object.js +0 -2049
  147. package/src/rule-factories/update-imports/v7-to-v8-map-object.js.map +0 -1
  148. /package/{src/cli → cli}/environment.d.ts +0 -0
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getTestFramework = void 0;
4
- const utility_1 = require("../../utility");
4
+ const index_1 = require("../../utility/index");
5
5
  const testPackageMaps = {
6
6
  'jest': ['jest'],
7
7
  'jasmine': ['jasmine-core']
@@ -13,7 +13,7 @@ const testPackageMaps = {
13
13
  */
14
14
  function getTestFramework(workspaceOptions, context) {
15
15
  if (workspaceOptions) {
16
- const testFramework = (0, utility_1.getSchematicOptions)(workspaceOptions, context)?.testFramework;
16
+ const testFramework = (0, index_1.getSchematicOptions)(workspaceOptions, context)?.testFramework;
17
17
  if (testFramework) {
18
18
  return testFramework;
19
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/rule-factories/get-test-frameworks/index.ts"],"names":[],"mappings":";;;AAEA,2CAAoD;AAGpD,MAAM,eAAe,GAA8C;IACjE,MAAM,EAAE,CAAC,MAAM,CAAC;IAChB,SAAS,EAAE,CAAC,cAAc,CAAC;CAC5B,CAAC;AAEF;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,gBAAwC,EAAE,OAAyB;IAClG,IAAI,gBAAgB,EAAE;QACpB,MAAM,aAAa,GAAG,IAAA,6BAAmB,EAAC,gBAAgB,EAAE,OAAO,CAAC,EAAE,aAAa,CAAC;QACpF,IAAI,aAAa,EAAE;YACjB,OAAO,aAAa,CAAC;SACtB;KACF;IACD,OAAO,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC;SACnC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACvB,IAAI;gBACF,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,GAAG,eAAe,CAAC,CAAC;aACjD;YAAC,MAAM;gBACN,OAAO,KAAK,CAAC;aACd;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,EAAE,CAAC,CAAC,CAA4B,CAAC;AACvC,CAAC;AAjBD,4CAiBC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/rule-factories/get-test-frameworks/index.ts"],"names":[],"mappings":";;;AAEA,+CAA0D;AAG1D,MAAM,eAAe,GAA8C;IACjE,MAAM,EAAE,CAAC,MAAM,CAAC;IAChB,SAAS,EAAE,CAAC,cAAc,CAAC;CAC5B,CAAC;AAEF;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,gBAAwC,EAAE,OAAyB;IAClG,IAAI,gBAAgB,EAAE;QACpB,MAAM,aAAa,GAAG,IAAA,2BAAmB,EAAC,gBAAgB,EAAE,OAAO,CAAC,EAAE,aAAa,CAAC;QACpF,IAAI,aAAa,EAAE;YACjB,OAAO,aAAa,CAAC;SACtB;KACF;IACD,OAAO,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC;SACnC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACvB,IAAI;gBACF,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,GAAG,eAAe,CAAC,CAAC;aACjD;YAAC,MAAM;gBACN,OAAO,KAAK,CAAC;aACd;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,EAAE,CAAC,CAAC,CAA4B,CAAC;AACvC,CAAC;AAjBD,4CAiBC"}
@@ -1,6 +1,6 @@
1
1
  export * from './add-imports/index';
2
2
  export * from './eslint-fix/index';
3
- export * from './interfaces';
3
+ export * from '../interfaces/rule-factories';
4
4
  export * from './get-test-frameworks/index';
5
5
  export * from './check-packages-peers/index';
6
6
  export * from './ng-add/index';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rule-factories/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rule-factories/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC"}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./add-imports/index"), exports);
5
5
  tslib_1.__exportStar(require("./eslint-fix/index"), exports);
6
- tslib_1.__exportStar(require("./interfaces"), exports);
6
+ tslib_1.__exportStar(require("../interfaces/rule-factories"), exports);
7
7
  tslib_1.__exportStar(require("./get-test-frameworks/index"), exports);
8
8
  tslib_1.__exportStar(require("./check-packages-peers/index"), exports);
9
9
  tslib_1.__exportStar(require("./ng-add/index"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rule-factories/index.ts"],"names":[],"mappings":";;;AAAA,8DAAoC;AACpC,6DAAmC;AACnC,uDAA6B;AAC7B,sEAA4C;AAC5C,uEAA6C;AAC7C,yDAA+B;AAC/B,kEAAwC;AACxC,iEAAuC;AACvC,oEAA0C;AAC1C,4DAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rule-factories/index.ts"],"names":[],"mappings":";;;AAAA,8DAAoC;AACpC,6DAAmC;AACnC,uEAA6C;AAC7C,sEAA4C;AAC5C,uEAA6C;AAC7C,yDAA+B;AAC/B,kEAAwC;AACxC,iEAAuC;AACvC,oEAA0C;AAC1C,4DAAkC"}
@@ -0,0 +1,78 @@
1
+ import { Rule, type TaskId, Tree } from '@angular-devkit/schematics';
2
+ import { NodeDependencyType } from '@schematics/angular/utility/dependencies';
3
+ import { SupportedPackageManagers } from '../../utility';
4
+ /**
5
+ * Options to be passed to the ng add task
6
+ */
7
+ export interface NgAddSchematicOptions {
8
+ /** Name of the project */
9
+ projectName?: string | null;
10
+ /** Skip the run of the linter*/
11
+ skipLinter?: boolean;
12
+ /** Skip the install process */
13
+ skipInstall?: boolean;
14
+ [x: string]: any;
15
+ }
16
+ export interface DependencyInManifest {
17
+ /**
18
+ * Range of the dependency
19
+ * @default 'latest'
20
+ */
21
+ range?: string;
22
+ /**
23
+ * Types of the dependency
24
+ * @default [NodeDependencyType.Default]
25
+ */
26
+ types?: NodeDependencyType[];
27
+ }
28
+ export interface DependencyToAdd {
29
+ /** Enforce this dependency to be applied to Workspace's manifest only */
30
+ toWorkspaceOnly?: boolean;
31
+ /** List of dependency to register in manifest */
32
+ inManifest: DependencyInManifest[];
33
+ /** ng-add schematic option dedicated to the package */
34
+ ngAddOptions?: NgAddSchematicOptions;
35
+ /** Determine if the dependency require to be installed */
36
+ requireInstall?: boolean;
37
+ }
38
+ export interface SetupDependenciesOptions {
39
+ /** Map of dependencies to install */
40
+ dependencies: Record<string, DependencyToAdd>;
41
+ /**
42
+ * Pattern of list of the dependency for which the ng-add run process is required
43
+ */
44
+ ngAddToRun?: (RegExp | string)[];
45
+ /**
46
+ * Will skip install in the end of the package.json update.
47
+ * if `undefined`, the installation will be process only if a ngAdd run is required.
48
+ * If `true` the install will not run in any case
49
+ * @default undefined
50
+ */
51
+ skipInstall?: boolean;
52
+ /** Project Name */
53
+ projectName?: string;
54
+ /** default ng-add schematic option */
55
+ ngAddOptions?: NgAddSchematicOptions;
56
+ /** Enforce install package manager */
57
+ packageManager?: SupportedPackageManagers;
58
+ /** Task will run after the given task ID (if specified) */
59
+ runAfterTasks?: TaskId[];
60
+ /** Callback to run after the task ID is calculated */
61
+ scheduleTaskCallback?: (taskIds?: TaskId[]) => void;
62
+ }
63
+ /**
64
+ * Retrieve the package install configuration
65
+ * This is a workaround to ng-add to add the dependency to the sub-package
66
+ * @param packageJsonPath Path to the module package.json file
67
+ * @param tree Tree to read the file
68
+ * @param projectName Name of the project
69
+ * @param devDependencyOnly If true, the dependency will be added as devDependency
70
+ */
71
+ export declare const getPackageInstallConfig: (packageJsonPath: string, tree: Tree, projectName?: string, devDependencyOnly?: boolean) => Record<string, DependencyToAdd>;
72
+ /**
73
+ * Setup dependency to a repository.
74
+ * Will run manually the ngAdd schematics according to the parameters and install the packages if required
75
+ * @param options
76
+ */
77
+ export declare const setupDependencies: (options: SetupDependenciesOptions) => Rule;
78
+ //# sourceMappingURL=dependencies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../../src/rule-factories/ng-add/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,IAAI,EAAa,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAI9E,OAAO,EAAyE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAIhI;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,0BAA0B;IAC1B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B,gCAAgC;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,+BAA+B;IAC/B,WAAW,CAAC,EAAE,OAAO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
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupDependencies = exports.getPackageInstallConfig = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const dependencies_1 = require("@schematics/angular/utility/dependencies");
6
+ const path = require("node:path");
7
+ const semver = require("semver");
8
+ const utility_1 = require("../../utility");
9
+ const tasks_1 = require("@angular-devkit/schematics/tasks");
10
+ const node_fs_1 = require("node:fs");
11
+ /**
12
+ * Retrieve the package install configuration
13
+ * This is a workaround to ng-add to add the dependency to the sub-package
14
+ * @param packageJsonPath Path to the module package.json file
15
+ * @param tree Tree to read the file
16
+ * @param projectName Name of the project
17
+ * @param devDependencyOnly If true, the dependency will be added as devDependency
18
+ */
19
+ const getPackageInstallConfig = (packageJsonPath, tree, projectName, devDependencyOnly) => {
20
+ if (!projectName) {
21
+ return {};
22
+ }
23
+ const packageJson = JSON.parse((0, node_fs_1.readFileSync)(packageJsonPath, { encoding: 'utf-8' }));
24
+ const workspaceProject = projectName ? (0, utility_1.getWorkspaceConfig)(tree)?.projects[projectName] : undefined;
25
+ return {
26
+ [packageJson.name]: {
27
+ inManifest: [{
28
+ range: `~${packageJson.version}`,
29
+ types: devDependencyOnly ? [dependencies_1.NodeDependencyType.Dev] : (0, utility_1.getProjectNewDependenciesTypes)(workspaceProject)
30
+ }],
31
+ requireInstall: true
32
+ }
33
+ };
34
+ };
35
+ exports.getPackageInstallConfig = getPackageInstallConfig;
36
+ /**
37
+ * Setup dependency to a repository.
38
+ * Will run manually the ngAdd schematics according to the parameters and install the packages if required
39
+ * @param options
40
+ */
41
+ const setupDependencies = (options) => {
42
+ return () => {
43
+ const ngAddToRun = new Set(Object.keys(options.dependencies)
44
+ .filter((dep) => options.ngAddToRun?.some((pattern) => typeof pattern === 'string' ? pattern === dep : pattern.test(dep))));
45
+ const requiringInstallList = new Set(Object.entries(options.dependencies).filter(([, { requireInstall }]) => requireInstall).map(([dep]) => dep));
46
+ const isInstallNeeded = () => options.skipInstall !== undefined ? !options.skipInstall : (ngAddToRun.size > 0 || requiringInstallList.size > 0);
47
+ const editPackageJson = (packageJsonPath, packageToInstall, dependency, updateLists) => {
48
+ return (tree, context) => {
49
+ if (!tree.exists(packageJsonPath)) {
50
+ context.logger.warn(`The file ${packageJsonPath} does not exist, the dependency ${packageToInstall} will not be added`);
51
+ return tree;
52
+ }
53
+ const packageJsonContent = tree.readJson(packageJsonPath);
54
+ dependency.inManifest.forEach(({ range, types }) => {
55
+ (types || [dependencies_1.NodeDependencyType.Default]).forEach((depType) => {
56
+ if (packageJsonContent[depType]?.[packageToInstall]) {
57
+ if (range && semver.validRange(range)) {
58
+ const currentMinimalVersion = semver.minVersion(packageJsonContent[depType]?.[packageToInstall]);
59
+ const myRangeMinimalVersion = semver.minVersion(range);
60
+ if (currentMinimalVersion && myRangeMinimalVersion && semver.gt(myRangeMinimalVersion, currentMinimalVersion)) {
61
+ context.logger.debug(`The dependency ${packageToInstall} (${depType}@${range}) will be added in ${packageJsonPath}`);
62
+ packageJsonContent[depType][packageToInstall] = range;
63
+ }
64
+ else {
65
+ if (updateLists) {
66
+ ngAddToRun.delete(packageToInstall);
67
+ requiringInstallList.delete(packageToInstall);
68
+ }
69
+ context.logger.debug(`The dependency ${packageToInstall} (${depType}) is already in ${packageJsonPath}, it will not be added.`);
70
+ context.logger.debug(`Because its range is inferior or included to the current one (${range} < ${packageJsonContent[depType][packageToInstall]}) in targeted ${packageJsonPath}`);
71
+ }
72
+ }
73
+ else {
74
+ if (updateLists) {
75
+ ngAddToRun.delete(packageToInstall);
76
+ requiringInstallList.delete(packageToInstall);
77
+ }
78
+ context.logger.warn(`The dependency ${packageToInstall} (${depType}) will not added ` +
79
+ `because there is already this dependency with a defined range (${packageJsonContent[depType][packageToInstall]}) in targeted ${packageJsonPath}`);
80
+ }
81
+ }
82
+ else {
83
+ packageJsonContent[depType] ||= {};
84
+ packageJsonContent[depType][packageToInstall] = range;
85
+ context.logger.debug(`The dependency ${packageToInstall} (${depType}@${range}) will be added in ${packageJsonPath}`);
86
+ }
87
+ packageJsonContent[depType] = Object.keys(packageJsonContent[depType])
88
+ .sort()
89
+ .reduce((acc, key) => {
90
+ acc[key] = packageJsonContent[depType][key];
91
+ return acc;
92
+ }, {});
93
+ });
94
+ });
95
+ const content = JSON.stringify(packageJsonContent, null, 2);
96
+ tree.overwrite(packageJsonPath, content);
97
+ return tree;
98
+ };
99
+ };
100
+ const addDependencies = (tree) => {
101
+ const workspaceConfig = (0, utility_1.getWorkspaceConfig)(tree);
102
+ const workspaceProject = options.projectName && workspaceConfig?.projects?.[options.projectName] || undefined;
103
+ const projectDirectory = workspaceProject?.root;
104
+ return (0, schematics_1.chain)(Object.entries(options.dependencies)
105
+ .map(([packageName, dependencyDetails]) => {
106
+ const shouldRunInSubPackage = projectDirectory && !dependencyDetails.toWorkspaceOnly;
107
+ const rootPackageRule = editPackageJson('package.json', packageName, dependencyDetails, !shouldRunInSubPackage);
108
+ if (shouldRunInSubPackage) {
109
+ return (0, schematics_1.chain)([
110
+ rootPackageRule,
111
+ editPackageJson(path.posix.join(projectDirectory, 'package.json'), packageName, dependencyDetails, true)
112
+ ]);
113
+ }
114
+ return rootPackageRule;
115
+ }));
116
+ };
117
+ const runNgAddSchematics = (_, context) => {
118
+ const packageManager = options.packageManager || (0, utility_1.getPackageManager)();
119
+ const installId = isInstallNeeded() ? [context.addTask(new tasks_1.NodePackageInstallTask({ packageManager, quiet: true }), options.runAfterTasks)] : undefined;
120
+ if (installId !== undefined) {
121
+ context.logger.debug(`Schedule the installation of the workspace (${ngAddToRun.size > 0 ? 'for: ' + [...ngAddToRun].join(', ') : options.skipInstall ? 'skipped' : 'forced'})`);
122
+ }
123
+ const getOptions = (packageName, schema) => {
124
+ const schemaOptions = schema?.description.schemaJson?.properties;
125
+ return Object.fromEntries(Object.entries({ projectName: options.projectName, ...options.ngAddOptions, ...options.dependencies[packageName].ngAddOptions })
126
+ .filter(([key]) => !schemaOptions || !!schemaOptions[key]));
127
+ };
128
+ const finalTaskId = [...ngAddToRun]
129
+ .map((packageName) => {
130
+ let schematic;
131
+ try {
132
+ const collection = context.engine.createCollection(packageName);
133
+ schematic = collection.createSchematic('ng-add');
134
+ }
135
+ catch (e) {
136
+ context.logger.warn(`The package ${packageName} was not installed, the options check will be skipped`, e);
137
+ }
138
+ const schematicOptions = getOptions(packageName, schematic);
139
+ return { packageName, schematicOptions };
140
+ })
141
+ .reduce((ids, { packageName, schematicOptions }) => {
142
+ context.logger.debug(`Schedule the schematic ng-add for ${packageName}`);
143
+ return [...ids, context.addTask(new tasks_1.RunSchematicTask(packageName, 'ng-add', schematicOptions), ids)];
144
+ }, [...(installId || []), ...(options.runAfterTasks || [])]);
145
+ if (options.scheduleTaskCallback) {
146
+ options.scheduleTaskCallback(finalTaskId);
147
+ }
148
+ };
149
+ return (0, schematics_1.chain)([
150
+ addDependencies,
151
+ runNgAddSchematics
152
+ ]);
153
+ };
154
+ };
155
+ exports.setupDependencies = setupDependencies;
156
+ //# sourceMappingURL=dependencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../../src/rule-factories/ng-add/dependencies.ts"],"names":[],"mappings":";;;AAAA,2DAAuF;AACvF,2EAA8E;AAC9E,kCAAkC;AAElC,iCAAiC;AACjC,2CAAgI;AAChI,4DAA4F;AAC5F,qCAAuC;AAoEvC;;;;;;;GAOG;AACI,MAAM,uBAAuB,GAAG,CAAC,eAAuB,EAAE,IAAU,EAAE,WAAoB,EAAE,iBAA2B,EAAmC,EAAE;IACjK,IAAI,CAAC,WAAW,EAAE;QAChB,OAAO,EAAE,CAAC;KACX;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,sBAAY,EAAC,eAAe,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC,CAAC,CAAgB,CAAC;IAClG,MAAM,gBAAgB,GAAG,WAAW,CAAC,CAAC,CAAC,IAAA,4BAAkB,EAAC,IAAI,CAAC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IACL,CAAC,CAAC;AAEJ,CAAC,CAAC;AA5HW,QAAA,iBAAiB,qBA4H5B"}
@@ -1,37 +1,4 @@
1
- import { Rule } from '@angular-devkit/schematics';
2
- import { NodeDependencyType } from '@schematics/angular/utility/dependencies';
3
- import type { PackageJson } from 'type-fest';
4
- import { SchematicOptionObject } from '../../interfaces';
5
- import type { NgAddPackageOptions } from '../../tasks/index';
6
- /**
7
- * Install via `ng add` a list of npm packages.
8
- * @param packages List of packages to be installed via `ng add`
9
- * @param options install options
10
- * @param packageJsonPath path of the package json of the project where they will be installed
11
- */
12
- export declare function ngAddPackages(packages: string[], options?: Omit<NgAddPackageOptions, 'version'> & {
13
- version?: string | (string | undefined)[];
14
- }, packageJsonPath?: string): Rule;
15
- /**
16
- * Look for the peer dependencies and run ng add on the package requested version
17
- * @param packages list of the name of the packages needed
18
- * @param packageJsonPath path to package json that needs the peer to be resolved
19
- * @param type how to install the dependency (dev, peer for a library or default for an application)
20
- * @param options
21
- * @param parentPackageInfo for logging purposes
22
- */
23
- export declare function ngAddPeerDependencyPackages(packages: string[], packageJsonPath: string, type: NodeDependencyType | undefined, options: NgAddPackageOptions, parentPackageInfo?: string): Rule;
24
- /**
25
- * Register the given package in the Angular CLI schematics
26
- * @param packageJson PackageJson of the project containing the collection to add to the project
27
- * @param angularJsonFile Path to the Angular.json file. Will use the workspace root's angular.json if not specified
28
- */
29
- export declare function registerPackageCollectionSchematics(packageJson: PackageJson, angularJsonFile?: string): Rule;
30
- /**
31
- * Setup schematics default params in angular.json
32
- * @param schematicsDefaultParams default params to setup by schematic
33
- * @param overrideValue Define if the given value should override the one already defined in the workspace
34
- * @param angularJsonFile Path to the Angular.json file. Will use the workspace root's angular.json if not specified
35
- */
36
- export declare function setupSchematicsDefaultParams(schematicsDefaultParams: Record<string, SchematicOptionObject>, overrideValue?: boolean, angularJsonFile?: string): Rule;
1
+ export * from './schematics-register';
2
+ export * from './dependencies';
3
+ export * from './ng-add.helpers';
37
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/rule-factories/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,IAAI,EAA+B,MAAM,4BAA4B,CAAC;AAG/G,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAI9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAA;CAAE,EAAE,eAAe,SAAkB,GAAG,IAAI,CA0HzL;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,MAAM,EAAE,IAAI,gCAAiD,EAC5I,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,CAAC,EAAE,MAAM,QAgBzD;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CAAC,WAAW,EAAE,WAAW,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAY5G;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,EAAE,aAAa,UAAQ,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAgClK"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/rule-factories/ng-add/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC"}
@@ -1,221 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setupSchematicsDefaultParams = exports.registerPackageCollectionSchematics = exports.ngAddPeerDependencyPackages = exports.ngAddPackages = void 0;
4
- const schematics_1 = require("@angular-devkit/schematics");
5
- const tasks_1 = require("@angular-devkit/schematics/tasks");
6
- const dependencies_1 = require("@schematics/angular/utility/dependencies");
7
- const node_fs_1 = require("node:fs");
8
- const path = require("node:path");
9
- const rxjs_1 = require("rxjs");
10
- const index_1 = require("../../utility/index");
11
- /**
12
- * Install via `ng add` a list of npm packages.
13
- * @param packages List of packages to be installed via `ng add`
14
- * @param options install options
15
- * @param packageJsonPath path of the package json of the project where they will be installed
16
- */
17
- function ngAddPackages(packages, options, packageJsonPath = '/package.json') {
18
- if (!packages.length) {
19
- return schematics_1.noop;
20
- }
21
- const cwd = process.cwd().replace(/[\\/]+/g, '/');
22
- // FileSystem working directory might be different from Tree working directory (when using `yarn workspace` for example)
23
- const fsWorkingDirectory = (options?.workingDirectory && !cwd.endsWith(options.workingDirectory)) ? options.workingDirectory : '.';
24
- const versions = Object.fromEntries(packages.map((packageName, index) => [packageName, typeof options?.version === 'object' ? options.version[index] : options?.version]));
25
- if (options?.workingDirectory && !packageJsonPath.startsWith(options.workingDirectory)) {
26
- packageJsonPath = path.join(options.workingDirectory, packageJsonPath);
27
- }
28
- const getInstalledVersion = (packageName) => {
29
- let versionFound;
30
- for (const workingDirectory of new Set([fsWorkingDirectory, '.'])) {
31
- try {
32
- const fileSystemPackageJson = JSON.parse((0, node_fs_1.readFileSync)(path.join(workingDirectory, 'package.json'), { encoding: 'utf8' }));
33
- let version;
34
- if (options?.dependencyType === dependencies_1.NodeDependencyType.Dev) {
35
- version = fileSystemPackageJson.devDependencies[packageName];
36
- }
37
- else if (options?.dependencyType === dependencies_1.NodeDependencyType.Peer) {
38
- version = fileSystemPackageJson.peerDependencies[packageName];
39
- }
40
- else {
41
- version = fileSystemPackageJson.dependencies[packageName];
42
- }
43
- if (versionFound && version !== versionFound) {
44
- // In case of conflict between package.json files, we consider the package as not installed to force its update
45
- return;
46
- }
47
- versionFound = version;
48
- }
49
- catch (e) {
50
- return;
51
- }
52
- }
53
- return versionFound;
54
- };
55
- const getNgAddSchema = (packageName, context) => {
56
- try {
57
- const collection = context.engine.createCollection(packageName);
58
- return collection.createSchematic('ng-add');
59
- }
60
- catch {
61
- context.logger.warn(`No ng-add found for ${packageName}`);
62
- return undefined;
63
- }
64
- };
65
- const getOptions = (schema) => {
66
- const schemaOptions = schema.description.schemaJson?.properties || {};
67
- return Object.entries(options || {}).reduce((accOptions, [key, value]) => {
68
- if (schemaOptions[key]) {
69
- accOptions[key] = value;
70
- }
71
- return accOptions;
72
- }, {});
73
- };
74
- const installedVersions = packages.map((packageName) => getInstalledVersion(packageName));
75
- const packageManager = (0, index_1.getPackageManager)();
76
- const packagesToInstall = packages.filter((packageName, index) => !installedVersions[index] || installedVersions[index] !== versions[packageName]);
77
- if (packagesToInstall.length < 1) {
78
- return schematics_1.noop;
79
- }
80
- return (0, schematics_1.chain)([
81
- // Update package.json in tree
82
- (tree) => {
83
- const sortDependencies = (packageJson, depType) => {
84
- packageJson[depType] = packageJson[depType] ?
85
- Object.fromEntries(Object.entries(packageJson[depType]).sort(([key1, _val1], [key2, _val2]) => key1.localeCompare(key2))) :
86
- undefined;
87
- };
88
- for (const filePath of new Set([packageJsonPath, './package.json'])) {
89
- const packageJson = tree.readJson(filePath);
90
- packages.forEach((packageName) => {
91
- const version = versions[packageName] || 'latest';
92
- if (options?.dependencyType === dependencies_1.NodeDependencyType.Dev) {
93
- packageJson.devDependencies = { ...packageJson.devDependencies, [packageName]: version };
94
- }
95
- else if (options?.dependencyType === dependencies_1.NodeDependencyType.Peer) {
96
- packageJson.peerDependencies = { ...packageJson.peerDependencies, [packageName]: version };
97
- }
98
- else {
99
- packageJson.dependencies = { ...packageJson.dependencies, [packageName]: version };
100
- }
101
- });
102
- ['dependencies', 'devDependencies', 'peerDependencies'].forEach((depType) => {
103
- sortDependencies(packageJson, depType);
104
- });
105
- tree.overwrite(filePath, JSON.stringify(packageJson, null, 2));
106
- }
107
- },
108
- // Run ng-adds
109
- async (tree, context) => {
110
- if (options?.skipNgAddSchematicRun) {
111
- context.logger.info(`Package(s) '${packagesToInstall.join(', ')}' was(were) installed.
112
- The run of 'ng-add' schematics for the package(s) is intentionally skipped. You can do the run standalone, later.`);
113
- return schematics_1.noop;
114
- }
115
- new Set([packageJsonPath, './package.json']).forEach((filePath) => {
116
- (0, node_fs_1.mkdirSync)(path.join(process.cwd(), path.dirname(filePath)), { recursive: true });
117
- (0, node_fs_1.writeFileSync)(path.join(process.cwd(), filePath), tree.readText(filePath));
118
- });
119
- context.addTask(new tasks_1.NodePackageInstallTask({
120
- packageManager: packageManager,
121
- hideOutput: false,
122
- quiet: false
123
- }));
124
- await (0, rxjs_1.lastValueFrom)(context.engine.executePostTasks());
125
- const ngAddsToApply = packagesToInstall
126
- .map((packageName) => ({ packageName, ngAddCollection: getNgAddSchema(packageName, context) }))
127
- .filter(({ packageName, ngAddCollection }) => {
128
- if (!ngAddCollection) {
129
- context.logger.info(`No ng-add schematic found for: '${packageName}'. Skipping ng add for: ${packageName}${versions[packageName] ? ' with version: ' + versions[packageName] : ''}`);
130
- }
131
- return !!ngAddCollection;
132
- })
133
- .map(({ packageName, ngAddCollection }) => (0, schematics_1.externalSchematic)(packageName, 'ng-add', getOptions(ngAddCollection)));
134
- return (0, schematics_1.chain)(ngAddsToApply);
135
- }
136
- ]);
137
- }
138
- exports.ngAddPackages = ngAddPackages;
139
- /**
140
- * Look for the peer dependencies and run ng add on the package requested version
141
- * @param packages list of the name of the packages needed
142
- * @param packageJsonPath path to package json that needs the peer to be resolved
143
- * @param type how to install the dependency (dev, peer for a library or default for an application)
144
- * @param options
145
- * @param parentPackageInfo for logging purposes
146
- */
147
- function ngAddPeerDependencyPackages(packages, packageJsonPath, type = dependencies_1.NodeDependencyType.Default, options, parentPackageInfo) {
148
- if (!packages.length) {
149
- return schematics_1.noop;
150
- }
151
- const dependencies = (0, index_1.getNodeDependencyList)((0, index_1.getExternalDependenciesVersionRange)(packages, packageJsonPath), type);
152
- return ngAddPackages(dependencies.map(({ name }) => name), {
153
- ...options,
154
- skipConfirmation: true,
155
- version: dependencies.map(({ version }) => version),
156
- parentPackageInfo,
157
- dependencyType: type,
158
- workingDirectory: options.workingDirectory
159
- });
160
- }
161
- exports.ngAddPeerDependencyPackages = ngAddPeerDependencyPackages;
162
- /**
163
- * Register the given package in the Angular CLI schematics
164
- * @param packageJson PackageJson of the project containing the collection to add to the project
165
- * @param angularJsonFile Path to the Angular.json file. Will use the workspace root's angular.json if not specified
166
- */
167
- function registerPackageCollectionSchematics(packageJson, angularJsonFile) {
168
- return (tree, context) => {
169
- if (!packageJson.name) {
170
- return tree;
171
- }
172
- const workspace = (0, index_1.getWorkspaceConfig)(tree, angularJsonFile);
173
- if (!workspace) {
174
- context.logger.error('No workspace found');
175
- return tree;
176
- }
177
- return (0, index_1.writeAngularJson)(tree, (0, index_1.registerCollectionSchematics)(workspace, packageJson.name), angularJsonFile);
178
- };
179
- }
180
- exports.registerPackageCollectionSchematics = registerPackageCollectionSchematics;
181
- /**
182
- * Setup schematics default params in angular.json
183
- * @param schematicsDefaultParams default params to setup by schematic
184
- * @param overrideValue Define if the given value should override the one already defined in the workspace
185
- * @param angularJsonFile Path to the Angular.json file. Will use the workspace root's angular.json if not specified
186
- */
187
- function setupSchematicsDefaultParams(schematicsDefaultParams, overrideValue = false, angularJsonFile) {
188
- return (tree, context) => {
189
- const workspace = (0, index_1.getWorkspaceConfig)(tree, angularJsonFile);
190
- if (!workspace) {
191
- context.logger.error('No workspace found');
192
- return tree;
193
- }
194
- workspace.schematics ||= {};
195
- Object.entries(schematicsDefaultParams).forEach(([schematicName, defaultParams]) => {
196
- workspace.schematics[schematicName] = overrideValue ? {
197
- ...workspace.schematics[schematicName],
198
- ...defaultParams
199
- } : {
200
- ...defaultParams,
201
- ...workspace.schematics[schematicName]
202
- };
203
- });
204
- Object.values(workspace.projects).forEach((project) => {
205
- Object.entries(schematicsDefaultParams).forEach(([schematicName, defaultParams]) => {
206
- if (project.schematics?.[schematicName]) {
207
- project.schematics[schematicName] = overrideValue ? {
208
- ...project.schematics[schematicName],
209
- ...defaultParams
210
- } : {
211
- ...defaultParams,
212
- ...project.schematics[schematicName]
213
- };
214
- }
215
- });
216
- });
217
- return (0, index_1.writeAngularJson)(tree, workspace, angularJsonFile);
218
- };
219
- }
220
- exports.setupSchematicsDefaultParams = setupSchematicsDefaultParams;
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./schematics-register"), exports);
5
+ tslib_1.__exportStar(require("./dependencies"), exports);
6
+ tslib_1.__exportStar(require("./ng-add.helpers"), exports);
221
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/rule-factories/ng-add/index.ts"],"names":[],"mappings":";;;AAAA,2DAA+G;AAC/G,4DAA0E;AAE1E,2EAA8E;AAC9E,qCAAiE;AACjE,kCAAkC;AAClC,+BAAqC;AAIrC,+CAAwL;AAExL;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,QAAkB,EAAE,OAA8F,EAAE,eAAe,GAAG,eAAe;IACjL,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;QACpB,OAAO,iBAAI,CAAC;KACb;IACD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAClD,wHAAwH;IACxH,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,gBAAgB,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC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E,SAAS,EAAE,eAAe,CAAC,CAAC;IAC5D,CAAC,CAAC;AACJ,CAAC;AAhCD,oEAgCC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/rule-factories/ng-add/index.ts"],"names":[],"mappings":";;;AAAA,gEAAsC;AACtC,yDAA+B;AAC/B,2DAAiC"}
@@ -0,0 +1,22 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ import { NodeDependencyType } from '@schematics/angular/utility/dependencies';
3
+ import type { NgAddPackageOptions } from '../../tasks/index';
4
+ /**
5
+ * Install via `ng add` a list of npm packages.
6
+ * @param packages List of packages to be installed via `ng add`
7
+ * @param options install options
8
+ * @param packageJsonPath path of the package json of the project where they will be installed
9
+ */
10
+ export declare function ngAddPackages(packages: string[], options?: Omit<NgAddPackageOptions, 'version'> & {
11
+ version?: string | (string | undefined)[];
12
+ }, packageJsonPath?: string): Rule;
13
+ /**
14
+ * Look for the peer dependencies and run ng add on the package requested version
15
+ * @param packages list of the name of the packages needed
16
+ * @param packageJsonPath path to package json that needs the peer to be resolved
17
+ * @param type how to install the dependency (dev, peer for a library or default for an application)
18
+ * @param options
19
+ * @param parentPackageInfo for logging purposes
20
+ */
21
+ export declare function ngAddPeerDependencyPackages(packages: string[], packageJsonPath: string, type: NodeDependencyType | undefined, options: NgAddPackageOptions, parentPackageInfo?: string): Rule;
22
+ //# sourceMappingURL=ng-add.helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ng-add.helpers.d.ts","sourceRoot":"","sources":["../../../../src/rule-factories/ng-add/ng-add.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,IAAI,EAA+B,MAAM,4BAA4B,CAAC;AAG/G,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAK9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAA;CAAE,EAAE,eAAe,SAAkB,GAAG,IAAI,CA0HzL;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,MAAM,EAAE,IAAI,gCAAiD,EAC5I,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,CAAC,EAAE,MAAM,QAgBzD"}