Tweak the fixture test for the pre-installed-wrangler test

This commit is contained in:
Peter Bacon Darwin 2024-05-02 17:46:10 +01:00
parent 2523489ae1
commit 06f5e60089
7 changed files with 66 additions and 1279 deletions

View file

@ -169,6 +169,4 @@ jobs:
uses: ./ uses: ./
with: with:
workingDirectory: "./test/pre-installed-wrangler" workingDirectory: "./test/pre-installed-wrangler"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} command: action-test
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: deploy --dry-run

View file

@ -93,34 +93,39 @@ async function installWrangler() {
["wrangler", "--version"], ["wrangler", "--version"],
{ {
cwd: config["workingDirectory"], cwd: config["workingDirectory"],
silent: true, silent: config.QUIET_MODE,
}, },
); );
const versionMatch = stdout.match(/wrangler (\d+\.\d+\.\d+)/); // There are two possible outputs from `wrangler --version`:
if (!versionMatch) { // ` ⛅️ wrangler 3.48.0 (update available 3.53.1)`
throw new Error( // and
`Unable to parse Wrangler version from the output: ${stdout}`, // `3.48.0`
); const versionMatch =
stdout.match(/wrangler (\d+\.\d+\.\d+)/) ??
stdout.match(/^(\d+\.\d+\.\d+)/);
if (versionMatch) {
installedVersion = versionMatch[1];
} }
installedVersion = versionMatch[1]; if (installedVersion) {
if (config.didUserProvideWranglerVersion) { if (config.didUserProvideWranglerVersion) {
if (semverEq(config.WRANGLER_VERSION, installedVersion)) { if (semverEq(config.WRANGLER_VERSION, installedVersion)) {
info(`✅ Using Wrangler ${installedVersion}`, true); info(`✅ Using Wrangler ${installedVersion}`, true);
endGroup(); endGroup();
return; return;
} else {
info(
`Wrangler version ${installedVersion} is not equal to the required version. Installing...`,
true,
);
}
} else { } else {
info( info(
`Wrangler version ${installedVersion} is not equal to the required version. Installing...`, `✅ No wrangler version specified, using pre-installed wrangler version ${installedVersion}`,
true, true,
); );
endGroup();
return;
} }
} else {
info(
`✅ No wrangler version specified, using pre-installed wrangler version ${installedVersion}`,
true,
);
endGroup();
return;
} }
} catch (error) { } catch (error) {
debug(`Error checking Wrangler version: ${error}`); debug(`Error checking Wrangler version: ${error}`);

View file

@ -0,0 +1,4 @@
#!/usr/bin/env node
"use strict";
require("../index");

View file

@ -0,0 +1,16 @@
const args = Array.from(process.argv);
const command = args.pop();
switch (command) {
case "--version":
console.log(
"⛅️ wrangler 1.1.1 (update available 1.2.3)\n" +
"-------------------------------------------------------",
);
process.exit(0);
case "action-test":
console.log("Test successful.");
process.exit(0);
default:
console.error("Invalid command");
process.exit(1);
}

View file

@ -0,0 +1,7 @@
{
"private": true,
"name": "wrangler",
"version": "1.1.1",
"main": "index.js",
"bin": "bin/wrangler"
}

File diff suppressed because it is too large Load diff

View file

@ -3,6 +3,6 @@
"license": "MIT", "license": "MIT",
"private": true, "private": true,
"devDependencies": { "devDependencies": {
"wrangler": "^3.28.0" "wrangler": "file:mock_packages/wrangler"
} }
} }