create-aphex 0.3.1 → 0.3.2
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 +5 -3
- package/dist/index.js +29 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,13 +13,15 @@ npm create aphex my-app
|
|
|
13
13
|
npx create-aphex my-app
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
CLI, which shells out to this package:
|
|
16
|
+
Pick a template with `--template`:
|
|
18
17
|
|
|
19
18
|
```bash
|
|
20
|
-
|
|
19
|
+
npm create aphex@latest my-site --template website
|
|
21
20
|
```
|
|
22
21
|
|
|
22
|
+
`base` (the default) is a minimal starter; `website` is a working marketing site
|
|
23
|
+
with a page builder, blog, forms and SEO.
|
|
24
|
+
|
|
23
25
|
## What it does
|
|
24
26
|
|
|
25
27
|
1. Prompts for a project name (or takes the positional argument).
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,8 @@ import pc from 'picocolors';
|
|
|
6
6
|
import { downloadTemplate } from 'giget';
|
|
7
7
|
import { parseArgs, templates } from './options.js';
|
|
8
8
|
import { withGeneratedAuthSecret } from './env.js';
|
|
9
|
+
/** Shown as the prompt's placeholder and used when the answer is left empty. */
|
|
10
|
+
const DEFAULT_PROJECT_NAME = 'my-aphex-project';
|
|
9
11
|
async function main() {
|
|
10
12
|
const cliOptions = parseArgs(process.argv.slice(2));
|
|
11
13
|
if (cliOptions.help) {
|
|
@@ -22,8 +24,16 @@ async function main() {
|
|
|
22
24
|
const projectName = cliOptions.projectName ??
|
|
23
25
|
(await p.text({
|
|
24
26
|
message: 'What is your project name?',
|
|
25
|
-
placeholder:
|
|
26
|
-
|
|
27
|
+
placeholder: DEFAULT_PROJECT_NAME,
|
|
28
|
+
// `placeholder` only greys out a hint; `defaultValue` is what an empty
|
|
29
|
+
// submit actually resolves to. Both, or pressing enter on the suggestion
|
|
30
|
+
// the prompt just showed you is an error.
|
|
31
|
+
defaultValue: DEFAULT_PROJECT_NAME,
|
|
32
|
+
// And `defaultValue` alone isn't enough: clack validates on enter and only
|
|
33
|
+
// substitutes the default afterwards, so a validator that rejects "" fires
|
|
34
|
+
// first and the default is never reached. Let empty through here — the
|
|
35
|
+
// substituted value is checked below, along with the `--` argument path.
|
|
36
|
+
validate: (value) => (value ? validateProjectName(value) : undefined)
|
|
27
37
|
}));
|
|
28
38
|
if (p.isCancel(projectName)) {
|
|
29
39
|
p.cancel('Operation cancelled');
|
|
@@ -92,8 +102,24 @@ async function main() {
|
|
|
92
102
|
writeFileSync(envPath, withGeneratedAuthSecret(readFileSync(envExamplePath, 'utf-8')));
|
|
93
103
|
}
|
|
94
104
|
spinner.stop('Project created successfully!');
|
|
95
|
-
const nextSteps = [
|
|
105
|
+
const nextSteps = [
|
|
106
|
+
`cd ${options.projectName}`,
|
|
107
|
+
'pnpm install',
|
|
108
|
+
'pnpm dev',
|
|
109
|
+
'',
|
|
110
|
+
pc.dim('Then open http://localhost:5173/admin — the first account you'),
|
|
111
|
+
pc.dim('create becomes the super admin.')
|
|
112
|
+
];
|
|
96
113
|
p.note(nextSteps.join('\n'), 'Next steps');
|
|
114
|
+
// The one thing that silently breaks a fresh project. `.env` pins AUTH_URL to
|
|
115
|
+
// port 5173, but Vite moves to 5174 when 5173 is taken — and Better Auth
|
|
116
|
+
// declines any request whose origin doesn't match, as a bare 404 from
|
|
117
|
+
// /api/auth/* with nothing in the log. The symptom is "sign-up does nothing",
|
|
118
|
+
// which is unguessable if you haven't been told. Cheap to say here; expensive
|
|
119
|
+
// to discover.
|
|
120
|
+
p.log.warn(`${pc.bold('If Vite starts on a port other than 5173')} (because it was taken), update\n` +
|
|
121
|
+
`${pc.cyan('AUTH_URL')} and ${pc.cyan('AUTH_TRUSTED_ORIGINS')} in ${pc.cyan('.env')} to match, or sign-in\n` +
|
|
122
|
+
`fails with a bare 404. Same when you deploy: set them to your real URL.`);
|
|
97
123
|
p.outro(pc.green('Your Aphex CMS project is ready! Check out the README.md for more information.'));
|
|
98
124
|
}
|
|
99
125
|
catch (error) {
|