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,117 @@
|
|
|
1
|
+
import { setTimeout } from "node:timers/promises";
|
|
2
|
+
import { Command, Flags } from "@oclif/core";
|
|
3
|
+
import { $ } from "bun";
|
|
4
|
+
import { colorify } from "../../core";
|
|
5
|
+
import { EntityCompose, type ServiceHealth, type ServiceInfo } from "../../entities";
|
|
6
|
+
|
|
7
|
+
export default class DevCheck extends Command {
|
|
8
|
+
static description = "Check the health of the DevContainer services";
|
|
9
|
+
|
|
10
|
+
static examples = ["intershell dev:check", "intershell dev:check --keep-alive"];
|
|
11
|
+
|
|
12
|
+
static flags = {
|
|
13
|
+
"keep-alive": Flags.boolean({
|
|
14
|
+
char: "s",
|
|
15
|
+
description: "Keep services alive after checks complete",
|
|
16
|
+
default: false,
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
async run(): Promise<void> {
|
|
21
|
+
const { flags } = await this.parse(DevCheck);
|
|
22
|
+
|
|
23
|
+
this.log(colorify.blue("๐งช Starting DevContainer Health Check..."));
|
|
24
|
+
|
|
25
|
+
await $`bun run dev:up --build`;
|
|
26
|
+
const compose = new EntityCompose("./docker-compose.dev.yml");
|
|
27
|
+
await this.monitorServiceHealth(compose);
|
|
28
|
+
|
|
29
|
+
this.log(colorify.blue("\n๐ Services are available at:"));
|
|
30
|
+
const devUrls = await compose.getServiceUrls();
|
|
31
|
+
for (const [name, url] of Object.entries(devUrls)) {
|
|
32
|
+
this.log(colorify.cyan(` โข ${name}: ${url}`));
|
|
33
|
+
}
|
|
34
|
+
this.log(colorify.green("โ
DevContainer health check completed successfully!"));
|
|
35
|
+
|
|
36
|
+
if (flags["keep-alive"]) {
|
|
37
|
+
this.log(
|
|
38
|
+
colorify.yellow("๐ก Use 'intershell dev:check --keep-alive' to keep services alive"),
|
|
39
|
+
);
|
|
40
|
+
} else {
|
|
41
|
+
this.log(colorify.yellow("๐งน Cleaning up services..."));
|
|
42
|
+
await $`bun run dev:down`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private readonly icons: Record<ServiceHealth["status"], string> = {
|
|
47
|
+
healthy: "โ
",
|
|
48
|
+
starting: "๐",
|
|
49
|
+
unhealthy: "โ",
|
|
50
|
+
unknown: "โ",
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
private readonly colors: Record<ServiceHealth["status"], (text: string) => string> = {
|
|
54
|
+
healthy: colorify.green,
|
|
55
|
+
starting: colorify.yellow,
|
|
56
|
+
unhealthy: colorify.red,
|
|
57
|
+
unknown: colorify.gray,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
private async monitorServiceHealth(compose: EntityCompose): Promise<void> {
|
|
61
|
+
const services = await compose.getServices();
|
|
62
|
+
this.log(colorify.yellow("โณ Waiting for services to become healthy..."));
|
|
63
|
+
|
|
64
|
+
const retryInterval = 5_000;
|
|
65
|
+
const maxRetries = 6; // 6 * retryInterval = 30 seconds total
|
|
66
|
+
let retryCount = 0;
|
|
67
|
+
let allHealthy = false;
|
|
68
|
+
|
|
69
|
+
let healthResult: ServiceHealth[] | null = null;
|
|
70
|
+
while (retryCount < maxRetries && !allHealthy) {
|
|
71
|
+
if (retryCount > 0) {
|
|
72
|
+
this.log(
|
|
73
|
+
colorify.yellow(
|
|
74
|
+
`๐ Retry ${retryCount}/${maxRetries} - Checking health again in 5 seconds...`,
|
|
75
|
+
),
|
|
76
|
+
);
|
|
77
|
+
await setTimeout(retryInterval);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
healthResult = await compose.getServiceHealth();
|
|
81
|
+
|
|
82
|
+
if (
|
|
83
|
+
healthResult?.every((s) => s.status === "healthy") &&
|
|
84
|
+
healthResult.length === services.length
|
|
85
|
+
) {
|
|
86
|
+
allHealthy = true;
|
|
87
|
+
} else {
|
|
88
|
+
retryCount++;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Print detailed health status
|
|
93
|
+
this.log(colorify.blue("\n๐ Final Service Health Status:"));
|
|
94
|
+
this.log("-".repeat(50));
|
|
95
|
+
if (!healthResult) {
|
|
96
|
+
throw new Error("Failed to get health status from services");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
for (const service of healthResult) {
|
|
100
|
+
const icon = this.icons[service.status];
|
|
101
|
+
const color = this.colors[service.status];
|
|
102
|
+
const port = services.find((s: ServiceInfo) => s.name === service.name)?.ports[0]?.host;
|
|
103
|
+
this.log(`${icon} ${color(service.name)}: ${service.status} ${port ? `(${port})` : ""}`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (healthResult.some((s) => s.status === "unhealthy")) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
`Unhealthy services after ${maxRetries} retries: ${healthResult
|
|
109
|
+
.filter((s) => s.status === "unhealthy")
|
|
110
|
+
.map((s) => s.name)
|
|
111
|
+
.join(", ")}`,
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
this.log(colorify.green("โ
All services are healthy"));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { $ } from "bun";
|
|
3
|
+
import { colorify } from "../../core";
|
|
4
|
+
|
|
5
|
+
export default class DevCleanup extends Command {
|
|
6
|
+
static description = `Clean up DevContainer services and development artifacts.
|
|
7
|
+
This only cleans up the development services, not the VS Code DevContainer itself.
|
|
8
|
+
To stop the VS Code DevContainer, run \`bun run dev:rm\` from the host machine.`;
|
|
9
|
+
|
|
10
|
+
static examples = ["intershell dev:cleanup", "intershell dev:cleanup --verbose"];
|
|
11
|
+
|
|
12
|
+
static flags = {
|
|
13
|
+
verbose: Flags.boolean({
|
|
14
|
+
char: "v",
|
|
15
|
+
description: "Enable verbose output",
|
|
16
|
+
default: false,
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
async run(): Promise<void> {
|
|
21
|
+
await this.parse(DevCleanup);
|
|
22
|
+
|
|
23
|
+
this.log(colorify.blue("๐งน Starting DevContainer cleanup..."));
|
|
24
|
+
|
|
25
|
+
this.log(colorify.yellow("๐ณ Stopping DevContainer services..."));
|
|
26
|
+
await $`docker compose -f ./docker-compose.dev.yml --profile all down --volumes`;
|
|
27
|
+
await $`docker compose -f ./docker-compose.dev.yml --profile all rm -f --volumes`;
|
|
28
|
+
|
|
29
|
+
this.log(colorify.green("โ
DevContainer cleanup completed successfully!"));
|
|
30
|
+
this.log(colorify.cyan("\n๐ก To start fresh on devcontainer, run:"));
|
|
31
|
+
this.log(colorify.cyan(" - intershell dev:setup"));
|
|
32
|
+
this.log(colorify.cyan(" - intershell dev:rm # To stop VS Code DevContainer (host only)"));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { $ } from "bun";
|
|
3
|
+
import { colorify } from "../../core";
|
|
4
|
+
|
|
5
|
+
export default class DevRm extends Command {
|
|
6
|
+
static description = `Stop and remove the VS Code DevContainer itself.
|
|
7
|
+
โ ๏ธ WARNING: This script must be run from the HOST machine, not from within the DevContainer.
|
|
8
|
+
This will stop the VS Code DevContainer and all associated containers.`;
|
|
9
|
+
|
|
10
|
+
static examples = ["intershell dev:rm", "intershell dev:rm --force"];
|
|
11
|
+
|
|
12
|
+
static flags = {
|
|
13
|
+
force: Flags.boolean({
|
|
14
|
+
char: "f",
|
|
15
|
+
description: "Force removal without confirmation",
|
|
16
|
+
default: false,
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
async run(): Promise<void> {
|
|
21
|
+
await this.parse(DevRm);
|
|
22
|
+
|
|
23
|
+
this.log(colorify.blue("๐ณ Stopping VS Code DevContainer..."));
|
|
24
|
+
|
|
25
|
+
// Check if we're in a DevContainer
|
|
26
|
+
const isInDevContainer = process.env.REMOTE_CONTAINERS === "true";
|
|
27
|
+
if (isInDevContainer) {
|
|
28
|
+
this.error(
|
|
29
|
+
colorify.red(
|
|
30
|
+
"โ ERROR: This script must be run from the HOST machine, not from within the DevContainer.",
|
|
31
|
+
),
|
|
32
|
+
);
|
|
33
|
+
this.log(
|
|
34
|
+
colorify.yellow(
|
|
35
|
+
"๐ก Please exit the DevContainer and run this command from your host terminal.",
|
|
36
|
+
),
|
|
37
|
+
);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
await this.stepStopDevContainer();
|
|
42
|
+
await this.stepStopRemoveAllContainers();
|
|
43
|
+
|
|
44
|
+
this.log(colorify.green("โ
DevContainer removal completed successfully!"));
|
|
45
|
+
this.log(colorify.cyan("\n๐ก To start fresh, run:"));
|
|
46
|
+
this.log(colorify.cyan(" - intershell local:setup # For local development"));
|
|
47
|
+
this.log(colorify.cyan(" - Press `Ctrl+Shift+P` (or `Cmd+Shift+P` on macOS) "));
|
|
48
|
+
this.log(colorify.cyan(" -Type 'Dev Containers: Reopen in Container' and select the command"));
|
|
49
|
+
this.log(colorify.cyan(" - intershell dev:setup # For DevContainer development"));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private async stepStopDevContainer(): Promise<void> {
|
|
53
|
+
this.log(colorify.yellow("๐ Stopping VS Code DevContainer..."));
|
|
54
|
+
// Stop the DevContainer using VS Code CLI
|
|
55
|
+
await $`code --command "devcontainers.stop"`.nothrow();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private async stepStopRemoveAllContainers(): Promise<void> {
|
|
59
|
+
this.log(colorify.yellow("๐ณ Stopping all related containers..."));
|
|
60
|
+
await $`docker compose -f ./docker-compose.dev.yml --profile all down --volumes --remove-orphans`;
|
|
61
|
+
await $`docker compose -f docker-compose.yml down --volumes --remove-orphans`;
|
|
62
|
+
this.log(colorify.yellow("๐๏ธ Removing containers..."));
|
|
63
|
+
await $`docker compose -f ./docker-compose.dev.yml --profile all rm -f --volumes`;
|
|
64
|
+
await $`docker compose -f docker-compose.yml rm -f --volumes`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { $ } from "bun";
|
|
3
|
+
import { colorify } from "../../core";
|
|
4
|
+
import { EntityCompose } from "../../entities";
|
|
5
|
+
|
|
6
|
+
export default class DevSetup extends Command {
|
|
7
|
+
static description =
|
|
8
|
+
"Setup DevContainer environment with Docker builds, service startup, and health verification";
|
|
9
|
+
|
|
10
|
+
static examples = [
|
|
11
|
+
"intershell dev:setup",
|
|
12
|
+
"intershell dev:setup --skip-health-check",
|
|
13
|
+
"intershell dev:setup --keep-running",
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
static flags = {
|
|
17
|
+
"skip-health-check": Flags.boolean({
|
|
18
|
+
char: "h",
|
|
19
|
+
description: "Skip health check verification",
|
|
20
|
+
default: false,
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
async run(): Promise<void> {
|
|
25
|
+
const { flags } = await this.parse(DevSetup);
|
|
26
|
+
|
|
27
|
+
this.log(colorify.blue("๐ณ Starting DevContainer setup..."));
|
|
28
|
+
|
|
29
|
+
await $`bun run dev:up --build`;
|
|
30
|
+
if (!flags["skip-health-check"]) {
|
|
31
|
+
this.log(colorify.blue("๐ฅ Running health checks..."));
|
|
32
|
+
await $`bun run dev:check`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
this.log(colorify.cyan("\n๐ก Services are running and available at:"));
|
|
36
|
+
const compose = new EntityCompose("./docker-compose.dev.yml");
|
|
37
|
+
const devUrls = await compose.getServiceUrls();
|
|
38
|
+
for (const [name, url] of Object.entries(devUrls)) {
|
|
39
|
+
this.log(colorify.cyan(` โข ${name}: ${url}`));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
this.log(colorify.yellow("๐ก Use 'bun run dev:cleanup' to stop services when done"));
|
|
43
|
+
this.log(colorify.cyan("\n๐ก Useful commands:"));
|
|
44
|
+
this.log(colorify.cyan(" - bun run dev:check # Check DevContainer health"));
|
|
45
|
+
this.log(colorify.cyan(" - bun run dev:logs # View service logs"));
|
|
46
|
+
this.log(colorify.cyan(" - bun run dev:cleanup # Clean DevContainer environment"));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { $ } from "bun";
|
|
3
|
+
import { colorify } from "../../core";
|
|
4
|
+
|
|
5
|
+
export default class LocalCleanup extends Command {
|
|
6
|
+
static description =
|
|
7
|
+
"Comprehensive cleanup of Docker containers, build artifacts, and development files. This includes DevContainer cleanup. To stop the VS Code DevContainer itself, run `bun run dev:rm` from host machine";
|
|
8
|
+
|
|
9
|
+
static examples = ["intershell local:cleanup", "intershell local:cleanup --verbose"];
|
|
10
|
+
|
|
11
|
+
static flags = {
|
|
12
|
+
verbose: Flags.boolean({
|
|
13
|
+
char: "v",
|
|
14
|
+
description: "Enable verbose output",
|
|
15
|
+
default: false,
|
|
16
|
+
}),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
private readonly directories = [
|
|
20
|
+
"dist",
|
|
21
|
+
"build",
|
|
22
|
+
"dist",
|
|
23
|
+
"dist-storybook",
|
|
24
|
+
".turbo",
|
|
25
|
+
".next",
|
|
26
|
+
".output",
|
|
27
|
+
"coverage",
|
|
28
|
+
".nyc_output",
|
|
29
|
+
".cache",
|
|
30
|
+
".parcel-cache",
|
|
31
|
+
".vite",
|
|
32
|
+
".swc",
|
|
33
|
+
".act",
|
|
34
|
+
".biomecache",
|
|
35
|
+
"bin",
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
private readonly files = [
|
|
39
|
+
".act-event.json",
|
|
40
|
+
"*.tsbuildinfo",
|
|
41
|
+
".log",
|
|
42
|
+
".tmp",
|
|
43
|
+
".temp",
|
|
44
|
+
".DS_Store",
|
|
45
|
+
"Thumbs.db",
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
async run(): Promise<void> {
|
|
49
|
+
await this.parse(LocalCleanup);
|
|
50
|
+
|
|
51
|
+
this.log(colorify.blue("๐งน Starting comprehensive cleanup..."));
|
|
52
|
+
|
|
53
|
+
this.log(colorify.yellow("๐๏ธ Cleaning development artifacts..."));
|
|
54
|
+
for (const directory of this.directories) {
|
|
55
|
+
await $`rm -rf ${directory} **/${directory} **/${directory}/**`.quiet().nothrow();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
this.log(colorify.yellow("๐ Cleaning logs and temp files..."));
|
|
59
|
+
for (const file of this.files) {
|
|
60
|
+
await $`rm -rf ${file} **/${file}`.quiet().nothrow();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
this.log(colorify.yellow("๐ฆ Cleaning node_modules in directories..."));
|
|
64
|
+
await $`rm -rf node_modules **/node_modules`.quiet().nothrow();
|
|
65
|
+
|
|
66
|
+
this.log(colorify.yellow("๐ฏ Cleaning VS Code configuration..."));
|
|
67
|
+
await $`rm -rf .vscode`.quiet().nothrow();
|
|
68
|
+
|
|
69
|
+
this.log(colorify.green("โ
Cleanup completed successfully!"));
|
|
70
|
+
this.log(colorify.cyan("\n๐ก To start fresh, run:"));
|
|
71
|
+
this.log(colorify.cyan(" - intershell local:setup # For local development"));
|
|
72
|
+
this.log(colorify.cyan(" - intershell dev:setup # For DevContainer development"));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { $ } from "bun";
|
|
3
|
+
import { colorify } from "../../core";
|
|
4
|
+
|
|
5
|
+
export default class LocalSetup extends Command {
|
|
6
|
+
static description =
|
|
7
|
+
"Complete local development environment setup with dependency installation, local builds, and VS Code configuration sync";
|
|
8
|
+
|
|
9
|
+
static examples = [
|
|
10
|
+
"intershell local:setup",
|
|
11
|
+
"intershell local:setup --skip-vscode",
|
|
12
|
+
"intershell local:setup --skip-tests",
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
static flags = {
|
|
16
|
+
"skip-vscode": Flags.boolean({
|
|
17
|
+
char: "v",
|
|
18
|
+
description: "Skip VS Code configuration sync",
|
|
19
|
+
default: false,
|
|
20
|
+
}),
|
|
21
|
+
"skip-tests": Flags.boolean({
|
|
22
|
+
char: "t",
|
|
23
|
+
description: "Skip running tests",
|
|
24
|
+
default: false,
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
async run(): Promise<void> {
|
|
29
|
+
const { flags } = await this.parse(LocalSetup);
|
|
30
|
+
|
|
31
|
+
this.log(colorify.blue("๐ Starting local development setup..."));
|
|
32
|
+
|
|
33
|
+
// Step 1: Install dependencies
|
|
34
|
+
this.log(colorify.blue("๐ฆ Installing dependencies..."));
|
|
35
|
+
await $`bun install`;
|
|
36
|
+
|
|
37
|
+
// Step 2: Run code quality checks
|
|
38
|
+
this.log(colorify.blue("๐ Running code quality checks..."));
|
|
39
|
+
await $`bun run check:fix`;
|
|
40
|
+
|
|
41
|
+
// Step 3: Type checking
|
|
42
|
+
this.log(colorify.blue("๐ Running type checks..."));
|
|
43
|
+
await $`bun run check:types`;
|
|
44
|
+
|
|
45
|
+
// Step 4: Run tests (unless skipped)
|
|
46
|
+
if (!flags["skip-tests"]) {
|
|
47
|
+
this.log(colorify.blue("๐งช Running tests..."));
|
|
48
|
+
await $`bun run test`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Step 5: Build all packages
|
|
52
|
+
this.log(colorify.blue("๐๏ธ Building all packages..."));
|
|
53
|
+
await $`bun run build`;
|
|
54
|
+
|
|
55
|
+
// Step 6: Sync VS Code configuration (unless skipped)
|
|
56
|
+
if (!flags["skip-vscode"]) {
|
|
57
|
+
this.log(colorify.blue("๐ฏ Syncing VS Code configuration..."));
|
|
58
|
+
await $`bun run local:vscode`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
this.log(colorify.green("โ
Local setup completed successfully!"));
|
|
62
|
+
|
|
63
|
+
this.log(colorify.cyan("\n๐ก Useful commands:"));
|
|
64
|
+
this.log(colorify.cyan(" - bun run check:quick # Quick verification"));
|
|
65
|
+
this.log(colorify.cyan(" - intershell dev:setup # Setup DevContainer environment"));
|
|
66
|
+
this.log(colorify.cyan(" - intershell local:cleanup # Clean everything"));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { exists, mkdir } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { Command, Flags } from "@oclif/core";
|
|
4
|
+
import { $ } from "bun";
|
|
5
|
+
import { EntityPackage } from "../../entities";
|
|
6
|
+
|
|
7
|
+
export default class LocalVscode extends Command {
|
|
8
|
+
static description =
|
|
9
|
+
"Synchronize VS Code extensions and settings from devcontainer.json to .vscode/ directory";
|
|
10
|
+
|
|
11
|
+
static examples = [
|
|
12
|
+
"intershell local:vscode",
|
|
13
|
+
"intershell local:vscode --dry-run",
|
|
14
|
+
"intershell local:vscode --extensions-only",
|
|
15
|
+
"intershell local:vscode --settings-only",
|
|
16
|
+
"intershell local:vscode --quiet",
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
static flags = {
|
|
20
|
+
"dry-run": Flags.boolean({
|
|
21
|
+
description: "Show what would be synced without making changes",
|
|
22
|
+
default: false,
|
|
23
|
+
}),
|
|
24
|
+
"extensions-only": Flags.boolean({
|
|
25
|
+
description: "Only sync extensions",
|
|
26
|
+
default: false,
|
|
27
|
+
}),
|
|
28
|
+
"settings-only": Flags.boolean({
|
|
29
|
+
description: "Only sync settings",
|
|
30
|
+
default: false,
|
|
31
|
+
}),
|
|
32
|
+
quiet: Flags.boolean({
|
|
33
|
+
description: "Suppress all output except errors",
|
|
34
|
+
default: false,
|
|
35
|
+
}),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Log a message only if not in quiet mode
|
|
40
|
+
*/
|
|
41
|
+
private logQuiet(message: string, quiet: boolean): void {
|
|
42
|
+
if (!quiet) {
|
|
43
|
+
this.log(message);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async run(): Promise<void> {
|
|
48
|
+
const { flags } = await this.parse(LocalVscode);
|
|
49
|
+
|
|
50
|
+
this.logQuiet("๐ Syncing VS Code configuration from devcontainer.json...", flags.quiet);
|
|
51
|
+
|
|
52
|
+
const scopes = await EntityPackage.getAllPackages();
|
|
53
|
+
this.logQuiet(`๐ Generated scopes: ${scopes.join(", ")}`, flags.quiet);
|
|
54
|
+
|
|
55
|
+
const {
|
|
56
|
+
customizations: { vscode: { extensions: recommendations = [], settings = {} } = {} } = {},
|
|
57
|
+
} = JSON.parse(
|
|
58
|
+
stripComments(
|
|
59
|
+
await Bun.file(join(process.cwd(), ".devcontainer", "devcontainer.json")).text(),
|
|
60
|
+
),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
// Update settings with generated scopes
|
|
64
|
+
const updatedSettings = {
|
|
65
|
+
...settings,
|
|
66
|
+
"conventionalCommits.scopes": scopes,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const settingsConfigString = JSON.stringify(updatedSettings, null, 2);
|
|
70
|
+
const extensionsConfigString = JSON.stringify({ recommendations }, null, 2);
|
|
71
|
+
|
|
72
|
+
if (flags["dry-run"]) {
|
|
73
|
+
this.logQuiet("๐ Dry run mode - showing what would be synced:", flags.quiet);
|
|
74
|
+
this.logQuiet(`๐ฆ Extensions:\n${extensionsConfigString}`, flags.quiet);
|
|
75
|
+
this.logQuiet(`โ๏ธ Settings:\n${settingsConfigString}`, flags.quiet);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Update devcontainer.json with new scopes
|
|
80
|
+
const devcontainerPath = join(process.cwd(), ".devcontainer", "devcontainer.json");
|
|
81
|
+
const devcontainerContent = JSON.parse(stripComments(await Bun.file(devcontainerPath).text()));
|
|
82
|
+
|
|
83
|
+
// Update the scopes in devcontainer.json
|
|
84
|
+
devcontainerContent.customizations.vscode.settings["conventionalCommits.scopes"] = scopes;
|
|
85
|
+
|
|
86
|
+
// Write back the updated devcontainer.json
|
|
87
|
+
await Bun.write(devcontainerPath, JSON.stringify(devcontainerContent, null, 2));
|
|
88
|
+
await $`bun run biome check --write ${devcontainerPath}`;
|
|
89
|
+
this.logQuiet(`โ
Updated ${devcontainerPath} with new scopes!`, flags.quiet);
|
|
90
|
+
|
|
91
|
+
const vscodeDir = join(process.cwd(), ".vscode");
|
|
92
|
+
if (!(await exists(vscodeDir))) await mkdir(vscodeDir, { recursive: true });
|
|
93
|
+
const extensionsPath = join(vscodeDir, "extensions.json");
|
|
94
|
+
const settingsPath = join(vscodeDir, "settings.json");
|
|
95
|
+
|
|
96
|
+
if (!flags["settings-only"]) {
|
|
97
|
+
await Bun.write(extensionsPath, extensionsConfigString);
|
|
98
|
+
this.logQuiet(`โ
Updated ${extensionsPath}!`, flags.quiet);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!flags["extensions-only"]) {
|
|
102
|
+
await Bun.write(settingsPath, settingsConfigString);
|
|
103
|
+
this.logQuiet(`โ
Updated ${settingsPath}!`, flags.quiet);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
this.logQuiet("โ
VS Code configuration synced successfully!", flags.quiet);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Strip comments from JSON content
|
|
112
|
+
*/
|
|
113
|
+
function stripComments(content: string): string {
|
|
114
|
+
return content
|
|
115
|
+
.replace(/\/\/[^\r\n]*/g, "")
|
|
116
|
+
.replace(/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g, "")
|
|
117
|
+
.replace(/^\s*[\r\n]/gm, "");
|
|
118
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { readdir } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { Command, Flags } from "@oclif/core";
|
|
4
|
+
import { $ } from "bun";
|
|
5
|
+
import { colorify } from "../core";
|
|
6
|
+
|
|
7
|
+
export default class UpdatePackageJson extends Command {
|
|
8
|
+
static description =
|
|
9
|
+
"Update the package.json exports attributes based on the files in the package";
|
|
10
|
+
|
|
11
|
+
static examples = ["intershell update-package-json"];
|
|
12
|
+
|
|
13
|
+
static flags = {
|
|
14
|
+
src: Flags.boolean({
|
|
15
|
+
char: "s",
|
|
16
|
+
description: "Are you using src directory? (default: true)",
|
|
17
|
+
default: true,
|
|
18
|
+
}),
|
|
19
|
+
"dry-run": Flags.boolean({
|
|
20
|
+
char: "d",
|
|
21
|
+
description: "Show what would be updated without making changes",
|
|
22
|
+
default: false,
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
async run(): Promise<void> {
|
|
27
|
+
const { flags } = await this.parse(UpdatePackageJson);
|
|
28
|
+
this.log(colorify.blue("๐งน Starting package.json update..."));
|
|
29
|
+
|
|
30
|
+
const packageJsonPath = path.join(process.cwd(), "package.json");
|
|
31
|
+
const packageDir = path.dirname(packageJsonPath);
|
|
32
|
+
const srcDir = flags.src ? path.join(packageDir, "src") : packageDir;
|
|
33
|
+
const files = await readdir(srcDir, {
|
|
34
|
+
withFileTypes: true,
|
|
35
|
+
recursive: false,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
this.log(
|
|
39
|
+
colorify.blue(`๐ Found ${files.length} exportable modules:`),
|
|
40
|
+
colorify.cyan(files.map((f) => f.name).join(" ")),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const newExports = await this.getNewExports(files, srcDir, packageDir);
|
|
44
|
+
|
|
45
|
+
if (flags["dry-run"]) {
|
|
46
|
+
this.log(colorify.yellow("๐ Dry run mode, skipping write:"));
|
|
47
|
+
this.log(JSON.stringify(newExports, null, 2));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const packageJson = JSON.parse(await Bun.file(packageJsonPath).text());
|
|
52
|
+
packageJson.exports = newExports;
|
|
53
|
+
|
|
54
|
+
await Bun.write(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
55
|
+
await $`bun biome check --write --no-errors-on-unmatched ${packageJsonPath}`;
|
|
56
|
+
this.log(colorify.green("โ
Package.json updated successfully"));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private async getNewExports(
|
|
60
|
+
files: Array<{ name: string; isDirectory(): boolean }>,
|
|
61
|
+
srcDir: string,
|
|
62
|
+
packageDir: string,
|
|
63
|
+
): Promise<Record<string, string>> {
|
|
64
|
+
const newExports: Record<string, string> = {};
|
|
65
|
+
|
|
66
|
+
for (const file of files) {
|
|
67
|
+
if (file.isDirectory()) {
|
|
68
|
+
const indexFile = path.join(srcDir, file.name, "index.ts");
|
|
69
|
+
const indexTsxFile = path.join(srcDir, file.name, "index.tsx");
|
|
70
|
+
const sameNameFile = path.join(srcDir, file.name, `${file.name}.ts`);
|
|
71
|
+
const sameNameTsxFile = path.join(srcDir, file.name, `${file.name}.tsx`);
|
|
72
|
+
|
|
73
|
+
if (await Bun.file(indexFile).exists()) {
|
|
74
|
+
newExports[`./${file.name}`] = `./${path.relative(packageDir, indexFile)}`;
|
|
75
|
+
} else if (await Bun.file(indexTsxFile).exists()) {
|
|
76
|
+
newExports[`./${file.name}`] = `./${path.relative(packageDir, indexTsxFile)}`;
|
|
77
|
+
} else if (await Bun.file(sameNameFile).exists()) {
|
|
78
|
+
newExports[`./${file.name}`] = `./${path.relative(packageDir, sameNameFile)}`;
|
|
79
|
+
} else if (await Bun.file(sameNameTsxFile).exists()) {
|
|
80
|
+
newExports[`./${file.name}`] = `./${path.relative(packageDir, sameNameTsxFile)}`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const shouldSkip = !file.name.endsWith(".ts") && !file.name.endsWith(".tsx");
|
|
87
|
+
if (shouldSkip) continue;
|
|
88
|
+
|
|
89
|
+
if (file.name === "index.ts") {
|
|
90
|
+
newExports["."] = "./index.ts";
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const mainFile = path.join(srcDir, file.name);
|
|
95
|
+
const relativePath = `./${path.relative(packageDir, mainFile)}`;
|
|
96
|
+
|
|
97
|
+
if (await Bun.file(mainFile).exists()) {
|
|
98
|
+
newExports[`./${file.name}`] = relativePath;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return newExports;
|
|
103
|
+
}
|
|
104
|
+
}
|