@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.
- package/README.md +427 -0
- package/dist/commands/create.d.ts +7 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +80 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/delete.d.ts +2 -0
- package/dist/commands/delete.d.ts.map +1 -0
- package/dist/commands/delete.js +54 -0
- package/dist/commands/delete.js.map +1 -0
- package/dist/commands/fork.d.ts +2 -0
- package/dist/commands/fork.d.ts.map +1 -0
- package/dist/commands/fork.js +52 -0
- package/dist/commands/fork.js.map +1 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +12 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/publish.d.ts +2 -0
- package/dist/commands/publish.d.ts.map +1 -0
- package/dist/commands/publish.js +139 -0
- package/dist/commands/publish.js.map +1 -0
- package/dist/commands/sync.d.ts +2 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +140 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/api.d.ts +55 -0
- package/dist/utils/api.d.ts.map +1 -0
- package/dist/utils/api.js +68 -0
- package/dist/utils/api.js.map +1 -0
- package/dist/utils/git.d.ts +41 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +171 -0
- package/dist/utils/git.js.map +1 -0
- package/package.json +39 -0
- package/src/commands/create.ts +97 -0
- package/src/commands/delete.ts +63 -0
- package/src/commands/fork.ts +58 -0
- package/src/commands/login.ts +104 -0
- package/src/commands/publish.ts +159 -0
- package/src/commands/sync.ts +284 -0
- package/src/index.ts +84 -0
- package/src/utils/api.ts +240 -0
- package/src/utils/auth.ts +21 -0
- package/src/utils/git.ts +194 -0
- package/tsconfig.json +24 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":";;;;;AAEA,oCAGC;AALD,kDAA0B;AAEnB,KAAK,UAAU,YAAY;IAChC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC,CAAC;IACjE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC,CAAC;AAC5E,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/commands/publish.ts"],"names":[],"mappings":"AAkEA,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAsFpD"}
|
@@ -0,0 +1,139 @@
|
|
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.publishCommand = publishCommand;
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
9
|
+
const path_1 = __importDefault(require("path"));
|
10
|
+
const api_1 = require("../utils/api");
|
11
|
+
const git_1 = require("../utils/git");
|
12
|
+
const readline_1 = require("readline");
|
13
|
+
const sync_1 = require("./sync");
|
14
|
+
// Simple confirmation function
|
15
|
+
async function confirm(question) {
|
16
|
+
return new Promise((resolve) => {
|
17
|
+
const rl = (0, readline_1.createInterface)({
|
18
|
+
input: process.stdin,
|
19
|
+
output: process.stdout
|
20
|
+
});
|
21
|
+
rl.question(`${question} (y/N): `, (answer) => {
|
22
|
+
rl.close();
|
23
|
+
resolve(answer.toLowerCase().trim() === 'y' || answer.toLowerCase().trim() === 'yes');
|
24
|
+
});
|
25
|
+
});
|
26
|
+
}
|
27
|
+
// Extract block ID from package.json or git URL
|
28
|
+
async function findBlockId() {
|
29
|
+
const packageJsonPath = path_1.default.join(process.cwd(), 'package.json');
|
30
|
+
if (fs_1.default.existsSync(packageJsonPath)) {
|
31
|
+
try {
|
32
|
+
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8'));
|
33
|
+
// Look for block ID in package.json name or description
|
34
|
+
if (packageJson.name && packageJson.name.startsWith('block-')) {
|
35
|
+
return packageJson.name.replace('block-', '');
|
36
|
+
}
|
37
|
+
// Look in description for block ID pattern
|
38
|
+
if (packageJson.description) {
|
39
|
+
const match = packageJson.description.match(/block[:\s]+([a-f0-9]{24})/i);
|
40
|
+
if (match) {
|
41
|
+
return match[1];
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
catch (error) {
|
46
|
+
console.warn(chalk_1.default.yellow('⚠️ Could not parse package.json'));
|
47
|
+
}
|
48
|
+
}
|
49
|
+
// Try to extract from git remote URL
|
50
|
+
try {
|
51
|
+
const gitManager = new git_1.GitManager();
|
52
|
+
const remoteUrl = await gitManager.getRemoteUrl();
|
53
|
+
if (remoteUrl) {
|
54
|
+
const match = remoteUrl.match(/block-([a-f0-9]{24})/);
|
55
|
+
if (match) {
|
56
|
+
return match[1];
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
catch (error) {
|
61
|
+
// Ignore git errors
|
62
|
+
}
|
63
|
+
return null;
|
64
|
+
}
|
65
|
+
async function publishCommand() {
|
66
|
+
try {
|
67
|
+
console.log(chalk_1.default.blue('🚀 Publishing block...'));
|
68
|
+
// Check if we're in a git repository
|
69
|
+
const gitManager = new git_1.GitManager();
|
70
|
+
const isGitRepo = await gitManager.isGitRepository();
|
71
|
+
if (!isGitRepo) {
|
72
|
+
console.error(chalk_1.default.red('❌ Not a git repository. Please run this command from a block repository.'));
|
73
|
+
process.exit(1);
|
74
|
+
}
|
75
|
+
// Get repository information
|
76
|
+
const repoInfo = await gitManager.getRepositoryInfo();
|
77
|
+
console.log(chalk_1.default.gray(` Current branch: ${repoInfo.branch}`));
|
78
|
+
console.log(chalk_1.default.gray(` Remote URL: ${repoInfo.remoteUrl}`));
|
79
|
+
// Find block ID
|
80
|
+
const blockId = await findBlockId();
|
81
|
+
if (!blockId) {
|
82
|
+
console.error(chalk_1.default.red('❌ Could not determine block ID from repository.'));
|
83
|
+
console.error(chalk_1.default.yellow(' Make sure you are in a block repository created with mext-cli'));
|
84
|
+
process.exit(1);
|
85
|
+
}
|
86
|
+
console.log(chalk_1.default.gray(` Block ID: ${blockId}`));
|
87
|
+
// Check for uncommitted changes
|
88
|
+
if (repoInfo.hasChanges) {
|
89
|
+
console.log(chalk_1.default.yellow('⚠️ You have uncommitted changes.'));
|
90
|
+
console.log(chalk_1.default.gray(' Please commit your changes before publishing:'));
|
91
|
+
console.log(chalk_1.default.gray(' git add . && git commit -m "Your commit message"'));
|
92
|
+
const proceed = await confirm('Do you want to continue anyway?');
|
93
|
+
if (!proceed) {
|
94
|
+
console.log(chalk_1.default.yellow('🚫 Publishing cancelled.'));
|
95
|
+
return;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
// Ask user to push changes
|
99
|
+
console.log(chalk_1.default.blue('\n📤 Push your changes to GitHub:'));
|
100
|
+
console.log(chalk_1.default.gray(` git push origin ${repoInfo.branch}`));
|
101
|
+
const pushed = await confirm('Have you pushed your changes to GitHub?');
|
102
|
+
if (!pushed) {
|
103
|
+
console.log(chalk_1.default.yellow('🚫 Please push your changes first and then run publish again.'));
|
104
|
+
return;
|
105
|
+
}
|
106
|
+
// Trigger save and bundle
|
107
|
+
console.log(chalk_1.default.yellow('📡 Triggering build and bundle process...'));
|
108
|
+
try {
|
109
|
+
const result = await api_1.apiClient.saveAndBundle({ blockId });
|
110
|
+
console.log(chalk_1.default.green('✅ Block published successfully!'));
|
111
|
+
console.log(chalk_1.default.gray(` Bundle Path: ${result.bundlePath}`));
|
112
|
+
console.log(chalk_1.default.gray(` Federation URL: ${result.federationUrl}`));
|
113
|
+
if (result.message) {
|
114
|
+
console.log(chalk_1.default.blue(` ${result.message}`));
|
115
|
+
}
|
116
|
+
// Automatically sync registry after successful publish
|
117
|
+
console.log(chalk_1.default.blue('\n🔄 Auto-syncing registry...'));
|
118
|
+
try {
|
119
|
+
await (0, sync_1.syncCommand)();
|
120
|
+
console.log(chalk_1.default.green('✅ Registry synced! Your block is now available as a named component.'));
|
121
|
+
}
|
122
|
+
catch (syncError) {
|
123
|
+
console.warn(chalk_1.default.yellow(`⚠️ Registry sync failed: ${syncError.message}`));
|
124
|
+
console.log(chalk_1.default.gray(' You can manually sync later with: mext-cli sync'));
|
125
|
+
// Don't fail the publish if sync fails - it's not critical
|
126
|
+
}
|
127
|
+
}
|
128
|
+
catch (buildError) {
|
129
|
+
console.error(chalk_1.default.red(`❌ Build failed: ${buildError.message}`));
|
130
|
+
console.log(chalk_1.default.yellow(' Check the server logs for more details.'));
|
131
|
+
process.exit(1);
|
132
|
+
}
|
133
|
+
}
|
134
|
+
catch (error) {
|
135
|
+
console.error(chalk_1.default.red(`❌ Failed to publish block: ${error.message}`));
|
136
|
+
process.exit(1);
|
137
|
+
}
|
138
|
+
}
|
139
|
+
//# sourceMappingURL=publish.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../src/commands/publish.ts"],"names":[],"mappings":";;;;;AAkEA,wCAsFC;AAxJD,kDAA0B;AAC1B,4CAAoB;AACpB,gDAAwB;AACxB,sCAAyC;AACzC,sCAA0C;AAC1C,uCAA2C;AAC3C,iCAAqC;AAErC,+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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GAAG,CAAC,mBAAmB,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YAClE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,4CAA4C,CAAC,CAAC,CAAC;YACxE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IAEH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,8BAA8B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACxE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AAmBA,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAuDjD"}
|
@@ -0,0 +1,140 @@
|
|
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.syncCommand = syncCommand;
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
9
|
+
const path_1 = __importDefault(require("path"));
|
10
|
+
async function syncCommand() {
|
11
|
+
try {
|
12
|
+
console.log(chalk_1.default.blue('🔄 Syncing block registry...'));
|
13
|
+
// Fetch registry from server
|
14
|
+
console.log(chalk_1.default.yellow('📡 Fetching registry from server...'));
|
15
|
+
const response = await fetch('http://localhost:3001/api/blocks/registry');
|
16
|
+
if (!response.ok) {
|
17
|
+
throw new Error(`Server responded with ${response.status}: ${response.statusText}`);
|
18
|
+
}
|
19
|
+
const data = await response.json();
|
20
|
+
const registry = data.registry;
|
21
|
+
const meta = data.meta;
|
22
|
+
console.log(chalk_1.default.green(`✅ Registry fetched successfully!`));
|
23
|
+
console.log(chalk_1.default.gray(` Total blocks: ${meta.totalBlocks}`));
|
24
|
+
console.log(chalk_1.default.gray(` Total components: ${meta.totalComponents}`));
|
25
|
+
console.log(chalk_1.default.gray(` Last updated: ${meta.lastUpdated}`));
|
26
|
+
if (Object.keys(registry).length === 0) {
|
27
|
+
console.log(chalk_1.default.yellow('⚠️ No components found in registry.'));
|
28
|
+
console.log(chalk_1.default.gray(' Make sure you have built some blocks first using "mext-cli publish"'));
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
// Display available components
|
32
|
+
console.log(chalk_1.default.blue('\n📋 Available components:'));
|
33
|
+
for (const [componentName, entry] of Object.entries(registry)) {
|
34
|
+
console.log(chalk_1.default.green(` ${componentName}`));
|
35
|
+
console.log(chalk_1.default.gray(` Block ID: ${entry.blockId}`));
|
36
|
+
console.log(chalk_1.default.gray(` Title: ${entry.title}`));
|
37
|
+
console.log(chalk_1.default.gray(` Description: ${entry.description.substring(0, 60)}${entry.description.length > 60 ? '...' : ''}`));
|
38
|
+
console.log(chalk_1.default.gray(` Tags: ${entry.tags?.join(', ') || 'none'}`));
|
39
|
+
console.log('');
|
40
|
+
}
|
41
|
+
// Generate named exports file
|
42
|
+
const mextBlockPath = findMextBlockPath();
|
43
|
+
if (mextBlockPath) {
|
44
|
+
console.log(chalk_1.default.blue('🔧 Updating mext-block named exports...'));
|
45
|
+
await generateNamedExports(mextBlockPath, registry);
|
46
|
+
console.log(chalk_1.default.green(`✅ Named exports updated in ${mextBlockPath}`));
|
47
|
+
}
|
48
|
+
else {
|
49
|
+
console.log(chalk_1.default.yellow('⚠️ mext-block package not found locally.'));
|
50
|
+
console.log(chalk_1.default.gray(' Named exports file not generated.'));
|
51
|
+
}
|
52
|
+
console.log(chalk_1.default.green('\n🎉 Registry sync completed!'));
|
53
|
+
}
|
54
|
+
catch (error) {
|
55
|
+
console.error(chalk_1.default.red(`❌ Failed to sync registry: ${error.message}`));
|
56
|
+
process.exit(1);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
/**
|
60
|
+
* Find the mext-block package path
|
61
|
+
*/
|
62
|
+
function findMextBlockPath() {
|
63
|
+
// Look for mext-block in common locations
|
64
|
+
const possiblePaths = [
|
65
|
+
path_1.default.join(process.cwd(), '..', 'mext-block'),
|
66
|
+
path_1.default.join(process.cwd(), 'mext-block'),
|
67
|
+
path_1.default.join(process.cwd(), '..', '..', 'mext-block'),
|
68
|
+
];
|
69
|
+
for (const possiblePath of possiblePaths) {
|
70
|
+
if (fs_1.default.existsSync(path_1.default.join(possiblePath, 'package.json'))) {
|
71
|
+
try {
|
72
|
+
const packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(possiblePath, 'package.json'), 'utf8'));
|
73
|
+
if (packageJson.name === 'mextblock') {
|
74
|
+
return possiblePath;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
catch (error) {
|
78
|
+
// Ignore invalid package.json files
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
return null;
|
83
|
+
}
|
84
|
+
/**
|
85
|
+
* Generate named exports file for the mext-block package
|
86
|
+
*/
|
87
|
+
async function generateNamedExports(mextBlockPath, registry) {
|
88
|
+
const namedExportsPath = path_1.default.join(mextBlockPath, 'src', 'namedExports.ts');
|
89
|
+
// Generate the file content
|
90
|
+
const content = `// Auto-generated file - DO NOT EDIT MANUALLY
|
91
|
+
// Generated on: ${new Date().toISOString()}
|
92
|
+
// Total components: ${Object.keys(registry).length}
|
93
|
+
|
94
|
+
import { createNamedBlock } from './components/NamedBlock';
|
95
|
+
|
96
|
+
${Object.entries(registry).map(([componentName, entry]) => `// ${entry.title}
|
97
|
+
// Block ID: ${entry.blockId}
|
98
|
+
// Description: ${entry.description}
|
99
|
+
// Tags: ${entry.tags?.join(', ') || 'none'}
|
100
|
+
export const ${componentName} = createNamedBlock('${componentName}');`).join('\n\n')}
|
101
|
+
|
102
|
+
// Export all components as an object for convenience
|
103
|
+
export const NamedComponents = {
|
104
|
+
${Object.keys(registry).map(componentName => ` ${componentName},`).join('\n')}
|
105
|
+
};
|
106
|
+
|
107
|
+
// Registry metadata
|
108
|
+
export const registryMetadata = {
|
109
|
+
totalComponents: ${Object.keys(registry).length},
|
110
|
+
lastGenerated: '${new Date().toISOString()}',
|
111
|
+
components: {
|
112
|
+
${Object.entries(registry).map(([componentName, entry]) => ` ${componentName}: {
|
113
|
+
blockId: '${entry.blockId}',
|
114
|
+
title: '${entry.title}',
|
115
|
+
description: '${entry.description.replace(/'/g, "\\'")}',
|
116
|
+
tags: [${entry.tags?.map(tag => `'${tag}'`).join(', ') || ''}],
|
117
|
+
lastUpdated: '${entry.lastUpdated}'
|
118
|
+
},`).join('\n')}
|
119
|
+
}
|
120
|
+
};
|
121
|
+
`;
|
122
|
+
// Ensure directory exists
|
123
|
+
const srcDir = path_1.default.dirname(namedExportsPath);
|
124
|
+
if (!fs_1.default.existsSync(srcDir)) {
|
125
|
+
fs_1.default.mkdirSync(srcDir, { recursive: true });
|
126
|
+
}
|
127
|
+
// Write the file
|
128
|
+
fs_1.default.writeFileSync(namedExportsPath, content, 'utf8');
|
129
|
+
// Update the main index.ts to include these exports
|
130
|
+
const indexPath = path_1.default.join(mextBlockPath, 'src', 'index.ts');
|
131
|
+
if (fs_1.default.existsSync(indexPath)) {
|
132
|
+
let indexContent = fs_1.default.readFileSync(indexPath, 'utf8');
|
133
|
+
// Add export for named exports if not already present
|
134
|
+
if (!indexContent.includes('export * from \'./namedExports\'')) {
|
135
|
+
indexContent += '\n// Auto-generated named exports\nexport * from \'./namedExports\';\n';
|
136
|
+
fs_1.default.writeFileSync(indexPath, indexContent, 'utf8');
|
137
|
+
}
|
138
|
+
}
|
139
|
+
}
|
140
|
+
//# sourceMappingURL=sync.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":";;;;;AAmBA,kCAuDC;AA1ED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{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
"use strict";
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
5
|
+
};
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
7
|
+
const commander_1 = require("commander");
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
9
|
+
const login_1 = require("./commands/login");
|
10
|
+
const create_1 = require("./commands/create");
|
11
|
+
const fork_1 = require("./commands/fork");
|
12
|
+
const delete_1 = require("./commands/delete");
|
13
|
+
const publish_1 = require("./commands/publish");
|
14
|
+
const sync_1 = require("./commands/sync");
|
15
|
+
const program = new commander_1.Command();
|
16
|
+
// CLI Configuration
|
17
|
+
program
|
18
|
+
.name('mext-cli')
|
19
|
+
.description('MEXT CLI for managing blocks and repositories')
|
20
|
+
.version('1.0.0');
|
21
|
+
// Add commands
|
22
|
+
program
|
23
|
+
.command('login')
|
24
|
+
.description('Authenticate with MEXT (placeholder)')
|
25
|
+
.action(login_1.loginCommand);
|
26
|
+
program
|
27
|
+
.command('create <name>')
|
28
|
+
.description('Create a new block and clone its repository')
|
29
|
+
.option('-d, --description <description>', 'Block description')
|
30
|
+
.option('-t, --type <type>', 'Block type', 'custom')
|
31
|
+
.action(create_1.createCommand);
|
32
|
+
program
|
33
|
+
.command('fork <blockId>')
|
34
|
+
.description('Fork an existing block and pull its content')
|
35
|
+
.action(fork_1.forkCommand);
|
36
|
+
program
|
37
|
+
.command('delete <blockId>')
|
38
|
+
.description('Delete a block')
|
39
|
+
.action(delete_1.deleteCommand);
|
40
|
+
program
|
41
|
+
.command('publish')
|
42
|
+
.description('Publish current block (push repo and trigger build)')
|
43
|
+
.action(publish_1.publishCommand);
|
44
|
+
program
|
45
|
+
.command('sync')
|
46
|
+
.description('Sync block registry and update named exports')
|
47
|
+
.action(sync_1.syncCommand);
|
48
|
+
// Error handling
|
49
|
+
program.on('command:*', () => {
|
50
|
+
console.error(chalk_1.default.red(`Invalid command: ${program.args.join(' ')}`));
|
51
|
+
console.log(chalk_1.default.yellow('See --help for a list of available commands.'));
|
52
|
+
process.exit(1);
|
53
|
+
});
|
54
|
+
// Parse arguments
|
55
|
+
program.parse(process.argv);
|
56
|
+
// Show help if no command provided
|
57
|
+
if (!process.argv.slice(2).length) {
|
58
|
+
program.outputHelp();
|
59
|
+
}
|
60
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,kDAA0B;AAC1B,4CAAgD;AAChD,8CAAkD;AAClD,0CAA8C;AAC9C,8CAAkD;AAClD,gDAAoD;AACpD,0CAA8C;AAE9C,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,oBAAoB;AACpB,OAAO;KACJ,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CAAC,+CAA+C,CAAC;KAC5D,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,eAAe;AACf,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,sCAAsC,CAAC;KACnD,MAAM,CAAC,oBAAY,CAAC,CAAC;AAExB,OAAO;KACJ,OAAO,CAAC,eAAe,CAAC;KACxB,WAAW,CAAC,6CAA6C,CAAC;KAC1D,MAAM,CAAC,iCAAiC,EAAE,mBAAmB,CAAC;KAC9D,MAAM,CAAC,mBAAmB,EAAE,YAAY,EAAE,QAAQ,CAAC;KACnD,MAAM,CAAC,sBAAa,CAAC,CAAC;AAEzB,OAAO;KACJ,OAAO,CAAC,gBAAgB,CAAC;KACzB,WAAW,CAAC,6CAA6C,CAAC;KAC1D,MAAM,CAAC,kBAAW,CAAC,CAAC;AAEvB,OAAO;KACJ,OAAO,CAAC,kBAAkB,CAAC;KAC3B,WAAW,CAAC,gBAAgB,CAAC;KAC7B,MAAM,CAAC,sBAAa,CAAC,CAAC;AAEzB,OAAO;KACJ,OAAO,CAAC,SAAS,CAAC;KAClB,WAAW,CAAC,qDAAqD,CAAC;KAClE,MAAM,CAAC,wBAAc,CAAC,CAAC;AAE1B,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,8CAA8C,CAAC;KAC3D,MAAM,CAAC,kBAAW,CAAC,CAAC;AAEvB,iBAAiB;AACjB,OAAO,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE;IAC3B,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,oBAAoB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACvE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,8CAA8C,CAAC,CAAC,CAAC;IAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,kBAAkB;AAClB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B,mCAAmC;AACnC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,OAAO,CAAC,UAAU,EAAE,CAAC;AACvB,CAAC"}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
export interface Block {
|
2
|
+
_id: string;
|
3
|
+
blockType: string;
|
4
|
+
title: string;
|
5
|
+
description: string;
|
6
|
+
gitUrl?: string;
|
7
|
+
courseId?: string;
|
8
|
+
courseName?: string;
|
9
|
+
allowedBrickTypes: string[];
|
10
|
+
allowedBlockTypes?: string[];
|
11
|
+
scope: ('library' | 'user-store' | 'published-store')[];
|
12
|
+
content: any[];
|
13
|
+
bundlePath?: string;
|
14
|
+
federationUrl?: string;
|
15
|
+
buildStatus?: 'pending' | 'building' | 'success' | 'failed';
|
16
|
+
buildError?: string;
|
17
|
+
lastBuilt?: Date;
|
18
|
+
createdAt: Date;
|
19
|
+
updatedAt: Date;
|
20
|
+
}
|
21
|
+
export interface CreateBlockRequest {
|
22
|
+
blockType: string;
|
23
|
+
title: string;
|
24
|
+
description: string;
|
25
|
+
gitUrl?: string;
|
26
|
+
courseId?: string;
|
27
|
+
courseName?: string;
|
28
|
+
allowedBrickTypes: string[];
|
29
|
+
allowedBlockTypes?: string[];
|
30
|
+
scope: string[];
|
31
|
+
content?: any[];
|
32
|
+
}
|
33
|
+
export interface ForkBlockRequest {
|
34
|
+
blockId: string;
|
35
|
+
title?: string;
|
36
|
+
description?: string;
|
37
|
+
}
|
38
|
+
export interface SaveAndBundleRequest {
|
39
|
+
blockId: string;
|
40
|
+
}
|
41
|
+
declare class ApiClient {
|
42
|
+
private client;
|
43
|
+
private baseUrl;
|
44
|
+
constructor(baseUrl?: string);
|
45
|
+
createBlock(data: CreateBlockRequest): Promise<Block>;
|
46
|
+
forkBlock(data: ForkBlockRequest): Promise<Block>;
|
47
|
+
deleteBlock(blockId: string): Promise<void>;
|
48
|
+
getBlock(blockId: string): Promise<Block>;
|
49
|
+
saveAndBundle(data: SaveAndBundleRequest): Promise<any>;
|
50
|
+
healthCheck(): Promise<boolean>;
|
51
|
+
setBaseUrl(url: string): void;
|
52
|
+
}
|
53
|
+
export declare const apiClient: ApiClient;
|
54
|
+
export {};
|
55
|
+
//# sourceMappingURL=api.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/utils/api.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MA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AEZ,OAAO,GAAE,MAAgC;IA2B/C,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,KAAK,CAAC;IAKrD,SAAS,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,KAAK,CAAC;IAKjD,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3C,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAKzC,aAAa,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC;IAKvD,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IASrC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAI9B;AAED,eAAO,MAAM,SAAS,WAAkB,CAAC"}
|
@@ -0,0 +1,68 @@
|
|
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.apiClient = void 0;
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
9
|
+
class ApiClient {
|
10
|
+
constructor(baseUrl = 'http://localhost:3001') {
|
11
|
+
this.baseUrl = baseUrl;
|
12
|
+
this.client = axios_1.default.create({
|
13
|
+
baseURL: baseUrl,
|
14
|
+
timeout: 30000,
|
15
|
+
headers: {
|
16
|
+
'Content-Type': 'application/json',
|
17
|
+
},
|
18
|
+
});
|
19
|
+
// Add response interceptor for error handling
|
20
|
+
this.client.interceptors.response.use((response) => response, (error) => {
|
21
|
+
if (error.response) {
|
22
|
+
console.error(chalk_1.default.red(`API Error ${error.response.status}: ${error.response.data?.error || error.message}`));
|
23
|
+
}
|
24
|
+
else if (error.request) {
|
25
|
+
console.error(chalk_1.default.red('Network Error: Could not reach MEXT server'));
|
26
|
+
console.error(chalk_1.default.yellow(`Make sure the server is running at ${this.baseUrl}`));
|
27
|
+
}
|
28
|
+
else {
|
29
|
+
console.error(chalk_1.default.red(`Request Error: ${error.message}`));
|
30
|
+
}
|
31
|
+
throw error;
|
32
|
+
});
|
33
|
+
}
|
34
|
+
async createBlock(data) {
|
35
|
+
const response = await this.client.post('/api/blocks', data);
|
36
|
+
return response.data;
|
37
|
+
}
|
38
|
+
async forkBlock(data) {
|
39
|
+
const response = await this.client.post('/api/blocks/fork', data);
|
40
|
+
return response.data;
|
41
|
+
}
|
42
|
+
async deleteBlock(blockId) {
|
43
|
+
await this.client.delete(`/api/blocks/${blockId}`);
|
44
|
+
}
|
45
|
+
async getBlock(blockId) {
|
46
|
+
const response = await this.client.get(`/api/blocks/${blockId}`);
|
47
|
+
return response.data;
|
48
|
+
}
|
49
|
+
async saveAndBundle(data) {
|
50
|
+
const response = await this.client.post('/api/blocks/save-and-bundle', data);
|
51
|
+
return response.data;
|
52
|
+
}
|
53
|
+
async healthCheck() {
|
54
|
+
try {
|
55
|
+
await this.client.get('/api/health');
|
56
|
+
return true;
|
57
|
+
}
|
58
|
+
catch (error) {
|
59
|
+
return false;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
setBaseUrl(url) {
|
63
|
+
this.baseUrl = url;
|
64
|
+
this.client.defaults.baseURL = url;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
exports.apiClient = new ApiClient();
|
68
|
+
//# sourceMappingURL=api.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/utils/api.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA4D;AAC5D,kDAA0B;AA8C1B,MAAM,SAAS;IAIb,YAAY,UAAkB,uBAAuB;QACnD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;YACzB,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,KA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AQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAe;QAC/B,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,OAAO,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAe;QAC5B,MAAM,QAAQ,GAAyB,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,OAAO,EAAE,CAAC,CAAC;QACvF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAA0B;QAC5C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,6BAA6B,EAAE,IAAI,CAAC,CAAC;QAC7E,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,WAAW;QACf,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;YACrC,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,UAAU,CAAC,GAAW;QACpB,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;QACnB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,GAAG,GAAG,CAAC;IACrC,CAAC;CACF;AAEY,QAAA,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC"}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
export declare class GitManager {
|
2
|
+
private git;
|
3
|
+
constructor(cwd?: string);
|
4
|
+
/**
|
5
|
+
* Clone a repository to a local directory
|
6
|
+
*/
|
7
|
+
cloneRepository(repoUrl: string, targetDir: string): Promise<void>;
|
8
|
+
/**
|
9
|
+
* Check if current directory is a Git repository
|
10
|
+
*/
|
11
|
+
isGitRepository(dir?: string): Promise<boolean>;
|
12
|
+
/**
|
13
|
+
* Get the current repository's remote URL
|
14
|
+
*/
|
15
|
+
getRemoteUrl(dir?: string): Promise<string | null>;
|
16
|
+
/**
|
17
|
+
* Check if there are uncommitted changes
|
18
|
+
*/
|
19
|
+
hasUncommittedChanges(dir?: string): Promise<boolean>;
|
20
|
+
/**
|
21
|
+
* Push current branch to remote
|
22
|
+
*/
|
23
|
+
pushToRemote(dir?: string): Promise<void>;
|
24
|
+
/**
|
25
|
+
* Get repository information
|
26
|
+
*/
|
27
|
+
getRepositoryInfo(dir?: string): Promise<{
|
28
|
+
branch: string;
|
29
|
+
remoteUrl: string | null;
|
30
|
+
hasChanges: boolean;
|
31
|
+
}>;
|
32
|
+
/**
|
33
|
+
* Extract repository name from URL
|
34
|
+
*/
|
35
|
+
static extractRepoName(gitUrl: string): string;
|
36
|
+
/**
|
37
|
+
* Validate Git URL format
|
38
|
+
*/
|
39
|
+
static isValidGitUrl(url: string): boolean;
|
40
|
+
}
|
41
|
+
//# sourceMappingURL=git.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":"AAgDA,qBAAa,UAAU;IACrB,OAAO,CAAC,GAAG,CAAY;gBAEX,GAAG,CAAC,EAAE,MAAM;IAIxB;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBxE;;OAEG;IACG,eAAe,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAUrD;;OAEG;IACG,YAAY,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAWxD;;OAEG;IACG,qBAAqB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAU3D;;OAEG;IACG,YAAY,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwB/C;;OAEG;IACG,iBAAiB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAC7C,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;IAaF;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAY9C;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;CAU3C"}
|