Skip to content

Commit

Permalink
✨ feat: add new monorepo params to work with monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Dec 23, 2022
1 parent 568de97 commit 0c6cd36
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/release-config/src/createConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export const createConfig = (options?: Options): SemRelOptions => {
...options,
};
// npm config
const { npmPublish, pkgRoot, tarballDir } = opts;
const npmConfig = npm({ npmPublish, pkgRoot, tarballDir });
const { npmPublish, pkgRoot, tarballDir, monorepo } = opts;
const npmConfig = npm({ npmPublish, pkgRoot, tarballDir, monorepo });

// github config
const {
Expand Down
8 changes: 6 additions & 2 deletions packages/release-config/src/plugins/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ import type { NPMPluginOpts } from '../type';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const npm = (options?: NPMPluginOpts): PluginSpec => {
// if using monorepo, use "@semrel-extra/npm" instead of the official package
// https://github.com/dhoulb/multi-semantic-release#npm-invalid-npm-token
const pkg = options?.monorepo ? '@semrel-extra/npm' : '@semantic-release/npm';

if (
!options ||
(typeof options.pkgRoot !== 'string' &&
typeof options.npmPublish !== 'boolean' &&
typeof options.tarballDir === 'undefined')
)
return '@semantic-release/npm';
return pkg;

return ['@semantic-release/npm', options];
return [pkg, options];
};

export default npm;
8 changes: 7 additions & 1 deletion packages/release-config/src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,15 @@ export interface NPMPluginOpts {
*/
npmPublish?: boolean;
/**
*Directory path to publish.
* Directory path to publish.
* default: `.`
*/
pkgRoot?: string;
tarballDir?: string | false;
/**
* 如果是 Monorepo 仓库发布npm包,使用 "@semrel-extra/npm" 替代官方包
* if using monorepo, use "@semrel-extra/npm" instead of the official package
* @see https://github.com/dhoulb/multi-semantic-release#npm-invalid-npm-token
*/
monorepo?: boolean;
}

0 comments on commit 0c6cd36

Please sign in to comment.