@minejs/hmm 0.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 +383 -0
- package/dist/main.cjs +31 -0
- package/dist/main.cjs.map +1 -0
- package/dist/main.d.cts +2 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +31 -0
- package/dist/main.js.map +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Maysara Elshewehy (https://github.com/maysara-elshewehy)
|
|
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,383 @@
|
|
|
1
|
+
<!-- ╔══════════════════════════════ BEG ══════════════════════════════╗ -->
|
|
2
|
+
|
|
3
|
+
<br>
|
|
4
|
+
<div align="center">
|
|
5
|
+
<p>
|
|
6
|
+
<img src="./assets/img/logo.png" alt="logo" style="" height="60" />
|
|
7
|
+
</p>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<div align="center">
|
|
11
|
+
<img src="https://img.shields.io/badge/v-0.0.1-black"/>
|
|
12
|
+
<a href="https://github.com/minejs"> <img src="https://img.shields.io/badge/🔥-@minejs-black"/> </a>
|
|
13
|
+
<br>
|
|
14
|
+
<img src="https://img.shields.io/badge/coverage-100%25-brightgreen" alt="Test Coverage" />
|
|
15
|
+
<img src="https://img.shields.io/github/issues/minejs/hmm?style=flat" alt="Github Repo Issues" />
|
|
16
|
+
<img src="https://img.shields.io/github/stars/minejs/hmm?style=social" alt="GitHub Repo stars" />
|
|
17
|
+
</div>
|
|
18
|
+
<br>
|
|
19
|
+
|
|
20
|
+
<!-- ╚═════════════════════════════════════════════════════════════════╝ -->
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
<!-- ╔══════════════════════════════ DOC ══════════════════════════════╗ -->
|
|
25
|
+
|
|
26
|
+
- ## Quick Start 🔥
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# install via bun or npm
|
|
30
|
+
bun install @minejs/hmm -g
|
|
31
|
+
|
|
32
|
+
# Now use 'hmm' anywhere
|
|
33
|
+
hmm --help
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Create a new space (interactive)
|
|
38
|
+
hmm init
|
|
39
|
+
|
|
40
|
+
# Or with options
|
|
41
|
+
hmm init my-lib -t lib
|
|
42
|
+
|
|
43
|
+
# Navigate and setup
|
|
44
|
+
cd my-lib
|
|
45
|
+
hmm install
|
|
46
|
+
hmm build
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
<br>
|
|
50
|
+
|
|
51
|
+
- ## Commands
|
|
52
|
+
|
|
53
|
+
- ### Space Management
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Create new space (interactive mode)
|
|
57
|
+
hmm init [name]
|
|
58
|
+
|
|
59
|
+
# Create with options
|
|
60
|
+
hmm init my-lib -t lib # Specify type (lib, cli, server, app)
|
|
61
|
+
hmm init my-lib -t lib --desc "My lib" # With description
|
|
62
|
+
|
|
63
|
+
# Show current space information
|
|
64
|
+
hmm info
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
68
|
+
|
|
69
|
+
- ### Package Manager (Bun wrapper)
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Install dependencies
|
|
73
|
+
hmm install # Install all from package.json
|
|
74
|
+
hmm i # Alias for install
|
|
75
|
+
hmm install lodash axios # Install specific packages
|
|
76
|
+
hmm install lodash --dev # Install as dev dependency
|
|
77
|
+
hmm install lodash --global # Install globally
|
|
78
|
+
|
|
79
|
+
# Remove packages
|
|
80
|
+
hmm remove <packages...> # Remove with confirmation
|
|
81
|
+
hmm r <packages...> # Alias for remove
|
|
82
|
+
hmm remove lodash axios # Remove multiple packages
|
|
83
|
+
hmm remove lodash --global # Remove global package
|
|
84
|
+
|
|
85
|
+
# Update packages
|
|
86
|
+
hmm update # Update all (interactive)
|
|
87
|
+
hmm up # Alias for update
|
|
88
|
+
hmm update lodash # Update specific packages
|
|
89
|
+
|
|
90
|
+
# Link packages
|
|
91
|
+
hmm link # Link current package globally
|
|
92
|
+
hmm link <package> # Link global package to project
|
|
93
|
+
hmm unlink # Unlink current package globally
|
|
94
|
+
hmm unlink <package> # Unlink global package from project
|
|
95
|
+
|
|
96
|
+
# List packages
|
|
97
|
+
hmm list # List local packages
|
|
98
|
+
hmm ls # Alias for list
|
|
99
|
+
hmm list --global # List global packages
|
|
100
|
+
|
|
101
|
+
# Run scripts
|
|
102
|
+
hmm run <script> # Run any script from package.json
|
|
103
|
+
hmm run dev # Example: run dev script
|
|
104
|
+
hmm run build -- --watch # Pass additional args to script
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
108
|
+
|
|
109
|
+
- ### Build & Development
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Lint the project
|
|
113
|
+
hmm lint
|
|
114
|
+
|
|
115
|
+
# Build the project
|
|
116
|
+
hmm build
|
|
117
|
+
|
|
118
|
+
# Start the project (builds first, then runs)
|
|
119
|
+
hmm start # Run the built main file
|
|
120
|
+
hmm start --help # Pass args to your app
|
|
121
|
+
hmm start arg1 arg2 --flag # All args passed through
|
|
122
|
+
|
|
123
|
+
# Run tests
|
|
124
|
+
hmm test # Run all tests
|
|
125
|
+
hmm test path/to/test.ts # Run specific test file
|
|
126
|
+
hmm test --coverage # Generate coverage report
|
|
127
|
+
hmm test --coverage --coverage-reporter=lcov # Specify reporter format
|
|
128
|
+
hmm test --watch # Run in watch mode
|
|
129
|
+
hmm test --bail # Exit on first failure
|
|
130
|
+
hmm test --timeout 5000 # Set timeout (ms)
|
|
131
|
+
hmm test --rerun-each 3 # Re-run each test N times
|
|
132
|
+
hmm test --concurrent # Run tests concurrently
|
|
133
|
+
hmm test -t "math" # Filter by test name pattern
|
|
134
|
+
hmm test --coverage --watch # Combine multiple options
|
|
135
|
+
|
|
136
|
+
# Clean build artifacts
|
|
137
|
+
hmm clean
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
141
|
+
|
|
142
|
+
- ### Publishing
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Publish to npm (interactive)
|
|
146
|
+
hmm publish
|
|
147
|
+
|
|
148
|
+
# Publish with options
|
|
149
|
+
hmm publish --tag beta # Publish with tag
|
|
150
|
+
hmm publish --access public # Set access level (public/restricted)
|
|
151
|
+
hmm publish --tag next --access public
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
<br>
|
|
155
|
+
|
|
156
|
+
- ## Space Types and Examples
|
|
157
|
+
|
|
158
|
+
- ### Available Types
|
|
159
|
+
|
|
160
|
+
- **`lib`** - TypeScript library for npm
|
|
161
|
+
|
|
162
|
+
> Zero dependencies template
|
|
163
|
+
>
|
|
164
|
+
> Perfect for publishing reusable packages
|
|
165
|
+
>
|
|
166
|
+
> Example: [hmm-repos/lib](https://github.com/hmm-repos/lib)
|
|
167
|
+
|
|
168
|
+
- **`cli`** - Command-line tool
|
|
169
|
+
|
|
170
|
+
> Includes `@minejs/cli` for CLI development
|
|
171
|
+
>
|
|
172
|
+
> Built-in argument parsing and command handling
|
|
173
|
+
>
|
|
174
|
+
> Example: [hmm-repos/cli](https://github.com/hmm-repos/cli)
|
|
175
|
+
|
|
176
|
+
- **`server`** - Backend server application
|
|
177
|
+
|
|
178
|
+
> Includes `@minejs/server` for server development
|
|
179
|
+
>
|
|
180
|
+
> Ready for API and backend services
|
|
181
|
+
>
|
|
182
|
+
> Example: [hmm-repos/server](https://github.com/hmm-repos/server)
|
|
183
|
+
|
|
184
|
+
- **`app`** - Full-stack web application
|
|
185
|
+
|
|
186
|
+
> Includes `@cruxjs/app`
|
|
187
|
+
>
|
|
188
|
+
> Complete web application stack
|
|
189
|
+
>
|
|
190
|
+
> Example: [hmm-repos/app](https://github.com/hmm-repos/app)
|
|
191
|
+
|
|
192
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
193
|
+
|
|
194
|
+
- ### Templates
|
|
195
|
+
|
|
196
|
+
> Each space type currently supports the **`clean`** template:
|
|
197
|
+
|
|
198
|
+
- Minimal setup with essential tools
|
|
199
|
+
|
|
200
|
+
- TypeScript configured
|
|
201
|
+
|
|
202
|
+
- Build system ready (tsup)
|
|
203
|
+
|
|
204
|
+
- Type-safe and production-ready
|
|
205
|
+
|
|
206
|
+
<br>
|
|
207
|
+
|
|
208
|
+
- ## Configuration
|
|
209
|
+
|
|
210
|
+
- ### `.hmm` File
|
|
211
|
+
|
|
212
|
+
> Each space contains a `.hmm` configuration file that stores project metadata:
|
|
213
|
+
|
|
214
|
+
```json
|
|
215
|
+
{
|
|
216
|
+
"type" : "cli",
|
|
217
|
+
"template" : "clean",
|
|
218
|
+
"pm" : "bun",
|
|
219
|
+
|
|
220
|
+
"repo" : {
|
|
221
|
+
"org" : "minejs",
|
|
222
|
+
"name" : "hmm",
|
|
223
|
+
"version" : "0.0.1",
|
|
224
|
+
"desc" : "Creates and manages the spaces",
|
|
225
|
+
"kw" : ["minejs", "hmm"],
|
|
226
|
+
"license" : "MIT",
|
|
227
|
+
"issues" : "https://github.com/minejs-org/hmm/issues",
|
|
228
|
+
"homepage" : "https://github.com/minejs-org/hmm#readme",
|
|
229
|
+
"git_url" : "git+https://github.com/minejs-org/hmm.git"
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
"author" : {
|
|
233
|
+
"id" : "maysara-elshewehy",
|
|
234
|
+
"name" : "Maysara",
|
|
235
|
+
"email" : "maysara.elshewehy@gmail.com",
|
|
236
|
+
"url" : "https://github.com/maysara-elshewehy"
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
"createdAt" : "2025-11-29T01:22:48.497Z"
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
244
|
+
|
|
245
|
+
- ### Key Features
|
|
246
|
+
|
|
247
|
+
- **Automatic Configuration**: Space automatically manages your `package.json` with proper formatting
|
|
248
|
+
|
|
249
|
+
- **Organization Support**: Create scoped packages with `@org/package-name` format
|
|
250
|
+
|
|
251
|
+
- **GitHub Integration**: Automatic repository URLs and author links
|
|
252
|
+
|
|
253
|
+
- **Consistent Formatting**: JSON files formatted with aligned colons and proper indentation
|
|
254
|
+
|
|
255
|
+
<br>
|
|
256
|
+
|
|
257
|
+
- ## Advanced Usage
|
|
258
|
+
|
|
259
|
+
- ### Creating Scoped Packages
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
# Create a package under an organization
|
|
263
|
+
hmm init @my-org/awesome-lib -t lib
|
|
264
|
+
|
|
265
|
+
# During interactive mode, enter: @my-org/package-name
|
|
266
|
+
hmm init
|
|
267
|
+
# name: @my-org/package-name
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
271
|
+
|
|
272
|
+
- ### Using Current Directory
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
# Create space in current directory (if folder name matches)
|
|
276
|
+
mkdir my-project
|
|
277
|
+
cd my-project
|
|
278
|
+
hmm init my-project -t lib
|
|
279
|
+
# Prompt: "Use current directory 'my-project' as the space root?" → Yes
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
283
|
+
|
|
284
|
+
- ### Test Workflows
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
# Development with watch mode
|
|
288
|
+
hmm test --watch
|
|
289
|
+
|
|
290
|
+
# CI/CD with coverage
|
|
291
|
+
hmm test --coverage --bail
|
|
292
|
+
|
|
293
|
+
# Generate coverage for external tools
|
|
294
|
+
hmm test --coverage --coverage-reporter=lcov
|
|
295
|
+
|
|
296
|
+
# Debug specific tests
|
|
297
|
+
hmm test -t "should handle errors" --bail
|
|
298
|
+
|
|
299
|
+
# Performance testing
|
|
300
|
+
hmm test --rerun-each 100 --concurrent
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
304
|
+
|
|
305
|
+
- ### Link Workflows
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
# Link your library for local development
|
|
309
|
+
cd my-lib
|
|
310
|
+
hmm link # Links globally
|
|
311
|
+
|
|
312
|
+
cd ../my-app
|
|
313
|
+
hmm link my-lib # Links my-lib to this project
|
|
314
|
+
|
|
315
|
+
# After development
|
|
316
|
+
cd ../my-app
|
|
317
|
+
hmm unlink my-lib # Unlink from project
|
|
318
|
+
|
|
319
|
+
cd ../my-lib
|
|
320
|
+
hmm unlink # Unlink globally
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
<div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> <br> </div>
|
|
324
|
+
|
|
325
|
+
- ### Publishing Workflow
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
# 1. Update version in package.json
|
|
329
|
+
# 2. Build and test
|
|
330
|
+
hmm build
|
|
331
|
+
hmm test --coverage
|
|
332
|
+
|
|
333
|
+
# 3. Publish (interactive)
|
|
334
|
+
hmm publish
|
|
335
|
+
# Confirms: package name, version, tag, access level
|
|
336
|
+
|
|
337
|
+
# Or publish directly
|
|
338
|
+
hmm publish --access public
|
|
339
|
+
|
|
340
|
+
# Beta releases
|
|
341
|
+
hmm publish --tag beta
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
<br>
|
|
345
|
+
|
|
346
|
+
- ## Requirements
|
|
347
|
+
|
|
348
|
+
> **Bun** >= 1.3.3
|
|
349
|
+
|
|
350
|
+
> **Git** (for template cloning)
|
|
351
|
+
|
|
352
|
+
> **Node.js** (optional, for npm compatibility)
|
|
353
|
+
|
|
354
|
+
<br>
|
|
355
|
+
|
|
356
|
+
- ## Documentation
|
|
357
|
+
|
|
358
|
+
> Full documentation coming soon at [Github Pages](#)
|
|
359
|
+
|
|
360
|
+
> For now, run `hmm --help` or check individual command help:
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
hmm --help
|
|
364
|
+
hmm init --help
|
|
365
|
+
hmm test --help
|
|
366
|
+
hmm publish --help
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
<!-- ╚═════════════════════════════════════════════════════════════════╝ -->
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
<!-- ╔══════════════════════════════ END ══════════════════════════════╗ -->
|
|
374
|
+
|
|
375
|
+
<br>
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
<div align="center">
|
|
380
|
+
<a href="https://github.com/maysara-elshewehy"><img src="https://img.shields.io/badge/by-Maysara-black"/></a>
|
|
381
|
+
</div>
|
|
382
|
+
|
|
383
|
+
<!-- ╚═════════════════════════════════════════════════════════════════╝ -->
|
package/dist/main.cjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
'use strict';var cli=require('@minejs/cli'),g=require('fs'),T=require('path'),prompts=require('@inquirer/prompts'),child_process=require('child_process');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var g__namespace=/*#__PURE__*/_interopNamespace(g);var T__namespace=/*#__PURE__*/_interopNamespace(T);var B=Object.defineProperty;var N=(u=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(u,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):u)(function(u){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+u+'" is not supported')});var K=(u,e)=>()=>(u&&(e=u(u=0)),e);var W=(u,e)=>{for(var t in e)B(u,t,{get:e[t],enumerable:true});};var q={};W(q,{TemplateRegistry:()=>b});var b,j=K(()=>{b=class{static{this.TEMPLATES={lib:{type:"lib",defaultTemplate:"clean",templates:[{name:"clean",label:"Clean Library",description:"Zero dependencies - just TypeScript and build tools",repo:"lib",requiresSetup:false,ready:true}]},server:{type:"server",defaultTemplate:"clean",templates:[{name:"clean",label:"Clean Server",description:"Comes with @minejs/server library for quick server development",repo:"server",deps:["@minejs/server"],requiresSetup:true,ready:true}]},cli:{type:"cli",defaultTemplate:"clean",templates:[{name:"clean",label:"Clean CLI",description:"Comes with @minejs/cli library for quick CLI development",repo:"cli",deps:["@minejs/cli"],requiresSetup:true,ready:true}]},app:{type:"app",defaultTemplate:"clean",templates:[{name:"clean",label:"Clean Web App",description:"Comes with @cruxjs framework for quick web development",repo:"app",deps:["@cruxjs/app"],requiresSetup:true,ready:true}]}};}static getTemplatesForType(e,t=false){let s=this.TEMPLATES[e]?.templates||[];return t?s:s.filter(r=>r.ready)}static getReadyTemplatesForType(e){return this.getTemplatesForType(e,false)}static getDefaultTemplate(e){let t=this.TEMPLATES[e];if(!t)return "clean";let s=t.templates.find(a=>a.name===t.defaultTemplate&&a.ready);return s?s.name:t.templates.find(a=>a.ready)?.name||t.defaultTemplate}static getTemplate(e,t){let s=this.TEMPLATES[e];return s?s.templates.find(r=>r.name===t):null}static isTemplateReady(e,t){return this.getTemplate(e,t)?.ready||false}static isValidTemplate(e,t){return this.getTemplatesForType(e).some(r=>r.name===t)}static getRepoName(e,t){return this.getTemplate(e,t)?.repo||"ready-lib"}static getSpaceTypes(){return Object.keys(this.TEMPLATES)}};});j();var R=["name","version","description","keywords","license","homepage","bugs","author","repository","type","main","types","bin","files","exports","scripts","engines","peerDependencies","dependencies","devDependencies"],J=["type","template","pm","repo","author","createdAt"];var P=class{static format(e,t={}){let s=t.indent||" ",r=t.alignColons!==false,a=t.sortKeys||false,i=t.tabWidth||4,n=t.keyOrder||[],m=r?this.calculateGlobalMaxKeyLength(e):0,p=this.calculateMaxDepth(e)*(s===" "?i:s.length);return this.formatValue(e,0,s,r,a,m,p,i,n)}static formatFile(e,t={}){let s=g__namespace.readFileSync(e,"utf-8");s.charCodeAt(0)===65279&&(s=s.slice(1));let r=JSON.parse(s),a=this.format(r,t);g__namespace.writeFileSync(e,a+`
|
|
3
|
+
`,"utf-8");}static findJsonFiles(e){let t=[],s=r=>{if(!g__namespace.existsSync(r))return;g__namespace.readdirSync(r,{withFileTypes:true}).forEach(i=>{let n=T__namespace.join(r,i.name);i.name!=="node_modules"&&(i.isDirectory()?s(n):i.isFile()&&i.name.endsWith(".json")&&t.push(n));});};return s(e),t}static formatDirectory(e,t={}){let s={success:[],failed:[]};return this.findJsonFiles(e).forEach(a=>{try{this.formatFile(a,t),s.success.push(a);}catch(i){s.failed.push({file:a,error:i instanceof Error?i.message:String(i)});}}),s}static calculateMaxDepth(e,t=0){if(!e||typeof e!="object")return t;let s=t;return Array.isArray(e)?e.forEach(r=>{let a=this.calculateMaxDepth(r,t+1);a>s&&(s=a);}):Object.values(e).forEach(r=>{let a=this.calculateMaxDepth(r,t+1);a>s&&(s=a);}),s}static sortKeys(e,t,s){if(t.length===0)return s?e.sort():e;let r=[],a=[];return e.forEach(i=>{t.includes(i)?r.push(i):a.push(i);}),r.sort((i,n)=>t.indexOf(i)-t.indexOf(n)),s&&a.sort(),[...r,...a]}static calculateGlobalMaxKeyLength(e){let t=0,s=r=>{if(!r||typeof r!="object")return;if(Array.isArray(r)){r.forEach(i=>s(i));return}Object.keys(r).forEach(i=>{let n=JSON.stringify(i).length;n>t&&(t=n),s(r[i]);});};return s(e),t}static formatValue(e,t,s,r,a,i,n,m,h){if(e===null)return "null";if(e===void 0)return "undefined";let p=typeof e;return p==="string"?JSON.stringify(e):p==="number"||p==="boolean"?String(e):Array.isArray(e)?this.formatArray(e,t,s,r,a,i,n,m,h):p==="object"?this.formatObject(e,t,s,r,a,i,n,m,h):JSON.stringify(e)}static formatArray(e,t,s,r,a,i,n,m,h){if(e.length===0)return "[]";if(e.every(o=>typeof o=="string"||typeof o=="number"||typeof o=="boolean"||o===null)&&e.length<=3)return "["+e.map(o=>this.formatValue(o,t,s,r,a,i,n,m,h)).join(", ")+"]";let y=s.repeat(t+1);return `[
|
|
4
|
+
`+e.map(o=>y+this.formatValue(o,t+1,s,r,a,i,n,m,h)).join(`,
|
|
5
|
+
`)+`
|
|
6
|
+
`+s.repeat(t)+"]"}static formatObject(e,t,s,r,a,i,n,m,h){if(Object.keys(e).length===0)return "{}";let p=Object.keys(e);p=this.sortKeys(p,h,a);let y=s.repeat(t+1),k=(t+1)*(s===" "?m:s.length);return `{
|
|
7
|
+
`+p.map(d=>{let c=JSON.stringify(d),f=this.formatValue(e[d],t+1,s,r,a,i,n,m,h),C=e[d]!==null&&typeof e[d]=="object"&&!Array.isArray(e[d]);if(r&&!C){let _=n-k,U=i-c.length,V=" ".repeat(_+U);return `${y}${c}${V} : ${f}`}else return `${y}${c}: ${f}`}).join(`,
|
|
8
|
+
`)+`
|
|
9
|
+
`+s.repeat(t)+"}"}};if(N.main===module){let u=process.argv[2]||process.cwd();T__namespace.isAbsolute(u)||(u=T__namespace.resolve(process.cwd(),u)),console.log(`\u{1F50D} Scanning for JSON files in: ${u}
|
|
10
|
+
`);let e=P.formatDirectory(u,{alignColons:true,sortKeys:false});e.success.length>0&&(console.log(`\u2705 Successfully formatted ${e.success.length} file(s):`),e.success.forEach(t=>{let s=T__namespace.relative(process.cwd(),t);console.log(` - ${s}`);})),e.failed.length>0&&(console.log(`
|
|
11
|
+
\u274C Failed to format ${e.failed.length} file(s):`),e.failed.forEach(({file:t,error:s})=>{let r=T__namespace.relative(process.cwd(),t);console.log(` - ${r}: ${s}`);})),e.success.length===0&&e.failed.length===0&&console.log("\u{1F4ED} No JSON files found.");}var F=class{constructor(e=process.cwd()){this.basePath=e;}async createSpace(e,t){let s=t||T__namespace.join(this.basePath,e.repo.name);if(g__namespace.existsSync(s))throw new Error(`Space path "${s}" already exists!`);let r=false;try{g__namespace.existsSync(s)||(g__namespace.mkdirSync(s,{recursive:!0}),r=!0),await this.cloneTemplate(e.type,s,e,e.template),this.createSpaceConfig(s,e);}catch(a){if(r&&g__namespace.existsSync(s))try{await this.safeDeleteDirectory(s);}catch{console.warn(`Warning: Could not clean up directory at "${s}"`);}throw a}}loadSpaceConfig(e){let t=e||this.basePath,s=T__namespace.join(t,".space");if(!g__namespace.existsSync(s))return null;let r=g__namespace.readFileSync(s,"utf-8");return JSON.parse(r)}isSpace(e){let t=e||this.basePath;return g__namespace.existsSync(T__namespace.join(t,".space"))}async cloneTemplate(e,t,s,r){let i=`https://github.com/hmm-repos/${b.getRepoName(e,r)}.git`;try{let{execSync:n}=await import('child_process');n(`git clone --quiet --depth 1 ${i} "${t}"`,{stdio:"pipe"});let m=T__namespace.join(t,".git");g__namespace.existsSync(m)&&await this.safeDeleteDirectory(m),await this.updateTemplateFiles(t,s);}catch(n){throw n instanceof Error?n.message&&n.message.includes("Repository not found")?new Error(`Template repository not found: ${i}
|
|
12
|
+
This template is not yet available. Please mark it as ready: false in templateRegistry.ts`):new Error(`Failed to clone template from ${i}: ${n.message||n}`):new Error(`Failed to clone template from ${i}: ${n}`)}}async updateTemplateFiles(e,t){let s=t.repo.org&&t.repo.org.trim()!=="",r=t.author.id&&t.author.id.trim()!=="",a=s?t.repo.org:r?t.author.id:"",i=a?`git+https://github.com/${a}/${t.repo.name}.git`:"",n=a?`https://github.com/${a}/${t.repo.name}#readme`:"",m=a?`https://github.com/${a}/${t.repo.name}/issues`:"",h=s?`@${t.repo.org}/${t.repo.name}`:t.repo.name,p="\u{1F525}-";s?p+=`@${(t.repo.org.replace(/-/g,"--")+"/"+t.repo.name.replace(/-/g,"--")).replace(/ /g,"_")}`:t.author.name?p+=(t.author.name.replace(/-/g,"--")+"/"+t.repo.name.replace(/-/g,"--")).replace(/ /g,"_"):p+=t.repo.name.replace(/-/g,"--").replace(/ /g,"_");let y=r?`https://github.com/${t.author.id}`:t.author.url||"",k=this.getAllFiles(e);for(let o of k)if(!(o.includes("node_modules")||o.includes(".git")))try{let d=g__namespace.readFileSync(o,"utf-8");if(d.includes("{{")&&(d=d.replace(/\{\{tag\}\}/g,h).replace(/\{\{tag-badge\}\}/g,p).replace(/\{\{name\}\}/g,t.repo.name).replace(/\{\{repo\}\}/g,t.repo.name).replace(/\{\{org\}\}/g,t.repo.org||"").replace(/\{\{desc\}\}/g,t.repo.desc||`A ${t.type} space`).replace(/\{\{description\}\}/g,t.repo.desc||`A ${t.type} space`).replace(/\{\{version\}\}/g,t.repo.version).replace(/\{\{license\}\}/g,t.repo.license||"MIT").replace(/\{\{url\}\}/g,i).replace(/\{\{repo_url\}\}/g,i).replace(/\{\{git_url\}\}/g,i).replace(/\{\{homepage\}\}/g,n).replace(/\{\{issues\}\}/g,m).replace(/\{\{type\}\}/g,t.type).replace(/\{\{template\}\}/g,t.template||"clean").replace(/\{\{pm\}\}/g,t.pm).replace(/\{\{author\}\}/g,t.author.name||"").replace(/\{\{author_name\}\}/g,t.author.name||"").replace(/\{\{author_id\}\}/g,t.author.id||"").replace(/\{\{author_email\}\}/g,t.author.email||"").replace(/\{\{author_url\}\}/g,y),g__namespace.writeFileSync(o,d,"utf-8")),o.endsWith("package.json")){let c=JSON.parse(d);if(c.name=h,c.version=t.repo.version,c.description=t.repo.desc||`A ${t.type} space`,c.license=t.repo.license||"MIT",t.repo.kw&&t.repo.kw.length>0?c.keywords=t.repo.kw:c.keywords=[],n&&(c.homepage=n),m&&(c.bugs||(c.bugs={}),c.bugs.url=m),t.author.name&&(t.author.email?c.author={name:t.author.name,email:t.author.email,url:y||void 0}:c.author={name:t.author.name,url:y||void 0}),i&&(c.repository={type:"git",url:i}),t.type==="cli"&&c.bin){let f=Object.keys(c.bin)[0],C=c.bin[f];delete c.bin[f],c.bin[t.repo.name]=C;}c.engines||(c.engines={}),c.engines.bun||(c.engines.bun=">=1.0.0"),d=P.format(c,{keyOrder:R}),g__namespace.writeFileSync(o,d+`
|
|
13
|
+
`,"utf-8");continue}}catch{continue}}getAllFiles(e,t=[]){return g__namespace.readdirSync(e).forEach(r=>{let a=T__namespace.join(e,r);g__namespace.statSync(a).isDirectory()?t=this.getAllFiles(a,t):t.push(a);}),t}createSpaceConfig(e,t){let s=T__namespace.join(e,".space"),r=t.repo.org&&t.repo.org.trim()!=="",a=t.author.id&&t.author.id.trim()!=="",i=r?t.repo.org:a?t.author.id:"",n=i?`git+https://github.com/${i}/${t.repo.name}.git`:"",m=i?`https://github.com/${i}/${t.repo.name}#readme`:"",h=i?`https://github.com/${i}/${t.repo.name}/issues`:"",p=a?`https://github.com/${t.author.id}`:t.author.url||"",y={type:t.type,template:t.template||"clean",pm:t.pm,repo:{org:t.repo.org||"",name:t.repo.name,version:t.repo.version,desc:t.repo.desc||`A ${t.type} space`,kw:t.repo.kw||[],license:t.repo.license||"MIT",issues:h,homepage:m,git_url:n},author:{id:t.author.id||"",name:t.author.name||"",email:t.author.email||"",url:p},createdAt:new Date().toISOString()},k=P.format(y,{keyOrder:J});g__namespace.writeFileSync(s,k+`
|
|
14
|
+
`,"utf-8");}async safeDeleteDirectory(e,t=3){for(let s=0;s<t;s++)try{if(g__namespace.rmSync(e,{recursive:!0,force:!0,maxRetries:3,retryDelay:100}),!g__namespace.existsSync(e))return}catch(r){if(s===t-1)throw r;await new Promise(a=>setTimeout(a,300*(s+1)));}}};var O=class{constructor(){this.DEFAULT_SCRIPTS={build:"tsup",test:"test",lint:"eslint src --ext .ts"};}install(e,t){let s=[];t?.global?(s.push("install","--global"),e&&e.length>0?s.push(...e):(console.error("\u2718 Please specify packages to install globally"),process.exit(1))):(s.push("install"),e&&e.length>0&&s.push(...e),t?.dev&&s.push("--dev")),console.log(`\u2192 Installing${e?` ${e.join(", ")}`:" dependencies"}${t?.global?" globally":""}...`),this.execute(s),t?.global||this.format();}remove(e,t){let s=["remove"];t?.global&&s.push("--global"),s.push(...e),console.log(`\u{1F5D1}\uFE0F Removing ${e.join(", ")}${t?.global?" globally":""}...`),this.execute(s),t?.global||this.format();}link(e){if(e){let t=Array.isArray(e)?e:[e],s=t.join(", ");console.log(`\u{1F517} Linking global package${t.length>1?"s":""} "${s}" to current project...`),this.execute(["link",...t]);}else console.log("\u{1F517} Linking current package globally..."),this.execute(["link"]);}unlink(e){if(e){let t=Array.isArray(e)?e:[e],s=t.join(", ");console.log(`\u{1F513} Unlinking global package${t.length>1?"s":""} "${s}" from current project...`),this.execute(["unlink",...t]);}else console.log("\u{1F513} Unlinking current package globally..."),this.execute(["unlink"]);}run(e,t){let s=this.getScriptCommand(e);if(s||(console.error(`\u2718 Script "${e}" not found in package.json and no default available`),process.exit(1)),this.isUsingDefaultScript(e)){let a=[...s.split(" ")];t&&t.length>0&&a.push(...t),this.execute(a);}else {let r=["run",e];t&&t.length>0&&r.push("--",...t),this.execute(r);}}runSilent(e,t){let s=this.getScriptCommand(e);if(!s)throw new Error(`Script "${e}" not found in package.json and no default available`);if(this.isUsingDefaultScript(e)){let a=[...s.split(" ")];t&&t.length>0&&a.push(...t),this.executeSilent(a);}else {let r=["run",e];t&&t.length>0&&r.push("--",...t),this.executeSilent(r);}}update(e){console.log(`\u{1F504} Updating${e?` ${e.join(", ")}`:" all packages"}...`);let t=["update"];e&&e.length>0&&t.push(...e),this.execute(t),this.format();}list(e){let t=["pm","ls"];e?.global&&t.push("--global"),this.execute(t);}init(){console.log("\u{1F4DD} Initializing package.json..."),this.execute(["init","-y"]),this.format();}publish(e,t){let s=["publish"];e?.tag&&s.push("--tag",e.tag);let r=e?.access||"public";s.push("--access",r),t&&t.stop(""),Bun.spawnSync(["bun",...s],{stdout:"inherit",stderr:"inherit",stdin:"inherit"}).exitCode===0?console.log("\u2714 Published successfully!"):(console.error("\u2718 Publish failed!"),process.exit(1));}execute(e){Bun.spawnSync(["bun",...e],{stdout:"inherit",stderr:"inherit"}).exitCode!==0&&(console.error(`\u2718 Command failed: bun ${e.join(" ")}`),process.exit(1));}executeSilent(e){let t=Bun.spawnSync(["bun",...e],{stdout:"pipe",stderr:"pipe"});if(t.exitCode!==0){let s=new TextDecoder().decode(t.stderr);console.error(`\u2718 Command failed: bun ${e.join(" ")}`),s&&console.error(s),process.exit(1);}}getName(){return "bun"}getEmoji(){return "\u{1F95F}"}format(){try{let e=T__namespace.join(process.cwd(),"package.json");g__namespace.existsSync(e)&&P.formatFile(e,{keyOrder:R});}catch{}}getScriptCommand(e){let t=T__namespace.join(process.cwd(),"package.json");if(g__namespace.existsSync(t))try{let s=JSON.parse(g__namespace.readFileSync(t,"utf-8"));if(s.scripts&&s.scripts[e])return s.scripts[e]}catch{}return e in this.DEFAULT_SCRIPTS?this.DEFAULT_SCRIPTS[e]:null}isUsingDefaultScript(e){let t=T__namespace.join(process.cwd(),"package.json");if(g__namespace.existsSync(t))try{let s=JSON.parse(g__namespace.readFileSync(t,"utf-8"));if(s.scripts&&s.scripts[e])return !1}catch{}return e in this.DEFAULT_SCRIPTS}};j();var l=class{static async promptInit(e){let t=e.name,s=e.type,r=e.template,a=e.desc,i="";if((!t||t==="my-space")&&(t=await prompts.input({message:"name:",default:"my-space",validate:o=>{if(!o||o.trim()==="")return "Space name is required";let d=/^@([a-z0-9-_]+)\/([a-z0-9-_]+)$/,c=/^[a-z0-9-_]+$/;return !d.test(o)&&!c.test(o)?'Name must be either "package-name" or "@org/package-name" (lowercase, numbers, hyphens, underscores only)':true}})),!s){let o=b.getTemplatesForType("lib",false).length>0,d=b.getTemplatesForType("cli",false).length>0,c=b.getTemplatesForType("server",false).length>0,f=b.getTemplatesForType("app",false).length>0;s=await prompts.select({message:"type:",choices:[{name:`\u2192 Library - TypeScript library for npm${o?"":" (Coming Soon)"}`,value:"lib",disabled:o?false:"No templates ready yet"},{name:`\u2192 CLI - Command-line tool${d?"":" (Coming Soon)"}`,value:"cli",disabled:d?false:"No templates ready yet"},{name:`\u2192 Server - Backend server application${c?"":" (Coming Soon)"}`,value:"server",disabled:c?false:"No templates ready yet"},{name:`\u2192 Web App - Full-stack web application${f?"":" (Coming Soon)"}`,value:"web",disabled:f?false:"No templates ready yet"}]});}if(!r){let o=b.getTemplatesForType(s,true);if(o.filter(f=>f.ready).length===0)throw new Error(`No templates are ready yet for "${s}" spaces. This space type is coming soon!`);let c=o.map(f=>{let C=f.ready?"\u2714":"\u{1F6A7}",_=f.ready?"":" (Coming Soon)";return {name:`${C} ${f.label}${_} - ${f.description}`,value:f.name,short:f.label,disabled:f.ready?false:"Not ready yet"}});r=await prompts.select({message:"template:",choices:c,default:b.getDefaultTemplate(s)});}a||(a=await prompts.input({message:"desc:",default:s==="lib"?"A TypeScript library":s==="cli"?"A command-line tool":"A backend server"}));let n="bun";i=await prompts.input({message:"author name:",default:""});let m=await prompts.input({message:"author email:",default:"",validate:o=>o&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o)?"Please enter a valid email address or leave empty":true}),h=await prompts.input({message:"github username:",default:"",validate:o=>o&&!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/i.test(o)?"Please enter a valid GitHub username or leave empty":true}),p=await prompts.input({message:"keywords (comma-separated):",default:""}),y=p?p.split(",").map(o=>o.trim()).filter(o=>o):[],k=await prompts.input({message:"license:",default:"MIT"});return {name:t,type:s,template:r,description:a,packageManager:n,author:i,authorEmail:m,githubId:h,keywords:y,license:k}}static async promptPublish(e){if(!await prompts.confirm({message:`Are you sure you want to publish "${e}" to npm?`,default:false}))return {confirm:false};let s=await prompts.input({message:"Publish with a tag (e.g., beta, next) or leave empty for latest:",default:""}),r=await prompts.select({message:"\u{1F510} Access level:",choices:[{name:"Public - Anyone can install",value:"public"},{name:"Restricted - Requires authentication",value:"restricted"}],default:"public"});return {confirm:true,tag:s||void 0,access:r}}static async promptRemove(e){let t=await prompts.confirm({message:`Remove ${e.join(", ")}?`,default:true});return {packages:e,confirm:t}}static async promptConfirm(e,t=false){let r=(await import('readline')).createInterface({input:process.stdin,output:process.stdout}),a=t?" (Y/n)":" (y/N)";return new Promise(i=>{r.question(`${e}${a} `,n=>{r.close(),n.trim()===""?i(t):i(n.trim().toLowerCase()==="y"||n.trim().toLowerCase()==="yes");});})}static async promptInstall(e){let t=await prompts.input({message:"Enter package names (space-separated):",default:e||"",validate:r=>!r||r.trim()===""?"Please enter at least one package name":true}),s=await prompts.confirm({message:"\u{1F6E0}\uFE0F Install as dev dependency?",default:false});return {packages:t.split(" ").filter(r=>r.trim()),isDev:s}}static async promptUpdate(){return await prompts.select({message:"What do you want to update?",choices:[{name:"All packages",value:"all"},{name:"Specific packages",value:"specific"}]})==="all"?{updateAll:true}:{updateAll:false,packages:(await prompts.input({message:"\u{1F4E6} Enter package names (space-separated):",validate:s=>!s||s.trim()===""?"Please enter at least one package name":true})).split(" ").filter(s=>s.trim())}}static async promptUseCurrentDir(e){return await prompts.confirm({message:`Use current directory "${e}" as the space root?`,default:true})}static async promptDeleteExistingDir(e){return await prompts.confirm({message:`\u26A0\uFE0F Directory already exists at "${e}". Delete and recreate?`,default:false})}static showSuccess(e,t){console.log(""),t.forEach(s=>{console.log(`\u2192 ${s}`);}),console.log("");}static showError(e,t){console.log(`
|
|
15
|
+
\u2718 Error:`,e),t&&t.message&&console.log(` ${t.message}`),console.log("");}static showWarning(e){console.log(`
|
|
16
|
+
\u26A0\uFE0F Warning:`,e),console.log("");}static showInfo(e){console.log(`
|
|
17
|
+
\u2139\uFE0F `,e),console.log("");}};var E=class{constructor(){this.frames=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];this.currentFrame=0;this.interval=null;}start(e){process.stdout.write(`
|
|
18
|
+
${e}`),this.interval=setInterval(()=>{process.stdout.write(`\r${this.frames[this.currentFrame]} ${e}`),this.currentFrame=(this.currentFrame+1)%this.frames.length;},80);}stop(e){this.interval&&(clearInterval(this.interval),this.interval=null),e===""?process.stdout.write("\r\x1B[K\x1B[1A\x1B[K"):process.stdout.write(`\r${e}
|
|
19
|
+
|
|
20
|
+
`);}stopWithError(e){this.interval&&(clearInterval(this.interval),this.interval=null),process.stdout.write(`\r\u2718 ${e}
|
|
21
|
+
|
|
22
|
+
`);}};var M=class u{constructor(e){this.config=e;this.pm=null;this.spaceManager=new F,this.initPackageManager();}static create(e){return new u(e)}run(){cli.cli(this.config.name,this.config.version).description(this.config.desc).command({name:"init",description:"Create a new space (lib or cli)",args:[{name:"name",required:false,default:"my-space",description:"Name of the space (supports @org/name format)"}],options:[{name:"type",flag:"-t",type:"string",required:false,description:"Type of space (lib or cli)"},{name:"description",flag:"--desc",type:"string",required:false,description:"Description of the space"}],action:e=>this.createNewSpaceOnGroundViaCLI(e)}).command({name:"lint",description:"Run linter for the current space",options:[{name:"fix",flag:"--fix",type:"boolean",required:false,description:"Automatically fix linting issues"}],action:e=>this.runLint(e)}).command({name:"info",description:"Show current space information",action:()=>this.showSpaceInfo()}).command({name:"install",aliases:["i"],description:"Install packages",allowDynamicArgs:true,args:[{name:"packages",required:false,description:"Packages to install (space-separated)"}],options:[{name:"dev",flag:"--dev",type:"boolean",required:false,description:"Install as dev dependency"},{name:"global",flag:"--global",type:"boolean",required:false,description:"Install globally"}],action:e=>this.installPackages(e)}).command({name:"remove",aliases:["r"],description:"Remove packages",allowDynamicArgs:true,args:[{name:"packages",required:true,description:"Packages to remove (space-separated)"}],options:[{name:"global",flag:"--global",type:"boolean",required:false,description:"Remove globally"}],action:e=>this.removePackages(e)}).command({name:"update",aliases:["up"],description:"Update packages",allowDynamicArgs:true,args:[{name:"packages",required:false,description:"Packages to update (space-separated, or all if empty)"}],action:e=>this.updatePackages(e)}).command({name:"link",description:"Link package globally (no args) or link global package(s) to project (with package name(s))",allowDynamicArgs:true,args:[{name:"package",required:false,description:"Package name(s) to link from global (optional, supports multiple)"}],action:e=>this.linkPackage(e)}).command({name:"unlink",description:"Unlink package globally (no args) or unlink global package(s) from project (with package name(s))",allowDynamicArgs:true,args:[{name:"package",required:false,description:"Package name(s) to unlink from global (optional, supports multiple)"}],action:e=>this.unlinkPackage(e)}).command({name:"list",aliases:["ls"],description:"List installed packages",options:[{name:"global",flag:"--global",type:"boolean",required:false,description:"List global packages"}],action:e=>this.listPackages(e)}).command({name:"build",description:"Build the current space",action:()=>this.buildSpace()}).command({name:"test",description:"Run tests for the current space",args:[{name:"path",required:false,description:"Specific test file or folder (optional)"}],options:[{name:"coverage",flag:"--coverage",type:"boolean",required:false,description:"Generate code coverage report"},{name:"watch",flag:"--watch",type:"boolean",required:false,description:"Run tests in watch mode"},{name:"bail",flag:"--bail",type:"boolean",required:false,description:"Exit on first test failure"},{name:"timeout",flag:"--timeout",type:"string",required:false,description:"Set test timeout in milliseconds"},{name:"rerun-each",flag:"--rerun-each",type:"string",required:false,description:"Re-run each test N times"},{name:"concurrent",flag:"--concurrent",type:"boolean",required:false,description:"Run tests concurrently"},{name:"coverage-reporter",flag:"--coverage-reporter",type:"string",required:false,description:"Coverage reporter format (text, lcov, etc.)"},{name:"test-name-pattern",flag:"-t",type:"string",required:false,description:"Filter tests by name pattern"}],action:e=>this.runTests(e)}).command({name:"run",description:"Run any script from package.json",args:[{name:"script",required:true,description:"Script name from package.json"}],allowDynamicArgs:true,allowDynamicOptions:true,action:e=>this.runScript(e)}).command({name:"clean",description:"Clean build artifacts",action:()=>this.clean()}).command({name:"start",description:"Start the main file",allowDynamicArgs:true,allowDynamicOptions:true,action:e=>this.startMain(e)}).command({name:"publish",description:"Publish space to npm registry",options:[{name:"tag",flag:"--tag",type:"string",required:false,description:"Publish with tag (e.g., beta, next)"},{name:"access",flag:"--access",type:"string",required:false,description:"Access level (public or restricted)"}],action:e=>this.publish(e)}).build().run();}static defaultConfig(){return {name:"Space",version:"0.0.1",desc:"Build flexible spaces for any platform"}}initPackageManager(){this.spaceManager.isSpace()&&(this.pm=new O);}ensureSpace(){return this.spaceManager.isSpace()?true:(console.error('\u2718 Not a space directory. Run "space init <name> -t lib|cli" first.'),false)}parsePackageName(e){let t=/^@([a-z0-9-_]+)\/([a-z0-9-_]+)$/i,s=e.match(t);return s?{org:s[1],name:s[2]}:{org:"",name:e}}async deleteDirectoryWithRetry(e,t=3){for(let s=0;s<t;s++)try{if(g__namespace.rmSync(e,{recursive:!0,force:!0,maxRetries:3,retryDelay:100}),!g__namespace.existsSync(e))return}catch(r){if(s===t-1)throw r;await new Promise(a=>setTimeout(a,500*(s+1)));}throw new Error("Failed to delete directory after multiple attempts")}async createNewSpaceOnGroundViaCLI(e){try{let t=await l.promptInit({type:e.options.type,template:e.options.template,org:"",name:e.args.name,desc:e.options.desc}),{org:s,name:r}=this.parsePackageName(t.name);["lib","cli","server","web"].includes(t.type)||(l.showError("Invalid space type. Must be lib, cli, server or web."),process.exit(1));let{TemplateRegistry:a}=await Promise.resolve().then(()=>(j(),q));a.isValidTemplate(t.type,t.template)||(l.showError("Invalid template for this space type."),process.exit(1)),a.isTemplateReady(t.type,t.template)||(l.showError("This template is not ready yet. Please choose another template."),process.exit(1));let i,n=T__namespace.basename(process.cwd());if(!r||r.trim()===""?await l.promptUseCurrentDir(n)?i=process.cwd():(l.showError("Space name is required when not using current directory"),process.exit(1)):n===r&&await l.promptUseCurrentDir(r)&&(i=process.cwd()),i||(i=T__namespace.join(process.cwd(),r)),g__namespace.existsSync(i)){g__namespace.statSync(i).isDirectory()||(l.showError(`Path "${i}" exists but is not a directory`),process.exit(1)),await l.promptDeleteExistingDir(i)||(l.showInfo("Space creation cancelled"),process.exit(0));try{await this.deleteDirectoryWithRetry(i);}catch(p){p instanceof Error?p.message&&(p.message.includes("EBUSY")||p.message.includes("EPERM")||p.message.includes("resource busy"))?l.showError(`Cannot delete directory - it's being used by another program.
|
|
23
|
+
|
|
24
|
+
Please try:
|
|
25
|
+
1. Close any terminals/editors with "${i}" open
|
|
26
|
+
2. Navigate out of the directory in all terminals
|
|
27
|
+
3. Run PowerShell/Terminal as Administrator
|
|
28
|
+
4. Wait a few seconds and try again`):l.showError("Failed to delete existing directory.",p):l.showError("Failed to delete existing directory.",new Error("Unknown error")),process.exit(1);}}await this.spaceManager.createSpace({type:t.type,template:t.template,pm:"bun",repo:{org:s,name:r,version:"0.0.1",desc:t.description,kw:t.keywords.length>0?t.keywords:[],license:t.license||"MIT"},author:{id:t.githubId,name:t.author,email:t.authorEmail,url:""},createdAt:new Date().toISOString()},i),l.showSuccess(r,[i===process.cwd()?"space install":`cd ${r}`,"space install","space build"]);}catch(t){l.showError("Failed to create space",t),process.exit(1);}}showSpaceInfo(){if(!this.ensureSpace())return;let e=this.spaceManager.loadSpaceConfig();if(!e){console.error("\u2718 Could not load space configuration.");return}console.log("");let s=e.repo?.org&&e.repo.org.trim()!==""?`${e.repo.org}/${e.repo.name}`:e.repo.name;if(console.log(`Name: ${s}`),console.log(`Type: ${e.type}`),console.log(`Version: ${e.repo.version}`),e.repo.desc&&e.repo.desc!=="{{desc}}"&&e.repo.desc!=="{{description}}"&&console.log(`Description: ${e.repo.desc}`),e.repo.kw){let r=[];if(Array.isArray(e.repo.kw))r=e.repo.kw.filter(a=>a&&typeof a=="string"&&a.trim()!==""&&a!=="{{kw}}"&&a!=="{{keywords}}");else if(typeof e.repo.kw=="string"){let a=e.repo.kw;a!=="{{kw}}"&&a!=="{{keywords}}"&&a.trim()!==""&&(r=a.split(",").map(i=>i.trim()).filter(i=>i!==""));}r.length>0&&console.log(`Keywords: ${r.join(", ")}`);}e.repo.license&&e.repo.license!=="{{license}}"&&console.log(`License: ${e.repo.license}`),console.log("PackageManager: bun"),e.author?.name&&e.author.name!=="{{author}}"&&e.author.name!=="{{author_name}}"&&console.log(`Author: ${e.author.name}`),console.log(`Created: ${new Date(e.createdAt).toLocaleDateString()}`),console.log("");}runLint(e){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let t=[];e?.options?.fix&&t.push("--fix"),t.length>0?this.pm.run("lint",t):this.pm.run("lint");}async installPackages(e){if(this.ensureSpace()){this.pm||this.initPackageManager();try{let t=[];if(e.args?.packages){let r=e.args.packages.split(" ").filter(a=>a.trim());t.push(...r);}e?.dynamicArgs&&Array.isArray(e.dynamicArgs)&&t.push(...e.dynamicArgs);let s=e.options?.dev||!1;if(t.length===0&&!await l.promptConfirm("No packages specified. Install all dependencies from package.json?",!0)){let a=await l.promptInstall();t=a.packages,s=a.isDev;}this.pm.install(t.length>0?t:void 0,{dev:s,global:e.options?.global});}catch(t){l.showError("\u2718 Installation failed",t),process.exit(1);}}}async removePackages(e){if(this.ensureSpace()){this.pm||this.initPackageManager();try{let t=[];if(e.args?.packages){let r=e.args.packages.split(" ").filter(a=>a.trim());t.push(...r);}if(e?.dynamicArgs&&Array.isArray(e.dynamicArgs)&&t.push(...e.dynamicArgs),t.length===0){l.showError("Please specify packages to remove");return}if(!(await l.promptRemove(t)).confirm){l.showInfo("Removal cancelled");return}this.pm.remove(t,{global:e.options?.global});}catch(t){l.showError("\u2718 Removal failed",t),process.exit(1);}}}async updatePackages(e){if(this.ensureSpace()){this.pm||this.initPackageManager();try{let t;if(e.args?.packages){let s=e.args.packages.split(" ").filter(r=>r.trim());t=s.length>0?s:void 0;}if(e?.dynamicArgs&&Array.isArray(e.dynamicArgs)&&(t||(t=[]),t.push(...e.dynamicArgs)),!t||t.length===0){let s=await l.promptUpdate();t=s.updateAll?void 0:s.packages;}this.pm.update(t);}catch(t){l.showError("\u2718 Update failed",t),process.exit(1);}}}linkPackage(e){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let t=[];e?.args?.package&&(typeof e.args.package=="string"?t.push(e.args.package):Array.isArray(e.args.package)&&t.push(...e.args.package)),e?.dynamicArgs&&Array.isArray(e.dynamicArgs)&&t.push(...e.dynamicArgs),this.pm.link(t.length>0?t:void 0);}unlinkPackage(e){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let t=[];e?.args?.package&&(typeof e.args.package=="string"?t.push(e.args.package):Array.isArray(e.args.package)&&t.push(...e.args.package)),e?.dynamicArgs&&Array.isArray(e.dynamicArgs)&&t.push(...e.dynamicArgs),this.pm.unlink(t.length>0?t:void 0);}listPackages(e){this.ensureSpace()&&(this.pm||this.initPackageManager(),this.pm.list({global:e.options?.global??false}));}runScript(e){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let t=e?.args?.script;if(!t){l.showError("Please specify a script name");return}try{let s=[];if(e?.dynamicArgs&&Array.isArray(e.dynamicArgs)&&s.push(...e.dynamicArgs),e?.dynamicOptions&&typeof e.dynamicOptions=="object")for(let[r,a]of Object.entries(e.dynamicOptions))s.push(`--${r}`),a!==!0&&a!==!1&&s.push(String(a));this.pm.run(t,s.length>0?s:void 0);}catch(s){l.showError(`Failed to run script "${t}"`,s),process.exit(1);}}buildSpace(e){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let t=new E;t.start("Building space...");try{this.pm.runSilent("build"),t.stop(e?"":"\u2714 Build succeeded");}catch{t.stopWithError("\u2718 Build failed"),process.exit(1);}}buildSpaceBool(e){if(!this.ensureSpace())return false;this.pm||this.initPackageManager();let t=new E;t.start("Building space...");try{return this.pm.runSilent("build"),t.stop(e?"":"\u2714 Build succeeded"),!0}catch{return t.stopWithError("\u2718 Build failed!"),false}}runTests(e){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let t=[],s=e?.args?.path;s&&t.push(s),e?.options?.coverage&&t.push("--coverage"),e?.options?.["coverage-reporter"]&&t.push("--coverage-reporter",e.options["coverage-reporter"]),e?.options?.watch&&t.push("--watch"),e?.options?.bail&&t.push("--bail"),e?.options?.timeout&&t.push("--timeout",e.options.timeout),e?.options?.["rerun-each"]&&t.push("--rerun-each",e.options["rerun-each"]),e?.options?.concurrent&&t.push("--concurrent"),e?.options?.["test-name-pattern"]&&t.push("-t",e.options["test-name-pattern"]),t.length>0?this.pm.run("test",t):this.pm.run("test");}clean(){if(!this.ensureSpace())return;this.pm||this.initPackageManager();let e=new E;e.start("Cleaning build artifacts...");try{this.pm.run("clean"),e.stop("\u2714 Clean complete!");}catch{e.stopWithError("\u2718 Clean failed!"),process.exit(1);}}startMain(e){if(this.buildSpaceBool(true))try{let t=this.findBuiltMainFile();t||(l.showError(`Could not find built entry point.
|
|
29
|
+
Expected to find dist/main.js or dist/index.js after build.`),process.exit(1));let s=[];if(e?.dynamicArgs&&Array.isArray(e.dynamicArgs)&&s.push(...e.dynamicArgs),e?.dynamicOptions&&typeof e.dynamicOptions=="object")for(let[a,i]of Object.entries(e.dynamicOptions))s.push(`--${a}`),i!==!0&&i!==!1&&s.push(String(i));s.length>0;let r=child_process.spawnSync("bun",[t,...s],{stdio:"inherit",cwd:process.cwd()});r.error&&(l.showError("Failed to start process",r.error),process.exit(1)),r.status!==0&&r.status!==null&&(console.error(`
|
|
30
|
+
\u2718 Process exited with error`),process.exit(r.status));}catch(t){l.showError("Failed to start",t),process.exit(1);}}findBuiltMainFile(){let e=["dist/main.js","dist/index.js","dist/app.js"];for(let t of e)if(g__namespace.existsSync(T__namespace.join(process.cwd(),t)))return t;try{let t=T__namespace.join(process.cwd(),"package.json");if(g__namespace.existsSync(t)){let s=JSON.parse(g__namespace.readFileSync(t,"utf-8"));if(s.main&&g__namespace.existsSync(s.main))return s.main}}catch{}return null}async publish(e){if(this.buildSpaceBool(true))try{let t=this.spaceManager.loadSpaceConfig();if(!t){l.showError("Could not load space configuration");return}let s=t.repo.org?`@${t.repo.org}/${t.repo.name}`:t.repo.name,r=e.options?.tag||void 0,a=e.options?.access||void 0;if(!r&&!a){let n=await l.promptPublish(s);if(!n.confirm){l.showInfo("Publish cancelled");return}r=n.tag,a=n.access;}let i=new E;i.start("Publishing package..."),this.pm.publish({tag:r,access:a},i);}catch(t){l.showError("Publish failed",t),process.exit(1);}}};var Y=M.create({name:"Space",version:"0.0.2",desc:"Build flexible spaces for any platform"});Y.run();//# sourceMappingURL=main.cjs.map
|
|
31
|
+
//# sourceMappingURL=main.cjs.map
|