Open lifeart opened 5 years ago
Hey @lifeart,
could you explain what ember-meta-explorer
does? and how to run it?
Yeah, basically it created for cases like this (get metadata from templates & components), get ts/js
ast data and other primitives.
It's used in Unstable Language Server (https://marketplace.visualstudio.com/items?itemName=lifeart.vscode-ember-unstable) https://github.com/emberwatch/ember-language-server/pull/173
And I have demo addon - https://github.com/lifeart/ember-component-info (you can intall it for any ember app) https://github.com/lifeart/ember-component-info/issues/1
ember-meta-explorer
- is an npm package with only few methods
export { processJSFile, parseScriptFile } from './utils/js-utils';
export { processTemplate } from './utils/hbs-utils';
export { extractComponentInformationFromMeta, rebelObject } from './utils/informator';
//https://github.com/lifeart/ember-meta-explorer/blob/master/src/index.d.ts
processJSFile
- get some metadata from any js/ts
file.
processTemplate
- get some metadata from any .hbs
file.
parseScriptFile
- get AST from any js/ts
file.
extractComponentInformationFromMeta
- create metadata object from processJSFile
, processTemplate
results.
rebelObject
- create object from strings like foo.bar
, foo.baz
-> { bar: null, baz: null }
My idea - to have single package to parse/analyze ember app code, and reuse it in high-order solutions.
Looks nice :+1: but I use more naive way of analyzing the code. I use simple regexes to catch occurrences of components in js
and hbs
files. Works well so far ;)
I'll keep an eye on your project if things with regexes would go too complex and too error-prone. Thanks.
k, default setup like
import { processJSFile, processTemplate } from 'ember-meta-explorer';
console.log(processJSFile('some-path-to-any-js-ts-file'));
console.log(processTemplate('some-path-to-any-hbs-file'));
should work for you out of the box. let me know if I can help
As I see, there is some related cases covered by https://github.com/lifeart/ember-meta-explorer any inputs I can help?