@amr-m-abdelgawad/devctl 0.1.2-bootstrap.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Amr MOUSA
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # @amr-m-abdelgawad/devctl
2
+
3
+ One terminal for your local stack. Start services, watch logs, check identity, and drive the proxy from a keyboard-first TUI, the CLI, or an agent over MCP.
4
+
5
+ ## Try it
6
+
7
+ Node.js 18 or later is the only prerequisite. The package installs its own official Bun runtime.
8
+
9
+ ```bash
10
+ npx @amr-m-abdelgawad/devctl@latest
11
+ ```
12
+
13
+ ## Install it
14
+
15
+ For regular use, install the command globally:
16
+
17
+ ```bash
18
+ npm install --global @amr-m-abdelgawad/devctl
19
+ devctl version
20
+ ```
21
+
22
+ Then, from a repository:
23
+
24
+ ```bash
25
+ devctl setup
26
+ devctl doctor
27
+ devctl
28
+ ```
29
+
30
+ Google Cloud CLI is optional and is needed only for user identity, service-account impersonation, or IAP.
31
+
32
+ Documentation and source: [github.com/amr-m-abdelgawad/devctl](https://github.com/amr-m-abdelgawad/devctl)
33
+
34
+ ## Platform support
35
+
36
+ - macOS: Apple silicon and Intel
37
+ - Linux: arm64 and x64, including glibc and musl distributions
38
+ - Windows: x64
39
+
40
+ This free npm distribution runs devctl's JavaScript with Bun's official runtime. It does not claim that the optional standalone GitHub binaries are signed by Apple or Microsoft.
package/bin/devctl.cjs ADDED
@@ -0,0 +1,150 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { closeSync, openSync, readSync } = require("node:fs");
5
+ const { resolve } = require("node:path");
6
+ const { spawn } = require("node:child_process");
7
+
8
+ const SUPPORTED_TARGETS = new Set([
9
+ "darwin-arm64",
10
+ "darwin-x64",
11
+ "linux-arm64",
12
+ "linux-x64",
13
+ "win32-x64",
14
+ ]);
15
+
16
+ function targetFor(platform = process.platform, arch = process.arch) {
17
+ return `${platform}-${arch}`;
18
+ }
19
+
20
+ function assertSupportedTarget(platform = process.platform, arch = process.arch) {
21
+ const target = targetFor(platform, arch);
22
+ if (!SUPPORTED_TARGETS.has(target)) {
23
+ throw new Error(
24
+ `devctl does not currently support ${target}. Supported targets: ${Array.from(SUPPORTED_TARGETS).join(", ")}.`,
25
+ );
26
+ }
27
+ return target;
28
+ }
29
+
30
+ function resolveBunExecutable(resolveModule = require.resolve) {
31
+ try {
32
+ return resolveModule("bun/bin/bun.exe", { paths: [__dirname] });
33
+ } catch (cause) {
34
+ throw new Error(
35
+ "The bundled Bun runtime is missing. Reinstall @amr-m-abdelgawad/devctl without --ignore-scripts and try again.",
36
+ { cause },
37
+ );
38
+ }
39
+ }
40
+
41
+ function readFilePrefix(filePath) {
42
+ const descriptor = openSync(filePath, "r");
43
+ try {
44
+ const prefix = Buffer.alloc(512);
45
+ const bytesRead = readSync(descriptor, prefix, 0, prefix.length, 0);
46
+ return prefix.subarray(0, bytesRead);
47
+ } finally {
48
+ closeSync(descriptor);
49
+ }
50
+ }
51
+
52
+ function assertInstalledBun(bunPath, readFile = readFilePrefix) {
53
+ const prefix = readFile(bunPath).toString("utf8");
54
+ if (prefix.includes("Bun's postinstall script was not run")) {
55
+ throw new Error(
56
+ "The bundled Bun runtime was not installed because npm lifecycle scripts were disabled. " +
57
+ "Reinstall without --ignore-scripts, then run devctl again.",
58
+ );
59
+ }
60
+ }
61
+
62
+ function launch(options = {}) {
63
+ const platform = options.platform ?? process.platform;
64
+ const arch = options.arch ?? process.arch;
65
+ const argv = options.argv ?? process.argv.slice(2);
66
+ const env = options.env ?? process.env;
67
+ const cwd = options.cwd ?? process.cwd();
68
+ const spawnChild = options.spawnChild ?? spawn;
69
+ const resolveModule = options.resolveModule ?? require.resolve;
70
+ const readFile = options.readFile ?? readFilePrefix;
71
+ const entrypoint = options.entrypoint ?? resolve(__dirname, "../dist/devctl.js");
72
+
73
+ assertSupportedTarget(platform, arch);
74
+ const bunPath = resolveBunExecutable(resolveModule);
75
+ assertInstalledBun(bunPath, readFile);
76
+
77
+ return spawnChild(bunPath, [entrypoint, ...argv], {
78
+ cwd,
79
+ env,
80
+ shell: false,
81
+ stdio: "inherit",
82
+ windowsHide: false,
83
+ });
84
+ }
85
+
86
+ function preserveChildExit(hostProcess, code, signal) {
87
+ if (typeof code === "number") {
88
+ hostProcess.exitCode = code;
89
+ return;
90
+ }
91
+ if (signal) {
92
+ hostProcess.kill(hostProcess.pid, signal);
93
+ return;
94
+ }
95
+ hostProcess.exitCode = 1;
96
+ }
97
+
98
+ function runMain() {
99
+ let child;
100
+ try {
101
+ child = launch();
102
+ } catch (error) {
103
+ const message = error instanceof Error ? error.message : String(error);
104
+ console.error(`devctl: ${message}`);
105
+ process.exitCode = 1;
106
+ return;
107
+ }
108
+
109
+ const forwardedSignals = process.platform === "win32" ? ["SIGINT", "SIGTERM"] : ["SIGINT", "SIGTERM", "SIGHUP"];
110
+ const handlers = new Map();
111
+ for (const signal of forwardedSignals) {
112
+ const handler = () => {
113
+ if (!child.killed) {
114
+ child.kill(signal);
115
+ }
116
+ };
117
+ handlers.set(signal, handler);
118
+ process.on(signal, handler);
119
+ }
120
+
121
+ child.once("error", (error) => {
122
+ for (const [signal, handler] of handlers) {
123
+ process.off(signal, handler);
124
+ }
125
+ console.error(`devctl: failed to start the bundled Bun runtime: ${error.message}`);
126
+ process.exitCode = 1;
127
+ });
128
+
129
+ child.once("exit", (code, signal) => {
130
+ for (const [registeredSignal, handler] of handlers) {
131
+ process.off(registeredSignal, handler);
132
+ }
133
+ preserveChildExit(process, code, signal);
134
+ });
135
+ }
136
+
137
+ if (require.main === module) {
138
+ runMain();
139
+ }
140
+
141
+ module.exports = {
142
+ SUPPORTED_TARGETS,
143
+ assertInstalledBun,
144
+ assertSupportedTarget,
145
+ launch,
146
+ preserveChildExit,
147
+ readFilePrefix,
148
+ resolveBunExecutable,
149
+ targetFor,
150
+ };