@edifice.io/cli 1.6.0-develop-docker.0 → 1.6.0-develop-b2school.10
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 +52 -46
package/package.json
CHANGED
package/src/publish/index.js
CHANGED
|
@@ -23,8 +23,6 @@ import {
|
|
|
23
23
|
export const publish = async (options) => {
|
|
24
24
|
const { branchConfigs, packages, rootDir, branch, tag, ghToken } = options;
|
|
25
25
|
|
|
26
|
-
console.log({ branchConfigs, packages, rootDir, branch, tag, ghToken });
|
|
27
|
-
|
|
28
26
|
const branchName = /** @type {string} */ (branch ?? currentGitBranch());
|
|
29
27
|
const isMainBranch = branchName === "main";
|
|
30
28
|
const npmTag = isMainBranch ? "latest" : branchName;
|
|
@@ -40,23 +38,16 @@ export const publish = async (options) => {
|
|
|
40
38
|
/** @type {string[]} */
|
|
41
39
|
const allTags = execSync("git tag").toString().split("\n");
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
// TODO: Keep this code for now, but it's not used
|
|
42
|
+
const filteredTags = allTags
|
|
43
|
+
// Ensure tag is valid
|
|
44
|
+
.filter((t) => semver.valid(t))
|
|
46
45
|
// Filter tags based on whether the branch is a release or pre-release
|
|
47
46
|
.filter((t) => {
|
|
48
47
|
const isPrereleaseTag = semver.prerelease(t) !== null;
|
|
49
48
|
const prereleaseBranch = semver.prerelease(t)?.[0];
|
|
50
49
|
// For prerelease branches, only include tags for that branch
|
|
51
50
|
if (branchConfig.prerelease) {
|
|
52
|
-
// If no tags exist for this prerelease branch, use main branch tags
|
|
53
|
-
const branchTags = semverTags.filter((t) => {
|
|
54
|
-
const tagPrerelease = semver.prerelease(t)?.[0];
|
|
55
|
-
return tagPrerelease === branchName;
|
|
56
|
-
});
|
|
57
|
-
if (branchTags.length === 0) {
|
|
58
|
-
return !isPrereleaseTag; // Use main branch tags
|
|
59
|
-
}
|
|
60
51
|
return isPrereleaseTag && prereleaseBranch === branchName;
|
|
61
52
|
}
|
|
62
53
|
// For main branch, exclude all prereleases
|
|
@@ -66,8 +57,32 @@ export const publish = async (options) => {
|
|
|
66
57
|
// @ts-ignore
|
|
67
58
|
.sort(semver.compare);
|
|
68
59
|
|
|
60
|
+
/* const filteredTags = allTags
|
|
61
|
+
// Ensure tag is valid
|
|
62
|
+
.filter((t) => semver.valid(t))
|
|
63
|
+
// Filter tags based on whether the branch is a release or pre-release
|
|
64
|
+
.filter((t) => {
|
|
65
|
+
const isPrereleaseTag = semver.prerelease(t) !== null;
|
|
66
|
+
return branchConfig.prerelease ? isPrereleaseTag : !isPrereleaseTag;
|
|
67
|
+
})
|
|
68
|
+
// sort by latest
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
.sort(semver.compare); */
|
|
71
|
+
|
|
69
72
|
// Get the latest tag
|
|
70
73
|
let latestTag = filteredTags.at(-1);
|
|
74
|
+
|
|
75
|
+
// TODO: Keep this code for now, but it's not used
|
|
76
|
+
/* if (branchConfig.prerelease) {
|
|
77
|
+
const mainTags = execSync("git tag --merged main").toString().split("\n");
|
|
78
|
+
const validMainTags = mainTags
|
|
79
|
+
.filter((t) => semver.valid(t))
|
|
80
|
+
.sort((a, b) => semver.compare(a, b));
|
|
81
|
+
|
|
82
|
+
latestTag = validMainTags.at(-1) || latestTag; // Use the latest tag from main if available
|
|
83
|
+
} */
|
|
84
|
+
|
|
85
|
+
// console.log({ filteredTags: filteredTags.reverse() });
|
|
71
86
|
let rangeFrom = latestTag;
|
|
72
87
|
|
|
73
88
|
// If RELEASE_ALL is set via a commit subject or body, all packages will be
|
|
@@ -122,10 +137,10 @@ export const publish = async (options) => {
|
|
|
122
137
|
return !exclude;
|
|
123
138
|
});
|
|
124
139
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
140
|
+
/**
|
|
141
|
+
* Get the commits since the latest tag
|
|
142
|
+
* @type {import('./index.js').Commit[]}
|
|
143
|
+
*/
|
|
129
144
|
const commitsSinceLatestTag = await Promise.all(
|
|
130
145
|
rawCommitsLog.map(async (c) => {
|
|
131
146
|
const parsed = await parseCommit(c.message);
|
|
@@ -177,13 +192,6 @@ export const publish = async (options) => {
|
|
|
177
192
|
-1,
|
|
178
193
|
);
|
|
179
194
|
|
|
180
|
-
// If there is a breaking change and no manual tag is set, do not release
|
|
181
|
-
/* if (recommendedReleaseLevel === 2 && !tag) {
|
|
182
|
-
throw new Error(
|
|
183
|
-
'Major versions releases must be tagged and released manually.'
|
|
184
|
-
);
|
|
185
|
-
} */
|
|
186
|
-
|
|
187
195
|
// If no release is semantically necessary and no manual tag is set, do not release
|
|
188
196
|
if (recommendedReleaseLevel === -1 && !tag) {
|
|
189
197
|
console.info(
|
|
@@ -197,17 +205,11 @@ export const publish = async (options) => {
|
|
|
197
205
|
recommendedReleaseLevel = 0;
|
|
198
206
|
}
|
|
199
207
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const releaseType = /** @type {const} */ ({
|
|
207
|
-
0: "patch",
|
|
208
|
-
1: "minor",
|
|
209
|
-
2: "major",
|
|
210
|
-
})[recommendedReleaseLevel];
|
|
208
|
+
const releaseType = branchConfig.prerelease
|
|
209
|
+
? "prerelease"
|
|
210
|
+
: /** @type {const} */ ({ 0: "patch", 1: "minor", 2: "major" })[
|
|
211
|
+
recommendedReleaseLevel
|
|
212
|
+
];
|
|
211
213
|
|
|
212
214
|
if (!releaseType) {
|
|
213
215
|
throw new Error(`Invalid release level: ${recommendedReleaseLevel}`);
|
|
@@ -215,11 +217,7 @@ export const publish = async (options) => {
|
|
|
215
217
|
|
|
216
218
|
const version = tag
|
|
217
219
|
? semver.parse(tag)?.version
|
|
218
|
-
: semver.inc(
|
|
219
|
-
latestTag,
|
|
220
|
-
branchConfig.prerelease ? `pre${releaseType}` : releaseType,
|
|
221
|
-
npmTag,
|
|
222
|
-
);
|
|
220
|
+
: semver.inc(latestTag, releaseType, npmTag);
|
|
223
221
|
|
|
224
222
|
if (!version) {
|
|
225
223
|
throw new Error(
|
|
@@ -418,25 +416,33 @@ export const publish = async (options) => {
|
|
|
418
416
|
}
|
|
419
417
|
|
|
420
418
|
console.info();
|
|
421
|
-
console.info("
|
|
422
|
-
execSync(
|
|
419
|
+
console.info("Resetting changes...");
|
|
420
|
+
/* execSync(
|
|
423
421
|
`git add -A && git reset -- ${changedPackages
|
|
424
422
|
.map((pkg) => path.resolve(rootDir, pkg.packageDir, "package.json"))
|
|
425
423
|
.join(" ")}`,
|
|
424
|
+
); */
|
|
425
|
+
execSync(
|
|
426
|
+
`git reset -- ${changedPackages
|
|
427
|
+
.map((pkg) => path.resolve(rootDir, pkg.packageDir, "package.json"))
|
|
428
|
+
.join(" ")}`,
|
|
426
429
|
);
|
|
427
430
|
execSync(
|
|
428
431
|
`git checkout -- ${changedPackages
|
|
429
432
|
.map((pkg) => path.resolve(rootDir, pkg.packageDir, "package.json"))
|
|
430
433
|
.join(" ")}`,
|
|
431
434
|
);
|
|
432
|
-
execSync(`git commit -m "${releaseCommitMsg(version)}" --allow-empty -n`);
|
|
433
|
-
console.info("
|
|
435
|
+
// execSync(`git commit -m "${releaseCommitMsg(version)}" --allow-empty -n`);
|
|
436
|
+
console.info(" Reset changes.");
|
|
434
437
|
|
|
435
|
-
console.info();
|
|
438
|
+
/* console.info();
|
|
436
439
|
console.info("Pushing changes...");
|
|
437
440
|
execSync(`git push origin ${currentGitBranch()}`);
|
|
438
|
-
console.info(" Changes pushed.");
|
|
441
|
+
console.info(" Changes pushed."); */
|
|
439
442
|
|
|
443
|
+
/**
|
|
444
|
+
* We tag the latest commit as we want to keep the history clean without any release commits
|
|
445
|
+
*/
|
|
440
446
|
console.info();
|
|
441
447
|
console.info(`Creating new git tag v${version}`);
|
|
442
448
|
execSync(`git tag -a -m "v${version}" v${version}`);
|