Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

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

5 changes: 0 additions & 5 deletions tools/generate-function-bindings/.gitignore

This file was deleted.

14 changes: 0 additions & 14 deletions tools/generate-function-bindings/.npmignore

This file was deleted.

7 changes: 0 additions & 7 deletions tools/generate-function-bindings/ambient.d.ts

This file was deleted.

18 changes: 0 additions & 18 deletions tools/generate-function-bindings/jest.config.js

This file was deleted.

16 changes: 3 additions & 13 deletions tools/generate-function-bindings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,9 @@
"private": "true",
"description": "Tool to generate CDK Terrain function bindings",
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"watch-preserve-output": "tsc -w --preserveWatchOutput",
"pretest": "pnpm run build",
"pretest:ci": "pnpm run build",
"test": "jest",
"test:ci": "jest --ci",
"jest-watch": "jest --watch",
"package": "./package.sh",
"dist-clean": "rm -rf dist",
"fetch-metadata": "ts-node scripts/fetch-metadata.ts",
"generate": "ts-node scripts/generate.ts"
},
"main": "src/index.js",
"types": "src/index.d.ts",
"repository": {
"type": "git",
"url": "git://github.com/open-constructs/cdk-terrain.git",
Expand All @@ -37,11 +25,13 @@
"@babel/generator": "^7.20.4",
"@babel/template": "^7.18.10",
"@babel/types": "^7.20.2",
"@types/babel__generator": "^7.27.0",
"@types/babel__template": "^7.4.4",
"@types/node": "20.17.51",
"ts-node": "^10.9.1",
"typescript": "^5.0.0"
},
"lint-staged": {
"src/**/*.ts": "tsc-files ambient.d.ts --noEmit"
"scripts/**/*.ts": "tsc-files --noEmit"
}
}
9 changes: 0 additions & 9 deletions tools/generate-function-bindings/package.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function fetchMetadata() {

const fixed = fixProductRelativeLinks(json);

await fs.writeFile(out, prettier.format(fixed, { parser: "json" }));
await fs.writeFile(out, await prettier.format(fixed, { parser: "json" }));
}

/**
Expand Down
12 changes: 6 additions & 6 deletions tools/generate-function-bindings/scripts/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const FUNCTION_BINDINGS_OUTPUT_FILE = path.resolve(
"..",
"packages",
"cdktn",
"lib",
"src",
"functions",
"terraform-functions.generated.ts",
);
Expand All @@ -35,7 +35,7 @@ const FUNCTIONS_MAP_OUTPUT_FILE = path.resolve(
"packages",
"@cdktn",
"hcl2cdk",
"lib",
"src",
"function-bindings",
"functions.generated.ts",
);
Expand Down Expand Up @@ -110,13 +110,13 @@ async function generateFunctionBindings() {

const program = t.program([IMPORTS, fnClass]);

const code = prettier.format(
const code = await prettier.format(
// adding comments unrelated to code doesn't work with an AST
`// Copyright (c) HashiCorp, Inc
// SPDX-License-Identifier: MPL-2.0
${generate(program as any).code}`,
{
parser: "babel",
parser: "babel-ts",
},
);

Expand Down Expand Up @@ -165,7 +165,7 @@ async function generateFunctionsMap() {

const program = t.program([fnMap]);

const code = prettier.format(
const code = await prettier.format(
// adding comments unrelated to code doesn't work with an AST
`// Copyright (c) HashiCorp, Inc
// SPDX-License-Identifier: MPL-2.0
Expand All @@ -174,7 +174,7 @@ async function generateFunctionsMap() {
// To update this file execute 'pnpm generate-function-bindings' in the root of the repository
${generate(program as any).code}`,
{
parser: "babel",
parser: "babel-ts",
},
);

Expand Down
8 changes: 2 additions & 6 deletions tools/generate-function-bindings/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,12 @@
"incremental": false,
"esModuleInterop": true
},
"files": [
"ambient.d.ts"
],
"include": [
"src/**/*.ts"
"scripts/**/*.ts"
],
"exclude": [
"node_modules",
"../../node_modules/**",
"**/*.d.ts",
"**/*.test.tsx"
"**/*.d.ts"
],
}
Loading