@mexty/cli 1.4.1 → 1.6.0
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/package.json +1 -1
- package/src/commands/update-git-url.ts +170 -0
- package/src/index.ts +10 -0
- package/src/utils/api.ts +8 -0
- package/dist/commands/create.d.ts +0 -9
- package/dist/commands/create.d.ts.map +0 -1
- package/dist/commands/create.js +0 -120
- 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 -59
- 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 -57
- 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 -90
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/publish.d.ts +0 -6
- package/dist/commands/publish.d.ts.map +0 -1
- package/dist/commands/publish.js +0 -173
- package/dist/commands/publish.js.map +0 -1
- package/dist/commands/save.d.ts +0 -2
- package/dist/commands/save.d.ts.map +0 -1
- package/dist/commands/save.js +0 -162
- package/dist/commands/save.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 -250
- 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 -76
- package/dist/index.js.map +0 -1
- package/dist/utils/api.d.ts +0 -92
- package/dist/utils/api.d.ts.map +0 -1
- package/dist/utils/api.js +0 -169
- package/dist/utils/api.js.map +0 -1
- package/dist/utils/auth.d.ts +0 -4
- package/dist/utils/auth.d.ts.map +0 -1
- package/dist/utils/auth.js +0 -27
- package/dist/utils/auth.js.map +0 -1
- package/dist/utils/git.d.ts +0 -42
- 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/package.json
CHANGED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { apiClient } from "../utils/api";
|
|
3
|
+
import { requireAuthentication, getAuthenticatedUser } from "../utils/auth";
|
|
4
|
+
import { createInterface } from "readline";
|
|
5
|
+
|
|
6
|
+
// Simple prompt function
|
|
7
|
+
async function prompt(
|
|
8
|
+
question: string,
|
|
9
|
+
defaultValue?: string
|
|
10
|
+
): Promise<string> {
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
const rl = createInterface({
|
|
13
|
+
input: process.stdin,
|
|
14
|
+
output: process.stdout,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const promptText = defaultValue
|
|
18
|
+
? `${question} (${defaultValue}): `
|
|
19
|
+
: `${question}: `;
|
|
20
|
+
|
|
21
|
+
rl.question(promptText, (answer) => {
|
|
22
|
+
rl.close();
|
|
23
|
+
resolve(answer.trim() || defaultValue || "");
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Simple yes/no prompt function
|
|
29
|
+
async function promptYesNo(question: string): Promise<boolean> {
|
|
30
|
+
return new Promise((resolve) => {
|
|
31
|
+
const rl = createInterface({
|
|
32
|
+
input: process.stdin,
|
|
33
|
+
output: process.stdout,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
rl.question(`${question} (y/n): `, (answer) => {
|
|
37
|
+
rl.close();
|
|
38
|
+
resolve(answer.toLowerCase().startsWith("y"));
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function updateGitUrlCommand(blockId?: string, gitUrl?: string, reset?: boolean) {
|
|
44
|
+
try {
|
|
45
|
+
// Require authentication
|
|
46
|
+
await requireAuthentication();
|
|
47
|
+
const user = getAuthenticatedUser();
|
|
48
|
+
|
|
49
|
+
console.log(chalk.blue("🔗 Update Block Git URL"));
|
|
50
|
+
console.log(chalk.gray("Update the Git repository URL for a block\n"));
|
|
51
|
+
|
|
52
|
+
// Get block ID if not provided
|
|
53
|
+
if (!blockId) {
|
|
54
|
+
blockId = await prompt("Enter block ID");
|
|
55
|
+
if (!blockId) {
|
|
56
|
+
console.error(chalk.red("❌ Block ID is required"));
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Validate block ID format
|
|
62
|
+
if (!/^[a-f0-9]{24}$/.test(blockId)) {
|
|
63
|
+
console.error(chalk.red("❌ Invalid block ID format"));
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
console.log(chalk.blue(`📦 Block ID: ${blockId}`));
|
|
68
|
+
|
|
69
|
+
// Get current block information
|
|
70
|
+
try {
|
|
71
|
+
const block = await apiClient.getBlock(blockId);
|
|
72
|
+
console.log(chalk.green(`✅ Found block: ${block.title}`));
|
|
73
|
+
console.log(chalk.gray(`Current Git URL: ${block.gitUrl || "Not set"}`));
|
|
74
|
+
|
|
75
|
+
// Check if current URL is default
|
|
76
|
+
const isDefaultUrl = block.gitUrl?.startsWith("https://github.com/mext-ai/block-");
|
|
77
|
+
if (isDefaultUrl) {
|
|
78
|
+
console.log(chalk.yellow("ℹ️ Current URL is the default Mext URL"));
|
|
79
|
+
}
|
|
80
|
+
} catch (error: any) {
|
|
81
|
+
console.error(chalk.red(`❌ Failed to fetch block: ${error.message}`));
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let newGitUrl: string | undefined;
|
|
86
|
+
let resetToDefault = false;
|
|
87
|
+
|
|
88
|
+
// Handle reset option
|
|
89
|
+
if (reset) {
|
|
90
|
+
resetToDefault = true;
|
|
91
|
+
newGitUrl = `https://github.com/mext-ai/block-${blockId}`;
|
|
92
|
+
console.log(chalk.blue(`🔄 Resetting to default URL: ${newGitUrl}`));
|
|
93
|
+
} else if (gitUrl) {
|
|
94
|
+
// Validate provided URL
|
|
95
|
+
const isValidUrl = /^https:\/\/github\.com\/[\w\-\.]+\/[\w\-\.]+(?:\.git)?$/.test(gitUrl);
|
|
96
|
+
if (!isValidUrl) {
|
|
97
|
+
console.error(chalk.red("❌ Invalid Git URL format. Please provide a valid GitHub URL."));
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
newGitUrl = gitUrl;
|
|
101
|
+
console.log(chalk.blue(`🔗 New Git URL: ${newGitUrl}`));
|
|
102
|
+
} else {
|
|
103
|
+
// Interactive mode
|
|
104
|
+
const currentBlock = await apiClient.getBlock(blockId);
|
|
105
|
+
const currentUrl = currentBlock.gitUrl || "";
|
|
106
|
+
|
|
107
|
+
// Ask for new URL
|
|
108
|
+
newGitUrl = await prompt("Enter new Git URL", currentUrl);
|
|
109
|
+
|
|
110
|
+
if (!newGitUrl) {
|
|
111
|
+
console.error(chalk.red("❌ Git URL is required"));
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Validate URL format
|
|
116
|
+
const isValidUrl = /^https:\/\/github\.com\/[\w\-\.]+\/[\w\-\.]+(?:\.git)?$/.test(newGitUrl);
|
|
117
|
+
if (!isValidUrl) {
|
|
118
|
+
console.error(chalk.red("❌ Invalid Git URL format. Please provide a valid GitHub URL."));
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Check if user wants to reset to default
|
|
123
|
+
if (!newGitUrl.startsWith("https://github.com/mext-ai/block-")) {
|
|
124
|
+
const shouldReset = await promptYesNo("This is not the default Mext URL. Do you want to reset to default instead?");
|
|
125
|
+
if (shouldReset) {
|
|
126
|
+
resetToDefault = true;
|
|
127
|
+
newGitUrl = `https://github.com/mext-ai/block-${blockId}`;
|
|
128
|
+
console.log(chalk.blue(`🔄 Resetting to default URL: ${newGitUrl}`));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Confirm the update
|
|
134
|
+
console.log(chalk.yellow(`\n⚠️ About to update Git URL to: ${newGitUrl}`));
|
|
135
|
+
const confirmed = await promptYesNo("Do you want to proceed?");
|
|
136
|
+
|
|
137
|
+
if (!confirmed) {
|
|
138
|
+
console.log(chalk.gray("❌ Update cancelled"));
|
|
139
|
+
process.exit(0);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Update the Git URL
|
|
143
|
+
console.log(chalk.blue("🔄 Updating Git URL..."));
|
|
144
|
+
|
|
145
|
+
try {
|
|
146
|
+
const result = await apiClient.updateBlockGitUrl(blockId, newGitUrl, resetToDefault);
|
|
147
|
+
|
|
148
|
+
console.log(chalk.green("✅ Git URL updated successfully!"));
|
|
149
|
+
console.log(chalk.gray(`New URL: ${result.gitUrl}`));
|
|
150
|
+
|
|
151
|
+
if (result.resetToDefault) {
|
|
152
|
+
console.log(chalk.yellow("🔄 URL was reset to default"));
|
|
153
|
+
}
|
|
154
|
+
} catch (error: any) {
|
|
155
|
+
console.error(chalk.red(`❌ Failed to update Git URL: ${error.message}`));
|
|
156
|
+
|
|
157
|
+
if (error.response?.status === 403) {
|
|
158
|
+
console.error(chalk.red("Access denied. You can only update blocks you own."));
|
|
159
|
+
} else if (error.response?.status === 404) {
|
|
160
|
+
console.error(chalk.red("Block not found."));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
} catch (error: any) {
|
|
167
|
+
console.error(chalk.red(`❌ Error: ${error.message}`));
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { createCommand } from "./commands/create";
|
|
|
7
7
|
import { deleteCommand } from "./commands/delete";
|
|
8
8
|
import { publishCommand } from "./commands/publish";
|
|
9
9
|
import { saveCommand } from "./commands/save";
|
|
10
|
+
import { updateGitUrlCommand } from "./commands/update-git-url";
|
|
10
11
|
import { apiClient } from "./utils/api";
|
|
11
12
|
|
|
12
13
|
const program = new Command();
|
|
@@ -71,6 +72,15 @@ program
|
|
|
71
72
|
.description("Save current block (git add, commit, push, and trigger build)")
|
|
72
73
|
.action(saveCommand);
|
|
73
74
|
|
|
75
|
+
program
|
|
76
|
+
.command("update-git-url [blockId]")
|
|
77
|
+
.description("Update the Git repository URL for a block")
|
|
78
|
+
.option("-u, --url <url>", "New Git URL")
|
|
79
|
+
.option("-r, --reset", "Reset to default Mext URL")
|
|
80
|
+
.action((blockId, options) => {
|
|
81
|
+
updateGitUrlCommand(blockId, options.url, options.reset);
|
|
82
|
+
});
|
|
83
|
+
|
|
74
84
|
// Error handling
|
|
75
85
|
program.on("command:*", () => {
|
|
76
86
|
console.error(chalk.red(`Invalid command: ${program.args.join(" ")}`));
|
package/src/utils/api.ts
CHANGED
|
@@ -304,6 +304,14 @@ class ApiClient {
|
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
+
async updateBlockGitUrl(blockId: string, gitUrl?: string, resetToDefault?: boolean): Promise<any> {
|
|
308
|
+
const response = await this.client.patch(`/api/blocks/${blockId}/git-url`, {
|
|
309
|
+
gitUrl,
|
|
310
|
+
resetToDefault,
|
|
311
|
+
});
|
|
312
|
+
return response.data;
|
|
313
|
+
}
|
|
314
|
+
|
|
307
315
|
setBaseUrl(url: string): void {
|
|
308
316
|
this.baseUrl = url;
|
|
309
317
|
this.client.defaults.baseURL = url;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAOA,UAAU,aAAa;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAwBD,wBAAsB,aAAa,CACjC,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAiIf"}
|
package/dist/commands/create.js
DELETED
|
@@ -1,120 +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
|
-
const auth_1 = require("../utils/auth");
|
|
13
|
-
// Simple prompt function to replace inquirer
|
|
14
|
-
async function prompt(question, defaultValue) {
|
|
15
|
-
return new Promise((resolve) => {
|
|
16
|
-
const rl = (0, readline_1.createInterface)({
|
|
17
|
-
input: process.stdin,
|
|
18
|
-
output: process.stdout,
|
|
19
|
-
});
|
|
20
|
-
const promptText = defaultValue
|
|
21
|
-
? `${question} (${defaultValue}): `
|
|
22
|
-
: `${question}: `;
|
|
23
|
-
rl.question(promptText, (answer) => {
|
|
24
|
-
rl.close();
|
|
25
|
-
resolve(answer.trim() || defaultValue || "");
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
async function createCommand(subcommand, options = {}) {
|
|
30
|
-
try {
|
|
31
|
-
// Check authentication first
|
|
32
|
-
(0, auth_1.requireAuthentication)();
|
|
33
|
-
const user = (0, auth_1.getAuthenticatedUser)();
|
|
34
|
-
// Handle both old and new syntax
|
|
35
|
-
let blockName;
|
|
36
|
-
let blockDescription;
|
|
37
|
-
let blockType;
|
|
38
|
-
if (subcommand === "block") {
|
|
39
|
-
// New syntax: mexty create block --name "..." --description "..." --category "..."
|
|
40
|
-
if (!options.name) {
|
|
41
|
-
console.error(chalk_1.default.red('❌ --name is required when using "mexty create block"'));
|
|
42
|
-
console.log(chalk_1.default.yellow(' Usage: mexty create block --name "Block Name" --description "Description" --category "category"'));
|
|
43
|
-
process.exit(1);
|
|
44
|
-
}
|
|
45
|
-
blockName = options.name;
|
|
46
|
-
blockDescription = options.description || `Custom block: ${blockName}`;
|
|
47
|
-
blockType = options.category || options.type || "custom";
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
// Old syntax: mexty create "Block Name" --description "..." --type "..."
|
|
51
|
-
if (!subcommand) {
|
|
52
|
-
console.error(chalk_1.default.red("❌ Block name is required"));
|
|
53
|
-
console.log(chalk_1.default.yellow(' Usage: mexty create "Block Name" [options]'));
|
|
54
|
-
console.log(chalk_1.default.yellow(' Or: mexty create block --name "Block Name" [options]'));
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
blockName = subcommand;
|
|
58
|
-
blockDescription = options.description || `Custom block: ${blockName}`;
|
|
59
|
-
blockType = options.type || "custom";
|
|
60
|
-
}
|
|
61
|
-
console.log(chalk_1.default.blue(`🚀 Creating new block: ${blockName}`));
|
|
62
|
-
console.log(chalk_1.default.gray(` User: ${user?.fullName || user?.email || "Unknown"}`));
|
|
63
|
-
console.log(chalk_1.default.gray(` Category: ${blockType}`));
|
|
64
|
-
// Prepare block data
|
|
65
|
-
const blockData = {
|
|
66
|
-
blockType: blockType,
|
|
67
|
-
title: blockName,
|
|
68
|
-
description: blockDescription,
|
|
69
|
-
allowedBrickTypes: ["text", "image", "video", "code", "quiz"], // Default allowed types
|
|
70
|
-
scope: ["user-store"], // Default scope for CLI-created blocks
|
|
71
|
-
content: [],
|
|
72
|
-
};
|
|
73
|
-
console.log(chalk_1.default.yellow("📡 Creating block on server..."));
|
|
74
|
-
// Create the block
|
|
75
|
-
const block = await api_1.apiClient.createBlock(blockData);
|
|
76
|
-
console.log(chalk_1.default.green(`✅ Block created successfully!`));
|
|
77
|
-
console.log(chalk_1.default.gray(` Block ID: ${block.id || block._id}`));
|
|
78
|
-
console.log(chalk_1.default.gray(` Block Type: ${block.blockType || block._doc?.blockType}`));
|
|
79
|
-
// Handle both plain objects and Mongoose documents
|
|
80
|
-
const gitUrl = block.gitUrl || block._doc?.gitUrl;
|
|
81
|
-
if (gitUrl) {
|
|
82
|
-
console.log(chalk_1.default.gray(` GitHub URL: ${gitUrl}`));
|
|
83
|
-
// Clone the repository
|
|
84
|
-
const repoName = git_1.GitManager.extractRepoName(gitUrl);
|
|
85
|
-
const targetDir = path_1.default.join(process.cwd(), repoName);
|
|
86
|
-
console.log(chalk_1.default.yellow(`📦 Cloning repository to ./${repoName}...`));
|
|
87
|
-
try {
|
|
88
|
-
const gitManager = new git_1.GitManager();
|
|
89
|
-
await gitManager.cloneRepository(gitUrl, targetDir);
|
|
90
|
-
console.log(chalk_1.default.green(`🎉 Block created and repository cloned successfully!`));
|
|
91
|
-
console.log(chalk_1.default.blue(`\nNext steps:`));
|
|
92
|
-
console.log(chalk_1.default.gray(` 1. cd ${repoName}`));
|
|
93
|
-
console.log(chalk_1.default.gray(` 2. Make your changes`));
|
|
94
|
-
console.log(chalk_1.default.gray(` 3. mexty save`));
|
|
95
|
-
// Change to the cloned directory
|
|
96
|
-
try {
|
|
97
|
-
process.chdir(targetDir);
|
|
98
|
-
console.log(chalk_1.default.green(`📁 Changed to directory: ${repoName}`));
|
|
99
|
-
}
|
|
100
|
-
catch (chdirError) {
|
|
101
|
-
console.warn(chalk_1.default.yellow(`⚠️ Could not change to directory: ${chdirError.message}`));
|
|
102
|
-
console.log(chalk_1.default.gray(` Please manually run: cd ${repoName}`));
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
catch (cloneError) {
|
|
106
|
-
console.error(chalk_1.default.red(`❌ Failed to clone repository: ${cloneError.message}`));
|
|
107
|
-
console.log(chalk_1.default.yellow(`You can manually clone it later:`));
|
|
108
|
-
console.log(chalk_1.default.gray(` git clone ${gitUrl}`));
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
console.log(chalk_1.default.yellow("⚠️ No GitHub repository was created (GitHub not configured)"));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
console.error(chalk_1.default.red(`❌ Failed to create block: ${error.message}`));
|
|
117
|
-
process.exit(1);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
//# sourceMappingURL=create.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":";;;;;AAoCA,sCAoIC;AAxKD,kDAA0B;AAC1B,gDAAwB;AACxB,sCAA6D;AAC7D,sCAA0C;AAC1C,uCAA2C;AAC3C,wCAA4E;AAS5E,6CAA6C;AAC7C,KAAK,UAAU,MAAM,CACnB,QAAgB,EAChB,YAAqB;IAErB,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;YAC7B,CAAC,CAAC,GAAG,QAAQ,KAAK,YAAY,KAAK;YACnC,CAAC,CAAC,GAAG,QAAQ,IAAI,CAAC;QAEpB,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,CACjC,UAAmB,EACnB,UAAyB,EAAE;IAE3B,IAAI,CAAC;QACH,6BAA6B;QAC7B,IAAA,4BAAqB,GAA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AU,CAAC,OAAO,EAAE,CAC3D,CACF,CAAC;oBACF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,8BAA8B,QAAQ,EAAE,CAAC,CAAC,CAAC;gBACpE,CAAC;YACH,CAAC;YAAC,OAAO,UAAe,EAAE,CAAC;gBACzB,OAAO,CAAC,KAAK,CACX,eAAK,CAAC,GAAG,CAAC,iCAAiC,UAAU,CAAC,OAAO,EAAE,CAAC,CACjE,CAAC;gBACF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,kCAAkC,CAAC,CAAC,CAAC;gBAC9D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,eAAe,MAAM,EAAE,CAAC,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,MAAM,CACV,8DAA8D,CAC/D,CACF,CAAC;QACJ,CAAC;IACH,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":"AAoBA,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0ClE"}
|
package/dist/commands/delete.js
DELETED
|
@@ -1,59 +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
|
-
const auth_1 = require("../utils/auth");
|
|
11
|
-
// Simple confirmation function
|
|
12
|
-
async function confirm(question) {
|
|
13
|
-
return new Promise((resolve) => {
|
|
14
|
-
const rl = (0, readline_1.createInterface)({
|
|
15
|
-
input: process.stdin,
|
|
16
|
-
output: process.stdout
|
|
17
|
-
});
|
|
18
|
-
rl.question(`${question} (y/N): `, (answer) => {
|
|
19
|
-
rl.close();
|
|
20
|
-
resolve(answer.toLowerCase().trim() === 'y' || answer.toLowerCase().trim() === 'yes');
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
async function deleteCommand(blockId) {
|
|
25
|
-
try {
|
|
26
|
-
// Check authentication first
|
|
27
|
-
(0, auth_1.requireAuthentication)();
|
|
28
|
-
const user = (0, auth_1.getAuthenticatedUser)();
|
|
29
|
-
console.log(chalk_1.default.blue(`🗑️ Deleting block: ${blockId}`));
|
|
30
|
-
console.log(chalk_1.default.gray(` User: ${user?.fullName || user?.email || 'Unknown'}`));
|
|
31
|
-
// Get block info first
|
|
32
|
-
console.log(chalk_1.default.yellow('📡 Fetching block information...'));
|
|
33
|
-
const block = await api_1.apiClient.getBlock(blockId);
|
|
34
|
-
console.log(chalk_1.default.gray(` Title: ${block.title}`));
|
|
35
|
-
console.log(chalk_1.default.gray(` Description: ${block.description}`));
|
|
36
|
-
if (block.gitUrl) {
|
|
37
|
-
console.log(chalk_1.default.gray(` GitHub URL: ${block.gitUrl}`));
|
|
38
|
-
}
|
|
39
|
-
// Confirm deletion
|
|
40
|
-
const confirmed = await confirm(chalk_1.default.red('Are you sure you want to delete this block? This action cannot be undone.'));
|
|
41
|
-
if (!confirmed) {
|
|
42
|
-
console.log(chalk_1.default.yellow('🚫 Deletion cancelled.'));
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
// Delete the block
|
|
46
|
-
console.log(chalk_1.default.yellow('📡 Deleting block on server...'));
|
|
47
|
-
await api_1.apiClient.deleteBlock(blockId);
|
|
48
|
-
console.log(chalk_1.default.green(`✅ Block deleted successfully!`));
|
|
49
|
-
if (block.gitUrl) {
|
|
50
|
-
console.log(chalk_1.default.yellow('⚠️ Note: The GitHub repository still exists and needs to be deleted manually if desired.'));
|
|
51
|
-
console.log(chalk_1.default.gray(` Repository: ${block.gitUrl}`));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
console.error(chalk_1.default.red(`❌ Failed to delete block: ${error.message}`));
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=delete.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../src/commands/delete.ts"],"names":[],"mappings":";;;;;AAoBA,sCA0CC;AA9DD,kDAA0B;AAC1B,sCAAyC;AACzC,uCAA2C;AAC3C,wCAA4E;AAE5E,+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;A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,gCAAgC,CAAC,CAAC,CAAC;QAC5D,MAAM,eAAS,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAErC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC,CAAC;QAE1D,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,2FAA2F,CAAC,CAAC,CAAC;YACvH,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,kBAAkB,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC5D,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"}
|
package/dist/commands/fork.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fork.d.ts","sourceRoot":"","sources":["../../src/commands/fork.ts"],"names":[],"mappings":"AAMA,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAmDhE"}
|
package/dist/commands/fork.js
DELETED
|
@@ -1,57 +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.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
|
-
const auth_1 = require("../utils/auth");
|
|
12
|
-
async function forkCommand(blockId) {
|
|
13
|
-
try {
|
|
14
|
-
// Check authentication first
|
|
15
|
-
(0, auth_1.requireAuthentication)();
|
|
16
|
-
const user = (0, auth_1.getAuthenticatedUser)();
|
|
17
|
-
console.log(chalk_1.default.blue(`🍴 Forking block: ${blockId}`));
|
|
18
|
-
console.log(chalk_1.default.gray(` User: ${user?.fullName || user?.email || 'Unknown'}`));
|
|
19
|
-
// Fork the block
|
|
20
|
-
console.log(chalk_1.default.yellow('📡 Forking block on server...'));
|
|
21
|
-
const forkedBlock = await api_1.apiClient.forkBlock({ blockId });
|
|
22
|
-
console.log(chalk_1.default.green(`✅ Block forked successfully!`));
|
|
23
|
-
console.log(chalk_1.default.gray(` New Block ID: ${forkedBlock._id}`));
|
|
24
|
-
console.log(chalk_1.default.gray(` Title: ${forkedBlock.title}`));
|
|
25
|
-
console.log(chalk_1.default.gray(` Description: ${forkedBlock.description}`));
|
|
26
|
-
if (forkedBlock.gitUrl) {
|
|
27
|
-
console.log(chalk_1.default.gray(` GitHub URL: ${forkedBlock.gitUrl}`));
|
|
28
|
-
// Clone the forked repository
|
|
29
|
-
const repoName = git_1.GitManager.extractRepoName(forkedBlock.gitUrl);
|
|
30
|
-
const targetDir = path_1.default.join(process.cwd(), repoName);
|
|
31
|
-
console.log(chalk_1.default.yellow(`📦 Cloning forked repository to ./${repoName}...`));
|
|
32
|
-
try {
|
|
33
|
-
const gitManager = new git_1.GitManager();
|
|
34
|
-
await gitManager.cloneRepository(forkedBlock.gitUrl, targetDir);
|
|
35
|
-
console.log(chalk_1.default.green(`🎉 Block forked and repository cloned successfully!`));
|
|
36
|
-
console.log(chalk_1.default.blue(`\nNext steps:`));
|
|
37
|
-
console.log(chalk_1.default.gray(` 1. cd ${repoName}`));
|
|
38
|
-
console.log(chalk_1.default.gray(` 2. Make your changes`));
|
|
39
|
-
console.log(chalk_1.default.gray(` 3. git add . && git commit -m "Your changes"`));
|
|
40
|
-
console.log(chalk_1.default.gray(` 4. mexty publish`));
|
|
41
|
-
}
|
|
42
|
-
catch (cloneError) {
|
|
43
|
-
console.error(chalk_1.default.red(`❌ Failed to clone repository: ${cloneError.message}`));
|
|
44
|
-
console.log(chalk_1.default.yellow(`You can manually clone it later:`));
|
|
45
|
-
console.log(chalk_1.default.gray(` git clone ${forkedBlock.gitUrl}`));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
console.log(chalk_1.default.yellow('⚠️ No GitHub repository available for this block'));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
console.error(chalk_1.default.red(`❌ Failed to fork block: ${error.message}`));
|
|
54
|
-
process.exit(1);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=fork.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fork.js","sourceRoot":"","sources":["../../src/commands/fork.ts"],"names":[],"mappings":";;;;;AAMA,kCAmDC;AAzDD,kDAA0B;AAC1B,gDAAwB;AACxB,sCAAyC;AACzC,sCAA0C;AAC1C,wCAA4E;AAErE,KAAK,UAAU,WAAW,CAAC,OAAe;IAC/C,IAAI,CAAC;QACH,6BAA6B;QAC7B,IAAA,4BAAqB,GAAE,CAAC;QAExB,MAAM,IAAI,GAAG,IAAA,2BAAoB,GAAE,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,qBAAqB,OAAO,EAAE,CAAC,CAAC,CAAC;QACxD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,QAAQ,IAAI,IAAI,EAAE,KAAK,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC;QAElF,iBAAiB;QACjB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,+BAA+B,CAAC,CAAC,CAAC;QAC3D,MAAM,WAAW,GAAG,MAAM,eAAS,CAAC,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I,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,oBAAoB,CAAC,CAAC,CAAC;YAEhD,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"}
|
package/dist/commands/login.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAwBA,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CA+ElD"}
|
package/dist/commands/login.js
DELETED
|
@@ -1,90 +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.loginCommand = loginCommand;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const readline_1 = require("readline");
|
|
9
|
-
const api_1 = require("../utils/api");
|
|
10
|
-
// Simple prompt function
|
|
11
|
-
async function prompt(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, (answer) => {
|
|
18
|
-
rl.close();
|
|
19
|
-
resolve(answer.trim());
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
// Wait function for countdown
|
|
24
|
-
async function wait(seconds) {
|
|
25
|
-
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
|
|
26
|
-
}
|
|
27
|
-
async function loginCommand() {
|
|
28
|
-
try {
|
|
29
|
-
console.log(chalk_1.default.blue('🔐 Login to MEXT'));
|
|
30
|
-
// Check if already authenticated
|
|
31
|
-
if (api_1.apiClient.isAuthenticated()) {
|
|
32
|
-
const user = api_1.apiClient.getStoredUser();
|
|
33
|
-
console.log(chalk_1.default.green('✅ You are already logged in!'));
|
|
34
|
-
console.log(chalk_1.default.gray(` Email: ${user?.email || 'Unknown'}`));
|
|
35
|
-
console.log(chalk_1.default.gray(` Name: ${user?.fullName || 'Not set'}`));
|
|
36
|
-
const logout = await prompt('Do you want to logout and login as a different user? (y/N): ');
|
|
37
|
-
if (logout.toLowerCase() !== 'y' && logout.toLowerCase() !== 'yes') {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
await api_1.apiClient.logout();
|
|
41
|
-
console.log(chalk_1.default.yellow('📤 Logged out successfully'));
|
|
42
|
-
}
|
|
43
|
-
// Request email
|
|
44
|
-
const email = await prompt('Enter your email address: ');
|
|
45
|
-
if (!email || !email.includes('@')) {
|
|
46
|
-
console.error(chalk_1.default.red('❌ Please provide a valid email address'));
|
|
47
|
-
process.exit(1);
|
|
48
|
-
}
|
|
49
|
-
console.log(chalk_1.default.yellow('📧 Requesting verification code...'));
|
|
50
|
-
// Request OTP
|
|
51
|
-
try {
|
|
52
|
-
const otpResponse = await api_1.apiClient.requestOTP(email);
|
|
53
|
-
if (!otpResponse.success) {
|
|
54
|
-
console.error(chalk_1.default.red(`❌ ${otpResponse.message}`));
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
console.log(chalk_1.default.green('✅ Verification code sent to your email'));
|
|
58
|
-
console.log(chalk_1.default.gray(' Please check your inbox (and spam folder)'));
|
|
59
|
-
// Wait a moment for the user to check email
|
|
60
|
-
await wait(2);
|
|
61
|
-
// Request OTP code
|
|
62
|
-
const otp = await prompt('Enter the 6-digit verification code: ');
|
|
63
|
-
if (!otp || otp.length !== 6 || !/^\d{6}$/.test(otp)) {
|
|
64
|
-
console.error(chalk_1.default.red('❌ Please provide a valid 6-digit code'));
|
|
65
|
-
process.exit(1);
|
|
66
|
-
}
|
|
67
|
-
console.log(chalk_1.default.yellow('🔓 Verifying code...'));
|
|
68
|
-
// Verify OTP
|
|
69
|
-
const verifyResponse = await api_1.apiClient.verifyOTP(email, otp);
|
|
70
|
-
if (!verifyResponse.success) {
|
|
71
|
-
console.error(chalk_1.default.red(`❌ ${verifyResponse.message}`));
|
|
72
|
-
process.exit(1);
|
|
73
|
-
}
|
|
74
|
-
console.log(chalk_1.default.green('🎉 Login successful!'));
|
|
75
|
-
console.log(chalk_1.default.gray(` Welcome, ${verifyResponse.user?.fullName || verifyResponse.user?.email || 'User'}!`));
|
|
76
|
-
if (!verifyResponse.user?.isProfileComplete) {
|
|
77
|
-
console.log(chalk_1.default.yellow('⚠️ Your profile is incomplete. Please complete it in the web interface.'));
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
console.error(chalk_1.default.red(`❌ Login failed: ${error.message}`));
|
|
82
|
-
process.exit(1);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
console.error(chalk_1.default.red(`❌ Login error: ${error.message}`));
|
|
87
|
-
process.exit(1);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=login.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":";;;;;AAwBA,oCA+EC;AAvGD,kDAA0B;AAC1B,uCAA2C;AAC3C,sCAAyC;AAEzC,yBAAyB;AACzB,KAAK,UAAU,MAAM,CAAC,QAAgB;IACpC,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,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE;YAC/B,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,8BAA8B;AAC9B,KAAK,UAAU,IAAI,CAAC,OAAe;IACjC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC;AACrE,CAAC;AAEM,KAAK,UAAU,YAAY;IAChC,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC;QAE5C,iCA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