|
| 1 | +const pkgDir = require('pkg-dir'); |
| 2 | +const globby = require('globby'); |
| 3 | +const debug = require('debug')('tagless-ember-components-codemod'); |
| 4 | + |
1 | 5 | async function run() { |
2 | | - console.log('Hello World!'); |
| 6 | + let path = await pkgDir(); |
| 7 | + await runForPath(path) |
| 8 | +} |
| 9 | + |
| 10 | +async function runForPath(path, options = {}) { |
| 11 | + debug('runForPath(%o, %o)', path, options); |
| 12 | + |
| 13 | + let log = options.log || console.log; |
| 14 | + |
| 15 | + // TODO check for ember-component-css dependency |
| 16 | + |
| 17 | + log(` 🔍 Searching for component files...`); |
| 18 | + let componentPaths = await globby('app/components/*.js', { cwd: path }); |
| 19 | + debug('componentPaths = %O', componentPaths); |
| 20 | + |
| 21 | + for (let componentPath of componentPaths) { |
| 22 | + // TODO skip tagless components (silent) |
| 23 | + // TODO skip components that use `this.element` (warn) |
| 24 | + // TODO skip components that use `click()` etc. (warn) |
| 25 | + |
| 26 | + // TODO analyze `tagName`, `attributeBindings`, `classNames`, ... |
| 27 | + // TODO skip on error (warn incl. please report) |
| 28 | + |
| 29 | + // TODO find corresponding template files |
| 30 | + // TODO skip if not found (warn) |
| 31 | + |
| 32 | + // TODO set `tagName: ''` and remove `attributeBindings`, `classNames`, ... |
| 33 | + // TODO wrap existing template with root element |
| 34 | + } |
3 | 35 | } |
4 | 36 |
|
5 | 37 | module.exports = { run }; |
0 commit comments