Skip to content

Commit 0c6cd36

Browse files
committed
✨ feat: add new monorepo params to work with monorepo
refs: https://github.com/dhoulb/multi-semantic-release#npm-invalid-npm-token
1 parent 568de97 commit 0c6cd36

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

packages/release-config/src/createConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export const createConfig = (options?: Options): SemRelOptions => {
1717
...options,
1818
};
1919
// npm config
20-
const { npmPublish, pkgRoot, tarballDir } = opts;
21-
const npmConfig = npm({ npmPublish, pkgRoot, tarballDir });
20+
const { npmPublish, pkgRoot, tarballDir, monorepo } = opts;
21+
const npmConfig = npm({ npmPublish, pkgRoot, tarballDir, monorepo });
2222

2323
// github config
2424
const {

packages/release-config/src/plugins/npm.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ import type { NPMPluginOpts } from '../type';
33

44
// eslint-disable-next-line @typescript-eslint/no-unused-vars
55
const npm = (options?: NPMPluginOpts): PluginSpec => {
6+
// if using monorepo, use "@semrel-extra/npm" instead of the official package
7+
// https://github.com/dhoulb/multi-semantic-release#npm-invalid-npm-token
8+
const pkg = options?.monorepo ? '@semrel-extra/npm' : '@semantic-release/npm';
9+
610
if (
711
!options ||
812
(typeof options.pkgRoot !== 'string' &&
913
typeof options.npmPublish !== 'boolean' &&
1014
typeof options.tarballDir === 'undefined')
1115
)
12-
return '@semantic-release/npm';
16+
return pkg;
1317

14-
return ['@semantic-release/npm', options];
18+
return [pkg, options];
1519
};
1620

1721
export default npm;

packages/release-config/src/type.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,15 @@ export interface NPMPluginOpts {
104104
*/
105105
npmPublish?: boolean;
106106
/**
107-
*Directory path to publish.
107+
* Directory path to publish.
108108
* default: `.`
109109
*/
110110
pkgRoot?: string;
111111
tarballDir?: string | false;
112+
/**
113+
* 如果是 Monorepo 仓库发布npm包,使用 "@semrel-extra/npm" 替代官方包
114+
* if using monorepo, use "@semrel-extra/npm" instead of the official package
115+
* @see https://github.com/dhoulb/multi-semantic-release#npm-invalid-npm-token
116+
*/
117+
monorepo?: boolean;
112118
}

0 commit comments

Comments
 (0)