relion 0.1.1 → 0.2.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.
Files changed (37) hide show
  1. package/package.json +84 -73
  2. package/src/cli.js +6 -0
  3. package/src/commands.js +16 -30
  4. package/src/defaults.js +6 -14
  5. package/src/index.js +48 -125
  6. package/src/lib/checkpoint.js +10 -10
  7. package/src/lib/configuration.js +21 -21
  8. package/src/lib/detect-package-manager.js +21 -18
  9. package/src/lib/format-commit-message.js +2 -2
  10. package/src/lib/latest-semver-tag.js +17 -17
  11. package/src/lib/lifecycles/bump.js +99 -91
  12. package/src/lib/lifecycles/changelog.js +47 -46
  13. package/src/lib/lifecycles/commit.js +34 -34
  14. package/src/lib/lifecycles/tag.js +32 -30
  15. package/src/lib/print-error.js +4 -4
  16. package/src/lib/run-exec.js +13 -12
  17. package/src/lib/run-execFile.js +13 -12
  18. package/src/lib/run-lifecycle-script.js +11 -11
  19. package/src/lib/stringify-package.js +9 -9
  20. package/src/lib/updaters/index.js +57 -54
  21. package/src/lib/updaters/types/csproj.js +6 -6
  22. package/src/lib/updaters/types/gradle.js +7 -7
  23. package/src/lib/updaters/types/json.js +12 -12
  24. package/src/lib/updaters/types/maven.js +22 -22
  25. package/src/lib/updaters/types/openapi.js +8 -8
  26. package/src/lib/updaters/types/plain-text.js +3 -3
  27. package/src/lib/updaters/types/python.js +19 -19
  28. package/src/lib/updaters/types/yaml.js +8 -8
  29. package/src/lib/write-file.js +4 -4
  30. package/src/preset/constants.js +1 -1
  31. package/src/preset/index.js +8 -8
  32. package/src/preset/parser.js +2 -2
  33. package/src/preset/templates/index.js +8 -8
  34. package/src/preset/whatBump.js +14 -13
  35. package/src/preset/writer.js +19 -19
  36. package/CHANGELOG.md +0 -47
  37. package/bin/cli.js +0 -9
@@ -1,43 +1,43 @@
1
- import jsdomPkg from 'jsdom';
2
- import serialize from 'w3c-xmlserializer';
3
- import { detectNewline } from 'detect-newline';
4
- const { JSDOM } = jsdomPkg;
5
- const CRLF = '\r\n';
6
- const LF = '\n';
1
+ import jsdomPkg from 'jsdom'
2
+ import serialize from 'w3c-xmlserializer'
3
+ import { detectNewline } from 'detect-newline'
4
+ const { JSDOM } = jsdomPkg
5
+ const CRLF = '\r\n'
6
+ const LF = '\n'
7
7
 
8
8
  function pomDocument(contents) {
9
- const dom = new JSDOM('');
10
- const parser = new dom.window.DOMParser();
11
- return parser.parseFromString(contents, 'application/xml');
9
+ const dom = new JSDOM('')
10
+ const parser = new dom.window.DOMParser()
11
+ return parser.parseFromString(contents, 'application/xml')
12
12
  }
13
13
 
14
14
  function pomVersionElement(document) {
15
- const versionElement = document.querySelector('project > version');
15
+ const versionElement = document.querySelector('project > version')
16
16
 
17
17
  if (!versionElement) {
18
- throw new Error('Failed to read the version field in your pom file - is it present?');
18
+ throw new Error('Failed to read the version field in your pom file - is it present?')
19
19
  }
20
20
 
21
- return versionElement;
21
+ return versionElement
22
22
  }
23
23
 
24
24
  export function readVersion(contents) {
25
- const document = pomDocument(contents);
26
- return pomVersionElement(document).textContent;
25
+ const document = pomDocument(contents)
26
+ return pomVersionElement(document).textContent
27
27
  }
28
28
 
29
29
  export function writeVersion(contents, version) {
30
- const newline = detectNewline(contents);
31
- const document = pomDocument(contents);
32
- const versionElement = pomVersionElement(document);
30
+ const newline = detectNewline(contents)
31
+ const document = pomDocument(contents)
32
+ const versionElement = pomVersionElement(document)
33
33
 
34
- versionElement.textContent = version;
34
+ versionElement.textContent = version
35
35
 
36
- const xml = serialize(document);
36
+ const xml = serialize(document)
37
37
 
38
38
  if (newline === CRLF) {
39
- return xml.replace(/\n/g, CRLF) + CRLF;
39
+ return xml.replace(/\n/g, CRLF) + CRLF
40
40
  }
41
41
 
42
- return xml + LF;
43
- }
42
+ return xml + LF
43
+ }
@@ -1,15 +1,15 @@
1
- import yaml from 'yaml';
2
- import { detectNewline } from 'detect-newline';
1
+ import yaml from 'yaml'
2
+ import { detectNewline } from 'detect-newline'
3
3
 
4
4
  export function readVersion(contents) {
5
- return yaml.parse(contents).info.version;
5
+ return yaml.parse(contents).info.version
6
6
  }
7
7
 
8
8
  export function writeVersion(contents, version) {
9
- const newline = detectNewline(contents);
10
- const document = yaml.parseDocument(contents);
9
+ const newline = detectNewline(contents)
10
+ const document = yaml.parseDocument(contents)
11
11
 
12
- document.get('info').set('version', version);
12
+ document.get('info').set('version', version)
13
13
 
14
- return document.toString().replace(/\r?\n/g, newline);
15
- }
14
+ return document.toString().replace(/\r?\n/g, newline)
15
+ }
@@ -1,7 +1,7 @@
1
1
  export function readVersion(contents) {
2
- return contents;
2
+ return contents
3
3
  }
4
4
 
5
5
  export function writeVersion(_contents, version) {
6
- return version;
7
- }
6
+ return version
7
+ }
@@ -1,30 +1,30 @@
1
- const versionExtractRegex = /version[" ]*=[ ]*["'](.*)["']/i;
1
+ const versionExtractRegex = /version[" ]*=[ ]*["'](.*)["']/i
2
2
 
3
3
  const getVersionIndex = function (lines) {
4
- let version;
4
+ let version
5
5
  const lineNumber = lines.findIndex((line) => {
6
- const versionMatcher = line.match(versionExtractRegex);
6
+ const versionMatcher = line.match(versionExtractRegex)
7
7
  // if version not found in lines provided, return false
8
8
  if (versionMatcher == null) {
9
- return false;
9
+ return false
10
10
  }
11
- version = versionMatcher[1];
12
- return true;
13
- });
14
- return { version, lineNumber };
15
- };
11
+ version = versionMatcher[1]
12
+ return true
13
+ })
14
+ return { version, lineNumber }
15
+ }
16
16
 
17
17
  export function readVersion(contents) {
18
- const lines = contents.split('\n');
19
- const versionIndex = getVersionIndex(lines);
20
- return versionIndex.version;
18
+ const lines = contents.split('\n')
19
+ const versionIndex = getVersionIndex(lines)
20
+ return versionIndex.version
21
21
  }
22
22
 
23
23
  export function writeVersion(contents, version) {
24
- const lines = contents.split('\n');
25
- const versionIndex = getVersionIndex(lines);
26
- const versionLine = lines[versionIndex.lineNumber];
27
- const newVersionLine = versionLine.replace(versionIndex.version, version);
28
- lines[versionIndex.lineNumber] = newVersionLine;
29
- return lines.join('\n');
30
- }
24
+ const lines = contents.split('\n')
25
+ const versionIndex = getVersionIndex(lines)
26
+ const versionLine = lines[versionIndex.lineNumber]
27
+ const newVersionLine = versionLine.replace(versionIndex.version, version)
28
+ lines[versionIndex.lineNumber] = newVersionLine
29
+ return lines.join('\n')
30
+ }
@@ -1,15 +1,15 @@
1
- import yaml from 'yaml';
2
- import { detectNewline } from 'detect-newline';
1
+ import yaml from 'yaml'
2
+ import { detectNewline } from 'detect-newline'
3
3
 
4
4
  export function readVersion(contents) {
5
- return yaml.parse(contents).version;
5
+ return yaml.parse(contents).version
6
6
  }
7
7
 
8
8
  export function writeVersion(contents, version) {
9
- const newline = detectNewline(contents);
10
- const document = yaml.parseDocument(contents);
9
+ const newline = detectNewline(contents)
10
+ const document = yaml.parseDocument(contents)
11
11
 
12
- document.set('version', version);
12
+ document.set('version', version)
13
13
 
14
- return document.toString().replace(/\r?\n/g, newline);
15
- }
14
+ return document.toString().replace(/\r?\n/g, newline)
15
+ }
@@ -1,6 +1,6 @@
1
- import fs from 'fs';
1
+ import fs from 'fs'
2
2
 
3
3
  export default function (args, filePath, content) {
4
- if (args.dryRun) return;
5
- fs.writeFileSync(filePath, content, 'utf8');
6
- }
4
+ if (args.dryRun) return
5
+ fs.writeFileSync(filePath, content, 'utf8')
6
+ }
@@ -13,4 +13,4 @@ export const DEFAULT_COMMIT_TYPES = Object.freeze(
13
13
  { type: 'build', section: 'Build System', hidden: true },
14
14
  { type: 'ci', section: 'Continuous Integration', hidden: true },
15
15
  ].map(Object.freeze),
16
- );
16
+ )
@@ -1,10 +1,10 @@
1
- import { DEFAULT_COMMIT_TYPES } from './constants.js';
2
- import { createParserOpts } from './parser.js';
3
- import { createWriterOpts } from './writer.js';
4
- import { createWhatBump } from './whatBump.js';
1
+ import { DEFAULT_COMMIT_TYPES } from './constants.js'
2
+ import { createParserOpts } from './parser.js'
3
+ import { createWriterOpts } from './writer.js'
4
+ import { createWhatBump } from './whatBump.js'
5
5
 
6
- export { DEFAULT_COMMIT_TYPES };
7
- export * from './templates/index.js';
6
+ export { DEFAULT_COMMIT_TYPES }
7
+ export * from './templates/index.js'
8
8
 
9
9
  export default async function createPreset(config) {
10
10
  return {
@@ -15,5 +15,5 @@ export default async function createPreset(config) {
15
15
  parser: createParserOpts(config),
16
16
  writer: await createWriterOpts(config),
17
17
  whatBump: createWhatBump(config),
18
- };
19
- }
18
+ }
19
+ }
@@ -7,5 +7,5 @@ export function createParserOpts(config) {
7
7
  revertPattern: /^(?:Revert|revert:)\s"?([\s\S]+?)"?\s*This reverts commit (\w*)\./i,
8
8
  revertCorrespondence: ['header', 'hash'],
9
9
  issuePrefixes: config?.issuePrefixes || ['#'],
10
- };
11
- }
10
+ }
11
+ }
@@ -1,13 +1,13 @@
1
- import fs from 'fs';
2
- import path from 'path';
1
+ import fs from 'fs'
2
+ import path from 'path'
3
3
 
4
- const dirpath = import.meta.dirname;
4
+ const dirpath = import.meta.dirname
5
5
 
6
6
  function read(name) {
7
- return fs.readFileSync(path.join(dirpath, `${name}.hbs`), 'utf-8');
7
+ return fs.readFileSync(path.join(dirpath, `${name}.hbs`), 'utf-8')
8
8
  }
9
9
 
10
- export const main = read('main');
11
- export const header = read('header');
12
- export const commit = read('commit');
13
- export const footer = read('footer');
10
+ export const main = read('main')
11
+ export const header = read('header')
12
+ export const commit = read('commit')
13
+ export const footer = read('footer')
@@ -1,24 +1,25 @@
1
1
  export function createWhatBump(config) {
2
2
  return function whatBump(commits) {
3
- let level = 2;
4
- let breakings = 0;
5
- let features = 0;
3
+ let level = 2
4
+ let breakings = 0
5
+ let features = 0
6
6
 
7
7
  commits.forEach((commit) => {
8
8
  if (commit.notes.length > 0) {
9
- breakings += commit.notes.length;
10
- level = 0;
11
- } else if (commit.type === 'feat' || commit.type === 'feature') {
12
- features += 1;
9
+ breakings += commit.notes.length
10
+ level = 0
11
+ }
12
+ else if (commit.type === 'feat' || commit.type === 'feature') {
13
+ features += 1
13
14
 
14
15
  if (level === 2) {
15
- level = 1;
16
+ level = 1
16
17
  }
17
18
  }
18
- });
19
+ })
19
20
 
20
21
  if (config?.preMajor && level < 2) {
21
- level++;
22
+ level++
22
23
  }
23
24
 
24
25
  return {
@@ -27,6 +28,6 @@ export function createWhatBump(config) {
27
28
  breakings === 1
28
29
  ? `There is ${breakings} BREAKING CHANGE and ${features} features`
29
30
  : `There are ${breakings} BREAKING CHANGES and ${features} features`,
30
- };
31
- };
32
- }
31
+ }
32
+ }
33
+ }
@@ -1,7 +1,6 @@
1
1
  import compareFunc from 'compare-func'
2
2
  import { DEFAULT_COMMIT_TYPES } from './constants.js'
3
- import { main, commit, header, footer } from './templates/index.js';
4
-
3
+ import { main, commit, header, footer } from './templates/index.js'
5
4
 
6
5
  const COMMIT_HASH_LENGTH = 7
7
6
  const releaseAsRegex = /release-as:\s*\w*@?([0-9]+\.[0-9]+\.[0-9a-z]+(-[0-9a-z.]+)?)\s*/i
@@ -20,24 +19,24 @@ export async function createWriterOpts(config) {
20
19
  compareUrlFormat: '{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}',
21
20
  userUrlFormat: '{{host}}/{{user}}',
22
21
  issuePrefixes: ['#'],
23
- ...config
22
+ ...config,
24
23
  }
25
24
  const commitUrlFormat = expandTemplate(finalConfig.commitUrlFormat, {
26
25
  host,
27
26
  owner,
28
- repository
27
+ repository,
29
28
  })
30
29
  const compareUrlFormat = expandTemplate(finalConfig.compareUrlFormat, {
31
30
  host,
32
31
  owner,
33
- repository
32
+ repository,
34
33
  })
35
34
  const issueUrlFormat = expandTemplate(finalConfig.issueUrlFormat, {
36
35
  host,
37
36
  owner,
38
37
  repository,
39
38
  id: '{{this.issue}}',
40
- prefix: '{{this.prefix}}'
39
+ prefix: '{{this.prefix}}',
41
40
  })
42
41
  const writerOpts = getWriterOpts(finalConfig)
43
42
 
@@ -62,15 +61,16 @@ function getWriterOpts(config) {
62
61
  const versionTagRegex = /tag:\s*([^,\s)]+)/i
63
62
  const keyCommitTag = keyCommit.gitTags?.match(versionTagRegex)
64
63
  if (keyCommitTag) {
65
- context.currentTag = keyCommitTag[1];
66
- const currentTagIndex = context.gitSemverTags.indexOf(context.currentTag);
67
- context.previousTag = (currentTagIndex === -1) ? null : context.gitSemverTags[currentTagIndex + 1];
64
+ context.currentTag = keyCommitTag[1]
65
+ const currentTagIndex = context.gitSemverTags.indexOf(context.currentTag)
66
+ context.previousTag = (currentTagIndex === -1) ? null : context.gitSemverTags[currentTagIndex + 1]
68
67
  }
69
- } else {
70
- context.currentTag = context.newTag || null;
71
- context.previousTag = context.gitSemverTags[0] || null;
72
68
  }
73
- return context;
69
+ else {
70
+ context.currentTag = context.newTag || null
71
+ context.previousTag = context.gitSemverTags[0] || null
72
+ }
73
+ return context
74
74
  },
75
75
  transform: (commit, context) => {
76
76
  let discard = true
@@ -89,7 +89,7 @@ function getWriterOpts(config) {
89
89
 
90
90
  return {
91
91
  ...note,
92
- title: 'BREAKING CHANGES'
92
+ title: 'BREAKING CHANGES',
93
93
  }
94
94
  })
95
95
 
@@ -123,7 +123,7 @@ function getWriterOpts(config) {
123
123
  owner: context.owner,
124
124
  repository: context.repository,
125
125
  id: issue,
126
- prefix
126
+ prefix,
127
127
  })
128
128
 
129
129
  return `[${prefix}${issue}](${url})`
@@ -139,7 +139,7 @@ function getWriterOpts(config) {
139
139
  host: context.host,
140
140
  owner: context.owner,
141
141
  repository: context.repository,
142
- user
142
+ user,
143
143
  })
144
144
 
145
145
  return `[@${user}](${usernameUrl})`
@@ -155,7 +155,7 @@ function getWriterOpts(config) {
155
155
  scope,
156
156
  shortHash,
157
157
  subject,
158
- references
158
+ references,
159
159
  }
160
160
  },
161
161
  groupBy: 'type',
@@ -169,7 +169,7 @@ function getWriterOpts(config) {
169
169
  },
170
170
  commitsSort: ['scope', 'subject'],
171
171
  noteGroupsSort: 'title',
172
- notesSort: compareFunc
172
+ notesSort: compareFunc,
173
173
  }
174
174
  }
175
175
 
@@ -198,4 +198,4 @@ function expandTemplate(template, context) {
198
198
  expanded = expanded.replace(new RegExp(`{{${key}}}`, 'g'), context[key])
199
199
  })
200
200
  return expanded
201
- }
201
+ }
package/CHANGELOG.md DELETED
@@ -1,47 +0,0 @@
1
- # Changelog
2
-
3
-
4
- ## [v0.1.1](https://github.com/Kh4f/relion/commits/v0.1.1) (2025-06-20)
5
-
6
- > [!NOTE]
7
- > This release is version `0.1.1` instead of `0.1.0` due to an npm restriction: [previously unpublished versions can never be republished](https://docs.npmjs.com/cli/v11/commands/npm-unpublish).
8
-
9
- ### ⚠ BREAKING CHANGES
10
- * The project and related references have been renamed to 'relion'.
11
- * `config` Changed alias for 'prerelease' option to 'P' to reserve 'p' for the new '--profile' option.
12
- * `config` The 'skip' object has been removed from the config. Now, 'bump', 'changelog', 'commit', and 'tag' are explicit boolean flags. By default, they are false and must be set to true in the user config to enable the corresponding steps.
13
- * `config` The 'firstRelease' property has been removed.
14
- * `config` The config structure has changed. All preset options must now be placed under a 'preset' key in the config file (or cli args). This will be smart-merged with the default preset.
15
-
16
- ### ✨ Features
17
- * `changelog` repeat last release changelog when no new commits ([bdcb9bc](https://github.com/Kh4f/relion/commit/bdcb9bca3ba38ef8a9a1332d82685b1c7a71508b))
18
- * `config` add support for `_<profileName>` profiles with CLI `--profile` flag ([a940100](https://github.com/Kh4f/relion/commit/a940100796af3fdcc224f1987775d6a4c04d62dd))
19
- * `config` add `.mjs` and `.ts` config support ([0efe117](https://github.com/Kh4f/relion/commit/0efe11740433e9a000878a4f0e0822a94a0ac6a2))
20
- * `cli` add context.fullChangelogLink flag ([949f09e](https://github.com/Kh4f/relion/commit/949f09ee9ddb3ce38a6568b4509a1c08c264f6da))
21
- * `templates` add full changelog link to footer ([e1ed82b](https://github.com/Kh4f/relion/commit/e1ed82b74c988b1785cd93336918b5f005cd1c38))
22
- * `templates` add link to current tag commits in header if it is the only tag ([f8a8d73](https://github.com/Kh4f/relion/commit/f8a8d73ef57b5b55ec184c172384ae0f36ac18a8))
23
- * `cli` add 'context.linkReferences' option ([bc048b4](https://github.com/Kh4f/relion/commit/bc048b4dd1446ee78f3ef670589a9ca5fb41ad3b))
24
- * `preset` re-export handlebars templates as strings ([1dc5952](https://github.com/Kh4f/relion/commit/1dc5952f42b08e0a86d71b162d427df51d4855c5))
25
- * `config` add 'all' option to run all lifecycle events ([d2a6fd3](https://github.com/Kh4f/relion/commit/d2a6fd3befd0dd13ab128e220a4a65236b2afe1d))
26
- * `config` allow defining custom context ([93d6f91](https://github.com/Kh4f/relion/commit/93d6f91caa490d418b20498da9ccc32ccda8ae46))
27
- * `config` add `writerOpts.commitsSort` to defaults ([dec6006](https://github.com/Kh4f/relion/commit/dec60066dc8690d97dac51707c03c0c0fbc75e4b))
28
- * `config` replace skip object with explicit bump, changelog, commit, and tag flags ([6f9f4e0](https://github.com/Kh4f/relion/commit/6f9f4e0af3fed9f1687ac1234af2a466c4db579d))
29
- * `config` require config preset options to be nested under 'preset' key ([01fc1f1](https://github.com/Kh4f/relion/commit/01fc1f16b71b40557877ad67442279892a9a4a60))
30
- * `changelog` support version prefixes in release headers ([00e5410](https://github.com/Kh4f/relion/commit/00e54105d686d90629c1a95a000c78896065b9e9))
31
-
32
- ### 🩹 Bug Fixes
33
- * `changelog` prevent empty changelog generation when last commit has a version tag ([080c007](https://github.com/Kh4f/relion/commit/080c007b88882bfbc7d0e9deb215252714de6475))
34
- * `writer` correct `previousTag` detection for `releaseCount` > 1 ([464cdfa](https://github.com/Kh4f/relion/commit/464cdfa90bef7af3154e6e3cb1a6d80268c2d375))
35
- * `cli` use `defaults.preset` for default preset options ([c824820](https://github.com/Kh4f/relion/commit/c824820fa355fc5ad4ff3666a8fa354d35ca35f4))
36
- * `config` avoid setting `preMajor` to false by default ([a22bd20](https://github.com/Kh4f/relion/commit/a22bd202731c8f4a8c9eb2cea622ed5ac1b9b720))
37
- * `config` resolve script import path with pathToFileURL ([3f6f930](https://github.com/Kh4f/relion/commit/3f6f93041403573d736eebd3ae55a4b1a922843a))
38
- * `package` update release script to use node for execution ([bd194d4](https://github.com/Kh4f/relion/commit/bd194d4e66884ca414659e6430cdda30427d6c1d))
39
- * `core` move `args.all` handling after `args` initialization ([e97b046](https://github.com/Kh4f/relion/commit/e97b04612019a49f9a3aca4653ae88999b3df2e6))
40
- * `cli` change aliases for commit-all and tag-prefix to avoid conflicts ([8adfdf7](https://github.com/Kh4f/relion/commit/8adfdf7cfe8e6545da1e6fe23298b0669102f142))
41
- * `commit` add tag prefix to version in release commit message ([0b955a4](https://github.com/Kh4f/relion/commit/0b955a4f3f6377b3092d086bd44a77c3e27816f5))
42
- * `bump` always resolve new version even if skip.bump is set ([6b560c9](https://github.com/Kh4f/relion/commit/6b560c967e8f8522ecfda1529dde26d0f80ebfe7))
43
- * `bump` add `await` before calling `resolveUpdaterObjectFromArgument` ([a7026fa](https://github.com/Kh4f/relion/commit/a7026fa6513bf2505415e2c69215173cec194bd1))
44
-
45
- ### 🧹 Adjustments
46
- * rename project to 'relion' ([faaa473](https://github.com/Kh4f/relion/commit/faaa473670c52e05821bdcc372f1a434eba1fb38))
47
- * `config` remove unnecessary? `firstRelease` property ([67266a8](https://github.com/Kh4f/relion/commit/67266a84668e34a1b22ddd361c702010b6619aac))
package/bin/cli.js DELETED
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import relion from '../src/index.js';
4
- import cmdParser from '../src/commands.js';
5
-
6
- relion(cmdParser.argv).catch((err) => {
7
- console.error(err);
8
- process.exit(1);
9
- });