Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export all operation nodes, forever. #972

Merged
merged 3 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"scripts": {
"clean": "rm -rf dist & rm -rf test/node/dist & rm -rf test/browser/bundle.js & rm -rf helpers",
"test": "npm run build && npm run test:node:build && npm run test:node:run && npm run test:typings && npm run test:esmimports",
"test": "npm run build && npm run test:node:build && npm run test:node:run && npm run test:typings && npm run test:esmimports && npm run test:exports",
"test:node:build": "tsc -p test/node",
"test:node": "npm run build && npm run test:node:build && npm run test:node:run",
"test:node:run": "mocha --timeout 15000 test/node/dist/**/*.test.js",
Expand All @@ -52,6 +52,7 @@
"test:typings": "tsd test/typings",
"test:esmimports": "node scripts/check-esm-imports.js",
"test:esbuild": "esbuild --bundle --platform=node --external:pg-native dist/esm/index.js --outfile=/dev/null",
"test:exports": "node scripts/check-exports.js",
"prettier": "prettier --write 'src/**/*.ts' 'test/**/*.ts'",
"build": "npm run clean && (npm run build:esm & npm run build:cjs) && npm run script:module-fixup && npm run script:copy-interface-doc",
"build:esm": "tsc -p tsconfig.json && npm run script:add-deno-type-references",
Expand Down
40 changes: 40 additions & 0 deletions scripts/check-exports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* This script ensures all files in a path are exported in the index.ts file.
* For now it only checks the operation-node folder, as we've had issues with
* missing exports there.
*/

const fs = require('node:fs')
const path = require('node:path')
const forEachFile = require('./util/for-each-file')

let errorsFound = false

function checkExports(dir) {
const indexFileContents = fs.readFileSync(
path.join(__dirname, '..', 'src/index.ts'),
'utf-8',
)

forEachFile(dir, (filePath) => {
if (filePath.endsWith('.ts')) {
const expectedExportPath = filePath.replace(
/^.+\/src\/(.+)\.ts$/,
"'./$1.js'",
)

if (!indexFileContents.includes(expectedExportPath)) {
console.log(`Missing export: ${expectedExportPath}`)
errorsFound = true
}
}
})
}

checkExports(path.join(__dirname, '..', 'src/operation-node'))

if (errorsFound) {
console.log(' ')
console.log('check-exports.js failed!')
process.exit(1)
}
49 changes: 27 additions & 22 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,29 @@ export * from './plugin/parse-json-results/parse-json-results-plugin.js'

export * from './operation-node/add-column-node.js'
export * from './operation-node/add-constraint-node.js'
export * from './operation-node/add-index-node.js'
export * from './operation-node/aggregate-function-node.js'
export * from './operation-node/alias-node.js'
export * from './operation-node/alter-column-node.js'
export * from './operation-node/alter-table-node.js'
export * from './operation-node/and-node.js'
export * from './operation-node/binary-operation-node.js'
export * from './operation-node/case-node.js'
export * from './operation-node/cast-node.js'
export * from './operation-node/check-constraint-node.js'
export * from './operation-node/column-definition-node.js'
export * from './operation-node/column-node.js'
export * from './operation-node/column-update-node.js'
export * from './operation-node/common-table-expression-node.js'
export * from './operation-node/common-table-expression-name-node.js'
export * from './operation-node/common-table-expression-node.js'
export * from './operation-node/constraint-node.js'
export * from './operation-node/create-index-node.js'
export * from './operation-node/create-schema-node.js'
export * from './operation-node/create-table-node.js'
export * from './operation-node/create-type-node.js'
export * from './operation-node/create-view-node.js'
export * from './operation-node/data-type-node.js'
export * from './operation-node/default-insert-value-node.js'
export * from './operation-node/default-value-node.js'
export * from './operation-node/delete-query-node.js'
export * from './operation-node/drop-column-node.js'
Expand All @@ -139,17 +144,26 @@ export * from './operation-node/drop-schema-node.js'
export * from './operation-node/drop-table-node.js'
export * from './operation-node/drop-type-node.js'
export * from './operation-node/drop-view-node.js'
export * from './operation-node/explain-node.js'
export * from './operation-node/fetch-node.js'
export * from './operation-node/foreign-key-constraint-node.js'
export * from './operation-node/from-node.js'
export * from './operation-node/function-node.js'
export * from './operation-node/generated-node.js'
export * from './operation-node/group-by-item-node.js'
export * from './operation-node/group-by-node.js'
export * from './operation-node/having-node.js'
export * from './operation-node/identifier-node.js'
export * from './operation-node/insert-query-node.js'
export * from './operation-node/join-node.js'
export * from './operation-node/json-operator-chain-node.js'
export * from './operation-node/json-path-leg-node.js'
export * from './operation-node/json-path-node.js'
export * from './operation-node/json-reference-node.js'
export * from './operation-node/limit-node.js'
export * from './operation-node/list-node.js'
export * from './operation-node/matched-node.js'
export * from './operation-node/merge-query-node.js'
export * from './operation-node/modify-column-node.js'
export * from './operation-node/offset-node.js'
export * from './operation-node/on-conflict-node.js'
Expand All @@ -163,7 +177,11 @@ export * from './operation-node/operator-node.js'
export * from './operation-node/or-node.js'
export * from './operation-node/order-by-item-node.js'
export * from './operation-node/order-by-node.js'
export * from './operation-node/output-node.js'
export * from './operation-node/over-node.js'
export * from './operation-node/parens-node.js'
export * from './operation-node/partition-by-item-node.js'
export * from './operation-node/partition-by-node.js'
export * from './operation-node/primary-constraint-node.js'
export * from './operation-node/primitive-value-list-node.js'
export * from './operation-node/query-node.js'
Expand All @@ -172,39 +190,26 @@ export * from './operation-node/reference-node.js'
export * from './operation-node/references-node.js'
export * from './operation-node/rename-column-node.js'
export * from './operation-node/returning-node.js'
export * from './operation-node/schemable-identifier-node.js'
export * from './operation-node/select-all-node.js'
export * from './operation-node/select-query-node.js'
export * from './operation-node/select-modifier-node.js'
export * from './operation-node/select-query-node.js'
export * from './operation-node/selection-node.js'
export * from './operation-node/set-operation-node.js'
export * from './operation-node/simple-reference-expression-node.js'
export * from './operation-node/table-node.js'
export * from './operation-node/top-node.js'
export * from './operation-node/tuple-node.js'
export * from './operation-node/unary-operation-node.js'
export * from './operation-node/unique-constraint-node.js'
export * from './operation-node/update-query-node.js'
export * from './operation-node/using-node.js'
export * from './operation-node/value-list-node.js'
export * from './operation-node/value-node.js'
export * from './operation-node/values-node.js'
export * from './operation-node/when-node.js'
export * from './operation-node/where-node.js'
export * from './operation-node/with-node.js'
export * from './operation-node/explain-node.js'
export * from './operation-node/default-insert-value-node.js'
export * from './operation-node/aggregate-function-node.js'
export * from './operation-node/over-node.js'
export * from './operation-node/partition-by-node.js'
export * from './operation-node/partition-by-item-node.js'
export * from './operation-node/set-operation-node.js'
export * from './operation-node/binary-operation-node.js'
export * from './operation-node/unary-operation-node.js'
export * from './operation-node/using-node.js'
export * from './operation-node/json-reference-node.js'
export * from './operation-node/json-path-leg-node.js'
export * from './operation-node/json-path-node.js'
export * from './operation-node/json-operator-chain-node.js'
export * from './operation-node/tuple-node.js'
export * from './operation-node/merge-query-node.js'
export * from './operation-node/matched-node.js'
export * from './operation-node/fetch-node.js'
export * from './operation-node/top-node.js'
export * from './operation-node/output-node.js'

export * from './util/column-type.js'
export * from './util/compilable.js'
Expand Down