@cmflow/cli 1.1.0 → 2.0.0-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.
- package/.prettierignore +5 -0
- package/.prettierrc +10 -0
- package/README.md +130 -32
- package/bin/cm-changelog.js +20 -12
- package/bin/cm-clean.js +4 -7
- package/bin/cm-config.js +8 -8
- package/bin/cm-deploy.js +4 -8
- package/bin/cm-fetch.js +7 -7
- package/bin/cm-finish.js +9 -9
- package/bin/cm-merge.js +7 -7
- package/bin/cm-publish.js +10 -10
- package/bin/cm-push.js +10 -10
- package/bin/cm-rebase.js +10 -10
- package/bin/cm-republish.js +7 -7
- package/bin/cm-start.js +10 -10
- package/bin/cm.js +20 -20
- package/bin/cmrelease.js +2 -2
- package/eslint.config.mjs +67 -0
- package/package.json +27 -21
- package/release.config.mjs +36 -19
- package/src/commands/changelog.js +23 -23
- package/src/commands/clean.js +13 -13
- package/src/commands/config.js +8 -8
- package/src/commands/deploy.js +15 -20
- package/src/commands/fetch.js +7 -10
- package/src/commands/finish.js +18 -19
- package/src/commands/index.js +10 -11
- package/src/commands/merge.js +30 -14
- package/src/commands/prompts/branches.js +20 -20
- package/src/commands/push.js +11 -14
- package/src/commands/rebase.js +17 -19
- package/src/commands/release.js +10 -11
- package/src/commands/republish.js +11 -14
- package/src/commands/start.js +52 -48
- package/src/commands/tasks/merge-branch.js +41 -37
- package/src/commands/tasks/push-branch.js +5 -11
- package/src/commands/tasks/rebase-all-branches.js +19 -24
- package/src/commands/tasks/refresh-repository.js +26 -24
- package/src/commands/tasks/run-test.js +11 -17
- package/src/commands/tasks/update-branch.js +33 -30
- package/src/commands/tasks/update-dependencies.js +38 -32
- package/src/commands/utils/check-install.js +16 -15
- package/src/common/cli/cli.js +55 -57
- package/src/common/cli/docker.js +31 -28
- package/src/common/cli/docker.test.js +94 -96
- package/src/common/cli/git.js +59 -68
- package/src/common/cli/git.test.js +187 -189
- package/src/common/cli/lerna.js +12 -12
- package/src/common/cli/lerna.test.js +38 -40
- package/src/common/cli/npm.js +17 -17
- package/src/common/cli/npm.test.js +38 -40
- package/src/common/cli/yarn.js +17 -17
- package/src/common/cli/yarn.test.js +40 -40
- package/src/common/configure-git-workspace.js +11 -17
- package/src/common/get-config.js +63 -119
- package/src/common/get-package-json.js +4 -4
- package/src/common/get-release-config.js +4 -5
- package/src/common/index.js +10 -10
- package/src/common/run-command.js +26 -28
- package/src/common/run-command.test.js +35 -39
- package/src/index.js +10 -1
- package/src/semantic/core/analyze-commits.js +17 -0
- package/src/semantic/core/conditional.js +25 -0
- package/src/semantic/core/fail.js +21 -0
- package/src/semantic/core/generate-notes.js +11 -0
- package/src/semantic/core/prepare/bump-version.js +38 -0
- package/src/semantic/core/prepare/post.js +38 -0
- package/src/semantic/core/prepare/run.js +22 -0
- package/src/semantic/core/success.js +33 -0
- package/src/semantic/core/verify-conditions.js +32 -0
- package/src/semantic/core/verify-release.js +9 -0
- package/src/semantic/define-config.js +68 -0
- package/src/semantic/docker/publish.js +5 -0
- package/src/semantic/docker/success.js +9 -0
- package/src/semantic/utils/bump-packages-version.js +52 -0
- package/src/semantic/utils/bump-packages-version.test.js +75 -0
- package/src/semantic/utils/calculate-snapshot-version.js +15 -0
- package/src/semantic/utils/calculate-snapshot-version.test.js +67 -0
- package/src/semantic/utils/display-package-info.js +11 -0
- package/src/semantic/utils/display-release-info.js +12 -0
- package/src/semantic/utils/docker-clean-tags.js +51 -0
- package/src/semantic/utils/docker-clean-tags.test.js +61 -0
- package/src/semantic/utils/docker-publish.js +23 -0
- package/src/semantic/utils/docker-publish.test.js +44 -0
- package/src/semantic/utils/log-section.js +5 -0
- package/src/semantic/utils/release-rules.js +15 -0
- package/src/semantic/utils/transform-writer.js +75 -0
- package/src/workflow/index.js +22 -22
- package/tsconfig.json +54 -0
- package/vitest.config.mts +10 -0
- package/bin/cm-publish-pages.js +0 -12
- package/semantic.js +0 -1
- package/src/commands/publish-pages.js +0 -29
- package/src/common/cli/heroku.js +0 -21
- package/src/common/cli/heroku.test.js +0 -62
- package/src/main.js +0 -10
- package/src/semantic-release/actions/analyze-commits.js +0 -14
- package/src/semantic-release/actions/fail.js +0 -16
- package/src/semantic-release/actions/generate-notes.js +0 -12
- package/src/semantic-release/actions/index.js +0 -8
- package/src/semantic-release/actions/prepare.js +0 -114
- package/src/semantic-release/actions/publish.js +0 -17
- package/src/semantic-release/actions/success.js +0 -32
- package/src/semantic-release/actions/verify-conditions.js +0 -30
- package/src/semantic-release/actions/verify-release.js +0 -9
- package/src/semantic-release/get-semantic-config.js +0 -115
- package/src/semantic-release/utils/bump-packages-version.js +0 -51
- package/src/semantic-release/utils/bump-packages-version.test.js +0 -78
- package/src/semantic-release/utils/calculate-snapshot-version.js +0 -10
- package/src/semantic-release/utils/calculate-snapshot-version.test.js +0 -69
- package/src/semantic-release/utils/display-package-info.js +0 -11
- package/src/semantic-release/utils/display-release-info.js +0 -12
- package/src/semantic-release/utils/docker-clean-tags.js +0 -45
- package/src/semantic-release/utils/docker-clean-tags.test.js +0 -63
- package/src/semantic-release/utils/docker-publish.js +0 -47
- package/src/semantic-release/utils/docker-publish.test.js +0 -67
- package/src/semantic-release/utils/ghpages-publish.js +0 -16
- package/src/semantic-release/utils/log-section.js +0 -5
- /package/src/{semantic-release → semantic}/utils/__mock__/test1/package.json +0 -0
- /package/src/{semantic-release → semantic}/utils/__mock__/test1/packages/a/package.json +0 -0
- /package/src/{semantic-release → semantic}/utils/__mock__/test1/packages/b/package.json +0 -0
- /package/src/{semantic-release → semantic}/utils/__mock__/test2/package.json +0 -0
- /package/src/{semantic-release → semantic}/utils/__mock__/test2/packages/a/package.json +0 -0
- /package/src/{semantic-release → semantic}/utils/__mock__/test2/packages/b/package.json +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import stylistic from "@stylistic/eslint-plugin";
|
|
2
|
+
import typescriptEslint from "@typescript-eslint/eslint-plugin";
|
|
3
|
+
import typescriptParser from "@typescript-eslint/parser";
|
|
4
|
+
import pluginPrettierRecommended from "eslint-plugin-prettier/recommended";
|
|
5
|
+
import pluginSimpleImportSort from "eslint-plugin-simple-import-sort";
|
|
6
|
+
import vitest from "eslint-plugin-vitest";
|
|
7
|
+
import globals from "globals";
|
|
8
|
+
|
|
9
|
+
export default [
|
|
10
|
+
{
|
|
11
|
+
ignores: [
|
|
12
|
+
"node_modules",
|
|
13
|
+
"dist",
|
|
14
|
+
"**/public",
|
|
15
|
+
"reports",
|
|
16
|
+
"**/coverage",
|
|
17
|
+
"**/reports",
|
|
18
|
+
"**/dist",
|
|
19
|
+
"**/node_modules",
|
|
20
|
+
".yarn",
|
|
21
|
+
"**/__generated__/**"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
languageOptions: {
|
|
26
|
+
sourceType: "module",
|
|
27
|
+
parser: typescriptParser,
|
|
28
|
+
parserOptions: {
|
|
29
|
+
ecmaVersion: "latest",
|
|
30
|
+
sourceType: "module"
|
|
31
|
+
},
|
|
32
|
+
globals: {
|
|
33
|
+
...globals.node
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
plugins: {
|
|
37
|
+
...stylistic.configs.recommended.plugins,
|
|
38
|
+
"@typescript-eslint": typescriptEslint,
|
|
39
|
+
"simple-import-sort": pluginSimpleImportSort
|
|
40
|
+
},
|
|
41
|
+
rules: {
|
|
42
|
+
...stylistic.configs.recommended.rules,
|
|
43
|
+
"@stylistic/lines-between-class-members": ["error", "always", { exceptAfterOverload: true }],
|
|
44
|
+
"@typescript-eslint/no-unused-vars": "error",
|
|
45
|
+
"simple-import-sort/imports": "error",
|
|
46
|
+
"simple-import-sort/exports": "error"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
files: ["*/*.spec.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}", "*/*.test.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"], // or any other pattern
|
|
51
|
+
plugins: {
|
|
52
|
+
vitest
|
|
53
|
+
},
|
|
54
|
+
rules: {
|
|
55
|
+
...vitest.configs.recommended.rules, // you can also use vitest.configs.all.rules to enable all rules
|
|
56
|
+
"vitest/consistent-test-it": [
|
|
57
|
+
"error",
|
|
58
|
+
{
|
|
59
|
+
fn: "it",
|
|
60
|
+
withinDescribe: "it"
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"vitest/no-alias-methods": "error"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
pluginPrettierRecommended
|
|
67
|
+
];
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmflow/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
4
|
"description": "An awesome Git Flow",
|
|
5
5
|
"author": "camfou",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"email": "camfou@gmail.com",
|
|
8
8
|
"main": "./src/index.js",
|
|
9
|
-
"module": "./src/
|
|
9
|
+
"module": "./src/index.js",
|
|
10
10
|
"type": "module",
|
|
11
11
|
"private": false,
|
|
12
12
|
"bin": {
|
|
@@ -26,8 +26,14 @@
|
|
|
26
26
|
"cmchangelog": "bin/cm-changelog.js",
|
|
27
27
|
"cmconfig": "bin/cm-config.js"
|
|
28
28
|
},
|
|
29
|
+
"exports": {
|
|
30
|
+
".": "./index.js",
|
|
31
|
+
"./semantic/prepare/*": "./src/semantic-release/core/prepare/*.js",
|
|
32
|
+
"./semantic/*": "./src/semantic-release/core/*.js",
|
|
33
|
+
"./semantic/docker/*": "./src/semantic-release/docker/*.js"
|
|
34
|
+
},
|
|
29
35
|
"dependencies": {
|
|
30
|
-
"axios": "
|
|
36
|
+
"axios": "1.8.2",
|
|
31
37
|
"chalk": "^4.1.0",
|
|
32
38
|
"commander": "5.1.0",
|
|
33
39
|
"conventional-changelog": "3.1.25",
|
|
@@ -46,17 +52,20 @@
|
|
|
46
52
|
"split": "1.0.1"
|
|
47
53
|
},
|
|
48
54
|
"devDependencies": {
|
|
49
|
-
"eslint": "
|
|
50
|
-
"eslint
|
|
51
|
-
"eslint-plugin
|
|
52
|
-
"eslint
|
|
53
|
-
"eslint-
|
|
54
|
-
"eslint-
|
|
55
|
-
"eslint-plugin-
|
|
55
|
+
"@stylistic/eslint-plugin": "^4.2.0",
|
|
56
|
+
"@typescript-eslint/parser": "8.26.1",
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "8.26.1",
|
|
58
|
+
"eslint": "9.21.0",
|
|
59
|
+
"eslint-config-prettier": "10.0.2",
|
|
60
|
+
"eslint-formatter-junit": "^8.40.0",
|
|
61
|
+
"eslint-plugin-prettier": "5.2.3",
|
|
62
|
+
"eslint-plugin-simple-import-sort": "12.1.1",
|
|
63
|
+
"eslint-plugin-vitest": "0.5.4",
|
|
56
64
|
"husky": "4.3.6",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
65
|
+
"prettier": "3.5.1",
|
|
66
|
+
"lint-staged": "10.5.3",
|
|
67
|
+
"vitest": "^3.0.8",
|
|
68
|
+
"typescript": "5.8.2"
|
|
60
69
|
},
|
|
61
70
|
"peerDependencies": {
|
|
62
71
|
"@semantic-release/commit-analyzer": "^11.1.0",
|
|
@@ -67,19 +76,16 @@
|
|
|
67
76
|
"@semantic-release/commit-analyzer": {
|
|
68
77
|
"optional": true
|
|
69
78
|
},
|
|
70
|
-
"@semantic-release/github": {
|
|
71
|
-
"optional": true
|
|
72
|
-
},
|
|
73
79
|
"@semantic-release/release-notes-generator": {
|
|
74
80
|
"optional": true
|
|
75
81
|
}
|
|
76
82
|
},
|
|
77
83
|
"scripts": {
|
|
78
84
|
"test": "yarn lint && yarn test_unit",
|
|
79
|
-
"test_unit": "
|
|
80
|
-
"lint": "eslint
|
|
81
|
-
"lint_ci": "eslint
|
|
82
|
-
"lint_fix": "eslint
|
|
85
|
+
"test_unit": "vitest run",
|
|
86
|
+
"lint": "eslint",
|
|
87
|
+
"lint_ci": "eslint --format junit --output-file ./reports/eslint.xml",
|
|
88
|
+
"lint_fix": "eslint --fix",
|
|
83
89
|
"release": "node bin/cmrelease.js",
|
|
84
90
|
"release_dry_run": "node bin/cmrelease.js --dry-run",
|
|
85
91
|
"build_changelog": "node bin/cm-changelog.js"
|
|
@@ -92,7 +98,7 @@
|
|
|
92
98
|
},
|
|
93
99
|
"lint-staged": {
|
|
94
100
|
"*.js": [
|
|
95
|
-
"eslint
|
|
101
|
+
"eslint --fix",
|
|
96
102
|
"git add"
|
|
97
103
|
]
|
|
98
104
|
},
|
package/release.config.mjs
CHANGED
|
@@ -1,22 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineConfig } from "./src/index.js";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
branches: [
|
|
5
|
+
"master",
|
|
6
|
+
{
|
|
7
|
+
name: "alpha",
|
|
8
|
+
prerelease: true,
|
|
9
|
+
channel: "alpha"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: "beta",
|
|
13
|
+
prerelease: true,
|
|
14
|
+
channel: "beta"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "rc",
|
|
18
|
+
prerelease: true,
|
|
19
|
+
channel: "rc"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
verifyConditions: ["./src/semantic/core/verify-conditions.js"],
|
|
23
|
+
analyzeCommits: ["@semantic-release/commit-analyzer"],
|
|
24
|
+
verifyRelease: ["./src/semantic/core/verify-release.js"],
|
|
25
|
+
generateNotes: ["./src/semantic/core/generate-notes.js"],
|
|
26
|
+
prepare: ["./src/semantic/core/prepare/bump-version.js", "./src/semantic/core/prepare/post.js"],
|
|
27
|
+
publish: ["@semantic-release/github"],
|
|
28
|
+
success: [
|
|
29
|
+
[
|
|
30
|
+
"./src/semantic/core/success.js",
|
|
31
|
+
{
|
|
32
|
+
when: () => true
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"@semantic-release/github"
|
|
12
36
|
],
|
|
13
|
-
|
|
14
|
-
analyzeCommits: ['./semantic'],
|
|
15
|
-
verifyRelease: ['./semantic'],
|
|
16
|
-
generateNotes: ['./semantic'],
|
|
17
|
-
prepare: ['./semantic'],
|
|
18
|
-
publish: ['./semantic'],
|
|
19
|
-
success: ['./semantic'],
|
|
20
|
-
fail: ['./semantic'],
|
|
37
|
+
fail: ["@semantic-release/github"],
|
|
21
38
|
npmPublish: false
|
|
22
|
-
}
|
|
39
|
+
});
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import conventionalChangelog from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import conventionalChangelog from "conventional-changelog";
|
|
2
|
+
import { createWriteStream } from "fs";
|
|
3
|
+
import { Observable } from "rxjs";
|
|
4
4
|
|
|
5
5
|
export class Changelog {
|
|
6
|
-
mapContext
|
|
6
|
+
mapContext(commander, config) {
|
|
7
7
|
return {
|
|
8
|
-
preset: commander.preset ||
|
|
8
|
+
preset: commander.preset || "angular",
|
|
9
9
|
releaseCount: commander.releaseCount || 0,
|
|
10
10
|
outfile: `${process.cwd()}/CHANGELOG.md`,
|
|
11
|
-
|
|
12
|
-
tagPrefix: (config.tagFormat || commander.tagPrefix ||
|
|
13
|
-
}
|
|
11
|
+
|
|
12
|
+
tagPrefix: (config.tagFormat || commander.tagPrefix || "").replace("${version}", "")
|
|
13
|
+
};
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
exec
|
|
17
|
-
const writableStream = createWriteStream(outfile, { encoding:
|
|
16
|
+
exec({ preset, releaseCount, outfile, tagPrefix }) {
|
|
17
|
+
const writableStream = createWriteStream(outfile, { encoding: "utf8" });
|
|
18
18
|
|
|
19
|
-
return new Observable(observer => {
|
|
19
|
+
return new Observable((observer) => {
|
|
20
20
|
const stream = conventionalChangelog({
|
|
21
21
|
preset,
|
|
22
22
|
releaseCount,
|
|
23
23
|
path: `${process.cwd()}/package.json`,
|
|
24
24
|
tagPrefix
|
|
25
|
-
})
|
|
25
|
+
});
|
|
26
26
|
|
|
27
|
-
stream.pipe(writableStream)
|
|
27
|
+
stream.pipe(writableStream);
|
|
28
28
|
|
|
29
|
-
stream.on(
|
|
30
|
-
observer.error(err)
|
|
31
|
-
})
|
|
29
|
+
stream.on("error", (err) => {
|
|
30
|
+
observer.error(err);
|
|
31
|
+
});
|
|
32
32
|
|
|
33
|
-
stream.on(
|
|
34
|
-
observer.complete()
|
|
35
|
-
})
|
|
36
|
-
})
|
|
33
|
+
stream.on("end", () => {
|
|
34
|
+
observer.complete();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
getTasks
|
|
39
|
+
getTasks(ctx) {
|
|
40
40
|
return [
|
|
41
41
|
{
|
|
42
|
-
title:
|
|
42
|
+
title: "Generate changelog",
|
|
43
43
|
task: () => this.exec(ctx)
|
|
44
44
|
}
|
|
45
|
-
]
|
|
45
|
+
];
|
|
46
46
|
}
|
|
47
47
|
}
|
package/src/commands/clean.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import chalk from
|
|
2
|
-
import figures from
|
|
3
|
-
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import figures from "figures";
|
|
3
|
+
|
|
4
|
+
import { dockerCleanTags } from "../semantic/utils/docker-clean-tags.js";
|
|
4
5
|
|
|
5
6
|
export class Clean {
|
|
6
|
-
mapContext
|
|
7
|
+
mapContext(commander, context) {
|
|
7
8
|
return {
|
|
8
9
|
...context
|
|
9
|
-
}
|
|
10
|
+
};
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
prompt
|
|
13
|
-
return []
|
|
13
|
+
prompt() {
|
|
14
|
+
return [];
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
getTasks
|
|
17
|
+
getTasks(context) {
|
|
17
18
|
return [
|
|
18
19
|
{
|
|
19
|
-
title:
|
|
20
|
+
title: "Clean docker tags",
|
|
20
21
|
task: () => dockerCleanTags(context)
|
|
21
22
|
}
|
|
22
|
-
]
|
|
23
|
+
];
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
success
|
|
26
|
-
|
|
27
|
-
console.log(chalk.green(figures.tick), 'Docker tags cleaned')
|
|
26
|
+
success() {
|
|
27
|
+
console.log(chalk.green(figures.tick), "Docker tags cleaned");
|
|
28
28
|
}
|
|
29
29
|
}
|
package/src/commands/config.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { configureGitWorkspace, getConfig } from
|
|
1
|
+
import { configureGitWorkspace, getConfig } from "../common/index.js";
|
|
2
2
|
|
|
3
3
|
export class Config {
|
|
4
|
-
mapContext
|
|
4
|
+
mapContext(commander, context) {
|
|
5
5
|
return {
|
|
6
6
|
...context,
|
|
7
7
|
config: getConfig()
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
prompt
|
|
12
|
-
return []
|
|
11
|
+
prompt() {
|
|
12
|
+
return [];
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
getTasks
|
|
15
|
+
getTasks(context) {
|
|
16
16
|
return [
|
|
17
17
|
{
|
|
18
|
-
title:
|
|
18
|
+
title: "Configure workspace",
|
|
19
19
|
task: () => configureGitWorkspace(context)
|
|
20
20
|
}
|
|
21
|
-
]
|
|
21
|
+
];
|
|
22
22
|
}
|
|
23
23
|
}
|
package/src/commands/deploy.js
CHANGED
|
@@ -1,39 +1,34 @@
|
|
|
1
|
-
import chalk from
|
|
2
|
-
import figures from
|
|
3
|
-
|
|
4
|
-
import { getConfig } from
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import figures from "figures";
|
|
3
|
+
|
|
4
|
+
import { getConfig } from "../common/index.js";
|
|
5
|
+
import { dockerPublish } from "../semantic/utils/docker-publish.js";
|
|
5
6
|
|
|
6
7
|
export class Deploy {
|
|
7
|
-
mapContext
|
|
8
|
+
mapContext(commander, context) {
|
|
8
9
|
return {
|
|
9
10
|
...context,
|
|
10
11
|
target: commander.target,
|
|
11
12
|
config: getConfig()
|
|
12
|
-
}
|
|
13
|
+
};
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
prompt
|
|
16
|
-
return []
|
|
16
|
+
prompt() {
|
|
17
|
+
return [];
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
getTasks
|
|
20
|
+
getTasks(context) {
|
|
20
21
|
return [
|
|
21
22
|
{
|
|
22
|
-
title:
|
|
23
|
+
title: "Deploy on docker",
|
|
23
24
|
task: () => {
|
|
24
|
-
|
|
25
|
-
case 'docker':
|
|
26
|
-
return deployOnDockerHub(context)
|
|
27
|
-
case 'heroku':
|
|
28
|
-
return deployOnHeroku(context)
|
|
29
|
-
}
|
|
25
|
+
return dockerPublish(context);
|
|
30
26
|
}
|
|
31
27
|
}
|
|
32
|
-
]
|
|
28
|
+
];
|
|
33
29
|
}
|
|
34
30
|
|
|
35
|
-
success
|
|
36
|
-
|
|
37
|
-
console.log(chalk.green(figures.tick), 'Github pages deployed')
|
|
31
|
+
success() {
|
|
32
|
+
console.log(chalk.green(figures.tick), "Docker image deployed");
|
|
38
33
|
}
|
|
39
34
|
}
|
package/src/commands/fetch.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { refreshRepository } from
|
|
1
|
+
import { refreshRepository } from "./tasks/refresh-repository.js";
|
|
2
2
|
|
|
3
3
|
export class Fetch {
|
|
4
|
-
mapContext
|
|
4
|
+
mapContext(commander, context) {
|
|
5
5
|
return {
|
|
6
6
|
...context,
|
|
7
7
|
output: []
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
getTasks
|
|
12
|
-
return [
|
|
13
|
-
refreshRepository(context)
|
|
14
|
-
]
|
|
11
|
+
getTasks(context) {
|
|
12
|
+
return [refreshRepository(context)];
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
success
|
|
18
|
-
|
|
19
|
-
console.log(context.output.filter(l => !l.match('Fetching')).join('\n'))
|
|
15
|
+
success(context) {
|
|
16
|
+
console.log(context.output.filter((l) => !l.match("Fetching")).join("\n"));
|
|
20
17
|
}
|
|
21
18
|
}
|
package/src/commands/finish.js
CHANGED
|
@@ -1,44 +1,43 @@
|
|
|
1
|
-
import chalk from
|
|
2
|
-
import figures from
|
|
3
|
-
|
|
4
|
-
import { git } from
|
|
5
|
-
import {
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import figures from "figures";
|
|
3
|
+
|
|
4
|
+
import { git } from "../common/cli/git.js";
|
|
5
|
+
import { Rebase } from "./rebase.js";
|
|
6
|
+
import { pushBranch } from "./tasks/push-branch.js";
|
|
6
7
|
|
|
7
8
|
export class Finish extends Rebase {
|
|
8
|
-
mapContext
|
|
9
|
+
mapContext(commander, context) {
|
|
9
10
|
return {
|
|
10
11
|
...super.mapContext(commander, context),
|
|
11
12
|
checkStatus: true,
|
|
12
13
|
force: true
|
|
13
|
-
}
|
|
14
|
+
};
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
verifyConditions
|
|
17
|
+
verifyConditions(context) {
|
|
17
18
|
// Can't finish a production branch
|
|
18
19
|
if (context.featureBranch === context.fromBranch) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
process.exit(1)
|
|
20
|
+
console.error(chalk.red(`${figures.cross} ${context.fromBranch} cannot be finished`));
|
|
21
|
+
process.exit(1);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
getTasks
|
|
25
|
+
getTasks(context) {
|
|
26
26
|
return [
|
|
27
27
|
...super.getTasks(context),
|
|
28
28
|
{
|
|
29
29
|
title: `Add ${context.RELEASE_CANDIDATE_TAG} on last commit`,
|
|
30
|
-
task
|
|
31
|
-
const message = `${git.getLastCommitMsg()} ${context.RELEASE_CANDIDATE_TAG}
|
|
30
|
+
task() {
|
|
31
|
+
const message = `${git.getLastCommitMsg()} ${context.RELEASE_CANDIDATE_TAG}`;
|
|
32
32
|
|
|
33
|
-
return git.commit(
|
|
33
|
+
return git.commit("--amend", "-m", message).toObservable();
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
pushBranch(context)
|
|
37
|
-
]
|
|
37
|
+
];
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
success
|
|
41
|
-
|
|
42
|
-
console.log(chalk.green(figures.tick), 'Branch', chalk.green(context.featureBranch), 'is finished')
|
|
40
|
+
success(context) {
|
|
41
|
+
console.log(chalk.green(figures.tick), "Branch", chalk.green(context.featureBranch), "is finished");
|
|
43
42
|
}
|
|
44
43
|
}
|
package/src/commands/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from './merge.js'
|
|
1
|
+
export * from "./changelog.js";
|
|
2
|
+
export * from "./clean.js";
|
|
3
|
+
export * from "./deploy.js";
|
|
4
|
+
export * from "./fetch.js";
|
|
5
|
+
export * from "./finish.js";
|
|
6
|
+
export * from "./merge.js";
|
|
7
|
+
export * from "./push.js";
|
|
8
|
+
export * from "./rebase.js";
|
|
9
|
+
export * from "./republish.js";
|
|
10
|
+
export * from "./start.js";
|
package/src/commands/merge.js
CHANGED
|
@@ -1,25 +1,41 @@
|
|
|
1
|
-
import chalk from
|
|
2
|
-
import figures from
|
|
3
|
-
|
|
4
|
-
import { git } from
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import figures from "figures";
|
|
3
|
+
|
|
4
|
+
import { git } from "../common/cli/git.js";
|
|
5
|
+
import { mergeBranch } from "./tasks/merge-branch.js";
|
|
5
6
|
|
|
6
7
|
export class Merge {
|
|
7
|
-
getTasks
|
|
8
|
-
const { RELEASE_CANDIDATE_TAG } = context
|
|
9
|
-
this.lastCommitMessage = git.getLastCommitMsg()
|
|
8
|
+
getTasks(context) {
|
|
9
|
+
const { RELEASE_CANDIDATE_TAG } = context;
|
|
10
|
+
this.lastCommitMessage = git.getLastCommitMsg();
|
|
10
11
|
if (this.lastCommitMessage.includes(RELEASE_CANDIDATE_TAG)) {
|
|
11
|
-
return [mergeBranch(context)]
|
|
12
|
+
return [mergeBranch(context)];
|
|
12
13
|
}
|
|
13
|
-
return []
|
|
14
|
+
return [];
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
success
|
|
17
|
-
const { RELEASE_CANDIDATE_TAG } = context
|
|
17
|
+
success(context) {
|
|
18
|
+
const { RELEASE_CANDIDATE_TAG } = context;
|
|
18
19
|
if (this.lastCommitMessage.includes(RELEASE_CANDIDATE_TAG)) {
|
|
19
|
-
context.logger.info(
|
|
20
|
+
context.logger.info(
|
|
21
|
+
chalk.green(figures.tick),
|
|
22
|
+
"Branch",
|
|
23
|
+
chalk.green(context.BRANCH_NAME),
|
|
24
|
+
`merged into ${context.PRODUCTION_BRANCH}`
|
|
25
|
+
);
|
|
20
26
|
} else {
|
|
21
|
-
context.logger.info(
|
|
22
|
-
|
|
27
|
+
context.logger.info(
|
|
28
|
+
chalk.green(figures.tick),
|
|
29
|
+
"Merge branch",
|
|
30
|
+
chalk.green(context.BRANCH_NAME),
|
|
31
|
+
`into ${context.PRODUCTION_BRANCH} not required`
|
|
32
|
+
);
|
|
33
|
+
context.logger.info(
|
|
34
|
+
chalk.green(figures.tick),
|
|
35
|
+
"Last commit message : ",
|
|
36
|
+
chalk.green(this.lastCommitMessage),
|
|
37
|
+
`does not contains ${RELEASE_CANDIDATE_TAG}`
|
|
38
|
+
);
|
|
23
39
|
}
|
|
24
40
|
}
|
|
25
41
|
}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import inquirer from
|
|
2
|
-
import { git } from '../../common/index.js'
|
|
1
|
+
import inquirer from "inquirer";
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { git } from "../../common/index.js";
|
|
4
|
+
|
|
5
|
+
function toRemote(branch, origin) {
|
|
6
|
+
branch = branch.replace(`${origin}/`);
|
|
7
|
+
return `${origin}/${branch}`;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export function branches
|
|
10
|
-
const currentBranch = git.getBranchName()
|
|
11
|
-
const originDevelop = `${origin}/${DEVELOP_BRANCH}
|
|
12
|
-
const originProduction = `${origin}/${PRODUCTION_BRANCH}
|
|
10
|
+
export function branches({ fromBranch, origin, PRODUCTION_BRANCH, DEVELOP_BRANCH, message = "Start your branch from:" }) {
|
|
11
|
+
const currentBranch = git.getBranchName();
|
|
12
|
+
const originDevelop = `${origin}/${DEVELOP_BRANCH}`;
|
|
13
|
+
const originProduction = `${origin}/${PRODUCTION_BRANCH}`;
|
|
13
14
|
|
|
14
|
-
let startFromBranches = [
|
|
15
|
-
originProduction
|
|
16
|
-
]
|
|
15
|
+
let startFromBranches = [originProduction];
|
|
17
16
|
|
|
18
17
|
if (startFromBranches.indexOf(toRemote(currentBranch, origin)) === -1 && git.branchExists(currentBranch, origin)) {
|
|
19
|
-
startFromBranches = startFromBranches.concat(toRemote(currentBranch, origin))
|
|
18
|
+
startFromBranches = startFromBranches.concat(toRemote(currentBranch, origin));
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
const remoteBranches = git
|
|
23
|
-
.
|
|
24
|
-
.
|
|
21
|
+
const remoteBranches = git
|
|
22
|
+
.branchesInfos("-r")
|
|
23
|
+
.map((info) => info.branch)
|
|
24
|
+
.filter((name) => !startFromBranches.includes(name) && ![originDevelop, originProduction].includes(name));
|
|
25
25
|
|
|
26
26
|
if (remoteBranches.length) {
|
|
27
|
-
startFromBranches = startFromBranches.concat(new inquirer.Separator(), remoteBranches)
|
|
27
|
+
startFromBranches = startFromBranches.concat(new inquirer.Separator(), remoteBranches);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
return {
|
|
31
|
-
type:
|
|
32
|
-
name:
|
|
31
|
+
type: "list",
|
|
32
|
+
name: "fromBranch",
|
|
33
33
|
message,
|
|
34
34
|
default: startFromBranches.indexOf(fromBranch || originProduction),
|
|
35
35
|
choices: startFromBranches,
|
|
36
36
|
when: !fromBranch || currentBranch !== DEVELOP_BRANCH
|
|
37
|
-
}
|
|
37
|
+
};
|
|
38
38
|
}
|