summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar natemoo-re <natemoo-re@users.noreply.github.com> 2023-01-20 14:54:53 +0000
committerGravatar fredkbot <fred+astrobot@astro.build> 2023-01-20 14:54:53 +0000
commitad13467a8481b3a25754ba368e05e243b04506f5 (patch)
treed82efcc7aca3c8be050e81c97c24ed4c040410dd
parentd8919b1a2197616b70ec57f0fb00b0bde6943e43 (diff)
downloadastro-ad13467a8481b3a25754ba368e05e243b04506f5.tar.gz
astro-ad13467a8481b3a25754ba368e05e243b04506f5.tar.zst
astro-ad13467a8481b3a25754ba368e05e243b04506f5.zip
[ci] format
Diffstat (limited to '')
-rw-r--r--packages/create-astro/src/index.ts154
1 files changed, 83 insertions, 71 deletions
diff --git a/packages/create-astro/src/index.ts b/packages/create-astro/src/index.ts
index 089fd4782..4a4008438 100644
--- a/packages/create-astro/src/index.ts
+++ b/packages/create-astro/src/index.ts
@@ -77,7 +77,7 @@ const VALID_PROJECT_DIRECTORY_SAFE_LIST = [
function isValidProjectDirectory(dirPath: string) {
if (!fs.existsSync(dirPath)) {
- return true;
+ return true;
}
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.
export async function main() {
- const pkgManager = detectPackageManager()?.name || 'npm';
+ const pkgManager = detectPackageManager()?.name || 'npm';
const [username, version] = await Promise.all([getName(), getVersion()]);
logger.debug('Verbose logging turned on');
if (!args.skipHouston) {
- await say(
- [
- [
+ await say(
+ [
+ [
'Welcome',
'to',
label('astro', color.bgGreen, color.black),
@@ -213,26 +213,30 @@ export async function main() {
templateSpinner.text = green('Template copied!');
templateSpinner.succeed();
- const install = args.y ? true : (await prompts(
- {
- type: 'confirm',
- name: 'install',
- message: `Would you like to install ${pkgManager} dependencies? ${reset(
- dim('(recommended)')
- )}`,
- initial: true,
- },
- {
- onCancel: () => {
- ora().info(
- dim(
- 'Operation cancelled. Your project folder has already been created, however no dependencies have been installed'
- )
- );
- process.exit(1);
- },
- }
- )).install;
+ const install = args.y
+ ? true
+ : (
+ await prompts(
+ {
+ type: 'confirm',
+ name: 'install',
+ message: `Would you like to install ${pkgManager} dependencies? ${reset(
+ dim('(recommended)')
+ )}`,
+ initial: true,
+ },
+ {
+ onCancel: () => {
+ ora().info(
+ dim(
+ 'Operation cancelled. Your project folder has already been created, however no dependencies have been installed'
+ )
+ );
+ process.exit(1);
+ },
+ }
+ )
+ ).install;
if (args.dryRun) {
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.');
}
- const gitResponse = args.y ? true : (await prompts(
- {
- type: 'confirm',
- name: 'git',
- message: `Would you like to initialize a new git repository? ${reset(dim('(optional)'))}`,
- initial: true,
- },
- {
- onCancel: () => {
- ora().info(
- dim('Operation cancelled. No worries, your project folder has already been created')
- );
- process.exit(1);
- },
- }
- )).git;
+ const gitResponse = args.y
+ ? true
+ : (
+ await prompts(
+ {
+ type: 'confirm',
+ name: 'git',
+ message: `Would you like to initialize a new git repository? ${reset(
+ dim('(optional)')
+ )}`,
+ initial: true,
+ },
+ {
+ onCancel: () => {
+ ora().info(
+ dim('Operation cancelled. No worries, your project folder has already been created')
+ );
+ process.exit(1);
+ },
+ }
+ )
+ ).git;
if (args.dryRun) {
ora().info(dim(`--dry-run enabled, skipping.`));
@@ -284,36 +294,38 @@ export async function main() {
);
}
- if (args.y && !args.typescript) {
- ora().warn(
- dim('--typescript <choice> missing. Defaulting to "strict"')
- );
- args.typescript = 'strict';
- }
-
- const tsResponse = args.typescript || (await prompts(
- {
- type: 'select',
- name: 'typescript',
- message: 'How would you like to setup TypeScript?',
- choices: [
- { 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.'
- )
- );
- process.exit(1);
- },
- }
- )).typescript;
+ if (args.y && !args.typescript) {
+ ora().warn(dim('--typescript <choice> missing. Defaulting to "strict"'));
+ args.typescript = 'strict';
+ }
+
+ const tsResponse =
+ args.typescript ||
+ (
+ await prompts(
+ {
+ type: 'select',
+ name: 'typescript',
+ message: 'How would you like to setup TypeScript?',
+ choices: [
+ { 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.'
+ )
+ );
+ process.exit(1);
+ },
+ }
+ )
+ ).typescript;
if (tsResponse === 'unsure') {
await typescriptByDefault();