forked from cloudflare/workers-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: change version command to give update information (cloudflare#1498
) * feat: change version command to give update information * Prettify code * Conform to prettier style in .changeset * Add resiliance to snapshot against version number changing * Conform to prettier style * Read version from package.json, increase test coverage * Remove unneeded helper function * bump a fixture version to generate a new npm cache on CI Co-authored-by: Cameron Robey <[email protected]> Co-authored-by: Cameron Robey <[email protected]> Co-authored-by: Sunil Pai <[email protected]>
- Loading branch information
1 parent
e09abbc
commit fe3fbd9
Showing
5 changed files
with
97 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
feat: change version command to give update information | ||
When running version command, we want to display update information if current version is not up to date. Achieved by replacing default output with the wrangler banner. | ||
Previous behaviour (just outputting current version) reamins when !isTTY. | ||
Version command changed from inbuilt .version() from yargs, to a regular command to allow for asynchronous behaviour. | ||
|
||
Implements https://github.com/cloudflare/wrangler2/issues/1492 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
{ | ||
"name": "worker-app", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"test": "npx jest" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"private": true, | ||
"jest": { | ||
"testRegex": ".*.test\\.[jt]sx?$", | ||
"testEnvironment": "wrangler" | ||
} | ||
"name": "worker-app", | ||
"version": "1.0.1", | ||
"private": true, | ||
"description": "", | ||
"license": "ISC", | ||
"author": "", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"test": "npx jest" | ||
}, | ||
"jest": { | ||
"testEnvironment": "wrangler", | ||
"testRegex": ".*.test\\.[jt]sx?$" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { version } from "./../../package.json"; | ||
import { mockConsoleMethods } from "./helpers/mock-console"; | ||
import { useMockIsTTY } from "./helpers/mock-istty"; | ||
import { runWrangler } from "./helpers/run-wrangler"; | ||
|
||
describe("version", () => { | ||
const std = mockConsoleMethods(); | ||
const { setIsTTY } = useMockIsTTY(); | ||
|
||
// We cannot test output of version banner, | ||
// as it is disabled in jest environments | ||
|
||
// it("should output version banner", async () => { | ||
// await runWrangler("-v"); | ||
// expect(std.out).toMatchInlineSnapshot(` | ||
// " ⛅️ wrangler 2.0.22 | ||
// [38;5;214m--------------------[39m" | ||
// `); | ||
// }); | ||
|
||
it("should output current version if !isTTY calling -v", async () => { | ||
setIsTTY(false); | ||
|
||
await runWrangler("-v"); | ||
expect(std.out).toMatch(version); | ||
}); | ||
|
||
// This run separately as command handling is different | ||
it("should output current version if !isTTY calling --version", async () => { | ||
setIsTTY(false); | ||
|
||
await runWrangler("--version"); | ||
expect(std.out).toMatch(version); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters