kiriya 0.1.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/CHANGELOG.md +58 -0
- package/LICENSE +21 -0
- package/README.md +87 -0
- package/dist/src/config/clean-rules.js +39 -0
- package/dist/src/config/config-keys.js +24 -0
- package/dist/src/config/dependency-directories.js +16 -0
- package/dist/src/config/modules.js +38 -0
- package/dist/src/config/protected-paths.js +32 -0
- package/dist/src/config/rebuildable-directories.js +20 -0
- package/dist/src/core/application/command-registry.js +57 -0
- package/dist/src/core/application/config-values.js +33 -0
- package/dist/src/core/application/path-guard.js +69 -0
- package/dist/src/core/application/paths.js +77 -0
- package/dist/src/core/application/plugin-loader.js +100 -0
- package/dist/src/core/application/process-ending.js +28 -0
- package/dist/src/core/application/root-scope.js +123 -0
- package/dist/src/core/application/safety.js +26 -0
- package/dist/src/core/application/text-input.js +44 -0
- package/dist/src/core/application/walk.js +34 -0
- package/dist/src/core/domain/command.js +8 -0
- package/dist/src/core/domain/encodings.js +70 -0
- package/dist/src/core/domain/errors.js +49 -0
- package/dist/src/core/domain/glob.js +57 -0
- package/dist/src/core/domain/global-options.js +10 -0
- package/dist/src/core/domain/input-schema.js +54 -0
- package/dist/src/core/domain/message.js +7 -0
- package/dist/src/core/domain/module.js +2 -0
- package/dist/src/core/domain/names.js +22 -0
- package/dist/src/core/domain/ports/clipboard.js +2 -0
- package/dist/src/core/domain/ports/clock.js +2 -0
- package/dist/src/core/domain/ports/command-catalog.js +2 -0
- package/dist/src/core/domain/ports/compression.js +2 -0
- package/dist/src/core/domain/ports/config-store.js +2 -0
- package/dist/src/core/domain/ports/confirmation.js +2 -0
- package/dist/src/core/domain/ports/environment.js +2 -0
- package/dist/src/core/domain/ports/file-content.js +2 -0
- package/dist/src/core/domain/ports/file-system.js +2 -0
- package/dist/src/core/domain/ports/hasher.js +2 -0
- package/dist/src/core/domain/ports/network.js +2 -0
- package/dist/src/core/domain/ports/opener.js +2 -0
- package/dist/src/core/domain/ports/passthrough.js +2 -0
- package/dist/src/core/domain/ports/plugin-inventory.js +2 -0
- package/dist/src/core/domain/ports/plugin-source.js +2 -0
- package/dist/src/core/domain/ports/port-table.js +2 -0
- package/dist/src/core/domain/ports/process-runner.js +2 -0
- package/dist/src/core/domain/ports/process-table.js +2 -0
- package/dist/src/core/domain/ports/protected-paths.js +2 -0
- package/dist/src/core/domain/ports/random-source.js +2 -0
- package/dist/src/core/domain/ports/standard-input.js +2 -0
- package/dist/src/core/domain/ports/system-info.js +2 -0
- package/dist/src/core/domain/ports/trash.js +2 -0
- package/dist/src/core/domain/secrets.js +59 -0
- package/dist/src/core/domain/targets.js +41 -0
- package/dist/src/core/domain/text-case.js +39 -0
- package/dist/src/core/domain/values/bytes.js +13 -0
- package/dist/src/core/domain/view.js +2 -0
- package/dist/src/core/infrastructure/node/can-listen.js +10 -0
- package/dist/src/core/infrastructure/node/closed-standard-input.adapter.js +12 -0
- package/dist/src/core/infrastructure/node/config-location.js +27 -0
- package/dist/src/core/infrastructure/node/fs-errors.js +22 -0
- package/dist/src/core/infrastructure/node/json-config-store.adapter.js +69 -0
- package/dist/src/core/infrastructure/node/node-compression.adapter.js +82 -0
- package/dist/src/core/infrastructure/node/node-environment.adapter.js +21 -0
- package/dist/src/core/infrastructure/node/node-file-content.adapter.js +99 -0
- package/dist/src/core/infrastructure/node/node-file-system.adapter.js +169 -0
- package/dist/src/core/infrastructure/node/node-hasher.adapter.js +32 -0
- package/dist/src/core/infrastructure/node/node-network.adapter.js +168 -0
- package/dist/src/core/infrastructure/node/node-plugin-source.adapter.js +89 -0
- package/dist/src/core/infrastructure/node/node-process-runner.adapter.js +48 -0
- package/dist/src/core/infrastructure/node/node-random-source.adapter.js +7 -0
- package/dist/src/core/infrastructure/node/node-standard-input.adapter.js +24 -0
- package/dist/src/core/infrastructure/node/node-system-info.adapter.js +63 -0
- package/dist/src/core/infrastructure/node/process-signals.js +51 -0
- package/dist/src/core/infrastructure/node/run-program.js +65 -0
- package/dist/src/core/infrastructure/node/system-clock.adapter.js +22 -0
- package/dist/src/core/infrastructure/node/typed-programs.js +45 -0
- package/dist/src/core/infrastructure/platform/linux/freedesktop-trash.adapter.js +115 -0
- package/dist/src/core/infrastructure/platform/linux/linux-clipboard.adapter.js +70 -0
- package/dist/src/core/infrastructure/platform/linux/linux-opener.adapter.js +21 -0
- package/dist/src/core/infrastructure/platform/linux/linux-port-table.adapter.js +97 -0
- package/dist/src/core/infrastructure/platform/linux/linux-process-table.adapter.js +61 -0
- package/dist/src/core/infrastructure/platform/macos/macos-clipboard.adapter.js +29 -0
- package/dist/src/core/infrastructure/platform/macos/macos-opener.adapter.js +13 -0
- package/dist/src/core/infrastructure/platform/macos/macos-port-table.adapter.js +86 -0
- package/dist/src/core/infrastructure/platform/macos/macos-process-table.adapter.js +62 -0
- package/dist/src/core/infrastructure/platform/macos/macos-trash.adapter.js +64 -0
- package/dist/src/core/infrastructure/platform/windows/system32.js +6 -0
- package/dist/src/core/infrastructure/platform/windows/windows-clipboard.adapter.js +50 -0
- package/dist/src/core/infrastructure/platform/windows/windows-opener.adapter.js +11 -0
- package/dist/src/core/infrastructure/platform/windows/windows-port-table.adapter.js +38 -0
- package/dist/src/core/infrastructure/platform/windows/windows-process-table.adapter.js +134 -0
- package/dist/src/core/infrastructure/platform/windows/windows-trash.adapter.js +86 -0
- package/dist/src/core/presentation/cli/argv.js +83 -0
- package/dist/src/core/presentation/cli/cli-application.js +201 -0
- package/dist/src/core/presentation/cli/cli-view-format.js +46 -0
- package/dist/src/core/presentation/cli/help.js +202 -0
- package/dist/src/core/presentation/cli/json-output.js +28 -0
- package/dist/src/core/presentation/cli/style.js +21 -0
- package/dist/src/core/presentation/cli/suggest.js +25 -0
- package/dist/src/core/presentation/cli/terminal-confirmation.js +63 -0
- package/dist/src/core/presentation/ended-processes.js +18 -0
- package/dist/src/core/presentation/i18n/translator.js +23 -0
- package/dist/src/core/presentation/list-preview.js +10 -0
- package/dist/src/core/presentation/mcp/elicitation.js +55 -0
- package/dist/src/core/presentation/mcp/mcp-application.js +60 -0
- package/dist/src/core/presentation/mcp/mcp-confirmation.js +59 -0
- package/dist/src/core/presentation/mcp/mcp-server.js +355 -0
- package/dist/src/core/presentation/mcp/protocol.js +32 -0
- package/dist/src/core/presentation/mcp/request-state.js +66 -0
- package/dist/src/core/presentation/mcp/tool-definitions.js +149 -0
- package/dist/src/core/presentation/mcp/tool-results.js +56 -0
- package/dist/src/i18n/locales/en.js +827 -0
- package/dist/src/main.js +154 -0
- package/dist/src/modules/archive/application/archive-sources.js +55 -0
- package/dist/src/modules/archive/application/create-tar.use-case.js +123 -0
- package/dist/src/modules/archive/application/create-zip.use-case.js +106 -0
- package/dist/src/modules/archive/application/extract-tar.use-case.js +240 -0
- package/dist/src/modules/archive/application/extract-zip.use-case.js +181 -0
- package/dist/src/modules/archive/application/tar-reader.js +45 -0
- package/dist/src/modules/archive/application/zip-reader.js +57 -0
- package/dist/src/modules/archive/archive.module.js +27 -0
- package/dist/src/modules/archive/domain/crc32.js +18 -0
- package/dist/src/modules/archive/domain/tar-format.js +97 -0
- package/dist/src/modules/archive/domain/tar-stream.js +223 -0
- package/dist/src/modules/archive/domain/zip-format.js +158 -0
- package/dist/src/modules/archive/presentation/tar.view.js +17 -0
- package/dist/src/modules/archive/presentation/untar.view.js +30 -0
- package/dist/src/modules/archive/presentation/unzip.view.js +24 -0
- package/dist/src/modules/archive/presentation/zip.view.js +17 -0
- package/dist/src/modules/clip/application/copy-text.use-case.js +43 -0
- package/dist/src/modules/clip/application/paste-text.use-case.js +25 -0
- package/dist/src/modules/clip/clip.module.js +16 -0
- package/dist/src/modules/clip/presentation/clip.views.js +7 -0
- package/dist/src/modules/completion/application/print-script.use-case.js +38 -0
- package/dist/src/modules/completion/application/suggest-words.use-case.js +37 -0
- package/dist/src/modules/completion/completion.module.js +14 -0
- package/dist/src/modules/completion/domain/scripts.js +91 -0
- package/dist/src/modules/completion/domain/suggest.js +134 -0
- package/dist/src/modules/completion/presentation/completion.views.js +6 -0
- package/dist/src/modules/config/application/config-commands.js +14 -0
- package/dist/src/modules/config/application/get-setting.use-case.js +25 -0
- package/dist/src/modules/config/application/list-config-keys.use-case.js +26 -0
- package/dist/src/modules/config/application/list-settings.use-case.js +28 -0
- package/dist/src/modules/config/application/set-setting.use-case.js +53 -0
- package/dist/src/modules/config/application/show-config-path.use-case.js +21 -0
- package/dist/src/modules/config/application/unset-setting.use-case.js +28 -0
- package/dist/src/modules/config/config.module.js +28 -0
- package/dist/src/modules/config/presentation/config.views.js +33 -0
- package/dist/src/modules/convert/application/convert-case.use-case.js +38 -0
- package/dist/src/modules/convert/application/convert-codecs.use-case.js +92 -0
- package/dist/src/modules/convert/application/convert-input.js +16 -0
- package/dist/src/modules/convert/application/convert-json.use-case.js +51 -0
- package/dist/src/modules/convert/application/convert-time.use-case.js +39 -0
- package/dist/src/modules/convert/application/decode-jwt.use-case.js +52 -0
- package/dist/src/modules/convert/convert.module.js +29 -0
- package/dist/src/modules/convert/domain/json-syntax.js +135 -0
- package/dist/src/modules/convert/domain/jwt.js +29 -0
- package/dist/src/modules/convert/domain/moments.js +20 -0
- package/dist/src/modules/convert/presentation/convert.views.js +44 -0
- package/dist/src/modules/docker/application/clean-engine.use-case.js +77 -0
- package/dist/src/modules/docker/application/compose-project.js +45 -0
- package/dist/src/modules/docker/application/docker-engine.js +40 -0
- package/dist/src/modules/docker/application/list-containers.use-case.js +69 -0
- package/dist/src/modules/docker/application/run-compose.use-case.js +83 -0
- package/dist/src/modules/docker/application/show-logs.use-case.js +51 -0
- package/dist/src/modules/docker/application/stop-project.use-case.js +56 -0
- package/dist/src/modules/docker/docker.module.js +23 -0
- package/dist/src/modules/docker/domain/compose-file.js +105 -0
- package/dist/src/modules/docker/domain/engine-output.js +65 -0
- package/dist/src/modules/docker/presentation/docker.views.js +63 -0
- package/dist/src/modules/doctor/application/run-checks.use-case.js +128 -0
- package/dist/src/modules/doctor/doctor.module.js +13 -0
- package/dist/src/modules/doctor/domain/versions.js +22 -0
- package/dist/src/modules/doctor/presentation/doctor.view.js +30 -0
- package/dist/src/modules/env/application/check-dotenv.use-case.js +116 -0
- package/dist/src/modules/env/application/inspect-path.use-case.js +71 -0
- package/dist/src/modules/env/application/path-entries.js +28 -0
- package/dist/src/modules/env/application/show-variables.use-case.js +47 -0
- package/dist/src/modules/env/domain/dotenv.js +62 -0
- package/dist/src/modules/env/env.module.js +17 -0
- package/dist/src/modules/env/presentation/env.views.js +43 -0
- package/dist/src/modules/files/application/clean-builds.use-case.js +149 -0
- package/dist/src/modules/files/application/compare-paths.use-case.js +127 -0
- package/dist/src/modules/files/application/copy-paths.use-case.js +101 -0
- package/dist/src/modules/files/application/create-paths.use-case.js +85 -0
- package/dist/src/modules/files/application/delete-paths.use-case.js +127 -0
- package/dist/src/modules/files/application/find-duplicates.use-case.js +105 -0
- package/dist/src/modules/files/application/find-files.use-case.js +131 -0
- package/dist/src/modules/files/application/hash-files.use-case.js +73 -0
- package/dist/src/modules/files/application/list-entries.use-case.js +87 -0
- package/dist/src/modules/files/application/measure-folders.use-case.js +102 -0
- package/dist/src/modules/files/application/move-entry.js +19 -0
- package/dist/src/modules/files/application/move-paths.use-case.js +82 -0
- package/dist/src/modules/files/application/read-text.use-case.js +92 -0
- package/dist/src/modules/files/application/rename-paths.use-case.js +184 -0
- package/dist/src/modules/files/application/replace-text.use-case.js +146 -0
- package/dist/src/modules/files/application/search-text.use-case.js +115 -0
- package/dist/src/modules/files/application/show-info.use-case.js +80 -0
- package/dist/src/modules/files/application/show-tree.use-case.js +75 -0
- package/dist/src/modules/files/application/sync-folders.use-case.js +162 -0
- package/dist/src/modules/files/application/text-files.js +46 -0
- package/dist/src/modules/files/application/transfers.js +35 -0
- package/dist/src/modules/files/domain/case-style.js +18 -0
- package/dist/src/modules/files/domain/filters.js +9 -0
- package/dist/src/modules/files/domain/sync-plan.js +35 -0
- package/dist/src/modules/files/domain/text-encoding.js +75 -0
- package/dist/src/modules/files/domain/values.js +28 -0
- package/dist/src/modules/files/files.module.js +70 -0
- package/dist/src/modules/files/presentation/clean.view.js +15 -0
- package/dist/src/modules/files/presentation/compare.view.js +50 -0
- package/dist/src/modules/files/presentation/copy.view.js +17 -0
- package/dist/src/modules/files/presentation/delete.view.js +16 -0
- package/dist/src/modules/files/presentation/dupes.view.js +20 -0
- package/dist/src/modules/files/presentation/find.view.js +16 -0
- package/dist/src/modules/files/presentation/grep.view.js +27 -0
- package/dist/src/modules/files/presentation/hash.view.js +15 -0
- package/dist/src/modules/files/presentation/info.view.js +36 -0
- package/dist/src/modules/files/presentation/list.view.js +17 -0
- package/dist/src/modules/files/presentation/move.view.js +14 -0
- package/dist/src/modules/files/presentation/new.view.js +8 -0
- package/dist/src/modules/files/presentation/read.view.js +6 -0
- package/dist/src/modules/files/presentation/rename.view.js +16 -0
- package/dist/src/modules/files/presentation/replace.view.js +26 -0
- package/dist/src/modules/files/presentation/size.view.js +24 -0
- package/dist/src/modules/files/presentation/sync.view.js +37 -0
- package/dist/src/modules/files/presentation/tree.view.js +22 -0
- package/dist/src/modules/gen/application/gen-options.js +18 -0
- package/dist/src/modules/gen/application/generate-passwords.use-case.js +39 -0
- package/dist/src/modules/gen/application/generate-tokens.use-case.js +38 -0
- package/dist/src/modules/gen/application/generate-ulids.use-case.js +40 -0
- package/dist/src/modules/gen/application/generate-uuids.use-case.js +32 -0
- package/dist/src/modules/gen/domain/identifiers.js +65 -0
- package/dist/src/modules/gen/domain/secrets.js +43 -0
- package/dist/src/modules/gen/gen.module.js +20 -0
- package/dist/src/modules/git/application/fetch-repositories.use-case.js +50 -0
- package/dist/src/modules/git/application/git-client.js +62 -0
- package/dist/src/modules/git/application/pull-repositories.use-case.js +67 -0
- package/dist/src/modules/git/application/repositories.js +67 -0
- package/dist/src/modules/git/application/show-status.use-case.js +49 -0
- package/dist/src/modules/git/application/switch-branch.use-case.js +118 -0
- package/dist/src/modules/git/domain/repository-status.js +37 -0
- package/dist/src/modules/git/git.module.js +25 -0
- package/dist/src/modules/git/presentation/git.views.js +100 -0
- package/dist/src/modules/net/application/check-connection.use-case.js +71 -0
- package/dist/src/modules/net/application/list-addresses.use-case.js +29 -0
- package/dist/src/modules/net/application/lookup-name.use-case.js +55 -0
- package/dist/src/modules/net/net.module.js +17 -0
- package/dist/src/modules/net/presentation/net.views.js +39 -0
- package/dist/src/modules/open/application/open-target.use-case.js +53 -0
- package/dist/src/modules/open/domain/targets.js +45 -0
- package/dist/src/modules/open/open.module.js +12 -0
- package/dist/src/modules/open/presentation/open.view.js +6 -0
- package/dist/src/modules/port/application/end-port-owners.use-case.js +68 -0
- package/dist/src/modules/port/application/find-free-port.use-case.js +40 -0
- package/dist/src/modules/port/application/find-listeners.use-case.js +34 -0
- package/dist/src/modules/port/application/port-owners.js +25 -0
- package/dist/src/modules/port/domain/port-number.js +8 -0
- package/dist/src/modules/port/port.module.js +17 -0
- package/dist/src/modules/port/presentation/port.views.js +27 -0
- package/dist/src/modules/proc/application/end-processes.use-case.js +77 -0
- package/dist/src/modules/proc/application/find-processes.use-case.js +50 -0
- package/dist/src/modules/proc/application/list-processes.use-case.js +41 -0
- package/dist/src/modules/proc/application/show-tree.use-case.js +40 -0
- package/dist/src/modules/proc/domain/process-tree.js +55 -0
- package/dist/src/modules/proc/presentation/proc.views.js +28 -0
- package/dist/src/modules/proc/proc.module.js +19 -0
- package/dist/src/modules/sys/application/create-report.use-case.js +30 -0
- package/dist/src/modules/sys/application/find-tools.use-case.js +20 -0
- package/dist/src/modules/sys/application/machine-facts.js +44 -0
- package/dist/src/modules/sys/application/show-info.use-case.js +29 -0
- package/dist/src/modules/sys/domain/tools.js +17 -0
- package/dist/src/modules/sys/presentation/sys.views.js +67 -0
- package/dist/src/modules/sys/sys.module.js +17 -0
- package/dist/src/modules/wait/application/poll.js +26 -0
- package/dist/src/modules/wait/application/wait-file.use-case.js +55 -0
- package/dist/src/modules/wait/application/wait-port.use-case.js +76 -0
- package/dist/src/modules/wait/application/wait-url.use-case.js +71 -0
- package/dist/src/modules/wait/domain/reasons.js +14 -0
- package/dist/src/modules/wait/domain/wait-input.js +50 -0
- package/dist/src/modules/wait/presentation/wait.views.js +31 -0
- package/dist/src/modules/wait/wait.module.js +21 -0
- package/package.json +57 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { done } from "../../../core/domain/command.js";
|
|
2
|
+
import { UsageError } from "../../../core/domain/errors.js";
|
|
3
|
+
import { RawReader } from "../../../core/domain/input-schema.js";
|
|
4
|
+
import { message } from "../../../core/domain/message.js";
|
|
5
|
+
import { failureReason } from "../domain/reasons.js";
|
|
6
|
+
import { parseHttpAddress, readStatuses, readTimeout, statusIsReady, TIMEOUT_OPTION } from "../domain/wait-input.js";
|
|
7
|
+
import { poll } from "./poll.js";
|
|
8
|
+
/** The longest one request may take, so a server that never answers is asked again. */
|
|
9
|
+
export const URL_ATTEMPT_MS = 5_000;
|
|
10
|
+
export const waitUrlSpec = {
|
|
11
|
+
id: "wait.url",
|
|
12
|
+
summary: "wait.url.summary",
|
|
13
|
+
examples: [
|
|
14
|
+
"kiriya wait url http://localhost:3000/health",
|
|
15
|
+
"kiriya wait url https://example.com/ready --status 200 --status 204",
|
|
16
|
+
],
|
|
17
|
+
safety: "read",
|
|
18
|
+
idempotent: true,
|
|
19
|
+
usesNetwork: true,
|
|
20
|
+
runsUserCommands: false,
|
|
21
|
+
// The address can carry any text to a website, as with open.
|
|
22
|
+
sensitive: true,
|
|
23
|
+
input: {
|
|
24
|
+
positionals: [{ name: "url", description: "wait.url.arg.url", required: true, variadic: false }],
|
|
25
|
+
options: {
|
|
26
|
+
status: { type: "string", description: "wait.url.option.status", valueName: "<code>", multiple: true },
|
|
27
|
+
timeout: TIMEOUT_OPTION,
|
|
28
|
+
},
|
|
29
|
+
parse(raw) {
|
|
30
|
+
const reader = new RawReader(raw);
|
|
31
|
+
const text = reader.positional(0) ?? "";
|
|
32
|
+
const url = parseHttpAddress(text);
|
|
33
|
+
if (url === null)
|
|
34
|
+
throw new UsageError("wait.url.not-http", { url: text });
|
|
35
|
+
return { url, statuses: readStatuses(reader), timeoutSeconds: readTimeout(reader) };
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
export class WaitForUrl {
|
|
40
|
+
network;
|
|
41
|
+
clock;
|
|
42
|
+
spec = waitUrlSpec;
|
|
43
|
+
constructor(network, clock) {
|
|
44
|
+
this.network = network;
|
|
45
|
+
this.clock = clock;
|
|
46
|
+
}
|
|
47
|
+
async execute(input, context) {
|
|
48
|
+
const polled = await poll(this.clock, input.timeoutSeconds * 1000, context.signal, async (allowedMs) => {
|
|
49
|
+
const outcome = await this.network.request(input.url, Math.min(URL_ATTEMPT_MS, allowedMs), context.signal);
|
|
50
|
+
return { ready: outcome.ok && statusIsReady(outcome.status, input.statuses), value: outcome };
|
|
51
|
+
});
|
|
52
|
+
const { last } = polled;
|
|
53
|
+
const data = {
|
|
54
|
+
url: input.url,
|
|
55
|
+
ready: polled.ready,
|
|
56
|
+
attempts: polled.attempts,
|
|
57
|
+
waitedMs: polled.waitedMs,
|
|
58
|
+
status: last.ok ? last.status : null,
|
|
59
|
+
failure: last.ok ? null : last.failure,
|
|
60
|
+
code: last.ok ? null : last.code,
|
|
61
|
+
};
|
|
62
|
+
if (polled.ready)
|
|
63
|
+
return done(data);
|
|
64
|
+
const reason = last.ok
|
|
65
|
+
? message("wait.reason.status", { status: last.status })
|
|
66
|
+
: failureReason(last.failure, new URL(input.url).hostname, last.code);
|
|
67
|
+
const failure = message("wait.url.timed-out", { url: input.url, seconds: input.timeoutSeconds, reason });
|
|
68
|
+
return done(data, { failures: [failure] });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=wait-url.use-case.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { message } from "../../../core/domain/message.js";
|
|
2
|
+
const REASONS = {
|
|
3
|
+
refused: "wait.reason.refused",
|
|
4
|
+
timeout: "wait.reason.timeout",
|
|
5
|
+
"not-found": "wait.reason.not-found",
|
|
6
|
+
unreachable: "wait.reason.unreachable",
|
|
7
|
+
tls: "wait.reason.tls",
|
|
8
|
+
failed: "wait.reason.failed",
|
|
9
|
+
};
|
|
10
|
+
/** Why the last attempt was not ready, worded to end a sentence. */
|
|
11
|
+
export function failureReason(failure, host, code) {
|
|
12
|
+
return message(REASONS[failure], { host, code: code ?? failure });
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=reasons.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { UsageError } from "../../../core/domain/errors.js";
|
|
2
|
+
import { parseTarget } from "../../../core/domain/targets.js";
|
|
3
|
+
export const DEFAULT_TIMEOUT_SECONDS = 60;
|
|
4
|
+
export const MAX_TIMEOUT_SECONDS = 3_600;
|
|
5
|
+
export const TIMEOUT_OPTION = {
|
|
6
|
+
type: "string",
|
|
7
|
+
description: "wait.option.timeout",
|
|
8
|
+
valueName: "<seconds>",
|
|
9
|
+
};
|
|
10
|
+
/** --timeout in whole seconds: 60 by default, and at most an hour. */
|
|
11
|
+
export function readTimeout(reader) {
|
|
12
|
+
const seconds = reader.positiveInteger("timeout", DEFAULT_TIMEOUT_SECONDS);
|
|
13
|
+
if (seconds > MAX_TIMEOUT_SECONDS)
|
|
14
|
+
throw new UsageError("wait.timeout-range", { max: MAX_TIMEOUT_SECONDS });
|
|
15
|
+
return seconds;
|
|
16
|
+
}
|
|
17
|
+
/** A port on this machine, such as 5432, or what net check takes: host:port, [IPv6]:port or a URL; null for anything else. */
|
|
18
|
+
export function parsePortTarget(text) {
|
|
19
|
+
const value = text.trim();
|
|
20
|
+
if (!/^\d+$/.test(value))
|
|
21
|
+
return parseTarget(value);
|
|
22
|
+
const port = Number(value);
|
|
23
|
+
return value.length <= 5 && port >= 1 && port <= 65_535 ? { host: "localhost", port } : null;
|
|
24
|
+
}
|
|
25
|
+
/** An http or https address as the URL parser writes it; null for anything else. */
|
|
26
|
+
export function parseHttpAddress(text) {
|
|
27
|
+
let url;
|
|
28
|
+
try {
|
|
29
|
+
url = new URL(text.trim());
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return (url.protocol === "http:" || url.protocol === "https:") && url.hostname !== "" ? url.href : null;
|
|
35
|
+
}
|
|
36
|
+
/** The statuses --status names, each a code from 100 to 599. */
|
|
37
|
+
export function readStatuses(reader) {
|
|
38
|
+
return reader.strings("status").map((value) => {
|
|
39
|
+
const status = Number(value);
|
|
40
|
+
if (!/^\d{3}$/.test(value) || status < 100 || status > 599) {
|
|
41
|
+
throw new UsageError("wait.url.bad-status", { value });
|
|
42
|
+
}
|
|
43
|
+
return status;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/** Any 2xx status is ready, unless --status names the statuses that are. */
|
|
47
|
+
export function statusIsReady(status, wanted) {
|
|
48
|
+
return wanted.length === 0 ? status >= 200 && status < 300 : wanted.includes(status);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=wait-input.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { message } from "../../../core/domain/message.js";
|
|
2
|
+
import { formatTarget } from "../../../core/domain/targets.js";
|
|
3
|
+
/** Seconds with one decimal, such as 3.5. */
|
|
4
|
+
const seconds = (ms) => (ms / 1000).toFixed(1);
|
|
5
|
+
// A wait that ran out of time arrives as a failure, so each view prints a line only when it is ready.
|
|
6
|
+
export const portView = (output, format) => {
|
|
7
|
+
if (!output.ready)
|
|
8
|
+
return [];
|
|
9
|
+
const target = formatTarget(output);
|
|
10
|
+
const line = output.gone
|
|
11
|
+
? message("wait.port.closed", { target, seconds: seconds(output.waitedMs) })
|
|
12
|
+
: message("wait.port.listening", {
|
|
13
|
+
target,
|
|
14
|
+
address: output.address ?? output.host,
|
|
15
|
+
seconds: seconds(output.waitedMs),
|
|
16
|
+
});
|
|
17
|
+
return [format.green(format.text(line))];
|
|
18
|
+
};
|
|
19
|
+
export const urlView = (output, format) => {
|
|
20
|
+
if (!output.ready || output.status === null)
|
|
21
|
+
return [];
|
|
22
|
+
const line = message("wait.url.ready", { url: output.url, status: output.status, seconds: seconds(output.waitedMs) });
|
|
23
|
+
return [format.green(format.text(line))];
|
|
24
|
+
};
|
|
25
|
+
export const fileView = (output, format) => {
|
|
26
|
+
if (!output.ready)
|
|
27
|
+
return [];
|
|
28
|
+
const params = { path: format.path(output.path), seconds: seconds(output.waitedMs) };
|
|
29
|
+
return [format.green(format.text(message(output.gone ? "wait.file.gone" : "wait.file.exists", params)))];
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=wait.views.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { WaitForFile } from "./application/wait-file.use-case.js";
|
|
2
|
+
import { WaitForPort } from "./application/wait-port.use-case.js";
|
|
3
|
+
import { WaitForUrl } from "./application/wait-url.use-case.js";
|
|
4
|
+
import { fileView, portView, urlView } from "./presentation/wait.views.js";
|
|
5
|
+
export const waitModule = {
|
|
6
|
+
id: "wait",
|
|
7
|
+
summary: "wait.summary",
|
|
8
|
+
about: "wait.about",
|
|
9
|
+
examples: [
|
|
10
|
+
"kiriya wait port 5432",
|
|
11
|
+
"kiriya wait url http://localhost:3000/health",
|
|
12
|
+
"kiriya wait file dist/app.js --timeout 120",
|
|
13
|
+
],
|
|
14
|
+
guide: "https://github.com/SatPaingOo/kiriya/blob/main/docs/modules/wait.md",
|
|
15
|
+
register(registrar, ports) {
|
|
16
|
+
registrar.add(new WaitForPort(ports.network, ports.clock), portView);
|
|
17
|
+
registrar.add(new WaitForUrl(ports.network, ports.clock), urlView);
|
|
18
|
+
registrar.add(new WaitForFile(ports.fileSystem, ports.clock), fileView);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=wait.module.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "kiriya",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "One command-line toolbox for everyday developer work that behaves the same on Windows, Linux and macOS.",
|
|
5
|
+
"mcpName": "io.github.SatPaingOo/kiriya",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Sat Paing Oo",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/SatPaingOo/kiriya.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/SatPaingOo/kiriya/issues"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/SatPaingOo/kiriya#readme",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"cli",
|
|
18
|
+
"developer-tools",
|
|
19
|
+
"cross-platform",
|
|
20
|
+
"toolbox",
|
|
21
|
+
"windows",
|
|
22
|
+
"linux",
|
|
23
|
+
"macos"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"bin": {
|
|
27
|
+
"kiriya": "dist/src/main.js"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist/src",
|
|
31
|
+
"!dist/src/**/*.map",
|
|
32
|
+
"CHANGELOG.md"
|
|
33
|
+
],
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=22.13"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
39
|
+
"build": "npm run clean && tsc -p tsconfig.json",
|
|
40
|
+
"dev": "tsc -p tsconfig.json --watch",
|
|
41
|
+
"docs": "npm run build && node dist/tools/docs.js",
|
|
42
|
+
"test": "npm run build && node dist/tools/check-boundaries.js && node --test \"dist/tests/**/*.test.js\"",
|
|
43
|
+
"lint": "eslint .",
|
|
44
|
+
"format": "prettier --write .",
|
|
45
|
+
"format:check": "prettier --check .",
|
|
46
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@eslint/js": "^10.0.1",
|
|
50
|
+
"@modelcontextprotocol/client": "^2.0.0",
|
|
51
|
+
"@types/node": "^22.20.2",
|
|
52
|
+
"eslint": "^10.10.0",
|
|
53
|
+
"prettier": "^3.9.6",
|
|
54
|
+
"typescript": "^6.0.3",
|
|
55
|
+
"typescript-eslint": "^8.70.0"
|
|
56
|
+
}
|
|
57
|
+
}
|