Skip to content

Commit

Permalink
fix: match changes with change-case v5
Browse files Browse the repository at this point in the history
BREAKING CHANGE: configuration changed due to change-case v5
  • Loading branch information
hoonoh committed Dec 12, 2023
1 parent 00f0095 commit eb1a8f4
Show file tree
Hide file tree
Showing 8 changed files with 1,297 additions and 1,297 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ export type ChangeCase =
| 'capitalCase'
| 'constantCase'
| 'dotCase'
| 'headerCase'
| 'kebabCase'
| 'noCase'
| 'paramCase'
| 'pascalCase'
| 'pathCase'
| 'sentenceCase'
| 'snakeCase'
| 'trainCase'
| 'keep';

const config: UserConfig = {
conventions: {
schemas: 'camelCase',
columns: 'keep',
types: 'camelCase',
paths: 'paramCase',
paths: 'kebabCase',
},
};
```
Expand All @@ -95,7 +95,7 @@ Enum type code conventions are applied to Enum member names. Defaults to `camelC

#### Paths and filename conventions

Generated file paths and filename conventions. Defaults to `paramCase`.
Generated file paths and filename conventions. Defaults to `kebabCase`.

### Selecting targets

Expand Down
30 changes: 15 additions & 15 deletions src/config/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import {
capitalCase,
constantCase,
dotCase,
headerCase,
kebabCase,
noCase,
paramCase,
pascalCase,
pathCase,
sentenceCase,
snakeCase,
trainCase,
} from 'change-case';
import { DeepRequired } from 'ts-essentials';
import z from 'zod';
Expand All @@ -31,27 +31,27 @@ export type ChangeCase =
| 'capitalCase'
| 'constantCase'
| 'dotCase'
| 'headerCase'
| 'kebabCase'
| 'noCase'
| 'paramCase'
| 'pascalCase'
| 'pathCase'
| 'sentenceCase'
| 'snakeCase'
| 'trainCase'
| 'keep';

export const changeCaseMap: Record<ChangeCase, (input: string) => string> = {
camelCase: camelCase,
capitalCase: capitalCase,
constantCase: constantCase,
dotCase: dotCase,
headerCase: headerCase,
noCase: noCase,
paramCase: paramCase,
pascalCase: pascalCase,
pathCase: pathCase,
sentenceCase: sentenceCase,
snakeCase: snakeCase,
camelCase,
capitalCase,
constantCase,
dotCase,
kebabCase,
noCase,
pascalCase,
pathCase,
sentenceCase,
snakeCase,
trainCase,
keep: (input: string) => input,
} as const;

Expand Down
2 changes: 1 addition & 1 deletion src/config/validators/user-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export const validateUserConfig = async ({
schemas: changeCaseMap[conventions?.schemas || 'camelCase'],
columns: changeCaseMap[conventions?.columns || 'keep'],
types: changeCaseMap[conventions?.types || 'camelCase'],
paths: changeCaseMap[conventions?.paths || 'paramCase'],
paths: changeCaseMap[conventions?.paths || 'kebabCase'],
},
schemas: Object.keys(renderTargets),
renderTargets,
Expand Down
4 changes: 2 additions & 2 deletions src/generators/barrel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { paramCase, pascalCase } from 'change-case';
import { kebabCase, pascalCase } from 'change-case';
import { lstatSync } from 'fs';
import { readdir } from 'fs/promises';
import { resolve } from 'path';
Expand All @@ -25,7 +25,7 @@ export const generateBarrel: FileGenerator = async (config: Config) => {

await Promise.all(
files.map(async filename => {
const filenameNormalize = paramCase(filename.split('.').shift() || '');
const filenameNormalize = kebabCase(filename.split('.').shift() || '');
if (
// enum type file
filenameNormalize === 'enum-types' &&
Expand Down
14 changes: 7 additions & 7 deletions src/generators/helpers/change-case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import {
capitalCase,
constantCase,
dotCase,
headerCase,
kebabCase,
noCase,
paramCase,
pascalCase,
pathCase,
sentenceCase,
snakeCase,
trainCase,
} from 'change-case';

import { ChangeCase } from '../../config/types/config.js';
Expand All @@ -29,15 +29,12 @@ export const changeCase = (input: string, caseType?: ChangeCase) => {
case 'dotCase':
rtn = dotCase(input);
break;
case 'headerCase':
rtn = headerCase(input);
case 'kebabCase':
rtn = kebabCase(input);
break;
case 'noCase':
rtn = noCase(input);
break;
case 'paramCase':
rtn = paramCase(input);
break;
case 'pascalCase':
rtn = pascalCase(input);
break;
Expand All @@ -50,6 +47,9 @@ export const changeCase = (input: string, caseType?: ChangeCase) => {
case 'snakeCase':
rtn = snakeCase(input);
break;
case 'trainCase':
rtn = trainCase(input);
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Generated by [AVA](https://avajs.dev).
connectionURI: 'postgresql://postgres:secretpassword@localhost:54321/postgres',
conventions: {
columns: Function keep {},
paths: Function paramCase {},
paths: Function kebabCase {},
schemas: Function camelCase {},
types: Function camelCase {},
},
Expand Down
Binary file not shown.
Loading

0 comments on commit eb1a8f4

Please sign in to comment.