2023-07-18 00:17:59 +00:00
|
|
|
import fs from 'node:fs/promises';
|
2023-03-01 08:46:06 +00:00
|
|
|
import { loremIpsum } from './_util.js';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {URL} projectDir
|
|
|
|
*/
|
|
|
|
export async function run(projectDir) {
|
|
|
|
await fs.rm(projectDir, { recursive: true, force: true });
|
|
|
|
await fs.mkdir(new URL('./src/pages', projectDir), { recursive: true });
|
2023-08-25 13:00:51 +00:00
|
|
|
await fs.mkdir(new URL('./src/components', projectDir), { recursive: true });
|
2023-03-01 08:46:06 +00:00
|
|
|
|
|
|
|
await fs.writeFile(
|
|
|
|
new URL('./src/pages/index.astro', projectDir),
|
|
|
|
`\
|
|
|
|
---
|
2023-08-25 13:00:51 +00:00
|
|
|
import Paragraph from '../components/Paragraph.astro'
|
2023-03-01 08:46:06 +00:00
|
|
|
const content = "${loremIpsum}"
|
|
|
|
---
|
|
|
|
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8" />
|
|
|
|
<meta name="viewport" content="width=device-width" />
|
|
|
|
<meta name="generator" content={Astro.generator} />
|
|
|
|
<title>Astro</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1>Astro</h1>
|
|
|
|
<div>
|
2023-08-25 13:02:36 +00:00
|
|
|
${Array.from({ length: 100 })
|
|
|
|
.map(() => '<p>{content}</p>')
|
|
|
|
.join('\n')}
|
2023-08-25 13:00:51 +00:00
|
|
|
</div>
|
|
|
|
<div>
|
2023-08-25 13:02:36 +00:00
|
|
|
${Array.from({ length: 50 })
|
|
|
|
.map((_, i) => '<Paragraph num={' + i + '} str={content} />')
|
|
|
|
.join('\n')}
|
2023-03-01 08:46:06 +00:00
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>`,
|
|
|
|
'utf-8'
|
|
|
|
);
|
|
|
|
|
2023-08-25 13:00:51 +00:00
|
|
|
await fs.writeFile(
|
|
|
|
new URL('./src/components/Paragraph.astro', projectDir),
|
|
|
|
`<div>{Astro.props.num} {Astro.props.str}</div>`,
|
|
|
|
'utf-8'
|
|
|
|
);
|
|
|
|
|
2023-03-01 08:46:06 +00:00
|
|
|
await fs.writeFile(
|
|
|
|
new URL('./astro.config.js', projectDir),
|
|
|
|
`\
|
|
|
|
import { defineConfig } from 'astro/config';
|
|
|
|
import nodejs from '@astrojs/node';
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
output: 'server',
|
|
|
|
adapter: nodejs({ mode: 'standalone' }),
|
|
|
|
});`,
|
|
|
|
'utf-8'
|
|
|
|
);
|
|
|
|
}
|