diff --git a/README.md b/README.md index f16d216..78f9243 100644 --- a/README.md +++ b/README.md @@ -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..6b43c60 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, @@ -228,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) @@ -252,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 () => { @@ -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,