From 584d54053b0e0bde5fecffaaae94eff128fa0be7 Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Fri, 19 Aug 2022 12:11:23 +0100 Subject: [PATCH 1/3] update execa --- package.json | 2 +- yarn.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8b9ab67e..8c591c6f 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "eslint": "^8.22.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-prettier": "^4.2.1", - "execa": "^5.0.0", + "execa": "^6.1.0", "jest": "^28.1.3", "prettier": "^2.7.1", "release-it": "^15.3.0", diff --git a/yarn.lock b/yarn.lock index c0dbd671..b95d1a3b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2999,7 +2999,7 @@ esutils@^2.0.2: resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== -execa@6.1.0: +execa@6.1.0, execa@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/execa/-/execa-6.1.0.tgz#cea16dee211ff011246556388effa0818394fb20" integrity sha512-QVWlX2e50heYJcCPG0iWtf8r0xjEYfz/OYLGDYH+IyjWezzPNxz63qNFOu0l4YftGWuizFVZHHs8PrLU5p2IDA== From 5be447521eabfb3c27463096850d5a6cb4406273 Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Fri, 19 Aug 2022 15:05:37 +0100 Subject: [PATCH 2/3] update test:integration to work with latest execa --- package.json | 2 +- test/run-test.js | 59 ----------------------------------------------- test/run-test.mjs | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 60 deletions(-) delete mode 100644 test/run-test.js create mode 100644 test/run-test.mjs diff --git a/package.json b/package.json index 8c591c6f..8bd57945 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "lint": "eslint . --cache", "release": "release-it", "test": "codemod-cli test --coverage", - "test:integration": "node ./test/run-test.js", + "test:integration": "node ./test/run-test.mjs", "test:notelemetry": " node ./test/run-test-without-telemetry.js" }, "jest": { diff --git a/test/run-test.js b/test/run-test.js deleted file mode 100644 index c3f57fbb..00000000 --- a/test/run-test.js +++ /dev/null @@ -1,59 +0,0 @@ -/* eslint-disable no-console */ - -const { spawn } = require('child_process'); -const execa = require('execa'); -const path = require('path'); - -// resolved from the root of the project -const inputDir = path.resolve('./test/fixtures/input'); -const execOpts = { cwd: inputDir, stderr: 'inherit' }; - -(async () => { - console.log('installing deps'); - - await execa('rm', ['-rf', 'node_modules'], execOpts); - await execa('yarn', ['install'], execOpts); - - console.log('starting serve'); - - // We use spawn for this one so we can kill it later without throwing an error - const emberServe = spawn('yarn', ['start'], execOpts); - emberServe.stderr.pipe(process.stderr); - emberServe.stdout.pipe(process.stdout); - - await new Promise((resolve) => { - emberServe.stdout.on('data', (data) => { - if (data.toString().includes('Build successful')) { - resolve(); - } - }); - }); - - console.log('running codemod'); - - const codemod = execa( - '../../../bin/cli.js', - ['--telemetry', 'http://localhost:4200', 'app'], - execOpts - ); - codemod.stdout.pipe(process.stdout); - await codemod; - - console.log('codemod complete, ending serve'); - - emberServe.kill('SIGTERM'); - - console.log('comparing results'); - - try { - await execa('diff', ['-rq', './app', '../output/app'], execOpts); - } catch (e) { - console.error('codemod did not run successfully'); - console.log(e); - - process.exit(1); - } - - console.log('codemod ran successfully! 🎉'); - process.exit(0); -})(); diff --git a/test/run-test.mjs b/test/run-test.mjs new file mode 100644 index 00000000..b75de36b --- /dev/null +++ b/test/run-test.mjs @@ -0,0 +1,58 @@ +/* eslint-disable no-console */ + +import { spawn } from 'child_process'; +import { execa } from 'execa'; +import path from 'path'; + +// resolved from the root of the project +const inputDir = path.resolve('./test/fixtures/input'); +const execOpts = { cwd: inputDir, stderr: 'inherit' }; + + +console.log('installing deps'); + +await execa('rm', ['-rf', 'node_modules'], execOpts); +await execa('yarn', ['install'], execOpts); + +console.log('starting serve'); + +// We use spawn for this one so we can kill it later without throwing an error +const emberServe = spawn('yarn', ['start'], execOpts); +emberServe.stderr.pipe(process.stderr); +emberServe.stdout.pipe(process.stdout); + +await new Promise((resolve) => { + emberServe.stdout.on('data', (data) => { + if (data.toString().includes('Build successful')) { + resolve(); + } + }); +}); + +console.log('running codemod'); + +const codemod = execa( + '../../../bin/cli.js', + ['--telemetry', 'http://localhost:4200', 'app'], + execOpts +); +codemod.stdout.pipe(process.stdout); +await codemod; + +console.log('codemod complete, ending serve'); + +emberServe.kill('SIGTERM'); + +console.log('comparing results'); + +try { + await execa('diff', ['-rq', './app', '../output/app'], execOpts); +} catch (e) { + console.error('codemod did not run successfully'); + console.log(e); + + process.exit(1); +} + +console.log('codemod ran successfully! 🎉'); +process.exit(0); From d35bfdb883a1d76fc9691bb17c09a2de1d27b9ef Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Fri, 19 Aug 2022 15:08:34 +0100 Subject: [PATCH 3/3] fix test:notelemetry script to work with latest execa --- package.json | 2 +- test/run-test-without-telemetry.js | 33 ----------------------------- test/run-test-without-telemetry.mjs | 30 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 34 deletions(-) delete mode 100644 test/run-test-without-telemetry.js create mode 100644 test/run-test-without-telemetry.mjs diff --git a/package.json b/package.json index 8bd57945..5af59130 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "release": "release-it", "test": "codemod-cli test --coverage", "test:integration": "node ./test/run-test.mjs", - "test:notelemetry": " node ./test/run-test-without-telemetry.js" + "test:notelemetry": " node ./test/run-test-without-telemetry.mjs" }, "jest": { "collectCoverageFrom": [ diff --git a/test/run-test-without-telemetry.js b/test/run-test-without-telemetry.js deleted file mode 100644 index a89f930d..00000000 --- a/test/run-test-without-telemetry.js +++ /dev/null @@ -1,33 +0,0 @@ -/* eslint-disable no-console */ - -const execa = require('execa'); -const path = require('path'); - -// resolved from the root of the project -const inputDir = path.resolve('./test/fixtures/without-telemetry/input'); -const binPath = path.resolve('./bin/cli.js'); -const execOpts = { cwd: inputDir, stderr: 'inherit' }; - -(async () => { - console.log('running codemod'); - - const codemod = execa(binPath, ['app'], execOpts); - codemod.stdout.pipe(process.stdout); - await codemod; - - console.log('codemod complete'); - - console.log('comparing results'); - - try { - await execa('diff', ['-rq', './app', '../output/app'], execOpts); - } catch (e) { - console.error('codemod did not run successfully'); - console.log(e); - - process.exit(1); - } - - console.log('codemod ran successfully! 🎉'); - process.exit(0); -})(); diff --git a/test/run-test-without-telemetry.mjs b/test/run-test-without-telemetry.mjs new file mode 100644 index 00000000..99dd1c38 --- /dev/null +++ b/test/run-test-without-telemetry.mjs @@ -0,0 +1,30 @@ +/* eslint-disable no-console */ +import { execa } from 'execa'; +import path from 'path'; + +// resolved from the root of the project +const inputDir = path.resolve('./test/fixtures/without-telemetry/input'); +const binPath = path.resolve('./bin/cli.js'); +const execOpts = { cwd: inputDir, stderr: 'inherit' }; + +console.log('running codemod'); + +const codemod = execa(binPath, ['app'], execOpts); +codemod.stdout.pipe(process.stdout); +await codemod; + +console.log('codemod complete'); + +console.log('comparing results'); + +try { + await execa('diff', ['-rq', './app', '../output/app'], execOpts); +} catch (e) { + console.error('codemod did not run successfully'); + console.log(e); + + process.exit(1); +} + +console.log('codemod ran successfully! 🎉'); +process.exit(0);