Skip to content

Commit 1e16376

Browse files
authored
Chore: support JSR (#284)
1 parent 0cb1040 commit 1e16376

29 files changed

+2589
-88
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Setup Deno
2525
uses: denoland/setup-deno@v1
2626
with:
27-
deno-version: ${{ matrix.deno == 'old' && '1.37.2' || (matrix.deno == 'stable' && '1.x' || matrix.deno) }}
27+
deno-version: ${{ matrix.deno == 'old' && '1.40.0' || (matrix.deno == 'stable' && '1.x' || matrix.deno) }}
2828

2929
- run: deno --version
3030

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ contains the `denoland/deployctl` GitHub Action.
66
## Install
77

88
```shell
9-
deno install -qArf https://deno.land/x/deploy/deployctl.ts
9+
deno install -Arf jsr:@deno/deployctl
1010
```
1111

1212
## Usage

deno.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"name": "@deno/deployctl",
3+
"version": "1.11.0",
4+
"exports": "./deployctl.ts",
25
"fmt": {
36
"files": {
47
"exclude": ["action/node_modules/"]
@@ -13,5 +16,6 @@
1316
"test": "deno test -A --unstable tests/ src/",
1417
"build-action": "deno bundle ./src/utils/mod.ts > ./action/deps.js",
1518
"version-match": "deno run --allow-read --allow-env ./tools/version_match.ts"
16-
}
19+
},
20+
"importMap": "./import_map.json"
1721
}

deno.lock

+60-57
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deployctl.ts

+15-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
// Copyright 2021 Deno Land Inc. All rights reserved. MIT license.
44

5-
import { semverGreaterThanOrEquals, setColorEnabled } from "./deps.ts";
5+
import {
6+
semverGreaterThanOrEquals,
7+
semverParse,
8+
setColorEnabled,
9+
} from "./deps.ts";
610
import { Args, parseArgs } from "./src/args.ts";
711
import { error } from "./src/error.ts";
812
import deploySubcommand from "./src/subcommands/deploy.ts";
@@ -36,7 +40,12 @@ For more detailed help on each subcommand, use:
3640
deployctl <SUBCOMMAND> -h
3741
`;
3842

39-
if (!semverGreaterThanOrEquals(Deno.version.deno, MINIMUM_DENO_VERSION)) {
43+
if (
44+
!semverGreaterThanOrEquals(
45+
semverParse(Deno.version.deno),
46+
semverParse(MINIMUM_DENO_VERSION),
47+
)
48+
) {
4049
error(
4150
`The Deno version you are using is too old. Please update to Deno ${MINIMUM_DENO_VERSION} or later. To do this run \`deno upgrade\`.`,
4251
);
@@ -76,7 +85,10 @@ if (isTerminal(Deno.stdin)) {
7685
// If latestVersion is set we need to inform the user about a new release.
7786
if (
7887
latestVersion &&
79-
!(semverGreaterThanOrEquals(VERSION, latestVersion.toString()))
88+
!(semverGreaterThanOrEquals(
89+
semverParse(VERSION),
90+
semverParse(latestVersion.toString()),
91+
))
8092
) {
8193
console.error(
8294
[

deps.ts

+11-10
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export {
1313
relative,
1414
resolve,
1515
toFileUrl,
16-
} from "https://deno.land/std@0.170.0/path/mod.ts";
16+
} from "jsr:@std/path@0.217";
1717
export {
1818
bold,
1919
cyan,
@@ -23,18 +23,19 @@ export {
2323
setColorEnabled,
2424
stripColor,
2525
yellow,
26-
} from "https://deno.land/std@0.170.0/fmt/colors.ts";
27-
export { parse } from "https://deno.land/std@0.195.0/flags/mod.ts";
28-
export { TextLineStream } from "https://deno.land/std@0.170.0/streams/text_line_stream.ts";
29-
export * as JSONC from "https://deno.land/std@0.170.0/encoding/jsonc.ts";
30-
export { encodeHex } from "https://deno.land/std@0.212.0/encoding/hex.ts";
31-
export { delay } from "https://deno.land/std@0.212.0/async/mod.ts";
26+
} from "jsr:@std/fmt@0.217/colors";
27+
export { parse } from "jsr:@std/flags@0.217";
28+
export { TextLineStream } from "jsr:@std/streams@0.217/text_line_stream";
29+
export * as JSONC from "jsr:@std/jsonc@0.217";
30+
export { encodeHex } from "jsr:@std/encoding@0.217/hex";
31+
export { delay } from "jsr:@std/async@0.217";
3232

3333
// x/semver
3434
export {
35-
gte as semverGreaterThanOrEquals,
36-
valid as semverValid,
37-
} from "https://deno.land/[email protected]/semver/mod.ts";
35+
canParse as semverValid,
36+
greaterOrEqual as semverGreaterThanOrEquals,
37+
parse as semverParse,
38+
} from "jsr:@std/[email protected]";
3839

3940
// x/wait
4041
export {

import_map.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"imports": {
3+
"https://deno.land/": "./vendor/deno.land/",
4+
"https://raw.githubusercontent.com/denosaurs/wait/453df8babdd72c59d865c5a616c5b04ee1154b9f/": "./vendor/wait-deprecated-warnings-pr-head/"
5+
}
6+
}

src/subcommands/deploy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ The following example will fail because main.ts is not included:
5757
The entrypoint can also be a remote script. A common use case for this is to deploy an static site
5858
using std/http/file_server.ts (more details in https://docs.deno.com/deploy/tutorials/static-site ):
5959
60-
deployctl deploy --entrypoint=https://deno.land/[email protected]/http/file_server.ts
60+
deployctl deploy --entrypoint=jsr:@std/http/file_server
6161
6262
6363
USAGE:

src/subcommands/logs_test.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import { parseArgsForLogSubcommand } from "./logs.ts";
2-
import {
3-
assertEquals,
4-
assertThrows,
5-
} from "https://deno.land/[email protected]/testing/asserts.ts";
2+
import { assertEquals, assertThrows } from "jsr:@std/[email protected]";
63
import { parseArgs } from "../args.ts";
74

85
Deno.test("parseArgsForLogSubcommand", async (t) => {

src/subcommands/upgrade.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
// Copyright 2021 Deno Land Inc. All rights reserved. MIT license.
22

33
import { error } from "../error.ts";
4-
import { semverGreaterThanOrEquals, semverValid } from "../../deps.ts";
4+
import {
5+
semverGreaterThanOrEquals,
6+
semverParse,
7+
semverValid,
8+
} from "../../deps.ts";
59
import { VERSION } from "../version.ts";
610

711
const help = `deployctl upgrade
@@ -56,7 +60,10 @@ export default async function (rawArgs: Record<string, any>): Promise<void> {
5660
);
5761
}
5862

59-
if (!version && semverGreaterThanOrEquals(VERSION, latest)) {
63+
if (
64+
!version &&
65+
semverGreaterThanOrEquals(semverParse(VERSION), semverParse(latest))
66+
) {
6067
console.log("You're using the latest version.");
6168
Deno.exit();
6269
} else {

src/utils/api.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ export class API {
152152
throw new Error("Stream ended unexpectedly");
153153
}
154154

155-
const lines = res.body
155+
const lines: ReadableStream<string> = res.body
156156
.pipeThrough(new TextDecoderStream())
157157
.pipeThrough(new TextLineStream());
158-
return async function* () {
158+
return async function* (): AsyncGenerator<string, void> {
159159
for await (const line of lines) {
160160
if (line === "") return;
161161
yield line;

src/utils/mod.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { semverGreaterThanOrEquals } from "../../deps.ts";
1+
import { semverGreaterThanOrEquals, semverParse } from "../../deps.ts";
22

33
export { parseEntrypoint } from "./entrypoint.ts";
44
export { API, APIError } from "./api.ts";
@@ -7,7 +7,12 @@ export { fromFileUrl, resolve } from "../../deps.ts";
77

88
// deno-lint-ignore no-explicit-any
99
export function isTerminal(stream: any) {
10-
if (semverGreaterThanOrEquals(Deno.version.deno, "1.40.0")) {
10+
if (
11+
semverGreaterThanOrEquals(
12+
semverParse(Deno.version.deno),
13+
semverParse("1.40.0"),
14+
)
15+
) {
1116
return stream.isTerminal();
1217
} else {
1318
// deno-lint-ignore no-deprecated-deno-api

src/version.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export const VERSION = "1.10.5";
1+
export const VERSION = "1.11.0";
22

3-
export const MINIMUM_DENO_VERSION = "1.31.0";
3+
export const MINIMUM_DENO_VERSION = "1.40.0";

tests/deps.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from "https://deno.land/std@0.116.0/testing/asserts.ts";
1+
export * from "jsr:@std/assert@0.217";

tools/version_match.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Intended to run when a draft release is created on GitHub.
66

77
import { VERSION } from "../src/version.ts";
8-
import { assertEquals } from "https://deno.land/std@0.194.0/testing/asserts.ts";
8+
import { assertEquals } from "jsr:@std/assert@0.217";
99

1010
const releaseTagVersion = Deno.env.get("RELEASE_TAG")!;
1111
assertEquals(VERSION, releaseTagVersion);

0 commit comments

Comments
 (0)