-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove forked files from solhint to prevent errors
- Loading branch information
Alex Connolly
committed
Dec 11, 2023
1 parent
f306aa2
commit 800a2cc
Showing
5 changed files
with
55 additions
and
54 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 |
---|---|---|
|
@@ -4,4 +4,4 @@ cache | |
coverage | ||
typechain | ||
dist | ||
forks | ||
forks |
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ artifacts | |
cache | ||
coverage* | ||
gasReporterOutput.json | ||
|
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
node_modules | ||
contracts/passport | ||
contracts/seaport | ||
forks |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,50 @@ | ||
|
||
import fs from 'fs'; | ||
import replace from 'replace-in-file'; | ||
import forks from '../forks/forks.json'; | ||
import main from '../package.json'; | ||
|
||
forks.forEach(fork => { | ||
const dest = `contracts/${fork.name}`; | ||
fs.rmSync(dest, { recursive: true, force: true }); | ||
fs.cpSync(`forks/${fork.contracts}`, dest, { | ||
recursive: true, | ||
filter: (src: string, dest: string) => { | ||
const matches = fork.ignore.filter(ig => src.includes(`forks/${fork.contracts}/${ig}`)); | ||
// only include if there are no matches | ||
return matches.length == 0; | ||
} | ||
}); | ||
|
||
const rmTemplate = `DO NOT MODIFY THESE CONTRACTS DIRECTLY. This folder has been automatically extracted from ${fork.upstream} via a submodule in this repository's forks directory. See the upstream repository for full context.` | ||
|
||
fs.writeFileSync(`${dest}/README.md`, rmTemplate); | ||
|
||
if (fork.dependencies) { | ||
const pkg = JSON.parse(fs.readFileSync(`forks/${fork.name}/package.json`)); | ||
fork.dependencies.forEach(dep => { | ||
const depVersion = pkg.dependencies[dep] ? pkg.dependencies[dep] : pkg.devDependencies[dep]; | ||
|
||
const mainDepVersion = (main.dependencies as any)[dep]; | ||
// What happens if the version clashes! | ||
if (mainDepVersion && depVersion != mainDepVersion) { | ||
// Create a custom name e.g. @openzeppelin/contracts/seaport | ||
const customDepName = `${dep}/${fork.name}`; | ||
(main.dependencies as any)[customDepName] = `npm:${dep}@${depVersion}`; | ||
// Now replace all of the references to the dependency | ||
// inside the fork's copied contracts folder | ||
// e.g. '@openzeppelin/contracts/x/y.sol --> @openzeppelin/contracts/seaport/x/y.sol | ||
replace.sync({ | ||
from: dep, | ||
to: customDepName, | ||
files: [`${dest}/**/*.sol`] | ||
}); | ||
} else { | ||
// No clash in the dependencies, just add it | ||
(main.dependencies as any)[dep] = depVersion; | ||
} | ||
import fs from "fs"; | ||
import replace from "replace-in-file"; | ||
import forks from "../forks/forks.json"; | ||
import main from "../package.json"; | ||
|
||
forks.forEach((fork) => { | ||
const dest = `contracts/${fork.name}`; | ||
fs.rmSync(dest, { recursive: true, force: true }); | ||
fs.cpSync(`forks/${fork.contracts}`, dest, { | ||
recursive: true, | ||
filter: (src: string, dest: string) => { | ||
const matches = fork.ignore.filter((ig) => src.includes(`forks/${fork.contracts}/${ig}`)); | ||
// only include if there are no matches | ||
return matches.length === 0; | ||
}, | ||
}); | ||
|
||
const rmTemplate = `DO NOT MODIFY THESE CONTRACTS DIRECTLY. This folder has been automatically extracted from ${fork.upstream} via a submodule in this repository's forks directory. See the upstream repository for full context.`; | ||
|
||
fs.writeFileSync(`${dest}/README.md`, rmTemplate); | ||
|
||
if (fork.dependencies) { | ||
const pkg = JSON.parse(fs.readFileSync(`forks/${fork.name}/package.json`)); | ||
fork.dependencies.forEach((dep) => { | ||
const depVersion = pkg.dependencies[dep] ? pkg.dependencies[dep] : pkg.devDependencies[dep]; | ||
|
||
const mainDepVersion = (main.dependencies as any)[dep]; | ||
// What happens if the version clashes! | ||
if (mainDepVersion && depVersion !== mainDepVersion) { | ||
// Create a custom name e.g. @openzeppelin/contracts/seaport | ||
const customDepName = `${dep}/${fork.name}`; | ||
(main.dependencies as any)[customDepName] = `npm:${dep}@${depVersion}`; | ||
// Now replace all of the references to the dependency | ||
// inside the fork's copied contracts folder | ||
// e.g. '@openzeppelin/contracts/x/y.sol --> @openzeppelin/contracts/seaport/x/y.sol | ||
replace.sync({ | ||
from: dep, | ||
to: customDepName, | ||
files: [`${dest}/**/*.sol`], | ||
}); | ||
|
||
} | ||
} else { | ||
// No clash in the dependencies, just add it | ||
(main.dependencies as any)[dep] = depVersion; | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
// Update our main package.json | ||
fs.writeFileSync('package.json', JSON.stringify(main, null, 2), 'utf8'); | ||
|
||
fs.writeFileSync("package.json", JSON.stringify(main, null, 2), "utf8"); |