Dropped custom GUID validation function in favour of standard uuid library.
All checks were successful
build / build (push) Successful in 10s

This commit is contained in:
2026-03-07 14:40:55 +01:00
parent fe1b8f0e1f
commit 4dac95e081
4 changed files with 42 additions and 13 deletions

36
package-lock.json generated
View File

@@ -1,16 +1,21 @@
{ {
"name": "@slawek/sk-tools", "name": "@slawek/sk-tools",
"version": "0.1.2", "version": "0.1.3",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@slawek/sk-tools", "name": "@slawek/sk-tools",
"version": "0.1.0", "version": "0.1.2",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"d3-dsv": "^3.0.1", "d3-dsv": "^3.0.1",
"jmespath": "^0.16.0" "jmespath": "^0.16.0",
"semver": "^7.7.4",
"uuid": "^11.1.0"
},
"bin": {
"sk-tools": "dist/cli.js"
}, },
"devDependencies": { "devDependencies": {
"@types/d3-dsv": "^3.0.7", "@types/d3-dsv": "^3.0.7",
@@ -113,6 +118,18 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/semver": {
"version": "7.7.4",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
"integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/typescript": { "node_modules/typescript": {
"version": "5.9.3", "version": "5.9.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
@@ -133,6 +150,19 @@
"integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==",
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
},
"node_modules/uuid": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz",
"integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==",
"funding": [
"https://github.com/sponsors/broofa",
"https://github.com/sponsors/ctavan"
],
"license": "MIT",
"bin": {
"uuid": "dist/esm/bin/uuid"
}
} }
} }
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "@slawek/sk-tools", "name": "@slawek/sk-tools",
"version": "0.1.2", "version": "0.1.3",
"type": "module", "type": "module",
"files": [ "files": [
"dist", "dist",
@@ -10,8 +10,7 @@
"scripts": { "scripts": {
"clean": "rm -rf dist", "clean": "rm -rf dist",
"build": "npm run clean && tsc && chmod +x dist/cli.js", "build": "npm run clean && tsc && chmod +x dist/cli.js",
"build:watch": "tsc --watch", "build:watch": "tsc --watch"
"prepublishOnly": "npm run build"
}, },
"engines": { "engines": {
"node": ">=24.0.0" "node": ">=24.0.0"
@@ -19,7 +18,9 @@
"description": "A set of generic NodeJS utilities shared by Slawek tools.", "description": "A set of generic NodeJS utilities shared by Slawek tools.",
"dependencies": { "dependencies": {
"d3-dsv": "^3.0.1", "d3-dsv": "^3.0.1",
"jmespath": "^0.16.0" "jmespath": "^0.16.0",
"semver": "^7.7.4",
"uuid": "^11.1.0"
}, },
"devDependencies": { "devDependencies": {
"@types/d3-dsv": "^3.0.7", "@types/d3-dsv": "^3.0.7",

View File

@@ -9,3 +9,4 @@ export {
readCsvFromStdin, readCsvFromStdin,
renderOutput, renderOutput,
} from "./cli/utils.ts"; } from "./cli/utils.ts";
export { getConfig } from "./config/index.ts";

View File

@@ -1,5 +1,7 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
import { validate as validateUuid } from "uuid";
type Scalar = string | number | boolean | null | undefined; type Scalar = string | number | boolean | null | undefined;
type ScalarRow = Record<string, Scalar>; type ScalarRow = Record<string, Scalar>;
@@ -20,7 +22,7 @@ function formatCell(value: unknown): string {
} }
const inlineCodePredicates = [ const inlineCodePredicates = [
(value: Scalar): boolean => isGuid(value), (value: Scalar): boolean => typeof value === "string" && validateUuid(value),
(value: Scalar): boolean => (value: Scalar): boolean =>
typeof value === "string" typeof value === "string"
&& /^(?:\d{1,3}\.){3}\d{1,3}(?:\/(?:\d{1,2}|(?:\d{1,3}\.){3}\d{1,3}))?$/.test(value), && /^(?:\d{1,3}\.){3}\d{1,3}(?:\/(?:\d{1,2}|(?:\d{1,3}\.){3}\d{1,3}))?$/.test(value),
@@ -38,11 +40,6 @@ function renderCell(raw: Scalar, shouldQuote: boolean): string {
return text; return text;
} }
function isGuid(value: unknown): value is string {
return typeof value === "string"
&& /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
}
function toAutoHeaderLabel(key: string): string { function toAutoHeaderLabel(key: string): string {
const withSpaces = String(key) const withSpaces = String(key)
.replace(/[_-]+/g, " ") .replace(/[_-]+/g, " ")