Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): scaffold out astro add command #2849

Merged
merged 40 commits into from
Mar 25, 2022
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
471fa01
feat(cli): scaffold out `astro add` command
Mar 21, 2022
ea0793f
added first babel transforms
JuanM04 Mar 22, 2022
4a955bc
Format output
JuanM04 Mar 24, 2022
6616cda
Added changes confirmation
JuanM04 Mar 24, 2022
8b0b4bf
Error flow
JuanM04 Mar 24, 2022
ff5220c
Add dependencies
JuanM04 Mar 24, 2022
a9bc999
feat(cli): astro add cleanup pass
Mar 24, 2022
e79c461
feat: add support for tailwind
Mar 24, 2022
abbe3e2
chore: update lockfile
Mar 24, 2022
c8949da
fix: types
Mar 24, 2022
94e4e34
chore: rever @proload/core bump
Mar 24, 2022
234c4b1
chore: add changeset
Mar 24, 2022
a055557
chore: rollback dep update
Mar 24, 2022
787f129
Added spinners
JuanM04 Mar 24, 2022
728521c
chore: remove extra deps
Mar 24, 2022
17a0b7c
Removed extra argument
JuanM04 Mar 24, 2022
880c405
Use `execa` instead of `exec`
JuanM04 Mar 24, 2022
9ec534d
Changed how lines are trimmed within diffLines
JuanM04 Mar 25, 2022
0401ec6
refactor: move add to core
Mar 25, 2022
b168fab
refactor: remove old add entrypoint
Mar 25, 2022
6b94574
refactor: simplify wording
Mar 25, 2022
2803357
feat: improve diff
Mar 25, 2022
f6bb9ee
feat: improve diff and logging, add interactive prompt when no args p…
Mar 25, 2022
8610d78
Formatted files
JuanM04 Mar 25, 2022
59030bd
Added --yes
JuanM04 Mar 25, 2022
c942116
feat: improve logging for install command
Mar 25, 2022
e035d10
Fixed execa
JuanM04 Mar 25, 2022
a43bf5e
Added help message to add
JuanM04 Mar 25, 2022
638dc73
refactor: extract consts to own file
Mar 25, 2022
03fda0e
feat: remove implicit projectRoot behavior
Mar 25, 2022
7187bfc
feat: improve error handling, existing integrations
Mar 25, 2022
35a7dcc
fix(tailwind): ensure existing tailwind config is not overwritten
Mar 25, 2022
3d69ef6
refactor: prefer cwd to projectRoot flag
Mar 25, 2022
f6896b8
chore: add refactor notes
Mar 25, 2022
573ba5b
refactor: throw createPrettyError > implicit bail
Mar 25, 2022
2be9a7b
refactor: cleanup language
Mar 25, 2022
6aca7e6
feat(cli): prompt user before generating tailwind config
Mar 25, 2022
164b735
fix(cli): update config generation to use cwd
Mar 25, 2022
d588222
fix: resolve root from cwd
Mar 25, 2022
6e0eed5
chore: update changelog
Mar 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: throw createPrettyError > implicit bail
  • Loading branch information
Nate Moore committed Mar 25, 2022
commit 573ba5b640a7fb69c9e33b0a9d5d56d0ef15bbd0
11 changes: 5 additions & 6 deletions packages/astro/src/core/add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default async function add(names: string[], { cwd, flags, logging }: AddO
}
} catch (err) {
debug('add', 'Error parsing/modifying astro config: ', err);
return bail(err as Error);
throw createPrettyError(err as Error);
}

let configResult: UpdateResult | undefined;
Expand All @@ -124,7 +124,7 @@ export default async function add(names: string[], { cwd, flags, logging }: AddO
configResult = await updateAstroConfig({ configURL, ast, flags, logging });
} catch (err) {
debug('add', 'Error updating astro config', err);
return bail(err as Error);
throw createPrettyError(err as Error);
}
}

Expand Down Expand Up @@ -176,8 +176,7 @@ export default async function add(names: string[], { cwd, flags, logging }: AddO
return;
}
case UpdateResult.failure: {
bail(new Error(`Unable to install dependencies`));
return;
throw createPrettyError(new Error(`Unable to install dependencies`));
}
}
}
Expand All @@ -199,13 +198,13 @@ const toIdent = (name: string) => {
return name;
};

function bail(err: Error) {
function createPrettyError(err: Error) {
err.message = `Astro could not update your astro.config.js file safely.
Reason: ${err.message}

You will need to add these integration(s) manually.
Documentation: https://next--astro-docs-2.netlify.app/en/guides/integrations-guide/`
throw err;
return err;
}

async function addIntegration(ast: t.File, integration: IntegrationInfo) {
Expand Down