mirror of
https://github.com/withastro/astro.git
synced 2025-01-20 22:12:38 -05:00
607303be19
* Upgrade @astrojs/cli-kit * Add tasks to context * Change steps to use tasks * Do tasks at end * Add changeset * Make labels more consistent Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> * Update .changeset/chatty-penguins-sin.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> --------- Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
79 lines
2 KiB
TypeScript
79 lines
2 KiB
TypeScript
import { getContext } from './actions/context.js';
|
|
|
|
import { dependencies } from './actions/dependencies.js';
|
|
import { git } from './actions/git.js';
|
|
import { help } from './actions/help.js';
|
|
import { intro } from './actions/intro.js';
|
|
import { next } from './actions/next-steps.js';
|
|
import { projectName } from './actions/project-name.js';
|
|
import { template } from './actions/template.js';
|
|
import { setupTypeScript, typescript } from './actions/typescript.js';
|
|
import { verify } from './actions/verify.js';
|
|
import { setStdout } from './messages.js';
|
|
import { tasks } from '@astrojs/cli-kit';
|
|
|
|
const exit = () => process.exit(0);
|
|
process.on('SIGINT', exit);
|
|
process.on('SIGTERM', exit);
|
|
|
|
// Please also update the installation instructions in the docs at
|
|
// https://github.com/withastro/docs/blob/main/src/pages/en/install/auto.md
|
|
// if you make any changes to the flow or wording here.
|
|
export async function main() {
|
|
// Add some extra spacing from the noisy npm/pnpm init output
|
|
// eslint-disable-next-line no-console
|
|
console.log('');
|
|
// NOTE: In the v7.x version of npm, the default behavior of `npm init` was changed
|
|
// to no longer require `--` to pass args and instead pass `--` directly to us. This
|
|
// broke our arg parser, since `--` is a special kind of flag. Filtering for `--` here
|
|
// fixes the issue so that create-astro now works on all npm versions.
|
|
const cleanArgv = process.argv.slice(2).filter((arg) => arg !== '--');
|
|
const ctx = await getContext(cleanArgv);
|
|
if (ctx.help) {
|
|
help();
|
|
return;
|
|
}
|
|
|
|
const steps = [
|
|
verify,
|
|
intro,
|
|
projectName,
|
|
template,
|
|
dependencies,
|
|
typescript,
|
|
|
|
// Steps which write to files need to go above git
|
|
git,
|
|
];
|
|
|
|
for (const step of steps) {
|
|
await step(ctx);
|
|
}
|
|
|
|
// eslint-disable-next-line no-console
|
|
console.log('');
|
|
|
|
const labels = {
|
|
start: 'Project initializing...',
|
|
end: 'Project initialized!',
|
|
};
|
|
await tasks(labels, ctx.tasks);
|
|
|
|
await next(ctx);
|
|
|
|
process.exit(0);
|
|
}
|
|
|
|
export {
|
|
dependencies,
|
|
getContext,
|
|
git,
|
|
intro,
|
|
next,
|
|
projectName,
|
|
setStdout,
|
|
setupTypeScript,
|
|
template,
|
|
typescript,
|
|
verify,
|
|
};
|