From d3fa0bef4350fb6c3da306fdea44f7e8c65da769 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Sat, 5 Nov 2022 21:12:31 +1100 Subject: [PATCH 01/10] Use execa 6.x in `scripts` We need to use an obtuse method to import it as it is ESM only and `ts-node` doesn't play well with that. See https://github.com/TypeStrong/ts-node/discussions/1290 --- scripts/build-package.js | 2 +- scripts/check-package.js | 2 +- scripts/combine-compodoc.ts | 4 +- .../next-repro-generators/generate-repros.ts | 4 +- scripts/next-repro-generators/publish.ts | 8 +- scripts/next-repro-generators/utils/git.ts | 8 +- scripts/package.json | 2 +- scripts/utils/exec.ts | 22 +++++- scripts/utils/workspace.ts | 4 +- scripts/yarn.lock | 74 ++++++++++++++++++- 10 files changed, 107 insertions(+), 23 deletions(-) diff --git a/scripts/build-package.js b/scripts/build-package.js index 70468be2e0ea..3e9843b83282 100644 --- a/scripts/build-package.js +++ b/scripts/build-package.js @@ -115,7 +115,7 @@ async function run() { selection?.filter(Boolean).forEach(async (v) => { const commmand = (await readJSON(resolve(v.location, 'package.json'))).scripts.prep; const cwd = resolve(__dirname, '..', 'code', v.location); - const sub = require('execa').command( + const sub = await import('execa').execaCommand( `${commmand}${watchMode ? ' --watch' : ''}${prodMode ? ' --optimized' : ''}`, { cwd, diff --git a/scripts/check-package.js b/scripts/check-package.js index dc675d9bff1a..15c01f448384 100644 --- a/scripts/check-package.js +++ b/scripts/check-package.js @@ -98,7 +98,7 @@ async function run() { selection?.filter(Boolean).forEach(async (v) => { const commmand = (await readJSON(resolve(v.location, 'package.json'))).scripts.check; const cwd = resolve(__dirname, '..', 'code', v.location); - const sub = require('execa').command(`${commmand}${watchMode ? ' --watch' : ''}`, { + const sub = await require('execa').execaCommand(`${commmand}${watchMode ? ' --watch' : ''}`, { cwd, buffer: false, shell: true, diff --git a/scripts/combine-compodoc.ts b/scripts/combine-compodoc.ts index 79a02dc0c34c..b7558af7a670 100755 --- a/scripts/combine-compodoc.ts +++ b/scripts/combine-compodoc.ts @@ -3,7 +3,7 @@ // then combine the results into one large documentation.json import { join, resolve } from 'path'; -import execa from 'execa'; +import {execaCommand} from 'execa'; import { realpath, readFile, writeFile, lstat } from 'fs-extra'; import glob from 'glob'; import { directory } from 'tempy'; @@ -37,7 +37,7 @@ async function run(cwd: string) { dirs.map(async (dir) => { const outputDir = directory(); const resolvedDir = await realpath(dir); - await execa.command( + await execaCommand( `yarn compodoc ${resolvedDir} -p ./tsconfig.json -e json -d ${outputDir}`, { cwd } ); diff --git a/scripts/next-repro-generators/generate-repros.ts b/scripts/next-repro-generators/generate-repros.ts index d857944d6ba9..b14147d9e847 100755 --- a/scripts/next-repro-generators/generate-repros.ts +++ b/scripts/next-repro-generators/generate-repros.ts @@ -1,6 +1,6 @@ /* eslint-disable no-console */ import { join, relative } from 'path'; -import { command } from 'execa'; +import { execaCommand } from 'execa'; import type { Options as ExecaOptions } from 'execa'; import pLimit from 'p-limit'; import prettyTime from 'pretty-hrtime'; @@ -85,7 +85,7 @@ export const runCommand = async (script: string, options: ExecaOptions) => { console.log(`Running command: ${script}`); } - return command(script, { stdout: shouldDebug ? 'inherit' : 'ignore', shell: true, ...options }); + return execaCommand(script, { stdout: shouldDebug ? 'inherit' : 'ignore', shell: true, ...options }); }; const addDocumentation = async ( diff --git a/scripts/next-repro-generators/publish.ts b/scripts/next-repro-generators/publish.ts index 72aee2720b78..75bf2a606570 100755 --- a/scripts/next-repro-generators/publish.ts +++ b/scripts/next-repro-generators/publish.ts @@ -1,7 +1,7 @@ import program from 'commander'; import { join } from 'path'; import { existsSync } from 'fs'; -import { command } from 'execa'; +import { execaCommand } from '../utils/exec'; import * as tempy from 'tempy'; import { copy, emptyDir, readdir, remove, stat, writeFile } from 'fs-extra'; @@ -27,8 +27,8 @@ const publish = async (options: PublishOptions & { tmpFolder: string }) => { const templatesData = await getTemplatesData(); logger.log(`👯‍♂️ Cloning the repository ${remote} in branch ${gitBranch}`); - await command(`git clone ${remote} .`, { cwd: tmpFolder }); - await command(`git checkout ${gitBranch}`, { cwd: tmpFolder }); + await execaCommand(`git clone ${remote} .`, { cwd: tmpFolder }); + await execaCommand(`git checkout ${gitBranch}`, { cwd: tmpFolder }); // otherwise old files will stick around and result inconsistent states logger.log(`🗑 Delete existing template dirs from clone`); @@ -67,7 +67,7 @@ const publish = async (options: PublishOptions & { tmpFolder: string }) => { `); if (push) { - await command(`git push --set-upstream origin ${gitBranch}`, { + await execaCommand(`git push --set-upstream origin ${gitBranch}`, { cwd: tmpFolder, }); const remoteRepoUrl = `${remote.replace('.git', '')}/tree/${gitBranch}`; diff --git a/scripts/next-repro-generators/utils/git.ts b/scripts/next-repro-generators/utils/git.ts index 728034765652..bb828a7b6858 100644 --- a/scripts/next-repro-generators/utils/git.ts +++ b/scripts/next-repro-generators/utils/git.ts @@ -1,14 +1,14 @@ -import { command } from 'execa'; +import { execaCommand } from '../../utils/exec'; import { logger } from '../publish'; export async function commitAllToGit(cwd: string) { try { logger.log(`💪 Committing everything to the repository`); - await command('git add .', { cwd }); + await execaCommand('git add .', { cwd }); - const currentCommitSHA = await command('git rev-parse HEAD'); - await command( + const currentCommitSHA = await execaCommand('git rev-parse HEAD'); + await execaCommand( `git commit -m "Update examples - ${new Date().toDateString()} - ${currentCommitSHA.stdout .toString() .slice(0, 12)}"`, diff --git a/scripts/package.json b/scripts/package.json index e7190c1c757e..e8004c3a3b1c 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -115,7 +115,7 @@ "eslint-plugin-import": "^2.26.0", "eslint-plugin-react": "^7.31.10", "eslint-plugin-storybook": "^0.6.6", - "execa": "^5.0.0", + "execa": "^6.1.0", "express": "^4.17.1", "find-up": "^5.0.0", "fs-extra": "^9.0.1", diff --git a/scripts/utils/exec.ts b/scripts/utils/exec.ts index ca1fdb79d1ac..e2911a095f32 100644 --- a/scripts/utils/exec.ts +++ b/scripts/utils/exec.ts @@ -1,5 +1,5 @@ /* eslint-disable no-await-in-loop, no-restricted-syntax */ -import execa, { ExecaChildProcess, Options } from 'execa'; +import type { ExecaChildProcess, ExecaReturnValue, Options } from 'execa'; import chalk from 'chalk'; const logger = console; @@ -12,11 +12,25 @@ type StepOptions = { signal?: AbortSignal; }; +const dynamicImport = new Function('specifier', 'return import(specifier)'); +export const getExeca = async () => (await dynamicImport('execa')) as typeof import('execa'); + +// Reimplementation of `execaCommand` to use `getExeca` +export const execaCommand = async ( + command: string, + options: Options = {} +): Promise> => { + const { execaCommand } = await getExeca(); + // We await here because execaCommand returns a promise, but that's not what the user expects + return await execaCommand(command, options); +}; + export const exec = async ( command: string | string[], options: Options = {}, { startMessage, errorMessage, dryRun, debug, signal }: StepOptions = {} ): Promise => { + const execa = await getExeca() logger.info(); if (startMessage) logger.info(startMessage); @@ -30,7 +44,7 @@ export const exec = async ( stdout: debug ? 'inherit' : 'pipe', stderr: debug ? 'inherit' : 'pipe', }; - let currentChild: ExecaChildProcess; + let currentChild: ExecaChildProcess; // Newer versions of execa have explicit support for abort signals, but this works if (signal) { @@ -40,12 +54,12 @@ export const exec = async ( try { if (typeof command === 'string') { logger.debug(`> ${command}`); - currentChild = execa.command(command, { ...defaultOptions, ...options }); + currentChild = execa.execaCommand(command, { ...defaultOptions, ...options }); await currentChild; } else { for (const subcommand of command) { logger.debug(`> ${subcommand}`); - currentChild = execa.command(subcommand, { ...defaultOptions, ...options }); + currentChild = execa.execaCommand(subcommand, { ...defaultOptions, ...options }); await currentChild; } } diff --git a/scripts/utils/workspace.ts b/scripts/utils/workspace.ts index 982cdbc2fc5c..40fa0d159f19 100644 --- a/scripts/utils/workspace.ts +++ b/scripts/utils/workspace.ts @@ -1,4 +1,4 @@ -import command from 'execa'; +import { execaCommand } from './exec'; import memoize from 'memoizerific'; import { resolve } from 'path'; @@ -7,7 +7,7 @@ export type Workspace = { name: string; location: string }; const codeDir = resolve(__dirname, '../../code'); async function getWorkspaces() { - const { stdout } = await command('yarn workspaces list --json', { + const { stdout } = await execaCommand('yarn workspaces list --json', { cwd: codeDir, shell: true, }); diff --git a/scripts/yarn.lock b/scripts/yarn.lock index fb167307ddc9..2ab573c537fa 100644 --- a/scripts/yarn.lock +++ b/scripts/yarn.lock @@ -3399,7 +3399,7 @@ __metadata: eslint-plugin-import: ^2.26.0 eslint-plugin-react: ^7.31.10 eslint-plugin-storybook: ^0.6.6 - execa: ^5.0.0 + execa: ^6.1.0 express: ^4.17.1 find-up: ^5.0.0 fs-extra: ^9.0.1 @@ -8846,6 +8846,23 @@ __metadata: languageName: node linkType: hard +"execa@npm:^6.1.0": + version: 6.1.0 + resolution: "execa@npm:6.1.0" + dependencies: + cross-spawn: ^7.0.3 + get-stream: ^6.0.1 + human-signals: ^3.0.1 + is-stream: ^3.0.0 + merge-stream: ^2.0.0 + npm-run-path: ^5.1.0 + onetime: ^6.0.0 + signal-exit: ^3.0.7 + strip-final-newline: ^3.0.0 + checksum: 004ee32092af745766a1b0352fdba8701a4001bc3fe08e63101c04276d4c860bbe11bb8ab85f37acdff13d3da83d60e044041dcf24bd7e25e645a543828d9c41 + languageName: node + linkType: hard + "exit@npm:^0.1.2": version: 0.1.2 resolution: "exit@npm:0.1.2" @@ -9747,7 +9764,7 @@ __metadata: languageName: node linkType: hard -"get-stream@npm:^6.0.0": +"get-stream@npm:^6.0.0, get-stream@npm:^6.0.1": version: 6.0.1 resolution: "get-stream@npm:6.0.1" checksum: 49825d57d3fd6964228e6200a58169464b8e8970489b3acdc24906c782fb7f01f9f56f8e6653c4a50713771d6658f7cfe051e5eb8c12e334138c9c918b296341 @@ -10539,6 +10556,13 @@ __metadata: languageName: node linkType: hard +"human-signals@npm:^3.0.1": + version: 3.0.1 + resolution: "human-signals@npm:3.0.1" + checksum: 0bb27e72aea1666322f69ab9816e05df952ef2160346f2293f98f45d472edb1b62d0f1a596697b50d48d8f8222e6db3b9f9dc0b6bf6113866121001f0a8e48e9 + languageName: node + linkType: hard + "humanize-ms@npm:^1.2.1": version: 1.2.1 resolution: "humanize-ms@npm:1.2.1" @@ -11191,6 +11215,13 @@ __metadata: languageName: node linkType: hard +"is-stream@npm:^3.0.0": + version: 3.0.0 + resolution: "is-stream@npm:3.0.0" + checksum: eb2f7127af02ee9aa2a0237b730e47ac2de0d4e76a4a905a50a11557f2339df5765eaea4ceb8029f1efa978586abe776908720bfcb1900c20c6ec5145f6f29d8 + languageName: node + linkType: hard + "is-string@npm:^1.0.5, is-string@npm:^1.0.7": version: 1.0.7 resolution: "is-string@npm:1.0.7" @@ -14111,6 +14142,13 @@ __metadata: languageName: node linkType: hard +"mimic-fn@npm:^4.0.0": + version: 4.0.0 + resolution: "mimic-fn@npm:4.0.0" + checksum: de9cc32be9996fd941e512248338e43407f63f6d497abe8441fa33447d922e927de54d4cc3c1a3c6d652857acd770389d5a3823f311a744132760ce2be15ccbf + languageName: node + linkType: hard + "min-document@npm:^2.19.0": version: 2.19.0 resolution: "min-document@npm:2.19.0" @@ -14725,6 +14763,15 @@ __metadata: languageName: node linkType: hard +"npm-run-path@npm:^5.1.0": + version: 5.1.0 + resolution: "npm-run-path@npm:5.1.0" + dependencies: + path-key: ^4.0.0 + checksum: ff6d77514489f47fa1c3b1311d09cd4b6d09a874cc1866260f9dea12cbaabda0436ed7f8c2ee44d147bf99a3af29307c6f63b0f83d242b0b6b0ab25dff2629e3 + languageName: node + linkType: hard + "npmlog@npm:^5.0.1": version: 5.0.1 resolution: "npmlog@npm:5.0.1" @@ -14997,6 +15044,15 @@ __metadata: languageName: node linkType: hard +"onetime@npm:^6.0.0": + version: 6.0.0 + resolution: "onetime@npm:6.0.0" + dependencies: + mimic-fn: ^4.0.0 + checksum: 4eef7c6abfef697dd4479345a4100c382d73c149d2d56170a54a07418c50816937ad09500e1ed1e79d235989d073a9bade8557122aee24f0576ecde0f392bb6c + languageName: node + linkType: hard + "open@npm:8.4.0, open@npm:^8.4.0": version: 8.4.0 resolution: "open@npm:8.4.0" @@ -15385,6 +15441,13 @@ __metadata: languageName: node linkType: hard +"path-key@npm:^4.0.0": + version: 4.0.0 + resolution: "path-key@npm:4.0.0" + checksum: 794efeef32863a65ac312f3c0b0a99f921f3e827ff63afa5cb09a377e202c262b671f7b3832a4e64731003fa94af0263713962d317b9887bd1e0c48a342efba3 + languageName: node + linkType: hard + "path-parse@npm:^1.0.7": version: 1.0.7 resolution: "path-parse@npm:1.0.7" @@ -18009,6 +18072,13 @@ __metadata: languageName: node linkType: hard +"strip-final-newline@npm:^3.0.0": + version: 3.0.0 + resolution: "strip-final-newline@npm:3.0.0" + checksum: a771a17901427bac6293fd416db7577e2bc1c34a19d38351e9d5478c3c415f523f391003b42ed475f27e33a78233035df183525395f731d3bfb8cdcbd4da08ce + languageName: node + linkType: hard + "strip-indent@npm:^3.0.0": version: 3.0.0 resolution: "strip-indent@npm:3.0.0" From 7dd02bcbcced9998cc1097d82424832295eb7b1f Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Sat, 5 Nov 2022 21:14:21 +1100 Subject: [PATCH 02/10] Fix `require` to async `import` --- scripts/check-package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-package.js b/scripts/check-package.js index 15c01f448384..1cee8b12cd9b 100644 --- a/scripts/check-package.js +++ b/scripts/check-package.js @@ -98,7 +98,7 @@ async function run() { selection?.filter(Boolean).forEach(async (v) => { const commmand = (await readJSON(resolve(v.location, 'package.json'))).scripts.check; const cwd = resolve(__dirname, '..', 'code', v.location); - const sub = await require('execa').execaCommand(`${commmand}${watchMode ? ' --watch' : ''}`, { + const sub = await import('execa').execaCommand(`${commmand}${watchMode ? ' --watch' : ''}`, { cwd, buffer: false, shell: true, From dc7ebb75691dbb72aeef73e60918ef2281da91aa Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Sat, 5 Nov 2022 21:15:27 +1100 Subject: [PATCH 03/10] Some fixes --- scripts/combine-compodoc.ts | 2 +- scripts/utils/exec.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/combine-compodoc.ts b/scripts/combine-compodoc.ts index b7558af7a670..5e13f16ac229 100755 --- a/scripts/combine-compodoc.ts +++ b/scripts/combine-compodoc.ts @@ -3,7 +3,7 @@ // then combine the results into one large documentation.json import { join, resolve } from 'path'; -import {execaCommand} from 'execa'; +import { execaCommand } from 'execa'; import { realpath, readFile, writeFile, lstat } from 'fs-extra'; import glob from 'glob'; import { directory } from 'tempy'; diff --git a/scripts/utils/exec.ts b/scripts/utils/exec.ts index e2911a095f32..5f6851ed3836 100644 --- a/scripts/utils/exec.ts +++ b/scripts/utils/exec.ts @@ -12,6 +12,8 @@ type StepOptions = { signal?: AbortSignal; }; +// Note this is to fool `ts-node` into not turning the `import()` into a `require()`. +// See: https://github.com/TypeStrong/ts-node/discussions/1290 const dynamicImport = new Function('specifier', 'return import(specifier)'); export const getExeca = async () => (await dynamicImport('execa')) as typeof import('execa'); From 93aa6cad860138301bf717103cb35b1c98f8b38f Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Sat, 5 Nov 2022 21:19:23 +1100 Subject: [PATCH 04/10] Deepscan --- scripts/utils/exec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/utils/exec.ts b/scripts/utils/exec.ts index 5f6851ed3836..956bca51d47e 100644 --- a/scripts/utils/exec.ts +++ b/scripts/utils/exec.ts @@ -1,5 +1,5 @@ /* eslint-disable no-await-in-loop, no-restricted-syntax */ -import type { ExecaChildProcess, ExecaReturnValue, Options } from 'execa'; +import type { ExecaChildProcess, Options } from 'execa'; import chalk from 'chalk'; const logger = console; From 4ab4bf1fd57ed4643c561661e76fe440ccdd8b51 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Wed, 9 Nov 2022 13:53:52 +1100 Subject: [PATCH 05/10] Import `execaCommand` from utils in couple places --- scripts/combine-compodoc.ts | 2 +- scripts/next-repro-generators/generate-repros.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/combine-compodoc.ts b/scripts/combine-compodoc.ts index 5e13f16ac229..7dd04a7f509b 100755 --- a/scripts/combine-compodoc.ts +++ b/scripts/combine-compodoc.ts @@ -3,7 +3,7 @@ // then combine the results into one large documentation.json import { join, resolve } from 'path'; -import { execaCommand } from 'execa'; +import { execaCommand } from './utils/exec'; import { realpath, readFile, writeFile, lstat } from 'fs-extra'; import glob from 'glob'; import { directory } from 'tempy'; diff --git a/scripts/next-repro-generators/generate-repros.ts b/scripts/next-repro-generators/generate-repros.ts index b14147d9e847..780f0ea8835a 100755 --- a/scripts/next-repro-generators/generate-repros.ts +++ b/scripts/next-repro-generators/generate-repros.ts @@ -1,6 +1,6 @@ /* eslint-disable no-console */ import { join, relative } from 'path'; -import { execaCommand } from 'execa'; +import { execaCommand } from '../utils/exec'; import type { Options as ExecaOptions } from 'execa'; import pLimit from 'p-limit'; import prettyTime from 'pretty-hrtime'; From f1017f15d0a3552882efc08f1ef9674084c32c6d Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Wed, 9 Nov 2022 14:27:19 +1100 Subject: [PATCH 06/10] Update build scripts to async import execa --- scripts/utils/compile-babel.js | 5 +++-- scripts/utils/compile-tsc.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/utils/compile-babel.js b/scripts/utils/compile-babel.js index 269b38168708..d402e079159b 100644 --- a/scripts/utils/compile-babel.js +++ b/scripts/utils/compile-babel.js @@ -1,7 +1,6 @@ /* eslint-disable no-console */ const fs = require('fs-extra'); const path = require('path'); -const execa = require('execa'); const { join } = require('path'); function getCommand(watch, dir) { @@ -55,11 +54,13 @@ function handleExit(code, stderr, errorCallback) { } async function run({ watch, dir, silent, errorCallback }) { + const execa = await import('execa'); + return new Promise((resolve, reject) => { const command = getCommand(watch, dir); if (command !== '') { - const child = execa.command(command, { + const child = execa.execaCommand(command, { cwd: join(__dirname, '..'), buffer: false, env: { BABEL_MODE: path.basename(dir) }, diff --git a/scripts/utils/compile-tsc.js b/scripts/utils/compile-tsc.js index bdc824f143b5..a0bdf95e17f8 100644 --- a/scripts/utils/compile-tsc.js +++ b/scripts/utils/compile-tsc.js @@ -1,7 +1,6 @@ /* eslint-disable no-console */ const fs = require('fs-extra'); const path = require('path'); -const execa = require('execa'); function getCommand(watch) { const args = [ @@ -41,11 +40,13 @@ function handleExit(code, stderr, errorCallback) { } async function run({ optimized, watch, silent, errorCallback }) { + const execa = await import('execa'); + return new Promise((resolve, reject) => { const [command, tscOnly] = getCommand(watch); if (tscOnly || optimized) { - const child = execa.command(command, { + const child = execa.execaCommand(command, { buffer: false, }); let stderr = ''; From c54a59eaa651ec1e9d636ca90871dc057439323b Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Wed, 9 Nov 2022 15:02:32 +1100 Subject: [PATCH 07/10] Switch to new abort signal API --- scripts/utils/exec.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/scripts/utils/exec.ts b/scripts/utils/exec.ts index 57fde21f0c5e..cf2f5e4bd624 100644 --- a/scripts/utils/exec.ts +++ b/scripts/utils/exec.ts @@ -23,10 +23,10 @@ export const execaCommand = async ( command: string, options: Options = {} ): Promise> => { - const { execaCommand } = await getExeca(); + const execa = await getExeca(); // We await here because execaCommand returns a promise, but that's not what the user expects // eslint-disable-next-line @typescript-eslint/return-await - return await execaCommand(command, options); + return await execa.execaCommand(command, options); }; export const exec = async ( @@ -47,14 +47,10 @@ export const exec = async ( shell: true, stdout: debug ? 'inherit' : 'pipe', stderr: debug ? 'inherit' : 'pipe', + signal, }; let currentChild: ExecaChildProcess; - // Newer versions of execa have explicit support for abort signals, but this works - if (signal) { - signal.addEventListener('abort', () => currentChild.kill()); - } - try { if (typeof command === 'string') { logger.debug(`> ${command}`); From 97015329f93aa53750f1a48d21d4dfe7f4b7697c Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Wed, 9 Nov 2022 15:27:56 +1100 Subject: [PATCH 08/10] Don't need `node-abort-controller` any more --- scripts/next-repro-generators/generate-repros.ts | 9 ++++++--- scripts/package.json | 1 - scripts/task.ts | 1 - scripts/tasks/dev.ts | 1 - scripts/tasks/run-registry.ts | 1 - scripts/tasks/sandbox.ts | 2 ++ scripts/tasks/serve.ts | 1 - scripts/yarn.lock | 8 -------- 8 files changed, 8 insertions(+), 16 deletions(-) diff --git a/scripts/next-repro-generators/generate-repros.ts b/scripts/next-repro-generators/generate-repros.ts index 66f649763329..03a83f480b6d 100755 --- a/scripts/next-repro-generators/generate-repros.ts +++ b/scripts/next-repro-generators/generate-repros.ts @@ -1,13 +1,12 @@ /* eslint-disable no-console */ import { join, relative } from 'path'; -import { execaCommand } from '../utils/exec'; import type { Options as ExecaOptions } from 'execa'; import pLimit from 'p-limit'; import prettyTime from 'pretty-hrtime'; import { copy, emptyDir, ensureDir, move, remove, rename, writeFile } from 'fs-extra'; import { program } from 'commander'; -import type { AbortController } from 'node-abort-controller'; import { directory } from 'tempy'; +import { execaCommand } from '../utils/exec'; import { allTemplates as reproTemplates } from '../../code/lib/cli/src/repro-templates'; import storybookVersions from '../../code/lib/cli/src/versions'; @@ -85,7 +84,11 @@ export const runCommand = async (script: string, options: ExecaOptions) => { console.log(`Running command: ${script}`); } - return execaCommand(script, { stdout: shouldDebug ? 'inherit' : 'ignore', shell: true, ...options }); + return execaCommand(script, { + stdout: shouldDebug ? 'inherit' : 'ignore', + shell: true, + ...options, + }); }; const addDocumentation = async ( diff --git a/scripts/package.json b/scripts/package.json index e8004c3a3b1c..3a5a8696e48a 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -140,7 +140,6 @@ "lodash": "^4.17.21", "memoizerific": "^1.11.3", "mocha-list-tests": "^1.0.5", - "node-abort-controller": "^3.0.1", "node-cleanup": "^2.1.2", "node-fetch": "^2.6.1", "node-gyp": "^8.4.0", diff --git a/scripts/task.ts b/scripts/task.ts index cb8d9412e6e6..d056dd7ae96c 100644 --- a/scripts/task.ts +++ b/scripts/task.ts @@ -1,5 +1,4 @@ /* eslint-disable no-await-in-loop */ -import type { AbortController } from 'node-abort-controller'; import { getJunitXml } from 'junit-xml'; import { outputFile, readFile, pathExists } from 'fs-extra'; import { join, resolve } from 'path'; diff --git a/scripts/tasks/dev.ts b/scripts/tasks/dev.ts index 64bf8dd59dac..67dac5d2a255 100644 --- a/scripts/tasks/dev.ts +++ b/scripts/tasks/dev.ts @@ -1,4 +1,3 @@ -import { AbortController } from 'node-abort-controller'; import detectFreePort from 'detect-port'; import type { Task } from '../task'; diff --git a/scripts/tasks/run-registry.ts b/scripts/tasks/run-registry.ts index b98325869a22..8d5cd7909574 100644 --- a/scripts/tasks/run-registry.ts +++ b/scripts/tasks/run-registry.ts @@ -1,4 +1,3 @@ -import { AbortController } from 'node-abort-controller'; import detectFreePort from 'detect-port'; import { resolve } from 'path'; diff --git a/scripts/tasks/sandbox.ts b/scripts/tasks/sandbox.ts index 2ad9d437fe94..cf657e2cf423 100644 --- a/scripts/tasks/sandbox.ts +++ b/scripts/tasks/sandbox.ts @@ -17,6 +17,8 @@ export const sandbox: Task = { } const { create, install, addStories } = await import('./sandbox-parts'); + while (true); + await create(details, options); await install(details, options); await addStories(details, options); diff --git a/scripts/tasks/serve.ts b/scripts/tasks/serve.ts index f7aa5db7bdc5..fd630f6e7301 100644 --- a/scripts/tasks/serve.ts +++ b/scripts/tasks/serve.ts @@ -1,4 +1,3 @@ -import { AbortController } from 'node-abort-controller'; import detectFreePort from 'detect-port'; import type { Task } from '../task'; diff --git a/scripts/yarn.lock b/scripts/yarn.lock index 2ab573c537fa..33682b64b50c 100644 --- a/scripts/yarn.lock +++ b/scripts/yarn.lock @@ -3424,7 +3424,6 @@ __metadata: lodash: ^4.17.21 memoizerific: ^1.11.3 mocha-list-tests: ^1.0.5 - node-abort-controller: ^3.0.1 node-cleanup: ^2.1.2 node-fetch: ^2.6.1 node-gyp: ^8.4.0 @@ -14534,13 +14533,6 @@ __metadata: languageName: node linkType: hard -"node-abort-controller@npm:^3.0.1": - version: 3.0.1 - resolution: "node-abort-controller@npm:3.0.1" - checksum: 37f895533f7a18a2d83fa4853da1cc00fcae1e0a71553f9ffc94d3153f5fc886d6d4ef3a33bf60c38be161fab78c5b2275cbbf2359351fb12f5edad68d88d8ca - languageName: node - linkType: hard - "node-addon-api@npm:^3.2.1": version: 3.2.1 resolution: "node-addon-api@npm:3.2.1" From f1ea8e19cad6a340ecba234f8f9e1b5d5f3e6770 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Thu, 10 Nov 2022 11:10:13 +1100 Subject: [PATCH 09/10] WIP --- scripts/task.ts | 9 +++++---- scripts/tasks/run-registry.ts | 2 +- scripts/tasks/sandbox.ts | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/task.ts b/scripts/task.ts index d056dd7ae96c..597483401a27 100644 --- a/scripts/task.ts +++ b/scripts/task.ts @@ -445,6 +445,7 @@ async function run() { ); } + console.log('exiting 1'); controllers.forEach((controller) => { controller.abort(); }); @@ -458,11 +459,11 @@ async function run() { await new Promise(() => {}); } } - controllers.forEach((controller) => { - controller.abort(); - }); } - + console.log('exiting 0'); + controllers.forEach((controller) => { + controller.abort(); + }); return 0; } diff --git a/scripts/tasks/run-registry.ts b/scripts/tasks/run-registry.ts index 8d5cd7909574..750765ecb6b4 100644 --- a/scripts/tasks/run-registry.ts +++ b/scripts/tasks/run-registry.ts @@ -12,7 +12,7 @@ export async function runRegistry({ dryRun, debug }: { dryRun?: boolean; debug?: exec( 'CI=true yarn local-registry --open', { cwd: codeDir }, - { dryRun, debug, signal: controller.signal as AbortSignal } + { dryRun, debug, signal: controller.signal } ).catch((err) => { // If aborted, we want to make sure the rejection is handled. if (!err.killed) throw err; diff --git a/scripts/tasks/sandbox.ts b/scripts/tasks/sandbox.ts index cf657e2cf423..5c1795649601 100644 --- a/scripts/tasks/sandbox.ts +++ b/scripts/tasks/sandbox.ts @@ -17,7 +17,7 @@ export const sandbox: Task = { } const { create, install, addStories } = await import('./sandbox-parts'); - while (true); + // while (true); await create(details, options); await install(details, options); From 556d7df8c4db3a5afea2c66ce57f38bb30434424 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Mon, 21 Nov 2022 21:22:07 +1100 Subject: [PATCH 10/10] Remove debugging logs --- scripts/task.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/task.ts b/scripts/task.ts index 3defcc6bd6bb..a01a07fba690 100644 --- a/scripts/task.ts +++ b/scripts/task.ts @@ -456,7 +456,6 @@ async function run() { ); } - console.log('exiting 1'); controllers.forEach((controller) => { controller.abort(); }); @@ -471,7 +470,6 @@ async function run() { } } } - console.log('exiting 0'); controllers.forEach((controller) => { controller.abort(); });