generated from nestdotland/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.ts
59 lines (52 loc) · 1.56 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
import * as semver from "https://deno.land/x/semver@v1.0.0/mod.ts";
import { writeJson } from "https://x.nest.land/std@0.62.0/fs/mod.ts";
import { VERSION } from "https://github.com/denoland/deno_std/raw/main/version.ts";
const nestAPI = "https://x.nest.land/api/package/std";
const egg: any = await fetch(nestAPI)
.then((response) => response.json())
.then((data) => {
return data.packageUploadNames
.sort((v1: string, v2: string) => {
return semver.rcompare(v1.replace("std@", ""), v2.replace("std@", ""));
})[0]
.replace("std@", "");
});
console.log("nest.land: ", egg);
console.log("deno.land: ", VERSION);
const diff: number = semver.compare(egg, VERSION);
const config: object = {
"name": "std",
"description": "A decentralized mirror of Deno's Standard Modules",
"version": VERSION,
"entry": "./version.ts",
"stable": false,
"unlisted": true,
"fmt": false,
"repository": "https://github.com/nestdotland/std",
"ignore": ["./.git/**/*"],
"files": ["./**/*"],
};
if (diff === 0) {
// this ain't it chief!
console.log(`std@${egg} is already published`);
Deno.exit(0);
} else if (diff === 1) {
// wait, that's illegal!
console.error(
"\n\t[ERR]: I don't know how, but we are ahead of deno\n",
);
Deno.exit(1);
} else if (diff === -1) {
console.log("New version found!\nCreating config...");
await writeJson("egg.json", config, { spaces: 2 });
console.log(`Publishing std@${VERSION}...`);
Deno.run({
cmd: [
"eggs",
"publish",
"--no-check",
"--yes",
]
});
Deno.exit(0);
}