Skip to content

Commit

Permalink
add spinners when installing dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed May 16, 2023
1 parent 1fab54d commit b201226
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions code/lib/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"globby": "^11.0.2",
"jscodeshift": "^0.14.0",
"leven": "^3.1.0",
"ora": "^5.4.1",
"prettier": "^2.8.0",
"prompts": "^2.4.0",
"puppeteer-core": "^2.1.1",
Expand Down
18 changes: 15 additions & 3 deletions code/lib/cli/src/generators/baseGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import path from 'path';
import fse from 'fs-extra';
import { dedent } from 'ts-dedent';
import ora from 'ora';
import type { NpmOptions } from '../NpmOptions';
import type { SupportedRenderers, SupportedFrameworks, Builder } from '../project_types';
import { SupportedLanguage, externalFrameworks, CoreBuilder } from '../project_types';
import { copyTemplateFiles, paddedLog } from '../helpers';
import { copyTemplateFiles } from '../helpers';
import { configureMain, configurePreview } from './configure';
import type { JsPackageManager } from '../js-package-manager';
import { getPackageDetails } from '../js-package-manager';
Expand All @@ -17,6 +18,8 @@ import {
suggestESLintPlugin,
} from '../automigrate/helpers/eslintPlugin';

const logger = console;

const defaultOptions: FrameworkOptions = {
extraPackages: [],
extraAddons: [],
Expand Down Expand Up @@ -254,8 +257,13 @@ export async function baseGenerator(
(packageToInstall) => !installedDependencies.has(getPackageDetails(packageToInstall)[0])
);

paddedLog(`\nGetting the correct version of ${packages.length} packages`);
logger.log();
const versionedPackagesSpinner = ora({
indent: 2,
text: `Getting the correct version of ${packages.length} packages`,
}).start();
const versionedPackages = await packageManager.getVersionedPackages(packages);
versionedPackagesSpinner.succeed();

await fse.ensureDir(`./${storybookConfigFolder}`);

Expand Down Expand Up @@ -334,8 +342,12 @@ export async function baseGenerator(
}

if (depsToInstall.length > 0) {
paddedLog('Installing Storybook dependencies');
const addDependenciesSpinner = ora({
indent: 2,
text: 'Installing Storybook dependencies',
}).start();
await packageManager.addDependencies({ ...npmOptions, packageJson }, depsToInstall);
addDependenciesSpinner.succeed();
}

if (addScripts) {
Expand Down
1 change: 1 addition & 0 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5742,6 +5742,7 @@ __metadata:
globby: ^11.0.2
jscodeshift: ^0.14.0
leven: ^3.1.0
ora: ^5.4.1
prettier: ^2.8.0
prompts: ^2.4.0
puppeteer-core: ^2.1.1
Expand Down

0 comments on commit b201226

Please sign in to comment.