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

Dependencies: Remove shelljs use #22995

Merged
merged 5 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion code/addons/storyshots-puppeteer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@storybook/csf": "^0.1.0",
"@storybook/node-logger": "7.1.0-alpha.29",
"@storybook/types": "7.1.0-alpha.29",
"@types/jest-image-snapshot": "^5.1.0",
"@types/jest-image-snapshot": "^6.0.0",
"jest-image-snapshot": "^6.0.0"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions code/frameworks/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"@angular/forms": "^16.0.0-rc.4",
"@angular/platform-browser": "^16.0.0-rc.4",
"@angular/platform-browser-dynamic": "^16.0.0-rc.4",
"@types/cross-spawn": "^6.0.2",
"@types/tmp": "^0.2.3",
"cross-spawn": "^7.0.3",
"jest": "^29.3.1",
Expand Down
2 changes: 0 additions & 2 deletions code/lib/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
"puppeteer-core": "^2.1.1",
"read-pkg-up": "^7.0.1",
"semver": "^7.3.7",
"shelljs": "^0.8.5",
"simple-update-notifier": "^1.0.0",
"strip-json-comments": "^3.0.1",
"tempy": "^1.0.1",
Expand All @@ -100,7 +99,6 @@
"@types/prompts": "^2.0.9",
"@types/puppeteer-core": "^2.1.0",
"@types/semver": "^7.3.4",
"@types/shelljs": "^0.8.7",
"@types/util-deprecate": "^1.0.0",
"slash": "^5.0.0",
"strip-json-comments": "^3.1.1",
Expand Down
14 changes: 4 additions & 10 deletions code/lib/cli/src/link.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fse from 'fs-extra';
import path from 'path';
import { sync as spawnSync } from 'cross-spawn';
import { sync as spawnSync, spawn as spawnAsync } from 'cross-spawn';
import { logger } from '@storybook/node-logger';
import shell from 'shelljs';
import chalk from 'chalk';
import type { ExecOptions } from 'shelljs';

type ExecOptions = Parameters<typeof spawnAsync>[2];

interface LinkOptions {
target: string;
Expand All @@ -31,14 +31,8 @@ export const exec = async (

logger.info(command);
return new Promise((resolve, reject) => {
const defaultOptions: ExecOptions = {
silent: false,
};
const child = shell.exec(command, {
...defaultOptions,
const child = spawnAsync(command, {
...options,
async: true,
silent: false,
});

child.stderr.pipe(process.stderr);
Expand Down
20 changes: 9 additions & 11 deletions code/lib/cli/src/repro-generators/scripts.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import path from 'path';
import { readJSON, writeJSON, outputFile } from 'fs-extra';
import type { ExecOptions } from 'shelljs';
import shell from 'shelljs';
import { readJSON, writeJSON, outputFile, remove } from 'fs-extra';
import chalk from 'chalk';
import { command } from 'execa';
import spawn from 'cross-spawn';
import { cra, cra_typescript } from './configs';
import storybookVersions from '../versions';

Expand Down Expand Up @@ -42,6 +41,8 @@ interface Configuration {
registry?: string;
}

type ExecOptions = globalThis.Parameters<typeof spawn>[2];

export interface Options extends Parameters {
appName: string;
creationPath: string;
Expand Down Expand Up @@ -69,14 +70,8 @@ export const exec = async (

logger.debug(command);
return new Promise((resolve, reject) => {
const defaultOptions: ExecOptions = {
silent: false,
};
const child = shell.exec(command, {
...defaultOptions,
const child = spawn(command, {
...options,
async: true,
silent: false,
});

child.stderr.pipe(process.stderr);
Expand Down Expand Up @@ -221,7 +216,10 @@ const initStorybook = async ({ cwd, autoDetect = true, name, e2e, pnp }: Options

const addRequiredDeps = async ({ cwd, additionalDeps }: Options) => {
// Remove any lockfile generated without Yarn 2
shell.rm('-f', path.join(cwd, 'package-lock.json'), path.join(cwd, 'yarn.lock'));
await Promise.all([
remove(path.join(cwd, 'package-lock.json')),
remove(path.join(cwd, 'yarn.lock')),
]);

// eslint-disable-next-line @typescript-eslint/no-shadow
const command =
Expand Down
1 change: 1 addition & 0 deletions code/lib/codemod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@storybook/csf-tools": "7.1.0-alpha.29",
"@storybook/node-logger": "7.1.0-alpha.29",
"@storybook/types": "7.1.0-alpha.29",
"@types/cross-spawn": "^6.0.2",
"cross-spawn": "^7.0.3",
"globby": "^11.0.2",
"jscodeshift": "^0.14.0",
Expand Down
61 changes: 11 additions & 50 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5447,7 +5447,7 @@ __metadata:
"@storybook/csf": ^0.1.0
"@storybook/node-logger": 7.1.0-alpha.29
"@storybook/types": 7.1.0-alpha.29
"@types/jest-image-snapshot": ^5.1.0
"@types/jest-image-snapshot": ^6.0.0
"@types/puppeteer": ^5.4.0
enzyme: ^3.11.0
enzyme-to-json: ^3.6.1
Expand Down Expand Up @@ -5667,6 +5667,7 @@ __metadata:
"@storybook/preview-api": 7.1.0-alpha.29
"@storybook/telemetry": 7.1.0-alpha.29
"@storybook/types": 7.1.0-alpha.29
"@types/cross-spawn": ^6.0.2
"@types/node": ^16.0.0
"@types/react": ^16.14.34
"@types/react-dom": ^16.9.14
Expand Down Expand Up @@ -5985,7 +5986,6 @@ __metadata:
"@types/prompts": ^2.0.9
"@types/puppeteer-core": ^2.1.0
"@types/semver": ^7.3.4
"@types/shelljs": ^0.8.7
"@types/util-deprecate": ^1.0.0
boxen: ^5.1.2
chalk: ^4.1.0
Expand All @@ -6009,7 +6009,6 @@ __metadata:
puppeteer-core: ^2.1.1
read-pkg-up: ^7.0.1
semver: ^7.3.7
shelljs: ^0.8.5
simple-update-notifier: ^1.0.0
slash: ^5.0.0
strip-json-comments: ^3.1.1
Expand Down Expand Up @@ -6061,6 +6060,7 @@ __metadata:
"@storybook/csf-tools": 7.1.0-alpha.29
"@storybook/node-logger": 7.1.0-alpha.29
"@storybook/types": 7.1.0-alpha.29
"@types/cross-spawn": ^6.0.2
"@types/jscodeshift": ^0.11.6
ansi-regex: ^5.0.1
cross-spawn: ^7.0.3
Expand Down Expand Up @@ -8294,7 +8294,7 @@ __metadata:
languageName: node
linkType: hard

"@types/glob@npm:^7.1.1, @types/glob@npm:^7.1.3, @types/glob@npm:~7.2.0":
"@types/glob@npm:^7.1.1, @types/glob@npm:^7.1.3":
version: 7.2.0
resolution: "@types/glob@npm:7.2.0"
dependencies:
Expand Down Expand Up @@ -8379,14 +8379,14 @@ __metadata:
languageName: node
linkType: hard

"@types/jest-image-snapshot@npm:^5.1.0":
version: 5.1.0
resolution: "@types/jest-image-snapshot@npm:5.1.0"
"@types/jest-image-snapshot@npm:^6.0.0":
version: 6.1.0
resolution: "@types/jest-image-snapshot@npm:6.1.0"
dependencies:
"@types/jest": "*"
"@types/pixelmatch": "*"
ssim.js: ^3.1.1
checksum: c25db75b38960a84cc999a8b07f6f244d22e5e2c9965f78dc15c4249ec71a403363a50ee69884cdf66fcaf5a9ef125363316929fa1925d38868b3937c110138b
checksum: f811e9d49c1600ed85745bb5be3b0bb0c6da719eb761d62fa6f21214ca6e0ad822bc3643e7ab7260452e180dbabc2530661eb10688e49de2cb2c950bd2252ccf
languageName: node
linkType: hard

Expand Down Expand Up @@ -8804,16 +8804,6 @@ __metadata:
languageName: node
linkType: hard

"@types/shelljs@npm:^0.8.7":
version: 0.8.12
resolution: "@types/shelljs@npm:0.8.12"
dependencies:
"@types/glob": ~7.2.0
"@types/node": "*"
checksum: a29f5ef3d61b243e07f642dfb34471a1f2bde2883b217f83afab74a944aaafbf014ca15644cc543d68f6ea7e11e1241ce7e029e0e4555ef8e2869476b5993d47
languageName: node
linkType: hard

"@types/sockjs@npm:^0.3.33":
version: 0.3.33
resolution: "@types/sockjs@npm:0.3.33"
Expand Down Expand Up @@ -16978,7 +16968,7 @@ __metadata:
languageName: node
linkType: hard

"glob@npm:^7.0.0, glob@npm:^7.0.3, glob@npm:^7.1.2, glob@npm:^7.1.3, glob@npm:^7.1.4, glob@npm:^7.2.0":
"glob@npm:^7.0.3, glob@npm:^7.1.2, glob@npm:^7.1.3, glob@npm:^7.1.4, glob@npm:^7.2.0":
version: 7.2.3
resolution: "glob@npm:7.2.3"
dependencies:
Expand Down Expand Up @@ -18194,13 +18184,6 @@ __metadata:
languageName: node
linkType: hard

"interpret@npm:^1.0.0":
version: 1.4.0
resolution: "interpret@npm:1.4.0"
checksum: 08c5ad30032edeec638485bc3f6db7d0094d9b3e85e0f950866600af3c52e9fd69715416d29564731c479d9f4d43ff3e4d302a178196bdc0e6837ec147640450
languageName: node
linkType: hard

"invariant@npm:^2.2.4":
version: 2.2.4
resolution: "invariant@npm:2.2.4"
Expand Down Expand Up @@ -26110,15 +26093,6 @@ __metadata:
languageName: node
linkType: hard

"rechoir@npm:^0.6.2":
version: 0.6.2
resolution: "rechoir@npm:0.6.2"
dependencies:
resolve: ^1.1.6
checksum: 22c4bb32f4934a9468468b608417194f7e3ceba9a508512125b16082c64f161915a28467562368eeb15dc16058eb5b7c13a20b9eb29ff9927d1ebb3b5aa83e84
languageName: node
linkType: hard

"redent@npm:^3.0.0":
version: 3.0.0
resolution: "redent@npm:3.0.0"
Expand Down Expand Up @@ -26784,7 +26758,7 @@ __metadata:
languageName: node
linkType: hard

"resolve@npm:^1.1.6, resolve@npm:^1.10.0, resolve@npm:^1.12.0, resolve@npm:^1.13.1, resolve@npm:^1.14.2, resolve@npm:^1.15.1, resolve@npm:^1.17.0, resolve@npm:^1.19.0, resolve@npm:^1.20.0, resolve@npm:^1.22.1, resolve@npm:^1.3.2, resolve@npm:^1.4.0":
"resolve@npm:^1.10.0, resolve@npm:^1.12.0, resolve@npm:^1.13.1, resolve@npm:^1.14.2, resolve@npm:^1.15.1, resolve@npm:^1.17.0, resolve@npm:^1.19.0, resolve@npm:^1.20.0, resolve@npm:^1.22.1, resolve@npm:^1.3.2, resolve@npm:^1.4.0":
version: 1.22.3
resolution: "resolve@npm:1.22.3"
dependencies:
Expand Down Expand Up @@ -26823,7 +26797,7 @@ __metadata:
languageName: node
linkType: hard

"resolve@patch:resolve@^1.1.6#~builtin<compat/resolve>, resolve@patch:resolve@^1.10.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.12.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.13.1#~builtin<compat/resolve>, resolve@patch:resolve@^1.14.2#~builtin<compat/resolve>, resolve@patch:resolve@^1.15.1#~builtin<compat/resolve>, resolve@patch:resolve@^1.17.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.19.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.20.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.22.1#~builtin<compat/resolve>, resolve@patch:resolve@^1.3.2#~builtin<compat/resolve>, resolve@patch:resolve@^1.4.0#~builtin<compat/resolve>":
"resolve@patch:resolve@^1.10.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.12.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.13.1#~builtin<compat/resolve>, resolve@patch:resolve@^1.14.2#~builtin<compat/resolve>, resolve@patch:resolve@^1.15.1#~builtin<compat/resolve>, resolve@patch:resolve@^1.17.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.19.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.20.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.22.1#~builtin<compat/resolve>, resolve@patch:resolve@^1.3.2#~builtin<compat/resolve>, resolve@patch:resolve@^1.4.0#~builtin<compat/resolve>":
version: 1.22.3
resolution: "resolve@patch:resolve@npm%3A1.22.3#~builtin<compat/resolve>::version=1.22.3&hash=c3c19d"
dependencies:
Expand Down Expand Up @@ -27538,19 +27512,6 @@ __metadata:
languageName: node
linkType: hard

"shelljs@npm:^0.8.5":
version: 0.8.5
resolution: "shelljs@npm:0.8.5"
dependencies:
glob: ^7.0.0
interpret: ^1.0.0
rechoir: ^0.6.2
bin:
shjs: bin/shjs
checksum: feb25289a12e4bcd04c40ddfab51aff98a3729f5c2602d5b1a1b95f6819ec7804ac8147ebd8d9a85dfab69d501bcf92d7acef03247320f51c1552cec8d8e2382
languageName: node
linkType: hard

"side-channel@npm:^1.0.4":
version: 1.0.4
resolution: "side-channel@npm:1.0.4"
Expand Down
3 changes: 1 addition & 2 deletions scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.2",
"@testing-library/user-event": "^13.2.1",
"@types/cross-spawn": "^6.0.2",
"@types/detect-port": "^1.3.2",
"@types/ejs": "^3.1.1",
"@types/escodegen": "^0.0.6",
Expand All @@ -91,7 +92,6 @@
"@types/react-dom": "^16.9.17",
"@types/semver": "^7.3.4",
"@types/serve-static": "^1.13.8",
"@types/shelljs": "^0.8.7",
"@types/uuid": "^9.0.1",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/experimental-utils": "^5.45.0",
Expand Down Expand Up @@ -161,7 +161,6 @@
"remark-preset-lint-recommended": "^5.0.0",
"semver": "^7.3.7",
"serve-static": "^1.14.1",
"shelljs": "^0.8.5",
"simple-git": "^3.18.0",
"slash": "^3.0.0",
"sort-package-json": "^2.0.0",
Expand Down
18 changes: 9 additions & 9 deletions scripts/utils/command.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { ExecOptions } from 'shelljs';
import shell from 'shelljs';
import { sync as spawnSync } from 'cross-spawn';

type ExecOptions = Parameters<typeof spawnSync>[2];

export const exec = async (command: string, options: ExecOptions = {}) =>
new Promise((resolve, reject) => {
shell.exec(command, options, (code) => {
if (code === 0) {
resolve();
} else {
reject(new Error(`command exited with code: ${code}`));
}
});
const x = spawnSync(command, options);
if (x.status === 0) {
resolve(undefined);
} else {
reject(new Error(`command exited with code: ${x.status}: `));
}
});
Loading