sunpeak 0.5.18 → 0.5.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,186 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Local testing script for Sunpeak project.
5
- */
6
-
7
- import { execSync, spawn } from 'child_process';
8
- import { existsSync, readdirSync } from 'fs';
9
- import { fileURLToPath } from 'url';
10
- import { dirname, join } from 'path';
11
- import http from 'http';
12
-
13
- // Color codes for output
14
- const colors = {
15
- red: '\x1b[0;31m',
16
- green: '\x1b[0;32m',
17
- blue: '\x1b[0;34m',
18
- yellow: '\x1b[1;33m',
19
- reset: '\x1b[0m',
20
- };
21
-
22
- // Get project root
23
- const __filename = fileURLToPath(import.meta.url);
24
- const __dirname = dirname(__filename);
25
- const PROJECT_ROOT = join(__dirname, '..');
26
-
27
- function printSuccess(text) {
28
- console.log(`${colors.green}✓ ${text}${colors.reset}`);
29
- }
30
-
31
- function printError(text) {
32
- console.log(`${colors.red}✗ ${text}${colors.reset}`);
33
- }
34
-
35
- function runCommand(command, cwd) {
36
- try {
37
- execSync(command, {
38
- cwd,
39
- stdio: 'inherit',
40
- env: { ...process.env, FORCE_COLOR: '1' },
41
- });
42
- return true;
43
- } catch (error) {
44
- return false;
45
- }
46
- }
47
-
48
- function waitForServer(port, timeout = 10000) {
49
- return new Promise((resolve, reject) => {
50
- const startTime = Date.now();
51
- const checkServer = () => {
52
- const req = http.get(`http://localhost:${port}`, () => {
53
- resolve();
54
- });
55
- req.on('error', () => {
56
- if (Date.now() - startTime > timeout) {
57
- reject(new Error(`Server did not start within ${timeout}ms`));
58
- } else {
59
- setTimeout(checkServer, 500);
60
- }
61
- });
62
- req.end();
63
- };
64
- checkServer();
65
- });
66
- }
67
-
68
- // Main testing flow
69
- console.log(`${colors.yellow}Starting local testing for Sunpeak project...${colors.reset}`);
70
- console.log(`Project root: ${PROJECT_ROOT}\n`);
71
-
72
- try {
73
- console.log('Running: pnpm install');
74
- if (!runCommand('pnpm install', PROJECT_ROOT)) {
75
- throw new Error('pnpm install failed');
76
- }
77
- console.log()
78
- printSuccess('pnpm install');
79
-
80
- console.log('\nRunning: pnpm format');
81
- if (!runCommand('pnpm format', PROJECT_ROOT)) {
82
- throw new Error('pnpm format failed');
83
- }
84
- printSuccess('pnpm format');
85
-
86
- console.log('\nRunning: pnpm lint');
87
- if (!runCommand('pnpm lint', PROJECT_ROOT)) {
88
- throw new Error('pnpm lint failed');
89
- }
90
- printSuccess('pnpm lint');
91
-
92
- console.log('\nRunning: pnpm typecheck');
93
- if (!runCommand('pnpm typecheck', PROJECT_ROOT)) {
94
- throw new Error('pnpm typecheck failed');
95
- }
96
- printSuccess('pnpm typecheck');
97
-
98
- console.log('\nRunning: pnpm test');
99
- if (!runCommand('pnpm test', PROJECT_ROOT)) {
100
- throw new Error('pnpm test failed');
101
- }
102
- printSuccess('pnpm test');
103
-
104
- console.log('\nRunning: pnpm build');
105
- if (!runCommand('pnpm build', PROJECT_ROOT)) {
106
- throw new Error('pnpm build failed');
107
- }
108
- const chatgptDir = join(PROJECT_ROOT, 'dist', 'chatgpt');
109
- const expectedFiles = ['counter.js', 'albums.js', 'carousel.js'];
110
-
111
- // Check all expected files exist
112
- for (const file of expectedFiles) {
113
- const filePath = join(chatgptDir, file);
114
- if (!existsSync(filePath)) {
115
- printError(`Missing expected file: ./dist/chatgpt/${file}`);
116
- process.exit(1);
117
- }
118
- }
119
-
120
- // Verify only expected files are present
121
- const files = readdirSync(chatgptDir);
122
- const unexpectedFiles = files.filter(f => !expectedFiles.includes(f));
123
- if (unexpectedFiles.length > 0) {
124
- printError(`Unexpected files in ./dist/chatgpt/: ${unexpectedFiles.join(', ')}`);
125
- printError(`Expected only: ${expectedFiles.join(', ')}`);
126
- process.exit(1);
127
- }
128
-
129
- console.log()
130
- printSuccess('pnpm build');
131
-
132
- // MCP Server Check
133
- console.log('\nRunning: pnpm mcp:serve');
134
- const mcpProcess = spawn('pnpm', ['mcp:serve'], {
135
- cwd: PROJECT_ROOT,
136
- stdio: ['ignore', 'pipe', 'pipe'],
137
- env: { ...process.env, FORCE_COLOR: '1' },
138
- });
139
-
140
- const mcpErrors = [];
141
-
142
- mcpProcess.stderr.on('data', (data) => {
143
- const message = data.toString();
144
- if (message.includes('error') || message.includes('Error')) {
145
- mcpErrors.push(message.trim());
146
- }
147
- });
148
-
149
- // Store process for cleanup
150
- process.on('exit', () => {
151
- if (mcpProcess && !mcpProcess.killed) {
152
- mcpProcess.kill();
153
- }
154
- });
155
-
156
- try {
157
- console.log('\nWaiting for MCP server to start on port 6766...');
158
- await waitForServer(6766, 10000);
159
-
160
- // Give it a moment to ensure no immediate errors
161
- await new Promise(resolve => setTimeout(resolve, 1000));
162
-
163
- if (mcpErrors.length > 0) {
164
- printError('MCP server started but reported errors:');
165
- mcpErrors.forEach(err => console.log(` ${err}`));
166
- throw new Error('MCP server has errors');
167
- }
168
-
169
- } catch (error) {
170
- printError(`MCP server failed to start: ${error.message}`);
171
- throw error;
172
- } finally {
173
- console.log('Stopping MCP server...');
174
- mcpProcess.kill();
175
- // Give it a moment to shut down
176
- await new Promise(resolve => setTimeout(resolve, 1000));
177
- }
178
- console.log()
179
- printSuccess('pnpm mcp\n');
180
-
181
- printSuccess('All systems GO!\n\n');
182
- process.exit(0);
183
- } catch (error) {
184
- console.error(`\n${colors.red}Error: ${error.message}${colors.reset}\n`);
185
- process.exit(1);
186
- }