Skip to content

Commit

Permalink
build(build): change entry point and export builded version
Browse files Browse the repository at this point in the history
+ Change tsconfig to export d.ts files in dist
+ Introduces first code release to be imported

BREAKING CHANGE: + Update tsconfig and build rules
  • Loading branch information
samir-araujo committed Apr 1, 2020
1 parent 8b430a7 commit d887af6
Show file tree
Hide file tree
Showing 24 changed files with 339 additions and 3 deletions.
1 change: 1 addition & 0 deletions dist/__tests__/faker.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions dist/helpers/__tests__/getLocale.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions dist/helpers/__tests__/helpers.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions dist/helpers/__tests__/randomArrayElement.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions dist/helpers/__tests__/randomArrayElements.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions dist/helpers/__tests__/randomNumber.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
13 changes: 13 additions & 0 deletions dist/helpers/getLocale.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Locale, LocaleObject } from '../types/locale';
/**
* Return selectedLocale from locales collection.
* If selectedLocale is not found, it will return Locale.EN as fallback.
* If both are not present, them it will throw an error
*
* @export
* @template T
* @param {LocaleObject<T>} locales
* @param {Locale} [selectedLocale=Locale.EN]
* @returns {T}
*/
export default function getLocale<T>(locales: LocaleObject<T>, selectedLocale?: Locale): T;
11 changes: 11 additions & 0 deletions dist/helpers/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import getLocale from './getLocale';
import randomArrayElement from './randomArrayElement';
import randomArrayElements from './randomArrayElements';
import randomNumber from './randomNumber';
declare const _default: {
getLocale: typeof getLocale;
randomArrayElement: typeof randomArrayElement;
randomArrayElements: typeof randomArrayElements;
randomNumber: typeof randomNumber;
};
export default _default;
9 changes: 9 additions & 0 deletions dist/helpers/randomArrayElement.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Return a random element from given array
*
* @export
* @template T
* @param {T[]} collection
* @returns {T}
*/
export default function randomArrayElement<T>(collection: T[]): T;
12 changes: 12 additions & 0 deletions dist/helpers/randomArrayElements.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Return N random items from given array.
* If the amount of items requested is greater than collection length,
* it will return as many items as possible
*
* @export
* @template T
* @param {T[]} collection
* @param {number} amount
* @returns {T[]}
*/
export default function randomArrayElements<T>(collection: T[], amount: number): T[];
12 changes: 12 additions & 0 deletions dist/helpers/randomNumber.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Return a random number between min and max values.
* By default this function returns integers numbers, but can
* return float if isFloating = true
*
* @export
* @param {number} [min]
* @param {number} [max]
* @param {boolean} [isFloating=false]
* @returns {number}
*/
export default function randomNumber(min?: number, max?: number, isFloating?: boolean): number;
12 changes: 12 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
declare const faker: {
helpers: {
getLocale: typeof import("./helpers/getLocale").default;
randomArrayElement: typeof import("./helpers/randomArrayElement").default;
randomArrayElements: typeof import("./helpers/randomArrayElements").default;
randomNumber: typeof import("./helpers/randomNumber").default;
};
name: {
firstName: typeof import("./name/firstName/firstName").default;
};
};
export default faker;
1 change: 1 addition & 0 deletions dist/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/name/__tests__/firstName.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions dist/name/__tests__/name.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
11 changes: 11 additions & 0 deletions dist/name/firstName/firstName.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Locale } from '../../types/locale';
/**
* Return a random first name.
* If a valid locale is given, it will the locale collection.
* If the given locale is not valid, it will fallback to Locale.EN
*
* @export
* @param {Locale} [selectedLocale]
* @returns {string}
*/
export default function firstName(selectedLocale?: Locale): string;
1 change: 1 addition & 0 deletions dist/name/firstName/locales/__tests__/locales.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
2 changes: 2 additions & 0 deletions dist/name/firstName/locales/en/collection.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const collection: string[];
export default collection;
3 changes: 3 additions & 0 deletions dist/name/firstName/locales/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { LocaleObject } from '../../../types/locale';
declare const locales: LocaleObject<string[]>;
export default locales;
2 changes: 2 additions & 0 deletions dist/name/firstName/locales/pt_BR/collection.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const collection: string[];
export default collection;
5 changes: 5 additions & 0 deletions dist/name/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import firstName from './firstName/firstName';
declare const _default: {
firstName: typeof firstName;
};
export default _default;
233 changes: 233 additions & 0 deletions dist/types/locale.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
export declare enum Locale {
AF = "af",
AF_ZA = "af_ZA",
AR = "ar",
AR_AE = "ar_AE",
AR_BH = "ar_BH",
AR_DZ = "ar_DZ",
AR_EG = "ar_EG",
AR_IQ = "ar_IQ",
AR_JO = "ar_JO",
AR_KW = "ar_KW",
AR_LB = "ar_LB",
AR_LY = "ar_LY",
AR_MA = "ar_MA",
AR_OM = "ar_OM",
AR_QA = "ar_QA",
AR_SA = "ar_SA",
AR_SY = "ar_SY",
AR_TN = "ar_TN",
AR_YE = "ar_YE",
AZ = "az",
AZ_AZ = "az_AZ",
BE = "be",
BE_BY = "be_BY",
BG = "bg",
BG_BG = "bg_BG",
BS_BA = "bs_BA",
CA = "ca",
CA_ES = "ca_ES",
CS = "cs",
CS_CZ = "cs_CZ",
CY = "cy",
CY_GB = "cy_GB",
DA = "da",
DA_DK = "da_DK",
DE = "de",
DE_AT = "de_AT",
DE_CH = "de_CH",
DE_DE = "de_DE",
DE_LI = "de_LI",
DE_LU = "de_LU",
DV = "dv",
DV_MV = "dv_MV",
EL = "el",
EL_GR = "el_GR",
EN = "en",
EN_AU = "en_AU",
EN_BZ = "en_BZ",
EN_CA = "en_CA",
EN_CB = "en_CB",
EN_GB = "en_GB",
EN_IE = "en_IE",
EN_JM = "en_JM",
EN_NZ = "en_NZ",
EN_PH = "en_PH",
EN_TT = "en_TT",
EN_US = "en_US",
EN_ZA = "en_ZA",
EN_ZW = "en_ZW",
EO = "eo",
ES = "es",
ES_AR = "es_AR",
ES_BO = "es_BO",
ES_CL = "es_CL",
ES_CO = "es_CO",
ES_CR = "es_CR",
ES_DO = "es_DO",
ES_EC = "es_EC",
ES_ES = "es_ES",
ES_GT = "es_GT",
ES_HN = "es_HN",
ES_MX = "es_MX",
ES_NI = "es_NI",
ES_PA = "es_PA",
ES_PE = "es_PE",
ES_PR = "es_PR",
ES_PY = "es_PY",
ES_SV = "es_SV",
ES_UY = "es_UY",
ES_VE = "es_VE",
ET = "et",
ET_EE = "et_EE",
EU = "eu",
EU_ES = "eu_ES",
FA = "fa",
FA_IR = "fa_IR",
FI = "fi",
FI_FI = "fi_FI",
FO = "fo",
FO_FO = "fo_FO",
FR = "fr",
FR_BE = "fr_BE",
FR_CA = "fr_CA",
FR_CH = "fr_CH",
FR_FR = "fr_FR",
FR_LU = "fr_LU",
FR_MC = "fr_MC",
GL = "gl",
GL_ES = "gl_ES",
GU = "gu",
GU_IN = "gu_IN",
HE = "he",
HE_IL = "he_IL",
HI = "hi",
HI_IN = "hi_IN",
HR = "hr",
HR_BA = "hr_BA",
HR_HR = "hr_HR",
HU = "hu",
HU_HU = "hu_HU",
HY = "hy",
HY_AM = "hy_AM",
ID = "id",
ID_ID = "id_ID",
IS = "is",
IS_IS = "is_IS",
IT = "it",
IT_CH = "it_CH",
IT_IT = "it_IT",
JA = "ja",
JA_JP = "ja_JP",
KA = "ka",
KA_GE = "ka_GE",
KK = "kk",
KK_KZ = "kk_KZ",
KN = "kn",
KN_IN = "kn_IN",
KO = "ko",
KO_KR = "ko_KR",
KOK = "kok",
KOK_IN = "kok_IN",
KY = "ky",
KY_KG = "ky_KG",
LT = "lt",
LT_LT = "lt_LT",
LV = "lv",
LV_LV = "lv_LV",
MI = "mi",
MI_NZ = "mi_NZ",
MK = "mk",
MK_MK = "mk_MK",
MN = "mn",
MN_MN = "mn_MN",
MR = "mr",
MR_IN = "mr_IN",
MS = "ms",
MS_BN = "ms_BN",
MS_MY = "ms_MY",
MT = "mt",
MT_MT = "mt_MT",
NB = "nb",
NB_NO = "nb_NO",
NL = "nl",
NL_BE = "nl_BE",
NL_NL = "nl_NL",
NN_NO = "nn_NO",
NS = "ns",
NS_ZA = "ns_ZA",
PA = "pa",
PA_IN = "pa_IN",
PL = "pl",
PL_PL = "pl_PL",
PS = "ps",
PS_AR = "ps_AR",
PT = "pt",
PT_BR = "pt_BR",
PT_PT = "pt_PT",
QU = "qu",
QU_BO = "qu_BO",
QU_EC = "qu_EC",
QU_PE = "qu_PE",
RO = "ro",
RO_RO = "ro_RO",
RU = "ru",
RU_RU = "ru_RU",
SA = "sa",
SA_IN = "sa_IN",
SE = "se",
SE_FI = "se_FI",
SE_NO = "se_NO",
SE_SE = "se_SE",
SK = "sk",
SK_SK = "sk_SK",
SL = "sl",
SL_SI = "sl_SI",
SQ = "sq",
SQ_AL = "sq_AL",
SR_BA = "sr_BA",
SR_SP = "sr_SP",
SV = "sv",
SV_FI = "sv_FI",
SV_SE = "sv_SE",
SW = "sw",
SW_KE = "sw_KE",
SYR = "syr",
SYR_SY = "syr_SY",
TA = "ta",
TA_IN = "ta_IN",
TE = "te",
TE_IN = "te_IN",
TH = "th",
TH_TH = "th_TH",
TL = "tl",
TL_PH = "tl_PH",
TN = "tn",
TN_ZA = "tn_ZA",
TR = "tr",
TR_TR = "tr_TR",
TS = "ts",
TT = "tt",
TT_RU = "tt_RU",
UK = "uk",
UK_UA = "uk_UA",
UR = "ur",
UR_PK = "ur_PK",
UZ = "uz",
UZ_UZ = "uz_UZ",
VI = "vi",
VI_VN = "vi_VN",
XH = "xh",
XH_ZA = "xh_ZA",
ZH = "zh",
ZH_CN = "zh_CN",
ZH_HK = "zh_HK",
ZH_MO = "zh_MO",
ZH_SG = "zh_SG",
ZH_TW = "zh_TW",
ZU = "zu",
ZU_ZA = "zu_ZA"
}
export declare type LocaleObject<T = any> = {
[K in Locale]?: T;
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "faker-es6",
"version": "0.1.1",
"description": "A heavily inspired lib to generate massive amounts of realistic fake data. This lib was inspired by what I would like to see in Marak/faker.js plus I though it could be a good exercise",
"main": "index.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "git@github.com:samir-araujo/faker-es6.git",
"author": "Samir J M Araujo <samir.blanc@gmail.com>",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
"declaration": true /* Generates corresponding '.d.ts' file. */,
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
"outDir": "./dist" /* Redirect output structure to the directory. */,
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
Expand Down

0 comments on commit d887af6

Please sign in to comment.