aberlaas-release 2.22.1 → 2.22.3

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.
@@ -20,6 +20,12 @@ export async function ensureCorrectPublishedFiles(releaseData) {
20
20
  }
21
21
 
22
22
  __ = {
23
+ /**
24
+ * Ensures that npm and yarn publish the same files for a package
25
+ * @param {object} packageData - The package data object containing package information
26
+ * @returns {Promise<boolean>} True if npm and yarn publish the same files
27
+ * @throws {Error} Throws an error if published files differ between npm and yarn
28
+ */
23
29
  async ensureSameFilesPublishedWithYarnOrNpm(packageData) {
24
30
  const packageName = packageData.content.name;
25
31
  const npmFiles = await __.getNpmPublishedFiles(packageData);
@@ -3,16 +3,13 @@ import {
3
3
  consoleInfo,
4
4
  consoleWarn,
5
5
  env,
6
- exists,
7
6
  prompt,
8
- read,
9
7
  readJson,
10
8
  run,
11
9
  sleep,
12
- write,
13
10
  } from 'firost';
14
- import { hostGitPath, hostPackagePath } from 'aberlaas-helper';
15
- import { parse as parseEnvrc, stringify as stringifyEnvrc } from 'envfile';
11
+ import { hostPackagePath } from 'aberlaas-helper';
12
+ import { getNpmAuthToken, setNpmAuthToken } from './helper.js';
16
13
 
17
14
  export let __;
18
15
 
@@ -33,13 +30,18 @@ __ = {
33
30
  ensureNpmLogin,
34
31
  /**
35
32
  * Checks if the user is authenticated with npm by running 'yarn npm whoami' command
36
- * @returns {Promise<boolean>} Promise that resolves to true if authenticated, false otherwise
33
+ * @returns {boolean} Promise that resolves to true if authenticated, false otherwise
37
34
  */
38
35
  async isAuthenticated() {
36
+ const npmAuthToken = await __.getNpmAuthToken();
37
+
39
38
  try {
40
39
  await __.run('yarn npm whoami', {
41
40
  stderr: false,
42
41
  stdout: false,
42
+ env: {
43
+ ABERLAAS_RELEASE_NPM_AUTH_TOKEN: npmAuthToken,
44
+ },
43
45
  });
44
46
  return true;
45
47
  } catch (_err) {
@@ -143,20 +145,14 @@ __ = {
143
145
  },
144
146
 
145
147
  /**
146
- * Saves the npm token to .envrc file
148
+ * Saves the npm token to .env file
147
149
  */
148
150
  async saveNpmToken() {
149
- // TODO: replace with keyleth
150
- const envrcPath = hostGitPath('.envrc');
151
- const envrcAsJson = (await exists(envrcPath))
152
- ? parseEnvrc(await read(envrcPath))
153
- : {};
154
-
155
151
  const npmToken = await __.prompt('Enter you new token here:');
156
- envrcAsJson.ABERLAAS_RELEASE_NPM_AUTH_TOKEN = npmToken;
157
-
158
- await write(stringifyEnvrc(envrcAsJson), envrcPath);
152
+ await __.setNpmAuthToken(npmToken);
159
153
  },
154
+ getNpmAuthToken,
155
+ setNpmAuthToken,
160
156
  run,
161
157
  env,
162
158
  prompt,
@@ -3,8 +3,39 @@ import { glob, readJson } from 'firost';
3
3
  import { hostGitPath, hostGitRoot } from 'aberlaas-helper';
4
4
  import { getGitDiff, parseCommits } from 'changelogen';
5
5
  import semver from 'semver';
6
+ import { getLastReleasePoint } from './helper.js';
6
7
 
7
- export const __ = {
8
+ export let __;
9
+
10
+ /**
11
+ * Gathers all release information from CLI arguments
12
+ * @param {object} cliArgs - CLI arguments from minimist
13
+ * @returns {object} Release data containing bumpType, allPackages, currentVersion, newVersion, changelog
14
+ */
15
+ export async function getReleaseData(cliArgs) {
16
+ // Default options: changelog enabled unless explicitly disabled via CLI
17
+ const options = {
18
+ changelog: true,
19
+ ...cliArgs,
20
+ };
21
+
22
+ const allPackages = await __.getAllPackagesToRelease();
23
+ const currentVersion = allPackages[0].content.version;
24
+
25
+ const bumpType = await __.getBumpType(cliArgs, currentVersion);
26
+
27
+ const newVersion = semver.inc(currentVersion, bumpType);
28
+
29
+ return {
30
+ bumpType,
31
+ allPackages,
32
+ currentVersion,
33
+ newVersion,
34
+ changelog: options.changelog,
35
+ };
36
+ }
37
+
38
+ __ = {
8
39
  /**
9
40
  * Gets all packages that need to be released
10
41
  * @returns {Array<{filepath: string, content: object}>} Array of packages with their filepath and content
@@ -60,12 +91,14 @@ export const __ = {
60
91
  return argFromCli;
61
92
  }
62
93
 
63
- // Getting all commits since last version tag
94
+ // Find all commits since last publish
95
+ const lastReleasePoint = await getLastReleasePoint(currentVersion);
64
96
  const rawCommits = await getGitDiff(
65
- `v${currentVersion}`,
97
+ lastReleasePoint,
66
98
  'HEAD',
67
99
  hostGitRoot(),
68
100
  );
101
+
69
102
  // This is the minimal object required by changelogen
70
103
  const minimalConfig = { scopeMap: {} };
71
104
  const commits = parseCommits(rawCommits, minimalConfig);
@@ -86,31 +119,3 @@ export const __ = {
86
119
  return 'patch';
87
120
  },
88
121
  };
89
-
90
- /**
91
- * Gathers all release information from CLI arguments
92
- * @param {object} cliArgs - CLI arguments from minimist
93
- * @returns {object} Release data containing bumpType, allPackages, currentVersion, newVersion, changelog
94
- */
95
- export async function getReleaseData(cliArgs) {
96
- // Default options: changelog enabled unless explicitly disabled via CLI
97
- const options = {
98
- changelog: true,
99
- ...cliArgs,
100
- };
101
-
102
- const allPackages = await __.getAllPackagesToRelease();
103
- const currentVersion = allPackages[0].content.version;
104
-
105
- const bumpType = await __.getBumpType(cliArgs, currentVersion);
106
-
107
- const newVersion = semver.inc(currentVersion, bumpType);
108
-
109
- return {
110
- bumpType,
111
- allPackages,
112
- currentVersion,
113
- newVersion,
114
- changelog: options.changelog,
115
- };
116
- }
package/lib/helper.js ADDED
@@ -0,0 +1,36 @@
1
+ import { hostGitRoot } from 'aberlaas-helper';
2
+ import Gilmore from 'gilmore';
3
+ import { getKey, setKey } from 'keyleth';
4
+
5
+ /**
6
+ * Finds the last release point for git diff operations
7
+ * @param {string} version - Current version number (e.g., '1.2.3')
8
+ * @returns {Promise<string|null>} Tag name if exists (e.g., 'v1.2.3'), or null to search from repo beginning
9
+ */
10
+ export async function getLastReleasePoint(version) {
11
+ const repo = new Gilmore(hostGitRoot());
12
+
13
+ const tagName = `v${version}`;
14
+ const tagExists = await repo.tagExists(tagName);
15
+ return tagExists ? tagName : null;
16
+ }
17
+
18
+ /**
19
+ * Retrieves the npm authentication token from .env file
20
+ * @returns {string} The npm auth token, or null if not found
21
+ */
22
+ export async function getNpmAuthToken() {
23
+ return await getKey('ABERLAAS_RELEASE_NPM_AUTH_TOKEN', {
24
+ cwd: hostGitRoot(),
25
+ });
26
+ }
27
+
28
+ /**
29
+ * Saves the npm authentication token to .env file
30
+ * @param {string} token - The npm auth token to save
31
+ */
32
+ export async function setNpmAuthToken(token) {
33
+ await setKey('ABERLAAS_RELEASE_NPM_AUTH_TOKEN', token, {
34
+ cwd: hostGitRoot(),
35
+ });
36
+ }
@@ -1,6 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import { pMap } from 'golgoth';
3
3
  import { firostError, run, spinner } from 'firost';
4
+ import { getNpmAuthToken } from './helper.js';
4
5
 
5
6
  export let __;
6
7
 
@@ -33,6 +34,7 @@ export async function publishToNpm(releaseData) {
33
34
  __ = {
34
35
  async publishPackage(packageData) {
35
36
  const { filepath, content } = packageData;
37
+ const npmAuthToken = await __.getNpmAuthToken();
36
38
 
37
39
  try {
38
40
  // Note:
@@ -42,6 +44,9 @@ __ = {
42
44
  cwd: path.dirname(filepath),
43
45
  stdout: false,
44
46
  stderr: false,
47
+ env: {
48
+ ABERLAAS_RELEASE_NPM_AUTH_TOKEN: npmAuthToken,
49
+ },
45
50
  });
46
51
  return true;
47
52
  } catch (err) {
@@ -52,6 +57,7 @@ __ = {
52
57
  );
53
58
  }
54
59
  },
60
+ getNpmAuthToken,
55
61
  run,
56
62
  spinner,
57
63
  };
@@ -11,8 +11,27 @@ import {
11
11
  import { hostGitPath, hostGitRoot } from 'aberlaas-helper';
12
12
  import { generateMarkDown, getGitDiff, parseCommits } from 'changelogen';
13
13
  import cliMarkdown from 'cli-markdown';
14
+ import { getLastReleasePoint } from './helper.js';
14
15
 
15
- export const __ = {
16
+ export let __;
17
+
18
+ /**
19
+ * Update the CHANGELOG.md file with new additions
20
+ * @param {object} releaseData - Release data containing currentVersion, newVersion, and changeLog
21
+ * @param {boolean} [releaseData.changelog=true] Generate changelog
22
+ */
23
+ export async function updateChangelog(releaseData) {
24
+ if (!releaseData.changelog) {
25
+ return;
26
+ }
27
+
28
+ const suggestedChangelog = await __.generateChangelogFromGit(releaseData);
29
+ const approvedChangelog = await __.confirmOrEditChangelog(suggestedChangelog);
30
+
31
+ await __.addToExistingChangelogFile(approvedChangelog);
32
+ }
33
+
34
+ __ = {
16
35
  /**
17
36
  * Generate changelog markdown from git commits between two versions
18
37
  * @param {object} releaseData - Release data containing currentVersion, newVersion, and changeLog
@@ -20,12 +39,12 @@ export const __ = {
20
39
  */
21
40
  async generateChangelogFromGit(releaseData) {
22
41
  const { currentVersion, newVersion } = releaseData;
23
- const gitRoot = hostGitRoot();
24
- const currentVersionTag = `v${currentVersion}`;
42
+
43
+ const lastReleasePoint = await getLastReleasePoint(currentVersion);
25
44
 
26
45
  // Get config
27
46
  const config = {
28
- from: currentVersionTag,
47
+ from: lastReleasePoint,
29
48
  to: 'HEAD',
30
49
  newVersion,
31
50
  noAuthors: true,
@@ -42,7 +61,11 @@ export const __ = {
42
61
  scopeMap: {},
43
62
  };
44
63
 
45
- const rawCommits = await getGitDiff(currentVersionTag, 'HEAD', gitRoot);
64
+ const rawCommits = await getGitDiff(
65
+ lastReleasePoint,
66
+ 'HEAD',
67
+ hostGitRoot(),
68
+ );
46
69
  const commits = parseCommits(rawCommits, config);
47
70
 
48
71
  // Filter commits to only keep user-facing types
@@ -132,20 +155,5 @@ export const __ = {
132
155
  select,
133
156
  cliMarkdown,
134
157
  run,
158
+ getLastReleasePoint,
135
159
  };
136
-
137
- /**
138
- * Update the CHANGELOG.md file with new additions
139
- * @param {object} releaseData - Release data containing currentVersion, newVersion, and changeLog
140
- * @param {boolean} [releaseData.changelog=true] Generate changelog
141
- */
142
- export async function updateChangelog(releaseData) {
143
- if (!releaseData.changelog) {
144
- return;
145
- }
146
-
147
- const suggestedChangelog = await __.generateChangelogFromGit(releaseData);
148
- const approvedChangelog = await __.confirmOrEditChangelog(suggestedChangelog);
149
-
150
- await __.addToExistingChangelogFile(approvedChangelog);
151
- }
@@ -4,7 +4,24 @@ import { hostGitRoot } from 'aberlaas-helper';
4
4
  import Gilmore from 'gilmore';
5
5
  import { updateChangelog } from './updateChangelog.js';
6
6
 
7
- export const __ = {
7
+ export let __;
8
+
9
+ /**
10
+ * Update git repository with all changes for the release
11
+ * @param {object} releaseData - Release data containing currentVersion, newVersion, skipChangelog, and allPackages
12
+ */
13
+ export async function updateGitRepo(releaseData) {
14
+ // Update CHANGELOG.md
15
+ await __.updateChangelog(releaseData);
16
+
17
+ // Update all .version keys in packages
18
+ await __.bumpAllPackageVersions(releaseData);
19
+
20
+ // Commit and push to remote
21
+ await __.commitTagAndPush(releaseData);
22
+ }
23
+
24
+ __ = {
8
25
  /**
9
26
  * Bumps the version of all packages to the new version
10
27
  * @param {object} releaseData - Release data containing allPackages and newVersion
@@ -47,18 +64,3 @@ export const __ = {
47
64
  consoleInfo,
48
65
  updateChangelog,
49
66
  };
50
-
51
- /**
52
- * Update git repository with all changes for the release
53
- * @param {object} releaseData - Release data containing currentVersion, newVersion, skipChangelog, and allPackages
54
- */
55
- export async function updateGitRepo(releaseData) {
56
- // Update CHANGELOG.md
57
- await __.updateChangelog(releaseData);
58
-
59
- // Update all .version keys in packages
60
- await __.bumpAllPackageVersions(releaseData);
61
-
62
- // Commit and push to remote
63
- await __.commitTagAndPush(releaseData);
64
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aberlaas-release",
3
- "version": "2.22.1",
3
+ "version": "2.22.3",
4
4
  "type": "module",
5
5
  "description": "aberlaas release command: Release and publish new versions",
6
6
  "author": "Tim Carry <tim@pixelastic.com>",
@@ -18,20 +18,17 @@
18
18
  ".": "./lib/main.js"
19
19
  },
20
20
  "main": "./lib/main.js",
21
- "devDependencies": {
22
- "aberlaas-versions": "2.22.1"
23
- },
24
21
  "dependencies": {
25
- "aberlaas-helper": "2.22.1",
26
- "aberlaas-lint": "2.22.1",
27
- "aberlaas-test": "2.22.1",
22
+ "aberlaas-helper": "2.22.3",
23
+ "aberlaas-lint": "2.22.3",
24
+ "aberlaas-test": "2.22.3",
28
25
  "changelogen": "0.6.2",
29
26
  "cli-markdown": "3.5.1",
30
- "envfile": "7.1.0",
31
27
  "firost": "5.5.1",
32
28
  "gilmore": "1.2.0",
33
29
  "golgoth": "3.1.0",
34
- "semver": "7.7.3"
30
+ "keyleth": "0.2.0",
31
+ "semver": "7.7.4"
35
32
  },
36
33
  "scripts": {
37
34
  "build": "cd ../docs && yarn run build",