@qlever-llc/trellis 0.10.3 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/generate.js +24 -2
- package/package.json +2 -2
- package/script/generate.js +24 -2
- package/src/generate.ts +30 -2
package/esm/generate.js
CHANGED
|
@@ -8,6 +8,8 @@ const SUPPORTED_TARGETS = new Set([
|
|
|
8
8
|
"x86_64-apple-darwin",
|
|
9
9
|
"aarch64-apple-darwin",
|
|
10
10
|
]);
|
|
11
|
+
class ManifestNotFoundError extends Error {
|
|
12
|
+
}
|
|
11
13
|
async function main() {
|
|
12
14
|
const localRepoRoot = await findLocalTrellisRepoRoot();
|
|
13
15
|
if (localRepoRoot) {
|
|
@@ -29,6 +31,9 @@ function denoRuntime() {
|
|
|
29
31
|
return deno;
|
|
30
32
|
}
|
|
31
33
|
async function findLocalTrellisRepoRoot() {
|
|
34
|
+
if (new URL(globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).url).protocol !== "file:") {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
32
37
|
let current = urlDirname(globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).url);
|
|
33
38
|
while (current !== dirname(current)) {
|
|
34
39
|
if (await pathExists(joinPath(current, "rust/tools/generate/Cargo.toml")) &&
|
|
@@ -65,10 +70,11 @@ async function readFirstManifest(urls) {
|
|
|
65
70
|
const deno = denoRuntime();
|
|
66
71
|
for (const url of urls) {
|
|
67
72
|
try {
|
|
68
|
-
return JSON.parse(await
|
|
73
|
+
return JSON.parse(await readManifestText(url));
|
|
69
74
|
}
|
|
70
75
|
catch (error) {
|
|
71
|
-
if (error instanceof deno.errors.NotFound
|
|
76
|
+
if (error instanceof deno.errors.NotFound ||
|
|
77
|
+
error instanceof ManifestNotFoundError) {
|
|
72
78
|
continue;
|
|
73
79
|
}
|
|
74
80
|
throw error;
|
|
@@ -76,6 +82,22 @@ async function readFirstManifest(urls) {
|
|
|
76
82
|
}
|
|
77
83
|
throw new Error("@qlever-llc/trellis package manifest was not found");
|
|
78
84
|
}
|
|
85
|
+
async function readManifestText(url) {
|
|
86
|
+
if (url.protocol === "file:") {
|
|
87
|
+
return await denoRuntime().readTextFile(url);
|
|
88
|
+
}
|
|
89
|
+
if (url.protocol === "http:" || url.protocol === "https:") {
|
|
90
|
+
const response = await fetch(url);
|
|
91
|
+
if (response.status === 404) {
|
|
92
|
+
throw new ManifestNotFoundError(`package manifest was not found: ${url}`);
|
|
93
|
+
}
|
|
94
|
+
if (!response.ok) {
|
|
95
|
+
throw new Error(`failed to read ${url}: HTTP ${response.status}`);
|
|
96
|
+
}
|
|
97
|
+
return await response.text();
|
|
98
|
+
}
|
|
99
|
+
throw new Error(`unsupported package manifest URL protocol: ${url.protocol}`);
|
|
100
|
+
}
|
|
79
101
|
async function ensureCachedReleaseBinary(version) {
|
|
80
102
|
const target = releaseTarget();
|
|
81
103
|
const cacheDir = joinPath(cacheRoot(), version, target);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qlever-llc/trellis",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"description": "Client-side Trellis runtime, models, and contract helpers for TypeScript applications.",
|
|
5
5
|
"homepage": "https://github.com/Qlever-LLC/trellis#readme",
|
|
6
6
|
"repository": {
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"ts-deepmerge": "^7.0.3",
|
|
123
123
|
"typebox": "^1.0.15",
|
|
124
124
|
"ulid": "^3.0.1",
|
|
125
|
-
"@qlever-llc/result": "^0.10.
|
|
125
|
+
"@qlever-llc/result": "^0.10.4"
|
|
126
126
|
},
|
|
127
127
|
"devDependencies": {
|
|
128
128
|
"@types/node": "^20.9.0"
|
package/script/generate.js
CHANGED
|
@@ -10,6 +10,8 @@ const SUPPORTED_TARGETS = new Set([
|
|
|
10
10
|
"x86_64-apple-darwin",
|
|
11
11
|
"aarch64-apple-darwin",
|
|
12
12
|
]);
|
|
13
|
+
class ManifestNotFoundError extends Error {
|
|
14
|
+
}
|
|
13
15
|
async function main() {
|
|
14
16
|
const localRepoRoot = await findLocalTrellisRepoRoot();
|
|
15
17
|
if (localRepoRoot) {
|
|
@@ -31,6 +33,9 @@ function denoRuntime() {
|
|
|
31
33
|
return deno;
|
|
32
34
|
}
|
|
33
35
|
async function findLocalTrellisRepoRoot() {
|
|
36
|
+
if (new URL(globalThis[Symbol.for("import-meta-ponyfill-commonjs")](require, module).url).protocol !== "file:") {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
34
39
|
let current = urlDirname(globalThis[Symbol.for("import-meta-ponyfill-commonjs")](require, module).url);
|
|
35
40
|
while (current !== dirname(current)) {
|
|
36
41
|
if (await pathExists(joinPath(current, "rust/tools/generate/Cargo.toml")) &&
|
|
@@ -67,10 +72,11 @@ async function readFirstManifest(urls) {
|
|
|
67
72
|
const deno = denoRuntime();
|
|
68
73
|
for (const url of urls) {
|
|
69
74
|
try {
|
|
70
|
-
return JSON.parse(await
|
|
75
|
+
return JSON.parse(await readManifestText(url));
|
|
71
76
|
}
|
|
72
77
|
catch (error) {
|
|
73
|
-
if (error instanceof deno.errors.NotFound
|
|
78
|
+
if (error instanceof deno.errors.NotFound ||
|
|
79
|
+
error instanceof ManifestNotFoundError) {
|
|
74
80
|
continue;
|
|
75
81
|
}
|
|
76
82
|
throw error;
|
|
@@ -78,6 +84,22 @@ async function readFirstManifest(urls) {
|
|
|
78
84
|
}
|
|
79
85
|
throw new Error("@qlever-llc/trellis package manifest was not found");
|
|
80
86
|
}
|
|
87
|
+
async function readManifestText(url) {
|
|
88
|
+
if (url.protocol === "file:") {
|
|
89
|
+
return await denoRuntime().readTextFile(url);
|
|
90
|
+
}
|
|
91
|
+
if (url.protocol === "http:" || url.protocol === "https:") {
|
|
92
|
+
const response = await fetch(url);
|
|
93
|
+
if (response.status === 404) {
|
|
94
|
+
throw new ManifestNotFoundError(`package manifest was not found: ${url}`);
|
|
95
|
+
}
|
|
96
|
+
if (!response.ok) {
|
|
97
|
+
throw new Error(`failed to read ${url}: HTTP ${response.status}`);
|
|
98
|
+
}
|
|
99
|
+
return await response.text();
|
|
100
|
+
}
|
|
101
|
+
throw new Error(`unsupported package manifest URL protocol: ${url.protocol}`);
|
|
102
|
+
}
|
|
81
103
|
async function ensureCachedReleaseBinary(version) {
|
|
82
104
|
const target = releaseTarget();
|
|
83
105
|
const cacheDir = joinPath(cacheRoot(), version, target);
|
package/src/generate.ts
CHANGED
|
@@ -14,6 +14,8 @@ type PackageManifest = {
|
|
|
14
14
|
version?: unknown;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
class ManifestNotFoundError extends Error {}
|
|
18
|
+
|
|
17
19
|
type CommandStatus = {
|
|
18
20
|
success: boolean;
|
|
19
21
|
code: number;
|
|
@@ -45,6 +47,10 @@ function denoRuntime(): typeof dntShim.Deno {
|
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
async function findLocalTrellisRepoRoot(): Promise<string | undefined> {
|
|
50
|
+
if (new URL(import.meta.url).protocol !== "file:") {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
48
54
|
let current = urlDirname(import.meta.url);
|
|
49
55
|
while (current !== dirname(current)) {
|
|
50
56
|
if (
|
|
@@ -91,9 +97,12 @@ async function readFirstManifest(urls: URL[]): Promise<PackageManifest> {
|
|
|
91
97
|
const deno = denoRuntime();
|
|
92
98
|
for (const url of urls) {
|
|
93
99
|
try {
|
|
94
|
-
return JSON.parse(await
|
|
100
|
+
return JSON.parse(await readManifestText(url)) as PackageManifest;
|
|
95
101
|
} catch (error) {
|
|
96
|
-
if (
|
|
102
|
+
if (
|
|
103
|
+
error instanceof deno.errors.NotFound ||
|
|
104
|
+
error instanceof ManifestNotFoundError
|
|
105
|
+
) {
|
|
97
106
|
continue;
|
|
98
107
|
}
|
|
99
108
|
throw error;
|
|
@@ -102,6 +111,25 @@ async function readFirstManifest(urls: URL[]): Promise<PackageManifest> {
|
|
|
102
111
|
throw new Error("@qlever-llc/trellis package manifest was not found");
|
|
103
112
|
}
|
|
104
113
|
|
|
114
|
+
async function readManifestText(url: URL): Promise<string> {
|
|
115
|
+
if (url.protocol === "file:") {
|
|
116
|
+
return await denoRuntime().readTextFile(url);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (url.protocol === "http:" || url.protocol === "https:") {
|
|
120
|
+
const response = await fetch(url);
|
|
121
|
+
if (response.status === 404) {
|
|
122
|
+
throw new ManifestNotFoundError(`package manifest was not found: ${url}`);
|
|
123
|
+
}
|
|
124
|
+
if (!response.ok) {
|
|
125
|
+
throw new Error(`failed to read ${url}: HTTP ${response.status}`);
|
|
126
|
+
}
|
|
127
|
+
return await response.text();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
throw new Error(`unsupported package manifest URL protocol: ${url.protocol}`);
|
|
131
|
+
}
|
|
132
|
+
|
|
105
133
|
async function ensureCachedReleaseBinary(version: string): Promise<string> {
|
|
106
134
|
const target = releaseTarget();
|
|
107
135
|
const cacheDir = joinPath(cacheRoot(), version, target);
|