You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/cli/icp-bindgen.ts
+48Lines changed: 48 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,53 @@
1
1
#!/usr/bin/env node
2
2
3
+
/**
4
+
* The CLI is used to generate bindings for a `.did` file.
5
+
*
6
+
* ## Installation
7
+
*
8
+
* As a dev dependency for your project:
9
+
*
10
+
* ```bash
11
+
* npm install -D @icp-sdk/bindgen
12
+
* ```
13
+
*
14
+
* Or as a global command:
15
+
*
16
+
* ```bash
17
+
* npm install -g @icp-sdk/bindgen
18
+
* ```
19
+
*
20
+
* ## Usage
21
+
*
22
+
* Suppose you have a `./canisters/hello_world.did` file, and you want to output the generated bindings for your Vite app in the `src/bindings/` folder.
23
+
*
24
+
* You can generate the bindings with the following command:
* - `--did-file <path>`: Path to the `.did` file to generate bindings from
41
+
* - `--out-dir <dir>`: Directory where the bindings will be written
42
+
* - `--actor-interface-file`: If set, generates a `<service-name>.d.ts` file that contains the same types of the `<service-name>.ts` file. Has no effect if `--actor-disabled` is set. (default: `false`)
43
+
* - `--actor-disabled`: If set, skips generating the actor file (`<service-name>.ts`). (default: `false`)
44
+
* - `--force`: If set, overwrite existing files instead of aborting. (default: `false`)
45
+
*
46
+
* > **Note**: The CLI does not support additional features yet.
Copy file name to clipboardExpand all lines: src/plugins/vite.ts
+36Lines changed: 36 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,37 @@
1
+
/**
2
+
* The Vite plugin is used to generate bindings for a `.did` file during the build process.
3
+
*
4
+
* ## Installation
5
+
*
6
+
* ```bash
7
+
* npm install -D @icp-sdk/bindgen
8
+
* ```
9
+
*
10
+
* ## Usage
11
+
*
12
+
* Suppose you have a `./canisters/hello_world.did` file, and you want to output the generated bindings for your Vite app in the `src/bindings/` folder.
13
+
* Here's how the plugin configuration would look like:
14
+
*
15
+
* ```ts title="vite.config.ts"
16
+
* import { defineConfig } from "vite";
17
+
* import { icpBindgen } from '@icp-sdk/bindgen/plugins/vite';
18
+
*
19
+
* export default defineConfig({
20
+
* plugins: [
21
+
* // ... other plugins
22
+
* icpBindgen({
23
+
* didFile: './canisters/hello_world.did',
24
+
* outDir: './src/bindings',
25
+
* }),
26
+
* ],
27
+
* });
28
+
* ```
29
+
*
30
+
* For an explanation of the generated files, see the [Bindings Structure](https://js.icp.build/bindgen/latest/structure/) page.
0 commit comments