[ci] format
This commit is contained in:
parent
624595e353
commit
f27570d753
1 changed files with 82 additions and 70 deletions
|
@ -77,7 +77,7 @@ const VALID_PROJECT_DIRECTORY_SAFE_LIST = [
|
||||||
|
|
||||||
function isValidProjectDirectory(dirPath: string) {
|
function isValidProjectDirectory(dirPath: string) {
|
||||||
if (!fs.existsSync(dirPath)) {
|
if (!fs.existsSync(dirPath)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const conflicts = fs.readdirSync(dirPath).filter((content) => {
|
const conflicts = fs.readdirSync(dirPath).filter((content) => {
|
||||||
|
@ -93,14 +93,14 @@ const FILES_TO_REMOVE = ['.stackblitzrc', 'sandbox.config.json', 'CHANGELOG.md']
|
||||||
|
|
||||||
// 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.
|
// 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.
|
||||||
export async function main() {
|
export async function main() {
|
||||||
const pkgManager = detectPackageManager()?.name || 'npm';
|
const pkgManager = detectPackageManager()?.name || 'npm';
|
||||||
const [username, version] = await Promise.all([getName(), getVersion()]);
|
const [username, version] = await Promise.all([getName(), getVersion()]);
|
||||||
|
|
||||||
logger.debug('Verbose logging turned on');
|
logger.debug('Verbose logging turned on');
|
||||||
if (!args.skipHouston) {
|
if (!args.skipHouston) {
|
||||||
await say(
|
await say(
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
'Welcome',
|
'Welcome',
|
||||||
'to',
|
'to',
|
||||||
label('astro', color.bgGreen, color.black),
|
label('astro', color.bgGreen, color.black),
|
||||||
|
@ -213,26 +213,30 @@ export async function main() {
|
||||||
templateSpinner.text = green('Template copied!');
|
templateSpinner.text = green('Template copied!');
|
||||||
templateSpinner.succeed();
|
templateSpinner.succeed();
|
||||||
|
|
||||||
const install = args.y ? true : (await prompts(
|
const install = args.y
|
||||||
{
|
? true
|
||||||
type: 'confirm',
|
: (
|
||||||
name: 'install',
|
await prompts(
|
||||||
message: `Would you like to install ${pkgManager} dependencies? ${reset(
|
{
|
||||||
dim('(recommended)')
|
type: 'confirm',
|
||||||
)}`,
|
name: 'install',
|
||||||
initial: true,
|
message: `Would you like to install ${pkgManager} dependencies? ${reset(
|
||||||
},
|
dim('(recommended)')
|
||||||
{
|
)}`,
|
||||||
onCancel: () => {
|
initial: true,
|
||||||
ora().info(
|
},
|
||||||
dim(
|
{
|
||||||
'Operation cancelled. Your project folder has already been created, however no dependencies have been installed'
|
onCancel: () => {
|
||||||
)
|
ora().info(
|
||||||
);
|
dim(
|
||||||
process.exit(1);
|
'Operation cancelled. Your project folder has already been created, however no dependencies have been installed'
|
||||||
},
|
)
|
||||||
}
|
);
|
||||||
)).install;
|
process.exit(1);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
).install;
|
||||||
|
|
||||||
if (args.dryRun) {
|
if (args.dryRun) {
|
||||||
ora().info(dim(`--dry-run enabled, skipping.`));
|
ora().info(dim(`--dry-run enabled, skipping.`));
|
||||||
|
@ -255,22 +259,28 @@ export async function main() {
|
||||||
await info('No problem!', 'Remember to install dependencies after setup.');
|
await info('No problem!', 'Remember to install dependencies after setup.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const gitResponse = args.y ? true : (await prompts(
|
const gitResponse = args.y
|
||||||
{
|
? true
|
||||||
type: 'confirm',
|
: (
|
||||||
name: 'git',
|
await prompts(
|
||||||
message: `Would you like to initialize a new git repository? ${reset(dim('(optional)'))}`,
|
{
|
||||||
initial: true,
|
type: 'confirm',
|
||||||
},
|
name: 'git',
|
||||||
{
|
message: `Would you like to initialize a new git repository? ${reset(
|
||||||
onCancel: () => {
|
dim('(optional)')
|
||||||
ora().info(
|
)}`,
|
||||||
dim('Operation cancelled. No worries, your project folder has already been created')
|
initial: true,
|
||||||
);
|
},
|
||||||
process.exit(1);
|
{
|
||||||
},
|
onCancel: () => {
|
||||||
}
|
ora().info(
|
||||||
)).git;
|
dim('Operation cancelled. No worries, your project folder has already been created')
|
||||||
|
);
|
||||||
|
process.exit(1);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
).git;
|
||||||
|
|
||||||
if (args.dryRun) {
|
if (args.dryRun) {
|
||||||
ora().info(dim(`--dry-run enabled, skipping.`));
|
ora().info(dim(`--dry-run enabled, skipping.`));
|
||||||
|
@ -284,36 +294,38 @@ export async function main() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.y && !args.typescript) {
|
if (args.y && !args.typescript) {
|
||||||
ora().warn(
|
ora().warn(dim('--typescript <choice> missing. Defaulting to "strict"'));
|
||||||
dim('--typescript <choice> missing. Defaulting to "strict"')
|
args.typescript = 'strict';
|
||||||
);
|
}
|
||||||
args.typescript = 'strict';
|
|
||||||
}
|
|
||||||
|
|
||||||
const tsResponse = args.typescript || (await prompts(
|
const tsResponse =
|
||||||
{
|
args.typescript ||
|
||||||
type: 'select',
|
(
|
||||||
name: 'typescript',
|
await prompts(
|
||||||
message: 'How would you like to setup TypeScript?',
|
{
|
||||||
choices: [
|
type: 'select',
|
||||||
{ value: 'strict', title: 'Strict', description: '(recommended)' },
|
name: 'typescript',
|
||||||
{ value: 'strictest', title: 'Strictest' },
|
message: 'How would you like to setup TypeScript?',
|
||||||
{ value: 'base', title: 'Relaxed' },
|
choices: [
|
||||||
{ value: 'unsure', title: 'Help me choose' },
|
{ value: 'strict', title: 'Strict', description: '(recommended)' },
|
||||||
],
|
{ value: 'strictest', title: 'Strictest' },
|
||||||
},
|
{ value: 'base', title: 'Relaxed' },
|
||||||
{
|
{ value: 'unsure', title: 'Help me choose' },
|
||||||
onCancel: () => {
|
],
|
||||||
ora().info(
|
},
|
||||||
dim(
|
{
|
||||||
'Operation cancelled. Your project folder has been created but no TypeScript configuration file was created.'
|
onCancel: () => {
|
||||||
)
|
ora().info(
|
||||||
);
|
dim(
|
||||||
process.exit(1);
|
'Operation cancelled. Your project folder has been created but no TypeScript configuration file was created.'
|
||||||
},
|
)
|
||||||
}
|
);
|
||||||
)).typescript;
|
process.exit(1);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
).typescript;
|
||||||
|
|
||||||
if (tsResponse === 'unsure') {
|
if (tsResponse === 'unsure') {
|
||||||
await typescriptByDefault();
|
await typescriptByDefault();
|
||||||
|
|
Loading…
Reference in a new issue