diff --git a/.changeset/gentle-crabs-double.md b/.changeset/gentle-crabs-double.md new file mode 100644 index 0000000..6894244 --- /dev/null +++ b/.changeset/gentle-crabs-double.md @@ -0,0 +1,5 @@ +--- +"rdf-transform-graph-imports": patch +--- + +Add log when import is resolved diff --git a/index.ts b/index.ts index c6b95f1..a014f0e 100644 --- a/index.ts +++ b/index.ts @@ -1,10 +1,13 @@ import through2 from 'through2' import type { AnyPointer } from 'clownface' import type { Quad } from '@rdfjs/types' +import anylogger from 'anylogger' import { resolveImport } from './lib/path.js' import Environment from './lib/env.js' import fetchImport from './lib/fetchImport.js' +const log = anylogger('rdf-transform-graph-imports') + function transform(env: Environment) { const code = env.namespace('https://code.described.at/') @@ -27,6 +30,7 @@ function transform(env: Environment) { }) for (const importTarget of imports) { + log.debug(`Importing ${importTarget}`) const fetchStream = await fetchImport(env, importTarget) const importStream = fetchStream.pipe(transform(env)) diff --git a/package-lock.json b/package-lock.json index f79f2da..1e1dc09 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,15 @@ { "name": "rdf-transform-graph-imports", - "version": "0.1.0", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rdf-transform-graph-imports", - "version": "0.1.0", + "version": "0.2.0", "license": "MIT", "dependencies": { + "anylogger": "^1.0.11", "readable-stream": "3 - 4", "through2": "^4.0.2" }, @@ -40,6 +41,7 @@ "lint-staged": "^15.0.2", "mocha": "^10.2.0", "mocha-chai-jest-snapshot": "^1.1.4", + "patch-package": "^8.0.0", "sinon": "^17.0.1", "ts-node": "^10.9.1", "typescript": "^5.2.2" @@ -3086,6 +3088,12 @@ "dev": true, "peer": true }, + "node_modules/@yarnpkg/lockfile": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz", + "integrity": "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==", + "dev": true + }, "node_modules/@zazuko/env": { "version": "1.10.1", "resolved": "https://registry.npmjs.org/@zazuko/env/-/env-1.10.1.tgz", @@ -3307,6 +3315,11 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/anylogger": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/anylogger/-/anylogger-1.0.11.tgz", + "integrity": "sha512-sKTWPTG2/d71kLGVmymMJQQslUppxvCz6DN/eODL3/ckmfygZzD0t4P5tRXE3qpM62jI98F/YTHHzFhM12jiJQ==" + }, "node_modules/anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", @@ -3500,6 +3513,15 @@ "has-symbols": "^1.0.3" } }, + "node_modules/at-least-node": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", + "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", + "dev": true, + "engines": { + "node": ">= 4.0.0" + } + }, "node_modules/available-typed-arrays": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", @@ -5726,6 +5748,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/find-yarn-workspace-root": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz", + "integrity": "sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==", + "dev": true, + "dependencies": { + "micromatch": "^4.0.2" + } + }, "node_modules/find-yarn-workspace-root2": { "version": "1.2.16", "resolved": "https://registry.npmjs.org/find-yarn-workspace-root2/-/find-yarn-workspace-root2-1.2.16.tgz", @@ -6534,6 +6565,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true, + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -6822,6 +6868,18 @@ "node": ">=0.10.0" } }, + "node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", @@ -7139,6 +7197,24 @@ "dev": true, "peer": true }, + "node_modules/json-stable-stringify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.1.0.tgz", + "integrity": "sha512-zfA+5SuwYN2VWqN1/5HZaDzQKLJHaBVMZIIM+wuYjdptkaQsqzDdqjqf+lZZJUuJq1aanHiY8LhH8LmH+qBYJA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.5", + "isarray": "^2.0.5", + "jsonify": "^0.0.1", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", @@ -7146,6 +7222,12 @@ "dev": true, "peer": true }, + "node_modules/json-stable-stringify/node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "dev": true + }, "node_modules/json5": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", @@ -7168,6 +7250,15 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/jsonify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.1.tgz", + "integrity": "sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/jsonld": { "version": "8.3.1", "resolved": "https://registry.npmjs.org/jsonld/-/jsonld-8.3.1.tgz", @@ -7284,6 +7375,15 @@ "node": ">=0.10.0" } }, + "node_modules/klaw-sync": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/klaw-sync/-/klaw-sync-6.0.0.tgz", + "integrity": "sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.1.11" + } + }, "node_modules/kleur": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", @@ -7979,7 +8079,6 @@ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", "dev": true, - "peer": true, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -8491,6 +8590,22 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/open": { + "version": "7.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-7.4.2.tgz", + "integrity": "sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==", + "dev": true, + "dependencies": { + "is-docker": "^2.0.0", + "is-wsl": "^2.1.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/optionator": { "version": "0.9.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", @@ -8620,6 +8735,93 @@ "node": ">= 0.8" } }, + "node_modules/patch-package": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/patch-package/-/patch-package-8.0.0.tgz", + "integrity": "sha512-da8BVIhzjtgScwDJ2TtKsfT5JFWz1hYoBl9rUQ1f38MC2HwnEIkK8VN3dKMKcP7P7bvvgzNDbfNHtx3MsQb5vA==", + "dev": true, + "dependencies": { + "@yarnpkg/lockfile": "^1.1.0", + "chalk": "^4.1.2", + "ci-info": "^3.7.0", + "cross-spawn": "^7.0.3", + "find-yarn-workspace-root": "^2.0.0", + "fs-extra": "^9.0.0", + "json-stable-stringify": "^1.0.2", + "klaw-sync": "^6.0.0", + "minimist": "^1.2.6", + "open": "^7.4.2", + "rimraf": "^2.6.3", + "semver": "^7.5.3", + "slash": "^2.0.0", + "tmp": "^0.0.33", + "yaml": "^2.2.2" + }, + "bin": { + "patch-package": "index.js" + }, + "engines": { + "node": ">=14", + "npm": ">5" + } + }, + "node_modules/patch-package/node_modules/fs-extra": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", + "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", + "dev": true, + "dependencies": { + "at-least-node": "^1.0.0", + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/patch-package/node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/patch-package/node_modules/rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + } + }, + "node_modules/patch-package/node_modules/slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/patch-package/node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "dev": true, + "engines": { + "node": ">= 10.0.0" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", diff --git a/package.json b/package.json index f6423d1..2d57754 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "scripts": { "lint": "eslint --ext .ts --quiet --ignore-path .gitignore .", "test": "mocha", - "prepare": "husky install", + "prepare": "husky install; patch-package", "prepack": "tsc", "release": "changeset publish" }, @@ -36,6 +36,7 @@ }, "homepage": "https://github.com/zazuko/rdf-merge-stream#readme", "dependencies": { + "anylogger": "^1.0.11", "readable-stream": "3 - 4", "through2": "^4.0.2" }, @@ -67,6 +68,7 @@ "lint-staged": "^15.0.2", "mocha": "^10.2.0", "mocha-chai-jest-snapshot": "^1.1.4", + "patch-package": "^8.0.0", "sinon": "^17.0.1", "ts-node": "^10.9.1", "typescript": "^5.2.2" diff --git a/patches/anylogger+1.0.11.patch b/patches/anylogger+1.0.11.patch new file mode 100644 index 0000000..ddde3ff --- /dev/null +++ b/patches/anylogger+1.0.11.patch @@ -0,0 +1,185 @@ +diff --git a/node_modules/anylogger/anylogger.d.ts b/node_modules/anylogger/anylogger.d.ts +index 9a95f05..1b2a6a6 100644 +--- a/node_modules/anylogger/anylogger.d.ts ++++ b/node_modules/anylogger/anylogger.d.ts +@@ -1,88 +1,98 @@ +-export type BaseLevels = { +- error: 1, +- warn: 2, +- info: 3, +- log: 4, +- debug: 5, +- trace: 6, +-} ++declare namespace AnyLogger { ++ type BaseLevels = { ++ error: 1, ++ warn: 2, ++ info: 3, ++ log: 4, ++ debug: 5, ++ trace: 6, ++ } + +-export interface BaseLogger { +- /** +- * The name of this logger. +- */ +- name: string +- +- (level: keyof L, message?: any, ...args: any[]): void +- (message?: any, ...args: any[]): void +- +- error(message?: any, ...args: any[]): void +- warn(message?: any, ...args: any[]): void +- info(message?: any, ...args: any[]): void +- log(message?: any, ...args: any[]): void +- debug(message?: any, ...args: any[]): void +- trace(message?: any, ...args: any[]): void +- enabledFor(level: keyof L): boolean +-} ++ interface BaseLogger { ++ /** ++ * The name of this logger. ++ */ ++ name: string + +-export type Logger = BaseLogger & { +- [P in keyof Omit]: (message?: any, ...args: any[]) => void +-} ++ (level: keyof L, message?: any, ...args: any[]): void ++ ++ (message?: any, ...args: any[]): void ++ ++ error(message?: any, ...args: any[]): void ++ ++ warn(message?: any, ...args: any[]): void ++ ++ info(message?: any, ...args: any[]): void ++ ++ log(message?: any, ...args: any[]): void ++ ++ debug(message?: any, ...args: any[]): void ++ ++ trace(message?: any, ...args: any[]): void ++ ++ enabledFor(level: keyof L): boolean ++ } ++ ++ type Logger = BaseLogger & { ++ [P in keyof Omit]: (message?: any, ...args: any[]) => void ++ } ++ ++ interface AnyLogger = Logger> { ++ /** ++ * Returns an object containing all loggers created so far, keyed by name. ++ */ ++ (): { [name: string]: T } ++ ++ /** ++ * @param name The name of the new logger. ++ * @param config An optional config object. ++ * @returns A logger with the given `name` and `config`. ++ */ ++ (name: string, config?: object | undefined): T ++ ++ /** ++ * An object containing a mapping of level names to level values. ++ */ ++ levels: L & { [name: string]: number } ++ ++ /** ++ * Creates a new logger function that calls `anylogger.log` when invoked. ++ * ++ * @param name The name of the new logger. ++ * @param config An optional config object. ++ * @returns A new logger function with the given `name`. ++ */ ++ new(name: string, config?: object | undefined): T ++ ++ /** ++ * The log function used by `anylogger.new`. ++ * ++ * @param name The name of the logger to use ++ * @param level The log level. ++ * @param message The (formatted) message or any data to log. ++ * @param [params] Additional log (formatting) arguments. ++ */ ++ log(name: string, level: keyof L, message?: any, ...args: any[]): void ++ ++ /** ++ * The log function used by `anylogger.new`. ++ * ++ * @param name The name of the logger to use ++ * @param args The log arguments. ++ * @param message The (formatted) message or any data to log. ++ * @param [params] Additional log (formatting) arguments. ++ */ ++ log(name: string, message?: any, ...args: any[]): void ++ ++ /** ++ * @param logger The logger that should be (re-)extended. ++ * @return The logger that was given, extended. ++ */ ++ ext(logger: T): T ++ } + +-export interface AnyLogger = Logger> { +- /** +- * Returns an object containing all loggers created so far, keyed by name. +- */ +- (): { [name: string]: T } +- +- /** +- * @param name The name of the new logger. +- * @param config An optional config object. +- * @returns A logger with the given `name` and `config`. +- */ +- (name: string, config?: object | undefined): T +- +- /** +- * An object containing a mapping of level names to level values. +- */ +- levels: L & { [name: string]: number } +- +- /** +- * Creates a new logger function that calls `anylogger.log` when invoked. +- * +- * @param name The name of the new logger. +- * @param config An optional config object. +- * @returns A new logger function with the given `name`. +- */ +- new(name: string, config?: object | undefined): T +- +- /** +- * The log function used by `anylogger.new`. +- * +- * @param name The name of the logger to use +- * @param level The log level. +- * @param message The (formatted) message or any data to log. +- * @param [params] Additional log (formatting) arguments. +- */ +- log(name: string, level: keyof L, message?: any, ...args: any[]): void +- +- /** +- * The log function used by `anylogger.new`. +- * +- * @param name The name of the logger to use +- * @param args The log arguments. +- * @param message The (formatted) message or any data to log. +- * @param [params] Additional log (formatting) arguments. +- */ +- log(name: string, message?: any, ...args: any[]): void +- +- /** +- * @param logger The logger that should be (re-)extended. +- * @return The logger that was given, extended. +- */ +- ext(logger: T): T + } + +-declare const anylogger: AnyLogger ++declare const anylogger: AnyLogger.AnyLogger + +-export default anylogger ++export = anylogger