@schalkneethling/css-property-type-validator-cli 0.1.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/LICENSE +21 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +49 -0
- package/dist/cli.js.map +1 -0
- package/dist/formatter.d.ts +5 -0
- package/dist/formatter.d.ts.map +1 -0
- package/dist/formatter.js +25 -0
- package/dist/formatter.js.map +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Schalk Neethling
|
|
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/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { glob, readFile } from "node:fs/promises";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import { validateFiles } from "@schalkneethling/css-property-type-validator-core";
|
|
6
|
+
import { formatValidationResult } from "./formatter.js";
|
|
7
|
+
async function loadInputs(patterns) {
|
|
8
|
+
const filePaths = new Set();
|
|
9
|
+
for (const pattern of patterns) {
|
|
10
|
+
for await (const filePath of glob(pattern, { cwd: process.cwd() })) {
|
|
11
|
+
filePaths.add(filePath);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const cssFiles = [...filePaths]
|
|
15
|
+
.filter((filePath) => filePath.endsWith(".css"))
|
|
16
|
+
.map((filePath) => (filePath.startsWith("/") ? filePath : `${process.cwd()}/${filePath}`));
|
|
17
|
+
const inputs = await Promise.all(cssFiles.map(async (filePath) => ({
|
|
18
|
+
path: filePath,
|
|
19
|
+
css: await readFile(filePath, "utf8"),
|
|
20
|
+
})));
|
|
21
|
+
return inputs.sort((left, right) => left.path.localeCompare(right.path));
|
|
22
|
+
}
|
|
23
|
+
async function main() {
|
|
24
|
+
const program = new Command();
|
|
25
|
+
program
|
|
26
|
+
.name("css-property-type-validator")
|
|
27
|
+
.description("Validate @property registrations and var() usages across CSS files.")
|
|
28
|
+
.argument("<patterns...>", "CSS files or glob patterns to validate")
|
|
29
|
+
.option("-f, --format <format>", "output format: human or json", "human")
|
|
30
|
+
.action(async (patterns, options) => {
|
|
31
|
+
const format = options.format === "json" ? "json" : "human";
|
|
32
|
+
const inputs = await loadInputs(patterns);
|
|
33
|
+
if (inputs.length === 0) {
|
|
34
|
+
process.stderr.write("No CSS files matched the provided patterns.\n");
|
|
35
|
+
process.exitCode = 2;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const result = validateFiles(inputs);
|
|
39
|
+
const output = formatValidationResult(result, format);
|
|
40
|
+
process.stdout.write(`${output}\n`);
|
|
41
|
+
process.exitCode = result.diagnostics.length > 0 ? 1 : 0;
|
|
42
|
+
});
|
|
43
|
+
await program.parseAsync(process.argv);
|
|
44
|
+
}
|
|
45
|
+
main().catch((error) => {
|
|
46
|
+
process.stderr.write(`${error.message}\n`);
|
|
47
|
+
process.exit(2);
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,mDAAmD,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAMxD,KAAK,UAAU,UAAU,CAAC,QAAkB;IAC1C,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IAEpC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,KAAK,EAAE,MAAM,QAAQ,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC;YACnE,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,CAAC,GAAG,SAAS,CAAC;SAC5B,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,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;YACtE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACrB,OAAO;QACT,CAAC;QAED,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAEtD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC,CAAC;QACpC,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEL,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAI,KAAe,CAAC,OAAO,IAAI,CAAC,CAAC;IACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ValidationResult } from "@schalkneethling/css-property-type-validator-core";
|
|
2
|
+
type OutputFormat = "human" | "json";
|
|
3
|
+
export declare function formatValidationResult(result: ValidationResult, format: OutputFormat): string;
|
|
4
|
+
export {};
|
|
5
|
+
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,mDAAmD,CAAC;AAE3D,KAAK,YAAY,GAAG,OAAO,GAAG,MAAM,CAAC;AA6BrC,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,CAE7F"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function formatLocation(diagnostic) {
|
|
2
|
+
if (!diagnostic.loc) {
|
|
3
|
+
return diagnostic.filePath;
|
|
4
|
+
}
|
|
5
|
+
return `${diagnostic.filePath}:${diagnostic.loc.start.line}:${diagnostic.loc.start.column}`;
|
|
6
|
+
}
|
|
7
|
+
function formatHuman(diagnostics) {
|
|
8
|
+
if (diagnostics.length === 0) {
|
|
9
|
+
return "No validation issues found.";
|
|
10
|
+
}
|
|
11
|
+
return diagnostics
|
|
12
|
+
.map((diagnostic) => {
|
|
13
|
+
const location = formatLocation(diagnostic);
|
|
14
|
+
const details = [`${location} ${diagnostic.code}`, diagnostic.message];
|
|
15
|
+
if (diagnostic.snippet) {
|
|
16
|
+
details.push(` ${diagnostic.snippet}`);
|
|
17
|
+
}
|
|
18
|
+
return details.join("\n");
|
|
19
|
+
})
|
|
20
|
+
.join("\n\n");
|
|
21
|
+
}
|
|
22
|
+
export function formatValidationResult(result, format) {
|
|
23
|
+
return format === "json" ? JSON.stringify(result, null, 2) : formatHuman(result.diagnostics);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAOA,SAAS,cAAc,CAAC,UAAgC;IACtD,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;QACpB,OAAO,UAAU,CAAC,QAAQ,CAAC;IAC7B,CAAC;IAED,OAAO,GAAG,UAAU,CAAC,QAAQ,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;AAC9F,CAAC;AAED,SAAS,WAAW,CAAC,WAAmC;IACtD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,6BAA6B,CAAC;IACvC,CAAC;IAED,OAAO,WAAW;SACf,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;QAClB,MAAM,QAAQ,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;QAC5C,MAAM,OAAO,GAAG,CAAC,GAAG,QAAQ,IAAI,UAAU,CAAC,IAAI,EAAE,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;QAEvE,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;YACvB,OAAO,CAAC,IAAI,CAAC,KAAK,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;QAC1C,CAAC;QAED,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC;SACD,IAAI,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,MAAwB,EAAE,MAAoB;IACnF,OAAO,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC/F,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@schalkneethling/css-property-type-validator-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI for CSS custom property type validator.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"css",
|
|
7
|
+
"custom-properties",
|
|
8
|
+
"property",
|
|
9
|
+
"validator",
|
|
10
|
+
"cli"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "Schalk Neethling",
|
|
14
|
+
"bin": {
|
|
15
|
+
"css-property-type-validator": "./dist/cli.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/schalkneethling/css-property-type-validator.git",
|
|
24
|
+
"directory": "packages/cli"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/schalkneethling/css-property-type-validator#readme",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/schalkneethling/css-property-type-validator/issues"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"commander": "^14.0.3",
|
|
35
|
+
"@schalkneethling/css-property-type-validator-core": "0.1.0"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc -p tsconfig.json"
|
|
39
|
+
}
|
|
40
|
+
}
|