Skip to content

Commit

Permalink
Chore: Update Dependencies and Improve Compatibility for Build Process (
Browse files Browse the repository at this point in the history
#593)

* chore(deps): Updated chokidar file watching

Upgrading to version 4 of chokidar changed some the function signatures.
Code has been updated to use new signature and configuration. No
functional difference should be noticed.

* chore(deps): drop support for version 16 node

* chore(deps): Use esm import for Piscina

Also need to enable resolving json modules as Piscina does this in their
latest versions.

* chore(prettier): ignore runtime lib folder

* chore(compose): use new docker compose syntax

See https://github.blog/changelog/2024-04-10-github-hosted-runner-images-deprecation-notice-docker-compose-v1/
for the reasoning behind this update.

---------

Co-authored-by: Adel Salakh <[email protected]>
  • Loading branch information
amerryma and adelsz authored Jan 25, 2025
1 parent 6fd02d7 commit 01fbaf0
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['16', '18']
node-version: ['18', '20']
name: Test (node ${{ matrix.node-version }}.x)
steps:
- uses: actions/checkout@v4
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
packages/example
packages/query/src/loader/*/parser/
packages/query/src/loader/*/parser/
packages/runtime/lib/
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ The `packages/example` project is an end-to-end test suite for pgTyped. It conta
The packages `npm test` runs the following command:

```bash
docker-compose run build && docker-compose run test && docker-compose run test-cjs
docker compose run build && docker compose run test && docker compose run test-cjs
```

As you can see it runs the `build` target, then runs the `test` target twice, once with the `esm` module format and once with the `cjs` module format:
Expand Down
7 changes: 5 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@
},
"dependencies": {
"io-ts": "^2.1.2"
},
"engines": {
"node": ">=18"
}
}
4 changes: 2 additions & 2 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AsyncQueue } from '@pgtyped/wire';
import chokidar from 'chokidar';
import nun from 'nunjucks';

import PiscinaPool from 'piscina';
import { Piscina as PiscinaPool } from 'piscina';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { parseConfig, ParsedConfig, TransformConfig } from './config.js';
Expand Down Expand Up @@ -150,7 +150,7 @@ if (isWatchMode && fileOverride) {
}

try {
chokidar.watch(configPath).on('change', () => {
chokidar.watch(configPath, {}).on('change', () => {
console.log('Config file changed. Exiting.');
process.exit();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/typedSqlTagTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class TypedSqlTagTransformer {
chokidar
.watch(this.includePattern, {
persistent: true,
ignored: [this.localFileName],
ignored: this.localFileName,
})
.on('add', cb)
.on('change', cb)
Expand Down
2 changes: 1 addition & 1 deletion packages/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Try starting PgTyped and editing them to see live query type generation.
2. `cd pgtyped/packages/example`
3. `npm install`
4. `npm run build`
5. `docker-compose run watch`
5. `docker compose run watch`
6. Try editing queries in the SQL and TS files and see how PgTyped handles it.

The dockerized setup isn't required and is included for convenience.
Expand Down
2 changes: 1 addition & 1 deletion packages/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"node": ">=14.16"
},
"scripts": {
"test": "docker-compose run build && docker-compose run test && docker-compose run test-cjs",
"test": "docker compose run build && docker compose run test && docker compose run test-cjs",
"typegen": "pgtyped -c config.json",
"build": "echo 'No build step required. Use npm test instead'",
"watch": "echo 'No build step required. Use npm test instead'",
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */

/* Source Map Options */
Expand All @@ -56,5 +56,6 @@
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
"resolveJsonModule": true /* Include modules imported with '.json' extension */,
}
}

0 comments on commit 01fbaf0

Please sign in to comment.