@o3r/core 10.0.0-prerelease.99 → 10.1.0-prerelease.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 (34) hide show
  1. package/README.md +3 -2
  2. package/esm2022/messages/message.helpers.mjs +1 -1
  3. package/esm2022/store/async/async-entity.adapter.mjs +1 -1
  4. package/esm2022/store/async/async.helpers.mjs +1 -1
  5. package/esm2022/store/async/async.operators.mjs +1 -1
  6. package/esm2022/utils/deep-fill/deep-fill.mjs +1 -1
  7. package/esm2022/utils/rendering/rendering.helpers.mjs +1 -1
  8. package/fesm2022/o3r-core.mjs.map +1 -1
  9. package/package.json +6 -6
  10. package/schematics/component/container/index.js +2 -2
  11. package/schematics/ng-add/index.d.ts +2 -2
  12. package/schematics/ng-add/index.d.ts.map +1 -1
  13. package/schematics/ng-add/index.js +37 -27
  14. package/schematics/ng-add/project-setup/index.d.ts +4 -2
  15. package/schematics/ng-add/project-setup/index.d.ts.map +1 -1
  16. package/schematics/ng-add/project-setup/index.js +26 -22
  17. package/schematics/ng-add-create/templates/schematics/ng-add/index.ts.template +44 -15
  18. package/schematics/ng-add-create/templates/schematics/ng-add/schema.json.template +2 -3
  19. package/schematics/ng-add-create/templates/schematics/ng-add/schema.ts.template +1 -1
  20. package/schematics/rule-factories/additional-modules/index.d.ts +3 -2
  21. package/schematics/rule-factories/additional-modules/index.d.ts.map +1 -1
  22. package/schematics/rule-factories/additional-modules/index.js +19 -12
  23. package/schematics/rule-factories/otter-environment/index.js +1 -1
  24. package/schematics/rule-factories/playwright/index.d.ts +0 -1
  25. package/schematics/rule-factories/playwright/index.d.ts.map +1 -1
  26. package/schematics/rule-factories/playwright/index.js +16 -3
  27. package/schematics/rule-factories/store/index.d.ts +5 -1
  28. package/schematics/rule-factories/store/index.d.ts.map +1 -1
  29. package/schematics/rule-factories/store/index.js +28 -35
  30. package/schematics/shared/presets/helpers.d.ts +1 -1
  31. package/schematics/shared/presets/helpers.d.ts.map +1 -1
  32. package/schematics/shared/presets/helpers.js +23 -11
  33. package/schematics/shared/presets/preset.interface.d.ts +3 -1
  34. package/schematics/shared/presets/preset.interface.d.ts.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAiB/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAyDtD;;;GAGG;AACH,eAAO,MAAM,KAAK,0CAAiD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAK/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AA6EjD;;;GAGG;AACH,eAAO,MAAM,KAAK,0CAAiD,CAAC"}
@@ -2,44 +2,53 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ngAdd = void 0;
4
4
  const schematics_1 = require("@angular-devkit/schematics");
5
- const prompt_1 = require("@angular/cli/src/utilities/prompt");
6
- const schematics_2 = require("@o3r/schematics");
7
5
  const fs = require("node:fs");
8
6
  const path = require("node:path");
9
- const rxjs_1 = require("rxjs");
10
7
  const presets_1 = require("../shared/presets");
8
+ const prompt_1 = require("@angular/cli/src/utilities/prompt");
9
+ const schematics_2 = require("@o3r/schematics");
11
10
  const index_1 = require("./project-setup/index");
11
+ const schematics_3 = require("@o3r/schematics");
12
+ const dependencies_1 = require("@schematics/angular/utility/dependencies");
13
+ const workspacePackageName = '@o3r/workspace';
14
+ const o3rDevDependencies = [
15
+ '@o3r/schematics'
16
+ ];
12
17
  /**
13
18
  * Add Otter library to an Angular Project
14
19
  * @param options
15
20
  */
16
21
  function ngAddFn(options) {
17
22
  const corePackageJsonContent = JSON.parse(fs.readFileSync(path.resolve(__dirname, '..', '..', 'package.json'), { encoding: 'utf-8' }));
18
- const o3rCoreVersion = corePackageJsonContent.version ? `@${corePackageJsonContent.version}` : '';
19
- const schematicsDependencies = ['@o3r/schematics'];
20
- return async (tree, context) => {
21
- // check if the workspace package is installed, if not installed and we are in workspace context, we install
22
- const workspacePackageName = '@o3r/workspace';
23
- if (!options.projectName && !(0, schematics_2.isPackageInstalled)(workspacePackageName)) {
24
- schematicsDependencies.push(workspacePackageName);
23
+ const o3rCoreVersion = corePackageJsonContent.version;
24
+ return () => {
25
+ const dependenciesSetupConfig = {
26
+ projectName: options.projectName,
27
+ dependencies: o3rDevDependencies.reduce((acc, dep) => {
28
+ acc[dep] = {
29
+ inManifest: [{
30
+ range: `~${o3rCoreVersion}`,
31
+ types: [dependencies_1.NodeDependencyType.Dev]
32
+ }]
33
+ };
34
+ return acc;
35
+ }, {}),
36
+ ngAddToRun: [...o3rDevDependencies]
37
+ };
38
+ if (!options.projectName) {
39
+ dependenciesSetupConfig.dependencies[workspacePackageName] = {
40
+ toWorkspaceOnly: true,
41
+ inManifest: [{
42
+ range: `~${o3rCoreVersion}`,
43
+ types: [dependencies_1.NodeDependencyType.Default]
44
+ }]
45
+ };
46
+ (dependenciesSetupConfig.ngAddToRun ||= []).push(workspacePackageName);
25
47
  }
26
- const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
27
- const workingDirectory = workspaceProject?.root || '.';
28
- context.addTask(new schematics_2.AddDevInstall({
29
- packageName: [
30
- ...schematicsDependencies.map((dependency) => dependency + o3rCoreVersion)
31
- ].join(' '),
32
- hideOutput: false,
33
- quiet: false,
34
- workingDirectory,
35
- force: options.forceInstall
36
- }));
37
- await (0, rxjs_1.lastValueFrom)(context.engine.executePostTasks());
38
- return () => (0, schematics_1.chain)([
48
+ return (0, schematics_1.chain)([
39
49
  // eslint-disable-next-line @typescript-eslint/naming-convention
40
50
  (0, schematics_2.setupSchematicsDefaultParams)({ '*:ng-add': { registerDevtool: options.withDevtool } }),
41
- ...schematicsDependencies.map((dep) => (0, schematics_1.externalSchematic)(dep, 'ng-add', options)),
42
- options.projectName ? (0, index_1.prepareProject)(options) : (0, schematics_1.noop)(),
51
+ options.projectName ? (0, index_1.prepareProject)(options, dependenciesSetupConfig) : (0, schematics_1.noop)(),
43
52
  (0, schematics_2.registerPackageCollectionSchematics)(corePackageJsonContent),
44
53
  async (t, c) => {
45
54
  const { preset, externalPresets, ...forwardOptions } = options;
@@ -57,8 +66,9 @@ function ngAddFn(options) {
57
66
  externalPresetRunner?.rule || (0, schematics_1.noop)()
58
67
  ])(t, c);
59
68
  },
60
- (0, schematics_2.displayModuleListRule)({ packageName: options.projectName })
61
- ])(tree, context);
69
+ options.projectName ? (0, schematics_2.displayModuleListRule)({ packageName: options.projectName }) : (0, schematics_1.noop)(),
70
+ (0, schematics_3.setupDependencies)(dependenciesSetupConfig)
71
+ ]);
62
72
  };
63
73
  }
64
74
  /**
@@ -1,9 +1,11 @@
1
- import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
1
+ import { type Rule } from '@angular-devkit/schematics';
2
+ import { type SetupDependenciesOptions } from '@o3r/schematics';
2
3
  import type { NgAddSchematicsSchema } from '../schema';
3
4
  /**
4
5
  * Enable all the otter features requested by the user
5
6
  * Install all the related dependencies and import the features inside the application
6
7
  * @param options installation options to pass to the all the other packages' installation
8
+ * @param dependenciesSetupConfig
7
9
  */
8
- export declare const prepareProject: (options: NgAddSchematicsSchema) => (tree: Tree, context: SchematicContext) => Promise<() => void | Rule | import("@angular-devkit/schematics/src/tree/interface").Tree | import("rxjs").Observable<import("@angular-devkit/schematics/src/tree/interface").Tree> | Promise<void | Rule>>;
10
+ export declare const prepareProject: (options: NgAddSchematicsSchema, dependenciesSetupConfig: SetupDependenciesOptions) => Rule;
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/project-setup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAmBvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAMvD;;;;GAIG;AACH,eAAO,MAAM,cAAc,YAAa,qBAAqB,YAAkB,IAAI,0OA4ClF,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/project-setup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAUpE,OAAO,EAML,KAAK,wBAAwB,EAC9B,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAMvD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,YAAa,qBAAqB,2BAA2B,wBAAwB,KAAG,IA8ClH,CAAC"}
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.prepareProject = void 0;
4
4
  const schematics_1 = require("@angular-devkit/schematics");
5
- const dependencies_1 = require("@schematics/angular/utility/dependencies");
6
5
  const fs = require("node:fs");
7
6
  const path = require("node:path");
8
7
  const index_1 = require("../../rule-factories/index");
@@ -15,8 +14,9 @@ const index_2 = require("../utils/index");
15
14
  * Enable all the otter features requested by the user
16
15
  * Install all the related dependencies and import the features inside the application
17
16
  * @param options installation options to pass to the all the other packages' installation
17
+ * @param dependenciesSetupConfig
18
18
  */
19
- const prepareProject = (options) => async (tree, context) => {
19
+ const prepareProject = (options, dependenciesSetupConfig) => async (tree, context) => {
20
20
  const coreSchematicsFolder = path.resolve(__dirname, '..');
21
21
  const corePackageJsonPath = path.resolve(coreSchematicsFolder, '..', '..', 'package.json');
22
22
  const corePackageJsonContent = JSON.parse(fs.readFileSync(corePackageJsonPath, { encoding: 'utf-8' }));
@@ -34,27 +34,31 @@ const prepareProject = (options) => async (tree, context) => {
34
34
  ...(installOtterLinter ? ['@o3r/eslint-config-otter'] : []),
35
35
  ...depsInfo.o3rPeerDeps
36
36
  ]));
37
- const type = projectType === 'library' ? dependencies_1.NodeDependencyType.Peer : dependencies_1.NodeDependencyType.Default;
38
37
  const projectDirectory = workspaceProject?.root;
39
- const optionsAndWorkingDir = { ...options, workingDirectory: projectDirectory };
40
- return () => {
41
- const appLibRules = [
42
- (0, update_builders_names_1.updateBuildersNames)(),
43
- (0, update_generators_names_1.updateOtterGeneratorsNames)(),
44
- (0, index_1.updateOtterEnvironmentAdapter)(optionsAndWorkingDir, coreSchematicsFolder),
45
- (0, index_1.updateStore)(optionsAndWorkingDir, projectType),
46
- options.enableCustomization && projectType === 'application' ? (0, index_1.updateCustomizationEnvironment)(coreSchematicsFolder, o3rCoreVersion, optionsAndWorkingDir, false) : schematics_1.noop,
47
- projectType === 'application' ? (0, index_1.updateAdditionalModules)(optionsAndWorkingDir, coreSchematicsFolder) : schematics_1.noop,
48
- (0, schematics_2.removePackages)(replaced_packages_1.packagesToRemove),
49
- (0, index_1.o3rBasicUpdates)(options.projectName, o3rCoreVersion, projectType),
50
- (0, schematics_2.ngAddPackages)(internalPackagesToInstallWithNgAdd, { skipConfirmation: true, version: o3rCoreVersion, parentPackageInfo: '@o3r/core - setup', projectName: options.projectName, dependencyType: type, workingDirectory: projectDirectory }),
51
- // task that should run after the schematics should be after the ng-add task as they will wait for the package installation before running the other dependencies
52
- !options.skipLinter && installOtterLinter ? (0, schematics_2.applyEsLintFix)() : (0, schematics_1.noop)(),
53
- // dependencies for store (mainly ngrx, store dev tools, storage sync), playwright, linter are installed by hand if the option is active
54
- options.skipInstall ? (0, schematics_1.noop)() : schematics_2.install
55
- ];
56
- return (0, schematics_1.chain)(appLibRules)(tree, context);
57
- };
38
+ const optionsAndWorkingDir = { ...options, workingDirectory: projectDirectory, dependenciesSetupConfig };
39
+ internalPackagesToInstallWithNgAdd
40
+ .forEach((dep) => {
41
+ dependenciesSetupConfig.dependencies[dep] = {
42
+ inManifest: [{
43
+ range: `~${o3rCoreVersion}`,
44
+ types: (0, schematics_2.getProjectNewDependenciesTypes)(workspaceProject)
45
+ }]
46
+ };
47
+ });
48
+ (dependenciesSetupConfig.ngAddToRun ||= []).push(...internalPackagesToInstallWithNgAdd);
49
+ const appLibRules = [
50
+ (0, update_builders_names_1.updateBuildersNames)(),
51
+ (0, update_generators_names_1.updateOtterGeneratorsNames)(),
52
+ (0, index_1.updateOtterEnvironmentAdapter)(optionsAndWorkingDir, coreSchematicsFolder),
53
+ (0, index_1.updateStore)(optionsAndWorkingDir, projectType),
54
+ options.enableCustomization && projectType === 'application' ? (0, index_1.updateCustomizationEnvironment)(coreSchematicsFolder, o3rCoreVersion, optionsAndWorkingDir, false) : schematics_1.noop,
55
+ projectType === 'application' ? (0, index_1.updateAdditionalModules)(optionsAndWorkingDir, dependenciesSetupConfig) : schematics_1.noop,
56
+ (0, schematics_2.removePackages)(replaced_packages_1.packagesToRemove),
57
+ (0, index_1.o3rBasicUpdates)(options.projectName, o3rCoreVersion, projectType),
58
+ // task that should run after the schematics should be after the ng-add task as they will wait for the package installation before running the other dependencies
59
+ !options.skipLinter && installOtterLinter ? (0, schematics_2.applyEsLintFix)() : (0, schematics_1.noop)()
60
+ ];
61
+ return (0, schematics_1.chain)(appLibRules);
58
62
  };
59
63
  exports.prepareProject = prepareProject;
60
64
  //# sourceMappingURL=index.js.map
@@ -1,32 +1,61 @@
1
1
  import { chain, noop, Rule } from '@angular-devkit/schematics';
2
- import { applyEsLintFix, createSchematicWithMetricsIfInstalled, install, ngAddPackages, getO3rPeerDeps } from '@o3r/schematics';
3
2
  import type { NgAddSchematicsSchema } from './schema';
4
3
  import * as path from 'node:path';
4
+ import { type DependencyToAdd } from '@o3r/schematics';
5
+
6
+ const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
5
7
 
6
8
  const doCustomAction: Rule = (tree, _context) => {
7
9
  // your custom code here
8
10
  return tree;
9
11
  };
10
12
 
13
+ const dependenciesToInstall = [
14
+ // Add the dependencies to install here
15
+ ];
16
+
17
+ const dependenciesToNgAdd = [
18
+ // Add the dependencies to install with NgAdd here
19
+ ];
20
+
11
21
  /**
12
22
  * Add Otter <%= featureName %> to an Otter Project
13
23
  *
14
24
  * @param options
15
25
  */
16
26
  function ngAddFn(options: NgAddSchematicsSchema): Rule {
17
- return async (_tree, context) => {
18
- // retrieve dependencies following the /^@o3r\/.*/ pattern within the peerDependencies of the current module
19
- const depsInfo = getO3rPeerDeps(path.resolve(__dirname, '..', '..', 'package.json'));
20
- return chain([
21
- // optional custom action dedicated to this module
22
- doCustomAction,
23
- options.skipLinter ? noop() : applyEsLintFix(),
24
- // install packages needed in the current module
25
- options.skipInstall ? noop : install,
26
- // add the missing Otter modules in the current project
27
- ngAddPackages(depsInfo.o3rPeerDeps, { skipConfirmation: true, version: depsInfo.packageVersion, parentPackageInfo: `${depsInfo.packageName!} - setup` })
28
- ]);
27
+ return async (tree, context) => {
28
+ try {
29
+ // use dynamic import to properly raise an exception if it is not an Otter project.
30
+ const { getProjectNewDependenciesTypes, getPackageInstallConfig, applyEsLintFix, install } = await import('@o3r/schematics');
31
+ // current package version
32
+ const version = JSON.stringify(fs.readFileSync(packageJsonPath)).version;
33
+ const dependencies = [...dependenciesToInstall, ...dependenciesToNgAdd].reduce((acc, dep) => {
34
+ acc[dep] = {
35
+ inManifest: [{
36
+ range: `~${version}`,
37
+ types: getProjectNewDependenciesTypes(workspaceProject)
38
+ }]
39
+ };
40
+ return acc;
41
+ }, getPackageInstallConfig(packageJsonPath, tree, options.projectName));
42
+ return chain([
43
+ // optional custom action dedicated to this module
44
+ doCustomAction,
45
+ options.skipLinter ? noop() : applyEsLintFix(),
46
+ setupDependencies({
47
+ projectName: options.projectName,
48
+ dependencies,
49
+ ngAddToRun: dependenciesToNgAdd,
50
+ skipInstall: options.skipInstall
51
+ })
52
+ ]);
53
+ } catch (e) {
54
+ // If the installation is initialized in a non-Otter application, mandatory packages will be missing. We need to notify the user
55
+ context.logger.error(`[ERROR]: Adding <%= featureName %> has failed.
56
+ If the error is related to missing @o3r dependencies you need to install '@o3r/core' to be able to use the <%= featureName %> package. Please run 'ng add @o3r/core' .
57
+ Otherwise, use the error message as guidance.`);
58
+ throw (e);
59
+ }
29
60
  };
30
61
  }
31
-
32
- export const ngAdd = createSchematicWithMetricsIfInstalled(ngAddFn);
@@ -4,7 +4,7 @@
4
4
  "title": "Add <%= featureName %> project",
5
5
  "description": "'ng add <%= featureName %>' project",
6
6
  "properties": {
7
- "name": {
7
+ "projectName": {
8
8
  "type": "string",
9
9
  "description": "Project name",
10
10
  "$default": {
@@ -18,8 +18,7 @@
18
18
  },
19
19
  "skipInstall": {
20
20
  "type": "boolean",
21
- "description": "Skip the install process",
22
- "default": true
21
+ "description": "Skip the install process"
23
22
  }
24
23
  },
25
24
  "additionalProperties": true,
@@ -2,7 +2,7 @@ import type { SchematicOptionObject } from '@o3r/schematics';
2
2
 
3
3
  export interface NgAddSchematicsSchema extends SchematicOptionObject {
4
4
  /** Project name */
5
- name: string | undefined;
5
+ projectName: string | undefined;
6
6
 
7
7
  /** Skip the linter process */
8
8
  skipLinter: boolean;
@@ -1,13 +1,14 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
+ import { type SetupDependenciesOptions } from '@o3r/schematics';
2
3
  /**
3
4
  * Add additional modules for dev only
4
5
  * @param options @see RuleFactory.options
5
6
  * @param options.projectName
6
7
  * @param options.workingDirectory the directory where to execute the rule factory
7
- * @param _rootPath @see RuleFactory.rootPath
8
+ * @param dependenciesSetupConfig
8
9
  */
9
10
  export declare function updateAdditionalModules(options: {
10
11
  projectName?: string | undefined;
11
12
  workingDirectory?: string | undefined;
12
- }, _rootPath: string): Rule;
13
+ }, dependenciesSetupConfig: SetupDependenciesOptions): Rule;
13
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/rule-factories/additional-modules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAiBjF;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAwMrJ"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/rule-factories/additional-modules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAIL,KAAK,wBAAwB,EAC9B,MAAM,iBAAiB,CAAC;AAczB;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,EAAE,uBAAuB,EAAE,wBAAwB,GAAG,IAAI,CA6MrL"}
@@ -8,31 +8,38 @@ const utility_1 = require("@schematics/angular/utility");
8
8
  const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
9
9
  const change_1 = require("@schematics/angular/utility/change");
10
10
  const path = require("node:path");
11
+ const fs = require("node:fs");
12
+ const dependencies_1 = require("@schematics/angular/utility/dependencies");
11
13
  const packageJsonPath = path.resolve(__dirname, '..', '..', '..', 'package.json');
14
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf-8' }));
12
15
  const ngrxStoreDevtoolsDep = '@ngrx/store-devtools';
13
16
  /**
14
17
  * Add additional modules for dev only
15
18
  * @param options @see RuleFactory.options
16
19
  * @param options.projectName
17
20
  * @param options.workingDirectory the directory where to execute the rule factory
18
- * @param _rootPath @see RuleFactory.rootPath
21
+ * @param dependenciesSetupConfig
19
22
  */
20
- function updateAdditionalModules(options, _rootPath) {
23
+ function updateAdditionalModules(options, dependenciesSetupConfig) {
21
24
  /**
22
25
  * Update package.json to add additional modules dependencies
23
26
  * @param tree
24
- * @param context
25
27
  */
26
- const updatePackageJson = (tree, context) => {
28
+ const updatePackageJson = (tree) => {
27
29
  const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
28
- const type = (0, schematics_2.getProjectNewDependenciesType)(workspaceProject);
29
- const generatorDependencies = [ngrxStoreDevtoolsDep];
30
- try {
31
- return (0, schematics_2.ngAddPeerDependencyPackages)(generatorDependencies, packageJsonPath, type, { ...options, skipNgAddSchematicRun: true });
32
- }
33
- catch (e) {
34
- context.logger.warn(`Could not find generatorDependencies ${generatorDependencies.join(', ')} in file ${packageJsonPath}`);
35
- }
30
+ const types = (0, schematics_2.getProjectNewDependenciesTypes)(workspaceProject);
31
+ dependenciesSetupConfig.dependencies.chokidar = {
32
+ inManifest: [{
33
+ range: packageJson.peerDependencies.chokidar,
34
+ types: [dependencies_1.NodeDependencyType.Dev]
35
+ }]
36
+ };
37
+ dependenciesSetupConfig.dependencies[ngrxStoreDevtoolsDep] = {
38
+ inManifest: [{
39
+ range: packageJson.generatorDependencies[ngrxStoreDevtoolsDep],
40
+ types
41
+ }]
42
+ };
36
43
  return tree;
37
44
  };
38
45
  /**
@@ -66,7 +66,7 @@ function updateOtterEnvironmentAdapter(options, _rootPath) {
66
66
  schematics_2.OTTER_ITEM_TYPES.forEach((item) => {
67
67
  const path = schematics_2.TYPES_DEFAULT_FOLDER[item].lib ? `modules/${scope}/${schematics_2.TYPES_DEFAULT_FOLDER[item].lib}` : null;
68
68
  if (path) {
69
- workspace.schematics[item] = {
69
+ workspace.schematics[`${item}*`] = {
70
70
  path,
71
71
  ...(workspace.schematics[item] || {})
72
72
  };
@@ -2,7 +2,6 @@ import { Rule } from '@angular-devkit/schematics';
2
2
  import { NgAddPackageOptions } from '@o3r/schematics';
3
3
  /**
4
4
  * Add Playwright to Otter application
5
- *
6
5
  * @param options @see RuleFactory.options
7
6
  * @param options.projectName
8
7
  * @param rootPath @see RuleFactory.rootPath
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/rule-factories/playwright/index.ts"],"names":[],"mappings":"AACA,OAAO,EAA+D,IAAI,EAAyC,MAAM,4BAA4B,CAAC;AACtJ,OAAO,EAAqB,mBAAmB,EAA+B,MAAM,iBAAiB,CAAC;AAItG;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,IAAI,CAsD1F"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/rule-factories/playwright/index.ts"],"names":[],"mappings":"AACA,OAAO,EAA+D,IAAI,EAAyC,MAAM,4BAA4B,CAAC;AACtJ,OAAO,EAGL,mBAAmB,EAEpB,MAAM,iBAAiB,CAAC;AAMzB;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,IAAI,CAoE1F"}
@@ -6,14 +6,16 @@ const schematics_1 = require("@angular-devkit/schematics");
6
6
  const schematics_2 = require("@o3r/schematics");
7
7
  const dependencies_1 = require("@schematics/angular/utility/dependencies");
8
8
  const path = require("node:path");
9
+ const fs = require("node:fs");
9
10
  /**
10
11
  * Add Playwright to Otter application
11
- *
12
12
  * @param options @see RuleFactory.options
13
13
  * @param options.projectName
14
14
  * @param rootPath @see RuleFactory.rootPath
15
15
  */
16
16
  function updatePlaywright(rootPath, options = {}) {
17
+ const ownPackageJsonPath = path.resolve(__dirname, '..', '..', '..', 'package.json');
18
+ const ownPackageJson = JSON.parse(fs.readFileSync(ownPackageJsonPath, { encoding: 'utf-8' }));
17
19
  return (tree, context) => {
18
20
  // update gitignore
19
21
  if (tree.exists('/.gitignore')) {
@@ -36,8 +38,19 @@ function updatePlaywright(rootPath, options = {}) {
36
38
  packageJson.scripts['test:playwright:sanity'] ||= 'playwright test --config=e2e-playwright/playwright-config.sanity.ts';
37
39
  tree.overwrite('/package.json', JSON.stringify(packageJson, null, 2));
38
40
  }
39
- const corePackageJsonPath = path.resolve(__dirname, '..', '..', '..', 'package.json');
40
- const ngAddRules = (0, schematics_2.ngAddPeerDependencyPackages)(['@playwright/test', 'rimraf'], corePackageJsonPath, dependencies_1.NodeDependencyType.Dev, { ...options, skipNgAddSchematicRun: true });
41
+ const dependencies = ['@playwright/test', 'rimraf'].reduce((acc, dep) => {
42
+ acc[dep] = {
43
+ inManifest: [{
44
+ range: ownPackageJson.generatorDependencies[dep],
45
+ types: [dependencies_1.NodeDependencyType.Dev]
46
+ }]
47
+ };
48
+ return acc;
49
+ }, {});
50
+ const ngAddRules = (0, schematics_2.setupDependencies)({
51
+ projectName: options.projectName || undefined,
52
+ dependencies
53
+ });
41
54
  // generate files
42
55
  if (!tree.exists('/e2e-playwright/playwright-config.ts')) {
43
56
  const name = 'my-scenario';
@@ -1,4 +1,5 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
+ import { type SetupDependenciesOptions } from '@o3r/schematics';
2
3
  import { WorkspaceProject } from '@o3r/schematics';
3
4
  /**
4
5
  * Add Redux Store support
@@ -7,9 +8,12 @@ import { WorkspaceProject } from '@o3r/schematics';
7
8
  * @param options.projectName
8
9
  * @param options.workingDirectory
9
10
  * @param projectType
11
+ * @param options.dependenciesSetupConfig
12
+ * @param options.workingDirector
10
13
  */
11
14
  export declare function updateStore(options: {
12
15
  projectName?: string | undefined;
13
- workingDirectory?: string | undefined;
16
+ workingDirector?: string | undefined;
17
+ dependenciesSetupConfig: SetupDependenciesOptions;
14
18
  }, projectType?: WorkspaceProject['projectType']): Rule;
15
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/rule-factories/store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAWjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAiBnD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAC,EAAE,WAAW,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,GAAG,IAAI,CA6IpK"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/rule-factories/store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AACjF,OAAO,EASL,KAAK,wBAAwB,EAC9B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAkBnD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,uBAAuB,EAAE,wBAAwB,CAAA;CAAE,EACtI,WAAW,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,GAAG,IAAI,CAkIrD"}
@@ -5,18 +5,18 @@ const schematics_1 = require("@angular-devkit/schematics");
5
5
  const schematics_2 = require("@o3r/schematics");
6
6
  const utility_1 = require("@schematics/angular/utility");
7
7
  const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
8
- const dependencies_1 = require("@schematics/angular/utility/dependencies");
9
8
  const path = require("node:path");
10
9
  const ts = require("typescript");
11
10
  const fs = require("node:fs");
12
- const packageJsonPath = path.resolve(__dirname, '..', '..', '..', 'package.json');
11
+ const coreSchematicsFolder = path.resolve(__dirname, '..', '..');
12
+ const corePackageJsonPath = path.resolve(coreSchematicsFolder, '..', 'package.json');
13
+ const corePackageJsonContent = JSON.parse(fs.readFileSync(corePackageJsonPath, { encoding: 'utf-8' }));
14
+ const o3rCoreVersion = corePackageJsonContent.version;
13
15
  const ngrxEffectsDep = '@ngrx/effects';
14
16
  const ngrxEntityDep = '@ngrx/entity';
15
17
  const ngrxStoreDep = '@ngrx/store';
16
18
  const ngrxRouterStore = '@ngrx/router-store';
17
19
  const ngrxRouterStoreDevToolDep = '@ngrx/store-devtools';
18
- // TODO Remove this explicit dependency when correctly brought by the ng-add of @o3r/store-sync
19
- const fastDeepEqualDep = 'fast-deep-equal';
20
20
  /**
21
21
  * Add Redux Store support
22
22
  * @param options @see RuleFactory.options
@@ -24,47 +24,40 @@ const fastDeepEqualDep = 'fast-deep-equal';
24
24
  * @param options.projectName
25
25
  * @param options.workingDirectory
26
26
  * @param projectType
27
+ * @param options.dependenciesSetupConfig
28
+ * @param options.workingDirector
27
29
  */
28
30
  function updateStore(options, projectType) {
29
31
  const addStoreModules = (tree) => {
30
- const coreSchematicsFolder = path.resolve(__dirname, '..', '..');
31
- const corePackageJsonPath = path.resolve(coreSchematicsFolder, '..', 'package.json');
32
- const corePackageJsonContent = JSON.parse(fs.readFileSync(corePackageJsonPath, { encoding: 'utf-8' }));
33
- const o3rCoreVersion = corePackageJsonContent.version;
34
32
  const workspaceConfig = (0, schematics_2.getWorkspaceConfig)(tree);
35
33
  const workspaceProject = options.projectName && workspaceConfig?.projects?.[options.projectName] || undefined;
36
- const projectDirectory = workspaceProject?.root;
37
- return (0, schematics_2.ngAddPackages)(['@o3r/store-sync'], {
38
- skipConfirmation: true,
39
- version: o3rCoreVersion,
40
- parentPackageInfo: '@o3r/core - setup',
41
- projectName: options.projectName,
42
- dependencyType: dependencies_1.NodeDependencyType.Default,
43
- workingDirectory: projectDirectory
44
- });
34
+ const storeSyncPackageName = '@o3r/store-sync';
35
+ options.dependenciesSetupConfig.dependencies[storeSyncPackageName] = {
36
+ inManifest: [{
37
+ range: `~${o3rCoreVersion}`,
38
+ types: (0, schematics_2.getProjectNewDependenciesTypes)(workspaceProject)
39
+ }]
40
+ };
41
+ (options.dependenciesSetupConfig.ngAddToRun ||= []).push(storeSyncPackageName);
45
42
  };
46
43
  /**
47
- * Changed package.json start script to run localization generation
44
+ * Change package.json with the new dependencies
48
45
  * @param tree
49
- * @param context
50
46
  */
51
- const updatePackageJson = (tree, context) => {
52
- const type = projectType === 'library' ? dependencies_1.NodeDependencyType.Peer : dependencies_1.NodeDependencyType.Default;
53
- const appDeps = [ngrxEffectsDep, ngrxRouterStore, ngrxRouterStoreDevToolDep, fastDeepEqualDep];
47
+ const updatePackageJson = (tree) => {
48
+ const workspaceConfig = (0, schematics_2.getWorkspaceConfig)(tree);
49
+ const workspaceProject = options.projectName && workspaceConfig?.projects?.[options.projectName] || undefined;
50
+ const appDeps = [ngrxEffectsDep, ngrxRouterStore, ngrxRouterStoreDevToolDep];
54
51
  const corePeerDeps = [ngrxEntityDep, ngrxStoreDep];
55
- let dependenciesList = [...corePeerDeps];
56
- if (projectType === 'application') {
57
- dependenciesList = [...dependenciesList, ...appDeps];
58
- }
59
- return () => {
60
- try {
61
- return (0, schematics_2.ngAddPeerDependencyPackages)(dependenciesList, packageJsonPath, type, { ...options, skipNgAddSchematicRun: true })(tree, context);
62
- }
63
- catch (e) {
64
- context.logger.warn(`Could not find generatorDependency ${dependenciesList.join(', ')} in file ${packageJsonPath}`);
65
- return tree;
66
- }
67
- };
52
+ const dependenciesList = projectType === 'application' ? [...corePeerDeps, ...appDeps] : [...corePeerDeps];
53
+ Object.entries((0, schematics_2.getExternalDependenciesVersionRange)(dependenciesList, corePackageJsonPath)).forEach(([dep, range]) => {
54
+ options.dependenciesSetupConfig.dependencies[dep] = {
55
+ inManifest: [{
56
+ range,
57
+ types: (0, schematics_2.getProjectNewDependenciesTypes)(workspaceProject)
58
+ }]
59
+ };
60
+ });
68
61
  };
69
62
  /**
70
63
  * Edit main module with the translation required configuration
@@ -1,4 +1,4 @@
1
- import type { Rule } from '@angular-devkit/schematics';
1
+ import { type Rule } from '@angular-devkit/schematics';
2
2
  import type { PresetOptions } from './preset.interface';
3
3
  /**
4
4
  * Default implementation of the preset rule
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../schematics/shared/presets/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,4BAA4B,CAAC;AAMrD,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,eAAe,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,aAAkB,GAAG,IAAI,CAkBrG"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../schematics/shared/presets/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,IAAI,EAAC,MAAM,4BAA4B,CAAC;AAK3D,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,eAAe,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,aAAkB,GAAG,IAAI,CAgCrG"}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defaultPresetRuleFactory = void 0;
4
- const schematics_1 = require("@o3r/schematics");
5
- const dependencies_1 = require("@schematics/angular/utility/dependencies");
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const schematics_2 = require("@o3r/schematics");
6
6
  const fs = require("node:fs");
7
7
  const path = require("node:path");
8
8
  /**
@@ -12,18 +12,30 @@ const path = require("node:path");
12
12
  */
13
13
  function defaultPresetRuleFactory(moduleToInstall, options = {}) {
14
14
  return (tree, _context) => {
15
- const workingDirectory = options?.projectName && (0, schematics_1.getWorkspaceConfig)(tree)?.projects[options.projectName]?.root || '.';
15
+ const corePackageJsonContent = JSON.parse(fs.readFileSync(path.resolve(__dirname, '..', '..', '..', 'package.json'), { encoding: 'utf-8' }));
16
+ const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
16
17
  if (!moduleToInstall.length) {
17
18
  return tree;
18
19
  }
19
- const corePackageJsonContent = JSON.parse(fs.readFileSync(path.resolve(__dirname, '..', '..', '..', 'package.json'), { encoding: 'utf-8' }));
20
- return (0, schematics_1.ngAddPackages)(moduleToInstall, {
21
- ...options,
22
- skipConfirmation: true,
23
- version: corePackageJsonContent.version,
24
- parentPackageInfo: '@o3r/core - preset setup',
25
- dependencyType: dependencies_1.NodeDependencyType.Dev,
26
- workingDirectory
20
+ const dependencies = moduleToInstall.reduce((acc, dep) => {
21
+ acc[dep] = {
22
+ inManifest: [{
23
+ range: `~${corePackageJsonContent.version}`,
24
+ types: (0, schematics_2.getProjectNewDependenciesTypes)(workspaceProject)
25
+ }]
26
+ };
27
+ return acc;
28
+ }, {});
29
+ if (options.dependenciesSetupConfig) {
30
+ options.dependenciesSetupConfig.dependencies = {
31
+ ...options.dependenciesSetupConfig.dependencies,
32
+ ...dependencies
33
+ };
34
+ }
35
+ return options.dependenciesSetupConfig ? schematics_1.noop : (0, schematics_2.setupDependencies)({
36
+ projectName: options.projectName,
37
+ dependencies,
38
+ ngAddToRun: moduleToInstall
27
39
  });
28
40
  };
29
41
  }