Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelly Selden committed Nov 17, 2019
1 parent 659bfd2 commit 447599c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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); }); } }"
}
}
31 changes: 22 additions & 9 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -26,17 +27,18 @@ 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();

return processBin({
bin: 'ember-cli-update',
args: [
'--run-codemods',
`--codemods-json='${JSON.stringify(manifest)}'`
`--codemods-json='${JSON.stringify(manifest).replace(/\\"/g, '\\"')}'`
],
cwd: tmpPath,
commitMessage,
Expand Down Expand Up @@ -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.')) {
Expand All @@ -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';
Expand All @@ -118,9 +134,6 @@ describe('runs codemods', function() {
fixtureCompare({
mergeFixtures
});

assertNoUnstaged(status);
assertCodemodRan(status);
});
}
});

0 comments on commit 447599c

Please sign in to comment.