Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
` ${count1 ? chalk.default.blue(count1) : ''}` +
` ${count2 ? '/ ' + chalk.default.yellowBright(count2) : ''}`
);
};
let projectPath = (minimist(process.argv.slice(2)) as any).p;
if (!projectPath) {
projectPath = './tsconfig.json';
}
if (!existsSync(projectPath)) {
error('Cannot find tsconfig at "' + projectPath + '".');
process.exit(1);
}
console.log('Parsing...');
let parseError: any = null;
const projectSymbols = new ProjectSymbols(
projectPath,
resourceResolver,
e => (parseError = e)
);
const allModules: ModuleSymbol[] = projectSymbols.getModules();
const allPipes: PipeSymbol[] = projectSymbols.getPipes();
const allProviders: ProviderSymbol[] = projectSymbols.getProviders();
const allDirectives: DirectiveSymbol[] = projectSymbols.getDirectives();
const treeMod = new ModuleTree();
if (!parseError) {
console.log('');
console.log('Results:');
console.log('');
// Count modules
getDependencies(): Dependencies[] {
const contextSymbols = new ContextSymbols(this.program, this.resourceResolver);
// console.log('getModules::', contextSymbols.getModules().pop());
fs.writeFileSync(
'./xxxxxxxxx.json',
JSON.stringify(contextSymbols.getContextSummary() /*.map( d => d._symbol.name )*/, null, 2)
);
// @todo we should return this type
// {
// name,
// file: srcFile.fileName.split('/').splice(-3).join('/'),
// providers: this.getModuleProviders(props),
// declarations: this.getModuleDeclations(props),
// imports: this.getModuleImports(props),
// exports: this.getModuleExports(props),
// bootstrap: this.getModuleBootstrap(props),
// __raw: props
NgAst.prototype.getDependencies = function () {
var contextSymbols = new ngast_1.ContextSymbols(this.program, this.resourceResolver);
// console.log('getModules::', contextSymbols.getModules().pop());
fs.writeFileSync('./xxxxxxxxx.json', JSON.stringify(contextSymbols.getContextSummary() /*.map( d => d._symbol.name )*/, null, 2));
// @todo we should return this type
// {
// name,
// file: srcFile.fileName.split('/').splice(-3).join('/'),
// providers: this.getModuleProviders(props),
// declarations: this.getModuleDeclations(props),
// imports: this.getModuleImports(props),
// exports: this.getModuleExports(props),
// bootstrap: this.getModuleBootstrap(props),
// __raw: props
// };
return [];
};
NgAst.prototype.getFileName = function (contextSymbols) {
export const parse = (projectPath: string) => {
const project = new ProjectSymbols(
createProgramFromTsConfig(projectPath),
{
getSync: (path: string) => readFileSync(path).toString(),
get: (path: string) =>
new Promise((resolve, reject) =>
readFile(path, (error, content) => (error ? reject(error) : resolve(content.toString())))
)
},
(error: string, path: string) => console.error(error, path)
);
return formatContext(project);
};
Project.prototype.load = function (tsconfig, reporter) {
this.projectSymbols = new ngast.ProjectSymbols(tsconfig, {
get: function (name) {
return new Promise(function (resolve, reject) {
fs.readFile(name, function (e, data) {
if (e)
reject(e);
else
resolve(data.toString());
});
});
},
getSync: function (name) {
return fs.readFileSync(name, { encoding: 'utf-8' });
}
}, reporter);
return Promise.resolve(this.projectSymbols);
};
load(tsconfig: string, reporter: ErrorReporter) {
this.projectSymbols = new ProjectSymbols(
tsconfig,
{
get(name: string) {
return new Promise((resolve: any, reject: any) => {
readFile(name, (e, data) => {
if (e) reject(e);
else resolve(data.toString());
});
});
},
getSync(name: string) {
return readFileSync(name, { encoding: 'utf-8' });
}
},
reporter
);
TemplateState.prototype.getMetadata = function (id) {
var s = this.symbols[id];
if (s) {
if (s instanceof _angular_compiler.ElementAst) {
return getElementMetadata(s);
}
else if (s instanceof ngast.DirectiveSymbol) {
return getDirectiveMetadata(s);
}
}
return null;
};
TemplateState.prototype.nextState = function (id) {
ModuleState.prototype.nextState = function (nodeId) {
if (nodeId === this.symbolId) {
return null;
}
var data = this.symbols[nodeId].data;
if (!data) {
return null;
}
if (data.symbol instanceof ngast.DirectiveSymbol) {
return new DirectiveState(this.context, data.symbol);
}
else if (data.symbol instanceof ngast.ProviderSymbol) {
return new ProviderState(this.context, data.symbol);
}
else if (data.symbol instanceof ngast.PipeSymbol) {
return new PipeState(this.context, data.symbol);
}
return null;
};
ModuleState.prototype.getData = function () {
ModuleState.prototype.getMetadata = function (id) {
var data = this.symbols[id].data;
if (!data) {
return null;
}
if (data.symbol instanceof ngast.DirectiveSymbol) {
return getDirectiveMetadata(data.symbol);
}
else if (data.symbol instanceof ngast.ProviderSymbol) {
return getProviderMetadata(data.symbol);
}
else if (data.symbol instanceof ngast.PipeSymbol) {
return getPipeMetadata(data.symbol);
}
return null;
};
ModuleState.prototype.nextState = function (nodeId) {
id = getProviderId(node.getMetadata());
name = getProviderName(node.getMetadata());
}
else {
id = getId(node.symbol);
name = node.symbol.name;
}
nodes[id] = {
id: id,
label: name,
data: {
symbol: node,
metadata: null
},
type: {
angular: node instanceof ngast.Symbol ? isAngularSymbol(node.symbol) : isAngularSymbol(node.getMetadata()),
type: symbolType
}
};
edges.push({
from: parentSet,
to: id
});
};
return ModuleState;