@cmflow/cli 3.3.0 → 3.4.0-alpha.3
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/README.md +102 -298
- package/dist/bin/cm.mjs +83622 -0
- package/dist/bin/cmrelease.mjs +75079 -0
- package/dist/cli-truncate-Bi2MjGwF.mjs +323 -0
- package/dist/cli-truncate-DMcpM5Q7.mjs +2 -0
- package/dist/cli-truncate-DMcpM5Q7.mjs.map +1 -0
- package/dist/cli-truncate-DsW0mgI_.mjs +323 -0
- package/dist/common-BdfXquG0.mjs +61 -0
- package/dist/common-BdfXquG0.mjs.map +1 -0
- package/dist/compile-packages-BB08_q2B.mjs +2 -0
- package/dist/compile-packages-BB08_q2B.mjs.map +1 -0
- package/dist/docker-Cc30aRzl.mjs +34 -0
- package/dist/docker-Cc30aRzl.mjs.map +1 -0
- package/dist/docker-clean-tags-EvFdWykP.mjs +2 -0
- package/dist/docker-clean-tags-EvFdWykP.mjs.map +1 -0
- package/dist/docker-publish-CG0aN9se.mjs +2 -0
- package/dist/docker-publish-CG0aN9se.mjs.map +1 -0
- package/dist/find-packages-611B-66T.mjs +42 -0
- package/dist/find-packages-611B-66T.mjs.map +1 -0
- package/dist/get-config-8ivgd1KC.mjs +9 -0
- package/dist/get-config-8ivgd1KC.mjs.map +1 -0
- package/dist/get-east-asian-width-Tfn8qoqd.mjs +2 -0
- package/dist/get-east-asian-width-Tfn8qoqd.mjs.map +1 -0
- package/dist/get-east-asian-width-wiVWCFXf.mjs +682 -0
- package/dist/log-update-CLbF3iV6.mjs +6 -0
- package/dist/log-update-CLbF3iV6.mjs.map +1 -0
- package/dist/log-update-CTXRtajW.mjs +668 -0
- package/dist/log-update-Dy1vPMGY.mjs +668 -0
- package/dist/npm-VM_GgazT.mjs +2 -0
- package/dist/npm-VM_GgazT.mjs.map +1 -0
- package/dist/rolldown-runtime-B4iAMlE-.mjs +35 -0
- package/dist/semver-DFjVbN1S.mjs +2 -0
- package/dist/semver-DFjVbN1S.mjs.map +1 -0
- package/dist/source-CwLcYLzI.mjs +7 -0
- package/dist/source-CwLcYLzI.mjs.map +1 -0
- package/dist/wrap-ansi-9ugahFCy.mjs +9 -0
- package/dist/wrap-ansi-9ugahFCy.mjs.map +1 -0
- package/dist/wrap-ansi-BRr0GA6g.mjs +330 -0
- package/dist/wrap-ansi-Cupoo4Yg.mjs +330 -0
- package/dist/wrap-ansi-dwgEjNWf.mjs +2 -0
- package/dist/write-package-cxki9d3K.mjs +8 -0
- package/dist/write-package-cxki9d3K.mjs.map +1 -0
- package/dist/write-packages-CxCAl_AG.mjs +10 -0
- package/dist/write-packages-CxCAl_AG.mjs.map +1 -0
- package/package.json +40 -63
- package/tsdown.config.ts +54 -0
- package/.oxfmtrc.json +0 -11
- package/.yarn/install-state.gz +0 -0
- package/.yarn/releases/yarn-4.7.0.cjs +0 -935
- package/.yarnrc.yml +0 -3
- package/bin/checkfeatures.js +0 -13
- package/bin/cm-clean.js +0 -8
- package/bin/cm-config.js +0 -15
- package/bin/cm-deploy.js +0 -8
- package/bin/cm-expedit.js +0 -19
- package/bin/cm-fetch.js +0 -12
- package/bin/cm-finish.js +0 -14
- package/bin/cm-jira-releases.js +0 -16
- package/bin/cm-merge.js +0 -12
- package/bin/cm-publish.js +0 -15
- package/bin/cm-push.js +0 -15
- package/bin/cm-rebase.js +0 -15
- package/bin/cm-republish.js +0 -12
- package/bin/cm-start.js +0 -21
- package/bin/cm.js +0 -27
- package/bin/cmpull.js +0 -22
- package/bin/cmrelease.js +0 -5
- package/mise.toml +0 -2
- package/oxlint.json +0 -25
- package/release.config.mjs +0 -39
- package/src/commands/checkfeatures.js +0 -20
- package/src/commands/clean.js +0 -29
- package/src/commands/config.js +0 -23
- package/src/commands/deploy.js +0 -34
- package/src/commands/fetch.js +0 -18
- package/src/commands/finish.js +0 -43
- package/src/commands/index.js +0 -12
- package/src/commands/jira-releases.js +0 -62
- package/src/commands/merge.js +0 -41
- package/src/commands/prompts/branches.js +0 -38
- package/src/commands/pull.js +0 -30
- package/src/commands/push.js +0 -23
- package/src/commands/rebase.js +0 -35
- package/src/commands/release.js +0 -21
- package/src/commands/republish.js +0 -21
- package/src/commands/start.js +0 -109
- package/src/commands/tasks/merge-branch.js +0 -65
- package/src/commands/tasks/push-branch.js +0 -10
- package/src/commands/tasks/rebase-all-branches.js +0 -29
- package/src/commands/tasks/refresh-repository.js +0 -34
- package/src/commands/tasks/run-test.js +0 -21
- package/src/commands/tasks/update-branch.js +0 -43
- package/src/commands/tasks/update-dependencies.js +0 -42
- package/src/commands/utils/check-install.js +0 -31
- package/src/common/back/directus/directus-flow.js +0 -40
- package/src/common/back/directus/directus-flow.test.js +0 -62
- package/src/common/back/http/http-proxy.js +0 -15
- package/src/common/back/http/http-request.js +0 -77
- package/src/common/back/http/http-request.spec.js +0 -49
- package/src/common/back/jira/get-sorted-releases.js +0 -40
- package/src/common/back/jira/interfaces/JiraIIssue.d.ts +0 -100
- package/src/common/back/jira/jira-releases.js +0 -36
- package/src/common/back/jira/jira-request.js +0 -21
- package/src/common/back/jira/jira-request.spec.js +0 -59
- package/src/common/back/jira/jira-search.js +0 -17
- package/src/common/back/jira/jira-search.spec.js +0 -44
- package/src/common/cli/bun.js +0 -33
- package/src/common/cli/bun.test.js +0 -51
- package/src/common/cli/cli.js +0 -110
- package/src/common/cli/docker.js +0 -66
- package/src/common/cli/docker.test.js +0 -133
- package/src/common/cli/git.js +0 -121
- package/src/common/cli/git.test.js +0 -207
- package/src/common/cli/lerna.js +0 -25
- package/src/common/cli/lerna.test.js +0 -51
- package/src/common/cli/npm.js +0 -33
- package/src/common/cli/npm.test.js +0 -51
- package/src/common/cli/pnpm.js +0 -34
- package/src/common/cli/pnpm.test.js +0 -51
- package/src/common/cli/yarn.js +0 -33
- package/src/common/cli/yarn.test.js +0 -53
- package/src/common/configure-git-workspace.js +0 -26
- package/src/common/get-config.js +0 -157
- package/src/common/get-package-json.js +0 -14
- package/src/common/get-package-manager.js +0 -12
- package/src/common/get-release-config.js +0 -8
- package/src/common/index.js +0 -13
- package/src/common/run-command.js +0 -64
- package/src/common/run-command.test.js +0 -65
- package/src/index.js +0 -10
- package/src/semantic/core/analyze-commits.js +0 -17
- package/src/semantic/core/conditional.js +0 -55
- package/src/semantic/core/exit.js +0 -14
- package/src/semantic/core/prepare/bump-version.js +0 -38
- package/src/semantic/core/prepare/commit.js +0 -29
- package/src/semantic/core/prepare/release-info.js +0 -5
- package/src/semantic/core/run.js +0 -22
- package/src/semantic/core/sync-repository.js +0 -52
- package/src/semantic/core/verify-conditions.js +0 -40
- package/src/semantic/core/verify-release.js +0 -9
- package/src/semantic/define-config.js +0 -42
- package/src/semantic/docker/publish.js +0 -5
- package/src/semantic/docker/success.js +0 -9
- package/src/semantic/utils/__mock__/test1/package.json +0 -7
- package/src/semantic/utils/__mock__/test1/packages/a/package.json +0 -9
- package/src/semantic/utils/__mock__/test1/packages/b/package.json +0 -7
- package/src/semantic/utils/__mock__/test2/package.json +0 -4
- package/src/semantic/utils/__mock__/test2/packages/a/package.json +0 -7
- package/src/semantic/utils/__mock__/test2/packages/b/package.json +0 -5
- package/src/semantic/utils/bump-packages-version.js +0 -52
- package/src/semantic/utils/bump-packages-version.test.js +0 -75
- package/src/semantic/utils/calculate-snapshot-version.js +0 -15
- package/src/semantic/utils/calculate-snapshot-version.test.js +0 -67
- package/src/semantic/utils/display-package-info.js +0 -11
- package/src/semantic/utils/display-release-info.js +0 -12
- package/src/semantic/utils/docker-clean-tags.js +0 -51
- package/src/semantic/utils/docker-clean-tags.test.js +0 -61
- package/src/semantic/utils/docker-publish.js +0 -23
- package/src/semantic/utils/docker-publish.test.js +0 -44
- package/src/semantic/utils/log-section.js +0 -5
- package/src/semantic/utils/release-rules.js +0 -15
- package/src/semantic/utils/transform-writer.js +0 -77
- package/src/workflow/index.js +0 -42
- package/tsconfig.json +0 -37
- package/vitest.config.mts +0 -10
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import inquirer from "inquirer";
|
|
2
|
-
|
|
3
|
-
import { git } from "../../common/index.js";
|
|
4
|
-
|
|
5
|
-
function toRemote(branch, origin) {
|
|
6
|
-
branch = branch.replace(`${origin}/`);
|
|
7
|
-
return `${origin}/${branch}`;
|
|
8
|
-
}
|
|
9
|
-
|
|
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}`;
|
|
14
|
-
|
|
15
|
-
let startFromBranches = [originProduction];
|
|
16
|
-
|
|
17
|
-
if (startFromBranches.indexOf(toRemote(currentBranch, origin)) === -1 && git.branchExists(currentBranch, origin)) {
|
|
18
|
-
startFromBranches = startFromBranches.concat(toRemote(currentBranch, origin));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const remoteBranches = git
|
|
22
|
-
.branchesInfos("-r")
|
|
23
|
-
.map((info) => info.branch)
|
|
24
|
-
.filter((name) => !startFromBranches.includes(name) && ![originDevelop, originProduction].includes(name));
|
|
25
|
-
|
|
26
|
-
if (remoteBranches.length) {
|
|
27
|
-
startFromBranches = startFromBranches.concat(new inquirer.Separator(), remoteBranches);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
type: "list",
|
|
32
|
-
name: "fromBranch",
|
|
33
|
-
message,
|
|
34
|
-
default: startFromBranches.indexOf(fromBranch || originProduction),
|
|
35
|
-
choices: startFromBranches,
|
|
36
|
-
when: !fromBranch || currentBranch !== DEVELOP_BRANCH
|
|
37
|
-
};
|
|
38
|
-
}
|
package/src/commands/pull.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { git } from "../common/index.js";
|
|
2
|
-
|
|
3
|
-
export class Pull {
|
|
4
|
-
mapContext(options, context) {
|
|
5
|
-
return { ...context, targetBranch: options.branch };
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
getTasks(context) {
|
|
9
|
-
const { targetBranch } = context;
|
|
10
|
-
|
|
11
|
-
return [
|
|
12
|
-
{
|
|
13
|
-
title: "Git fetch",
|
|
14
|
-
task: () => git.fetch("--all", "--prune", "--tags")
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
title: `Delete local branch ${targetBranch}`,
|
|
18
|
-
task: () => git.branch("-D", targetBranch).catch(() => {})
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
title: `Checkout origin/${targetBranch}`,
|
|
22
|
-
task: () => git.checkout(`origin/${targetBranch}`, "--track")
|
|
23
|
-
}
|
|
24
|
-
];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
success(context) {
|
|
28
|
-
console.log(`BRANCH ${context.targetBranch} RETRIEVE DONE`);
|
|
29
|
-
}
|
|
30
|
-
}
|
package/src/commands/push.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import figures from "figures";
|
|
3
|
-
|
|
4
|
-
import { Rebase } from "./rebase.js";
|
|
5
|
-
import { pushBranch } from "./tasks/push-branch.js";
|
|
6
|
-
|
|
7
|
-
export class Push extends Rebase {
|
|
8
|
-
mapContext(commander, context) {
|
|
9
|
-
return {
|
|
10
|
-
...super.mapContext(commander, context),
|
|
11
|
-
force: !!commander.force,
|
|
12
|
-
checkStatus: true
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
getTasks(context) {
|
|
17
|
-
return [...super.getTasks(context), pushBranch(context)];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
success(context) {
|
|
21
|
-
console.log(chalk.green(figures.tick), "Branch", chalk.green(context.featureBranch), "rebased and pushed.");
|
|
22
|
-
}
|
|
23
|
-
}
|
package/src/commands/rebase.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
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";
|
|
9
|
-
|
|
10
|
-
export class Rebase extends Fetch {
|
|
11
|
-
mapContext(commander, context) {
|
|
12
|
-
return {
|
|
13
|
-
...context,
|
|
14
|
-
origin: context.ORIGIN,
|
|
15
|
-
featureBranch: git.getBranchName(),
|
|
16
|
-
fromBranch: context.PRODUCTION_BRANCH,
|
|
17
|
-
checkStatus: commander.force === undefined ? true : !!commander.force,
|
|
18
|
-
rebase: true,
|
|
19
|
-
skipTest: !commander.cucumber && !commander.unitTest,
|
|
20
|
-
skipUnit: !commander.unitTest,
|
|
21
|
-
skipE2E: context.HAS_E2E ? !commander.cucumber : true
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
getTasks(context) {
|
|
26
|
-
return [...super.getTasks(context), updateBranch(context), updateDependencies(context), ...runTest(context)];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
success(context) {
|
|
30
|
-
console.log(
|
|
31
|
-
chalk.green(figures.tick),
|
|
32
|
-
`Branch ${chalk.green(context.featureBranch)} rebased from ${chalk.green(context.fromBranch)} HEAD`
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
}
|
package/src/commands/release.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import semantic_release from "semantic-release";
|
|
2
|
-
|
|
3
|
-
delete process.env.CIRCLE_PR_NUMBER;
|
|
4
|
-
delete process.env.CIRCLE_PULL_REQUEST;
|
|
5
|
-
delete process.env.CI_PULL_REQUEST;
|
|
6
|
-
|
|
7
|
-
export function release(options = {}) {
|
|
8
|
-
semantic_release({
|
|
9
|
-
dryRun: process.argv.includes("--dry-run"),
|
|
10
|
-
ci: false,
|
|
11
|
-
noCi: true,
|
|
12
|
-
...options
|
|
13
|
-
})
|
|
14
|
-
.then(() => {
|
|
15
|
-
process.exitCode = 0;
|
|
16
|
-
})
|
|
17
|
-
.catch((err) => {
|
|
18
|
-
console.log("Error while releasing", err);
|
|
19
|
-
process.exitCode = 1;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
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";
|
|
6
|
-
|
|
7
|
-
export class Republish extends Fetch {
|
|
8
|
-
mapContext(commander, context) {
|
|
9
|
-
return {
|
|
10
|
-
...super.mapContext(commander, context)
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
getTasks(context) {
|
|
15
|
-
return [...super.getTasks(context), rebaseAllBranches(context)];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
success() {
|
|
19
|
-
console.log(chalk.green(figures.tick), "All branches rebased and pushed.");
|
|
20
|
-
}
|
|
21
|
-
}
|
package/src/commands/start.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import figures from "figures";
|
|
3
|
-
|
|
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
|
-
|
|
10
|
-
function sanitize(name) {
|
|
11
|
-
return name
|
|
12
|
-
.replace(/[/\\_|. ]/gi, "-")
|
|
13
|
-
.split("-")
|
|
14
|
-
.filter(Boolean)
|
|
15
|
-
.join("-");
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class Start extends Fetch {
|
|
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
|
-
}
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
...context,
|
|
35
|
-
origin: context.ORIGIN,
|
|
36
|
-
jiraId: options.jiraId,
|
|
37
|
-
branchName: options.branchName,
|
|
38
|
-
type
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
prompt(context) {
|
|
43
|
-
return [
|
|
44
|
-
{
|
|
45
|
-
type: "input",
|
|
46
|
-
name: "jiraId",
|
|
47
|
-
message: "What is the Jira ID ? (leave blank to skip)",
|
|
48
|
-
default: context.jiraId,
|
|
49
|
-
when: !context.jiraId
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
type: "list",
|
|
53
|
-
name: "type",
|
|
54
|
-
message: "Choose the type of your branch:",
|
|
55
|
-
choices: ["fix", "feat", "chore", "docs", "tech"],
|
|
56
|
-
default: context.type,
|
|
57
|
-
when: !context.type && !context.jiraId
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
type: "input",
|
|
61
|
-
name: "branchName",
|
|
62
|
-
message: "What is the branch name ?",
|
|
63
|
-
validate(branch) {
|
|
64
|
-
if (!branch.length) {
|
|
65
|
-
return "Branch name is required";
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (git.branchExists(branch, context.origin)) {
|
|
69
|
-
return `${branch} already exists`;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return true;
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
when: !context.branchName
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
branches(context)
|
|
79
|
-
];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
getTasks(context) {
|
|
83
|
-
context.branchName = sanitize(context.branchName);
|
|
84
|
-
|
|
85
|
-
context.featureBranch = context.jiraId
|
|
86
|
-
? `${context.jiraId}-${context.branchName}`
|
|
87
|
-
: context.branchName.includes(context.type + "-")
|
|
88
|
-
? context.branchName
|
|
89
|
-
: `${context.type}-${context.branchName}`;
|
|
90
|
-
|
|
91
|
-
context.fromBranch = context.fromBranch || context.PRODUCTION_BRANCH;
|
|
92
|
-
|
|
93
|
-
return [
|
|
94
|
-
...super.getTasks(context),
|
|
95
|
-
{
|
|
96
|
-
title: `Create branch from ${chalk.green(context.fromBranch)}`,
|
|
97
|
-
task: () => git.checkout("--no-track", "-b", context.featureBranch, context.fromBranch).toObservable()
|
|
98
|
-
},
|
|
99
|
-
updateDependencies(context)
|
|
100
|
-
];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
success(context) {
|
|
104
|
-
console.log(
|
|
105
|
-
chalk.green(figures.tick),
|
|
106
|
-
`New branch ${chalk.green(context.featureBranch)} created from ${chalk.green(context.fromBranch)} HEAD`
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { git } from "../../common/index.js";
|
|
2
|
-
|
|
3
|
-
function setGHToken(context) {
|
|
4
|
-
const {
|
|
5
|
-
logger,
|
|
6
|
-
config: { SCM_TOKEN, REPOSITORY_URL, ORIGIN }
|
|
7
|
-
} = context;
|
|
8
|
-
|
|
9
|
-
if (SCM_TOKEN) {
|
|
10
|
-
const repository = REPOSITORY_URL.replace("https://", "");
|
|
11
|
-
|
|
12
|
-
logger.info(`Configure remote repository ${repository}`);
|
|
13
|
-
git.remote("remove", ORIGIN).sync();
|
|
14
|
-
git.remote("add", ORIGIN, `https://${SCM_TOKEN}@${repository}`).sync();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async function gitMep(context) {
|
|
19
|
-
const {
|
|
20
|
-
logger,
|
|
21
|
-
branch,
|
|
22
|
-
config: { PRODUCTION_BRANCH, ORIGIN }
|
|
23
|
-
} = context;
|
|
24
|
-
|
|
25
|
-
logger.info(`Branch ${branch.name} is candidate to MEP`);
|
|
26
|
-
|
|
27
|
-
git.reset("--hard");
|
|
28
|
-
git.clean("-f", "-d").sync();
|
|
29
|
-
|
|
30
|
-
logger.info("Checkout production branch");
|
|
31
|
-
|
|
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();
|
|
36
|
-
|
|
37
|
-
logger.info(`Current branch: ${PRODUCTION_BRANCH}`);
|
|
38
|
-
|
|
39
|
-
const building = git.getLastCommitMsg();
|
|
40
|
-
logger.info("Last commit message on production", building);
|
|
41
|
-
|
|
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`);
|
|
45
|
-
|
|
46
|
-
setGHToken(context);
|
|
47
|
-
|
|
48
|
-
logger.info(`Push ${PRODUCTION_BRANCH} branch`);
|
|
49
|
-
await git.push(ORIGIN, PRODUCTION_BRANCH);
|
|
50
|
-
logger.info(`${PRODUCTION_BRANCH} branch pushed`);
|
|
51
|
-
|
|
52
|
-
logger.info(`Remove ${ORIGIN}/${branch.name} branch`);
|
|
53
|
-
await git.push(ORIGIN, ":" + branch.name);
|
|
54
|
-
logger.info(`${ORIGIN}/${branch.name} branch correctly removed`);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function mergeBranch(context) {
|
|
58
|
-
const { BRANCH_NAME, PRODUCTION_BRANCH } = context;
|
|
59
|
-
return {
|
|
60
|
-
title: `Merge ${BRANCH_NAME} into ${PRODUCTION_BRANCH}`,
|
|
61
|
-
task: async () => {
|
|
62
|
-
await gitMep(context);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { git } from "../../common/cli/git.js";
|
|
2
|
-
|
|
3
|
-
export function pushBranch({ origin = "origin", featureBranch, upstream = true, noVerify = true }) {
|
|
4
|
-
return {
|
|
5
|
-
title: `Push ${featureBranch}`,
|
|
6
|
-
task: () => {
|
|
7
|
-
return git.push(...[upstream ? "-u" : "", "-f", origin, featureBranch, noVerify ? "--no-verify" : ""].filter(Boolean)).toObservable();
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { git } from "../../common/cli/git.js";
|
|
2
|
-
|
|
3
|
-
export function rebaseAllBranches(context) {
|
|
4
|
-
const { origin = "origin", upstream = true, noVerify = true } = context;
|
|
5
|
-
return {
|
|
6
|
-
title: "Rebase all branches",
|
|
7
|
-
task: async () => {
|
|
8
|
-
const remoteBranches = git
|
|
9
|
-
.branches("-r")
|
|
10
|
-
.filter((b) => !new RegExp(`${context.PRODUCTION_BRANCH}|${context.DEVELOP_BRANCH}`).test(b));
|
|
11
|
-
for (const remoteBranch of remoteBranches) {
|
|
12
|
-
const branch = remoteBranch.split("/")[1];
|
|
13
|
-
try {
|
|
14
|
-
await git.branch("-D", branch);
|
|
15
|
-
} catch {}
|
|
16
|
-
try {
|
|
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 {
|
|
21
|
-
try {
|
|
22
|
-
await git.rebase("--abort");
|
|
23
|
-
await git.reset("--hard");
|
|
24
|
-
} catch {}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import Listr from "listr";
|
|
2
|
-
import { catchError, EMPTY } from "rxjs";
|
|
3
|
-
|
|
4
|
-
import { git } from "../../common/index.js";
|
|
5
|
-
|
|
6
|
-
function pipe(observable, output) {
|
|
7
|
-
observable.pipe(
|
|
8
|
-
catchError((err) => {
|
|
9
|
-
output.push(err);
|
|
10
|
-
return EMPTY;
|
|
11
|
-
})
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
observable.subscribe((result) => {
|
|
15
|
-
output.push(result);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
return observable;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function refreshRepository(context) {
|
|
22
|
-
const { output = [] } = context;
|
|
23
|
-
|
|
24
|
-
return {
|
|
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
|
-
};
|
|
34
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { getPackageManager, git } from "../../common/index.js";
|
|
2
|
-
|
|
3
|
-
export const runTest = ({ E2E_CMD, PACKAGE_MANAGER, skipTest, skipUnit, skipE2E }) => {
|
|
4
|
-
return [
|
|
5
|
-
{
|
|
6
|
-
title: "Unit test",
|
|
7
|
-
skip: () => skipTest || skipUnit,
|
|
8
|
-
task: () => getPackageManager(PACKAGE_MANAGER).run("test")
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
title: "E2E test",
|
|
12
|
-
skip: () => skipTest || skipE2E,
|
|
13
|
-
task: () => getPackageManager(PACKAGE_MANAGER).run(E2E_CMD || "test_e2e")
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
title: "Reset changes",
|
|
17
|
-
skip: () => skipTest,
|
|
18
|
-
task: () => git.reset("--hard") // reset files updated unit test
|
|
19
|
-
}
|
|
20
|
-
];
|
|
21
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import Listr from "listr";
|
|
3
|
-
|
|
4
|
-
import { git } from "../../common/cli/git.js";
|
|
5
|
-
|
|
6
|
-
async function checkBranchRemoteStatus({ featureBranch, origin, force }) {
|
|
7
|
-
const isBranchExists = git.branchExists(featureBranch, origin);
|
|
8
|
-
|
|
9
|
-
if (isBranchExists && !force) {
|
|
10
|
-
const result = git.checkBranchRemoteStatus(featureBranch);
|
|
11
|
-
|
|
12
|
-
if (result) {
|
|
13
|
-
throw new Error("Remote branch changed, check diff before continue");
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const updateBranch = ({ origin, featureBranch, fromBranch, force, checkStatus = true, rebase = true }) => {
|
|
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
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import Listr from "listr";
|
|
2
|
-
import { catchError } from "rxjs";
|
|
3
|
-
|
|
4
|
-
import { getPackageManager } from "../../common/index.js";
|
|
5
|
-
import { refreshMetadata, shouldReinstall } from "../utils/check-install.js";
|
|
6
|
-
|
|
7
|
-
export const updateDependencies = ({ PACKAGE_MANAGER }) => {
|
|
8
|
-
const reinstall = shouldReinstall();
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
title: "Install",
|
|
12
|
-
enabled: () => reinstall,
|
|
13
|
-
task: () =>
|
|
14
|
-
new Listr(
|
|
15
|
-
[
|
|
16
|
-
{
|
|
17
|
-
title: `Restore dependencies using ${PACKAGE_MANAGER.toUpperCase()}`,
|
|
18
|
-
task: () =>
|
|
19
|
-
getPackageManager(PACKAGE_MANAGER)
|
|
20
|
-
.restore()
|
|
21
|
-
.toObservable()
|
|
22
|
-
.pipe(
|
|
23
|
-
catchError((error) => {
|
|
24
|
-
if (PACKAGE_MANAGER === "yarn") {
|
|
25
|
-
if (error.stderr.startsWith("error Your lockfile needs to be updated")) {
|
|
26
|
-
throw new Error("yarn.lock file is outdated. Run yarn, commit the updated lockfile and try again.");
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
throw error;
|
|
31
|
-
})
|
|
32
|
-
)
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
title: "Refresh metadata",
|
|
36
|
-
task: () => refreshMetadata()
|
|
37
|
-
}
|
|
38
|
-
],
|
|
39
|
-
{ concurrency: false }
|
|
40
|
-
)
|
|
41
|
-
};
|
|
42
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import isEqual from "lodash/isEqual.js";
|
|
2
|
-
|
|
3
|
-
import { getPackageJson, git } from "../../common/index.js";
|
|
4
|
-
|
|
5
|
-
function getDeps() {
|
|
6
|
-
const pkg = getPackageJson();
|
|
7
|
-
return {
|
|
8
|
-
dependencies: pkg.dependencies,
|
|
9
|
-
devDependencies: pkg.devDependencies
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function getHash() {
|
|
14
|
-
return Buffer.from(JSON.stringify(getDeps())).toString("base64");
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function getDepsFromHash() {
|
|
18
|
-
try {
|
|
19
|
-
return JSON.parse(Buffer.from(git.config("--local", "npm.hash"), "base64").toString("utf8"));
|
|
20
|
-
} catch {
|
|
21
|
-
return "";
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function shouldReinstall() {
|
|
26
|
-
return !isEqual(getDeps(), getDepsFromHash());
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function refreshMetadata() {
|
|
30
|
-
git.config("--local", "npm.hash", `${getHash()}`);
|
|
31
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import axiosRetry from "axios-retry";
|
|
2
|
-
|
|
3
|
-
import { getConfig } from "../../get-config.js";
|
|
4
|
-
import { httpRequest } from "../http/http-request.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Trigger a Directus Flow
|
|
8
|
-
*
|
|
9
|
-
* @param {string} projectId - The project identifier to send to the flow
|
|
10
|
-
* @param {string[]} versions - The versions list to send to the flow
|
|
11
|
-
* @param {object} [opts] - Additional request options (e.g., rejectUnauthorized)
|
|
12
|
-
* @returns {Promise<unknown>} The parsed JSON response
|
|
13
|
-
*/
|
|
14
|
-
export async function triggerDirectusFlow(projectId, versions, opts = {}) {
|
|
15
|
-
const { DIRECTUS_URL, DIRECTUS_FLOW_ID, DIRECTUS_ACCESS_TOKEN } = getConfig();
|
|
16
|
-
|
|
17
|
-
const endpoint = `${DIRECTUS_URL}/flows/trigger/${DIRECTUS_FLOW_ID}`;
|
|
18
|
-
|
|
19
|
-
const options = {
|
|
20
|
-
method: "post",
|
|
21
|
-
callee: "DIRECTUS",
|
|
22
|
-
headers: {
|
|
23
|
-
Authorization: `Bearer ${DIRECTUS_ACCESS_TOKEN}`,
|
|
24
|
-
"Content-Type": "application/json"
|
|
25
|
-
},
|
|
26
|
-
data: {
|
|
27
|
-
projectId,
|
|
28
|
-
versions
|
|
29
|
-
},
|
|
30
|
-
retries: 3,
|
|
31
|
-
retryDelay: axiosRetry.exponentialDelay,
|
|
32
|
-
...opts
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
if (options.data && options.headers?.["Content-Type"] === "application/json") {
|
|
36
|
-
options.data = JSON.stringify(options.data);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return httpRequest(endpoint, options);
|
|
40
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
// Use vi.hoisted to create mock references that are available to mock factories
|
|
2
|
-
const httpRequestMock = vi.hoisted(() => vi.fn());
|
|
3
|
-
|
|
4
|
-
// Mock get-config to provide DIRECTUS_* env values
|
|
5
|
-
vi.mock("../../get-config.js", () => ({
|
|
6
|
-
getConfig: () => ({
|
|
7
|
-
DIRECTUS_URL: "https://directus.example.com",
|
|
8
|
-
DIRECTUS_FLOW_ID: "flow-123",
|
|
9
|
-
DIRECTUS_ACCESS_TOKEN: "token-abc"
|
|
10
|
-
})
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
// Spy/mock for httpRequest
|
|
14
|
-
vi.mock("../http/http-request.js", () => ({
|
|
15
|
-
httpRequest: httpRequestMock
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
|
-
// Now import the SUT after mocks are in place
|
|
19
|
-
import { triggerDirectusFlow } from "./directus-flow.js";
|
|
20
|
-
|
|
21
|
-
describe("triggerDirectusFlow", () => {
|
|
22
|
-
beforeEach(() => {
|
|
23
|
-
httpRequestMock.mockReset();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("should call httpRequest with the expected endpoint, headers and body", async () => {
|
|
27
|
-
httpRequestMock.mockResolvedValue({ ok: true, data: { status: "queued" } });
|
|
28
|
-
|
|
29
|
-
const projectId = "CMAB";
|
|
30
|
-
const versions = ["2.3.0", "2.2.0"];
|
|
31
|
-
const opts = { rejectUnauthorized: true };
|
|
32
|
-
|
|
33
|
-
const result = await triggerDirectusFlow(projectId, versions, opts);
|
|
34
|
-
|
|
35
|
-
expect(result).toEqual({ ok: true, data: { status: "queued" } });
|
|
36
|
-
|
|
37
|
-
expect(httpRequestMock).toHaveBeenCalledTimes(1);
|
|
38
|
-
|
|
39
|
-
const expectedEndpoint = "https://directus.example.com/flows/trigger/flow-123";
|
|
40
|
-
const expectedBody = JSON.stringify({ projectId, versions });
|
|
41
|
-
|
|
42
|
-
expect(httpRequestMock).toHaveBeenCalledWith(
|
|
43
|
-
expectedEndpoint,
|
|
44
|
-
expect.objectContaining({
|
|
45
|
-
method: "post",
|
|
46
|
-
callee: "DIRECTUS",
|
|
47
|
-
rejectUnauthorized: true,
|
|
48
|
-
headers: expect.objectContaining({
|
|
49
|
-
Authorization: "Bearer token-abc",
|
|
50
|
-
"Content-Type": "application/json"
|
|
51
|
-
}),
|
|
52
|
-
data: expectedBody
|
|
53
|
-
})
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("should propagate errors from httpRequest", async () => {
|
|
58
|
-
httpRequestMock.mockRejectedValue(new Error("network error"));
|
|
59
|
-
|
|
60
|
-
await expect(triggerDirectusFlow("CMAB", ["1.0.0"])).rejects.toThrow("network error");
|
|
61
|
-
});
|
|
62
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
2
|
-
|
|
3
|
-
import { getConfig } from "../../get-config.js";
|
|
4
|
-
|
|
5
|
-
const { HTTPS_PROXY } = getConfig();
|
|
6
|
-
|
|
7
|
-
export const getHttpProxy = (opts) => {
|
|
8
|
-
if (HTTPS_PROXY) {
|
|
9
|
-
console.debug({
|
|
10
|
-
message: `Using proxy agent for ${opts.callee} requests`,
|
|
11
|
-
value: HTTPS_PROXY
|
|
12
|
-
});
|
|
13
|
-
return new HttpsProxyAgent(HTTPS_PROXY, opts);
|
|
14
|
-
}
|
|
15
|
-
};
|