@jotx-labs/cli 2.4.130 → 2.4.131

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/cli.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * jotx CLI - Demonstrates platform independence
4
+ * Uses @jotx-labs/core + NodePlatform
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;GAGG"}
package/dist/cli.js ADDED
@@ -0,0 +1,196 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * jotx CLI - Demonstrates platform independence
5
+ * Uses @jotx-labs/core + NodePlatform
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ const commander_1 = require("commander");
42
+ const fs = __importStar(require("fs/promises"));
43
+ const core_1 = require("@jotx-labs/core");
44
+ const adapters_1 = require("@jotx-labs/adapters");
45
+ const renderer = new adapters_1.HTMLRenderer();
46
+ const program = new commander_1.Command();
47
+ program
48
+ .name('jotx')
49
+ .description('jotx CLI - Parse, validate, and convert jotx files')
50
+ .version('2.4.130');
51
+ // Parse command
52
+ program
53
+ .command('parse <file>')
54
+ .description('Parse a .jot file and show AST')
55
+ .action(async (file) => {
56
+ try {
57
+ const text = await fs.readFile(file, 'utf-8');
58
+ const result = (0, core_1.parseAndValidate)(text);
59
+ if (result.isValid) {
60
+ console.log('✅ Parse successful!');
61
+ console.log(JSON.stringify(result.ast, null, 2));
62
+ }
63
+ else {
64
+ console.error('❌ Parse failed:');
65
+ result.errors.forEach((err) => {
66
+ console.error(` - ${err.message}`);
67
+ });
68
+ process.exit(1);
69
+ }
70
+ }
71
+ catch (error) {
72
+ console.error('❌ Error:', error);
73
+ process.exit(1);
74
+ }
75
+ });
76
+ // Validate command
77
+ program
78
+ .command('validate <file>')
79
+ .description('Validate a .jot file')
80
+ .action(async (file) => {
81
+ try {
82
+ const text = await fs.readFile(file, 'utf-8');
83
+ const result = (0, core_1.parseAndValidate)(text);
84
+ if (result.isValid) {
85
+ console.log(`✅ ${file} is valid!`);
86
+ console.log(` Document: ${result.ast.document.id}`);
87
+ console.log(` Type: ${result.ast.document.type}`);
88
+ console.log(` Blocks: ${result.ast.document.blocks.length}`);
89
+ }
90
+ else {
91
+ console.error(`❌ ${file} has errors:`);
92
+ result.errors.forEach((err) => {
93
+ console.error(` - ${err.message}`);
94
+ });
95
+ process.exit(1);
96
+ }
97
+ }
98
+ catch (error) {
99
+ console.error('❌ Error:', error);
100
+ process.exit(1);
101
+ }
102
+ });
103
+ // Convert command
104
+ program
105
+ .command('convert <file>')
106
+ .description('Convert .jot file to HTML')
107
+ .option('-o, --output <file>', 'Output file (default: stdout)')
108
+ .action(async (file, options) => {
109
+ try {
110
+ const text = await fs.readFile(file, 'utf-8');
111
+ const result = (0, core_1.parseAndValidate)(text);
112
+ if (!result.isValid) {
113
+ console.error('❌ File has errors:');
114
+ result.errors.forEach((err) => {
115
+ console.error(` - ${err.message}`);
116
+ });
117
+ process.exit(1);
118
+ }
119
+ // Render to HTML
120
+ const html = renderer.render({
121
+ id: result.ast.document.id,
122
+ type: result.ast.document.type,
123
+ metadata: result.ast.document.metadata,
124
+ blocks: result.ast.document.blocks
125
+ });
126
+ // Wrap in full HTML document
127
+ const title = result.ast.document.metadata?.title || 'jotx Document';
128
+ const fullHtml = `<!DOCTYPE html>
129
+ <html lang="en">
130
+ <head>
131
+ <meta charset="UTF-8">
132
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
133
+ <title>${title}</title>
134
+ <style>
135
+ body { font-family: system-ui, -apple-system, sans-serif; max-width: 800px; margin: 40px auto; padding: 0 20px; }
136
+ h1 { font-size: 2em; margin-bottom: 0.5em; }
137
+ h2 { font-size: 1.5em; margin-top: 1.5em; }
138
+ h3 { font-size: 1.2em; margin-top: 1.2em; }
139
+ code { background: #f5f5f5; padding: 2px 6px; border-radius: 3px; }
140
+ pre { background: #f5f5f5; padding: 16px; border-radius: 6px; overflow-x: auto; }
141
+ blockquote { border-left: 4px solid #ddd; padding-left: 16px; margin-left: 0; color: #666; }
142
+ </style>
143
+ </head>
144
+ <body>
145
+ ${html}
146
+ </body>
147
+ </html>`;
148
+ if (options.output) {
149
+ await fs.writeFile(options.output, fullHtml, 'utf-8');
150
+ console.log(`✅ Converted to ${options.output}`);
151
+ }
152
+ else {
153
+ console.log(fullHtml);
154
+ }
155
+ }
156
+ catch (error) {
157
+ console.error('❌ Error:', error);
158
+ process.exit(1);
159
+ }
160
+ });
161
+ // Info command
162
+ program
163
+ .command('info <file>')
164
+ .description('Show document information')
165
+ .action(async (file) => {
166
+ try {
167
+ const text = await fs.readFile(file, 'utf-8');
168
+ const result = (0, core_1.parseAndValidate)(text);
169
+ if (!result.isValid) {
170
+ console.error('❌ File has errors');
171
+ process.exit(1);
172
+ }
173
+ const doc = result.ast.document;
174
+ console.log('📄 Document Information');
175
+ console.log('─'.repeat(50));
176
+ console.log(`ID: ${doc.id}`);
177
+ console.log(`Type: ${doc.type}`);
178
+ console.log(`Title: ${doc.metadata?.title || '(none)'}`);
179
+ console.log(`Blocks: ${doc.blocks.length}`);
180
+ console.log();
181
+ console.log('Block Types:');
182
+ const blockCounts = {};
183
+ doc.blocks.forEach((block) => {
184
+ blockCounts[block.type] = (blockCounts[block.type] || 0) + 1;
185
+ });
186
+ Object.entries(blockCounts).forEach(([type, count]) => {
187
+ console.log(` - ${type}: ${count}`);
188
+ });
189
+ }
190
+ catch (error) {
191
+ console.error('❌ Error:', error);
192
+ process.exit(1);
193
+ }
194
+ });
195
+ program.parse();
196
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AACA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yCAAmC;AACnC,gDAAiC;AAEjC,0CAAiG;AACjG,kDAAkD;AAElD,MAAM,QAAQ,GAAG,IAAI,uBAAY,EAAE,CAAA;AAEnC,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAA;AAE7B,OAAO;KACJ,IAAI,CAAC,MAAM,CAAC;KACZ,WAAW,CAAC,oDAAoD,CAAC;KACjE,OAAO,CAAC,SAAS,CAAC,CAAA;AAErB,gBAAgB;AAChB,OAAO;KACJ,OAAO,CAAC,cAAc,CAAC;KACvB,WAAW,CAAC,gCAAgC,CAAC;KAC7C,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,EAA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