Skip to main content


The Full-stack Framework in Deno.
Very Popular
Go to Latest
import { gzipDecode } from ''import log from '../log.ts'import { colors, ensureDir, ensureFile, fromStreamReader, path, Untar } from '../std.ts'import util from '../util.ts'
const gitignore = [ '.DS_Store', 'Thumbs.db', '.aleph/', 'dist/',]
const vscExtensions = { 'recommendations': [ 'denoland.vscode-deno' ]}
const vscSettings = { 'files.eol': '\n', 'files.trimTrailingWhitespace': true, 'files.exclude': { '**/.git': true, '**/.DS_Store': true, '**/Thumbs.db': true, '**/.aleph': true }, 'deno.enable': true, 'deno.unstable': true, 'deno.import_map': './import_map.json'}
export const helpMessage = `Usage: aleph init <dir> [...options]
<dir> represents the directory of Aleph.js app,if the <dir> is empty, the current directory will be used.
Options: -h, --help Prints help message`
export default async function (appDir: string, options: Record<string, string | boolean>) { const rev = 'master''Downloading template...') const resp = await fetch('' + rev) const gzData = await Deno.readAll(fromStreamReader(resp.body!.getReader()))'Saving template...') const tarData = gzipDecode(gzData) const entryList = new Untar(new Deno.Buffer(tarData))
// todo: add template select ui let template = 'hello-world' for await (const entry of entryList) { if (entry.fileName.startsWith(`alephjs-templates-${rev}/${template}/`)) { const fp = path.join(appDir, util.trimPrefix(entry.fileName, `alephjs-templates-${rev}/${template}/`)) if (entry.type === 'directory') { await ensureDir(fp) continue } await ensureFile(fp) const file = await, { write: true }) await Deno.copy(entry, file) } }
await ensureDir(path.join(appDir, '.vscode')) await Deno.writeTextFile(path.join(appDir, '.vscode', 'extensions.json'), JSON.stringify(vscExtensions, undefined, 4)) await Deno.writeTextFile(path.join(appDir, '.vscode', 'settings.json'), JSON.stringify(vscSettings, undefined, 4)) await Deno.writeTextFile(path.join(appDir, '.gitignore'), gitignore.join('\n')) await Deno.writeTextFile(path.join(appDir, 'import_map.json'), JSON.stringify({ imports: {} }, undefined, 4))'Done')'---')'Aleph.js is ready to Go.'))`${colors.dim('$')} cd ` + path.basename(appDir))`${colors.dim('$')} aleph ${colors.bold('dev')} ${colors.dim('# start the app in `development` mode')}`)`${colors.dim('$')} aleph ${colors.bold('start')} ${colors.dim('# start the app in `production` mode')}`)`${colors.dim('$')} aleph ${colors.bold('build')} ${colors.dim('# build the app to a static site (SSG)')}`)'---') Deno.exit(0)}