@citemap/cli 0.3.1 → 0.3.3
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.
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
2
|
|
|
4
3
|
// src/index.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var VERSION = "0.3.
|
|
4
|
+
import { readFileSync } from "fs";
|
|
5
|
+
import { resolve } from "path";
|
|
6
|
+
import { validate, validateAndDiagnose } from "@citemap/validator";
|
|
7
|
+
var VERSION = "0.3.3";
|
|
9
8
|
var colors = {
|
|
10
9
|
reset: "\x1B[0m",
|
|
11
10
|
bright: "\x1B[1m",
|
|
@@ -40,8 +39,8 @@ function printVersion() {
|
|
|
40
39
|
}
|
|
41
40
|
function loadJSON(filePath) {
|
|
42
41
|
try {
|
|
43
|
-
const absolutePath =
|
|
44
|
-
const content =
|
|
42
|
+
const absolutePath = resolve(filePath);
|
|
43
|
+
const content = readFileSync(absolutePath, "utf-8");
|
|
45
44
|
return JSON.parse(content);
|
|
46
45
|
} catch (error) {
|
|
47
46
|
if (error instanceof SyntaxError) {
|
|
@@ -106,7 +105,7 @@ ${statusIcon} ${statusText} citemap.json ${colors.dim}v${result.version}${color
|
|
|
106
105
|
process.exit(result.valid ? 0 : 1);
|
|
107
106
|
}
|
|
108
107
|
function formatDiagnosticOutput(data) {
|
|
109
|
-
const result =
|
|
108
|
+
const result = validateAndDiagnose(data);
|
|
110
109
|
const diag = result.diagnosis;
|
|
111
110
|
const statusIcon = result.valid ? `${colors.green}\u2713${colors.reset}` : `${colors.red}\u2717${colors.reset}`;
|
|
112
111
|
const statusText = result.valid ? `${colors.green}Valid${colors.reset}` : `${colors.red}Invalid${colors.reset}`;
|
|
@@ -202,7 +201,7 @@ async function main() {
|
|
|
202
201
|
}
|
|
203
202
|
const data = loadJSON(filePath);
|
|
204
203
|
if (command === "validate") {
|
|
205
|
-
const result =
|
|
204
|
+
const result = validate(data);
|
|
206
205
|
formatValidationOutput(result);
|
|
207
206
|
} else if (command === "diagnose") {
|
|
208
207
|
formatDiagnosticOutput(data);
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@citemap/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Command-line tool for validating citemap.json files",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"citemap": "./dist/index.
|
|
7
|
+
"citemap": "./dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "tsup src/index.ts --format
|
|
13
|
+
"build": "tsup src/index.ts --format esm --no-dts --out-dir dist",
|
|
14
14
|
"dev": "node --loader ts-node/esm src/index.ts",
|
|
15
15
|
"prepublishOnly": "npm run build"
|
|
16
16
|
},
|