Skip to content

Commit

Permalink
improve upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Sep 8, 2024
1 parent 068090e commit 667d35a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ 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.7] - 2024-09-08
### Fixed
- Keep existing imports after upgrading Lume with an external import map file.
- Don't override lume tasks after upgrading.

## [0.2.6] - 2024-08-30
### Changed
- Upgrade Deno minimum version to `1.46`.
Expand Down Expand Up @@ -108,6 +113,7 @@ First version
[#1]: https://github.com/lumeland/init/issues/1
[#3]: https://github.com/lumeland/init/issues/3

[0.2.7]: https://github.com/lumeland/init/compare/v0.2.6...v0.2.7
[0.2.6]: https://github.com/lumeland/init/compare/v0.2.5...v0.2.6
[0.2.5]: https://github.com/lumeland/init/compare/v0.2.4...v0.2.5
[0.2.4]: https://github.com/lumeland/init/compare/v0.2.3...v0.2.4
Expand Down
7 changes: 4 additions & 3 deletions steps/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ function configureLume(deno: DenoConfig, version: string) {

// Configure lume tasks
deno.tasks ??= {};
deno.tasks.lume = `echo "import 'lume/cli.ts'" | deno run -A -`;
deno.tasks.build = "deno task lume";
deno.tasks.serve = "deno task lume -s";
deno.tasks.lume ??= `echo "import 'lume/cli.ts'" | deno run -A -`;
deno.tasks.lume.replace(" --unstable ", " "); // Remove --unstable flag
deno.tasks.build ??= "deno task lume";
deno.tasks.serve ??= "deno task lume -s";

// Configure the compiler options
deno.compilerOptions ??= {};
Expand Down
12 changes: 8 additions & 4 deletions steps/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ async function saveDenoConfig(
let changed = false;

if (deno.importMap) {
const importMap = { imports: deno.imports, scopes: deno.scopes };
const existingContent = await Deno.readTextFile(deno.importMap);
const newContent = JSON.stringify(importMap, null, 2) + "\n";
const mapText = await Deno.readTextFile(deno.importMap);
const map = JSON.parse(mapText);
Object.assign(map.imports, deno.imports);
if (deno.scopes) {
Object.assign(map.scopes, deno.scopes);
}
const newContent = JSON.stringify(map, null, 2) + "\n";

if (existingContent.trim() !== newContent.trim()) {
if (mapText.trim() !== newContent.trim()) {
changed = true;
}

Expand Down

0 comments on commit 667d35a

Please sign in to comment.