-
Notifications
You must be signed in to change notification settings - Fork 5
/
update-imports.ts
executable file
·56 lines (49 loc) · 1.71 KB
/
update-imports.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
#!/usr/bin/env -S deno run --allow-run --allow-read --allow-write
// delete the imports directory
await Deno.remove("imports", { recursive: true });
// run "cdk8s import k8s --language=typescript"
let command = new Deno.Command("cdk8s", {
args: ["import", "k8s", "--language=typescript"],
});
console.log(new TextDecoder().decode((await command.output()).stdout));
// run "kubectl get crds -o json | cdk8s import /dev/stdin --language=typescript"
command = new Deno.Command("bash", {
args: [
"-c",
"kubectl get crds -o json | cdk8s import /dev/stdin --language=typescript",
],
});
console.log(new TextDecoder().decode((await command.output()).stdout));
const files = Deno.readDir("imports");
// add "// deno-lint-ignore-file" to the top of each file in the imports directory
for await (const file of files) {
if (file.isFile) {
const filePath = `imports/${file.name}`;
const content = await Deno.readTextFile(filePath);
await Deno.writeTextFile(
filePath,
`// deno-lint-ignore-file\n${content}`,
);
}
}
// look for "public toJson(): any {", change this to "public override toJson(): any {"
// fixes This member must have an 'override' modifier because it overrides a member in the base class 'ApiObject'.
for await (const file of files) {
if (file.isFile) {
const filePath = `imports/${file.name}`;
let content = await Deno.readTextFile(filePath);
content = content.replaceAll(
"public toJson(): any {",
"public override toJson(): any {",
);
await Deno.writeTextFile(
filePath,
content,
);
}
}
// run deno fmt
command = new Deno.Command("deno", {
args: ["fmt", "imports"],
});
console.log(new TextDecoder().decode((await command.output()).stdout));