-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathupdate.ts
executable file
·108 lines (96 loc) · 2.54 KB
/
update.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/env -S ghjk deno run -A --config=typegate/deno.jsonc
// Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0.
// SPDX-License-Identifier: MPL-2.0
import {
$,
expandGlobSync,
parseArgs,
resolve,
udd,
} from "./deps.ts";
import { projectDir, runOrExit } from "./utils.ts";
const denoConfigPath = resolve(projectDir, "src/typegate/deno.jsonc");
const devConfigPath = resolve(projectDir, "tools/deps.ts");
const flags = parseArgs(Deno.args, {
boolean: ["outdated", "upgrade", "cache-only", "src-only"],
default: {
outdated: false,
upgrade: false,
"cache-only": false,
"src-only": false,
},
});
if (flags.outdated || flags.upgrade) {
for await (const configPath of [denoConfigPath, devConfigPath]) {
console.log(
`Checking for updates for ${$.path(projectDir).relative(configPath)}:`,
);
const deps = await udd(configPath, { dryRun: flags.outdated });
console.log();
const depCats = Object.groupBy(deps, (d) => String(d.success));
if (depCats["undefined"]) {
console.log("No upgrade available:");
for (const dep of depCats["undefined"]) {
console.log(`- ${dep.initUrl}: ${dep.initVersion}`);
}
}
if (depCats["true"]) {
console.log("Auto-upgrade available:");
for (const dep of depCats["true"]) {
console.log(
`- ${dep.initUrl}: ${dep.initVersion} → ${dep.message}`,
);
}
}
if (depCats["false"]) {
console.log("Unable to upgrade:");
for (const dep of depCats["false"]) {
console.log(
`- ${dep.initUrl}: ${dep.initVersion} → ${dep.message}`,
);
}
}
}
}
const tsFiles = [
...expandGlobSync(
`src/typegate/src/**/*.ts`,
{
root: projectDir,
globstar: true,
},
),
...flags["src-only"] ? [] : expandGlobSync(
`tests/**/*.ts`,
{
root: projectDir,
globstar: true,
exclude: [
"tests/e2e/nextjs/apollo",
"tests/runtimes/temporal/worker",
],
},
),
].map((f: any) => f.path);
await runOrExit([
Deno.execPath(),
"cache",
`--config=${denoConfigPath}`,
"--unstable-worker-options",
"--unstable-net",
...flags["cache-only"] ? [] : ["--reload", "--lock-write"],
...tsFiles,
], projectDir);
/* for (const file of tsFiles) {
const out = await $`deno info
--config=${denoConfigPath}
--unstable-worker-options
--unstable-net
${file}`
.cwd(projectDir)
.missing("stdout");
if (/missing/.test(out)) {
console.log(file);
break;
}
} */