deno.land / x / lume@v2.1.4 / cli / upgrade.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
import { log } from "../core/utils/log.ts";import { getCurrentVersion, getLatestDevelopmentVersion, getLatestVersion,} from "../core/utils/lume_version.ts";import { readDenoConfig, updateLumeVersion, writeDenoConfig,} from "../core/utils/deno_config.ts";
interface Options { dev?: boolean; version?: string;}export default function ({ dev, version }: Options) { return upgrade(dev, version);}
/** Upgrade the Lume installation to the latest version */export async function upgrade(dev: boolean | string = false, version?: string) { const latest = version ? version : dev ? await getLatestDevelopmentVersion() : await getLatestVersion(); const url = getVersionUrl(latest, dev);
if (latest === getCurrentVersion()) { const message = version ? `You're already using this version of Lume:` : dev ? "You're using the latest version of Lume:" : "You're using the latest development version of Lume:";
log.info(`${message} <green>${latest}</green>`); return; }
log.info( version ? `Updating Lume to <green>${latest}</green>...` : `New version available. Updating Lume to <green>${latest}</green>...`, );
const denoConfig = await readDenoConfig();
if (!denoConfig) { throw new Error("No Deno config file found"); }
updateLumeVersion(url, denoConfig);
// Remove deno.lock file try { await Deno.remove("deno.lock"); } catch { // Ignore }
await writeDenoConfig(denoConfig);
log.info("Update successful!");
if (!dev) { log.info( `See the changes in <gray>https://github.com/lumeland/lume/blob/${latest}/CHANGELOG.md</gray>`, ); }}
function getVersionUrl(version: string, dev: boolean | string = false): URL { // Prepend automatically "v" to the version if it's missing if (!dev && !version.startsWith("v")) { version = `v${version}`; }
return new URL( dev ? `https://cdn.jsdelivr.net/gh/lumeland/lume@${version}/` : `https://deno.land/x/lume@${version}/`, );}
lume

Version Info

Tagged at
7 months ago