Skip to content

Commit

Permalink
Load Wrangler in extension (#7560)
Browse files Browse the repository at this point in the history
* Initial Wrangler loading

* Remove duplicate path

* lockfile

* workspace

* lockfile

* Create thirty-windows-prove.md
  • Loading branch information
penalosa authored Dec 17, 2024
1 parent 9a7bf32 commit 59eef4f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/thirty-windows-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cloudflare-workers-bindings-extension": patch
---

Load Wrangler in extension
3 changes: 2 additions & 1 deletion packages/cloudflare-workers-bindings-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
"eslint": "^8.57.0",
"npm-run-all": "^4.1.5",
"typescript": "^5.4.5",
"vsce": "^2.15.0"
"vsce": "^2.15.0",
"wrangler": "workspace:*"
},
"engines": {
"vscode": "^1.92.0"
Expand Down
15 changes: 15 additions & 0 deletions packages/cloudflare-workers-bindings-extension/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
import * as vscode from "vscode";
import { importWrangler } from "./wrangler";

export async function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand(
"cloudflare-workers-bindings-extension.testCommand",
() =>
vscode.window.showInformationMessage(`Successfully called test command.`)
);

const rootPath =
vscode.workspace.workspaceFolders &&
vscode.workspace.workspaceFolders.length > 0
? vscode.workspace.workspaceFolders[0].uri.fsPath
: undefined;

if (!rootPath) {
return;
}

const wrangler = importWrangler(rootPath);

// Do stuff with Wrangler
}
15 changes: 15 additions & 0 deletions packages/cloudflare-workers-bindings-extension/src/wrangler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as path from "path";

export function importWrangler(
workspaceRoot: string
): typeof import("wrangler") {
const wrangler = path.join(
workspaceRoot,
"node_modules",
"wrangler",
"wrangler-dist",
"cli.js"
);

return require(wrangler);
}
3 changes: 2 additions & 1 deletion packages/cloudflare-workers-bindings-extension/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"sourceMap": true,
"rootDir": "src",
"strict": true,
"noEmit": true /* enable all strict type-checking options */
"noEmit": true /* enable all strict type-checking options */,
"skipLibCheck": true
/* Additional Checks */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

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

0 comments on commit 59eef4f

Please sign in to comment.