Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ember-no-implicit-this-codemod #20

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/addon/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,12 @@
},
"nodeVersionRange": ">=8",
"commands": ["github:ember-codemods/ember-data-codemod globals-to-ember-data-imports app/**/*.js"]
},
"ember-no-implicit-this-codemod": {
"versionRanges": {
"ember-source": ">=3.12"
},
"nodeVersionRange": ">=8",
"script": "let ps = execa.command(\"ember s\", { stderr: \"inherit\", preferLocal: true }); 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); }); } }"
}
}
7 changes: 7 additions & 0 deletions packages/app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,12 @@
},
"nodeVersionRange": ">=8",
"commands": ["github:ember-codemods/ember-data-codemod globals-to-ember-data-imports app/**/*.js"]
},
"ember-no-implicit-this-codemod": {
"versionRanges": {
"ember-source": ">=3.12"
},
"nodeVersionRange": ">=8",
"script": "let ps = execa.command(\"ember s\", { stderr: \"inherit\", preferLocal: true }); 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); }); } }"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Controller from '@ember/controller';

export default Controller.extend({
controllerProperty: 'test'
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{this.controllerProperty}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Controller from '@ember/controller';

export default Controller.extend({
controllerProperty: 'test'
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{controllerProperty}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Controller from '@ember/controller';

export default Controller.extend({
controllerProperty: 'test'
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{this.controllerProperty}}
10 changes: 10 additions & 0 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
assertNoUnstaged,
assertCodemodRan
} = require('./helpers/assertions');
const run = require('ember-cli-update/src/run');

let manifest;
let fixturesPath;
Expand Down Expand Up @@ -121,6 +122,10 @@ describe('runs codemods', function() {
} = await merge({
async beforeMerge() {
await _merge('local', tmpPath);

if (manifest[codemod].script) {
await run('npm install', { cwd: tmpPath });
}
}
});

Expand Down Expand Up @@ -148,9 +153,14 @@ describe('runs codemods', function() {
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 Down