@ama-mfe/ng-utils 14.5.0-prerelease.9 → 14.5.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/migration.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/angular/angular-cli/master/packages/angular_devkit/schematics/collection-schema.json",
3
+ "schematics": {
4
+ "migration-v14_5": {
5
+ "version": "14.5.0-alpha.0",
6
+ "description": "Updates of @ama-mfe/ng-utils to v14.5.*: drops the AbstractMessageConsumer auto-start pattern and rewires consumers to start explicitly from the application configuration.",
7
+ "factory": "./schematics/ng-update/v14-5/index#updateV14_5"
8
+ }
9
+ }
10
+ }
package/package.json CHANGED
@@ -1,29 +1,29 @@
1
1
  {
2
2
  "name": "@ama-mfe/ng-utils",
3
- "version": "14.5.0-prerelease.9",
3
+ "version": "14.5.0-rc.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
7
  "peerDependencies": {
8
- "@ama-mfe/messages": "~14.5.0-prerelease.9",
9
- "@amadeus-it-group/microfrontends": "0.0.10",
10
- "@amadeus-it-group/microfrontends-angular": "0.0.10",
8
+ "@ama-mfe/messages": "~14.5.0-rc.2",
9
+ "@amadeus-it-group/microfrontends": "0.0.11",
10
+ "@amadeus-it-group/microfrontends-angular": "0.0.11",
11
11
  "@angular-devkit/core": "^21.0.0",
12
12
  "@angular-devkit/schematics": "^21.0.0",
13
13
  "@angular/common": "^21.0.0",
14
14
  "@angular/core": "^21.0.0",
15
15
  "@angular/platform-browser": "^21.0.0",
16
16
  "@angular/router": "^21.0.0",
17
- "@o3r/logger": "~14.5.0-prerelease.9",
18
- "@o3r/schematics": "~14.5.0-prerelease.9",
17
+ "@o3r/logger": "~14.5.0-rc.2",
18
+ "@o3r/schematics": "~14.5.0-rc.2",
19
19
  "rxjs": "^7.8.1",
20
20
  "type-fest": "^5.3.1"
21
21
  },
22
22
  "dependencies": {
23
- "@amadeus-it-group/microfrontends": "0.0.10",
24
- "@amadeus-it-group/microfrontends-angular": "0.0.10",
25
- "@o3r/logger": "~14.5.0-prerelease.9",
26
- "@o3r/schematics": "~14.5.0-prerelease.9",
23
+ "@amadeus-it-group/microfrontends": "0.0.11",
24
+ "@amadeus-it-group/microfrontends-angular": "0.0.11",
25
+ "@o3r/logger": "~14.5.0-rc.2",
26
+ "@o3r/schematics": "~14.5.0-rc.2",
27
27
  "tslib": "^2.6.2"
28
28
  },
29
29
  "sideEffects": false,
@@ -34,6 +34,9 @@
34
34
  "communication protocol"
35
35
  ],
36
36
  "schematics": "./collection.json",
37
+ "ng-update": {
38
+ "migrations": "./migration.json"
39
+ },
37
40
  "peerDependenciesMeta": {
38
41
  "@ama-mfe/messages": {
39
42
  "optional": true
@@ -0,0 +1,8 @@
1
+ import { type Rule } from '@angular-devkit/schematics';
2
+ /**
3
+ * Migration of `@ama-mfe/ng-utils` to v14.5.0.
4
+ *
5
+ * Appends explicit `.start()` calls for the in-repo consumers that no longer auto-start.
6
+ */
7
+ export declare const updateV14_5: (options: any) => Rule;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-update/v14-5/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EAGV,MAAM,4BAA4B,CAAC;AAkEpC;;;;GAIG;AAEH,eAAO,MAAM,WAAW,wBAAsC,CAAC"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateV14_5 = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const schematics_2 = require("@o3r/schematics");
6
+ /**
7
+ * In-repo {@link AbstractMessageConsumer} subclasses that used to auto-start in their constructor.
8
+ * In v15 the constructor is removed, so the application must start them explicitly.
9
+ */
10
+ const KNOWN_CONSUMERS = [
11
+ 'NavigationConsumerService',
12
+ 'ThemeConsumerService',
13
+ 'HistoryConsumerService',
14
+ 'ResizeConsumerService'
15
+ ];
16
+ /**
17
+ * For every known consumer injected in the given file, append a `.start()` call to its `inject(<Consumer>)`
18
+ * expression. Idempotent: an `inject(<Consumer>)` already followed by `.start(` is left untouched.
19
+ * @param tree Schematic tree
20
+ * @param filePath Path of the `app.config.ts` / `main.ts` file
21
+ * @param context Schematic context for logging
22
+ */
23
+ const appendStartToInjectedConsumers = (tree, filePath, context) => {
24
+ const original = tree.readText(filePath);
25
+ let updated = original;
26
+ const started = [];
27
+ for (const consumer of KNOWN_CONSUMERS) {
28
+ // Match `inject(<Consumer>)` that is not already followed by `.start(`.
29
+ const injectRegex = new RegExp(`inject\\(\\s*${consumer}\\s*\\)(?!\\s*\\.start\\b)`, 'g');
30
+ if (injectRegex.test(updated)) {
31
+ updated = updated.replace(injectRegex, `inject(${consumer}).start()`);
32
+ started.push(consumer);
33
+ }
34
+ }
35
+ if (updated !== original) {
36
+ tree.overwrite(filePath, updated);
37
+ context.logger.info(`[ama-mfe ng-update] Added explicit ".start()" call for ${started.join(', ')} in ${filePath}.`);
38
+ }
39
+ };
40
+ /**
41
+ * Migration to v14.5.0 of `@ama-mfe/ng-utils`.
42
+ *
43
+ * The consumers no longer auto-start in their constructor. This migration scans the
44
+ * application configuration files (`app.config.ts` / `main.ts`) and, for every known consumer already injected there,
45
+ * appends an explicit `.start()` call so the consumer keeps being started.
46
+ */
47
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- version contained in the function name
48
+ function updateV14_5Fn() {
49
+ return (tree, context) => {
50
+ const files = (0, schematics_2.findFilesInTree)(tree.getDir('/'), (filePath) => /\b(?:app\.config|main)\.ts$/.test(filePath) && !/\bdist\b/.test(filePath));
51
+ for (const file of files) {
52
+ appendStartToInjectedConsumers(tree, file.path, context);
53
+ }
54
+ return (0, schematics_2.applyEsLintFix)() ?? (0, schematics_1.noop)();
55
+ };
56
+ }
57
+ /**
58
+ * Migration of `@ama-mfe/ng-utils` to v14.5.0.
59
+ *
60
+ * Appends explicit `.start()` calls for the in-repo consumers that no longer auto-start.
61
+ */
62
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- version contained in the function name
63
+ exports.updateV14_5 = (0, schematics_2.createOtterSchematic)(updateV14_5Fn);
64
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-update/v14-5/index.ts"],"names":[],"mappings":";;;AAAA,2DAKoC;AACpC,gDAIyB;AAEzB;;;GAGG;AACH,MAAM,eAAe,GAAG;IACtB,2BAA2B;IAC3B,sBAAsB;IACtB,wBAAwB;IACxB,uBAAuB;CACf,CAAC;AAEX;;;;;;GAMG;AACH,MAAM,8BAA8B,GAAG,CAAC,IAAU,EAAE,QAAgB,EAAE,OAAyB,EAAQ,EAAE;IACvG,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACzC,IAAI,OAAO,GAAG,QAAQ,CAAC;IACvB,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE,CAAC;QACvC,wEAAwE;QACxE,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC,gBAAgB,QAAQ,4BAA4B,EAAE,GAAG,CAAC,CAAC;QAC1F,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9B,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,QAAQ,WAAW,CAAC,CAAC;YACtE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzB,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,0DAA0D,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO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