projectName() — astro Function Reference
Architecture documentation for the projectName() function in project-name.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD dfcc9a2d_0cef_59c9_1637_e2cf041cb1c2["projectName()"] 5e62c00c_3931_b38d_250d_e3ed87297fa7["project-name.ts"] dfcc9a2d_0cef_59c9_1637_e2cf041cb1c2 -->|defined in| 5e62c00c_3931_b38d_250d_e3ed87297fa7 f2449e0b_de03_10e2_7f57_53b44cbe293a["checkCwd()"] dfcc9a2d_0cef_59c9_1637_e2cf041cb1c2 -->|calls| f2449e0b_de03_10e2_7f57_53b44cbe293a style dfcc9a2d_0cef_59c9_1637_e2cf041cb1c2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/create-astro/src/actions/project-name.ts lines 8–63
export async function projectName(
ctx: Pick<Context, 'yes' | 'dryRun' | 'prompt' | 'projectName' | 'exit'> & { cwd?: string },
) {
await checkCwd(ctx.cwd);
if (!ctx.cwd || !isEmpty(ctx.cwd)) {
if (ctx.cwd && !isEmpty(ctx.cwd)) {
await info('Hmm...', `${color.reset(`"${ctx.cwd}"`)}${color.dim(` is not empty!`)}`);
}
if (ctx.yes) {
ctx.projectName = generateProjectName();
ctx.cwd = `./${ctx.projectName}`;
await info('dir', `Project created at ./${ctx.projectName}`);
return;
}
const { name } = await ctx.prompt({
name: 'name',
type: 'text',
label: title('dir'),
message: 'Where should we create your new project?',
initial: `./${generateProjectName()}`,
validate(value: string) {
if (!isEmpty(value)) {
return `Directory is not empty!`;
}
// Check for non-printable characters
if (value.match(/[^\x20-\x7E]/g) !== null)
return `Invalid non-printable character present!`;
return true;
},
});
ctx.cwd = name!.trim();
ctx.projectName = toValidName(name!);
if (ctx.dryRun) {
await info('--dry-run', 'Skipping project naming');
return;
}
} else {
let name = ctx.cwd;
if (name === '.' || name === './') {
const parts = process.cwd().split(path.sep);
name = parts[parts.length - 1];
} else if (name.startsWith('./') || name.startsWith('../')) {
const parts = name.split('/');
name = parts[parts.length - 1];
}
ctx.projectName = toValidName(name);
}
if (!ctx.cwd) {
ctx.exit(1);
}
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does projectName() do?
projectName() is a function in the astro codebase, defined in packages/create-astro/src/actions/project-name.ts.
Where is projectName() defined?
projectName() is defined in packages/create-astro/src/actions/project-name.ts at line 8.
What does projectName() call?
projectName() calls 1 function(s): checkCwd.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free