@gogd-core/ggd 0.1.5 → 0.1.9

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 ADDED
@@ -0,0 +1,151 @@
1
+ # @gogd-core/ggd
2
+
3
+ GoGoodDev workspace CLI — a unified command-line tool for environment management, git workflows, and Jenkins CI integration.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g @gogd-core/ggd
9
+ ```
10
+
11
+ Shell tab-completion is auto-installed on `npm install -g` (bash, zsh, powershell).
12
+
13
+ ## Requirements
14
+
15
+ - Node.js 20+
16
+
17
+ ## Commands
18
+
19
+ ### `ggd env` — Environment Management
20
+
21
+ ```bash
22
+ ggd env use <name> # Switch to a named environment
23
+ ```
24
+
25
+ ### `ggd run` — Execute Shell Commands
26
+
27
+ ```bash
28
+ ggd run <command...> # Run any shell command via cross-platform executor
29
+ ```
30
+
31
+ ### `ggd rsh` — Git Reset Hard (Safe)
32
+
33
+ Reset current branch to `origin/<branch>` with safety checks.
34
+
35
+ ```bash
36
+ ggd rsh
37
+ ```
38
+
39
+ Shows current branch name and uncommitted change count before prompting for confirmation. Prevents accidental data loss.
40
+
41
+ ### `ggd mt` — Merge Tool
42
+
43
+ Merge current branch into a target branch with automatic branch management.
44
+
45
+ ```bash
46
+ ggd mt <target-branch>
47
+ ```
48
+
49
+ Switches to the target branch (re-creates from origin if it exists locally), then merges the source branch with confirmation.
50
+
51
+ ### `ggd jenkins` — Jenkins CI Integration
52
+
53
+ Trigger and monitor Jenkins builds from the terminal.
54
+
55
+ #### Setup
56
+
57
+ ```bash
58
+ # Interactive setup (manual entry)
59
+ ggd jenkins setup
60
+
61
+ # Setup with a team preset file (recommended)
62
+ ggd jenkins setup --preset <path-to-preset.json>
63
+ ```
64
+
65
+ Saves config to `~/.ggd/jenkins.json`. Re-running setup preserves existing values.
66
+
67
+ #### Build
68
+
69
+ ```bash
70
+ # List available build targets
71
+ ggd jenkins build
72
+
73
+ # Trigger a build with defaults
74
+ ggd jenkins build <target>
75
+
76
+ # Override parameters
77
+ ggd jenkins build <target> --KEY=value --KEY2=value2
78
+
79
+ # Trigger without watching (detached mode)
80
+ ggd jenkins build <target> --detach
81
+ ```
82
+
83
+ The build command will:
84
+ 1. Trigger the Jenkins job via REST API (with CSRF crumb support)
85
+ 2. Poll the queue until the build starts
86
+ 3. Stream console output (last 5 lines) in real-time
87
+ 4. Send a desktop notification when done (Windows/macOS/Linux)
88
+
89
+ Use `--help` to see all targets with their default parameters:
90
+
91
+ ```bash
92
+ ggd jenkins build --help
93
+ ```
94
+
95
+ #### View Config
96
+
97
+ ```bash
98
+ ggd jenkins config # Print current config as JSON
99
+ ```
100
+
101
+ ### `ggd completion` — Shell Completion
102
+
103
+ Tab-completion is auto-installed globally. To manually output the script:
104
+
105
+ ```bash
106
+ ggd completion # Auto-detect shell
107
+ ggd completion bash
108
+ ggd completion zsh
109
+ ggd completion powershell
110
+ ```
111
+
112
+ ## Preset Files
113
+
114
+ Teams can share Jenkins configuration via preset files. These are JSON files that define environments, job paths, and build targets:
115
+
116
+ ```json
117
+ {
118
+ "url": "http://jenkins.example.com",
119
+ "environments": {
120
+ "staging": {
121
+ "ui": "staging/job/frontend",
122
+ "api": "staging/job/api"
123
+ },
124
+ "production": {
125
+ "ui": "production/job/frontend",
126
+ "api": "production/job/api"
127
+ }
128
+ },
129
+ "targets": [
130
+ {
131
+ "name": "ui",
132
+ "displayName": "UI (Frontend)",
133
+ "jobPathKey": "ui",
134
+ "defaults": {
135
+ "COMMIT_HASH": "a-staging",
136
+ "SITE": "acc"
137
+ }
138
+ }
139
+ ]
140
+ }
141
+ ```
142
+
143
+ Load with: `ggd jenkins setup --preset <file>`
144
+
145
+ ## Configuration
146
+
147
+ All config is stored at `~/.ggd/jenkins.json`. No environment variables required.
148
+
149
+ ## License
150
+
151
+ Private
package/main.js CHANGED
@@ -609,6 +609,21 @@ function createJenkinsCommand() {
609
609
  if (!config || config.targets.length === 0) {
610
610
  return "\nNo build targets configured. Run: ggd jenkins setup --preset <file>";
611
611
  }
612
+ const buildIdx = process.argv.indexOf("build");
613
+ const targetArg = buildIdx !== -1 ? process.argv.slice(buildIdx + 1).find((a) => !a.startsWith("-")) : void 0;
614
+ const specificTarget = targetArg ? findTarget(targetArg, config.targets) : void 0;
615
+ if (specificTarget) {
616
+ let text2 = `
617
+ ${specificTarget.displayName} (${specificTarget.name}) parameters:
618
+ `;
619
+ for (const [k, v] of Object.entries(specificTarget.defaults)) {
620
+ text2 += ` --${k.padEnd(42)} [default: ${v || "<empty>"}]
621
+ `;
622
+ }
623
+ text2 += `
624
+ Override: ggd jenkins build ${specificTarget.name} --KEY=value`;
625
+ return text2;
626
+ }
612
627
  let text = "\nAvailable build targets:\n";
613
628
  for (const t of config.targets) {
614
629
  text += `
@@ -791,6 +806,16 @@ program.addCommand(createRshCommand());
791
806
  program.addCommand(createMtCommand());
792
807
  program.addCommand(createJenkinsCommand());
793
808
  program.addCommand(createCompletionCommand());
809
+ var ALIASES = {
810
+ jb: ["jenkins", "build"]
811
+ };
812
+ var cmdIdx = process.argv.findIndex((_, i) => i >= 2 && !process.argv[i]?.startsWith("-"));
813
+ if (cmdIdx !== -1) {
814
+ const expansion = ALIASES[process.argv[cmdIdx]];
815
+ if (expansion) {
816
+ process.argv.splice(cmdIdx, 1, ...expansion);
817
+ }
818
+ }
794
819
  if (process.argv.includes("--get-completions")) {
795
820
  const args = process.argv.slice(process.argv.indexOf("--get-completions") + 1);
796
821
  const suggestions = getCompletions(program, args);
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "@gogd-core/ggd",
3
- "version": "0.1.5",
3
+ "version": "0.1.9",
4
+ "description": "GoGoodDev workspace CLI",
5
+ "bin": {
6
+ "ggd": "./main.js"
7
+ },
8
+ "license": "MIT",
4
9
  "dependencies": {
5
10
  "commander": "12.1.0",
6
11
  "execa": "5.1.1"
7
12
  },
8
13
  "main": "./main.js",
9
14
  "type": "commonjs",
10
- "bin": {
11
- "ggd": "./main.js"
12
- },
13
- "scripts": {
14
- "postinstall": "node ./postinstall.js"
15
- },
16
- "description": "GoGoodDev workspace CLI",
17
15
  "repository": {
18
16
  "type": "git",
19
17
  "url": "https://github.com/andaman-nr/gogooddev.workspace.git"
20
18
  },
21
- "license": "MIT"
19
+ "scripts": {
20
+ "postinstall": "node ./postinstall.js"
21
+ }
22
22
  }
package/src/index.d.ts CHANGED
@@ -1,2 +1,10 @@
1
1
  export { createEnvCommand, createRunCommand, createCompletionCommand } from './commands';
2
2
  export { exec, isWindows, defaultShell } from './core';
3
+ export { getCurrentBranch, getUncommittedChangeCount, resetHard } from './commands/git/rsh';
4
+ export { localBranchExists, deleteLocalBranch, switchBranch, mergeBranch, pushBranch } from './commands/git/mt';
5
+ export { readConfig, writeConfig, getConfigPath, maskToken } from './commands/jenkins/jenkins';
6
+ export type { JenkinsConfig, JenkinsJobPaths } from './commands/jenkins/jenkins';
7
+ export { findTarget, listTargetNames, parseOverrides, mergeParams, resolveJobPath, triggerBuild, waitForBuild, watchBuild, } from './commands/jenkins/jenkins-build';
8
+ export type { BuildTarget } from './commands/jenkins/jenkins-build';
9
+ export { loadPresetFile } from './commands/jenkins/jenkins-presets';
10
+ export type { JenkinsPreset } from './commands/jenkins/jenkins-presets';