-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: auto update import map version
- Loading branch information
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const versionRegex = /version: "(.+?)"/gim; | ||
|
||
const configYaml = await Deno.readTextFile("/config.yaml"); | ||
|
||
const result = versionRegex.exec(configYaml); | ||
|
||
const version = result?.at?.(1); | ||
|
||
if (version) { | ||
const importMapText = await Deno.readTextFile( | ||
"/config/reactive-home/import_map.json" | ||
); | ||
|
||
let importMapJson: Record<string, any> = {}; | ||
|
||
try { | ||
importMapJson = JSON.parse(importMapText); | ||
} catch (e) { | ||
console.error("Failed to parse import map. Recreate import map.", e); | ||
} | ||
|
||
if (!importMapJson.imports) { | ||
importMapJson.imports = {}; | ||
} | ||
|
||
console.log(`Set reactivehome version to v${version}`); | ||
|
||
importMapJson.imports[ | ||
"reactive-home" | ||
] = `https://deno.land/x/reactivehome@v${version}/mod.ts`; | ||
|
||
await Deno.writeTextFile( | ||
"/config/reactive-home/import_map.json", | ||
JSON.stringify(importMapJson, null, 2) | ||
); | ||
} |