|
| 1 | +# How to Contribute to the SDK |
| 2 | + |
| 3 | +## Local Environment Setup |
| 4 | + |
| 5 | +### Global Dependencies |
| 6 | + |
| 7 | +Clone the repo (ideally your own fork of it) and initialize the global |
| 8 | +dependencies like Node.js, NPM, etc. We use [`asdf`](https://asdf-vm.com/) to |
| 9 | +manage these, so assuming we're located in this directory (i.e. `packages/sdk/`) |
| 10 | +we can run the following command to install them: |
| 11 | + |
| 12 | +```shell |
| 13 | +asdf install |
| 14 | +``` |
| 15 | + |
| 16 | +If you prefer to use another tool make sure you use the same versions that are |
| 17 | +specified in the `.tool-versions` files [in this current directory, and |
| 18 | +recursively going up until you reach the root of the |
| 19 | +repo](https://asdf-vm.com/guide/getting-started.html#_6-set-a-version). |
| 20 | + |
| 21 | +### Local Dependencies |
| 22 | + |
| 23 | +You can install the package's dependencies by using `pnpm` or `npm`: |
| 24 | + |
| 25 | +```shell |
| 26 | +pnpm install |
| 27 | +``` |
| 28 | + |
| 29 | +Since other packages in this repository already use `pnpm`, we recommend you use |
| 30 | +it in this case too to keep your `node_modules` footprint low. |
| 31 | + |
| 32 | +## Build the Package |
| 33 | + |
| 34 | +There's a script that you can invoke with `pnpm` to build the package artifacts: |
| 35 | + |
| 36 | +```shell |
| 37 | +pnpm build |
| 38 | +``` |
| 39 | + |
| 40 | +You can also watch the code for changes, and automatically build a new artifact |
| 41 | +after each change with the `watch` script: |
| 42 | + |
| 43 | +```shell |
| 44 | +pnpm watch |
| 45 | +``` |
| 46 | + |
| 47 | +### Use the Package |
| 48 | + |
| 49 | +You can use pnpm's `link` command to point other code to your local version of |
| 50 | +this package during development. This lets you test the SDK in other local apps, |
| 51 | +end-to-end. |
| 52 | + |
| 53 | +In this `packages/sdk/` directory: |
| 54 | + |
| 55 | +```shell |
| 56 | +pnpm link --global |
| 57 | +``` |
| 58 | + |
| 59 | +> [!NOTE] |
| 60 | +When using the version of Node.js specified in |
| 61 | +[`.tool-versions`](./.tool-versions) (via `asdf`), the command above will |
| 62 | +install the package in the `asdf` Node.js environment. To use this package |
| 63 | +elsewhere, you'll need to use the same version of Node.js. Please reference the |
| 64 | +latest version of [the `.tool-versions` file](./.tool-versions) and add that to |
| 65 | +the `.tool-versions` file in your local project where you'd like to use the SDK. |
| 66 | + |
| 67 | +For example, in your app's directory: |
| 68 | + |
| 69 | +```shell |
| 70 | +# Replace /path/to/pipedream with the actual path to this repository |
| 71 | +grep nodejs /path/to/pipedream/packages/sdk/.tool-versions >> .tool-versions |
| 72 | +asdf install |
| 73 | +pnpm install @pipedream/sdk |
| 74 | +``` |
| 75 | + |
| 76 | +Then, link the SDK package to it's local path: |
| 77 | + |
| 78 | +```shell |
| 79 | +pnpm link @pipedream/sdk |
| 80 | +``` |
| 81 | + |
| 82 | +To confirm you successfully installed the correct version of the SDK, and that |
| 83 | +it's tied to your local copy of the Pipedream SDK: |
| 84 | + |
| 85 | +```shell |
| 86 | +ls -l node_modules/@pipedream |
| 87 | +``` |
| 88 | + |
| 89 | +You should see an output like this one (notice the last line): |
| 90 | + |
| 91 | +```text |
| 92 | +total 0 |
| 93 | +drwxr-xr-x 9 jay staff 288 30 Oct 14:01 mysql |
| 94 | +drwxr-xr-x 10 jay staff 320 30 Oct 14:01 platform |
| 95 | +lrwxr-xr-x 1 jay staff 31 30 Oct 14:06 sdk -> ../../../pipedream/packages/sdk |
| 96 | +``` |
0 commit comments