@cmflow/cli 0.76.0 → 0.76.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/bin/cm-changelog.js +2 -3
  2. package/bin/cm-clean.js +2 -3
  3. package/bin/cm-config.js +3 -4
  4. package/bin/cm-deploy.js +2 -3
  5. package/bin/cm-fetch.js +2 -3
  6. package/bin/cm-finish.js +2 -3
  7. package/bin/cm-merge.js +2 -3
  8. package/bin/cm-publish-pages.js +2 -3
  9. package/bin/cm-publish.js +2 -3
  10. package/bin/cm-push.js +2 -3
  11. package/bin/cm-rebase.js +2 -3
  12. package/bin/cm-republish.js +2 -3
  13. package/bin/cm-start.js +2 -3
  14. package/bin/cm.js +2 -7
  15. package/bin/cmrelease.js +1 -3
  16. package/package.json +17 -15
  17. package/release.config.js +1 -1
  18. package/semantic.js +1 -1
  19. package/src/commands/clean.js +2 -1
  20. package/src/commands/config.js +1 -1
  21. package/src/commands/deploy.js +2 -2
  22. package/src/commands/fetch.js +1 -1
  23. package/src/commands/finish.js +3 -3
  24. package/src/commands/index.js +11 -11
  25. package/src/commands/merge.js +2 -2
  26. package/src/commands/prompts/branches.js +1 -1
  27. package/src/commands/publish-pages.js +1 -1
  28. package/src/commands/push.js +2 -2
  29. package/src/commands/rebase.js +5 -5
  30. package/src/commands/release.js +18 -2
  31. package/src/commands/republish.js +2 -2
  32. package/src/commands/start.js +5 -5
  33. package/src/commands/tasks/merge-branch.js +1 -1
  34. package/src/commands/tasks/push-branch.js +1 -1
  35. package/src/commands/tasks/rebase-all-branches.js +1 -1
  36. package/src/commands/tasks/refresh-repository.js +3 -2
  37. package/src/commands/tasks/run-test.js +1 -1
  38. package/src/commands/tasks/update-branch.js +1 -1
  39. package/src/commands/tasks/update-dependencies.js +3 -3
  40. package/src/commands/utils/check-install.js +3 -2
  41. package/src/common/cli/cli.js +4 -2
  42. package/src/common/cli/docker.js +1 -1
  43. package/src/common/cli/docker.test.js +6 -13
  44. package/src/common/cli/git.js +1 -1
  45. package/src/common/cli/git.test.js +5 -9
  46. package/src/common/cli/heroku.js +1 -1
  47. package/src/common/cli/heroku.test.js +4 -10
  48. package/src/common/cli/lerna.js +1 -1
  49. package/src/common/cli/lerna.test.js +4 -9
  50. package/src/common/cli/npm.js +4 -4
  51. package/src/common/cli/npm.test.js +4 -10
  52. package/src/common/cli/yarn.js +4 -4
  53. package/src/common/cli/yarn.test.js +4 -9
  54. package/src/common/configure-git-workspace.js +1 -1
  55. package/src/common/get-config.js +24 -4
  56. package/src/common/index.js +10 -10
  57. package/src/common/run-command.js +2 -2
  58. package/src/common/run-command.test.js +4 -8
  59. package/src/index.js +1 -1
  60. package/src/main.js +5 -5
  61. package/src/semantic-release/actions/analyze-commits.js +2 -4
  62. package/src/semantic-release/actions/fail.js +2 -2
  63. package/src/semantic-release/actions/generate-notes.js +2 -3
  64. package/src/semantic-release/actions/index.js +8 -8
  65. package/src/semantic-release/actions/prepare.js +3 -5
  66. package/src/semantic-release/actions/publish.js +3 -3
  67. package/src/semantic-release/actions/success.js +3 -5
  68. package/src/semantic-release/actions/verify-conditions.js +2 -3
  69. package/src/semantic-release/actions/verify-release.js +2 -4
  70. package/src/semantic-release/get-semantic-config.js +2 -2
  71. package/src/semantic-release/utils/bump-packages-version.test.js +1 -4
  72. package/src/semantic-release/utils/calculate-snapshot-version.js +1 -1
  73. package/src/semantic-release/utils/calculate-snapshot-version.test.js +3 -10
  74. package/src/semantic-release/utils/display-package-info.js +1 -1
  75. package/src/semantic-release/utils/display-release-info.js +1 -1
  76. package/src/semantic-release/utils/docker-clean-tags.js +1 -1
  77. package/src/semantic-release/utils/docker-clean-tags.test.js +3 -12
  78. package/src/semantic-release/utils/docker-publish.js +2 -5
  79. package/src/semantic-release/utils/docker-publish.test.js +17 -33
  80. package/src/semantic-release/utils/ghpages-publish.js +1 -1
@@ -1,4 +1,4 @@
1
- import { Cli } from './cli.js'
1
+ import { Cli } from './cli'
2
2
 
3
3
  class LernaCli extends Cli {
4
4
  constructor () {
@@ -1,13 +1,8 @@
1
- import { beforeEach, describe, expect, it, jest } from '@jest/globals'
1
+ import execa from 'execa'
2
+ import { lerna } from './lerna'
3
+ import { Cli } from './cli'
2
4
 
3
- jest.unstable_mockModule('execa', () => {
4
- const execaMock = jest.fn()
5
- execaMock.sync = jest.fn()
6
- return { default: execaMock }
7
- })
8
- const { default: execa } = await import('execa')
9
- const { lerna } = await import('./lerna.js')
10
- const { Cli } = await import('./cli.js')
5
+ jest.mock('execa')
11
6
 
12
7
  execa.sync.mockImplementation((...args) => {
13
8
  return {
@@ -1,4 +1,4 @@
1
- import { Cli } from './cli.js'
1
+ import { Cli } from './cli'
2
2
 
3
3
  class NpmCli extends Cli {
4
4
  constructor () {
@@ -22,9 +22,9 @@ class NpmCli extends Cli {
22
22
  }
23
23
 
24
24
  /**
25
- * Reinstall dependencies without package-lock mutation
26
- * @returns {Promise<unknown>}
27
- */
25
+ * Reinstall dependencies without package-lock mutation
26
+ * @returns {Promise<unknown>}
27
+ */
28
28
  restore () {
29
29
  return super.run('ci')
30
30
  }
@@ -1,14 +1,8 @@
1
- import { beforeEach, describe, expect, it, jest } from '@jest/globals'
1
+ import execa from 'execa'
2
+ import { npm } from './npm'
3
+ import { Cli } from './cli'
2
4
 
3
- jest.unstable_mockModule('execa', () => {
4
- const execaMock = jest.fn()
5
- execaMock.sync = jest.fn()
6
- return { default: execaMock }
7
- })
8
-
9
- const { default: execa } = await import('execa')
10
- const { npm } = await import('./npm.js')
11
- const { Cli } = await import('./cli.js')
5
+ jest.mock('execa')
12
6
 
13
7
  execa.sync.mockImplementation((...args) => {
14
8
  return {
@@ -1,4 +1,4 @@
1
- import { Cli } from './cli.js'
1
+ import { Cli } from './cli'
2
2
 
3
3
  class YarnCli extends Cli {
4
4
  constructor () {
@@ -22,9 +22,9 @@ class YarnCli extends Cli {
22
22
  }
23
23
 
24
24
  /**
25
- * Reinstall dependencies without yarn.lock mutation
26
- * @returns {Promise<unknown>}
27
- */
25
+ * Reinstall dependencies without yarn.lock mutation
26
+ * @returns {Promise<unknown>}
27
+ */
28
28
  restore () {
29
29
  return super.run('install', '--immutable')
30
30
  }
@@ -1,13 +1,8 @@
1
- import { beforeEach, describe, expect, it, jest } from '@jest/globals'
1
+ import execa from 'execa'
2
+ import { yarn } from './yarn'
3
+ import { Cli } from './cli'
2
4
 
3
- jest.unstable_mockModule('execa', () => {
4
- const execaMock = jest.fn()
5
- execaMock.sync = jest.fn()
6
- return { default: execaMock }
7
- })
8
- const { default: execa } = await import('execa')
9
- const { yarn } = await import('./yarn.js')
10
- const { Cli } = await import('./cli.js')
5
+ jest.mock('execa')
11
6
 
12
7
  execa.sync.mockImplementation((...args) => {
13
8
  return {
@@ -1,4 +1,4 @@
1
- import { git } from './cli/git.js'
1
+ import { git } from './cli/git'
2
2
 
3
3
  export function configureGitWorkspace (context) {
4
4
  const {
@@ -1,7 +1,7 @@
1
1
  import hasYarn from 'has-yarn'
2
- import get from 'lodash/get.js'
3
- import { git } from './cli/git.js'
4
- import { getPackageJson } from './get-package-json.js'
2
+ import { get } from 'lodash'
3
+ import { git } from './cli/git'
4
+ import { getPackageJson } from './get-package-json'
5
5
  import fs from 'fs'
6
6
  import { join } from 'path'
7
7
 
@@ -19,6 +19,26 @@ export function getCI () {
19
19
  GIT_USER_EMAIL
20
20
  } = env
21
21
  if (env.CI) {
22
+ if (env.TRAVIS) {
23
+ const {
24
+ TRAVIS_BUILD_NUMBER,
25
+ TRAVIS_COMMIT,
26
+ TRAVIS_PULL_REQUEST,
27
+ TRAVIS_BRANCH
28
+ } = env
29
+
30
+ return {
31
+ CI_NAME: 'Travis CI',
32
+ USER: GIT_USER_NAME || 'Travis CI',
33
+ EMAIL: GIT_USER_EMAIL || 'travis@travis-ci.org',
34
+ BUILD_NUMBER: TRAVIS_BUILD_NUMBER,
35
+ CI_ORIGIN: 'origin-git',
36
+ REF_COMMIT: TRAVIS_COMMIT,
37
+ IS_PULL_REQUEST: TRAVIS_PULL_REQUEST && TRAVIS_PULL_REQUEST !== 'false',
38
+ BRANCH_NAME: TRAVIS_BRANCH
39
+ }
40
+ }
41
+
22
42
  if (env.GITLAB_CI) {
23
43
  const {
24
44
  CI_BUILD_ID,
@@ -107,7 +127,7 @@ export function getConfig () {
107
127
  HAS_LERNA: pkg.dependencies.lerna || pkg.devDependencies.lerna,
108
128
  HAS_BUILD: pkg.scripts.build,
109
129
  HAS_E2E: !!E2E_CMD,
110
- E2E_CMD,
130
+ E2E_CMD: E2E_CMD,
111
131
  HAS_BUILD_CHANGELOG: pkg.scripts.build_changelog,
112
132
  get DEPLOY_ON_DOCKER () {
113
133
  return toBool(process.env.DEPLOY_ON_DOCKER) && DOCKER_HUB_ID && DOCKER_HUB_PWD
@@ -1,10 +1,10 @@
1
- export * from './cli/cli.js'
2
- export * from './cli/docker.js'
3
- export * from './cli/git.js'
4
- export * from './cli/lerna.js'
5
- export * from './cli/npm.js'
6
- export * from './cli/yarn.js'
7
- export * from './get-config.js'
8
- export * from './configure-git-workspace.js'
9
- export * from './get-package-json.js'
10
- export * from './run-command.js'
1
+ export * from './cli/cli'
2
+ export * from './cli/docker'
3
+ export * from './cli/git'
4
+ export * from './cli/lerna'
5
+ export * from './cli/npm'
6
+ export * from './cli/yarn'
7
+ export * from './get-config'
8
+ export * from './configure-git-workspace'
9
+ export * from './get-package-json'
10
+ export * from './run-command'
@@ -2,8 +2,8 @@ import chalk from 'chalk'
2
2
  import figures from 'figures'
3
3
  import inquirer from 'inquirer'
4
4
  import Listr from 'listr'
5
- import { getReleaseConfig } from './get-release-config.js'
6
- import { getConfig } from './get-config.js'
5
+ import { getReleaseConfig } from './get-release-config'
6
+ import { getConfig } from './get-config'
7
7
 
8
8
  function createTasksRunner (tasks, ctx) {
9
9
  return new Listr(tasks, {
@@ -1,10 +1,7 @@
1
- import { beforeEach, describe, expect, it, jest } from '@jest/globals'
1
+ import Listr from 'listr'
2
+ import { runCommand } from './run-command'
2
3
 
3
- jest.unstable_mockModule('listr', () => {
4
- return { default: jest.fn() }
5
- })
6
- const { default: Listr } = await import('listr')
7
- const { runCommand } = await import('./run-command.js')
4
+ jest.mock('listr')
8
5
 
9
6
  describe('runCommand', () => {
10
7
  beforeEach(() => {
@@ -55,8 +52,7 @@ describe('runCommand', () => {
55
52
  }
56
53
 
57
54
  jest.spyOn(console, 'error').mockReturnValue(undefined)
58
- jest.spyOn(process, 'exit').mockImplementation(() => {
59
- })
55
+ jest.spyOn(process, 'exit').mockImplementation(() => {})
60
56
 
61
57
  await runCommand(Cmd, {
62
58
  prop: '1'
package/src/index.js CHANGED
@@ -1 +1 @@
1
- export * from './main.js'
1
+ module.exports = require('esm')(module)('./main.js')
package/src/main.js CHANGED
@@ -1,9 +1,9 @@
1
- import * as commands from './commands/index.js'
1
+ import * as commands from './commands'
2
2
 
3
- export * from './workflow/index.js'
4
- export * from './common/index.js'
5
- export * from './commands/release.js'
6
- export * from './semantic-release/get-semantic-config.js'
3
+ export * from './workflow'
4
+ export * from './common'
5
+ export * from './commands/release'
6
+ export * from './semantic-release/get-semantic-config'
7
7
 
8
8
  export {
9
9
  commands
@@ -1,11 +1,9 @@
1
- import * as commitAnalyzerPlugins from '@semantic-release/commit-analyzer'
2
- import { calculateSnapshotVersion } from '../utils/calculate-snapshot-version.js'
1
+ import commitAnalyzerPlugins from '@semantic-release/commit-analyzer'
3
2
 
4
3
  export function analyzeCommits (pluginConfig, context) {
5
4
  if (context.branch && context.branch.type !== 'prerelease') {
6
5
  return commitAnalyzerPlugins.analyzeCommits(pluginConfig, context)
7
6
  }
8
- context.nextRelease.version = calculateSnapshotVersion(context)
9
- context.lastRelease.version = null
7
+
10
8
  return 'patch' // always trigger patch for prerelease
11
9
  }
@@ -1,5 +1,5 @@
1
- import * as githubPlugins from '@semantic-release/github'
2
- import { git } from '../../common/index.js'
1
+ import githubPlugins from '@semantic-release/github'
2
+ import { git } from '../../common'
3
3
 
4
4
  export async function fail (pluginConfig, context) {
5
5
  if (context.branch && context.branch.type !== 'prerelease') {
@@ -1,8 +1,7 @@
1
- import * as releaseNotesPlugins from '@semantic-release/release-notes-generator'
2
- import { getConfig, npm, yarn } from '../../common/index.js'
1
+ import releaseNotesPlugins from '@semantic-release/release-notes-generator'
2
+ import { npm, yarn } from '../../common'
3
3
 
4
4
  export async function generateNotes (pluginConfig, context) {
5
- context.config = getConfig()
6
5
  if (context.branch.type === 'release' && !context.config.SKIP_GITHUB_PUBLISH) {
7
6
  if (context.config.HAS_BUILD_CHANGELOG) {
8
7
  await (context.config.HAS_YARN ? yarn : npm).run('build_changelog')
@@ -1,8 +1,8 @@
1
- export * from './verify-conditions.js'
2
- export * from './analyze-commits.js'
3
- export * from './verify-release.js'
4
- export * from './generate-notes.js'
5
- export * from './prepare.js'
6
- export * from './publish.js'
7
- export * from './success.js'
8
- export * from './fail.js'
1
+ export * from './verify-conditions'
2
+ export * from './analyze-commits'
3
+ export * from './verify-release'
4
+ export * from './generate-notes'
5
+ export * from './prepare'
6
+ export * from './publish'
7
+ export * from './success'
8
+ export * from './fail'
@@ -1,9 +1,8 @@
1
- import { dockerPublish } from '../utils/docker-publish.js'
2
- import { configureGitWorkspace, getConfig, git, lerna, npm, yarn } from '../../common/index.js'
3
- import { bumpPackagesVersion } from '../utils/bump-packages-version.js'
1
+ import { dockerPublish } from '../utils/docker-publish'
2
+ import { configureGitWorkspace, git, lerna, npm, yarn } from '../../common'
3
+ import { bumpPackagesVersion } from '../utils/bump-packages-version'
4
4
 
5
5
  async function gitPrepareRelease (pluginConfig, context) {
6
- context.config = getConfig()
7
6
  const {
8
7
  logger,
9
8
  config: {
@@ -29,7 +28,6 @@ async function gitPrepareRelease (pluginConfig, context) {
29
28
  }
30
29
 
31
30
  export async function prepare (pluginConfig, context) {
32
- context.config = getConfig()
33
31
  const {
34
32
  branch,
35
33
  config: {
@@ -1,6 +1,6 @@
1
- import * as githubPlugins from '@semantic-release/github'
2
- import { dockerPublish } from '../utils/docker-publish.js'
3
- import { ghPagesPublish } from '../utils/ghpages-publish.js'
1
+ import githubPlugins from '@semantic-release/github'
2
+ import { dockerPublish } from '../utils/docker-publish'
3
+ import { ghPagesPublish } from '../utils/ghpages-publish'
4
4
 
5
5
  export async function publish (pluginConfig, context) {
6
6
  const { branch, env: { SKIP_GITHUB_PUBLISH, GITHUB_PAGES_PATH } } = context
@@ -1,7 +1,6 @@
1
- import * as githubPlugins from '@semantic-release/github'
2
- import { dockerCleanTags } from '../utils/docker-clean-tags.js'
3
- import { getConfig } from '../../common/get-config.js'
4
- import { git } from '../../common/index.js'
1
+ import githubPlugins from '@semantic-release/github'
2
+ import { dockerCleanTags } from '../utils/docker-clean-tags'
3
+ import { git } from '../../common'
5
4
 
6
5
  async function githubSuccess (pluginConfig, context) {
7
6
  const { logger, config: { PRODUCTION_BRANCH, ORIGIN, DEVELOP_BRANCH } } = context
@@ -17,7 +16,6 @@ async function githubSuccess (pluginConfig, context) {
17
16
  }
18
17
 
19
18
  export async function success (pluginConfig, context) {
20
- context.config = getConfig()
21
19
  const { branch, config: { SKIP_GITHUB_PUBLISH } } = context
22
20
 
23
21
  if (branch.type !== 'prerelease' && !SKIP_GITHUB_PUBLISH) {
@@ -1,9 +1,8 @@
1
1
  import chalk from 'chalk'
2
- import * as githubPlugins from '@semantic-release/github'
3
- import { getConfig, git } from '../../common/index.js'
2
+ import githubPlugins from '@semantic-release/github'
3
+ import { git } from '../../common'
4
4
 
5
5
  export function verifyConditions (pluginConfig, context) {
6
- context.config = getConfig()
7
6
  if (pluginConfig.dryRun) {
8
7
  return
9
8
  }
@@ -1,9 +1,7 @@
1
- import { displayPackageInfo } from '../utils/display-package-info.js'
2
- import { displayReleaseInfo } from '../utils/display-release-info.js'
3
- import { getConfig } from '../../common/index.js'
1
+ import { displayPackageInfo } from '../utils/display-package-info'
2
+ import { displayReleaseInfo } from '../utils/display-release-info'
4
3
 
5
4
  export function verifyRelease (pluginConfig, context) {
6
- context.config = getConfig()
7
5
  displayPackageInfo(context)
8
6
  displayReleaseInfo(context)
9
7
  }
@@ -1,5 +1,5 @@
1
- import { getConfig } from '../common/get-config.js'
2
- import { WORKFLOW_CONFIGURATION } from '../workflow/index.js'
1
+ import { getConfig } from '../common/get-config'
2
+ import { WORKFLOW_CONFIGURATION } from '../workflow'
3
3
 
4
4
  const releaseRules = WORKFLOW_CONFIGURATION.map(({ label, ...props }) => props)
5
5
  const commitTypeMapping = WORKFLOW_CONFIGURATION.reduce((obj, { type, label }) => {
@@ -1,9 +1,6 @@
1
- import { bumpPackagesVersion } from './bump-packages-version.js'
1
+ import { bumpPackagesVersion } from './bump-packages-version'
2
2
  import path from 'path'
3
3
  import fs from 'fs-extra'
4
- import { jest, describe, it, beforeEach, expect } from '@jest/globals'
5
- import * as url from 'url'
6
- const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
7
4
 
8
5
  describe('bumpPackagesVersion()', () => {
9
6
  beforeEach(() => {
@@ -1,5 +1,5 @@
1
1
  import semver from 'semver'
2
- import { git } from '../../common/index.js'
2
+ import { git } from '../../common'
3
3
 
4
4
  export function calculateSnapshotVersion (context) {
5
5
  const { nextRelease: { type }, lastRelease, config: { REF_COMMIT } } = context
@@ -1,14 +1,7 @@
1
- import { beforeEach, describe, expect, it, jest } from '@jest/globals'
1
+ import { git } from '../../common'
2
+ import { calculateSnapshotVersion } from './calculate-snapshot-version'
2
3
 
3
- jest.unstable_mockModule('../../common', () => {
4
- return {
5
- git: {
6
- getCommitTag: jest.fn()
7
- }
8
- }
9
- })
10
- const { git } = await import('../../common/index.js')
11
- const { calculateSnapshotVersion } = await import('./calculate-snapshot-version.js')
4
+ jest.mock('../../common')
12
5
 
13
6
  describe('calculateSnapshotVersion', () => {
14
7
  beforeEach(() => {
@@ -1,4 +1,4 @@
1
- import { logSection } from './log-section.js'
1
+ import { logSection } from './log-section'
2
2
 
3
3
  export function displayPackageInfo (context) {
4
4
  logSection('Package Info', context)
@@ -1,4 +1,4 @@
1
- import { logSection } from './log-section.js'
1
+ import { logSection } from './log-section'
2
2
 
3
3
  export function displayReleaseInfo (context) {
4
4
  logSection('Release Info', context)
@@ -1,4 +1,4 @@
1
- import { docker } from '../../common/index.js'
1
+ import { docker } from '../../common'
2
2
 
3
3
  function mapTags (tags) {
4
4
  tags = tags
@@ -1,16 +1,7 @@
1
- import { beforeEach, describe, expect, it, jest } from '@jest/globals'
1
+ import { docker } from '../../common'
2
+ import { dockerCleanTags } from './docker-clean-tags'
2
3
 
3
- jest.unstable_mockModule('../../common', () => {
4
- return {
5
- docker: {
6
- getToken: jest.fn(),
7
- getTags: jest.fn(),
8
- deleteTag: jest.fn()
9
- }
10
- }
11
- })
12
- const { docker } = await import('../../common/index.js')
13
- const { dockerCleanTags } = await import('./docker-clean-tags.js')
4
+ jest.mock('../../common')
14
5
 
15
6
  describe('dockerCleanTags', () => {
16
7
  beforeEach(() => {
@@ -1,9 +1,7 @@
1
- import { heroku } from '../../common/cli/heroku.js'
2
- import { docker } from '../../common/cli/docker.js'
3
- import { getConfig } from '../../common/get-config.js'
1
+ import { docker } from '../../common'
2
+ import { heroku } from '../../common/cli/heroku'
4
3
 
5
4
  export async function dockerPublish (context) {
6
- context.config = getConfig()
7
5
  const { logger, config: { DEPLOY_ON_DOCKER, DEPLOY_ON_HEROKU, SKIP_DEPLOY } } = context
8
6
 
9
7
  if (!SKIP_DEPLOY) {
@@ -24,7 +22,6 @@ export async function dockerPublish (context) {
24
22
  }
25
23
 
26
24
  export async function deployOnDockerHub (context) {
27
- context.config = getConfig()
28
25
  const { logger, config: { PRODUCTION_BRANCH, DOCKER_REPOSITORY, DOCKER_HUB_ID, DOCKER_HUB_PWD } } = context
29
26
 
30
27
  docker.login('-u', DOCKER_HUB_ID, '-p', DOCKER_HUB_PWD)
@@ -1,33 +1,10 @@
1
- import { describe, expect, it, jest } from '@jest/globals'
1
+ import { dockerPublish } from './docker-publish'
2
+ import { docker } from '../../common'
2
3
 
3
- jest.unstable_mockModule('../../common/cli/docker.js', () => {
4
- return {
5
- docker: {
6
- login: jest.fn(),
7
- tag: jest.fn(),
8
- push: jest.fn()
9
- }
10
- }
11
- })
12
-
13
- jest.unstable_mockModule('../../common/get-config.js', () => {
14
- return {
15
- getConfig: jest.fn()
16
- }
17
- })
18
- const { docker } = await import('../../common/cli/docker.js')
19
- const { getConfig } = await import('../../common/get-config.js')
20
- const { dockerPublish } = await import('./docker-publish.js')
4
+ jest.mock('../../common')
21
5
 
22
6
  describe('dockerPublish', () => {
23
7
  it('should publish docker image', async () => {
24
- getConfig.mockReturnValue({
25
- DEPLOY_ON_DOCKER: true,
26
- PRODUCTION_BRANCH: 'production',
27
- DOCKER_REPOSITORY: 'owner',
28
- DOCKER_HUB_ID: 'login',
29
- DOCKER_HUB_PWD: 'password'
30
- })
31
8
  const context = {
32
9
  logger: {
33
10
  info: jest.fn(),
@@ -35,6 +12,13 @@ describe('dockerPublish', () => {
35
12
  },
36
13
  branch: {
37
14
  name: 'branch-name'
15
+ },
16
+ config: {
17
+ DEPLOY_ON_DOCKER: true,
18
+ PRODUCTION_BRANCH: 'production',
19
+ DOCKER_REPOSITORY: 'owner',
20
+ DOCKER_HUB_ID: 'login',
21
+ DOCKER_HUB_PWD: 'password'
38
22
  }
39
23
  }
40
24
  await dockerPublish(context)
@@ -44,13 +28,6 @@ describe('dockerPublish', () => {
44
28
  expect(docker.push).toHaveBeenCalledWith('owner:branch-name')
45
29
  })
46
30
  it('should do nothing', async () => {
47
- getConfig.mockReturnValue({
48
- DEPLOY_ON_DOCKER: false,
49
- PRODUCTION_BRANCH: 'production',
50
- DOCKER_REPOSITORY: 'owner',
51
- DOCKER_HUB_ID: 'login',
52
- DOCKER_HUB_PWD: 'password'
53
- })
54
31
  const context = {
55
32
  logger: {
56
33
  info: jest.fn(),
@@ -58,6 +35,13 @@ describe('dockerPublish', () => {
58
35
  },
59
36
  branch: {
60
37
  name: 'branch-name'
38
+ },
39
+ config: {
40
+ DEPLOY_ON_DOCKER: false,
41
+ PRODUCTION_BRANCH: 'production',
42
+ DOCKER_REPOSITORY: 'owner',
43
+ DOCKER_HUB_ID: 'login',
44
+ DOCKER_HUB_PWD: 'password'
61
45
  }
62
46
  }
63
47
  await dockerPublish(context)
@@ -1,6 +1,6 @@
1
1
  import { join } from 'path'
2
2
  import { writeFileSync } from 'fs'
3
- import { git } from '../../common/index.js'
3
+ import { git } from '../../common'
4
4
 
5
5
  export async function ghPagesPublish (context) {
6
6
  const { config: { GITHUB_PAGES_PATH: cwd, GH_TOKEN, REPOSITORY_URL } } = context