Skip to content

Commit

Permalink
Fix chainId replacement bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ytham committed May 13, 2024
1 parent a2764e9 commit a5ccbf1
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion axiom-init/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "axiom-init",
"description": "Initialize a new Axiom project",
"version": "0.1.6",
"version": "0.1.7",
"author": "Intrinsic Technologies",
"scripts": {
"build": "rm -rf dist && node ./script/preBuild.js && tsc",
Expand Down
4 changes: 2 additions & 2 deletions axiom-init/src/projectScaffold/forge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const scaffoldForge = async (
sm.setPath(sm.basePath);

// Clone the axiom-quickstart template
console.log("Fetching Axiom quickstart template...");
console.log("\nFetching Axiom quickstart template...");
const tempDir = `.axiom-temp-${Date.now()}`;
await sm.execWithStream(`git clone --depth 1 https://github.com/axiom-crypto/axiom-quickstart.git ${tempDir}`, [], "Clone Axiom quickstart template");
sm.cp(`${tempDir}/.`, ".", ` - Copy files to ${chalk.bold(sm.basePath)}`);
Expand Down Expand Up @@ -98,7 +98,7 @@ export const scaffoldForge = async (
sm.findAndReplaceAll("Update chain data");

// Install package dependencies
console.log("Installing package dependencies...");
console.log("\nInstalling package dependencies...");
await sm.execWithStream(sm.manager, [sm.installCmd], `Install package dependencies`);

// Clean up cloned repo
Expand Down
4 changes: 2 additions & 2 deletions axiom-init/src/projectScaffold/nextjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const scaffoldNext = async (
}

// Clone the Next.js scaffold
console.log("Fetching Axiom Next.js scaffold...");
console.log("\nFetching Axiom Next.js scaffold...");
const tempDir = `.axiom-temp-nextjs-${Date.now()}`;
await sm.execWithStream(`git clone --depth 1 https://github.com/axiom-crypto/axiom-scaffold-nextjs.git ${tempDir}`, [], "Clone Axiom Next.js scaffold");
sm.cp(`${tempDir}/.`, appPath, ` - Copy Next.js scaffold files to ${chalk.bold(appPath)}`);
Expand All @@ -97,7 +97,7 @@ export const scaffoldNext = async (
sm.findAndReplaceAll("Update chain data");

// Install package dependencies
console.log("Installing Next.js scaffold dependencies...");
console.log("\nInstalling Next.js scaffold dependencies...");
await sm.execWithStream(sm.manager, [sm.installCmd], `Install Next.js scaffold dependencies`);

// Add Next.js files to git
Expand Down
1 change: 1 addition & 0 deletions axiom-init/src/projectScaffold/projectScaffoldManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export class ProjectScaffoldManager {
findAndReplaceAll(description: string) {
// Update chain ID
findAndReplaceRecursive(this.fullPath, 'CHAIN_ID = "11155111"', `CHAIN_ID = "${this.chainId}"`);
findAndReplaceRecursive(this.fullPath, '--sourceChainId 11155111', `--sourceChainId ${this.chainId}`);

// Update provider URI for Foundry
findAndReplaceRecursive(this.fullPath, 'PROVIDER_URI_11155111', `PROVIDER_URI_${this.chainId}`);
Expand Down
4 changes: 2 additions & 2 deletions axiom-init/src/projectScaffold/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const scaffoldScript = async (
sm.setPath(sm.basePath);

// Clone the axiom-quickstart template
console.log("Fetching Axiom quickstart template...");
console.log("\nFetching Axiom quickstart template...");
const tempDir = `.axiom-temp-${Date.now()}`;
await sm.execWithStream(`git clone --depth 1 https://github.com/axiom-crypto/axiom-quickstart.git ${tempDir}`, [], "Clone Axiom quickstart template");
sm.cp(`${tempDir}/.`, ".", ` - Copy files to ${chalk.bold(sm.basePath)}`);
Expand All @@ -94,7 +94,7 @@ export const scaffoldScript = async (
sm.findAndReplaceAll("Update chain data");

// Install package dependencies
console.log("Installing package dependencies...");
console.log("\nInstalling package dependencies...");
await sm.execWithStream(sm.manager, [sm.installCmd], `Install package dependencies`);

// Clean up cloned repo
Expand Down
18 changes: 9 additions & 9 deletions axiom-init/src/projectScaffold/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ export const findAndReplaceRecursive = (folder: string, find: string, replace: s
return;
}

const files = fs.readdirSync(folder);
files.forEach((file) => {
const filePath = path.join(folder, file);
const stat = fs.statSync(filePath);
const items = fs.readdirSync(folder);
items.forEach((item) => {
const itemPath = path.join(folder, item);
const stat = fs.statSync(itemPath);
if (stat.isDirectory()) {
// Skip directories that start with a dot
if (!file.startsWith('.')) {
findAndReplaceRecursive(filePath, find, replace);
// Skip directories that start with a dot except `.github`
if (item === ".github" || !item.startsWith('.')) {
findAndReplaceRecursive(itemPath, find, replace);
}
} else {
let content = fs.readFileSync(filePath, "utf8");
let content = fs.readFileSync(itemPath, "utf8");
content = content.replace(new RegExp(find, "g"), replace);
fs.writeFileSync(filePath, content, "utf8");
fs.writeFileSync(itemPath, content, "utf8");
}
});
}
2 changes: 1 addition & 1 deletion axiom-init/src/version.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This is an autogenerated file. It should match the version number in package.json.
// Do not modify this file directly.

export const CURRENT_VERSION = "0.1.6";
export const CURRENT_VERSION = "0.1.7";

0 comments on commit a5ccbf1

Please sign in to comment.