@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Marky
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,444 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @xessa/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The official Xessa command-line interface. It compiles `.cssx` sources to CSS, JavaScript class
|
|
4
|
+
maps, optional TypeScript declarations and optional source maps, and is a thin wrapper around
|
|
5
|
+
[`@xessa/compiler`](https://github.com/MARKjotep/xessa/blob/main/packages/compiler/README.md): the same parser, resolver and emitters that power the
|
|
6
|
+
API and the VS Code extension.
|
|
7
|
+
|
|
8
|
+
`@xessa/cli` is the command and operations reference. The complete language and compiler contract
|
|
9
|
+
lives in [`@xessa/compiler`](https://github.com/MARKjotep/xessa/blob/main/packages/compiler/README.md)
|
|
10
|
+
and the normative
|
|
11
|
+
[`SPECIFICATION.md`](https://github.com/MARKjotep/xessa/blob/main/SPECIFICATION.md); this page does
|
|
12
|
+
not restate the language.
|
|
13
|
+
|
|
14
|
+
The CLI depends on `@xessa/compiler`, so the complete spec and docs are installed at
|
|
15
|
+
`node_modules/@xessa/compiler/SPECIFICATION.md` and `node_modules/@xessa/compiler/docs/` — available
|
|
16
|
+
offline to npm and CLI users.
|
|
17
|
+
|
|
18
|
+
**0.1.1** is live on npm; **0.1.2** is release-ready, not yet published. Until 0.1.2 is live, use the
|
|
19
|
+
source-checkout workflow below or install the published 0.1.1.
|
|
20
|
+
|
|
21
|
+
## This README vs the language spec
|
|
22
|
+
|
|
23
|
+
| Question | Reference |
|
|
24
|
+
| ------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
25
|
+
| How do I install, run, configure and script it? | This page |
|
|
26
|
+
| What does a `.cssx` file mean? | [`@xessa/compiler`](https://github.com/MARKjotep/xessa/blob/main/packages/compiler/README.md) → [`SPECIFICATION.md`](https://github.com/MARKjotep/xessa/blob/main/SPECIFICATION.md) |
|
|
27
|
+
| How does the editor behave? | [`packages/vscode/README.md`](https://github.com/MARKjotep/xessa/blob/main/packages/vscode/README.md) |
|
|
28
|
+
|
|
29
|
+
## Requirements
|
|
30
|
+
|
|
31
|
+
- **Node.js ≥ 20** or **Bun**. The CLI is ESM and ships built `dist` output; its `bin` entry is
|
|
32
|
+
`dist/index.js` with a `#!/usr/bin/env node` shebang, so a Node-only machine works.
|
|
33
|
+
- A runtime dependency on `@xessa/compiler` is installed with the CLI.
|
|
34
|
+
- Workspaces are ordinary directories. No framework, bundler or browser runtime is required.
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
### As a local development dependency
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
npm install -D @xessa/cli
|
|
42
|
+
# or
|
|
43
|
+
bun add -d @xessa/cli
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This puts the `xessa` binary in `node_modules/.bin`. Use it directly or through your package
|
|
47
|
+
scripts:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
xessa build
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`npx @xessa/cli build` also resolves the locally installed package when you prefer an explicit
|
|
54
|
+
scoped invocation.
|
|
55
|
+
|
|
56
|
+
### Globally
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
npm install -g @xessa/cli
|
|
60
|
+
xessa build
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### One-off, without installing
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
npx @xessa/cli build
|
|
67
|
+
bunx @xessa/cli build
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
> **Important:** the unscoped `xessa` package on npm is the private repository root and is **not
|
|
71
|
+
> published**. Bare `npx xessa` therefore does not work. The `xessa` bin only exists after
|
|
72
|
+
> `@xessa/cli` is installed, or when you invoke the scoped package directly
|
|
73
|
+
> (`npx @xessa/cli`, `bunx @xessa/cli`).
|
|
74
|
+
|
|
75
|
+
### From a source checkout
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
bun install
|
|
79
|
+
bun run --cwd packages/compiler build
|
|
80
|
+
bun run --cwd packages/cli build
|
|
81
|
+
node packages/cli/dist/index.js --help
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The last command works without a global install; substitute its path for `xessa` anywhere below.
|
|
85
|
+
|
|
86
|
+
## 60-second quick start
|
|
87
|
+
|
|
88
|
+
### One file
|
|
89
|
+
|
|
90
|
+
Create `src/button.cssx`:
|
|
91
|
+
|
|
92
|
+
```cssx
|
|
93
|
+
@setup {
|
|
94
|
+
prefix: "ui";
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.button {
|
|
98
|
+
display: flex;
|
|
99
|
+
padding: 12px @md 20px;
|
|
100
|
+
background: #2563eb;
|
|
101
|
+
&:hover { opacity: 0.85; }
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Compile it:
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
npx @xessa/cli build src/button.cssx
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
With no configuration and no output overrides, both artifacts land next to the source:
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
src/button.css # .ui-button rules, inline @md lowered to @media
|
|
115
|
+
src/button.map.js # export const button = "ui-button";
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Defaults: `css-dir` and `map-dir` are the source directory, CSS is `<stem>.css`, the map is
|
|
119
|
+
`<stem>.map.js`, and CSS is **minified** (`minify: true`). Add `map-types: true` in `@setup` to
|
|
120
|
+
emit `<stem>.map.d.ts`, and `source-map: true` for a `.map` artifact. Pass `--no-minify` for
|
|
121
|
+
readable CSS.
|
|
122
|
+
|
|
123
|
+
### A project
|
|
124
|
+
|
|
125
|
+
No configuration is required. From the workspace root:
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
npx @xessa/cli build
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
`build` discovers `include: ["**/*.cssx"]` under the nearest workspace root and compiles every
|
|
132
|
+
entry. Add `xessa.config.json` only to change a default or scope discovery:
|
|
133
|
+
|
|
134
|
+
```json
|
|
135
|
+
{
|
|
136
|
+
"include": ["src/**/*.cssx"],
|
|
137
|
+
"classes": { "strategy": "prefix", "prefix": "ui" }
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
See [Configuration](#configuration) below for the full shape.
|
|
142
|
+
|
|
143
|
+
## Command reference
|
|
144
|
+
|
|
145
|
+
Commands are `build`, `check`, `watch`, `format`, `clean` and the `help`/`version` shortcuts.
|
|
146
|
+
Parsing is strict: unknown flags, extra positional arguments, a missing flag value and a missing
|
|
147
|
+
command are invocation errors (exit 2). `-h/--help` and `-v/--version` short-circuit every other
|
|
148
|
+
rule and exit 0.
|
|
149
|
+
|
|
150
|
+
### `xessa build [file]`
|
|
151
|
+
|
|
152
|
+
Compile the project (config include globs) or one file, write artifacts, and update the manifest.
|
|
153
|
+
|
|
154
|
+
- **Writes:** CSS, class map and any enabled declaration/source-map artifacts, plus
|
|
155
|
+
`.cssx-manifest.json` at the workspace root.
|
|
156
|
+
- **Flags:** `--config <path>`, `--json`, `--dry-run`, `--minify`, `--no-minify`.
|
|
157
|
+
- A failed entry writes nothing for that entry and keeps its previous good outputs.
|
|
158
|
+
- `--dry-run` positions diagnostics and prints the plan but writes no files and does not update
|
|
159
|
+
the manifest.
|
|
160
|
+
|
|
161
|
+
```sh
|
|
162
|
+
npx @xessa/cli build
|
|
163
|
+
npx @xessa/cli build src/button.cssx --no-minify
|
|
164
|
+
npx @xessa/cli build --config config/xessa.config.json --json
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### `xessa check [file]`
|
|
168
|
+
|
|
169
|
+
Run the same compilation pipeline and diagnostics as `build`, but **never write**. Exit 1 when any
|
|
170
|
+
error diagnostic is reported, 0 otherwise (warnings are allowed).
|
|
171
|
+
|
|
172
|
+
- **Writes:** nothing.
|
|
173
|
+
- **Flags:** `--config <path>`, `--json`, `--minify`, `--no-minify`.
|
|
174
|
+
- `--dry-run` is rejected for `check` because it already performs no writes (exit 2).
|
|
175
|
+
|
|
176
|
+
```sh
|
|
177
|
+
npx @xessa/cli check
|
|
178
|
+
npx @xessa/cli check src/button.cssx --json
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### `xessa watch [file]`
|
|
182
|
+
|
|
183
|
+
Build once, then rebuild affected entries on change until `SIGINT`/`SIGTERM`. Newly created
|
|
184
|
+
directories are included, and a config edit re-resolves the project.
|
|
185
|
+
|
|
186
|
+
- **Writes:** yes, like `build` (watch always writes; `--dry-run` does not apply).
|
|
187
|
+
- **Flags:** `--config <path>`, `--json`, `--minify`, `--no-minify`.
|
|
188
|
+
- **`--json`** emits **NDJSON**, one compact object per line: `{"type":"build",…}` after each
|
|
189
|
+
build generation, then `{"type":"watch","ready":true,"sources":N,"debounceMs":…}` once watchers
|
|
190
|
+
are attached. It is a stream, not a single JSON document.
|
|
191
|
+
|
|
192
|
+
```sh
|
|
193
|
+
npx @xessa/cli watch
|
|
194
|
+
npx @xessa/cli watch src/button.cssx
|
|
195
|
+
npx @xessa/cli watch --json | jq -c 'select(.type == "build")'
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### `xessa format [file]`
|
|
199
|
+
|
|
200
|
+
Reformat sources canonically in place. Formatting is parse→print: a file with parse errors is never
|
|
201
|
+
rewritten, and the errors are reported with their exit code.
|
|
202
|
+
|
|
203
|
+
- **Writes:** changed source files only (atomic replacement).
|
|
204
|
+
- **Flags:** `--check`, `--config <path>`, `--json`, `--dry-run`.
|
|
205
|
+
- **`--check`** writes nothing, lists files that would change, and exits **1** when any exist, 0
|
|
206
|
+
when everything is already canonical.
|
|
207
|
+
- `--dry-run` is accepted as an explicit no-write run; `--check` is the CI-friendly form.
|
|
208
|
+
- `--minify`/`--no-minify` have no effect on source formatting.
|
|
209
|
+
|
|
210
|
+
```sh
|
|
211
|
+
npx @xessa/cli format
|
|
212
|
+
npx @xessa/cli format --check
|
|
213
|
+
npx @xessa/cli format src/button.cssx --json
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### `xessa clean`
|
|
217
|
+
|
|
218
|
+
Delete generated files that the manifest records as compiler-owned **and** whose content hash still
|
|
219
|
+
matches the recorded hash. Edited outputs are kept and their ownership released. Stale writer
|
|
220
|
+
temporaries are swept; files outside the workspace and untrusted manifest records are refused.
|
|
221
|
+
|
|
222
|
+
- **Writes:** deletes files, and rewrites `.cssx-manifest.json` with the remaining owned records.
|
|
223
|
+
- **Flags:** `--config <path>`, `--dry-run`, `--json`. No file argument (exit 2).
|
|
224
|
+
- `--dry-run` prints what would be removed, deletes nothing and leaves the manifest untouched.
|
|
225
|
+
|
|
226
|
+
```sh
|
|
227
|
+
npx @xessa/cli clean --dry-run
|
|
228
|
+
npx @xessa/cli clean --json
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### `xessa --help`, `xessa --version`
|
|
232
|
+
|
|
233
|
+
Print usage or the CLI version and exit 0. `-h` and `-v` are the short forms. Both work before or
|
|
234
|
+
after a command and take precedence over command validation.
|
|
235
|
+
|
|
236
|
+
```sh
|
|
237
|
+
npx @xessa/cli --help
|
|
238
|
+
npx @xessa/cli -v
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Flags
|
|
242
|
+
|
|
243
|
+
| Flag | Value | Commands | Behaviour |
|
|
244
|
+
| ----------------- | -------- | --------------------------------- | ------------------------------------------------------------------------- |
|
|
245
|
+
| `--config` | `<path>` | `build`, `check`, `watch`, `format`, `clean` | Use this config file instead of the nearest `xessa.config.json`. Relative paths resolve from the working directory. May be given once; `--config=path` also works. |
|
|
246
|
+
| `--json` | none | `build`, `check`, `watch`, `clean`, `format` | Machine-readable output. One JSON document for build/check/clean/format; **NDJSON** for watch. |
|
|
247
|
+
| `--dry-run` | none | `build`, `clean` (also `format` as a no-write run) | Report planned work; write and delete nothing. Rejected by `check`; `watch` ignores it. |
|
|
248
|
+
| `--minify` | none | `build`, `check`, `watch` | Emit compact CSS (this is the default). |
|
|
249
|
+
| `--no-minify` | none | `build`, `check`, `watch` | Emit expanded, readable CSS. |
|
|
250
|
+
| `--check` | none | `format` only | Report files that would change; write nothing; exit 1 if any. |
|
|
251
|
+
| `-h`, `--help` | none | anywhere | Print usage and exit 0. |
|
|
252
|
+
| `-v`, `--version` | none | anywhere | Print the CLI version and exit 0. |
|
|
253
|
+
|
|
254
|
+
Notes:
|
|
255
|
+
|
|
256
|
+
- `--minify` / `--no-minify`: the last one on the command line wins.
|
|
257
|
+
- A value flag never consumes another option as its value: `--config --json` is a missing path, not
|
|
258
|
+
a config named `--json`. A bare `-` is a legal value.
|
|
259
|
+
- `--` ends flag parsing; later tokens are positional.
|
|
260
|
+
- Unknown options or commands, more than one file argument, a file argument to `clean`, `--check`
|
|
261
|
+
on a non-format command and a missing command all exit **2**.
|
|
262
|
+
|
|
263
|
+
## Project discovery and workspace root
|
|
264
|
+
|
|
265
|
+
- The CLI walks upward from the starting directory for the nearest **`xessa.config.json`**. The
|
|
266
|
+
directory containing that file is the workspace root.
|
|
267
|
+
- `--config <path>` overrides the walk; its directory becomes the workspace root.
|
|
268
|
+
- With no configuration file, the root is the nearest ancestor containing **`package.json`**; if
|
|
269
|
+
none exists, the starting directory itself.
|
|
270
|
+
- For `build`, `check` and `watch`, a **single-file** run still loads the nearest config for
|
|
271
|
+
project-level output, naming and media settings. The file must be inside the workspace root;
|
|
272
|
+
otherwise the CLI exits 2 and suggests `--config` for the containing project.
|
|
273
|
+
- **Project mode** discovers `.cssx` files via `include` (default `**/*.cssx`) minus `exclude`.
|
|
274
|
+
`node_modules` and `.git` are never walked, and only `.cssx` files are sources.
|
|
275
|
+
- An explicitly empty `include` array is an invocation error (exit 2). A project discovery that
|
|
276
|
+
matches no `.cssx` sources is also exit 2 (`No .cssx sources matched the project include globs.`),
|
|
277
|
+
not a silent success.
|
|
278
|
+
|
|
279
|
+
```sh
|
|
280
|
+
# run from anywhere, targeting a specific project
|
|
281
|
+
npx @xessa/cli build --config ../site/xessa.config.json
|
|
282
|
+
|
|
283
|
+
# one file inside a project whose config lives above it
|
|
284
|
+
npx @xessa/cli check --config ./xessa.config.json src/button.cssx
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## Configuration
|
|
288
|
+
|
|
289
|
+
Configuration is optional. A minimal `xessa.config.json`:
|
|
290
|
+
|
|
291
|
+
```json
|
|
292
|
+
{
|
|
293
|
+
"include": ["src/**/*.cssx"],
|
|
294
|
+
"classes": { "strategy": "prefix", "prefix": "ui" },
|
|
295
|
+
"output": {
|
|
296
|
+
"cssDir": "generated/styles",
|
|
297
|
+
"mapDir": "generated/maps",
|
|
298
|
+
"minify": true
|
|
299
|
+
},
|
|
300
|
+
"media": { "tablet": "(min-width: 48rem)" },
|
|
301
|
+
"compiler": { "strict": true, "mediaGrouping": "safe" }
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
**Precedence:** built-in defaults < project `xessa.config.json` < file `@setup` < explicit CLI
|
|
306
|
+
overrides (`--minify` / `--no-minify`). CLI path overrides are not implemented; only minification
|
|
307
|
+
is overridable from the command line.
|
|
308
|
+
|
|
309
|
+
`compiler.strict` defaults to `true`: an unknown configuration key is an error (exit 2). Set
|
|
310
|
+
`"compiler": { "strict": false }` to downgrade unknown keys to warnings. Known keys are always
|
|
311
|
+
type-checked and range-checked.
|
|
312
|
+
|
|
313
|
+
**Imported modules** do not need an `exclude` entry. A token-only or rule-bearing module declares
|
|
314
|
+
itself:
|
|
315
|
+
|
|
316
|
+
```cssx
|
|
317
|
+
@setup {
|
|
318
|
+
module: true;
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
`module: true` suppresses the file's own artifacts unless it authors emission keys explicitly, while
|
|
323
|
+
its tokens and rules remain importable with `@use`.
|
|
324
|
+
|
|
325
|
+
Project output directories resolve relative to the workspace root and mirror source paths; `@setup`
|
|
326
|
+
directories resolve relative to the source file, exactly. The full key table, path safety rules and
|
|
327
|
+
examples are in
|
|
328
|
+
[`docs/configuration.md`](https://github.com/MARKjotep/xessa/blob/main/docs/configuration.md).
|
|
329
|
+
|
|
330
|
+
## Outputs, manifest and safety
|
|
331
|
+
|
|
332
|
+
With defaults, one entry produces:
|
|
333
|
+
|
|
334
|
+
| Artifact | Default path | Default | Opt-in key |
|
|
335
|
+
| ------------- | ------------------- | ------- | ----------------------- |
|
|
336
|
+
| Stylesheet | `<source dir>/<stem>.css` | on | `emit-css` / `output.emitCss` |
|
|
337
|
+
| JS class map | `<source dir>/<stem>.map.js` | on | `emit-map` / `output.emitMap` |
|
|
338
|
+
| Declarations | beside the map, `<stem>.map.d.ts` | off | `map-types` / `output.mapTypes` |
|
|
339
|
+
| CSS source map| beside the stylesheet | off | `source-map` / `output.sourceMap` |
|
|
340
|
+
|
|
341
|
+
- CSS is minified by default; `--no-minify`, `@setup { minify: false; }` or `output.minify: false`
|
|
342
|
+
expands it.
|
|
343
|
+
- The class map exports one `export const` per class and imports no CSS by default; set
|
|
344
|
+
`import-css: true` to prepend a side-effect import of the planned stylesheet.
|
|
345
|
+
- Writes are atomic (temporary file plus rename). A build that fails validation writes nothing for
|
|
346
|
+
that entry and leaves the previous good outputs in place.
|
|
347
|
+
- `.cssx-manifest.json` at the workspace root records owned artifacts and content hashes. After a
|
|
348
|
+
fully successful project build, obsolete owned outputs are pruned only when they are still
|
|
349
|
+
unmodified.
|
|
350
|
+
- `clean` uses the same ownership and hash rules, so hand-edited outputs are kept.
|
|
351
|
+
- `source-map: true` is planned and accepted in v0.1; the current writer reports the artifact as
|
|
352
|
+
not implemented rather than writing an incomplete map. Declarations (`map-types`) are fully
|
|
353
|
+
supported.
|
|
354
|
+
|
|
355
|
+
## JSON output
|
|
356
|
+
|
|
357
|
+
`build`, `check`, `clean` and `format` print exactly one JSON document with `--json` (pretty
|
|
358
|
+
printed, trailing newline). `watch --json` prints NDJSON instead.
|
|
359
|
+
|
|
360
|
+
A build/check document has this shape:
|
|
361
|
+
|
|
362
|
+
```json
|
|
363
|
+
{
|
|
364
|
+
"command": "build",
|
|
365
|
+
"success": false,
|
|
366
|
+
"exitCode": 1,
|
|
367
|
+
"dryRun": false,
|
|
368
|
+
"workspaceRoot": "/project",
|
|
369
|
+
"configFile": "/project/xessa.config.json",
|
|
370
|
+
"entries": [
|
|
371
|
+
{
|
|
372
|
+
"file": "src/button.cssx",
|
|
373
|
+
"dependencies": [],
|
|
374
|
+
"outputs": [
|
|
375
|
+
{ "kind": "css", "path": "src/button.css", "written": false, "reason": "error" }
|
|
376
|
+
],
|
|
377
|
+
"diagnostics": [
|
|
378
|
+
{
|
|
379
|
+
"code": "XESSA1002",
|
|
380
|
+
"severity": "error",
|
|
381
|
+
"message": "Expected \";\" after declaration.",
|
|
382
|
+
"file": "src/button.cssx",
|
|
383
|
+
"line": 6,
|
|
384
|
+
"column": 18
|
|
385
|
+
}
|
|
386
|
+
]
|
|
387
|
+
}
|
|
388
|
+
],
|
|
389
|
+
"diagnostics": [],
|
|
390
|
+
"warnings": [],
|
|
391
|
+
"errors": []
|
|
392
|
+
}
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
`clean` reports `removed` and `skipped` arrays with `reason` values such as `deleted`,
|
|
396
|
+
`would-delete`, `missing`, `modified` or `untrusted`. `format` reports `files`, `changed` and
|
|
397
|
+
`written` per file. Invocation and configuration failures with `--json` still print a machine-readable
|
|
398
|
+
object (`command`, `success: false`, `exitCode: 2`, `error`) so scripts can parse every outcome.
|
|
399
|
+
|
|
400
|
+
## Exit codes
|
|
401
|
+
|
|
402
|
+
| Code | Meaning |
|
|
403
|
+
| ---- | ----------------------------------------------------------------------------------------------------------- |
|
|
404
|
+
| `0` | Success (warnings allowed; `check` and `format --check` with nothing to report). |
|
|
405
|
+
| `1` | Compile, validation or formatting error; write/manifest failure; or `format --check` found changes. |
|
|
406
|
+
| `2` | Invocation or configuration error: unknown flag/command, invalid config, missing flag value, empty include, empty discovery, file outside the workspace root. |
|
|
407
|
+
|
|
408
|
+
## Common mistakes and troubleshooting
|
|
409
|
+
|
|
410
|
+
- **`npx xessa` fails.** The unscoped `xessa` package is not published. Use `npx @xessa/cli …`,
|
|
411
|
+
`bunx @xessa/cli …`, or install `@xessa/cli` first so the local `xessa` bin exists.
|
|
412
|
+
- **Old `chikx` commands or config files.** The project was renamed to Xessa; use `xessa …` and
|
|
413
|
+
`xessa.config.json`. `.cssx` is the source extension either way.
|
|
414
|
+
- **`XESSA1002: Expected ";"`.** Xessa declarations require semicolons, including the last one in a
|
|
415
|
+
block.
|
|
416
|
+
- **"Source file … is outside the workspace root".** The nearest config or `package.json` belongs to
|
|
417
|
+
a different project. Pass `--config` for the intended project, or run from inside it.
|
|
418
|
+
- **"No .cssx sources matched the project include globs".** Check `include`, the working directory
|
|
419
|
+
and the workspace root; this is exit 2 by design.
|
|
420
|
+
- **`format --check` exits 1 but changed nothing.** It reports files that *would* change. Run
|
|
421
|
+
`xessa format` to write them.
|
|
422
|
+
- **`clean` leaves a file behind.** It was edited after generation (hash mismatch), is outside the
|
|
423
|
+
workspace, or is not recorded as a compiler artifact. `clean` never deletes unowned files.
|
|
424
|
+
- **Unknown configuration key exits 2.** Fix the key, or opt into warnings with
|
|
425
|
+
`"compiler": { "strict": false }`.
|
|
426
|
+
- **Installing ahead of the release.** `0.1.1` is on npm; `0.1.2` is release-ready but not yet
|
|
427
|
+
published, so use the source checkout commands above to run the newest changes.
|
|
428
|
+
|
|
429
|
+
## Documentation map
|
|
430
|
+
|
|
431
|
+
| Topic | Where |
|
|
432
|
+
| -------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
433
|
+
| Complete language and compiler spec (normative) | [`@xessa/compiler` README](https://github.com/MARKjotep/xessa/blob/main/packages/compiler/README.md) and [`SPECIFICATION.md`](https://github.com/MARKjotep/xessa/blob/main/SPECIFICATION.md) |
|
|
434
|
+
| Grammar and lexical rules | [`docs/grammar.md`](https://github.com/MARKjotep/xessa/blob/main/docs/grammar.md) |
|
|
435
|
+
| Cascade and emitted order | [`docs/cascade.md`](https://github.com/MARKjotep/xessa/blob/main/docs/cascade.md) |
|
|
436
|
+
| Configuration keys and precedence | [`docs/configuration.md`](https://github.com/MARKjotep/xessa/blob/main/docs/configuration.md) |
|
|
437
|
+
| Practical usage guide | [`docs/usage.md`](https://github.com/MARKjotep/xessa/blob/main/docs/usage.md) |
|
|
438
|
+
| Compatibility and known limitations | [`docs/compatibility.md`](https://github.com/MARKjotep/xessa/blob/main/docs/compatibility.md), [`docs/known-limitations.md`](https://github.com/MARKjotep/xessa/blob/main/docs/known-limitations.md) |
|
|
439
|
+
| Editor integration (VS Code) | [`packages/vscode/README.md`](https://github.com/MARKjotep/xessa/blob/main/packages/vscode/README.md) |
|
|
440
|
+
| Compiler API | [`packages/compiler/README.md`](https://github.com/MARKjotep/xessa/blob/main/packages/compiler/README.md) |
|
|
441
|
+
|
|
442
|
+
## License
|
|
443
|
+
|
|
444
|
+
MIT. See [`LICENSE`](https://github.com/MARKjotep/xessa/blob/main/LICENSE).
|
package/dist/args.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command-line argument parsing for `xessa`.
|
|
3
|
+
*
|
|
4
|
+
* Parsing is strict: unknown flags, missing flag values, extra positional
|
|
5
|
+
* arguments and a missing command all fail with exit code 2 (invocation error).
|
|
6
|
+
* `--help` and `--version` short-circuit every other rule.
|
|
7
|
+
*/
|
|
8
|
+
/** Commands the CLI dispatches. */
|
|
9
|
+
export type CommandName = "build" | "check" | "watch" | "clean" | "format" | "help";
|
|
10
|
+
/** Parsed CLI invocation. */
|
|
11
|
+
export interface CliInvocation {
|
|
12
|
+
/** Selected command; `help` when only `--help`/`--version` was requested. */
|
|
13
|
+
readonly command: CommandName;
|
|
14
|
+
/** Optional source file for single-entry build/check/watch. */
|
|
15
|
+
readonly file?: string;
|
|
16
|
+
/** Explicit `--config` path, absolute or relative to the working directory. */
|
|
17
|
+
readonly configPath?: string;
|
|
18
|
+
/** Emit machine-readable JSON (build/check/clean) or NDJSON (watch). */
|
|
19
|
+
readonly json: boolean;
|
|
20
|
+
/** Report planned work without writing or deleting. */
|
|
21
|
+
readonly dryRun: boolean;
|
|
22
|
+
/** `true` for `--minify`, `false` for `--no-minify`, `undefined` when unset. */
|
|
23
|
+
readonly minify?: boolean;
|
|
24
|
+
/** `true` for `--check`: report files that `format` would change, write nothing. */
|
|
25
|
+
readonly check?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Parse outcome for {@link parseArgs}. */
|
|
28
|
+
export type ParseOutcome = {
|
|
29
|
+
readonly ok: true;
|
|
30
|
+
readonly invocation: CliInvocation;
|
|
31
|
+
readonly help: boolean;
|
|
32
|
+
readonly version: boolean;
|
|
33
|
+
} | {
|
|
34
|
+
readonly ok: false;
|
|
35
|
+
readonly message: string;
|
|
36
|
+
/** Whether `--json` was seen before the failure, so callers can emit JSON. */
|
|
37
|
+
readonly json: boolean;
|
|
38
|
+
};
|
|
39
|
+
/** Usage text written by `--help`. */
|
|
40
|
+
export declare const USAGE = "xessa \u2014 compile Xessa stylesheets\n\nUsage:\n xessa build [file] [flags]\n xessa check [file] [flags]\n xessa watch [file] [flags]\n xessa clean [flags]\n xessa format [file] [flags]\n xessa --help\n xessa --version\n\nCommands:\n build Compile the project (config include globs) or one file and write outputs\n check Report diagnostics and planned outputs without writing anything\n watch Rebuild changed entries until interrupted\n clean Delete compiler-owned outputs that were not modified since generation\n format Format sources canonically (with --check to report without writing)\n\nFlags:\n --config <path> Use a specific xessa.config.json instead of the nearest one\n --json Print machine-readable results\n --dry-run Report planned work without writing files or deleting them\n --minify Emit compact CSS\n --no-minify Emit expanded CSS\n --check With format: list files that would change; write nothing\n -h, --help Show this help\n -v, --version Print the CLI version\n\nExit codes:\n 0 success\n 1 compile, validation or formatting errors (or --check found changes)\n 2 invocation or configuration errors\n";
|
|
41
|
+
/** Parse process arguments (without `node`/script) into an invocation. */
|
|
42
|
+
export declare function parseArgs(argv: readonly string[]): ParseOutcome;
|
|
43
|
+
//# sourceMappingURL=args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,mCAAmC;AACnC,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEpF,6BAA6B;AAC7B,MAAM,WAAW,aAAa;IAC5B,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,uDAAuD;IACvD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,gFAAgF;IAChF,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,oFAAoF;IACpF,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,2CAA2C;AAC3C,MAAM,MAAM,YAAY,GACpB;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,GACD;IACE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB,CAAC;AAEN,sCAAsC;AACtC,eAAO,MAAM,KAAK,ysCAgCjB,CAAC;AAaF,0EAA0E;AAC1E,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,YAAY,CAsJ/D"}
|