Skip to content

Commit

Permalink
refactor(packages): replace lodash with es-toolkit
Browse files Browse the repository at this point in the history
BREAKING CHANGE: replace lodash with es-toolkit
  • Loading branch information
JonasSchubert committed Dec 9, 2024
1 parent e981f90 commit 38216c1
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 36 deletions.
18 changes: 11 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
"contributors": [],
"license": "MIT",
"dependencies": {
"es-toolkit": "^1.29.0",
"execa": "^9.5.2",
"got": "^14.4.5",
"hpagent": "^1.2.0",
"lodash": "^4.17.21",
"url": "^0.11.4"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion plugins/custom-changelog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
| --- | --- | --- | --- |
| `customChangelog` | The path to the custom changelog file. | `yes` | `changelog.json`|
| `fileType` | The supported file type. | `yes` | `json`|
| `filter` | The filter to evaluate which commits shall be added to the custom changelog. Use a lodash template. | `yes` | `<% if (body?.startsWith('CUSTOM CHANGELOG:')) { body.replace('CUSTOM CHANGELOG:') } %>`|
| `filter` | The filter to evaluate which commits shall be added to the custom changelog. Use a [es-toolkit template](https://es-toolkit.slash.page/reference/compat/string/template.html#template). | `yes` | `<% if (body?.startsWith('CUSTOM CHANGELOG:')) { body.replace('CUSTOM CHANGELOG:') } %>`|
| `locale` | The locale is used to format the date for the custom changelog entry. | `yes` | `de`|
16 changes: 10 additions & 6 deletions plugins/custom-changelog/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/custom-changelog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"type": "module",
"dependencies": {
"@semantic-release/error": "^4.0.0",
"lodash": "^4.17.21"
"es-toolkit": "^1.29.0"
}
}
4 changes: 2 additions & 2 deletions plugins/custom-changelog/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import SemanticReleaseError from '@semantic-release/error';
import fs from 'node:fs';
import path from 'node:path';
import resolveOptions from './resolve-options.js';
import _ from 'lodash';
import { template } from 'es-toolkit/compat';

export default async (options, context) => {
const { commits, env: { CUSTOM_CHANGELOG_ENABLED }, logger } = context;
Expand All @@ -18,7 +18,7 @@ export default async (options, context) => {
// Format to expected format
.map((commit) => ({
date: new Date(commit.committerDate).toLocaleDateString(locale),
description: [_.template(filter)(commit)]
description: [template(filter)(commit)]
}))
// Remove empty descriptions
.filter(({ description }) => !!description[0])
Expand Down
20 changes: 12 additions & 8 deletions plugins/nuget/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions plugins/nuget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "module",
"dependencies": {
"@semantic-release/error": "4.0.0",
"execa": "^9.5.2",
"lodash": "^4.17.21"
"es-toolkit": "^1.29.0",
"execa": "^9.5.2"
}
}
12 changes: 6 additions & 6 deletions plugins/nuget/resolve-options.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import _ from 'lodash';
import { template } from 'es-toolkit/compat';

/**
* @param {{ apiKey: string | undefined; configuration: string; output: string; password: string | undefined; source: string | undefined; url: string | undefined; username: string | undefined }} options The plugin options.
* @param {*} context The semantic release context.
* @returns {{ apiKey: string | undefined; configuration: string; output: string; password: string | undefined; source: string | undefined; url: string | undefined; username: string | undefined }}
*/
export default (options, context) => ({
apiKey: _.template(options.apiKey)(context),
apiKey: template(options.apiKey)(context),
configuration: options.configuration || 'Release',
output: context.env.output || 'output',
password: _.template(options.password)(context),
source: _.template(options.source)(context),
url: _.template(options.url)(context),
username: _.template(options.username)(context)
password: template(options.password)(context),
source: template(options.source)(context),
url: template(options.url)(context),
username: template(options.username)(context)
});
4 changes: 2 additions & 2 deletions plugins/nuget/verifyConditions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import _ from 'lodash';
import { execa } from 'execa';
import { isString } from 'es-toolkit';
import resolveOptions from './resolve-options.js';

const isNonEmptyString = (value) => _.isString(value) && value.trim();
const isNonEmptyString = (value) => isString(value) && value.trim();

export default async (options, context) => {
const resolvedOptions = resolveOptions(options, context);
Expand Down

0 comments on commit 38216c1

Please sign in to comment.