release-it 19.0.3 → 19.0.4

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/lib/config.js CHANGED
@@ -4,9 +4,8 @@ import { isCI } from 'ci-info';
4
4
  import defaultsDeep from '@nodeutils/defaults-deep';
5
5
  import { isObjectStrict } from '@phun-ky/typeof';
6
6
  import merge from 'lodash.merge';
7
- import get from 'lodash.get';
8
7
  import { loadConfig as loadC12 } from 'c12';
9
- import { getSystemInfo, readJSON } from './util.js';
8
+ import { get, getSystemInfo, readJSON } from './util.js';
10
9
 
11
10
  const debug = util.debug('release-it:config');
12
11
  const defaultConfig = readJSON(new URL('../config/release-it.json', import.meta.url));
@@ -1,6 +1,6 @@
1
1
  import { debug } from 'node:util';
2
2
  import merge from 'lodash.merge';
3
- import get from 'lodash.get';
3
+ import { get } from '../util.js';
4
4
 
5
5
  class Plugin {
6
6
  static isEnabled() {
@@ -178,7 +178,7 @@ class GitHub extends Release {
178
178
  baseUrl,
179
179
  auth: `token ${this.token}`,
180
180
  userAgent: `release-it/${pkg.version}`,
181
- log: this.config.isDebug ? console : null,
181
+ log: this.config.isDebug ? console : {},
182
182
  request: {
183
183
  timeout
184
184
  }
package/lib/util.js CHANGED
@@ -179,3 +179,28 @@ export const pick = (object, keys) => {
179
179
  return obj;
180
180
  }, {});
181
181
  };
182
+
183
+ const parsePath = (path)=> {
184
+ const result = [];
185
+ const regex = /[^.[\]]+|\[(?:(\d+)|["'](.+?)["'])\]/g;
186
+ let match;
187
+
188
+ while ((match = regex.exec(path)) !== null) {
189
+ result.push(match[1] ?? match[2] ?? match[0]);
190
+ }
191
+
192
+ return result;
193
+ }
194
+
195
+ export const get = (obj, path, defaultValue = undefined) =>{
196
+ if (!path || typeof path !== 'string') {
197
+ return defaultValue;
198
+ }
199
+
200
+ try {
201
+ const keys = parsePath(path);
202
+ return keys.reduce((acc, key) => acc?.[key], obj) ?? defaultValue;
203
+ } catch {
204
+ return defaultValue;
205
+ }
206
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-it",
3
- "version": "19.0.3",
3
+ "version": "19.0.4",
4
4
  "description": "Generic CLI tool to automate versioning and package publishing-related tasks.",
5
5
  "keywords": [
6
6
  "build",
@@ -82,41 +82,40 @@
82
82
  "@octokit/rest": "21.1.1",
83
83
  "@phun-ky/typeof": "1.2.8",
84
84
  "async-retry": "1.3.3",
85
- "c12": "3.0.4",
86
- "ci-info": "^4.2.0",
85
+ "c12": "3.1.0",
86
+ "ci-info": "^4.3.0",
87
87
  "eta": "3.5.0",
88
88
  "git-url-parse": "16.1.0",
89
- "inquirer": "12.6.3",
89
+ "inquirer": "12.7.0",
90
90
  "issue-parser": "7.0.1",
91
- "lodash.get": "4.4.2",
92
91
  "lodash.merge": "4.6.2",
93
92
  "mime-types": "3.0.1",
94
93
  "new-github-release-url": "2.0.0",
95
- "open": "10.1.2",
94
+ "open": "10.2.0",
96
95
  "ora": "8.2.0",
97
96
  "os-name": "6.1.0",
98
97
  "proxy-agent": "6.5.0",
99
98
  "semver": "7.7.2",
100
99
  "tinyglobby": "0.2.14",
101
- "undici": "6.21.2",
100
+ "undici": "6.21.3",
102
101
  "url-join": "5.0.0",
103
102
  "wildcard-match": "5.1.4",
104
103
  "yargs-parser": "21.1.1"
105
104
  },
106
105
  "devDependencies": {
107
- "@eslint/compat": "1.2.9",
106
+ "@eslint/compat": "1.3.1",
108
107
  "@eslint/eslintrc": "3.3.1",
109
- "@eslint/js": "9.27.0",
108
+ "@eslint/js": "9.31.0",
110
109
  "@octokit/request-error": "6.1.8",
111
110
  "@types/node": "20.17.32",
112
- "eslint": "9.27.0",
113
- "eslint-plugin-import-x": "4.13.3",
114
- "globals": "16.2.0",
111
+ "eslint": "9.31.0",
112
+ "eslint-plugin-import-x": "4.16.1",
113
+ "globals": "16.3.0",
115
114
  "installed-check": "9.3.0",
116
- "knip": "5.59.1",
115
+ "knip": "5.61.3",
117
116
  "mentoss": "0.11.0",
118
117
  "mock-stdio": "1.0.3",
119
- "prettier": "3.5.3",
118
+ "prettier": "3.6.2",
120
119
  "remark-cli": "12.0.1",
121
120
  "remark-preset-webpro": "1.1.1",
122
121
  "tar": "7.4.3",
package/test/utils.js CHANGED
@@ -3,7 +3,7 @@ import test from 'node:test';
3
3
  import assert from 'node:assert/strict';
4
4
  import { stripVTControlCharacters } from 'node:util';
5
5
  import mockStdIo from 'mock-stdio';
6
- import { format, truncateLines, parseGitUrl, parseVersion } from '../lib/util.js';
6
+ import { format, truncateLines, parseGitUrl, parseVersion, get } from '../lib/util.js';
7
7
 
8
8
  test('format', () => {
9
9
  assert.equal(format('release v${version}', { version: '1.0.0' }), 'release v1.0.0');
@@ -96,3 +96,53 @@ test('parseVersion', () => {
96
96
  assert.deepEqual(parseVersion('1.0.0-next.1'), { version: '1.0.0-next.1', isPreRelease: true, preReleaseId: 'next' });
97
97
  assert.deepEqual(parseVersion('21.04.1'), { version: '21.04.1', isPreRelease: false, preReleaseId: null });
98
98
  });
99
+
100
+ const sample = {
101
+ root: {
102
+ level1: {
103
+ level2: {
104
+ value: 'nested'
105
+ },
106
+ array: [
107
+ { id: 1, data: 'first' },
108
+ { id: 2, data: 'second' }
109
+ ],
110
+ 'key.with.dot': {
111
+ special: true
112
+ }
113
+ },
114
+ mixed: [
115
+ { deep: { value: 100 } },
116
+ { deep: { value: 200 } }
117
+ ],
118
+ }
119
+ };
120
+
121
+ test('get: accesses a simple nested property', () => {
122
+ assert.equal(get(sample, 'root.level1.level2.value'), 'nested');
123
+ });
124
+
125
+ test('get: accesses array elements by index', () => {
126
+ assert.equal(get(sample, 'root.level1.array[0].data'), 'first');
127
+ assert.equal(get(sample, 'root.level1.array[1].id'), 2);
128
+ });
129
+
130
+ test('get: accesses keys with dots using bracket notation', () => {
131
+ assert.equal(get(sample, 'root.level1["key.with.dot"].special'), true);
132
+ });
133
+
134
+ test('get: navigates mixed objects and arrays', () => {
135
+ assert.equal(get(sample, 'root.mixed[0].deep.value'), 100);
136
+ assert.equal(get(sample, 'root.mixed[1].deep.value'), 200);
137
+ });
138
+
139
+ test('get: returns default value for non-existent properties', () => {
140
+ assert.equal(get(sample, 'root.level1.unknown', 'default'), 'default');
141
+ assert.equal(get(sample, 'root.level1.array[10].id', null), null);
142
+ });
143
+
144
+ test('get: handles empty path and null/undefined objects', () => {
145
+ assert.equal(get(sample, '', 'default'), 'default');
146
+ assert.equal(get(null, 'any.path', 'default'), 'default');
147
+ assert.equal(get(undefined, 'any.path', 'default'), 'default');
148
+ });