@mexty/cli 1.0.1 → 1.0.2

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 (41) hide show
  1. package/README.md +5 -5
  2. package/package.json +4 -2
  3. package/src/commands/sync.ts +2 -2
  4. package/src/index.ts +83 -83
  5. package/src/utils/api.ts +241 -239
  6. package/dist/commands/create.d.ts +0 -7
  7. package/dist/commands/create.d.ts.map +0 -1
  8. package/dist/commands/create.js +0 -80
  9. package/dist/commands/create.js.map +0 -1
  10. package/dist/commands/delete.d.ts +0 -2
  11. package/dist/commands/delete.d.ts.map +0 -1
  12. package/dist/commands/delete.js +0 -54
  13. package/dist/commands/delete.js.map +0 -1
  14. package/dist/commands/fork.d.ts +0 -2
  15. package/dist/commands/fork.d.ts.map +0 -1
  16. package/dist/commands/fork.js +0 -52
  17. package/dist/commands/fork.js.map +0 -1
  18. package/dist/commands/login.d.ts +0 -2
  19. package/dist/commands/login.d.ts.map +0 -1
  20. package/dist/commands/login.js +0 -12
  21. package/dist/commands/login.js.map +0 -1
  22. package/dist/commands/publish.d.ts +0 -2
  23. package/dist/commands/publish.d.ts.map +0 -1
  24. package/dist/commands/publish.js +0 -139
  25. package/dist/commands/publish.js.map +0 -1
  26. package/dist/commands/sync.d.ts +0 -2
  27. package/dist/commands/sync.d.ts.map +0 -1
  28. package/dist/commands/sync.js +0 -140
  29. package/dist/commands/sync.js.map +0 -1
  30. package/dist/index.d.ts +0 -3
  31. package/dist/index.d.ts.map +0 -1
  32. package/dist/index.js +0 -60
  33. package/dist/index.js.map +0 -1
  34. package/dist/utils/api.d.ts +0 -55
  35. package/dist/utils/api.d.ts.map +0 -1
  36. package/dist/utils/api.js +0 -68
  37. package/dist/utils/api.js.map +0 -1
  38. package/dist/utils/git.d.ts +0 -41
  39. package/dist/utils/git.d.ts.map +0 -1
  40. package/dist/utils/git.js +0 -171
  41. package/dist/utils/git.js.map +0 -1
package/src/utils/api.ts CHANGED
@@ -1,240 +1,242 @@
1
- import axios, { AxiosInstance, AxiosResponse } from 'axios';
2
- import chalk from 'chalk';
3
- import fs from 'fs';
4
- import path from 'path';
5
- import os from 'os';
6
-
7
- export interface Block {
8
- _id: string;
9
- blockType: string;
10
- title: string;
11
- description: string;
12
- gitUrl?: string;
13
- courseId?: string;
14
- courseName?: string;
15
- allowedBrickTypes: string[];
16
- allowedBlockTypes?: string[];
17
- scope: ('library' | 'user-store' | 'published-store')[];
18
- content: any[];
19
- bundlePath?: string;
20
- federationUrl?: string;
21
- buildStatus?: 'pending' | 'building' | 'success' | 'failed';
22
- buildError?: string;
23
- lastBuilt?: Date;
24
- createdAt: Date;
25
- updatedAt: Date;
26
- }
27
-
28
- export interface CreateBlockRequest {
29
- blockType: string;
30
- title: string;
31
- description: string;
32
- gitUrl?: string;
33
- courseId?: string;
34
- courseName?: string;
35
- allowedBrickTypes: string[];
36
- allowedBlockTypes?: string[];
37
- scope: string[];
38
- content?: any[];
39
- }
40
-
41
- export interface ForkBlockRequest {
42
- blockId: string;
43
- title?: string;
44
- description?: string;
45
- }
46
-
47
- export interface SaveAndBundleRequest {
48
- blockId: string;
49
- }
50
-
51
- export interface AuthResponse {
52
- success: boolean;
53
- message: string;
54
- token?: string;
55
- user?: {
56
- id: string;
57
- email: string;
58
- fullName?: string;
59
- occupation?: string;
60
- isProfileComplete: boolean;
61
- };
62
- }
63
-
64
- export interface LoginRequest {
65
- email: string;
66
- otp: string;
67
- }
68
-
69
- class ApiClient {
70
- private client: AxiosInstance;
71
- private baseUrl: string;
72
- private tokenPath: string;
73
-
74
- constructor(baseUrl: string = 'http://localhost:3001') {
75
- this.baseUrl = baseUrl;
76
- this.tokenPath = path.join(os.homedir(), '.mext', 'auth.json');
77
-
78
- this.client = axios.create({
79
- baseURL: baseUrl,
80
- timeout: 30000,
81
- headers: {
82
- 'Content-Type': 'application/json',
83
- },
84
- });
85
-
86
- // Add request interceptor to include auth token
87
- this.client.interceptors.request.use(
88
- (config) => {
89
- const token = this.getStoredToken();
90
- if (token) {
91
- config.headers.Authorization = `Bearer ${token}`;
92
- }
93
- return config;
94
- },
95
- (error) => Promise.reject(error)
96
- );
97
-
98
- // Add response interceptor for error handling
99
- this.client.interceptors.response.use(
100
- (response) => response,
101
- (error) => {
102
- if (error.response?.status === 401) {
103
- console.error(chalk.red('Authentication required. Please login first: mexty login'));
104
- this.clearStoredToken();
105
- } else if (error.response) {
106
- console.error(chalk.red(`API Error ${error.response.status}: ${error.response.data?.error || error.message}`));
107
- } else if (error.request) {
108
- console.error(chalk.red('Network Error: Could not reach MEXT server'));
109
- console.error(chalk.yellow(`Make sure the server is running at ${this.baseUrl}`));
110
- } else {
111
- console.error(chalk.red(`Request Error: ${error.message}`));
112
- }
113
- throw error;
114
- }
115
- );
116
- }
117
-
118
- private getStoredToken(): string | null {
119
- try {
120
- if (fs.existsSync(this.tokenPath)) {
121
- const authData = JSON.parse(fs.readFileSync(this.tokenPath, 'utf8'));
122
- return authData.token || null;
123
- }
124
- } catch (error) {
125
- // Ignore errors reading token file
126
- }
127
- return null;
128
- }
129
-
130
- private storeToken(token: string, user: any): void {
131
- try {
132
- const authDir = path.dirname(this.tokenPath);
133
- if (!fs.existsSync(authDir)) {
134
- fs.mkdirSync(authDir, { recursive: true });
135
- }
136
-
137
- const authData = {
138
- token,
139
- user,
140
- timestamp: new Date().toISOString()
141
- };
142
-
143
- fs.writeFileSync(this.tokenPath, JSON.stringify(authData, null, 2));
144
- } catch (error: any) {
145
- console.warn(chalk.yellow(`Warning: Could not store auth token: ${error.message}`));
146
- }
147
- }
148
-
149
- private clearStoredToken(): void {
150
- try {
151
- if (fs.existsSync(this.tokenPath)) {
152
- fs.unlinkSync(this.tokenPath);
153
- }
154
- } catch (error) {
155
- // Ignore errors clearing token file
156
- }
157
- }
158
-
159
- public isAuthenticated(): boolean {
160
- return this.getStoredToken() !== null;
161
- }
162
-
163
- public getStoredUser(): any {
164
- try {
165
- if (fs.existsSync(this.tokenPath)) {
166
- const authData = JSON.parse(fs.readFileSync(this.tokenPath, 'utf8'));
167
- return authData.user || null;
168
- }
169
- } catch (error) {
170
- // Ignore errors reading user data
171
- }
172
- return null;
173
- }
174
-
175
- async createBlock(data: CreateBlockRequest): Promise<Block> {
176
- const response: AxiosResponse<Block> = await this.client.post('/api/blocks', data);
177
- return response.data;
178
- }
179
-
180
- async forkBlock(data: ForkBlockRequest): Promise<Block> {
181
- const response: AxiosResponse<Block> = await this.client.post('/api/blocks/fork', data);
182
- return response.data;
183
- }
184
-
185
- async deleteBlock(blockId: string): Promise<void> {
186
- await this.client.delete(`/api/blocks/${blockId}`);
187
- }
188
-
189
- async getBlock(blockId: string): Promise<Block> {
190
- const response: AxiosResponse<Block> = await this.client.get(`/api/blocks/${blockId}`);
191
- return response.data;
192
- }
193
-
194
- async saveAndBundle(data: SaveAndBundleRequest): Promise<any> {
195
- const response = await this.client.post('/api/blocks/save-and-bundle', data);
196
- return response.data;
197
- }
198
-
199
- async healthCheck(): Promise<boolean> {
200
- try {
201
- await this.client.get('/api/health');
202
- return true;
203
- } catch (error) {
204
- return false;
205
- }
206
- }
207
-
208
- async requestOTP(email: string): Promise<AuthResponse> {
209
- const response: AxiosResponse<AuthResponse> = await this.client.post('/api/auth/request-otp', { email });
210
- return response.data;
211
- }
212
-
213
- async verifyOTP(email: string, otp: string): Promise<AuthResponse> {
214
- const response: AxiosResponse<AuthResponse> = await this.client.post('/api/auth/verify-otp', { email, otp });
215
- const data = response.data;
216
-
217
- if (data.success && data.token && data.user) {
218
- this.storeToken(data.token, data.user);
219
- }
220
-
221
- return data;
222
- }
223
-
224
- async logout(): Promise<void> {
225
- try {
226
- await this.client.post('/api/auth/logout');
227
- } catch (error) {
228
- // Ignore logout errors
229
- } finally {
230
- this.clearStoredToken();
231
- }
232
- }
233
-
234
- setBaseUrl(url: string): void {
235
- this.baseUrl = url;
236
- this.client.defaults.baseURL = url;
237
- }
238
- }
239
-
1
+ import axios, { AxiosInstance, AxiosResponse } from 'axios';
2
+ import chalk from 'chalk';
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import os from 'os';
6
+
7
+ export interface Block {
8
+ _id: string;
9
+ blockType: string;
10
+ title: string;
11
+ description: string;
12
+ gitUrl?: string;
13
+ courseId?: string;
14
+ courseName?: string;
15
+ allowedBrickTypes: string[];
16
+ allowedBlockTypes?: string[];
17
+ scope: ('library' | 'user-store' | 'published-store')[];
18
+ content: any[];
19
+ // Fork tracking
20
+ forkedId?: string;
21
+ bundlePath?: string;
22
+ federationUrl?: string;
23
+ buildStatus?: 'pending' | 'building' | 'success' | 'failed';
24
+ buildError?: string;
25
+ lastBuilt?: Date;
26
+ createdAt: Date;
27
+ updatedAt: Date;
28
+ }
29
+
30
+ export interface CreateBlockRequest {
31
+ blockType: string;
32
+ title: string;
33
+ description: string;
34
+ gitUrl?: string;
35
+ courseId?: string;
36
+ courseName?: string;
37
+ allowedBrickTypes: string[];
38
+ allowedBlockTypes?: string[];
39
+ scope: string[];
40
+ content?: any[];
41
+ }
42
+
43
+ export interface ForkBlockRequest {
44
+ blockId: string;
45
+ title?: string;
46
+ description?: string;
47
+ }
48
+
49
+ export interface SaveAndBundleRequest {
50
+ blockId: string;
51
+ }
52
+
53
+ export interface AuthResponse {
54
+ success: boolean;
55
+ message: string;
56
+ token?: string;
57
+ user?: {
58
+ id: string;
59
+ email: string;
60
+ fullName?: string;
61
+ occupation?: string;
62
+ isProfileComplete: boolean;
63
+ };
64
+ }
65
+
66
+ export interface LoginRequest {
67
+ email: string;
68
+ otp: string;
69
+ }
70
+
71
+ class ApiClient {
72
+ private client: AxiosInstance;
73
+ private baseUrl: string;
74
+ private tokenPath: string;
75
+
76
+ constructor(baseUrl: string = 'https://api.v2.mext.app') {
77
+ this.baseUrl = baseUrl;
78
+ this.tokenPath = path.join(os.homedir(), '.mext', 'auth.json');
79
+
80
+ this.client = axios.create({
81
+ baseURL: baseUrl,
82
+ timeout: 30000,
83
+ headers: {
84
+ 'Content-Type': 'application/json',
85
+ },
86
+ });
87
+
88
+ // Add request interceptor to include auth token
89
+ this.client.interceptors.request.use(
90
+ (config) => {
91
+ const token = this.getStoredToken();
92
+ if (token) {
93
+ config.headers.Authorization = `Bearer ${token}`;
94
+ }
95
+ return config;
96
+ },
97
+ (error) => Promise.reject(error)
98
+ );
99
+
100
+ // Add response interceptor for error handling
101
+ this.client.interceptors.response.use(
102
+ (response) => response,
103
+ (error) => {
104
+ if (error.response?.status === 401) {
105
+ console.error(chalk.red('Authentication required. Please login first: mexty login'));
106
+ this.clearStoredToken();
107
+ } else if (error.response) {
108
+ console.error(chalk.red(`API Error ${error.response.status}: ${error.response.data?.error || error.message}`));
109
+ } else if (error.request) {
110
+ console.error(chalk.red('Network Error: Could not reach MEXT server'));
111
+ console.error(chalk.yellow(`Make sure the server is running at ${this.baseUrl}`));
112
+ } else {
113
+ console.error(chalk.red(`Request Error: ${error.message}`));
114
+ }
115
+ throw error;
116
+ }
117
+ );
118
+ }
119
+
120
+ private getStoredToken(): string | null {
121
+ try {
122
+ if (fs.existsSync(this.tokenPath)) {
123
+ const authData = JSON.parse(fs.readFileSync(this.tokenPath, 'utf8'));
124
+ return authData.token || null;
125
+ }
126
+ } catch (error) {
127
+ // Ignore errors reading token file
128
+ }
129
+ return null;
130
+ }
131
+
132
+ private storeToken(token: string, user: any): void {
133
+ try {
134
+ const authDir = path.dirname(this.tokenPath);
135
+ if (!fs.existsSync(authDir)) {
136
+ fs.mkdirSync(authDir, { recursive: true });
137
+ }
138
+
139
+ const authData = {
140
+ token,
141
+ user,
142
+ timestamp: new Date().toISOString()
143
+ };
144
+
145
+ fs.writeFileSync(this.tokenPath, JSON.stringify(authData, null, 2));
146
+ } catch (error: any) {
147
+ console.warn(chalk.yellow(`Warning: Could not store auth token: ${error.message}`));
148
+ }
149
+ }
150
+
151
+ private clearStoredToken(): void {
152
+ try {
153
+ if (fs.existsSync(this.tokenPath)) {
154
+ fs.unlinkSync(this.tokenPath);
155
+ }
156
+ } catch (error) {
157
+ // Ignore errors clearing token file
158
+ }
159
+ }
160
+
161
+ public isAuthenticated(): boolean {
162
+ return this.getStoredToken() !== null;
163
+ }
164
+
165
+ public getStoredUser(): any {
166
+ try {
167
+ if (fs.existsSync(this.tokenPath)) {
168
+ const authData = JSON.parse(fs.readFileSync(this.tokenPath, 'utf8'));
169
+ return authData.user || null;
170
+ }
171
+ } catch (error) {
172
+ // Ignore errors reading user data
173
+ }
174
+ return null;
175
+ }
176
+
177
+ async createBlock(data: CreateBlockRequest): Promise<Block> {
178
+ const response: AxiosResponse<Block> = await this.client.post('/api/blocks', data);
179
+ return response.data;
180
+ }
181
+
182
+ async forkBlock(data: ForkBlockRequest): Promise<Block> {
183
+ const response: AxiosResponse<Block> = await this.client.post('/api/blocks/fork', data);
184
+ return response.data;
185
+ }
186
+
187
+ async deleteBlock(blockId: string): Promise<void> {
188
+ await this.client.delete(`/api/blocks/${blockId}`);
189
+ }
190
+
191
+ async getBlock(blockId: string): Promise<Block> {
192
+ const response: AxiosResponse<Block> = await this.client.get(`/api/blocks/${blockId}`);
193
+ return response.data;
194
+ }
195
+
196
+ async saveAndBundle(data: SaveAndBundleRequest): Promise<any> {
197
+ const response = await this.client.post('/api/blocks/save-and-bundle', data);
198
+ return response.data;
199
+ }
200
+
201
+ async healthCheck(): Promise<boolean> {
202
+ try {
203
+ await this.client.get('/api/health');
204
+ return true;
205
+ } catch (error) {
206
+ return false;
207
+ }
208
+ }
209
+
210
+ async requestOTP(email: string): Promise<AuthResponse> {
211
+ const response: AxiosResponse<AuthResponse> = await this.client.post('/api/auth/request-otp', { email });
212
+ return response.data;
213
+ }
214
+
215
+ async verifyOTP(email: string, otp: string): Promise<AuthResponse> {
216
+ const response: AxiosResponse<AuthResponse> = await this.client.post('/api/auth/verify-otp', { email, otp });
217
+ const data = response.data;
218
+
219
+ if (data.success && data.token && data.user) {
220
+ this.storeToken(data.token, data.user);
221
+ }
222
+
223
+ return data;
224
+ }
225
+
226
+ async logout(): Promise<void> {
227
+ try {
228
+ await this.client.post('/api/auth/logout');
229
+ } catch (error) {
230
+ // Ignore logout errors
231
+ } finally {
232
+ this.clearStoredToken();
233
+ }
234
+ }
235
+
236
+ setBaseUrl(url: string): void {
237
+ this.baseUrl = url;
238
+ this.client.defaults.baseURL = url;
239
+ }
240
+ }
241
+
240
242
  export const apiClient = new ApiClient();
@@ -1,7 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,80 +0,0 @@
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
@@ -1 +0,0 @@
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;AAO3C,6CAA6C;AAC7C,KAAK,UAAU,MAAM,CAAC,QAAgB,EAAE,YAAqB;IAC3D,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,MAAM,UAAU,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,QAAQ,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,CAAC;QAEtF,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE;YACjC,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,YAAY,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,aAAa,CAAC,IAAY,EAAE,OAAsB;IACtE,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,0BAA0B,IAAI,EAAE,CAAC,CAAC,CAAC;QAE1D,kCAAkC;QAClC,IAAI,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACtC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,WAAW,GAAG,MAAM,MAAM,CAAC,mCAAmC,EAAE,iBAAiB,IAAI,EAAE,CAAC,CAAC;QAC3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,EAAE,CAAC,CAAC,CAAC;QACvE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function deleteCommand(blockId: string): Promise<void>;
2
- //# sourceMappingURL=delete.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,54 +0,0 @@
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
@@ -1 +0,0 @@
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,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