react-ui-codemod
Advanced tools
Comparing version 1.3.0-beta.1 to 1.3.0-beta.2
@@ -86,5 +86,15 @@ /* eslint-disable import/no-default-export */ | ||
if (p.key.name === 'tests') { | ||
// console.log(j(p)); | ||
testsIndex = i; | ||
kindTests = propertiesToStringsObj(api, p.value.properties, collection); | ||
if (p.value.type === 'Identifier') { | ||
const variableName = p.value.name; | ||
kindTests = { | ||
[variableName]: variableName, | ||
}; | ||
processVariable(api, collection, variableName); | ||
} else if (p.value.type === 'ObjectExpression') { | ||
kindTests = propertiesToStringsObj(api, p.value.properties, collection); | ||
} else { | ||
console.log(kind + ': TESTS IS SOMETHING UNKNOWN: ', p.value.type); | ||
} | ||
} | ||
@@ -258,5 +268,7 @@ }); | ||
const file = prettier.format(mainTemplate(kind, stories, vars).replace(/as HTMLElement/g, ''), { | ||
parser: 'typescript', | ||
}); | ||
const file = | ||
prettier.format( | ||
mainTemplate(kind, stories, vars).replace(/as HTMLElement/g, ''), | ||
{ parser: 'typescript' } | ||
); | ||
@@ -269,3 +281,3 @@ const dir = path.join(path.dirname(filePath), '../__creevey__/'); | ||
writeFileSync(path.join(dir + kind + '.creevey.js'), file); | ||
writeFileSync(path.join(dir + kind.split('/').pop() + '.creevey.ts'), file); | ||
}; | ||
@@ -298,14 +310,4 @@ | ||
// const testsToStr = (stories: Stories): string => { | ||
// return Object.keys(stories) | ||
// .map((s) => { | ||
// return `${s}: [${Object.keys(stories[s].tests).join(', ')}]`; | ||
// }) | ||
// .join(', '); | ||
// }; | ||
// console.dir(stories); | ||
console.log(`Creating ${kind}.creevey.ts`); | ||
createTestFile(file.path, kind, stories, vars); | ||
// console.log(vars); | ||
@@ -312,0 +314,0 @@ return result.toSource(); |
{ | ||
"name": "react-ui-codemod", | ||
"version": "1.3.0-beta.1", | ||
"version": "1.3.0-beta.2", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
113133
2756