Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions templates/echo-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
},
"scripts": {
"start": "tsx src/index.ts",
"dev": "tsx src/index.ts",
"build": "tsc",
"dev": "tsx --env-file=.env.local src/index.ts",
"build": "node scripts/build.js",
"clean": "rm -rf dist",
"typecheck": "tsc --noEmit"
},
Expand All @@ -36,6 +36,7 @@
"cli-table3": "^0.6.5",
"commander": "^14.0.2",
"conf": "^15.0.2",
"dotenv": "^16.4.7",
"ink": "^6.4.0",
"keytar": "^7.9.0",
"open": "^10.2.0",
Expand Down
45 changes: 45 additions & 0 deletions templates/echo-cli/scripts/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { execSync } from 'child_process';
import dotenv from 'dotenv';
import { readFileSync, writeFileSync } from 'fs';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const rootDir = join(__dirname, '..');

// Load environment variables from .env.local
dotenv.config({ path: join(rootDir, '.env.local') });

const ECHO_APP_ID = process.env.ECHO_APP_ID;

if (!ECHO_APP_ID) {
console.error('Error: ECHO_APP_ID not found in .env.local');
process.exit(1);
}

const constantsPath = join(rootDir, 'src', 'constants.ts');

// Read the original file
const originalContent = readFileSync(constantsPath, 'utf8');

// Replace process.env.ECHO_APP_ID with the actual value
const modifiedContent = originalContent.replace(
/export const ECHO_APP_ID = process\.env\.ECHO_APP_ID!;/,
`export const ECHO_APP_ID = '${ECHO_APP_ID}';`
);

try {
// Write modified content
writeFileSync(constantsPath, modifiedContent, 'utf8');
console.log('Building with ECHO_APP_ID:', ECHO_APP_ID);

// Run TypeScript compiler
execSync('tsc', { stdio: 'inherit', cwd: rootDir });

console.log('Build completed successfully!');
} finally {
// Always restore the original file
writeFileSync(constantsPath, originalContent, 'utf8');
console.log('Restored original constants.ts');
}
4 changes: 2 additions & 2 deletions templates/echo-cli/src/core/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async function showEchoProfile(): Promise<void> {
label('Email:', chalk.white(user.email))
label('Balance:', chalk.green(`$${balance.balance.toFixed(4)}`))
label('Total Spent:', chalk.yellow(`$${balance.totalSpent.toFixed(4)}`))
label('Created:', chalk.white(new Date(user.createdAt).toLocaleDateString()))
label('Created:', chalk.white(new Date(user.createdAt as string).toLocaleDateString()))
blankLine()
} catch (err) {
displayAppError(createError({
Expand Down Expand Up @@ -89,7 +89,7 @@ async function showLocalWalletProfile(): Promise<void> {
}

try {
const balance = await getUSDCBalance(session.address, session.chainId)
const balance = await getUSDCBalance(session.address as `0x${string}`, session.chainId)

blankLine()
header('=== Local Wallet Profile ===')
Expand Down