@mexty/cli 1.0.1 → 1.1.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/README.md +5 -5
- package/package.json +4 -2
- package/src/commands/create.ts +109 -41
- package/src/commands/save.ts +213 -0
- package/src/commands/sync.ts +2 -2
- package/src/index.ts +98 -84
- package/src/utils/api.ts +241 -239
- package/src/utils/git.ts +28 -26
- 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/index.ts
CHANGED
@@ -1,84 +1,98 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
|
3
|
-
import { Command } from
|
4
|
-
import chalk from
|
5
|
-
import { loginCommand } from
|
6
|
-
import { createCommand } from
|
7
|
-
import { forkCommand } from
|
8
|
-
import { deleteCommand } from
|
9
|
-
import { publishCommand } from
|
10
|
-
import { syncCommand } from
|
11
|
-
import {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
.
|
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
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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 { saveCommand } from "./commands/save";
|
12
|
+
import { apiClient } from "./utils/api";
|
13
|
+
|
14
|
+
const program = new Command();
|
15
|
+
|
16
|
+
// CLI Configuration
|
17
|
+
program
|
18
|
+
.name("mexty")
|
19
|
+
.description(
|
20
|
+
"MEXT CLI for managing React microfrontend blocks and components"
|
21
|
+
)
|
22
|
+
.version("1.0.0");
|
23
|
+
|
24
|
+
// Add commands
|
25
|
+
program
|
26
|
+
.command("login")
|
27
|
+
.description("Authenticate with MEXT")
|
28
|
+
.action(loginCommand);
|
29
|
+
|
30
|
+
program
|
31
|
+
.command("logout")
|
32
|
+
.description("Logout from MEXT")
|
33
|
+
.action(async () => {
|
34
|
+
try {
|
35
|
+
if (!apiClient.isAuthenticated()) {
|
36
|
+
console.log(chalk.yellow("⚠️ You are not logged in"));
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
|
40
|
+
await apiClient.logout();
|
41
|
+
console.log(chalk.green("✅ Logged out successfully"));
|
42
|
+
} catch (error: any) {
|
43
|
+
console.error(chalk.red(`❌ Logout failed: ${error.message}`));
|
44
|
+
}
|
45
|
+
});
|
46
|
+
|
47
|
+
// Support both old and new create syntax
|
48
|
+
program
|
49
|
+
.command("create [subcommand]")
|
50
|
+
.description("Create a new React microfrontend block")
|
51
|
+
.option("-d, --description <description>", "Block description")
|
52
|
+
.option("-t, --type <type>", "Block type", "custom")
|
53
|
+
.option("-n, --name <name>", 'Block name (for "create block" syntax)')
|
54
|
+
.option(
|
55
|
+
"-c, --category <category>",
|
56
|
+
'Block category (for "create block" syntax)'
|
57
|
+
)
|
58
|
+
.action(createCommand);
|
59
|
+
|
60
|
+
program
|
61
|
+
.command("fork <blockId>")
|
62
|
+
.description("Fork an existing block and clone its repository")
|
63
|
+
.action(forkCommand);
|
64
|
+
|
65
|
+
program
|
66
|
+
.command("delete <blockId>")
|
67
|
+
.description("Delete a block (requires ownership)")
|
68
|
+
.action(deleteCommand);
|
69
|
+
|
70
|
+
program
|
71
|
+
.command("publish")
|
72
|
+
.description("Publish current block with automatic bundling")
|
73
|
+
.action(publishCommand);
|
74
|
+
|
75
|
+
program
|
76
|
+
.command("sync")
|
77
|
+
.description("Sync block registry and update typed exports")
|
78
|
+
.action(syncCommand);
|
79
|
+
|
80
|
+
program
|
81
|
+
.command("save")
|
82
|
+
.description("Save current block (git add, commit, push, and trigger build)")
|
83
|
+
.action(saveCommand);
|
84
|
+
|
85
|
+
// Error handling
|
86
|
+
program.on("command:*", () => {
|
87
|
+
console.error(chalk.red(`Invalid command: ${program.args.join(" ")}`));
|
88
|
+
console.log(chalk.yellow("See --help for a list of available commands."));
|
89
|
+
process.exit(1);
|
90
|
+
});
|
91
|
+
|
92
|
+
// Parse arguments
|
93
|
+
program.parse(process.argv);
|
94
|
+
|
95
|
+
// Show help if no command provided
|
96
|
+
if (!process.argv.slice(2).length) {
|
97
|
+
program.outputHelp();
|
98
|
+
}
|