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

Update: changed the dependency @fakerjs/faker from ver. 5.5.3 to 9.3.0 #1393

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 88 additions & 59 deletions lib/superstring/dynamic-variables.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var faker = require('@faker-js/faker/locale/en'),
var { faker } = require('@faker-js/faker'),
uuid = require('uuid'),

// locale list generated from: https://github.com/chromium/chromium/blob/master/ui/base/l10n/l10n_util.cc
Expand Down Expand Up @@ -110,7 +110,7 @@ var faker = require('@faker-js/faker/locale/en'),
$randomPhoneNumber: {
description: 'A random 10-digit phone number',
generator: function () {
return faker.phone.phoneNumberFormat(0);
return faker.helpers.fromRegExp(/[0-9]{3}-[0-9]{3}-[0-9]{4}/);
}
},

Expand All @@ -119,7 +119,8 @@ var faker = require('@faker-js/faker/locale/en'),
$randomPhoneNumberExt: {
description: 'A random phone number with extension (12 digits)',
generator: function () {
return faker.datatype.number({ min: 1, max: 99 }) + '-' + faker.phone.phoneNumberFormat(0);
return faker.number.int({ min: 1, max: 99 }) + '-' +
faker.helpers.fromRegExp(/[0-9]{3}-[0-9]{3}-[0-9]{4}/);
}
},

Expand All @@ -128,7 +129,7 @@ var faker = require('@faker-js/faker/locale/en'),
$randomLocale: {
description: 'A random two-letter language code (ISO 639-1)',
generator: function () {
return faker.random.arrayElement(LOCALES);
return faker.helpers.arrayElement(LOCALES);
}
},

Expand All @@ -138,11 +139,11 @@ var faker = require('@faker-js/faker/locale/en'),
description: 'Some random words',
generator: function () {
var words = [],
count = faker.datatype.number({ min: 2, max: 5 }),
count = faker.number.int({ min: 2, max: 5 }),
i;

for (i = 0; i < count; i++) {
words.push(faker.random.word());
words.push(faker.lorem.word());
}

return words.join(' ');
Expand All @@ -162,42 +163,42 @@ var faker = require('@faker-js/faker/locale/en'),
$randomDirectoryPath: {
description: 'A random directory path',
generator: function () {
return faker.random.arrayElement(DIRECTORY_PATHS);
return faker.helpers.arrayElement(DIRECTORY_PATHS);
}
},

$randomCity: {
description: 'A random city name',
generator: faker.address.city
generator: faker.location.city
},
$randomStreetName: {
description: 'A random street name',
generator: faker.address.streetName
generator: faker.location.street
},
$randomStreetAddress: {
description: 'A random street address (e.g. 1234 Main Street)',
generator: faker.address.streetAddress
generator: faker.location.streetAddress
},
$randomCountry: {
description: 'A random country',
generator: faker.address.country
generator: faker.location.country
},
$randomCountryCode: {
description: 'A random 2-letter country code (ISO 3166-1 alpha-2)',
generator: faker.address.countryCode
generator: faker.location.countryCode
},
$randomLatitude: {
description: 'A random latitude coordinate',
generator: faker.address.latitude
generator: faker.location.latitude
},
$randomLongitude: {
description: 'A random longitude coordinate',
generator: faker.address.longitude
generator: faker.location.longitude
},

$randomColor: {
description: 'A random color',
generator: faker.commerce.color
generator: faker.color.human
},
$randomDepartment: {
description: 'A random commerce category (e.g. electronics, clothing)',
Expand All @@ -222,19 +223,20 @@ var faker = require('@faker-js/faker/locale/en'),

$randomCompanyName: {
description: 'A random company name',
generator: faker.company.companyName
},
$randomCompanySuffix: {
description: 'A random company suffix (e.g. Inc, LLC, Group)',
generator: faker.company.companySuffix
generator: faker.company.name
},
// removed since faker.company.name attached company suffix automatically now
// $randomCompanySuffix: {
// description: 'A random company suffix (e.g. Inc, LLC, Group)',
// generator: faker.company.name.suffix
// },
$randomCatchPhrase: {
description: 'A random catchphrase',
generator: faker.company.catchPhrase
},
$randomBs: {
description: 'A random phrase of business speak',
generator: faker.company.bs
generator: faker.company.buzzPhrase
},
$randomCatchPhraseAdjective: {
description: 'A random catchphrase adjective',
Expand All @@ -250,15 +252,15 @@ var faker = require('@faker-js/faker/locale/en'),
},
$randomBsAdjective: {
description: 'A random business speak adjective',
generator: faker.company.bsAdjective
generator: faker.company.buzzAdjective
},
$randomBsBuzz: {
description: 'A random business speak buzzword',
generator: faker.company.bsBuzz
generator: faker.company.buzzVerb
},
$randomBsNoun: {
description: 'A random business speak noun',
generator: faker.company.bsNoun
generator: faker.company.buzzNoun
},

$randomDatabaseColumn: {
Expand Down Expand Up @@ -301,15 +303,17 @@ var faker = require('@faker-js/faker/locale/en'),

$randomBankAccount: {
description: 'A random 8-digit bank account number',
generator: faker.finance.account
generator: faker.finance.accountNumber
},
$randomBankAccountName: {
description: 'A random bank account name (e.g. savings account, checking account)',
generator: faker.finance.accountName
},
$randomCreditCardMask: {
description: 'A random masked credit card number',
generator: faker.finance.mask
generator: function () {
return faker.finance.iban().replace(/(?<=.{4})\w(?=.{2})/g, '*');
}
},
$randomPrice: {
description: 'A random price between 0.00 and 1000.00',
Expand Down Expand Up @@ -368,69 +372,94 @@ var faker = require('@faker-js/faker/locale/en'),
description: 'A random phrase',
generator: faker.hacker.phrase
},

$randomAvatarImage: {
description: 'A random avatar image',
generator: () => {
generator: function () {
const avatarUrls = [
'https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/' +
`avatar/${faker.number.int(1249)}.jpg`,
`https://avatars.githubusercontent.com/u/${faker.number.int(100000000)}`
];

// ref: https://github.com/faker-js/faker/blob/v8.4.1/src/modules/image/index.ts#L61
return faker.random.arrayElement([
// eslint-disable-next-line max-len
`https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/${faker.datatype.number(1249)}.jpg`,
`https://avatars.githubusercontent.com/u/${faker.datatype.number(100000000)}`
]);
return faker.helpers.arrayElement(avatarUrls);
}
},
$randomImageUrl: {
description: 'A URL for a random image',
generator: faker.image.imageUrl
generator: faker.image.url
},
$randomAbstractImage: {
description: 'A URL for a random abstract image',
generator: faker.image.abstract
generator: function () {
return faker.image.urlLoremFlickr({ category: 'abstract' });
}
},
$randomAnimalsImage: {
description: 'A URL for a random animal image',
generator: faker.image.animals
generator: function () {
return faker.image.urlLoremFlickr({ category: 'animals' });
}
},
$randomBusinessImage: {
description: 'A URL for a random stock business image',
generator: faker.image.business
generator: function () {
return faker.image.urlLoremFlickr({ category: 'business' });
}
},
$randomCatsImage: {
description: 'A URL for a random cat image',
generator: faker.image.cats
generator: function () {
return faker.image.urlLoremFlickr({ category: 'cats' });
}
},
$randomCityImage: {
description: 'A URL for a random city image',
generator: faker.image.city
generator: function () {
return faker.image.urlLoremFlickr({ category: 'city' });
}
},
$randomFoodImage: {
description: 'A URL for a random food image',
generator: faker.image.food
generator: function () {
return faker.image.urlLoremFlickr({ category: 'food' });
}
},
$randomNightlifeImage: {
description: 'A URL for a random nightlife image',
generator: faker.image.nightlife
generator: function () {
return faker.image.urlLoremFlickr({ category: 'nightlife' });
}
},
$randomFashionImage: {
description: 'A URL for a random fashion image',
generator: faker.image.fashion
generator: function () {
return faker.image.urlLoremFlickr({ category: 'fashion' });
}
},
$randomPeopleImage: {
description: 'A URL for a random image of a person',
generator: faker.image.people
generator: function () {
return faker.image.urlLoremFlickr({ category: 'people' });
}
},
$randomNatureImage: {
description: 'A URL for a random nature image',
generator: faker.image.nature
generator: function () {
return faker.image.urlLoremFlickr({ category: 'nature' });
}
},
$randomSportsImage: {
description: 'A URL for a random sports image',
generator: faker.image.sports
generator: function () {
return faker.image.urlLoremFlickr({ category: 'sports' });
}
},
$randomTransportImage: {
description: 'A URL for a random transportation image',
generator: faker.image.transport
generator: function () {
return faker.image.urlLoremFlickr({ category: 'transport' });
}
},
$randomImageDataUri: {
description: 'A random image data URI',
Expand All @@ -447,7 +476,7 @@ var faker = require('@faker-js/faker/locale/en'),
},
$randomUserName: {
description: 'A random username',
generator: faker.internet.userName
generator: faker.internet.username
},
$randomProtocol: {
description: 'A random internet protocol',
Expand Down Expand Up @@ -533,56 +562,56 @@ var faker = require('@faker-js/faker/locale/en'),

$randomFirstName: {
description: 'A random first name',
generator: faker.name.firstName
generator: faker.person.firstName
},
$randomLastName: {
description: 'A random last name',
generator: faker.name.lastName
generator: faker.person.lastName
},
$randomFullName: {
description: 'A random first and last name',
generator: faker.name.findName
generator: faker.person.fullName
},
$randomJobTitle: {
description: 'A random job title (e.g. senior software developer)',
generator: faker.name.jobTitle
generator: faker.person.jobTitle
},
$randomNamePrefix: {
description: 'A random name prefix (e.g. Mr., Mrs., Dr.)',
generator: faker.name.prefix
generator: faker.person.prefix
},
$randomNameSuffix: {
description: 'A random name suffix (e.g. Jr., MD, PhD)',
generator: faker.name.suffix
generator: faker.person.suffix
},
$randomJobDescriptor: {
description: 'A random job descriptor (e.g., senior, chief, corporate, etc.)',
generator: faker.name.jobDescriptor
generator: faker.person.jobDescriptor
},
$randomJobArea: {
description: 'A random job area (e.g. branding, functionality, usability)',
generator: faker.name.jobArea
generator: faker.person.jobArea
},
$randomJobType: {
description: 'A random job type (e.g. supervisor, manager, coordinator, etc.)',
generator: faker.name.jobType
generator: faker.person.jobType
},

$randomUUID: {
description: 'A random 36-character UUID',
generator: faker.datatype.uuid
generator: faker.string.uuid
},
$randomBoolean: {
description: 'A random boolean value (true/false)',
generator: faker.datatype.boolean
},
$randomWord: {
description: 'A random word',
generator: faker.random.word
generator: faker.lorem.word
},
$randomAlphaNumeric: {
description: 'A random alpha-numeric character',
generator: faker.random.alphaNumeric
generator: faker.string.alphanumeric
},

$randomFileName: {
Expand Down
Loading