Skip to content

Commit 5a3c538

Browse files
committed
Implement component file search
1 parent 0ef2627 commit 5a3c538

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

lib/index.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
1+
const pkgDir = require('pkg-dir');
2+
const globby = require('globby');
3+
const debug = require('debug')('tagless-ember-components-codemod');
4+
15
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+
}
335
}
436

537
module.exports = { run };

0 commit comments

Comments
 (0)