diff --git a/README.md b/README.md index a72fb06..a7d3f2e 100644 --- a/README.md +++ b/README.md @@ -71,9 +71,9 @@ $ yarn global add moris --size -s - m + s moris c c Example -s l - Optional argument that is used to specify a size of the component. s - index.tsx, styles.ts. m - index.tsx, styles.ts, types.ts. l - index.tsx, styles.ts, types.ts, useExample.ts. xl - index.tsx, styles.ts, types.ts, useExample.ts, constants.ts + Optional argument that is used to specify a size of the component. xs - index.tsx, styles.ts. s - index.tsx, styles.ts, types.ts. m - index.tsx, styles.ts, types.ts, useExample.ts. l - index.tsx, styles.ts, types.ts, useExample.ts, constants.ts xl - index.tsx, styles.ts, types.ts, useExample.ts, constants.ts, helpers.ts @@ -167,7 +167,7 @@ moris.json defaultComponentSet "defaultComponentSet": "l" - s m l xl + xs s m l xl defaultPath diff --git a/src/helpers.ts b/src/helpers.ts index bd953a0..c1b2704 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -82,18 +82,27 @@ export const returnDefaultContent = ( const propsName = `${name}Props`; const stylesName = `${name}Wrapper`; - const typesPath = useAbsolutePath ? `${modifiedPath}/types` : './types'; - const stylesPath = useAbsolutePath ? `${modifiedPath}/styles` : './styles'; + // IMPORT PATHS + + const typesPath = useAbsolutePath + ? `${modifiedPath}/${name}/types` + : './types'; + const stylesPath = useAbsolutePath + ? `${modifiedPath}/${name}/styles` + : './styles'; const hookPath = useAbsolutePath - ? `${modifiedPath}/${hookName}` + ? `${modifiedPath}/${name}/${hookName}` : `./${hookName}`; + // IMPORTS + const hookImport = displayHookImport ? `import { ${hookName} } from '${hookPath}';\n` : ''; const typesImport = displayTypesImport ? `import { ${propsName} } from '${typesPath}';\n` : ''; + const componentProps = displayTypesImport ? `{}: ${propsName}` : ''; const hookCall = displayHookImport ? `\n ${hookName}();\n` : ''; diff --git a/src/index.ts b/src/index.ts index 6423a9f..466b8b5 100755 --- a/src/index.ts +++ b/src/index.ts @@ -25,12 +25,6 @@ program let componentFolder = path.join(dirname, 'src', 'components', name); let pathWithoutSrc = `components`; - const componentFile = path.join(componentFolder, 'index.tsx'); - const stylesFile = path.join(componentFolder, 'styles.ts'); - const typesFile = path.join(componentFolder, 'types.ts'); - const hookFile = path.join(componentFolder, `use${name}.ts`); - const constantsFile = path.join(componentFolder, 'constants.ts'); - const { indexContent, stylesContent, @@ -54,17 +48,32 @@ program pathWithoutSrc = options.path.replace('src/', ''); } + const componentFile = path.join(componentFolder, 'index.tsx'); + const stylesFile = path.join(componentFolder, 'styles.ts'); + const typesFile = path.join(componentFolder, 'types.ts'); + const hookFile = path.join(componentFolder, `use${name}.ts`); + const constantsFile = path.join(componentFolder, 'constants.ts'); + const helpersFile = path.join(componentFolder, 'helpers.ts'); + const configurations = { - s: [componentFile, stylesFile], - m: [componentFile, stylesFile, typesFile], - l: [componentFile, stylesFile, typesFile, hookFile], - xl: [componentFile, stylesFile, typesFile, hookFile, constantsFile], + xs: [componentFile, stylesFile], + s: [componentFile, stylesFile, typesFile], + m: [componentFile, stylesFile, typesFile, hookFile], + l: [componentFile, stylesFile, typesFile, hookFile, helpersFile], + xl: [ + componentFile, + stylesFile, + typesFile, + hookFile, + helpersFile, + constantsFile, + ], }; const set = (options.size as keyof typeof configurations) || defaultComponentSet || - 'm'; + 's'; const { defaultHookContent,