@exhaustive-ui/core 22.0.0 → 22.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -54,7 +54,7 @@ TypeScript imports (`primeng/button` → `@exhaustive-ui/core/button`, `@primeui
54
54
  `PrimeNG` → `Exhaustive`, `PrimeNGConfigType` → `ExhaustiveConfigType`). Anything it cannot migrate is
55
55
  listed as a warning for manual review.
56
56
 
57
- Projects on PrimeNG v20 or older: upgrade to PrimeNG v21 first, then migrate.
57
+ Projects on PrimeNG v20 or older: upgrade to PrimeNG v21 first, then migrate. The [PrimeNG migration guide](https://exhaustive-ui.com/migration/primeng) covers each step; Optimus UI v2 projects run `ng generate @exhaustive-ui/core:migrate-from-optimus` instead, as the [Optimus UI migration guide](https://exhaustive-ui.com/migration/optimus) describes.
58
58
 
59
59
  ## Updating to v22
60
60
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exhaustive-ui/core",
3
- "version": "22.0.0",
3
+ "version": "22.0.1",
4
4
  "author": "e-xiste",
5
5
  "description": "ExhaustiveUI is a community-maintained, MIT licensed UI library for Angular with 80+ accessible components and design-agnostic theming, including Aura, Material, Lara and Nora presets.",
6
6
  "homepage": "https://exhaustive-ui.com/",
@@ -56,10 +56,10 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "tslib": "^2.3.0",
59
- "@exhaustive-ui/motion": "22.0.0",
60
- "@exhaustive-ui/styled": "22.0.0",
61
- "@exhaustive-ui/utils": "22.0.0",
62
- "@exhaustive-ui/styles": "22.0.0"
59
+ "@exhaustive-ui/motion": "22.0.1",
60
+ "@exhaustive-ui/styled": "22.0.1",
61
+ "@exhaustive-ui/styles": "22.0.1",
62
+ "@exhaustive-ui/utils": "22.0.1"
63
63
  },
64
64
  "peerDependenciesMeta": {
65
65
  "chart.js": {
@@ -11,6 +11,11 @@
11
11
  "factory": "./migrate-from-primeng/index#migrateFromPrimeng",
12
12
  "schema": "./migrate-from-primeng/schema.json"
13
13
  },
14
+ "migrate-from-optimus": {
15
+ "description": "Migrate an Optimus UI v2 project to ExhaustiveUI: @openng/optimus-ui* packages, imports, configuration API and CSS layer name.",
16
+ "factory": "./migrate-from-optimus/index#migrateFromOptimus",
17
+ "schema": "./migrate-from-optimus/schema.json"
18
+ },
14
19
  "migrate-from-primeflex": {
15
20
  "description": "Translate PrimeFlex utility classes to their Tailwind CSS equivalents across Angular templates.",
16
21
  "factory": "./migrate-from-primeflex/index#migrateFromPrimeflex",
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrateFromOptimus = migrateFromOptimus;
4
+ const mappings_1 = require("../utils/mappings");
5
+ const migrate_workspace_1 = require("../utils/migrate-workspace");
6
+ /**
7
+ * Migrates an Optimus UI v2 workspace to ExhaustiveUI: the @openng/optimus-ui* packages, their
8
+ * imports, the configuration API (provideOptimus, Optimus, OptimusConfigType, OPTIMUS_CONFIG) and the
9
+ * `optimus` CSS layer. @openng/icons is shared and stays. The v22 `ng update` migrations then run
10
+ * with `ng update @exhaustive-ui/core --migrate-only --from=3.0.0`.
11
+ */
12
+ function migrateFromOptimus(options) {
13
+ return (0, migrate_workspace_1.migrateWorkspace)({
14
+ source: mappings_1.OPTIMUS_SOURCE,
15
+ packageName: '@openng/optimus-ui',
16
+ minMajor: 2,
17
+ tooOldMessage: (major) => `Found @openng/optimus-ui v${major}. This migration starts from Optimus UI v2 on Angular 22 — update Optimus UI first, then re-run it. Use --force to skip this check.`,
18
+ leftoverPattern: /optimus-ui|\b(provideOptimus|Optimus|OptimusConfigType|OPTIMUS_CONFIG)\b/,
19
+ leftoverLabel: '@openng/optimus-ui/Optimus',
20
+ guideUrl: 'https://exhaustive-ui.com/migration/optimus'
21
+ }, options);
22
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "ExhaustiveUiMigrateFromOptimus",
4
+ "title": "Migrate an Optimus UI v2 project to ExhaustiveUI",
5
+ "description": "Migrate an Optimus UI v2 workspace to ExhaustiveUI: dependencies, imports, configuration API and CSS layer name.",
6
+ "type": "object",
7
+ "properties": {
8
+ "skipInstall": {
9
+ "type": "boolean",
10
+ "default": false,
11
+ "description": "Skip scheduling the package install task."
12
+ },
13
+ "force": {
14
+ "type": "boolean",
15
+ "default": false,
16
+ "description": "Run the migration even if the installed @openng/optimus-ui version is unsupported."
17
+ }
18
+ }
19
+ }
@@ -1,188 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.migrateFromPrimeng = migrateFromPrimeng;
4
- const schematics_1 = require("@angular-devkit/schematics");
5
- const tasks_1 = require("@angular-devkit/schematics/tasks");
6
- const gitignore_1 = require("../utils/gitignore");
7
4
  const mappings_1 = require("../utils/mappings");
8
- const package_json_1 = require("../utils/package-json");
9
- const rewrite_1 = require("../utils/rewrite");
10
- const workspace_files_1 = require("../utils/workspace-files");
11
- const REPORT_EXTENSIONS = ['.ts', '.mts', '.js', '.mjs', '.html', '.scss', '.css', '.sass', '.less', '.json', '.md'];
12
- // Files where renamed package assets (SPECIFIER_RENAMES) are referenced by path rather than
13
- // imported: global stylesheets and the styles arrays of angular.json/project.json.
14
- const STYLESHEET_EXTENSIONS = ['.css', '.scss', '.sass', '.less'];
15
- const WORKSPACE_CONFIG_NAMES = new Set(['angular.json', 'project.json']);
16
- const TAILWIND_CONFIG_RE = /(^|\/)tailwind\.config\.(js|cjs|mjs)$/;
17
- // A quoted string that follows an at-rule keyword: `@import 'pkg'`, `@use 'pkg/file'`,
18
- // `@plugin "pkg"`, `@reference`, `@config`, `@source`. Declaration values such as
19
- // `font-family: 'primeicons'` are deliberately out of reach — they are not package references.
20
- const STYLE_AT_RULE_RE = /(@[a-zA-Z-]+\s+)(['"])([^'"\n]+)\2/g;
21
- // `url(pkg/file)`, with or without quotes.
22
- const URL_REFERENCE_RE = /\burl\(\s*(['"]?)([^)'"\n]+)\1\s*\)/g;
23
- // Every string in angular.json/project.json styles/scripts arrays is a path.
24
- const JSON_STRING_RE = /"([^"\n]+)"/g;
25
- const MIN_PRIMENG_MAJOR = 21;
26
- // Lockfiles are regenerated by the scheduled NodePackageInstallTask and would otherwise flood the
27
- // leftover report with dozens of registry URL lines for a dependency we already swapped out.
28
- const LOCKFILE_NAMES = new Set(['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb', 'bun.lock']);
5
+ const migrate_workspace_1 = require("../utils/migrate-workspace");
29
6
  /**
30
7
  * Migrates a PrimeNG v21 workspace to ExhaustiveUI. The v22 `ng update` migrations then run with
31
8
  * `ng update @exhaustive-ui/core --migrate-only --from=3.0.0`.
32
9
  */
33
10
  function migrateFromPrimeng(options) {
34
- return (tree, context) => {
35
- checkVersionGate(tree, options);
36
- const isIgnored = (0, gitignore_1.createIgnoreMatcher)(tree);
37
- const packageJsonPaths = [];
38
- const sourcePaths = [];
39
- const assetReferencePaths = [];
40
- (0, workspace_files_1.visitWorkspaceFiles)(tree, (path) => {
41
- const basename = path.slice(path.lastIndexOf('/') + 1);
42
- if (basename === 'package.json') {
43
- packageJsonPaths.push(path);
44
- }
45
- else if (path.endsWith('.ts') || path.endsWith('.mts') || TAILWIND_CONFIG_RE.test(path)) {
46
- sourcePaths.push(path);
47
- }
48
- else if (STYLESHEET_EXTENSIONS.some((ext) => path.endsWith(ext)) || WORKSPACE_CONFIG_NAMES.has(basename)) {
49
- assetReferencePaths.push(path);
50
- }
51
- }, {
52
- shouldDescend: (path) => !package_json_1.SKIP_DIRS.test(path) && !isIgnored(path),
53
- shouldVisitFile: (path) => !package_json_1.SKIP_DIRS.test(path) && !isIgnored(path)
54
- });
55
- for (const path of packageJsonPaths) {
56
- migratePackageJson(tree, context, path);
57
- }
58
- // Layer tokens renamed inside cssLayer name/order strings (e.g. primeng-overwrites →
59
- // exhaustive-overwrites), collected across all sources so the matching `@layer` declarations
60
- // in stylesheets can be renamed to keep following the configured order.
61
- const layerRenames = new Map();
62
- for (const path of sourcePaths) {
63
- const original = tree.read(path).toString();
64
- const { text, changed, layerRenames: fileLayerRenames } = (0, rewrite_1.rewriteSource)(path, original);
65
- for (const [from, to] of fileLayerRenames) {
66
- layerRenames.set(from, to);
67
- }
68
- if (changed) {
69
- tree.overwrite(path, text);
70
- }
71
- }
72
- for (const path of assetReferencePaths) {
73
- migrateAssetReferences(tree, path, layerRenames);
74
- }
75
- reportLeftovers(tree, context, isIgnored);
76
- warnAboutPrimeflex(tree, context);
77
- if (!options.skipInstall) {
78
- context.addTask(new tasks_1.NodePackageInstallTask());
79
- }
80
- return tree;
81
- };
82
- }
83
- /**
84
- * PrimeFlex is an independent utility-CSS library that this schematic does not migrate. If the
85
- * workspace also depends on it, point the user at the dedicated `migrate-from-primeflex` schematic,
86
- * which translates PrimeFlex classes to Tailwind (ExhaustiveUI's recommended utility layer).
87
- */
88
- function warnAboutPrimeflex(tree, context) {
89
- if (!(0, package_json_1.hasPrimeflex)(tree)) {
90
- return;
91
- }
92
- context.logger.warn('PrimeFlex detected in this workspace. PrimeFlex is a separate utility-CSS library and is not migrated by this schematic. ' +
93
- 'ExhaustiveUI recommends Tailwind CSS — run the following to translate your PrimeFlex classes:\n' +
94
- ' ng generate @exhaustive-ui/core:migrate-from-primeflex');
95
- }
96
- function checkVersionGate(tree, options) {
97
- if (options.force) {
98
- return;
99
- }
100
- const major = (0, package_json_1.findPrimengMajor)(tree);
101
- if (major === null) {
102
- throw new schematics_1.SchematicsException('primeng is not installed in this workspace (or its version could not be parsed). Use --force to run the code migration anyway.');
103
- }
104
- if (major < MIN_PRIMENG_MAJOR) {
105
- throw new schematics_1.SchematicsException(`Found primeng v${major}. ExhaustiveUI is API-compatible with primeng v21 — upgrade first (ng update primeng@21), then re-run this migration. Use --force to skip this check.`);
106
- }
107
- }
108
- function migratePackageJson(tree, context, path) {
109
- const raw = tree.read(path).toString();
110
- const pkg = JSON.parse(raw);
111
- const result = (0, package_json_1.swapDependencies)(pkg);
112
- if (!result.changed) {
113
- return;
114
- }
115
- const indent = raw.match(/^\{\r?\n(\s+)/)?.[1] ?? ' ';
116
- tree.overwrite(path, JSON.stringify(pkg, null, indent) + '\n');
117
- context.logger.info(`${path}: replaced ${result.removed.join(', ')} with ${result.added.join(', ')}`);
118
- }
119
- function migrateAssetReferences(tree, path, layerRenames) {
120
- let text = tree.read(path).toString();
121
- let changed = false;
122
- for (const [from, to] of mappings_1.SPECIFIER_RENAMES) {
123
- if (text.includes(from)) {
124
- text = text.split(from).join(to);
125
- changed = true;
126
- }
127
- }
128
- const rewrite = (reference, rebuild, match) => {
129
- const mapped = (0, mappings_1.mapAssetReference)(reference);
130
- if (mapped === null) {
131
- return match;
132
- }
133
- changed = true;
134
- return rebuild(mapped);
135
- };
136
- if (WORKSPACE_CONFIG_NAMES.has(path.slice(path.lastIndexOf('/') + 1))) {
137
- text = text.replace(JSON_STRING_RE, (match, value) => rewrite(value, (mapped) => `"${mapped}"`, match));
138
- }
139
- else {
140
- text = text.replace(STYLE_AT_RULE_RE, (match, rule, quote, value) => rewrite(value, (mapped) => `${rule}${quote}${mapped}${quote}`, match));
141
- text = text.replace(URL_REFERENCE_RE, (match, quote, value) => rewrite(value, (mapped) => `url(${quote}${mapped}${quote})`, match));
142
- const layered = (0, rewrite_1.renameStylesheetLayers)(text, layerRenames);
143
- if (layered.changed) {
144
- text = layered.text;
145
- changed = true;
146
- }
147
- }
148
- if (changed) {
149
- tree.overwrite(path, text);
150
- }
151
- }
152
- function isLockfile(path) {
153
- const basename = path.slice(path.lastIndexOf('/') + 1);
154
- return LOCKFILE_NAMES.has(basename);
155
- }
156
- const MIGRATION_GUIDE_URL = 'https://exhaustive-ui.com/migration/primeng';
157
- function reportLeftovers(tree, context, isIgnored) {
158
- const leftovers = [];
159
- const files = new Set();
160
- (0, workspace_files_1.visitWorkspaceFiles)(tree, (path, read) => {
161
- const content = read();
162
- if (content === undefined) {
163
- return;
164
- }
165
- content.split('\n').forEach((line, index) => {
166
- if (/primeng|primeicons|@primeuix|tailwindcss-primeui|primelocale/i.test(line)) {
167
- leftovers.push(`${path}:${index + 1} ${line.trim()}`);
168
- files.add(path);
169
- }
170
- });
171
- }, {
172
- shouldDescend: (path) => !package_json_1.SKIP_DIRS.test(path) && !isIgnored(path),
173
- shouldVisitFile: (path) => !package_json_1.SKIP_DIRS.test(path) && !isIgnored(path) && !isLockfile(path) && REPORT_EXTENSIONS.some((ext) => path.endsWith(ext))
174
- });
175
- if (leftovers.length === 0) {
176
- context.logger.info('No leftover primeng/primeicons/@primeuix/tailwindcss-primeui/primelocale references found — nothing left to review.');
177
- return;
178
- }
179
- const summary = `${leftovers.length} reference${leftovers.length === 1 ? '' : 's'} in ${files.size} file${files.size === 1 ? '' : 's'}`;
180
- context.logger.warn(`The following ${summary} could not be migrated automatically and need manual review:`);
181
- for (const leftover of leftovers) {
182
- context.logger.warn(` ${leftover}`);
183
- }
184
- // The CLI prints its CREATE/UPDATE list once the rule returns, which pushes the report above
185
- // out of sight. Close with a reminder that the file list is not the whole story.
186
- context.logger.warn(`\nMigration done, but ${summary} still need manual review. Scroll up to the list above — the CREATE/UPDATE lines that follow only cover what was migrated for you.`);
187
- context.logger.warn(`Manual migration tables: ${MIGRATION_GUIDE_URL}`);
11
+ return (0, migrate_workspace_1.migrateWorkspace)({
12
+ source: mappings_1.PRIMENG_SOURCE,
13
+ packageName: 'primeng',
14
+ minMajor: 21,
15
+ tooOldMessage: (major) => `Found primeng v${major}. ExhaustiveUI is API-compatible with primeng v21 — upgrade first (ng update primeng@21), then re-run this migration. Use --force to skip this check.`,
16
+ leftoverPattern: /primeng|primeicons|@primeuix|tailwindcss-primeui|primelocale/i,
17
+ leftoverLabel: 'primeng/primeicons/@primeuix/tailwindcss-primeui/primelocale',
18
+ guideUrl: 'https://exhaustive-ui.com/migration/primeng'
19
+ }, options);
188
20
  }
@@ -12,7 +12,7 @@ const mappings_1 = require("../utils/mappings");
12
12
  const package_json_1 = require("../utils/package-json");
13
13
  const THEMES_PACKAGE = '@exhaustive-ui/themes';
14
14
  const DEFAULT_THEME = 'Aura';
15
- const MIGRATE_COMMAND = 'ng generate @exhaustive-ui/core@1:migrate-from-primeng';
15
+ const MIGRATE_COMMAND = 'ng generate @exhaustive-ui/core:migrate-from-primeng';
16
16
  function projectNotFound(name) {
17
17
  return `Project "${name}" was not found in the workspace.`;
18
18
  }
@@ -22,9 +22,9 @@ function projectNotFound(name) {
22
22
  * factory runs (`ng-add.save` is `"dependencies"`, and the CLI only cleans the entry up when
23
23
  * `save` is `false`), so the message has to account for it rather than pretend nothing happened.
24
24
  */
25
- function primengBailMessage() {
26
- return `primeng detected — ng add only sets up ExhaustiveUI in new projects, so no changes were made and the theme preset was not configured.
27
- To migrate this workspace, run: ${MIGRATE_COMMAND}
25
+ function primengBailMessage(library = 'primeng', command = MIGRATE_COMMAND) {
26
+ return `${library} detected — ng add only sets up ExhaustiveUI in new projects, so no changes were made and the theme preset was not configured.
27
+ To migrate this workspace, run: ${command}
28
28
  The Angular CLI has already added @exhaustive-ui/core to your dependencies. The migration schematic needs it there, so keep it — or remove it with your package manager if you did not mean to add ExhaustiveUI to this workspace.`;
29
29
  }
30
30
  /** The preset import name and its subpath module for the chosen theme (e.g. `Aura` → `@exhaustive-ui/themes/aura`). */
@@ -44,7 +44,8 @@ function manualInstructions(theme) {
44
44
  /**
45
45
  * Sets up ExhaustiveUI in a fresh (non-PrimeNG) project. Migrating an existing PrimeNG workspace is
46
46
  * a separate concern handled by the `migrate-from-primeng` schematic
47
- * (`ng generate @exhaustive-ui/core@1:migrate-from-primeng`) — when primeng is detected, ng-add
47
+ * (`ng generate @exhaustive-ui/core:migrate-from-primeng`), and an Optimus UI workspace by
48
+ * `migrate-from-optimus` — when primeng is detected, ng-add
48
49
  * makes no changes and throws, so the CLI reports the refusal as a failure (#1447). A warning was
49
50
  * not enough: the command exited 0 after asking for a theme preset it then discarded, which reads
50
51
  * as a successful setup, and the freshly-installed dependency in package.json reinforces that.
@@ -60,6 +61,9 @@ function ngAdd(options) {
60
61
  if ((0, package_json_1.hasPrimeng)(tree)) {
61
62
  throw new schematics_1.SchematicsException(primengBailMessage());
62
63
  }
64
+ if ((0, package_json_1.hasPrimeng)(tree, '@openng/optimus-ui')) {
65
+ throw new schematics_1.SchematicsException(primengBailMessage('@openng/optimus-ui', 'ng generate @exhaustive-ui/core:migrate-from-optimus'));
66
+ }
63
67
  return freshSetup(options);
64
68
  };
65
69
  }
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.VERSIONS = exports.IDENTIFIER_RENAMES = exports.SPECIFIER_RENAMES = exports.MODULE_MAP = void 0;
6
+ exports.VERSIONS = exports.OPTIMUS_SOURCE = exports.PRIMENG_SOURCE = exports.OPTIMUS_IDENTIFIER_RENAMES = exports.OPTIMUS_MODULE_MAP = exports.IDENTIFIER_RENAMES = exports.SPECIFIER_RENAMES = exports.MODULE_MAP = void 0;
7
7
  exports.mapAssetReference = mapAssetReference;
8
8
  exports.mapModuleSpecifier = mapModuleSpecifier;
9
9
  const versions_json_1 = __importDefault(require("./versions.json"));
@@ -31,6 +31,36 @@ exports.IDENTIFIER_RENAMES = new Map([
31
31
  // compiles, but rewriting to OpenngIcons moves users onto the current API.
32
32
  ['PrimeIcons', 'OpenngIcons']
33
33
  ]);
34
+ // Optimus UI v2 is the PrimeNG v21 codebase under @openng/* names; ExhaustiveUI is the same code
35
+ // renamed again. @openng/icons is shared by both and stays.
36
+ exports.OPTIMUS_MODULE_MAP = new Map([
37
+ ['@openng/optimus-ui-themes', '@exhaustive-ui/themes'],
38
+ ['@openng/optimus-ui-styled', '@exhaustive-ui/styled'],
39
+ ['@openng/optimus-ui-styles', '@exhaustive-ui/styles'],
40
+ ['@openng/optimus-ui-utils', '@exhaustive-ui/utils'],
41
+ ['@openng/optimus-ui-motion', '@exhaustive-ui/motion'],
42
+ ['@openng/optimus-ui-tailwindcss', '@exhaustive-ui/tailwindcss'],
43
+ ['@openng/optimus-ui-locale', '@exhaustive-ui/locale'],
44
+ ['@openng/optimus-ui', '@exhaustive-ui/core']
45
+ ]);
46
+ exports.OPTIMUS_IDENTIFIER_RENAMES = new Map([
47
+ ['provideOptimus', 'provideExhaustive'],
48
+ ['Optimus', 'Exhaustive'],
49
+ ['OptimusConfigType', 'ExhaustiveConfigType'],
50
+ ['OPTIMUS_CONFIG', 'EXHAUSTIVE_CONFIG']
51
+ ]);
52
+ exports.PRIMENG_SOURCE = {
53
+ moduleMap: exports.MODULE_MAP,
54
+ specifierRenames: exports.SPECIFIER_RENAMES,
55
+ identifierRenames: exports.IDENTIFIER_RENAMES,
56
+ layerName: 'primeng'
57
+ };
58
+ exports.OPTIMUS_SOURCE = {
59
+ moduleMap: exports.OPTIMUS_MODULE_MAP,
60
+ specifierRenames: new Map(),
61
+ identifierRenames: exports.OPTIMUS_IDENTIFIER_RENAMES,
62
+ layerName: 'optimus'
63
+ };
34
64
  // versions.json is generated by scripts/build-schematics.mjs from the workspace package
35
65
  // manifests (and the pnpm-workspace.yaml catalog for @openng/icons) — never edit it by hand.
36
66
  exports.VERSIONS = versions_json_1.default;
@@ -38,18 +68,18 @@ exports.VERSIONS = versions_json_1.default;
38
68
  // angular.json/project.json, is a path rather than a module specifier — it may carry a webpack
39
69
  // tilde or a node_modules/ prefix that has to survive the rename.
40
70
  const PACKAGE_PREFIX_RE = /^(.*(?:node_modules\/|~))?(.*)$/;
41
- function mapAssetReference(reference) {
71
+ function mapAssetReference(reference, source = exports.PRIMENG_SOURCE) {
42
72
  const match = PACKAGE_PREFIX_RE.exec(reference);
43
73
  const prefix = match?.[1] ?? '';
44
- const mapped = mapModuleSpecifier(match?.[2] ?? reference);
74
+ const mapped = mapModuleSpecifier(match?.[2] ?? reference, source);
45
75
  return mapped === null ? null : `${prefix}${mapped}`;
46
76
  }
47
- function mapModuleSpecifier(spec) {
48
- const renamed = exports.SPECIFIER_RENAMES.get(spec);
77
+ function mapModuleSpecifier(spec, source = exports.PRIMENG_SOURCE) {
78
+ const renamed = source.specifierRenames.get(spec);
49
79
  if (renamed !== undefined) {
50
80
  return renamed;
51
81
  }
52
- for (const [from, to] of exports.MODULE_MAP) {
82
+ for (const [from, to] of source.moduleMap) {
53
83
  if (spec === from) {
54
84
  return to;
55
85
  }
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrateWorkspace = migrateWorkspace;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const tasks_1 = require("@angular-devkit/schematics/tasks");
6
+ const gitignore_1 = require("./gitignore");
7
+ const mappings_1 = require("./mappings");
8
+ const package_json_1 = require("./package-json");
9
+ const rewrite_1 = require("./rewrite");
10
+ const workspace_files_1 = require("./workspace-files");
11
+ const REPORT_EXTENSIONS = ['.ts', '.mts', '.js', '.mjs', '.html', '.scss', '.css', '.sass', '.less', '.json', '.md'];
12
+ // Files where renamed package assets (SPECIFIER_RENAMES) are referenced by path rather than
13
+ // imported: global stylesheets and the styles arrays of angular.json/project.json.
14
+ const STYLESHEET_EXTENSIONS = ['.css', '.scss', '.sass', '.less'];
15
+ const WORKSPACE_CONFIG_NAMES = new Set(['angular.json', 'project.json']);
16
+ const TAILWIND_CONFIG_RE = /(^|\/)tailwind\.config\.(js|cjs|mjs)$/;
17
+ // A quoted string that follows an at-rule keyword: `@import 'pkg'`, `@use 'pkg/file'`,
18
+ // `@plugin "pkg"`, `@reference`, `@config`, `@source`. Declaration values such as
19
+ // `font-family: 'primeicons'` are deliberately out of reach — they are not package references.
20
+ const STYLE_AT_RULE_RE = /(@[a-zA-Z-]+\s+)(['"])([^'"\n]+)\2/g;
21
+ // `url(pkg/file)`, with or without quotes.
22
+ const URL_REFERENCE_RE = /\burl\(\s*(['"]?)([^)'"\n]+)\1\s*\)/g;
23
+ // Every string in angular.json/project.json styles/scripts arrays is a path.
24
+ const JSON_STRING_RE = /"([^"\n]+)"/g;
25
+ // Lockfiles are regenerated by the scheduled NodePackageInstallTask and would otherwise flood the
26
+ // leftover report with dozens of registry URL lines for a dependency we already swapped out.
27
+ const LOCKFILE_NAMES = new Set(['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb', 'bun.lock']);
28
+ /**
29
+ * Moves a workspace from another library of the PrimeNG v21 family to ExhaustiveUI: dependencies,
30
+ * imports, configuration API, stylesheet and angular.json references, CSS layer names. The v22
31
+ * `ng update` migrations then run with `ng update @exhaustive-ui/core --migrate-only --from=3.0.0`.
32
+ */
33
+ function migrateWorkspace(migration, options) {
34
+ const { source } = migration;
35
+ return (tree, context) => {
36
+ checkVersionGate(tree, migration, options);
37
+ const isIgnored = (0, gitignore_1.createIgnoreMatcher)(tree);
38
+ const packageJsonPaths = [];
39
+ const sourcePaths = [];
40
+ const assetReferencePaths = [];
41
+ (0, workspace_files_1.visitWorkspaceFiles)(tree, (path) => {
42
+ const basename = path.slice(path.lastIndexOf('/') + 1);
43
+ if (basename === 'package.json') {
44
+ packageJsonPaths.push(path);
45
+ }
46
+ else if (path.endsWith('.ts') || path.endsWith('.mts') || TAILWIND_CONFIG_RE.test(path)) {
47
+ sourcePaths.push(path);
48
+ }
49
+ else if (STYLESHEET_EXTENSIONS.some((ext) => path.endsWith(ext)) || WORKSPACE_CONFIG_NAMES.has(basename)) {
50
+ assetReferencePaths.push(path);
51
+ }
52
+ }, {
53
+ shouldDescend: (path) => !package_json_1.SKIP_DIRS.test(path) && !isIgnored(path),
54
+ shouldVisitFile: (path) => !package_json_1.SKIP_DIRS.test(path) && !isIgnored(path)
55
+ });
56
+ for (const path of packageJsonPaths) {
57
+ migratePackageJson(tree, context, path, source);
58
+ }
59
+ // Layer tokens renamed inside cssLayer name/order strings (e.g. primeng-overwrites →
60
+ // exhaustive-overwrites), collected across all sources so the matching `@layer` declarations
61
+ // in stylesheets can be renamed to keep following the configured order.
62
+ const layerRenames = new Map();
63
+ for (const path of sourcePaths) {
64
+ const original = tree.read(path).toString();
65
+ const { text, changed, layerRenames: fileLayerRenames } = (0, rewrite_1.rewriteSource)(path, original, source);
66
+ for (const [from, to] of fileLayerRenames) {
67
+ layerRenames.set(from, to);
68
+ }
69
+ if (changed) {
70
+ tree.overwrite(path, text);
71
+ }
72
+ }
73
+ for (const path of assetReferencePaths) {
74
+ migrateAssetReferences(tree, path, layerRenames, source);
75
+ }
76
+ reportLeftovers(tree, context, isIgnored, migration);
77
+ warnAboutPrimeflex(tree, context);
78
+ if (!options.skipInstall) {
79
+ context.addTask(new tasks_1.NodePackageInstallTask());
80
+ }
81
+ return tree;
82
+ };
83
+ }
84
+ /**
85
+ * PrimeFlex is an independent utility-CSS library that this schematic does not migrate. If the
86
+ * workspace also depends on it, point the user at the dedicated `migrate-from-primeflex` schematic,
87
+ * which translates PrimeFlex classes to Tailwind (ExhaustiveUI's recommended utility layer).
88
+ */
89
+ function warnAboutPrimeflex(tree, context) {
90
+ if (!(0, package_json_1.hasPrimeflex)(tree)) {
91
+ return;
92
+ }
93
+ context.logger.warn('PrimeFlex detected in this workspace. PrimeFlex is a separate utility-CSS library and is not migrated by this schematic. ' +
94
+ 'ExhaustiveUI recommends Tailwind CSS — run the following to translate your PrimeFlex classes:\n' +
95
+ ' ng generate @exhaustive-ui/core:migrate-from-primeflex');
96
+ }
97
+ function checkVersionGate(tree, migration, options) {
98
+ if (options.force) {
99
+ return;
100
+ }
101
+ const major = (0, package_json_1.findPrimengMajor)(tree, migration.packageName);
102
+ if (major === null) {
103
+ throw new schematics_1.SchematicsException(`${migration.packageName} is not installed in this workspace (or its version could not be parsed). Use --force to run the code migration anyway.`);
104
+ }
105
+ if (major < migration.minMajor) {
106
+ throw new schematics_1.SchematicsException(migration.tooOldMessage(major));
107
+ }
108
+ }
109
+ function migratePackageJson(tree, context, path, source) {
110
+ const raw = tree.read(path).toString();
111
+ const pkg = JSON.parse(raw);
112
+ const result = (0, package_json_1.swapDependencies)(pkg, source.moduleMap);
113
+ if (!result.changed) {
114
+ return;
115
+ }
116
+ const indent = raw.match(/^\{\r?\n(\s+)/)?.[1] ?? ' ';
117
+ tree.overwrite(path, JSON.stringify(pkg, null, indent) + '\n');
118
+ context.logger.info(`${path}: replaced ${result.removed.join(', ')} with ${result.added.join(', ')}`);
119
+ }
120
+ function migrateAssetReferences(tree, path, layerRenames, source) {
121
+ let text = tree.read(path).toString();
122
+ let changed = false;
123
+ for (const [from, to] of source.specifierRenames) {
124
+ if (text.includes(from)) {
125
+ text = text.split(from).join(to);
126
+ changed = true;
127
+ }
128
+ }
129
+ const rewrite = (reference, rebuild, match) => {
130
+ const mapped = (0, mappings_1.mapAssetReference)(reference, source);
131
+ if (mapped === null) {
132
+ return match;
133
+ }
134
+ changed = true;
135
+ return rebuild(mapped);
136
+ };
137
+ if (WORKSPACE_CONFIG_NAMES.has(path.slice(path.lastIndexOf('/') + 1))) {
138
+ text = text.replace(JSON_STRING_RE, (match, value) => rewrite(value, (mapped) => `"${mapped}"`, match));
139
+ }
140
+ else {
141
+ text = text.replace(STYLE_AT_RULE_RE, (match, rule, quote, value) => rewrite(value, (mapped) => `${rule}${quote}${mapped}${quote}`, match));
142
+ text = text.replace(URL_REFERENCE_RE, (match, quote, value) => rewrite(value, (mapped) => `url(${quote}${mapped}${quote})`, match));
143
+ const layered = (0, rewrite_1.renameStylesheetLayers)(text, layerRenames);
144
+ if (layered.changed) {
145
+ text = layered.text;
146
+ changed = true;
147
+ }
148
+ }
149
+ if (changed) {
150
+ tree.overwrite(path, text);
151
+ }
152
+ }
153
+ function isLockfile(path) {
154
+ const basename = path.slice(path.lastIndexOf('/') + 1);
155
+ return LOCKFILE_NAMES.has(basename);
156
+ }
157
+ function reportLeftovers(tree, context, isIgnored, migration) {
158
+ const leftovers = [];
159
+ const files = new Set();
160
+ (0, workspace_files_1.visitWorkspaceFiles)(tree, (path, read) => {
161
+ const content = read();
162
+ if (content === undefined) {
163
+ return;
164
+ }
165
+ content.split('\n').forEach((line, index) => {
166
+ if (migration.leftoverPattern.test(line)) {
167
+ leftovers.push(`${path}:${index + 1} ${line.trim()}`);
168
+ files.add(path);
169
+ }
170
+ });
171
+ }, {
172
+ shouldDescend: (path) => !package_json_1.SKIP_DIRS.test(path) && !isIgnored(path),
173
+ shouldVisitFile: (path) => !package_json_1.SKIP_DIRS.test(path) && !isIgnored(path) && !isLockfile(path) && REPORT_EXTENSIONS.some((ext) => path.endsWith(ext))
174
+ });
175
+ if (leftovers.length === 0) {
176
+ context.logger.info(`No leftover ${migration.leftoverLabel} references found — nothing left to review.`);
177
+ return;
178
+ }
179
+ const summary = `${leftovers.length} reference${leftovers.length === 1 ? '' : 's'} in ${files.size} file${files.size === 1 ? '' : 's'}`;
180
+ context.logger.warn(`The following ${summary} could not be migrated automatically and need manual review:`);
181
+ for (const leftover of leftovers) {
182
+ context.logger.warn(` ${leftover}`);
183
+ }
184
+ // The CLI prints its CREATE/UPDATE list once the rule returns, which pushes the report above
185
+ // out of sight. Close with a reminder that the file list is not the whole story.
186
+ context.logger.warn(`\nMigration done, but ${summary} still need manual review. Scroll up to the list above — the CREATE/UPDATE lines that follow only cover what was migrated for you.`);
187
+ context.logger.warn(`Migration guide: ${migration.guideUrl}`);
188
+ }
@@ -13,14 +13,14 @@ const workspace_files_1 = require("./workspace-files");
13
13
  exports.SKIP_DIRS = /(^|\/)(node_modules|dist|\.angular|\.git|out-tsc)(\/|$)/;
14
14
  // Sections where a package can be declared as a direct dependency of some kind.
15
15
  const DIRECT_DEPENDENCY_SECTIONS = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];
16
- function swapDependencies(pkg) {
16
+ function swapDependencies(pkg, moduleMap = mappings_1.MODULE_MAP) {
17
17
  const result = { changed: false, added: [], removed: [] };
18
18
  for (const section of DIRECT_DEPENDENCY_SECTIONS) {
19
19
  const deps = pkg[section];
20
20
  if (!deps) {
21
21
  continue;
22
22
  }
23
- for (const [from, to] of mappings_1.MODULE_MAP) {
23
+ for (const [from, to] of moduleMap) {
24
24
  if (!(from in deps)) {
25
25
  continue;
26
26
  }
@@ -109,17 +109,17 @@ function declaresPackage(pkg, name) {
109
109
  * sections plus resolutions/overrides/pnpm.overrides — or null when primeng is absent or no
110
110
  * declared range contains a parseable major (e.g. `"latest"` or a tag).
111
111
  */
112
- function getPrimengMajor(pkg) {
112
+ function getPrimengMajor(pkg, name = 'primeng') {
113
113
  const ranges = [];
114
114
  for (const section of DIRECT_DEPENDENCY_SECTIONS) {
115
115
  const deps = pkg[section];
116
- const range = isRecord(deps) ? deps['primeng'] : undefined;
116
+ const range = isRecord(deps) ? deps[name] : undefined;
117
117
  if (typeof range === 'string') {
118
118
  ranges.push(range);
119
119
  }
120
120
  }
121
121
  for (const section of overrideSections(pkg)) {
122
- collectOverrideRanges(section, 'primeng', ranges);
122
+ collectOverrideRanges(section, name, ranges);
123
123
  }
124
124
  let max = null;
125
125
  for (const range of ranges) {
@@ -138,10 +138,10 @@ function getPrimengMajor(pkg) {
138
138
  * Scans every package.json in the workspace tree (skipping node_modules/dist/.angular/.git/out-tsc)
139
139
  * and returns the highest primeng major found across all of them, or null if primeng is nowhere.
140
140
  */
141
- function findPrimengMajor(tree) {
141
+ function findPrimengMajor(tree, name = 'primeng') {
142
142
  let max = null;
143
143
  visitWorkspacePackageJsons(tree, (pkg) => {
144
- const major = getPrimengMajor(pkg);
144
+ const major = getPrimengMajor(pkg, name);
145
145
  if (major !== null && (max === null || major > max)) {
146
146
  max = major;
147
147
  }
@@ -154,13 +154,13 @@ function findPrimengMajor(tree) {
154
154
  * resolutions/overrides/pnpm.overrides — regardless of whether its version spec is parseable
155
155
  * (e.g. `"latest"`, a tag, a git URL, …).
156
156
  */
157
- function hasPrimeng(tree) {
157
+ function hasPrimeng(tree, name = 'primeng') {
158
158
  let found = false;
159
159
  visitWorkspacePackageJsons(tree, (pkg) => {
160
160
  if (found) {
161
161
  return;
162
162
  }
163
- if (declaresPackage(pkg, 'primeng')) {
163
+ if (declaresPackage(pkg, name)) {
164
164
  found = true;
165
165
  }
166
166
  });
@@ -37,7 +37,7 @@ exports.rewriteSource = rewriteSource;
37
37
  exports.renameStylesheetLayers = renameStylesheetLayers;
38
38
  const ts = __importStar(require("typescript"));
39
39
  const mappings_1 = require("./mappings");
40
- function rewriteSource(fileName, text) {
40
+ function rewriteSource(fileName, text, source = mappings_1.PRIMENG_SOURCE) {
41
41
  const sourceFile = ts.createSourceFile(fileName, text, ts.ScriptTarget.Latest, true);
42
42
  const edits = [];
43
43
  const layerRenames = new Map();
@@ -47,7 +47,7 @@ function rewriteSource(fileName, text) {
47
47
  // renaming an import to one of these would shadow/corrupt an unrelated declaration
48
48
  const declaredNames = collectDeclaredNames(sourceFile);
49
49
  const editSpecifier = (literal) => {
50
- const mapped = (0, mappings_1.mapModuleSpecifier)(literal.text);
50
+ const mapped = (0, mappings_1.mapModuleSpecifier)(literal.text, source);
51
51
  if (mapped === null) {
52
52
  return false;
53
53
  }
@@ -58,7 +58,7 @@ function rewriteSource(fileName, text) {
58
58
  const renameBindings = (elements, trackLocals) => {
59
59
  for (const spec of elements) {
60
60
  const original = spec.propertyName ?? spec.name;
61
- const newName = mappings_1.IDENTIFIER_RENAMES.get(original.text);
61
+ const newName = source.identifierRenames.get(original.text);
62
62
  if (!newName) {
63
63
  continue;
64
64
  }
@@ -116,7 +116,7 @@ function rewriteSource(fileName, text) {
116
116
  };
117
117
  visitUsages(sourceFile);
118
118
  }
119
- rewriteCssLayerNames(sourceFile, text, edits, layerRenames);
119
+ rewriteCssLayerNames(sourceFile, text, edits, layerRenames, source.layerName);
120
120
  if (edits.length === 0) {
121
121
  return { text, changed: false, layerRenames };
122
122
  }
@@ -202,12 +202,21 @@ function usageReplacement(node, newName) {
202
202
  }
203
203
  return newName;
204
204
  }
205
- // PrimeNG's default CSS cascade layer is named `primeng`. Users who enable the theme's cssLayer
206
- // option with an explicit name/order carry that token into their app config, e.g.
205
+ // PrimeNG's default CSS cascade layer is named `primeng` (Optimus UI's `optimus`). Users who enable
206
+ // the theme's cssLayer option with an explicit name/order carry that token into their app config, e.g.
207
207
  // cssLayer: { name: 'primeng', order: 'theme, base, primeng' }
208
- const CSS_LAYER_TOKEN_RE = /\bprimeng\b/g;
209
- function rewriteCssLayerNames(sourceFile, text, edits, layerRenames) {
208
+ // Without a name (`cssLayer: true`, or an object with no `name`), the library used its default
209
+ // layer, which becomes `exhaustive`: stylesheets that declare that layer follow it.
210
+ function rewriteCssLayerNames(sourceFile, text, edits, layerRenames, layerName) {
211
+ const CSS_LAYER_TOKEN_RE = new RegExp(`\\b${layerName}\\b`, 'g');
210
212
  const visit = (node) => {
213
+ if (ts.isPropertyAssignment(node) && propertyKeyText(node.name) === 'cssLayer') {
214
+ const initializer = node.initializer;
215
+ const usesDefaultName = initializer.kind === ts.SyntaxKind.TrueKeyword || (ts.isObjectLiteralExpression(initializer) && !initializer.properties.some((prop) => prop.name !== undefined && propertyKeyText(prop.name) === 'name'));
216
+ if (usesDefaultName) {
217
+ layerRenames.set(layerName, 'exhaustive');
218
+ }
219
+ }
211
220
  if (ts.isPropertyAssignment(node) && propertyKeyText(node.name) === 'cssLayer' && ts.isObjectLiteralExpression(node.initializer)) {
212
221
  for (const prop of node.initializer.properties) {
213
222
  if (!ts.isPropertyAssignment(prop) || !ts.isStringLiteralLike(prop.initializer)) {
@@ -1,11 +1,11 @@
1
1
  {
2
- "@exhaustive-ui/core": "^22.0.0",
3
- "@exhaustive-ui/locale": "^22.0.0",
4
- "@exhaustive-ui/motion": "^22.0.0",
5
- "@exhaustive-ui/styled": "^22.0.0",
6
- "@exhaustive-ui/styles": "^22.0.0",
7
- "@exhaustive-ui/tailwindcss": "^22.0.0",
8
- "@exhaustive-ui/themes": "^22.0.0",
9
- "@exhaustive-ui/utils": "^22.0.0",
2
+ "@exhaustive-ui/core": "^22.0.1",
3
+ "@exhaustive-ui/locale": "^22.0.1",
4
+ "@exhaustive-ui/motion": "^22.0.1",
5
+ "@exhaustive-ui/styled": "^22.0.1",
6
+ "@exhaustive-ui/styles": "^22.0.1",
7
+ "@exhaustive-ui/tailwindcss": "^22.0.1",
8
+ "@exhaustive-ui/themes": "^22.0.1",
9
+ "@exhaustive-ui/utils": "^22.0.1",
10
10
  "@openng/icons": "^1.0.0"
11
11
  }