From cd4a8262a0951fd085b0f668c957aab70a2fc3aa Mon Sep 17 00:00:00 2001 From: Ian Macartney Date: Wed, 17 Jul 2024 10:20:37 -0700 Subject: [PATCH 01/14] publish npm command --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c5c00c11..ee6ed206 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "test:coverage": "vitest run --coverage --coverage.reporter=text", "testFunctionsExistingBackend": "just convex deploy && just convex env set IS_TEST true && vitest --run convex/example.test.ts", "testFunctions": "node backendHarness.js 'npm run testFunctionsExistingBackend'", - "arethetypeswrong": "cd packges/convex-helpers/dist && attw $(npm pack)" + "arethetypeswrong": "cd packges/convex-helpers/dist && attw $(npm pack)", + "publish": "./publish.sh" }, "dependencies": { "classnames": "^2.3.2", From ca7cb2f93ec1b19c8b23ee1f47e8e4225596bc36 Mon Sep 17 00:00:00 2001 From: Ian Macartney Date: Wed, 17 Jul 2024 11:10:33 -0700 Subject: [PATCH 02/14] add entrypoint directories for every file --- package-lock.json | 7 +- package.json | 6 +- packages/convex-helpers/generate-exports.mjs | 43 +++++++++-- packages/convex-helpers/package.json | 76 ++++++++++---------- packages/convex-helpers/tsconfig.json | 2 +- publish.sh | 5 +- 6 files changed, 85 insertions(+), 54 deletions(-) diff --git a/package-lock.json b/package-lock.json index cab778a5..3c9a8226 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "dependencies": { "classnames": "^2.3.2", "convex": "^1.13.0", - "convex-helpers": "file:packages/convex-helpers/dist", + "convex-helpers": "file:packages/convex-helpers", "hono": "^4.3.6", "react": "^18.0.0", "react-dom": "^18.0.0", @@ -2553,7 +2553,7 @@ } }, "node_modules/convex-helpers": { - "resolved": "packages/convex-helpers/dist", + "resolved": "packages/convex-helpers", "link": true }, "node_modules/convex-test": { @@ -6436,8 +6436,7 @@ "url": "https://github.com/sponsors/colinhacks" } }, - "packages/convex-helpers/dist": { - "name": "convex-helpers", + "packages/convex-helpers": { "version": "0.1.49-alpha.0", "license": "MIT", "peerDependencies": { diff --git a/package.json b/package.json index ee6ed206..11b0876c 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "dev:helpers": "cd packages/convex-helpers && chokidar '*.ts' 'server/**/*.ts' 'react/**/*.ts*' 'tsconfig*.json' 'package.json' -c 'npm run build' --initial", "predev": "cd packages/convex-helpers && npm run build", "lint": "tsc --project tsconfig.test.json", - "build": "cd packages/convex-helpers && node generate-exports.mjs && mkdir -p dist && cp -r *.ts server react ./package.json ./tsconfig.json ./README.md ../../LICENSE ./.npmignore dist/ && rm dist/server/_generated/_ignore.ts && cd dist/ && tsc", + "build": "cd packages/convex-helpers && node generate-exports.mjs && tsc", "clean": "rm -rf packages/convex-helpers/dist", "test": "vitest run", "test:watch": "vitest", @@ -18,13 +18,13 @@ "test:coverage": "vitest run --coverage --coverage.reporter=text", "testFunctionsExistingBackend": "just convex deploy && just convex env set IS_TEST true && vitest --run convex/example.test.ts", "testFunctions": "node backendHarness.js 'npm run testFunctionsExistingBackend'", - "arethetypeswrong": "cd packges/convex-helpers/dist && attw $(npm pack)", + "arethetypeswrong": "cd packges/convex-helpers && attw $(npm pack)", "publish": "./publish.sh" }, "dependencies": { "classnames": "^2.3.2", "convex": "^1.13.0", - "convex-helpers": "file:packages/convex-helpers/dist", + "convex-helpers": "file:packages/convex-helpers", "hono": "^4.3.6", "react": "^18.0.0", "react-dom": "^18.0.0", diff --git a/packages/convex-helpers/generate-exports.mjs b/packages/convex-helpers/generate-exports.mjs index ab247099..d579c00a 100644 --- a/packages/convex-helpers/generate-exports.mjs +++ b/packages/convex-helpers/generate-exports.mjs @@ -7,9 +7,10 @@ const __dirname = path.dirname(fileURLToPath(new URL(import.meta.url))); function directoryContents(dirname) { return fs - .readdirSync(path.join(__dirname, dirname)) + .readdirSync(path.join(__dirname, dirname), { recursive: true }) .filter((filename) => filename.endsWith(".ts") || filename.endsWith(".tsx")) .filter((filename) => !filename.includes(".test")) + .filter((filename) => !filename.includes("_generated")) .map((filename) => path.join(dirname, filename)); } @@ -19,7 +20,6 @@ function entryPointFiles() { "./testing.ts", "./validators.ts", ...directoryContents("react"), - ...directoryContents("react/cache"), ...directoryContents("server"), ]; } @@ -52,8 +52,8 @@ function generateExport(source) { ); return { - types: `./${extensionless}.d.ts`, - default: `./${extensionless}.js`, + types: `./dist/${extensionless}.d.ts`, + default: `./dist/${extensionless}.js`, }; } @@ -87,3 +87,38 @@ function checkPackageJsonExports() { } checkPackageJsonExports(); + +function createEntrypoints() { + let created = false; + for (const entryPointFile of entryPointFiles()) { + const entryPoint = entryPointFromFile(entryPointFile); + if (entryPoint === ".") continue; + const entryPointPath = path.join(__dirname, entryPoint); + if (!fs.existsSync(entryPointPath)) { + // make directory + fs.mkdirSync(entryPointPath, { recursive: true }); + } + const packagePath = path.join(entryPointPath, "package.json"); + if (!fs.existsSync(packagePath)) { + fs.writeFileSync( + packagePath, + JSON.stringify( + { + type: "module", + module: path.join("..", "dist", entryPointFile), + types: path.join("..", "dist", `${entryPoint}.d.ts`), + }, + null, + 2, + ), + ); + created = true; + } + } + if (created) { + console.log(`Created entrypoints. Check those into git.`); + process.exit(1); + } +} + +createEntrypoints(); diff --git a/packages/convex-helpers/package.json b/packages/convex-helpers/package.json index 77494a78..a6c476e2 100644 --- a/packages/convex-helpers/package.json +++ b/packages/convex-helpers/package.json @@ -5,80 +5,80 @@ "type": "module", "exports": { ".": { - "types": "./index.d.ts", - "default": "./index.js" + "types": "./dist/index.d.ts", + "default": "./dist/index.js" }, "./testing": { - "types": "./testing.d.ts", - "default": "./testing.js" + "types": "./dist/testing.d.ts", + "default": "./dist/testing.js" }, "./validators": { - "types": "./validators.d.ts", - "default": "./validators.js" + "types": "./dist/validators.d.ts", + "default": "./dist/validators.js" }, "./react": { - "types": "./react/index.d.ts", - "default": "./react/index.js" + "types": "./dist/react/index.d.ts", + "default": "./dist/react/index.js" }, "./react/sessions": { - "types": "./react/sessions.d.ts", - "default": "./react/sessions.js" + "types": "./dist/react/sessions.d.ts", + "default": "./dist/react/sessions.js" }, "./react/cache/hooks": { - "types": "./react/cache/hooks.d.ts", - "default": "./react/cache/hooks.js" + "types": "./dist/react/cache/hooks.d.ts", + "default": "./dist/react/cache/hooks.js" }, "./react/cache/provider": { - "types": "./react/cache/provider.d.ts", - "default": "./react/cache/provider.js" + "types": "./dist/react/cache/provider.d.ts", + "default": "./dist/react/cache/provider.js" }, "./server/customFunctions": { - "types": "./server/customFunctions.d.ts", - "default": "./server/customFunctions.js" + "types": "./dist/server/customFunctions.d.ts", + "default": "./dist/server/customFunctions.js" }, "./server/filter": { - "types": "./server/filter.d.ts", - "default": "./server/filter.js" + "types": "./dist/server/filter.d.ts", + "default": "./dist/server/filter.js" }, "./server/hono": { - "types": "./server/hono.d.ts", - "default": "./server/hono.js" + "types": "./dist/server/hono.d.ts", + "default": "./dist/server/hono.js" }, "./server": { - "types": "./server/index.d.ts", - "default": "./server/index.js" + "types": "./dist/server/index.d.ts", + "default": "./dist/server/index.js" }, "./server/migrations": { - "types": "./server/migrations.d.ts", - "default": "./server/migrations.js" + "types": "./dist/server/migrations.d.ts", + "default": "./dist/server/migrations.js" }, "./server/pagination": { - "types": "./server/pagination.d.ts", - "default": "./server/pagination.js" + "types": "./dist/server/pagination.d.ts", + "default": "./dist/server/pagination.js" }, "./server/rateLimit": { - "types": "./server/rateLimit.d.ts", - "default": "./server/rateLimit.js" + "types": "./dist/server/rateLimit.d.ts", + "default": "./dist/server/rateLimit.js" }, "./server/relationships": { - "types": "./server/relationships.d.ts", - "default": "./server/relationships.js" + "types": "./dist/server/relationships.d.ts", + "default": "./dist/server/relationships.js" }, "./server/retries": { - "types": "./server/retries.d.ts", - "default": "./server/retries.js" + "types": "./dist/server/retries.d.ts", + "default": "./dist/server/retries.js" }, "./server/rowLevelSecurity": { - "types": "./server/rowLevelSecurity.d.ts", - "default": "./server/rowLevelSecurity.js" + "types": "./dist/server/rowLevelSecurity.d.ts", + "default": "./dist/server/rowLevelSecurity.js" }, "./server/sessions": { - "types": "./server/sessions.d.ts", - "default": "./server/sessions.js" + "types": "./dist/server/sessions.d.ts", + "default": "./dist/server/sessions.js" }, "./server/zod": { - "types": "./server/zod.d.ts", - "default": "./server/zod.js" + "types": "./dist/server/zod.d.ts", + "default": "./dist/server/zod.js" } }, "repository": { diff --git a/packages/convex-helpers/tsconfig.json b/packages/convex-helpers/tsconfig.json index 3fa29f3d..eecd7ab1 100644 --- a/packages/convex-helpers/tsconfig.json +++ b/packages/convex-helpers/tsconfig.json @@ -55,7 +55,7 @@ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - "outDir": "./", /* Specify an output folder for all emitted files. */ + "outDir": "./dist", /* Specify an output folder for all emitted files. */ // "removeComments": true, /* Disable emitting comments. */ // "noEmit": true, /* Disable emitting files from a compilation. */ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ diff --git a/publish.sh b/publish.sh index 99306afe..a5a7e315 100755 --- a/publish.sh +++ b/publish.sh @@ -41,9 +41,6 @@ else version=$current fi -cp package.json dist/ - -cd dist npm publish --dry-run popd >/dev/null echo "^^^ DRY RUN ^^^" @@ -54,7 +51,7 @@ if [ "$publish" = "y" ]; then # If there's nothing to commit, continue git commit -m "npm $version" || true - pushd packages/convex-helpers/dist >/dev/null + pushd packages/convex-helpers >/dev/null if (echo "$version" | grep alpha >/dev/null); then npm publish --tag alpha else From 3d3e8a885d3f67768164d40fbd9feb44b9479066 Mon Sep 17 00:00:00 2001 From: Ian Macartney Date: Wed, 17 Jul 2024 11:14:17 -0700 Subject: [PATCH 03/14] just overwrite package.json --- packages/convex-helpers/generate-exports.mjs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/convex-helpers/generate-exports.mjs b/packages/convex-helpers/generate-exports.mjs index d579c00a..ba4ad96e 100644 --- a/packages/convex-helpers/generate-exports.mjs +++ b/packages/convex-helpers/generate-exports.mjs @@ -72,16 +72,11 @@ function checkPackageJsonExports() { const actual = packageJson.exports; const expected = generateExports(); if (JSON.stringify(actual) !== JSON.stringify(expected)) { - console.error("-------------------->8--------------------"); - console.log( - ` "exports": ${indent(JSON.stringify(expected, null, 2), 2)},`, + packageJson.exports = expected; + fs.writeFileSync( + path.join(__dirname, "package.json"), + JSON.stringify(packageJson, null, 2) + "\n", ); - console.error("-------------------->8--------------------"); - console.error( - "`package.json` exports are not correct. Copy exports from above or run", - ); - console.error("node generate-exports.mjs | pbcopy"); - console.error("and paste into package.json."); process.exit(1); } } From 883a7cbc1a787c0d5d04a07c83455b5ea9ec4ddd Mon Sep 17 00:00:00 2001 From: Ian Macartney Date: Wed, 17 Jul 2024 11:14:31 -0700 Subject: [PATCH 04/14] add the folders & files --- packages/convex-helpers/react/cache/hooks/package.json | 5 +++++ packages/convex-helpers/react/cache/provider/package.json | 5 +++++ packages/convex-helpers/react/package.json | 5 +++++ packages/convex-helpers/react/sessions/package.json | 5 +++++ packages/convex-helpers/server/customFunctions/package.json | 5 +++++ packages/convex-helpers/server/filter/package.json | 5 +++++ packages/convex-helpers/server/hono/package.json | 5 +++++ packages/convex-helpers/server/migrations/package.json | 5 +++++ packages/convex-helpers/server/package.json | 5 +++++ packages/convex-helpers/server/pagination/package.json | 5 +++++ packages/convex-helpers/server/rateLimit/package.json | 5 +++++ packages/convex-helpers/server/relationships/package.json | 5 +++++ packages/convex-helpers/server/retries/package.json | 5 +++++ packages/convex-helpers/server/rowLevelSecurity/package.json | 5 +++++ packages/convex-helpers/server/sessions/package.json | 5 +++++ packages/convex-helpers/server/zod/package.json | 5 +++++ packages/convex-helpers/testing/package.json | 5 +++++ packages/convex-helpers/validators/package.json | 5 +++++ 18 files changed, 90 insertions(+) create mode 100644 packages/convex-helpers/react/cache/hooks/package.json create mode 100644 packages/convex-helpers/react/cache/provider/package.json create mode 100644 packages/convex-helpers/react/package.json create mode 100644 packages/convex-helpers/react/sessions/package.json create mode 100644 packages/convex-helpers/server/customFunctions/package.json create mode 100644 packages/convex-helpers/server/filter/package.json create mode 100644 packages/convex-helpers/server/hono/package.json create mode 100644 packages/convex-helpers/server/migrations/package.json create mode 100644 packages/convex-helpers/server/package.json create mode 100644 packages/convex-helpers/server/pagination/package.json create mode 100644 packages/convex-helpers/server/rateLimit/package.json create mode 100644 packages/convex-helpers/server/relationships/package.json create mode 100644 packages/convex-helpers/server/retries/package.json create mode 100644 packages/convex-helpers/server/rowLevelSecurity/package.json create mode 100644 packages/convex-helpers/server/sessions/package.json create mode 100644 packages/convex-helpers/server/zod/package.json create mode 100644 packages/convex-helpers/testing/package.json create mode 100644 packages/convex-helpers/validators/package.json diff --git a/packages/convex-helpers/react/cache/hooks/package.json b/packages/convex-helpers/react/cache/hooks/package.json new file mode 100644 index 00000000..eca1b350 --- /dev/null +++ b/packages/convex-helpers/react/cache/hooks/package.json @@ -0,0 +1,5 @@ +{ + "type": "module", + "module": "../dist/react/cache/hooks.ts", + "types": "../dist/react/cache/hooks.d.ts" +} \ No newline at end of file diff --git a/packages/convex-helpers/react/cache/provider/package.json b/packages/convex-helpers/react/cache/provider/package.json new file mode 100644 index 00000000..3bc0690a --- /dev/null +++ b/packages/convex-helpers/react/cache/provider/package.json @@ -0,0 +1,5 @@ +{ + "type": "module", + "module": "../dist/react/cache/provider.tsx", + "types": "../dist/react/cache/provider.d.ts" +} \ No newline at end of file diff --git a/packages/convex-helpers/react/package.json b/packages/convex-helpers/react/package.json new file mode 100644 index 00000000..a994d529 --- /dev/null +++ b/packages/convex-helpers/react/package.json @@ -0,0 +1,5 @@ +{ + "type": "module", + "module": "../dist/react/index.ts", + "types": "../dist/react.d.ts" +} \ No newline at end of file diff --git a/packages/convex-helpers/react/sessions/package.json b/packages/convex-helpers/react/sessions/package.json new file mode 100644 index 00000000..72303673 --- /dev/null +++ b/packages/convex-helpers/react/sessions/package.json @@ -0,0 +1,5 @@ +{ + "type": "module", + "module": "../dist/react/sessions.ts", + "types": "../dist/react/sessions.d.ts" +} \ No newline at end of file diff --git a/packages/convex-helpers/server/customFunctions/package.json b/packages/convex-helpers/server/customFunctions/package.json new file mode 100644 index 00000000..8d56dddf --- /dev/null +++ b/packages/convex-helpers/server/customFunctions/package.json @@ -0,0 +1,5 @@ +{ + "type": "module", + "module": "../dist/server/customFunctions.ts", + "types": "../dist/server/customFunctions.d.ts" +} \ No newline at end of file diff --git a/packages/convex-helpers/server/filter/package.json b/packages/convex-helpers/server/filter/package.json new file mode 100644 index 00000000..29199f8d --- /dev/null +++ b/packages/convex-helpers/server/filter/package.json @@ -0,0 +1,5 @@ +{ + "type": "module", + "module": "../dist/server/filter.ts", + "types": "../dist/server/filter.d.ts" +} \ No newline at end of file diff --git a/packages/convex-helpers/server/hono/package.json b/packages/convex-helpers/server/hono/package.json new file mode 100644 index 00000000..01985747 --- /dev/null +++ b/packages/convex-helpers/server/hono/package.json @@ -0,0 +1,5 @@ +{ + "type": "module", + "module": "../dist/server/hono.ts", + "types": "../dist/server/hono.d.ts" +} \ No newline at end of file diff --git a/packages/convex-helpers/server/migrations/package.json b/packages/convex-helpers/server/migrations/package.json new file mode 100644 index 00000000..05e5c371 --- /dev/null +++ b/packages/convex-helpers/server/migrations/package.json @@ -0,0 +1,5 @@ +{ + "type": "module", + "module": "../dist/server/migrations.ts", + "types": "../dist/server/migrations.d.ts" +} \ No newline at end of file diff --git a/packages/convex-helpers/server/package.json b/packages/convex-helpers/server/package.json new file mode 100644 index 00000000..b65f5c01 --- /dev/null +++ b/packages/convex-helpers/server/package.json @@ -0,0 +1,5 @@ +{ + "type": "module", + "module": "../dist/server/index.ts", + "types": "../dist/server.d.ts" +} \ No newline at end of file diff --git a/packages/convex-helpers/server/pagination/package.json b/packages/convex-helpers/server/pagination/package.json new file mode 100644 index 00000000..b9e442b1 --- /dev/null +++ b/packages/convex-helpers/server/pagination/package.json @@ -0,0 +1,5 @@ +{ + "type": "module", + "module": "../dist/server/pagination.ts", + "types": "../dist/server/pagination.d.ts" +} \ No newline at end of file diff --git a/packages/convex-helpers/server/rateLimit/package.json b/packages/convex-helpers/server/rateLimit/package.json new file mode 100644 index 00000000..9d7e0f3b --- /dev/null +++ b/packages/convex-helpers/server/rateLimit/package.json @@ -0,0 +1,5 @@ +{ + "type": "module", + "module": "../dist/server/rateLimit.ts", + "types": "../dist/server/rateLimit.d.ts" +} \ No newline at end of file diff --git a/packages/convex-helpers/server/relationships/package.json b/packages/convex-helpers/server/relationships/package.json new file mode 100644 index 00000000..ffbc2a0f --- /dev/null +++ b/packages/convex-helpers/server/relationships/package.json @@ -0,0 +1,5 @@ +{ + "type": "module", + "module": "../dist/server/relationships.ts", + "types": "../dist/server/relationships.d.ts" +} \ No newline at end of file diff --git a/packages/convex-helpers/server/retries/package.json b/packages/convex-helpers/server/retries/package.json new file mode 100644 index 00000000..bfdb47a5 --- /dev/null +++ b/packages/convex-helpers/server/retries/package.json @@ -0,0 +1,5 @@ +{ + "type": "module", + "module": "../dist/server/retries.ts", + "types": "../dist/server/retries.d.ts" +} \ No newline at end of file diff --git a/packages/convex-helpers/server/rowLevelSecurity/package.json b/packages/convex-helpers/server/rowLevelSecurity/package.json new file mode 100644 index 00000000..43080efd --- /dev/null +++ b/packages/convex-helpers/server/rowLevelSecurity/package.json @@ -0,0 +1,5 @@ +{ + "type": "module", + "module": "../dist/server/rowLevelSecurity.ts", + "types": "../dist/server/rowLevelSecurity.d.ts" +} \ No newline at end of file diff --git a/packages/convex-helpers/server/sessions/package.json b/packages/convex-helpers/server/sessions/package.json new file mode 100644 index 00000000..e4c144b0 --- /dev/null +++ b/packages/convex-helpers/server/sessions/package.json @@ -0,0 +1,5 @@ +{ + "type": "module", + "module": "../dist/server/sessions.ts", + "types": "../dist/server/sessions.d.ts" +} \ No newline at end of file diff --git a/packages/convex-helpers/server/zod/package.json b/packages/convex-helpers/server/zod/package.json new file mode 100644 index 00000000..918fdde3 --- /dev/null +++ b/packages/convex-helpers/server/zod/package.json @@ -0,0 +1,5 @@ +{ + "type": "module", + "module": "../dist/server/zod.ts", + "types": "../dist/server/zod.d.ts" +} \ No newline at end of file diff --git a/packages/convex-helpers/testing/package.json b/packages/convex-helpers/testing/package.json new file mode 100644 index 00000000..9a397067 --- /dev/null +++ b/packages/convex-helpers/testing/package.json @@ -0,0 +1,5 @@ +{ + "type": "module", + "module": "../dist/testing.ts", + "types": "../dist/testing.d.ts" +} \ No newline at end of file diff --git a/packages/convex-helpers/validators/package.json b/packages/convex-helpers/validators/package.json new file mode 100644 index 00000000..4ef8255b --- /dev/null +++ b/packages/convex-helpers/validators/package.json @@ -0,0 +1,5 @@ +{ + "type": "module", + "module": "../dist/validators.ts", + "types": "../dist/validators.d.ts" +} \ No newline at end of file From e09143e9f9d677174bc9fa6832bb2c92bd4bd026 Mon Sep 17 00:00:00 2001 From: Ian Macartney Date: Wed, 17 Jul 2024 11:19:38 -0700 Subject: [PATCH 05/14] npm 0.1.49-alpha.1 --- package-lock.json | 2 +- packages/convex-helpers/.npmignore | 2 ++ packages/convex-helpers/package.json | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3c9a8226..ff5480fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6437,7 +6437,7 @@ } }, "packages/convex-helpers": { - "version": "0.1.49-alpha.0", + "version": "0.1.49-alpha.1", "license": "MIT", "peerDependencies": { "convex": "^1.13.0", diff --git a/packages/convex-helpers/.npmignore b/packages/convex-helpers/.npmignore index eaa8a157..3aa7acea 100644 --- a/packages/convex-helpers/.npmignore +++ b/packages/convex-helpers/.npmignore @@ -1,4 +1,6 @@ node_modules package-lock.json +generate-exports.mjs +vitest.config.mts *.tgz *.tsbuildinfo diff --git a/packages/convex-helpers/package.json b/packages/convex-helpers/package.json index a6c476e2..65ff6a3b 100644 --- a/packages/convex-helpers/package.json +++ b/packages/convex-helpers/package.json @@ -1,6 +1,6 @@ { "name": "convex-helpers", - "version": "0.1.49-alpha.0", + "version": "0.1.49-alpha.1", "description": "A collection of useful code to complement the official convex package.", "type": "module", "exports": { From 2cca0d6713c076db02b97136418b32d0d549c583 Mon Sep 17 00:00:00 2001 From: Ian Macartney Date: Wed, 17 Jul 2024 11:26:00 -0700 Subject: [PATCH 06/14] add npmrc for publish token for package --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b30639b1..b2636ae4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -# For this repo, let's not all share our convex projects -convex.json +# Login info for npm publishing +.npmrc # Or our local env .env.local From d021798a9d60c8f7d648df711c6b91ac8cd0e288 Mon Sep 17 00:00:00 2001 From: Ian Macartney Date: Wed, 17 Jul 2024 11:54:02 -0700 Subject: [PATCH 07/14] don't commit folders --- packages/convex-helpers/react/cache/hooks/package.json | 5 ----- packages/convex-helpers/react/cache/provider/package.json | 5 ----- packages/convex-helpers/react/package.json | 5 ----- packages/convex-helpers/react/sessions/package.json | 5 ----- packages/convex-helpers/server/customFunctions/package.json | 5 ----- packages/convex-helpers/server/filter/package.json | 5 ----- packages/convex-helpers/server/hono/package.json | 5 ----- packages/convex-helpers/server/migrations/package.json | 5 ----- packages/convex-helpers/server/package.json | 5 ----- packages/convex-helpers/server/pagination/package.json | 5 ----- packages/convex-helpers/server/rateLimit/package.json | 5 ----- packages/convex-helpers/server/relationships/package.json | 5 ----- packages/convex-helpers/server/retries/package.json | 5 ----- packages/convex-helpers/server/rowLevelSecurity/package.json | 5 ----- packages/convex-helpers/server/sessions/package.json | 5 ----- packages/convex-helpers/server/zod/package.json | 5 ----- packages/convex-helpers/testing/package.json | 5 ----- packages/convex-helpers/validators/package.json | 5 ----- 18 files changed, 90 deletions(-) delete mode 100644 packages/convex-helpers/react/cache/hooks/package.json delete mode 100644 packages/convex-helpers/react/cache/provider/package.json delete mode 100644 packages/convex-helpers/react/package.json delete mode 100644 packages/convex-helpers/react/sessions/package.json delete mode 100644 packages/convex-helpers/server/customFunctions/package.json delete mode 100644 packages/convex-helpers/server/filter/package.json delete mode 100644 packages/convex-helpers/server/hono/package.json delete mode 100644 packages/convex-helpers/server/migrations/package.json delete mode 100644 packages/convex-helpers/server/package.json delete mode 100644 packages/convex-helpers/server/pagination/package.json delete mode 100644 packages/convex-helpers/server/rateLimit/package.json delete mode 100644 packages/convex-helpers/server/relationships/package.json delete mode 100644 packages/convex-helpers/server/retries/package.json delete mode 100644 packages/convex-helpers/server/rowLevelSecurity/package.json delete mode 100644 packages/convex-helpers/server/sessions/package.json delete mode 100644 packages/convex-helpers/server/zod/package.json delete mode 100644 packages/convex-helpers/testing/package.json delete mode 100644 packages/convex-helpers/validators/package.json diff --git a/packages/convex-helpers/react/cache/hooks/package.json b/packages/convex-helpers/react/cache/hooks/package.json deleted file mode 100644 index eca1b350..00000000 --- a/packages/convex-helpers/react/cache/hooks/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "module", - "module": "../dist/react/cache/hooks.ts", - "types": "../dist/react/cache/hooks.d.ts" -} \ No newline at end of file diff --git a/packages/convex-helpers/react/cache/provider/package.json b/packages/convex-helpers/react/cache/provider/package.json deleted file mode 100644 index 3bc0690a..00000000 --- a/packages/convex-helpers/react/cache/provider/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "module", - "module": "../dist/react/cache/provider.tsx", - "types": "../dist/react/cache/provider.d.ts" -} \ No newline at end of file diff --git a/packages/convex-helpers/react/package.json b/packages/convex-helpers/react/package.json deleted file mode 100644 index a994d529..00000000 --- a/packages/convex-helpers/react/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "module", - "module": "../dist/react/index.ts", - "types": "../dist/react.d.ts" -} \ No newline at end of file diff --git a/packages/convex-helpers/react/sessions/package.json b/packages/convex-helpers/react/sessions/package.json deleted file mode 100644 index 72303673..00000000 --- a/packages/convex-helpers/react/sessions/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "module", - "module": "../dist/react/sessions.ts", - "types": "../dist/react/sessions.d.ts" -} \ No newline at end of file diff --git a/packages/convex-helpers/server/customFunctions/package.json b/packages/convex-helpers/server/customFunctions/package.json deleted file mode 100644 index 8d56dddf..00000000 --- a/packages/convex-helpers/server/customFunctions/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "module", - "module": "../dist/server/customFunctions.ts", - "types": "../dist/server/customFunctions.d.ts" -} \ No newline at end of file diff --git a/packages/convex-helpers/server/filter/package.json b/packages/convex-helpers/server/filter/package.json deleted file mode 100644 index 29199f8d..00000000 --- a/packages/convex-helpers/server/filter/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "module", - "module": "../dist/server/filter.ts", - "types": "../dist/server/filter.d.ts" -} \ No newline at end of file diff --git a/packages/convex-helpers/server/hono/package.json b/packages/convex-helpers/server/hono/package.json deleted file mode 100644 index 01985747..00000000 --- a/packages/convex-helpers/server/hono/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "module", - "module": "../dist/server/hono.ts", - "types": "../dist/server/hono.d.ts" -} \ No newline at end of file diff --git a/packages/convex-helpers/server/migrations/package.json b/packages/convex-helpers/server/migrations/package.json deleted file mode 100644 index 05e5c371..00000000 --- a/packages/convex-helpers/server/migrations/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "module", - "module": "../dist/server/migrations.ts", - "types": "../dist/server/migrations.d.ts" -} \ No newline at end of file diff --git a/packages/convex-helpers/server/package.json b/packages/convex-helpers/server/package.json deleted file mode 100644 index b65f5c01..00000000 --- a/packages/convex-helpers/server/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "module", - "module": "../dist/server/index.ts", - "types": "../dist/server.d.ts" -} \ No newline at end of file diff --git a/packages/convex-helpers/server/pagination/package.json b/packages/convex-helpers/server/pagination/package.json deleted file mode 100644 index b9e442b1..00000000 --- a/packages/convex-helpers/server/pagination/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "module", - "module": "../dist/server/pagination.ts", - "types": "../dist/server/pagination.d.ts" -} \ No newline at end of file diff --git a/packages/convex-helpers/server/rateLimit/package.json b/packages/convex-helpers/server/rateLimit/package.json deleted file mode 100644 index 9d7e0f3b..00000000 --- a/packages/convex-helpers/server/rateLimit/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "module", - "module": "../dist/server/rateLimit.ts", - "types": "../dist/server/rateLimit.d.ts" -} \ No newline at end of file diff --git a/packages/convex-helpers/server/relationships/package.json b/packages/convex-helpers/server/relationships/package.json deleted file mode 100644 index ffbc2a0f..00000000 --- a/packages/convex-helpers/server/relationships/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "module", - "module": "../dist/server/relationships.ts", - "types": "../dist/server/relationships.d.ts" -} \ No newline at end of file diff --git a/packages/convex-helpers/server/retries/package.json b/packages/convex-helpers/server/retries/package.json deleted file mode 100644 index bfdb47a5..00000000 --- a/packages/convex-helpers/server/retries/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "module", - "module": "../dist/server/retries.ts", - "types": "../dist/server/retries.d.ts" -} \ No newline at end of file diff --git a/packages/convex-helpers/server/rowLevelSecurity/package.json b/packages/convex-helpers/server/rowLevelSecurity/package.json deleted file mode 100644 index 43080efd..00000000 --- a/packages/convex-helpers/server/rowLevelSecurity/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "module", - "module": "../dist/server/rowLevelSecurity.ts", - "types": "../dist/server/rowLevelSecurity.d.ts" -} \ No newline at end of file diff --git a/packages/convex-helpers/server/sessions/package.json b/packages/convex-helpers/server/sessions/package.json deleted file mode 100644 index e4c144b0..00000000 --- a/packages/convex-helpers/server/sessions/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "module", - "module": "../dist/server/sessions.ts", - "types": "../dist/server/sessions.d.ts" -} \ No newline at end of file diff --git a/packages/convex-helpers/server/zod/package.json b/packages/convex-helpers/server/zod/package.json deleted file mode 100644 index 918fdde3..00000000 --- a/packages/convex-helpers/server/zod/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "module", - "module": "../dist/server/zod.ts", - "types": "../dist/server/zod.d.ts" -} \ No newline at end of file diff --git a/packages/convex-helpers/testing/package.json b/packages/convex-helpers/testing/package.json deleted file mode 100644 index 9a397067..00000000 --- a/packages/convex-helpers/testing/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "module", - "module": "../dist/testing.ts", - "types": "../dist/testing.d.ts" -} \ No newline at end of file diff --git a/packages/convex-helpers/validators/package.json b/packages/convex-helpers/validators/package.json deleted file mode 100644 index 4ef8255b..00000000 --- a/packages/convex-helpers/validators/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "module", - "module": "../dist/validators.ts", - "types": "../dist/validators.d.ts" -} \ No newline at end of file From 0d9a55cd233a10997f50e1b8258e20bb6e840272 Mon Sep 17 00:00:00 2001 From: Ian Macartney Date: Wed, 17 Jul 2024 11:50:19 -0700 Subject: [PATCH 08/14] split up entry point generation/deletion --- delete-entrypoints.mjs | 26 ++++ generate-entrypoints.mjs | 46 +++++++ generate-exports.mjs | 46 +++++++ generate-utils.mjs | 42 +++++++ package.json | 2 +- packages/convex-helpers/generate-exports.mjs | 119 ------------------- packages/convex-helpers/package.json | 2 + publish.sh | 3 + 8 files changed, 166 insertions(+), 120 deletions(-) create mode 100644 delete-entrypoints.mjs create mode 100644 generate-entrypoints.mjs create mode 100644 generate-exports.mjs create mode 100644 generate-utils.mjs delete mode 100644 packages/convex-helpers/generate-exports.mjs diff --git a/delete-entrypoints.mjs b/delete-entrypoints.mjs new file mode 100644 index 00000000..e20163ef --- /dev/null +++ b/delete-entrypoints.mjs @@ -0,0 +1,26 @@ +import fs from "node:fs"; +import path from "node:path"; +import { + __dirname, + entryPointFiles, + entryPointFromFile, +} from "./generate-utils.mjs"; + +function createEntrypoints() { + for (const entryPointFile of entryPointFiles()) { + const entryPoint = entryPointFromFile(entryPointFile); + if (entryPoint === ".") continue; + + const entryPointPath = path.join(__dirname, entryPoint); + const packagePath = path.join(entryPointPath, "package.json"); + if (fs.existsSync(packagePath)) { + fs.rmSync(packagePath); + } + const fileName = path.parse(entryPointFile).name; + if (fileName !== "index" && fs.existsSync(entryPointPath)) { + fs.rmdirSync(entryPointPath); + } + } +} + +createEntrypoints(); diff --git a/generate-entrypoints.mjs b/generate-entrypoints.mjs new file mode 100644 index 00000000..fb6928c5 --- /dev/null +++ b/generate-entrypoints.mjs @@ -0,0 +1,46 @@ +import fs from "node:fs"; +import path from "node:path"; +import { + __dirname, + entryPointFiles, + entryPointFromFile, +} from "./generate-utils.mjs"; + +function createEntrypoints() { + for (const entryPointFile of entryPointFiles()) { + const entryPoint = entryPointFromFile(entryPointFile); + if (entryPoint === ".") continue; + const entryPointPath = path.join(__dirname, entryPoint); + if (!fs.existsSync(entryPointPath)) { + // make directory + fs.mkdirSync(entryPointPath, { recursive: true }); + } + const extensionless = path.join( + path.parse(entryPointFile).dir, + path.parse(entryPointFile).name, + ); + const packagePath = path.join(entryPointPath, "package.json"); + const parts = entryPoint.split("/"); + const dist = path.join( + parts + .slice(1) + .map(() => "..") + .join("/"), + "dist", + ); + fs.writeFileSync( + packagePath, + JSON.stringify( + { + type: "module", + module: path.join(dist, `${extensionless}.js`), + types: path.join(dist, `${extensionless}.d.ts`), + }, + null, + 2, + ), + ); + } +} + +createEntrypoints(); diff --git a/generate-exports.mjs b/generate-exports.mjs new file mode 100644 index 00000000..9fecc94c --- /dev/null +++ b/generate-exports.mjs @@ -0,0 +1,46 @@ +import fs from "node:fs"; +import path from "node:path"; +import process from "node:process"; +import { + __dirname, + entryPointFiles, + entryPointFromFile, +} from "./generate-utils.mjs"; + +function generateExport(source) { + let extensionless = path.join( + path.parse(source).dir, + path.parse(source).name, + ); + + return { + types: `./dist/${extensionless}.d.ts`, + default: `./dist/${extensionless}.js`, + }; +} + +function generateExports() { + const obj = {}; + for (const entryPoint of entryPointFiles()) { + obj[entryPointFromFile(entryPoint)] = generateExport(entryPoint); + } + return obj; +} + +function generatePackageExports() { + const packageJson = JSON.parse( + fs.readFileSync(path.join(__dirname, "package.json")), + ); + const actual = packageJson.exports; + const expected = generateExports(); + if (JSON.stringify(actual) !== JSON.stringify(expected)) { + packageJson.exports = expected; + fs.writeFileSync( + path.join(__dirname, "package.json"), + JSON.stringify(packageJson, null, 2) + "\n", + ); + process.exit(1); + } +} + +generatePackageExports(); diff --git a/generate-utils.mjs b/generate-utils.mjs new file mode 100644 index 00000000..ae3871f3 --- /dev/null +++ b/generate-utils.mjs @@ -0,0 +1,42 @@ +import fs from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +export const __dirname = path.join( + path.dirname(fileURLToPath(new URL(import.meta.url))), + "packages", + "convex-helpers", +); + +function directoryContents(dirname) { + return fs + .readdirSync(path.join(__dirname, dirname), { recursive: true }) + .filter((filename) => filename.endsWith(".ts") || filename.endsWith(".tsx")) + .filter((filename) => !filename.includes(".test")) + .filter((filename) => !filename.includes("_generated")) + .map((filename) => path.join(dirname, filename)); +} + +export function entryPointFiles() { + return [ + "./index.ts", + "./testing.ts", + "./validators.ts", + ...directoryContents("react"), + ...directoryContents("server"), + ]; +} + +export function entryPointFromFile(source) { + let entryPoint = path.join(path.parse(source).dir, path.parse(source).name); + + if (path.parse(source).name === "index") { + entryPoint = path.parse(source).dir; + } + + if (!entryPoint.startsWith(".")) { + entryPoint = `./${entryPoint}`; + } + + return entryPoint; +} diff --git a/package.json b/package.json index 11b0876c..28f2e673 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "dev:helpers": "cd packages/convex-helpers && chokidar '*.ts' 'server/**/*.ts' 'react/**/*.ts*' 'tsconfig*.json' 'package.json' -c 'npm run build' --initial", "predev": "cd packages/convex-helpers && npm run build", "lint": "tsc --project tsconfig.test.json", - "build": "cd packages/convex-helpers && node generate-exports.mjs && tsc", + "build": "node generate-exports.mjs && cd packages/convex-helpers && tsc", "clean": "rm -rf packages/convex-helpers/dist", "test": "vitest run", "test:watch": "vitest", diff --git a/packages/convex-helpers/generate-exports.mjs b/packages/convex-helpers/generate-exports.mjs deleted file mode 100644 index ba4ad96e..00000000 --- a/packages/convex-helpers/generate-exports.mjs +++ /dev/null @@ -1,119 +0,0 @@ -import fs from "node:fs"; -import path from "node:path"; -import process from "node:process"; -import { fileURLToPath } from "node:url"; - -const __dirname = path.dirname(fileURLToPath(new URL(import.meta.url))); - -function directoryContents(dirname) { - return fs - .readdirSync(path.join(__dirname, dirname), { recursive: true }) - .filter((filename) => filename.endsWith(".ts") || filename.endsWith(".tsx")) - .filter((filename) => !filename.includes(".test")) - .filter((filename) => !filename.includes("_generated")) - .map((filename) => path.join(dirname, filename)); -} - -function entryPointFiles() { - return [ - "./index.ts", - "./testing.ts", - "./validators.ts", - ...directoryContents("react"), - ...directoryContents("server"), - ]; -} - -function indent(s, n) { - const lines = s.split("\n"); - return ( - lines.shift() + "\n" + lines.map((line) => " ".repeat(n) + line).join("\n") - ); -} - -function entryPointFromFile(source) { - let entryPoint = path.join(path.parse(source).dir, path.parse(source).name); - - if (path.parse(source).name === "index") { - entryPoint = path.parse(source).dir; - } - - if (!entryPoint.startsWith(".")) { - entryPoint = `./${entryPoint}`; - } - - return entryPoint; -} - -function generateExport(source) { - let extensionless = path.join( - path.parse(source).dir, - path.parse(source).name, - ); - - return { - types: `./dist/${extensionless}.d.ts`, - default: `./dist/${extensionless}.js`, - }; -} - -function generateExports() { - const obj = {}; - for (const entryPoint of entryPointFiles()) { - obj[entryPointFromFile(entryPoint)] = generateExport(entryPoint); - } - return obj; -} - -function checkPackageJsonExports() { - const packageJson = JSON.parse( - fs.readFileSync(path.join(__dirname, "package.json")), - ); - const actual = packageJson.exports; - const expected = generateExports(); - if (JSON.stringify(actual) !== JSON.stringify(expected)) { - packageJson.exports = expected; - fs.writeFileSync( - path.join(__dirname, "package.json"), - JSON.stringify(packageJson, null, 2) + "\n", - ); - process.exit(1); - } -} - -checkPackageJsonExports(); - -function createEntrypoints() { - let created = false; - for (const entryPointFile of entryPointFiles()) { - const entryPoint = entryPointFromFile(entryPointFile); - if (entryPoint === ".") continue; - const entryPointPath = path.join(__dirname, entryPoint); - if (!fs.existsSync(entryPointPath)) { - // make directory - fs.mkdirSync(entryPointPath, { recursive: true }); - } - const packagePath = path.join(entryPointPath, "package.json"); - if (!fs.existsSync(packagePath)) { - fs.writeFileSync( - packagePath, - JSON.stringify( - { - type: "module", - module: path.join("..", "dist", entryPointFile), - types: path.join("..", "dist", `${entryPoint}.d.ts`), - }, - null, - 2, - ), - ); - created = true; - } - } - if (created) { - console.log(`Created entrypoints. Check those into git.`); - process.exit(1); - } -} - -createEntrypoints(); diff --git a/packages/convex-helpers/package.json b/packages/convex-helpers/package.json index 65ff6a3b..34c4614f 100644 --- a/packages/convex-helpers/package.json +++ b/packages/convex-helpers/package.json @@ -81,6 +81,8 @@ "default": "./dist/server/zod.js" } }, + "module": "./dist/index.js", + "types": "./dist/index.d.ts", "repository": { "type": "git", "url": "git+https://github.com/get-convex/convex-helpers.git", diff --git a/publish.sh b/publish.sh index a5a7e315..8cc4c5ca 100755 --- a/publish.sh +++ b/publish.sh @@ -34,6 +34,7 @@ npm view convex-helpers@alpha version read -r -p "Enter the new version number (hit enter for $current): " version +node generate-entrypoints.mjs pushd packages/convex-helpers >/dev/null if [ -n "$version" ]; then npm pkg set version="$version" @@ -58,10 +59,12 @@ if [ "$publish" = "y" ]; then npm publish fi popd >/dev/null + node delete-entrypoints.mjs git tag "npm/$version" git push origin "npm/$version" git push else echo "Aborted." + node delete-entrypoints.mjs git co package-lock.json packages/convex-helpers/package.json fi From 26081943347ab798d1400d8e78217dc2e6f4fc00 Mon Sep 17 00:00:00 2001 From: Ian Macartney Date: Wed, 17 Jul 2024 12:47:19 -0700 Subject: [PATCH 09/14] npm 0.1.49-alpha.2 --- package-lock.json | 2 +- packages/convex-helpers/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index ff5480fe..e671d2f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6437,7 +6437,7 @@ } }, "packages/convex-helpers": { - "version": "0.1.49-alpha.1", + "version": "0.1.49-alpha.2", "license": "MIT", "peerDependencies": { "convex": "^1.13.0", diff --git a/packages/convex-helpers/package.json b/packages/convex-helpers/package.json index 34c4614f..1657a04a 100644 --- a/packages/convex-helpers/package.json +++ b/packages/convex-helpers/package.json @@ -1,6 +1,6 @@ { "name": "convex-helpers", - "version": "0.1.49-alpha.1", + "version": "0.1.49-alpha.2", "description": "A collection of useful code to complement the official convex package.", "type": "module", "exports": { From 1a039cf1cad3821db7daa7ffac8b4ae5a9b4da2e Mon Sep 17 00:00:00 2001 From: Ian Macartney Date: Wed, 17 Jul 2024 12:48:56 -0700 Subject: [PATCH 10/14] delete entrypoints at start of publishing --- publish.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/publish.sh b/publish.sh index 8cc4c5ca..47ba6951 100755 --- a/publish.sh +++ b/publish.sh @@ -35,6 +35,12 @@ npm view convex-helpers@alpha version read -r -p "Enter the new version number (hit enter for $current): " version node generate-entrypoints.mjs +function cleanup() { + node delete-entrypoints.mjs + git co package-lock.json packages/convex-helpers/package.json +} +trap cleanup EXIT + pushd packages/convex-helpers >/dev/null if [ -n "$version" ]; then npm pkg set version="$version" @@ -59,12 +65,7 @@ if [ "$publish" = "y" ]; then npm publish fi popd >/dev/null - node delete-entrypoints.mjs git tag "npm/$version" git push origin "npm/$version" git push -else - echo "Aborted." - node delete-entrypoints.mjs - git co package-lock.json packages/convex-helpers/package.json fi From bbd429ac15e89c0d2a7e04fede7abdb54eda03f5 Mon Sep 17 00:00:00 2001 From: Ian Macartney Date: Wed, 17 Jul 2024 13:13:17 -0700 Subject: [PATCH 11/14] update vitest config --- convex/example.test.ts | 3 +-- convex/vitest.config.mts | 16 ++++++++++++++++ vite.config.mts | 8 +------- vitest.workspace.ts | 1 + 4 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 convex/vitest.config.mts create mode 100644 vitest.workspace.ts diff --git a/convex/example.test.ts b/convex/example.test.ts index 2d63fa29..8194ee9d 100644 --- a/convex/example.test.ts +++ b/convex/example.test.ts @@ -1,8 +1,7 @@ import { api } from "./_generated/api"; import { ConvexTestingHelper } from "convex-helpers/testing"; -// Un-skip this test to run end-to-end tests. Also see vitest.config.mts. -describe.skip("testingExample", () => { +describe("testingExample", () => { let t: ConvexTestingHelper; beforeEach(() => { diff --git a/convex/vitest.config.mts b/convex/vitest.config.mts new file mode 100644 index 00000000..9c66d704 --- /dev/null +++ b/convex/vitest.config.mts @@ -0,0 +1,16 @@ +import { defineConfig } from "vitest/config"; + +// https://vitejs.dev/config/ +export default defineConfig({ + test: { + environment: "edge-runtime", + exclude: [], + passWithNoTests: true, + + // Only run one suite at a time because all of our tests are running against + // the same backend and we don't want to leak state. + maxWorkers: 1, + minWorkers: 1, + globals: true, + }, +}); diff --git a/vite.config.mts b/vite.config.mts index dc79b3c0..b071ef3e 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -6,14 +6,8 @@ export default defineConfig({ plugins: [react()], test: { environment: "jsdom", - exclude: ["**/node_modules/**", "packages/**/dist/**"], - passWithNoTests: true, + exclude: ["node_modules/**", "convex/**", "packages/**"], - // For the end-to-end tests, uncomment these lines - // Only run one suite at a time because all of our tests are running against - // the same backend and we don't want to leak state. - // maxWorkers: 1, - // minWorkers: 1, globals: true, }, }); diff --git a/vitest.workspace.ts b/vitest.workspace.ts new file mode 100644 index 00000000..7e879254 --- /dev/null +++ b/vitest.workspace.ts @@ -0,0 +1 @@ +export default [".", "packages/convex-helpers"]; From 4639374a08c789ffa3bd38f83596f1ab224f57de Mon Sep 17 00:00:00 2001 From: Ian Macartney Date: Wed, 17 Jul 2024 13:14:54 -0700 Subject: [PATCH 12/14] commit to git after successful publish --- publish.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/publish.sh b/publish.sh index 47ba6951..90555401 100755 --- a/publish.sh +++ b/publish.sh @@ -54,10 +54,6 @@ echo "^^^ DRY RUN ^^^" read -r -p "Publish $version to npm? (y/n): " publish if [ "$publish" = "y" ]; then npm i - git add package.json package-lock.json packages/convex-helpers/package.json - # If there's nothing to commit, continue - git commit -m "npm $version" || true - pushd packages/convex-helpers >/dev/null if (echo "$version" | grep alpha >/dev/null); then npm publish --tag alpha @@ -65,6 +61,9 @@ if [ "$publish" = "y" ]; then npm publish fi popd >/dev/null + git add package.json package-lock.json packages/convex-helpers/package.json + # If there's nothing to commit, continue + git commit -m "npm $version" || true git tag "npm/$version" git push origin "npm/$version" git push From 76ea8f28e3313aa3568a98b1a824e426754e0dfb Mon Sep 17 00:00:00 2001 From: Ian Macartney Date: Wed, 17 Jul 2024 13:54:21 -0700 Subject: [PATCH 13/14] take out unused ignores --- packages/convex-helpers/.npmignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/convex-helpers/.npmignore b/packages/convex-helpers/.npmignore index 3aa7acea..c00f0192 100644 --- a/packages/convex-helpers/.npmignore +++ b/packages/convex-helpers/.npmignore @@ -1,6 +1,3 @@ -node_modules -package-lock.json -generate-exports.mjs vitest.config.mts *.tgz *.tsbuildinfo From 38d3c9c36738893acad577a3bf66b10ce14e684f Mon Sep 17 00:00:00 2001 From: Ian Macartney Date: Wed, 17 Jul 2024 18:48:47 -0700 Subject: [PATCH 14/14] fix arethetypeswrong command --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 28f2e673..07adb83b 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "test:coverage": "vitest run --coverage --coverage.reporter=text", "testFunctionsExistingBackend": "just convex deploy && just convex env set IS_TEST true && vitest --run convex/example.test.ts", "testFunctions": "node backendHarness.js 'npm run testFunctionsExistingBackend'", - "arethetypeswrong": "cd packges/convex-helpers && attw $(npm pack)", + "arethetypeswrong": "cd packages/convex-helpers && attw $(npm pack)", "publish": "./publish.sh" }, "dependencies": {