Skip to content

Commit

Permalink
refactor!: cleanup deprecations (#1440)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 authored Oct 14, 2022
1 parent 1ab33c5 commit 9c1437d
Show file tree
Hide file tree
Showing 38 changed files with 98 additions and 1,517 deletions.
3 changes: 0 additions & 3 deletions docs/.vitepress/api-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,19 @@ export const apiPages = [
{ text: 'Database', link: '/api/database.html' },
{ text: 'Datatype', link: '/api/datatype.html' },
{ text: 'Date', link: '/api/date.html' },
{ text: 'Fake', link: '/api/fake.html' },
{ text: 'Finance', link: '/api/finance.html' },
{ text: 'Git', link: '/api/git.html' },
{ text: 'Hacker', link: '/api/hacker.html' },
{ text: 'Helpers', link: '/api/helpers.html' },
{ text: 'Image', link: '/api/image.html' },
{ text: 'Internet', link: '/api/internet.html' },
{ text: 'Lorem', link: '/api/lorem.html' },
{ text: 'Mersenne', link: '/api/mersenne.html' },
{ text: 'Music', link: '/api/music.html' },
{ text: 'Name', link: '/api/name.html' },
{ text: 'Phone', link: '/api/phone.html' },
{ text: 'Random', link: '/api/random.html' },
{ text: 'Science', link: '/api/science.html' },
{ text: 'System', link: '/api/system.html' },
{ text: 'Unique', link: '/api/unique.html' },
{ text: 'Vehicle', link: '/api/vehicle.html' },
{ text: 'Word', link: '/api/word.html' },
];
2 changes: 0 additions & 2 deletions scripts/apidoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
writeApiPagesIndex,
writeApiSearchIndex,
} from './apidoc/apiDocsWriter';
import { processDirectMethods } from './apidoc/directMethods';
import { processModuleMethods } from './apidoc/moduleMethods';
import { initMarkdownRenderer } from './apidoc/signature';
import type { PageIndex } from './apidoc/utils';
Expand Down Expand Up @@ -35,7 +34,6 @@ async function build(): Promise<void> {

const modulesPages: PageIndex = [];
modulesPages.push(...processModuleMethods(project));
modulesPages.push(...processDirectMethods(project));
writeApiPagesIndex(modulesPages);

writeApiSearchIndex(project);
Expand Down
35 changes: 1 addition & 34 deletions scripts/apidoc/apiDocsWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { ProjectReflection } from 'typedoc';
import { ReflectionKind } from 'typedoc';
import type { Method } from '../../docs/.vitepress/components/api-docs/method';
import type { APIGroup, APIItem } from '../../docs/api/api-types';
import { selectDirectMethods } from './directMethods';
import { extractModuleName, selectApiModules } from './moduleMethods';
import type { PageIndex } from './utils';
import {
Expand Down Expand Up @@ -78,37 +77,6 @@ export function writeApiDocsModulePage(
writeFileSync(resolve(pathOutputDir, `${lowerModuleName}.md`), content);
}

/**
* Writes the api page for the given method to the correct location.
*
* @param methodName The name of the method to write the docs for.
* @param capitalizedMethodName The capitalized name of the method.
*/
export function writeApiDocsDirectPage(
methodName: string,
capitalizedMethodName: string
): void {
let content = `
<script setup>
import ApiDocsMethod from '../.vitepress/components/api-docs/method.vue';
import ${methodName} from './${methodName}.json';
</script>
<!-- This file is automatically generated. -->
<!-- Run '${scriptCommand}' to update -->
# ${capitalizedMethodName}
## ${methodName}
<ApiDocsMethod :method="${methodName}.${methodName}" v-once />
`.replace(/\n +/g, '\n');

content = vitePressInFileOptions + formatMarkdown(content);

writeFileSync(resolve(pathOutputDir, `${methodName}.md`), content);
}

/**
* Writes the api docs data to correct location.
*
Expand Down Expand Up @@ -164,9 +132,8 @@ export function writeApiSearchIndex(project: ProjectReflection): void {
apiIndex.push(moduleApiSection);

const apiModules = selectApiModules(project);
const directMethods = selectDirectMethods(project);

moduleApiSection.items = [...apiModules, ...directMethods]
moduleApiSection.items = apiModules
.map((module) => {
const moduleName = extractModuleName(module);
const apiSection: APIItem = {
Expand Down
68 changes: 0 additions & 68 deletions scripts/apidoc/directMethods.ts

This file was deleted.

7 changes: 1 addition & 6 deletions src/faker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { CompanyModule } from './modules/company';
import { DatabaseModule } from './modules/database';
import { DatatypeModule } from './modules/datatype';
import { DateModule } from './modules/date';
import { FakeModule } from './modules/fake';
import { FinanceModule } from './modules/finance';
import { GitModule } from './modules/git';
import { HackerModule } from './modules/hacker';
Expand All @@ -24,7 +23,6 @@ import { PhoneModule } from './modules/phone';
import { RandomModule } from './modules/random';
import { ScienceModule } from './modules/science';
import { SystemModule } from './modules/system';
import { UniqueModule } from './modules/unique';
import { VehicleModule } from './modules/vehicle';
import { WordModule } from './modules/word';
import type { LiteralUnion } from './utils/types';
Expand Down Expand Up @@ -76,11 +74,8 @@ export class Faker {

readonly definitions: LocaleDefinition = this.initDefinitions();

readonly fake: FakeModule['fake'] = new FakeModule(this).fake;
readonly unique: UniqueModule['unique'] = new UniqueModule(this).unique;

/**
* @deprecated Internal. Use faker.datatype.number() or faker.seed() instead.
* @internal
*/
readonly mersenne: MersenneModule = new MersenneModule();
readonly random: RandomModule = new RandomModule(this);
Expand Down
7 changes: 2 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,20 @@ export type { CompanyModule } from './modules/company';
export type { DatabaseModule } from './modules/database';
export type { DatatypeModule } from './modules/datatype';
export type { DateModule } from './modules/date';
export type { FakeModule } from './modules/fake';
export type { FinanceModule } from './modules/finance';
export type { GitModule } from './modules/git';
export type { HackerModule } from './modules/hacker';
export type { HelpersModule } from './modules/helpers';
export type { ImageModule } from './modules/image';
export type { InternetModule } from './modules/internet';
export type { LoremModule } from './modules/lorem';
export type { MersenneModule } from './modules/mersenne';
export type { MusicModule } from './modules/music';
export { Gender, Sex } from './modules/name';
export type { GenderType, NameModule, SexType } from './modules/name';
export { Sex } from './modules/name';
export type { NameModule, SexType } from './modules/name';
export type { PhoneModule } from './modules/phone';
export type { RandomModule } from './modules/random';
export type { ChemicalElement, ScienceModule, Unit } from './modules/science';
export type { SystemModule } from './modules/system';
export type { UniqueModule } from './modules/unique';
export type { VehicleModule } from './modules/vehicle';
export type { WordModule } from './modules/word';
export { Faker };
Expand Down
132 changes: 4 additions & 128 deletions src/modules/address/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Faker } from '../..';
import { deprecated } from '../../internal/deprecated';

/**
* Module to generate addresses and locations.
Expand Down Expand Up @@ -69,80 +68,16 @@ export class AddressModule {
/**
* Generates a random localized city name.
*
* @param format The index of the format to use. Deprecated do not use.
*
* @example
* faker.address.city() // 'East Jarretmouth'
*
* @since 2.0.1
*/
city(format?: string | number): string {
if (format != null) {
deprecated({
deprecated: 'faker.address.city(format)',
proposed: 'faker.address.city() or faker.helpers.fake(format)',
since: '7.0',
until: '8.0',
});
}
const formats = this.faker.definitions.address.city;

if (typeof format !== 'number') {
format = this.faker.datatype.number(formats.length - 1);
}

return this.faker.helpers.fake(formats[format]);
}

/**
* Returns a random localized city prefix.
*
* @see faker.address.city()
*
* @example
* faker.address.cityPrefix() // 'East'
*
* @since 2.0.1
*
* @deprecated
* Use `faker.address.city()` instead.
*/
cityPrefix(): string {
deprecated({
deprecated: 'faker.address.cityPrefix()',
proposed: "faker.address.city() or faker.fake('{{address.city_prefix}}')",
since: '7.2',
until: '8.0',
});
return this.faker.helpers.arrayElement(
this.faker.definitions.address.city_prefix
);
}

/**
* Returns a random localized city suffix.
*
* @see faker.address.city()
*
* @example
* faker.address.citySuffix() // 'mouth'
*
* @since 2.0.1
*
* @deprecated
* Use `faker.address.city()` instead.
*/
citySuffix(): string {
deprecated({
deprecated: 'faker.address.citySuffix()',
proposed:
"faker.address.city() or faker.helpers.fake('{{address.city_suffix}}')",
since: '7.2',
until: '8.0',
});
return this.faker.helpers.arrayElement(
this.faker.definitions.address.city_suffix
city(): string {
const pattern = this.faker.helpers.arrayElement(
this.faker.definitions.address.city
);
return this.faker.helpers.fake(pattern);
}

/**
Expand Down Expand Up @@ -199,17 +134,6 @@ export class AddressModule {
* @since 2.0.1
*/
streetName(): string {
if (this.faker.definitions.address.street_name == null) {
deprecated({
deprecated:
'faker.address.streetName() without address.street_name definitions',
proposed:
'faker.address.street() or provide address.street_name definitions',
since: '7.0',
until: '8.0',
});
return this.street();
}
return this.faker.helpers.arrayElement(
this.faker.definitions.address.street_name
);
Expand All @@ -235,54 +159,6 @@ export class AddressModule {
return this.faker.helpers.fake(format);
}

/**
* Returns a random localized street suffix.
*
* @see faker.address.street()
*
* @example
* faker.address.streetSuffix() // 'Streets'
*
* @since 2.0.1
*
* @deprecated Use faker.address.street() instead.
*/
streetSuffix(): string {
deprecated({
deprecated: 'faker.address.streetSuffix()',
proposed: 'faker.address.street()',
since: '7.4',
until: '8.0',
});
return this.faker.helpers.arrayElement(
this.faker.definitions.address.street_suffix
);
}

/**
* Returns a random localized street prefix.
*
* @see faker.address.street()
*
* @example
* fakerGH.address.streetPrefix() // 'Boame'
*
* @since 3.0.0
*
* @deprecated Use faker.address.street() instead.
*/
streetPrefix(): string {
deprecated({
deprecated: 'faker.address.streetPrefix()',
proposed: 'faker.address.street()',
since: '7.4',
until: '8.0',
});
return this.faker.helpers.arrayElement(
this.faker.definitions.address.street_prefix
);
}

/**
* Generates a random localized secondary address. This refers to a specific location at a given address
* such as an apartment or room number.
Expand Down
Loading

0 comments on commit 9c1437d

Please sign in to comment.