1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/xcatliu-pagic

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
mod.ts 2.3 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
xcatliu Отправлено 14.10.2021 10:54 4ee4e39
#!/usr/bin/env -S deno --unstable --allow-read --allow-write --allow-net --allow-run
export { React, ReactDOM, ReactDOMServer } from './deps.ts';
export { t, Trans } from './src/plugins/i18n.tsx';
import { fs } from './deps.ts';
import { logger } from './src/utils/mod.ts';
import Pagic from './src/Pagic.ts';
export default Pagic;
export * from './src/Pagic.ts';
import { Command } from 'https://deno.land/x/cliffy@v0.19.6/command/mod.ts';
import { Select } from 'https://deno.land/x/cliffy@v0.19.6/prompt/select.ts';
import { Confirm } from 'https://deno.land/x/cliffy@v0.19.6/prompt/confirm.ts';
if (import.meta.main) {
const build = new Command()
.description('Build a static website')
.option('--watch [watch:boolean]', 'Watch file changes to rebuild')
.option('--serve [serve:boolean]', 'Start local service, preview static website')
.option('--port <port:number>', 'Specify the local port of the service')
.action((options: any) => {
const pagic = new Pagic(options);
pagic.build();
if (!options.watch && !options.serve) {
pagic.on('buildFinish', () => Deno.exit(0));
}
});
const init = new Command().description('Init pagic site/theme/plugin').action(async () => {
const mode: string = await Select.prompt({
message: 'Init current dir as a',
options: [
{ name: 'site', value: 'site' },
{ name: 'theme', value: 'theme' },
{ name: 'plugin', value: 'plugin' },
],
});
const pagic = new Pagic();
switch (mode) {
case 'site':
if (await fs.exists('pagic.config.ts')) {
logger.warn('pagic.config.ts already exists, exit');
return;
}
if (await fs.exists('pagic.config.tsx')) {
logger.warn('pagic.config.tsx already exists, exit');
return;
}
await Deno.writeTextFile('pagic.config.ts', 'export default {};\n');
break;
case 'theme':
if (await fs.exists('mod.ts')) {
const confirmed = await Confirm.prompt('mod.ts already exists, do you want to override it?');
if (!confirmed) {
return;
}
}
pagic.generateThemeMod();
break;
default:
logger.error(`Invalid mode ${mode}`);
}
});
await new Command().name('pagic').command('build', build).command('init', init).parse(Deno.args);
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/xcatliu-pagic.git
git@api.gitlife.ru:oschina-mirror/xcatliu-pagic.git
oschina-mirror
xcatliu-pagic
xcatliu-pagic
master