-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: script to update imports into the docs package
- Loading branch information
Showing
6 changed files
with
69 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* We have to generate the connector list into actual files because webpack / next.js is extremely not performant | ||
* when importing modules with dynamic paths at runtime | ||
*/ | ||
|
||
import * as fs from 'node:fs' | ||
import {join as pathJoin} from 'node:path' | ||
import prettier from 'prettier' | ||
|
||
const sdkList = fs | ||
.readdirSync(pathJoin(__dirname, '../sdks'), { | ||
withFileTypes: true, | ||
}) | ||
.filter((r) => r.isDirectory()) | ||
.map((d) => { | ||
const path = pathJoin(__dirname, '../sdks', d.name) | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
const pkgJson: {name: string} = JSON.parse( | ||
fs.readFileSync(pathJoin(path, 'package.json'), 'utf-8'), | ||
) | ||
return pkgJson.name | ||
}) | ||
|
||
async function updateDocImports() { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
const pkgJson: {dependencies: {}} = require('../docs/package.json') | ||
pkgJson.dependencies = { | ||
...pkgJson.dependencies, | ||
...Object.fromEntries(sdkList.map((s) => [s, 'workspace:*'])), | ||
} | ||
fs.writeFileSync( | ||
pathJoin(__dirname, '../docs/package.json'), | ||
await prettier.format(JSON.stringify(pkgJson), { | ||
...(require('../prettier.config') as {}), | ||
parser: 'json', | ||
}), | ||
) | ||
} | ||
|
||
// console.log(sdkList) | ||
void updateDocImports() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters