mirror of
https://github.com/cloudflare/wrangler-action.git
synced 2024-11-22 01:53:24 +01:00
Tweak the fixture test for the pre-installed-wrangler test
This commit is contained in:
parent
2523489ae1
commit
06f5e60089
7 changed files with 66 additions and 1279 deletions
4
.github/workflows/deploy.yml
vendored
4
.github/workflows/deploy.yml
vendored
|
@ -169,6 +169,4 @@ jobs:
|
|||
uses: ./
|
||||
with:
|
||||
workingDirectory: "./test/pre-installed-wrangler"
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
command: deploy --dry-run
|
||||
command: action-test
|
||||
|
|
19
src/index.ts
19
src/index.ts
|
@ -93,16 +93,20 @@ async function installWrangler() {
|
|||
["wrangler", "--version"],
|
||||
{
|
||||
cwd: config["workingDirectory"],
|
||||
silent: true,
|
||||
silent: config.QUIET_MODE,
|
||||
},
|
||||
);
|
||||
const versionMatch = stdout.match(/wrangler (\d+\.\d+\.\d+)/);
|
||||
if (!versionMatch) {
|
||||
throw new Error(
|
||||
`Unable to parse Wrangler version from the output: ${stdout}`,
|
||||
);
|
||||
}
|
||||
// There are two possible outputs from `wrangler --version`:
|
||||
// ` ⛅️ wrangler 3.48.0 (update available 3.53.1)`
|
||||
// and
|
||||
// `3.48.0`
|
||||
const versionMatch =
|
||||
stdout.match(/wrangler (\d+\.\d+\.\d+)/) ??
|
||||
stdout.match(/^(\d+\.\d+\.\d+)/);
|
||||
if (versionMatch) {
|
||||
installedVersion = versionMatch[1];
|
||||
}
|
||||
if (installedVersion) {
|
||||
if (config.didUserProvideWranglerVersion) {
|
||||
if (semverEq(config.WRANGLER_VERSION, installedVersion)) {
|
||||
info(`✅ Using Wrangler ${installedVersion}`, true);
|
||||
|
@ -122,6 +126,7 @@ async function installWrangler() {
|
|||
endGroup();
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
debug(`Error checking Wrangler version: ${error}`);
|
||||
info(
|
||||
|
|
4
test/pre-installed-wrangler/mock_packages/wrangler/bin/wrangler
Executable file
4
test/pre-installed-wrangler/mock_packages/wrangler/bin/wrangler
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
|
||||
require("../index");
|
16
test/pre-installed-wrangler/mock_packages/wrangler/index.js
Normal file
16
test/pre-installed-wrangler/mock_packages/wrangler/index.js
Normal 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);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"private": true,
|
||||
"name": "wrangler",
|
||||
"version": "1.1.1",
|
||||
"main": "index.js",
|
||||
"bin": "bin/wrangler"
|
||||
}
|
1265
test/pre-installed-wrangler/package-lock.json
generated
1265
test/pre-installed-wrangler/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -3,6 +3,6 @@
|
|||
"license": "MIT",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"wrangler": "^3.28.0"
|
||||
"wrangler": "file:mock_packages/wrangler"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue