@red-glare/create 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +122 -0
- package/dist/index.js.map +1 -0
- package/package.json +36 -0
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# @red-glare/create
|
|
2
|
+
|
|
3
|
+
> CLI scaffolder for [Red Glare](https://github.com/red-glare/red-glare) USWDS documentation sites.
|
|
4
|
+
|
|
5
|
+
Bootstraps a new Astro project pre-wired with `@red-glare/astro`, USWDS styles, Preact for interactive islands, and a minimal docs starter.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm create @red-glare my-agency-docs
|
|
11
|
+
# or
|
|
12
|
+
npm create @red-glare my-agency-docs
|
|
13
|
+
# or
|
|
14
|
+
yarn create @red-glare my-agency-docs
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Then:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
cd my-agency-docs
|
|
21
|
+
pnpm install
|
|
22
|
+
pnpm dev
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
See the [main README](https://github.com/red-glare/red-glare#readme) for what `@red-glare/astro` ships and how to configure it.
|
|
26
|
+
|
|
27
|
+
## License
|
|
28
|
+
|
|
29
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { join, resolve } from 'node:path';
|
|
4
|
+
import process from 'node:process';
|
|
5
|
+
import { parseArgs } from 'node:util';
|
|
6
|
+
async function main() {
|
|
7
|
+
const { positionals } = parseArgs({ allowPositionals: true });
|
|
8
|
+
const projectName = positionals[0];
|
|
9
|
+
if (!projectName) {
|
|
10
|
+
// eslint-disable-next-line no-console
|
|
11
|
+
console.log('Usage: pnpm create @red-glare <project-name>\n\nExample:\n pnpm create @red-glare my-agency-docs');
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const projectDir = resolve(process.cwd(), projectName);
|
|
15
|
+
// eslint-disable-next-line no-console
|
|
16
|
+
console.log(`\nCreating Red Glare project in ${projectDir}...\n`);
|
|
17
|
+
await mkdir(join(projectDir, 'src/content/docs'), { recursive: true });
|
|
18
|
+
await mkdir(join(projectDir, 'src/styles'), { recursive: true });
|
|
19
|
+
await mkdir(join(projectDir, 'public'), { recursive: true });
|
|
20
|
+
// `@astrojs/preact` + `preact` ship alongside `@red-glare/astro`
|
|
21
|
+
// because Astro's renderer resolver looks up the integration's server
|
|
22
|
+
// entry point from the project cwd, not from the transitive dep
|
|
23
|
+
// graph. Omitting them here would leave a scaffolded project unable
|
|
24
|
+
// to hydrate its tab / code-group islands.
|
|
25
|
+
await writeFile(join(projectDir, 'package.json'), `${JSON.stringify({
|
|
26
|
+
name: projectName,
|
|
27
|
+
version: '0.0.1',
|
|
28
|
+
private: true,
|
|
29
|
+
type: 'module',
|
|
30
|
+
scripts: {
|
|
31
|
+
dev: 'astro dev',
|
|
32
|
+
build: 'astro build',
|
|
33
|
+
preview: 'astro preview',
|
|
34
|
+
},
|
|
35
|
+
dependencies: {
|
|
36
|
+
'@astrojs/preact': '^5.1.1',
|
|
37
|
+
'@red-glare/astro': '^0.0.1',
|
|
38
|
+
'astro': '^6.0.0',
|
|
39
|
+
'preact': '^10.29.1',
|
|
40
|
+
},
|
|
41
|
+
}, null, 2)}\n`);
|
|
42
|
+
await writeFile(join(projectDir, 'astro.config.mjs'), `import { defineConfig } from 'astro/config'
|
|
43
|
+
import redGlare from '@red-glare/astro'
|
|
44
|
+
|
|
45
|
+
export default defineConfig({
|
|
46
|
+
integrations: [
|
|
47
|
+
redGlare({
|
|
48
|
+
title: '${projectName}',
|
|
49
|
+
description: 'Documentation site powered by Red Glare',
|
|
50
|
+
governmentBanner: true,
|
|
51
|
+
}),
|
|
52
|
+
],
|
|
53
|
+
})
|
|
54
|
+
`);
|
|
55
|
+
await writeFile(join(projectDir, 'src/content.config.ts'), `import { defineCollection } from 'astro:content'
|
|
56
|
+
import { docsLoader, docsSchema } from '@red-glare/astro/schema'
|
|
57
|
+
|
|
58
|
+
const docs = defineCollection({
|
|
59
|
+
loader: docsLoader(),
|
|
60
|
+
schema: docsSchema,
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
export const collections = { docs }
|
|
64
|
+
`);
|
|
65
|
+
await writeFile(join(projectDir, 'src/content/docs/index.md'), `---
|
|
66
|
+
title: Welcome
|
|
67
|
+
description: Getting started with your documentation site.
|
|
68
|
+
template: splash
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
Welcome to your new documentation site, powered by [Red Glare](https://github.com/red-glare).
|
|
72
|
+
|
|
73
|
+
## Getting Started
|
|
74
|
+
|
|
75
|
+
Edit this file at \`src/content/docs/index.md\` to get started.
|
|
76
|
+
|
|
77
|
+
Add new pages by creating markdown files in \`src/content/docs/\`.
|
|
78
|
+
`);
|
|
79
|
+
await writeFile(join(projectDir, 'src/content/docs/getting-started.md'), `---
|
|
80
|
+
title: Getting Started
|
|
81
|
+
description: How to set up and use this documentation site.
|
|
82
|
+
sidebar:
|
|
83
|
+
order: 1
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Installation
|
|
87
|
+
|
|
88
|
+
Your documentation site is already set up and ready to go.
|
|
89
|
+
|
|
90
|
+
## Adding Pages
|
|
91
|
+
|
|
92
|
+
Create new \`.md\` files in \`src/content/docs/\` and they will automatically appear in the sidebar.
|
|
93
|
+
|
|
94
|
+
## Frontmatter
|
|
95
|
+
|
|
96
|
+
Each page supports frontmatter for metadata:
|
|
97
|
+
|
|
98
|
+
\`\`\`yaml
|
|
99
|
+
---
|
|
100
|
+
title: Page Title
|
|
101
|
+
description: Brief description
|
|
102
|
+
sidebar:
|
|
103
|
+
label: Custom Label
|
|
104
|
+
order: 1
|
|
105
|
+
toc: true
|
|
106
|
+
---
|
|
107
|
+
\`\`\`
|
|
108
|
+
`);
|
|
109
|
+
await writeFile(join(projectDir, 'tsconfig.json'), `${JSON.stringify({
|
|
110
|
+
extends: 'astro/tsconfigs/strict',
|
|
111
|
+
compilerOptions: {
|
|
112
|
+
types: ['node'],
|
|
113
|
+
},
|
|
114
|
+
}, null, 2)}\n`);
|
|
115
|
+
// eslint-disable-next-line no-console
|
|
116
|
+
console.log(`Done! Next steps:\n\n cd ${projectName}\n pnpm install\n pnpm dev\n`);
|
|
117
|
+
}
|
|
118
|
+
main().catch((err) => {
|
|
119
|
+
console.error(err);
|
|
120
|
+
process.exit(1);
|
|
121
|
+
});
|
|
122
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,KAAK,UAAU,IAAI;IACjB,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAA;IAC7D,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;IAElC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,mGAAmG,CAAC,CAAA;QAChH,OAAO,CAAC,IAAI,CAAC,CAAC,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;;;;CASH,CACE,CAAA;IAED,MAAM,SAAS,CACb,IAAI,CAAC,UAAU,EAAE,2BAA2B,CAAC,EAC7C;;;;;;;;;;;;;CAaH,CACE,CAAA;IAED,MAAM,SAAS,CACb,IAAI,CAAC,UAAU,EAAE,qCAAqC,CAAC,EACvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BH,CACE,CAAA;IAED,MAAM,SAAS,CACb,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,EACjC,GAAG,IAAI,CAAC,SAAS,CACf;QACE,OAAO,EAAE,wBAAwB;QACjC,eAAe,EAAE;YACf,KAAK,EAAE,CAAC,MAAM,CAAC;SAChB;KACF,EACD,IAAI,EACJ,CAAC,CACF,IAAI,CACN,CAAA;IAED,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,6BAA6B,WAAW,gCAAgC,CAAC,CAAA;AACvF,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@red-glare/create",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"description": "CLI scaffolder for Red Glare documentation sites",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/red-glare/red-glare",
|
|
10
|
+
"directory": "packages/create"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"create",
|
|
14
|
+
"scaffold",
|
|
15
|
+
"uswds",
|
|
16
|
+
"astro",
|
|
17
|
+
"documentation",
|
|
18
|
+
"federal",
|
|
19
|
+
"government"
|
|
20
|
+
],
|
|
21
|
+
"bin": {
|
|
22
|
+
"red-glare": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^22.0.0",
|
|
29
|
+
"typescript": "^5.9.3"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"dev": "tsc --watch",
|
|
34
|
+
"typecheck": "tsc --noEmit"
|
|
35
|
+
}
|
|
36
|
+
}
|