deno.land / x / ultra@v2.3.8 / tools / patch.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
109
110
111
112
113
114
import { walk } from "https://deno.land/std@0.176.0/fs/mod.ts";import { increment, parse as parseSemver, ReleaseType,} from "https://deno.land/std@0.176.0/semver/mod.ts";import { globToRegExp } from "https://deno.land/std@0.176.0/path/glob.ts";import { parse } from "https://deno.land/std@0.176.0/flags/mod.ts";import { assert } from "https://deno.land/std@0.176.0/_util/asserts.ts";
/** * This tool will update deno.land import strings in readme's and importMaps * to use the new version specified. * * It will also update the version.ts with the new version. */
export const DENOLAND_REGEX = /\/\/deno\.land\/x\/ultra@v[\w\.\-]+\//;
export const ULTRA_OUTPUT_REGEX = globToRegExp("examples/**/.ultra", { extended: true, globstar: true, caseInsensitive: false,});
export const IMPORT_MAP_REGEX = globToRegExp("examples/**/importMap.json", { extended: true, globstar: true, caseInsensitive: false,});
const parsedArgs = parse(Deno.args, { string: "release",});
const listFormatter = new Intl.ListFormat("default", { style: "short", type: "disjunction",});
async function patchFile(path: string, newVersion: string) { console.log(`Patching: ${path}`); const content = await Deno.readTextFile(path); await Deno.writeTextFile( path, content.replace(DENOLAND_REGEX, `//deno.land/x/ultra@v${newVersion}/`), );}
if (import.meta.main) { const releaseTypes = [ "pre", "major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease", ]; const release = parsedArgs.release;
assert(release !== undefined, "Must provide a release type."); assert( releaseTypes.includes(release), `Not a valid release type. Accepted values: ${ listFormatter.format(releaseTypes) }`, );
const { VERSION: currentVersion } = await import("../version.ts"); const parsedVersion = parseSemver(currentVersion, { includePrerelease: true, });
if (!parsedVersion) { throw new Error("Failed to parse current version as semver."); }
console.log(`Current version: ${parsedVersion.toString()}`); const nextVersion = increment(parsedVersion, release as ReleaseType, { includePrerelease: true, }, release === "pre" ? "beta" : undefined);
const version = prompt("Whats the new version?", nextVersion || undefined);
if (version) { await patchFile("./README.md", version); await patchFile("./lib/create/common/content/importMap.ts", version); await patchFile( "./examples/ultra-website/content/docs/create-project.mdx", version, );
for await ( const entry of walk("./", { match: [IMPORT_MAP_REGEX], skip: [ULTRA_OUTPUT_REGEX], }) ) { await patchFile(entry.path, version); }
/** * Set the new version */ console.log("Updating version.ts"); await Deno.writeTextFile( "./version.ts", `/* Do not set this manually, run tools/patch.ts if releasing a new version */\nexport const VERSION = "${version}";\n`, ); }}
ultra

Version Info

Tagged at
8 months ago