Skip to content

Commit

Permalink
allow to customize the Lume version to use
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Jun 4, 2024
1 parent 6aaa360 commit f42ebca
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export interface InitConfig {
plugins?: string[];
mode?: string;
cms?: boolean;
version?: string;
}

/** Class to manage the initialization */
Expand Down
6 changes: 4 additions & 2 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand All @@ -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),
Expand Down
10 changes: 7 additions & 3 deletions steps/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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");

Expand Down
19 changes: 17 additions & 2 deletions upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit f42ebca

Please sign in to comment.