@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.
- package/README.md +5 -5
- package/package.json +4 -2
- package/src/commands/sync.ts +2 -2
- package/src/index.ts +83 -83
- package/src/utils/api.ts +241 -239
- package/dist/commands/create.d.ts +0 -7
- package/dist/commands/create.d.ts.map +0 -1
- package/dist/commands/create.js +0 -80
- package/dist/commands/create.js.map +0 -1
- package/dist/commands/delete.d.ts +0 -2
- package/dist/commands/delete.d.ts.map +0 -1
- package/dist/commands/delete.js +0 -54
- package/dist/commands/delete.js.map +0 -1
- package/dist/commands/fork.d.ts +0 -2
- package/dist/commands/fork.d.ts.map +0 -1
- package/dist/commands/fork.js +0 -52
- package/dist/commands/fork.js.map +0 -1
- package/dist/commands/login.d.ts +0 -2
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js +0 -12
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/publish.d.ts +0 -2
- package/dist/commands/publish.d.ts.map +0 -1
- package/dist/commands/publish.js +0 -139
- package/dist/commands/publish.js.map +0 -1
- package/dist/commands/sync.d.ts +0 -2
- package/dist/commands/sync.d.ts.map +0 -1
- package/dist/commands/sync.js +0 -140
- package/dist/commands/sync.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -60
- package/dist/index.js.map +0 -1
- package/dist/utils/api.d.ts +0 -55
- package/dist/utils/api.d.ts.map +0 -1
- package/dist/utils/api.js +0 -68
- package/dist/utils/api.js.map +0 -1
- package/dist/utils/git.d.ts +0 -41
- package/dist/utils/git.d.ts.map +0 -1
- package/dist/utils/git.js +0 -171
- 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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
private
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
this.
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
} else if (error.
|
108
|
-
console.error(chalk.red(
|
109
|
-
|
110
|
-
|
111
|
-
console.error(chalk.
|
112
|
-
}
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
}
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
}
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
}
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
}
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
return
|
205
|
-
}
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
}
|
230
|
-
|
231
|
-
}
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
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 +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"}
|
package/dist/commands/create.js
DELETED
@@ -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;I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CAAkC,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"}
|
@@ -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"}
|
package/dist/commands/delete.js
DELETED
@@ -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+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