intershell 0.3.0
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 +301 -0
- package/dist/commands/ci/act.d.ts +13 -0
- package/dist/commands/ci/act.d.ts.map +1 -0
- package/dist/commands/ci/act.js +89 -0
- package/dist/commands/ci/act.js.map +1 -0
- package/dist/commands/ci/attach-affected.d.ts +12 -0
- package/dist/commands/ci/attach-affected.d.ts.map +1 -0
- package/dist/commands/ci/attach-affected.js +83 -0
- package/dist/commands/ci/attach-affected.js.map +1 -0
- package/dist/commands/ci/attach-service-ports.d.ts +10 -0
- package/dist/commands/ci/attach-service-ports.d.ts.map +1 -0
- package/dist/commands/ci/attach-service-ports.js +25 -0
- package/dist/commands/ci/attach-service-ports.js.map +1 -0
- package/dist/commands/commit-check.d.ts +13 -0
- package/dist/commands/commit-check.d.ts.map +1 -0
- package/dist/commands/commit-check.js +110 -0
- package/dist/commands/commit-check.js.map +1 -0
- package/dist/commands/commit.d.ts +16 -0
- package/dist/commands/commit.d.ts.map +1 -0
- package/dist/commands/commit.js +91 -0
- package/dist/commands/commit.js.map +1 -0
- package/dist/commands/dev/check.d.ts +13 -0
- package/dist/commands/dev/check.d.ts.map +1 -0
- package/dist/commands/dev/check.js +91 -0
- package/dist/commands/dev/check.js.map +1 -0
- package/dist/commands/dev/cleanup.d.ts +10 -0
- package/dist/commands/dev/cleanup.d.ts.map +1 -0
- package/dist/commands/dev/cleanup.js +28 -0
- package/dist/commands/dev/cleanup.js.map +1 -0
- package/dist/commands/dev/rm.d.ts +12 -0
- package/dist/commands/dev/rm.d.ts.map +1 -0
- package/dist/commands/dev/rm.js +49 -0
- package/dist/commands/dev/rm.js.map +1 -0
- package/dist/commands/dev/setup.d.ts +10 -0
- package/dist/commands/dev/setup.d.ts.map +1 -0
- package/dist/commands/dev/setup.js +40 -0
- package/dist/commands/dev/setup.js.map +1 -0
- package/dist/commands/local/cleanup.d.ts +12 -0
- package/dist/commands/local/cleanup.d.ts.map +1 -0
- package/dist/commands/local/cleanup.js +62 -0
- package/dist/commands/local/cleanup.js.map +1 -0
- package/dist/commands/local/setup.d.ts +11 -0
- package/dist/commands/local/setup.d.ts.map +1 -0
- package/dist/commands/local/setup.js +55 -0
- package/dist/commands/local/setup.js.map +1 -0
- package/dist/commands/local/vscode.d.ts +17 -0
- package/dist/commands/local/vscode.d.ts.map +1 -0
- package/dist/commands/local/vscode.js +94 -0
- package/dist/commands/local/vscode.js.map +1 -0
- package/dist/commands/update-package-json.d.ts +12 -0
- package/dist/commands/update-package-json.d.ts.map +1 -0
- package/dist/commands/update-package-json.js +82 -0
- package/dist/commands/update-package-json.js.map +1 -0
- package/dist/commands/version/apply.d.ts +16 -0
- package/dist/commands/version/apply.d.ts.map +1 -0
- package/dist/commands/version/apply.js +120 -0
- package/dist/commands/version/apply.js.map +1 -0
- package/dist/commands/version/ci.d.ts +12 -0
- package/dist/commands/version/ci.d.ts.map +1 -0
- package/dist/commands/version/ci.js +67 -0
- package/dist/commands/version/ci.js.map +1 -0
- package/dist/commands/version/prepare.d.ts +19 -0
- package/dist/commands/version/prepare.d.ts.map +1 -0
- package/dist/commands/version/prepare.js +153 -0
- package/dist/commands/version/prepare.js.map +1 -0
- package/dist/core/colorify.d.ts +21 -0
- package/dist/core/colorify.d.ts.map +1 -0
- package/dist/core/colorify.js +56 -0
- package/dist/core/colorify.js.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +3 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/types.d.ts +181 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +5 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/wrapshell.d.ts +19 -0
- package/dist/core/wrapshell.d.ts.map +1 -0
- package/dist/core/wrapshell.js +323 -0
- package/dist/core/wrapshell.js.map +1 -0
- package/dist/entities/affected/affected.d.ts +4 -0
- package/dist/entities/affected/affected.d.ts.map +1 -0
- package/dist/entities/affected/affected.js +20 -0
- package/dist/entities/affected/affected.js.map +1 -0
- package/dist/entities/affected/affected.test.d.ts +2 -0
- package/dist/entities/affected/affected.test.d.ts.map +1 -0
- package/dist/entities/affected/affected.test.js +305 -0
- package/dist/entities/affected/affected.test.js.map +1 -0
- package/dist/entities/affected/index.d.ts +2 -0
- package/dist/entities/affected/index.d.ts.map +1 -0
- package/dist/entities/affected/index.js +2 -0
- package/dist/entities/affected/index.js.map +1 -0
- package/dist/entities/branch/branch.d.ts +8 -0
- package/dist/entities/branch/branch.d.ts.map +1 -0
- package/dist/entities/branch/branch.js +74 -0
- package/dist/entities/branch/branch.js.map +1 -0
- package/dist/entities/branch/branch.test.d.ts +2 -0
- package/dist/entities/branch/branch.test.d.ts.map +1 -0
- package/dist/entities/branch/branch.test.js +316 -0
- package/dist/entities/branch/branch.test.js.map +1 -0
- package/dist/entities/branch/branch.types.d.ts +6 -0
- package/dist/entities/branch/branch.types.d.ts.map +1 -0
- package/dist/entities/branch/branch.types.js +2 -0
- package/dist/entities/branch/branch.types.js.map +1 -0
- package/dist/entities/branch/index.d.ts +3 -0
- package/dist/entities/branch/index.d.ts.map +1 -0
- package/dist/entities/branch/index.js +3 -0
- package/dist/entities/branch/index.js.map +1 -0
- package/dist/entities/commit/commit.d.ts +15 -0
- package/dist/entities/commit/commit.d.ts.map +1 -0
- package/dist/entities/commit/commit.js +196 -0
- package/dist/entities/commit/commit.js.map +1 -0
- package/dist/entities/commit/commit.test.d.ts +26 -0
- package/dist/entities/commit/commit.test.d.ts.map +1 -0
- package/dist/entities/commit/commit.test.js +550 -0
- package/dist/entities/commit/commit.test.js.map +1 -0
- package/dist/entities/commit/commit.types.d.ts +49 -0
- package/dist/entities/commit/commit.types.d.ts.map +1 -0
- package/dist/entities/commit/commit.types.js +31 -0
- package/dist/entities/commit/commit.types.js.map +1 -0
- package/dist/entities/commit/index.d.ts +3 -0
- package/dist/entities/commit/index.d.ts.map +1 -0
- package/dist/entities/commit/index.js +3 -0
- package/dist/entities/commit/index.js.map +1 -0
- package/dist/entities/commit/pr.d.ts +11 -0
- package/dist/entities/commit/pr.d.ts.map +1 -0
- package/dist/entities/commit/pr.js +201 -0
- package/dist/entities/commit/pr.js.map +1 -0
- package/dist/entities/commit/pr.test.d.ts +2 -0
- package/dist/entities/commit/pr.test.d.ts.map +1 -0
- package/dist/entities/commit/pr.test.js +782 -0
- package/dist/entities/commit/pr.test.js.map +1 -0
- package/dist/entities/compose/compose.d.ts +18 -0
- package/dist/entities/compose/compose.d.ts.map +1 -0
- package/dist/entities/compose/compose.js +197 -0
- package/dist/entities/compose/compose.js.map +1 -0
- package/dist/entities/compose/compose.test.d.ts +2 -0
- package/dist/entities/compose/compose.test.d.ts.map +1 -0
- package/dist/entities/compose/compose.test.js +406 -0
- package/dist/entities/compose/compose.test.js.map +1 -0
- package/dist/entities/compose/compose.types.d.ts +77 -0
- package/dist/entities/compose/compose.types.d.ts.map +1 -0
- package/dist/entities/compose/compose.types.js +2 -0
- package/dist/entities/compose/compose.types.js.map +1 -0
- package/dist/entities/compose/index.d.ts +3 -0
- package/dist/entities/compose/index.d.ts.map +1 -0
- package/dist/entities/compose/index.js +3 -0
- package/dist/entities/compose/index.js.map +1 -0
- package/dist/entities/entities.shell.d.ts +29 -0
- package/dist/entities/entities.shell.d.ts.map +1 -0
- package/dist/entities/entities.shell.js +27 -0
- package/dist/entities/entities.shell.js.map +1 -0
- package/dist/entities/entities.shell.test.d.ts +2 -0
- package/dist/entities/entities.shell.test.d.ts.map +1 -0
- package/dist/entities/entities.shell.test.js +23 -0
- package/dist/entities/entities.shell.test.js.map +1 -0
- package/dist/entities/index.d.ts +12 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/index.js +12 -0
- package/dist/entities/index.js.map +1 -0
- package/dist/entities/intershell-config/intershell-config.d.ts +11 -0
- package/dist/entities/intershell-config/intershell-config.d.ts.map +1 -0
- package/dist/entities/intershell-config/intershell-config.default.d.ts +188 -0
- package/dist/entities/intershell-config/intershell-config.default.d.ts.map +1 -0
- package/dist/entities/intershell-config/intershell-config.default.js +225 -0
- package/dist/entities/intershell-config/intershell-config.default.js.map +1 -0
- package/dist/entities/intershell-config/intershell-config.js +132 -0
- package/dist/entities/intershell-config/intershell-config.js.map +1 -0
- package/dist/entities/intershell-config/intershell-config.test.d.ts +2 -0
- package/dist/entities/intershell-config/intershell-config.test.d.ts.map +1 -0
- package/dist/entities/intershell-config/intershell-config.test.js +102 -0
- package/dist/entities/intershell-config/intershell-config.test.js.map +1 -0
- package/dist/entities/intershell-config/intershell-config.types.d.ts +103 -0
- package/dist/entities/intershell-config/intershell-config.types.d.ts.map +1 -0
- package/dist/entities/intershell-config/intershell-config.types.js +2 -0
- package/dist/entities/intershell-config/intershell-config.types.js.map +1 -0
- package/dist/entities/package/index.d.ts +4 -0
- package/dist/entities/package/index.d.ts.map +1 -0
- package/dist/entities/package/index.js +4 -0
- package/dist/entities/package/index.js.map +1 -0
- package/dist/entities/package/package.d.ts +49 -0
- package/dist/entities/package/package.d.ts.map +1 -0
- package/dist/entities/package/package.js +234 -0
- package/dist/entities/package/package.js.map +1 -0
- package/dist/entities/package/package.shell.d.ts +48 -0
- package/dist/entities/package/package.shell.d.ts.map +1 -0
- package/dist/entities/package/package.shell.js +118 -0
- package/dist/entities/package/package.shell.js.map +1 -0
- package/dist/entities/package/package.test.d.ts +23 -0
- package/dist/entities/package/package.test.d.ts.map +1 -0
- package/dist/entities/package/package.test.js +637 -0
- package/dist/entities/package/package.test.js.map +1 -0
- package/dist/entities/package/package.types.d.ts +48 -0
- package/dist/entities/package/package.types.d.ts.map +1 -0
- package/dist/entities/package/package.types.js +2 -0
- package/dist/entities/package/package.types.js.map +1 -0
- package/dist/entities/package-changelog/index.d.ts +4 -0
- package/dist/entities/package-changelog/index.d.ts.map +1 -0
- package/dist/entities/package-changelog/index.js +4 -0
- package/dist/entities/package-changelog/index.js.map +1 -0
- package/dist/entities/package-changelog/package-changelog.d.ts +20 -0
- package/dist/entities/package-changelog/package-changelog.d.ts.map +1 -0
- package/dist/entities/package-changelog/package-changelog.js +59 -0
- package/dist/entities/package-changelog/package-changelog.js.map +1 -0
- package/dist/entities/package-changelog/package-changelog.types.d.ts +25 -0
- package/dist/entities/package-changelog/package-changelog.types.d.ts.map +1 -0
- package/dist/entities/package-changelog/package-changelog.types.js +2 -0
- package/dist/entities/package-changelog/package-changelog.types.js.map +1 -0
- package/dist/entities/package-changelog/template.d.ts +20 -0
- package/dist/entities/package-changelog/template.d.ts.map +1 -0
- package/dist/entities/package-changelog/template.default.d.ts +10 -0
- package/dist/entities/package-changelog/template.default.d.ts.map +1 -0
- package/dist/entities/package-changelog/template.default.js +85 -0
- package/dist/entities/package-changelog/template.default.js.map +1 -0
- package/dist/entities/package-changelog/template.js +90 -0
- package/dist/entities/package-changelog/template.js.map +1 -0
- package/dist/entities/package-commits/dependency-analyzer.d.ts +35 -0
- package/dist/entities/package-commits/dependency-analyzer.d.ts.map +1 -0
- package/dist/entities/package-commits/dependency-analyzer.js +169 -0
- package/dist/entities/package-commits/dependency-analyzer.js.map +1 -0
- package/dist/entities/package-commits/dependency-analyzer.test.d.ts +2 -0
- package/dist/entities/package-commits/dependency-analyzer.test.d.ts.map +1 -0
- package/dist/entities/package-commits/dependency-analyzer.test.js +25 -0
- package/dist/entities/package-commits/dependency-analyzer.test.js.map +1 -0
- package/dist/entities/package-commits/index.d.ts +3 -0
- package/dist/entities/package-commits/index.d.ts.map +1 -0
- package/dist/entities/package-commits/index.js +3 -0
- package/dist/entities/package-commits/index.js.map +1 -0
- package/dist/entities/package-commits/package-commits.d.ts +33 -0
- package/dist/entities/package-commits/package-commits.d.ts.map +1 -0
- package/dist/entities/package-commits/package-commits.js +149 -0
- package/dist/entities/package-commits/package-commits.js.map +1 -0
- package/dist/entities/package-commits/package-commits.test.d.ts +2 -0
- package/dist/entities/package-commits/package-commits.test.d.ts.map +1 -0
- package/dist/entities/package-commits/package-commits.test.js +40 -0
- package/dist/entities/package-commits/package-commits.test.js.map +1 -0
- package/dist/entities/package-tags/index.d.ts +2 -0
- package/dist/entities/package-tags/index.d.ts.map +1 -0
- package/dist/entities/package-tags/index.js +2 -0
- package/dist/entities/package-tags/index.js.map +1 -0
- package/dist/entities/package-tags/package-tags.d.ts +24 -0
- package/dist/entities/package-tags/package-tags.d.ts.map +1 -0
- package/dist/entities/package-tags/package-tags.js +197 -0
- package/dist/entities/package-tags/package-tags.js.map +1 -0
- package/dist/entities/package-tags/package-tags.test.d.ts +2 -0
- package/dist/entities/package-tags/package-tags.test.d.ts.map +1 -0
- package/dist/entities/package-tags/package-tags.test.js +60 -0
- package/dist/entities/package-tags/package-tags.test.js.map +1 -0
- package/dist/entities/package-version/index.d.ts +3 -0
- package/dist/entities/package-version/index.d.ts.map +1 -0
- package/dist/entities/package-version/index.js +3 -0
- package/dist/entities/package-version/index.js.map +1 -0
- package/dist/entities/package-version/package-version.d.ts +16 -0
- package/dist/entities/package-version/package-version.d.ts.map +1 -0
- package/dist/entities/package-version/package-version.js +166 -0
- package/dist/entities/package-version/package-version.js.map +1 -0
- package/dist/entities/package-version/package-version.test.d.ts +2 -0
- package/dist/entities/package-version/package-version.test.d.ts.map +1 -0
- package/dist/entities/package-version/package-version.test.js +113 -0
- package/dist/entities/package-version/package-version.test.js.map +1 -0
- package/dist/entities/package-version/package-version.types.d.ts +31 -0
- package/dist/entities/package-version/package-version.types.d.ts.map +1 -0
- package/dist/entities/package-version/package-version.types.js +2 -0
- package/dist/entities/package-version/package-version.types.js.map +1 -0
- package/dist/entities/tag/index.d.ts +3 -0
- package/dist/entities/tag/index.d.ts.map +1 -0
- package/dist/entities/tag/index.js +3 -0
- package/dist/entities/tag/index.js.map +1 -0
- package/dist/entities/tag/tag.d.ts +24 -0
- package/dist/entities/tag/tag.d.ts.map +1 -0
- package/dist/entities/tag/tag.js +168 -0
- package/dist/entities/tag/tag.js.map +1 -0
- package/dist/entities/tag/tag.test.d.ts +2 -0
- package/dist/entities/tag/tag.test.d.ts.map +1 -0
- package/dist/entities/tag/tag.test.js +638 -0
- package/dist/entities/tag/tag.test.js.map +1 -0
- package/dist/entities/tag/tag.types.d.ts +35 -0
- package/dist/entities/tag/tag.types.d.ts.map +1 -0
- package/dist/entities/tag/tag.types.js +2 -0
- package/dist/entities/tag/tag.types.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/package.json +73 -0
- package/src/commands/ci/act.ts +95 -0
- package/src/commands/ci/attach-affected.ts +93 -0
- package/src/commands/ci/attach-service-ports.ts +31 -0
- package/src/commands/commit-check.ts +124 -0
- package/src/commands/commit.ts +103 -0
- package/src/commands/dev/check.ts +117 -0
- package/src/commands/dev/cleanup.ts +34 -0
- package/src/commands/dev/rm.ts +66 -0
- package/src/commands/dev/setup.ts +48 -0
- package/src/commands/local/cleanup.ts +74 -0
- package/src/commands/local/setup.ts +68 -0
- package/src/commands/local/vscode.ts +118 -0
- package/src/commands/update-package-json.ts +104 -0
- package/src/commands/version/apply.ts +156 -0
- package/src/commands/version/ci.ts +85 -0
- package/src/commands/version/prepare.ts +217 -0
- package/src/core/colorify.ts +61 -0
- package/src/core/index.ts +3 -0
- package/src/core/types.ts +262 -0
- package/src/core/wrapshell.ts +388 -0
- package/src/entities/affected/affected.test.ts +427 -0
- package/src/entities/affected/affected.ts +22 -0
- package/src/entities/affected/index.ts +1 -0
- package/src/entities/branch/branch.test.ts +348 -0
- package/src/entities/branch/branch.ts +89 -0
- package/src/entities/branch/branch.types.ts +5 -0
- package/src/entities/branch/index.ts +2 -0
- package/src/entities/commit/commit.test.ts +769 -0
- package/src/entities/commit/commit.ts +245 -0
- package/src/entities/commit/commit.types.ts +81 -0
- package/src/entities/commit/index.ts +2 -0
- package/src/entities/commit/pr.test.ts +860 -0
- package/src/entities/commit/pr.ts +241 -0
- package/src/entities/compose/compose.test.ts +496 -0
- package/src/entities/compose/compose.ts +251 -0
- package/src/entities/compose/compose.types.ts +88 -0
- package/src/entities/compose/index.ts +2 -0
- package/src/entities/entities.shell.test.ts +35 -0
- package/src/entities/entities.shell.ts +81 -0
- package/src/entities/index.ts +11 -0
- package/src/entities/intershell-config/intershell-config.default.ts +229 -0
- package/src/entities/intershell-config/intershell-config.test.ts +117 -0
- package/src/entities/intershell-config/intershell-config.ts +143 -0
- package/src/entities/intershell-config/intershell-config.types.ts +118 -0
- package/src/entities/package/index.ts +3 -0
- package/src/entities/package/package.shell.ts +124 -0
- package/src/entities/package/package.test.ts +830 -0
- package/src/entities/package/package.ts +267 -0
- package/src/entities/package/package.types.ts +49 -0
- package/src/entities/package-changelog/index.ts +3 -0
- package/src/entities/package-changelog/package-changelog.ts +81 -0
- package/src/entities/package-changelog/package-changelog.types.ts +30 -0
- package/src/entities/package-changelog/template.default.ts +109 -0
- package/src/entities/package-changelog/template.ts +118 -0
- package/src/entities/package-commits/dependency-analyzer.test.ts +29 -0
- package/src/entities/package-commits/dependency-analyzer.ts +194 -0
- package/src/entities/package-commits/index.ts +2 -0
- package/src/entities/package-commits/package-commits.test.ts +44 -0
- package/src/entities/package-commits/package-commits.ts +191 -0
- package/src/entities/package-tags/index.ts +1 -0
- package/src/entities/package-tags/package-tags.test.ts +73 -0
- package/src/entities/package-tags/package-tags.ts +234 -0
- package/src/entities/package-version/index.ts +2 -0
- package/src/entities/package-version/package-version.test.ts +141 -0
- package/src/entities/package-version/package-version.ts +234 -0
- package/src/entities/package-version/package-version.types.ts +35 -0
- package/src/entities/tag/index.ts +2 -0
- package/src/entities/tag/tag.test.ts +844 -0
- package/src/entities/tag/tag.ts +208 -0
- package/src/entities/tag/tag.types.ts +37 -0
- package/src/index.ts +7 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { $ } from "bun";
|
|
3
|
+
import { colorify } from "../../core";
|
|
4
|
+
import { EntityPackage, EntityPackageTags } from "../../entities";
|
|
5
|
+
|
|
6
|
+
export default class VersionApply extends Command {
|
|
7
|
+
static description = "Create git version tags and commit version changes";
|
|
8
|
+
|
|
9
|
+
static examples = [
|
|
10
|
+
"intershell version:apply",
|
|
11
|
+
"intershell version:apply --message 'Release version 1.2.3'",
|
|
12
|
+
"intershell version:apply --no-push",
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
static flags = {
|
|
16
|
+
package: Flags.string({
|
|
17
|
+
char: "p",
|
|
18
|
+
description: "Package name to process (default: all packages)",
|
|
19
|
+
}),
|
|
20
|
+
message: Flags.string({
|
|
21
|
+
char: "m",
|
|
22
|
+
description: "Tag message",
|
|
23
|
+
}),
|
|
24
|
+
"no-push": Flags.boolean({
|
|
25
|
+
char: "n",
|
|
26
|
+
description: "Don't push tag to remote after creation",
|
|
27
|
+
default: false,
|
|
28
|
+
}),
|
|
29
|
+
"dry-run": Flags.boolean({
|
|
30
|
+
char: "d",
|
|
31
|
+
description: "Show planned changes without applying them",
|
|
32
|
+
default: false,
|
|
33
|
+
}),
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
async run(): Promise<void> {
|
|
37
|
+
const { flags } = await this.parse(VersionApply);
|
|
38
|
+
const packageName = flags.package || "root";
|
|
39
|
+
this.log(`š¦ Processing package: ${colorify.blue(packageName)}`);
|
|
40
|
+
|
|
41
|
+
const packageInstance = new EntityPackage(packageName);
|
|
42
|
+
const version = packageInstance.readVersion();
|
|
43
|
+
const tagSeriesName = packageInstance.getTagSeriesName();
|
|
44
|
+
const tagName = `${tagSeriesName}${version}`;
|
|
45
|
+
|
|
46
|
+
if (!tagSeriesName) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
`Tag series name not found for ${packageName}, this package should not be versioned (private package). Only versioned packages can be processed.`,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (flags["dry-run"]) {
|
|
53
|
+
this.log(colorify.yellow("š Dry run mode - would execute:"));
|
|
54
|
+
this.log(colorify.gray(` ⢠Commit version changes for package ${packageName}`));
|
|
55
|
+
this.log(colorify.gray(` ⢠Create tag ${tagName} for ${packageName}`));
|
|
56
|
+
if (!flags["no-push"]) {
|
|
57
|
+
this.log(colorify.gray(" ⢠Push commit changes to remote"));
|
|
58
|
+
this.log(colorify.gray(" ⢠Push tags to remote"));
|
|
59
|
+
}
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
this.log("š Adding all changes...");
|
|
64
|
+
await $`git add .`;
|
|
65
|
+
const statusResult = await $`git status --porcelain`.nothrow();
|
|
66
|
+
const hasChanges = statusResult.text().trim() !== "";
|
|
67
|
+
|
|
68
|
+
if (!hasChanges) {
|
|
69
|
+
this.log(colorify.yellow("ā ļø No changes to commit"));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
await this.commitVersionChanges();
|
|
74
|
+
await this.createTagsForPackage(packageName, flags);
|
|
75
|
+
await this.pushChanges(flags);
|
|
76
|
+
|
|
77
|
+
this.log(colorify.green("ā
Version apply operation completed successfully!"));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private async commitVersionChanges(): Promise<void> {
|
|
81
|
+
const commitMessage = await Bun.file(".git/COMMIT_EDITMSG").text();
|
|
82
|
+
|
|
83
|
+
this.log("š Commit message:");
|
|
84
|
+
this.log(commitMessage);
|
|
85
|
+
|
|
86
|
+
await $`git commit -m "${commitMessage}"`;
|
|
87
|
+
|
|
88
|
+
this.log(colorify.green("ā
Successfully committed version changes"));
|
|
89
|
+
const commitHash = await $`git rev-parse --short HEAD`.text();
|
|
90
|
+
this.log(`š·ļø Commit hash: ${commitHash.trim()}`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private async createTagsForPackage(
|
|
94
|
+
packageName: string,
|
|
95
|
+
flags: {
|
|
96
|
+
message?: string;
|
|
97
|
+
"no-push"?: boolean;
|
|
98
|
+
"dry-run"?: boolean;
|
|
99
|
+
},
|
|
100
|
+
): Promise<void> {
|
|
101
|
+
const packageInstance = new EntityPackage(packageName);
|
|
102
|
+
const version = packageInstance.readVersion();
|
|
103
|
+
if (!version) {
|
|
104
|
+
throw new Error(`Version not found for ${packageName}`);
|
|
105
|
+
}
|
|
106
|
+
const packageTags = new EntityPackageTags(packageInstance);
|
|
107
|
+
|
|
108
|
+
// Check if tag already exists
|
|
109
|
+
const tagExists = await packageTags.packageTagExists(version);
|
|
110
|
+
if (tagExists) {
|
|
111
|
+
const prefix = await packageTags.getTagPrefix();
|
|
112
|
+
const tagName = `${prefix}${version}`;
|
|
113
|
+
this.log(`āļø Tag already exists: ${tagName}`);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
this.log(`š·ļø Creating tag for ${packageName}: ${version}`);
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
await packageTags.createPackageTag(
|
|
121
|
+
version,
|
|
122
|
+
flags.message || `Release ${packageName} version ${version}`,
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const prefix = await packageTags.getTagPrefix();
|
|
126
|
+
const tagName = `${prefix}${version}`;
|
|
127
|
+
this.log(`ā
Created tag: ${tagName}`);
|
|
128
|
+
} catch (error) {
|
|
129
|
+
throw new Error(
|
|
130
|
+
`Failed to create tag for ${packageName}: ${error instanceof Error ? error.message : String(error)}`,
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private async pushChanges(flags: { "no-push"?: boolean; "dry-run"?: boolean }): Promise<void> {
|
|
136
|
+
if (flags["no-push"]) {
|
|
137
|
+
this.log(colorify.yellow("ā ļø Skipping push (--no-push specified)"));
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (flags["dry-run"]) {
|
|
142
|
+
this.log(colorify.yellow("ā ļø Skipping push (--dry-run specified)"));
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
try {
|
|
147
|
+
this.log("š¤ Pushing commit changes to remote...");
|
|
148
|
+
await $`git push --follow-tags`;
|
|
149
|
+
this.log("ā
Pushed commit changes to remote");
|
|
150
|
+
} catch (error) {
|
|
151
|
+
throw new Error(
|
|
152
|
+
`Failed to push commit changes to remote: ${error instanceof Error ? error.message : String(error)}`,
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { $ } from "bun";
|
|
3
|
+
import { colorify } from "../../core";
|
|
4
|
+
import { EntityTag } from "../../entities";
|
|
5
|
+
|
|
6
|
+
export default class VersionCi extends Command {
|
|
7
|
+
static description = "Complete CI versioning workflow: auth ā prepare ā apply";
|
|
8
|
+
|
|
9
|
+
static examples = [
|
|
10
|
+
"intershell version:ci",
|
|
11
|
+
"intershell version:ci --dry-run",
|
|
12
|
+
"intershell version:ci --no-push",
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
static flags = {
|
|
16
|
+
"no-push": Flags.boolean({
|
|
17
|
+
char: "n",
|
|
18
|
+
description: "Don't push tag to remote after creation",
|
|
19
|
+
default: false,
|
|
20
|
+
}),
|
|
21
|
+
"dry-run": Flags.boolean({
|
|
22
|
+
char: "d",
|
|
23
|
+
description: "Show planned changes without applying them",
|
|
24
|
+
default: false,
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
async run(): Promise<void> {
|
|
29
|
+
const { flags } = await this.parse(VersionCi);
|
|
30
|
+
this.log("š Starting CI version workflow...");
|
|
31
|
+
|
|
32
|
+
await this.configureGitAuth(flags);
|
|
33
|
+
|
|
34
|
+
const fromTag = await EntityTag.getBaseCommitSha();
|
|
35
|
+
this.log(`š Using base commit: ${colorify.blue(fromTag)}`);
|
|
36
|
+
|
|
37
|
+
this.log("\nš§ Preparing versions...");
|
|
38
|
+
// Note: In a real implementation, you would call the prepare command here
|
|
39
|
+
// For now, we'll just show what would happen
|
|
40
|
+
this.log(`š Would run: intershell version:prepare --from ${fromTag}`);
|
|
41
|
+
|
|
42
|
+
this.log("\nš Applying version changes...");
|
|
43
|
+
// Note: In a real implementation, you would call the apply command here
|
|
44
|
+
// For now, we'll just show what would happen
|
|
45
|
+
this.log(`š Would run: intershell version:apply${flags["no-push"] ? " --no-push" : ""}`);
|
|
46
|
+
|
|
47
|
+
this.log(colorify.green("\nā
CI version workflow completed successfully!"));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private async configureGitAuth(flags: {
|
|
51
|
+
"dry-run"?: boolean;
|
|
52
|
+
"no-push"?: boolean;
|
|
53
|
+
}): Promise<void> {
|
|
54
|
+
this.log("š Configuring Git authentication...");
|
|
55
|
+
|
|
56
|
+
if (flags["dry-run"]) {
|
|
57
|
+
this.log("-> š Dry run, skipping git config");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!process.env.GITHUB_ACTIONS) {
|
|
62
|
+
this.log("-> š Running locally, skip git config");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!process.env.GITHUB_REPOSITORY) {
|
|
67
|
+
this.log("-> ā ļø GITHUB_REPOSITORY not found");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!process.env.GITHUB_TOKEN) {
|
|
72
|
+
this.log("-> ā ļø GITHUB_TOKEN not found");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this.log("-> š Configuring Git authentication...");
|
|
77
|
+
await $`git config user.name "github-actions[bot]"`;
|
|
78
|
+
await $`git config user.email "github-actions[bot]@users.noreply.github.com"`;
|
|
79
|
+
await $`git remote set-url origin https://x-access-token:${process.env.GITHUB_TOKEN}@github.com/${process.env.GITHUB_REPOSITORY}.git`;
|
|
80
|
+
|
|
81
|
+
const actualRemoteUrl = await $`git remote get-url origin`.text();
|
|
82
|
+
const maskedUrl = actualRemoteUrl.replace(/https:\/\/x-access-token:[^@]+@/, "***@");
|
|
83
|
+
this.log(`-> š Git authentication configured, remote URL: ${maskedUrl}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { Command, Flags } from "@oclif/core";
|
|
3
|
+
import { $ } from "bun";
|
|
4
|
+
import { colorify } from "../../core";
|
|
5
|
+
import {
|
|
6
|
+
DefaultChangelogTemplate,
|
|
7
|
+
EntityCompose,
|
|
8
|
+
EntityPackage,
|
|
9
|
+
EntityPackageChangelog,
|
|
10
|
+
EntityPackageCommits,
|
|
11
|
+
EntityPackageTags,
|
|
12
|
+
EntityPackageVersion,
|
|
13
|
+
type EntityPackageVersionBumpType,
|
|
14
|
+
EntityTag,
|
|
15
|
+
} from "../../entities";
|
|
16
|
+
|
|
17
|
+
const bumpTypeOptions = ["major", "minor", "patch", "none"] as EntityPackageVersionBumpType[];
|
|
18
|
+
|
|
19
|
+
export default class VersionPrepare extends Command {
|
|
20
|
+
static description = "Prepare version bumps and generate changelogs for packages";
|
|
21
|
+
|
|
22
|
+
static examples = [
|
|
23
|
+
"intershell version:prepare",
|
|
24
|
+
"intershell version:prepare --package root",
|
|
25
|
+
"intershell version:prepare --from v1.0.0 --to HEAD",
|
|
26
|
+
"intershell version:prepare --from-version 1.0.0 --to-version 1.2.0",
|
|
27
|
+
"intershell version:prepare --package package-name --from-version 1.0.0",
|
|
28
|
+
"intershell version:prepare --package root --bump-type major",
|
|
29
|
+
"intershell version:prepare --bump-type patch",
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
static flags = {
|
|
33
|
+
package: Flags.string({
|
|
34
|
+
char: "p",
|
|
35
|
+
description: "Package name to process (default: all packages)",
|
|
36
|
+
default: "root",
|
|
37
|
+
}),
|
|
38
|
+
from: Flags.string({
|
|
39
|
+
char: "f",
|
|
40
|
+
description: "Start commit/tag for changelog generation",
|
|
41
|
+
}),
|
|
42
|
+
to: Flags.string({
|
|
43
|
+
char: "t",
|
|
44
|
+
description: "End commit/tag for changelog generation (default: HEAD)",
|
|
45
|
+
}),
|
|
46
|
+
"from-version": Flags.string({
|
|
47
|
+
description:
|
|
48
|
+
"Start version for changelog generation (converts to appropriate tag based on package)",
|
|
49
|
+
}),
|
|
50
|
+
"to-version": Flags.string({
|
|
51
|
+
description:
|
|
52
|
+
"End version for changelog generation (converts to appropriate tag based on package)",
|
|
53
|
+
}),
|
|
54
|
+
"bump-type": Flags.string({
|
|
55
|
+
description: "Override version bump type (major, minor, patch, none)",
|
|
56
|
+
options: bumpTypeOptions,
|
|
57
|
+
}),
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
async run(): Promise<void> {
|
|
61
|
+
const { flags } = await this.parse(VersionPrepare);
|
|
62
|
+
const packageName = flags.package || "root";
|
|
63
|
+
|
|
64
|
+
this.log("š Validating package configurations...");
|
|
65
|
+
const validationResult = await EntityPackage.validateAllPackages();
|
|
66
|
+
if (validationResult.length > 0) {
|
|
67
|
+
this.error(
|
|
68
|
+
`ā Package validation failed!\nFound ${validationResult.length} validation errors:\n${validationResult.map((error) => ` š¦ ${error}`).join("\n")}`,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
this.log(colorify.green("ā
All packages passed validation"));
|
|
72
|
+
|
|
73
|
+
const allVersionedPackages = await EntityPackage.getVersionedPackages();
|
|
74
|
+
const packageInstance = new EntityPackage(packageName);
|
|
75
|
+
const packageTags = new EntityPackageTags(packageInstance);
|
|
76
|
+
const packageCommits = new EntityPackageCommits(packageInstance);
|
|
77
|
+
const packageVersion = new EntityPackageVersion(packageInstance, packageCommits, packageTags);
|
|
78
|
+
const prefix = packageInstance.getTagSeriesName();
|
|
79
|
+
|
|
80
|
+
if (!allVersionedPackages.includes(packageName)) {
|
|
81
|
+
throw new Error(
|
|
82
|
+
`Package "${packageName}" should not be versioned (private package). Only versioned packages can be processed.`,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
if (!prefix) {
|
|
86
|
+
throw new Error(
|
|
87
|
+
`Tag series name not found for ${packageName}, this package should not be versioned (private package). Only versioned packages can be processed.`,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
this.log(`š Starting version preparation for package ${colorify.blue(packageName)}`);
|
|
92
|
+
const { fromCommit, toCommit } = await this.resolveCommitRange({
|
|
93
|
+
packageTags,
|
|
94
|
+
from: flags.from,
|
|
95
|
+
to: flags.to,
|
|
96
|
+
fromVersion: Array.isArray(flags["from-version"])
|
|
97
|
+
? flags["from-version"][0]
|
|
98
|
+
: flags["from-version"],
|
|
99
|
+
toVersion: Array.isArray(flags["to-version"]) ? flags["to-version"][0] : flags["to-version"],
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const from =
|
|
103
|
+
flags.from || flags["from-version"]
|
|
104
|
+
? fromCommit
|
|
105
|
+
: await packageTags.getBaseTagShaForPackage();
|
|
106
|
+
|
|
107
|
+
this.log(`š Generating changelog from ${colorify.blue(from)} to ${colorify.blue(toCommit)}`);
|
|
108
|
+
|
|
109
|
+
// Get commits and version data using EntityPackageVersion
|
|
110
|
+
const commits = await packageCommits.getCommitsInRange(from, toCommit);
|
|
111
|
+
const overrideBumpType = flags["bump-type"] as "major" | "minor" | "patch" | "none" | undefined;
|
|
112
|
+
const versionData = await packageVersion.calculateVersionData(commits, overrideBumpType);
|
|
113
|
+
|
|
114
|
+
// Create changelog with commits
|
|
115
|
+
const template = new DefaultChangelogTemplate(packageName, prefix);
|
|
116
|
+
const changelog = new EntityPackageChangelog(packageInstance, commits, {
|
|
117
|
+
template,
|
|
118
|
+
versionData,
|
|
119
|
+
versionMode: true,
|
|
120
|
+
});
|
|
121
|
+
const changelogContent = changelog.generateMergedChangelog();
|
|
122
|
+
|
|
123
|
+
if (commits.length === 0) {
|
|
124
|
+
this.log(colorify.yellow(`š¦ ${packageName}: ${colorify.yellow("No commits found")}`));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (!versionData.shouldBump) {
|
|
128
|
+
this.log(
|
|
129
|
+
colorify.yellow(
|
|
130
|
+
`š¦ ${packageName}: ${colorify.yellow("No version bump needed")} (${versionData.bumpType})`,
|
|
131
|
+
),
|
|
132
|
+
);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
this.log(
|
|
137
|
+
`š Updating package version from ${versionData.currentVersion} to ${versionData.targetVersion} in ${packageInstance.getJsonPath()}`,
|
|
138
|
+
);
|
|
139
|
+
await packageInstance.writeVersion(versionData.targetVersion);
|
|
140
|
+
await $`bun install`;
|
|
141
|
+
await packageInstance.writeChangelog(changelogContent);
|
|
142
|
+
|
|
143
|
+
const tagName = `${prefix}${versionData.targetVersion}`;
|
|
144
|
+
const versionCommitMessage = `release(${packageName}): ${tagName} [${versionData.bumpType}] (${versionData.currentVersion} => ${versionData.targetVersion})\n\nš Commits processed: ${commits.length}\nš Changelog updated: (${packageInstance.getChangelogPath()})`;
|
|
145
|
+
this.log(
|
|
146
|
+
`š¦ (${colorify.yellow(versionData.currentVersion)} => ${colorify.green(versionData.targetVersion)}) ${colorify.blue(packageName)}: ${versionData.bumpType} (${colorify.green(packageInstance.getChangelogPath())})`,
|
|
147
|
+
);
|
|
148
|
+
await Bun.write(".git/COMMIT_EDITMSG", versionCommitMessage);
|
|
149
|
+
this.log(
|
|
150
|
+
`${colorify.green("š Commit message written in")} ${colorify.blue(".git/COMMIT_EDITMSG")}:`,
|
|
151
|
+
`\n\t${versionCommitMessage.replace(/\n/g, "\n\t")}`,
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
const services = await new EntityCompose("docker-compose.yml").getServices();
|
|
155
|
+
const servicesToDeploy = services.filter((s) => s.name === packageName).map((s) => s.name);
|
|
156
|
+
if (servicesToDeploy) {
|
|
157
|
+
const servicesToDeployNames = servicesToDeploy.join(",");
|
|
158
|
+
if (process.env.GITHUB_OUTPUT) {
|
|
159
|
+
await fs.promises.appendFile(
|
|
160
|
+
process.env.GITHUB_OUTPUT,
|
|
161
|
+
`packages-to-deploy=${servicesToDeployNames}\n`,
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
this.log(`\nš Packages to deploy: ${colorify.blue(servicesToDeployNames)}`);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
this.log(
|
|
168
|
+
"\nš Next steps:\n" +
|
|
169
|
+
"1. Review the generated changelogs\n" +
|
|
170
|
+
`2. Run ${colorify.blue("intershell version:apply")} to commit, tag and push the versions (you can turn it off using --no-push)`,
|
|
171
|
+
);
|
|
172
|
+
this.log(colorify.green("ā
Version preparation completed!"));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Resolves from/to commits, handling version-to-tag conversion when needed
|
|
177
|
+
*/
|
|
178
|
+
private async resolveCommitRange({
|
|
179
|
+
packageTags,
|
|
180
|
+
from,
|
|
181
|
+
to,
|
|
182
|
+
fromVersion,
|
|
183
|
+
toVersion,
|
|
184
|
+
}: {
|
|
185
|
+
packageTags: EntityPackageTags;
|
|
186
|
+
from?: string;
|
|
187
|
+
to?: string;
|
|
188
|
+
fromVersion?: string;
|
|
189
|
+
toVersion?: string;
|
|
190
|
+
}): Promise<{ fromCommit: string; toCommit: string }> {
|
|
191
|
+
let fromCommit: string;
|
|
192
|
+
let toCommit: string;
|
|
193
|
+
// Handle --from-version conversion
|
|
194
|
+
if (fromVersion) {
|
|
195
|
+
const fromTag = `${await packageTags.getTagPrefix()}${fromVersion}`;
|
|
196
|
+
this.log(`š Converting --from-version ${fromVersion} to tag: ${fromTag}`);
|
|
197
|
+
fromCommit = await EntityTag.getBaseCommitSha(fromTag);
|
|
198
|
+
} else if (from) {
|
|
199
|
+
fromCommit = await EntityTag.getBaseCommitSha(from);
|
|
200
|
+
} else {
|
|
201
|
+
// No --from specified, let EntityPackageTags auto-find the correct base SHA
|
|
202
|
+
// This will use the latest tag if it exists, or fall back to first commit for first-time versioning
|
|
203
|
+
fromCommit = await packageTags.getBaseTagShaForPackage();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Handle --to-version conversion
|
|
207
|
+
if (toVersion) {
|
|
208
|
+
const toTag = `${await packageTags.getTagPrefix()}${toVersion}`;
|
|
209
|
+
this.log(`š Converting --to-version ${toVersion} to tag: ${toTag}`);
|
|
210
|
+
toCommit = await EntityTag.getBaseCommitSha(toTag);
|
|
211
|
+
} else {
|
|
212
|
+
toCommit = to || "HEAD";
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return { fromCommit, toCommit };
|
|
216
|
+
}
|
|
217
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom console coloring utility to replace chalk
|
|
3
|
+
* Provides ANSI color codes for terminal output
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// ANSI color codes
|
|
7
|
+
const colors = {
|
|
8
|
+
red: "\x1b[31m",
|
|
9
|
+
green: "\x1b[32m",
|
|
10
|
+
yellow: "\x1b[33m",
|
|
11
|
+
blue: "\x1b[34m",
|
|
12
|
+
cyan: "\x1b[36m",
|
|
13
|
+
gray: "\x1b[90m",
|
|
14
|
+
bold: "\x1b[1m",
|
|
15
|
+
reset: "\x1b[0m",
|
|
16
|
+
} as const;
|
|
17
|
+
|
|
18
|
+
const createColorFunction = (colorCode: string) => {
|
|
19
|
+
return (text: string): string => {
|
|
20
|
+
return `${colorCode}${text}${colors.reset}`;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Console color utility that mimics chalk's API
|
|
26
|
+
*/
|
|
27
|
+
export const colorify = {
|
|
28
|
+
red: createColorFunction(colors.red),
|
|
29
|
+
green: createColorFunction(colors.green),
|
|
30
|
+
yellow: createColorFunction(colors.yellow),
|
|
31
|
+
blue: createColorFunction(colors.blue),
|
|
32
|
+
cyan: createColorFunction(colors.cyan),
|
|
33
|
+
gray: createColorFunction(colors.gray),
|
|
34
|
+
bold: createColorFunction(colors.bold),
|
|
35
|
+
reset: colors.reset,
|
|
36
|
+
|
|
37
|
+
supportsColor: (): boolean => {
|
|
38
|
+
// Check if we're in a terminal that supports colors
|
|
39
|
+
return process.stdout.isTTY && process.env.NO_COLOR !== "1";
|
|
40
|
+
},
|
|
41
|
+
disable: () => {
|
|
42
|
+
Object.keys(colorify).forEach((key) => {
|
|
43
|
+
if (typeof colorify[key as keyof typeof colorify] === "function") {
|
|
44
|
+
(colorify as unknown as Record<string, (text: string) => string>)[key] = (text: string) =>
|
|
45
|
+
text;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
enable: () => {
|
|
50
|
+
Object.keys(colors).forEach((key) => {
|
|
51
|
+
if (key !== "reset") {
|
|
52
|
+
(colorify as unknown as Record<string, (text: string) => string>)[key] =
|
|
53
|
+
createColorFunction(colors[key as keyof typeof colors]);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
} as const;
|
|
58
|
+
|
|
59
|
+
if (!colorify.supportsColor()) {
|
|
60
|
+
colorify.disable();
|
|
61
|
+
}
|