@smartsoft001/core 2.143.0 → 2.145.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.
@@ -0,0 +1,11 @@
1
+ {
2
+ "generators": {
3
+ "use-stack-packages": {
4
+ "cli": "nx",
5
+ "version": "2.145.0",
6
+ "description": "Replace individually installed @smartsoft001 packages with the stack package that already pins them.",
7
+ "factory": "./src/migrations/use-stack-packages/use-stack-packages",
8
+ "documentation": "./src/migrations/use-stack-packages/README.md"
9
+ }
10
+ }
11
+ }
package/package.json CHANGED
@@ -1,21 +1,25 @@
1
1
  {
2
2
  "name": "@smartsoft001/core",
3
- "version": "2.143.0",
3
+ "version": "2.145.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
+ "ng-update": {
8
+ "migrations": "./migrations.json",
9
+ "supportsOptionalMigrations": true
10
+ },
7
11
  "description": "Every framework-agnostic @smartsoft001 package in one install: the model decorators, the domain contracts, the helpers and the shared DTOs.",
8
12
  "license": "MIT",
9
13
  "dependencies": {
10
- "@smartsoft001/models": "2.143.0",
11
- "@smartsoft001/domain-core": "2.143.0",
12
- "@smartsoft001/utils": "2.143.0",
13
- "@smartsoft001/users": "2.143.0",
14
- "@smartsoft001/auth-domain": "2.143.0",
15
- "@smartsoft001/crud-domain": "2.143.0",
16
- "@smartsoft001/crud-shell-dtos": "2.143.0",
17
- "@smartsoft001/auth-shell-dtos": "2.143.0",
18
- "@smartsoft001/crud-shell-app-services": "2.143.0",
19
- "@smartsoft001/auth-shell-app-services": "2.143.0"
14
+ "@smartsoft001/models": "2.145.0",
15
+ "@smartsoft001/domain-core": "2.145.0",
16
+ "@smartsoft001/utils": "2.145.0",
17
+ "@smartsoft001/users": "2.145.0",
18
+ "@smartsoft001/auth-domain": "2.145.0",
19
+ "@smartsoft001/crud-domain": "2.145.0",
20
+ "@smartsoft001/crud-shell-dtos": "2.145.0",
21
+ "@smartsoft001/auth-shell-dtos": "2.145.0",
22
+ "@smartsoft001/crud-shell-app-services": "2.145.0",
23
+ "@smartsoft001/auth-shell-app-services": "2.145.0"
20
24
  }
21
25
  }
@@ -0,0 +1,52 @@
1
+ # use-stack-packages
2
+
3
+ Since 2.143.0 the framework publishes four meta packages that pin a set of libraries at one
4
+ version: `@smartsoft001/core`, `@smartsoft001/angular-stack`, `@smartsoft001/nestjs-stack` and
5
+ `@smartsoft001/payments-stack`. This migration rewrites your `package.json` so a project that
6
+ already installs a whole set installs the set instead of listing its parts.
7
+
8
+ ## What it changes
9
+
10
+ In `dependencies` and in `devDependencies`, whenever a section lists **two or more** packages that
11
+ one stack pins, those entries are replaced by a single entry for the stack:
12
+
13
+ ```diff
14
+ "dependencies": {
15
+ - "@smartsoft001/angular": "2.143.0",
16
+ - "@smartsoft001/crud-shell-angular": "2.143.0"
17
+ + "@smartsoft001/angular-stack": "2.143.0"
18
+ }
19
+ ```
20
+
21
+ Details worth knowing:
22
+
23
+ - The stack takes the version the replaced entries carried. They are normally in lockstep. When
24
+ they are not, the highest version wins and the log line says so.
25
+ - `@smartsoft001/core` is resolved first, and is itself part of the Angular and the NestJS stack.
26
+ A project with the full core set plus `@smartsoft001/angular` ends up with `angular-stack` alone,
27
+ because that stack already pins `core`.
28
+ - An entry for a stack you already install is folded into the result rather than duplicated.
29
+ - The new entry keeps the position and the section of the first entry it replaces. If the section
30
+ was sorted alphabetically it stays sorted.
31
+ - Every replacement is logged, and one final line names the packages that stayed individually
32
+ installed.
33
+
34
+ ## What it deliberately does not change
35
+
36
+ - **A single member of a stack.** Installing one library on purpose is a legitimate choice, so one
37
+ entry is never turned into a stack that would pull in the rest.
38
+ - **Packages no stack pins**: `@smartsoft001/fb`, `@smartsoft001/google` and
39
+ `@smartsoft001/claude-plugins` are left exactly as they are.
40
+ - **Members split across sections.** Each section is counted on its own, so one member in
41
+ `dependencies` and one in `devDependencies` is two lonely entries, not a stack.
42
+ - **Anything outside `package.json`.** Imports keep working because the stacks re-export nothing and
43
+ hide nothing: every library stays installed, just by way of the stack. Your lockfile is not
44
+ touched, so run your package manager's install afterwards.
45
+
46
+ Running the migration a second time changes nothing.
47
+
48
+ ## How to undo it
49
+
50
+ The change is confined to `package.json`, so `git checkout -- package.json` before you install is
51
+ enough. If you have already installed, put the individual entries back at the version the stack
52
+ carried and install again. The stacks add no code of their own, so nothing else needs reverting.
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function update(tree: Tree): Promise<void>;
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = update;
4
+ const devkit_1 = require("@nx/devkit");
5
+ /**
6
+ * The meta packages and the packages each of them pins.
7
+ *
8
+ * This mirrors the `dependencies` block of every `package.json` under
9
+ * `packages/meta` and has to be kept in step with them by hand: a consumer's
10
+ * `node_modules` is not guaranteed to contain the meta packages, so the
11
+ * migration cannot read the lists at runtime.
12
+ *
13
+ * `@smartsoft001/core` comes first, and is itself a member of the Angular and
14
+ * the NestJS stack, so a project that pulls in the whole core set collapses to
15
+ * `core` and from there into the framework stack.
16
+ */
17
+ const STACKS = {
18
+ '@smartsoft001/core': [
19
+ '@smartsoft001/models',
20
+ '@smartsoft001/domain-core',
21
+ '@smartsoft001/utils',
22
+ '@smartsoft001/users',
23
+ '@smartsoft001/auth-domain',
24
+ '@smartsoft001/crud-domain',
25
+ '@smartsoft001/crud-shell-dtos',
26
+ '@smartsoft001/auth-shell-dtos',
27
+ '@smartsoft001/crud-shell-app-services',
28
+ '@smartsoft001/auth-shell-app-services',
29
+ ],
30
+ '@smartsoft001/angular-stack': [
31
+ '@smartsoft001/core',
32
+ '@smartsoft001/angular',
33
+ '@smartsoft001/crud-shell-angular',
34
+ ],
35
+ '@smartsoft001/nestjs-stack': [
36
+ '@smartsoft001/core',
37
+ '@smartsoft001/nestjs',
38
+ '@smartsoft001/mongo',
39
+ '@smartsoft001/crud-shell-nestjs',
40
+ '@smartsoft001/auth-shell-nestjs',
41
+ ],
42
+ '@smartsoft001/payments-stack': [
43
+ '@smartsoft001/trans-domain',
44
+ '@smartsoft001/trans-shell-app-services',
45
+ '@smartsoft001/trans-shell-nestjs',
46
+ '@smartsoft001/paypal',
47
+ '@smartsoft001/payu',
48
+ '@smartsoft001/paynow',
49
+ '@smartsoft001/revolut',
50
+ ],
51
+ };
52
+ /** Every package a stack pins, the stacks themselves excluded. */
53
+ const MEMBERS = new Set(Object.values(STACKS)
54
+ .flat()
55
+ .filter((name) => !(name in STACKS)));
56
+ const SECTIONS = ['dependencies', 'devDependencies'];
57
+ /** Compares the numbers in two npm specifiers, so `^2.143.0` beats `2.140.0`. */
58
+ function compareVersions(a, b) {
59
+ const numbers = (value) => (value.match(/\d+/g) ?? []).map(Number);
60
+ const left = numbers(a);
61
+ const right = numbers(b);
62
+ for (let index = 0; index < Math.max(left.length, right.length); index++) {
63
+ const difference = (left[index] ?? 0) - (right[index] ?? 0);
64
+ if (difference !== 0) {
65
+ return difference;
66
+ }
67
+ }
68
+ return 0;
69
+ }
70
+ function highestVersion(versions) {
71
+ return versions.reduce((highest, version) => compareVersions(version, highest) > 0 ? version : highest);
72
+ }
73
+ function isSorted(names) {
74
+ return names.every((name, index) => index === 0 || names[index - 1] <= name);
75
+ }
76
+ /**
77
+ * Replaces every group of two or more members of one stack with the stack,
78
+ * in the position of the first entry it replaces.
79
+ */
80
+ function collapse(deps) {
81
+ const keepSorted = isSorted(Object.keys(deps));
82
+ const replacements = [];
83
+ let entries = Object.entries(deps);
84
+ for (const [stack, members] of Object.entries(STACKS)) {
85
+ const present = entries.filter(([name]) => members.includes(name));
86
+ if (present.length < 2) {
87
+ continue;
88
+ }
89
+ // An entry for the stack itself is folded in rather than left duplicated.
90
+ const replaces = ([name]) => members.includes(name) || name === stack;
91
+ const versions = entries.filter(replaces).map(([, version]) => version);
92
+ const version = highestVersion(versions);
93
+ replacements.push({
94
+ stack,
95
+ version,
96
+ versions,
97
+ replaced: present.map(([name]) => name),
98
+ });
99
+ const next = [];
100
+ for (const entry of entries) {
101
+ if (!replaces(entry)) {
102
+ next.push(entry);
103
+ }
104
+ else if (next.every(([name]) => name !== stack)) {
105
+ next.push([stack, version]);
106
+ }
107
+ }
108
+ entries = next;
109
+ }
110
+ if (keepSorted) {
111
+ entries.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
112
+ }
113
+ return { deps: Object.fromEntries(entries), replacements };
114
+ }
115
+ function describeReplacement(section, replacement) {
116
+ const { stack, version, versions, replaced } = replacement;
117
+ const disagreed = versions.some((other) => other !== versions[0])
118
+ ? `, versions differed (${versions.join(', ')}), kept the highest`
119
+ : '';
120
+ return `${section}: ${replaced.join(', ')} -> ${stack}@${version}${disagreed}`;
121
+ }
122
+ async function update(tree) {
123
+ const leftovers = [];
124
+ (0, devkit_1.updateJson)(tree, 'package.json', (json) => {
125
+ for (const section of SECTIONS) {
126
+ const current = json[section];
127
+ if (!current) {
128
+ continue;
129
+ }
130
+ const { deps, replacements } = collapse(current);
131
+ json[section] = deps;
132
+ for (const replacement of replacements) {
133
+ devkit_1.logger.info(describeReplacement(section, replacement));
134
+ }
135
+ for (const name of Object.keys(deps)) {
136
+ if (MEMBERS.has(name) && !leftovers.includes(name)) {
137
+ leftovers.push(name);
138
+ }
139
+ }
140
+ }
141
+ return json;
142
+ });
143
+ if (leftovers.length > 0) {
144
+ devkit_1.logger.info(`Still installed individually: ${leftovers.join(', ')}`);
145
+ }
146
+ }
147
+ //# sourceMappingURL=use-stack-packages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-stack-packages.js","sourceRoot":"","sources":["../../../../../../../packages/meta/core/src/migrations/use-stack-packages/use-stack-packages.ts"],"names":[],"mappings":";;AAoKA,yBAgCC;AApMD,uCAAsD;AAEtD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,GAA6B;IACvC,oBAAoB,EAAE;QACpB,sBAAsB;QACtB,2BAA2B;QAC3B,qBAAqB;QACrB,qBAAqB;QACrB,2BAA2B;QAC3B,2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