Skip to content

Commit f7563e0

Browse files
committed
feat: remove additional features
For now, we don't want to make the additional features option available, as the current only additional feature (canister env) is still being worked on.
1 parent 2c777f6 commit f7563e0

File tree

7 files changed

+0
-127
lines changed

7 files changed

+0
-127
lines changed

docs/src/content/docs/structure.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,3 @@ const greeting = await actor.greet('World');
3838
### `<service-name>.d.ts`
3939

4040
This file contains the same TypeScript types as [`<service-name>.ts`](#service-namets). It is typically used to add to LLMs' contexts' to give knowledge about what types are available in the service. Set the [`output.actor.interfaceFile`](./core/api/type-aliases/GenerateOutputOptions.md#interfaceFile) option to `true` to generate this file.
41-
42-
### `canister-env.d.ts`
43-
44-
This file contains the strongly-typed canister environment variables. It is typically used make the `@icp-sdk/canister-env` package more type-safe. configure the [`additionalFeatures.canisterEnv`](./core/api/type-aliases/GenerateAdditionalFeaturesOptions.md#canisterEnv) option to generate this file.
45-
46-
> Not supported by the CLI yet.

src/cli/icp-bindgen.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
* - `--actor-disabled`: If set, skips generating the actor file (`<service-name>.ts`). (default: `false`)
4444
* - `--force`: If set, overwrite existing files instead of aborting. (default: `false`)
4545
*
46-
* > **Note**: The CLI does not support additional features yet.
47-
*
4846
* @module cli
4947
*/
5048

src/core/generate/features/canister-env.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/core/generate/features/index.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/core/generate/index.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import { basename, resolve } from 'node:path';
22
import { prepareBinding } from './bindings.ts';
3-
import {
4-
type GenerateAdditionalFeaturesOptions,
5-
generateAdditionalFeatures,
6-
} from './features/index.ts';
73
import { ensureDir, writeFileSafe } from './fs.ts';
84
import { type WasmGenerateResult, wasmGenerate, wasmInit } from './rs.ts';
95

10-
export type { GenerateAdditionalFeaturesOptions } from './features/index.ts';
11-
126
const DID_FILE_EXTENSION = '.did';
137

148
/**
@@ -63,10 +57,6 @@ export type GenerateOptions = {
6357
* Options for controlling the generated output files.
6458
*/
6559
output?: GenerateOutputOptions;
66-
/**
67-
* Additional features to generate bindings with.
68-
*/
69-
additionalFeatures?: GenerateAdditionalFeaturesOptions;
7060
};
7161

7262
/**
@@ -118,10 +108,6 @@ export async function generate(options: GenerateOptions) {
118108
output,
119109
force,
120110
});
121-
122-
if (options.additionalFeatures) {
123-
await generateAdditionalFeatures(options.additionalFeatures, options.outDir, force);
124-
}
125111
}
126112

127113
type WriteBindingsOptions = {

src/plugins/vite.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ async function run(options: Options) {
125125
// We want to overwrite existing files in the build process
126126
force: true,
127127
},
128-
additionalFeatures: options.additionalFeatures,
129128
});
130129

131130
console.log(cyan(`[${VITE_PLUGIN_NAME}] Bindings generated at`), green(options.outDir));

tests/generate.test.ts

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -134,26 +134,6 @@ describe('generate', () => {
134134
expect(fileExists(otherDidFilePath)).toBe(true);
135135
});
136136

137-
it('should generate a bindgen with canister env feature', async () => {
138-
const helloWorldServiceName = 'hello_world';
139-
const helloWorldDidFile = `${TESTS_ASSETS_DIR}/${helloWorldServiceName}.did`;
140-
141-
await generate({
142-
didFile: helloWorldDidFile,
143-
outDir: OUTPUT_DIR,
144-
additionalFeatures: {
145-
canisterEnv: {
146-
variableNames: ['IC_CANISTER_ID:backend'],
147-
},
148-
},
149-
});
150-
151-
await expectGeneratedOutput(SNAPSHOTS_DIR, helloWorldServiceName);
152-
await expect(await readFileFromOutput('canister-env.d.ts')).toMatchFileSnapshot(
153-
`${SNAPSHOTS_DIR}/${helloWorldServiceName}/canister-env.d.ts.snapshot`,
154-
);
155-
});
156-
157137
it('should abort on existing files unless output.force is true', async () => {
158138
const serviceName = 'hello_world';
159139
const didFile = `${TESTS_ASSETS_DIR}/${serviceName}.did`;
@@ -185,43 +165,6 @@ describe('generate', () => {
185165
}),
186166
).resolves.toBeUndefined();
187167
});
188-
189-
it('should abort feature file write on collision unless output.force is true', async () => {
190-
const serviceName = 'example';
191-
const didFile = `${TESTS_ASSETS_DIR}/${serviceName}.did`;
192-
193-
// Pre-create canister-env to trigger collision in additional features
194-
vol.mkdirSync(OUTPUT_DIR, { recursive: true });
195-
vol.writeFileSync(`${OUTPUT_DIR}/canister-env.d.ts`, '// existing', { encoding: 'utf-8' });
196-
197-
await expect(
198-
generate({
199-
didFile,
200-
outDir: OUTPUT_DIR,
201-
additionalFeatures: {
202-
canisterEnv: {
203-
variableNames: ['IC_CANISTER_ID:backend'],
204-
},
205-
},
206-
}),
207-
).rejects.toThrow(
208-
/The generated file already exists: .*canister-env\.d\.ts. To overwrite it, use the `force` option./i,
209-
);
210-
211-
// With force, it should overwrite and succeed
212-
await expect(
213-
generate({
214-
didFile,
215-
outDir: OUTPUT_DIR,
216-
output: { force: true },
217-
additionalFeatures: {
218-
canisterEnv: {
219-
variableNames: ['IC_CANISTER_ID:backend'],
220-
},
221-
},
222-
}),
223-
).resolves.toBeUndefined();
224-
});
225168
});
226169

227170
async function readFileFromOutput(path: string): Promise<string> {

0 commit comments

Comments
 (0)