@radkode/neo 0.16.0 → 1.0.1
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 +21 -0
- package/README.md +55 -236
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +113 -24
- package/dist/cli.js.map +1 -1
- package/dist/commands/git/push/index.d.ts +8 -2
- package/dist/commands/git/push/index.d.ts.map +1 -1
- package/dist/commands/git/push/index.js +49 -44
- package/dist/commands/git/push/index.js.map +1 -1
- package/dist/core/plugins/command-registry.d.ts +16 -0
- package/dist/core/plugins/command-registry.d.ts.map +1 -0
- package/dist/core/plugins/command-registry.js +40 -0
- package/dist/core/plugins/command-registry.js.map +1 -0
- package/dist/core/plugins/event-bus.d.ts +12 -0
- package/dist/core/plugins/event-bus.d.ts.map +1 -0
- package/dist/core/plugins/event-bus.js +56 -0
- package/dist/core/plugins/event-bus.js.map +1 -0
- package/dist/core/plugins/index.d.ts +6 -0
- package/dist/core/plugins/index.d.ts.map +1 -0
- package/dist/core/plugins/index.js +6 -0
- package/dist/core/plugins/index.js.map +1 -0
- package/dist/core/plugins/plugin-context.d.ts +3 -0
- package/dist/core/plugins/plugin-context.d.ts.map +1 -0
- package/dist/core/plugins/plugin-context.js +116 -0
- package/dist/core/plugins/plugin-context.js.map +1 -0
- package/dist/core/plugins/plugin-loader.d.ts +30 -0
- package/dist/core/plugins/plugin-loader.d.ts.map +1 -0
- package/dist/core/plugins/plugin-loader.js +149 -0
- package/dist/core/plugins/plugin-loader.js.map +1 -0
- package/dist/core/plugins/plugin-registry.d.ts +21 -0
- package/dist/core/plugins/plugin-registry.d.ts.map +1 -0
- package/dist/core/plugins/plugin-registry.js +150 -0
- package/dist/core/plugins/plugin-registry.js.map +1 -0
- package/dist/types/schemas.d.ts +3 -3
- package/dist/types/schemas.d.ts.map +1 -1
- package/dist/types/schemas.js +3 -7
- package/dist/types/schemas.js.map +1 -1
- package/dist/utils/config.d.ts +6 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +8 -0
- package/dist/utils/config.js.map +1 -1
- package/package.json +28 -21
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Jacek Radko
|
|
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
CHANGED
|
@@ -1,306 +1,125 @@
|
|
|
1
|
-
```
|
|
2
|
-
███╗ ██╗███████╗ ██████╗ ██████╗██╗ ██╗
|
|
3
|
-
████╗ ██║██╔════╝██╔═══██╗ ██╔════╝██║ ██║
|
|
4
|
-
██╔██╗ ██║█████╗ ██║ ██║ ██║ ██║ ██║
|
|
5
|
-
██║╚██╗██║██╔══╝ ██║ ██║ ██║ ██║ ██║
|
|
6
|
-
██║ ╚████║███████╗╚██████╔╝ ╚██████╗███████╗██║
|
|
7
|
-
╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═════╝╚══════╝╚═╝
|
|
8
|
-
```
|
|
9
|
-
|
|
10
1
|
<div align="center">
|
|
11
2
|
|
|
12
|
-
|
|
3
|
+
# Neo CLI
|
|
4
|
+
|
|
5
|
+
**An opinionated CLI that wraps common commands to smooth out paper cuts and speed up your workflow.**
|
|
13
6
|
|
|
14
7
|
[](https://www.npmjs.com/package/@radkode/neo)
|
|
15
|
-
[](
|
|
8
|
+
[](LICENSE)
|
|
16
9
|
[](https://www.typescriptlang.org/)
|
|
17
10
|
[](https://github.com/radkode/neo/actions)
|
|
18
11
|
|
|
19
|
-
Intelligent git operations • Configuration management • Self-updating
|
|
20
|
-
|
|
21
12
|
</div>
|
|
22
13
|
|
|
23
14
|
---
|
|
24
15
|
|
|
25
|
-
##
|
|
16
|
+
## Why Neo?
|
|
17
|
+
|
|
18
|
+
Daily CLI workflows have friction. Neo wraps familiar commands with sensible defaults and guardrails:
|
|
26
19
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
🚀 **TypeScript First** - Built with full TypeScript support and type safety
|
|
20
|
+
| Friction | Neo's Solution |
|
|
21
|
+
|----------|----------------|
|
|
22
|
+
| Accidentally pushing to `main` | Interactive confirmation before main branch pushes |
|
|
23
|
+
| Forgetting to pull before pushing | `neo git push` pulls first, then pushes |
|
|
24
|
+
| Typing `git stash && git pull && git stash pop` | `neo git pull` handles it automatically |
|
|
25
|
+
| Managing scattered config files | Unified `neo config` with secure secrets storage |
|
|
34
26
|
|
|
35
|
-
|
|
27
|
+
Neo doesn't replace your tools—it wraps them with opinions that prevent mistakes and save keystrokes.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
36
30
|
|
|
37
31
|
```bash
|
|
38
|
-
# Install globally
|
|
39
32
|
npm install -g @radkode/neo
|
|
40
|
-
# or
|
|
33
|
+
# or
|
|
41
34
|
pnpm add -g @radkode/neo
|
|
42
35
|
```
|
|
43
36
|
|
|
44
37
|
## Quick Start
|
|
45
38
|
|
|
46
39
|
```bash
|
|
47
|
-
|
|
48
|
-
neo
|
|
49
|
-
|
|
50
|
-
#
|
|
51
|
-
neo init
|
|
52
|
-
|
|
53
|
-
# Check for updates
|
|
54
|
-
neo update --check-only
|
|
55
|
-
|
|
56
|
-
# Configure a setting
|
|
57
|
-
neo config set editor.default "code"
|
|
58
|
-
|
|
59
|
-
# Smart git push with main branch protection
|
|
60
|
-
neo git push
|
|
61
|
-
|
|
62
|
-
# View current configuration
|
|
63
|
-
neo config list
|
|
40
|
+
neo --help # See all commands
|
|
41
|
+
neo git push # Smart push with main branch protection
|
|
42
|
+
neo git pull # Auto-stash, pull, pop
|
|
43
|
+
neo config list # View your configuration
|
|
64
44
|
```
|
|
65
45
|
|
|
66
|
-
##
|
|
46
|
+
## Commands
|
|
67
47
|
|
|
68
|
-
###
|
|
48
|
+
### `neo git push`
|
|
69
49
|
|
|
70
|
-
|
|
50
|
+
Pulls before pushing. Prompts for confirmation on `main`.
|
|
71
51
|
|
|
72
52
|
```bash
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
Radkode's Lightning-Fast CLI Framework
|
|
77
|
-
|
|
78
|
-
⚠️ You are about to push directly to the main branch.
|
|
79
|
-
This is generally not recommended as it bypasses code review processes.
|
|
80
|
-
✔ Are you sure you want to continue? » No
|
|
81
|
-
|
|
82
|
-
✅ Push cancelled. Here's how to push your changes safely:
|
|
83
|
-
1. Create a feature branch: git checkout -b feature/your-feature-name
|
|
84
|
-
2. Push to your branch: git push -u origin feature/your-feature-name
|
|
85
|
-
3. Create a pull request to merge into main
|
|
86
|
-
|
|
87
|
-
This protects the main branch from accidental changes.
|
|
53
|
+
neo git push # Safe push (confirms on main)
|
|
54
|
+
neo git push --force # Force push
|
|
55
|
+
neo git push --tags # Include tags
|
|
88
56
|
```
|
|
89
57
|
|
|
90
|
-
###
|
|
91
|
-
|
|
92
|
-
```bash
|
|
93
|
-
$ neo config set theme.primary "#00ff88"
|
|
94
|
-
✨ Configuration saved: theme.primary = "#00ff88"
|
|
58
|
+
### `neo git pull`
|
|
95
59
|
|
|
96
|
-
|
|
97
|
-
📝 Your Configuration:
|
|
98
|
-
|
|
99
|
-
🎨 theme.primary "#00ff88"
|
|
100
|
-
💻 editor.default "code"
|
|
101
|
-
🚀 workflow.auto true
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
## Commands
|
|
105
|
-
|
|
106
|
-
### `init`
|
|
107
|
-
|
|
108
|
-
Install and configure Neo CLI globally.
|
|
60
|
+
Stashes uncommitted changes, pulls, and restores your work.
|
|
109
61
|
|
|
110
62
|
```bash
|
|
111
|
-
neo
|
|
63
|
+
neo git pull # Auto-stash and pull
|
|
64
|
+
neo git pull --rebase # Pull with rebase
|
|
112
65
|
```
|
|
113
66
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
- `--force` - Force reconfiguration if already initialized
|
|
117
|
-
- `--skip-install` - Skip global installation (configuration only)
|
|
118
|
-
|
|
119
|
-
### `config`
|
|
67
|
+
### `neo git stash`
|
|
120
68
|
|
|
121
|
-
|
|
69
|
+
Simplified stash management.
|
|
122
70
|
|
|
123
71
|
```bash
|
|
124
|
-
|
|
125
|
-
neo
|
|
126
|
-
|
|
127
|
-
# Get a configuration value
|
|
128
|
-
neo config get api.key
|
|
129
|
-
|
|
130
|
-
# List all configuration values
|
|
131
|
-
neo config list
|
|
72
|
+
neo git stash # Stash changes
|
|
73
|
+
neo git stash pop # Pop latest stash
|
|
74
|
+
neo git stash list # List stashes
|
|
132
75
|
```
|
|
133
76
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
- `config get <key>` - Get a configuration value
|
|
137
|
-
- `config set <key> <value>` - Set a configuration value
|
|
138
|
-
- `config list` - List all configuration values
|
|
139
|
-
|
|
140
|
-
### `git`
|
|
141
|
-
|
|
142
|
-
Enhanced git operations with safety features.
|
|
77
|
+
### `neo config`
|
|
143
78
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
Smart git push with main branch protection.
|
|
79
|
+
Key-value configuration with secure secrets storage.
|
|
147
80
|
|
|
148
81
|
```bash
|
|
149
|
-
|
|
150
|
-
neo
|
|
151
|
-
|
|
152
|
-
# Force push (use with caution)
|
|
153
|
-
neo git push --force
|
|
154
|
-
|
|
155
|
-
# Dry run to see what would be pushed
|
|
156
|
-
neo git push --dry-run
|
|
157
|
-
|
|
158
|
-
# Push and set upstream branch
|
|
159
|
-
neo git push --set-upstream origin feature-branch
|
|
160
|
-
|
|
161
|
-
# Push with tags
|
|
162
|
-
neo git push --tags
|
|
82
|
+
neo config set key value # Set a value
|
|
83
|
+
neo config get key # Get a value
|
|
84
|
+
neo config list # List all values
|
|
163
85
|
```
|
|
164
86
|
|
|
165
|
-
|
|
87
|
+
### `neo update`
|
|
166
88
|
|
|
167
|
-
-
|
|
168
|
-
- `-u, --set-upstream <branch>` - Set upstream branch
|
|
169
|
-
- `--dry-run` - Show what would be pushed without actually pushing
|
|
170
|
-
- `--tags` - Push tags along with commits
|
|
171
|
-
|
|
172
|
-
**Safety Features:**
|
|
173
|
-
|
|
174
|
-
- ⚠️ Interactive confirmation when pushing to main branch
|
|
175
|
-
- 📝 Helpful guidance for safer alternatives
|
|
176
|
-
- ✅ Graceful cancellation (exits with success code)
|
|
177
|
-
- 🎯 Encourages best practices while allowing flexibility
|
|
178
|
-
|
|
179
|
-
### `update`
|
|
180
|
-
|
|
181
|
-
Update Neo CLI to the latest version from npm.
|
|
89
|
+
Self-update with your detected package manager.
|
|
182
90
|
|
|
183
91
|
```bash
|
|
184
|
-
# Update to
|
|
185
|
-
neo update
|
|
186
|
-
|
|
187
|
-
# Check for updates without installing
|
|
188
|
-
neo update --check-only
|
|
189
|
-
|
|
190
|
-
# Force update/reinstall even if on latest version
|
|
191
|
-
neo update --force
|
|
92
|
+
neo update # Update to latest
|
|
93
|
+
neo update --check-only # Check for updates
|
|
192
94
|
```
|
|
193
95
|
|
|
194
|
-
Options:
|
|
195
|
-
|
|
196
|
-
- `--check-only` - Only check for updates without installing
|
|
197
|
-
- `--force` - Force update even if already on latest version
|
|
198
|
-
|
|
199
|
-
**Features:**
|
|
200
|
-
|
|
201
|
-
- 🔍 Automatic version checking against npm registry
|
|
202
|
-
- 📦 Smart package manager detection (npm, pnpm, yarn)
|
|
203
|
-
- ✨ Interactive confirmation before updating
|
|
204
|
-
- 🎯 Helpful error messages for permission issues
|
|
205
|
-
- ⚡ Progress indicators with real-time status
|
|
206
|
-
|
|
207
96
|
## Global Options
|
|
208
97
|
|
|
209
|
-
|
|
210
|
-
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
-
|
|
214
|
-
-
|
|
98
|
+
```
|
|
99
|
+
-v, --verbose Verbose output
|
|
100
|
+
--no-color Disable colors
|
|
101
|
+
--no-banner Hide banner
|
|
102
|
+
-h, --help Show help
|
|
103
|
+
-V, --version Show version
|
|
104
|
+
```
|
|
215
105
|
|
|
216
106
|
## Development
|
|
217
107
|
|
|
218
|
-
### Setup
|
|
219
|
-
|
|
220
108
|
```bash
|
|
221
109
|
git clone https://github.com/radkode/neo.git
|
|
222
110
|
cd neo
|
|
223
111
|
pnpm install
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
### Build
|
|
227
|
-
|
|
228
|
-
```bash
|
|
229
112
|
pnpm run build
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
### Test
|
|
233
|
-
|
|
234
|
-
```bash
|
|
235
113
|
pnpm test
|
|
236
|
-
pnpm run test:watch
|
|
237
|
-
pnpm run test:coverage
|
|
238
|
-
```
|
|
239
114
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
```bash
|
|
243
|
-
# Link for local testing
|
|
115
|
+
# Local testing
|
|
244
116
|
pnpm run link-local
|
|
245
|
-
|
|
246
|
-
# Test the CLI
|
|
247
117
|
neo --help
|
|
248
|
-
|
|
249
|
-
# Unlink when done
|
|
250
118
|
pnpm run unlink-local
|
|
251
119
|
```
|
|
252
120
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
This project uses [Changesets](https://github.com/changesets/changesets) for version management and publishing.
|
|
256
|
-
|
|
257
|
-
#### Creating a Changeset
|
|
258
|
-
|
|
259
|
-
When you make changes that should be released, create a changeset:
|
|
260
|
-
|
|
261
|
-
```bash
|
|
262
|
-
# Create a new changeset
|
|
263
|
-
pnpm changeset
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
This will:
|
|
267
|
-
|
|
268
|
-
1. Prompt you to select which packages to version (this project has one)
|
|
269
|
-
2. Ask for the type of change (patch, minor, major)
|
|
270
|
-
3. Request a description of the changes
|
|
271
|
-
4. Generate a changeset file in `.changeset/`
|
|
272
|
-
|
|
273
|
-
#### Release Workflow
|
|
274
|
-
|
|
275
|
-
```bash
|
|
276
|
-
# Check current changeset status
|
|
277
|
-
pnpm changeset:status
|
|
278
|
-
|
|
279
|
-
# Consume changesets and update version
|
|
280
|
-
pnpm version-packages
|
|
281
|
-
|
|
282
|
-
# Publish to npm (after tests pass)
|
|
283
|
-
pnpm release
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
#### Change Types
|
|
287
|
-
|
|
288
|
-
- **patch**: Bug fixes, small improvements (0.1.0 → 0.1.1)
|
|
289
|
-
- **minor**: New features, enhancements (0.1.0 → 0.2.0)
|
|
290
|
-
- **major**: Breaking changes (0.1.0 → 1.0.0)
|
|
291
|
-
|
|
292
|
-
#### CI Integration
|
|
293
|
-
|
|
294
|
-
The changeset workflow integrates with:
|
|
295
|
-
|
|
296
|
-
- GitHub releases and changelogs
|
|
297
|
-
- Automated version bumping
|
|
298
|
-
- NPM publishing pipeline
|
|
121
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
|
|
299
122
|
|
|
300
123
|
## License
|
|
301
124
|
|
|
302
|
-
MIT © Jacek Radko
|
|
303
|
-
|
|
304
|
-
---
|
|
305
|
-
|
|
306
|
-
Built with ⚡ by [Radkode](https://github.com/jacekradko)
|
|
125
|
+
[MIT](LICENSE) © Jacek Radko
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAgBtD,wBAAsB,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAkJlD"}
|
package/dist/cli.js
CHANGED
|
@@ -6,8 +6,11 @@ import { registerCommands } from './commands/index.js';
|
|
|
6
6
|
import { configManager } from './utils/config.js';
|
|
7
7
|
import { notifyIfCliUpdateAvailable } from './utils/update-check.js';
|
|
8
8
|
import { Colors } from './utils/ui-types.js';
|
|
9
|
+
import { pluginRegistry, commandRegistry } from './core/plugins/index.js';
|
|
10
|
+
import { success } from './core/errors/index.js';
|
|
9
11
|
import packageJson from '../package.json' with { type: 'json' };
|
|
10
|
-
|
|
12
|
+
let pluginsLoaded = false;
|
|
13
|
+
export async function createCLI() {
|
|
11
14
|
const program = new Command();
|
|
12
15
|
program
|
|
13
16
|
.name('neo')
|
|
@@ -47,36 +50,122 @@ export function createCLI() {
|
|
|
47
50
|
if (!isHelpOrVersion) {
|
|
48
51
|
await notifyIfCliUpdateAvailable();
|
|
49
52
|
}
|
|
53
|
+
if (pluginsLoaded) {
|
|
54
|
+
await pluginRegistry.executeBeforeCommand(commandName, opts);
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
.hook('postAction', async (_thisCommand, actionCommand) => {
|
|
58
|
+
const commandName = actionCommand.name();
|
|
59
|
+
if (pluginsLoaded) {
|
|
60
|
+
await pluginRegistry.executeAfterCommand(commandName, success(undefined));
|
|
61
|
+
}
|
|
50
62
|
});
|
|
51
63
|
registerCommands(program);
|
|
52
|
-
return program;
|
|
53
|
-
}
|
|
54
|
-
if (import.meta.url === `file://${process.argv[1]}` || process.argv[1]?.endsWith('cli.js')) {
|
|
55
|
-
const program = createCLI();
|
|
56
|
-
if (process.argv.length <= 2) {
|
|
57
|
-
program.help();
|
|
58
|
-
}
|
|
59
|
-
program.exitOverride();
|
|
60
64
|
try {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
const config = await configManager.read();
|
|
66
|
+
const pluginsEnabled = config.plugins?.enabled !== false;
|
|
67
|
+
if (pluginsEnabled) {
|
|
68
|
+
const disabledPlugins = config.plugins?.disabled ?? [];
|
|
69
|
+
await pluginRegistry.loadPlugins(disabledPlugins);
|
|
70
|
+
pluginsLoaded = true;
|
|
71
|
+
for (const command of commandRegistry.getAll()) {
|
|
72
|
+
const cmd = new Command(command.name);
|
|
73
|
+
cmd.description(command.description);
|
|
74
|
+
if (command.options) {
|
|
75
|
+
for (const opt of command.options) {
|
|
76
|
+
if (opt.required) {
|
|
77
|
+
cmd.requiredOption(opt.flags, opt.description, opt.defaultValue);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
cmd.option(opt.flags, opt.description, opt.defaultValue);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (command.arguments) {
|
|
85
|
+
for (const arg of command.arguments) {
|
|
86
|
+
if (arg.required) {
|
|
87
|
+
cmd.argument(`<${arg.name}>`, arg.description);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
cmd.argument(`[${arg.name}]`, arg.description);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
cmd.action(async (...args) => {
|
|
95
|
+
const opts = args[args.length - 2];
|
|
96
|
+
const cmdArgs = args.slice(0, -2);
|
|
97
|
+
if (command.validate && !command.validate(opts)) {
|
|
98
|
+
logger.error(`Invalid options for command "${command.name}"`);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
const result = await command.execute(opts, cmdArgs);
|
|
102
|
+
if (!result.success) {
|
|
103
|
+
logger.error(result.error.message);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
program.addCommand(cmd);
|
|
108
|
+
logger.debug(`Registered plugin command: ${command.name}`);
|
|
67
109
|
}
|
|
68
|
-
if (
|
|
69
|
-
|
|
110
|
+
if (pluginRegistry.size > 0) {
|
|
111
|
+
logger.debug(`Loaded ${pluginRegistry.size} plugin(s)`);
|
|
70
112
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
logger.debug(`Plugin loading failed: ${error}`);
|
|
117
|
+
}
|
|
118
|
+
return program;
|
|
119
|
+
}
|
|
120
|
+
async function cleanup(code) {
|
|
121
|
+
if (pluginsLoaded) {
|
|
122
|
+
await pluginRegistry.executeOnExit(code);
|
|
123
|
+
await pluginRegistry.disposeAll();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (import.meta.url === `file://${process.argv[1]}` || process.argv[1]?.endsWith('cli.js')) {
|
|
127
|
+
process.on('beforeExit', async (code) => {
|
|
128
|
+
await cleanup(code);
|
|
129
|
+
});
|
|
130
|
+
process.on('SIGINT', async () => {
|
|
131
|
+
await cleanup(130);
|
|
132
|
+
process.exit(130);
|
|
133
|
+
});
|
|
134
|
+
process.on('SIGTERM', async () => {
|
|
135
|
+
await cleanup(143);
|
|
136
|
+
process.exit(143);
|
|
137
|
+
});
|
|
138
|
+
createCLI()
|
|
139
|
+
.then((program) => {
|
|
140
|
+
if (process.argv.length <= 2) {
|
|
141
|
+
program.help();
|
|
142
|
+
}
|
|
143
|
+
program.exitOverride();
|
|
144
|
+
try {
|
|
145
|
+
program.parse();
|
|
146
|
+
}
|
|
147
|
+
catch (err) {
|
|
148
|
+
if (err && typeof err === 'object' && 'code' in err) {
|
|
149
|
+
if (err.code === 'commander.helpDisplayed' || err.code === 'commander.help') {
|
|
150
|
+
process.exit(0);
|
|
151
|
+
}
|
|
152
|
+
if (err.code === 'commander.version') {
|
|
153
|
+
process.exit(0);
|
|
154
|
+
}
|
|
155
|
+
if (err.code === 'commander.missingArgument' || err.code === 'commander.unknownCommand') {
|
|
156
|
+
console.error(`\n${chalk.hex(Colors.error)('Error:')} ${err instanceof Error ? err.message : String(err)}`);
|
|
157
|
+
console.log(`\nRun ${chalk.hex(Colors.primary)('neo --help')} for usage information.`);
|
|
158
|
+
process.exit(1);
|
|
159
|
+
}
|
|
75
160
|
}
|
|
161
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
162
|
+
logger.error(errorMessage);
|
|
163
|
+
process.exit(1);
|
|
76
164
|
}
|
|
77
|
-
|
|
78
|
-
|
|
165
|
+
})
|
|
166
|
+
.catch((err) => {
|
|
167
|
+
logger.error(`CLI initialization failed: ${err}`);
|
|
79
168
|
process.exit(1);
|
|
80
|
-
}
|
|
169
|
+
});
|
|
81
170
|
}
|
|
82
171
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAA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AAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAC7F,CAAC;oBACF,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,yBAAyB,CAAC,CAAC;oBACvF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;YAED,MAAM,YAAY,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACtE,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;YAC3B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,MAAM,CAAC,KAAK,CAAC,8BAA8B,GAAG,EAAE,CAAC,CAAC;QAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Command } from '@commander-js/extra-typings';
|
|
2
|
-
import type { GitPushOptions } from '../../../types/schemas.js';
|
|
3
2
|
import { type Result } from '../../../core/errors/index.js';
|
|
4
|
-
|
|
3
|
+
interface PushOptions {
|
|
4
|
+
dryRun?: boolean | undefined;
|
|
5
|
+
passthrough: string[];
|
|
6
|
+
remote?: string | undefined;
|
|
7
|
+
branch?: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare function executePush(options: PushOptions): Promise<Result<void>>;
|
|
5
10
|
export declare function createPushCommand(): Command;
|
|
11
|
+
export {};
|
|
6
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/git/push/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/git/push/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAMtD,OAAO,EAAE,KAAK,MAAM,EAA+B,MAAM,wBAAwB,CAAC;AAUlF,UAAU,WAAW;IACnB,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAMD,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAiJ7E;AAiFD,wBAAgB,iBAAiB,IAAI,OAAO,CA8D3C"}
|