ember-modules-codemod icon indicating copy to clipboard operation
ember-modules-codemod copied to clipboard

Intelligent list of paths.

Open rwjblue opened this issue 8 years ago • 7 comments

By default (e.g. no customized arguments) the codemod should process the following directories:

  • If in an addon (determined by keywords in package.json):
    • addon, addon-test-support, and tests
  • If in an app:
    • app and tests
  • Both addon and app types should process any require('./package)['ember-addon'].paths

The codemod should also allow an explicit path to be specified on the command line. When specified on the command line, the default paths (described above) should not be processed and only the specific path provided in the first arg should be processed.

rwjblue avatar Jul 31 '17 14:07 rwjblue

@Turbo87 - You 👍 on the general plan laid out above?

rwjblue avatar Jul 31 '17 14:07 rwjblue

in general I'm 👍

I'm just not sure what the require() stuff is for 🤔

Turbo87 avatar Jul 31 '17 15:07 Turbo87

Haha, I was just too lazy to write it out manually. For the auto-detect bit, this is basically what I'm proposing:

const ADDON_PATHS = ['addon', 'addon-test-support', 'tests'];
const APP_PATHS = ['app', 'tests'];

let paths;
let package = JSON.parse(fs.readFileSync('package.json'));
if (package.keywords && package.keywords.indexOf('ember-addon') > -1) {
  // addon
  paths = ADDON_PATHS.slice();
} else {
  // app
  paths = APP_PATHS.slice();
}

if (package['ember-addon'] && package['ember-addon'].paths) {
  package['ember-addon'].paths).filter(Boolean);
  package['ember-addon'].paths.forEach(inRepoAddonBasePath => {
    ADDON_PATHS.forEach(addonFolderName => {
      let fullPath = path.join(inRepoAddonBasePath, addonFolderName);
      paths.push(fullPath);
    });
  });
}

rwjblue avatar Jul 31 '17 15:07 rwjblue

aka. in-repo-addons, right?

Turbo87 avatar Jul 31 '17 15:07 Turbo87

c

rwjblue avatar Jul 31 '17 15:07 rwjblue

currently we auto-process all of lib which isn't guaranteed to be an addon at all (e.g. many addons use lib for node-land code also)

rwjblue avatar Jul 31 '17 15:07 rwjblue

Is this still needed?

cyril-sf avatar Aug 30 '18 22:08 cyril-sf