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
Use execa instead of exec
  • Loading branch information
JuanM04 authored and Nate Moore committed Mar 25, 2022
commit 880c405625ad68a1d57116fbe8ce2f3ad586002e
28 changes: 6 additions & 22 deletions packages/astro/src/cli/add.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type yargs from 'yargs-parser';
import path from 'path';
import fs from 'fs/promises';
import { exec } from 'child_process';
import { execaCommand } from 'execa';
import { fileURLToPath } from 'url';
import { diffLines } from 'diff';
import boxen from 'boxen';
Expand Down Expand Up @@ -255,22 +255,14 @@ async function getInstallIntegrationsCommand({ integrations, cwd = process.cwd()
}
}

async function tryToInstallIntegrations({
integrations,
cwd = process.cwd(),
logging,
}: {
integrations: IntegrationInfo[];
cwd?: string;
logging: LogOptions;
}): Promise<UpdateResult> {
const cmd = await getInstallIntegrationsCommand({ integrations, cwd });
async function tryToInstallIntegrations({ integrations, cwd, logging }: { integrations: IntegrationInfo[]; cwd?: string; logging: LogOptions }): Promise<UpdateResult> {
const installCommand = await getInstallIntegrationsCommand({ integrations, cwd });

if (cmd === null) {
if (installCommand === null) {
info(logging, null);
return UpdateResult.none;
} else {
const message = `\n${boxen(cyan(cmd), { margin: 0.5, padding: 0.5, borderStyle: 'round' })}\n`;
const message = `\n${boxen(cyan(installCommand), { margin: 0.5, padding: 0.5, borderStyle: 'round' })}\n`;
info(logging, null, `\n ${magenta('Astro will run the following command to install...')}\n${message}`);
natemoo-re marked this conversation as resolved.
Show resolved Hide resolved
const response = await prompts({
type: 'confirm',
Expand All @@ -282,15 +274,7 @@ async function tryToInstallIntegrations({
if (response.installDependencies) {
const spinner = ora('Installing dependencies...').start();
try {
await new Promise((resolve, reject) => {
exec(cmd, (err, stdout, stderr) => {
if (err) {
reject(stderr);
} else {
resolve(stdout);
}
});
});
await execaCommand(installCommand, { cwd });
spinner.succeed();
return UpdateResult.updated;
} catch (err) {
Expand Down