1 | import { PackageJson, PackageJsonWithDepsAndDevDeps } from './PackageJson';
|
2 | /**
|
3 | * Extract package name and version from input
|
4 | *
|
5 | * @param pkg A string like `@storybook/cli`, `react` or `react@^16`
|
6 | * @return A tuple of 2 elements: [packageName, packageVersion]
|
7 | */
|
8 | export declare function getPackageDetails(pkg: string): [
|
9 | string,
|
10 | string?
|
11 | ];
|
12 | export declare abstract class JsPackageManager {
|
13 | abstract readonly type: 'npm' | 'yarn1' | 'yarn2';
|
14 | abstract initPackageJson(): void;
|
15 | abstract getRunStorybookCommand(): string;
|
16 | abstract getRunCommand(command: string): string;
|
17 | /**
|
18 | * Install dependencies listed in `package.json`
|
19 | */
|
20 | installDependencies(): void;
|
21 | /**
|
22 | * Read the `package.json` file available in the directory the command was call from
|
23 | * If there is no `package.json` it will create one.
|
24 | */
|
25 | retrievePackageJson(): PackageJsonWithDepsAndDevDeps;
|
26 | /**
|
27 | * Add dependencies to a project using `yarn add` or `npm install`.
|
28 | *
|
29 | * @param {Object} options contains `skipInstall`, `packageJson` and `installAsDevDependencies` which we use to determine how we install packages.
|
30 | * @param {Array} dependencies contains a list of packages to add.
|
31 | * @example
|
32 | * addDependencies(options, [
|
33 | * `@storybook/react@${storybookVersion}`,
|
34 | * `@storybook/addon-actions@${actionsVersion}`,
|
35 | * `@storybook/addon-links@${linksVersion}`,
|
36 | * `@storybook/addons@${addonsVersion}`,
|
37 | * ]);
|
38 | */
|
39 | addDependencies(options: {
|
40 | skipInstall?: boolean;
|
41 | installAsDevDependencies?: boolean;
|
42 | packageJson?: PackageJson;
|
43 | }, dependencies: string[]): void;
|
44 | /**
|
45 | * Return an array of strings matching following format: `<package_name>@<package_latest_version>`
|
46 | *
|
47 | * @param packages
|
48 | */
|
49 | getVersionedPackages(...packages: string[]): Promise<string[]>;
|
50 | /**
|
51 | * Return an array of string standing for the latest version of the input packages.
|
52 | * To be able to identify which version goes with which package the order of the input array is keep.
|
53 | *
|
54 | * @param packageNames
|
55 | */
|
56 | getVersions(...packageNames: string[]): Promise<string[]>;
|
57 | /**
|
58 | * Return the latest version of the input package available on npmjs registry.
|
59 | * If constraint are provided it return the latest version matching the constraints.
|
60 | *
|
61 | * For `@storybook/*` packages the latest version is retrieved from `cli/src/versions.json` file directly
|
62 | *
|
63 | * @param packageName The name of the package
|
64 | * @param constraint A valid semver constraint, example: '1.x || >=2.5.0 || 5.0.0 - 7.2.3'
|
65 | */
|
66 | getVersion(packageName: string, constraint?: string): Promise<string>;
|
67 | /**
|
68 | * Get the latest version of the package available on npmjs.com.
|
69 | * If constraint is set then it returns a version satisfying it, otherwise the latest version available is returned.
|
70 | *
|
71 | * @param packageName Name of the package
|
72 | * @param constraint Version range to use to constraint the returned version
|
73 | */
|
74 | latestVersion(packageName: string, constraint?: string): Promise<string>;
|
75 | addStorybookCommandInScripts(options?: {
|
76 | port: number;
|
77 | staticFolder?: string;
|
78 | preCommand?: string;
|
79 | }): void;
|
80 | addESLintConfig(): void;
|
81 | addScripts(scripts: Record<string, string>): void;
|
82 | protected abstract runInstall(): void;
|
83 | protected abstract runAddDeps(dependencies: string[], installAsDevDependencies: boolean): void;
|
84 | /**
|
85 | * Get the latest or all versions of the input package available on npmjs.com
|
86 | *
|
87 | * @param packageName Name of the package
|
88 | * @param fetchAllVersions Should return
|
89 | */
|
90 | protected abstract runGetVersions<T extends boolean>(packageName: string, fetchAllVersions: T): Promise<T extends true ? string[] : string>;
|
91 | executeCommand(command: string, args: string[], stdio?: 'pipe' | 'inherit'): string;
|
92 | }
|