-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify-setup.js
More file actions
191 lines (166 loc) · 6.9 KB
/
verify-setup.js
File metadata and controls
191 lines (166 loc) · 6.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/usr/bin/env node
/**
* BoldChrome Setup Verification Script
*
* This script verifies that your development environment is properly configured
* for building and testing the BoldChrome Chrome extension.
*/
const fs = require('fs');
const path = require('path');
const colors = {
reset: '\x1b[0m',
green: '\x1b[32m',
red: '\x1b[31m',
yellow: '\x1b[33m',
blue: '\x1b[34m',
cyan: '\x1b[36m'
};
function log(message, color = 'reset') {
console.log(`${colors[color]}${message}${colors.reset}`);
}
function checkFile(filePath, description) {
const exists = fs.existsSync(filePath);
const status = exists ? '✓' : '✗';
const color = exists ? 'green' : 'red';
log(` ${status} ${description}`, color);
return exists;
}
function checkEnvVariable(key) {
const value = process.env[key];
const exists = !!value;
const status = exists ? '✓' : '✗';
const color = exists ? 'green' : 'yellow';
const displayValue = exists ? value.substring(0, 20) + '...' : 'NOT SET';
log(` ${status} ${key} = ${displayValue}`, color);
return exists;
}
log('\n╔══════════════════════════════════════════════════════════════╗', 'cyan');
log('║ BoldChrome Setup Verification Script ║', 'cyan');
log('╚══════════════════════════════════════════════════════════════╝\n', 'cyan');
let allChecks = true;
// Check 1: File Structure
log('1. File Structure', 'blue');
allChecks &= checkFile('package.json', 'package.json exists');
allChecks &= checkFile('svelte.config.js', 'svelte.config.js exists');
allChecks &= checkFile('vite.config.ts', 'vite.config.ts exists');
allChecks &= checkFile('tsconfig.json', 'tsconfig.json exists');
allChecks &= checkFile('.env.local', '.env.local exists (for development)');
allChecks &= checkFile('.env.example', '.env.example exists (template)');
allChecks &= checkFile('static/manifest.json', 'Chrome manifest.json exists');
log('');
// Check 2: Source Code Structure
log('2. Source Code Structure', 'blue');
allChecks &= checkFile('src/routes/popup/+page.svelte', 'Popup UI component');
allChecks &= checkFile('src/routes/popup/page.ts', 'Popup logic file');
allChecks &= checkFile('src/lib/stores/index.ts', 'Svelte stores');
log('');
// Check 3: Dependencies
log('3. Dependencies', 'blue');
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const requiredDeps = [
'sveltekit-adapter-chrome-extension'
];
const requiredDevDeps = [
'@sveltejs/kit',
'@sveltejs/vite-plugin-svelte',
'svelte',
'typescript',
'vite'
];
let depsOk = true;
for (const dep of requiredDeps) {
const exists = packageJson.dependencies && packageJson.dependencies[dep];
const status = exists ? '✓' : '✗';
const color = exists ? 'green' : 'red';
log(` ${status} ${dep}`, color);
depsOk &= !!exists;
}
for (const dep of requiredDevDeps) {
const exists = packageJson.devDependencies && packageJson.devDependencies[dep];
const status = exists ? '✓' : '✗';
const color = exists ? 'green' : 'red';
log(` ${status} ${dep} (dev)`, color);
depsOk &= !!exists;
}
allChecks &= depsOk;
log('');
// Check 4: Environment Variables
log('4. Environment Configuration', 'blue');
const envExists = fs.existsSync('.env.local');
if (envExists) {
const envContent = fs.readFileSync('.env.local', 'utf8');
const hasKeyLine = envContent.includes('PUBLIC_GOOGLE_API_KEY=');
const apiKeySet = hasKeyLine && envContent.split('\n').some(line => line.startsWith('PUBLIC_GOOGLE_API_KEY=') && line.split('=')[1]?.trim());
const status = apiKeySet ? '✓' : (hasKeyLine ? '⚠' : '✗');
const color = apiKeySet ? 'green' : (hasKeyLine ? 'yellow' : 'red');
log(` ${status} .env.local is configured`, color);
if (!apiKeySet) {
log(` ⚠ PUBLIC_GOOGLE_API_KEY is not set or empty. Get one from https://ai.google.dev`, 'yellow');
allChecks = false;
}
} else {
log(' ✗ .env.local not found', 'red');
log(' Run: cp .env.example .env.local', 'yellow');
allChecks = false;
}
log('');
// Check 5: package manager
log('5. Package Manager', 'blue');
const hasNpm = fs.existsSync('package-lock.json');
const hasPnpm = fs.existsSync('pnpm-lock.yaml');
const hasYarn = fs.existsSync('yarn.lock');
if (hasNpm) {
log(' ✓ npm detected', 'green');
} else if (hasPnpm) {
log(' ✓ pnpm detected', 'green');
} else if (hasYarn) {
log(' ✓ yarn detected', 'green');
} else {
log(' ✗ No package manager lock file found', 'red');
log(' Run: npm install', 'yellow');
allChecks = false;
}
const nodeModulesExists = fs.existsSync('node_modules');
if (nodeModulesExists) {
log(' ✓ node_modules installed', 'green');
} else {
log(' ✗ node_modules not found', 'red');
log(' Run: npm install', 'yellow');
allChecks = false;
}
log('');
// Check 6: Build Directory
log('6. Build Output', 'blue');
const buildExists = fs.existsSync('build');
if (buildExists) {
log(' ✓ /build directory exists', 'green');
const manifestExists = fs.existsSync('build/manifest.json');
if (manifestExists) {
log(' ✓ manifest.json in /build', 'green');
} else {
log(' ⚠ manifest.json not found in /build', 'yellow');
log(' Run: npm run build', 'yellow');
}
} else {
log(' ⚠ /build directory not created yet', 'yellow');
log(' Run: npm run build', 'yellow');
}
log('');
// Summary
log('╔══════════════════════════════════════════════════════════════╗', 'cyan');
if (allChecks) {
log('║ ✓ All checks passed! Ready to develop. ║', 'green');
log('║ ║', 'cyan');
log('║ Next steps: ║', 'cyan');
log('║ 1. Run: npm run build ║', 'cyan');
log('║ 2. Go to chrome://extensions ║', 'cyan');
log('║ 3. Enable "Developer mode" ║', 'cyan');
log('║ 4. Click "Load unpacked" and select /build ║', 'cyan');
log('║ 5. Click the extension icon to open the wallet popup ║', 'cyan');
} else {
log('║ ✗ Some checks failed. See issues above. ║', 'red');
log('║ ║', 'cyan');
log('║ Fix the issues above and run this script again. ║', 'cyan');
}
log('╚══════════════════════════════════════════════════════════════╝\n', 'cyan');
process.exit(allChecks ? 0 : 1);