Skip to content

Commit ec38350

Browse files
committed
Update to deno 2.0.0
1 parent 9d08ab5 commit ec38350

File tree

10 files changed

+91
-108
lines changed

10 files changed

+91
-108
lines changed

cli.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ run() {
3939
}
4040

4141
set_version() {
42-
local VERSION=${1:-"dev"}
42+
local VERSION=${1:-"0.0.0"}
4343
local JSR_JSON
4444
JSR_JSON=$(jq -e --arg VERSION "${VERSION}" '.version=$VERSION' ./deno.json)
4545
echo "${JSR_JSON}" >./deno.json

deno.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "@wok/jetski",
33
"version": "0.0.0",
44
"exports": {
5-
"./types": "./src/types.ts"
5+
"./types": "./src/types.ts",
6+
".": "./src/app.ts"
67
},
78
"publish": {
89
"include": ["./src", "./deno.json", "./README.md", "./LICENSE"]
@@ -31,13 +32,13 @@
3132
}
3233
},
3334
"imports": {
34-
"@std/assert": "jsr:@std/assert@^1.0.5",
35+
"@std/assert": "jsr:@std/assert@^1.0.6",
3536
"@std/async": "jsr:@std/async@^1.0.5",
3637
"@std/fmt": "jsr:@std/fmt@^1.0.2",
37-
"@std/fs": "jsr:@std/fs@^1.0.3",
38+
"@std/fs": "jsr:@std/fs@^1.0.4",
3839
"@std/path": "jsr:@std/path@^1.0.6",
3940
"@std/yaml": "jsr:@std/yaml@^1.0.5",
40-
"@wok/typebox": "jsr:@wok/typebox@^0.33.13",
41-
"@wok/utils": "jsr:@wok/utils@^3.0.0"
41+
"@wok/typebox": "jsr:@wok/typebox@^0.33.15",
42+
"@wok/utils": "jsr:@wok/utils@^3.2.0"
4243
}
4344
}

deno.lock

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

flake.lock

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

flake.nix

+30-52
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@
1313
let
1414
pkgs = import nixpkgs { inherit system; };
1515
hotPotPkgs = hotPot.packages.${system};
16-
hotPotLib = hotPot.lib.${system};
17-
deno = hotPotPkgs.deno;
1816
# denort = hotPotPkgs.denort;
1917
vscodeSettings = pkgs.writeTextFile {
2018
name = "vscode-settings.json";
2119
text = builtins.toJSON {
2220
"deno.enable" = true;
2321
"deno.lint" = true;
2422
"deno.unstable" = true;
25-
"deno.path" = deno + "/bin/deno";
23+
"deno.path" = hotPotPkgs.deno + "/bin/deno";
2624
"deno.suggest.imports.hosts" = {
2725
"https://deno.land" = false;
2826
};
@@ -50,58 +48,39 @@
5048
};
5149
runtimeInputs = builtins.attrValues
5250
{
51+
inherit (hotPotPkgs)
52+
deno
53+
;
5354
inherit (pkgs)
5455
kubectl
5556
;
5657
};
57-
jetski =
58-
let
59-
name = "jetski";
60-
src = builtins.path
61-
{
62-
path = ./.;
63-
name = "${name}-src";
64-
filter = with pkgs.lib; (path: /* type */_:
65-
hasInfix "/src" path ||
66-
hasSuffix "/deno.lock" path ||
67-
hasSuffix "/deno.json" path
68-
);
69-
};
70-
deno-cache-dir = pkgs.callPackage hotPotLib.denoAppCache2 {
71-
inherit deno name src;
72-
config-file = ./deno.json;
73-
lock-file = ./deno.lock;
74-
};
75-
transpiled = pkgs.callPackage hotPotLib.denoAppTranspile
76-
{
77-
inherit name deno-cache-dir src;
78-
appSrcPath = "./src/app.ts";
79-
denoRunFlags = ''"''${DENO_RUN_FLAGS[@]}"'';
80-
preExec = ''
81-
DENO_RUN_FLAGS=("-A")
82-
if [ ! -f deno.lock ]; then
83-
DENO_RUN_FLAGS+=("--no-lock")
84-
fi
85-
if [ -f deno.json ]; then
86-
DENO_RUN_FLAGS+=("--config=deno.json")
87-
elif [ -f deno.jsonc ]; then
88-
DENO_RUN_FLAGS+=("--config=deno.jsonc")
89-
fi
90-
'';
91-
allowNpmSpecifiers = true;
92-
};
93-
denoJson = builtins.fromJSON (builtins.readFile ./deno.json);
94-
in
95-
pkgs.runCommandLocal "${name}-wrapped"
96-
{
97-
buildInputs = [ pkgs.makeWrapper ];
98-
}
99-
''
100-
makeWrapper ${transpiled}/bin/jetski $out/bin/jetski \
101-
--set JETSKI_VERSION "${denoJson.version}" \
102-
--prefix PATH : "${pkgs.lib.makeBinPath runtimeInputs}" \
103-
--set-default JETSKI_ENABLE_STACKTRACE "0"
104-
'';
58+
denoJson = builtins.fromJSON (builtins.readFile ./deno.json);
59+
src = builtins.path
60+
{
61+
path = ./.;
62+
name = "jetski-src";
63+
filter = with pkgs.lib; (path: /* type */_:
64+
hasInfix "/src" path ||
65+
hasSuffix "/deno.lock" path ||
66+
hasSuffix "/deno.json" path
67+
);
68+
};
69+
jetski-bin = pkgs.writeShellScript "jetski"
70+
(if denoJson.version == "0.0.0" then ''
71+
deno run -A --check ${src}/src/app.ts "$@"
72+
'' else ''
73+
deno run -A jsr:@wok/jetski@${denoJson.version} "$@"
74+
'');
75+
jetski = pkgs.runCommandLocal "jetski"
76+
{
77+
buildInputs = [ pkgs.makeWrapper ];
78+
}
79+
''
80+
makeWrapper ${jetski-bin} $out/bin/jetski \
81+
--prefix PATH : "${pkgs.lib.makeBinPath runtimeInputs}" \
82+
--set-default JETSKI_ENABLE_STACKTRACE "0"
83+
'';
10584
in
10685
{
10786
devShell = pkgs.mkShellNoCC {
@@ -110,7 +89,6 @@
11089
cat ${vscodeSettings} > ./.vscode/settings.json
11190
'';
11291
buildInputs = runtimeInputs ++ builtins.attrValues {
113-
inherit deno;
11492
inherit (hotPotPkgs)
11593
typescript-eslint
11694
;

src/actions/create.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export async function createInstance(instance: InstanceConfig, signal: AbortSign
170170
},
171171
});
172172
} catch (e) {
173-
err("Failed launching", e.toString());
173+
err("Failed launching", e);
174174
return ExitCode.One;
175175
} finally {
176176
await Deno.remove(tempDir, { recursive: true });

src/actions/version.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { createCliAction, ExitCode } from "../deps.ts";
2+
import { default as config } from "../../deno.json" with { type: "json" };
23

34
export default createCliAction(
45
{},
56
() => {
6-
console.log({ app: Deno.env.get("JETSKI_VERSION") ?? "dev", ...Deno.version });
7+
console.log(JSON.stringify({ app: config.version === "0.0.0" ? "dev" : config.version, ...Deno.version }, null, 2));
78
return Promise.resolve(ExitCode.Zero);
89
},
910
);

src/app.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ try {
2626
await program.run(Deno.args);
2727
} catch (e) {
2828
if (e instanceof NonZeroExitError) {
29-
console.error(bold(red("[Error]")), JSON.stringify(e, null, 2));
29+
console.error(bold(red("[Error]")), e);
3030
} else if (Deno.env.get("JETSKI_ENABLE_STACKTRACE") !== "0") {
31-
console.error(bold(red("[Error]")), e.message, JSON.stringify(e, null, 2));
31+
console.error(bold(red("[Error]")), e);
3232
throw e;
3333
} else {
34-
console.error(bold(red("[Error]")), e.message);
34+
console.error(bold(red("[Error]")), e);
3535
}
3636

3737
Deno.exit(1);

src/multipass.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ export async function multipassInfo(
105105
const output = (() => {
106106
try {
107107
return JSON.parse(maybeJson);
108-
} catch (e) {
109-
throw new Error(`Failed parsing 'multipass info ...' output to JSON due to: ${e.toString()}. Got: ${maybeJson}`);
108+
} catch (cause) {
109+
throw new Error(`Failed parsing 'multipass info ...' output to JSON. Got: ${maybeJson}`, {
110+
cause,
111+
});
110112
}
111113
})();
112114

@@ -380,7 +382,7 @@ export async function multipassPostStart(instance: InstanceConfig, abortSignal:
380382
try {
381383
return (await multipassInfo({ name })).state;
382384
} catch (e) {
383-
err("Failed obtaining instance state, will retry in 1s. Reason:", e.message);
385+
err("Failed obtaining instance state, will retry in 1s. Reason:", e);
384386
await delay(1000, { signal: abortSignal });
385387
}
386388
}

src/utils.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,10 @@ export async function createCloudInitConfig(
147147

148148
return result.value;
149149
}
150-
} catch (e) {
151-
throw new Error(`Failed reading join metadata from ${instance.joinMetadataPath}. Reason: ${e.message}`, e);
150+
} catch (cause) {
151+
throw new Error(`Failed reading join metadata from ${instance.joinMetadataPath}`, {
152+
cause,
153+
});
152154
}
153155
})();
154156

0 commit comments

Comments
 (0)