const declarations = specifiers.map(specifier => { if (specifier.node.type === 'ExportSpecifier') { return t.objectProperty( specifier.get('exported').node, specifier.get('local').node t.callExpression(t.identifier('addExport'), [ t.objectExpression( path.get('declaration').get('declarations').map(d => t.objectProperty( d.get('id').node, d.get('id').node
const fileMetaGenerator = (meta) => { const { path, mocks, } = meta; return t.objectExpression([ t.objectProperty(t.identifier('path'), t.stringLiteral(path)), t.objectProperty(t.identifier('mocks'), t.arrayExpression(mocks.map(mock => t.stringLiteral(mock)))), ]); }
traverse(ast, { ObjectExpression(astPath) { const properties = astPath.node.properties; properties.forEach(element => { if (element.value && element.value.name === self.argv.parentName) { astPath.pushContainer('properties', t.objectProperty(t.identifier('children'), t.arrayExpression([self.generateEl(true, true)]))); astPath.skip(); } }); } });
generateEl(isChildren = true, isFirst = false) { const propertyArray = [t.objectProperty(t.identifier('path'), t.stringLiteral(`${isChildren ? (isFirst ? '' : this.toLowerLine(this.argv.componentName)) : (isFirst ? '/' : '/' + this.toLowerLine(this.argv.componentName))}`)), t.objectProperty(t.identifier('component'), t.identifier(this.argv.ComponentName))]; if (this.argv.metaParam) { propertyArray.push(t.objectProperty(t.identifier('meta'), t.stringLiteral(this.argv.metaParam)), t.objectProperty(t.identifier('name'), t.stringLiteral(this.argv.componentName))); } return t.objectExpression(propertyArray); }
const metaGenerator = (path, funObj) => { const { name, isAsync, paramIds, isDefault, isEcmaDefault, injectionWhitelist, isObject, } = funObj; return t.objectExpression([ t.objectProperty(t.identifier('path'), t.stringLiteral(path)), t.objectProperty(t.identifier('name'), t.stringLiteral(name)), // t.objectProperty(t.identifier('localName'), t.stringLiteral(localName)), t.objectProperty(t.identifier('paramIds'), t.arrayExpression(paramIds.map(pid => t.stringLiteral(pid)))), t.objectProperty(t.identifier('injectionWhitelist'), t.arrayExpression(injectionWhitelist.map(wl => t.stringLiteral(wl)))), t.objectProperty(t.identifier('isDefault'), t.booleanLiteral(isDefault)), t.objectProperty(t.identifier('isEcmaDefault'), t.booleanLiteral(isEcmaDefault)), t.objectProperty(t.identifier('isAsync'), t.booleanLiteral(isAsync)), t.objectProperty(t.identifier('isObject'), t.booleanLiteral(isObject)), ]); }