diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9d6eefd5..7ec5b918 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -50,13 +50,36 @@ importers: typescript: ^3.9.7 tools/tupctime: dependencies: + '@types/better-sqlite3': 5.4.0 + '@types/debug': 4.1.5 + '@types/node': 14.0.23 better-sqlite3: 7.0.1 debug: 4.1.1 + devDependencies: + typescript: 3.9.7 specifiers: + '@types/better-sqlite3': ^5.4.0 + '@types/debug': ^4.1.5 + '@types/node': ^14.0.23 better-sqlite3: ^7.0.1 debug: ^4.1.1 + typescript: ^3.9.7 lockfileVersion: 5.1 packages: + /@types/better-sqlite3/5.4.0: + dependencies: + '@types/integer': 1.0.1 + dev: false + resolution: + integrity: sha512-nzm7lJ7l3jBmGUbtkL8cdOMhPkN6Pw2IM+b0V7iIKba+YKiLrjkIy7vVLsBIVnd7+lgzBzrHsXZxCaFTcmw5Ow== + /@types/debug/4.1.5: + dev: false + resolution: + integrity: sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ== + /@types/integer/1.0.1: + dev: false + resolution: + integrity: sha512-DmZDpSVnsuBrOhtHwE1oKmUJ3qVjHhhNQ7WnZy9/RhH3A24Ar+9o4SoaCWcTzQhalpRDIAMsfdoZLWNJtdBR7A== /@types/node/14.0.23: dev: false resolution: diff --git a/tools/tupctime/index.js b/tools/tupctime/index.ts similarity index 82% rename from tools/tupctime/index.js rename to tools/tupctime/index.ts index 6053acd9..a41b734c 100644 --- a/tools/tupctime/index.js +++ b/tools/tupctime/index.ts @@ -40,7 +40,7 @@ AND name NOT IN ('^', '$')`); const updateQuery = db.prepare(`UPDATE node SET mtime = ? WHERE id = ?`); function update() { - const stack = [{isDir: true, id: 0, path: "."}]; + const stack : {isDir: boolean, id : number, path: string, ctime?: bigint, name?: string}[] = [{isDir: true, id: 0, path: "."}]; let item; while (item = stack.pop()) { @@ -57,11 +57,16 @@ function update() { } } else { // bigint calculation is necessary to avoid rounding errors/spurious update + // + // typescript doesn't understand second argument to lstatSync, or + // that division can work between a number and bigint, so ignore + // + // @ts-ignore const ctime = fs.lstatSync(item.path, {bigint: true}).ctimeMs / 1000n; if (ctime !== item.ctime) { debug(`Updating ${item.path}: ${ctime}, ${item.ctime}`); if (updateQuery.run(ctime, item.id).changes !== 1) - throw new Error(`Couldn't update ${path}`); + throw new Error(`Couldn't update ${item.path}`); } } } diff --git a/tools/tupctime/package.json b/tools/tupctime/package.json index 7c16e87e..050d1291 100644 --- a/tools/tupctime/package.json +++ b/tools/tupctime/package.json @@ -1,7 +1,17 @@ { "dependencies": { - "better-sqlite3":"^7.0.1", - "debug":"^4.1.1" + "@types/better-sqlite3": "^5.4.0", + "@types/debug": "^4.1.5", + "@types/node": "^14.0.23", + "better-sqlite3": "^7.0.1", + "debug": "^4.1.1" }, - "type": "module" + "type": "module", + "scripts": { + "prepare": "tsc" + }, + "devDependencies": { + "typescript": "^3.9.7" + }, + "main": "./dist/index.js" } diff --git a/tools/tupctime/tsconfig.json b/tools/tupctime/tsconfig.json new file mode 100644 index 00000000..e37f4e41 --- /dev/null +++ b/tools/tupctime/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "../../tsconfig-base", + "compilerOptions": { + "outDir": "dist", + } +} diff --git a/tsconfig-base.json b/tsconfig-base.json index 43b6acb4..6683b035 100644 --- a/tsconfig-base.json +++ b/tsconfig-base.json @@ -1,8 +1,8 @@ { "compilerOptions": { "incremental": true, - "target": "es2018", - "lib": ["es2018"], + "target": "es2020", + "lib": ["es2020"], "module": "esnext", "jsx": "react", "strict": true,