@cmflow/cli 1.0.16 → 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.
- package/.prettierignore +5 -0
- package/.prettierrc +10 -0
- package/README.md +106 -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 +49 -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 +66 -38
- 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/fail.js +29 -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/publish.js +9 -0
- package/src/semantic/core/success.js +37 -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 +5 -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
package/src/commands/rebase.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import chalk from
|
|
2
|
-
import figures from
|
|
3
|
-
|
|
4
|
-
import { git } from
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import figures from "figures";
|
|
3
|
+
|
|
4
|
+
import { git } from "../common/cli/git.js";
|
|
5
|
+
import { Fetch } from "./fetch.js";
|
|
6
|
+
import { runTest } from "./tasks/run-test.js";
|
|
7
|
+
import { updateBranch } from "./tasks/update-branch.js";
|
|
8
|
+
import { updateDependencies } from "./tasks/update-dependencies.js";
|
|
8
9
|
|
|
9
10
|
export class Rebase extends Fetch {
|
|
10
|
-
mapContext
|
|
11
|
+
mapContext(commander, context) {
|
|
11
12
|
return {
|
|
12
13
|
...context,
|
|
13
14
|
useYarn: context.HAS_YARN,
|
|
@@ -19,20 +20,17 @@ export class Rebase extends Fetch {
|
|
|
19
20
|
skipTest: !commander.cucumber && !commander.unitTest,
|
|
20
21
|
skipUnit: !commander.unitTest,
|
|
21
22
|
skipE2E: context.HAS_E2E ? !commander.cucumber : true
|
|
22
|
-
}
|
|
23
|
+
};
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
getTasks
|
|
26
|
-
return [
|
|
27
|
-
...super.getTasks(context),
|
|
28
|
-
updateBranch(context),
|
|
29
|
-
updateDependencies(context),
|
|
30
|
-
...runTest(context)
|
|
31
|
-
]
|
|
26
|
+
getTasks(context) {
|
|
27
|
+
return [...super.getTasks(context), updateBranch(context), updateDependencies(context), ...runTest(context)];
|
|
32
28
|
}
|
|
33
29
|
|
|
34
|
-
success
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
success(context) {
|
|
31
|
+
console.log(
|
|
32
|
+
chalk.green(figures.tick),
|
|
33
|
+
`Branch ${chalk.green(context.featureBranch)} rebased from ${chalk.green(context.fromBranch)} HEAD`
|
|
34
|
+
);
|
|
37
35
|
}
|
|
38
36
|
}
|
package/src/commands/release.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import semantic_release from
|
|
1
|
+
import semantic_release from "semantic-release";
|
|
2
2
|
|
|
3
|
-
delete process.env.CIRCLE_PR_NUMBER
|
|
4
|
-
delete process.env.CIRCLE_PULL_REQUEST
|
|
5
|
-
delete process.env.CI_PULL_REQUEST
|
|
3
|
+
delete process.env.CIRCLE_PR_NUMBER;
|
|
4
|
+
delete process.env.CIRCLE_PULL_REQUEST;
|
|
5
|
+
delete process.env.CI_PULL_REQUEST;
|
|
6
6
|
|
|
7
|
-
export function release
|
|
7
|
+
export function release(options = {}) {
|
|
8
8
|
semantic_release({
|
|
9
|
-
dryRun: process.argv.includes(
|
|
9
|
+
dryRun: process.argv.includes("--dry-run"),
|
|
10
10
|
ci: false,
|
|
11
11
|
noCi: true,
|
|
12
12
|
...options
|
|
13
13
|
})
|
|
14
14
|
.then(() => {
|
|
15
|
-
process.exitCode = 0
|
|
15
|
+
process.exitCode = 0;
|
|
16
16
|
})
|
|
17
17
|
.catch((err) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
})
|
|
18
|
+
console.log("Error while releasing", err);
|
|
19
|
+
process.exitCode = 1;
|
|
20
|
+
});
|
|
22
21
|
}
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
import chalk from
|
|
2
|
-
import figures from
|
|
3
|
-
|
|
4
|
-
import {
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import figures from "figures";
|
|
3
|
+
|
|
4
|
+
import { Fetch } from "./fetch.js";
|
|
5
|
+
import { rebaseAllBranches } from "./tasks/rebase-all-branches.js";
|
|
5
6
|
|
|
6
7
|
export class Republish extends Fetch {
|
|
7
|
-
mapContext
|
|
8
|
+
mapContext(commander, context) {
|
|
8
9
|
return {
|
|
9
10
|
...super.mapContext(commander, context)
|
|
10
|
-
}
|
|
11
|
+
};
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
getTasks
|
|
14
|
-
return [
|
|
15
|
-
...super.getTasks(context),
|
|
16
|
-
rebaseAllBranches(context)
|
|
17
|
-
]
|
|
14
|
+
getTasks(context) {
|
|
15
|
+
return [...super.getTasks(context), rebaseAllBranches(context)];
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
success
|
|
21
|
-
|
|
22
|
-
console.log(chalk.green(figures.tick), 'All branches rebased and pushed.')
|
|
18
|
+
success() {
|
|
19
|
+
console.log(chalk.green(figures.tick), "All branches rebased and pushed.");
|
|
23
20
|
}
|
|
24
21
|
}
|
package/src/commands/start.js
CHANGED
|
@@ -1,82 +1,110 @@
|
|
|
1
|
-
import chalk from
|
|
2
|
-
import figures from
|
|
3
|
-
import { git } from '../common/cli/git.js'
|
|
4
|
-
import { branches } from './prompts/branches.js'
|
|
5
|
-
import { Fetch } from './fetch.js'
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import figures from "figures";
|
|
6
3
|
|
|
7
|
-
import {
|
|
8
|
-
import { WORKFLOW_CONFIGURATION } from
|
|
4
|
+
import { git } from "../common/cli/git.js";
|
|
5
|
+
import { WORKFLOW_CONFIGURATION } from "../workflow/index.js";
|
|
6
|
+
import { Fetch } from "./fetch.js";
|
|
7
|
+
import { branches } from "./prompts/branches.js";
|
|
8
|
+
import { updateDependencies } from "./tasks/update-dependencies.js";
|
|
9
9
|
|
|
10
|
-
function sanitize
|
|
11
|
-
return name
|
|
10
|
+
function sanitize(name) {
|
|
11
|
+
return name
|
|
12
|
+
.replace(/[/\\_|. ]/gi, "-")
|
|
13
|
+
.split("-")
|
|
14
|
+
.filter(Boolean)
|
|
15
|
+
.join("-");
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
export class Start extends Fetch {
|
|
15
|
-
mapContext
|
|
16
|
-
options.branchName = options.branchName ||
|
|
17
|
-
const type = WORKFLOW_CONFIGURATION
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
mapContext(options, context) {
|
|
20
|
+
options.branchName = options.branchName || "";
|
|
21
|
+
const type = WORKFLOW_CONFIGURATION.map(({ type }) => type).find((t) => options.branchName.startsWith(`${t}-`));
|
|
22
|
+
|
|
23
|
+
if (!options.branchName && options.jiraId) {
|
|
24
|
+
options.branchName = options.jiraId;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (options.branchName.startsWith("CMAB-")) {
|
|
28
|
+
const [, key, ...rest] = options.branchName.split("-");
|
|
29
|
+
options.jiraId = `CMAB-${key}`;
|
|
30
|
+
options.branchName = rest.join("-");
|
|
31
|
+
}
|
|
20
32
|
|
|
21
33
|
return {
|
|
22
34
|
...context,
|
|
23
35
|
useYarn: context.HAS_YARN,
|
|
24
36
|
origin: context.ORIGIN,
|
|
37
|
+
jiraId: options.jiraId,
|
|
25
38
|
branchName: options.branchName,
|
|
26
39
|
type
|
|
27
|
-
}
|
|
40
|
+
};
|
|
28
41
|
}
|
|
29
42
|
|
|
30
|
-
prompt
|
|
43
|
+
prompt(context) {
|
|
31
44
|
return [
|
|
32
45
|
{
|
|
33
|
-
type:
|
|
34
|
-
name:
|
|
35
|
-
message:
|
|
36
|
-
|
|
46
|
+
type: "input",
|
|
47
|
+
name: "jiraId",
|
|
48
|
+
message: "What is the Jira ID ? (leave blank to skip)",
|
|
49
|
+
default: context.jiraId,
|
|
50
|
+
when: !context.jiraId
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: "list",
|
|
54
|
+
name: "type",
|
|
55
|
+
message: "Choose the type of your branch:",
|
|
56
|
+
choices: ["fix", "feat", "chore", "docs", "tech"],
|
|
37
57
|
default: context.type,
|
|
38
|
-
when: !context.type
|
|
58
|
+
when: !context.type && !context.jiraId
|
|
39
59
|
},
|
|
40
60
|
{
|
|
41
|
-
type:
|
|
42
|
-
name:
|
|
43
|
-
message:
|
|
44
|
-
validate
|
|
61
|
+
type: "input",
|
|
62
|
+
name: "branchName",
|
|
63
|
+
message: "What is the branch name ?",
|
|
64
|
+
validate(branch) {
|
|
45
65
|
if (!branch.length) {
|
|
46
|
-
return
|
|
66
|
+
return "Branch name is required";
|
|
47
67
|
}
|
|
48
68
|
|
|
49
69
|
if (git.branchExists(branch, context.origin)) {
|
|
50
|
-
return `${branch} already exists
|
|
70
|
+
return `${branch} already exists`;
|
|
51
71
|
}
|
|
52
72
|
|
|
53
|
-
return true
|
|
73
|
+
return true;
|
|
54
74
|
},
|
|
55
75
|
|
|
56
76
|
when: !context.branchName
|
|
57
77
|
},
|
|
58
78
|
|
|
59
79
|
branches(context)
|
|
60
|
-
]
|
|
80
|
+
];
|
|
61
81
|
}
|
|
62
82
|
|
|
63
|
-
getTasks
|
|
64
|
-
context.branchName = sanitize(context.branchName)
|
|
65
|
-
|
|
66
|
-
context.
|
|
83
|
+
getTasks(context) {
|
|
84
|
+
context.branchName = sanitize(context.branchName);
|
|
85
|
+
|
|
86
|
+
context.featureBranch = context.jiraId
|
|
87
|
+
? `${context.jiraId}-${context.branchName}`
|
|
88
|
+
: context.branchName.includes(context.type + "-")
|
|
89
|
+
? context.branchName
|
|
90
|
+
: `${context.type}-${context.branchName}`;
|
|
91
|
+
|
|
92
|
+
context.fromBranch = context.fromBranch || context.PRODUCTION_BRANCH;
|
|
67
93
|
|
|
68
94
|
return [
|
|
69
95
|
...super.getTasks(context),
|
|
70
96
|
{
|
|
71
97
|
title: `Create branch from ${chalk.green(context.fromBranch)}`,
|
|
72
|
-
task: () => git.checkout(
|
|
98
|
+
task: () => git.checkout("--no-track", "-b", context.featureBranch, context.fromBranch).toObservable()
|
|
73
99
|
},
|
|
74
100
|
updateDependencies(context)
|
|
75
|
-
]
|
|
101
|
+
];
|
|
76
102
|
}
|
|
77
103
|
|
|
78
|
-
success
|
|
79
|
-
|
|
80
|
-
|
|
104
|
+
success(context) {
|
|
105
|
+
console.log(
|
|
106
|
+
chalk.green(figures.tick),
|
|
107
|
+
`New branch ${chalk.green(context.featureBranch)} created from ${chalk.green(context.fromBranch)} HEAD`
|
|
108
|
+
);
|
|
81
109
|
}
|
|
82
110
|
}
|
|
@@ -1,61 +1,65 @@
|
|
|
1
|
-
import { git } from
|
|
1
|
+
import { git } from "../../common/index.js";
|
|
2
2
|
|
|
3
|
-
function setGHToken
|
|
3
|
+
function setGHToken(context) {
|
|
4
4
|
const {
|
|
5
5
|
logger,
|
|
6
|
-
config: {
|
|
7
|
-
} = context
|
|
6
|
+
config: { SCM_TOKEN, REPOSITORY_URL, ORIGIN }
|
|
7
|
+
} = context;
|
|
8
8
|
|
|
9
|
-
if (
|
|
10
|
-
const repository = REPOSITORY_URL.replace(
|
|
9
|
+
if (SCM_TOKEN) {
|
|
10
|
+
const repository = REPOSITORY_URL.replace("https://", "");
|
|
11
11
|
|
|
12
|
-
logger.info(`Configure remote repository ${repository}`)
|
|
13
|
-
git.remote(
|
|
14
|
-
git.remote(
|
|
12
|
+
logger.info(`Configure remote repository ${repository}`);
|
|
13
|
+
git.remote("remove", ORIGIN).sync();
|
|
14
|
+
git.remote("add", ORIGIN, `https://${SCM_TOKEN}@${repository}`).sync();
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
async function gitMep
|
|
19
|
-
const {
|
|
18
|
+
async function gitMep(context) {
|
|
19
|
+
const {
|
|
20
|
+
logger,
|
|
21
|
+
branch,
|
|
22
|
+
config: { PRODUCTION_BRANCH, ORIGIN }
|
|
23
|
+
} = context;
|
|
20
24
|
|
|
21
|
-
logger.info(`Branch ${branch.name} is candidate to MEP`)
|
|
25
|
+
logger.info(`Branch ${branch.name} is candidate to MEP`);
|
|
22
26
|
|
|
23
|
-
git.reset(
|
|
24
|
-
git.clean(
|
|
27
|
+
git.reset("--hard");
|
|
28
|
+
git.clean("-f", "-d").sync();
|
|
25
29
|
|
|
26
|
-
logger.info(
|
|
30
|
+
logger.info("Checkout production branch");
|
|
27
31
|
|
|
28
|
-
git.config(
|
|
29
|
-
git.fetch().sync()
|
|
30
|
-
git.fetch(
|
|
31
|
-
git.checkout(
|
|
32
|
+
git.config("--replace-all", "remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*");
|
|
33
|
+
git.fetch().sync();
|
|
34
|
+
git.fetch("--tags").sync();
|
|
35
|
+
git.checkout("-qf", PRODUCTION_BRANCH).sync();
|
|
32
36
|
|
|
33
|
-
logger.info(`Current branch: ${PRODUCTION_BRANCH}`)
|
|
37
|
+
logger.info(`Current branch: ${PRODUCTION_BRANCH}`);
|
|
34
38
|
|
|
35
|
-
const building = git.getLastCommitMsg()
|
|
36
|
-
logger.info(
|
|
39
|
+
const building = git.getLastCommitMsg();
|
|
40
|
+
logger.info("Last commit message on production", building);
|
|
37
41
|
|
|
38
|
-
logger.info(`Merge ${branch.name} into ${PRODUCTION_BRANCH} branch`)
|
|
39
|
-
git.merge(
|
|
40
|
-
logger.info(`${branch.name} merged into ${PRODUCTION_BRANCH} branch`)
|
|
42
|
+
logger.info(`Merge ${branch.name} into ${PRODUCTION_BRANCH} branch`);
|
|
43
|
+
git.merge("--no-ff", "-m", `${branch.name}`, branch.name);
|
|
44
|
+
logger.info(`${branch.name} merged into ${PRODUCTION_BRANCH} branch`);
|
|
41
45
|
|
|
42
|
-
setGHToken(context)
|
|
46
|
+
setGHToken(context);
|
|
43
47
|
|
|
44
|
-
logger.info(`Push ${PRODUCTION_BRANCH} branch`)
|
|
45
|
-
await git.push(ORIGIN, PRODUCTION_BRANCH)
|
|
46
|
-
logger.info(`${PRODUCTION_BRANCH} branch pushed`)
|
|
48
|
+
logger.info(`Push ${PRODUCTION_BRANCH} branch`);
|
|
49
|
+
await git.push(ORIGIN, PRODUCTION_BRANCH);
|
|
50
|
+
logger.info(`${PRODUCTION_BRANCH} branch pushed`);
|
|
47
51
|
|
|
48
|
-
logger.info(`Remove ${ORIGIN}/${branch.name} branch`)
|
|
49
|
-
await git.push(ORIGIN,
|
|
50
|
-
logger.info(`${ORIGIN}/${branch.name} branch correctly removed`)
|
|
52
|
+
logger.info(`Remove ${ORIGIN}/${branch.name} branch`);
|
|
53
|
+
await git.push(ORIGIN, ":" + branch.name);
|
|
54
|
+
logger.info(`${ORIGIN}/${branch.name} branch correctly removed`);
|
|
51
55
|
}
|
|
52
56
|
|
|
53
|
-
export function mergeBranch
|
|
54
|
-
const { BRANCH_NAME, PRODUCTION_BRANCH } = context
|
|
55
|
-
return
|
|
57
|
+
export function mergeBranch(context) {
|
|
58
|
+
const { BRANCH_NAME, PRODUCTION_BRANCH } = context;
|
|
59
|
+
return {
|
|
56
60
|
title: `Merge ${BRANCH_NAME} into ${PRODUCTION_BRANCH}`,
|
|
57
61
|
task: async () => {
|
|
58
|
-
await gitMep(context)
|
|
62
|
+
await gitMep(context);
|
|
59
63
|
}
|
|
60
|
-
}
|
|
64
|
+
};
|
|
61
65
|
}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import { git } from
|
|
1
|
+
import { git } from "../../common/cli/git.js";
|
|
2
2
|
|
|
3
|
-
export function pushBranch
|
|
4
|
-
return
|
|
3
|
+
export function pushBranch({ origin = "origin", featureBranch, upstream = true, noVerify = true }) {
|
|
4
|
+
return {
|
|
5
5
|
title: `Push ${featureBranch}`,
|
|
6
6
|
task: () => {
|
|
7
|
-
return git.push(...[
|
|
8
|
-
upstream ? '-u' : '',
|
|
9
|
-
'-f',
|
|
10
|
-
origin,
|
|
11
|
-
featureBranch,
|
|
12
|
-
noVerify ? '--no-verify' : ''
|
|
13
|
-
].filter(Boolean)).toObservable()
|
|
7
|
+
return git.push(...[upstream ? "-u" : "", "-f", origin, featureBranch, noVerify ? "--no-verify" : ""].filter(Boolean)).toObservable();
|
|
14
8
|
}
|
|
15
|
-
}
|
|
9
|
+
};
|
|
16
10
|
}
|
|
@@ -1,34 +1,29 @@
|
|
|
1
|
-
import { git } from
|
|
1
|
+
import { git } from "../../common/cli/git.js";
|
|
2
2
|
|
|
3
|
-
export function rebaseAllBranches
|
|
4
|
-
const { origin =
|
|
5
|
-
return
|
|
6
|
-
title:
|
|
3
|
+
export function rebaseAllBranches(context) {
|
|
4
|
+
const { origin = "origin", upstream = true, noVerify = true } = context;
|
|
5
|
+
return {
|
|
6
|
+
title: "Rebase all branches",
|
|
7
7
|
task: async () => {
|
|
8
|
-
const remoteBranches = git
|
|
9
|
-
.
|
|
8
|
+
const remoteBranches = git
|
|
9
|
+
.branches("-r")
|
|
10
|
+
.filter((b) => !new RegExp(`${context.PRODUCTION_BRANCH}|${context.DEVELOP_BRANCH}`).test(b));
|
|
10
11
|
for (const remoteBranch of remoteBranches) {
|
|
11
|
-
const branch = remoteBranch.split(
|
|
12
|
+
const branch = remoteBranch.split("/")[1];
|
|
12
13
|
try {
|
|
13
|
-
await git.branch(
|
|
14
|
-
} catch
|
|
14
|
+
await git.branch("-D", branch);
|
|
15
|
+
} catch {}
|
|
15
16
|
try {
|
|
16
|
-
await git.checkout(
|
|
17
|
-
await git.rebase(`${origin}/${context.PRODUCTION_BRANCH}`)
|
|
18
|
-
await git.push(...[
|
|
19
|
-
|
|
20
|
-
'-f',
|
|
21
|
-
origin,
|
|
22
|
-
branch,
|
|
23
|
-
noVerify ? '--no-verify' : ''
|
|
24
|
-
].filter(Boolean))
|
|
25
|
-
} catch (e) {
|
|
17
|
+
await git.checkout("--track", remoteBranch);
|
|
18
|
+
await git.rebase(`${origin}/${context.PRODUCTION_BRANCH}`);
|
|
19
|
+
await git.push(...[upstream ? "-u" : "", "-f", origin, branch, noVerify ? "--no-verify" : ""].filter(Boolean));
|
|
20
|
+
} catch {
|
|
26
21
|
try {
|
|
27
|
-
await git.rebase(
|
|
28
|
-
await git.reset(
|
|
29
|
-
} catch
|
|
22
|
+
await git.rebase("--abort");
|
|
23
|
+
await git.reset("--hard");
|
|
24
|
+
} catch {}
|
|
30
25
|
}
|
|
31
26
|
}
|
|
32
27
|
}
|
|
33
|
-
}
|
|
28
|
+
};
|
|
34
29
|
}
|
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { git } from '../../common/index.js'
|
|
1
|
+
import Listr from "listr";
|
|
2
|
+
import { catchError, EMPTY } from "rxjs";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
observable.pipe(catchError((err) => {
|
|
7
|
-
output.push(err)
|
|
8
|
-
return EMPTY
|
|
9
|
-
}))
|
|
4
|
+
import { git } from "../../common/index.js";
|
|
10
5
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
function pipe(observable, output) {
|
|
7
|
+
observable.pipe(
|
|
8
|
+
catchError((err) => {
|
|
9
|
+
output.push(err);
|
|
10
|
+
return EMPTY;
|
|
11
|
+
})
|
|
12
|
+
);
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
observable.subscribe((result) => {
|
|
15
|
+
output.push(result);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return observable;
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
export function refreshRepository
|
|
19
|
-
const {
|
|
20
|
-
output = []
|
|
21
|
-
} = context
|
|
21
|
+
export function refreshRepository(context) {
|
|
22
|
+
const { output = [] } = context;
|
|
22
23
|
|
|
23
24
|
return {
|
|
24
|
-
title:
|
|
25
|
-
task: () =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
title: "Refresh local repository",
|
|
26
|
+
task: () =>
|
|
27
|
+
new Listr([
|
|
28
|
+
{
|
|
29
|
+
title: "Git fetch",
|
|
30
|
+
task: () => pipe(git.fetch("--prune").toObservable(), output)
|
|
31
|
+
}
|
|
32
|
+
])
|
|
33
|
+
};
|
|
32
34
|
}
|
|
@@ -1,29 +1,23 @@
|
|
|
1
|
-
import { git, npm, yarn } from
|
|
1
|
+
import { git, npm, yarn } from "../../common/index.js";
|
|
2
2
|
|
|
3
|
-
export const runTest = ({
|
|
4
|
-
|
|
5
|
-
useYarn,
|
|
6
|
-
skipTest,
|
|
7
|
-
skipUnit,
|
|
8
|
-
skipE2E
|
|
9
|
-
}) => {
|
|
10
|
-
const manager = useYarn ? yarn : npm
|
|
3
|
+
export const runTest = ({ E2E_CMD, useYarn, skipTest, skipUnit, skipE2E }) => {
|
|
4
|
+
const manager = useYarn ? yarn : npm;
|
|
11
5
|
|
|
12
6
|
return [
|
|
13
7
|
{
|
|
14
|
-
title:
|
|
8
|
+
title: "Unit test",
|
|
15
9
|
skip: () => skipTest || skipUnit,
|
|
16
|
-
task: () => manager.run(
|
|
10
|
+
task: () => manager.run("test")
|
|
17
11
|
},
|
|
18
12
|
{
|
|
19
|
-
title:
|
|
13
|
+
title: "E2E test",
|
|
20
14
|
skip: () => skipTest || skipE2E,
|
|
21
|
-
task: () => manager.run(E2E_CMD ||
|
|
15
|
+
task: () => manager.run(E2E_CMD || "test_e2e")
|
|
22
16
|
},
|
|
23
17
|
{
|
|
24
|
-
title:
|
|
18
|
+
title: "Reset changes",
|
|
25
19
|
skip: () => skipTest,
|
|
26
|
-
task: () => git.reset(
|
|
20
|
+
task: () => git.reset("--hard") // reset files updated unit test
|
|
27
21
|
}
|
|
28
|
-
]
|
|
29
|
-
}
|
|
22
|
+
];
|
|
23
|
+
};
|
|
@@ -1,40 +1,43 @@
|
|
|
1
|
-
import chalk from
|
|
2
|
-
import Listr from
|
|
3
|
-
import { git } from '../../common/cli/git.js'
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import Listr from "listr";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { git } from "../../common/cli/git.js";
|
|
5
|
+
|
|
6
|
+
async function checkBranchRemoteStatus({ featureBranch, origin, force }) {
|
|
7
|
+
const isBranchExists = git.branchExists(featureBranch, origin);
|
|
7
8
|
|
|
8
9
|
if (isBranchExists && !force) {
|
|
9
|
-
const result = git.checkBranchRemoteStatus(featureBranch)
|
|
10
|
+
const result = git.checkBranchRemoteStatus(featureBranch);
|
|
10
11
|
|
|
11
12
|
if (result) {
|
|
12
|
-
throw new Error(
|
|
13
|
+
throw new Error("Remote branch changed, check diff before continue");
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export const updateBranch = ({ origin, featureBranch, fromBranch, force, checkStatus = true, rebase = true }) => {
|
|
18
|
-
return
|
|
19
|
-
title:
|
|
20
|
-
task: () =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
19
|
+
return {
|
|
20
|
+
title: "Rebase branch",
|
|
21
|
+
task: () =>
|
|
22
|
+
new Listr(
|
|
23
|
+
[
|
|
24
|
+
{
|
|
25
|
+
title: "Check status",
|
|
26
|
+
enabled: () => checkStatus,
|
|
27
|
+
task: () =>
|
|
28
|
+
checkBranchRemoteStatus({
|
|
29
|
+
force,
|
|
30
|
+
featureBranch,
|
|
31
|
+
origin
|
|
32
|
+
})
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title: `Rebase from ${origin}/${chalk.green(fromBranch)}`,
|
|
36
|
+
enabled: () => rebase,
|
|
37
|
+
task: () => git.rebase(`${origin}/${fromBranch}`).toObservable()
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
{ concurrent: false }
|
|
41
|
+
)
|
|
42
|
+
};
|
|
43
|
+
};
|