From 2e8d685a53257f66c94d1bf5c56c8724c4541720 Mon Sep 17 00:00:00 2001 From: zhongliang02 Date: Thu, 7 Nov 2024 13:42:13 +0800 Subject: [PATCH 1/5] fix: package json exports --- packages/validators/package.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/validators/package.json b/packages/validators/package.json index 4d90700..4c31862 100644 --- a/packages/validators/package.json +++ b/packages/validators/package.json @@ -4,6 +4,10 @@ "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { + ".": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, "./url": { "types": "./dist/url/index.d.ts", "default": "./dist/url/index.js" @@ -19,6 +23,9 @@ }, "typesVersions": { "*": { + ".": [ + "./dist/index.d.ts" + ], "url": [ "./dist/url/index.d.ts" ], From 9072b3930ecdef0538233ba59d972f167acea3c4 Mon Sep 17 00:00:00 2001 From: zhongliang02 Date: Thu, 7 Nov 2024 14:34:30 +0800 Subject: [PATCH 2/5] bump package version to 1.2.7 --- packages/validators/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/validators/package.json b/packages/validators/package.json index 4c31862..6a90fda 100644 --- a/packages/validators/package.json +++ b/packages/validators/package.json @@ -1,6 +1,6 @@ { "name": "@opengovsg/starter-kitty-validators", - "version": "1.2.6", + "version": "1.2.7", "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { From 5742eb99c906cedc746d3adca468da664da6208c Mon Sep 17 00:00:00 2001 From: zhongliang02 Date: Tue, 19 Nov 2024 11:07:16 +0800 Subject: [PATCH 3/5] fix: replace node: imports --- apps/docs/.vitepress/utils.ts | 4 ++-- packages/eslint-config/index.js | 2 +- packages/safe-fs/src/__tests__/fs.test.ts | 4 ++-- packages/safe-fs/src/getter.ts | 2 +- packages/safe-fs/src/index.ts | 2 +- packages/safe-fs/src/sanitizers.ts | 4 ++-- packages/safe-fs/vitest.config.ts | 2 +- packages/safe-fs/vitest.setup.ts | 4 ++-- packages/validators/src/__tests__/path.test.ts | 2 +- packages/validators/src/path/options.ts | 2 +- packages/validators/src/path/schema.ts | 2 +- packages/validators/src/path/utils.ts | 2 +- packages/validators/vitest.config.ts | 2 +- 13 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/docs/.vitepress/utils.ts b/apps/docs/.vitepress/utils.ts index 565a82a..6940e41 100644 --- a/apps/docs/.vitepress/utils.ts +++ b/apps/docs/.vitepress/utils.ts @@ -1,5 +1,5 @@ -import fs from 'node:fs' -import path from 'node:path' +import fs from 'fs' +import path from 'path' export const scanDir = (dir: string) => { let res = fs.readdirSync(path.resolve(__dirname, `../${dir}`)).filter(item => !item.startsWith('.')) as string[] diff --git a/packages/eslint-config/index.js b/packages/eslint-config/index.js index cfe18a2..dc53b40 100644 --- a/packages/eslint-config/index.js +++ b/packages/eslint-config/index.js @@ -1,4 +1,4 @@ -const { resolve } = require("node:path"); +const { resolve } = require("path"); const project = resolve(process.cwd(), "tsconfig.json"); diff --git a/packages/safe-fs/src/__tests__/fs.test.ts b/packages/safe-fs/src/__tests__/fs.test.ts index f17b73d..3e80b2f 100644 --- a/packages/safe-fs/src/__tests__/fs.test.ts +++ b/packages/safe-fs/src/__tests__/fs.test.ts @@ -1,5 +1,5 @@ -import fs from 'node:fs' -import path from 'node:path' +import fs from 'fs' +import path from 'path' import { vol } from 'memfs' import { beforeEach, describe, expect, it } from 'vitest' diff --git a/packages/safe-fs/src/getter.ts b/packages/safe-fs/src/getter.ts index be4071e..094cf93 100644 --- a/packages/safe-fs/src/getter.ts +++ b/packages/safe-fs/src/getter.ts @@ -1,4 +1,4 @@ -import fs from 'node:fs' +import fs from 'fs' import PARAMS_TO_SANITIZE from '@/params' import { sanitizePath } from '@/sanitizers' diff --git a/packages/safe-fs/src/index.ts b/packages/safe-fs/src/index.ts index e5e5779..58d46f5 100644 --- a/packages/safe-fs/src/index.ts +++ b/packages/safe-fs/src/index.ts @@ -4,7 +4,7 @@ * @packageDocumentation */ -import * as fs from 'node:fs' +import * as fs from 'fs' import { createGetter } from '@/getter' diff --git a/packages/safe-fs/src/sanitizers.ts b/packages/safe-fs/src/sanitizers.ts index 3dcd009..054f821 100644 --- a/packages/safe-fs/src/sanitizers.ts +++ b/packages/safe-fs/src/sanitizers.ts @@ -1,5 +1,5 @@ -import { PathLike } from 'node:fs' -import path from 'node:path' +import { PathLike } from 'fs' +import path from 'path' const LEADING_DOT_SLASH_REGEX = /^(\.\.(\/|\\|$))+/ diff --git a/packages/safe-fs/vitest.config.ts b/packages/safe-fs/vitest.config.ts index 9ff6101..fe822c3 100644 --- a/packages/safe-fs/vitest.config.ts +++ b/packages/safe-fs/vitest.config.ts @@ -1,4 +1,4 @@ -import path from 'node:path' +import path from 'path' export default { resolve: { diff --git a/packages/safe-fs/vitest.setup.ts b/packages/safe-fs/vitest.setup.ts index 6319d9d..6b12795 100644 --- a/packages/safe-fs/vitest.setup.ts +++ b/packages/safe-fs/vitest.setup.ts @@ -1,6 +1,6 @@ import { vi } from 'vitest' -vi.mock('node:fs', async () => { +vi.mock('fs', async () => { const memfs: { fs: typeof fs } = await vi.importActual('memfs') return { @@ -10,7 +10,7 @@ vi.mock('node:fs', async () => { } }) -vi.mock('node:fs/promises', async () => { +vi.mock('fs/promises', async () => { const memfs: { fs: typeof fs } = await vi.importActual('memfs') return { diff --git a/packages/validators/src/__tests__/path.test.ts b/packages/validators/src/__tests__/path.test.ts index dd4c6ba..ff3c843 100644 --- a/packages/validators/src/__tests__/path.test.ts +++ b/packages/validators/src/__tests__/path.test.ts @@ -1,4 +1,4 @@ -import path from 'node:path' +import path from 'path' import { describe, expect, it } from 'vitest' import { ZodError } from 'zod' diff --git a/packages/validators/src/path/options.ts b/packages/validators/src/path/options.ts index 2712c66..3e93ad4 100644 --- a/packages/validators/src/path/options.ts +++ b/packages/validators/src/path/options.ts @@ -1,4 +1,4 @@ -import path from 'node:path' +import path from 'path' import { z } from 'zod' diff --git a/packages/validators/src/path/schema.ts b/packages/validators/src/path/schema.ts index a177074..6bb6a25 100644 --- a/packages/validators/src/path/schema.ts +++ b/packages/validators/src/path/schema.ts @@ -1,4 +1,4 @@ -import path from 'node:path' +import path from 'path' import { z } from 'zod' diff --git a/packages/validators/src/path/utils.ts b/packages/validators/src/path/utils.ts index 4b21f18..5f48e04 100644 --- a/packages/validators/src/path/utils.ts +++ b/packages/validators/src/path/utils.ts @@ -1,4 +1,4 @@ -import path from 'node:path' +import path from 'path' export const isSafePath = (absPath: string, basePath: string): boolean => { // check for poison null bytes diff --git a/packages/validators/vitest.config.ts b/packages/validators/vitest.config.ts index 0733414..d7eb39e 100644 --- a/packages/validators/vitest.config.ts +++ b/packages/validators/vitest.config.ts @@ -1,4 +1,4 @@ -import path from 'node:path' +import path from 'path' export default { resolve: { From 0c79e953e3b5eb13ab6c73ed2a55a627f6376f04 Mon Sep 17 00:00:00 2001 From: zhongliang02 Date: Tue, 19 Nov 2024 11:24:40 +0800 Subject: [PATCH 4/5] chore: bump version number --- packages/validators/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/validators/package.json b/packages/validators/package.json index 6a90fda..5975217 100644 --- a/packages/validators/package.json +++ b/packages/validators/package.json @@ -1,6 +1,6 @@ { "name": "@opengovsg/starter-kitty-validators", - "version": "1.2.7", + "version": "1.2.8", "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { From 3ea595bf86c3fd1fbb6bf08a6370218db3264f03 Mon Sep 17 00:00:00 2001 From: zhongliang02 Date: Tue, 19 Nov 2024 11:32:47 +0800 Subject: [PATCH 5/5] chore: linting --- packages/safe-fs/src/__tests__/fs.test.ts | 3 +-- packages/validators/src/__tests__/path.test.ts | 1 - packages/validators/src/path/options.ts | 1 - packages/validators/src/path/schema.ts | 1 - 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/safe-fs/src/__tests__/fs.test.ts b/packages/safe-fs/src/__tests__/fs.test.ts index 3e80b2f..3fd5664 100644 --- a/packages/safe-fs/src/__tests__/fs.test.ts +++ b/packages/safe-fs/src/__tests__/fs.test.ts @@ -1,7 +1,6 @@ import fs from 'fs' -import path from 'path' - import { vol } from 'memfs' +import path from 'path' import { beforeEach, describe, expect, it } from 'vitest' import { createGetter } from '@/getter' diff --git a/packages/validators/src/__tests__/path.test.ts b/packages/validators/src/__tests__/path.test.ts index ff3c843..c5c41ce 100644 --- a/packages/validators/src/__tests__/path.test.ts +++ b/packages/validators/src/__tests__/path.test.ts @@ -1,5 +1,4 @@ import path from 'path' - import { describe, expect, it } from 'vitest' import { ZodError } from 'zod' diff --git a/packages/validators/src/path/options.ts b/packages/validators/src/path/options.ts index 3e93ad4..46d9bcc 100644 --- a/packages/validators/src/path/options.ts +++ b/packages/validators/src/path/options.ts @@ -1,5 +1,4 @@ import path from 'path' - import { z } from 'zod' /** diff --git a/packages/validators/src/path/schema.ts b/packages/validators/src/path/schema.ts index 6bb6a25..1df1ab2 100644 --- a/packages/validators/src/path/schema.ts +++ b/packages/validators/src/path/schema.ts @@ -1,5 +1,4 @@ import path from 'path' - import { z } from 'zod' import { ParsedPathValidatorOptions } from '@/path/options'