-
Notifications
You must be signed in to change notification settings - Fork 7
Add bootstrap scripts
#120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,8 +51,9 @@ const ALLOW_LIST = [ | |
| ]; | ||
|
|
||
| console.log("Copying files to", EXAMPLES_DIR); | ||
|
|
||
| // Clean up the destination directory before copying | ||
| fs.rmSync(EXAMPLES_DIR, { recursive: true, force: true }); | ||
| // fs.rmSync(EXAMPLES_DIR, { recursive: true, force: true }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did you mean to leave this commented out line in?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah. I might regret that, but for now it seems most appropriate. It does mean that someone disabling an example above would have to manually delete the dir, but the benefit is that we're not nuking the build directories. |
||
|
|
||
| const require = createRequire(import.meta.url); | ||
|
|
||
|
|
@@ -67,17 +68,28 @@ let counter = 0; | |
| for (const src of ALLOW_LIST) { | ||
| const srcPath = path.join(SRC_DIR, src); | ||
| const destPath = path.join(EXAMPLES_DIR, src); | ||
|
|
||
| const uniquePackageName = `example-${counter++}`; | ||
|
|
||
| if (fs.existsSync(destPath)) { | ||
| console.warn( | ||
| `Destination path ${destPath} already exists - skipping copy of ${src}.` | ||
| ); | ||
| continue; | ||
| } | ||
|
|
||
| console.log("Copying from", srcPath, "to", destPath); | ||
| fs.cpSync(srcPath, destPath, { recursive: true }); | ||
| // Delete all package.json files recursively, as they have duplicate names, causing collisions when hashing | ||
| // Update package names in package.json files recursively, | ||
| // as they have duplicate names, causing collisions when vendored into the host package. | ||
| for (const entry of fs.readdirSync(destPath, { | ||
| withFileTypes: true, | ||
| recursive: true, | ||
| })) { | ||
| if (entry.name === "package.json") { | ||
| const packageJson = readPackageSync({ cwd: entry.parentPath }); | ||
| // Ensure example package names are unique | ||
| packageJson.name = `example-${counter++}`; | ||
| packageJson.name = uniquePackageName; | ||
| fs.writeFileSync( | ||
| path.join(entry.parentPath, entry.name), | ||
| JSON.stringify(packageJson, null, 2), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add
npm run bootstrapin the multi-platform CI?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, once #118 merge I believe.
I will do that in a follow-up PR.