@mexty/cli 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.
Files changed (49) hide show
  1. package/README.md +427 -0
  2. package/dist/commands/create.d.ts +7 -0
  3. package/dist/commands/create.d.ts.map +1 -0
  4. package/dist/commands/create.js +80 -0
  5. package/dist/commands/create.js.map +1 -0
  6. package/dist/commands/delete.d.ts +2 -0
  7. package/dist/commands/delete.d.ts.map +1 -0
  8. package/dist/commands/delete.js +54 -0
  9. package/dist/commands/delete.js.map +1 -0
  10. package/dist/commands/fork.d.ts +2 -0
  11. package/dist/commands/fork.d.ts.map +1 -0
  12. package/dist/commands/fork.js +52 -0
  13. package/dist/commands/fork.js.map +1 -0
  14. package/dist/commands/login.d.ts +2 -0
  15. package/dist/commands/login.d.ts.map +1 -0
  16. package/dist/commands/login.js +12 -0
  17. package/dist/commands/login.js.map +1 -0
  18. package/dist/commands/publish.d.ts +2 -0
  19. package/dist/commands/publish.d.ts.map +1 -0
  20. package/dist/commands/publish.js +139 -0
  21. package/dist/commands/publish.js.map +1 -0
  22. package/dist/commands/sync.d.ts +2 -0
  23. package/dist/commands/sync.d.ts.map +1 -0
  24. package/dist/commands/sync.js +140 -0
  25. package/dist/commands/sync.js.map +1 -0
  26. package/dist/index.d.ts +3 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +60 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/utils/api.d.ts +55 -0
  31. package/dist/utils/api.d.ts.map +1 -0
  32. package/dist/utils/api.js +68 -0
  33. package/dist/utils/api.js.map +1 -0
  34. package/dist/utils/git.d.ts +41 -0
  35. package/dist/utils/git.d.ts.map +1 -0
  36. package/dist/utils/git.js +171 -0
  37. package/dist/utils/git.js.map +1 -0
  38. package/package.json +39 -0
  39. package/src/commands/create.ts +97 -0
  40. package/src/commands/delete.ts +63 -0
  41. package/src/commands/fork.ts +58 -0
  42. package/src/commands/login.ts +104 -0
  43. package/src/commands/publish.ts +159 -0
  44. package/src/commands/sync.ts +284 -0
  45. package/src/index.ts +84 -0
  46. package/src/utils/api.ts +240 -0
  47. package/src/utils/auth.ts +21 -0
  48. package/src/utils/git.ts +194 -0
  49. package/tsconfig.json +24 -0
package/README.md ADDED
@@ -0,0 +1,427 @@
1
+ # MEXT CLI
2
+
3
+ Command-line interface for managing MEXT blocks and repositories with automatic props schema generation and type-safe component development.
4
+
5
+ ## Installation
6
+
7
+ ### From Source (Development)
8
+
9
+ ```bash
10
+ # Navigate to the CLI directory
11
+ cd cli
12
+
13
+ # Install dependencies
14
+ npm install
15
+
16
+ # Build the CLI
17
+ npm run build
18
+
19
+ # Link for global usage (optional)
20
+ npm link
21
+ ```
22
+
23
+ ### Global Installation (Future)
24
+
25
+ ```bash
26
+ npm install -g mexty
27
+ ```
28
+
29
+ ## Prerequisites
30
+
31
+ - Node.js 16+ installed
32
+ - Git installed and configured
33
+ - MEXT server running (default: http://localhost:3001)
34
+ - GitHub access for repository operations
35
+
36
+ ## Commands
37
+
38
+ ### `mexty login`
39
+
40
+ Authenticate with MEXT (currently a placeholder).
41
+
42
+ ```bash
43
+ mexty login
44
+ ```
45
+
46
+ ### `mexty create <name>`
47
+
48
+ Create a new block and clone its repository locally.
49
+
50
+ ```bash
51
+ # Basic usage
52
+ mexty create "My Block"
53
+
54
+ # With options
55
+ mexty create "My Block" --description "My custom block description" --type custom
56
+ ```
57
+
58
+ **Options:**
59
+ - `-d, --description <description>`: Block description
60
+ - `-t, --type <type>`: Block type (default: custom)
61
+
62
+ **What it does:**
63
+ 1. Creates a new block on the MEXT server
64
+ 2. Automatically creates a GitHub repository (if configured)
65
+ 3. Clones the repository to your local machine with enhanced template
66
+ 4. Sets up proper TypeScript props interface structure
67
+ 5. Provides next steps for development
68
+
69
+ ### `mexty fork <blockId>`
70
+
71
+ Fork an existing block and pull its content locally.
72
+
73
+ ```bash
74
+ mexty fork 507f1f77bcf86cd799439011
75
+ ```
76
+
77
+ **What it does:**
78
+ 1. Creates a fork of the specified block on the MEXT server
79
+ 2. Creates a new GitHub repository for the fork
80
+ 3. Clones the forked repository to your local machine
81
+ 4. Preserves the original props schema for type safety
82
+
83
+ ### `mexty delete <blockId>`
84
+
85
+ Delete a block from the MEXT server.
86
+
87
+ ```bash
88
+ mexty delete 507f1f77bcf86cd799439011
89
+ ```
90
+
91
+ **What it does:**
92
+ 1. Shows block information for confirmation
93
+ 2. Prompts for confirmation
94
+ 3. Deletes the block from the server
95
+ 4. Note: GitHub repository needs to be deleted manually if desired
96
+
97
+ ### `mexty sync`
98
+
99
+ Sync the block registry, props schemas, and update named exports with TypeScript definitions.
100
+
101
+ ```bash
102
+ mexty sync
103
+ ```
104
+
105
+ **What it does:**
106
+ 1. Fetches the latest registry from the MEXT server
107
+ 2. Downloads all available props schemas for type generation
108
+ 3. Updates the mext-block package's named exports with proper TypeScript types
109
+ 4. Generates type definitions for component props
110
+ 5. Shows available components and their metadata
111
+ 6. Enables IntelliSense support for all synced components
112
+
113
+ **When to use:**
114
+ - **After someone else publishes a block** and you want to use it as a typed component
115
+ - **On a different computer** than where the block was published
116
+ - **To get latest props schemas** and type definitions
117
+ - **To manually refresh** the registry if components seem outdated
118
+
119
+ **Note:** This command is automatically executed after a successful `mexty publish` on the same machine, so you typically don't need to run it manually unless you're on a different computer or want to get components published by others.
120
+
121
+ ### `mexty publish`
122
+
123
+ Publish the current block with automatic props schema parsing and registry synchronization.
124
+
125
+ ```bash
126
+ # In your block repository directory
127
+ mexty publish
128
+ ```
129
+
130
+ **What it does:**
131
+ 1. Checks if you're in a valid block repository
132
+ 2. Shows repository status and detects the block ID
133
+ 3. Checks for uncommitted changes
134
+ 4. Prompts you to push changes to GitHub
135
+ 5. **Automatically parses your block.tsx props interface** using AI
136
+ 6. Generates and stores JSON schema for your component props
137
+ 7. Triggers the build and bundle process on the server
138
+ 8. Provides feedback on the build status
139
+ 9. **Automatically syncs the registry** to make your block available as a typed component
140
+ 10. Updates local TypeScript definitions for immediate use
141
+
142
+ **🆕 Auto Props Parsing:**
143
+ When you push files via Sandpack editor or publish your block, the system automatically:
144
+ - Analyzes your `block.tsx` file
145
+ - Extracts the props interface using AI
146
+ - Generates JSON schema for validation and typing
147
+ - Updates the block's metadata with props information
148
+ - Enables type-safe usage across the ecosystem
149
+
150
+ ## Workflow
151
+
152
+ ### Creating a New Block with Type Safety
153
+
154
+ ```bash
155
+ # 1. Create and clone the block
156
+ mexty create "My Amazing Block"
157
+
158
+ # 2. Navigate to the repository
159
+ cd block-<block-id>
160
+
161
+ # 3. Define your props interface in src/block.tsx
162
+ # Example:
163
+ # interface BlockProps {
164
+ # title: string;
165
+ # count?: number;
166
+ # theme: 'light' | 'dark';
167
+ # onAction?: () => void;
168
+ # }
169
+
170
+ # 4. Implement your component logic
171
+ # Edit files, add features, etc.
172
+
173
+ # 5. Commit your changes
174
+ git add .
175
+ git commit -m "Add amazing features with typed props"
176
+
177
+ # 6. Push to GitHub
178
+ git push origin main
179
+
180
+ # 7. Publish the block (automatically parses props and syncs registry)
181
+ mexty publish
182
+ ```
183
+
184
+ **What happens automatically:**
185
+ - Your props interface is parsed by AI and converted to JSON schema
186
+ - Type definitions are generated for your component
187
+ - Registry is updated with your new typed component
188
+ - Other developers can immediately use your component with full IntelliSense
189
+
190
+ ### Using Typed Components
191
+
192
+ After publishing or syncing, you can use components with full type safety:
193
+
194
+ ```tsx
195
+ // Full TypeScript support with IntelliSense
196
+ import { MyAmazingBlock } from 'mextblock';
197
+
198
+ // Props are fully typed - you get autocompletion and error checking
199
+ <MyAmazingBlock
200
+ props={{
201
+ title: "Hello World", // ✅ Required string
202
+ count: 42, // ✅ Optional number
203
+ theme: "dark", // ✅ Must be 'light' | 'dark'
204
+ onAction: () => console.log('clicked') // ✅ Optional function
205
+ }}
206
+ />
207
+
208
+ // Runtime validation (optional)
209
+ <MyAmazingBlock
210
+ validateProps
211
+ props={{ title: "Hello" }}
212
+ onError={(error) => console.log('Props validation failed:', error)}
213
+ />
214
+ ```
215
+
216
+ ### Forking an Existing Block
217
+
218
+ ```bash
219
+ # 1. Fork and clone the block
220
+ mexty fork 507f1f77bcf86cd799439011
221
+
222
+ # 2. Navigate to the repository
223
+ cd block-<new-block-id>
224
+
225
+ # 3. Make your modifications
226
+ # Customize the forked block
227
+
228
+ # 4. Follow steps 4-6 from "Creating a New Block"
229
+ # Note: publish automatically syncs the registry
230
+ ```
231
+
232
+ ### Multi-Developer Team Workflow
233
+
234
+ **Developer A (Publishing a new block):**
235
+ ```bash
236
+ mexty create "Team Component"
237
+ cd block-<id>
238
+ # Define props interface in block.tsx:
239
+ # interface TeamComponentProps {
240
+ # teamName: string;
241
+ # members: Array<{ name: string; role: string }>;
242
+ # theme?: 'corporate' | 'casual';
243
+ # }
244
+ git add . && git commit -m "Add team component with typed props"
245
+ git push origin main
246
+ mexty publish # Automatically parses props and syncs registry locally
247
+ ```
248
+
249
+ **Developer B (Using the new component on different computer):**
250
+ ```bash
251
+ # First, sync to get the latest components and their type definitions
252
+ mexty sync
253
+
254
+ # Then use in your React app with full TypeScript support
255
+ import { TeamComponent } from 'mextblock';
256
+
257
+ <TeamComponent
258
+ props={{
259
+ teamName: "Engineering",
260
+ members: [
261
+ { name: "Alice", role: "Frontend" },
262
+ { name: "Bob", role: "Backend" }
263
+ ],
264
+ theme: "corporate"
265
+ }}
266
+ />
267
+ ```
268
+
269
+ ## Advanced Features
270
+
271
+ ### Props Schema Auto-Generation
272
+
273
+ The MEXT system automatically analyzes your TypeScript interfaces and generates JSON schemas for:
274
+
275
+ - **Type validation**: Runtime props checking
276
+ - **Default values**: Automatic application of defaults
277
+ - **IntelliSense**: Full IDE support with autocompletion
278
+ - **Documentation**: Automatic props documentation from JSDoc comments
279
+
280
+ **Example props interface that gets auto-parsed:**
281
+ ```tsx
282
+ interface BlockProps {
283
+ /** The main title to display */
284
+ title: string;
285
+
286
+ /** Optional subtitle text */
287
+ subtitle?: string;
288
+
289
+ /** Number of items to show (defaults to 10) */
290
+ count?: number;
291
+
292
+ /** Visual theme variant */
293
+ theme: 'light' | 'dark' | 'auto';
294
+
295
+ /** Custom styling overrides */
296
+ customStyles?: React.CSSProperties;
297
+
298
+ /** Click event handler */
299
+ onClick?: (event: MouseEvent) => void;
300
+ }
301
+ ```
302
+
303
+ Gets converted to JSON schema automatically for runtime validation and type generation.
304
+
305
+ ### Typed Component Creation
306
+
307
+ For advanced use cases, you can create strongly typed components:
308
+
309
+ ```tsx
310
+ import { createTypedBlock } from 'mextblock';
311
+
312
+ interface GameProps {
313
+ level: number;
314
+ playerName: string;
315
+ difficulty: 'easy' | 'medium' | 'hard';
316
+ onGameOver?: (score: number) => void;
317
+ }
318
+
319
+ // Creates a component with full TypeScript support
320
+ const TypedGame = createTypedBlock<GameProps>('VirtualGame', {
321
+ defaultProps: {
322
+ level: 1,
323
+ difficulty: 'easy'
324
+ },
325
+ validateProps: true
326
+ });
327
+
328
+ // Usage with full type safety
329
+ <TypedGame props={{ level: 5, playerName: "Alice", difficulty: "hard" }} />
330
+ ```
331
+
332
+ ## Configuration
333
+
334
+ The CLI uses the following default settings:
335
+
336
+ - **Server URL**: http://localhost:3001
337
+ - **Timeout**: 30 seconds for API requests
338
+ - **Props Parsing**: Automatic on publish/push
339
+ - **Type Generation**: Automatic on sync
340
+
341
+ ## API Integration
342
+
343
+ The CLI integrates with several new server endpoints:
344
+
345
+ - `GET /api/blocks/sync` - Full registry and props schema sync
346
+ - `GET /api/blocks/:blockId/props-schema` - Get specific props schema
347
+ - `POST /api/blocks/:blockId/reparse-props` - Force re-parse props schema
348
+
349
+ ## Troubleshooting
350
+
351
+ ### "Network Error: Could not reach MEXT server"
352
+
353
+ Make sure the MEXT server is running on the expected port (default: 3001).
354
+
355
+ ### "GitHub repository creation failed"
356
+
357
+ Check that the server has proper GitHub configuration:
358
+ - `GITHUB_TOKEN` environment variable
359
+ - `GITHUB_USERNAME` environment variable
360
+
361
+ ### "Could not determine block ID from repository"
362
+
363
+ This happens when running `mexty publish` in a directory that's not a valid block repository. Make sure you're in a directory created by `mexty create` or `mexty fork`.
364
+
365
+ ### "Props parsing failed"
366
+
367
+ If automatic props parsing fails:
368
+ 1. Ensure your `block.tsx` has a clear TypeScript interface
369
+ 2. Check that the interface is properly exported or used in the component
370
+ 3. Use JSDoc comments for better AI understanding
371
+ 4. Run `mexty publish` again or manually trigger re-parsing
372
+
373
+ ### "TypeScript definitions not updating"
374
+
375
+ If you're not getting proper type support:
376
+ 1. Run `mexty sync` to refresh type definitions
377
+ 2. Restart your TypeScript language server
378
+ 3. Check that the component was successfully published and parsed
379
+ 4. Verify your mext-block package is up to date
380
+
381
+ ### Permission Issues
382
+
383
+ If you get permission errors, you may need to:
384
+ 1. Set up GitHub SSH keys properly
385
+ 2. Ensure your GitHub token has the necessary permissions
386
+ 3. Check repository access rights
387
+
388
+ ## Development
389
+
390
+ ### Building
391
+
392
+ ```bash
393
+ npm run build
394
+ ```
395
+
396
+ ### Development Mode
397
+
398
+ ```bash
399
+ npm run dev
400
+ ```
401
+
402
+ ### Project Structure
403
+
404
+ ```
405
+ cli/
406
+ ├── src/
407
+ │ ├── commands/ # Individual CLI commands
408
+ │ │ ├── login.ts
409
+ │ │ ├── create.ts
410
+ │ │ ├── fork.ts
411
+ │ │ ├── delete.ts
412
+ │ │ ├── publish.ts
413
+ │ │ └── sync.ts # Enhanced with props schema sync
414
+ │ ├── utils/
415
+ │ │ ├── api.ts # API client for MEXT server
416
+ │ │ ├── git.ts # Git operations utility
417
+ │ │ └── types.ts # Type generation utilities
418
+ │ └── index.ts # Main CLI entry point
419
+ ├── dist/ # Compiled JavaScript
420
+ ├── package.json
421
+ ├── tsconfig.json
422
+ └── README.md
423
+ ```
424
+
425
+ ## License
426
+
427
+ MIT
@@ -0,0 +1,7 @@
1
+ interface CreateOptions {
2
+ description?: string;
3
+ type?: string;
4
+ }
5
+ export declare function createCommand(name: string, options: CreateOptions): Promise<void>;
6
+ export {};
7
+ //# sourceMappingURL=create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAMA,UAAU,aAAa;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAmBD,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA8DvF"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createCommand = createCommand;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const api_1 = require("../utils/api");
10
+ const git_1 = require("../utils/git");
11
+ const readline_1 = require("readline");
12
+ // Simple prompt function to replace inquirer
13
+ async function prompt(question, defaultValue) {
14
+ return new Promise((resolve) => {
15
+ const rl = (0, readline_1.createInterface)({
16
+ input: process.stdin,
17
+ output: process.stdout
18
+ });
19
+ const promptText = defaultValue ? `${question} (${defaultValue}): ` : `${question}: `;
20
+ rl.question(promptText, (answer) => {
21
+ rl.close();
22
+ resolve(answer.trim() || defaultValue || '');
23
+ });
24
+ });
25
+ }
26
+ async function createCommand(name, options) {
27
+ try {
28
+ console.log(chalk_1.default.blue(`🚀 Creating new block: ${name}`));
29
+ // Get description if not provided
30
+ let description = options.description;
31
+ if (!description) {
32
+ description = await prompt('Enter a description for the block', `Custom block: ${name}`);
33
+ }
34
+ // Prepare block data
35
+ const blockData = {
36
+ blockType: options.type || 'custom',
37
+ title: name,
38
+ description: description,
39
+ allowedBrickTypes: ['text', 'image', 'video', 'code', 'quiz'], // Default allowed types
40
+ scope: ['user-store'], // Default scope for CLI-created blocks
41
+ content: []
42
+ };
43
+ console.log(chalk_1.default.yellow('📡 Creating block on server...'));
44
+ // Create the block
45
+ const block = await api_1.apiClient.createBlock(blockData);
46
+ console.log(chalk_1.default.green(`✅ Block created successfully!`));
47
+ console.log(chalk_1.default.gray(` Block ID: ${block._id}`));
48
+ console.log(chalk_1.default.gray(` Block Type: ${block.blockType}`));
49
+ if (block.gitUrl) {
50
+ console.log(chalk_1.default.gray(` GitHub URL: ${block.gitUrl}`));
51
+ // Clone the repository
52
+ const repoName = git_1.GitManager.extractRepoName(block.gitUrl);
53
+ const targetDir = path_1.default.join(process.cwd(), repoName);
54
+ console.log(chalk_1.default.yellow(`📦 Cloning repository to ./${repoName}...`));
55
+ try {
56
+ const gitManager = new git_1.GitManager();
57
+ await gitManager.cloneRepository(block.gitUrl, targetDir);
58
+ console.log(chalk_1.default.green(`🎉 Block created and repository cloned successfully!`));
59
+ console.log(chalk_1.default.blue(`\nNext steps:`));
60
+ console.log(chalk_1.default.gray(` 1. cd ${repoName}`));
61
+ console.log(chalk_1.default.gray(` 2. Make your changes`));
62
+ console.log(chalk_1.default.gray(` 3. git add . && git commit -m "Your changes"`));
63
+ console.log(chalk_1.default.gray(` 4. mext-cli publish`));
64
+ }
65
+ catch (cloneError) {
66
+ console.error(chalk_1.default.red(`❌ Failed to clone repository: ${cloneError.message}`));
67
+ console.log(chalk_1.default.yellow(`You can manually clone it later:`));
68
+ console.log(chalk_1.default.gray(` git clone ${block.gitUrl}`));
69
+ }
70
+ }
71
+ else {
72
+ console.log(chalk_1.default.yellow('⚠️ No GitHub repository was created (GitHub not configured)'));
73
+ }
74
+ }
75
+ catch (error) {
76
+ console.error(chalk_1.default.red(`❌ Failed to create block: ${error.message}`));
77
+ process.exit(1);
78
+ }
79
+ }
80
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":";;;;;AA4BA,sCA8DC;AA1FD,kDAA0B;AAC1B,gDAAwB;AACxB,sCAA6D;AAC7D,sCAA0C;AAC1C,uCAA2C;AAO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C,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;gBACzC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,WAAW,QAAQ,EAAE,CAAC,CAAC,CAAC;gBAC/C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC;gBAClD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC,CAAC;gBAC1E,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC;YAEnD,CAAC;YAAC,OAAO,UAAe,EAAE,CAAC;gBACzB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,iCAAiC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;gBAChF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,kCAAkC,CAAC,CAAC,CAAC;gBAC9D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,eAAe,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,8DAA8D,CAAC,CAAC,CAAC;QAC5F,CAAC;IAEH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,6BAA6B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACvE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function deleteCommand(blockId: string): Promise<void>;
2
+ //# sourceMappingURL=delete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../src/commands/delete.ts"],"names":[],"mappings":"AAmBA,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAqClE"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.deleteCommand = deleteCommand;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const api_1 = require("../utils/api");
9
+ const readline_1 = require("readline");
10
+ // Simple confirmation function
11
+ async function confirm(question) {
12
+ return new Promise((resolve) => {
13
+ const rl = (0, readline_1.createInterface)({
14
+ input: process.stdin,
15
+ output: process.stdout
16
+ });
17
+ rl.question(`${question} (y/N): `, (answer) => {
18
+ rl.close();
19
+ resolve(answer.toLowerCase().trim() === 'y' || answer.toLowerCase().trim() === 'yes');
20
+ });
21
+ });
22
+ }
23
+ async function deleteCommand(blockId) {
24
+ try {
25
+ console.log(chalk_1.default.blue(`🗑️ Deleting block: ${blockId}`));
26
+ // Get block info first
27
+ console.log(chalk_1.default.yellow('📡 Fetching block information...'));
28
+ const block = await api_1.apiClient.getBlock(blockId);
29
+ console.log(chalk_1.default.gray(` Title: ${block.title}`));
30
+ console.log(chalk_1.default.gray(` Description: ${block.description}`));
31
+ if (block.gitUrl) {
32
+ console.log(chalk_1.default.gray(` GitHub URL: ${block.gitUrl}`));
33
+ }
34
+ // Confirm deletion
35
+ const confirmed = await confirm(chalk_1.default.red('Are you sure you want to delete this block? This action cannot be undone.'));
36
+ if (!confirmed) {
37
+ console.log(chalk_1.default.yellow('🚫 Deletion cancelled.'));
38
+ return;
39
+ }
40
+ // Delete the block
41
+ console.log(chalk_1.default.yellow('📡 Deleting block on server...'));
42
+ await api_1.apiClient.deleteBlock(blockId);
43
+ console.log(chalk_1.default.green(`✅ Block deleted successfully!`));
44
+ if (block.gitUrl) {
45
+ console.log(chalk_1.default.yellow('⚠️ Note: The GitHub repository still exists and needs to be deleted manually if desired.'));
46
+ console.log(chalk_1.default.gray(` Repository: ${block.gitUrl}`));
47
+ }
48
+ }
49
+ catch (error) {
50
+ console.error(chalk_1.default.red(`❌ Failed to delete block: ${error.message}`));
51
+ process.exit(1);
52
+ }
53
+ }
54
+ //# sourceMappingURL=delete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.js","sourceRoot":"","sources":["../../src/commands/delete.ts"],"names":[],"mappings":";;;;;AAmBA,sCAqCC;AAxDD,kDAA0B;AAC1B,sCAAyC;AACzC,uCAA2C;AAE3C,+BAA+B;AAC/B,KAAK,UAAU,OAAO,CAAC,QAAgB;IACrC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,EAAE,GAAG,IAAA,0BAAe,EAAC;YACzB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;QAEH,EAAE,CAAC,QAAQ,CAAC,GAAG,QAAQ,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE;YAC5C,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,CAAC,CAAC;QACxF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,aAAa,CAAC,OAAe;IACjD,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,wBAAwB,OAAO,EAAE,CAAC,CAAC,CAAC;QAE3D,uBAAuB;QACvB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,kCAAkC,CAAC,CAAC,CAAC;QAC9D,MAAM,KAAK,GAAG,MAAM,eAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAE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,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function forkCommand(blockId: string): Promise<void>;
2
+ //# sourceMappingURL=fork.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fork.d.ts","sourceRoot":"","sources":["../../src/commands/fork.ts"],"names":[],"mappings":"AAKA,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA8ChE"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.forkCommand = forkCommand;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const api_1 = require("../utils/api");
10
+ const git_1 = require("../utils/git");
11
+ async function forkCommand(blockId) {
12
+ try {
13
+ console.log(chalk_1.default.blue(`🍴 Forking block: ${blockId}`));
14
+ // Fork the block
15
+ console.log(chalk_1.default.yellow('📡 Forking block on server...'));
16
+ const forkedBlock = await api_1.apiClient.forkBlock({ blockId });
17
+ console.log(chalk_1.default.green(`✅ Block forked successfully!`));
18
+ console.log(chalk_1.default.gray(` New Block ID: ${forkedBlock._id}`));
19
+ console.log(chalk_1.default.gray(` Title: ${forkedBlock.title}`));
20
+ console.log(chalk_1.default.gray(` Description: ${forkedBlock.description}`));
21
+ if (forkedBlock.gitUrl) {
22
+ console.log(chalk_1.default.gray(` GitHub URL: ${forkedBlock.gitUrl}`));
23
+ // Clone the forked repository
24
+ const repoName = git_1.GitManager.extractRepoName(forkedBlock.gitUrl);
25
+ const targetDir = path_1.default.join(process.cwd(), repoName);
26
+ console.log(chalk_1.default.yellow(`📦 Cloning forked repository to ./${repoName}...`));
27
+ try {
28
+ const gitManager = new git_1.GitManager();
29
+ await gitManager.cloneRepository(forkedBlock.gitUrl, targetDir);
30
+ console.log(chalk_1.default.green(`🎉 Block forked and repository cloned successfully!`));
31
+ console.log(chalk_1.default.blue(`\nNext steps:`));
32
+ console.log(chalk_1.default.gray(` 1. cd ${repoName}`));
33
+ console.log(chalk_1.default.gray(` 2. Make your changes`));
34
+ console.log(chalk_1.default.gray(` 3. git add . && git commit -m "Your changes"`));
35
+ console.log(chalk_1.default.gray(` 4. mext-cli publish`));
36
+ }
37
+ catch (cloneError) {
38
+ console.error(chalk_1.default.red(`❌ Failed to clone repository: ${cloneError.message}`));
39
+ console.log(chalk_1.default.yellow(`You can manually clone it later:`));
40
+ console.log(chalk_1.default.gray(` git clone ${forkedBlock.gitUrl}`));
41
+ }
42
+ }
43
+ else {
44
+ console.log(chalk_1.default.yellow('⚠️ No GitHub repository available for this block'));
45
+ }
46
+ }
47
+ catch (error) {
48
+ console.error(chalk_1.default.red(`❌ Failed to fork block: ${error.message}`));
49
+ process.exit(1);
50
+ }
51
+ }
52
+ //# sourceMappingURL=fork.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fork.js","sourceRoot":"","sources":["../../src/commands/fork.ts"],"names":[],"mappings":";;;;;AAKA,kCA8CC;AAnDD,kDAA0B;AAC1B,gDAAwB;AACxB,sCAAyC;AACzC,sCAA0C;AAEnC,KAAK,UAAU,WAAW,CAAC,OAAe;IAC/C,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,qBAAqB,OAAO,EAAE,CAAC,CAAC,CAAC;QAExD,iBAAiB;QACjB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,+BAA+B,CAAC,CAAC,CAAC;QAC3D,MAAM,WAAW,GAAG,MAAM,eAAS,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QAE3D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC,CAAC;QACzD,OAAO,CAAC,G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AAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC,CAAC;gBAC1E,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC;YAEnD,CAAC;YAAC,OAAO,UAAe,EAAE,CAAC;gBACzB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,iCAAiC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;gBAChF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,kCAAkC,CAAC,CAAC,CAAC;gBAC9D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,eAAe,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,mDAAmD,CAAC,CAAC,CAAC;QACjF,CAAC;IAEH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,2BAA2B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function loginCommand(): Promise<void>;
2
+ //# sourceMappingURL=login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAEA,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAGlD"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.loginCommand = loginCommand;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ async function loginCommand() {
9
+ console.log(chalk_1.default.blue('🔐 Login functionality coming soon...'));
10
+ console.log(chalk_1.default.gray('For now, the CLI works without authentication.'));
11
+ }
12
+ //# sourceMappingURL=login.js.map