Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: cleanup deprecations #1440

Merged
merged 12 commits into from
Oct 14, 2022
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
6 changes: 2 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ 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';
Expand All @@ -55,13 +54,12 @@ export type { InternetModule } from './modules/internet';
export type { LoremModule } from './modules/lorem';
export type { MersenneModule } from './modules/mersenne';
Shinigami92 marked this conversation as resolved.
Show resolved Hide resolved
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
99 changes: 0 additions & 99 deletions src/modules/address/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,57 +94,6 @@ export class AddressModule {
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
);
}

/**
* Returns a random localized and existing city name.
*
Expand Down Expand Up @@ -235,54 +184,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
24 changes: 0 additions & 24 deletions src/modules/commerce/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Faker } from '../../faker';
import { deprecated } from '../../internal/deprecated';

/**
* Module to generate commerce and product related entries.
Expand All @@ -15,29 +14,6 @@ export class CommerceModule {
}
}

/**
* Returns a human readable color name.
*
* @see faker.color.human()
*
* @example
* faker.commerce.color() // 'red'
*
* @since 3.0.0
*
* @deprecated
* Use `faker.color.human()` instead.
*/
color(): string {
deprecated({
deprecated: 'faker.commerce.color()',
proposed: 'faker.color.human()',
since: '7.0',
until: '8.0',
});
return this.faker.color.human();
}

/**
* Returns a department inside a shop.
*
Expand Down
25 changes: 0 additions & 25 deletions src/modules/company/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,6 @@ export class CompanyModule {
return this.faker.helpers.fake(formats[format]);
}

/**
* Generates a random company name.
*
* @param format The optional format index used to select a format.
*
* @see faker.company.name()
*
* @example
* faker.company.companyName() // 'Zieme, Hauck and McClure'
*
* @since 2.0.1
*
* @deprecated Use `faker.company.name()` instead
*/
companyName(format?: number): string {
deprecated({
deprecated: 'faker.company.companyName()',
proposed: 'faker.company.name()',
since: '7.4',
until: '8.0',
});

return this.name(format);
}

/**
* Returns a random company suffix.
*
Expand Down
Loading