Skip to content

Commit 785ad32

Browse files
committed
fix: windows smoke test
1 parent cebd96a commit 785ad32

File tree

2 files changed

+48
-24
lines changed

2 files changed

+48
-24
lines changed

extensions/cli/build.mjs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ try {
4545
// Handle .js extensions in imports
4646
resolveExtensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
4747

48-
// Preserve important Node.js globals
49-
define: {
50-
"process.env.NODE_ENV": '"production"',
51-
},
52-
5348
// Handle TypeScript paths and local packages
5449
alias: {
5550
"@continuedev/config-yaml": resolve(

extensions/cli/smoke-test.mjs

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,19 @@ runTest("Wrapper script has shebang", () => {
6060
}
6161
});
6262

63+
// Cross-platform command execution helper
64+
function getCLICommand(args = "") {
65+
const isWindows = process.platform === "win32";
66+
if (isWindows) {
67+
return `node dist/cn.js ${args}`;
68+
} else {
69+
return `./dist/cn.js ${args}`;
70+
}
71+
}
72+
6373
// Test 3: Version command works
6474
runTest("Version command", () => {
65-
const output = execCommand("./dist/cn.js --version");
75+
const output = execCommand(getCLICommand("--version"));
6676
const packageJson = JSON.parse(
6777
readFileSync(resolve(__dirname, "package.json"), "utf8"),
6878
);
@@ -75,31 +85,48 @@ runTest("Version command", () => {
7585

7686
// Test 4: Help command works
7787
runTest("Help command", () => {
78-
const output = execCommand("./dist/cn.js --help");
88+
const output = execCommand(getCLICommand("--help"));
7989
if (!output.includes("Continue CLI") || !output.includes("--version")) {
8090
throw new Error("Help output missing expected content");
8191
}
8292
});
8393

8494
// Test 5: Check bundle size
8595
runTest("Bundle size is reasonable", () => {
86-
const stats = execSync(`ls -lh dist/index.js`, { encoding: "utf8" });
87-
const sizeMatch = stats.match(/(\d+(?:\.\d+)?[MK])/);
88-
if (sizeMatch) {
89-
const size = sizeMatch[1];
90-
console.log(`(${size})`);
91-
92-
// Parse size to check it's not too large
93-
const numSize = parseFloat(size);
94-
const unit = size.slice(-1);
95-
const sizeInMB = unit === "M" ? numSize : numSize / 1024;
96-
97-
// This is arbitrary. We might go over at some point,
98-
// in which case you can just increase this.
99-
if (sizeInMB > 20) {
100-
throw new Error(`Bundle too large: ${size}`);
96+
const isWindows = process.platform === "win32";
97+
const command = isWindows
98+
? `powershell -Command "(Get-Item dist/index.js).length / 1MB"`
99+
: `ls -lh dist/index.js`;
100+
101+
let sizeInMB;
102+
103+
if (isWindows) {
104+
try {
105+
const output = execCommand(command);
106+
sizeInMB = parseFloat(output.trim());
107+
} catch {
108+
// Fallback for Windows if PowerShell fails
109+
const stats = readFileSync(resolve(__dirname, "dist/index.js"));
110+
sizeInMB = stats.length / (1024 * 1024);
111+
}
112+
} else {
113+
const stats = execCommand(command);
114+
const sizeMatch = stats.match(/(\d+(?:\.\d+)?[MK])/);
115+
if (sizeMatch) {
116+
const size = sizeMatch[1];
117+
const numSize = parseFloat(size);
118+
const unit = size.slice(-1);
119+
sizeInMB = unit === "M" ? numSize : numSize / 1024;
101120
}
102121
}
122+
123+
console.log(`(${sizeInMB.toFixed(1)}M)`);
124+
125+
// This is arbitrary. We might go over at some point,
126+
// in which case you can just increase this.
127+
if (sizeInMB > 20) {
128+
throw new Error(`Bundle too large: ${sizeInMB.toFixed(1)}M`);
129+
}
103130
});
104131

105132
// Test 6: Check that local packages are bundled
@@ -135,7 +162,9 @@ runTest("Local packages are bundled", () => {
135162
runTest("CLI can be invoked", () => {
136163
try {
137164
// Test that the CLI runs without crashing when given no args
138-
execCommand("./dist/cn.js --help > /dev/null 2>&1");
165+
const isWindows = process.platform === "win32";
166+
const nullDevice = isWindows ? "nul" : "/dev/null";
167+
execCommand(`${getCLICommand("--help")} > ${nullDevice} 2>&1`);
139168
} catch (error) {
140169
throw new Error(`CLI invocation failed: ${error.message}`);
141170
}
@@ -158,7 +187,7 @@ runTest("Build metadata exists", () => {
158187
// Test 9: Verify no missing external dependencies
159188
runTest("No missing runtime dependencies", () => {
160189
// This would fail in Test 3 if dependencies were missing, but let's be explicit
161-
const output = execCommand("./dist/cn.js --version 2>&1", {
190+
const output = execCommand(`${getCLICommand("--version")} 2>&1`, {
162191
env: { ...process.env, NODE_ENV: "production" },
163192
});
164193

0 commit comments

Comments
 (0)