From 447599c021e7c257d0d137025a26a31e8c6d4a61 Mon Sep 17 00:00:00 2001 From: Kelly Selden Date: Sun, 17 Nov 2019 22:38:13 +0000 Subject: [PATCH] wip --- .vscode/launch.json | 2 +- manifest.json | 2 +- test/tests.js | 31 ++++++++++++++++++++++--------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 934f8ce..fa9b56a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -15,7 +15,7 @@ "--colors", "test/tests.js", "-f", - "ember-modules-codemod" + "ember-no-implicit-this-codemod" ], "env": { "DEBUG": "ember-cli-update,boilerplate-update,git-diff-apply,git-fixtures" diff --git a/manifest.json b/manifest.json index d2beb74..d36a5ec 100644 --- a/manifest.json +++ b/manifest.json @@ -128,6 +128,6 @@ }, "projectOptions": ["app", "addon"], "nodeVersion": "8.0.0", - "script": "let ps = execa.command('ember s', { stderr: 'inherit' }); ps.stdout.pipe(process.stdout); try { let url = await new Promise((resolve, reject) => { ps.stdout.on('data', data => { let str = data.toString(); let matches = str.match(/^Build successful \\(\\d+ms\\) – Serving on (.*)$/m); if (matches) { resolve(matches[1]); } }); ps.once('error', reject); ps.once('exit', reject); }); await execa.command(`npx ember-no-implicit-this-codemod ${url} app/`, { stdio: 'inherit' }); } finally { if (!ps.exitCode) { ps.kill(); await new Promise(resolve => { ps.once('exit', resolve); }); } }" + "script": "let ps = execa.command(\"ember s\", { stderr: \"inherit\" }); ps.stdout.pipe(process.stdout); try { let url = await new Promise((resolve, reject) => { ps.stdout.on(\"data\", data => { let str = data.toString(); let matches = str.match(/^Build successful \\(\\d+ms\\) – Serving on (.*)$/m); if (matches) { resolve(matches[1]); } }); ps.once(\"error\", reject); ps.once(\"exit\", reject); }); await execa.command(`npx ember-no-implicit-this-codemod ${url} app/`, { stdio: \"inherit\" }); } finally { if (!ps.exitCode) { ps.kill(); await new Promise(resolve => { ps.once(\"exit\", resolve); }); } }" } } diff --git a/test/tests.js b/test/tests.js index 230b923..36780ed 100644 --- a/test/tests.js +++ b/test/tests.js @@ -13,11 +13,12 @@ const { assertCodemodRan } = require('./helpers/assertions'); const manifest = require('../manifest'); +const run = require('ember-cli-update/src/run'); const codemods = Object.keys(manifest); describe('runs codemods', function() { - this.timeout(5 * 60 * 1000); + // this.timeout(10 * 60 * 1000); let tmpPath; @@ -26,9 +27,10 @@ describe('runs codemods', function() { commitMessage, beforeMerge = () => Promise.resolve() }) { - tmpPath = await buildTmp({ - fixturesPath - }); + // tmpPath = await buildTmp({ + // fixturesPath + // }); + tmpPath = "C:\\Users\\kelly\\AppData\\Local\\Temp\\tmp-12600ZNdscU6OkirE"; await beforeMerge(); @@ -36,7 +38,7 @@ describe('runs codemods', function() { bin: 'ember-cli-update', args: [ '--run-codemods', - `--codemods-json='${JSON.stringify(manifest)}'` + `--codemods-json='${JSON.stringify(manifest).replace(/\\"/g, '\\"')}'` ], cwd: tmpPath, commitMessage, @@ -82,10 +84,16 @@ describe('runs codemods', function() { commitMessage: 'my-app', runCodemods: true, async beforeMerge() { - await _merge('local', tmpPath); + // await _merge('local', tmpPath); + + // await run('npm install', { cwd: tmpPath }); + + debugger; } }); + // ps.stdout.pipe(process.stdout); + ps.stdout.on('data', data => { let str = data.toString(); if (str.includes('These codemods apply to your project.')) { @@ -100,9 +108,17 @@ describe('runs codemods', function() { status } = await promise; + assertNoUnstaged(status); + assertCodemodRan(status); + + await fs.remove(path.join(tmpPath, 'package-lock.json')); + // file is indeterminent between OS's, so ignore await fs.remove(path.join(tmpPath, 'MODULE_REPORT.md')); + // remove dist and node_modules before fixture compare + await run('git clean -fdX', { cwd: tmpPath }); + let nodeVersion = 'latest-node'; if (process.env.NODE_LTS) { nodeVersion = 'min-node'; @@ -118,9 +134,6 @@ describe('runs codemods', function() { fixtureCompare({ mergeFixtures }); - - assertNoUnstaged(status); - assertCodemodRan(status); }); } });