Skip to content

Commit

Permalink
Chore: support JSR (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnauorriols authored Mar 1, 2024
1 parent 0cb1040 commit 1e16376
Show file tree
Hide file tree
Showing 29 changed files with 2,589 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno == 'old' && '1.37.2' || (matrix.deno == 'stable' && '1.x' || matrix.deno) }}
deno-version: ${{ matrix.deno == 'old' && '1.40.0' || (matrix.deno == 'stable' && '1.x' || matrix.deno) }}

- run: deno --version

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ contains the `denoland/deployctl` GitHub Action.
## Install

```shell
deno install -qArf https://deno.land/x/deploy/deployctl.ts
deno install -Arf jsr:@deno/deployctl
```

## Usage
Expand Down
6 changes: 5 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"name": "@deno/deployctl",
"version": "1.11.0",
"exports": "./deployctl.ts",
"fmt": {
"files": {
"exclude": ["action/node_modules/"]
Expand All @@ -13,5 +16,6 @@
"test": "deno test -A --unstable tests/ src/",
"build-action": "deno bundle ./src/utils/mod.ts > ./action/deps.js",
"version-match": "deno run --allow-read --allow-env ./tools/version_match.ts"
}
},
"importMap": "./import_map.json"
}
117 changes: 60 additions & 57 deletions deno.lock

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

18 changes: 15 additions & 3 deletions deployctl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

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

import { semverGreaterThanOrEquals, setColorEnabled } from "./deps.ts";
import {
semverGreaterThanOrEquals,
semverParse,
setColorEnabled,
} from "./deps.ts";
import { Args, parseArgs } from "./src/args.ts";
import { error } from "./src/error.ts";
import deploySubcommand from "./src/subcommands/deploy.ts";
Expand Down Expand Up @@ -36,7 +40,12 @@ For more detailed help on each subcommand, use:
deployctl <SUBCOMMAND> -h
`;

if (!semverGreaterThanOrEquals(Deno.version.deno, MINIMUM_DENO_VERSION)) {
if (
!semverGreaterThanOrEquals(
semverParse(Deno.version.deno),
semverParse(MINIMUM_DENO_VERSION),
)
) {
error(
`The Deno version you are using is too old. Please update to Deno ${MINIMUM_DENO_VERSION} or later. To do this run \`deno upgrade\`.`,
);
Expand Down Expand Up @@ -76,7 +85,10 @@ if (isTerminal(Deno.stdin)) {
// If latestVersion is set we need to inform the user about a new release.
if (
latestVersion &&
!(semverGreaterThanOrEquals(VERSION, latestVersion.toString()))
!(semverGreaterThanOrEquals(
semverParse(VERSION),
semverParse(latestVersion.toString()),
))
) {
console.error(
[
Expand Down
21 changes: 11 additions & 10 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export {
relative,
resolve,
toFileUrl,
} from "https://deno.land/std@0.170.0/path/mod.ts";
} from "jsr:@std/path@0.217";
export {
bold,
cyan,
Expand All @@ -23,18 +23,19 @@ export {
setColorEnabled,
stripColor,
yellow,
} from "https://deno.land/std@0.170.0/fmt/colors.ts";
export { parse } from "https://deno.land/std@0.195.0/flags/mod.ts";
export { TextLineStream } from "https://deno.land/std@0.170.0/streams/text_line_stream.ts";
export * as JSONC from "https://deno.land/std@0.170.0/encoding/jsonc.ts";
export { encodeHex } from "https://deno.land/std@0.212.0/encoding/hex.ts";
export { delay } from "https://deno.land/std@0.212.0/async/mod.ts";
} from "jsr:@std/fmt@0.217/colors";
export { parse } from "jsr:@std/flags@0.217";
export { TextLineStream } from "jsr:@std/streams@0.217/text_line_stream";
export * as JSONC from "jsr:@std/jsonc@0.217";
export { encodeHex } from "jsr:@std/encoding@0.217/hex";
export { delay } from "jsr:@std/async@0.217";

// x/semver
export {
gte as semverGreaterThanOrEquals,
valid as semverValid,
} from "https://deno.land/[email protected]/semver/mod.ts";
canParse as semverValid,
greaterOrEqual as semverGreaterThanOrEquals,
parse as semverParse,
} from "jsr:@std/[email protected]";

// x/wait
export {
Expand Down
6 changes: 6 additions & 0 deletions import_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"imports": {
"https://deno.land/": "./vendor/deno.land/",
"https://raw.githubusercontent.com/denosaurs/wait/453df8babdd72c59d865c5a616c5b04ee1154b9f/": "./vendor/wait-deprecated-warnings-pr-head/"
}
}
2 changes: 1 addition & 1 deletion src/subcommands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The following example will fail because main.ts is not included:
The entrypoint can also be a remote script. A common use case for this is to deploy an static site
using std/http/file_server.ts (more details in https://docs.deno.com/deploy/tutorials/static-site ):
deployctl deploy --entrypoint=https://deno.land/[email protected]/http/file_server.ts
deployctl deploy --entrypoint=jsr:@std/http/file_server
USAGE:
Expand Down
5 changes: 1 addition & 4 deletions src/subcommands/logs_test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { parseArgsForLogSubcommand } from "./logs.ts";
import {
assertEquals,
assertThrows,
} from "https://deno.land/[email protected]/testing/asserts.ts";
import { assertEquals, assertThrows } from "jsr:@std/[email protected]";
import { parseArgs } from "../args.ts";

Deno.test("parseArgsForLogSubcommand", async (t) => {
Expand Down
11 changes: 9 additions & 2 deletions src/subcommands/upgrade.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// Copyright 2021 Deno Land Inc. All rights reserved. MIT license.

import { error } from "../error.ts";
import { semverGreaterThanOrEquals, semverValid } from "../../deps.ts";
import {
semverGreaterThanOrEquals,
semverParse,
semverValid,
} from "../../deps.ts";
import { VERSION } from "../version.ts";

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

if (!version && semverGreaterThanOrEquals(VERSION, latest)) {
if (
!version &&
semverGreaterThanOrEquals(semverParse(VERSION), semverParse(latest))
) {
console.log("You're using the latest version.");
Deno.exit();
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ export class API {
throw new Error("Stream ended unexpectedly");
}

const lines = res.body
const lines: ReadableStream<string> = res.body
.pipeThrough(new TextDecoderStream())
.pipeThrough(new TextLineStream());
return async function* () {
return async function* (): AsyncGenerator<string, void> {
for await (const line of lines) {
if (line === "") return;
yield line;
Expand Down
9 changes: 7 additions & 2 deletions src/utils/mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { semverGreaterThanOrEquals } from "../../deps.ts";
import { semverGreaterThanOrEquals, semverParse } from "../../deps.ts";

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

// deno-lint-ignore no-explicit-any
export function isTerminal(stream: any) {
if (semverGreaterThanOrEquals(Deno.version.deno, "1.40.0")) {
if (
semverGreaterThanOrEquals(
semverParse(Deno.version.deno),
semverParse("1.40.0"),
)
) {
return stream.isTerminal();
} else {
// deno-lint-ignore no-deprecated-deno-api
Expand Down
4 changes: 2 additions & 2 deletions src/version.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const VERSION = "1.10.5";
export const VERSION = "1.11.0";

export const MINIMUM_DENO_VERSION = "1.31.0";
export const MINIMUM_DENO_VERSION = "1.40.0";
2 changes: 1 addition & 1 deletion tests/deps.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/std@0.116.0/testing/asserts.ts";
export * from "jsr:@std/assert@0.217";
2 changes: 1 addition & 1 deletion tools/version_match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Intended to run when a draft release is created on GitHub.

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

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

0 comments on commit 1e16376

Please sign in to comment.