Skip to content

Commit

Permalink
migrate std to jsr
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkal committed Jun 14, 2024
1 parent 0fde5dc commit 1ccb226
Show file tree
Hide file tree
Showing 18 changed files with 249 additions and 35 deletions.
6 changes: 3 additions & 3 deletions args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* @license MIT
*/

import * as flags from "https://deno.land/[email protected].0/flags/mod.ts";
import { JSON_SCHEMA, parse } from "https://deno.land/[email protected].0/yaml/mod.ts";
import { parseArgs } from "jsr:@std/cli@0.224.6/parse-args";
import { JSON_SCHEMA, parse } from "jsr:@std/yaml@0.224.1";

/**
* If the value is '-' stdin is read and returned.
Expand Down Expand Up @@ -51,7 +51,7 @@ export function getArgsObject(
: (_: string, value: string) => {
return !!looksLikeYamlRe.exec(value);
};
const rawArgs = flags.parse(argsArray || Deno.args);
const rawArgs = parseArgs(argsArray || Deno.args);
const parsedArgs: any = {};
Object.entries(rawArgs).forEach(([key, rawValue]) => {
let value = textOrStdIn(rawValue);
Expand Down
2 changes: 1 addition & 1 deletion dedent.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/std@0.224.0/assert/mod.ts";
import { assertEquals } from "jsr:@std/assert@0.226.0";
import { dedent } from "./dedent.ts";
const it = Deno.test;

Expand Down
217 changes: 217 additions & 0 deletions deno.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @license MIT
*/

import * as fs from "https://deno.land/std@0.224.0/fs/mod.ts";
import * as fs from "jsr:@std/fs@0.229.3";

const jsDocStartRe = /^\/\*\*/;
const jsDocMidRe = /^\s+\*\s/;
Expand Down
4 changes: 2 additions & 2 deletions emittery.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assertEquals } from "https://deno.land/std@0.224.0/assert/mod.ts";
import { delay } from "https://deno.land/[email protected].0/async/delay.ts";
import { assertEquals } from "jsr:@std/assert@0.226.0";
import { delay } from "jsr:@std/async@0.224.2";
import { Emittery } from "./emittery.ts";
const emitter = new Emittery();

Expand Down
2 changes: 1 addition & 1 deletion http-signature/verify.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/std@0.224.0/assert/mod.ts";
import { assertEquals } from "jsr:@std/assert@0.226.0";
const it = Deno.test;

import * as httpsig from "./verify.ts";
Expand Down
2 changes: 1 addition & 1 deletion http-signature/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import { HmacSha256 } from "https://deno.land/[email protected]/hash/sha256.ts";
import { encodeBase64 } from "https://deno.land/[email protected].0/encoding/base64.ts";
import { encodeBase64 } from "jsr:@std/encoding@0.224.3";

/////
interface parseOptions {
Expand Down
6 changes: 3 additions & 3 deletions kite/extended-string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import { sha1 } from "https://deno.land/x/[email protected]/mod.ts";
import titleCase from "https://deno.land/x/[email protected]/titleCase.ts";
import { sha256 } from "https://deno.land/x/[email protected]/mod.ts";
import * as base32 from "https://deno.land/[email protected].0/encoding/base32.ts";
import { decodeBase32, encodeBase32 } from "jsr:@std/encoding@0.224.3/base32";

const RE = /^{{.*}}$/;

Expand Down Expand Up @@ -91,10 +91,10 @@ class Helpers {
b64dec = atob;
b32enc = (a: string) => {
const binary = new TextEncoder().encode(a);
return base32.encodeBase32(binary);
return encodeBase32(binary);
};
b32dec = (a: string) => {
const decoded = base32.decodeBase32(a);
const decoded = decodeBase32(a);
return new TextDecoder().decode(decoded);
};
sha1sum = sha1;
Expand Down
2 changes: 1 addition & 1 deletion kite/template-cli.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/std@0.224.0/assert/mod.ts";
import { assertEquals } from "jsr:@std/assert@0.226.0";
const it = Deno.test;
import { canonicalizeOptions, CliFlags } from "./template-cli.ts";
import { TemplateConfig } from "./template.ts";
Expand Down
2 changes: 1 addition & 1 deletion kite/template-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import template, {
} from "./template.ts";
import { getArgsObject } from "../args.ts";
import { merge } from "../merge.ts";
import * as YAML from "https://deno.land/[email protected].0/yaml/mod.ts";
import * as YAML from "jsr:@std/yaml@0.224.1";

const helpText = `\
Kite™️ Template Tool by Brandon Kalinowski @brandonkal
Expand Down
2 changes: 1 addition & 1 deletion kite/template.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/std@0.224.0/assert/mod.ts";
import { assertEquals } from "jsr:@std/assert@0.226.0";
const it = Deno.test;
import { getConfigFromYaml, TemplateConfig } from "./template.ts";
import { dedent } from "../dedent.ts";
Expand Down
16 changes: 9 additions & 7 deletions kite/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
* @license MIT
*/

import * as fs from "https://deno.land/[email protected]/fs/mod.ts";
import * as path from "https://deno.land/[email protected]/path/mod.ts";
import * as fs from "jsr:@std/[email protected]";
import * as path from "jsr:@std/[email protected]";
import * as YAML from "jsr:@std/[email protected]";
import { toText } from "jsr:@std/[email protected]";
import { decodeBase32, encodeBase32 } from "jsr:@std/[email protected]/base32";

import { sha1 } from "https://deno.land/x/[email protected]/mod.ts";
import titleCase from "https://deno.land/x/[email protected]/titleCase.ts";
import { sha256 } from "https://deno.land/x/[email protected]/mod.ts";
import * as YAML from "https://deno.land/[email protected]/yaml/mod.ts";
import * as base32 from "https://deno.land/[email protected]/encoding/base32.ts";
import { toText } from "https://deno.land/[email protected]/streams/to_text.ts";

import * as k8s from "https://x.kite.run/lib/kubernetes.ts";

import { dotProp, homedir, jsonItem, visitAll, withTimeout } from "../utils.ts";
Expand Down Expand Up @@ -901,10 +903,10 @@ function ops(envars: Record<string, string | undefined>) {
b64dec: atob,
b32enc: (a: string) => {
const binary = new TextEncoder().encode(a);
return base32.encodeBase32(binary);
return encodeBase32(binary);
},
b32dec: (a: string) => {
const decoded = base32.decodeBase32(a);
const decoded = decodeBase32(a);
return new TextDecoder().decode(decoded);
},
sha1sum: (a: string) => sha1(a, "utf8", "hex"),
Expand Down
5 changes: 1 addition & 4 deletions kubernetes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
* Refer to kite.ts for more info.
*/

import {
JSON_SCHEMA,
parseAll,
} from "https://deno.land/[email protected]/yaml/mod.ts";
import { JSON_SCHEMA, parseAll } from "jsr:@std/[email protected]";
import * as kite from "./kite.ts";
import { meta } from "./kubernetes/gen/types.ts";

Expand Down
3 changes: 1 addition & 2 deletions merge.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file merge.ts
* @copyright 2020 Brandon Kalinowski (brandonkal)
* @copyright 2020-2024 Brandon Kalinowski (brandonkal)
* @author jk authors
* @description Provides generic object merging functions. Useful for config generation.
* Portions of this work were obtained via the Apache 2.0 License.
Expand Down Expand Up @@ -344,7 +344,6 @@ export function deepWithKey(mergeKey: string, rules?: MergeObject<any>) {
* ```
*/
export function merge<A>(a: A, b: A, rule?: MergeObject<A>): any {
//@ts-ignore
if (a === b) {
return a;
}
Expand Down
2 changes: 1 addition & 1 deletion retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @license MIT
*/

import { delay as wait } from "https://deno.land/[email protected]/async/delay.ts";
import { delay as wait } from "jsr:@std/async@0.224.0";

/**
* Retry an async function until it does not throw an exception.
Expand Down
4 changes: 2 additions & 2 deletions testutils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file testutils.ts
* @copyright 2024 Brandon Kalinowski (@brandonkal). ISC.
* @copyright 2020-2024 Brandon Kalinowski (@brandonkal). ISC.
* Portions of this work were obtained via the ISC License.
* That original work is Copyright 2019 Allain Lalonde.
* @description Utilities for testing. Replicates expect from Jest.
Expand All @@ -16,7 +16,7 @@ export function describe(desc: string, fn: Function) {
console.log(desc);
fn();
}
export { fail } from "https://deno.land/std@0.224.0/assert/mod.ts";
export { fail } from "jsr:@std/assert@0.226.0";
export const it = Deno.test;
export { expect } from "https://raw.githubusercontent.com/brandonkal/expect/b457497332ba2197835f4eacef3e95dac569ee8d/expect.ts";
import * as m from "https://raw.githubusercontent.com/brandonkal/expect/b457497332ba2197835f4eacef3e95dac569ee8d/mock.ts";
Expand Down
5 changes: 2 additions & 3 deletions yaml-tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
* @license MIT
*/

import * as YAML from "https://deno.land/[email protected]/yaml/mod.ts";
import { Type } from "https://deno.land/[email protected]/yaml/type.ts";
import * as YAML from "jsr:@std/[email protected]";
import { Schema } from "https://deno.land/[email protected]/yaml/schema.ts";
import { execDedent } from "./dedent.ts";
import { stripUndefined } from "./utils.ts";

const undefinedType = new Type("tag:yaml.org,2002:js/undefined", {
const undefinedType = new YAML.Type("tag:yaml.org,2002:js/undefined", {
kind: "scalar",
resolve: () => true,
construct: () => undefined,
Expand Down
2 changes: 1 addition & 1 deletion yaml.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/std@0.224.0/assert/mod.ts";
import { assertEquals } from "jsr:@std/assert@0.226.0";
const it = Deno.test;

import { dedent } from "./dedent.ts";
Expand Down

0 comments on commit 1ccb226

Please sign in to comment.