Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 403c5b7

Browse files
committed
Update aleph version in import only in prod mode
1 parent 6f0c611 commit 403c5b7

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

cli.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const commands = {
1212
'dev': 'Start the app in development mode',
1313
'start': 'Start the app in production mode',
1414
'build': 'Build the app to a static site (SSG)',
15-
'analyze': 'Analyze the app deps',
1615
'upgrade': 'Upgrade Aleph.js command'
1716
}
1817

@@ -98,19 +97,21 @@ async function main() {
9897
const importMap = await loadImportMap(importMapFile)
9998
let updateImportMaps: boolean | null = null
10099
let verison = VERSION
101-
for (const key in importMap.imports) {
102-
const url = importMap.imports[key]
103-
if (/\/\/deno\.land\/x\/aleph@v?\d+\.\d+\.\d+(-[a-z0-9\.]+)?\//.test(url)) {
104-
const [prefix, rest] = util.splitBy(url, '@')
105-
const [ver, suffix] = util.splitBy(rest, '/')
106-
if (ver !== 'v' + VERSION && updateImportMaps === null) {
107-
updateImportMaps = confirm(`You are using a different version of Aleph.js, expect ${ver} -> v${bold(VERSION)}, update '${basename(importMapFile)}'?`)
108-
if (!updateImportMaps) {
109-
verison = ver.slice(1)
100+
if (command === 'dev') {
101+
for (const key in importMap.imports) {
102+
const url = importMap.imports[key]
103+
if (/\/\/deno\.land\/x\/aleph@v?\d+\.\d+\.\d+(-[a-z0-9\.]+)?\//.test(url)) {
104+
const [prefix, rest] = util.splitBy(url, '@')
105+
const [ver, suffix] = util.splitBy(rest, '/')
106+
if (ver !== 'v' + VERSION && updateImportMaps === null) {
107+
updateImportMaps = confirm(`You are using a different version of Aleph.js, expect ${ver} -> v${bold(VERSION)}, update '${basename(importMapFile)}'?`)
108+
if (!updateImportMaps) {
109+
verison = ver.slice(1)
110+
}
111+
}
112+
if (updateImportMaps) {
113+
importMap.imports[key] = `${prefix}@v${VERSION}/${suffix}`
110114
}
111-
}
112-
if (updateImportMaps) {
113-
importMap.imports[key] = `${prefix}@v${VERSION}/${suffix}`
114115
}
115116
}
116117
}

0 commit comments

Comments
 (0)