@gogd-core/ggd 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/main.js ADDED
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+
26
+ // apps/ggd/src/main.ts
27
+ var import_commander3 = require("commander");
28
+
29
+ // apps/ggd/src/commands/env.ts
30
+ var import_commander = require("commander");
31
+ function createEnvCommand() {
32
+ const env = new import_commander.Command("env").description("Manage environments");
33
+ env.command("use <name>").description("Switch to a named environment").action((name) => {
34
+ console.log(`Switched to environment: ${name}`);
35
+ });
36
+ return env;
37
+ }
38
+
39
+ // apps/ggd/src/commands/run.ts
40
+ var import_commander2 = require("commander");
41
+
42
+ // apps/ggd/src/core/exec.ts
43
+ var import_execa = __toESM(require("execa"));
44
+
45
+ // apps/ggd/src/core/os.ts
46
+ function isWindows() {
47
+ return process.platform === "win32";
48
+ }
49
+ function defaultShell() {
50
+ return isWindows() ? "cmd.exe" : "/bin/sh";
51
+ }
52
+
53
+ // apps/ggd/src/core/exec.ts
54
+ async function exec(cmd) {
55
+ try {
56
+ const result = await import_execa.default.command(cmd, {
57
+ stdio: "inherit",
58
+ shell: defaultShell()
59
+ });
60
+ return result.exitCode;
61
+ } catch (error) {
62
+ if (isExecaError(error)) {
63
+ return error.exitCode ?? 1;
64
+ }
65
+ throw error;
66
+ }
67
+ }
68
+ function isExecaError(error) {
69
+ return typeof error === "object" && error !== null && "exitCode" in error;
70
+ }
71
+
72
+ // apps/ggd/src/commands/run.ts
73
+ function createRunCommand() {
74
+ const run = new import_commander2.Command("run").description("Execute a shell command").argument("<cmd...>", "Command and arguments to execute").allowExcessArguments(true).action(async (cmdParts) => {
75
+ const cmd = cmdParts.join(" ");
76
+ const exitCode = await exec(cmd);
77
+ if (exitCode !== 0) {
78
+ process.exitCode = exitCode;
79
+ }
80
+ });
81
+ return run;
82
+ }
83
+
84
+ // apps/ggd/src/main.ts
85
+ var program = new import_commander3.Command();
86
+ program.name("ggd").description("GoGoodDev workspace CLI").version("0.1.0");
87
+ program.addCommand(createEnvCommand());
88
+ program.addCommand(createRunCommand());
89
+ program.parse(process.argv);
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@gogd-core/ggd",
3
+ "version": "0.1.0",
4
+ "dependencies": {
5
+ "commander": "12.1.0",
6
+ "execa": "5.1.1"
7
+ },
8
+ "main": "./main.js",
9
+ "type": "commonjs",
10
+ "bin": {
11
+ "ggd": "./main.js"
12
+ },
13
+ "description": "GoGoodDev workspace CLI",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/andaman-nr/gogooddev.workspace.git"
17
+ },
18
+ "license": "MIT"
19
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * `ggd env` command — environment management.
3
+ */
4
+ import { Command } from 'commander';
5
+ /**
6
+ * Creates the `env` command with subcommands.
7
+ */
8
+ export declare function createEnvCommand(): Command;
@@ -0,0 +1,2 @@
1
+ export { createEnvCommand } from './env';
2
+ export { createRunCommand } from './run';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * `ggd run` command — execute arbitrary shell commands via execa.
3
+ */
4
+ import { Command } from 'commander';
5
+ /**
6
+ * Creates the `run` command.
7
+ * Passes all remaining arguments as a single command string.
8
+ */
9
+ export declare function createRunCommand(): Command;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Cross-platform command execution wrapper around execa.
3
+ */
4
+ /**
5
+ * Executes a shell command string with stdio passthrough.
6
+ * Uses the platform-appropriate shell (cmd.exe on Windows, /bin/sh otherwise).
7
+ *
8
+ * @param cmd - The command string to execute
9
+ * @returns The exit code of the process (0 = success)
10
+ */
11
+ export declare function exec(cmd: string): Promise<number>;
@@ -0,0 +1,2 @@
1
+ export { exec } from './exec';
2
+ export { isWindows, defaultShell } from './os';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Platform detection helpers for cross-platform CLI execution.
3
+ */
4
+ /**
5
+ * Returns true if the current platform is Windows.
6
+ */
7
+ export declare function isWindows(): boolean;
8
+ /**
9
+ * Returns the default shell for the current platform.
10
+ */
11
+ export declare function defaultShell(): string;
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { createEnvCommand, createRunCommand } from './commands';
2
+ export { exec, isWindows, defaultShell } from './core';
package/src/main.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * ggd CLI entry point.
3
+ *
4
+ * Registers all commands and parses process.argv via commander.
5
+ */
6
+ export {};