@blkc-code/cli 0.1.1 → 0.1.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/bin/blkc.js +24 -0
- package/dist/cli.js +24 -0
- package/dist/commands/block.d.ts +12 -1
- package/dist/commands/block.d.ts.map +1 -0
- package/dist/commands/block.js +180 -268
- package/dist/commands/block.js.map +1 -1
- package/dist/commands/circuit.d.ts +12 -1
- package/dist/commands/circuit.d.ts.map +1 -0
- package/dist/commands/circuit.js +146 -152
- package/dist/commands/circuit.js.map +1 -1
- package/dist/commands/deploy.d.ts +14 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +332 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/kit.d.ts +12 -1
- package/dist/commands/kit.d.ts.map +1 -0
- package/dist/commands/kit.js +137 -160
- package/dist/commands/kit.js.map +1 -1
- package/dist/commands/logbook.d.ts +12 -1
- package/dist/commands/logbook.d.ts.map +1 -0
- package/dist/commands/logbook.js +150 -136
- package/dist/commands/logbook.js.map +1 -1
- package/dist/index.d.ts +19 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -34
- package/dist/index.js.map +1 -1
- package/package.json +57 -33
- package/src/__tests__/smoke.test.ts +8 -0
- package/src/commands/block.ts +219 -0
- package/src/commands/circuit.ts +182 -0
- package/src/commands/deploy.ts +373 -0
- package/src/commands/kit.ts +173 -0
- package/src/commands/logbook.ts +194 -0
- package/src/index.ts +70 -0
- package/LICENSE +0 -201
- package/NOTICE +0 -5
- package/README.md +0 -13
- package/dist/utils/filesystem.d.ts +0 -5
- package/dist/utils/filesystem.js +0 -21
- package/dist/utils/filesystem.js.map +0 -1
- package/dist/utils/github.d.ts +0 -23
- package/dist/utils/github.js +0 -66
- package/dist/utils/github.js.map +0 -1
package/dist/commands/logbook.js
CHANGED
|
@@ -1,156 +1,170 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
+
*/
|
|
4
10
|
import chalk from "chalk";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const mergeRecords = (records) => records.reduce((acc, record) => ({ ...acc, ...record }), {});
|
|
20
|
-
const cleanRecord = (record) => Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined && value !== null));
|
|
21
|
-
const buildDataPayload = async (options) => {
|
|
22
|
-
const dataAggregates = [];
|
|
23
|
-
if (options.data && typeof options.data === "string") {
|
|
24
|
-
dataAggregates.push(parseJson(options.data, "--data"));
|
|
25
|
-
}
|
|
26
|
-
if (options.dataFile && typeof options.dataFile === "string") {
|
|
27
|
-
const resolved = path.resolve(options.dataFile);
|
|
28
|
-
dataAggregates.push(await parseJsonFile(resolved));
|
|
29
|
-
}
|
|
30
|
-
if (options.message && typeof options.message === "string") {
|
|
31
|
-
dataAggregates.push({ message: options.message });
|
|
32
|
-
}
|
|
33
|
-
if (dataAggregates.length === 0) {
|
|
34
|
-
return {};
|
|
35
|
-
}
|
|
36
|
-
return mergeRecords(dataAggregates);
|
|
37
|
-
};
|
|
38
|
-
const defaultActorName = () => process.env.BLKC_ACTOR_NAME ?? os.userInfo().username;
|
|
39
|
-
const resolveLogbook = (options) => new Logbook({
|
|
40
|
-
filePath: path.resolve(options.file ?? DEFAULT_LOGBOOK_PATH),
|
|
41
|
-
algorithm: options.algorithm ?? DEFAULT_ALGORITHM,
|
|
42
|
-
});
|
|
43
|
-
const printVerification = (result) => {
|
|
44
|
-
if (result.valid) {
|
|
45
|
-
console.log(chalk.green(`✔ Logbook verified (${result.entries.length} entries)`));
|
|
46
|
-
if (result.lastHash) {
|
|
47
|
-
console.log(chalk.dim(`Last hash: ${result.lastHash}`));
|
|
48
|
-
}
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
console.error(chalk.red("✖ Logbook verification failed"));
|
|
52
|
-
result.issues.forEach((issue) => {
|
|
53
|
-
const context = issue.entry ? chalk.dim(` ${JSON.stringify(issue.entry)}`) : "";
|
|
54
|
-
console.error(chalk.red(` • [${issue.index + 1}] ${issue.message}${context}`));
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
export const registerLogbookCommands = (program) => {
|
|
58
|
-
const logbook = program
|
|
59
|
-
.command("logbook")
|
|
60
|
-
.description("Inspect and update the BLKC logbook")
|
|
61
|
-
.option("-f, --file <path>", "Path to logbook JSONL file", DEFAULT_LOGBOOK_PATH)
|
|
62
|
-
.option("-a, --algorithm <hash>", "Hash algorithm", DEFAULT_ALGORITHM);
|
|
63
|
-
logbook
|
|
64
|
-
.command("append")
|
|
65
|
-
.description("Append a new entry to the logbook")
|
|
66
|
-
.requiredOption("-e, --event <event>", "Event identifier")
|
|
67
|
-
.option("-m, --message <message>", "Optional message stored under data.message")
|
|
68
|
-
.option("-d, --data <json>", "JSON payload merged into entry data")
|
|
69
|
-
.option("--data-file <path>", "Path to JSON file merged into entry data")
|
|
70
|
-
.option("--actor-name <name>", "Actor display name")
|
|
71
|
-
.option("--actor-email <email>", "Actor email")
|
|
72
|
-
.option("--actor-role <role>", "Actor role")
|
|
73
|
-
.option("--timestamp <iso>", "Override timestamp (ISO-8601)")
|
|
74
|
-
.action(async (options, command) => {
|
|
75
|
-
const parentOpts = (command.parent?.opts() ?? {});
|
|
76
|
-
const logbookInstance = resolveLogbook(parentOpts);
|
|
77
|
-
const data = await buildDataPayload(options);
|
|
78
|
-
const actor = cleanRecord({
|
|
79
|
-
name: options.actorName ?? defaultActorName(),
|
|
80
|
-
email: options.actorEmail,
|
|
81
|
-
role: options.actorRole,
|
|
82
|
-
});
|
|
83
|
-
const entry = {
|
|
84
|
-
event: options.event,
|
|
85
|
-
actor: actor,
|
|
86
|
-
data,
|
|
87
|
-
timestamp: options.timestamp,
|
|
88
|
-
};
|
|
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();
|
|
89
25
|
try {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
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
|
+
}
|
|
93
52
|
}
|
|
94
53
|
catch (error) {
|
|
95
|
-
|
|
96
|
-
process.
|
|
54
|
+
spinner.fail(`Failed to verify: ${error}`);
|
|
55
|
+
process.exit(1);
|
|
97
56
|
}
|
|
98
57
|
});
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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();
|
|
105
83
|
try {
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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)}...`));
|
|
110
112
|
}
|
|
111
113
|
}
|
|
112
114
|
catch (error) {
|
|
113
|
-
|
|
114
|
-
process.
|
|
115
|
+
spinner.fail(`Failed to show info: ${error}`);
|
|
116
|
+
process.exit(1);
|
|
115
117
|
}
|
|
116
118
|
});
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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();
|
|
125
130
|
try {
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
console.log(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const idx = entries.length - subset.length + index + 1;
|
|
137
|
-
console.log(chalk.cyan(`#${idx} ${entry.event}`));
|
|
138
|
-
console.log(` actor: ${entry.actor.name}${entry.actor.role ? ` (${entry.actor.role})` : ""}`);
|
|
139
|
-
console.log(` timestamp: ${entry.timestamp}`);
|
|
140
|
-
console.log(` hash: ${entry.hash}`);
|
|
141
|
-
if (entry.prevHash) {
|
|
142
|
-
console.log(` prevHash: ${entry.prevHash}`);
|
|
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}`));
|
|
143
141
|
}
|
|
144
|
-
if (entry.
|
|
145
|
-
console.log(`
|
|
142
|
+
if (entry.hash) {
|
|
143
|
+
console.log(chalk.gray(` Hash: ${entry.hash.substring(0, 16)}...`));
|
|
146
144
|
}
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
}
|
|
146
|
+
if (tailEntries.length === 0) {
|
|
147
|
+
console.log(chalk.gray("\nNo entries found"));
|
|
148
|
+
}
|
|
149
149
|
}
|
|
150
150
|
catch (error) {
|
|
151
|
-
|
|
152
|
-
process.
|
|
151
|
+
spinner.fail(`Failed to tail: ${error}`);
|
|
152
|
+
process.exit(1);
|
|
153
153
|
}
|
|
154
154
|
});
|
|
155
|
-
}
|
|
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
|
+
}
|
|
156
170
|
//# sourceMappingURL=logbook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logbook.js","sourceRoot":"","sources":["../../src/commands/logbook.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E,SAAS,kBAAkB,CAAC,OAAgB;IAC1C,OAAO;SACJ,OAAO,CAAC,oBAAoB,CAAC;SAC7B,W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C,IAAI,CAAC,cAAc,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;gBAClF,CAAC;gBACD,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;oBACf,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;gBACvE,CAAC;YACH,CAAC;YAED,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC7B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,mBAAmB,KAAK,EAAE,CAAC,CAAC;YACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC;AAED,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E,qDAAqD;AACrD,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACtD,MAAM,cAAc,GAAG,OAAO;SAC3B,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,kBAAkB,CAAC;SAC/B,KAAK,CAAC,GAAG,CAAC,CAAC;IAEd,kBAAkB,CAAC,cAAc,CAAC,CAAC;IACnC,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAClC,gBAAgB,CAAC,cAAc,CAAC,CAAC;IACjC,gBAAgB,CAAC,cAAc,CAAC,CAAC;AACnC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
|
|
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
|
+
*/
|
|
2
11
|
import { Command } from "commander";
|
|
12
|
+
/**
|
|
13
|
+
* The main BLKC CLI program.
|
|
14
|
+
*/
|
|
3
15
|
export declare const program: Command;
|
|
4
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Run the CLI.
|
|
18
|
+
*/
|
|
19
|
+
export declare function run(): Promise<void>;
|
|
20
|
+
export default program;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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
CHANGED
|
@@ -1,52 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
+
*/
|
|
5
11
|
import { Command } from "commander";
|
|
6
|
-
import { registerBlockCommands } from "./commands/block";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { registerLogbookCommands } from "./commands/logbook";
|
|
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
|
+
*/
|
|
10
20
|
export const program = new Command();
|
|
21
|
+
// Configure the CLI
|
|
11
22
|
program
|
|
12
23
|
.name("blkc")
|
|
13
|
-
.description("BLKC developer CLI")
|
|
24
|
+
.description("BLKC developer CLI - Tools for working with Blocks, Kits, Circuits, and Logbook")
|
|
14
25
|
.version("0.1.0");
|
|
26
|
+
// Show help after errors
|
|
15
27
|
program.showHelpAfterError();
|
|
28
|
+
// Configure output to prevent duplicate errors
|
|
16
29
|
program.configureOutput({
|
|
17
30
|
outputError: (str) => {
|
|
18
|
-
//
|
|
19
|
-
|
|
31
|
+
// Only print the error if it's not already been handled
|
|
32
|
+
if (str && !str.includes("error:")) {
|
|
33
|
+
console.error(str.trim());
|
|
34
|
+
}
|
|
20
35
|
},
|
|
21
36
|
});
|
|
37
|
+
// Register all command groups
|
|
22
38
|
registerBlockCommands(program);
|
|
23
|
-
registerCircuitCommands(program);
|
|
24
39
|
registerKitCommands(program);
|
|
40
|
+
registerCircuitCommands(program);
|
|
25
41
|
registerLogbookCommands(program);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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);
|
|
30
51
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return realpathSync(file);
|
|
52
|
+
catch (error) {
|
|
53
|
+
if (error instanceof Error) {
|
|
54
|
+
console.error(`Error: ${error.message}`);
|
|
35
55
|
}
|
|
36
|
-
|
|
37
|
-
|
|
56
|
+
else {
|
|
57
|
+
console.error("An unknown error occurred");
|
|
38
58
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
export const run = async () => {
|
|
43
|
-
await program.parseAsync(process.argv);
|
|
44
|
-
};
|
|
45
|
-
if (isDirectExecution()) {
|
|
46
|
-
run().catch((error) => {
|
|
47
|
-
// eslint-disable-next-line no-console
|
|
48
|
-
console.error(error instanceof Error ? error.message : error);
|
|
49
|
-
process.exitCode = 1;
|
|
50
|
-
});
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
51
61
|
}
|
|
62
|
+
// Export for bin usage
|
|
63
|
+
export default program;
|
|
52
64
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";
|
|
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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/cli",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"license": "Apache-2.0",
|
|
3
|
+
"version": "0.1.2",
|
|
5
4
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
"blkc": "dist/index.js"
|
|
8
|
-
},
|
|
5
|
+
"description": "BLKC developer CLI tools",
|
|
9
6
|
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.mjs",
|
|
10
8
|
"types": "dist/index.d.ts",
|
|
9
|
+
"bin": {
|
|
10
|
+
"blkc": "dist/cli.js"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"require": "./dist/index.js",
|
|
15
|
+
"import": "./dist/index.mjs",
|
|
16
|
+
"types": "./dist/index.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
11
19
|
"files": [
|
|
12
20
|
"dist",
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"README.md"
|
|
21
|
+
"src",
|
|
22
|
+
"bin"
|
|
16
23
|
],
|
|
17
24
|
"scripts": {
|
|
18
|
-
"build": "tsc
|
|
19
|
-
"
|
|
20
|
-
"typecheck": "tsc --noEmit
|
|
21
|
-
"lint": "eslint
|
|
22
|
-
"test": "vitest",
|
|
23
|
-
"
|
|
25
|
+
"build": "tsc && cp bin/blkc.js dist/cli.js",
|
|
26
|
+
"build:watch": "tsc -w",
|
|
27
|
+
"typecheck": "tsc --noEmit",
|
|
28
|
+
"lint": "eslint src --ext .ts",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"test:watch": "vitest",
|
|
31
|
+
"test:coverage": "vitest run --coverage",
|
|
32
|
+
"clean": "rm -rf dist"
|
|
24
33
|
},
|
|
25
34
|
"dependencies": {
|
|
26
|
-
"@blkc-code/core": "0.1.
|
|
27
|
-
"@blkc-code/logbook": "0.1.
|
|
28
|
-
"@
|
|
35
|
+
"@blkc-code/core": "^0.1.0",
|
|
36
|
+
"@blkc-code/logbook": "^0.1.0",
|
|
37
|
+
"@modelcontextprotocol/sdk": "^1.32.0",
|
|
29
38
|
"chalk": "^5.3.0",
|
|
30
39
|
"commander": "^12.1.0",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"ora": "^8.0.1"
|
|
40
|
+
"inquirer": "^12.0.0",
|
|
41
|
+
"ora": "^8.1.0"
|
|
34
42
|
},
|
|
35
43
|
"devDependencies": {
|
|
36
|
-
"@types/
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
},
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
"@types/inquirer": "^9.0.7",
|
|
45
|
+
"@types/node": "^22.9.0",
|
|
46
|
+
"@types/react": "^19.3.0",
|
|
47
|
+
"typescript": "^5.9.3",
|
|
48
|
+
"vitest": "^5.1.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"typescript": "^5.9.3"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=22.0.0"
|
|
55
|
+
},
|
|
56
|
+
"keywords": [
|
|
57
|
+
"blkc",
|
|
58
|
+
"cli",
|
|
59
|
+
"developer-tools",
|
|
60
|
+
"command-line"
|
|
61
|
+
],
|
|
62
|
+
"author": "Black Code Enterprises LLC",
|
|
63
|
+
"license": "Apache-2.0",
|
|
64
|
+
"repository": {
|
|
65
|
+
"type": "git",
|
|
66
|
+
"url": "git+https://github.com/blkc-community/blkc.git",
|
|
67
|
+
"directory": "packages/cli"
|
|
68
|
+
},
|
|
69
|
+
"bugs": {
|
|
70
|
+
"url": "https://github.com/blkc-community/blkc/issues"
|
|
71
|
+
},
|
|
72
|
+
"homepage": "https://blkc.community"
|
|
49
73
|
}
|