From c5bf04229cd4d7a2d217ca4912b33d4c23c00bc1 Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Sat, 24 Aug 2024 20:48:47 +0200 Subject: [PATCH 1/8] feat!: switch to type module --- .eslintrc.cjs | 2 +- .gitignore | 3 +-- .prettierrc.js | 2 +- bin/node-pg-migrate | 7 ------- package.json | 32 +++++++++++--------------------- pnpm-lock.yaml | 8 ++++---- src/db.ts | 2 +- tsconfig.build.json | 9 +++++++-- tsconfig.json | 19 +++++++++++++------ tsconfig.lint.json | 16 ---------------- tsup-bin.config.ts | 2 +- tsup.config.ts | 38 +++++++++++--------------------------- 12 files changed, 51 insertions(+), 89 deletions(-) delete mode 100644 bin/node-pg-migrate delete mode 100644 tsconfig.lint.json diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 5e3e6426..861872d8 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -24,7 +24,7 @@ module.exports = defineConfig({ 'plugin:prettier/recommended', ], parserOptions: { - project: ['./tsconfig.lint.json'], + project: ['./tsconfig.json'], warnOnUnsupportedTypeScriptVersion: false, }, rules: { diff --git a/.gitignore b/.gitignore index fa34d34b..28c28154 100644 --- a/.gitignore +++ b/.gitignore @@ -80,9 +80,8 @@ versions.json /lib /migrations +/bin/*.cjs /bin/*.js -/bin/*.mjs -/bin/esm TAGS REVISION diff --git a/.prettierrc.js b/.prettierrc.js index 38966977..063dc85a 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -3,7 +3,7 @@ /** * @type {import('prettier').Config} */ -module.exports = { +export default { plugins: ['prettier-plugin-organize-imports'], singleQuote: true, trailingComma: 'es5', diff --git a/bin/node-pg-migrate b/bin/node-pg-migrate deleted file mode 100644 index 1923ac2b..00000000 --- a/bin/node-pg-migrate +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env node - -console.warn( - 'bin/node-pg-migrate is deprecated. Please use bin/node-pg-migrate.js instead.' -); - -require('./node-pg-migrate.js'); diff --git a/package.json b/package.json index eff94aa6..6efdf280 100644 --- a/package.json +++ b/package.json @@ -25,34 +25,24 @@ }, "bin": { "node-pg-migrate": "bin/node-pg-migrate.js", - "node-pg-migrate-cjs": "bin/node-pg-migrate.js", - "node-pg-migrate-esm": "bin/node-pg-migrate.mjs" + "node-pg-migrate-cjs": "bin/node-pg-migrate.cjs", + "node-pg-migrate-esm": "bin/node-pg-migrate.js" }, - "type": "commonjs", - "main": "dist/index.js", - "module": "dist/esm/index.mjs", + "type": "module", + "main": "dist/index.cjs", + "module": "dist/index.js", "types": "dist/index.d.ts", "exports": { - "./dist/*": { - "types": "./dist/*.d.ts", - "require": "./dist/*.js", - "import": "./dist/esm/*.mjs", - "default": "./dist/*.js" - }, - "./bin/*": { - "require": "./bin/*.js", - "import": "./bin/*.mjs", - "default": "./bin/*.js" - }, ".": { "types": "./dist/index.d.ts", - "require": "./dist/index.js", - "import": "./dist/esm/index.mjs", + "import": "./dist/index.js", + "require": "./dist/index.cjs", "default": "./dist/index.js" }, - "./*": { - "types": "./dist/*.d.ts", - "require": "./dist/*.js" + "./bin/*": { + "import": "./bin/*.js", + "require": "./bin/*.cjs", + "default": "./bin/*.js" }, "./package.json": "./package.json" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 17fa7b25..8b4f40db 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -813,8 +813,8 @@ packages: '@ungap/structured-clone@1.2.0': resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} - '@vitejs/plugin-vue@5.1.3': - resolution: {integrity: sha512-3xbWsKEKXYlmX82aOHufFQVnkbMC/v8fLpWwh6hWOUrK5fbbtBh9Q/WWse27BFgSy2/e2c0fz5Scgya9h2GLhw==} + '@vitejs/plugin-vue@5.1.2': + resolution: {integrity: sha512-nY9IwH12qeiJqumTCLJLE7IiNx7HZ39cbHaysEUd+Myvbz9KAqd2yq+U01Kab1R/H1BmiyM2ShTYlNH32Fzo3A==} engines: {node: ^18.0.0 || >=20.0.0} peerDependencies: vite: ^5.0.0 @@ -3304,7 +3304,7 @@ snapshots: '@ungap/structured-clone@1.2.0': {} - '@vitejs/plugin-vue@5.1.3(vite@5.4.2(@types/node@18.19.47))(vue@3.4.38(typescript@5.5.4))': + '@vitejs/plugin-vue@5.1.2(vite@5.4.2(@types/node@18.19.47))(vue@3.4.38(typescript@5.5.4))': dependencies: vite: 5.4.2(@types/node@18.19.47) vue: 3.4.38(typescript@5.5.4) @@ -5227,7 +5227,7 @@ snapshots: '@shikijs/core': 1.15.1 '@shikijs/transformers': 1.15.1 '@types/markdown-it': 14.1.2 - '@vitejs/plugin-vue': 5.1.3(vite@5.4.2(@types/node@18.19.47))(vue@3.4.38(typescript@5.5.4)) + '@vitejs/plugin-vue': 5.1.2(vite@5.4.2(@types/node@18.19.47))(vue@3.4.38(typescript@5.5.4)) '@vue/devtools-api': 7.3.9 '@vue/shared': 3.4.38 '@vueuse/core': 11.0.3(vue@3.4.38(typescript@5.5.4)) diff --git a/src/db.ts b/src/db.ts index e9925541..e0389975 100644 --- a/src/db.ts +++ b/src/db.ts @@ -11,7 +11,7 @@ import type { QueryConfig, QueryResult, } from 'pg'; -import pg from 'pg'; +import * as pg from 'pg'; import type { DB, Logger } from './types'; /* eslint-disable @typescript-eslint/no-explicit-any */ diff --git a/tsconfig.build.json b/tsconfig.build.json index cb7dc7b4..fae28412 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,11 +1,16 @@ { "extends": "./tsconfig.json", "compilerOptions": { + "target": "ES2022", "noEmit": false, - "declaration": true, "emitDeclarationOnly": true, "rootDir": "src", - "outDir": "dist" + "outDir": "dist", + + // This negates what is set in the extended tsconfig.json + "skipLibCheck": false, + "allowSyntheticDefaultImports": false, + "resolveJsonModule": false }, "include": ["src"] } diff --git a/tsconfig.json b/tsconfig.json index cc20782f..c1f1f975 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,19 +1,26 @@ { "compilerOptions": { - "target": "ES2022", - "module": "CommonJS", + "target": "ESNext", "moduleResolution": "Node", + "module": "ESNext", "lib": ["ES2022", "DOM"], + "strict": true, "noEmit": true, - "resolveJsonModule": true, + "declaration": true, + "stripInternal": true, + "verbatimModuleSyntax": true, + "esModuleInterop": true, "sourceMap": false, "forceConsistentCasingInFileNames": true, - "strict": true, "noImplicitAny": true, "noUnusedLocals": true, "noImplicitOverride": true, - "skipLibCheck": true + + // These are configs specifically for !build and have to be reverted in the tsconfig.build.json + "skipLibCheck": true, + "allowSyntheticDefaultImports": true, + "resolveJsonModule": true }, - "exclude": ["node_modules", "templates", "dist", "migrations"] + "exclude": ["node_modules", "dist"] } diff --git a/tsconfig.lint.json b/tsconfig.lint.json deleted file mode 100644 index 99ffe861..00000000 --- a/tsconfig.lint.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "moduleResolution": "Node", - "module": "CommonJS", - "strict": true, - "noEmit": true, - "lib": ["ES2020"], - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "noImplicitAny": true, - "noUnusedLocals": true, - "noImplicitOverride": true, - "allowJs": true - } -} diff --git a/tsup-bin.config.ts b/tsup-bin.config.ts index e531177f..a793b89b 100644 --- a/tsup-bin.config.ts +++ b/tsup-bin.config.ts @@ -7,7 +7,7 @@ export default defineConfig({ format: ['esm', 'cjs'], target: ['es2022', 'node18'], dts: false, - minify: false, + minify: true, sourcemap: false, bundle: false, }); diff --git a/tsup.config.ts b/tsup.config.ts index 832712c6..3ef2b76b 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,29 +1,13 @@ import { defineConfig } from 'tsup'; -export default defineConfig([ - // src esm - { - entry: ['src/index.ts'], - outDir: 'dist/esm', - clean: true, - format: 'esm', - target: ['es2022', 'node18'], - dts: false, - minify: false, - sourcemap: false, - bundle: true, - outExtension: () => ({ js: '.mjs' }), - }, - // src cjs - { - entry: ['src/**/*.ts'], - outDir: 'dist', - clean: false, - format: 'cjs', - target: ['es2020', 'node16'], - dts: false, - minify: false, - sourcemap: false, - bundle: false, - }, -]); +export default defineConfig({ + entry: ['src/index.ts'], + outDir: 'dist', + clean: true, + format: ['esm', 'cjs'], + target: ['es2022', 'node18'], + dts: false, + minify: true, + sourcemap: false, + splitting: true, +}); From ba8014fc35e3257551c102da160e5cf17e7cc972 Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Mon, 26 Aug 2024 22:31:20 +0200 Subject: [PATCH 2/8] chore!: rename files to cjs --- templates/migration-template.ts | 2 +- test/{1414549381268_names.js => 1414549381268_names.cjs} | 0 ...81268_names_promise.js => 1414549381268_names_promise.cjs} | 0 test/cockroach/{004_table.js => 004_table.cjs} | 0 test/cockroach/{006_table_rename.js => 006_table_rename.cjs} | 0 test/cockroach/{008_column_drop.js => 008_column_drop.cjs} | 0 test/cockroach/{009_column.js => 009_column.cjs} | 0 .../cockroach/{011_column_rename.js => 011_column_rename.cjs} | 0 test/cockroach/{012_column_alter.js => 012_column_alter.cjs} | 0 .../{014_add_constraint.js => 014_add_constraint.cjs} | 0 .../{017_drop_constraint.js => 017_drop_constraint.cjs} | 2 +- test/cockroach/{019_add_index.js => 019_add_index.cjs} | 0 test/cockroach/{020_create_index.js => 020_create_index.cjs} | 0 test/cockroach/{062_view.js => 062_view.cjs} | 0 test/cockroach/{062_view_test.js => 062_view_test.cjs} | 0 test/migration.spec.ts | 4 ++-- test/migrations/{001_noop.js => 001_noop.cjs} | 0 test/migrations/{002_callback.js => 002_callback.cjs} | 0 test/migrations/{003_promise.js => 003_promise.cjs} | 0 test/migrations/{004_table.js => 004_table.cjs} | 0 test/migrations/{005_table_test.js => 005_table_test.cjs} | 0 test/migrations/{006_table_rename.js => 006_table_rename.cjs} | 0 .../{007_table_rename_test.js => 007_table_rename_test.cjs} | 0 test/migrations/{008_column_drop.js => 008_column_drop.cjs} | 0 test/migrations/{009_column.js => 009_column.cjs} | 0 test/migrations/{010_column_test.js => 010_column_test.cjs} | 0 .../{011_column_rename.js => 011_column_rename.cjs} | 0 test/migrations/{012_column_alter.js => 012_column_alter.cjs} | 0 .../{013_column_alter_test.js => 013_column_alter_test.cjs} | 0 .../{014_add_constraint.js => 014_add_constraint.cjs} | 0 ...015_add_constraint_test.js => 015_add_constraint_test.cjs} | 0 .../{016_rename_constraint.js => 016_rename_constraint.cjs} | 0 .../{017_drop_constraint.js => 017_drop_constraint.cjs} | 0 ...8_drop_constraint_test.js => 018_drop_constraint_test.cjs} | 0 test/migrations/{019_add_index.js => 019_add_index.cjs} | 0 test/migrations/{020_drop_index.js => 020_drop_index.cjs} | 0 test/migrations/{021_add_type.js => 021_add_type.cjs} | 0 .../{022_add_type_test.js => 022_add_type_test.cjs} | 0 .../{023_add_type_attribute.js => 023_add_type_attribute.cjs} | 0 ...type_attribute_test.js => 024_add_type_attribute_test.cjs} | 0 .../{025_set_type_attribute.js => 025_set_type_attribute.cjs} | 0 ...type_attribute_test.js => 026_set_type_attribute_test.cjs} | 0 .../{027_add_type_value.js => 027_add_type_value.cjs} | 0 ...028_add_type_value_test.js => 028_add_type_value_test.cjs} | 0 ...rename_type_attribute.js => 029_rename_type_attribute.cjs} | 0 ...e_attribute_test.js => 030_rename_type_attribute_test.cjs} | 0 ...031_drop_type_attribute.js => 031_drop_type_attribute.cjs} | 0 ...ype_attribute_test.js => 032_drop_type_attribute_test.cjs} | 0 test/migrations/{033_drop_type.js => 033_drop_type.cjs} | 0 .../{034_drop_type_test.js => 034_drop_type_test.cjs} | 0 test/migrations/{035_role_add.js => 035_role_add.cjs} | 0 test/migrations/{036_role_alter.js => 036_role_alter.cjs} | 0 test/migrations/{037_role_rename.js => 037_role_rename.cjs} | 0 test/migrations/{038_role_drop.js => 038_role_drop.cjs} | 0 .../{039_function_create.js => 039_function_create.cjs} | 0 .../{040_function_rename.js => 040_function_rename.cjs} | 0 .../{041_function_test.js => 041_function_test.cjs} | 0 .../{042_function_drop.js => 042_function_drop.cjs} | 0 ...trigger_create_rename.js => 043_trigger_create_rename.cjs} | 0 test/migrations/{044_trigger_test.js => 044_trigger_test.cjs} | 0 test/migrations/{045_trigger_drop.js => 045_trigger_drop.cjs} | 0 ...6_domain_create_rename.js => 046_domain_create_rename.cjs} | 0 test/migrations/{047_domain_check.js => 047_domain_check.cjs} | 0 test/migrations/{048_domain_drop.js => 048_domain_drop.cjs} | 0 ...quence_create_rename.js => 049_sequence_create_rename.cjs} | 0 .../{050_sequence_test.js => 050_sequence_test.cjs} | 0 .../{051_sequence_alter.js => 051_sequence_alter.cjs} | 0 ...052_sequence_alter_test.js => 052_sequence_alter_test.cjs} | 0 .../{053_sequence_drop.js => 053_sequence_drop.cjs} | 0 .../{054_operator_create.js => 054_operator_create.cjs} | 0 .../{055_operator_test.js => 055_operator_test.cjs} | 0 .../{056_operator_drop.js => 056_operator_drop.cjs} | 0 .../{057_policy_create.js => 057_policy_create.cjs} | 0 test/migrations/{058_policy_test.js => 058_policy_test.cjs} | 0 test/migrations/{059_policy_drop.js => 059_policy_drop.cjs} | 0 .../{060_column_comment.js => 060_column_comment.cjs} | 0 ...061_column_comment_test.js => 061_column_comment_test.cjs} | 0 test/migrations/{062_view.js => 062_view.cjs} | 0 test/migrations/{063_view_test.js => 063_view_test.cjs} | 0 .../{064_alter_view_column.js => 064_alter_view_column.cjs} | 0 .../{065_materialized_view.js => 065_materialized_view.cjs} | 0 ...terialized_view_test.js => 066_materialized_view_test.cjs} | 0 ...rialized_view_alter.js => 067_materialized_view_alter.cjs} | 0 test/migrations/{068_extension.js => 068_extension.cjs} | 0 test/migrations/{069_comments.js => 069_comments.cjs} | 0 .../{070_extension_schema.js => 070_extension_schema.cjs} | 0 ...foreign_key.js => 071_constraint_name_for_foreign_key.cjs} | 0 ...2_alter_column_comment.js => 072_alter_column_comment.cjs} | 0 ...lumn_comment_test.js => 073_alter_column_comment_test.cjs} | 0 .../{074_rename_type_value.js => 074_rename_type_value.cjs} | 0 .../{075_drop_index_schema.js => 075_drop_index_schema.cjs} | 0 .../{076_create_table_like.js => 076_create_table_like.cjs} | 0 ...erated_column.js => 077_create_table_generated_column.cjs} | 0 ...lumn_if_not_exists.js => 078_add_column_if_not_exists.cjs} | 0 .../{079_drop_index_schema.js => 079_drop_index_schema.cjs} | 0 ...take_2.js => 080_create_table_generated_column_take_2.cjs} | 0 .../{081_temporary_table.js => 081_temporary_table.cjs} | 0 test/migrations/{082_view_options.js => 082_view_options.cjs} | 0 ...alter_column_sequence.js => 083_alter_column_sequence.cjs} | 0 .../{084_drop_unique_index.js => 084_drop_unique_index.cjs} | 0 ...es_schemas_roles.js => 085_grant_tables_schemas_roles.cjs} | 0 test/migrations/{086_grant_test.js => 086_grant_test.cjs} | 0 ...s_schemas_roles.js => 087_revoke_tables_schemas_roles.cjs} | 0 test/migrations/{088_revoke_test.js => 088_revoke_test.cjs} | 0 .../{089_grant_reverse.js => 089_grant_reverse.cjs} | 0 test/migrations/{090_create_cast.js => 090_create_cast.cjs} | 0 test/migrations/{091_function_set.js => 091_function_set.cjs} | 0 107 files changed, 4 insertions(+), 4 deletions(-) rename test/{1414549381268_names.js => 1414549381268_names.cjs} (100%) rename test/{1414549381268_names_promise.js => 1414549381268_names_promise.cjs} (100%) rename test/cockroach/{004_table.js => 004_table.cjs} (100%) rename test/cockroach/{006_table_rename.js => 006_table_rename.cjs} (100%) rename test/cockroach/{008_column_drop.js => 008_column_drop.cjs} (100%) rename test/cockroach/{009_column.js => 009_column.cjs} (100%) rename test/cockroach/{011_column_rename.js => 011_column_rename.cjs} (100%) rename test/cockroach/{012_column_alter.js => 012_column_alter.cjs} (100%) rename test/cockroach/{014_add_constraint.js => 014_add_constraint.cjs} (100%) rename test/cockroach/{017_drop_constraint.js => 017_drop_constraint.cjs} (68%) rename test/cockroach/{019_add_index.js => 019_add_index.cjs} (100%) rename test/cockroach/{020_create_index.js => 020_create_index.cjs} (100%) rename test/cockroach/{062_view.js => 062_view.cjs} (100%) rename test/cockroach/{062_view_test.js => 062_view_test.cjs} (100%) rename test/migrations/{001_noop.js => 001_noop.cjs} (100%) rename test/migrations/{002_callback.js => 002_callback.cjs} (100%) rename test/migrations/{003_promise.js => 003_promise.cjs} (100%) rename test/migrations/{004_table.js => 004_table.cjs} (100%) rename test/migrations/{005_table_test.js => 005_table_test.cjs} (100%) rename test/migrations/{006_table_rename.js => 006_table_rename.cjs} (100%) rename test/migrations/{007_table_rename_test.js => 007_table_rename_test.cjs} (100%) rename test/migrations/{008_column_drop.js => 008_column_drop.cjs} (100%) rename test/migrations/{009_column.js => 009_column.cjs} (100%) rename test/migrations/{010_column_test.js => 010_column_test.cjs} (100%) rename test/migrations/{011_column_rename.js => 011_column_rename.cjs} (100%) rename test/migrations/{012_column_alter.js => 012_column_alter.cjs} (100%) rename test/migrations/{013_column_alter_test.js => 013_column_alter_test.cjs} (100%) rename test/migrations/{014_add_constraint.js => 014_add_constraint.cjs} (100%) rename test/migrations/{015_add_constraint_test.js => 015_add_constraint_test.cjs} (100%) rename test/migrations/{016_rename_constraint.js => 016_rename_constraint.cjs} (100%) rename test/migrations/{017_drop_constraint.js => 017_drop_constraint.cjs} (100%) rename test/migrations/{018_drop_constraint_test.js => 018_drop_constraint_test.cjs} (100%) rename test/migrations/{019_add_index.js => 019_add_index.cjs} (100%) rename test/migrations/{020_drop_index.js => 020_drop_index.cjs} (100%) rename test/migrations/{021_add_type.js => 021_add_type.cjs} (100%) rename test/migrations/{022_add_type_test.js => 022_add_type_test.cjs} (100%) rename test/migrations/{023_add_type_attribute.js => 023_add_type_attribute.cjs} (100%) rename test/migrations/{024_add_type_attribute_test.js => 024_add_type_attribute_test.cjs} (100%) rename test/migrations/{025_set_type_attribute.js => 025_set_type_attribute.cjs} (100%) rename test/migrations/{026_set_type_attribute_test.js => 026_set_type_attribute_test.cjs} (100%) rename test/migrations/{027_add_type_value.js => 027_add_type_value.cjs} (100%) rename test/migrations/{028_add_type_value_test.js => 028_add_type_value_test.cjs} (100%) rename test/migrations/{029_rename_type_attribute.js => 029_rename_type_attribute.cjs} (100%) rename test/migrations/{030_rename_type_attribute_test.js => 030_rename_type_attribute_test.cjs} (100%) rename test/migrations/{031_drop_type_attribute.js => 031_drop_type_attribute.cjs} (100%) rename test/migrations/{032_drop_type_attribute_test.js => 032_drop_type_attribute_test.cjs} (100%) rename test/migrations/{033_drop_type.js => 033_drop_type.cjs} (100%) rename test/migrations/{034_drop_type_test.js => 034_drop_type_test.cjs} (100%) rename test/migrations/{035_role_add.js => 035_role_add.cjs} (100%) rename test/migrations/{036_role_alter.js => 036_role_alter.cjs} (100%) rename test/migrations/{037_role_rename.js => 037_role_rename.cjs} (100%) rename test/migrations/{038_role_drop.js => 038_role_drop.cjs} (100%) rename test/migrations/{039_function_create.js => 039_function_create.cjs} (100%) rename test/migrations/{040_function_rename.js => 040_function_rename.cjs} (100%) rename test/migrations/{041_function_test.js => 041_function_test.cjs} (100%) rename test/migrations/{042_function_drop.js => 042_function_drop.cjs} (100%) rename test/migrations/{043_trigger_create_rename.js => 043_trigger_create_rename.cjs} (100%) rename test/migrations/{044_trigger_test.js => 044_trigger_test.cjs} (100%) rename test/migrations/{045_trigger_drop.js => 045_trigger_drop.cjs} (100%) rename test/migrations/{046_domain_create_rename.js => 046_domain_create_rename.cjs} (100%) rename test/migrations/{047_domain_check.js => 047_domain_check.cjs} (100%) rename test/migrations/{048_domain_drop.js => 048_domain_drop.cjs} (100%) rename test/migrations/{049_sequence_create_rename.js => 049_sequence_create_rename.cjs} (100%) rename test/migrations/{050_sequence_test.js => 050_sequence_test.cjs} (100%) rename test/migrations/{051_sequence_alter.js => 051_sequence_alter.cjs} (100%) rename test/migrations/{052_sequence_alter_test.js => 052_sequence_alter_test.cjs} (100%) rename test/migrations/{053_sequence_drop.js => 053_sequence_drop.cjs} (100%) rename test/migrations/{054_operator_create.js => 054_operator_create.cjs} (100%) rename test/migrations/{055_operator_test.js => 055_operator_test.cjs} (100%) rename test/migrations/{056_operator_drop.js => 056_operator_drop.cjs} (100%) rename test/migrations/{057_policy_create.js => 057_policy_create.cjs} (100%) rename test/migrations/{058_policy_test.js => 058_policy_test.cjs} (100%) rename test/migrations/{059_policy_drop.js => 059_policy_drop.cjs} (100%) rename test/migrations/{060_column_comment.js => 060_column_comment.cjs} (100%) rename test/migrations/{061_column_comment_test.js => 061_column_comment_test.cjs} (100%) rename test/migrations/{062_view.js => 062_view.cjs} (100%) rename test/migrations/{063_view_test.js => 063_view_test.cjs} (100%) rename test/migrations/{064_alter_view_column.js => 064_alter_view_column.cjs} (100%) rename test/migrations/{065_materialized_view.js => 065_materialized_view.cjs} (100%) rename test/migrations/{066_materialized_view_test.js => 066_materialized_view_test.cjs} (100%) rename test/migrations/{067_materialized_view_alter.js => 067_materialized_view_alter.cjs} (100%) rename test/migrations/{068_extension.js => 068_extension.cjs} (100%) rename test/migrations/{069_comments.js => 069_comments.cjs} (100%) rename test/migrations/{070_extension_schema.js => 070_extension_schema.cjs} (100%) rename test/migrations/{071_constraint_name_for_foreign_key.js => 071_constraint_name_for_foreign_key.cjs} (100%) rename test/migrations/{072_alter_column_comment.js => 072_alter_column_comment.cjs} (100%) rename test/migrations/{073_alter_column_comment_test.js => 073_alter_column_comment_test.cjs} (100%) rename test/migrations/{074_rename_type_value.js => 074_rename_type_value.cjs} (100%) rename test/migrations/{075_drop_index_schema.js => 075_drop_index_schema.cjs} (100%) rename test/migrations/{076_create_table_like.js => 076_create_table_like.cjs} (100%) rename test/migrations/{077_create_table_generated_column.js => 077_create_table_generated_column.cjs} (100%) rename test/migrations/{078_add_column_if_not_exists.js => 078_add_column_if_not_exists.cjs} (100%) rename test/migrations/{079_drop_index_schema.js => 079_drop_index_schema.cjs} (100%) rename test/migrations/{080_create_table_generated_column_take_2.js => 080_create_table_generated_column_take_2.cjs} (100%) rename test/migrations/{081_temporary_table.js => 081_temporary_table.cjs} (100%) rename test/migrations/{082_view_options.js => 082_view_options.cjs} (100%) rename test/migrations/{083_alter_column_sequence.js => 083_alter_column_sequence.cjs} (100%) rename test/migrations/{084_drop_unique_index.js => 084_drop_unique_index.cjs} (100%) rename test/migrations/{085_grant_tables_schemas_roles.js => 085_grant_tables_schemas_roles.cjs} (100%) rename test/migrations/{086_grant_test.js => 086_grant_test.cjs} (100%) rename test/migrations/{087_revoke_tables_schemas_roles.js => 087_revoke_tables_schemas_roles.cjs} (100%) rename test/migrations/{088_revoke_test.js => 088_revoke_test.cjs} (100%) rename test/migrations/{089_grant_reverse.js => 089_grant_reverse.cjs} (100%) rename test/migrations/{090_create_cast.js => 090_create_cast.cjs} (100%) rename test/migrations/{091_function_set.js => 091_function_set.cjs} (100%) diff --git a/templates/migration-template.ts b/templates/migration-template.ts index 6ba1556f..1fe0d9cd 100644 --- a/templates/migration-template.ts +++ b/templates/migration-template.ts @@ -1,4 +1,4 @@ -import { ColumnDefinitions, MigrationBuilder } from 'node-pg-migrate'; +import type { ColumnDefinitions, MigrationBuilder } from 'node-pg-migrate'; export const shorthands: ColumnDefinitions | undefined = undefined; diff --git a/test/1414549381268_names.js b/test/1414549381268_names.cjs similarity index 100% rename from test/1414549381268_names.js rename to test/1414549381268_names.cjs diff --git a/test/1414549381268_names_promise.js b/test/1414549381268_names_promise.cjs similarity index 100% rename from test/1414549381268_names_promise.js rename to test/1414549381268_names_promise.cjs diff --git a/test/cockroach/004_table.js b/test/cockroach/004_table.cjs similarity index 100% rename from test/cockroach/004_table.js rename to test/cockroach/004_table.cjs diff --git a/test/cockroach/006_table_rename.js b/test/cockroach/006_table_rename.cjs similarity index 100% rename from test/cockroach/006_table_rename.js rename to test/cockroach/006_table_rename.cjs diff --git a/test/cockroach/008_column_drop.js b/test/cockroach/008_column_drop.cjs similarity index 100% rename from test/cockroach/008_column_drop.js rename to test/cockroach/008_column_drop.cjs diff --git a/test/cockroach/009_column.js b/test/cockroach/009_column.cjs similarity index 100% rename from test/cockroach/009_column.js rename to test/cockroach/009_column.cjs diff --git a/test/cockroach/011_column_rename.js b/test/cockroach/011_column_rename.cjs similarity index 100% rename from test/cockroach/011_column_rename.js rename to test/cockroach/011_column_rename.cjs diff --git a/test/cockroach/012_column_alter.js b/test/cockroach/012_column_alter.cjs similarity index 100% rename from test/cockroach/012_column_alter.js rename to test/cockroach/012_column_alter.cjs diff --git a/test/cockroach/014_add_constraint.js b/test/cockroach/014_add_constraint.cjs similarity index 100% rename from test/cockroach/014_add_constraint.js rename to test/cockroach/014_add_constraint.cjs diff --git a/test/cockroach/017_drop_constraint.js b/test/cockroach/017_drop_constraint.cjs similarity index 68% rename from test/cockroach/017_drop_constraint.js rename to test/cockroach/017_drop_constraint.cjs index 8c78f4e7..81459713 100644 --- a/test/cockroach/017_drop_constraint.js +++ b/test/cockroach/017_drop_constraint.cjs @@ -1,4 +1,4 @@ -const constraint = require('./014_add_constraint'); +const constraint = require('./014_add_constraint.cjs'); exports.up = (pgm) => { pgm.dropConstraint('t1', constraint.constraint); diff --git a/test/cockroach/019_add_index.js b/test/cockroach/019_add_index.cjs similarity index 100% rename from test/cockroach/019_add_index.js rename to test/cockroach/019_add_index.cjs diff --git a/test/cockroach/020_create_index.js b/test/cockroach/020_create_index.cjs similarity index 100% rename from test/cockroach/020_create_index.js rename to test/cockroach/020_create_index.cjs diff --git a/test/cockroach/062_view.js b/test/cockroach/062_view.cjs similarity index 100% rename from test/cockroach/062_view.js rename to test/cockroach/062_view.cjs diff --git a/test/cockroach/062_view_test.js b/test/cockroach/062_view_test.cjs similarity index 100% rename from test/cockroach/062_view_test.js rename to test/cockroach/062_view_test.cjs diff --git a/test/migration.spec.ts b/test/migration.spec.ts index a2e2ab59..8c8a2a92 100644 --- a/test/migration.spec.ts +++ b/test/migration.spec.ts @@ -4,8 +4,8 @@ import type { DBConnection } from '../src/db'; import { getTimestamp, Migration } from '../src/migration'; import type { Logger, RunnerOption } from '../src/types'; -const callbackMigration = '1414549381268_names.js'; -const promiseMigration = '1414549381268_names_promise.js'; +const callbackMigration = '1414549381268_names.cjs'; +const promiseMigration = '1414549381268_names_promise.cjs'; const migrationsTable = 'pgmigrations'; const actionsCallback = require(`./${callbackMigration}`); diff --git a/test/migrations/001_noop.js b/test/migrations/001_noop.cjs similarity index 100% rename from test/migrations/001_noop.js rename to test/migrations/001_noop.cjs diff --git a/test/migrations/002_callback.js b/test/migrations/002_callback.cjs similarity index 100% rename from test/migrations/002_callback.js rename to test/migrations/002_callback.cjs diff --git a/test/migrations/003_promise.js b/test/migrations/003_promise.cjs similarity index 100% rename from test/migrations/003_promise.js rename to test/migrations/003_promise.cjs diff --git a/test/migrations/004_table.js b/test/migrations/004_table.cjs similarity index 100% rename from test/migrations/004_table.js rename to test/migrations/004_table.cjs diff --git a/test/migrations/005_table_test.js b/test/migrations/005_table_test.cjs similarity index 100% rename from test/migrations/005_table_test.js rename to test/migrations/005_table_test.cjs diff --git a/test/migrations/006_table_rename.js b/test/migrations/006_table_rename.cjs similarity index 100% rename from test/migrations/006_table_rename.js rename to test/migrations/006_table_rename.cjs diff --git a/test/migrations/007_table_rename_test.js b/test/migrations/007_table_rename_test.cjs similarity index 100% rename from test/migrations/007_table_rename_test.js rename to test/migrations/007_table_rename_test.cjs diff --git a/test/migrations/008_column_drop.js b/test/migrations/008_column_drop.cjs similarity index 100% rename from test/migrations/008_column_drop.js rename to test/migrations/008_column_drop.cjs diff --git a/test/migrations/009_column.js b/test/migrations/009_column.cjs similarity index 100% rename from test/migrations/009_column.js rename to test/migrations/009_column.cjs diff --git a/test/migrations/010_column_test.js b/test/migrations/010_column_test.cjs similarity index 100% rename from test/migrations/010_column_test.js rename to test/migrations/010_column_test.cjs diff --git a/test/migrations/011_column_rename.js b/test/migrations/011_column_rename.cjs similarity index 100% rename from test/migrations/011_column_rename.js rename to test/migrations/011_column_rename.cjs diff --git a/test/migrations/012_column_alter.js b/test/migrations/012_column_alter.cjs similarity index 100% rename from test/migrations/012_column_alter.js rename to test/migrations/012_column_alter.cjs diff --git a/test/migrations/013_column_alter_test.js b/test/migrations/013_column_alter_test.cjs similarity index 100% rename from test/migrations/013_column_alter_test.js rename to test/migrations/013_column_alter_test.cjs diff --git a/test/migrations/014_add_constraint.js b/test/migrations/014_add_constraint.cjs similarity index 100% rename from test/migrations/014_add_constraint.js rename to test/migrations/014_add_constraint.cjs diff --git a/test/migrations/015_add_constraint_test.js b/test/migrations/015_add_constraint_test.cjs similarity index 100% rename from test/migrations/015_add_constraint_test.js rename to test/migrations/015_add_constraint_test.cjs diff --git a/test/migrations/016_rename_constraint.js b/test/migrations/016_rename_constraint.cjs similarity index 100% rename from test/migrations/016_rename_constraint.js rename to test/migrations/016_rename_constraint.cjs diff --git a/test/migrations/017_drop_constraint.js b/test/migrations/017_drop_constraint.cjs similarity index 100% rename from test/migrations/017_drop_constraint.js rename to test/migrations/017_drop_constraint.cjs diff --git a/test/migrations/018_drop_constraint_test.js b/test/migrations/018_drop_constraint_test.cjs similarity index 100% rename from test/migrations/018_drop_constraint_test.js rename to test/migrations/018_drop_constraint_test.cjs diff --git a/test/migrations/019_add_index.js b/test/migrations/019_add_index.cjs similarity index 100% rename from test/migrations/019_add_index.js rename to test/migrations/019_add_index.cjs diff --git a/test/migrations/020_drop_index.js b/test/migrations/020_drop_index.cjs similarity index 100% rename from test/migrations/020_drop_index.js rename to test/migrations/020_drop_index.cjs diff --git a/test/migrations/021_add_type.js b/test/migrations/021_add_type.cjs similarity index 100% rename from test/migrations/021_add_type.js rename to test/migrations/021_add_type.cjs diff --git a/test/migrations/022_add_type_test.js b/test/migrations/022_add_type_test.cjs similarity index 100% rename from test/migrations/022_add_type_test.js rename to test/migrations/022_add_type_test.cjs diff --git a/test/migrations/023_add_type_attribute.js b/test/migrations/023_add_type_attribute.cjs similarity index 100% rename from test/migrations/023_add_type_attribute.js rename to test/migrations/023_add_type_attribute.cjs diff --git a/test/migrations/024_add_type_attribute_test.js b/test/migrations/024_add_type_attribute_test.cjs similarity index 100% rename from test/migrations/024_add_type_attribute_test.js rename to test/migrations/024_add_type_attribute_test.cjs diff --git a/test/migrations/025_set_type_attribute.js b/test/migrations/025_set_type_attribute.cjs similarity index 100% rename from test/migrations/025_set_type_attribute.js rename to test/migrations/025_set_type_attribute.cjs diff --git a/test/migrations/026_set_type_attribute_test.js b/test/migrations/026_set_type_attribute_test.cjs similarity index 100% rename from test/migrations/026_set_type_attribute_test.js rename to test/migrations/026_set_type_attribute_test.cjs diff --git a/test/migrations/027_add_type_value.js b/test/migrations/027_add_type_value.cjs similarity index 100% rename from test/migrations/027_add_type_value.js rename to test/migrations/027_add_type_value.cjs diff --git a/test/migrations/028_add_type_value_test.js b/test/migrations/028_add_type_value_test.cjs similarity index 100% rename from test/migrations/028_add_type_value_test.js rename to test/migrations/028_add_type_value_test.cjs diff --git a/test/migrations/029_rename_type_attribute.js b/test/migrations/029_rename_type_attribute.cjs similarity index 100% rename from test/migrations/029_rename_type_attribute.js rename to test/migrations/029_rename_type_attribute.cjs diff --git a/test/migrations/030_rename_type_attribute_test.js b/test/migrations/030_rename_type_attribute_test.cjs similarity index 100% rename from test/migrations/030_rename_type_attribute_test.js rename to test/migrations/030_rename_type_attribute_test.cjs diff --git a/test/migrations/031_drop_type_attribute.js b/test/migrations/031_drop_type_attribute.cjs similarity index 100% rename from test/migrations/031_drop_type_attribute.js rename to test/migrations/031_drop_type_attribute.cjs diff --git a/test/migrations/032_drop_type_attribute_test.js b/test/migrations/032_drop_type_attribute_test.cjs similarity index 100% rename from test/migrations/032_drop_type_attribute_test.js rename to test/migrations/032_drop_type_attribute_test.cjs diff --git a/test/migrations/033_drop_type.js b/test/migrations/033_drop_type.cjs similarity index 100% rename from test/migrations/033_drop_type.js rename to test/migrations/033_drop_type.cjs diff --git a/test/migrations/034_drop_type_test.js b/test/migrations/034_drop_type_test.cjs similarity index 100% rename from test/migrations/034_drop_type_test.js rename to test/migrations/034_drop_type_test.cjs diff --git a/test/migrations/035_role_add.js b/test/migrations/035_role_add.cjs similarity index 100% rename from test/migrations/035_role_add.js rename to test/migrations/035_role_add.cjs diff --git a/test/migrations/036_role_alter.js b/test/migrations/036_role_alter.cjs similarity index 100% rename from test/migrations/036_role_alter.js rename to test/migrations/036_role_alter.cjs diff --git a/test/migrations/037_role_rename.js b/test/migrations/037_role_rename.cjs similarity index 100% rename from test/migrations/037_role_rename.js rename to test/migrations/037_role_rename.cjs diff --git a/test/migrations/038_role_drop.js b/test/migrations/038_role_drop.cjs similarity index 100% rename from test/migrations/038_role_drop.js rename to test/migrations/038_role_drop.cjs diff --git a/test/migrations/039_function_create.js b/test/migrations/039_function_create.cjs similarity index 100% rename from test/migrations/039_function_create.js rename to test/migrations/039_function_create.cjs diff --git a/test/migrations/040_function_rename.js b/test/migrations/040_function_rename.cjs similarity index 100% rename from test/migrations/040_function_rename.js rename to test/migrations/040_function_rename.cjs diff --git a/test/migrations/041_function_test.js b/test/migrations/041_function_test.cjs similarity index 100% rename from test/migrations/041_function_test.js rename to test/migrations/041_function_test.cjs diff --git a/test/migrations/042_function_drop.js b/test/migrations/042_function_drop.cjs similarity index 100% rename from test/migrations/042_function_drop.js rename to test/migrations/042_function_drop.cjs diff --git a/test/migrations/043_trigger_create_rename.js b/test/migrations/043_trigger_create_rename.cjs similarity index 100% rename from test/migrations/043_trigger_create_rename.js rename to test/migrations/043_trigger_create_rename.cjs diff --git a/test/migrations/044_trigger_test.js b/test/migrations/044_trigger_test.cjs similarity index 100% rename from test/migrations/044_trigger_test.js rename to test/migrations/044_trigger_test.cjs diff --git a/test/migrations/045_trigger_drop.js b/test/migrations/045_trigger_drop.cjs similarity index 100% rename from test/migrations/045_trigger_drop.js rename to test/migrations/045_trigger_drop.cjs diff --git a/test/migrations/046_domain_create_rename.js b/test/migrations/046_domain_create_rename.cjs similarity index 100% rename from test/migrations/046_domain_create_rename.js rename to test/migrations/046_domain_create_rename.cjs diff --git a/test/migrations/047_domain_check.js b/test/migrations/047_domain_check.cjs similarity index 100% rename from test/migrations/047_domain_check.js rename to test/migrations/047_domain_check.cjs diff --git a/test/migrations/048_domain_drop.js b/test/migrations/048_domain_drop.cjs similarity index 100% rename from test/migrations/048_domain_drop.js rename to test/migrations/048_domain_drop.cjs diff --git a/test/migrations/049_sequence_create_rename.js b/test/migrations/049_sequence_create_rename.cjs similarity index 100% rename from test/migrations/049_sequence_create_rename.js rename to test/migrations/049_sequence_create_rename.cjs diff --git a/test/migrations/050_sequence_test.js b/test/migrations/050_sequence_test.cjs similarity index 100% rename from test/migrations/050_sequence_test.js rename to test/migrations/050_sequence_test.cjs diff --git a/test/migrations/051_sequence_alter.js b/test/migrations/051_sequence_alter.cjs similarity index 100% rename from test/migrations/051_sequence_alter.js rename to test/migrations/051_sequence_alter.cjs diff --git a/test/migrations/052_sequence_alter_test.js b/test/migrations/052_sequence_alter_test.cjs similarity index 100% rename from test/migrations/052_sequence_alter_test.js rename to test/migrations/052_sequence_alter_test.cjs diff --git a/test/migrations/053_sequence_drop.js b/test/migrations/053_sequence_drop.cjs similarity index 100% rename from test/migrations/053_sequence_drop.js rename to test/migrations/053_sequence_drop.cjs diff --git a/test/migrations/054_operator_create.js b/test/migrations/054_operator_create.cjs similarity index 100% rename from test/migrations/054_operator_create.js rename to test/migrations/054_operator_create.cjs diff --git a/test/migrations/055_operator_test.js b/test/migrations/055_operator_test.cjs similarity index 100% rename from test/migrations/055_operator_test.js rename to test/migrations/055_operator_test.cjs diff --git a/test/migrations/056_operator_drop.js b/test/migrations/056_operator_drop.cjs similarity index 100% rename from test/migrations/056_operator_drop.js rename to test/migrations/056_operator_drop.cjs diff --git a/test/migrations/057_policy_create.js b/test/migrations/057_policy_create.cjs similarity index 100% rename from test/migrations/057_policy_create.js rename to test/migrations/057_policy_create.cjs diff --git a/test/migrations/058_policy_test.js b/test/migrations/058_policy_test.cjs similarity index 100% rename from test/migrations/058_policy_test.js rename to test/migrations/058_policy_test.cjs diff --git a/test/migrations/059_policy_drop.js b/test/migrations/059_policy_drop.cjs similarity index 100% rename from test/migrations/059_policy_drop.js rename to test/migrations/059_policy_drop.cjs diff --git a/test/migrations/060_column_comment.js b/test/migrations/060_column_comment.cjs similarity index 100% rename from test/migrations/060_column_comment.js rename to test/migrations/060_column_comment.cjs diff --git a/test/migrations/061_column_comment_test.js b/test/migrations/061_column_comment_test.cjs similarity index 100% rename from test/migrations/061_column_comment_test.js rename to test/migrations/061_column_comment_test.cjs diff --git a/test/migrations/062_view.js b/test/migrations/062_view.cjs similarity index 100% rename from test/migrations/062_view.js rename to test/migrations/062_view.cjs diff --git a/test/migrations/063_view_test.js b/test/migrations/063_view_test.cjs similarity index 100% rename from test/migrations/063_view_test.js rename to test/migrations/063_view_test.cjs diff --git a/test/migrations/064_alter_view_column.js b/test/migrations/064_alter_view_column.cjs similarity index 100% rename from test/migrations/064_alter_view_column.js rename to test/migrations/064_alter_view_column.cjs diff --git a/test/migrations/065_materialized_view.js b/test/migrations/065_materialized_view.cjs similarity index 100% rename from test/migrations/065_materialized_view.js rename to test/migrations/065_materialized_view.cjs diff --git a/test/migrations/066_materialized_view_test.js b/test/migrations/066_materialized_view_test.cjs similarity index 100% rename from test/migrations/066_materialized_view_test.js rename to test/migrations/066_materialized_view_test.cjs diff --git a/test/migrations/067_materialized_view_alter.js b/test/migrations/067_materialized_view_alter.cjs similarity index 100% rename from test/migrations/067_materialized_view_alter.js rename to test/migrations/067_materialized_view_alter.cjs diff --git a/test/migrations/068_extension.js b/test/migrations/068_extension.cjs similarity index 100% rename from test/migrations/068_extension.js rename to test/migrations/068_extension.cjs diff --git a/test/migrations/069_comments.js b/test/migrations/069_comments.cjs similarity index 100% rename from test/migrations/069_comments.js rename to test/migrations/069_comments.cjs diff --git a/test/migrations/070_extension_schema.js b/test/migrations/070_extension_schema.cjs similarity index 100% rename from test/migrations/070_extension_schema.js rename to test/migrations/070_extension_schema.cjs diff --git a/test/migrations/071_constraint_name_for_foreign_key.js b/test/migrations/071_constraint_name_for_foreign_key.cjs similarity index 100% rename from test/migrations/071_constraint_name_for_foreign_key.js rename to test/migrations/071_constraint_name_for_foreign_key.cjs diff --git a/test/migrations/072_alter_column_comment.js b/test/migrations/072_alter_column_comment.cjs similarity index 100% rename from test/migrations/072_alter_column_comment.js rename to test/migrations/072_alter_column_comment.cjs diff --git a/test/migrations/073_alter_column_comment_test.js b/test/migrations/073_alter_column_comment_test.cjs similarity index 100% rename from test/migrations/073_alter_column_comment_test.js rename to test/migrations/073_alter_column_comment_test.cjs diff --git a/test/migrations/074_rename_type_value.js b/test/migrations/074_rename_type_value.cjs similarity index 100% rename from test/migrations/074_rename_type_value.js rename to test/migrations/074_rename_type_value.cjs diff --git a/test/migrations/075_drop_index_schema.js b/test/migrations/075_drop_index_schema.cjs similarity index 100% rename from test/migrations/075_drop_index_schema.js rename to test/migrations/075_drop_index_schema.cjs diff --git a/test/migrations/076_create_table_like.js b/test/migrations/076_create_table_like.cjs similarity index 100% rename from test/migrations/076_create_table_like.js rename to test/migrations/076_create_table_like.cjs diff --git a/test/migrations/077_create_table_generated_column.js b/test/migrations/077_create_table_generated_column.cjs similarity index 100% rename from test/migrations/077_create_table_generated_column.js rename to test/migrations/077_create_table_generated_column.cjs diff --git a/test/migrations/078_add_column_if_not_exists.js b/test/migrations/078_add_column_if_not_exists.cjs similarity index 100% rename from test/migrations/078_add_column_if_not_exists.js rename to test/migrations/078_add_column_if_not_exists.cjs diff --git a/test/migrations/079_drop_index_schema.js b/test/migrations/079_drop_index_schema.cjs similarity index 100% rename from test/migrations/079_drop_index_schema.js rename to test/migrations/079_drop_index_schema.cjs diff --git a/test/migrations/080_create_table_generated_column_take_2.js b/test/migrations/080_create_table_generated_column_take_2.cjs similarity index 100% rename from test/migrations/080_create_table_generated_column_take_2.js rename to test/migrations/080_create_table_generated_column_take_2.cjs diff --git a/test/migrations/081_temporary_table.js b/test/migrations/081_temporary_table.cjs similarity index 100% rename from test/migrations/081_temporary_table.js rename to test/migrations/081_temporary_table.cjs diff --git a/test/migrations/082_view_options.js b/test/migrations/082_view_options.cjs similarity index 100% rename from test/migrations/082_view_options.js rename to test/migrations/082_view_options.cjs diff --git a/test/migrations/083_alter_column_sequence.js b/test/migrations/083_alter_column_sequence.cjs similarity index 100% rename from test/migrations/083_alter_column_sequence.js rename to test/migrations/083_alter_column_sequence.cjs diff --git a/test/migrations/084_drop_unique_index.js b/test/migrations/084_drop_unique_index.cjs similarity index 100% rename from test/migrations/084_drop_unique_index.js rename to test/migrations/084_drop_unique_index.cjs diff --git a/test/migrations/085_grant_tables_schemas_roles.js b/test/migrations/085_grant_tables_schemas_roles.cjs similarity index 100% rename from test/migrations/085_grant_tables_schemas_roles.js rename to test/migrations/085_grant_tables_schemas_roles.cjs diff --git a/test/migrations/086_grant_test.js b/test/migrations/086_grant_test.cjs similarity index 100% rename from test/migrations/086_grant_test.js rename to test/migrations/086_grant_test.cjs diff --git a/test/migrations/087_revoke_tables_schemas_roles.js b/test/migrations/087_revoke_tables_schemas_roles.cjs similarity index 100% rename from test/migrations/087_revoke_tables_schemas_roles.js rename to test/migrations/087_revoke_tables_schemas_roles.cjs diff --git a/test/migrations/088_revoke_test.js b/test/migrations/088_revoke_test.cjs similarity index 100% rename from test/migrations/088_revoke_test.js rename to test/migrations/088_revoke_test.cjs diff --git a/test/migrations/089_grant_reverse.js b/test/migrations/089_grant_reverse.cjs similarity index 100% rename from test/migrations/089_grant_reverse.js rename to test/migrations/089_grant_reverse.cjs diff --git a/test/migrations/090_create_cast.js b/test/migrations/090_create_cast.cjs similarity index 100% rename from test/migrations/090_create_cast.js rename to test/migrations/090_create_cast.cjs diff --git a/test/migrations/091_function_set.js b/test/migrations/091_function_set.cjs similarity index 100% rename from test/migrations/091_function_set.js rename to test/migrations/091_function_set.cjs From e2fb129c2c669cc68fc8592c284f5140a03ac982 Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Mon, 26 Aug 2024 22:37:38 +0200 Subject: [PATCH 3/8] chore: remove unnecessary default property in package.json --- package.json | 6 ++---- tsconfig.build.json | 7 +------ 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 6efdf280..bbb942e2 100644 --- a/package.json +++ b/package.json @@ -36,13 +36,11 @@ ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js", - "require": "./dist/index.cjs", - "default": "./dist/index.js" + "require": "./dist/index.cjs" }, "./bin/*": { "import": "./bin/*.js", - "require": "./bin/*.cjs", - "default": "./bin/*.js" + "require": "./bin/*.cjs" }, "./package.json": "./package.json" }, diff --git a/tsconfig.build.json b/tsconfig.build.json index fae28412..d53ec84f 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -5,12 +5,7 @@ "noEmit": false, "emitDeclarationOnly": true, "rootDir": "src", - "outDir": "dist", - - // This negates what is set in the extended tsconfig.json - "skipLibCheck": false, - "allowSyntheticDefaultImports": false, - "resolveJsonModule": false + "outDir": "dist" }, "include": ["src"] } From f52c9cad6ee8020109e2f3591c735055cebe4ee3 Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Mon, 26 Aug 2024 22:41:08 +0200 Subject: [PATCH 4/8] chore: adjust pg import --- src/db.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/db.ts b/src/db.ts index e0389975..e9925541 100644 --- a/src/db.ts +++ b/src/db.ts @@ -11,7 +11,7 @@ import type { QueryConfig, QueryResult, } from 'pg'; -import * as pg from 'pg'; +import pg from 'pg'; import type { DB, Logger } from './types'; /* eslint-disable @typescript-eslint/no-explicit-any */ From 4f564b454d30a1f927f0a75ed6127b245215e2ef Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Mon, 26 Aug 2024 23:07:35 +0200 Subject: [PATCH 5/8] chore: update file extensions to .cjs --- .eslintrc.cjs | 2 +- test/migrations/005_table_test.cjs | 2 +- test/migrations/016_rename_constraint.cjs | 2 +- test/migrations/017_drop_constraint.cjs | 2 +- test/migrations/038_role_drop.cjs | 4 ++-- test/migrations/040_function_rename.cjs | 2 +- test/migrations/042_function_drop.cjs | 4 ++-- test/migrations/045_trigger_drop.cjs | 2 +- test/migrations/048_domain_drop.cjs | 2 +- test/migrations/053_sequence_drop.cjs | 2 +- test/migrations/056_operator_drop.cjs | 2 +- test/migrations/059_policy_drop.cjs | 2 +- test/migrations/061_column_comment_test.cjs | 2 +- test/migrations/073_alter_column_comment_test.cjs | 2 +- test/migrations/086_grant_test.cjs | 2 +- test/migrations/087_revoke_tables_schemas_roles.cjs | 2 +- test/migrations/088_revoke_test.cjs | 4 ++-- 17 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 861872d8..ca471689 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -141,7 +141,7 @@ module.exports = defineConfig({ }, overrides: [ { - files: ['test/migrations/*.js'], + files: ['test/migrations/*.js', 'test/migrations/*.cjs'], rules: { 'unicorn/prefer-module': 'off', diff --git a/test/migrations/005_table_test.cjs b/test/migrations/005_table_test.cjs index 04097843..dd858495 100644 --- a/test/migrations/005_table_test.cjs +++ b/test/migrations/005_table_test.cjs @@ -1,4 +1,4 @@ -const table = require('./004_table'); +const table = require('./004_table.cjs'); const schema = process.env.SCHEMA || 'public'; diff --git a/test/migrations/016_rename_constraint.cjs b/test/migrations/016_rename_constraint.cjs index a02585b1..d96a7156 100644 --- a/test/migrations/016_rename_constraint.cjs +++ b/test/migrations/016_rename_constraint.cjs @@ -1,4 +1,4 @@ -const constraint = require('./014_add_constraint'); +const constraint = require('./014_add_constraint.cjs'); exports.constraint = 'chck_nmbr_new'; diff --git a/test/migrations/017_drop_constraint.cjs b/test/migrations/017_drop_constraint.cjs index 33cea907..099289a2 100644 --- a/test/migrations/017_drop_constraint.cjs +++ b/test/migrations/017_drop_constraint.cjs @@ -1,4 +1,4 @@ -const constraint = require('./016_rename_constraint'); +const constraint = require('./016_rename_constraint.cjs'); exports.up = (pgm) => { pgm.dropConstraint('t1', constraint.constraint); diff --git a/test/migrations/038_role_drop.cjs b/test/migrations/038_role_drop.cjs index 3c074d95..037b80e4 100644 --- a/test/migrations/038_role_drop.cjs +++ b/test/migrations/038_role_drop.cjs @@ -1,5 +1,5 @@ -const create = require('./035_role_add'); -const rename = require('./037_role_rename'); +const create = require('./035_role_add.cjs'); +const rename = require('./037_role_rename.cjs'); exports.up = (pgm) => { pgm.dropRole('rx'); diff --git a/test/migrations/040_function_rename.cjs b/test/migrations/040_function_rename.cjs index 7bf7ca38..cf67eae1 100644 --- a/test/migrations/040_function_rename.cjs +++ b/test/migrations/040_function_rename.cjs @@ -1,4 +1,4 @@ -const { params } = require('./039_function_create'); +const { params } = require('./039_function_create.cjs'); exports.up = (pgm) => { pgm.renameFunction('f', params, 'add'); diff --git a/test/migrations/042_function_drop.cjs b/test/migrations/042_function_drop.cjs index 2f3af71b..c2277e34 100644 --- a/test/migrations/042_function_drop.cjs +++ b/test/migrations/042_function_drop.cjs @@ -1,5 +1,5 @@ -const create = require('./039_function_create'); -const rename = require('./040_function_rename'); +const create = require('./039_function_create.cjs'); +const rename = require('./040_function_rename.cjs'); exports.up = (pgm) => { pgm.dropFunction('add', create.params); diff --git a/test/migrations/045_trigger_drop.cjs b/test/migrations/045_trigger_drop.cjs index 7658f437..0723cff8 100644 --- a/test/migrations/045_trigger_drop.cjs +++ b/test/migrations/045_trigger_drop.cjs @@ -1,4 +1,4 @@ -const trigger = require('./043_trigger_create_rename'); +const trigger = require('./043_trigger_create_rename.cjs'); exports.up = (pgm) => { pgm.dropTrigger('tt', 'trig'); diff --git a/test/migrations/048_domain_drop.cjs b/test/migrations/048_domain_drop.cjs index bc8bb5e8..24488034 100644 --- a/test/migrations/048_domain_drop.cjs +++ b/test/migrations/048_domain_drop.cjs @@ -1,4 +1,4 @@ -const domain = require('./046_domain_create_rename'); +const domain = require('./046_domain_create_rename.cjs'); exports.up = (pgm) => { pgm.dropTable('td'); diff --git a/test/migrations/053_sequence_drop.cjs b/test/migrations/053_sequence_drop.cjs index 3e0769b6..8a33cddb 100644 --- a/test/migrations/053_sequence_drop.cjs +++ b/test/migrations/053_sequence_drop.cjs @@ -1,4 +1,4 @@ -const sequence = require('./049_sequence_create_rename'); +const sequence = require('./049_sequence_create_rename.cjs'); exports.up = (pgm) => { pgm.dropTable('ts'); diff --git a/test/migrations/056_operator_drop.cjs b/test/migrations/056_operator_drop.cjs index 270953a3..f830edaf 100644 --- a/test/migrations/056_operator_drop.cjs +++ b/test/migrations/056_operator_drop.cjs @@ -1,4 +1,4 @@ -const operator = require('./054_operator_create'); +const operator = require('./054_operator_create.cjs'); exports.up = (pgm) => { pgm.dropOperator('+', { left: 'complex', right: 'complex' }); diff --git a/test/migrations/059_policy_drop.cjs b/test/migrations/059_policy_drop.cjs index 31a1d956..ceefde2e 100644 --- a/test/migrations/059_policy_drop.cjs +++ b/test/migrations/059_policy_drop.cjs @@ -1,4 +1,4 @@ -const policy = require('./057_policy_create'); +const policy = require('./057_policy_create.cjs'); exports.up = policy.down; diff --git a/test/migrations/061_column_comment_test.cjs b/test/migrations/061_column_comment_test.cjs index 575ccb78..18cd95b5 100644 --- a/test/migrations/061_column_comment_test.cjs +++ b/test/migrations/061_column_comment_test.cjs @@ -1,7 +1,7 @@ const { comment, table: { schema, name }, -} = require('./060_column_comment'); +} = require('./060_column_comment.cjs'); exports.up = async (pgm) => { const [{ description }] = await pgm.db.select( diff --git a/test/migrations/073_alter_column_comment_test.cjs b/test/migrations/073_alter_column_comment_test.cjs index fe679bde..53289aa9 100644 --- a/test/migrations/073_alter_column_comment_test.cjs +++ b/test/migrations/073_alter_column_comment_test.cjs @@ -1,7 +1,7 @@ const { table: { schema, name }, comment, -} = require('./072_alter_column_comment'); +} = require('./072_alter_column_comment.cjs'); exports.up = async (pgm) => { const [{ description }] = await pgm.db.select( diff --git a/test/migrations/086_grant_test.cjs b/test/migrations/086_grant_test.cjs index 8fd9f276..31db39b9 100644 --- a/test/migrations/086_grant_test.cjs +++ b/test/migrations/086_grant_test.cjs @@ -1,6 +1,6 @@ const { constants: { schema, table, role1, role2, tablePrivileges, schemaPrivilege }, -} = require('./085_grant_tables_schemas_roles'); +} = require('./085_grant_tables_schemas_roles.cjs'); const hasTablePrivileges = async (pgm, role, tableName, privileges) => { const rows = await pgm.db.select(` diff --git a/test/migrations/087_revoke_tables_schemas_roles.cjs b/test/migrations/087_revoke_tables_schemas_roles.cjs index 21a86c75..cf48e1ad 100644 --- a/test/migrations/087_revoke_tables_schemas_roles.cjs +++ b/test/migrations/087_revoke_tables_schemas_roles.cjs @@ -1,6 +1,6 @@ const { constants: { schema, table, role1, role2, tablePrivileges, schemaPrivilege }, -} = require('./085_grant_tables_schemas_roles'); +} = require('./085_grant_tables_schemas_roles.cjs'); exports.up = (pgm) => { pgm.revokeRoles(role1, role2); diff --git a/test/migrations/088_revoke_test.cjs b/test/migrations/088_revoke_test.cjs index 3474540d..2428eafd 100644 --- a/test/migrations/088_revoke_test.cjs +++ b/test/migrations/088_revoke_test.cjs @@ -1,10 +1,10 @@ const { constants: { schema, table, role1, role2, tablePrivileges, schemaPrivilege }, -} = require('./085_grant_tables_schemas_roles'); +} = require('./085_grant_tables_schemas_roles.cjs'); const { utils: { hasTablePrivileges, hasSchemaPrivilege, isMemberOf }, -} = require('./086_grant_test'); +} = require('./086_grant_test.cjs'); exports.up = async (pgm) => { const hasGrantedTablePrivileges = await hasTablePrivileges( From 6a789fd52078264d9d0b0ba76b7b9d7ad70105a8 Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Mon, 26 Aug 2024 23:21:08 +0200 Subject: [PATCH 6/8] chore: run ts-node is esm context --- .github/workflows/postgres-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/postgres-test.yml b/.github/workflows/postgres-test.yml index d634f0de..92cd7b0b 100644 --- a/.github/workflows/postgres-test.yml +++ b/.github/workflows/postgres-test.yml @@ -722,7 +722,7 @@ jobs: run: pnpm run build - name: Integration Test - run: pnpm ts-node test/ts/customRunnerDBUrl.ts + run: pnpm ts-node-esm test/ts/customRunnerDBUrl.ts env: DATABASE_URL: postgres://ubuntu:ubuntu@localhost:5432/integration_test @@ -773,7 +773,7 @@ jobs: run: pnpm run build - name: Integration Test - run: pnpm ts-node test/ts/customRunnerDBClient.ts + run: pnpm ts-node-esm test/ts/customRunnerDBClient.ts env: DATABASE_URL: postgres://ubuntu:ubuntu@localhost:5432/integration_test @@ -824,6 +824,6 @@ jobs: run: pnpm run build - name: Integration Test - run: pnpm ts-node test/ts/customRunnerUndefCount.ts + run: pnpm ts-node-esm test/ts/customRunnerUndefCount.ts env: DATABASE_URL: postgres://ubuntu:ubuntu@localhost:5432/integration_test From 09e8ae54bdbe90e174ec6371e1aff983058b2b40 Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Mon, 26 Aug 2024 23:25:06 +0200 Subject: [PATCH 7/8] chore: try tsx --- .github/workflows/postgres-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/postgres-test.yml b/.github/workflows/postgres-test.yml index 92cd7b0b..c8b67aaf 100644 --- a/.github/workflows/postgres-test.yml +++ b/.github/workflows/postgres-test.yml @@ -722,7 +722,7 @@ jobs: run: pnpm run build - name: Integration Test - run: pnpm ts-node-esm test/ts/customRunnerDBUrl.ts + run: pnpm tsx test/ts/customRunnerDBUrl.ts env: DATABASE_URL: postgres://ubuntu:ubuntu@localhost:5432/integration_test @@ -773,7 +773,7 @@ jobs: run: pnpm run build - name: Integration Test - run: pnpm ts-node-esm test/ts/customRunnerDBClient.ts + run: pnpm tsx test/ts/customRunnerDBClient.ts env: DATABASE_URL: postgres://ubuntu:ubuntu@localhost:5432/integration_test @@ -824,6 +824,6 @@ jobs: run: pnpm run build - name: Integration Test - run: pnpm ts-node-esm test/ts/customRunnerUndefCount.ts + run: pnpm tsx test/ts/customRunnerUndefCount.ts env: DATABASE_URL: postgres://ubuntu:ubuntu@localhost:5432/integration_test From 540b387cfe91986b35cb784bd887ffb142a0764c Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Mon, 26 Aug 2024 23:28:14 +0200 Subject: [PATCH 8/8] chore: alternative __dirname --- test/ts/customRunner.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/ts/customRunner.ts b/test/ts/customRunner.ts index 71005ec5..60b6035f 100644 --- a/test/ts/customRunner.ts +++ b/test/ts/customRunner.ts @@ -1,4 +1,5 @@ -import { resolve } from 'node:path'; +import { dirname, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; import type { Client } from 'pg'; import type { RunnerOption } from '../../dist'; import { runner } from '../../dist'; @@ -13,6 +14,8 @@ type Options = | ({ databaseUrl: string } & TestOptions) | ({ dbClient: Client } & TestOptions); +const __dirname = dirname(fileURLToPath(import.meta.url)); + export const run = async (options: Options): Promise => { const opts: Omit & Options = { migrationsTable: 'migrations',