@digigov/cli 2.4.1 → 2.4.2-platform-263.12-06-26-14-50
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/CHANGELOG.md +320 -0
- package/commands/packages/changelog.js +377 -0
- package/commands/packages.js +2 -0
- package/lib/registry.js +40 -3
- package/package.json +2 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# Change Log - @digigov/cli
|
|
2
|
+
|
|
3
|
+
<!-- This log was last generated on Fri, 12 Jun 2026 14:50:19 GMT and should not be manually modified. -->
|
|
4
|
+
|
|
5
|
+
<!-- Start content -->
|
|
6
|
+
|
|
7
|
+
## 2.4.2-platform-263.12-06-26-14-50
|
|
8
|
+
|
|
9
|
+
Fri, 12 Jun 2026 14:50:19 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Include CHANGELOG.md in published files (sangelopoulos@admin.grnet.gr)
|
|
14
|
+
|
|
15
|
+
## 2.3.0
|
|
16
|
+
|
|
17
|
+
Thu, 04 Jun 2026 13:54:34 GMT
|
|
18
|
+
|
|
19
|
+
### Minor changes
|
|
20
|
+
|
|
21
|
+
- Add sdk packages management subcommands (sangelopoulos@admin.grnet.gr)
|
|
22
|
+
|
|
23
|
+
## 2.0.8
|
|
24
|
+
Wed, 11 Feb 2026 14:46:37 GMT
|
|
25
|
+
|
|
26
|
+
_Version update only_
|
|
27
|
+
|
|
28
|
+
## 2.0.7
|
|
29
|
+
Tue, 10 Feb 2026 13:53:35 GMT
|
|
30
|
+
|
|
31
|
+
_Version update only_
|
|
32
|
+
|
|
33
|
+
## 2.0.6
|
|
34
|
+
Wed, 28 Jan 2026 13:14:05 GMT
|
|
35
|
+
|
|
36
|
+
_Version update only_
|
|
37
|
+
|
|
38
|
+
## 2.0.5
|
|
39
|
+
Tue, 27 Jan 2026 13:46:07 GMT
|
|
40
|
+
|
|
41
|
+
_Version update only_
|
|
42
|
+
|
|
43
|
+
## 2.0.4
|
|
44
|
+
Tue, 27 Jan 2026 13:12:04 GMT
|
|
45
|
+
|
|
46
|
+
_Version update only_
|
|
47
|
+
|
|
48
|
+
## 2.0.3
|
|
49
|
+
Wed, 21 Jan 2026 21:01:49 GMT
|
|
50
|
+
|
|
51
|
+
_Version update only_
|
|
52
|
+
|
|
53
|
+
## 2.0.2
|
|
54
|
+
Wed, 21 Jan 2026 15:58:34 GMT
|
|
55
|
+
|
|
56
|
+
### Breaking changes
|
|
57
|
+
|
|
58
|
+
- Use typescript & commanderjs
|
|
59
|
+
|
|
60
|
+
### Patches
|
|
61
|
+
|
|
62
|
+
- Hide unnecessary & confusing error log
|
|
63
|
+
- Isolate resolveProject function to a new file
|
|
64
|
+
- Improve error logs
|
|
65
|
+
- Improve error logs & reduce verbosity
|
|
66
|
+
- Update @microsoft/rush-lib
|
|
67
|
+
- Update package.json
|
|
68
|
+
|
|
69
|
+
### Updates
|
|
70
|
+
|
|
71
|
+
- Add tsconfig.cli to exports
|
|
72
|
+
- Remove unused config files
|
|
73
|
+
- Add type checking in dev for js files
|
|
74
|
+
- Update @types/node
|
|
75
|
+
|
|
76
|
+
## 1.1.0
|
|
77
|
+
Mon, 29 Jan 2024 10:12:45 GMT
|
|
78
|
+
|
|
79
|
+
### Minor changes
|
|
80
|
+
|
|
81
|
+
- Upgrade typescript to v5
|
|
82
|
+
|
|
83
|
+
## 1.0.1
|
|
84
|
+
Tue, 19 Dec 2023 15:00:14 GMT
|
|
85
|
+
|
|
86
|
+
### Patches
|
|
87
|
+
|
|
88
|
+
- Make package compatible with node v18
|
|
89
|
+
|
|
90
|
+
## 1.0.0
|
|
91
|
+
Fri, 15 Dec 2023 15:23:56 GMT
|
|
92
|
+
|
|
93
|
+
### Breaking changes
|
|
94
|
+
|
|
95
|
+
- Upgrade versions to v1.0.0-rc
|
|
96
|
+
|
|
97
|
+
### Patches
|
|
98
|
+
|
|
99
|
+
- Check for lock files in project
|
|
100
|
+
|
|
101
|
+
## 0.6.6
|
|
102
|
+
Wed, 22 Feb 2023 15:41:06 GMT
|
|
103
|
+
|
|
104
|
+
### Patches
|
|
105
|
+
|
|
106
|
+
- Add extra check for workspace root folder when reading gitignore file
|
|
107
|
+
|
|
108
|
+
## 0.6.5
|
|
109
|
+
Thu, 02 Feb 2023 16:12:09 GMT
|
|
110
|
+
|
|
111
|
+
### Patches
|
|
112
|
+
|
|
113
|
+
- Remove dirName from DigigovCommand class
|
|
114
|
+
|
|
115
|
+
## 0.6.4
|
|
116
|
+
Fri, 02 Dec 2022 11:20:56 GMT
|
|
117
|
+
|
|
118
|
+
### Patches
|
|
119
|
+
|
|
120
|
+
- Upgrade tslib to v2.4.1
|
|
121
|
+
|
|
122
|
+
## 0.6.3
|
|
123
|
+
Fri, 18 Nov 2022 08:33:43 GMT
|
|
124
|
+
|
|
125
|
+
### Patches
|
|
126
|
+
|
|
127
|
+
- testing tests
|
|
128
|
+
|
|
129
|
+
## 0.6.2
|
|
130
|
+
Wed, 16 Nov 2022 14:27:34 GMT
|
|
131
|
+
|
|
132
|
+
### Patches
|
|
133
|
+
|
|
134
|
+
- Remove whitespace from lib.js, also test release process, move along :)
|
|
135
|
+
|
|
136
|
+
## 0.6.1
|
|
137
|
+
Tue, 17 May 2022 11:04:22 GMT
|
|
138
|
+
|
|
139
|
+
### Patches
|
|
140
|
+
|
|
141
|
+
- Fix author field in package.json, adding GRNET Devs and their contact details
|
|
142
|
+
|
|
143
|
+
## 0.6.0
|
|
144
|
+
Mon, 18 Apr 2022 13:00:33 GMT
|
|
145
|
+
|
|
146
|
+
### Minor changes
|
|
147
|
+
|
|
148
|
+
- Upgrade @types/node version
|
|
149
|
+
|
|
150
|
+
## 0.5.28
|
|
151
|
+
Thu, 14 Apr 2022 12:32:51 GMT
|
|
152
|
+
|
|
153
|
+
### Patches
|
|
154
|
+
|
|
155
|
+
- Upgrade rushjs to 5.64.0
|
|
156
|
+
|
|
157
|
+
## 0.5.27
|
|
158
|
+
Mon, 14 Feb 2022 09:56:29 GMT
|
|
159
|
+
|
|
160
|
+
### Patches
|
|
161
|
+
|
|
162
|
+
- pin down and sync deps versions
|
|
163
|
+
|
|
164
|
+
## 0.5.26
|
|
165
|
+
Thu, 10 Feb 2022 13:45:56 GMT
|
|
166
|
+
|
|
167
|
+
### Patches
|
|
168
|
+
|
|
169
|
+
- pin down dependency versions
|
|
170
|
+
|
|
171
|
+
## 0.5.25
|
|
172
|
+
Tue, 02 Nov 2021 13:03:39 GMT
|
|
173
|
+
|
|
174
|
+
### Patches
|
|
175
|
+
|
|
176
|
+
- Bump version to update node engine version
|
|
177
|
+
|
|
178
|
+
### Updates
|
|
179
|
+
|
|
180
|
+
- change node supported versions
|
|
181
|
+
|
|
182
|
+
## 0.5.24
|
|
183
|
+
Thu, 12 Aug 2021 08:56:35 GMT
|
|
184
|
+
|
|
185
|
+
_Version update only_
|
|
186
|
+
|
|
187
|
+
## 0.5.23
|
|
188
|
+
Thu, 12 Aug 2021 06:18:14 GMT
|
|
189
|
+
|
|
190
|
+
_Version update only_
|
|
191
|
+
|
|
192
|
+
## 0.5.22
|
|
193
|
+
Tue, 03 Aug 2021 12:09:02 GMT
|
|
194
|
+
|
|
195
|
+
_Version update only_
|
|
196
|
+
|
|
197
|
+
## 0.5.21
|
|
198
|
+
Tue, 03 Aug 2021 10:22:51 GMT
|
|
199
|
+
|
|
200
|
+
_Version update only_
|
|
201
|
+
|
|
202
|
+
## 0.5.20
|
|
203
|
+
Fri, 30 Jul 2021 13:01:30 GMT
|
|
204
|
+
|
|
205
|
+
_Version update only_
|
|
206
|
+
|
|
207
|
+
## 0.5.19
|
|
208
|
+
Fri, 30 Jul 2021 11:35:29 GMT
|
|
209
|
+
|
|
210
|
+
_Version update only_
|
|
211
|
+
|
|
212
|
+
## 0.5.18
|
|
213
|
+
Fri, 30 Jul 2021 10:46:37 GMT
|
|
214
|
+
|
|
215
|
+
_Version update only_
|
|
216
|
+
|
|
217
|
+
## 0.5.17
|
|
218
|
+
Fri, 30 Jul 2021 08:49:46 GMT
|
|
219
|
+
|
|
220
|
+
_Version update only_
|
|
221
|
+
|
|
222
|
+
## 0.5.16
|
|
223
|
+
Fri, 30 Jul 2021 07:46:24 GMT
|
|
224
|
+
|
|
225
|
+
_Version update only_
|
|
226
|
+
|
|
227
|
+
## 0.5.15
|
|
228
|
+
Tue, 27 Jul 2021 10:14:43 GMT
|
|
229
|
+
|
|
230
|
+
_Version update only_
|
|
231
|
+
|
|
232
|
+
## 0.5.14
|
|
233
|
+
Thu, 15 Jul 2021 11:16:22 GMT
|
|
234
|
+
|
|
235
|
+
_Version update only_
|
|
236
|
+
|
|
237
|
+
## 0.5.13
|
|
238
|
+
Fri, 09 Jul 2021 08:59:32 GMT
|
|
239
|
+
|
|
240
|
+
_Version update only_
|
|
241
|
+
|
|
242
|
+
## 0.5.12
|
|
243
|
+
Thu, 08 Jul 2021 15:08:50 GMT
|
|
244
|
+
|
|
245
|
+
_Version update only_
|
|
246
|
+
|
|
247
|
+
## 0.5.11
|
|
248
|
+
Wed, 30 Jun 2021 12:09:21 GMT
|
|
249
|
+
|
|
250
|
+
_Version update only_
|
|
251
|
+
|
|
252
|
+
## 0.5.10
|
|
253
|
+
Wed, 23 Jun 2021 13:04:19 GMT
|
|
254
|
+
|
|
255
|
+
_Version update only_
|
|
256
|
+
|
|
257
|
+
## 0.5.9
|
|
258
|
+
Wed, 02 Jun 2021 12:04:27 GMT
|
|
259
|
+
|
|
260
|
+
_Version update only_
|
|
261
|
+
|
|
262
|
+
## 0.5.8
|
|
263
|
+
Wed, 02 Jun 2021 08:33:44 GMT
|
|
264
|
+
|
|
265
|
+
_Version update only_
|
|
266
|
+
|
|
267
|
+
## 0.5.7
|
|
268
|
+
Wed, 05 May 2021 14:11:41 GMT
|
|
269
|
+
|
|
270
|
+
_Version update only_
|
|
271
|
+
|
|
272
|
+
## 0.5.6
|
|
273
|
+
Thu, 22 Apr 2021 15:04:42 GMT
|
|
274
|
+
|
|
275
|
+
_Version update only_
|
|
276
|
+
|
|
277
|
+
## 0.5.5
|
|
278
|
+
Thu, 22 Apr 2021 14:39:18 GMT
|
|
279
|
+
|
|
280
|
+
_Version update only_
|
|
281
|
+
|
|
282
|
+
## 0.5.4
|
|
283
|
+
Thu, 22 Apr 2021 14:06:40 GMT
|
|
284
|
+
|
|
285
|
+
_Version update only_
|
|
286
|
+
|
|
287
|
+
## 0.5.3
|
|
288
|
+
Thu, 22 Apr 2021 12:56:25 GMT
|
|
289
|
+
|
|
290
|
+
### Patches
|
|
291
|
+
|
|
292
|
+
- Fix prepack behaviour
|
|
293
|
+
|
|
294
|
+
## 0.5.2
|
|
295
|
+
Thu, 01 Apr 2021 10:33:13 GMT
|
|
296
|
+
|
|
297
|
+
### Patches
|
|
298
|
+
|
|
299
|
+
- Fix files included in published tarball
|
|
300
|
+
|
|
301
|
+
## 0.5.1
|
|
302
|
+
Wed, 31 Mar 2021 14:56:49 GMT
|
|
303
|
+
|
|
304
|
+
### Patches
|
|
305
|
+
|
|
306
|
+
- Introduce the new cli for Digigov apps, that supports external plugins eg. @digigov/cli-app
|
|
307
|
+
|
|
308
|
+
## 0.5.0
|
|
309
|
+
Tue, 23 Mar 2021 16:48:10 GMT
|
|
310
|
+
|
|
311
|
+
### Minor changes
|
|
312
|
+
|
|
313
|
+
- nai poios einai 2
|
|
314
|
+
|
|
315
|
+
## 0.4.0
|
|
316
|
+
Tue, 23 Mar 2021 16:17:35 GMT
|
|
317
|
+
|
|
318
|
+
### Minor changes
|
|
319
|
+
|
|
320
|
+
- nai poios einai 2
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { execa } from 'execa';
|
|
5
|
+
import { DigigovCommand } from '../../lib/command.js';
|
|
6
|
+
import { logger } from '../../lib/logger.js';
|
|
7
|
+
import { findPackageJson } from '../../lib/project-utils.cjs';
|
|
8
|
+
import {
|
|
9
|
+
getScopedDependencies,
|
|
10
|
+
getInstalledVersion,
|
|
11
|
+
} from '../../lib/scope-scan.js';
|
|
12
|
+
import { compareVersions } from '../../lib/registry.js';
|
|
13
|
+
|
|
14
|
+
const DOCS_CHANGELOG_URL =
|
|
15
|
+
'https://devs.pages.grnet.gr/digigov/digigov-sdk/sdk-docs/docs/releases/changelog';
|
|
16
|
+
|
|
17
|
+
export function createChangelogCommand() {
|
|
18
|
+
const cmd = new DigigovCommand('changelog');
|
|
19
|
+
cmd
|
|
20
|
+
.description(
|
|
21
|
+
'Show changelog entries for every installed @digigov package',
|
|
22
|
+
)
|
|
23
|
+
.option(
|
|
24
|
+
'--since <version>',
|
|
25
|
+
'Show all entries newer than this version (applied to every package)',
|
|
26
|
+
)
|
|
27
|
+
.action(async (options) => {
|
|
28
|
+
const pkgPath = findPackageJson();
|
|
29
|
+
if (!pkgPath) {
|
|
30
|
+
logger.warn('No package.json found in the current directory tree.');
|
|
31
|
+
process.exitCode = 1;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const projectRoot = path.dirname(pkgPath);
|
|
35
|
+
/** @type {Record<string, unknown>} */
|
|
36
|
+
const pkg = await fs.readJSON(pkgPath);
|
|
37
|
+
const scoped = getScopedDependencies(pkg);
|
|
38
|
+
|
|
39
|
+
if (scoped.length === 0) {
|
|
40
|
+
logger.warn('No @digigov/* dependencies found. Nothing to show.');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** @type {{ versions: Map<string, string>, ref: string } | null} */
|
|
45
|
+
let gitBase = null;
|
|
46
|
+
if (!options.since) {
|
|
47
|
+
gitBase = await getPreviousVersionsFromGit(pkgPath);
|
|
48
|
+
if (gitBase) {
|
|
49
|
+
console.log(
|
|
50
|
+
chalk.dim(
|
|
51
|
+
`Comparing against base (${gitBase.ref.slice(0, 8)})...\n`,
|
|
52
|
+
),
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
let printedCount = 0;
|
|
58
|
+
for (const dep of scoped) {
|
|
59
|
+
const installedVersion = getInstalledVersion(projectRoot, dep.name);
|
|
60
|
+
if (!installedVersion) {
|
|
61
|
+
console.log(
|
|
62
|
+
'\n' + chalk.bold(dep.name) + ' ' + chalk.dim('(not installed)'),
|
|
63
|
+
);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let sinceVersion =
|
|
68
|
+
options.since ?? gitBase?.versions.get(dep.name) ?? null;
|
|
69
|
+
|
|
70
|
+
if (sinceVersion && sinceVersion === installedVersion) {
|
|
71
|
+
sinceVersion = null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const changelogPath = path.join(
|
|
75
|
+
projectRoot,
|
|
76
|
+
'node_modules',
|
|
77
|
+
...dep.name.split('/'),
|
|
78
|
+
'CHANGELOG.md',
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
if (!fs.existsSync(changelogPath)) {
|
|
82
|
+
console.log(
|
|
83
|
+
'\n' +
|
|
84
|
+
chalk.bold.cyan(dep.name) +
|
|
85
|
+
' ' +
|
|
86
|
+
chalk.dim(`v${installedVersion}`) +
|
|
87
|
+
' ' +
|
|
88
|
+
chalk.dim('(no CHANGELOG bundled)'),
|
|
89
|
+
);
|
|
90
|
+
printedCount++;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const content = await fs.readFile(changelogPath, 'utf8');
|
|
95
|
+
|
|
96
|
+
if (sinceVersion) {
|
|
97
|
+
const entries = parseEntriesSince(content, sinceVersion);
|
|
98
|
+
printEntries(dep.name, installedVersion, sinceVersion, entries);
|
|
99
|
+
} else {
|
|
100
|
+
const entry = parseLatestEntry(content);
|
|
101
|
+
printEntry(dep.name, installedVersion, entry);
|
|
102
|
+
}
|
|
103
|
+
printedCount++;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
console.log(
|
|
107
|
+
'\n' +
|
|
108
|
+
chalk.dim('Full release notes → ') +
|
|
109
|
+
chalk.dim.underline(DOCS_CHANGELOG_URL),
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
return cmd;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @typedef {{ version: string, date: string, sections: Array<{ heading: string, items: string[] }> }} ChangelogEntry
|
|
117
|
+
*/
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Strip leading range characters (`^`, `~`, `>=`, `>`, `<=`, `<`) from a
|
|
122
|
+
* version specifier and return the bare semver. Returns `null` for
|
|
123
|
+
* non-semver values (workspace:*, catalog:, etc.).
|
|
124
|
+
*
|
|
125
|
+
* @param {string} range
|
|
126
|
+
* @returns {string | null}
|
|
127
|
+
*/
|
|
128
|
+
function stripRangePrefix(range) {
|
|
129
|
+
const match = range.match(/(\d+\.\d+[\.\d]*.*)/);
|
|
130
|
+
return match ? match[1] : null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Parse all version blocks newer than `sinceVersion` from a beachball
|
|
135
|
+
* CHANGELOG.md. Entries are returned in changelog order (newest first).
|
|
136
|
+
*
|
|
137
|
+
* @param {string} content
|
|
138
|
+
* @param {string} sinceVersion
|
|
139
|
+
* @returns {ChangelogEntry[]}
|
|
140
|
+
*/
|
|
141
|
+
function parseEntriesSince(content, sinceVersion) {
|
|
142
|
+
const lines = content.split('\n');
|
|
143
|
+
/** @type {ChangelogEntry[]} */
|
|
144
|
+
const entries = [];
|
|
145
|
+
/** @type {ChangelogEntry | null} */
|
|
146
|
+
let current = null;
|
|
147
|
+
/** @type {{ heading: string, items: string[] } | null} */
|
|
148
|
+
let currentSection = null;
|
|
149
|
+
|
|
150
|
+
for (const line of lines) {
|
|
151
|
+
const versionMatch = line.match(/^## (\S+)/);
|
|
152
|
+
if (versionMatch) {
|
|
153
|
+
const version = versionMatch[1];
|
|
154
|
+
if (compareVersions(version, sinceVersion) <= 0) break;
|
|
155
|
+
current = { version, date: '', sections: [] };
|
|
156
|
+
currentSection = null;
|
|
157
|
+
entries.push(current);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (!current) continue;
|
|
162
|
+
|
|
163
|
+
if (!current.date && line.trim() && !line.startsWith('#')) {
|
|
164
|
+
current.date = line.trim();
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const sectionMatch = line.match(/^### (.+)/);
|
|
169
|
+
if (sectionMatch) {
|
|
170
|
+
currentSection = { heading: sectionMatch[1], items: [] };
|
|
171
|
+
current.sections.push(currentSection);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const itemMatch = line.match(/^- (.+)/);
|
|
176
|
+
if (itemMatch && currentSection) {
|
|
177
|
+
currentSection.items.push(
|
|
178
|
+
itemMatch[1].replace(/\s*\([^)]+@[^)]+\)\s*$/, '').trim(),
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return entries;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Parse the first (latest) version block from a beachball CHANGELOG.md.
|
|
188
|
+
*
|
|
189
|
+
* @param {string} content
|
|
190
|
+
* @returns {ChangelogEntry | null}
|
|
191
|
+
*/
|
|
192
|
+
function parseLatestEntry(content) {
|
|
193
|
+
const lines = content.split('\n');
|
|
194
|
+
let inEntry = false;
|
|
195
|
+
let version = '';
|
|
196
|
+
let date = '';
|
|
197
|
+
/** @type {Array<{ heading: string, items: string[] }>} */
|
|
198
|
+
const sections = [];
|
|
199
|
+
/** @type {{ heading: string, items: string[] } | null} */
|
|
200
|
+
let currentSection = null;
|
|
201
|
+
|
|
202
|
+
for (const line of lines) {
|
|
203
|
+
const versionMatch = line.match(/^## (\S+)/);
|
|
204
|
+
if (versionMatch) {
|
|
205
|
+
if (inEntry) break;
|
|
206
|
+
version = versionMatch[1];
|
|
207
|
+
inEntry = true;
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (!inEntry) continue;
|
|
211
|
+
|
|
212
|
+
if (!date && line.trim() && !line.startsWith('#')) {
|
|
213
|
+
date = line.trim();
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const sectionMatch = line.match(/^### (.+)/);
|
|
218
|
+
if (sectionMatch) {
|
|
219
|
+
currentSection = { heading: sectionMatch[1], items: [] };
|
|
220
|
+
sections.push(currentSection);
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const itemMatch = line.match(/^- (.+)/);
|
|
225
|
+
if (itemMatch && currentSection) {
|
|
226
|
+
const item = itemMatch[1]
|
|
227
|
+
.replace(/\s*\([^)]+@[^)]+\)\s*$/, '')
|
|
228
|
+
.trim();
|
|
229
|
+
currentSection.items.push(item);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (!version) return null;
|
|
234
|
+
return { version, date, sections };
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* @param {string} name
|
|
239
|
+
* @param {string} installedVersion
|
|
240
|
+
* @param {string} sinceVersion
|
|
241
|
+
* @param {ChangelogEntry[]} entries
|
|
242
|
+
*/
|
|
243
|
+
function printEntries(name, installedVersion, sinceVersion, entries) {
|
|
244
|
+
console.log(
|
|
245
|
+
'\n' +
|
|
246
|
+
chalk.bold.cyan(name) +
|
|
247
|
+
' ' +
|
|
248
|
+
chalk.dim(`v${sinceVersion} → v${installedVersion}`),
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
if (entries.length === 0) {
|
|
252
|
+
console.log(chalk.dim(' No changelog entries found for this range'));
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
for (const entry of entries) {
|
|
257
|
+
console.log(
|
|
258
|
+
' ' + chalk.bold(`v${entry.version}`) + ' ' + chalk.dim(entry.date),
|
|
259
|
+
);
|
|
260
|
+
if (entry.sections.length === 0) {
|
|
261
|
+
console.log(chalk.dim(' Version update only'));
|
|
262
|
+
}
|
|
263
|
+
for (const section of entry.sections) {
|
|
264
|
+
console.log(' ' + chalk.yellow(section.heading));
|
|
265
|
+
for (const item of section.items) {
|
|
266
|
+
console.log(' ' + chalk.dim('·') + ' ' + item);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* @param {string} name
|
|
274
|
+
* @param {string} installedVersion
|
|
275
|
+
* @param {ChangelogEntry | null} entry
|
|
276
|
+
*/
|
|
277
|
+
function printEntry(name, installedVersion, entry) {
|
|
278
|
+
console.log(
|
|
279
|
+
'\n' + chalk.bold.cyan(name) + ' ' + chalk.dim(`v${installedVersion}`),
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
if (!entry) {
|
|
283
|
+
console.log(chalk.dim(' (could not parse changelog)'));
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
console.log(chalk.dim(` ${entry.date}`));
|
|
288
|
+
|
|
289
|
+
if (entry.sections.length === 0) {
|
|
290
|
+
console.log(chalk.dim(' Version update only'));
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
for (const section of entry.sections) {
|
|
295
|
+
console.log(' ' + chalk.yellow(section.heading));
|
|
296
|
+
for (const item of section.items) {
|
|
297
|
+
console.log(' ' + chalk.dim('·') + ' ' + item);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Read `package.json` at the git base branch and return a map of `@digigov/*`
|
|
304
|
+
* package names to their bare semver (range prefix stripped).
|
|
305
|
+
*
|
|
306
|
+
* Base ref resolution order: merge-base with main → master → origin/main →
|
|
307
|
+
* origin/master → HEAD~1. Returns `null` when git is unavailable or the
|
|
308
|
+
* file cannot be read.
|
|
309
|
+
*
|
|
310
|
+
* @param {string} pkgJsonPath Absolute path to the consumer's package.json
|
|
311
|
+
* @returns {Promise<{ versions: Map<string, string>, ref: string } | null>}
|
|
312
|
+
*/
|
|
313
|
+
async function getPreviousVersionsFromGit(pkgJsonPath) {
|
|
314
|
+
let gitRoot;
|
|
315
|
+
try {
|
|
316
|
+
const { stdout } = await execa(
|
|
317
|
+
'git',
|
|
318
|
+
['rev-parse', '--show-toplevel'],
|
|
319
|
+
{ cwd: path.dirname(pkgJsonPath) },
|
|
320
|
+
);
|
|
321
|
+
gitRoot = stdout.trim();
|
|
322
|
+
} catch {
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const pkgRelative = path
|
|
327
|
+
.relative(gitRoot, pkgJsonPath)
|
|
328
|
+
.replace(/\\/g, '/');
|
|
329
|
+
|
|
330
|
+
let baseRef = null;
|
|
331
|
+
for (const branch of ['main', 'master', 'origin/main', 'origin/master']) {
|
|
332
|
+
try {
|
|
333
|
+
const { stdout } = await execa(
|
|
334
|
+
'git',
|
|
335
|
+
['merge-base', 'HEAD', branch],
|
|
336
|
+
{ cwd: gitRoot },
|
|
337
|
+
);
|
|
338
|
+
baseRef = stdout.trim();
|
|
339
|
+
break;
|
|
340
|
+
} catch {
|
|
341
|
+
// try next candidate
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (!baseRef) {
|
|
346
|
+
try {
|
|
347
|
+
const { stdout } = await execa('git', ['rev-parse', 'HEAD~1'], {
|
|
348
|
+
cwd: gitRoot,
|
|
349
|
+
});
|
|
350
|
+
baseRef = stdout.trim();
|
|
351
|
+
} catch {
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
let basePkg;
|
|
357
|
+
try {
|
|
358
|
+
const { stdout } = await execa(
|
|
359
|
+
'git',
|
|
360
|
+
['show', `${baseRef}:${pkgRelative}`],
|
|
361
|
+
{ cwd: gitRoot },
|
|
362
|
+
);
|
|
363
|
+
basePkg = JSON.parse(stdout);
|
|
364
|
+
} catch {
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
const baseScoped = getScopedDependencies(basePkg);
|
|
369
|
+
/** @type {Map<string, string>} */
|
|
370
|
+
const versions = new Map();
|
|
371
|
+
for (const dep of baseScoped) {
|
|
372
|
+
const bare = stripRangePrefix(dep.range);
|
|
373
|
+
if (bare) versions.set(dep.name, bare);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
return { versions, ref: baseRef };
|
|
377
|
+
}
|
package/commands/packages.js
CHANGED
|
@@ -2,6 +2,7 @@ import { DigigovCommand } from '../lib/command.js';
|
|
|
2
2
|
import { createInitCommand } from './packages/init.js';
|
|
3
3
|
import { createUpdateCommand } from './packages/update.js';
|
|
4
4
|
import { createDoctorCommand } from './packages/doctor.js';
|
|
5
|
+
import { createChangelogCommand } from './packages/changelog.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Register the built-in `packages` command group on the host program.
|
|
@@ -14,5 +15,6 @@ export function registerPackagesCommand(program) {
|
|
|
14
15
|
group.addCommand(createInitCommand());
|
|
15
16
|
group.addCommand(createUpdateCommand());
|
|
16
17
|
group.addCommand(createDoctorCommand());
|
|
18
|
+
group.addCommand(createChangelogCommand());
|
|
17
19
|
program.addCommand(group);
|
|
18
20
|
}
|
package/lib/registry.js
CHANGED
|
@@ -231,16 +231,53 @@ export async function getPackageInfo(packageName) {
|
|
|
231
231
|
* @param {string} b
|
|
232
232
|
*/
|
|
233
233
|
export function compareVersions(a, b) {
|
|
234
|
-
const [coreA, preA
|
|
235
|
-
const [coreB, preB
|
|
236
|
-
const coreCmp = compareCore(coreA
|
|
234
|
+
const [coreA, preA] = splitCoreAndPre(a);
|
|
235
|
+
const [coreB, preB] = splitCoreAndPre(b);
|
|
236
|
+
const coreCmp = compareCore(coreA, coreB);
|
|
237
237
|
if (coreCmp !== 0) return coreCmp;
|
|
238
238
|
if (preA === preB) return 0;
|
|
239
239
|
if (preA === '') return 1;
|
|
240
240
|
if (preB === '') return -1;
|
|
241
|
+
const keyA = internalPrereleaseSortKey(preA);
|
|
242
|
+
const keyB = internalPrereleaseSortKey(preB);
|
|
243
|
+
if (keyA && keyB) {
|
|
244
|
+
if (keyA === keyB) return 0;
|
|
245
|
+
return keyA > keyB ? 1 : -1;
|
|
246
|
+
}
|
|
241
247
|
return comparePrerelease(preA, preB);
|
|
242
248
|
}
|
|
243
249
|
|
|
250
|
+
/**
|
|
251
|
+
* Split a version into core and pre-release tail on the FIRST `-` only.
|
|
252
|
+
* `2.2.4-govgr-4546.09-06-26-13-10` → `['2.2.4', 'govgr-4546.09-06-26-13-10']`.
|
|
253
|
+
*
|
|
254
|
+
* @param {string} v
|
|
255
|
+
* @returns {[string, string]}
|
|
256
|
+
*/
|
|
257
|
+
function splitCoreAndPre(v) {
|
|
258
|
+
const i = v.indexOf('-');
|
|
259
|
+
if (i === -1) return [v, ''];
|
|
260
|
+
return [v.slice(0, i), v.slice(i + 1)];
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Recognise our internal pre-release format `<word>-<digits>.DD-MM-YY-hh-mm`
|
|
265
|
+
* (zero-padded) and return a chronologically sortable key. Returns `null`
|
|
266
|
+
* for any other shape so the caller falls back to standard semver
|
|
267
|
+
* pre-release comparison.
|
|
268
|
+
*
|
|
269
|
+
* @param {string} pre
|
|
270
|
+
* @returns {string | null}
|
|
271
|
+
*/
|
|
272
|
+
function internalPrereleaseSortKey(pre) {
|
|
273
|
+
const m = pre.match(
|
|
274
|
+
/^([a-zA-Z]+)-(\d+)\.(\d{2})-(\d{2})-(\d{2})-(\d{2})-(\d{2})$/,
|
|
275
|
+
);
|
|
276
|
+
if (!m) return null;
|
|
277
|
+
const [, , issue, dd, mm, yy, hh, mi] = m;
|
|
278
|
+
return `${yy}${mm}${dd}${hh}${mi}-${issue.padStart(8, '0')}`;
|
|
279
|
+
}
|
|
280
|
+
|
|
244
281
|
/**
|
|
245
282
|
* @param {string} a
|
|
246
283
|
* @param {string} b
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digigov/cli",
|
|
3
3
|
"description": "CLI for Digigov apps and libs with plugin support",
|
|
4
|
-
"version": "2.4.
|
|
4
|
+
"version": "2.4.2-platform-263.12-06-26-14-50",
|
|
5
5
|
"author": "GRNET Devs <devs@lists.grnet.gr>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"/lib",
|
|
32
32
|
"/commands",
|
|
33
33
|
"tsconfig.cli.json",
|
|
34
|
+
"CHANGELOG.md",
|
|
34
35
|
"!**/*.test.js",
|
|
35
36
|
"!test"
|
|
36
37
|
],
|