Skip to content

Commit

Permalink
🚧 Preinstall solc to avoid parallel execution errors [Alternative fix] (
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista authored Jan 22, 2024
1 parent f855e5d commit 8597ba3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/strong-moles-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-lz-oapp": patch
---

Remove unwanted files from cloned examples
9 changes: 9 additions & 0 deletions examples/oft/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": ["//"],
"pipeline": {
"compile": {
"dependsOn": ["@layerzerolabs/oapp-example#compile"],
"description": "We include this dependency to make sure that the compilation is executed in series to avoid race conditions with solc compilers in foundry"
}
}
}
28 changes: 27 additions & 1 deletion packages/create-lz-oapp/src/utilities/cloning.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Config, Example } from '@/types'
import { rm } from 'fs/promises'
import { resolve } from 'path'
import tiged from 'tiged'

/**
Expand Down Expand Up @@ -27,7 +28,11 @@ export const cloneExample = async ({ example, destination }: Config) => {
})

try {
return await emitter.clone(destination)
// First we clone the whole proejct
await emitter.clone(destination)

// Then we cleanup what we don't want to be included
await cleanupExample(destination)
} catch (error: unknown) {
try {
// Let's make sure to clean up after us
Expand Down Expand Up @@ -63,6 +68,27 @@ export const cloneExample = async ({ example, destination }: Config) => {
}
}

// List of files to be removed after the cloning is done
const IGNORED_FILES = ['CHANGELOG.md', 'turbo.json']

/**
* Helper utility that removes the files we don't want to include in the final project
* after the cloning is done
*
* @param {string} destination The directory containing the cloned project
*/
const cleanupExample = async (destination: string) => {
for (const fileName of IGNORED_FILES) {
const filePath = resolve(destination, fileName)

try {
await rm(filePath, { force: true })
} catch {
// If the cleanup fails let's just do nothing for now
}
}
}

export class CloningError extends Error {
constructor(message: string = 'Unknown error during example cloning') {
super(message)
Expand Down

0 comments on commit 8597ba3

Please sign in to comment.