From 608bce114d8c060b27be0a561bde2eb30ed0b791 Mon Sep 17 00:00:00 2001 From: dvirtz Date: Sun, 1 Dec 2024 21:50:53 +0000 Subject: [PATCH 1/3] feat: add pattern option resolves "Provide minimatch patterns support for `src` option as `gh-pages` does" #110 --- README.md | 21 +++++++++++---------- src/main/ts/config.ts | 7 ++++++- src/main/ts/defaults.ts | 1 + src/main/ts/ghpages.ts | 5 +++-- src/main/ts/interface.ts | 1 + src/test/ts/config.ts | 13 +++++++++---- src/test/ts/index.ts | 8 ++++++-- 7 files changed, 37 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index f16d216..de94772 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# @qiwi/semantic-release-gh-pages-plugin +# @wiki/semantic-release-gh-pages-plugin -[![CI](https://github.com/qiwi/semantic-release-gh-pages-plugin/workflows/CI/badge.svg)](https://github.com/qiwi/semantic-release-gh-pages-plugin/actions) -[![Test Coverage](https://api.codeclimate.com/v1/badges/c149b0666dda28813aa4/test_coverage)](https://codeclimate.com/github/qiwi/semantic-release-gh-pages-plugin/test_coverage) -[![Maintainability](https://api.codeclimate.com/v1/badges/c149b0666dda28813aa4/maintainability)](https://codeclimate.com/github/qiwi/semantic-release-gh-pages-plugin/maintainability) -[![npm (tag)](https://img.shields.io/npm/v/@qiwi/semantic-release-gh-pages-plugin/latest.svg)](https://www.npmjs.com/package/@qiwi/semantic-release-gh-pages-plugin) +[![CI](https://github.com/wiki/semantic-release-gh-pages-plugin/workflows/CI/badge.svg)](https://github.com/wiki/semantic-release-gh-pages-plugin/actions) +[![Test Coverage](https://api.codeclimate.com/v1/badges/c149b0666dda28813aa4/test_coverage)](https://codeclimate.com/github/wiki/semantic-release-gh-pages-plugin/test_coverage) +[![Maintainability](https://api.codeclimate.com/v1/badges/c149b0666dda28813aa4/maintainability)](https://codeclimate.com/github/wiki/semantic-release-gh-pages-plugin/maintainability) +[![npm (tag)](https://img.shields.io/npm/v/@wiki/semantic-release-gh-pages-plugin/latest.svg)](https://www.npmjs.com/package/@wiki/semantic-release-gh-pages-plugin) gh-pages publishing plugin for [semantic-release](https://github.com/semantic-release/semantic-release) @@ -15,9 +15,9 @@ gh-pages publishing plugin for [semantic-release](https://github.com/semantic-re ## Install ```bash # yarn -yarn add @qiwi/semantic-release-gh-pages-plugin --dev +yarn add @wiki/semantic-release-gh-pages-plugin --dev # npm -npm i @qiwi/semantic-release-gh-pages-plugin -D +npm i @wiki/semantic-release-gh-pages-plugin -D ``` ## Usage @@ -30,13 +30,13 @@ Describe plugin configuration in [package.json / .releaserc.js](https://github.c "@semantic-release/changelog", "@semantic-release/npm", "@semantic-release/git", - "@qiwi/semantic-release-gh-pages-plugin" + "@wiki/semantic-release-gh-pages-plugin" ], "publish": [ "@semantic-release/npm", "@semantic-release/github", [ - "@qiwi/semantic-release-gh-pages-plugin", + "@wiki/semantic-release-gh-pages-plugin", { "msg": "updated", "branch": "docs" @@ -57,7 +57,7 @@ or even shorter if default settings are used: "@semantic-release/git", "@semantic-release/github", "@semantic-release/npm", - "@qiwi/semantic-release-gh-pages-plugin" + "@wiki/semantic-release-gh-pages-plugin" ] } } @@ -84,6 +84,7 @@ or even shorter if default settings are used: | `pullTagsBranch` | Target branch for tags fetching hook. If '' empty string, skips this action | `globalConfig.branch` \|\| `master` | | `dotfiles` | gh-pages [dotfiles](https://github.com/tschaub/gh-pages#optionsdotfiles) option | `false` | | `add` | gh-pages [add](https://github.com/tschaub/gh-pages#optionsadd) option | `false` | +| `pattern` | gh-pages [src](https://github.com/tschaub/gh-pages#optionssrc) option | `**/*` | ## License [MIT](./LICENSE) diff --git a/src/main/ts/config.ts b/src/main/ts/config.ts index 9003df3..2f0431c 100644 --- a/src/main/ts/config.ts +++ b/src/main/ts/config.ts @@ -12,6 +12,7 @@ import { DEFAULT_DST, DEFAULT_ENTERPRISE, DEFAULT_MSG, + DEFAULT_PATTERN, DEFAULT_PULL_TAGS_BRANCH, DEFAULT_SRC, PLUGIN_PATH} from './defaults' @@ -27,7 +28,8 @@ export { DEFAULT_DST, DEFAULT_ENTERPRISE, PLUGIN_PATH, - DEFAULT_PULL_TAGS_BRANCH + DEFAULT_PULL_TAGS_BRANCH, + DEFAULT_PATTERN, } from './defaults' const gitUrlParse = catchToSmth(gitParse, {}) @@ -132,6 +134,7 @@ export const resolveConfig = async (pluginConfig: TAnyMap, context: TContext, pa msg = DEFAULT_MSG, src = DEFAULT_SRC, dst = DEFAULT_DST, + pattern = DEFAULT_PATTERN, add, dotfiles } = opts @@ -149,6 +152,7 @@ export const resolveConfig = async (pluginConfig: TAnyMap, context: TContext, pa debug('ciBranch= %s', ciBranch) debug('docsBranch= %s', docsBranch) debug('pullTagsBranch= %s', pullTagsBranch) + debug('pattern = %s', pattern) return { src, @@ -162,6 +166,7 @@ export const resolveConfig = async (pluginConfig: TAnyMap, context: TContext, pa token, add, dotfiles, + pattern, } } diff --git a/src/main/ts/defaults.ts b/src/main/ts/defaults.ts index 9857d9f..e7ce1ac 100644 --- a/src/main/ts/defaults.ts +++ b/src/main/ts/defaults.ts @@ -7,3 +7,4 @@ export const DEFAULT_DST = '.' export const DEFAULT_MSG = 'docs updated <%= nextRelease.gitTag %>' export const DEFAULT_ENTERPRISE = false export const DEFAULT_PULL_TAGS_BRANCH = 'master' +export const DEFAULT_PATTERN = '**/*' diff --git a/src/main/ts/ghpages.ts b/src/main/ts/ghpages.ts index 2e8392a..c7cccb8 100644 --- a/src/main/ts/ghpages.ts +++ b/src/main/ts/ghpages.ts @@ -40,7 +40,7 @@ export const pullTags = (opts: IPushOpts): Promise => { * @private */ export const pushPages = (opts: IPushOpts) => new Promise((resolve, reject) => { - const { src, logger , repo, docsBranch, dst, message, add, dotfiles} = opts + const { src, logger , repo, docsBranch, dst, message, add, dotfiles, pattern } = opts const ghpagesOpts: PublishOptions = { repo, branch: docsBranch, @@ -48,6 +48,7 @@ export const pushPages = (opts: IPushOpts) => new Promise((resolve, reject) => { message, add, dotfiles, + src: pattern, } ghpagePublish(src, ghpagesOpts, (err?: any) => { @@ -56,7 +57,7 @@ export const pushPages = (opts: IPushOpts) => new Promise((resolve, reject) => { reject(err) } else { - logger.log(`Docs published successfully, branch=${ghpagesOpts.branch}, src=${src}, dst=${ghpagesOpts.dest}`) + logger.log(`Docs published successfully, branch=${ghpagesOpts.branch}, src=${src}, pattern=${ghpagesOpts.src}, dst=${ghpagesOpts.dest}`) resolve(OK) } }) diff --git a/src/main/ts/interface.ts b/src/main/ts/interface.ts index f87bedc..4479599 100644 --- a/src/main/ts/interface.ts +++ b/src/main/ts/interface.ts @@ -38,6 +38,7 @@ export interface IGhpagesPluginConfig { enterprise?: boolean, dotfiles?: boolean add?: boolean + pattern?: string, } export interface IPushOpts extends IGhpagesPluginConfig { diff --git a/src/test/ts/config.ts b/src/test/ts/config.ts index 430a668..b774502 100644 --- a/src/test/ts/config.ts +++ b/src/test/ts/config.ts @@ -5,6 +5,7 @@ import { DEFAULT_MSG, DEFAULT_PULL_TAGS_BRANCH, DEFAULT_SRC, + DEFAULT_PATTERN, // getRepo, extractRepoDomain, extractRepoName, @@ -141,7 +142,8 @@ describe('config', () => { msg: 'doc update', token, repo: `https://${token}@enterprise.com/org/repo.git`, - pullTagsBranch: 'dev' + pullTagsBranch: 'dev', + pattern: DEFAULT_PATTERN, }) }) @@ -188,7 +190,8 @@ describe('config', () => { msg: 'doc update', token, repo: `https://${token}@enterprise.com/org/repo.git`, - pullTagsBranch: 'foo' + pullTagsBranch: 'foo', + pattern: DEFAULT_PATTERN, }) }) @@ -227,7 +230,8 @@ describe('config', () => { src: DEFAULT_SRC, token, repo: repositoryUrl, - pullTagsBranch: DEFAULT_PULL_TAGS_BRANCH + pullTagsBranch: DEFAULT_PULL_TAGS_BRANCH, + pattern: DEFAULT_PATTERN, }) }) @@ -328,7 +332,8 @@ describe('config', () => { src: 'dist/web', token: 'secure', repo: `https://secure@github-enterprise-repo-url.com/foo/bar.git`, - pullTagsBranch: DEFAULT_PULL_TAGS_BRANCH + pullTagsBranch: DEFAULT_PULL_TAGS_BRANCH, + pattern: DEFAULT_PATTERN, }) }) }) diff --git a/src/test/ts/index.ts b/src/test/ts/index.ts index 865acab..6d4f5be 100644 --- a/src/test/ts/index.ts +++ b/src/test/ts/index.ts @@ -10,6 +10,7 @@ import { DEFAULT_MSG, DEFAULT_PULL_TAGS_BRANCH, DEFAULT_SRC, + DEFAULT_PATTERN, PLUGIN_PATH } from '../../main/ts' import { getUrlFromPackage } from '../../main/ts/config' @@ -84,6 +85,7 @@ describe('index', () => { msg: DEFAULT_MSG, dst: DEFAULT_DST, src: DEFAULT_SRC, + pattern: DEFAULT_PATTERN, enterprise: DEFAULT_ENTERPRISE, repo: await getRepoUrl(pluginConfig, context, DEFAULT_ENTERPRISE), token, @@ -203,7 +205,8 @@ describe('index', () => { repo: await getRepoUrl(pluginConfig, context, false), branch: 'doc-branch', message: 'docs updated v{{=it.nextRelease.gitTag}}', - dest: 'root' + dest: 'root', + src: DEFAULT_PATTERN, } const execaOpts = { cwd, @@ -275,7 +278,8 @@ describe('index', () => { repo: await getRepoUrl(pluginConfig, context, false), branch: DEFAULT_BRANCH, message: DEFAULT_MSG, - dest: DEFAULT_DST + dest: DEFAULT_DST, + src: DEFAULT_PATTERN, } const expected = { src: DOCS_ERR, From e15ad9c8930061baacd8e8f6df8f9223b7b5eca6 Mon Sep 17 00:00:00 2001 From: dvirtz Date: Thu, 5 Dec 2024 18:11:11 +0000 Subject: [PATCH 2/3] test: fix failing tests --- src/test/ts/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/ts/index.ts b/src/test/ts/index.ts index 6d4f5be..6b43c60 100644 --- a/src/test/ts/index.ts +++ b/src/test/ts/index.ts @@ -231,7 +231,7 @@ describe('index', () => { ) expect(log).toHaveBeenCalledWith('Publishing docs via gh-pages') - expect(log).toHaveBeenCalledWith('Docs published successfully, branch=doc-branch, src=docs, dst=root') + expect(log).toHaveBeenCalledWith(`Docs published successfully, branch=doc-branch, src=docs, pattern=${DEFAULT_PATTERN}, dst=root`) expect(ghpagesPublish).toHaveBeenCalledWith(DEFAULT_SRC, expectedOpts, expect.any(Function)) expect(res).toBe(OK) @@ -255,7 +255,7 @@ describe('index', () => { await publish(pluginConfig, context) expect(log).toHaveBeenCalledWith('Publishing docs via gh-pages') - expect(log).toHaveBeenCalledWith('Docs published successfully, branch=gh-pages, src=docs, dst=.') + expect(log).toHaveBeenCalledWith(`Docs published successfully, branch=gh-pages, src=docs, pattern=${DEFAULT_PATTERN}, dst=.`) }) it('throws rejection on gh-pages fail', async () => { From 40d478c7b35933c51798eb8d6c2b0cecc31bf6d1 Mon Sep 17 00:00:00 2001 From: dvirtz Date: Thu, 5 Dec 2024 21:26:29 +0000 Subject: [PATCH 3/3] chore: undo scope change --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index de94772..78f9243 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# @wiki/semantic-release-gh-pages-plugin +# @qiwi/semantic-release-gh-pages-plugin -[![CI](https://github.com/wiki/semantic-release-gh-pages-plugin/workflows/CI/badge.svg)](https://github.com/wiki/semantic-release-gh-pages-plugin/actions) -[![Test Coverage](https://api.codeclimate.com/v1/badges/c149b0666dda28813aa4/test_coverage)](https://codeclimate.com/github/wiki/semantic-release-gh-pages-plugin/test_coverage) -[![Maintainability](https://api.codeclimate.com/v1/badges/c149b0666dda28813aa4/maintainability)](https://codeclimate.com/github/wiki/semantic-release-gh-pages-plugin/maintainability) -[![npm (tag)](https://img.shields.io/npm/v/@wiki/semantic-release-gh-pages-plugin/latest.svg)](https://www.npmjs.com/package/@wiki/semantic-release-gh-pages-plugin) +[![CI](https://github.com/qiwi/semantic-release-gh-pages-plugin/workflows/CI/badge.svg)](https://github.com/qiwi/semantic-release-gh-pages-plugin/actions) +[![Test Coverage](https://api.codeclimate.com/v1/badges/c149b0666dda28813aa4/test_coverage)](https://codeclimate.com/github/qiwi/semantic-release-gh-pages-plugin/test_coverage) +[![Maintainability](https://api.codeclimate.com/v1/badges/c149b0666dda28813aa4/maintainability)](https://codeclimate.com/github/qiwi/semantic-release-gh-pages-plugin/maintainability) +[![npm (tag)](https://img.shields.io/npm/v/@qiwi/semantic-release-gh-pages-plugin/latest.svg)](https://www.npmjs.com/package/@qiwi/semantic-release-gh-pages-plugin) gh-pages publishing plugin for [semantic-release](https://github.com/semantic-release/semantic-release) @@ -15,9 +15,9 @@ gh-pages publishing plugin for [semantic-release](https://github.com/semantic-re ## Install ```bash # yarn -yarn add @wiki/semantic-release-gh-pages-plugin --dev +yarn add @qiwi/semantic-release-gh-pages-plugin --dev # npm -npm i @wiki/semantic-release-gh-pages-plugin -D +npm i @qiwi/semantic-release-gh-pages-plugin -D ``` ## Usage @@ -30,13 +30,13 @@ Describe plugin configuration in [package.json / .releaserc.js](https://github.c "@semantic-release/changelog", "@semantic-release/npm", "@semantic-release/git", - "@wiki/semantic-release-gh-pages-plugin" + "@qiwi/semantic-release-gh-pages-plugin" ], "publish": [ "@semantic-release/npm", "@semantic-release/github", [ - "@wiki/semantic-release-gh-pages-plugin", + "@qiwi/semantic-release-gh-pages-plugin", { "msg": "updated", "branch": "docs" @@ -57,7 +57,7 @@ or even shorter if default settings are used: "@semantic-release/git", "@semantic-release/github", "@semantic-release/npm", - "@wiki/semantic-release-gh-pages-plugin" + "@qiwi/semantic-release-gh-pages-plugin" ] } }