@blkc-code/cli 0.1.3 → 0.3.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/dist/blkc.cjs +75131 -0
- package/package.json +18 -30
- package/bin/blkc.js +0 -24
- package/dist/cli.js +0 -24
- package/dist/commands/block.d.ts +0 -13
- package/dist/commands/block.d.ts.map +0 -1
- package/dist/commands/block.js +0 -196
- package/dist/commands/block.js.map +0 -1
- package/dist/commands/circuit.d.ts +0 -13
- package/dist/commands/circuit.d.ts.map +0 -1
- package/dist/commands/circuit.js +0 -160
- package/dist/commands/circuit.js.map +0 -1
- package/dist/commands/deploy.d.ts +0 -14
- package/dist/commands/deploy.d.ts.map +0 -1
- package/dist/commands/deploy.js +0 -332
- package/dist/commands/deploy.js.map +0 -1
- package/dist/commands/kit.d.ts +0 -13
- package/dist/commands/kit.d.ts.map +0 -1
- package/dist/commands/kit.js +0 -152
- package/dist/commands/kit.js.map +0 -1
- package/dist/commands/logbook.d.ts +0 -13
- package/dist/commands/logbook.d.ts.map +0 -1
- package/dist/commands/logbook.js +0 -170
- package/dist/commands/logbook.js.map +0 -1
- package/dist/index.d.ts +0 -21
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -64
- package/dist/index.js.map +0 -1
- package/src/__tests__/smoke.test.ts +0 -8
- package/src/commands/block.ts +0 -219
- package/src/commands/circuit.ts +0 -182
- package/src/commands/deploy.ts +0 -373
- package/src/commands/kit.ts +0 -173
- package/src/commands/logbook.ts +0 -194
- package/src/index.ts +0 -70
package/dist/commands/logbook.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BLKC CLI - Logbook Commands
|
|
3
|
-
*
|
|
4
|
-
* Commands for working with BLKC Logbook.
|
|
5
|
-
*
|
|
6
|
-
* @package @blkc-code/cli
|
|
7
|
-
* @license Apache-2.0
|
|
8
|
-
* @author Black Code Enterprises LLC
|
|
9
|
-
*/
|
|
10
|
-
import chalk from "chalk";
|
|
11
|
-
import ora from "ora";
|
|
12
|
-
import { stat } from "node:fs/promises";
|
|
13
|
-
import path from "node:path";
|
|
14
|
-
import { Logbook, verifyLogbook, readLogbook } from "@blkc-code/logbook";
|
|
15
|
-
// ============================================================================
|
|
16
|
-
// Command: logbook verify
|
|
17
|
-
// ============================================================================
|
|
18
|
-
function setupVerifyCommand(program) {
|
|
19
|
-
program
|
|
20
|
-
.command("verify <file-path>")
|
|
21
|
-
.description("Verify Logbook chain integrity")
|
|
22
|
-
.option("--algorithm <algo>", "Hash algorithm", "sha256")
|
|
23
|
-
.action(async (filePath, options) => {
|
|
24
|
-
const spinner = ora("Verifying Logbook...").start();
|
|
25
|
-
try {
|
|
26
|
-
const absolutePath = path.resolve(process.cwd(), filePath);
|
|
27
|
-
// Check if file exists
|
|
28
|
-
try {
|
|
29
|
-
await stat(absolutePath);
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
spinner.fail(`File not found: ${absolutePath}`);
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
const result = await verifyLogbook(absolutePath, options.algorithm);
|
|
36
|
-
if (result.valid) {
|
|
37
|
-
spinner.succeed("Logbook verification passed");
|
|
38
|
-
console.log(chalk.green("\n✓ Chain is valid"));
|
|
39
|
-
console.log(chalk.gray(` Entries: ${result.entries.length}`));
|
|
40
|
-
console.log(chalk.gray(` Last hash: ${result.lastHash?.substring(0, 16)}...`));
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
spinner.fail("Logbook verification failed");
|
|
44
|
-
console.error(chalk.red("\n✗ Chain is invalid"));
|
|
45
|
-
console.error(chalk.red(` Issues: ${result.issues.length}`));
|
|
46
|
-
for (const issue of result.issues) {
|
|
47
|
-
console.error(chalk.red(`\n Entry ${issue.index}:`));
|
|
48
|
-
console.error(chalk.red(` ${issue.message}`));
|
|
49
|
-
}
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
spinner.fail(`Failed to verify: ${error}`);
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
// ============================================================================
|
|
60
|
-
// Command: logbook check
|
|
61
|
-
// ============================================================================
|
|
62
|
-
function setupCheckCommand(program) {
|
|
63
|
-
program
|
|
64
|
-
.command("check <file-path>")
|
|
65
|
-
.description("Check Logbook for issues (alias for verify)")
|
|
66
|
-
.action(async (filePath) => {
|
|
67
|
-
// Delegate to verify
|
|
68
|
-
const verifyCmd = program.commands.find((c) => c.name() === "verify");
|
|
69
|
-
if (verifyCmd) {
|
|
70
|
-
await verifyCmd.action(filePath, {});
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
// ============================================================================
|
|
75
|
-
// Command: logbook info
|
|
76
|
-
// ============================================================================
|
|
77
|
-
function setupInfoCommand(program) {
|
|
78
|
-
program
|
|
79
|
-
.command("info <file-path>")
|
|
80
|
-
.description("Show Logbook information")
|
|
81
|
-
.action(async (filePath) => {
|
|
82
|
-
const spinner = ora("Loading Logbook info...").start();
|
|
83
|
-
try {
|
|
84
|
-
const absolutePath = path.resolve(process.cwd(), filePath);
|
|
85
|
-
// Check if file exists
|
|
86
|
-
try {
|
|
87
|
-
await stat(absolutePath);
|
|
88
|
-
}
|
|
89
|
-
catch {
|
|
90
|
-
spinner.fail(`File not found: ${absolutePath}`);
|
|
91
|
-
process.exit(1);
|
|
92
|
-
}
|
|
93
|
-
const logbook = new Logbook({ filePath: absolutePath });
|
|
94
|
-
const info = await logbook.info();
|
|
95
|
-
spinner.succeed(`Logbook: ${info.filePath}`);
|
|
96
|
-
console.log(chalk.bold("\nLogbook Information"));
|
|
97
|
-
console.log(chalk.gray("─".repeat(40)));
|
|
98
|
-
console.log(chalk.gray(`File: ${info.filePath}`));
|
|
99
|
-
console.log(chalk.gray(`Entry count: ${info.entryCount}`));
|
|
100
|
-
if (info.firstEntry) {
|
|
101
|
-
console.log(chalk.gray(`\nFirst Entry:`));
|
|
102
|
-
console.log(chalk.gray(` Timestamp: ${info.firstEntry.timestamp}`));
|
|
103
|
-
console.log(chalk.gray(` Actor: ${info.firstEntry.actor.name}`));
|
|
104
|
-
console.log(chalk.gray(` Event: ${info.firstEntry.event}`));
|
|
105
|
-
}
|
|
106
|
-
if (info.lastEntry) {
|
|
107
|
-
console.log(chalk.gray(`\nLast Entry:`));
|
|
108
|
-
console.log(chalk.gray(` Timestamp: ${info.lastEntry.timestamp}`));
|
|
109
|
-
console.log(chalk.gray(` Actor: ${info.lastEntry.actor.name}`));
|
|
110
|
-
console.log(chalk.gray(` Event: ${info.lastEntry.event}`));
|
|
111
|
-
console.log(chalk.gray(` Hash: ${info.lastHash?.substring(0, 16)}...`));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
spinner.fail(`Failed to show info: ${error}`);
|
|
116
|
-
process.exit(1);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
// ============================================================================
|
|
121
|
-
// Command: logbook tail
|
|
122
|
-
// ============================================================================
|
|
123
|
-
function setupTailCommand(program) {
|
|
124
|
-
program
|
|
125
|
-
.command("tail <file-path>")
|
|
126
|
-
.description("Show the last N entries from Logbook")
|
|
127
|
-
.option("--lines <n>", "Number of lines to show", "10")
|
|
128
|
-
.action(async (filePath, options) => {
|
|
129
|
-
const spinner = ora("Reading Logbook...").start();
|
|
130
|
-
try {
|
|
131
|
-
const absolutePath = path.resolve(process.cwd(), filePath);
|
|
132
|
-
const lines = parseInt(options.lines, 10) || 10;
|
|
133
|
-
const entries = await readLogbook(absolutePath);
|
|
134
|
-
const tailEntries = entries.slice(-lines);
|
|
135
|
-
spinner.succeed(`Showing last ${tailEntries.length} entries`);
|
|
136
|
-
for (const entry of tailEntries) {
|
|
137
|
-
console.log(chalk.gray(`\n[${entry.timestamp}] ${entry.event}`));
|
|
138
|
-
console.log(chalk.gray(` Actor: ${entry.actor.name}`));
|
|
139
|
-
if (entry.subject) {
|
|
140
|
-
console.log(chalk.gray(` Subject: ${entry.subject.type}:${entry.subject.id}`));
|
|
141
|
-
}
|
|
142
|
-
if (entry.hash) {
|
|
143
|
-
console.log(chalk.gray(` Hash: ${entry.hash.substring(0, 16)}...`));
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
if (tailEntries.length === 0) {
|
|
147
|
-
console.log(chalk.gray("\nNo entries found"));
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
catch (error) {
|
|
151
|
-
spinner.fail(`Failed to tail: ${error}`);
|
|
152
|
-
process.exit(1);
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
// ============================================================================
|
|
157
|
-
// Register Commands
|
|
158
|
-
// ============================================================================
|
|
159
|
-
/** Register all logbook commands with the program */
|
|
160
|
-
export function registerLogbookCommands(program) {
|
|
161
|
-
const logbookProgram = program
|
|
162
|
-
.command("logbook")
|
|
163
|
-
.description("Logbook commands")
|
|
164
|
-
.alias("l");
|
|
165
|
-
setupVerifyCommand(logbookProgram);
|
|
166
|
-
setupCheckCommand(logbookProgram);
|
|
167
|
-
setupInfoCommand(logbookProgram);
|
|
168
|
-
setupTailCommand(logbookProgram);
|
|
169
|
-
}
|
|
170
|
-
//# sourceMappingURL=logbook.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logbook.js","sourceRoot":"","sources":["../../src/commands/logbook.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAA6B,MAAM,oBAAoB,CAAC;AAEpG,+EAA+E;AA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,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BLKC CLI - Developer tools for BLKC
|
|
3
|
-
*
|
|
4
|
-
* This package provides command-line tools for working with BLKC Blocks, Kits, Circuits, and Logbook.
|
|
5
|
-
*
|
|
6
|
-
* @package @blkc-code/cli
|
|
7
|
-
* @version 0.1.0
|
|
8
|
-
* @license Apache-2.0
|
|
9
|
-
* @author Black Code Enterprises LLC
|
|
10
|
-
*/
|
|
11
|
-
import { Command } from "commander";
|
|
12
|
-
/**
|
|
13
|
-
* The main BLKC CLI program.
|
|
14
|
-
*/
|
|
15
|
-
export declare const program: Command;
|
|
16
|
-
/**
|
|
17
|
-
* Run the CLI.
|
|
18
|
-
*/
|
|
19
|
-
export declare function run(): Promise<void>;
|
|
20
|
-
export default program;
|
|
21
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC;;GAEG;AACH,eAAO,MAAM,OAAO,SAAgB,CAAC;AA+BrC;;GAEG;AACH,wBAAsB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAWzC;AAGD,eAAe,OAAO,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BLKC CLI - Developer tools for BLKC
|
|
3
|
-
*
|
|
4
|
-
* This package provides command-line tools for working with BLKC Blocks, Kits, Circuits, and Logbook.
|
|
5
|
-
*
|
|
6
|
-
* @package @blkc-code/cli
|
|
7
|
-
* @version 0.1.0
|
|
8
|
-
* @license Apache-2.0
|
|
9
|
-
* @author Black Code Enterprises LLC
|
|
10
|
-
*/
|
|
11
|
-
import { Command } from "commander";
|
|
12
|
-
import { registerBlockCommands } from "./commands/block.js";
|
|
13
|
-
import { registerKitCommands } from "./commands/kit.js";
|
|
14
|
-
import { registerCircuitCommands } from "./commands/circuit.js";
|
|
15
|
-
import { registerLogbookCommands } from "./commands/logbook.js";
|
|
16
|
-
import { registerDeployCommands } from "./commands/deploy.js";
|
|
17
|
-
/**
|
|
18
|
-
* The main BLKC CLI program.
|
|
19
|
-
*/
|
|
20
|
-
export const program = new Command();
|
|
21
|
-
// Configure the CLI
|
|
22
|
-
program
|
|
23
|
-
.name("blkc")
|
|
24
|
-
.description("BLKC developer CLI - Tools for working with Blocks, Kits, Circuits, and Logbook")
|
|
25
|
-
.version("0.1.0");
|
|
26
|
-
// Show help after errors
|
|
27
|
-
program.showHelpAfterError();
|
|
28
|
-
// Configure output to prevent duplicate errors
|
|
29
|
-
program.configureOutput({
|
|
30
|
-
outputError: (str) => {
|
|
31
|
-
// Only print the error if it's not already been handled
|
|
32
|
-
if (str && !str.includes("error:")) {
|
|
33
|
-
console.error(str.trim());
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
// Register all command groups
|
|
38
|
-
registerBlockCommands(program);
|
|
39
|
-
registerKitCommands(program);
|
|
40
|
-
registerCircuitCommands(program);
|
|
41
|
-
registerLogbookCommands(program);
|
|
42
|
-
registerDeployCommands(program);
|
|
43
|
-
// Add a global --help flag
|
|
44
|
-
program.option("--debug", "Enable debug mode");
|
|
45
|
-
/**
|
|
46
|
-
* Run the CLI.
|
|
47
|
-
*/
|
|
48
|
-
export async function run() {
|
|
49
|
-
try {
|
|
50
|
-
await program.parseAsync(process.argv);
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
if (error instanceof Error) {
|
|
54
|
-
console.error(`Error: ${error.message}`);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
console.error("An unknown error occurred");
|
|
58
|
-
}
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// Export for bin usage
|
|
63
|
-
export default program;
|
|
64
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAErC,oBAAoB;AACpB,OAAO;KACJ,IAAI,CAAC,MAAM,CAAC;KACZ,WAAW,CAAC,iFAAiF,CAAC;KAC9F,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,yBAAyB;AACzB,OAAO,CAAC,kBAAkB,EAAE,CAAC;AAE7B,+CAA+C;AAC/C,OAAO,CAAC,eAAe,CAAC;IACtB,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE;QACnB,wDAAwD;QACxD,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;CACF,CAAC,CAAC;AAEH,8BAA8B;AAC9B,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAC/B,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC7B,uBAAuB,CAAC,OAAO,CAAC,CAAC;AACjC,uBAAuB,CAAC,OAAO,CAAC,CAAC;AACjC,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAEhC,2BAA2B;AAC3B,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;AAE/C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG;IACvB,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,uBAAuB;AACvB,eAAe,OAAO,CAAC"}
|
package/src/commands/block.ts
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BLKC CLI - Block Commands
|
|
3
|
-
*
|
|
4
|
-
* Commands for working with BLKC Blocks.
|
|
5
|
-
*
|
|
6
|
-
* @package @blkc-code/cli
|
|
7
|
-
* @license Apache-2.0
|
|
8
|
-
* @author Black Code Enterprises LLC
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { Command } from "commander";
|
|
12
|
-
import chalk from "chalk";
|
|
13
|
-
import ora from "ora";
|
|
14
|
-
import { readFile } from "node:fs/promises";
|
|
15
|
-
import path from "node:path";
|
|
16
|
-
import { BlockSchema } from "@blkc-code/core";
|
|
17
|
-
|
|
18
|
-
// ============================================================================
|
|
19
|
-
// Command: block validate
|
|
20
|
-
// ============================================================================
|
|
21
|
-
|
|
22
|
-
function setupValidateCommand(program: Command): void {
|
|
23
|
-
program
|
|
24
|
-
.command("validate <manifest-path>")
|
|
25
|
-
.description("Validate a Block manifest")
|
|
26
|
-
.action(async (manifestPath: string) => {
|
|
27
|
-
const spinner = ora("Validating Block manifest...").start();
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
const absolutePath = path.resolve(process.cwd(), manifestPath);
|
|
31
|
-
const content = await readFile(absolutePath, { encoding: "utf8" });
|
|
32
|
-
const manifest = JSON.parse(content);
|
|
33
|
-
|
|
34
|
-
const result = BlockSchema.safeParse(manifest);
|
|
35
|
-
|
|
36
|
-
if (!result.success) {
|
|
37
|
-
spinner.fail("Validation failed");
|
|
38
|
-
console.error(chalk.red("\nValidation errors:"));
|
|
39
|
-
for (const issue of result.error.issues) {
|
|
40
|
-
console.error(` - ${chalk.red(issue.path.join("."))}: ${issue.message}`);
|
|
41
|
-
}
|
|
42
|
-
process.exit(1);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
spinner.succeed("Block manifest is valid");
|
|
46
|
-
const block = result.data;
|
|
47
|
-
console.log(chalk.gray(`\nBlock ID: ${block.id}`));
|
|
48
|
-
console.log(chalk.gray(`Name: ${block.name}`));
|
|
49
|
-
console.log(chalk.gray(`Kind: ${block.kind}`));
|
|
50
|
-
console.log(chalk.gray(`Version: ${block.version}`));
|
|
51
|
-
} catch (error) {
|
|
52
|
-
spinner.fail(`Failed to validate: ${error}`);
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// ============================================================================
|
|
59
|
-
// Command: block test
|
|
60
|
-
// ============================================================================
|
|
61
|
-
|
|
62
|
-
function setupTestCommand(program: Command): void {
|
|
63
|
-
program
|
|
64
|
-
.command("test <manifest-path>")
|
|
65
|
-
.description("Test a Block")
|
|
66
|
-
.action(async (manifestPath: string) => {
|
|
67
|
-
const spinner = ora("Testing Block...").start();
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
const absolutePath = path.resolve(process.cwd(), manifestPath);
|
|
71
|
-
const content = await readFile(absolutePath, { encoding: "utf8" });
|
|
72
|
-
const manifest = JSON.parse(content);
|
|
73
|
-
|
|
74
|
-
// Validate first
|
|
75
|
-
const result = BlockSchema.safeParse(manifest);
|
|
76
|
-
if (!result.success) {
|
|
77
|
-
spinner.fail("Validation failed");
|
|
78
|
-
console.error(chalk.red("Validation errors:"));
|
|
79
|
-
for (const issue of result.error.issues) {
|
|
80
|
-
console.error(` - ${chalk.red(issue.path.join("."))}: ${issue.message}`);
|
|
81
|
-
}
|
|
82
|
-
process.exit(1);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const block = result.data;
|
|
86
|
-
|
|
87
|
-
// Test based on kind
|
|
88
|
-
if (block.kind === "ui") {
|
|
89
|
-
// Test UI Block
|
|
90
|
-
spinner.succeed("UI Block test passed");
|
|
91
|
-
console.log(chalk.gray(`\nBlock: ${block.id}`));
|
|
92
|
-
console.log(chalk.gray(`Has ${block.controls.length} controls`));
|
|
93
|
-
console.log(chalk.gray(`Has ${Object.keys(block.renderers).length} renderers`));
|
|
94
|
-
} else {
|
|
95
|
-
// Test Capability Block
|
|
96
|
-
spinner.succeed("Capability Block test passed");
|
|
97
|
-
console.log(chalk.gray(`\nBlock: ${block.id}`));
|
|
98
|
-
console.log(chalk.gray(`Runtime: ${block.runtime}`));
|
|
99
|
-
console.log(chalk.gray(`Entry: ${block.entryPoint}`));
|
|
100
|
-
}
|
|
101
|
-
} catch (error) {
|
|
102
|
-
spinner.fail(`Failed to test: ${error}`);
|
|
103
|
-
process.exit(1);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// ============================================================================
|
|
109
|
-
// Command: block list
|
|
110
|
-
// ============================================================================
|
|
111
|
-
|
|
112
|
-
function setupListCommand(program: Command): void {
|
|
113
|
-
program
|
|
114
|
-
.command("list")
|
|
115
|
-
.description("List all Blocks in a directory")
|
|
116
|
-
.option("--dir <dir>", "Directory to search", ".")
|
|
117
|
-
.action(async () => {
|
|
118
|
-
const spinner = ora("Searching for Blocks...").start();
|
|
119
|
-
|
|
120
|
-
try {
|
|
121
|
-
// In a real implementation, we would walk the directory tree
|
|
122
|
-
// and find all manifest.json files
|
|
123
|
-
// For now, simulate with a delay
|
|
124
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
125
|
-
|
|
126
|
-
spinner.succeed("Found Blocks");
|
|
127
|
-
console.log(chalk.gray("\nNo Blocks found in current implementation."));
|
|
128
|
-
console.log(chalk.gray("Use 'blkc block validate <path>' to validate a specific Block."));
|
|
129
|
-
} catch (error) {
|
|
130
|
-
spinner.fail(`Failed to list Blocks: ${error}`);
|
|
131
|
-
process.exit(1);
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// ============================================================================
|
|
137
|
-
// Command: block info
|
|
138
|
-
// ============================================================================
|
|
139
|
-
|
|
140
|
-
function setupInfoCommand(program: Command): void {
|
|
141
|
-
program
|
|
142
|
-
.command("info <manifest-path>")
|
|
143
|
-
.description("Show detailed information about a Block")
|
|
144
|
-
.action(async (manifestPath: string) => {
|
|
145
|
-
const spinner = ora("Loading Block info...").start();
|
|
146
|
-
|
|
147
|
-
try {
|
|
148
|
-
const absolutePath = path.resolve(process.cwd(), manifestPath);
|
|
149
|
-
const content = await readFile(absolutePath, { encoding: "utf8" });
|
|
150
|
-
const manifest = JSON.parse(content);
|
|
151
|
-
|
|
152
|
-
const result = BlockSchema.safeParse(manifest);
|
|
153
|
-
if (!result.success) {
|
|
154
|
-
spinner.fail("Invalid Block manifest");
|
|
155
|
-
process.exit(1);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const block = result.data;
|
|
159
|
-
spinner.succeed(`Block: ${block.id}`);
|
|
160
|
-
|
|
161
|
-
console.log(chalk.bold("\nBlock Information"));
|
|
162
|
-
console.log(chalk.gray("─".repeat(40)));
|
|
163
|
-
console.log(chalk.gray(`ID: ${block.id}`));
|
|
164
|
-
console.log(chalk.gray(`Name: ${block.name}`));
|
|
165
|
-
console.log(chalk.gray(`Summary: ${block.summary}`));
|
|
166
|
-
console.log(chalk.gray(`Kind: ${block.kind}`));
|
|
167
|
-
console.log(chalk.gray(`Version: ${block.version}`));
|
|
168
|
-
console.log(chalk.gray(`License: ${block.license}`));
|
|
169
|
-
console.log(chalk.gray(`Visibility: ${block.visibility}`));
|
|
170
|
-
|
|
171
|
-
if (block.tags.length > 0) {
|
|
172
|
-
console.log(chalk.gray(`Tags: ${block.tags.join(", ")}`));
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (block.kind === "ui") {
|
|
176
|
-
console.log(chalk.bold("\nUI Block Details"));
|
|
177
|
-
console.log(chalk.gray("─".repeat(40)));
|
|
178
|
-
console.log(chalk.gray(`Category: ${block.category || "none"}`));
|
|
179
|
-
console.log(chalk.gray(`Controls: ${block.controls.length}`));
|
|
180
|
-
console.log(chalk.gray(`Renderers: ${Object.keys(block.renderers).join(", ")}`));
|
|
181
|
-
console.log(chalk.gray(`Props: ${Object.keys(block.props.properties || {}).length}`));
|
|
182
|
-
} else {
|
|
183
|
-
console.log(chalk.bold("\nCapability Block Details"));
|
|
184
|
-
console.log(chalk.gray("─".repeat(40)));
|
|
185
|
-
console.log(chalk.gray(`Runtime: ${block.runtime}`));
|
|
186
|
-
console.log(chalk.gray(`Entry: ${block.entryPoint}`));
|
|
187
|
-
console.log(chalk.gray(`Size: ${block.sizeMB || "unknown"} MB`));
|
|
188
|
-
console.log(chalk.gray(`Inputs: ${block.inputs.length > 0 ? block.inputs.join(", ") : "none"}`));
|
|
189
|
-
console.log(chalk.gray(`Outputs: ${block.outputs.length > 0 ? block.outputs.join(", ") : "none"}`));
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (block.repository) {
|
|
193
|
-
console.log(chalk.bold("\nRepository"));
|
|
194
|
-
console.log(chalk.gray("─".repeat(40)));
|
|
195
|
-
console.log(chalk.gray(block.repository));
|
|
196
|
-
}
|
|
197
|
-
} catch (error) {
|
|
198
|
-
spinner.fail(`Failed to show info: ${error}`);
|
|
199
|
-
process.exit(1);
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// ============================================================================
|
|
205
|
-
// Register Commands
|
|
206
|
-
// ============================================================================
|
|
207
|
-
|
|
208
|
-
/** Register all block commands with the program */
|
|
209
|
-
export function registerBlockCommands(program: Command): void {
|
|
210
|
-
const blockProgram = program
|
|
211
|
-
.command("block")
|
|
212
|
-
.description("Block commands")
|
|
213
|
-
.alias("b");
|
|
214
|
-
|
|
215
|
-
setupValidateCommand(blockProgram);
|
|
216
|
-
setupTestCommand(blockProgram);
|
|
217
|
-
setupListCommand(blockProgram);
|
|
218
|
-
setupInfoCommand(blockProgram);
|
|
219
|
-
}
|