Skip to content

Commit 5ebd93e

Browse files
committed
linting fixes
1 parent 9d642b6 commit 5ebd93e

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

packages/cli/src/commands/studio.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,12 @@ async function launchStudio(coursePath: string, options: StudioOptions) {
125125
}
126126
} catch (error) {
127127
// Handle catastrophic build errors by falling back to embedded source
128-
console.log(chalk.yellow(`⚠️ Unable to process questions, using embedded studio-ui`));
128+
console.log(
129+
chalk.yellow(
130+
`⚠️ Unable to process questions due to ${error},\n⚠️ Using embedded studio-ui`
131+
)
132+
);
133+
129134
const embeddedPath = path.join(__dirname, '..', 'studio-ui-src');
130135

131136
if (fs.existsSync(embeddedPath)) {

packages/cli/src/utils/ExpressManager.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ export class ExpressManager {
3838
}
3939

4040
const expressAssetsPath = join(__dirname, '..', 'express-assets');
41-
41+
4242
if (!fs.existsSync(expressAssetsPath)) {
4343
throw new Error('Express assets not found. Please rebuild the CLI package.');
4444
}
4545

4646
const expressMainPath = join(expressAssetsPath, 'app.js');
47-
47+
4848
if (!fs.existsSync(expressMainPath)) {
4949
throw new Error('Express main file not found at: ' + expressMainPath);
5050
}
@@ -59,6 +59,7 @@ export class ExpressManager {
5959
const packageJson = require(packageJsonPath);
6060
version = packageJson.version || '0.0.0';
6161
} catch (error) {
62+
console.warn('Could not read package.json for version:', error);
6263
// Fallback version if package.json not found
6364
version = '0.0.0';
6465
}
@@ -73,14 +74,14 @@ export class ExpressManager {
7374
COUCHDB_PASSWORD: this.options.couchdbPassword,
7475
VERSION: version,
7576
NODE_ENV: 'studio',
76-
PROJECT_PATH: this.options.projectPath || process.cwd()
77+
PROJECT_PATH: this.options.projectPath || process.cwd(),
7778
};
7879

7980
return new Promise((resolve, reject) => {
8081
this.process = spawn('node', [expressMainPath], {
8182
env,
8283
stdio: ['pipe', 'pipe', 'pipe'],
83-
cwd: expressAssetsPath
84+
cwd: expressAssetsPath,
8485
});
8586

8687
if (!this.process) {
@@ -128,7 +129,7 @@ export class ExpressManager {
128129
// Timeout if server doesn't start within 10 seconds
129130
setTimeout(() => {
130131
if (!started) {
131-
this.stop();
132+
void this.stop();
132133
reject(new Error('Express server failed to start within timeout'));
133134
}
134135
}, 10000);
@@ -168,42 +169,42 @@ export class ExpressManager {
168169
getConnectionDetails() {
169170
return {
170171
url: `http://localhost:${this.options.port}`,
171-
port: this.options.port
172+
port: this.options.port,
172173
};
173174
}
174175

175176
private async findAvailablePort(startPort: number): Promise<number> {
176177
const net = await import('net');
177-
178+
178179
for (let port = startPort; port < startPort + 100; port++) {
179180
if (await this.isPortAvailable(port, net)) {
180181
return port;
181182
}
182183
}
183-
184+
184185
throw new Error(`No available port found starting from ${startPort}`);
185186
}
186187

187-
private isPortAvailable(port: number, net: any): Promise<boolean> {
188+
private isPortAvailable(port: number, net: typeof import('net')): Promise<boolean> {
188189
return new Promise((resolve) => {
189190
const server = net.createServer();
190-
191+
191192
server.listen(port, '127.0.0.1', () => {
192193
server.close(() => resolve(true));
193194
});
194-
195+
195196
server.on('error', () => resolve(false));
196197
});
197198
}
198199

199200
private extractServerFromUrl(url: string): string {
200201
// Extract hostname:port from URL like "http://localhost:5984"
201-
const match = url.match(/https?:\/\/([^\/]+)/);
202+
const match = url.match(/https?:\/\/([^/]+)/);
202203
return match ? match[1] : 'localhost:5984';
203204
}
204205

205206
private extractProtocolFromUrl(url: string): string {
206207
// Extract protocol from URL like "http://localhost:5984"
207208
return url.startsWith('https') ? 'https' : 'http';
208209
}
209-
}
210+
}

packages/cli/src/utils/NodeFileSystemAdapter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class NodeFileSystemAdapter implements FileSystemAdapter {
5151
return {
5252
isDirectory: () => stats.isDirectory(),
5353
isFile: () => stats.isFile(),
54-
size: stats.size
54+
size: stats.size,
5555
};
5656
} catch (error) {
5757
throw new FileSystemError(
@@ -76,7 +76,7 @@ export class NodeFileSystemAdapter implements FileSystemAdapter {
7676
}
7777
}
7878

79-
async writeJson(filePath: string, data: any, options?: { spaces?: number }): Promise<void> {
79+
async writeJson(filePath: string, data: unknown, options?: { spaces?: number }): Promise<void> {
8080
try {
8181
await fse.writeJson(filePath, data, options);
8282
} catch (error) {
@@ -113,4 +113,4 @@ export class NodeFileSystemAdapter implements FileSystemAdapter {
113113
isAbsolute(filePath: string): boolean {
114114
return path.isAbsolute(filePath);
115115
}
116-
}
116+
}

0 commit comments

Comments
 (0)