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

Commit d2039bd

Browse files
committed
refactor(cli): improve init command
1 parent 08391af commit d2039bd

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

cli/init.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { join } from 'https://deno.land/[email protected]/path/mod.ts'
55
import { gzipDecode } from 'https://deno.land/x/[email protected]/mod.ts'
66
import { ensureTextFile } from '../shared/fs.ts'
77
import util from '../shared/util.ts'
8+
import { defaultReactVersion } from '../shared/constants.ts'
89
import { VERSION } from '../version.ts'
910

1011
export const helpMessage = `
@@ -58,17 +59,17 @@ export default async function (nameArg?: string) {
5859
]
5960
const importMap = {
6061
imports: {
61-
'~/': './', '@/': './',
62+
'~/': './',
6263
'aleph': `https://deno.land/x/aleph@v${VERSION}/mod.ts`,
6364
'aleph/': `https://deno.land/x/aleph@v${VERSION}/`,
64-
'react': 'https://esm.sh/react@17.0.1',
65-
'react-dom': 'https://esm.sh/react-dom@17.0.1',
65+
'react': `https://esm.sh/react@${defaultReactVersion}`,
66+
'react-dom': `https://esm.sh/react-dom@${defaultReactVersion}`,
6667
},
6768
scopes: {}
6869
}
6970
await Promise.all([
7071
Deno.writeTextFile(join(cwd, name, '.gitignore'), gitignore.join('\n')),
71-
Deno.writeTextFile(join(cwd, name, 'import_map.json'), JSON.stringify(importMap, undefined, 4))
72+
Deno.writeTextFile(join(cwd, name, 'import_map.json'), JSON.stringify(importMap, undefined, 2))
7273
])
7374

7475
if (vscode) {
@@ -84,8 +85,8 @@ export default async function (nameArg?: string) {
8485
}
8586
await ensureDir(join(name, '.vscode'))
8687
await Promise.all([
87-
Deno.writeTextFile(join(name, '.vscode', 'extensions.json'), JSON.stringify(extensions, undefined, 4)),
88-
Deno.writeTextFile(join(name, '.vscode', 'settings.json'), JSON.stringify(settigns, undefined, 4))
88+
Deno.writeTextFile(join(name, '.vscode', 'extensions.json'), JSON.stringify(extensions, undefined, 2)),
89+
Deno.writeTextFile(join(name, '.vscode', 'settings.json'), JSON.stringify(settigns, undefined, 2))
8990
])
9091
}
9192

@@ -110,6 +111,6 @@ async function ask(question: string = ':', stdin = Deno.stdin, stdout = Deno.std
110111

111112
async function confirm(question: string = 'are you sure?') {
112113
let a: string
113-
while (!/^(y(es)?|no?)$/i.test(a = (await ask(question + ' [y/n]')).trim())) { }
114+
while (!/^(y(es)?|no?)$/i.test(a = (await ask(question + ' ' + dim('[y/n]'))).trim())) { }
114115
return a.charAt(0).toLowerCase() === 'y'
115116
}

0 commit comments

Comments
 (0)