diff --git a/code/addons/storyshots-puppeteer/package.json b/code/addons/storyshots-puppeteer/package.json index b72470ff5e2e..84ad7408c941 100644 --- a/code/addons/storyshots-puppeteer/package.json +++ b/code/addons/storyshots-puppeteer/package.json @@ -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": { diff --git a/code/frameworks/angular/package.json b/code/frameworks/angular/package.json index 2aa6af716f17..fb2f336cad91 100644 --- a/code/frameworks/angular/package.json +++ b/code/frameworks/angular/package.json @@ -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", diff --git a/code/lib/cli/package.json b/code/lib/cli/package.json index 93406ced99ad..1d13d81e49d9 100644 --- a/code/lib/cli/package.json +++ b/code/lib/cli/package.json @@ -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", @@ -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", diff --git a/code/lib/cli/src/link.ts b/code/lib/cli/src/link.ts index cb9d32e99b64..090f0434fb2a 100644 --- a/code/lib/cli/src/link.ts +++ b/code/lib/cli/src/link.ts @@ -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[2]; interface LinkOptions { target: string; @@ -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); diff --git a/code/lib/cli/src/repro-generators/scripts.ts b/code/lib/cli/src/repro-generators/scripts.ts index f47050163209..d5056b2540c9 100644 --- a/code/lib/cli/src/repro-generators/scripts.ts +++ b/code/lib/cli/src/repro-generators/scripts.ts @@ -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'; @@ -42,6 +41,8 @@ interface Configuration { registry?: string; } +type ExecOptions = globalThis.Parameters[2]; + export interface Options extends Parameters { appName: string; creationPath: string; @@ -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); @@ -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 = diff --git a/code/lib/codemod/package.json b/code/lib/codemod/package.json index 526a6e3eced0..a89da61b280d 100644 --- a/code/lib/codemod/package.json +++ b/code/lib/codemod/package.json @@ -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", diff --git a/code/yarn.lock b/code/yarn.lock index 4fdacfef8fb7..e10bf7840e2d 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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: @@ -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 @@ -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" @@ -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: @@ -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" @@ -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" @@ -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: @@ -26823,7 +26797,7 @@ __metadata: languageName: node linkType: hard -"resolve@patch:resolve@^1.1.6#~builtin, resolve@patch:resolve@^1.10.0#~builtin, resolve@patch:resolve@^1.12.0#~builtin, resolve@patch:resolve@^1.13.1#~builtin, resolve@patch:resolve@^1.14.2#~builtin, resolve@patch:resolve@^1.15.1#~builtin, resolve@patch:resolve@^1.17.0#~builtin, resolve@patch:resolve@^1.19.0#~builtin, resolve@patch:resolve@^1.20.0#~builtin, resolve@patch:resolve@^1.22.1#~builtin, resolve@patch:resolve@^1.3.2#~builtin, resolve@patch:resolve@^1.4.0#~builtin": +"resolve@patch:resolve@^1.10.0#~builtin, resolve@patch:resolve@^1.12.0#~builtin, resolve@patch:resolve@^1.13.1#~builtin, resolve@patch:resolve@^1.14.2#~builtin, resolve@patch:resolve@^1.15.1#~builtin, resolve@patch:resolve@^1.17.0#~builtin, resolve@patch:resolve@^1.19.0#~builtin, resolve@patch:resolve@^1.20.0#~builtin, resolve@patch:resolve@^1.22.1#~builtin, resolve@patch:resolve@^1.3.2#~builtin, resolve@patch:resolve@^1.4.0#~builtin": version: 1.22.3 resolution: "resolve@patch:resolve@npm%3A1.22.3#~builtin::version=1.22.3&hash=c3c19d" dependencies: @@ -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" diff --git a/scripts/package.json b/scripts/package.json index e859bbb20c2c..66b0b9f4742b 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -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", @@ -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", @@ -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", diff --git a/scripts/utils/command.ts b/scripts/utils/command.ts index f1167f6993df..c7994e57c783 100644 --- a/scripts/utils/command.ts +++ b/scripts/utils/command.ts @@ -1,13 +1,13 @@ -import type { ExecOptions } from 'shelljs'; -import shell from 'shelljs'; +import { sync as spawnSync } from 'cross-spawn'; + +type ExecOptions = Parameters[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}: `)); + } }); diff --git a/scripts/yarn.lock b/scripts/yarn.lock index b38a3a233391..e4e07a50ac9e 100644 --- a/scripts/yarn.lock +++ b/scripts/yarn.lock @@ -2980,6 +2980,7 @@ __metadata: "@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 @@ -2993,7 +2994,6 @@ __metadata: "@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 @@ -3064,7 +3064,6 @@ __metadata: 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 @@ -3452,6 +3451,15 @@ __metadata: languageName: node linkType: hard +"@types/cross-spawn@npm:^6.0.2": + version: 6.0.2 + resolution: "@types/cross-spawn@npm:6.0.2" + dependencies: + "@types/node": "*" + checksum: 658bd49267a7200e87e67c48ef1e58ee7418bbd4417fb191393b7051d47f590023090cad7b69eb3821d1907b82392b764e1114b1ec6000b01e98126926c8b06f + languageName: node + linkType: hard + "@types/detect-port@npm:^1.3.2": version: 1.3.3 resolution: "@types/detect-port@npm:1.3.3" @@ -3516,7 +3524,7 @@ __metadata: languageName: node linkType: hard -"@types/glob@npm:^7.1.1, @types/glob@npm:~7.2.0": +"@types/glob@npm:^7.1.1": version: 7.2.0 resolution: "@types/glob@npm:7.2.0" dependencies: @@ -3823,16 +3831,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/stack-utils@npm:^2.0.0": version: 2.0.1 resolution: "@types/stack-utils@npm:2.0.1" @@ -8351,7 +8349,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.0.3, glob@npm:^7.1.2, glob@npm:^7.1.3, glob@npm:^7.1.4": version: 7.2.3 resolution: "glob@npm:7.2.3" dependencies: @@ -9008,13 +9006,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 - "ip@npm:^2.0.0": version: 2.0.0 resolution: "ip@npm:2.0.0" @@ -12953,15 +12944,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" @@ -13408,7 +13390,7 @@ __metadata: languageName: node linkType: hard -"resolve@npm:^1.1.6, resolve@npm:^1.10.0, resolve@npm:^1.12.0, resolve@npm:^1.14.2, resolve@npm:^1.20.0, resolve@npm:^1.22.1": +"resolve@npm:^1.10.0, resolve@npm:^1.12.0, resolve@npm:^1.14.2, resolve@npm:^1.20.0, resolve@npm:^1.22.1": version: 1.22.3 resolution: "resolve@npm:1.22.3" dependencies: @@ -13434,7 +13416,7 @@ __metadata: languageName: node linkType: hard -"resolve@patch:resolve@^1.1.6#~builtin, resolve@patch:resolve@^1.10.0#~builtin, resolve@patch:resolve@^1.12.0#~builtin, resolve@patch:resolve@^1.14.2#~builtin, resolve@patch:resolve@^1.20.0#~builtin, resolve@patch:resolve@^1.22.1#~builtin": +"resolve@patch:resolve@^1.10.0#~builtin, resolve@patch:resolve@^1.12.0#~builtin, resolve@patch:resolve@^1.14.2#~builtin, resolve@patch:resolve@^1.20.0#~builtin, resolve@patch:resolve@^1.22.1#~builtin": version: 1.22.3 resolution: "resolve@patch:resolve@npm%3A1.22.3#~builtin::version=1.22.3&hash=c3c19d" dependencies: @@ -13793,19 +13775,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"