@uxf/scripts 14.1.0 → 14.2.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.
- package/README.md +40 -10
- package/package.json +1 -1
- package/src/gitlab.js +51 -3
- package/src/gitlab.test.js +42 -0
- package/src/uxf-dependencies-check/index.js +8 -4
- package/src/uxf-dependencies-check/peer-deps.d.ts +10 -0
- package/src/uxf-dependencies-check/peer-deps.js +62 -4
- package/src/uxf-dependencies-check/types.d.ts +3 -0
- package/src/uxf-release/cli.js +44 -0
- package/src/uxf-release/index.js +98 -41
- package/src/uxf-release/index.test.js +28 -14
- package/src/uxf-release/run.test.js +96 -0
package/README.md
CHANGED
|
@@ -23,16 +23,16 @@ Requires **Node.js >= 24** (`engines.node`). No peer dependencies. Runtime depen
|
|
|
23
23
|
|
|
24
24
|
## Commands
|
|
25
25
|
|
|
26
|
-
| Command | Purpose
|
|
27
|
-
| ------------------------- |
|
|
28
|
-
| `uxf-release` | Generate release notes from Git commits, create a GitLab release, notify Slack / Google Chat.
|
|
29
|
-
| `uxf-push-notifier` | Notify Google Chat when a merge request is merged into (or code is pushed to) the default branch.
|
|
30
|
-
| `uxf-dependencies-check` | Detect version conflicts
|
|
31
|
-
| `uxf-audit` | Print a JSON report of Node / Yarn / Next / React and installed `@uxf/*` versions.
|
|
32
|
-
| `uxf-claude-sync` | Download global guidelines from a URL into a `CLAUDE.md` file.
|
|
33
|
-
| `uxf-i18n-namespaces-gen` | Generate an `i18n-pages.json` mapping routes to the translation namespaces they use.
|
|
34
|
-
| `uxf-sitemap-check` | Crawl a sitemap and check all URLs for HTTP errors, duplicates, and missing pages.
|
|
35
|
-
| `uxf-sitemap-meta-export` | Crawl a sitemap and export page meta tags (title, description, OG) to `export.csv`.
|
|
26
|
+
| Command | Purpose |
|
|
27
|
+
| ------------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
28
|
+
| `uxf-release` | Generate release notes from Git commits, create a GitLab release, notify Slack / Google Chat. |
|
|
29
|
+
| `uxf-push-notifier` | Notify Google Chat when a merge request is merged into (or code is pushed to) the default branch. |
|
|
30
|
+
| `uxf-dependencies-check` | Detect version conflicts, missing/mismatched peers of `@uxf/*` packages and missing peers of other deps. |
|
|
31
|
+
| `uxf-audit` | Print a JSON report of Node / Yarn / Next / React and installed `@uxf/*` versions. |
|
|
32
|
+
| `uxf-claude-sync` | Download global guidelines from a URL into a `CLAUDE.md` file. |
|
|
33
|
+
| `uxf-i18n-namespaces-gen` | Generate an `i18n-pages.json` mapping routes to the translation namespaces they use. |
|
|
34
|
+
| `uxf-sitemap-check` | Crawl a sitemap and check all URLs for HTTP errors, duplicates, and missing pages. |
|
|
35
|
+
| `uxf-sitemap-meta-export` | Crawl a sitemap and export page meta tags (title, description, OG) to `export.csv`. |
|
|
36
36
|
|
|
37
37
|
Every command accepts `-h` / `--help`.
|
|
38
38
|
|
|
@@ -40,6 +40,15 @@ Every command accepts `-h` / `--help`.
|
|
|
40
40
|
|
|
41
41
|
Reads commits on `master` since the last Git tag, generates release notes (grouped by conventional-commit type, linking YouTrack issues), creates a GitLab release, and posts a summary to Slack and/or Google Chat. Warns when the range contains DB migration files.
|
|
42
42
|
|
|
43
|
+
Without the options below it behaves as it always did. They let a project release from another branch under its own version tags and with notes written elsewhere (e.g. by Claude in an earlier job):
|
|
44
|
+
|
|
45
|
+
- `--ref` – branch, tag or SHA to release from instead of `master`.
|
|
46
|
+
- `--from` – the range starts after this tag or SHA (GitLab compare) instead of the last tag with `--tag-prefix`.
|
|
47
|
+
- `--tag` – exact tag name (`1.0.21`) instead of `<prefix><timestamp>`. An existing tag is reused. When the release already exists, the run stops before sending anything, so a rerun neither announces the version twice nor overwrites notes edited by hand.
|
|
48
|
+
- `--notes-file` – Markdown used instead of the commit list, in the release as is and in the message converted to Google Chat formatting. The migration warning is still added.
|
|
49
|
+
- `--fallback-note` – put before the commit list when the notes file is missing or empty, so a failed notes job still ends in a release that says what to do.
|
|
50
|
+
- `--no-release` – send the message only, e.g. when deploying an already released version to production.
|
|
51
|
+
|
|
43
52
|
```
|
|
44
53
|
Usage:
|
|
45
54
|
uxf-release [options]
|
|
@@ -57,6 +66,12 @@ Options:
|
|
|
57
66
|
-m, --message Message title [string]
|
|
58
67
|
-p, --project-id GitLab project id (or use CI_PROJECT_ID) [number]
|
|
59
68
|
-s, --slack-channel Slack channel for notification [string]
|
|
69
|
+
--ref Branch, tag or SHA to release from (default: master)
|
|
70
|
+
--from Range start, tag or SHA (default: last prefixed tag)
|
|
71
|
+
--tag Exact tag name (default: prefix + timestamp)
|
|
72
|
+
--notes-file Markdown used instead of the commit list
|
|
73
|
+
--fallback-note Text before the commit list when notes are missing
|
|
74
|
+
--release Create the GitLab release; --no-release only notifies
|
|
60
75
|
-d, --dry-run Skip publishing and notifications [boolean]
|
|
61
76
|
-h, --help Show help [boolean]
|
|
62
77
|
```
|
|
@@ -82,6 +97,19 @@ release:
|
|
|
82
97
|
- uxf-release
|
|
83
98
|
```
|
|
84
99
|
|
|
100
|
+
Release cut on staging under a semver tag, with notes from an earlier job that is allowed to fail:
|
|
101
|
+
|
|
102
|
+
```yaml
|
|
103
|
+
release:staging:
|
|
104
|
+
image: node:24
|
|
105
|
+
stage: deploy
|
|
106
|
+
when: always
|
|
107
|
+
script:
|
|
108
|
+
- npx -y -p @uxf/scripts uxf-release --ref "$CI_COMMIT_SHA" --from "$PREVIOUS_VERSION" --tag "$VERSION"
|
|
109
|
+
--notes-file release-notes.md --fallback-note "Release notes are missing, write them by hand."
|
|
110
|
+
--message "App $VERSION on staging"
|
|
111
|
+
```
|
|
112
|
+
|
|
85
113
|
### uxf-push-notifier
|
|
86
114
|
|
|
87
115
|
Runs in GitLab CI. If the current commit is the merge commit of a merged MR, it posts a Google Chat message with the MR title, author, approver, and who merged it; otherwise it posts the list of pushed commits. Requires `GITLAB_TOKEN` plus the standard GitLab CI variables (`CI_SERVER_URL`, `CI_PROJECT_ID`, `CI_COMMIT_SHA`, `CI_COMMIT_BEFORE_SHA`, `CI_COMMIT_REF_NAME`).
|
|
@@ -120,6 +148,8 @@ All-in-one dependency health check for projects using `@uxf/*` packages. Runs tw
|
|
|
120
148
|
1. **Version conflict detection** — reports dependencies where the project and/or `@uxf/*` packages themselves resolve to different versions. Transitive-only duplicates (a dep pulled in by unrelated third-party packages at a different version) are ignored, since they don't affect `@uxf/*` compatibility.
|
|
121
149
|
2. **Peer dependency check** — verifies that all `peerDependencies` of installed `@uxf/*` packages are present and version-matched. `react`, `react-dom` and `next` are skipped, since a consumer always supplies those itself.
|
|
122
150
|
|
|
151
|
+
The project's other direct dependencies are checked for **missing** required peers too. `@apollo/client` 4 requires `rxjs`, which a project usually has only because an unrelated package such as `concurrently` depends on it, until it stops. Optional peers are skipped, and a version outside a third-party peer range is not reported, since that is the project's call and `--fix` must not downgrade it. A missing peer is suggested and installed at the version already in the project's own `node_modules` when it satisfies the range, so the lock file keeps a single copy.
|
|
152
|
+
|
|
123
153
|
`@uxf/*` peers are checked like any other, and walked into: `@uxf/ui` peers `@uxf/core-react`, which peers `@uxf/core`, so a project listing only `@uxf/ui` is told to add all three. Neither yarn nor npm installs a peer of a peer, so without this the missing packages only show up as a build-time `Cannot find module`. The walk stops wherever a package is absent from `node_modules`, because its own peers cannot be read yet — `--fix` therefore installs what it found and repeats the collection until a pass adds nothing new.
|
|
124
154
|
|
|
125
155
|
A version mismatch on an `@uxf/*` package is reported but never auto-installed. Resolving a mismatch means installing `name@expected`, and for UXF packages that expected value is an exact pin taken from whichever package lags behind — so `--fix` would downgrade a package you bumped on purpose (`@uxf/data-grid@11.129.0` pins `@uxf/core@11.129.0`, and a project on `@uxf/core@11.131.0` would be pulled back). UXF packages move in lockstep, so the check points at `yarn up "@uxf/*"` instead. A _missing_ `@uxf/*` package is still installed by `--fix`, since adding one cannot downgrade anything.
|
package/package.json
CHANGED
package/src/gitlab.js
CHANGED
|
@@ -70,6 +70,22 @@ async function loadCommits(from, ref_name = "master") {
|
|
|
70
70
|
return commits.filter((commit) => commit.created_at !== from);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Commity dosažitelné z `to`, ale ne z `from`, od nejnovějšího (stejně jako `loadCommits`).
|
|
75
|
+
* Na rozdíl od `loadCommits` nestojí na datu, takže sedí i pro větev, na kterou se commity
|
|
76
|
+
* dostaly později, než vznikly (staging, master posunutý ze stagingu).
|
|
77
|
+
*
|
|
78
|
+
* @param {string} from tag nebo SHA
|
|
79
|
+
* @param {string} to tag, větev nebo SHA
|
|
80
|
+
*/
|
|
81
|
+
async function compareCommits(from, to) {
|
|
82
|
+
const { data } = await gitlabRequest(`/projects/${env.CI_PROJECT_ID}/repository/compare`, {
|
|
83
|
+
params: { from, to },
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
return [...data.commits].reverse();
|
|
87
|
+
}
|
|
88
|
+
|
|
73
89
|
async function findMigrationFiles(commits) {
|
|
74
90
|
console.log(`Hledám migrace v ${commits.length} commitech od posledního releasu ...`);
|
|
75
91
|
|
|
@@ -125,9 +141,33 @@ async function getLastTag(tagPrefix = "release-", ref_name = "master") {
|
|
|
125
141
|
return tag;
|
|
126
142
|
}
|
|
127
143
|
|
|
128
|
-
|
|
129
|
-
|
|
144
|
+
function generateTagName(tagPrefix = "release-") {
|
|
145
|
+
return tagPrefix + formatTagTimestamp();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @param {string} tag
|
|
150
|
+
* @returns {Promise<any | null>} release k tagu, nebo null, když neexistuje
|
|
151
|
+
*/
|
|
152
|
+
async function getRelease(tag) {
|
|
153
|
+
try {
|
|
154
|
+
const { data } = await gitlabRequest(`/projects/${env.CI_PROJECT_ID}/releases/${encodeURIComponent(tag)}`);
|
|
155
|
+
return data;
|
|
156
|
+
} catch (error) {
|
|
157
|
+
if (error.status === 404) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
130
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Založí release. Když tag ještě neexistuje, GitLab ho vytvoří na `ref`, jinak release připojí
|
|
166
|
+
* k existujícímu tagu.
|
|
167
|
+
*
|
|
168
|
+
* @param {{description: string, tag: string, ref?: string, dryRun?: boolean}} options
|
|
169
|
+
*/
|
|
170
|
+
async function createReleaseForTag({ description, tag, ref = "master", dryRun = false }) {
|
|
131
171
|
if (dryRun) {
|
|
132
172
|
console.log(`\n🎉🎉🎉 Release "${tag}" published (skipped in dry run)\n\n${description}`);
|
|
133
173
|
return;
|
|
@@ -135,12 +175,16 @@ async function createRelease(description, tagPrefix = "release-", dryRun = false
|
|
|
135
175
|
|
|
136
176
|
await gitlabRequest(`/projects/${env.CI_PROJECT_ID}/releases`, {
|
|
137
177
|
method: "POST",
|
|
138
|
-
body: { description, tag_name: tag, ref
|
|
178
|
+
body: { description, tag_name: tag, ref },
|
|
139
179
|
});
|
|
140
180
|
|
|
141
181
|
console.log(`\n🎉🎉🎉 Release "${tag}" published\n\n${description}`);
|
|
142
182
|
}
|
|
143
183
|
|
|
184
|
+
async function createRelease(description, tagPrefix = "release-", dryRun = false) {
|
|
185
|
+
await createReleaseForTag({ description, tag: generateTagName(tagPrefix), dryRun });
|
|
186
|
+
}
|
|
187
|
+
|
|
144
188
|
function getSingleMergeRequestChanges(projectId, mr_iid) {
|
|
145
189
|
return gitlabRequest(`/projects/${projectId}/merge_requests/${mr_iid}/changes`).then((r) => r.data);
|
|
146
190
|
}
|
|
@@ -167,6 +211,10 @@ function getAllProjects() {
|
|
|
167
211
|
|
|
168
212
|
module.exports = {
|
|
169
213
|
loadCommits,
|
|
214
|
+
compareCommits,
|
|
215
|
+
generateTagName,
|
|
216
|
+
getRelease,
|
|
217
|
+
createReleaseForTag,
|
|
170
218
|
getLastTag,
|
|
171
219
|
createRelease,
|
|
172
220
|
getAllMergeRequests,
|
package/src/gitlab.test.js
CHANGED
|
@@ -185,6 +185,48 @@ describe("createRelease", () => {
|
|
|
185
185
|
});
|
|
186
186
|
});
|
|
187
187
|
|
|
188
|
+
describe("createReleaseForTag", () => {
|
|
189
|
+
it("creates the release on the given tag and ref", async () => {
|
|
190
|
+
const calls = stubFetch([{ body: {} }]);
|
|
191
|
+
|
|
192
|
+
await GitLab.createReleaseForTag({ description: "notes", tag: "1.0.21", ref: "staging" });
|
|
193
|
+
|
|
194
|
+
expect(JSON.parse(calls[0].init.body)).toEqual({ description: "notes", tag_name: "1.0.21", ref: "staging" });
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it("fails like createRelease when GitLab refuses", async () => {
|
|
198
|
+
stubFetch([{ body: { message: "Release already exists" }, status: 409 }]);
|
|
199
|
+
|
|
200
|
+
await expect(GitLab.createReleaseForTag({ description: "notes", tag: "1.0.21" })).rejects.toThrow("409");
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
describe("getRelease", () => {
|
|
205
|
+
it("returns the release of the tag", async () => {
|
|
206
|
+
const calls = stubFetch([{ body: { tag_name: "1.0.21" } }]);
|
|
207
|
+
|
|
208
|
+
await expect(GitLab.getRelease("cz/1.0.21")).resolves.toEqual({ tag_name: "1.0.21" });
|
|
209
|
+
expect(calls[0].url).toContain("/projects/42/releases/cz%2F1.0.21");
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("returns null when the tag has no release", async () => {
|
|
213
|
+
stubFetch([{ body: { message: "404 Not Found" }, status: 404 }]);
|
|
214
|
+
|
|
215
|
+
await expect(GitLab.getRelease("1.0.21")).resolves.toBeNull();
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
describe("compareCommits", () => {
|
|
220
|
+
it("asks for the range and returns the commits newest first", async () => {
|
|
221
|
+
const calls = stubFetch([{ body: { commits: [{ id: "old" }, { id: "new" }] } }]);
|
|
222
|
+
|
|
223
|
+
const commits = await GitLab.compareCommits("1.0.20", "staging");
|
|
224
|
+
|
|
225
|
+
expect(calls[0].url).toContain("/projects/42/repository/compare?from=1.0.20&to=staging");
|
|
226
|
+
expect(commits.map((commit) => commit.id)).toEqual(["new", "old"]);
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
188
230
|
describe("findMigrationFiles", () => {
|
|
189
231
|
it("collects api migration files and ignores everything else", async () => {
|
|
190
232
|
stubFetch([
|
|
@@ -20,6 +20,12 @@ function readProjectPackageJson(cwd) {
|
|
|
20
20
|
}
|
|
21
21
|
/** Upper bound on the install/re-collect cycle in `--fix`; the @uxf peer graph is far shallower. */
|
|
22
22
|
const MAX_FIX_PASSES = 5;
|
|
23
|
+
function collectPendingDeps(uxfPackages, nodeModulesPath, projectPkg) {
|
|
24
|
+
const required = (0, peer_deps_1.collectRequiredPeerDeps)(uxfPackages, nodeModulesPath, projectPkg);
|
|
25
|
+
const pending = (0, peer_deps_1.findMissingOrMismatchedDeps)(required, projectPkg);
|
|
26
|
+
(0, peer_deps_1.mergeMissingDeps)(pending.missing, (0, peer_deps_1.findMissingThirdPartyPeerDeps)(projectPkg, nodeModulesPath));
|
|
27
|
+
return pending;
|
|
28
|
+
}
|
|
23
29
|
/**
|
|
24
30
|
* Installs, re-collects, and repeats.
|
|
25
31
|
*
|
|
@@ -37,8 +43,7 @@ function runFixPasses(initial, ctx) {
|
|
|
37
43
|
console.error("\nCould not re-read package.json after installing."); // eslint-disable-line no-console
|
|
38
44
|
return 1;
|
|
39
45
|
}
|
|
40
|
-
|
|
41
|
-
pending = (0, peer_deps_1.findMissingOrMismatchedDeps)(required, projectPkg);
|
|
46
|
+
pending = collectPendingDeps((0, peer_deps_1.findInstalledUxfPackages)(projectPkg), ctx.nodeModulesPath, projectPkg);
|
|
42
47
|
if (pending.missing.size === 0 && pending.mismatched.size === 0) {
|
|
43
48
|
console.log("\nAll peer dependencies are now installed."); // eslint-disable-line no-console
|
|
44
49
|
return 0;
|
|
@@ -112,8 +117,7 @@ async function checkUxfDependencies(options) {
|
|
|
112
117
|
console.log("Could not parse lock file — skipping conflict check.\n"); // eslint-disable-line no-console
|
|
113
118
|
}
|
|
114
119
|
// --- Peer dependency check ---
|
|
115
|
-
const
|
|
116
|
-
const { missing, mismatched, overridden } = (0, peer_deps_1.findMissingOrMismatchedDeps)(requiredPeerDeps, projectPkg);
|
|
120
|
+
const { missing, mismatched, overridden } = collectPendingDeps(uxfPackages, nodeModulesPath, projectPkg);
|
|
117
121
|
const consumerMismatched = (0, peer_deps_1.findConsumerProvidedMismatches)(uxfPackages, nodeModulesPath, projectPkg);
|
|
118
122
|
(0, peer_deps_1.printConsumerProvidedGuidance)(consumerMismatched, pm);
|
|
119
123
|
if (missing.size === 0 && mismatched.size === 0) {
|
|
@@ -13,6 +13,16 @@ export declare function findMissingOrMismatchedDeps(requiredPeerDeps: Map<string
|
|
|
13
13
|
mismatched: Map<string, MismatchInfo>;
|
|
14
14
|
overridden: Map<string, string>;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Required peers of the project's other direct dependencies that the project does not declare, such as
|
|
18
|
+
* `rxjs` for `@apollo/client` 4, which otherwise resolves only while some unrelated package happens to
|
|
19
|
+
* pull it in. Missing ones only: a version outside a third-party peer range is the project's call.
|
|
20
|
+
*
|
|
21
|
+
* The version is the one already in node_modules when it satisfies the range, so `--fix` adds no second copy.
|
|
22
|
+
*/
|
|
23
|
+
export declare function findMissingThirdPartyPeerDeps(projectPkg: PackageJson, nodeModulesPath: string): Map<string, DepInfo>;
|
|
24
|
+
/** Merges `extra` into `target`; the version already in `target` wins, a prod requirer on either side makes it prod. */
|
|
25
|
+
export declare function mergeMissingDeps(target: Map<string, DepInfo>, extra: Map<string, DepInfo>): void;
|
|
16
26
|
/**
|
|
17
27
|
* `react`, `react-dom` and `next` are left out of the peer collection, so `--fix` never installs them:
|
|
18
28
|
* the project picks those versions. A project whose own spec cannot satisfy what an installed `@uxf/*`
|
|
@@ -7,6 +7,8 @@ exports.findInstalledUxfPackages = findInstalledUxfPackages;
|
|
|
7
7
|
exports.collectRequiredPeerDeps = collectRequiredPeerDeps;
|
|
8
8
|
exports.isOverrideSpec = isOverrideSpec;
|
|
9
9
|
exports.findMissingOrMismatchedDeps = findMissingOrMismatchedDeps;
|
|
10
|
+
exports.findMissingThirdPartyPeerDeps = findMissingThirdPartyPeerDeps;
|
|
11
|
+
exports.mergeMissingDeps = mergeMissingDeps;
|
|
10
12
|
exports.findConsumerProvidedMismatches = findConsumerProvidedMismatches;
|
|
11
13
|
exports.printConsumerProvidedGuidance = printConsumerProvidedGuidance;
|
|
12
14
|
exports.printPeerDepsReport = printPeerDepsReport;
|
|
@@ -126,6 +128,58 @@ function findMissingOrMismatchedDeps(requiredPeerDeps, projectPkg) {
|
|
|
126
128
|
}
|
|
127
129
|
return { missing, mismatched, overridden };
|
|
128
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Required peers of the project's other direct dependencies that the project does not declare, such as
|
|
133
|
+
* `rxjs` for `@apollo/client` 4, which otherwise resolves only while some unrelated package happens to
|
|
134
|
+
* pull it in. Missing ones only: a version outside a third-party peer range is the project's call.
|
|
135
|
+
*
|
|
136
|
+
* The version is the one already in node_modules when it satisfies the range, so `--fix` adds no second copy.
|
|
137
|
+
*/
|
|
138
|
+
function findMissingThirdPartyPeerDeps(projectPkg, nodeModulesPath) {
|
|
139
|
+
var _a, _b, _c, _d, _e;
|
|
140
|
+
const prodDeps = new Set(Object.keys((_a = projectPkg.dependencies) !== null && _a !== void 0 ? _a : {}));
|
|
141
|
+
const allProjectDeps = { ...projectPkg.dependencies, ...projectPkg.devDependencies };
|
|
142
|
+
const missing = new Map();
|
|
143
|
+
for (const requirer of Object.keys(allProjectDeps)) {
|
|
144
|
+
if (requirer.startsWith("@uxf/")) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const pkgJson = (0, package_json_1.readPackageJson)(path_1.default.join(nodeModulesPath, requirer, "package.json"));
|
|
148
|
+
const isRequirerDev = !prodDeps.has(requirer);
|
|
149
|
+
for (const [depName, range] of Object.entries((_b = pkgJson === null || pkgJson === void 0 ? void 0 : pkgJson.peerDependencies) !== null && _b !== void 0 ? _b : {})) {
|
|
150
|
+
if (!range ||
|
|
151
|
+
allProjectDeps[depName] ||
|
|
152
|
+
CONSUMER_PROVIDED.has(depName) ||
|
|
153
|
+
((_d = (_c = pkgJson === null || pkgJson === void 0 ? void 0 : pkgJson.peerDependenciesMeta) === null || _c === void 0 ? void 0 : _c[depName]) === null || _d === void 0 ? void 0 : _d.optional)) {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
const existing = missing.get(depName);
|
|
157
|
+
if (existing) {
|
|
158
|
+
existing.requiredBy.push(requirer);
|
|
159
|
+
if (!isRequirerDev) {
|
|
160
|
+
existing.isDev = false;
|
|
161
|
+
}
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
const installed = (_e = (0, package_json_1.readPackageJson)(path_1.default.join(nodeModulesPath, depName, "package.json"))) === null || _e === void 0 ? void 0 : _e.version;
|
|
165
|
+
const version = installed && (0, semver_1.satisfies)(installed, range, { includePrerelease: true }) ? installed : range;
|
|
166
|
+
missing.set(depName, { version, requiredBy: [requirer], isDev: isRequirerDev });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return missing;
|
|
170
|
+
}
|
|
171
|
+
/** Merges `extra` into `target`; the version already in `target` wins, a prod requirer on either side makes it prod. */
|
|
172
|
+
function mergeMissingDeps(target, extra) {
|
|
173
|
+
for (const [name, info] of extra) {
|
|
174
|
+
const existing = target.get(name);
|
|
175
|
+
if (!existing) {
|
|
176
|
+
target.set(name, info);
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
existing.requiredBy.push(...info.requiredBy.filter((requirer) => !existing.requiredBy.includes(requirer)));
|
|
180
|
+
existing.isDev = existing.isDev && info.isDev;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
129
183
|
/**
|
|
130
184
|
* `react`, `react-dom` and `next` are left out of the peer collection, so `--fix` never installs them:
|
|
131
185
|
* the project picks those versions. A project whose own spec cannot satisfy what an installed `@uxf/*`
|
|
@@ -267,14 +321,18 @@ function splitMismatchesByDevFlag(deps) {
|
|
|
267
321
|
}
|
|
268
322
|
function printSuggestedCommands(missing, mismatched, pm) {
|
|
269
323
|
const { cmd, addArg } = (0, detect_package_manager_1.getInstallCommand)(pm);
|
|
324
|
+
// A third-party peer range such as `>=16.8 <20` would otherwise break the copied command.
|
|
325
|
+
const formatShellArgs = (packages) => formatInstallArgs(packages)
|
|
326
|
+
.map((arg) => `"${arg}"`)
|
|
327
|
+
.join(" ");
|
|
270
328
|
if (missing.size > 0) {
|
|
271
329
|
const { prod, dev } = splitDepsByDevFlag(missing);
|
|
272
330
|
if (prod.size > 0) {
|
|
273
|
-
const pkgs =
|
|
331
|
+
const pkgs = formatShellArgs(prod);
|
|
274
332
|
console.log(`To install missing dependencies, run:\n ${cmd} ${addArg} ${pkgs}\n`); // eslint-disable-line no-console
|
|
275
333
|
}
|
|
276
334
|
if (dev.size > 0) {
|
|
277
|
-
const pkgs =
|
|
335
|
+
const pkgs = formatShellArgs(dev);
|
|
278
336
|
console.log(`To install missing dev dependencies, run:\n ${cmd} ${addArg} -D ${pkgs}\n`); // eslint-disable-line no-console
|
|
279
337
|
}
|
|
280
338
|
}
|
|
@@ -282,11 +340,11 @@ function printSuggestedCommands(missing, mismatched, pm) {
|
|
|
282
340
|
if (fixable.size > 0) {
|
|
283
341
|
const { prod, dev } = splitMismatchesByDevFlag(fixable);
|
|
284
342
|
if (prod.size > 0) {
|
|
285
|
-
const pkgs =
|
|
343
|
+
const pkgs = formatShellArgs(prod);
|
|
286
344
|
console.log(`To fix version mismatches, run:\n ${cmd} ${addArg} ${pkgs}\n`); // eslint-disable-line no-console
|
|
287
345
|
}
|
|
288
346
|
if (dev.size > 0) {
|
|
289
|
-
const pkgs =
|
|
347
|
+
const pkgs = formatShellArgs(dev);
|
|
290
348
|
console.log(`To fix dev version mismatches, run:\n ${cmd} ${addArg} -D ${pkgs}\n`); // eslint-disable-line no-console
|
|
291
349
|
}
|
|
292
350
|
}
|
|
@@ -3,6 +3,9 @@ export interface PackageJson {
|
|
|
3
3
|
dependencies?: Partial<Record<string, string>>;
|
|
4
4
|
devDependencies?: Partial<Record<string, string>>;
|
|
5
5
|
peerDependencies?: Partial<Record<string, string>>;
|
|
6
|
+
peerDependenciesMeta?: Partial<Record<string, {
|
|
7
|
+
optional?: boolean;
|
|
8
|
+
}>>;
|
|
6
9
|
uxf?: {
|
|
7
10
|
ignoredConflicts?: string[];
|
|
8
11
|
};
|
package/src/uxf-release/cli.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { existsSync, readFileSync } = require("fs");
|
|
1
2
|
const { argv, env } = require("process");
|
|
2
3
|
|
|
3
4
|
module.exports = async () => {
|
|
@@ -44,6 +45,37 @@ Environment variables:
|
|
|
44
45
|
type: "string",
|
|
45
46
|
group: "Options",
|
|
46
47
|
})
|
|
48
|
+
.option("ref", {
|
|
49
|
+
describe: "Branch, tag or SHA the release is cut from (default: master)",
|
|
50
|
+
type: "string",
|
|
51
|
+
group: "Options",
|
|
52
|
+
})
|
|
53
|
+
.option("from", {
|
|
54
|
+
describe: "Tag or SHA the commit range starts after (default: the last tag with --tag-prefix)",
|
|
55
|
+
type: "string",
|
|
56
|
+
group: "Options",
|
|
57
|
+
})
|
|
58
|
+
.option("tag", {
|
|
59
|
+
describe: "Exact tag name for the release (default: --tag-prefix + timestamp)",
|
|
60
|
+
type: "string",
|
|
61
|
+
group: "Options",
|
|
62
|
+
})
|
|
63
|
+
.option("notes-file", {
|
|
64
|
+
describe: "Markdown file used instead of the commit list in the release and the message",
|
|
65
|
+
type: "string",
|
|
66
|
+
group: "Options",
|
|
67
|
+
})
|
|
68
|
+
.option("fallback-note", {
|
|
69
|
+
describe: "Text put before the commit list when --notes-file is missing or empty",
|
|
70
|
+
type: "string",
|
|
71
|
+
group: "Options",
|
|
72
|
+
})
|
|
73
|
+
.option("release", {
|
|
74
|
+
describe: "Create the GitLab release (--no-release only sends the message)",
|
|
75
|
+
type: "boolean",
|
|
76
|
+
default: true,
|
|
77
|
+
group: "Options",
|
|
78
|
+
})
|
|
47
79
|
.option("d", {
|
|
48
80
|
alias: "dry-run",
|
|
49
81
|
describe: "Skip publishing and sending slack notification",
|
|
@@ -84,10 +116,22 @@ Environment variables:
|
|
|
84
116
|
return 1;
|
|
85
117
|
}
|
|
86
118
|
|
|
119
|
+
const notesFile = options["notes-file"];
|
|
120
|
+
if (notesFile && !existsSync(notesFile)) {
|
|
121
|
+
console.log(`- notes file "${notesFile}" not found, using the commit list`);
|
|
122
|
+
}
|
|
123
|
+
|
|
87
124
|
await require("./index")({
|
|
88
125
|
dryRun,
|
|
89
126
|
messageTitle,
|
|
90
127
|
tagPrefix,
|
|
128
|
+
ref: options.ref,
|
|
129
|
+
from: options.from,
|
|
130
|
+
tag: options.tag,
|
|
131
|
+
// Chybějící soubor není chyba: notes může generovat krok, který smí selhat.
|
|
132
|
+
notes: notesFile && existsSync(notesFile) ? readFileSync(notesFile, "utf8") : undefined,
|
|
133
|
+
fallbackNote: options["fallback-note"],
|
|
134
|
+
release: options.release,
|
|
91
135
|
channel: slackChannel,
|
|
92
136
|
googleChatWebhook: googleChatWebhook || env.GOOGLE_WEBHOOK_URL,
|
|
93
137
|
});
|
package/src/uxf-release/index.js
CHANGED
|
@@ -13,15 +13,6 @@ function generateSlackCommitMessage(commit) {
|
|
|
13
13
|
: `• ${title} <${web_url}|${short_id}> (${author_email})`;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function generateSlackMessage(commits, messageTitle) {
|
|
17
|
-
return {
|
|
18
|
-
text: `${messageTitle}
|
|
19
|
-
|
|
20
|
-
${commits.map(generateSlackCommitMessage).join("\n")}
|
|
21
|
-
`,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
16
|
function generateGoogleCommitMessage(commit) {
|
|
26
17
|
const { title, short_id, web_url, author_email } = commit;
|
|
27
18
|
const parsedCommit = parseCommitMessage(title);
|
|
@@ -47,15 +38,6 @@ function generateGoogleCommitMessage(commit) {
|
|
|
47
38
|
return `* ${title} ${suffix}`;
|
|
48
39
|
}
|
|
49
40
|
|
|
50
|
-
function generateGoogleMessage(commits, messageTitle) {
|
|
51
|
-
return {
|
|
52
|
-
text: `${messageTitle}
|
|
53
|
-
|
|
54
|
-
${commits.map(generateGoogleCommitMessage).join("\n")}
|
|
55
|
-
`,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
41
|
function generateReleaseCommitMessage(commit) {
|
|
60
42
|
const { title, short_id, web_url, author_email } = commit;
|
|
61
43
|
|
|
@@ -90,41 +72,116 @@ function generateMigrationWarning(migrationFiles = []) {
|
|
|
90
72
|
}
|
|
91
73
|
|
|
92
74
|
/**
|
|
93
|
-
*
|
|
75
|
+
* Markdown z `--notes-file` do textu Google Chatu, který markdown nečte: nadpisy a `**tučně**`
|
|
76
|
+
* na `*tučně*`, odkazy na `<url|text>`, odrážky na `•`.
|
|
77
|
+
*
|
|
78
|
+
* @param {string} markdown
|
|
94
79
|
*/
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
80
|
+
function markdownToGoogleChat(markdown) {
|
|
81
|
+
return markdown
|
|
82
|
+
.split("\n")
|
|
83
|
+
.map((line) => {
|
|
84
|
+
const heading = /^#{1,6}\s+(.*)$/.exec(line);
|
|
85
|
+
const text = heading ? `*${heading[1].replace(/\*\*/g, "")}*` : line.replace(/^(\s*)[-*]\s+/, "$1• ");
|
|
86
|
+
|
|
87
|
+
return text.replace(/\*\*(.+?)\*\*/g, "*$1*").replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, "<$2|$1>");
|
|
88
|
+
})
|
|
89
|
+
.join("\n");
|
|
90
|
+
}
|
|
101
91
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Text pro release a pro Chat. Notes z `--notes-file` mají přednost před seznamem commitů;
|
|
94
|
+
* když chybí, dostane seznam commitů před sebe `fallbackNote` (např. „notes doplňte ručně“).
|
|
95
|
+
*
|
|
96
|
+
* @param {{commits: any[], notes?: string, fallbackNote?: string}} input
|
|
97
|
+
* @returns {{release: string, googleChat: string, slack: string}}
|
|
98
|
+
*/
|
|
99
|
+
function generateBody({ commits, notes, fallbackNote }) {
|
|
100
|
+
if (notes) {
|
|
101
|
+
const chatNotes = markdownToGoogleChat(notes);
|
|
102
|
+
return { release: notes, googleChat: chatNotes, slack: chatNotes };
|
|
106
103
|
}
|
|
107
104
|
|
|
108
|
-
|
|
105
|
+
const prefix = fallbackNote ? `${fallbackNote}\n\n` : "";
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
release: prefix + commits.map(generateReleaseCommitMessage).join("\n"),
|
|
109
|
+
googleChat: prefix + commits.map(generateGoogleCommitMessage).join("\n"),
|
|
110
|
+
slack: prefix + commits.map(generateSlackCommitMessage).join("\n"),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Výchozí běh (bez `from`, `tag`, `notes`) se chová jako dřív: commity na `master` od posledního
|
|
116
|
+
* tagu s prefixem, release s tagem `<prefix><čas>`, seznam commitů v release i ve zprávě.
|
|
117
|
+
*
|
|
118
|
+
* @param config {{
|
|
119
|
+
* dryRun?: boolean,
|
|
120
|
+
* channel?: string,
|
|
121
|
+
* messageTitle?: string,
|
|
122
|
+
* googleChatWebhook?: string,
|
|
123
|
+
* tagPrefix?: string,
|
|
124
|
+
* ref?: string,
|
|
125
|
+
* from?: string,
|
|
126
|
+
* tag?: string,
|
|
127
|
+
* notes?: string,
|
|
128
|
+
* fallbackNote?: string,
|
|
129
|
+
* release?: boolean,
|
|
130
|
+
* }}
|
|
131
|
+
*/
|
|
132
|
+
module.exports = async function (config) {
|
|
133
|
+
const ref = config.ref || "master";
|
|
109
134
|
|
|
110
|
-
//
|
|
111
|
-
|
|
112
|
-
if (
|
|
113
|
-
|
|
135
|
+
// Opakovaný job s pojmenovaným tagem nesmí verzi ohlásit podruhé ani přepsat release,
|
|
136
|
+
// který mezitím někdo ručně doplnil.
|
|
137
|
+
if (config.tag && config.release !== false && (await GitLab.getRelease(config.tag))) {
|
|
138
|
+
console.log(`- release "${config.tag}" already exists, nothing to do`);
|
|
139
|
+
return;
|
|
114
140
|
}
|
|
115
141
|
|
|
116
|
-
|
|
142
|
+
let commits;
|
|
143
|
+
if (config.from) {
|
|
144
|
+
commits = await GitLab.compareCommits(config.from, ref);
|
|
145
|
+
} else {
|
|
146
|
+
const lastTag = await GitLab.getLastTag(config.tagPrefix, ref);
|
|
147
|
+
commits = await GitLab.loadCommits(lastTag ? lastTag.commit.committed_date : null, ref);
|
|
148
|
+
}
|
|
149
|
+
const migrationFiles = await GitLab.findMigrationFiles(commits);
|
|
117
150
|
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
|
|
151
|
+
const migrationWarning = generateMigrationWarning(migrationFiles);
|
|
152
|
+
const body = generateBody({
|
|
153
|
+
commits,
|
|
154
|
+
notes: config.notes?.replace(/\r\n/g, "\n").trim(),
|
|
155
|
+
fallbackNote: config.fallbackNote,
|
|
156
|
+
});
|
|
157
|
+
const withWarning = (text) => (migrationWarning ? `${text}\n\n${migrationWarning}` : text);
|
|
158
|
+
|
|
159
|
+
await Slack.chatPostMessage(
|
|
160
|
+
config.channel,
|
|
161
|
+
{ text: withWarning(`${config.messageTitle}\n\n${body.slack}\n`) },
|
|
162
|
+
config.dryRun,
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
await GoogleChat.chatPostMessage(
|
|
166
|
+
{ text: withWarning(`${config.messageTitle}\n\n${body.googleChat}\n`) },
|
|
167
|
+
{ dryRun: config.dryRun, webhookUrl: config.googleChatWebhook },
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
if (config.release === false) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
121
173
|
|
|
122
|
-
await GitLab.
|
|
174
|
+
await GitLab.createReleaseForTag({
|
|
175
|
+
description: migrationWarning + body.release,
|
|
176
|
+
tag: config.tag || GitLab.generateTagName(config.tagPrefix),
|
|
177
|
+
ref,
|
|
178
|
+
dryRun: config.dryRun,
|
|
179
|
+
});
|
|
123
180
|
};
|
|
124
181
|
|
|
125
182
|
module.exports.generateSlackCommitMessage = generateSlackCommitMessage;
|
|
126
|
-
module.exports.generateSlackMessage = generateSlackMessage;
|
|
127
183
|
module.exports.generateGoogleCommitMessage = generateGoogleCommitMessage;
|
|
128
|
-
module.exports.generateGoogleMessage = generateGoogleMessage;
|
|
129
184
|
module.exports.generateReleaseCommitMessage = generateReleaseCommitMessage;
|
|
130
185
|
module.exports.generateMigrationWarning = generateMigrationWarning;
|
|
186
|
+
module.exports.markdownToGoogleChat = markdownToGoogleChat;
|
|
187
|
+
module.exports.generateBody = generateBody;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const {
|
|
2
2
|
generateSlackCommitMessage,
|
|
3
|
-
generateSlackMessage,
|
|
4
3
|
generateGoogleCommitMessage,
|
|
5
|
-
generateGoogleMessage,
|
|
6
4
|
generateReleaseCommitMessage,
|
|
7
5
|
generateMigrationWarning,
|
|
6
|
+
markdownToGoogleChat,
|
|
7
|
+
generateBody,
|
|
8
8
|
} = require("./index");
|
|
9
9
|
|
|
10
10
|
const baseCommit = {
|
|
@@ -91,20 +91,34 @@ describe("generateReleaseCommitMessage", () => {
|
|
|
91
91
|
});
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
-
describe("
|
|
95
|
-
it("
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
expect(
|
|
94
|
+
describe("markdownToGoogleChat", () => {
|
|
95
|
+
it("turns headings, bold, links and bullets into Google Chat formatting", () => {
|
|
96
|
+
const markdown =
|
|
97
|
+
"### Novinky\n\n- **Strom** má žluté složky ([ATK-417](https://youtrack.uxf.dev/issue/ATK-417))\n - vnořená";
|
|
98
|
+
|
|
99
|
+
expect(markdownToGoogleChat(markdown)).toBe(
|
|
100
|
+
"*Novinky*\n\n• *Strom* má žluté složky (<https://youtrack.uxf.dev/issue/ATK-417|ATK-417>)\n • vnořená",
|
|
101
|
+
);
|
|
100
102
|
});
|
|
101
103
|
});
|
|
102
104
|
|
|
103
|
-
describe("
|
|
104
|
-
it("
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
expect(
|
|
108
|
-
expect(
|
|
105
|
+
describe("generateBody", () => {
|
|
106
|
+
it("uses the notes instead of the commit list", () => {
|
|
107
|
+
const body = generateBody({ commits: [baseCommit], notes: "- **Nové**", fallbackNote: "doplnit" });
|
|
108
|
+
|
|
109
|
+
expect(body.release).toBe("- **Nové**");
|
|
110
|
+
expect(body.googleChat).toBe("• *Nové*");
|
|
111
|
+
expect(body.release).not.toContain("fix the bug");
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("puts the fallback note before the commit list when there are no notes", () => {
|
|
115
|
+
const body = generateBody({ commits: [baseCommit], fallbackNote: "Notes chybí, doplňte je ručně." });
|
|
116
|
+
|
|
117
|
+
expect(body.release).toMatch(/^Notes chybí, doplňte je ručně\.\n\n- \*\*FIX\*\* fix the bug/);
|
|
118
|
+
expect(body.googleChat).toMatch(/^Notes chybí, doplňte je ručně\.\n\n\* _FIX_ fix the bug/);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("lists the commits alone by default", () => {
|
|
122
|
+
expect(generateBody({ commits: [baseCommit] }).release).toMatch(/^- \*\*FIX\*\* fix the bug/);
|
|
109
123
|
});
|
|
110
124
|
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
jest.mock("../gitlab");
|
|
2
|
+
jest.mock("../slack");
|
|
3
|
+
jest.mock("../google-chat");
|
|
4
|
+
|
|
5
|
+
const GitLab = require("../gitlab");
|
|
6
|
+
const GoogleChat = require("../google-chat");
|
|
7
|
+
const release = require("./index");
|
|
8
|
+
|
|
9
|
+
const commit = {
|
|
10
|
+
title: "[ATK-417] Color the folder icons yellow",
|
|
11
|
+
short_id: "7f26862",
|
|
12
|
+
web_url: "https://git.test/commit/7f26862",
|
|
13
|
+
author_email: "dev@example.com",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
jest.resetAllMocks();
|
|
18
|
+
GitLab.findMigrationFiles.mockResolvedValue([]);
|
|
19
|
+
GitLab.generateTagName.mockReturnValue("release-2026-10-20-12-00");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe("uxf-release", () => {
|
|
23
|
+
it("keeps the default flow: commits on master since the last prefixed tag", async () => {
|
|
24
|
+
// Výchozí běh se na existující release neptá, tag s časem je pokaždé nový.
|
|
25
|
+
GitLab.getLastTag.mockResolvedValue({ commit: { committed_date: "2026-10-01T00:00:00Z" } });
|
|
26
|
+
GitLab.loadCommits.mockResolvedValue([commit]);
|
|
27
|
+
|
|
28
|
+
await release({ messageTitle: "Nasazeno" });
|
|
29
|
+
|
|
30
|
+
expect(GitLab.getLastTag).toHaveBeenCalledWith(undefined, "master");
|
|
31
|
+
expect(GitLab.loadCommits).toHaveBeenCalledWith("2026-10-01T00:00:00Z", "master");
|
|
32
|
+
expect(GitLab.compareCommits).not.toHaveBeenCalled();
|
|
33
|
+
expect(GitLab.getRelease).not.toHaveBeenCalled();
|
|
34
|
+
expect(GitLab.createReleaseForTag).toHaveBeenCalledWith({
|
|
35
|
+
description: expect.stringContaining("Color the folder icons yellow"),
|
|
36
|
+
tag: "release-2026-10-20-12-00",
|
|
37
|
+
ref: "master",
|
|
38
|
+
dryRun: undefined,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("cuts a named release from an explicit range with the given notes", async () => {
|
|
43
|
+
GitLab.compareCommits.mockResolvedValue([commit]);
|
|
44
|
+
GitLab.findMigrationFiles.mockResolvedValue(["api/migrations/Version1.php"]);
|
|
45
|
+
|
|
46
|
+
await release({
|
|
47
|
+
messageTitle: "ACU 1.0.21",
|
|
48
|
+
ref: "staging",
|
|
49
|
+
from: "1.0.20",
|
|
50
|
+
tag: "1.0.21",
|
|
51
|
+
notes: "- Žluté složky\n",
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
expect(GitLab.compareCommits).toHaveBeenCalledWith("1.0.20", "staging");
|
|
55
|
+
expect(GitLab.getLastTag).not.toHaveBeenCalled();
|
|
56
|
+
const { description, tag, ref } = GitLab.createReleaseForTag.mock.calls[0][0];
|
|
57
|
+
expect([tag, ref]).toEqual(["1.0.21", "staging"]);
|
|
58
|
+
expect(description).toContain("api/migrations/Version1.php");
|
|
59
|
+
expect(description).toContain("- Žluté složky");
|
|
60
|
+
expect(description).not.toContain("7f26862");
|
|
61
|
+
expect(GoogleChat.chatPostMessage.mock.calls[0][0].text).toMatch(/^ACU 1\.0\.21\n\n• Žluté složky/);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("does nothing when the named release already exists", async () => {
|
|
65
|
+
GitLab.getRelease.mockResolvedValue({ tag_name: "1.0.21" });
|
|
66
|
+
|
|
67
|
+
await release({ messageTitle: "ACU 1.0.21", ref: "staging", from: "1.0.20", tag: "1.0.21" });
|
|
68
|
+
|
|
69
|
+
expect(GitLab.compareCommits).not.toHaveBeenCalled();
|
|
70
|
+
expect(GoogleChat.chatPostMessage).not.toHaveBeenCalled();
|
|
71
|
+
expect(GitLab.createReleaseForTag).not.toHaveBeenCalled();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("reads CRLF notes like LF ones", async () => {
|
|
75
|
+
GitLab.compareCommits.mockResolvedValue([commit]);
|
|
76
|
+
|
|
77
|
+
await release({
|
|
78
|
+
messageTitle: "ACU",
|
|
79
|
+
from: "1.0.20",
|
|
80
|
+
tag: "1.0.21",
|
|
81
|
+
notes: "### Novinky\r\n\r\n- Žluté složky\r\n",
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
expect(GitLab.createReleaseForTag.mock.calls[0][0].description).toBe("### Novinky\n\n- Žluté složky");
|
|
85
|
+
expect(GoogleChat.chatPostMessage.mock.calls[0][0].text).toBe("ACU\n\n*Novinky*\n\n• Žluté složky\n");
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("only sends the message with --no-release", async () => {
|
|
89
|
+
GitLab.compareCommits.mockResolvedValue([commit]);
|
|
90
|
+
|
|
91
|
+
await release({ messageTitle: "ACU 1.0.21 na produkci", from: "abc", release: false, notes: "- Žluté složky" });
|
|
92
|
+
|
|
93
|
+
expect(GoogleChat.chatPostMessage).toHaveBeenCalled();
|
|
94
|
+
expect(GitLab.createReleaseForTag).not.toHaveBeenCalled();
|
|
95
|
+
});
|
|
96
|
+
});
|