Skip to content

Commit b6d3476

Browse files
Make .d.ts files from sdk/types included in the build output (#122)
* Make .d.ts files from sdk/types included in the build output * Restore proper formatting
1 parent 3d5a684 commit b6d3476

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

packages/cre-sdk-examples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@chainlink/cre-sdk-examples",
33
"private": true,
4-
"version": "0.0.6-alpha",
4+
"version": "0.0.7-alpha",
55
"type": "module",
66
"author": "Ernest Nowacki",
77
"license": "BUSL-1.1",

packages/cre-sdk/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@chainlink/cre-sdk",
3-
"version": "0.0.6-alpha",
3+
"version": "0.0.7-alpha",
44
"type": "module",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -10,7 +10,7 @@
1010
"import": "./dist/index.js"
1111
},
1212
"./restricted-apis": {
13-
"types": "./dist/restricted-apis.d.ts"
13+
"types": "./dist/sdk/types/restricted-apis.d.ts"
1414
},
1515
"./pb": {
1616
"types": "./dist/pb.d.ts",
Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
import { glob } from 'fast-glob'
22
import { copyFile, mkdir } from 'fs/promises'
3-
import { dirname, join, relative } from 'path'
3+
import { join } from 'path'
44

55
const buildTypes = async () => {
6-
console.log('🔧 Including restricted-apis type in built files...')
6+
console.log('🔧 Copying type definition files to dist...')
77

88
// Define paths relative to the scripts directory
99
const packageRoot = join(import.meta.dir, '../..')
10-
const sourceFile = join(packageRoot, 'src/sdk/types/restricted-apis.d.ts')
11-
const destFile = join(packageRoot, 'dist/restricted-apis.d.ts')
10+
const sourceDir = join(packageRoot, 'src/sdk/types')
11+
const destDir = join(packageRoot, 'dist/sdk/types')
1212

13-
// Ensure the dist directory exists
14-
await mkdir(dirname(destFile), { recursive: true })
13+
// Ensure the destination directory exists
14+
await mkdir(destDir, { recursive: true })
1515

16-
// Copy the file
17-
await copyFile(sourceFile, destFile)
16+
// Find all .d.ts files in the source directory
17+
const typeFiles = await glob('*.d.ts', {
18+
cwd: sourceDir,
19+
absolute: false,
20+
})
1821

19-
console.log('✅ Included restricted-apis type in the build.')
22+
// Copy each file
23+
for (const file of typeFiles) {
24+
const sourceFile = join(sourceDir, file)
25+
const destFile = join(destDir, file)
26+
await copyFile(sourceFile, destFile)
27+
console.log(` ✓ Copied ${file}`)
28+
}
29+
30+
console.log(`✅ Copied ${typeFiles.length} type definition file(s) to dist/sdk/types`)
2031
}
2132

2233
export const main = buildTypes

0 commit comments

Comments
 (0)