@xessa/cli 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +443 -2
- package/dist/args.d.ts +43 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +202 -0
- package/dist/args.js.map +1 -0
- package/dist/commands/build.d.ts +44 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +533 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/check.d.ts +11 -0
- package/dist/commands/check.d.ts.map +1 -0
- package/dist/commands/check.js +35 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/clean.d.ts +12 -0
- package/dist/commands/clean.d.ts.map +1 -0
- package/dist/commands/clean.js +140 -0
- package/dist/commands/clean.js.map +1 -0
- package/dist/commands/format.d.ts +41 -0
- package/dist/commands/format.d.ts.map +1 -0
- package/dist/commands/format.js +127 -0
- package/dist/commands/format.js.map +1 -0
- package/dist/commands/watch.d.ts +38 -0
- package/dist/commands/watch.d.ts.map +1 -0
- package/dist/commands/watch.js +338 -0
- package/dist/commands/watch.js.map +1 -0
- package/dist/compiler.d.ts +20 -0
- package/dist/compiler.d.ts.map +1 -0
- package/dist/compiler.js +57 -0
- package/dist/compiler.js.map +1 -0
- package/dist/config.d.ts +93 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +331 -0
- package/dist/config.js.map +1 -0
- package/dist/formatter.d.ts +21 -0
- package/dist/formatter.d.ts.map +1 -0
- package/dist/formatter.js +38 -0
- package/dist/formatter.js.map +1 -0
- package/dist/glob.d.ts +52 -0
- package/dist/glob.d.ts.map +1 -0
- package/dist/glob.js +214 -0
- package/dist/glob.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +114 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +56 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +138 -0
- package/dist/manifest.js.map +1 -0
- package/dist/paths.d.ts +24 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +42 -0
- package/dist/paths.js.map +1 -0
- package/dist/project.d.ts +44 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +92 -0
- package/dist/project.js.map +1 -0
- package/dist/report.d.ts +128 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +128 -0
- package/dist/report.js.map +1 -0
- package/dist/setup.d.ts +58 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +181 -0
- package/dist/setup.js.map +1 -0
- package/dist/writer.d.ts +32 -0
- package/dist/writer.d.ts.map +1 -0
- package/dist/writer.js +93 -0
- package/dist/writer.js.map +1 -0
- package/package.json +40 -4
- package/src/args.ts +246 -0
- package/src/commands/build.ts +682 -0
- package/src/commands/check.ts +45 -0
- package/src/commands/clean.ts +168 -0
- package/src/commands/format.ts +169 -0
- package/src/commands/watch.ts +366 -0
- package/src/compiler-api.d.ts +261 -0
- package/src/compiler.ts +65 -0
- package/src/config.ts +443 -0
- package/src/formatter.ts +56 -0
- package/src/glob.ts +230 -0
- package/src/index.ts +137 -0
- package/src/manifest.ts +176 -0
- package/src/paths.ts +50 -0
- package/src/project.ts +122 -0
- package/src/report.ts +230 -0
- package/src/setup.ts +218 -0
- package/src/writer.ts +102 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `xessa clean` — remove compiler-owned outputs.
|
|
3
|
+
*
|
|
4
|
+
* Only files recorded in `.cssx-manifest.json` whose current SHA-256 hash still
|
|
5
|
+
* matches the manifest are deleted. Files modified since generation are kept and
|
|
6
|
+
* reported; missing files are dropped from the manifest. `--dry-run` reports the
|
|
7
|
+
* same decision without touching the disk.
|
|
8
|
+
*/
|
|
9
|
+
import { findWorkspaceRoot, loadConfig } from "../config.js";
|
|
10
|
+
import { isArtifactRecord, readManifest, writeManifest } from "../manifest.js";
|
|
11
|
+
import { dirnamePosix, isWithin, joinPosix } from "../paths.js";
|
|
12
|
+
import { invocationFailure, toJson, writeErrorLine, writeLine } from "../report.js";
|
|
13
|
+
import { hashFile, removeFile, sweepTemporaries } from "../writer.js";
|
|
14
|
+
/** Run `xessa clean`. */
|
|
15
|
+
export async function runClean(invocation, cwd) {
|
|
16
|
+
const loaded = await loadConfig({
|
|
17
|
+
cwd,
|
|
18
|
+
startDir: cwd,
|
|
19
|
+
...(invocation.configPath === undefined ? {} : { explicitPath: invocation.configPath }),
|
|
20
|
+
});
|
|
21
|
+
if (!loaded.ok)
|
|
22
|
+
return invocationFailure(invocation.command, loaded.message, invocation.json);
|
|
23
|
+
const config = loaded.config;
|
|
24
|
+
const root = config === null ? await findWorkspaceRoot(cwd) : config.root;
|
|
25
|
+
const warnings = [...loaded.warnings];
|
|
26
|
+
const errors = [];
|
|
27
|
+
const removed = [];
|
|
28
|
+
const skipped = [];
|
|
29
|
+
const manifestResult = await readManifest(root);
|
|
30
|
+
warnings.push(...manifestResult.warnings);
|
|
31
|
+
// Sweep writer temporaries left behind by an interrupted build. The manifest
|
|
32
|
+
// carries the artifact directories; the workspace root and configured output
|
|
33
|
+
// directories cover a manifest write that was itself interrupted.
|
|
34
|
+
const sweepDirectories = new Set([root]);
|
|
35
|
+
for (const directory of [config?.output?.cssDir, config?.output?.mapDir]) {
|
|
36
|
+
if (directory === undefined)
|
|
37
|
+
continue;
|
|
38
|
+
const absolute = joinPosix(root, directory);
|
|
39
|
+
if (isWithin(root, absolute))
|
|
40
|
+
sweepDirectories.add(absolute);
|
|
41
|
+
}
|
|
42
|
+
for (const record of manifestResult.manifest.files) {
|
|
43
|
+
const directory = dirnamePosix(joinPosix(root, record.path));
|
|
44
|
+
if (isWithin(root, directory))
|
|
45
|
+
sweepDirectories.add(directory);
|
|
46
|
+
}
|
|
47
|
+
await sweepTemporaries([...sweepDirectories]);
|
|
48
|
+
const remaining = [];
|
|
49
|
+
for (const record of manifestResult.manifest.files) {
|
|
50
|
+
const absolute = joinPosix(root, record.path);
|
|
51
|
+
if (!isWithin(root, absolute) || record.path.startsWith("/")) {
|
|
52
|
+
warnings.push(`Ignoring manifest path outside the workspace: ${record.path}`);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (!isCompilerArtifact(record, root)) {
|
|
56
|
+
skipped.push({ path: record.path, reason: "untrusted" });
|
|
57
|
+
warnings.push(`Refusing to delete ${record.path}: the record does not describe a compiler artifact; ownership released.`);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const currentHash = await hashFile(absolute);
|
|
61
|
+
if (currentHash === null) {
|
|
62
|
+
skipped.push({ path: record.path, reason: "missing" });
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (currentHash !== record.hash) {
|
|
66
|
+
skipped.push({ path: record.path, reason: "modified" });
|
|
67
|
+
warnings.push(`Kept ${record.path}: modified since generation; ownership released.`);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (invocation.dryRun) {
|
|
71
|
+
removed.push({ path: record.path, reason: "would-delete" });
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
await removeFile(absolute);
|
|
76
|
+
removed.push({ path: record.path, reason: "deleted" });
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
errors.push(`Could not delete ${record.path}: ${describeError(error)}`);
|
|
80
|
+
remaining.push(record);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (!invocation.dryRun) {
|
|
84
|
+
// Records whose deletion failed stay owned so a retry can finish the job.
|
|
85
|
+
try {
|
|
86
|
+
await writeManifest(root, { version: 1, files: remaining });
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
errors.push(`Could not update .cssx-manifest.json: ${describeError(error)}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const failed = errors.length > 0;
|
|
93
|
+
const report = {
|
|
94
|
+
command: "clean",
|
|
95
|
+
success: !failed,
|
|
96
|
+
exitCode: failed ? 1 : 0,
|
|
97
|
+
dryRun: invocation.dryRun,
|
|
98
|
+
workspaceRoot: root,
|
|
99
|
+
configFile: config?.file ?? null,
|
|
100
|
+
removed,
|
|
101
|
+
skipped,
|
|
102
|
+
warnings,
|
|
103
|
+
errors,
|
|
104
|
+
};
|
|
105
|
+
if (invocation.json) {
|
|
106
|
+
writeLine(toJson(report).trimEnd());
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
for (const item of removed) {
|
|
110
|
+
writeLine(invocation.dryRun ? `would remove ${item.path}` : `removed ${item.path}`);
|
|
111
|
+
}
|
|
112
|
+
for (const item of skipped)
|
|
113
|
+
writeLine(`skipped ${item.path} (${item.reason})`);
|
|
114
|
+
for (const warning of warnings)
|
|
115
|
+
writeErrorLine(`xessa: warning: ${warning}`);
|
|
116
|
+
for (const error of errors)
|
|
117
|
+
writeErrorLine(`xessa: error: ${error}`);
|
|
118
|
+
const verb = invocation.dryRun ? "removable" : "removed";
|
|
119
|
+
writeLine(`xessa clean: ${removed.length} file${removed.length === 1 ? "" : "s"} ${verb}, ` +
|
|
120
|
+
`${skipped.length} skipped`);
|
|
121
|
+
}
|
|
122
|
+
return failed ? 1 : 0;
|
|
123
|
+
}
|
|
124
|
+
function describeError(error) {
|
|
125
|
+
return error instanceof Error ? error.message : String(error);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Whether a manifest record describes a file the compiler can have produced.
|
|
129
|
+
*
|
|
130
|
+
* A record alone is not proof of ownership: the manifest can be hand-edited or
|
|
131
|
+
* copied from another project. Deletion therefore also requires an
|
|
132
|
+
* artifact-shaped path for its `kind` and a `source` that resolves inside the
|
|
133
|
+
* workspace. Anything else is released, not deleted (CSSX-T10).
|
|
134
|
+
*/
|
|
135
|
+
function isCompilerArtifact(record, root) {
|
|
136
|
+
if (!isArtifactRecord(record))
|
|
137
|
+
return false;
|
|
138
|
+
return isWithin(root, joinPosix(root, record.source));
|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AAC,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `xessa format [file]` — canonical source formatting.
|
|
3
|
+
*
|
|
4
|
+
* The command resolves entries exactly like `xessa check` (explicit file or the
|
|
5
|
+
* project include/exclude globs), parses and reprints each source with the pure
|
|
6
|
+
* compiler formatter, and reports the files it changed. Default mode writes the
|
|
7
|
+
* canonical text atomically in place; `--check` writes nothing and exits 1 when
|
|
8
|
+
* at least one file would change. Parse errors are reported and never rewrite
|
|
9
|
+
* the affected file. Exit codes stay contractual: 0 success, 1 formatting or
|
|
10
|
+
* parse errors (or `--check` changes), 2 invocation/configuration errors.
|
|
11
|
+
*/
|
|
12
|
+
import type { CliInvocation } from "../args.js";
|
|
13
|
+
import { type CliDiagnostic } from "../report.js";
|
|
14
|
+
/** One source file and what this run did with it. */
|
|
15
|
+
export interface FormatFileRecord {
|
|
16
|
+
/** Workspace-relative POSIX source path. */
|
|
17
|
+
readonly file: string;
|
|
18
|
+
/** Whether the canonical text differs from the authored text. */
|
|
19
|
+
readonly changed: boolean;
|
|
20
|
+
/** Whether this run wrote the file. */
|
|
21
|
+
readonly written: boolean;
|
|
22
|
+
/** Why the file was not written, when applicable. */
|
|
23
|
+
readonly reason?: string;
|
|
24
|
+
}
|
|
25
|
+
/** Machine-readable `xessa format` report (`--json`). */
|
|
26
|
+
export interface JsonFormatReport {
|
|
27
|
+
readonly command: "format";
|
|
28
|
+
readonly success: boolean;
|
|
29
|
+
readonly exitCode: number;
|
|
30
|
+
readonly check: boolean;
|
|
31
|
+
readonly dryRun: boolean;
|
|
32
|
+
readonly workspaceRoot: string;
|
|
33
|
+
readonly configFile: string | null;
|
|
34
|
+
readonly files: readonly FormatFileRecord[];
|
|
35
|
+
readonly changed: readonly string[];
|
|
36
|
+
readonly diagnostics: readonly CliDiagnostic[];
|
|
37
|
+
readonly errors: readonly string[];
|
|
38
|
+
}
|
|
39
|
+
/** Run `xessa format [file] [--check]`. */
|
|
40
|
+
export declare function runFormat(invocation: CliInvocation, cwd: string): Promise<number>;
|
|
41
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/commands/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAIhD,OAAO,EACL,KAAK,aAAa,EAQnB,MAAM,cAAc,CAAC;AAGtB,qDAAqD;AACrD,MAAM,WAAW,gBAAgB;IAC/B,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,uCAAuC;IACvC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,qDAAqD;IACrD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,yDAAyD;AACzD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,SAAS,aAAa,EAAE,CAAC;IAC/C,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAED,2CAA2C;AAC3C,wBAAsB,SAAS,CAAC,UAAU,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA2GvF"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `xessa format [file]` — canonical source formatting.
|
|
3
|
+
*
|
|
4
|
+
* The command resolves entries exactly like `xessa check` (explicit file or the
|
|
5
|
+
* project include/exclude globs), parses and reprints each source with the pure
|
|
6
|
+
* compiler formatter, and reports the files it changed. Default mode writes the
|
|
7
|
+
* canonical text atomically in place; `--check` writes nothing and exits 1 when
|
|
8
|
+
* at least one file would change. Parse errors are reported and never rewrite
|
|
9
|
+
* the affected file. Exit codes stay contractual: 0 success, 1 formatting or
|
|
10
|
+
* parse errors (or `--check` changes), 2 invocation/configuration errors.
|
|
11
|
+
*/
|
|
12
|
+
import { readFile } from "node:fs/promises";
|
|
13
|
+
import { loadFormatter } from "../formatter.js";
|
|
14
|
+
import { joinPosix } from "../paths.js";
|
|
15
|
+
import { prepareProject } from "../project.js";
|
|
16
|
+
import { DiagnosticPositions, dedupeDiagnostics, formatDiagnostic, invocationFailure, toJson, writeErrorLine, writeLine, } from "../report.js";
|
|
17
|
+
import { atomicWrite } from "../writer.js";
|
|
18
|
+
/** Run `xessa format [file] [--check]`. */
|
|
19
|
+
export async function runFormat(invocation, cwd) {
|
|
20
|
+
const prepared = await prepareProject(invocation, cwd);
|
|
21
|
+
if (!prepared.ok)
|
|
22
|
+
return invocationFailure(invocation.command, prepared.message, invocation.json);
|
|
23
|
+
const context = prepared.context;
|
|
24
|
+
const check = invocation.check === true;
|
|
25
|
+
const dryRun = invocation.dryRun;
|
|
26
|
+
let formatter;
|
|
27
|
+
try {
|
|
28
|
+
formatter = await loadFormatter();
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
return invocationFailure(invocation.command, error instanceof Error ? error.message : String(error), invocation.json);
|
|
32
|
+
}
|
|
33
|
+
const positions = new DiagnosticPositions(context.root);
|
|
34
|
+
const files = [];
|
|
35
|
+
const diagnostics = [];
|
|
36
|
+
const errors = [];
|
|
37
|
+
for (const entry of context.entries) {
|
|
38
|
+
const absolute = joinPosix(context.root, entry);
|
|
39
|
+
let source;
|
|
40
|
+
try {
|
|
41
|
+
source = await readFile(absolute, "utf8");
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
errors.push(`${entry}: cannot read source (${describeError(error)}).`);
|
|
45
|
+
files.push({ file: entry, changed: false, written: false, reason: "read-failed" });
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const result = formatter.format(source, entry);
|
|
49
|
+
diagnostics.push(...(await positions.convert(result.diagnostics)));
|
|
50
|
+
if (result.diagnostics.some((diagnostic) => diagnostic.severity === "error")) {
|
|
51
|
+
errors.push(`${entry}: not formatted because parsing reported errors.`);
|
|
52
|
+
files.push({ file: entry, changed: false, written: false, reason: "parse-error" });
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const changed = result.formatted !== source;
|
|
56
|
+
if (!changed) {
|
|
57
|
+
files.push({ file: entry, changed: false, written: false });
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (check || dryRun) {
|
|
61
|
+
files.push({ file: entry, changed: true, written: false, reason: "not-written" });
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
await atomicWrite(absolute, result.formatted);
|
|
66
|
+
files.push({ file: entry, changed: true, written: true });
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
errors.push(`${entry}: cannot write formatted source (${describeError(error)}).`);
|
|
70
|
+
files.push({ file: entry, changed: true, written: false, reason: "write-failed" });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const positioned = dedupeDiagnostics(diagnostics);
|
|
74
|
+
const changedFiles = files.filter((file) => file.changed).map((file) => file.file);
|
|
75
|
+
const failed = errors.length > 0 || positioned.some((diagnostic) => diagnostic.severity === "error");
|
|
76
|
+
const exitCode = failed ? 1 : check && changedFiles.length > 0 ? 1 : 0;
|
|
77
|
+
const success = exitCode === 0;
|
|
78
|
+
if (invocation.json) {
|
|
79
|
+
const report = {
|
|
80
|
+
command: "format",
|
|
81
|
+
success,
|
|
82
|
+
exitCode,
|
|
83
|
+
check,
|
|
84
|
+
dryRun,
|
|
85
|
+
workspaceRoot: context.root,
|
|
86
|
+
configFile: context.config?.file ?? null,
|
|
87
|
+
files,
|
|
88
|
+
changed: changedFiles,
|
|
89
|
+
diagnostics: positioned,
|
|
90
|
+
errors,
|
|
91
|
+
};
|
|
92
|
+
writeLine(toJson(report).trimEnd());
|
|
93
|
+
return exitCode;
|
|
94
|
+
}
|
|
95
|
+
for (const diagnostic of positioned)
|
|
96
|
+
writeErrorLine(formatDiagnostic(diagnostic));
|
|
97
|
+
for (const error of errors)
|
|
98
|
+
writeErrorLine(`xessa format: ${error}`);
|
|
99
|
+
if (check) {
|
|
100
|
+
if (changedFiles.length > 0) {
|
|
101
|
+
writeLine(`xessa format --check: ${changedFiles.length} file(s) would be reformatted:`);
|
|
102
|
+
for (const file of changedFiles)
|
|
103
|
+
writeLine(` ${file}`);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
writeLine(`xessa format --check: ${files.length} file(s) already formatted.`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else if (dryRun) {
|
|
110
|
+
writeLine(`xessa format --dry-run: ${changedFiles.length} file(s) would be reformatted.`);
|
|
111
|
+
for (const file of changedFiles)
|
|
112
|
+
writeLine(` ${file}`);
|
|
113
|
+
}
|
|
114
|
+
else if (changedFiles.length > 0) {
|
|
115
|
+
writeLine(`xessa format: reformatted ${changedFiles.length} file(s):`);
|
|
116
|
+
for (const file of changedFiles)
|
|
117
|
+
writeLine(` ${file}`);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
writeLine(`xessa format: ${files.length} file(s) already formatted.`);
|
|
121
|
+
}
|
|
122
|
+
return exitCode;
|
|
123
|
+
}
|
|
124
|
+
function describeError(error) {
|
|
125
|
+
return error instanceof Error ? error.message : String(error);
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/commands/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAEL,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,EACN,cAAc,EACd,SAAS,GACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AA6B3C,2CAA2C;AAC3C,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,UAAyB,EAAE,GAAW;IACpE,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IACvD,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,OAAO,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IAElG,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;IACjC,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,KAAK,IAAI,CAAC;IACxC,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IACjC,IAAI,SAAoD,CAAC;IACzD,IAAI,CAAC;QACH,SAAS,GAAG,MAAM,aAAa,EAAE,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,iBAAiB,CACtB,UAAU,CA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AAC;YAC5B,SAAS,CAAC,yBAAyB,YAAY,CAAC,MAAM,gCAAgC,CAAC,CAAC;YACxF,KAAK,MAAM,IAAI,IAAI,YAAY;gBAAE,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;QAC1D,CAAC;aAAM,CAAC;YACN,SAAS,CAAC,yBAAyB,KAAK,CAAC,MAAM,6BAA6B,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;SAAM,IAAI,MAAM,EAAE,CAAC;QAClB,SAAS,CAAC,2BAA2B,YAAY,CAAC,MAAM,gCAAgC,CAAC,CAAC;QAC1F,KAAK,MAAM,IAAI,IAAI,YAAY;YAAE,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;SAAM,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnC,SAAS,CAAC,6BAA6B,YAAY,CAAC,MAAM,WAAW,CAAC,CAAC;QACvE,KAAK,MAAM,IAAI,IAAI,YAAY;YAAE,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;SAAM,CAAC;QACN,SAAS,CAAC,iBAAiB,KAAK,CAAC,MAAM,6BAA6B,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `xessa watch` — incremental rebuilds until interrupted.
|
|
3
|
+
*
|
|
4
|
+
* The watcher performs an initial full build, then watches the directories that
|
|
5
|
+
* hold entry sources and their import dependencies. Events are debounced, mapped
|
|
6
|
+
* through a reverse import graph (built from `CompileResult.dependencies`) to the
|
|
7
|
+
* affected entries, and serialized: one build runs at a time and any event that
|
|
8
|
+
* arrives mid-build invalidates it through a generation counter, so a stale
|
|
9
|
+
* result never lands on disk.
|
|
10
|
+
*
|
|
11
|
+
* Sources (`.cssx`), the configuration file and directory events trigger work.
|
|
12
|
+
* Generated CSS, JS, declarations, maps, writer temporaries and the manifest are
|
|
13
|
+
* matched against the known artifact set and ignored, so the watcher cannot feed
|
|
14
|
+
* back on its own outputs. Deletions and unhandled paths trigger a full
|
|
15
|
+
* rediscovery through the include globs.
|
|
16
|
+
*/
|
|
17
|
+
import type { CliInvocation } from "../args.js";
|
|
18
|
+
/**
|
|
19
|
+
* Debounce window for filesystem events in milliseconds.
|
|
20
|
+
*
|
|
21
|
+
* Exported so integration tests can reason about event coalescing instead of
|
|
22
|
+
* guessing at a sleep, and reported in the JSON `watch` ready event. Changing it
|
|
23
|
+
* only affects latency, never correctness: every build is still awaited through
|
|
24
|
+
* its emitted build event.
|
|
25
|
+
*/
|
|
26
|
+
export declare const WATCH_DEBOUNCE_MS = 40;
|
|
27
|
+
/** Options for {@link runWatch}. */
|
|
28
|
+
export interface WatchOptions {
|
|
29
|
+
/** Parsed invocation with the optional single-entry file argument. */
|
|
30
|
+
readonly invocation: CliInvocation;
|
|
31
|
+
/** Working directory used to resolve relative paths. */
|
|
32
|
+
readonly cwd: string;
|
|
33
|
+
/** Abort signal that stops the watcher; defaults to SIGINT/SIGTERM. */
|
|
34
|
+
readonly signal?: AbortSignal;
|
|
35
|
+
}
|
|
36
|
+
/** Run `xessa watch [file]` until aborted. */
|
|
37
|
+
export declare function runWatch(options: WatchOptions): Promise<number>;
|
|
38
|
+
//# sourceMappingURL=watch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/commands/watch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAShD;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,oCAAoC;AACpC,MAAM,WAAW,YAAY;IAC3B,sEAAsE;IACtE,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,wDAAwD;IACxD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAeD,8CAA8C;AAC9C,wBAAsB,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAmSrE"}
|