@cmflow/cli 1.1.0 → 1.1.1-alpha.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 (124) hide show
  1. package/.prettierignore +5 -0
  2. package/.prettierrc +10 -0
  3. package/README.md +106 -32
  4. package/bin/cm-changelog.js +20 -12
  5. package/bin/cm-clean.js +4 -7
  6. package/bin/cm-config.js +8 -8
  7. package/bin/cm-deploy.js +4 -8
  8. package/bin/cm-fetch.js +7 -7
  9. package/bin/cm-finish.js +9 -9
  10. package/bin/cm-merge.js +7 -7
  11. package/bin/cm-publish.js +10 -10
  12. package/bin/cm-push.js +10 -10
  13. package/bin/cm-rebase.js +10 -10
  14. package/bin/cm-republish.js +7 -7
  15. package/bin/cm-start.js +10 -10
  16. package/bin/cm.js +20 -20
  17. package/bin/cmrelease.js +2 -2
  18. package/eslint.config.mjs +67 -0
  19. package/package.json +27 -21
  20. package/release.config.mjs +49 -19
  21. package/src/commands/changelog.js +23 -23
  22. package/src/commands/clean.js +13 -13
  23. package/src/commands/config.js +8 -8
  24. package/src/commands/deploy.js +15 -20
  25. package/src/commands/fetch.js +7 -10
  26. package/src/commands/finish.js +18 -19
  27. package/src/commands/index.js +10 -11
  28. package/src/commands/merge.js +30 -14
  29. package/src/commands/prompts/branches.js +20 -20
  30. package/src/commands/push.js +11 -14
  31. package/src/commands/rebase.js +17 -19
  32. package/src/commands/release.js +10 -11
  33. package/src/commands/republish.js +11 -14
  34. package/src/commands/start.js +52 -48
  35. package/src/commands/tasks/merge-branch.js +41 -37
  36. package/src/commands/tasks/push-branch.js +5 -11
  37. package/src/commands/tasks/rebase-all-branches.js +19 -24
  38. package/src/commands/tasks/refresh-repository.js +26 -24
  39. package/src/commands/tasks/run-test.js +11 -17
  40. package/src/commands/tasks/update-branch.js +33 -30
  41. package/src/commands/tasks/update-dependencies.js +38 -32
  42. package/src/commands/utils/check-install.js +16 -15
  43. package/src/common/cli/cli.js +55 -57
  44. package/src/common/cli/docker.js +31 -28
  45. package/src/common/cli/docker.test.js +94 -96
  46. package/src/common/cli/git.js +59 -68
  47. package/src/common/cli/git.test.js +187 -189
  48. package/src/common/cli/lerna.js +12 -12
  49. package/src/common/cli/lerna.test.js +38 -40
  50. package/src/common/cli/npm.js +17 -17
  51. package/src/common/cli/npm.test.js +38 -40
  52. package/src/common/cli/yarn.js +17 -17
  53. package/src/common/cli/yarn.test.js +40 -40
  54. package/src/common/configure-git-workspace.js +11 -17
  55. package/src/common/get-config.js +63 -119
  56. package/src/common/get-package-json.js +4 -4
  57. package/src/common/get-release-config.js +4 -5
  58. package/src/common/index.js +10 -10
  59. package/src/common/run-command.js +26 -28
  60. package/src/common/run-command.test.js +35 -39
  61. package/src/index.js +10 -1
  62. package/src/semantic/core/analyze-commits.js +17 -0
  63. package/src/semantic/core/fail.js +29 -0
  64. package/src/semantic/core/generate-notes.js +11 -0
  65. package/src/semantic/core/prepare/bump-version.js +38 -0
  66. package/src/semantic/core/prepare/post.js +38 -0
  67. package/src/semantic/core/prepare/run.js +22 -0
  68. package/src/semantic/core/publish.js +9 -0
  69. package/src/semantic/core/success.js +37 -0
  70. package/src/semantic/core/verify-conditions.js +32 -0
  71. package/src/semantic/core/verify-release.js +9 -0
  72. package/src/semantic/define-config.js +68 -0
  73. package/src/semantic/docker/publish.js +5 -0
  74. package/src/semantic/docker/success.js +9 -0
  75. package/src/semantic/utils/bump-packages-version.js +52 -0
  76. package/src/semantic/utils/bump-packages-version.test.js +75 -0
  77. package/src/semantic/utils/calculate-snapshot-version.js +15 -0
  78. package/src/semantic/utils/calculate-snapshot-version.test.js +67 -0
  79. package/src/semantic/utils/display-package-info.js +11 -0
  80. package/src/semantic/utils/display-release-info.js +12 -0
  81. package/src/semantic/utils/docker-clean-tags.js +51 -0
  82. package/src/semantic/utils/docker-clean-tags.test.js +61 -0
  83. package/src/semantic/utils/docker-publish.js +23 -0
  84. package/src/semantic/utils/docker-publish.test.js +44 -0
  85. package/src/semantic/utils/log-section.js +5 -0
  86. package/src/semantic/utils/release-rules.js +5 -0
  87. package/src/semantic/utils/transform-writer.js +75 -0
  88. package/src/workflow/index.js +22 -22
  89. package/tsconfig.json +54 -0
  90. package/vitest.config.mts +10 -0
  91. package/bin/cm-publish-pages.js +0 -12
  92. package/semantic.js +0 -1
  93. package/src/commands/publish-pages.js +0 -29
  94. package/src/common/cli/heroku.js +0 -21
  95. package/src/common/cli/heroku.test.js +0 -62
  96. package/src/main.js +0 -10
  97. package/src/semantic-release/actions/analyze-commits.js +0 -14
  98. package/src/semantic-release/actions/fail.js +0 -16
  99. package/src/semantic-release/actions/generate-notes.js +0 -12
  100. package/src/semantic-release/actions/index.js +0 -8
  101. package/src/semantic-release/actions/prepare.js +0 -114
  102. package/src/semantic-release/actions/publish.js +0 -17
  103. package/src/semantic-release/actions/success.js +0 -32
  104. package/src/semantic-release/actions/verify-conditions.js +0 -30
  105. package/src/semantic-release/actions/verify-release.js +0 -9
  106. package/src/semantic-release/get-semantic-config.js +0 -115
  107. package/src/semantic-release/utils/bump-packages-version.js +0 -51
  108. package/src/semantic-release/utils/bump-packages-version.test.js +0 -78
  109. package/src/semantic-release/utils/calculate-snapshot-version.js +0 -10
  110. package/src/semantic-release/utils/calculate-snapshot-version.test.js +0 -69
  111. package/src/semantic-release/utils/display-package-info.js +0 -11
  112. package/src/semantic-release/utils/display-release-info.js +0 -12
  113. package/src/semantic-release/utils/docker-clean-tags.js +0 -45
  114. package/src/semantic-release/utils/docker-clean-tags.test.js +0 -63
  115. package/src/semantic-release/utils/docker-publish.js +0 -47
  116. package/src/semantic-release/utils/docker-publish.test.js +0 -67
  117. package/src/semantic-release/utils/ghpages-publish.js +0 -16
  118. package/src/semantic-release/utils/log-section.js +0 -5
  119. /package/src/{semantic-release → semantic}/utils/__mock__/test1/package.json +0 -0
  120. /package/src/{semantic-release → semantic}/utils/__mock__/test1/packages/a/package.json +0 -0
  121. /package/src/{semantic-release → semantic}/utils/__mock__/test1/packages/b/package.json +0 -0
  122. /package/src/{semantic-release → semantic}/utils/__mock__/test2/package.json +0 -0
  123. /package/src/{semantic-release → semantic}/utils/__mock__/test2/packages/a/package.json +0 -0
  124. /package/src/{semantic-release → semantic}/utils/__mock__/test2/packages/b/package.json +0 -0
@@ -1,37 +1,43 @@
1
- import { npm, yarn } from '../../common/index.js'
2
- import { refreshMetadata, shouldReinstall } from '../utils/check-install.js'
3
- import Listr from 'listr'
4
- import { catchError } from 'rxjs'
1
+ import Listr from "listr";
2
+ import { catchError } from "rxjs";
3
+
4
+ import { npm, yarn } from "../../common/index.js";
5
+ import { refreshMetadata, shouldReinstall } from "../utils/check-install.js";
5
6
 
6
7
  export const updateDependencies = ({ useYarn }) => {
7
- const manager = useYarn ? yarn : npm
8
- const reinstall = shouldReinstall()
8
+ const manager = useYarn ? yarn : npm;
9
+ const reinstall = shouldReinstall();
9
10
 
10
- return ({
11
- title: 'Install',
11
+ return {
12
+ title: "Install",
12
13
  enabled: () => reinstall,
13
- task: () => new Listr(
14
- [
15
- {
16
- title: `Restore dependencies using ${useYarn ? 'Yarn' : 'Npm'}`,
17
- task: () => manager.restore()
18
- .toObservable()
19
- .pipe(catchError(error => {
20
- if (useYarn) {
21
- if (error.stderr.startsWith('error Your lockfile needs to be updated')) {
22
- throw new Error('yarn.lock file is outdated. Run yarn, commit the updated lockfile and try again.')
23
- }
24
- }
14
+ task: () =>
15
+ new Listr(
16
+ [
17
+ {
18
+ title: `Restore dependencies using ${useYarn ? "Yarn" : "Npm"}`,
19
+ task: () =>
20
+ manager
21
+ .restore()
22
+ .toObservable()
23
+ .pipe(
24
+ catchError((error) => {
25
+ if (useYarn) {
26
+ if (error.stderr.startsWith("error Your lockfile needs to be updated")) {
27
+ throw new Error("yarn.lock file is outdated. Run yarn, commit the updated lockfile and try again.");
28
+ }
29
+ }
25
30
 
26
- throw error
27
- }))
28
- },
29
- {
30
- title: 'Refresh metadata',
31
- task: () => refreshMetadata()
32
- }
33
- ],
34
- { concurrency: false }
35
- )
36
- })
37
- }
31
+ throw error;
32
+ })
33
+ )
34
+ },
35
+ {
36
+ title: "Refresh metadata",
37
+ task: () => refreshMetadata()
38
+ }
39
+ ],
40
+ { concurrency: false }
41
+ )
42
+ };
43
+ };
@@ -1,30 +1,31 @@
1
- import isEqual from 'lodash/isEqual.js'
2
- import { getPackageJson, git } from '../../common/index.js'
1
+ import isEqual from "lodash/isEqual.js";
3
2
 
4
- function getDeps () {
5
- const pkg = getPackageJson()
3
+ import { getPackageJson, git } from "../../common/index.js";
4
+
5
+ function getDeps() {
6
+ const pkg = getPackageJson();
6
7
  return {
7
8
  dependencies: pkg.dependencies,
8
9
  devDependencies: pkg.devDependencies
9
- }
10
+ };
10
11
  }
11
12
 
12
- export function getHash () {
13
- return Buffer.from(JSON.stringify(getDeps())).toString('base64')
13
+ export function getHash() {
14
+ return Buffer.from(JSON.stringify(getDeps())).toString("base64");
14
15
  }
15
16
 
16
- export function getDepsFromHash () {
17
+ export function getDepsFromHash() {
17
18
  try {
18
- return JSON.parse(Buffer.from(git.config('--local', 'npm.hash'), 'base64').toString('utf8'))
19
- } catch (er) {
20
- return ''
19
+ return JSON.parse(Buffer.from(git.config("--local", "npm.hash"), "base64").toString("utf8"));
20
+ } catch {
21
+ return "";
21
22
  }
22
23
  }
23
24
 
24
- export function shouldReinstall () {
25
- return !isEqual(getDeps(), getDepsFromHash())
25
+ export function shouldReinstall() {
26
+ return !isEqual(getDeps(), getDepsFromHash());
26
27
  }
27
28
 
28
- export function refreshMetadata () {
29
- git.config('--local', 'npm.hash', `${getHash()}`)
29
+ export function refreshMetadata() {
30
+ git.config("--local", "npm.hash", `${getHash()}`);
30
31
  }
@@ -1,112 +1,110 @@
1
- import 'any-observable/register/rxjs-all.js' // eslint-disable-line import/no-unassigned-import
2
- import execa from 'execa'
3
- import { fromEvent, merge, map, filter, takeUntil } from 'rxjs'
4
- import { spawnSync } from 'child_process'
1
+ import "any-observable/register/rxjs-all.js";
2
+
3
+ import { spawnSync } from "child_process";
4
+ import execa from "execa";
5
+ import { filter, fromEvent, map, merge, takeUntil } from "rxjs";
5
6
  export class Cli {
6
- constructor (cmd) {
7
- this.cmd = cmd
7
+ constructor(cmd) {
8
+ this.cmd = cmd;
8
9
  }
9
10
 
10
- sync (...args) {
11
- return Cli.run(this.cmd, args).sync()
11
+ sync(...args) {
12
+ return Cli.run(this.cmd, args).sync();
12
13
  }
13
14
 
14
- run (...args) {
15
- return Cli.run(this.cmd, args)
15
+ run(...args) {
16
+ return Cli.run(this.cmd, args);
16
17
  }
17
18
 
18
- get (...args) {
19
- return Cli.run(this.cmd, args).get()
19
+ get(...args) {
20
+ return Cli.run(this.cmd, args).get();
20
21
  }
21
22
 
22
- static run (cmd, args = [], options = {}) {
23
+ static run(cmd, args = [], options = {}) {
23
24
  const run = (opt = {}) => {
24
25
  return execa(cmd, args, {
25
26
  cwd: process.cwd(),
26
27
  ...opt,
27
28
  ...options
28
- })
29
- }
29
+ });
30
+ };
30
31
 
31
- let isPromise = true
32
+ let isPromise = true;
32
33
 
33
34
  const promise = new Promise((resolve, reject) => {
34
35
  setTimeout(async () => {
35
36
  if (isPromise) {
36
37
  try {
37
38
  const result = await run({
38
- stdio: 'inherit'
39
- })
39
+ stdio: "inherit"
40
+ });
40
41
 
41
- resolve(result)
42
+ resolve(result);
42
43
  } catch (err) {
43
- // eslint-disable-next-line no-console
44
- reject(err)
44
+ reject(err);
45
45
  }
46
46
  } else {
47
- resolve()
47
+ resolve();
48
48
  }
49
- }, 10)
50
- })
49
+ }, 10);
50
+ });
51
51
 
52
52
  promise.toObservable = (opt) => {
53
- isPromise = false
54
- const cp = run(opt)
55
- const end$ = fromEvent(cp, 'close')
56
- const stdout$ = fromEvent(cp.stdout, 'data').pipe(
53
+ isPromise = false;
54
+ const cp = run(opt);
55
+ const end$ = fromEvent(cp, "close");
56
+ const stdout$ = fromEvent(cp.stdout, "data").pipe(
57
57
  takeUntil(end$),
58
- map(data => data.toString())
59
- )
60
- const stderr$ = fromEvent(cp.stderr, 'data').pipe(
58
+ map((data) => data.toString())
59
+ );
60
+ const stderr$ = fromEvent(cp.stderr, "data").pipe(
61
61
  takeUntil(end$),
62
- map(data => data.toString())
63
- )
62
+ map((data) => data.toString())
63
+ );
64
64
 
65
- return merge(stdout$, stderr$).pipe(
66
- filter(Boolean)
67
- )
68
- }
65
+ return merge(stdout$, stderr$).pipe(filter(Boolean));
66
+ };
69
67
 
70
68
  promise.toStream = (opt) => {
71
- isPromise = false
69
+ isPromise = false;
72
70
 
73
- return run(opt)
74
- }
71
+ return run(opt);
72
+ };
75
73
 
76
74
  promise.cwd = (cwd) => {
77
- options.cwd = cwd
78
- return promise
79
- }
75
+ options.cwd = cwd;
76
+ return promise;
77
+ };
80
78
 
81
79
  promise.sync = (opt) => {
82
- isPromise = false
80
+ isPromise = false;
83
81
  return execa.sync(cmd, args, {
84
82
  cwd: process.cwd(),
85
- stdio: 'inherit',
83
+ stdio: "inherit",
86
84
  ...options,
87
85
  ...opt
88
- })
89
- }
86
+ });
87
+ };
90
88
 
91
89
  promise.getRaw = (opt) => {
92
- isPromise = false
90
+ isPromise = false;
93
91
  return Cli.getRaw(cmd, args, {
94
92
  cwd: process.cwd(),
95
93
  ...options,
96
94
  ...opt
97
- })
98
- }
95
+ });
96
+ };
99
97
 
100
- promise.get = promise.getRaw
98
+ promise.get = promise.getRaw;
101
99
 
102
- return promise
100
+ return promise;
103
101
  }
104
102
 
105
- static getRaw (cmd, args, options) {
103
+ static getRaw(cmd, args, options) {
106
104
  return spawnSync(cmd, args, options)
107
- .output.filter(o => !!o)
108
- .map(o => o.toString())
109
- .join('\n')
110
- .trim()
105
+ .output.filter((o) => !!o)
106
+ .map((o) => o.toString())
107
+ .join("\n")
108
+ .trim();
111
109
  }
112
110
  }
@@ -1,63 +1,66 @@
1
- import axios from 'axios'
2
- import { Cli } from './cli.js'
1
+ import axios from "axios";
2
+
3
+ import { Cli } from "./cli.js";
3
4
 
4
5
  class DockerCli extends Cli {
5
- constructor () {
6
- super('docker')
6
+ constructor() {
7
+ super("docker");
7
8
  }
8
9
 
9
- tag (...args) {
10
- return this.get('tag', ...args)
10
+ tag(...args) {
11
+ return this.get("tag", ...args);
11
12
  }
12
13
 
13
- login (...args) {
14
- return this.sync('login', ...args)
14
+ login(...args) {
15
+ return this.sync("login", ...args);
15
16
  }
16
17
 
17
- push (...args) {
18
- return this.run('push', ...args)
18
+ push(...args) {
19
+ return this.run("push", ...args);
19
20
  }
20
21
 
21
- async getToken (username, password) {
22
- const { data: { token } } = await axios({
23
- method: 'POST',
24
- url: 'https://hub.docker.com/v2/users/login/',
22
+ async getToken(username, password) {
23
+ const {
24
+ data: { token }
25
+ } = await axios({
26
+ method: "POST",
27
+ url: "https://hub.docker.com/v2/users/login/",
25
28
  headers: {
26
- Accept: 'application/json',
27
- 'Content-Type': 'application/json'
29
+ Accept: "application/json",
30
+ "Content-Type": "application/json"
28
31
  },
29
32
  data: {
30
33
  username,
31
34
  password
32
35
  }
33
- })
36
+ });
34
37
 
35
- return token
38
+ return token;
36
39
  }
37
40
 
38
- async getTags ({ token, repository }) {
41
+ async getTags({ token, repository }) {
39
42
  const { data } = await axios({
40
- method: 'GET',
43
+ method: "GET",
41
44
  url: `https://hub.docker.com/v2/repositories/${repository}/tags/?page=1&page_size=500`,
42
45
  headers: {
43
- Accept: 'application/json',
46
+ Accept: "application/json",
44
47
  Authorization: `JWT ${token}`
45
48
  }
46
- })
49
+ });
47
50
 
48
- return data.results
51
+ return data.results;
49
52
  }
50
53
 
51
- async deleteTag (tag, { token, repository }) {
54
+ async deleteTag(tag, { token, repository }) {
52
55
  await axios({
53
- method: 'DELETE',
56
+ method: "DELETE",
54
57
  url: `https://hub.docker.com/v2/repositories/${repository}/tags/${tag}/`,
55
58
  headers: {
56
- Accept: 'application/json',
59
+ Accept: "application/json",
57
60
  Authorization: `JWT ${token}`
58
61
  }
59
- })
62
+ });
60
63
  }
61
64
  }
62
65
 
63
- export const docker = new DockerCli()
66
+ export const docker = new DockerCli();
@@ -1,135 +1,133 @@
1
- import { beforeEach, describe, expect, it, jest } from '@jest/globals'
1
+ vi.mock("axios", () => {
2
+ return { default: vi.fn() };
3
+ });
4
+ vi.mock("execa", () => {
5
+ const execaMock = vi.fn();
6
+ execaMock.sync = vi.fn();
7
+ return { default: execaMock };
8
+ });
9
+ const { default: execa } = await import("execa");
10
+ const { default: axios } = await import("axios");
11
+ const { docker } = await import("./docker.js");
12
+ const { Cli } = await import("./cli.js");
2
13
 
3
- jest.unstable_mockModule('axios', () => {
4
- return { default: jest.fn() }
5
- })
6
- jest.unstable_mockModule('execa', () => {
7
- const execaMock = jest.fn()
8
- execaMock.sync = jest.fn()
9
- return { default: execaMock }
10
- })
11
- const { default: execa } = await import('execa')
12
- const { default: axios } = await import('axios')
13
- const { docker } = await import('./docker.js')
14
- const { Cli } = await import('./cli.js')
15
-
16
- execa.mockReturnValue({})
14
+ execa.mockReturnValue({});
17
15
 
18
16
  execa.sync.mockImplementation((...args) => {
19
17
  return {
20
- stdout: `CMD: ${[].concat(...args.filter(arg => typeof arg === 'string' || Array.isArray(arg))).join(' ')}`
21
- }
22
- })
18
+ stdout: `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
19
+ };
20
+ });
23
21
 
24
- describe('DockerCli', () => {
22
+ describe("DockerCli", () => {
25
23
  beforeEach(() => {
26
- jest.spyOn(Cli, 'getRaw').mockImplementation((...args) => {
27
- return `CMD: ${[].concat(...args.filter(arg => typeof arg === 'string' || Array.isArray(arg))).join(' ')}`
28
- })
29
- })
30
- describe('tag', () => {
31
- it('should run tag cmd', () => {
32
- const result = docker.tag('tag-arg', 'image')
24
+ vi.spyOn(Cli, "getRaw").mockImplementation((...args) => {
25
+ return `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`;
26
+ });
27
+ });
28
+ describe("tag", () => {
29
+ it("should run tag cmd", () => {
30
+ const result = docker.tag("tag-arg", "image");
33
31
 
34
- expect(result).toEqual('CMD: docker tag tag-arg image')
35
- expect(Cli.getRaw).toHaveBeenCalledWith('docker', ['tag', 'tag-arg', 'image'], {
32
+ expect(result).toEqual("CMD: docker tag tag-arg image");
33
+ expect(Cli.getRaw).toHaveBeenCalledWith("docker", ["tag", "tag-arg", "image"], {
36
34
  cwd: process.cwd()
37
- })
38
- })
39
- })
40
- describe('login', () => {
41
- it('should run login cmd', () => {
42
- const result = docker.login('login-arg')
35
+ });
36
+ });
37
+ });
38
+ describe("login", () => {
39
+ it("should run login cmd", () => {
40
+ const result = docker.login("login-arg");
43
41
 
44
- expect(result.stdout).toEqual('CMD: docker login login-arg')
45
- expect(execa.sync).toHaveBeenCalledWith('docker', ['login', 'login-arg'], {
42
+ expect(result.stdout).toEqual("CMD: docker login login-arg");
43
+ expect(execa.sync).toHaveBeenCalledWith("docker", ["login", "login-arg"], {
46
44
  cwd: process.cwd(),
47
- stdio: 'inherit'
48
- })
49
- })
50
- })
51
- describe('push', () => {
52
- it('should run push cmd', async () => {
53
- await docker.push('push-arg')
45
+ stdio: "inherit"
46
+ });
47
+ });
48
+ });
49
+ describe("push", () => {
50
+ it("should run push cmd", async () => {
51
+ await docker.push("push-arg");
54
52
 
55
- expect(execa).toHaveBeenCalledWith('docker', ['push', 'push-arg'], {
53
+ expect(execa).toHaveBeenCalledWith("docker", ["push", "push-arg"], {
56
54
  cwd: process.cwd(),
57
- stdio: 'inherit'
58
- })
59
- })
60
- })
61
- describe('getToken', () => {
55
+ stdio: "inherit"
56
+ });
57
+ });
58
+ });
59
+ describe("getToken", () => {
62
60
  beforeEach(() => {
63
- axios.mockReturnValue({ data: { token: 'token' } })
64
- })
65
- it('should get token', async () => {
66
- const token = await docker.getToken('username', 'password')
61
+ axios.mockReturnValue({ data: { token: "token" } });
62
+ });
63
+ it("should get token", async () => {
64
+ const token = await docker.getToken("username", "password");
67
65
 
68
66
  expect(axios).toHaveBeenCalledWith({
69
- method: 'POST',
70
- url: 'https://hub.docker.com/v2/users/login/',
67
+ method: "POST",
68
+ url: "https://hub.docker.com/v2/users/login/",
71
69
  headers: {
72
- Accept: 'application/json',
73
- 'Content-Type': 'application/json'
70
+ Accept: "application/json",
71
+ "Content-Type": "application/json"
74
72
  },
75
73
  data: {
76
- password: 'password',
77
- username: 'username'
74
+ password: "password",
75
+ username: "username"
78
76
  }
79
- })
80
- expect(token).toEqual('token')
81
- })
82
- })
83
- describe('getTags', () => {
77
+ });
78
+ expect(token).toEqual("token");
79
+ });
80
+ });
81
+ describe("getTags", () => {
84
82
  beforeEach(() => {
85
83
  axios.mockReturnValue({
86
84
  data: {
87
85
  results: [
88
86
  {
89
- name: 'branch-1',
90
- last_updated: new Date('2020-06-01')
87
+ name: "branch-1",
88
+ last_updated: new Date("2020-06-01")
91
89
  }
92
90
  ]
93
91
  }
94
- })
95
- })
96
- it('should get token', async () => {
92
+ });
93
+ });
94
+ it("should get token", async () => {
97
95
  const tags = await docker.getTags({
98
- token: 'token',
99
- repository: 'owner'
100
- })
96
+ token: "token",
97
+ repository: "owner"
98
+ });
101
99
 
102
100
  expect(tags).toEqual([
103
101
  {
104
- name: 'branch-1',
105
- last_updated: new Date('2020-06-01')
102
+ name: "branch-1",
103
+ last_updated: new Date("2020-06-01")
106
104
  }
107
- ])
105
+ ]);
108
106
  expect(axios).toHaveBeenCalledWith({
109
- method: 'GET',
110
- url: 'https://hub.docker.com/v2/repositories/owner/tags/?page=1&page_size=500',
107
+ method: "GET",
108
+ url: "https://hub.docker.com/v2/repositories/owner/tags/?page=1&page_size=500",
111
109
  headers: {
112
- Accept: 'application/json',
113
- Authorization: 'JWT token'
110
+ Accept: "application/json",
111
+ Authorization: "JWT token"
114
112
  }
115
- })
116
- })
117
- })
118
- describe('deleteTag', () => {
119
- it('should run delete Tag', async () => {
120
- await docker.deleteTag('my-tag', {
121
- token: 'token',
122
- repository: 'owner'
123
- })
113
+ });
114
+ });
115
+ });
116
+ describe("deleteTag", () => {
117
+ it("should run delete Tag", async () => {
118
+ await docker.deleteTag("my-tag", {
119
+ token: "token",
120
+ repository: "owner"
121
+ });
124
122
 
125
123
  expect(axios).toHaveBeenCalledWith({
126
124
  headers: {
127
- Accept: 'application/json',
128
- Authorization: 'JWT token'
125
+ Accept: "application/json",
126
+ Authorization: "JWT token"
129
127
  },
130
- method: 'DELETE',
131
- url: 'https://hub.docker.com/v2/repositories/owner/tags/my-tag/'
132
- })
133
- })
134
- })
135
- })
128
+ method: "DELETE",
129
+ url: "https://hub.docker.com/v2/repositories/owner/tags/my-tag/"
130
+ });
131
+ });
132
+ });
133
+ });