@edifice.io/cli 1.6.0-develop-b2school.7 → 1.6.0-develop-docker.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/package.json +1 -1
- package/src/publish/index.js +31 -9
package/package.json
CHANGED
package/src/publish/index.js
CHANGED
|
@@ -23,6 +23,8 @@ 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
|
+
|
|
26
28
|
const branchName = /** @type {string} */ (branch ?? currentGitBranch());
|
|
27
29
|
const isMainBranch = branchName === "main";
|
|
28
30
|
const npmTag = isMainBranch ? "latest" : branchName;
|
|
@@ -38,15 +40,23 @@ export const publish = async (options) => {
|
|
|
38
40
|
/** @type {string[]} */
|
|
39
41
|
const allTags = execSync("git tag").toString().split("\n");
|
|
40
42
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
const semverTags = allTags.filter((t) => semver.valid(t)).reverse();
|
|
44
|
+
|
|
45
|
+
const filteredTags = semverTags
|
|
44
46
|
// Filter tags based on whether the branch is a release or pre-release
|
|
45
47
|
.filter((t) => {
|
|
46
48
|
const isPrereleaseTag = semver.prerelease(t) !== null;
|
|
47
49
|
const prereleaseBranch = semver.prerelease(t)?.[0];
|
|
48
50
|
// For prerelease branches, only include tags for that branch
|
|
49
51
|
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
|
+
}
|
|
50
60
|
return isPrereleaseTag && prereleaseBranch === branchName;
|
|
51
61
|
}
|
|
52
62
|
// For main branch, exclude all prereleases
|
|
@@ -187,11 +197,17 @@ export const publish = async (options) => {
|
|
|
187
197
|
recommendedReleaseLevel = 0;
|
|
188
198
|
}
|
|
189
199
|
|
|
190
|
-
const releaseType = branchConfig.prerelease
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
200
|
+
// const releaseType = branchConfig.prerelease
|
|
201
|
+
// ? "prerelease"
|
|
202
|
+
// : /** @type {const} */ ({ 0: "patch", 1: "minor", 2: "major" })[
|
|
203
|
+
// recommendedReleaseLevel
|
|
204
|
+
// ];
|
|
205
|
+
|
|
206
|
+
const releaseType = /** @type {const} */ ({
|
|
207
|
+
0: "patch",
|
|
208
|
+
1: "minor",
|
|
209
|
+
2: "major",
|
|
210
|
+
})[recommendedReleaseLevel];
|
|
195
211
|
|
|
196
212
|
if (!releaseType) {
|
|
197
213
|
throw new Error(`Invalid release level: ${recommendedReleaseLevel}`);
|
|
@@ -199,7 +215,11 @@ export const publish = async (options) => {
|
|
|
199
215
|
|
|
200
216
|
const version = tag
|
|
201
217
|
? semver.parse(tag)?.version
|
|
202
|
-
: semver.inc(
|
|
218
|
+
: semver.inc(
|
|
219
|
+
latestTag,
|
|
220
|
+
branchConfig.prerelease ? `pre${releaseType}` : releaseType,
|
|
221
|
+
npmTag,
|
|
222
|
+
);
|
|
203
223
|
|
|
204
224
|
if (!version) {
|
|
205
225
|
throw new Error(
|
|
@@ -232,6 +252,8 @@ export const publish = async (options) => {
|
|
|
232
252
|
const changed = changedFiles.some(
|
|
233
253
|
(file) =>
|
|
234
254
|
file.startsWith(path.join(pkg.packageDir, "src")) ||
|
|
255
|
+
// check if any files in the assets directory were modified
|
|
256
|
+
file.startsWith(path.join(pkg.packageDir, "assets")) ||
|
|
235
257
|
file.startsWith(path.join(pkg.packageDir, "package.json")),
|
|
236
258
|
);
|
|
237
259
|
return changed;
|