Skip to content

Commit

Permalink
updated installation process to be verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoalbanese committed Jan 23, 2024
1 parent a8d0b83 commit 28093f9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/commands/add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const addPackage = async (options?: InitOptions) => {
const promptResponse = await promptUser(options);
const start = Date.now();
spinner.start();
spinner.text = "Beginning Installation Process";
spinner.text = "Beginning Configuration Process";

if (config.componentLib === undefined) {
if (promptResponse.componentLib === "shadcn-ui") {
Expand Down Expand Up @@ -235,13 +235,13 @@ export const addPackage = async (options?: InitOptions) => {
if (config.t3 && config.auth === "next-auth") {
checkAndAddAuthUtils();
}
spinner.succeed("Configuration complete");

await installPackagesFromList();
await installShadcnComponentList();

const end = Date.now();
const duration = end - start;
spinner.succeed();

printNextSteps(promptResponse, duration);
} else {
Expand Down
1 change: 0 additions & 1 deletion src/commands/add/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ export const addToShadcnComponentList = (components: string[]) =>
export const installShadcnComponentList = async () => {
// consola.start("Installing shadcn components:", shadCnComponentList);
if (shadCnComponentList.length === 0) return;
spinner.text = "Installing ShadcnUI Components";
await installShadcnUIComponents(shadCnComponentList);
// consola.ready("Successfully installed components.");
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ ${
export const revalidate = 0;
export default async function ${tableNameCapitalised}Page() {
${schema.belongsToUser ? "await checkAuth();\n" : ""}
return (
<main>
<div className="relative">
Expand All @@ -242,6 +241,7 @@ export default async function ${tableNameCapitalised}Page() {
}
const ${tableNameCapitalised} = async () => {
${schema.belongsToUser ? "await checkAuth();\n" : ""}
const { ${tableNameCamelCase} } = await get${tableNameCapitalised}();
${
relationsFormatted
Expand Down
22 changes: 14 additions & 8 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ export function createFolder(relativePath: string, log = false) {
export const runCommand = async (command: string, args: string[]) => {
const formattedArgs = args.filter((a) => a !== "");
try {
await execa(command, formattedArgs, { stdio: "ignore" });
await execa(command, formattedArgs, {
stdio: "inherit",
});
} catch (error) {
throw new Error(
`command "${command} ${formattedArgs
Expand All @@ -74,20 +76,21 @@ export async function installPackages(
const installCommand = pmType === "npm" ? "install" : "add";

try {
if (packages.dev) {
spinner.stop();
console.log("\n");
consola.info("Installing Dependencies");
if (packages.regular) {
await runCommand(
pmType,
[installCommand, "-D"].concat(packages.dev.split(" "))
[installCommand].concat(packages.regular.split(" "))
);
}

if (packages.regular) {
if (packages.dev) {
await runCommand(
pmType,
[installCommand].concat(packages.regular.split(" "))
[installCommand, "-D"].concat(packages.dev.split(" "))
);
}

// consola.success(
// `Regular dependencies installed: \n${packages.regular
// .split(" ")
Expand Down Expand Up @@ -174,8 +177,11 @@ export async function installShadcnUIComponents(
// `Installing shadcn-ui components: ${componentsToInstall.join(", ")}`
// );
try {
spinner.stop();
console.log("\n");
consola.info("Installing ShadcnUI Components");
await execa(pmInstallCommand[preferredPackageManager], installArgs, {
stdio: "ignore",
stdio: "inherit",
});
// consola.success(
// `Installed components: ${componentsToInstall.join(", ")}`
Expand Down

0 comments on commit 28093f9

Please sign in to comment.