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
4 changes: 2 additions & 2 deletions templates/cli/bun.lock.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"": {
"name": "{{ language.params.npmPackage|caseDash }}",
"dependencies": {
"@appwrite.io/console": "^15.1.0",
"@appwrite.io/console": "^15.1.1",
"@napi-rs/keyring": "^1.3.0",
"chalk": "4.1.2",
"chokidar": "^3.6.0",
Expand Down Expand Up @@ -52,7 +52,7 @@
"tmp": "^0.2.6",
},
"packages": {
"@appwrite.io/console": ["@appwrite.io/console@15.1.0", "", { "dependencies": { "json-bigint": "1.0.0" } }, "sha512-uQ8can9vDKoP6zxqhp8JzOYma/w40eKuYzZzsI9ATCRHSzRig0WQ6fue8rZEgOuD3eF3S2GbtHZK4drotAT8Ug=="],
"@appwrite.io/console": ["@appwrite.io/console@15.1.1", "", { "dependencies": { "json-bigint": "1.0.0" } }, "sha512-W4t9xNuHoNUYGypcZtgPaHvuS/AFjSdDDleeNQl3cWMiOrS9wasVyIwygAHeQjis9evwPC4WUbfpx8WWYXijDg=="],

"@babel/runtime": ["@babel/runtime@7.29.7", "", {}, "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw=="],

Expand Down
6 changes: 2 additions & 4 deletions templates/cli/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -830,10 +830,8 @@ export function openBrowser(url: string): void {

switch (process.platform) {
case "win32":
command = "cmd";
// "" is start's window-title arg; quoting the URL stops cmd from
// splitting it on `&` (and running the remainder as a command).
args = ["/c", "start", "", `"${url}"`];
command = "rundll32";
args = ["url.dll,FileProtocolHandler", url];
break;
case "darwin":
command = "open";
Expand Down
8 changes: 4 additions & 4 deletions templates/cli/package-lock.json.twig

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion templates/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"windows-arm64": "esbuild cli.ts --bundle --loader:.hbs=text --platform=node --target=node18 --format=esm --external:fsevents --external:terminal-image --outfile=dist/bundle-win-arm64.mjs && pkg dist/bundle-win-arm64.mjs --fallback-to-source -t node18-win-arm64 -o build/appwrite-cli-win-arm64.exe"
},
"dependencies": {
"@appwrite.io/console": "^15.1.0",
"@appwrite.io/console": "^15.1.1",
"@napi-rs/keyring": "^1.3.0",
"chalk": "4.1.2",
"chokidar": "^3.6.0",
Expand Down
2 changes: 1 addition & 1 deletion templates/cli/package.json.twig
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"windows-arm64": "bun build cli.ts --compile --minify --target=bun-windows-arm64 --outfile build/appwrite-cli-win-arm64.exe"
},
"dependencies": {
"@appwrite.io/console": "^15.1.0",
"@appwrite.io/console": "^15.1.1",
"@napi-rs/keyring": "^1.3.0",
"chalk": "4.1.2",
"chokidar": "^3.6.0",
Expand Down
33 changes: 30 additions & 3 deletions tests/e2e/languages/cli/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1146,14 +1146,13 @@ async function runAuthChecks() {
assert.ok(captured, "expected openBrowser to spawn an open command");
const expectedCommand =
process.platform === "win32"
? "cmd"
? "rundll32"
: process.platform === "darwin"
? "open"
: "xdg-open";
assert.equal(captured.command, expectedCommand);
// win32 quotes the URL arg, so match by substring rather than equality.
assert.ok(
captured.args.some((arg) => arg.includes(url)),
captured.args.includes(url),
"expected the verification URL to be passed to the open command",
);

Expand All @@ -1168,6 +1167,34 @@ async function runAuthChecks() {
};
assert.doesNotThrow(() => openBrowser(url));

const originalPlatform = process.platform;
try {
Object.defineProperty(process, "platform", {
value: "win32",
});

const windowsUrl =
"https://cloud.appwrite.io/device?user=a b&next=one|two<three>four^five";
captured = null;
childProcess.spawn = (command, args) => {
captured = { command, args };
return {
on() {},
unref() {},
};
};

openBrowser(windowsUrl);
assert.deepEqual(captured, {
command: "rundll32",
args: ["url.dll,FileProtocolHandler", windowsUrl],
});
} finally {
Object.defineProperty(process, "platform", {
value: originalPlatform,
});
}

const listeners = new Map();
const stdin = process.stdin;
const originalIsTTY = stdin.isTTY;
Expand Down
Loading