From f70cbf79ab768446c9a7a4d913fa9f0de0c004b6 Mon Sep 17 00:00:00 2001 From: shinshin86 Date: Thu, 26 Sep 2024 20:17:27 +0900 Subject: [PATCH 1/3] docs: add local development instructions to readme --- README.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/README.md b/README.md index b913bd4..436f26e 100644 --- a/README.md +++ b/README.md @@ -333,3 +333,58 @@ sql: runtime: node driver: better-sqlite3 # npm package name ``` + +## Development + +If you want to build and test sqlc-gen-typescript locally, follow these steps: + +1. Clone the repository and install dependencies: + ``` + git clone https://github.com/sqlc-dev/sqlc-gen-typescript.git + cd sqlc-gen-typescript + npm install + ``` + +2. Make your desired changes to the codebase. The main source files are located in the `src` directory. + +3. If you've made changes that require updating dependencies, run: + ``` + npm install + ``` + +4. Build the WASM plugin: + ``` + npx tsc --noEmit + npx esbuild --bundle src/app.ts --tree-shaking=true --format=esm --target=es2020 --outfile=out.js + + # Ensure you have Javy installed and available in your PATH + javy compile out.js -o examples/plugin.wasm + ``` + +5. To test your local build, create a test project with a `sqlc.yaml` file containing: + + ```yaml + version: '2' + plugins: + - name: ts + wasm: + url: file:///{path_to_your_local_wasm_file} + sha256: {sha256_of_your_wasm_file} + sql: + - schema: "schema.sql" + queries: "query.sql" + engine: {your_database_engine} + codegen: + - out: db + plugin: ts + options: + runtime: node + driver: {your_database_driver} + ``` + + Replace the placeholders with appropriate values for your setup. + +6. Run sqlc in your test project to generate TypeScript code using your local plugin build: + ``` + sqlc generate + ``` From 0956d0ec471633308780bcc48d45629e2167363b Mon Sep 17 00:00:00 2001 From: shinshin86 Date: Thu, 26 Sep 2024 21:45:00 +0900 Subject: [PATCH 2/3] fix readme --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 436f26e..7ac202f 100644 --- a/README.md +++ b/README.md @@ -352,13 +352,13 @@ If you want to build and test sqlc-gen-typescript locally, follow these steps: npm install ``` -4. Build the WASM plugin: +4. Build the WASM plugin: +Check the `Makefile` for details. ``` - npx tsc --noEmit - npx esbuild --bundle src/app.ts --tree-shaking=true --format=esm --target=es2020 --outfile=out.js + make out.js # Ensure you have Javy installed and available in your PATH - javy compile out.js -o examples/plugin.wasm + make examples/plugin.wasm ``` 5. To test your local build, create a test project with a `sqlc.yaml` file containing: @@ -368,7 +368,7 @@ If you want to build and test sqlc-gen-typescript locally, follow these steps: plugins: - name: ts wasm: - url: file:///{path_to_your_local_wasm_file} + url: file://{path_to_your_local_wasm_file} sha256: {sha256_of_your_wasm_file} sql: - schema: "schema.sql" From f9dccebf76a00199eed03abee3bd7b02742f412f Mon Sep 17 00:00:00 2001 From: shinshin86 Date: Tue, 8 Oct 2024 06:43:13 +0900 Subject: [PATCH 3/3] add a link to the core sqlc development guide --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 7ac202f..5798b73 100644 --- a/README.md +++ b/README.md @@ -388,3 +388,6 @@ Check the `Makefile` for details. ``` sqlc generate ``` + +For more details on sqlc development, refer to the sqlc core development guide. This guide provides additional information on setting up and working with sqlc in general, which may be useful for contributors to this project. +https://docs.sqlc.dev/en/latest/guides/development.html \ No newline at end of file