From a5e27eb80996ab4f0801b324c5e76db616e524aa Mon Sep 17 00:00:00 2001 From: Kelly Selden Date: Sun, 17 Nov 2019 22:38:13 +0000 Subject: [PATCH 1/3] chore: supporting test modifications --- test/tests.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/tests.js b/test/tests.js index 1a89d769..4773fe5a 100644 --- a/test/tests.js +++ b/test/tests.js @@ -12,6 +12,7 @@ const { assertNoUnstaged, assertCodemodRan } = require('./helpers/assertions'); +const run = require('ember-cli-update/src/run'); let manifest; let fixturesPath; @@ -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 }); + } } }); @@ -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'; From b8c19cfcab487124afb92941853e7fecbe070b08 Mon Sep 17 00:00:00 2001 From: Kelly Selden Date: Sun, 17 Nov 2019 22:37:48 +0000 Subject: [PATCH 2/3] chore: add fixtures --- .../latest-node/my-app/app/controllers/application.js | 5 +++++ .../latest-node/my-app/app/templates/application.hbs | 1 + .../local/my-app/app/controllers/application.js | 5 +++++ .../local/my-app/app/templates/application.hbs | 1 + .../min-node/my-app/app/controllers/application.js | 5 +++++ .../min-node/my-app/app/templates/application.hbs | 1 + 6 files changed, 18 insertions(+) create mode 100644 test/fixtures/codemods/ember-no-implicit-this-codemod/latest-node/my-app/app/controllers/application.js create mode 100644 test/fixtures/codemods/ember-no-implicit-this-codemod/latest-node/my-app/app/templates/application.hbs create mode 100644 test/fixtures/codemods/ember-no-implicit-this-codemod/local/my-app/app/controllers/application.js create mode 100644 test/fixtures/codemods/ember-no-implicit-this-codemod/local/my-app/app/templates/application.hbs create mode 100644 test/fixtures/codemods/ember-no-implicit-this-codemod/min-node/my-app/app/controllers/application.js create mode 100644 test/fixtures/codemods/ember-no-implicit-this-codemod/min-node/my-app/app/templates/application.hbs diff --git a/test/fixtures/codemods/ember-no-implicit-this-codemod/latest-node/my-app/app/controllers/application.js b/test/fixtures/codemods/ember-no-implicit-this-codemod/latest-node/my-app/app/controllers/application.js new file mode 100644 index 00000000..9d32b823 --- /dev/null +++ b/test/fixtures/codemods/ember-no-implicit-this-codemod/latest-node/my-app/app/controllers/application.js @@ -0,0 +1,5 @@ +import Controller from '@ember/controller'; + +export default Controller.extend({ + controllerProperty: 'test' +}); diff --git a/test/fixtures/codemods/ember-no-implicit-this-codemod/latest-node/my-app/app/templates/application.hbs b/test/fixtures/codemods/ember-no-implicit-this-codemod/latest-node/my-app/app/templates/application.hbs new file mode 100644 index 00000000..2a9976f7 --- /dev/null +++ b/test/fixtures/codemods/ember-no-implicit-this-codemod/latest-node/my-app/app/templates/application.hbs @@ -0,0 +1 @@ +{{this.controllerProperty}} diff --git a/test/fixtures/codemods/ember-no-implicit-this-codemod/local/my-app/app/controllers/application.js b/test/fixtures/codemods/ember-no-implicit-this-codemod/local/my-app/app/controllers/application.js new file mode 100644 index 00000000..9d32b823 --- /dev/null +++ b/test/fixtures/codemods/ember-no-implicit-this-codemod/local/my-app/app/controllers/application.js @@ -0,0 +1,5 @@ +import Controller from '@ember/controller'; + +export default Controller.extend({ + controllerProperty: 'test' +}); diff --git a/test/fixtures/codemods/ember-no-implicit-this-codemod/local/my-app/app/templates/application.hbs b/test/fixtures/codemods/ember-no-implicit-this-codemod/local/my-app/app/templates/application.hbs new file mode 100644 index 00000000..475c4bfc --- /dev/null +++ b/test/fixtures/codemods/ember-no-implicit-this-codemod/local/my-app/app/templates/application.hbs @@ -0,0 +1 @@ +{{controllerProperty}} diff --git a/test/fixtures/codemods/ember-no-implicit-this-codemod/min-node/my-app/app/controllers/application.js b/test/fixtures/codemods/ember-no-implicit-this-codemod/min-node/my-app/app/controllers/application.js new file mode 100644 index 00000000..9d32b823 --- /dev/null +++ b/test/fixtures/codemods/ember-no-implicit-this-codemod/min-node/my-app/app/controllers/application.js @@ -0,0 +1,5 @@ +import Controller from '@ember/controller'; + +export default Controller.extend({ + controllerProperty: 'test' +}); diff --git a/test/fixtures/codemods/ember-no-implicit-this-codemod/min-node/my-app/app/templates/application.hbs b/test/fixtures/codemods/ember-no-implicit-this-codemod/min-node/my-app/app/templates/application.hbs new file mode 100644 index 00000000..2a9976f7 --- /dev/null +++ b/test/fixtures/codemods/ember-no-implicit-this-codemod/min-node/my-app/app/templates/application.hbs @@ -0,0 +1 @@ +{{this.controllerProperty}} From 964185ad303e0d0e676255017c6df7e2603a793d Mon Sep 17 00:00:00 2001 From: Kelly Selden Date: Sat, 24 Aug 2019 12:39:49 +0100 Subject: [PATCH 3/3] feat: add ember-no-implicit-this-codemod --- packages/addon/manifest.json | 7 +++++++ packages/app/manifest.json | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/packages/addon/manifest.json b/packages/addon/manifest.json index 7b4b2f3d..8f7a1141 100644 --- a/packages/addon/manifest.json +++ b/packages/addon/manifest.json @@ -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); }); } }" } } diff --git a/packages/app/manifest.json b/packages/app/manifest.json index 7b4b2f3d..8f7a1141 100644 --- a/packages/app/manifest.json +++ b/packages/app/manifest.json @@ -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); }); } }" } }