@cmflow/cli 3.3.0 → 3.4.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/.yarn/install-state.gz +0 -0
- package/.yarn/releases/yarn-4.18.0.cjs +1000 -0
- package/.yarnrc.yml +8 -1
- package/bin/cm-checkfeatures.ts +10 -0
- package/bin/cm-clean.ts +10 -0
- package/bin/cm-config.ts +10 -0
- package/bin/cm-deploy.ts +10 -0
- package/bin/{cm-expedit.js → cm-expedit.ts} +4 -4
- package/bin/cm-fetch.ts +10 -0
- package/bin/cm-finish.ts +10 -0
- package/bin/cm-jira-releases.ts +10 -0
- package/bin/cm-merge.ts +10 -0
- package/bin/cm-publish.ts +10 -0
- package/bin/cm-pull.ts +8 -0
- package/bin/cm-push.ts +10 -0
- package/bin/cm-rebase.ts +10 -0
- package/bin/{cmrelease.js → cm-release.ts} +0 -0
- package/bin/cm-republish.ts +10 -0
- package/bin/cm-start.ts +10 -0
- package/bin/cm.ts +40 -0
- package/dist/bin/cm.mjs +74985 -0
- package/dist/bin/cmrelease.mjs +72397 -0
- package/dist/cli-truncate-BmHD4ngn.mjs +152 -0
- package/dist/cli-truncate-CXNquMRK.mjs +152 -0
- package/dist/cli-truncate-DbOyuy2e.mjs +2 -0
- package/dist/cli-truncate-DbOyuy2e.mjs.map +1 -0
- package/dist/common-CwPbT3So.mjs +66 -0
- package/dist/common-CwPbT3So.mjs.map +1 -0
- package/dist/docker-clean-tags-Cd-E8IqJ.mjs +2 -0
- package/dist/docker-clean-tags-Cd-E8IqJ.mjs.map +1 -0
- package/dist/docker-publish-B0E0qYYB.mjs +2 -0
- package/dist/docker-publish-B0E0qYYB.mjs.map +1 -0
- package/dist/get-config-DoOyLztI.mjs +41 -0
- package/dist/get-config-DoOyLztI.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-eFfEkHwo.mjs +682 -0
- package/dist/log-update-B2GqeeDd.mjs +497 -0
- package/dist/log-update-BldA9lkm.mjs +497 -0
- package/dist/log-update-By8Z-mak.mjs +6 -0
- package/dist/log-update-By8Z-mak.mjs.map +1 -0
- package/dist/rolldown-runtime-B4iAMlE-.mjs +35 -0
- package/dist/semver-D8gwMSFO.mjs +2 -0
- package/dist/semver-D8gwMSFO.mjs.map +1 -0
- package/dist/src/index.mjs +18 -0
- package/dist/src/index.mjs.map +1 -0
- package/dist/src/semantic/core/analyze-commits.mjs +2 -0
- package/dist/src/semantic/core/analyze-commits.mjs.map +1 -0
- package/dist/src/semantic/core/conditional.mjs +2 -0
- package/dist/src/semantic/core/conditional.mjs.map +1 -0
- package/dist/src/semantic/core/exit.mjs +2 -0
- package/dist/src/semantic/core/exit.mjs.map +1 -0
- package/dist/src/semantic/core/prepare/bump-version.mjs +48 -0
- package/dist/src/semantic/core/prepare/bump-version.mjs.map +1 -0
- package/dist/src/semantic/core/prepare/commit.mjs +2 -0
- package/dist/src/semantic/core/prepare/commit.mjs.map +1 -0
- package/dist/src/semantic/core/prepare/release-info.mjs +2 -0
- package/dist/src/semantic/core/prepare/release-info.mjs.map +1 -0
- package/dist/src/semantic/core/run.mjs +2 -0
- package/dist/src/semantic/core/run.mjs.map +1 -0
- package/dist/src/semantic/core/sync-repository.mjs +2 -0
- package/dist/src/semantic/core/sync-repository.mjs.map +1 -0
- package/dist/src/semantic/core/verify-conditions.mjs +2 -0
- package/dist/src/semantic/core/verify-conditions.mjs.map +1 -0
- package/dist/src/semantic/core/verify-release.mjs +2 -0
- package/dist/src/semantic/core/verify-release.mjs.map +1 -0
- package/dist/src/semantic/docker/publish.mjs +2 -0
- package/dist/src/semantic/docker/publish.mjs.map +1 -0
- package/dist/src/semantic/docker/success.mjs +2 -0
- package/dist/src/semantic/docker/success.mjs.map +1 -0
- package/dist/strip-ansi-Aeu5cmZe.mjs +174 -0
- package/dist/strip-ansi-Cl0pRo-s.mjs +2 -0
- package/dist/strip-ansi-Cl0pRo-s.mjs.map +1 -0
- package/dist/wrap-ansi-BeIjar2W.mjs +2 -0
- package/dist/wrap-ansi-CWIezXNl.mjs +330 -0
- package/dist/wrap-ansi-DsMb4WnZ.mjs +9 -0
- package/dist/wrap-ansi-DsMb4WnZ.mjs.map +1 -0
- package/dist/wrap-ansi-T0rz0Urp.mjs +330 -0
- package/package.json +47 -38
- package/release.config.mjs +6 -6
- package/src/commands/checkfeatures.ts +39 -0
- package/src/commands/clean.ts +36 -0
- package/src/commands/config.ts +31 -0
- package/src/commands/deploy.ts +39 -0
- package/src/commands/fetch.ts +30 -0
- package/src/commands/finish.ts +50 -0
- package/src/commands/{index.js → index.ts} +1 -0
- package/src/commands/jira-releases.ts +97 -0
- package/src/commands/merge.ts +58 -0
- package/src/commands/prompts/{branches.js → branches.ts} +13 -5
- package/src/commands/pull.ts +44 -0
- package/src/commands/push.ts +48 -0
- package/src/commands/rebase.ts +56 -0
- package/src/commands/republish.ts +34 -0
- package/src/commands/start.ts +123 -0
- package/src/commands/tasks/{merge-branch.js → merge-branch.ts} +18 -3
- package/src/commands/tasks/push-branch.ts +19 -0
- package/src/commands/tasks/{rebase-all-branches.js → rebase-all-branches.ts} +10 -2
- package/src/commands/tasks/{refresh-repository.js → refresh-repository.ts} +8 -4
- package/src/commands/tasks/run-test.ts +28 -0
- package/src/commands/tasks/{update-branch.js → update-branch.ts} +15 -9
- package/src/commands/tasks/{update-dependencies.js → update-dependencies.ts} +4 -3
- package/src/common/back/directus/{directus-flow.test.js → directus-flow.test.ts} +1 -0
- package/src/common/back/directus/{directus-flow.js → directus-flow.ts} +10 -2
- package/src/common/back/http/{http-proxy.js → http-proxy.ts} +7 -1
- package/src/common/back/http/{http-request.spec.js → http-request.spec.ts} +8 -7
- package/src/common/back/http/{http-request.js → http-request.ts} +16 -19
- package/src/common/back/jira/{get-sorted-releases.js → get-sorted-releases.ts} +2 -2
- package/src/common/back/jira/{jira-releases.js → jira-releases.ts} +14 -3
- package/src/common/back/jira/{jira-request.js → jira-request.ts} +9 -1
- package/src/common/back/jira/{jira-search.js → jira-search.ts} +2 -2
- package/src/common/cli/{bun.test.js → bun.test.ts} +17 -10
- package/src/common/cli/{bun.js → bun.ts} +4 -4
- package/src/common/cli/cli.ts +127 -0
- package/src/common/cli/{docker.test.js → docker.test.ts} +22 -14
- package/src/common/cli/{docker.js → docker.ts} +6 -6
- package/src/common/cli/{git.test.js → git.test.ts} +19 -11
- package/src/common/cli/{git.js → git.ts} +24 -24
- package/src/common/cli/{lerna.test.js → lerna.test.ts} +18 -11
- package/src/common/cli/{lerna.js → lerna.ts} +4 -4
- package/src/common/cli/{npm.test.js → npm.test.ts} +17 -10
- package/src/common/cli/{npm.js → npm.ts} +4 -4
- package/src/common/cli/{pnpm.test.js → pnpm.test.ts} +17 -10
- package/src/common/cli/{pnpm.js → pnpm.ts} +4 -4
- package/src/common/cli/{yarn.test.js → yarn.test.ts} +17 -12
- package/src/common/cli/{yarn.js → yarn.ts} +4 -4
- package/src/common/configure-git-workspace.ts +39 -0
- package/src/common/{get-config.js → get-config.ts} +3 -1
- package/src/common/{get-package-json.js → get-package-json.ts} +1 -0
- package/src/common/{get-package-manager.js → get-package-manager.ts} +1 -0
- package/src/common/{get-release-config.js → get-release-config.ts} +1 -0
- package/src/common/{index.js → index.ts} +1 -0
- package/src/common/{run-command.test.js → run-command.test.ts} +1 -0
- package/src/common/run-command.ts +67 -0
- package/src/common/types.ts +26 -0
- package/src/common/vendor.d.ts +4 -0
- package/src/{index.js → index.ts} +5 -1
- package/src/semantic/core/{analyze-commits.js → analyze-commits.ts} +7 -3
- package/src/semantic/core/{conditional.js → conditional.ts} +16 -9
- package/src/semantic/core/{exit.js → exit.ts} +3 -2
- package/src/semantic/core/prepare/{bump-version.js → bump-version.ts} +11 -8
- package/src/semantic/core/prepare/{commit.js → commit.ts} +3 -2
- package/src/semantic/core/prepare/release-info.ts +6 -0
- package/src/semantic/core/{run.js → run.ts} +3 -2
- package/src/semantic/core/sync-repository.ts +55 -0
- package/src/semantic/core/{verify-conditions.js → verify-conditions.ts} +4 -3
- package/src/semantic/core/{verify-release.js → verify-release.ts} +2 -1
- package/src/semantic/docker/publish.ts +6 -0
- package/src/semantic/docker/{success.js → success.ts} +2 -1
- package/src/semantic/utils/{bump-packages-version.test.js → bump-packages-version.test.ts} +1 -0
- package/src/semantic/utils/{bump-packages-version.js → bump-packages-version.ts} +12 -11
- package/src/semantic/utils/{calculate-snapshot-version.test.js → calculate-snapshot-version.test.ts} +10 -8
- package/src/semantic/utils/calculate-snapshot-version.ts +17 -0
- package/src/semantic/utils/display-package-info.ts +12 -0
- package/src/semantic/utils/display-release-info.ts +13 -0
- package/src/semantic/utils/{docker-clean-tags.test.js → docker-clean-tags.test.ts} +1 -0
- package/src/semantic/utils/{docker-clean-tags.js → docker-clean-tags.ts} +11 -4
- package/src/semantic/utils/{docker-publish.test.js → docker-publish.test.ts} +1 -0
- package/src/semantic/utils/{docker-publish.js → docker-publish.ts} +4 -3
- package/src/semantic/utils/{log-section.js → log-section.ts} +5 -1
- package/src/semantic/utils/{transform-writer.js → transform-writer.ts} +37 -13
- package/tsconfig.build.json +29 -0
- package/tsconfig.json +8 -15
- package/tsdown.config.ts +63 -0
- package/vitest.config.mts +2 -3
- package/.yarn/releases/yarn-4.7.0.cjs +0 -935
- 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-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/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/jira-releases.js +0 -62
- package/src/commands/merge.js +0 -41
- package/src/commands/pull.js +0 -30
- package/src/commands/push.js +0 -23
- package/src/commands/rebase.js +0 -35
- package/src/commands/republish.js +0 -21
- package/src/commands/start.js +0 -109
- package/src/commands/tasks/push-branch.js +0 -10
- package/src/commands/tasks/run-test.js +0 -21
- package/src/common/cli/cli.js +0 -110
- package/src/common/configure-git-workspace.js +0 -26
- package/src/common/run-command.js +0 -64
- package/src/semantic/core/prepare/release-info.js +0 -5
- package/src/semantic/core/sync-repository.js +0 -52
- package/src/semantic/docker/publish.js +0 -5
- package/src/semantic/utils/calculate-snapshot-version.js +0 -15
- package/src/semantic/utils/display-package-info.js +0 -11
- package/src/semantic/utils/display-release-info.js +0 -12
- /package/src/commands/{release.js → release.ts} +0 -0
- /package/src/commands/utils/{check-install.js → check-install.ts} +0 -0
- /package/src/common/back/jira/{jira-request.spec.js → jira-request.spec.ts} +0 -0
- /package/src/common/back/jira/{jira-search.spec.js → jira-search.spec.ts} +0 -0
- /package/src/semantic/{define-config.js → define-config.ts} +0 -0
- /package/src/semantic/utils/{release-rules.js → release-rules.ts} +0 -0
- /package/src/workflow/{index.js → index.ts} +0 -0
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import * as commitAnalyzerPlugins from "@semantic-release/commit-analyzer";
|
|
2
|
+
import type { ReleaseType } from "semantic-release";
|
|
3
|
+
import type { SemanticContext } from "../../common/types.js";
|
|
2
4
|
|
|
3
5
|
import { calculateSnapshotVersion } from "../utils/calculate-snapshot-version.js";
|
|
4
6
|
|
|
5
|
-
export async function analyzeCommits(pluginConfig, context) {
|
|
7
|
+
export async function analyzeCommits(pluginConfig: Record<string, unknown>, context: SemanticContext) {
|
|
6
8
|
if (context.branch && context.branch.type !== "prerelease") {
|
|
7
9
|
return commitAnalyzerPlugins.analyzeCommits(pluginConfig, context);
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
const analyzedCommits = await commitAnalyzerPlugins.analyzeCommits(pluginConfig, context);
|
|
11
13
|
context.nextRelease = context.nextRelease || {};
|
|
12
|
-
context.nextRelease.type = analyzedCommits;
|
|
14
|
+
context.nextRelease.type = (analyzedCommits ?? undefined) as ReleaseType;
|
|
13
15
|
context.nextRelease.version = calculateSnapshotVersion(context);
|
|
14
|
-
context.lastRelease
|
|
16
|
+
if (context.lastRelease) {
|
|
17
|
+
(context.lastRelease as { version: string | null }).version = null;
|
|
18
|
+
}
|
|
15
19
|
|
|
16
20
|
return "patch";
|
|
17
21
|
}
|
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
import { getConfig } from "../../common/index.js";
|
|
2
|
+
import type { SemanticContext } from "../../common/types.js";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
interface ConditionalPluginConfig {
|
|
5
|
+
when?: (context: SemanticContext) => boolean;
|
|
6
|
+
run?: string | string[];
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function prepare(pluginConfig: ConditionalPluginConfig, context: SemanticContext) {
|
|
4
11
|
return runAll("prepare", pluginConfig, context, context.branch?.type === "release");
|
|
5
12
|
}
|
|
6
13
|
|
|
7
|
-
export function success(pluginConfig, context) {
|
|
14
|
+
export function success(pluginConfig: ConditionalPluginConfig, context: SemanticContext) {
|
|
8
15
|
return runAll("success", pluginConfig, context, context.branch?.type === "release");
|
|
9
16
|
}
|
|
10
17
|
|
|
11
|
-
export function publish(pluginConfig, context) {
|
|
18
|
+
export function publish(pluginConfig: ConditionalPluginConfig, context: SemanticContext) {
|
|
12
19
|
return runAll("publish", pluginConfig, context, context.branch?.type === "release");
|
|
13
20
|
}
|
|
14
21
|
|
|
15
|
-
export function generateNotes(pluginConfig, context) {
|
|
22
|
+
export function generateNotes(pluginConfig: ConditionalPluginConfig, context: SemanticContext) {
|
|
16
23
|
return runAll("generateNotes", pluginConfig, context, context.branch?.type === "release");
|
|
17
24
|
}
|
|
18
25
|
|
|
19
|
-
export function fail(pluginConfig, context) {
|
|
26
|
+
export function fail(pluginConfig: ConditionalPluginConfig, context: SemanticContext) {
|
|
20
27
|
return runAll("fail", pluginConfig, context, context.branch?.type === "release");
|
|
21
28
|
}
|
|
22
29
|
|
|
23
|
-
async function runAll(step, pluginConfig, context, defaultCondition) {
|
|
30
|
+
async function runAll(step: string, pluginConfig: ConditionalPluginConfig, context: SemanticContext, defaultCondition: boolean) {
|
|
24
31
|
context.config = getConfig();
|
|
25
32
|
|
|
26
33
|
const condition = pluginConfig.when !== undefined ? pluginConfig.when(context) : defaultCondition;
|
|
@@ -31,15 +38,15 @@ async function runAll(step, pluginConfig, context, defaultCondition) {
|
|
|
31
38
|
}
|
|
32
39
|
|
|
33
40
|
if (pluginConfig.run) {
|
|
34
|
-
const tasks = [].concat(pluginConfig.run);
|
|
41
|
+
const tasks: string[] = ([] as string[]).concat(pluginConfig.run as string);
|
|
35
42
|
|
|
36
43
|
for (const task of tasks) {
|
|
37
44
|
if (typeof task === "string") {
|
|
38
|
-
const mod = await import(task)
|
|
45
|
+
const mod = (await import(task)) as Record<string, (config: unknown, ctx: unknown) => Promise<void>>;
|
|
39
46
|
const taskFunction = mod[step];
|
|
40
47
|
|
|
41
48
|
if (taskFunction) {
|
|
42
|
-
context.logger.
|
|
49
|
+
context.logger.info(` Start conditional step "${step}" of plugin "${task}"`);
|
|
43
50
|
|
|
44
51
|
try {
|
|
45
52
|
await taskFunction(pluginConfig, context);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { getConfig } from "../../common/index.js";
|
|
2
|
+
import type { SemanticContext } from "../../common/types.js";
|
|
2
3
|
|
|
3
|
-
export default async function exit(pluginConfig, context) {
|
|
4
|
+
export default async function exit(pluginConfig: Record<string, unknown>, context: SemanticContext) {
|
|
4
5
|
context.config = getConfig();
|
|
5
|
-
const condition = pluginConfig.when !== undefined ? pluginConfig.when(context) : true;
|
|
6
|
+
const condition = pluginConfig.when !== undefined ? (pluginConfig.when as (ctx: SemanticContext) => boolean)(context) : true;
|
|
6
7
|
|
|
7
8
|
if (condition) {
|
|
8
9
|
// avoid next semantic-release steps when is a prerelease or release branch with SKIP_GITHUB_PUBLISH
|
|
@@ -1,36 +1,39 @@
|
|
|
1
1
|
import { getConfig, getPackageManager, lerna } from "../../../common/index.js";
|
|
2
2
|
import { bumpPackagesVersion } from "../../utils/bump-packages-version.js";
|
|
3
|
+
import type { SemanticContext } from "../../../common/types.js";
|
|
3
4
|
|
|
4
|
-
export async function prepare(_, context) {
|
|
5
|
+
export async function prepare(_: unknown, context: SemanticContext) {
|
|
5
6
|
context.config = getConfig();
|
|
6
7
|
const {
|
|
7
8
|
config: { PACKAGE_MANAGER, HAS_LERNA, BUMP_METHOD, WORKSPACES },
|
|
8
9
|
logger
|
|
9
10
|
} = context;
|
|
10
|
-
const versionPackageManager = PACKAGE_MANAGER === "yarn" ? "npm" : PACKAGE_MANAGER;
|
|
11
|
+
const versionPackageManager = PACKAGE_MANAGER === "yarn" ? "npm" : (PACKAGE_MANAGER as string);
|
|
11
12
|
|
|
12
13
|
logger.info(`Start bump version for all packages using method: ${BUMP_METHOD}`);
|
|
13
14
|
|
|
15
|
+
const version = context.nextRelease?.version ?? "";
|
|
16
|
+
|
|
14
17
|
switch (BUMP_METHOD) {
|
|
15
18
|
case "native":
|
|
16
19
|
logger.info("Using package manager");
|
|
17
|
-
getPackageManager(PACKAGE_MANAGER).newVersion(
|
|
20
|
+
getPackageManager(PACKAGE_MANAGER as string).newVersion(version);
|
|
18
21
|
break;
|
|
19
22
|
case "lerna":
|
|
20
23
|
if (HAS_LERNA) {
|
|
21
|
-
await lerna.newVersion(
|
|
24
|
+
await lerna.newVersion(version);
|
|
22
25
|
}
|
|
23
26
|
break;
|
|
24
27
|
case "cmflow":
|
|
25
|
-
await bumpPackagesVersion(
|
|
26
|
-
await getPackageManager(PACKAGE_MANAGER).install();
|
|
28
|
+
await bumpPackagesVersion(version, WORKSPACES as string[]);
|
|
29
|
+
await getPackageManager(PACKAGE_MANAGER as string).install();
|
|
27
30
|
break;
|
|
28
31
|
case "native:lerna":
|
|
29
32
|
default:
|
|
30
|
-
getPackageManager(versionPackageManager).newVersion(
|
|
33
|
+
getPackageManager(versionPackageManager).newVersion(version);
|
|
31
34
|
|
|
32
35
|
if (HAS_LERNA) {
|
|
33
|
-
await lerna.newVersion(
|
|
36
|
+
await lerna.newVersion(version);
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { configureGitWorkspace, getConfig, git } from "../../../common/index.js";
|
|
2
|
+
import type { SemanticContext } from "../../../common/types.js";
|
|
2
3
|
|
|
3
|
-
export async function prepare(pluginConfig, context) {
|
|
4
|
+
export async function prepare(pluginConfig: Record<string, unknown>, context: SemanticContext) {
|
|
4
5
|
context.config = getConfig();
|
|
5
6
|
|
|
6
7
|
const {
|
|
@@ -18,7 +19,7 @@ export async function prepare(pluginConfig, context) {
|
|
|
18
19
|
logger.info("Get commit stage status");
|
|
19
20
|
git.status();
|
|
20
21
|
|
|
21
|
-
const revisionMessage = `chore: ${CI_NAME} build ${context.branch.name} ${BUILD_NUMBER} ${context.nextRelease
|
|
22
|
+
const revisionMessage = `chore: ${CI_NAME} build ${context.branch.name} ${BUILD_NUMBER} ${context.nextRelease?.gitTag} [ci skip]`;
|
|
22
23
|
|
|
23
24
|
logger.info("Commit changes with revision message: ");
|
|
24
25
|
logger.info(revisionMessage);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { writeFile } from "node:fs/promises";
|
|
2
|
+
import type { SemanticContext } from "../../../common/types.js";
|
|
3
|
+
|
|
4
|
+
export function prepare(pluginConfig: { path: string }, context: SemanticContext) {
|
|
5
|
+
return writeFile(pluginConfig.path, context.branch.name, { encoding: "utf-8" });
|
|
6
|
+
}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { getConfig, getPackageManager } from "../../common/index.js";
|
|
2
|
+
import type { SemanticContext } from "../../common/types.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @param pluginConfig {{command: string}}
|
|
5
6
|
* @param context
|
|
6
7
|
* @return {Promise<void>}
|
|
7
8
|
*/
|
|
8
|
-
export default async function runCommand(pluginConfig, context) {
|
|
9
|
+
export default async function runCommand(pluginConfig: { command: string }, context: SemanticContext) {
|
|
9
10
|
context.config = getConfig();
|
|
10
11
|
const {
|
|
11
12
|
config: { PACKAGE_MANAGER },
|
|
12
13
|
logger
|
|
13
14
|
} = context;
|
|
14
15
|
|
|
15
|
-
const pkgManager = getPackageManager(PACKAGE_MANAGER);
|
|
16
|
+
const pkgManager = getPackageManager(PACKAGE_MANAGER as string);
|
|
16
17
|
|
|
17
18
|
logger.info(`Start ${pluginConfig.command} task`);
|
|
18
19
|
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { getConfig, git } from "../../common/index.js";
|
|
2
|
+
import type { SemanticContext } from "../../common/types.js";
|
|
3
|
+
|
|
4
|
+
export default async function syncRepository(pluginConfig: Record<string, unknown>, context: SemanticContext) {
|
|
5
|
+
context.config = getConfig();
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
logger,
|
|
9
|
+
config: { PRODUCTION_BRANCH, ORIGIN, DEVELOP_BRANCH }
|
|
10
|
+
} = context;
|
|
11
|
+
|
|
12
|
+
logger.info("Prepare release");
|
|
13
|
+
|
|
14
|
+
async function asyncCatchError(fn: () => unknown) {
|
|
15
|
+
try {
|
|
16
|
+
return await fn();
|
|
17
|
+
} catch (er) {
|
|
18
|
+
context.logger.error(String(er), (er as Error).stack);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
await asyncCatchError(() => git.fetch());
|
|
23
|
+
|
|
24
|
+
const branchesOption = context.options?.branches;
|
|
25
|
+
const branchesArray = Array.isArray(branchesOption) ? branchesOption : branchesOption ? [branchesOption] : [];
|
|
26
|
+
const candidateBranches =
|
|
27
|
+
(pluginConfig.includes as string[] | undefined) ||
|
|
28
|
+
branchesArray.map((branch: string | { name?: string }) => {
|
|
29
|
+
return (branch as { name?: string }).name || (branch as string);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
logger.info(`Candidate branches to sync: ${(candidateBranches as string[]).join(", ")}`);
|
|
33
|
+
|
|
34
|
+
if ((candidateBranches as string[]).includes(context.branch.name)) {
|
|
35
|
+
logger.info(`Push ${context.branch.name}`);
|
|
36
|
+
|
|
37
|
+
await asyncCatchError(() => {
|
|
38
|
+
logger.info(`git push --quiet --set-upstream ${ORIGIN} ${context.branch.name}`);
|
|
39
|
+
|
|
40
|
+
return git.push("--quiet", "--set-upstream", ORIGIN as string, context.branch.name);
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
logger.info(`Skip push for ${context.branch.name}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (PRODUCTION_BRANCH !== DEVELOP_BRANCH) {
|
|
47
|
+
logger.info(`Sync ${DEVELOP_BRANCH} with ${PRODUCTION_BRANCH}`);
|
|
48
|
+
logger.info(`git push -f ${ORIGIN} ${PRODUCTION_BRANCH}:refs/heads/${DEVELOP_BRANCH}`);
|
|
49
|
+
|
|
50
|
+
await asyncCatchError(async () => {
|
|
51
|
+
await git.push("-f", ORIGIN as string, `${PRODUCTION_BRANCH}:refs/heads/${DEVELOP_BRANCH}`);
|
|
52
|
+
logger.success(`${ORIGIN}/${DEVELOP_BRANCH} branch correctly updated`);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
|
|
3
3
|
import { getConfig, git } from "../../common/index.js";
|
|
4
|
+
import type { SemanticContext } from "../../common/types.js";
|
|
4
5
|
|
|
5
|
-
export function verifyConditions(pluginConfig, context) {
|
|
6
|
+
export function verifyConditions(pluginConfig: Record<string, unknown>, context: SemanticContext) {
|
|
6
7
|
if (pluginConfig.dryRun) {
|
|
7
8
|
return;
|
|
8
9
|
}
|
|
@@ -16,8 +17,8 @@ export function verifyConditions(pluginConfig, context) {
|
|
|
16
17
|
if (USER && EMAIL) {
|
|
17
18
|
context.logger.info("Configure git with username");
|
|
18
19
|
|
|
19
|
-
git.config("--global", "user.name", USER);
|
|
20
|
-
git.config("--global", "user.email", EMAIL);
|
|
20
|
+
git.config("--global", "user.name", USER as string);
|
|
21
|
+
git.config("--global", "user.email", EMAIL as string);
|
|
21
22
|
|
|
22
23
|
context.logger.info("Configure git branch");
|
|
23
24
|
context.logger.success("Workspace is correctly configured");
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { getConfig } from "../../common/index.js";
|
|
2
2
|
import { displayPackageInfo } from "../utils/display-package-info.js";
|
|
3
3
|
import { displayReleaseInfo } from "../utils/display-release-info.js";
|
|
4
|
+
import type { SemanticContext } from "../../common/types.js";
|
|
4
5
|
|
|
5
|
-
export function verifyRelease(pluginConfig, context) {
|
|
6
|
+
export function verifyRelease(pluginConfig: Record<string, unknown>, context: SemanticContext) {
|
|
6
7
|
context.config = getConfig();
|
|
7
8
|
displayPackageInfo(context);
|
|
8
9
|
displayReleaseInfo(context);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { CmContext } from "../../common/types.js";
|
|
1
2
|
import { dockerCleanTags } from "../utils/docker-clean-tags.js";
|
|
2
3
|
|
|
3
|
-
export async function success(
|
|
4
|
+
export async function success(_: Record<string, unknown>, context: CmContext) {
|
|
4
5
|
try {
|
|
5
6
|
await dockerCleanTags(context);
|
|
6
7
|
} catch (er) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import fs from "fs-extra";
|
|
2
|
-
import globby from "globby";
|
|
2
|
+
import { globby } from "globby";
|
|
3
3
|
import { dirname } from "path";
|
|
4
4
|
|
|
5
5
|
const PACKAGE_JSON_PROPS = ["dependencies", "devDependencies", "peerDependencies"];
|
|
6
6
|
|
|
7
|
-
export async function bumpPackagesVersion(version, workspaces, cwd = process.cwd()) {
|
|
7
|
+
export async function bumpPackagesVersion(version: string, workspaces: string[], cwd = process.cwd()) {
|
|
8
8
|
const patterns = workspaces.map((path) => `${path}/package.json`).concat("package.json");
|
|
9
9
|
|
|
10
10
|
const files = await globby(patterns, {
|
|
@@ -12,13 +12,13 @@ export async function bumpPackagesVersion(version, workspaces, cwd = process.cwd
|
|
|
12
12
|
absolute: true
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
const names = new Set();
|
|
15
|
+
const names = new Set<string>();
|
|
16
16
|
|
|
17
17
|
const packages = await Promise.all(
|
|
18
|
-
files.map(async (file) => {
|
|
19
|
-
const pkg = await fs.readJson(file)
|
|
18
|
+
files.map(async (file: string) => {
|
|
19
|
+
const pkg = (await fs.readJson(file)) as Record<string, unknown>;
|
|
20
20
|
|
|
21
|
-
names.add(pkg.name);
|
|
21
|
+
names.add(pkg.name as string);
|
|
22
22
|
|
|
23
23
|
return {
|
|
24
24
|
file,
|
|
@@ -28,7 +28,7 @@ export async function bumpPackagesVersion(version, workspaces, cwd = process.cwd
|
|
|
28
28
|
);
|
|
29
29
|
|
|
30
30
|
return Promise.all(
|
|
31
|
-
packages.map(({ pkg, file }) => {
|
|
31
|
+
packages.map(({ pkg, file }: { pkg: Record<string, unknown>; file: string }) => {
|
|
32
32
|
pkg.version = version;
|
|
33
33
|
|
|
34
34
|
PACKAGE_JSON_PROPS.forEach((key) => bumpDependencies(pkg, key, version, names));
|
|
@@ -39,13 +39,14 @@ export async function bumpPackagesVersion(version, workspaces, cwd = process.cwd
|
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
function bumpDependencies(pkg, key, version, names) {
|
|
42
|
+
function bumpDependencies(pkg: Record<string, unknown>, key: string, version: string, names: Set<string>) {
|
|
43
43
|
pkg[key] = pkg[key] || {};
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
const deps = pkg[key] as Record<string, string>;
|
|
46
|
+
if (deps) {
|
|
46
47
|
names.forEach((name) => {
|
|
47
|
-
if (
|
|
48
|
-
|
|
48
|
+
if (deps[name] && !deps[name].startsWith("workspace:")) {
|
|
49
|
+
deps[name] = version;
|
|
49
50
|
}
|
|
50
51
|
});
|
|
51
52
|
}
|
package/src/semantic/utils/{calculate-snapshot-version.test.js → calculate-snapshot-version.test.ts}
RENAMED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { git, getConfig } from "../../common/index.js";
|
|
2
|
+
import type { CmContext } from "../../common/types";
|
|
3
|
+
import { calculateSnapshotVersion } from "./calculate-snapshot-version.js";
|
|
4
|
+
|
|
1
5
|
vi.mock("../../common/index.js", () => {
|
|
2
6
|
return {
|
|
3
7
|
git: {
|
|
@@ -6,19 +10,17 @@ vi.mock("../../common/index.js", () => {
|
|
|
6
10
|
getConfig: vi.fn()
|
|
7
11
|
};
|
|
8
12
|
});
|
|
9
|
-
const { git, getConfig } = await import("../../common/index.js");
|
|
10
|
-
const { calculateSnapshotVersion } = await import("./calculate-snapshot-version.js");
|
|
11
13
|
|
|
12
14
|
describe("calculateSnapshotVersion", () => {
|
|
13
15
|
beforeEach(() => {
|
|
14
|
-
git.getCommitTag.mockReturnValue("13246u");
|
|
15
|
-
getConfig.mockReturnValue({
|
|
16
|
+
vi.mocked(git.getCommitTag).mockReturnValue("13246u");
|
|
17
|
+
vi.mocked(getConfig).mockReturnValue({
|
|
16
18
|
DEPLOY_ON_DOCKER: true,
|
|
17
19
|
PRODUCTION_BRANCH: "production",
|
|
18
20
|
DOCKER_REPOSITORY: "owner",
|
|
19
21
|
DOCKER_HUB_ID: "login",
|
|
20
22
|
DOCKER_HUB_PWD: "password"
|
|
21
|
-
});
|
|
23
|
+
} as unknown as CmContext["config"]);
|
|
22
24
|
});
|
|
23
25
|
it("should return the snapshot version", () => {
|
|
24
26
|
const context = {
|
|
@@ -26,7 +28,7 @@ describe("calculateSnapshotVersion", () => {
|
|
|
26
28
|
lastRelease: {
|
|
27
29
|
version: "1.0.0"
|
|
28
30
|
}
|
|
29
|
-
};
|
|
31
|
+
} as CmContext;
|
|
30
32
|
|
|
31
33
|
const version = calculateSnapshotVersion(context);
|
|
32
34
|
expect(git.getCommitTag).toHaveBeenCalledWith(context.config.REF_COMMIT);
|
|
@@ -42,7 +44,7 @@ describe("calculateSnapshotVersion", () => {
|
|
|
42
44
|
config: {
|
|
43
45
|
REF_COMMIT: "REF_COMMIT"
|
|
44
46
|
}
|
|
45
|
-
};
|
|
47
|
+
} as CmContext;
|
|
46
48
|
|
|
47
49
|
const version = calculateSnapshotVersion(context);
|
|
48
50
|
expect(git.getCommitTag).toHaveBeenCalledWith(context.config.REF_COMMIT);
|
|
@@ -58,7 +60,7 @@ describe("calculateSnapshotVersion", () => {
|
|
|
58
60
|
config: {
|
|
59
61
|
REF_COMMIT: "REF_COMMIT"
|
|
60
62
|
}
|
|
61
|
-
};
|
|
63
|
+
} as CmContext;
|
|
62
64
|
|
|
63
65
|
const version = calculateSnapshotVersion(context);
|
|
64
66
|
expect(git.getCommitTag).toHaveBeenCalledWith(context.config.REF_COMMIT);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import semver from "semver";
|
|
2
|
+
|
|
3
|
+
import { getConfig, git } from "../../common/index.js";
|
|
4
|
+
import type { SemanticContext } from "../../common/types.js";
|
|
5
|
+
|
|
6
|
+
export function calculateSnapshotVersion(context: SemanticContext) {
|
|
7
|
+
context.config = getConfig();
|
|
8
|
+
const {
|
|
9
|
+
nextRelease,
|
|
10
|
+
lastRelease,
|
|
11
|
+
config: { REF_COMMIT }
|
|
12
|
+
} = context;
|
|
13
|
+
const parsed = semver.parse(lastRelease?.version ?? "0.0.0");
|
|
14
|
+
const { major, minor, patch } = parsed ?? { major: 0, minor: 0, patch: 0 };
|
|
15
|
+
|
|
16
|
+
return `${semver.inc(`${major}.${minor}.${patch}`, nextRelease?.type ?? "patch") ?? "0.0.0"}-beta${git.getCommitTag(REF_COMMIT as string)}`;
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { logSection } from "./log-section.js";
|
|
2
|
+
import type { SemanticContext } from "../../common/types.js";
|
|
3
|
+
|
|
4
|
+
export function displayPackageInfo(context: SemanticContext) {
|
|
5
|
+
logSection("Package Info", context);
|
|
6
|
+
context.logger.info("Name : " + context.config.PROJECT_NAME);
|
|
7
|
+
context.logger.info("Version : " + context.lastRelease?.version);
|
|
8
|
+
context.logger.info("Repository : " + context.config.REPOSITORY_URL);
|
|
9
|
+
context.logger.info("Branch : " + context.branch.name);
|
|
10
|
+
context.logger.info("Tag : " + context.lastRelease?.gitTag);
|
|
11
|
+
context.logger.info("GitHead : " + context.lastRelease?.gitHead);
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { logSection } from "./log-section.js";
|
|
2
|
+
import type { SemanticContext } from "../../common/types.js";
|
|
3
|
+
|
|
4
|
+
export function displayReleaseInfo(context: SemanticContext) {
|
|
5
|
+
logSection("Release Info", context);
|
|
6
|
+
context.logger.info("Branch : " + context.branch.name);
|
|
7
|
+
context.logger.info("Build N° : " + context.config.BUILD_NUMBER);
|
|
8
|
+
context.logger.info("Version : " + context.nextRelease?.version);
|
|
9
|
+
context.logger.info("Tag : " + context.nextRelease?.gitTag);
|
|
10
|
+
context.logger.info("GitHead : " + context.nextRelease?.gitHead);
|
|
11
|
+
context.logger.info("Type : " + context.nextRelease?.type);
|
|
12
|
+
context.logger.info("Channel : " + context.nextRelease?.channel);
|
|
13
|
+
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { docker } from "../../common/index.js";
|
|
2
|
+
import type { CmContext } from "../../common/types";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
interface DockerTag {
|
|
5
|
+
name: string;
|
|
6
|
+
last_updated: string | Date;
|
|
7
|
+
date?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function mapTags(tags: DockerTag[]) {
|
|
11
|
+
const mapped = tags
|
|
5
12
|
.map((tag) => {
|
|
6
13
|
return {
|
|
7
14
|
name: tag.name,
|
|
@@ -12,7 +19,7 @@ function mapTags(tags) {
|
|
|
12
19
|
|
|
13
20
|
let tagFound = false;
|
|
14
21
|
|
|
15
|
-
return
|
|
22
|
+
return mapped.reduce((result: typeof mapped, tag) => {
|
|
16
23
|
if (tag.name.match(/\d+\.\d+\.\d+/)) {
|
|
17
24
|
tagFound = true;
|
|
18
25
|
} else if (tagFound) {
|
|
@@ -22,7 +29,7 @@ function mapTags(tags) {
|
|
|
22
29
|
}, []);
|
|
23
30
|
}
|
|
24
31
|
|
|
25
|
-
export async function dockerCleanTags(context) {
|
|
32
|
+
export async function dockerCleanTags(context: CmContext) {
|
|
26
33
|
const {
|
|
27
34
|
logger,
|
|
28
35
|
config: { DOCKER_HUB_ID, DOCKER_HUB_PWD, DOCKER_REPOSITORY }
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { docker } from "../../common/cli/docker.js";
|
|
2
2
|
import { getConfig } from "../../common/get-config.js";
|
|
3
|
+
import type { SemanticContext } from "../../common/types.js";
|
|
3
4
|
|
|
4
|
-
export async function dockerPublish(context) {
|
|
5
|
+
export async function dockerPublish(context: SemanticContext) {
|
|
5
6
|
context.config = getConfig();
|
|
6
7
|
const {
|
|
7
8
|
logger,
|
|
8
9
|
config: { PRODUCTION_BRANCH, DOCKER_REPOSITORY, DOCKER_HUB_ID, DOCKER_HUB_PWD }
|
|
9
10
|
} = context;
|
|
10
11
|
|
|
11
|
-
docker.login("-u", DOCKER_HUB_ID, "-p", DOCKER_HUB_PWD);
|
|
12
|
+
docker.login("-u", DOCKER_HUB_ID as string, "-p", DOCKER_HUB_PWD as string);
|
|
12
13
|
|
|
13
14
|
const image =
|
|
14
15
|
PRODUCTION_BRANCH === context.branch.name
|
|
15
|
-
? `${DOCKER_REPOSITORY}:${context.nextRelease
|
|
16
|
+
? `${DOCKER_REPOSITORY}:${context.nextRelease?.version}`
|
|
16
17
|
: `${DOCKER_REPOSITORY}:${context.branch.name}`;
|
|
17
18
|
logger.info("context.branch.name : ", context.branch.name);
|
|
18
19
|
logger.info("context.nextRelease.version : ", context.nextRelease && context.nextRelease.version);
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
interface LogContext {
|
|
2
|
+
logger: { info: (...args: unknown[]) => void };
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function logSection(title: string, context: LogContext) {
|
|
2
6
|
context.logger.info("-----------------------------------");
|
|
3
7
|
context.logger.info(`--- ${title}`);
|
|
4
8
|
context.logger.info("-----------------------------------");
|
|
@@ -1,24 +1,48 @@
|
|
|
1
1
|
import { WORKFLOW_CONFIGURATION } from "../../workflow/index.js";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
type CommitTypeMapping = Record<string, string>;
|
|
4
|
+
|
|
5
|
+
const commitTypeMapping: CommitTypeMapping = WORKFLOW_CONFIGURATION.reduce(
|
|
6
|
+
(obj: CommitTypeMapping, { type, label }: { type: string; label: string }) => {
|
|
7
|
+
return {
|
|
8
|
+
...obj,
|
|
9
|
+
[type]: label
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
{} as CommitTypeMapping
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
interface Commit {
|
|
16
|
+
type: string;
|
|
17
|
+
message?: string;
|
|
18
|
+
subject?: string;
|
|
19
|
+
scope?: string;
|
|
20
|
+
hash?: string;
|
|
21
|
+
shortHash?: string;
|
|
22
|
+
notes: Array<{ title: string }>;
|
|
23
|
+
references: Array<{ issue: string }>;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface TransformContext {
|
|
28
|
+
repository?: string;
|
|
29
|
+
host?: string;
|
|
30
|
+
owner?: string;
|
|
31
|
+
repoUrl?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const transformCommitType = (commit: Commit): string => {
|
|
11
35
|
if (commitTypeMapping[commit.type]) {
|
|
12
36
|
return commitTypeMapping[commit.type];
|
|
13
37
|
}
|
|
14
38
|
|
|
15
|
-
return commitTypeMapping.
|
|
39
|
+
return commitTypeMapping["default"] ?? commit.type;
|
|
16
40
|
};
|
|
17
41
|
|
|
18
|
-
export function transformWriter(commit, context) {
|
|
42
|
+
export function transformWriter(commit: Commit, context: TransformContext) {
|
|
19
43
|
commit = { ...commit };
|
|
20
44
|
|
|
21
|
-
const issues = [];
|
|
45
|
+
const issues: string[] = [];
|
|
22
46
|
|
|
23
47
|
commit.notes.forEach((note) => {
|
|
24
48
|
note.title = "BREAKING CHANGES";
|
|
@@ -47,14 +71,14 @@ export function transformWriter(commit, context) {
|
|
|
47
71
|
if (url) {
|
|
48
72
|
url = `${url}/issues/`;
|
|
49
73
|
// Issue URLs.
|
|
50
|
-
commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => {
|
|
74
|
+
commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue: string) => {
|
|
51
75
|
issues.push(issue);
|
|
52
76
|
return `[#${issue}](${url}${issue})`;
|
|
53
77
|
});
|
|
54
78
|
}
|
|
55
79
|
if (context.host) {
|
|
56
80
|
// User URLs.
|
|
57
|
-
commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
|
|
81
|
+
commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username: string) => {
|
|
58
82
|
if (username.includes("/")) {
|
|
59
83
|
return `@${username}`;
|
|
60
84
|
}
|