Skip to content

Commit 353d825

Browse files
committed
Moved files
1 parent 356d44e commit 353d825

13 files changed

+78
-75
lines changed

src/interface/Attributes.ts src/attributes/Attributes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RelationNames } from './Interface';
1+
import { RelationNames } from '../interface/Interface';
22

33
export default class Attributes {
44
Attrs: Record<string, Record<string, any>>;

src/case/index.ts

-55
This file was deleted.
File renamed without changes.

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { program } from 'commander';
2-
import InterfaceManager from './interface/InterfaceManager';
2+
import InterfaceManager from './program/InterfaceManager';
33

44
program
55
.name('t4s');

src/interface/BuiltinComponentInterface.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { caseType } from '../case';
1+
import { caseType } from '../utils/casing';
22
import ComponentInterface from './ComponentInterface';
33

44
export default class BuiltinComponentInterface extends ComponentInterface {

src/interface/BuiltinInterface.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { caseType } from '../case';
1+
import { caseType } from '../utils/casing';
22
import Interface from './Interface';
33

44
export default class BuiltinInterface extends Interface {

src/interface/ComponentInterface.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { caseType } from '../case';
1+
import { caseType } from '../utils/casing';
22
import Interface from './Interface';
33

44
export default class ComponentInterface extends Interface {

src/interface/Interface.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { dirname, join, relative } from 'path/posix';
2-
import { caseType, changeCase } from '../case';
2+
import { caseType, changeCase } from '../utils/casing';
33
import { prefixDotSlash } from '../utils';
4-
import Attributes from './Attributes';
4+
import Attributes from '../attributes/Attributes';
55
import { camelCase, pascalCase, dotCase, snakeCase, capitalCase, constantCase, paramCase } from 'change-case';
66

77
export type RelationNames = Record<string, { name: string, inter: Interface }>;

src/interface/builtinInterfaces.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { caseType } from '../case';
1+
import { caseType } from '../utils/casing';
22
import BuiltinComponentInterface from './BuiltinComponentInterface';
33
import BuiltinInterface from './BuiltinInterface';
44

src/plugins/index.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import EventEmitter from "events";
2-
import { SupportedPluginNamesType } from "./types";
3-
import registerUrlAlias from "./url-alias";
1+
import EventEmitter from 'events';
2+
import { SupportedPluginNamesType } from './types';
3+
import registerUrlAlias from './url-alias';
44

5-
export const registerPlugins = (pluginNames: Set<SupportedPluginNamesType>, eventEmitter: EventEmitter) => {
5+
export const registerPlugins = (
6+
pluginNames: Set<SupportedPluginNamesType>,
7+
eventEmitter: EventEmitter
8+
) => {
69
if (pluginNames.has('url-alias')) {
710
registerUrlAlias(eventEmitter);
811
}
9-
}
12+
};

src/plugins/url-alias/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import EventEmitter from "events";
2-
import { Events, SchemasType } from "../../events";
1+
import EventEmitter from 'events';
2+
import { Events, SchemasType } from '../../events';
33

44
const addUrlAliasToAllContentTypes = ({ apiSchemas }: SchemasType) => {
55
apiSchemas.forEach((schema) => {

src/interface/InterfaceManager.ts src/program/InterfaceManager.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import { join } from 'path/posix';
44
import {
55
createMediaFormatInterface,
66
createMediaInterface,
7-
} from './builtinInterfaces';
8-
import ComponentInterface from './ComponentInterface';
9-
import Interface from './Interface';
7+
} from '../interface/builtinInterfaces';
8+
import ComponentInterface from '../interface/ComponentInterface';
9+
import Interface from '../interface/Interface';
1010
import {
1111
getApiSchemas,
1212
getComponentCategoryFolders,
1313
getComponentSchemas,
14-
} from './schemaReader';
14+
} from '../content-types/reader';
1515
import prettier from 'prettier';
1616
import { pascalCase } from 'pascal-case';
17-
import { caseType, caseTypesArray, changeCase, checkCaseType } from '../case';
17+
import { caseType, caseTypesArray, changeCase, checkCaseType } from '../utils/casing/';
1818
import EventEmitter from 'events';
1919
import { Events } from '../events';
2020
import { registerPlugins } from '../plugins';

src/utils/casing/index.ts

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import {
2+
camelCase,
3+
pascalCase,
4+
dotCase,
5+
snakeCase,
6+
capitalCase,
7+
constantCase,
8+
paramCase,
9+
} from 'change-case';
10+
11+
export const caseTypesArray = [
12+
'camel',
13+
'capital',
14+
'dot',
15+
'snake',
16+
'pascal',
17+
'constant',
18+
'kebab',
19+
] as const;
20+
21+
export type caseType = typeof caseTypesArray[number];
22+
23+
export function checkCaseType(caseName: caseType): caseName is caseType {
24+
return caseTypesArray.includes(caseName);
25+
}
26+
27+
export function changeCase(text: string, caseName: caseType): string {
28+
let name: string = text;
29+
switch (caseName) {
30+
case 'dot':
31+
name = dotCase(name);
32+
break;
33+
case 'camel':
34+
name = camelCase(name);
35+
break;
36+
case 'snake':
37+
name = snakeCase(name);
38+
break;
39+
case 'capital':
40+
name = capitalCase(name);
41+
break;
42+
case 'constant':
43+
name = constantCase(name);
44+
break;
45+
case 'kebab':
46+
// paramcase is the same as kebab
47+
name = paramCase(name);
48+
break;
49+
case 'pascal':
50+
default:
51+
name = pascalCase(name);
52+
break;
53+
}
54+
return name;
55+
}

0 commit comments

Comments
 (0)