@ozsarman/clarityjs 0.6.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 +178 -0
- package/package.json +168 -0
- package/src/analyze.js +534 -0
- package/src/async-state.js +555 -0
- package/src/bundle-runtime.js +35 -0
- package/src/clarity-bundle.js +332 -0
- package/src/clarity-test.js +622 -0
- package/src/cli.js +453 -0
- package/src/codegen.js +1934 -0
- package/src/dev-server.js +362 -0
- package/src/devtools.js +765 -0
- package/src/edge.js +606 -0
- package/src/error-overlay.js +535 -0
- package/src/file-conventions.js +472 -0
- package/src/font.js +513 -0
- package/src/game-loop.js +106 -0
- package/src/head.js +393 -0
- package/src/hydrate.js +292 -0
- package/src/i18n.js +403 -0
- package/src/image.js +352 -0
- package/src/index.js +193 -0
- package/src/islands.js +284 -0
- package/src/isr.js +306 -0
- package/src/layout.js +342 -0
- package/src/lexer.js +572 -0
- package/src/linter.js +547 -0
- package/src/pages-router.js +229 -0
- package/src/parser.js +1108 -0
- package/src/router.js +732 -0
- package/src/runtime.js +1465 -0
- package/src/scoped-css.js +641 -0
- package/src/server-actions.js +439 -0
- package/src/server-data.js +225 -0
- package/src/sourcemap.js +130 -0
- package/src/ssg.js +310 -0
- package/src/ssr.js +621 -0
- package/src/store.js +276 -0
- package/src/transitions.js +438 -0
- package/src/ts-plugin.js +613 -0
- package/src/typegen.js +240 -0
- package/src/vite-plugin.js +447 -0
- package/types/index.d.ts +366 -0
package/src/cli.js
ADDED
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Clarity.js CLI
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* clarity build <file.clarity> — compile a single file
|
|
7
|
+
* clarity build <dir/> — compile all .clarity files in a directory
|
|
8
|
+
* clarity check <file.clarity> — typecheck / lint without emitting
|
|
9
|
+
* clarity demo — print a demo compilation
|
|
10
|
+
*
|
|
11
|
+
* Author: Claude (Anthropic)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { readFileSync, writeFileSync, readdirSync, statSync, mkdirSync } from 'fs';
|
|
15
|
+
import { join, dirname, basename, extname } from 'path';
|
|
16
|
+
import { compile } from './index.js';
|
|
17
|
+
import { startDevServer } from './dev-server.js';
|
|
18
|
+
import { bundle } from './clarity-bundle.js';
|
|
19
|
+
import { formatCode, formatFile, lintCode, lintFile, processDirectory, formatLintReport, loadConfig } from './linter.js';
|
|
20
|
+
import { generateStaticSite } from './ssg.js';
|
|
21
|
+
import { analyzeBundle } from './analyze.js';
|
|
22
|
+
|
|
23
|
+
// ─── Colors ──────────────────────────────────────────────────────────────────
|
|
24
|
+
const c = {
|
|
25
|
+
reset: '\x1b[0m',
|
|
26
|
+
bold: '\x1b[1m',
|
|
27
|
+
dim: '\x1b[2m',
|
|
28
|
+
green: '\x1b[32m',
|
|
29
|
+
blue: '\x1b[34m',
|
|
30
|
+
yellow: '\x1b[33m',
|
|
31
|
+
red: '\x1b[31m',
|
|
32
|
+
cyan: '\x1b[36m',
|
|
33
|
+
white: '\x1b[37m',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function log(msg) { console.log(msg); }
|
|
37
|
+
function ok(msg) { console.log(`${c.green}✓${c.reset} ${msg}`); }
|
|
38
|
+
function info(msg) { console.log(`${c.blue}ℹ${c.reset} ${msg}`); }
|
|
39
|
+
function warn(msg) { console.log(`${c.yellow}⚠${c.reset} ${msg}`); }
|
|
40
|
+
function err(msg) { console.error(`${c.red}✗${c.reset} ${msg}`); }
|
|
41
|
+
function header(msg) { console.log(`\n${c.bold}${c.cyan}${msg}${c.reset}`); }
|
|
42
|
+
|
|
43
|
+
// ─── Banner ───────────────────────────────────────────────────────────────────
|
|
44
|
+
function printBanner() {
|
|
45
|
+
console.log(`
|
|
46
|
+
${c.bold}${c.cyan} ╔═══════════════════════════════════╗
|
|
47
|
+
║ CLARITY.JS v0.5.0 ║
|
|
48
|
+
║ AI-Native UI Framework ║
|
|
49
|
+
║ by Claude (Anthropic) ║
|
|
50
|
+
╚═══════════════════════════════════╝${c.reset}
|
|
51
|
+
`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ─── Commands ─────────────────────────────────────────────────────────────────
|
|
55
|
+
function cmdBuild(target) {
|
|
56
|
+
let files = [];
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const stat = statSync(target);
|
|
60
|
+
if (stat.isDirectory()) {
|
|
61
|
+
files = readdirSync(target)
|
|
62
|
+
.filter(f => f.endsWith('.clarity'))
|
|
63
|
+
.map(f => join(target, f));
|
|
64
|
+
} else {
|
|
65
|
+
files = [target];
|
|
66
|
+
}
|
|
67
|
+
} catch (_) {
|
|
68
|
+
err(`Cannot read: ${target}`);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (files.length === 0) {
|
|
73
|
+
warn(`No .clarity files found in: ${target}`);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
header(`Building ${files.length} file(s)...`);
|
|
78
|
+
let success = 0, failed = 0;
|
|
79
|
+
|
|
80
|
+
for (const file of files) {
|
|
81
|
+
const src = readFileSync(file, 'utf8');
|
|
82
|
+
try {
|
|
83
|
+
const { code } = compile(src, { filename: file, runtimePath: './clarity-runtime.js' });
|
|
84
|
+
const outFile = file.replace(/\.clarity$/, '.js');
|
|
85
|
+
writeFileSync(outFile, code, 'utf8');
|
|
86
|
+
ok(`${basename(file)} → ${basename(outFile)} (${code.length} bytes)`);
|
|
87
|
+
success++;
|
|
88
|
+
} catch (e) {
|
|
89
|
+
err(`${basename(file)}: ${e.message}`);
|
|
90
|
+
failed++;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
log('');
|
|
95
|
+
log(`${c.dim}Results: ${c.green}${success} ok${c.reset}${c.dim}, ${failed > 0 ? c.red : ''}${failed} failed${c.reset}`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function cmdCheck(file) {
|
|
99
|
+
header(`Checking ${file}...`);
|
|
100
|
+
const src = readFileSync(file, 'utf8');
|
|
101
|
+
try {
|
|
102
|
+
const { ast, tokens } = compile(src, { filename: file });
|
|
103
|
+
ok(`No errors found`);
|
|
104
|
+
info(`${tokens.length} tokens, ${ast.components.length} component(s)`);
|
|
105
|
+
for (const comp of ast.components) {
|
|
106
|
+
const stateCount = comp.body.filter(n => n.type === 'StateDecl').length;
|
|
107
|
+
const effectCount = comp.body.filter(n => n.type === 'EffectDecl').length;
|
|
108
|
+
const hasRender = comp.body.some(n => n.type === 'RenderBlock');
|
|
109
|
+
info(` ${c.bold}${comp.name}${c.reset} — ${stateCount} state, ${effectCount} effects, render: ${hasRender ? 'yes' : 'no'}`);
|
|
110
|
+
}
|
|
111
|
+
} catch (e) {
|
|
112
|
+
err(e.message);
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function cmdDemo() {
|
|
118
|
+
printBanner();
|
|
119
|
+
header('Demo: Compiling a Counter component');
|
|
120
|
+
|
|
121
|
+
const source = `
|
|
122
|
+
component Counter() {
|
|
123
|
+
state count = 0
|
|
124
|
+
|
|
125
|
+
render {
|
|
126
|
+
<div class="counter">
|
|
127
|
+
<h1>{ count }</h1>
|
|
128
|
+
<button on:click={ count++ }>Artir</button>
|
|
129
|
+
<button on:click={ count-- }>Azalt</button>
|
|
130
|
+
</div>
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
`.trim();
|
|
134
|
+
|
|
135
|
+
log(`\n${c.dim}// Source (.clarity):${c.reset}`);
|
|
136
|
+
log(c.yellow + source + c.reset);
|
|
137
|
+
|
|
138
|
+
try {
|
|
139
|
+
const { code, tokens, ast } = compile(source, { filename: 'demo.clarity' });
|
|
140
|
+
log(`\n${c.dim}// Generated JavaScript:${c.reset}`);
|
|
141
|
+
log(c.green + code + c.reset);
|
|
142
|
+
log(`\n${c.dim}Tokens: ${tokens.length} | AST nodes: ${JSON.stringify(ast).length} chars${c.reset}`);
|
|
143
|
+
} catch (e) {
|
|
144
|
+
err(`Compilation failed: ${e.message}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function cmdAst(file) {
|
|
149
|
+
header(`AST for ${file}`);
|
|
150
|
+
const src = readFileSync(file, 'utf8');
|
|
151
|
+
try {
|
|
152
|
+
const { ast } = compile(src, { filename: file });
|
|
153
|
+
log(JSON.stringify(ast, null, 2));
|
|
154
|
+
} catch (e) {
|
|
155
|
+
err(e.message);
|
|
156
|
+
process.exit(1);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function cmdTypes(file) {
|
|
161
|
+
header(`Generating types for ${file}`);
|
|
162
|
+
const src = readFileSync(file, 'utf8');
|
|
163
|
+
try {
|
|
164
|
+
const { dts, ast } = compile(src, { filename: file, types: true });
|
|
165
|
+
const outFile = file.replace(/\.clarity$/, '.d.ts');
|
|
166
|
+
writeFileSync(outFile, dts, 'utf8');
|
|
167
|
+
ok(`${basename(file)} → ${basename(outFile)} (${dts.length} bytes)`);
|
|
168
|
+
info(`${ast.components.length} component type(s) generated`);
|
|
169
|
+
for (const comp of ast.components) {
|
|
170
|
+
const hasProps = comp.params.length > 0;
|
|
171
|
+
info(` ${c.bold}${comp.name}${c.reset}${hasProps ? ` — ${comp.params.length} prop(s)` : ''}`);
|
|
172
|
+
}
|
|
173
|
+
} catch (e) {
|
|
174
|
+
err(e.message);
|
|
175
|
+
process.exit(1);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function cmdBundle(args) {
|
|
180
|
+
// Parse: clarity bundle <entry> [--out dist/bundle.js] [--minify] [--watch] [--prod]
|
|
181
|
+
const entry = args.find(a => !a.startsWith('--'));
|
|
182
|
+
const outIdx = args.indexOf('--out');
|
|
183
|
+
const outfile = outIdx >= 0 && args[outIdx + 1] ? args[outIdx + 1] : 'dist/bundle.js';
|
|
184
|
+
const minify = args.includes('--minify') || args.includes('--prod');
|
|
185
|
+
const watch = args.includes('--watch');
|
|
186
|
+
const mode = (minify || args.includes('--prod')) ? 'production' : 'development';
|
|
187
|
+
|
|
188
|
+
if (!entry) {
|
|
189
|
+
err('Usage: clarity bundle <entry.js> [--out dist/bundle.js] [--minify] [--watch]');
|
|
190
|
+
process.exit(1);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
bundle({
|
|
194
|
+
entry: entry,
|
|
195
|
+
projectDir: process.cwd(),
|
|
196
|
+
outfile,
|
|
197
|
+
minify,
|
|
198
|
+
watch,
|
|
199
|
+
mode,
|
|
200
|
+
sourcemap: !minify,
|
|
201
|
+
}).then(({ ok }) => {
|
|
202
|
+
if (!ok && !watch) process.exit(1);
|
|
203
|
+
}).catch(e => {
|
|
204
|
+
err(e.message);
|
|
205
|
+
process.exit(1);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async function cmdFormat(args) {
|
|
210
|
+
// clarity format [target] [--check] [--stdin] [--write]
|
|
211
|
+
const check = args.includes('--check');
|
|
212
|
+
const stdin = args.includes('--stdin');
|
|
213
|
+
const target = args.find(a => !a.startsWith('--')) ?? '.';
|
|
214
|
+
|
|
215
|
+
if (stdin) {
|
|
216
|
+
// stdin → stdout: editör pipe desteği
|
|
217
|
+
let input = '';
|
|
218
|
+
process.stdin.setEncoding('utf8');
|
|
219
|
+
process.stdin.on('data', d => input += d);
|
|
220
|
+
process.stdin.on('end', () => {
|
|
221
|
+
process.stdout.write(formatCode(input));
|
|
222
|
+
});
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
let stat;
|
|
227
|
+
try { stat = statSync(target); } catch {
|
|
228
|
+
err(`Dosya/dizin bulunamadı: ${target}`);
|
|
229
|
+
process.exit(1);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (stat.isDirectory()) {
|
|
233
|
+
header(`Formatting ${target}/**/*.clarity...`);
|
|
234
|
+
const results = await processDirectory(target, 'format', { write: !check });
|
|
235
|
+
const changed = results.filter(r => r.changed).length;
|
|
236
|
+
const total = results.length;
|
|
237
|
+
|
|
238
|
+
if (check) {
|
|
239
|
+
if (changed > 0) {
|
|
240
|
+
warn(`${changed}/${total} dosya biçimlendirme gerektiriyor.`);
|
|
241
|
+
process.exit(1);
|
|
242
|
+
} else {
|
|
243
|
+
ok(`Tüm ${total} dosya doğru biçimlendirilmiş.`);
|
|
244
|
+
}
|
|
245
|
+
} else {
|
|
246
|
+
ok(`${changed} dosya biçimlendirildi (${total} toplam).`);
|
|
247
|
+
}
|
|
248
|
+
} else {
|
|
249
|
+
const { changed, content } = await formatFile(target, { write: !check });
|
|
250
|
+
if (check) {
|
|
251
|
+
if (changed) { warn(`${target} biçimlendirme gerektiriyor.`); process.exit(1); }
|
|
252
|
+
else ok(`${target} doğru biçimlendirilmiş.`);
|
|
253
|
+
} else {
|
|
254
|
+
if (changed) ok(`${target} biçimlendirildi.`);
|
|
255
|
+
else info(`${target} zaten doğru biçimde.`);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
async function cmdLint(args) {
|
|
261
|
+
// clarity lint [target] [--fix] [--rule <name>] [--format json|compact|pretty]
|
|
262
|
+
const fix = args.includes('--fix');
|
|
263
|
+
const fmtIdx = args.indexOf('--format');
|
|
264
|
+
const fmtMode = fmtIdx >= 0 ? args[fmtIdx + 1] : 'pretty';
|
|
265
|
+
const ruleIdx = args.indexOf('--rule');
|
|
266
|
+
const ruleOverride = ruleIdx >= 0 ? args[ruleIdx + 1] : null;
|
|
267
|
+
const target = args.find(a => !a.startsWith('--')) ?? '.';
|
|
268
|
+
|
|
269
|
+
let stat;
|
|
270
|
+
try { stat = statSync(target); } catch {
|
|
271
|
+
err(`Dosya/dizin bulunamadı: ${target}`);
|
|
272
|
+
process.exit(1);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const config = await loadConfig();
|
|
276
|
+
const ruleOpts = ruleOverride
|
|
277
|
+
? { ...config.rules, [ruleOverride]: 'error' }
|
|
278
|
+
: config.rules;
|
|
279
|
+
|
|
280
|
+
let results = [];
|
|
281
|
+
|
|
282
|
+
if (stat.isDirectory()) {
|
|
283
|
+
header(`Linting ${target}/**/*.clarity...`);
|
|
284
|
+
results = await processDirectory(target, 'lint', { fix, rules: ruleOpts });
|
|
285
|
+
} else {
|
|
286
|
+
results = [await lintFile(target, { fix, rules: ruleOpts })];
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const report = formatLintReport(results, fmtMode);
|
|
290
|
+
log(report);
|
|
291
|
+
|
|
292
|
+
const totalErrors = results.reduce((s, r) => s + (r.errorCount ?? 0), 0);
|
|
293
|
+
if (fix) {
|
|
294
|
+
const fixed = results.filter(r => r.fixed).length;
|
|
295
|
+
if (fixed > 0) ok(`${fixed} dosyada otomatik düzeltme yapıldı.`);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (totalErrors > 0) process.exit(1);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
async function cmdSsg(args) {
|
|
302
|
+
// clarity ssg [pagesDir] [--out <outDir>] [--base <url>] [--concurrent N] [--verbose]
|
|
303
|
+
const outIdx = args.indexOf('--out');
|
|
304
|
+
const baseIdx = args.indexOf('--base');
|
|
305
|
+
const concIdx = args.indexOf('--concurrent');
|
|
306
|
+
const outDir = outIdx >= 0 && args[outIdx + 1] ? args[outIdx + 1] : 'dist';
|
|
307
|
+
const baseUrl = baseIdx >= 0 && args[baseIdx + 1] ? args[baseIdx + 1] : '';
|
|
308
|
+
const concurrent = concIdx >= 0 && args[concIdx + 1] ? parseInt(args[concIdx + 1], 10) : 4;
|
|
309
|
+
const verbose = args.includes('--verbose') || args.includes('-v');
|
|
310
|
+
const pagesDir = args.find(a => !a.startsWith('--')) ?? 'pages';
|
|
311
|
+
|
|
312
|
+
header(`Generating static site → ${outDir}/`);
|
|
313
|
+
info(`Pages: ${pagesDir} | Concurrent: ${concurrent}${baseUrl ? ' | Base: ' + baseUrl : ''}`);
|
|
314
|
+
|
|
315
|
+
try {
|
|
316
|
+
const result = await generateStaticSite({
|
|
317
|
+
pagesDir,
|
|
318
|
+
outDir,
|
|
319
|
+
baseUrl,
|
|
320
|
+
concurrent,
|
|
321
|
+
verbose,
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
const { pages = [], duration = 0, errors = [] } = result ?? {};
|
|
325
|
+
|
|
326
|
+
log('');
|
|
327
|
+
if (errors.length > 0) {
|
|
328
|
+
for (const e of errors) err(` ${e.path ?? e.file ?? '?'}: ${e.message ?? e}`);
|
|
329
|
+
warn(`${pages.length} page(s) generated, ${errors.length} error(s) — ${duration}ms`);
|
|
330
|
+
process.exit(1);
|
|
331
|
+
} else {
|
|
332
|
+
ok(`${pages.length} page(s) generated in ${duration}ms`);
|
|
333
|
+
if (verbose) for (const p of pages) info(` → ${p}`);
|
|
334
|
+
}
|
|
335
|
+
} catch (e) {
|
|
336
|
+
err(`SSG failed: ${e.message}`);
|
|
337
|
+
if (verbose) console.error(e);
|
|
338
|
+
process.exit(1);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
async function cmdAnalyze(args) {
|
|
343
|
+
// clarity analyze [distDir] [--json] [--open] [--out path] [--verbose]
|
|
344
|
+
const distDir = args.find(a => !a.startsWith('--')) ?? 'dist';
|
|
345
|
+
const outIdx = args.indexOf('--out');
|
|
346
|
+
const outFile = outIdx >= 0 && args[outIdx + 1] ? args[outIdx + 1] : 'clarity-analyze.html';
|
|
347
|
+
const openBrowser = args.includes('--open');
|
|
348
|
+
const emitJson = args.includes('--json');
|
|
349
|
+
const verbose = args.includes('--verbose') || args.includes('-v');
|
|
350
|
+
|
|
351
|
+
header(`Analysing bundle in ${distDir}/...`);
|
|
352
|
+
|
|
353
|
+
try {
|
|
354
|
+
const report = await analyzeBundle({
|
|
355
|
+
distDir,
|
|
356
|
+
outFile,
|
|
357
|
+
open: openBrowser,
|
|
358
|
+
json: emitJson,
|
|
359
|
+
verbose: true,
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
ok(`Report generated → ${outFile}`);
|
|
363
|
+
info(`Total: ${(report.total / 1024).toFixed(1)} KB | JS: ${(report.totalJS / 1024).toFixed(1)} KB | ${report.fileCount} files`);
|
|
364
|
+
|
|
365
|
+
if (report.chunks.length > 0) {
|
|
366
|
+
info('Top 5 chunks:');
|
|
367
|
+
for (const c of report.chunks.slice(0, 5)) {
|
|
368
|
+
const bar = '▓'.repeat(Math.max(1, Math.round(c.size / report.chunks[0].size * 15)));
|
|
369
|
+
log(` ${bar.padEnd(15)} ${((c.size)/1024).toFixed(1).padStart(6)} KB ${c.name}`);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (openBrowser) info('Opening in browser…');
|
|
374
|
+
} catch (e) {
|
|
375
|
+
err(e.message);
|
|
376
|
+
process.exit(1);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function cmdDev(args) {
|
|
381
|
+
// Parse: clarity dev [dir] [--port N] [--open]
|
|
382
|
+
let dir = process.cwd();
|
|
383
|
+
let port = 3000;
|
|
384
|
+
let open = false;
|
|
385
|
+
|
|
386
|
+
for (let i = 0; i < args.length; i++) {
|
|
387
|
+
if (args[i] === '--port' && args[i + 1]) { port = parseInt(args[i + 1], 10); i++; }
|
|
388
|
+
else if (args[i] === '--open') { open = true; }
|
|
389
|
+
else if (!args[i].startsWith('--')) { dir = args[i]; }
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
startDevServer({ dir, port, open });
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function cmdHelp() {
|
|
396
|
+
printBanner();
|
|
397
|
+
log(`${c.bold}Usage:${c.reset}`);
|
|
398
|
+
log(` clarity dev [dir] [--port N] [--open] Start dev server with HMR`);
|
|
399
|
+
log(` clarity bundle <entry.js> [--out dist/] [--minify] [--watch] [--prod] Bundle for production`);
|
|
400
|
+
log(` clarity build <file.clarity> Compile a .clarity file to .js`);
|
|
401
|
+
log(` clarity build <directory/> Compile all .clarity files in a directory`);
|
|
402
|
+
log(` clarity ssg [pagesDir] [--out dist] Generate static HTML for all pages`);
|
|
403
|
+
log(` clarity analyze [dist] [--open] [--json] [--out report.html] Bundle size report`);;
|
|
404
|
+
log(` clarity ssg --base https://mysite.com --concurrent 8 Custom base URL & concurrency`);
|
|
405
|
+
log(` clarity check <file.clarity> Check for errors without emitting`);
|
|
406
|
+
log(` clarity format [dir|file] [--check] Format .clarity files (--check: CI mode)`);
|
|
407
|
+
log(` clarity format --stdin Read from stdin, write to stdout`);
|
|
408
|
+
log(` clarity lint [dir|file] [--fix] Lint .clarity files`);
|
|
409
|
+
log(` clarity lint --rule <name> [dir|file] Run a specific rule`);
|
|
410
|
+
log(` clarity lint --format json JSON output`);
|
|
411
|
+
log(` clarity types <file.clarity> Generate TypeScript .d.ts declarations`);
|
|
412
|
+
log(` clarity ast <file.clarity> Print the AST as JSON`);
|
|
413
|
+
log(` clarity demo Run a demo compilation`);
|
|
414
|
+
log(` clarity help Show this help`);
|
|
415
|
+
log('');
|
|
416
|
+
log(`${c.bold}Examples:${c.reset}`);
|
|
417
|
+
log(` clarity dev Serve cwd on port 3000`);
|
|
418
|
+
log(` clarity dev ./my-app --port 8080 Serve ./my-app on port 8080`);
|
|
419
|
+
log(` clarity build examples/counter.clarity`);
|
|
420
|
+
log(` clarity build examples/`);
|
|
421
|
+
log(` clarity ssg pages/ --out dist --base https://mysite.com`);
|
|
422
|
+
log(` clarity ssg --verbose SSG + ayrıntılı log`);
|
|
423
|
+
log(` clarity format src/ Biçimlendir`);
|
|
424
|
+
log(` clarity format --check src/ CI kontrol (değişiklik yazmaz)`);
|
|
425
|
+
log(` clarity lint src/ --fix Lint + otomatik düzelt`);
|
|
426
|
+
log(` clarity check src/App.clarity`);
|
|
427
|
+
log(` clarity types src/App.clarity`);
|
|
428
|
+
log('');
|
|
429
|
+
log(`${c.dim}Clarity.js v0.5.0 — AI-Native UI Framework${c.reset}`);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// ─── Entry ───────────────────────────────────────────────────────────────────
|
|
433
|
+
const [,, command, ...restArgs] = process.argv;
|
|
434
|
+
const target = restArgs[0];
|
|
435
|
+
|
|
436
|
+
switch (command) {
|
|
437
|
+
case 'dev': cmdDev(restArgs); break;
|
|
438
|
+
case 'bundle': cmdBundle(restArgs); break;
|
|
439
|
+
case 'build': target ? cmdBuild(target) : (err('Usage: clarity build <file>'), process.exit(1)); break;
|
|
440
|
+
case 'check': target ? cmdCheck(target) : (err('Usage: clarity check <file>'), process.exit(1)); break;
|
|
441
|
+
case 'types': target ? cmdTypes(target) : (err('Usage: clarity types <file>'), process.exit(1)); break;
|
|
442
|
+
case 'ast': target ? cmdAst(target) : (err('Usage: clarity ast <file>'), process.exit(1)); break;
|
|
443
|
+
case 'format': cmdFormat(restArgs); break;
|
|
444
|
+
case 'lint': cmdLint(restArgs); break;
|
|
445
|
+
case 'ssg': cmdSsg(restArgs); break;
|
|
446
|
+
case 'analyze': cmdAnalyze(restArgs); break;
|
|
447
|
+
case 'demo': cmdDemo(); break;
|
|
448
|
+
case 'help':
|
|
449
|
+
case '--help':
|
|
450
|
+
case '-h':
|
|
451
|
+
default:
|
|
452
|
+
cmdHelp();
|
|
453
|
+
}
|