@cmflow/cli 0.76.2 → 1.0.1

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 +3 -2
  2. package/bin/cm-clean.js +3 -2
  3. package/bin/cm-config.js +4 -3
  4. package/bin/cm-deploy.js +3 -2
  5. package/bin/cm-fetch.js +3 -2
  6. package/bin/cm-finish.js +3 -2
  7. package/bin/cm-merge.js +3 -2
  8. package/bin/cm-publish-pages.js +3 -2
  9. package/bin/cm-publish.js +3 -2
  10. package/bin/cm-push.js +3 -2
  11. package/bin/cm-rebase.js +3 -2
  12. package/bin/cm-republish.js +3 -2
  13. package/bin/cm-start.js +3 -2
  14. package/bin/cm.js +7 -2
  15. package/bin/cmrelease.js +3 -1
  16. package/package.json +18 -20
  17. package/release.config.js +5 -2
  18. package/semantic.js +1 -1
  19. package/src/commands/clean.js +1 -2
  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 +7 -19
  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 +2 -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 +2 -3
  41. package/src/common/cli/cli.js +2 -4
  42. package/src/common/cli/docker.js +1 -1
  43. package/src/common/cli/docker.test.js +13 -6
  44. package/src/common/cli/git.js +1 -1
  45. package/src/common/cli/git.test.js +9 -5
  46. package/src/common/cli/heroku.js +1 -1
  47. package/src/common/cli/heroku.test.js +10 -4
  48. package/src/common/cli/lerna.js +1 -1
  49. package/src/common/cli/lerna.test.js +9 -4
  50. package/src/common/cli/npm.js +4 -4
  51. package/src/common/cli/npm.test.js +10 -4
  52. package/src/common/cli/yarn.js +4 -4
  53. package/src/common/cli/yarn.test.js +9 -4
  54. package/src/common/configure-git-workspace.js +1 -1
  55. package/src/common/get-config.js +4 -24
  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 +8 -4
  59. package/src/index.js +1 -1
  60. package/src/main.js +5 -5
  61. package/src/semantic-release/actions/analyze-commits.js +9 -4
  62. package/src/semantic-release/actions/fail.js +2 -2
  63. package/src/semantic-release/actions/generate-notes.js +3 -2
  64. package/src/semantic-release/actions/index.js +8 -8
  65. package/src/semantic-release/actions/prepare.js +5 -3
  66. package/src/semantic-release/actions/publish.js +3 -3
  67. package/src/semantic-release/actions/success.js +5 -3
  68. package/src/semantic-release/actions/verify-conditions.js +3 -2
  69. package/src/semantic-release/actions/verify-release.js +4 -2
  70. package/src/semantic-release/get-semantic-config.js +2 -2
  71. package/src/semantic-release/utils/bump-packages-version.test.js +4 -1
  72. package/src/semantic-release/utils/calculate-snapshot-version.js +2 -1
  73. package/src/semantic-release/utils/calculate-snapshot-version.test.js +18 -6
  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 +12 -3
  78. package/src/semantic-release/utils/docker-publish.js +5 -2
  79. package/src/semantic-release/utils/docker-publish.test.js +33 -17
  80. package/src/semantic-release/utils/ghpages-publish.js +1 -1
@@ -1,4 +1,4 @@
1
- import { Cli } from './cli'
1
+ import { Cli } from './cli.js'
2
2
 
3
3
  export class HerokuCli extends Cli {
4
4
  constructor () {
@@ -1,8 +1,14 @@
1
- import execa from 'execa'
2
- import { Cli } from './cli'
3
- import { heroku } from './heroku'
1
+ import { beforeEach, describe, expect, it, jest } from '@jest/globals'
4
2
 
5
- jest.mock('execa')
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
+
10
+ const { Cli } = await import('./cli.js')
11
+ const { heroku } = await import('./heroku.js')
6
12
 
7
13
  execa.sync.mockImplementation((...args) => {
8
14
  return {
@@ -1,4 +1,4 @@
1
- import { Cli } from './cli'
1
+ import { Cli } from './cli.js'
2
2
 
3
3
  class LernaCli extends Cli {
4
4
  constructor () {
@@ -1,8 +1,13 @@
1
- import execa from 'execa'
2
- import { lerna } from './lerna'
3
- import { Cli } from './cli'
1
+ import { beforeEach, describe, expect, it, jest } from '@jest/globals'
4
2
 
5
- jest.mock('execa')
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')
6
11
 
7
12
  execa.sync.mockImplementation((...args) => {
8
13
  return {
@@ -1,4 +1,4 @@
1
- import { Cli } from './cli'
1
+ import { Cli } from './cli.js'
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,8 +1,14 @@
1
- import execa from 'execa'
2
- import { npm } from './npm'
3
- import { Cli } from './cli'
1
+ import { beforeEach, describe, expect, it, jest } from '@jest/globals'
4
2
 
5
- jest.mock('execa')
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')
6
12
 
7
13
  execa.sync.mockImplementation((...args) => {
8
14
  return {
@@ -1,4 +1,4 @@
1
- import { Cli } from './cli'
1
+ import { Cli } from './cli.js'
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,8 +1,13 @@
1
- import execa from 'execa'
2
- import { yarn } from './yarn'
3
- import { Cli } from './cli'
1
+ import { beforeEach, describe, expect, it, jest } from '@jest/globals'
4
2
 
5
- jest.mock('execa')
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')
6
11
 
7
12
  execa.sync.mockImplementation((...args) => {
8
13
  return {
@@ -1,4 +1,4 @@
1
- import { git } from './cli/git'
1
+ import { git } from './cli/git.js'
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'
3
- import { git } from './cli/git'
4
- import { getPackageJson } from './get-package-json'
2
+ import get from 'lodash/get.js'
3
+ import { git } from './cli/git.js'
4
+ import { getPackageJson } from './get-package-json.js'
5
5
  import fs from 'fs'
6
6
  import { join } from 'path'
7
7
 
@@ -19,26 +19,6 @@ 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
-
42
22
  if (env.GITLAB_CI) {
43
23
  const {
44
24
  CI_BUILD_ID,
@@ -127,7 +107,7 @@ export function getConfig () {
127
107
  HAS_LERNA: pkg.dependencies.lerna || pkg.devDependencies.lerna,
128
108
  HAS_BUILD: pkg.scripts.build,
129
109
  HAS_E2E: !!E2E_CMD,
130
- E2E_CMD: E2E_CMD,
110
+ E2E_CMD,
131
111
  HAS_BUILD_CHANGELOG: pkg.scripts.build_changelog,
132
112
  get DEPLOY_ON_DOCKER () {
133
113
  return toBool(process.env.DEPLOY_ON_DOCKER) && DOCKER_HUB_ID && DOCKER_HUB_PWD
@@ -1,10 +1,10 @@
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'
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'
@@ -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'
6
- import { getConfig } from './get-config'
5
+ import { getReleaseConfig } from './get-release-config.js'
6
+ import { getConfig } from './get-config.js'
7
7
 
8
8
  function createTasksRunner (tasks, ctx) {
9
9
  return new Listr(tasks, {
@@ -1,7 +1,10 @@
1
- import Listr from 'listr'
2
- import { runCommand } from './run-command'
1
+ import { beforeEach, describe, expect, it, jest } from '@jest/globals'
3
2
 
4
- jest.mock('listr')
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')
5
8
 
6
9
  describe('runCommand', () => {
7
10
  beforeEach(() => {
@@ -52,7 +55,8 @@ describe('runCommand', () => {
52
55
  }
53
56
 
54
57
  jest.spyOn(console, 'error').mockReturnValue(undefined)
55
- jest.spyOn(process, 'exit').mockImplementation(() => {})
58
+ jest.spyOn(process, 'exit').mockImplementation(() => {
59
+ })
56
60
 
57
61
  await runCommand(Cmd, {
58
62
  prop: '1'
package/src/index.js CHANGED
@@ -1 +1 @@
1
- module.exports = require('esm')(module)('./main.js')
1
+ export * from './main.js'
package/src/main.js CHANGED
@@ -1,9 +1,9 @@
1
- import * as commands from './commands'
1
+ import * as commands from './commands/index.js'
2
2
 
3
- export * from './workflow'
4
- export * from './common'
5
- export * from './commands/release'
6
- export * from './semantic-release/get-semantic-config'
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'
7
7
 
8
8
  export {
9
9
  commands
@@ -1,9 +1,14 @@
1
- import commitAnalyzerPlugins from '@semantic-release/commit-analyzer'
1
+ import * as commitAnalyzerPlugins from '@semantic-release/commit-analyzer'
2
+ import { calculateSnapshotVersion } from '../utils/calculate-snapshot-version.js'
2
3
 
3
- export function analyzeCommits (pluginConfig, context) {
4
+ export async function analyzeCommits (pluginConfig, context) {
4
5
  if (context.branch && context.branch.type !== 'prerelease') {
5
6
  return commitAnalyzerPlugins.analyzeCommits(pluginConfig, context)
6
7
  }
7
-
8
- return 'patch' // always trigger patch for prerelease
8
+ const analyzedCommits = await commitAnalyzerPlugins.analyzeCommits(pluginConfig, context)
9
+ context.nextRelease = context.nextRelease || {}
10
+ context.nextRelease.type = analyzedCommits
11
+ context.nextRelease.version = calculateSnapshotVersion(context)
12
+ context.lastRelease.version = null
13
+ return analyzedCommits
9
14
  }
@@ -1,5 +1,5 @@
1
- import githubPlugins from '@semantic-release/github'
2
- import { git } from '../../common'
1
+ import * as githubPlugins from '@semantic-release/github'
2
+ import { git } from '../../common/index.js'
3
3
 
4
4
  export async function fail (pluginConfig, context) {
5
5
  if (context.branch && context.branch.type !== 'prerelease') {
@@ -1,7 +1,8 @@
1
- import releaseNotesPlugins from '@semantic-release/release-notes-generator'
2
- import { npm, yarn } from '../../common'
1
+ import * as releaseNotesPlugins from '@semantic-release/release-notes-generator'
2
+ import { getConfig, npm, yarn } from '../../common/index.js'
3
3
 
4
4
  export async function generateNotes (pluginConfig, context) {
5
+ context.config = getConfig()
5
6
  if (context.branch.type === 'release' && !context.config.SKIP_GITHUB_PUBLISH) {
6
7
  if (context.config.HAS_BUILD_CHANGELOG) {
7
8
  await (context.config.HAS_YARN ? yarn : npm).run('build_changelog')
@@ -1,8 +1,8 @@
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
+ 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,8 +1,9 @@
1
- import { dockerPublish } from '../utils/docker-publish'
2
- import { configureGitWorkspace, git, lerna, npm, yarn } from '../../common'
3
- import { bumpPackagesVersion } from '../utils/bump-packages-version'
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'
4
4
 
5
5
  async function gitPrepareRelease (pluginConfig, context) {
6
+ context.config = getConfig()
6
7
  const {
7
8
  logger,
8
9
  config: {
@@ -28,6 +29,7 @@ async function gitPrepareRelease (pluginConfig, context) {
28
29
  }
29
30
 
30
31
  export async function prepare (pluginConfig, context) {
32
+ context.config = getConfig()
31
33
  const {
32
34
  branch,
33
35
  config: {
@@ -1,6 +1,6 @@
1
- import githubPlugins from '@semantic-release/github'
2
- import { dockerPublish } from '../utils/docker-publish'
3
- import { ghPagesPublish } from '../utils/ghpages-publish'
1
+ import * as githubPlugins from '@semantic-release/github'
2
+ import { dockerPublish } from '../utils/docker-publish.js'
3
+ import { ghPagesPublish } from '../utils/ghpages-publish.js'
4
4
 
5
5
  export async function publish (pluginConfig, context) {
6
6
  const { branch, env: { SKIP_GITHUB_PUBLISH, GITHUB_PAGES_PATH } } = context
@@ -1,6 +1,7 @@
1
- import githubPlugins from '@semantic-release/github'
2
- import { dockerCleanTags } from '../utils/docker-clean-tags'
3
- import { git } from '../../common'
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'
4
5
 
5
6
  async function githubSuccess (pluginConfig, context) {
6
7
  const { logger, config: { PRODUCTION_BRANCH, ORIGIN, DEVELOP_BRANCH } } = context
@@ -16,6 +17,7 @@ async function githubSuccess (pluginConfig, context) {
16
17
  }
17
18
 
18
19
  export async function success (pluginConfig, context) {
20
+ context.config = getConfig()
19
21
  const { branch, config: { SKIP_GITHUB_PUBLISH } } = context
20
22
 
21
23
  if (branch.type !== 'prerelease' && !SKIP_GITHUB_PUBLISH) {
@@ -1,8 +1,9 @@
1
1
  import chalk from 'chalk'
2
- import githubPlugins from '@semantic-release/github'
3
- import { git } from '../../common'
2
+ import * as githubPlugins from '@semantic-release/github'
3
+ import { getConfig, git } from '../../common/index.js'
4
4
 
5
5
  export function verifyConditions (pluginConfig, context) {
6
+ context.config = getConfig()
6
7
  if (pluginConfig.dryRun) {
7
8
  return
8
9
  }
@@ -1,7 +1,9 @@
1
- import { displayPackageInfo } from '../utils/display-package-info'
2
- import { displayReleaseInfo } from '../utils/display-release-info'
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'
3
4
 
4
5
  export function verifyRelease (pluginConfig, context) {
6
+ context.config = getConfig()
5
7
  displayPackageInfo(context)
6
8
  displayReleaseInfo(context)
7
9
  }
@@ -1,5 +1,5 @@
1
- import { getConfig } from '../common/get-config'
2
- import { WORKFLOW_CONFIGURATION } from '../workflow'
1
+ import { getConfig } from '../common/get-config.js'
2
+ import { WORKFLOW_CONFIGURATION } from '../workflow/index.js'
3
3
 
4
4
  const releaseRules = WORKFLOW_CONFIGURATION.map(({ label, ...props }) => props)
5
5
  const commitTypeMapping = WORKFLOW_CONFIGURATION.reduce((obj, { type, label }) => {
@@ -1,6 +1,9 @@
1
- import { bumpPackagesVersion } from './bump-packages-version'
1
+ import { bumpPackagesVersion } from './bump-packages-version.js'
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))
4
7
 
5
8
  describe('bumpPackagesVersion()', () => {
6
9
  beforeEach(() => {
@@ -1,7 +1,8 @@
1
1
  import semver from 'semver'
2
- import { git } from '../../common'
2
+ import { getConfig, git } from '../../common/index.js'
3
3
 
4
4
  export function calculateSnapshotVersion (context) {
5
+ context.config = getConfig()
5
6
  const { nextRelease: { type }, lastRelease, config: { REF_COMMIT } } = context
6
7
  const { major, minor, patch } = semver.parse(lastRelease.version)
7
8
 
@@ -1,20 +1,32 @@
1
- import { git } from '../../common'
2
- import { calculateSnapshotVersion } from './calculate-snapshot-version'
1
+ import { beforeEach, describe, expect, it, jest } from '@jest/globals'
3
2
 
4
- jest.mock('../../common')
3
+ jest.unstable_mockModule('../../common/index.js', () => {
4
+ return {
5
+ git: {
6
+ getCommitTag: jest.fn()
7
+ },
8
+ getConfig: jest.fn()
9
+ }
10
+ })
11
+ const { git, getConfig } = await import('../../common/index.js')
12
+ const { calculateSnapshotVersion } = await import('./calculate-snapshot-version.js')
5
13
 
6
14
  describe('calculateSnapshotVersion', () => {
7
15
  beforeEach(() => {
8
16
  git.getCommitTag.mockReturnValue('13246u')
17
+ getConfig.mockReturnValue({
18
+ DEPLOY_ON_DOCKER: true,
19
+ PRODUCTION_BRANCH: 'production',
20
+ DOCKER_REPOSITORY: 'owner',
21
+ DOCKER_HUB_ID: 'login',
22
+ DOCKER_HUB_PWD: 'password'
23
+ })
9
24
  })
10
25
  it('should return the snapshot version', () => {
11
26
  const context = {
12
27
  nextRelease: { type: 'patch' },
13
28
  lastRelease: {
14
29
  version: '1.0.0'
15
- },
16
- config: {
17
- REF_COMMIT: 'REF_COMMIT'
18
30
  }
19
31
  }
20
32
 
@@ -1,4 +1,4 @@
1
- import { logSection } from './log-section'
1
+ import { logSection } from './log-section.js'
2
2
 
3
3
  export function displayPackageInfo (context) {
4
4
  logSection('Package Info', context)
@@ -1,4 +1,4 @@
1
- import { logSection } from './log-section'
1
+ import { logSection } from './log-section.js'
2
2
 
3
3
  export function displayReleaseInfo (context) {
4
4
  logSection('Release Info', context)
@@ -1,4 +1,4 @@
1
- import { docker } from '../../common'
1
+ import { docker } from '../../common/index.js'
2
2
 
3
3
  function mapTags (tags) {
4
4
  tags = tags
@@ -1,7 +1,16 @@
1
- import { docker } from '../../common'
2
- import { dockerCleanTags } from './docker-clean-tags'
1
+ import { beforeEach, describe, expect, it, jest } from '@jest/globals'
3
2
 
4
- jest.mock('../../common')
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')
5
14
 
6
15
  describe('dockerCleanTags', () => {
7
16
  beforeEach(() => {
@@ -1,7 +1,9 @@
1
- import { docker } from '../../common'
2
- import { heroku } from '../../common/cli/heroku'
1
+ import { heroku } from '../../common/cli/heroku.js'
2
+ import { docker } from '../../common/cli/docker.js'
3
+ import { getConfig } from '../../common/get-config.js'
3
4
 
4
5
  export async function dockerPublish (context) {
6
+ context.config = getConfig()
5
7
  const { logger, config: { DEPLOY_ON_DOCKER, DEPLOY_ON_HEROKU, SKIP_DEPLOY } } = context
6
8
 
7
9
  if (!SKIP_DEPLOY) {
@@ -22,6 +24,7 @@ export async function dockerPublish (context) {
22
24
  }
23
25
 
24
26
  export async function deployOnDockerHub (context) {
27
+ context.config = getConfig()
25
28
  const { logger, config: { PRODUCTION_BRANCH, DOCKER_REPOSITORY, DOCKER_HUB_ID, DOCKER_HUB_PWD } } = context
26
29
 
27
30
  docker.login('-u', DOCKER_HUB_ID, '-p', DOCKER_HUB_PWD)
@@ -1,10 +1,33 @@
1
- import { dockerPublish } from './docker-publish'
2
- import { docker } from '../../common'
1
+ import { describe, expect, it, jest } from '@jest/globals'
3
2
 
4
- jest.mock('../../common')
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')
5
21
 
6
22
  describe('dockerPublish', () => {
7
23
  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
+ })
8
31
  const context = {
9
32
  logger: {
10
33
  info: jest.fn(),
@@ -12,13 +35,6 @@ describe('dockerPublish', () => {
12
35
  },
13
36
  branch: {
14
37
  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'
22
38
  }
23
39
  }
24
40
  await dockerPublish(context)
@@ -28,6 +44,13 @@ describe('dockerPublish', () => {
28
44
  expect(docker.push).toHaveBeenCalledWith('owner:branch-name')
29
45
  })
30
46
  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
+ })
31
54
  const context = {
32
55
  logger: {
33
56
  info: jest.fn(),
@@ -35,13 +58,6 @@ describe('dockerPublish', () => {
35
58
  },
36
59
  branch: {
37
60
  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'
45
61
  }
46
62
  }
47
63
  await dockerPublish(context)
@@ -1,6 +1,6 @@
1
1
  import { join } from 'path'
2
2
  import { writeFileSync } from 'fs'
3
- import { git } from '../../common'
3
+ import { git } from '../../common/index.js'
4
4
 
5
5
  export async function ghPagesPublish (context) {
6
6
  const { config: { GITHUB_PAGES_PATH: cwd, GH_TOKEN, REPOSITORY_URL } } = context