@edifice.io/cli 1.6.0-develop.9 → 1.6.1-develop-pedago.1731942440734
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/package.json +1 -1
- package/src/publish/index.js +74 -51
package/package.json
CHANGED
package/src/publish/index.js
CHANGED
|
@@ -41,10 +41,10 @@ export const publish = async (options) => {
|
|
|
41
41
|
const filteredTags = allTags
|
|
42
42
|
// Ensure tag is valid
|
|
43
43
|
.filter((t) => semver.valid(t))
|
|
44
|
-
//
|
|
44
|
+
// Only include non-prerelease tags from main branch
|
|
45
45
|
.filter((t) => {
|
|
46
|
-
|
|
47
|
-
return
|
|
46
|
+
// Exclude any prerelease tags
|
|
47
|
+
return semver.prerelease(t) === null;
|
|
48
48
|
})
|
|
49
49
|
// sort by latest
|
|
50
50
|
// @ts-ignore
|
|
@@ -52,6 +52,7 @@ export const publish = async (options) => {
|
|
|
52
52
|
|
|
53
53
|
// Get the latest tag
|
|
54
54
|
let latestTag = filteredTags.at(-1);
|
|
55
|
+
|
|
55
56
|
let rangeFrom = latestTag;
|
|
56
57
|
|
|
57
58
|
// If RELEASE_ALL is set via a commit subject or body, all packages will be
|
|
@@ -97,7 +98,6 @@ export const publish = async (options) => {
|
|
|
97
98
|
const rawCommitsLog = (
|
|
98
99
|
await simpleGit().log({ from: rangeFrom, to: "HEAD" })
|
|
99
100
|
).all.filter((c) => {
|
|
100
|
-
console.log(c.message);
|
|
101
101
|
const exclude = [
|
|
102
102
|
c.message.startsWith("Merge branch "), // No merge commits
|
|
103
103
|
c.message.includes("version & publish"), // No version bump commits
|
|
@@ -162,13 +162,6 @@ export const publish = async (options) => {
|
|
|
162
162
|
-1,
|
|
163
163
|
);
|
|
164
164
|
|
|
165
|
-
// If there is a breaking change and no manual tag is set, do not release
|
|
166
|
-
/* if (recommendedReleaseLevel === 2 && !tag) {
|
|
167
|
-
throw new Error(
|
|
168
|
-
'Major versions releases must be tagged and released manually.'
|
|
169
|
-
);
|
|
170
|
-
} */
|
|
171
|
-
|
|
172
165
|
// If no release is semantically necessary and no manual tag is set, do not release
|
|
173
166
|
if (recommendedReleaseLevel === -1 && !tag) {
|
|
174
167
|
console.info(
|
|
@@ -194,7 +187,9 @@ export const publish = async (options) => {
|
|
|
194
187
|
|
|
195
188
|
const version = tag
|
|
196
189
|
? semver.parse(tag)?.version
|
|
197
|
-
:
|
|
190
|
+
: branchConfig.prerelease
|
|
191
|
+
? `${semver.inc(latestTag, releaseType, npmTag, false)}.${Date.now()}`
|
|
192
|
+
: semver.inc(latestTag, releaseType, npmTag);
|
|
198
193
|
|
|
199
194
|
if (!version) {
|
|
200
195
|
throw new Error(
|
|
@@ -227,6 +222,8 @@ export const publish = async (options) => {
|
|
|
227
222
|
const changed = changedFiles.some(
|
|
228
223
|
(file) =>
|
|
229
224
|
file.startsWith(path.join(pkg.packageDir, "src")) ||
|
|
225
|
+
// check if any files in the assets directory were modified
|
|
226
|
+
file.startsWith(path.join(pkg.packageDir, "assets")) ||
|
|
230
227
|
file.startsWith(path.join(pkg.packageDir, "package.json")),
|
|
231
228
|
);
|
|
232
229
|
return changed;
|
|
@@ -263,6 +260,10 @@ export const publish = async (options) => {
|
|
|
263
260
|
const changelogCommitsMd = await Promise.all(
|
|
264
261
|
Object.entries(
|
|
265
262
|
commitsSinceLatestTag.reduce((prev, curr) => {
|
|
263
|
+
// Only include fix, feat, and chore commits
|
|
264
|
+
if (!["docs", "fix", "feat", "chore"].includes(curr.type)) {
|
|
265
|
+
return prev;
|
|
266
|
+
}
|
|
266
267
|
return {
|
|
267
268
|
...prev,
|
|
268
269
|
[curr.type]: [...(prev[curr.type] ?? []), curr],
|
|
@@ -270,20 +271,7 @@ export const publish = async (options) => {
|
|
|
270
271
|
}, /** @type {Record<string, import('./index').Commit[]>} */ ({})),
|
|
271
272
|
)
|
|
272
273
|
.sort(
|
|
273
|
-
getSorterFn(([type]) =>
|
|
274
|
-
[
|
|
275
|
-
"other",
|
|
276
|
-
"examples",
|
|
277
|
-
"docs",
|
|
278
|
-
"ci",
|
|
279
|
-
"test",
|
|
280
|
-
"chore",
|
|
281
|
-
"refactor",
|
|
282
|
-
"perf",
|
|
283
|
-
"fix",
|
|
284
|
-
"feat",
|
|
285
|
-
].indexOf(type),
|
|
286
|
-
),
|
|
274
|
+
getSorterFn(([type]) => ["docs", "chore", "fix", "feat"].indexOf(type)),
|
|
287
275
|
)
|
|
288
276
|
.reverse()
|
|
289
277
|
.map(async ([type, commits]) => {
|
|
@@ -327,7 +315,15 @@ export const publish = async (options) => {
|
|
|
327
315
|
).then((groups) => {
|
|
328
316
|
return groups
|
|
329
317
|
.map(([type, commits]) => {
|
|
330
|
-
|
|
318
|
+
const typeTitle =
|
|
319
|
+
{
|
|
320
|
+
fix: "Bug fixes",
|
|
321
|
+
feat: "Features",
|
|
322
|
+
chore: "Chores",
|
|
323
|
+
docs: "Documentation",
|
|
324
|
+
}[type] || capitalize(type);
|
|
325
|
+
|
|
326
|
+
return [`### ${typeTitle}`, commits.join("\n")].join("\n\n");
|
|
331
327
|
})
|
|
332
328
|
.join("\n\n");
|
|
333
329
|
});
|
|
@@ -392,33 +388,60 @@ export const publish = async (options) => {
|
|
|
392
388
|
|
|
393
389
|
console.info();
|
|
394
390
|
console.info("Committing changes...");
|
|
395
|
-
//execSync(`git add -A && git commit -m "${releaseCommitMsg(version)}"`);
|
|
396
|
-
execSync(
|
|
397
|
-
`git add -A && git reset -- ${changedPackages
|
|
398
|
-
.map((pkg) => path.resolve(rootDir, pkg.packageDir, "package.json"))
|
|
399
|
-
.join(" ")}`,
|
|
400
|
-
);
|
|
401
|
-
execSync(
|
|
402
|
-
`git checkout -- ${changedPackages
|
|
403
|
-
.map((pkg) => path.resolve(rootDir, pkg.packageDir, "package.json"))
|
|
404
|
-
.join(" ")}`,
|
|
405
|
-
);
|
|
406
|
-
execSync(`git commit -m "${releaseCommitMsg(version)}" --allow-empty`);
|
|
407
|
-
console.info(" Committed Changes.");
|
|
408
391
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
392
|
+
/**
|
|
393
|
+
* We only commit changes on the main branch to avoid creating a new release
|
|
394
|
+
* for every commit on a prerelease branch.
|
|
395
|
+
*/
|
|
396
|
+
if (isMainBranch) {
|
|
397
|
+
/**
|
|
398
|
+
* Add all changed files and commit the changes with a release commit message.
|
|
399
|
+
*/
|
|
400
|
+
execSync(`git add -A && git commit -m "${releaseCommitMsg(version)}"`);
|
|
401
|
+
console.info(" Committed Changes.");
|
|
413
402
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
403
|
+
console.info();
|
|
404
|
+
console.info("Pushing changes...");
|
|
405
|
+
/**
|
|
406
|
+
* Push the changes to the main branch.
|
|
407
|
+
*/
|
|
408
|
+
execSync(`git push origin ${currentGitBranch()}`);
|
|
409
|
+
console.info(" Changes pushed.");
|
|
417
410
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
411
|
+
console.info();
|
|
412
|
+
console.info(`Creating new git tag v${version}`);
|
|
413
|
+
/**
|
|
414
|
+
* Create a new git tag for the release.
|
|
415
|
+
*/
|
|
416
|
+
execSync(`git tag -a -m "v${version}" v${version}`);
|
|
417
|
+
|
|
418
|
+
console.info();
|
|
419
|
+
console.info("Pushing tags...");
|
|
420
|
+
/**
|
|
421
|
+
* Push the tags to the main branch.
|
|
422
|
+
*/
|
|
423
|
+
execSync("git push --tags");
|
|
424
|
+
console.info(" Tags pushed.");
|
|
425
|
+
} else {
|
|
426
|
+
/**
|
|
427
|
+
* Reset the changes to the package.json files so that we don't commit them
|
|
428
|
+
* in the prerelease branch.
|
|
429
|
+
*/
|
|
430
|
+
execSync(
|
|
431
|
+
`git reset -- ${changedPackages
|
|
432
|
+
.map((pkg) => path.resolve(rootDir, pkg.packageDir, "package.json"))
|
|
433
|
+
.join(" ")}`,
|
|
434
|
+
);
|
|
435
|
+
/**
|
|
436
|
+
* Checkout the package.json files so that we don't commit them in the
|
|
437
|
+
* prerelease branch.
|
|
438
|
+
*/
|
|
439
|
+
execSync(
|
|
440
|
+
`git checkout -- ${changedPackages
|
|
441
|
+
.map((pkg) => path.resolve(rootDir, pkg.packageDir, "package.json"))
|
|
442
|
+
.join(" ")}`,
|
|
443
|
+
);
|
|
444
|
+
}
|
|
422
445
|
|
|
423
446
|
if (ghToken && isMainBranch) {
|
|
424
447
|
console.info();
|