@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/README.md
CHANGED
@@ -30,7 +30,7 @@ npm install -g mexty
|
|
30
30
|
|
31
31
|
- Node.js 16+ installed
|
32
32
|
- Git installed and configured
|
33
|
-
- MEXT server running (default:
|
33
|
+
- MEXT server running (default: https://api.v2.mext.app)
|
34
34
|
- GitHub access for repository operations
|
35
35
|
|
36
36
|
## Commands
|
@@ -193,7 +193,7 @@ After publishing or syncing, you can use components with full type safety:
|
|
193
193
|
|
194
194
|
```tsx
|
195
195
|
// Full TypeScript support with IntelliSense
|
196
|
-
import { MyAmazingBlock } from '
|
196
|
+
import { MyAmazingBlock } from '@mexty/block';
|
197
197
|
|
198
198
|
// Props are fully typed - you get autocompletion and error checking
|
199
199
|
<MyAmazingBlock
|
@@ -252,7 +252,7 @@ mexty publish # Automatically parses props and syncs registry locally
|
|
252
252
|
mexty sync
|
253
253
|
|
254
254
|
# Then use in your React app with full TypeScript support
|
255
|
-
import { TeamComponent } from '
|
255
|
+
import { TeamComponent } from '@mexty/block';
|
256
256
|
|
257
257
|
<TeamComponent
|
258
258
|
props={{
|
@@ -307,7 +307,7 @@ Gets converted to JSON schema automatically for runtime validation and type gene
|
|
307
307
|
For advanced use cases, you can create strongly typed components:
|
308
308
|
|
309
309
|
```tsx
|
310
|
-
import { createTypedBlock } from '
|
310
|
+
import { createTypedBlock } from '@mexty/block';
|
311
311
|
|
312
312
|
interface GameProps {
|
313
313
|
level: number;
|
@@ -333,7 +333,7 @@ const TypedGame = createTypedBlock<GameProps>('VirtualGame', {
|
|
333
333
|
|
334
334
|
The CLI uses the following default settings:
|
335
335
|
|
336
|
-
- **Server URL**:
|
336
|
+
- **Server URL**: https://api.v2.mext.app
|
337
337
|
- **Timeout**: 30 seconds for API requests
|
338
338
|
- **Props Parsing**: Automatic on publish/push
|
339
339
|
- **Type Generation**: Automatic on sync
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@mexty/cli",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.2",
|
4
4
|
"description": "MEXT CLI for managing blocks and repositories",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"bin": {
|
@@ -12,9 +12,11 @@
|
|
12
12
|
"start": "node dist/index.js"
|
13
13
|
},
|
14
14
|
"dependencies": {
|
15
|
-
"
|
15
|
+
"@types/inquirer": "^9.0.8",
|
16
16
|
"axios": "^1.6.0",
|
17
17
|
"chalk": "^4.1.2",
|
18
|
+
"commander": "^11.1.0",
|
19
|
+
"inquirer": "^12.6.3",
|
18
20
|
"simple-git": "^3.20.0"
|
19
21
|
},
|
20
22
|
"devDependencies": {
|
package/src/commands/sync.ts
CHANGED
@@ -30,7 +30,7 @@ export async function syncCommand(): Promise<void> {
|
|
30
30
|
|
31
31
|
// Fetch registry from server
|
32
32
|
console.log(chalk.yellow('📡 Fetching registry from server...'));
|
33
|
-
const response = await fetch('
|
33
|
+
const response = await fetch('https://api.v2.mext.app/api/blocks/registry');
|
34
34
|
|
35
35
|
if (!response.ok) {
|
36
36
|
throw new Error(`Server responded with ${response.status}: ${response.statusText}`);
|
@@ -114,7 +114,7 @@ function findMextBlockPath(): string | null {
|
|
114
114
|
if (fs.existsSync(path.join(possiblePath, 'package.json'))) {
|
115
115
|
try {
|
116
116
|
const packageJson = JSON.parse(fs.readFileSync(path.join(possiblePath, 'package.json'), 'utf8'));
|
117
|
-
if (packageJson.name === '@mexty/block' || packageJson.name === '
|
117
|
+
if (packageJson.name === '@mexty/block' || packageJson.name === '@mexty/block') {
|
118
118
|
return possiblePath;
|
119
119
|
}
|
120
120
|
} catch (error) {
|
package/src/index.ts
CHANGED
@@ -1,84 +1,84 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
|
3
|
-
import { Command } from 'commander';
|
4
|
-
import chalk from 'chalk';
|
5
|
-
import { loginCommand } from './commands/login';
|
6
|
-
import { createCommand } from './commands/create';
|
7
|
-
import { forkCommand } from './commands/fork';
|
8
|
-
import { deleteCommand } from './commands/delete';
|
9
|
-
import { publishCommand } from './commands/publish';
|
10
|
-
import { syncCommand } from './commands/sync';
|
11
|
-
import { apiClient } from './utils/api';
|
12
|
-
|
13
|
-
const program = new Command();
|
14
|
-
|
15
|
-
// CLI Configuration
|
16
|
-
program
|
17
|
-
.name('mexty')
|
18
|
-
.description('MEXT CLI for managing React microfrontend blocks and components')
|
19
|
-
.version('1.0.0');
|
20
|
-
|
21
|
-
// Add commands
|
22
|
-
program
|
23
|
-
.command('login')
|
24
|
-
.description('Authenticate with MEXT')
|
25
|
-
.action(loginCommand);
|
26
|
-
|
27
|
-
program
|
28
|
-
.command('logout')
|
29
|
-
.description('Logout from MEXT')
|
30
|
-
.action(async () => {
|
31
|
-
try {
|
32
|
-
if (!apiClient.isAuthenticated()) {
|
33
|
-
console.log(chalk.yellow('⚠️ You are not logged in'));
|
34
|
-
return;
|
35
|
-
}
|
36
|
-
|
37
|
-
await apiClient.logout();
|
38
|
-
console.log(chalk.green('✅ Logged out successfully'));
|
39
|
-
} catch (error: any) {
|
40
|
-
console.error(chalk.red(`❌ Logout failed: ${error.message}`));
|
41
|
-
}
|
42
|
-
});
|
43
|
-
|
44
|
-
program
|
45
|
-
.command('create <name>')
|
46
|
-
.description('Create a new React microfrontend block')
|
47
|
-
.option('-d, --description <description>', 'Block description')
|
48
|
-
.option('-t, --type <type>', 'Block type', 'custom')
|
49
|
-
.action(createCommand);
|
50
|
-
|
51
|
-
program
|
52
|
-
.command('fork <blockId>')
|
53
|
-
.description('Fork an existing block and clone its repository')
|
54
|
-
.action(forkCommand);
|
55
|
-
|
56
|
-
program
|
57
|
-
.command('delete <blockId>')
|
58
|
-
.description('Delete a block (requires ownership)')
|
59
|
-
.action(deleteCommand);
|
60
|
-
|
61
|
-
program
|
62
|
-
.command('publish')
|
63
|
-
.description('Publish current block with automatic bundling')
|
64
|
-
.action(publishCommand);
|
65
|
-
|
66
|
-
program
|
67
|
-
.command('sync')
|
68
|
-
.description('Sync block registry and update typed exports')
|
69
|
-
.action(syncCommand);
|
70
|
-
|
71
|
-
// Error handling
|
72
|
-
program.on('command:*', () => {
|
73
|
-
console.error(chalk.red(`Invalid command: ${program.args.join(' ')}`));
|
74
|
-
console.log(chalk.yellow('See --help for a list of available commands.'));
|
75
|
-
process.exit(1);
|
76
|
-
});
|
77
|
-
|
78
|
-
// Parse arguments
|
79
|
-
program.parse(process.argv);
|
80
|
-
|
81
|
-
// Show help if no command provided
|
82
|
-
if (!process.argv.slice(2).length) {
|
83
|
-
program.outputHelp();
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
import { Command } from 'commander';
|
4
|
+
import chalk from 'chalk';
|
5
|
+
import { loginCommand } from './commands/login';
|
6
|
+
import { createCommand } from './commands/create';
|
7
|
+
import { forkCommand } from './commands/fork';
|
8
|
+
import { deleteCommand } from './commands/delete';
|
9
|
+
import { publishCommand } from './commands/publish';
|
10
|
+
import { syncCommand } from './commands/sync';
|
11
|
+
import { apiClient } from './utils/api';
|
12
|
+
|
13
|
+
const program = new Command();
|
14
|
+
|
15
|
+
// CLI Configuration
|
16
|
+
program
|
17
|
+
.name('mexty')
|
18
|
+
.description('MEXT CLI for managing React microfrontend blocks and components')
|
19
|
+
.version('1.0.0');
|
20
|
+
|
21
|
+
// Add commands
|
22
|
+
program
|
23
|
+
.command('login')
|
24
|
+
.description('Authenticate with MEXT')
|
25
|
+
.action(loginCommand);
|
26
|
+
|
27
|
+
program
|
28
|
+
.command('logout')
|
29
|
+
.description('Logout from MEXT')
|
30
|
+
.action(async () => {
|
31
|
+
try {
|
32
|
+
if (!apiClient.isAuthenticated()) {
|
33
|
+
console.log(chalk.yellow('⚠️ You are not logged in'));
|
34
|
+
return;
|
35
|
+
}
|
36
|
+
|
37
|
+
await apiClient.logout();
|
38
|
+
console.log(chalk.green('✅ Logged out successfully'));
|
39
|
+
} catch (error: any) {
|
40
|
+
console.error(chalk.red(`❌ Logout failed: ${error.message}`));
|
41
|
+
}
|
42
|
+
});
|
43
|
+
|
44
|
+
program
|
45
|
+
.command('create <name>')
|
46
|
+
.description('Create a new React microfrontend block')
|
47
|
+
.option('-d, --description <description>', 'Block description')
|
48
|
+
.option('-t, --type <type>', 'Block type', 'custom')
|
49
|
+
.action(createCommand);
|
50
|
+
|
51
|
+
program
|
52
|
+
.command('fork <blockId>')
|
53
|
+
.description('Fork an existing block and clone its repository')
|
54
|
+
.action(forkCommand);
|
55
|
+
|
56
|
+
program
|
57
|
+
.command('delete <blockId>')
|
58
|
+
.description('Delete a block (requires ownership)')
|
59
|
+
.action(deleteCommand);
|
60
|
+
|
61
|
+
program
|
62
|
+
.command('publish')
|
63
|
+
.description('Publish current block with automatic bundling')
|
64
|
+
.action(publishCommand);
|
65
|
+
|
66
|
+
program
|
67
|
+
.command('sync')
|
68
|
+
.description('Sync block registry and update typed exports')
|
69
|
+
.action(syncCommand);
|
70
|
+
|
71
|
+
// Error handling
|
72
|
+
program.on('command:*', () => {
|
73
|
+
console.error(chalk.red(`Invalid command: ${program.args.join(' ')}`));
|
74
|
+
console.log(chalk.yellow('See --help for a list of available commands.'));
|
75
|
+
process.exit(1);
|
76
|
+
});
|
77
|
+
|
78
|
+
// Parse arguments
|
79
|
+
program.parse(process.argv);
|
80
|
+
|
81
|
+
// Show help if no command provided
|
82
|
+
if (!process.argv.slice(2).length) {
|
83
|
+
program.outputHelp();
|
84
84
|
}
|