@mono-labs/cli 0.0.51 → 0.0.53

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.
Files changed (3) hide show
  1. package/README.md +211 -50
  2. package/lib/index.js +8 -8
  3. package/package.json +9 -1
package/README.md CHANGED
@@ -1,86 +1,247 @@
1
- # Mono CLI Tool
1
+ <div align="center">
2
2
 
3
- A fast and efficient CLI tool for building and deploying projects.
3
+ # mono-labs CLI
4
4
 
5
- ## Installation
5
+ Declarative, token-aware task runner for JavaScript/TypeScript monorepos.
6
+ Configure commands with simple JSON – no custom scripting required.
7
+
8
+ </div>
9
+
10
+ ## Why This Exists
11
+
12
+ You often need a repeatable set of steps to bootstrap or run your full stack
13
+ (web, mobile, backend, infra). Traditional npm scripts become tangled. This CLI
14
+ lets you:
15
+
16
+ - Describe commands in `.mono/*.json` files
17
+ - Emit dynamic values from scripts (`{out:token value}`)
18
+ - Inject those values into later commands & environment variables
19
+ - Run multiple background services + one attached foreground process
20
+
21
+ No publishing needed: you can link and iterate locally.
22
+
23
+ ---
24
+
25
+ ## Quick Start (Beginner Friendly)
26
+
27
+ 1. Install dependencies:
6
28
 
7
- ### Local Development
8
29
  ```bash
9
- # Install dependencies
10
30
  yarn install
31
+ ```
32
+
33
+ 2. Create a `.mono` directory in your project root.
34
+ 3. Add a file `.mono/hello.json`:
11
35
 
12
- # Test the CLI locally
13
- yarn start --help
36
+ ```json
37
+ { "actions": ["echo Hello World"] }
14
38
  ```
15
39
 
16
- ### Global Installation
40
+ 4. Run the command:
41
+
17
42
  ```bash
18
- # Install globally using yarn
19
- yarn global add .
43
+ yarn mono hello
44
+ ```
45
+
46
+ You should see `Hello World`.
47
+
48
+ ### Adding a Command with an Argument
49
+
50
+ ```json
51
+ // .mono/greet.json
52
+ {
53
+ "actions": ["echo Hi ${arg}"],
54
+ "argument": { "description": "Name to greet", "default": "friend" }
55
+ }
56
+ ```
57
+
58
+ ```bash
59
+ yarn mono greet # Hi friend
60
+ yarn mono greet Alice # Hi Alice
61
+ ```
62
+
63
+ ### Adding an Option
64
+
65
+ ```json
66
+ // .mono/build.json
67
+ {
68
+ "actions": ["echo Building for ${platform} debug=${debug}"],
69
+ "options": {
70
+ "platform": { "type": "string", "default": "ios" },
71
+ "debug": { "description": "Enable debug mode" }
72
+ }
73
+ }
74
+ ```
75
+
76
+ ```bash
77
+ yarn mono build --platform android --debug
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Core Concepts
83
+
84
+ | Concept | Summary |
85
+ | -------------- | --------------------------------------------------------------------------------------------- |
86
+ | `.mono/*.json` | Each file (except `config.json`) becomes a command. `dev.json` -> `yarn mono dev`. |
87
+ | `preactions` | Sequential setup commands whose output can define tokens. |
88
+ | `actions` | Main workload commands. All but last run detached; last is attached (interactive). |
89
+ | Tokens | Printed from preactions as `{out:key value}` and later substituted as `${key}`. |
90
+ | Environments | `environments.dev` / `environments.stage` provide token-aware env vars. Use `--stage` switch. |
91
+ | Data Layer | Merges defaults, user flags, argument, and emitted tokens. |
92
+
93
+ Full schemas & rules: see `docs/configuration.md`.
94
+
95
+ ---
96
+
97
+ ## Documentation Index
98
+
99
+ | Topic | File |
100
+ | ------------------------ | ------------------------- |
101
+ | Architecture / internals | `docs/architecture.md` |
102
+ | Configuration schema | `docs/configuration.md` |
103
+ | Practical examples | `docs/examples.md` |
104
+ | Troubleshooting | `docs/troubleshooting.md` |
20
105
 
21
- # Or link for development
106
+ ---
107
+
108
+ ## How It Works (Short Version)
109
+
110
+ 1. CLI scans `.mono/` at startup.
111
+ 2. Builds Commander commands for each JSON file.
112
+ 3. When invoked: merges defaults + flags + argument into data layer.
113
+ 4. Runs `preactions` (foreground) capturing `{out:key value}` tokens.
114
+ 5. Spawns each action (background except last). Performs `${token}`
115
+ substitution.
116
+ 6. Cleans background processes on exit or Ctrl+C.
117
+
118
+ Details: `docs/architecture.md`.
119
+
120
+ ---
121
+
122
+ ## Local Development / Linking
123
+
124
+ From this repo root:
125
+
126
+ ```bash
22
127
  yarn link
23
128
  ```
24
129
 
25
- ## Usage
130
+ In a target project:
26
131
 
27
- ### Build Command
28
132
  ```bash
29
- # Basic build
30
- haste build
133
+ yarn link "@mono-labs/cli"
134
+ ```
31
135
 
32
- # Build with specific environment
33
- haste build --env production
136
+ Then use:
34
137
 
35
- # Build with watch mode
36
- haste build --watch
138
+ ```bash
139
+ yarn mono <command>
37
140
  ```
38
141
 
39
- ### Deploy Command
142
+ To unlink later:
143
+
40
144
  ```bash
41
- # Basic deploy
42
- haste deploy
145
+ yarn unlink "@mono-labs/cli"
146
+ ```
43
147
 
44
- # Deploy to specific environment
45
- haste deploy --env staging
148
+ Alternative (direct file install):
46
149
 
47
- # Force deployment
48
- haste deploy --force
150
+ ```bash
151
+ yarn add file:/absolute/path/to/mono-labs-cli
49
152
  ```
50
153
 
51
- ## Available Commands
154
+ ---
52
155
 
53
- - `haste build` - Build the project
54
- - `haste deploy` - Deploy the project
55
- - `haste --help` - Show help information
56
- - `haste --version` - Show version information
156
+ ## Emitting Dynamic Values
57
157
 
58
- ## Development
158
+ Inside a `preactions` script output lines like:
59
159
 
60
- ### Project Structure
61
160
  ```
62
- haste/
63
- ├── bin/
64
- │ └── haste.js # Main CLI entry point
65
- ├── lib/
66
- │ └── commands/
67
- │ ├── build.js # Build command implementation
68
- │ └── deploy.js # Deploy command implementation
69
- ├── package.json
70
- └── README.md
161
+ {out:ngrok_api https://1234.ngrok.dev}
162
+ {out:region us-east-1}
71
163
  ```
72
164
 
73
- ### Adding New Commands
165
+ Then reference in actions or environments as `${ngrok_api}` or `${region}`.
166
+
167
+ ---
168
+
169
+ ## Example Advanced Command
170
+
171
+ ```json
172
+ // .mono/dev.json
173
+ {
174
+ "preactions": ["docker compose up -d", "node scripts/ngrok_setup"],
175
+ "actions": [
176
+ "yarn backend dynamodb-admin -p 8082 --dynamo-endpoint=http://localhost:8000",
177
+ "yarn mono backend server"
178
+ ],
179
+ "argument": { "type": "string", "default": "dev" },
180
+ "options": {
181
+ "stage": { "description": "Use stage env" },
182
+ "profile": { "type": "string", "description": "Profile name" }
183
+ },
184
+ "environments": {
185
+ "dev": { "API_URL": "${ngrok_api}", "MODE": "dev" },
186
+ "stage": { "API_URL": "${ngrok_api}", "MODE": "stage" }
187
+ }
188
+ }
189
+ ```
74
190
 
75
- 1. Create a new file in `lib/commands/`
76
- 2. Export an `execute` function
77
- 3. Add the command to `bin/haste.js`
191
+ Run:
78
192
 
79
- ### Dependencies
193
+ ```bash
194
+ yarn mono dev --profile alpha
195
+ ```
80
196
 
81
- - **commander** - Command-line argument parsing
82
- - **chalk** - Terminal string styling
197
+ ---
198
+
199
+ ## Design Decisions
200
+
201
+ - JSON over JS: simpler, toolable, safer for newcomers.
202
+ - Single positional argument: keeps mental model small.
203
+ - Token system: decouples script output from later steps.
204
+ - Background/foreground split: stable dev server orchestration.
205
+
206
+ ---
207
+
208
+ ## Extending
209
+
210
+ | Need | Approach |
211
+ | ---------------------- | --------------------------------------------- |
212
+ | Multiple arguments | Extend `cliFactory.js` to parse more. |
213
+ | JSON schema validation | Add Ajv in `boot()` loader. |
214
+ | Parallel preactions | Modify `runHasteCommand.js` to `Promise.all`. |
215
+ | Different token syntax | Adjust regex in `runForeground.js`. |
216
+
217
+ ---
218
+
219
+ ## Contributing
220
+
221
+ 1. Fork & clone
222
+ 2. Create a feature branch
223
+ 3. Add/adjust tests (future roadmap)
224
+ 4. Submit PR with clear description
225
+
226
+ ---
227
+
228
+ ## FAQ (Fast Answers)
229
+
230
+ | Question | Answer |
231
+ | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
232
+ | How do I list commands? | Look at filenames in `.mono/` or run `yarn mono --help`. |
233
+ | How do I pass env vars manually? | `MY_VAR=1 yarn mono dev` (POSIX) or `set MY_VAR=1 && yarn mono dev` (CMD) or `$env:MY_VAR=1; yarn mono dev` (PowerShell). |
234
+ | Does it support Windows? | Yes; process cleanup uses `taskkill`. |
235
+ | What if a token is missing? | It stays literal (`${token}`); no crash. |
236
+
237
+ ---
83
238
 
84
239
  ## License
85
240
 
86
- MIT
241
+ MIT © Contributors
242
+
243
+ ---
244
+
245
+ ## Next Steps
246
+
247
+ Jump to: `docs/examples.md` for hands-on learning.
package/lib/index.js CHANGED
@@ -43,13 +43,13 @@ program.on('command:*', (operands) => {
43
43
  stdio: 'inherit',
44
44
  shell: process.platform === 'win32',
45
45
  });
46
- // const child = spawn('yarn', args, {
47
- // stdio: 'inherit',
48
- // shell: process.platform === 'win32',
49
- // });
50
- // child.on('exit', (code) => {
51
- // console.log('Child process exited with code:', code);
52
- // process.exitCode = code ?? 1;
53
- // });
46
+ const child = spawn('yarn', args, {
47
+ stdio: 'inherit',
48
+ shell: process.platform === 'win32',
49
+ });
50
+ child.on('exit', (code) => {
51
+ console.log('Child process exited with code:', code);
52
+ process.exitCode = code ?? 1;
53
+ });
54
54
  });
55
55
  program.parse();
package/package.json CHANGED
@@ -1,9 +1,17 @@
1
1
  {
2
2
  "name": "@mono-labs/cli",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "description": "A CLI tool for building and deploying projects",
5
5
  "type": "module",
6
6
  "main": "index.js",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/codymurphyjones/mono-labs-cli.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/codymurphyjones/mono-labs-cli/issues"
13
+ },
14
+ "homepage": "https://github.com/codymurphyjones/mono-labs-cli#readme",
7
15
  "bin": {
8
16
  "mono": "./bin/mono.js"
9
17
  },