2023-02-06 16:19:37 +00:00
|
|
|
import { getContext } from './actions/context.js';
|
|
|
|
|
|
|
|
import { dependencies } from './actions/dependencies.js';
|
|
|
|
import { git } from './actions/git.js';
|
2023-02-06 16:21:48 +00:00
|
|
|
import { help } from './actions/help.js';
|
|
|
|
import { intro } from './actions/intro.js';
|
2023-02-06 16:19:37 +00:00
|
|
|
import { next } from './actions/next-steps.js';
|
2023-02-06 16:21:48 +00:00
|
|
|
import { projectName } from './actions/project-name.js';
|
|
|
|
import { template } from './actions/template.js';
|
|
|
|
import { setupTypeScript, typescript } from './actions/typescript.js';
|
|
|
|
import { setStdout } from './messages.js';
|
2023-02-06 16:19:37 +00:00
|
|
|
|
2023-02-06 16:21:48 +00:00
|
|
|
const exit = () => process.exit(0);
|
|
|
|
process.on('SIGINT', exit);
|
|
|
|
process.on('SIGTERM', exit);
|
2023-02-06 16:19:37 +00:00
|
|
|
|
|
|
|
// 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.
|
2021-06-08 15:10:56 +00:00
|
|
|
export async function main() {
|
2023-02-06 16:19:37 +00:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2023-02-21 16:48:06 +00:00
|
|
|
const steps = [
|
|
|
|
intro,
|
|
|
|
projectName,
|
|
|
|
template,
|
|
|
|
dependencies,
|
|
|
|
typescript,
|
|
|
|
|
|
|
|
// Steps which write to files need to go above git
|
2023-02-21 16:50:11 +00:00
|
|
|
git,
|
|
|
|
next,
|
2023-02-21 16:48:06 +00:00
|
|
|
];
|
2023-02-06 16:19:37 +00:00
|
|
|
|
|
|
|
for (const step of steps) {
|
2023-02-06 16:21:48 +00:00
|
|
|
await step(ctx);
|
2023-02-06 16:19:37 +00:00
|
|
|
}
|
|
|
|
process.exit(0);
|
2021-06-08 15:12:07 +00:00
|
|
|
}
|
2022-04-26 15:24:24 +00:00
|
|
|
|
2023-02-06 16:19:37 +00:00
|
|
|
export {
|
|
|
|
setStdout,
|
|
|
|
getContext,
|
|
|
|
intro,
|
|
|
|
projectName,
|
|
|
|
template,
|
|
|
|
dependencies,
|
|
|
|
git,
|
|
|
|
typescript,
|
|
|
|
setupTypeScript,
|
2023-02-06 16:21:48 +00:00
|
|
|
next,
|
|
|
|
};
|