From 71db179a8dce3a535612203f7f80be9cd5f5f3a9 Mon Sep 17 00:00:00 2001 From: Rajasegar Chandran Date: Fri, 18 Oct 2019 12:30:50 +0530 Subject: [PATCH 1/3] [FEAT] Add computed-property property() Modifier codemod --- src/index.js | 2 +- .../codemod/latest-node/my-app/app/controllers/application.js | 4 ++++ .../codemod/local/my-app/app/controllers/application.js | 4 ++++ .../codemod/min-node/my-app/app/controllers/application.js | 4 ++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 9af5c67c6..4b063002e 100644 --- a/src/index.js +++ b/src/index.js @@ -194,7 +194,7 @@ All blueprints are up-to-date!`; statsOnly, listCodemods, runCodemods, - codemodsUrl: 'https://raw.githubusercontent.com/ember-cli/ember-cli-update-codemods-manifest/v3/manifest.json', + codemodsUrl: 'https://raw.githubusercontent.com/rajasegar/ember-cli-update-codemods-manifest/cp-property-map/manifest.json', createCustomDiff, ignoredFiles: [await getBlueprintFilePath(cwd)], wasRunAsExecutable diff --git a/test/fixtures/codemod/latest-node/my-app/app/controllers/application.js b/test/fixtures/codemod/latest-node/my-app/app/controllers/application.js index 3ab228e66..3e5d2fad9 100644 --- a/test/fixtures/codemod/latest-node/my-app/app/controllers/application.js +++ b/test/fixtures/codemod/latest-node/my-app/app/controllers/application.js @@ -11,6 +11,10 @@ export default Controller.extend({ return `${this.firstName} ${this.lastName}`; }, + friendNames: map('friends', ['nameKey'], function(friend) { + return friend[this.nameKey]; + }), + actions: { foo(object) { this.doStuff(object); diff --git a/test/fixtures/codemod/local/my-app/app/controllers/application.js b/test/fixtures/codemod/local/my-app/app/controllers/application.js index c9137a10d..f0ac5fb39 100644 --- a/test/fixtures/codemod/local/my-app/app/controllers/application.js +++ b/test/fixtures/codemod/local/my-app/app/controllers/application.js @@ -10,6 +10,10 @@ export default Ember.Controller.extend({ return `${this.firstName} ${this.lastName}`; }).volatile('firstName', 'lastName'), + friendNames: map('friends', function(friend) { + return friend[this.nameKey]; + }).property('nameKey'), + actions: { foo(object) { Ember.propertyWillChange(object, 'someProperty'); diff --git a/test/fixtures/codemod/min-node/my-app/app/controllers/application.js b/test/fixtures/codemod/min-node/my-app/app/controllers/application.js index 3ab228e66..3e5d2fad9 100644 --- a/test/fixtures/codemod/min-node/my-app/app/controllers/application.js +++ b/test/fixtures/codemod/min-node/my-app/app/controllers/application.js @@ -11,6 +11,10 @@ export default Controller.extend({ return `${this.firstName} ${this.lastName}`; }, + friendNames: map('friends', ['nameKey'], function(friend) { + return friend[this.nameKey]; + }), + actions: { foo(object) { this.doStuff(object); From 217284fb3da333c6a674c5f8650589e9b1dd78bd Mon Sep 17 00:00:00 2001 From: Rajasegar Chandran Date: Wed, 23 Oct 2019 16:03:28 +0530 Subject: [PATCH 2/3] [CHORE] Importing map for the computed properties Addressing review comments --- .../codemod/latest-node/my-app/app/controllers/application.js | 1 + .../fixtures/codemod/local/my-app/app/controllers/application.js | 1 + .../codemod/min-node/my-app/app/controllers/application.js | 1 + 3 files changed, 3 insertions(+) diff --git a/test/fixtures/codemod/latest-node/my-app/app/controllers/application.js b/test/fixtures/codemod/latest-node/my-app/app/controllers/application.js index 3e5d2fad9..120047e65 100644 --- a/test/fixtures/codemod/latest-node/my-app/app/controllers/application.js +++ b/test/fixtures/codemod/latest-node/my-app/app/controllers/application.js @@ -1,6 +1,7 @@ import Controller from '@ember/controller'; import Ember from 'ember'; import { assign } from '@ember/polyfills'; +import { map } from '@ember/object/computed'; export default Controller.extend({ fullName: computed('firstName', 'lastName', function() { diff --git a/test/fixtures/codemod/local/my-app/app/controllers/application.js b/test/fixtures/codemod/local/my-app/app/controllers/application.js index f0ac5fb39..d2431a133 100644 --- a/test/fixtures/codemod/local/my-app/app/controllers/application.js +++ b/test/fixtures/codemod/local/my-app/app/controllers/application.js @@ -1,5 +1,6 @@ import Ember from 'ember'; import { merge } from '@ember/polyfills'; +import { map } from '@ember/object/computed'; export default Ember.Controller.extend({ fullName: computed(function() { diff --git a/test/fixtures/codemod/min-node/my-app/app/controllers/application.js b/test/fixtures/codemod/min-node/my-app/app/controllers/application.js index 3e5d2fad9..120047e65 100644 --- a/test/fixtures/codemod/min-node/my-app/app/controllers/application.js +++ b/test/fixtures/codemod/min-node/my-app/app/controllers/application.js @@ -1,6 +1,7 @@ import Controller from '@ember/controller'; import Ember from 'ember'; import { assign } from '@ember/polyfills'; +import { map } from '@ember/object/computed'; export default Controller.extend({ fullName: computed('firstName', 'lastName', function() { From a10d471cc679dc92ff92cdfbd790b5696259219f Mon Sep 17 00:00:00 2001 From: Kelly Selden Date: Wed, 23 Oct 2019 12:16:20 +0100 Subject: [PATCH 3/3] revert --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 4b063002e..9af5c67c6 100644 --- a/src/index.js +++ b/src/index.js @@ -194,7 +194,7 @@ All blueprints are up-to-date!`; statsOnly, listCodemods, runCodemods, - codemodsUrl: 'https://raw.githubusercontent.com/rajasegar/ember-cli-update-codemods-manifest/cp-property-map/manifest.json', + codemodsUrl: 'https://raw.githubusercontent.com/ember-cli/ember-cli-update-codemods-manifest/v3/manifest.json', createCustomDiff, ignoredFiles: [await getBlueprintFilePath(cwd)], wasRunAsExecutable