import './typeset/typeset-interface.ts';import './typeset/typeset-workflows.ts';
import { default as workers } from './mod.ts';import { default as snippet } from './snippet/index.ts';
const flag = await snippet.flag.resolve(Deno.args);const path = await (async () => { let path = flag['p'] as boolean | string | undefined;
if (typeof path != 'string' && path) { const repo = await snippet.repo.requestConfig(); if (repo && !repo.name.endsWith('github.io.git')) path = repo.name; }
if (typeof path != 'string') path = ''; return `/${path.replace(/[^a-zA-Z0-9-_]/g, '')}/`.replace(/\/\//g, '/'); })();
if ('v' in flag || 'version' in flag) { const plain = `reader 0.1.3-experimental`;
snippet.print.info(plain); Deno.exit();}
if ('h' in flag || 'help' in flag) { const plain = `Usage: reader [options]
Options: -v, --version output the version number -h, --help output usage information
-s, --stream start a local server for bundled assets -b, --bundle write bundled assets to the repository workflows -p use repository name as path namespace -f force file writes`;
snippet.print.info(plain); Deno.exit();}
const { source, output, hosted } = { source: { urn: snippet.path.resolve('./') }, output: { urn: 'bundle' in flag ? snippet.path.resolve('./.github/workflows-output') : await Deno.makeTempDir({ prefix: 'workflows-output-' }), }, hosted: { urn: 'bundle' in flag ? snippet.path.resolve('./.github/workflows-hosted') : await Deno.makeTempDir({ prefix: 'workflows-hosted-' }),
path: path, },};
if (!('f' in flag)) { snippet.print.info(`You are about to initialize a reader for the directories –
${snippet.print.bold(snippet.path.resolve())}`);
if ('bundle' in flag) snippet.print.info(`and write bundled assets to the directories –
${snippet.print.bold(output.urn)} ${snippet.print.bold(hosted.urn)}`);
if (!(await snippet.input.confirm(`Are you ready to proceed?`))) { snippet.print.fail('Aborted by user.'); Deno.exit(); }}
const { worker } = { worker: 's' in flag || 'stream' in flag ? workers.stream : workers.bundle };for await (const res of worker({ source, output, hosted })) snippet.print.info('Bundle completed!');