Skip to content

Commit

Permalink
remove --use-npm flag from CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Jan 3, 2024
1 parent bf06e6e commit d6d5c7a
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 53 deletions.
8 changes: 8 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
- [Require Angular 15 and up](#require-angular-15-and-up)
- [Svelte](#svelte)
- [Require Svelte 4 and up](#require-svelte-4-and-up)
- [Deprecations which are now removed](#deprecations-which-are-now-removed)
- [--use-npm flag in storybook CLI](#--use-npm-flag-in-storybook-cli)
- [From version 7.5.0 to 7.6.0](#from-version-750-to-760)
- [CommonJS with Vite is deprecated](#commonjs-with-vite-is-deprecated)
- [Using implicit actions during rendering is deprecated](#using-implicit-actions-during-rendering-is-deprecated)
Expand Down Expand Up @@ -507,6 +509,12 @@ Starting in 8.0, Storybook requires Angular 15 and up.

Starting in 8.0, Storybook requires Svelte 4 and up.

### Deprecations which are now removed

#### --use-npm flag in storybook CLI

The `--use-npm` is now removed. Use `--package-manager=npm` instead. [More info here](#cli-option---use-npm-deprecated).

## From version 7.5.0 to 7.6.0

#### CommonJS with Vite is deprecated
Expand Down
15 changes: 4 additions & 11 deletions code/lib/cli/src/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import { isAbsolute, join } from 'path';
import SemVer from 'semver';
import dedent from 'ts-dedent';

import {
JsPackageManagerFactory,
useNpmWarning,
type PackageManagerName,
} from './js-package-manager';
import { JsPackageManagerFactory, type PackageManagerName } from './js-package-manager';
import { getStorybookVersion, isCorePackage } from './utils';

const logger = console;
Expand Down Expand Up @@ -71,13 +67,10 @@ const checkInstalled = (addonName: string, main: any) => {
*/
export async function add(
addon: string,
options: { useNpm: boolean; packageManager: PackageManagerName; skipPostinstall: boolean }
options: { packageManager: PackageManagerName; skipPostinstall: boolean }
) {
let { packageManager: pkgMgr } = options;
if (options.useNpm) {
useNpmWarning();
pkgMgr = 'npm';
}
const { packageManager: pkgMgr } = options;

const packageManager = JsPackageManagerFactory.getPackageManager({ force: pkgMgr });
const packageJson = await packageManager.retrievePackageJson();
const { mainConfig, configDir } = getStorybookInfo(packageJson);
Expand Down
12 changes: 1 addition & 11 deletions code/lib/cli/src/automigrate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import dedent from 'ts-dedent';
import { join } from 'path';
import { getStorybookInfo, loadMainConfig } from '@storybook/core-common';
import invariant from 'tiny-invariant';
import { JsPackageManagerFactory, useNpmWarning } from '../js-package-manager';
import { JsPackageManagerFactory } from '../js-package-manager';
import type { PackageManagerName } from '../js-package-manager';

import type { Fix, FixId, FixOptions, FixSummary } from './fixes';
Expand Down Expand Up @@ -55,7 +55,6 @@ export const automigrate = async ({
fixes: inputFixes,
dryRun,
yes,
useNpm,
packageManager: pkgMgr,
list,
configDir: userSpecifiedConfigDir,
Expand Down Expand Up @@ -86,7 +85,6 @@ export const automigrate = async ({

const { fixResults, fixSummary, preCheckFailure } = await runFixes({
fixes,
useNpm,
pkgMgr,
userSpecifiedConfigDir,
rendererPackage,
Expand Down Expand Up @@ -129,7 +127,6 @@ export async function runFixes({
fixes,
dryRun,
yes,
useNpm,
pkgMgr,
userSpecifiedConfigDir,
rendererPackage,
Expand All @@ -138,7 +135,6 @@ export async function runFixes({
fixes: Fix[];
yes?: boolean;
dryRun?: boolean;
useNpm?: boolean;
pkgMgr?: PackageManagerName;
userSpecifiedConfigDir?: string;
rendererPackage?: string;
Expand All @@ -148,12 +144,6 @@ export async function runFixes({
fixResults: Record<FixId, FixStatus>;
fixSummary: FixSummary;
}> {
if (useNpm) {
useNpmWarning();
// eslint-disable-next-line no-param-reassign
pkgMgr = 'npm';
}

const packageManager = JsPackageManagerFactory.getPackageManager({ force: pkgMgr });

const fixResults = {} as Record<FixId, FixStatus>;
Expand Down
1 change: 0 additions & 1 deletion code/lib/cli/src/automigrate/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export interface FixOptions {
fixes?: Fix[];
yes?: boolean;
dryRun?: boolean;
useNpm?: boolean;
packageManager?: PackageManagerName;
configDir?: string;
renderer?: string;
Expand Down
4 changes: 0 additions & 4 deletions code/lib/cli/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ command('init')
.option('-f --force', 'Force add Storybook')
.option('-s --skip-install', 'Skip installing deps')
.option('--package-manager <npm|pnpm|yarn1|yarn2>', 'Force package manager for installing deps')
.option('-N --use-npm', 'Use npm to install deps (deprecated)')
.option('--use-pnp', 'Enable pnp mode for Yarn 2+')
.option('-p --parser <babel | babylon | flow | ts | tsx>', 'jscodeshift parser')
.option('-t --type <type>', 'Add Storybook for a specific project type')
Expand All @@ -65,7 +64,6 @@ command('add <addon>')
'--package-manager <npm|pnpm|yarn1|yarn2>',
'Force package manager for installing dependencies'
)
.option('-N --use-npm', 'Use NPM to install dependencies (deprecated)')
.option('-s --skip-postinstall', 'Skip package specific postinstall config modifications')
.action((addonName: string, options: any) => add(addonName, options));

Expand All @@ -79,7 +77,6 @@ command('upgrade')
'--package-manager <npm|pnpm|yarn1|yarn2>',
'Force package manager for installing dependencies'
)
.option('-N --use-npm', 'Use NPM to install dependencies (deprecated)')
.option('-y --yes', 'Skip prompting the user')
.option('-n --dry-run', 'Only check for upgrades, do not install')
.option('-t --tag <tag>', 'Upgrade to a certain npm dist-tag (e.g. next, prerelease)')
Expand Down Expand Up @@ -167,7 +164,6 @@ command('automigrate [fixId]')
.option('-y --yes', 'Skip prompting the user')
.option('-n --dry-run', 'Only check for fixes, do not actually run them')
.option('--package-manager <npm|pnpm|yarn1|yarn2>', 'Force package manager')
.option('-N --use-npm', 'Use npm as package manager (deprecated)')
.option('-l --list', 'List available migrations')
.option('-c, --config-dir <dir-name>', 'Directory of Storybook configurations to migrate')
.option('-s --skip-install', 'Skip installing deps')
Expand Down
1 change: 0 additions & 1 deletion code/lib/cli/src/generators/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export type Generator<T = void> = (

export type CommandOptions = {
packageManager: PackageManagerName;
useNpm?: boolean;
usePnp?: boolean;
type?: ProjectType;
force?: any;
Expand Down
9 changes: 2 additions & 7 deletions code/lib/cli/src/initiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import svelteKitGenerator from './generators/SVELTEKIT';
import solidGenerator from './generators/SOLID';
import serverGenerator from './generators/SERVER';
import type { JsPackageManager } from './js-package-manager';
import { JsPackageManagerFactory, useNpmWarning } from './js-package-manager';
import { JsPackageManagerFactory } from './js-package-manager';
import type { NpmOptions } from './NpmOptions';
import type { CommandOptions, GeneratorOptions } from './generators/types';
import { HandledError } from './HandledError';
Expand Down Expand Up @@ -235,12 +235,7 @@ async function doInitiate(
}
| { shouldRunDev: false }
> {
let { packageManager: pkgMgr } = options;
if (options.useNpm) {
useNpmWarning();

pkgMgr = 'npm';
}
const { packageManager: pkgMgr } = options;

const packageManager = JsPackageManagerFactory.getPackageManager({
force: pkgMgr,
Expand Down
8 changes: 0 additions & 8 deletions code/lib/cli/src/js-package-manager/deprecations.ts

This file was deleted.

2 changes: 0 additions & 2 deletions code/lib/cli/src/js-package-manager/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export * from './deprecations';

export * from './JsPackageManagerFactory';

export * from './JsPackageManager';
Expand Down
9 changes: 1 addition & 8 deletions code/lib/cli/src/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { logger } from '@storybook/node-logger';
import { withTelemetry } from '@storybook/core-server';

import type { PackageJsonWithMaybeDeps, PackageManagerName } from './js-package-manager';
import { getPackageDetails, JsPackageManagerFactory, useNpmWarning } from './js-package-manager';
import { getPackageDetails, JsPackageManagerFactory } from './js-package-manager';
import { coerceSemver, commandLog } from './helpers';
import { automigrate } from './automigrate';
import { isCorePackage } from './utils';
Expand Down Expand Up @@ -135,7 +135,6 @@ export interface UpgradeOptions {
tag: string;
prerelease: boolean;
skipCheck: boolean;
useNpm: boolean;
packageManager: PackageManagerName;
dryRun: boolean;
yes: boolean;
Expand All @@ -147,18 +146,12 @@ export const doUpgrade = async ({
tag,
prerelease,
skipCheck,
useNpm,
packageManager: pkgMgr,
dryRun,
configDir,
yes,
...options
}: UpgradeOptions) => {
if (useNpm) {
useNpmWarning();
// eslint-disable-next-line no-param-reassign
pkgMgr = 'npm';
}
const packageManager = JsPackageManagerFactory.getPackageManager({ force: pkgMgr });

const beforeVersion = await getStorybookCoreVersion();
Expand Down

0 comments on commit d6d5c7a

Please sign in to comment.