@edifice.io/cli 1.6.0 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/cli",
3
- "version": "1.6.0",
3
+ "version": "1.6.1-develop-pedago.1731942440734",
4
4
  "description": "Edifice Frontend CLI",
5
5
  "keywords": [
6
6
  "frontend",
@@ -41,16 +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
- // Filter tags based on whether the branch is a release or pre-release
44
+ // Only include non-prerelease tags from main branch
45
45
  .filter((t) => {
46
- const isPrereleaseTag = semver.prerelease(t) !== null;
47
- const prereleaseBranch = semver.prerelease(t)?.[0];
48
- // For prerelease branches, only include tags for that branch
49
- if (branchConfig.prerelease) {
50
- return isPrereleaseTag && prereleaseBranch === branchName;
51
- }
52
- // For main branch, exclude all prereleases
53
- return !isPrereleaseTag;
46
+ // Exclude any prerelease tags
47
+ return semver.prerelease(t) === null;
54
48
  })
55
49
  // sort by latest
56
50
  // @ts-ignore
@@ -58,6 +52,7 @@ export const publish = async (options) => {
58
52
 
59
53
  // Get the latest tag
60
54
  let latestTag = filteredTags.at(-1);
55
+
61
56
  let rangeFrom = latestTag;
62
57
 
63
58
  // If RELEASE_ALL is set via a commit subject or body, all packages will be
@@ -167,13 +162,6 @@ export const publish = async (options) => {
167
162
  -1,
168
163
  );
169
164
 
170
- // If there is a breaking change and no manual tag is set, do not release
171
- /* if (recommendedReleaseLevel === 2 && !tag) {
172
- throw new Error(
173
- 'Major versions releases must be tagged and released manually.'
174
- );
175
- } */
176
-
177
165
  // If no release is semantically necessary and no manual tag is set, do not release
178
166
  if (recommendedReleaseLevel === -1 && !tag) {
179
167
  console.info(
@@ -199,7 +187,9 @@ export const publish = async (options) => {
199
187
 
200
188
  const version = tag
201
189
  ? semver.parse(tag)?.version
202
- : semver.inc(latestTag, releaseType, npmTag);
190
+ : branchConfig.prerelease
191
+ ? `${semver.inc(latestTag, releaseType, npmTag, false)}.${Date.now()}`
192
+ : semver.inc(latestTag, releaseType, npmTag);
203
193
 
204
194
  if (!version) {
205
195
  throw new Error(
@@ -270,6 +260,10 @@ export const publish = async (options) => {
270
260
  const changelogCommitsMd = await Promise.all(
271
261
  Object.entries(
272
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
+ }
273
267
  return {
274
268
  ...prev,
275
269
  [curr.type]: [...(prev[curr.type] ?? []), curr],
@@ -277,20 +271,7 @@ export const publish = async (options) => {
277
271
  }, /** @type {Record<string, import('./index').Commit[]>} */ ({})),
278
272
  )
279
273
  .sort(
280
- getSorterFn(([type]) =>
281
- [
282
- "other",
283
- "examples",
284
- "docs",
285
- "ci",
286
- "test",
287
- "chore",
288
- "refactor",
289
- "perf",
290
- "fix",
291
- "feat",
292
- ].indexOf(type),
293
- ),
274
+ getSorterFn(([type]) => ["docs", "chore", "fix", "feat"].indexOf(type)),
294
275
  )
295
276
  .reverse()
296
277
  .map(async ([type, commits]) => {
@@ -334,7 +315,15 @@ export const publish = async (options) => {
334
315
  ).then((groups) => {
335
316
  return groups
336
317
  .map(([type, commits]) => {
337
- return [`### ${capitalize(type)}`, commits.join("\n")].join("\n\n");
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");
338
327
  })
339
328
  .join("\n\n");
340
329
  });
@@ -399,32 +388,60 @@ export const publish = async (options) => {
399
388
 
400
389
  console.info();
401
390
  console.info("Committing changes...");
402
- execSync(
403
- `git add -A && git reset -- ${changedPackages
404
- .map((pkg) => path.resolve(rootDir, pkg.packageDir, "package.json"))
405
- .join(" ")}`,
406
- );
407
- execSync(
408
- `git checkout -- ${changedPackages
409
- .map((pkg) => path.resolve(rootDir, pkg.packageDir, "package.json"))
410
- .join(" ")}`,
411
- );
412
- execSync(`git commit -m "${releaseCommitMsg(version)}" --allow-empty -n`);
413
- console.info(" Committed Changes.");
414
391
 
415
- console.info();
416
- console.info("Pushing changes...");
417
- execSync(`git push origin ${currentGitBranch()}`);
418
- console.info(" Changes pushed.");
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.");
419
402
 
420
- console.info();
421
- console.info(`Creating new git tag v${version}`);
422
- execSync(`git tag -a -m "v${version}" v${version}`);
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.");
423
410
 
424
- console.info();
425
- console.info("Pushing tags...");
426
- execSync("git push --tags");
427
- console.info(" Tags pushed.");
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
+ }
428
445
 
429
446
  if (ghToken && isMainBranch) {
430
447
  console.info();