From f42ebca2afb1db3c4212120fc027f7f86970a1cb Mon Sep 17 00:00:00 2001 From: Oscar Otero Date: Tue, 4 Jun 2024 15:03:20 +0200 Subject: [PATCH] allow to customize the Lume version to use --- CHANGELOG.md | 5 +++++ init.ts | 1 + mod.ts | 6 ++++-- steps/start.ts | 10 +++++++--- upgrade.ts | 19 +++++++++++++++++-- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4b6e14..fa3f8a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/) and this project adheres to [Semantic Versioning](https://semver.org/). +## [0.2.2] - 2024-06-04 +### Added +- New `--version | -v` argument to `init` and `upgrade`. + ## [0.2.1] - 2024-06-03 ### Fixed - Don't ask for mode if `--plugins` or `--theme` is passed. @@ -85,6 +89,7 @@ First version [#1]: https://github.com/lumeland/init/issues/1 [#3]: https://github.com/lumeland/init/issues/3 +[0.2.2]: https://github.com/lumeland/init/compare/v0.2.1...v0.2.2 [0.2.1]: https://github.com/lumeland/init/compare/v0.2.0...v0.2.1 [0.2.0]: https://github.com/lumeland/init/compare/v0.1.12...v0.2.0 [0.1.12]: https://github.com/lumeland/init/compare/v0.1.11...v0.1.12 diff --git a/init.ts b/init.ts index e0e326d..3f3a638 100644 --- a/init.ts +++ b/init.ts @@ -71,6 +71,7 @@ export interface InitConfig { plugins?: string[]; mode?: string; cms?: boolean; + version?: string; } /** Class to manage the initialization */ diff --git a/mod.ts b/mod.ts index 52cd13a..799e2d2 100644 --- a/mod.ts +++ b/mod.ts @@ -26,9 +26,9 @@ export default function init(initConfig: InitConfig) { export function run(args: string[] = Deno.args) { const parsed = parseArgs(args, { - string: ["src", "theme", "plugins"], + string: ["src", "theme", "plugins", "version"], boolean: ["dev", "help", "no-cms", "cms"], - alias: { dev: "d", help: "h" }, + alias: { dev: "d", help: "h", version: "v" }, }); if (parsed.help) { @@ -39,6 +39,7 @@ export function run(args: string[] = Deno.args) { Options: -h, --help Show this help -d, --dev Use the development version + -v, --version The version of Lume to install --src The source directory --theme The theme to install --plugins The plugins to install @@ -51,6 +52,7 @@ export function run(args: string[] = Deno.args) { const process = init({ path: String(path), src: parsed.src, + version: parsed.version, theme: parsed.theme, dev: parsed.dev, cms: parsed.cms || (parsed["no-cms"] ? false : undefined), diff --git a/steps/start.ts b/steps/start.ts index 762d5ce..ca7343d 100644 --- a/steps/start.ts +++ b/steps/start.ts @@ -12,7 +12,9 @@ export default function () { } // Configure the import map - const version = dev + const version = config.version + ? config.version + : dev ? await getLatestGitHubCommit("lumeland/cms") : await getLatestVersion("lume"); @@ -48,12 +50,14 @@ export default function () { } export function updateLume() { - return async ({ deno, dev, lume }: Init) => { + return async ({ deno, dev, lume, config }: Init) => { if (!checkDenoVersion()) { return; } - const version = dev + const version = config.version + ? config.version + : dev ? await getLatestGitHubCommit("lumeland/lume") : await getLatestVersion("lume"); diff --git a/upgrade.ts b/upgrade.ts index 8eb2e09..5983308 100644 --- a/upgrade.ts +++ b/upgrade.ts @@ -20,14 +20,29 @@ export default function init(initConfig: InitConfig) { export function run(args: string[] = Deno.args) { const parsed = parseArgs(args, { - boolean: ["dev"], - alias: { dev: "d" }, + boolean: ["dev", "help"], + string: ["version"], + alias: { dev: "d", version: "v", help: "h" }, }); + if (parsed.help) { + console.log(` + Usage: + upgrade.ts [options] + + Options: + -h, --help Show this help + -d, --dev Use the development version + -v, --version The version of Lume to install +`); + Deno.exit(); + } + const path = parsed._[0] || "."; const process = init({ path: String(path), dev: parsed.dev, + version: parsed.version, }); process.run(); }