Skip to content

Commit

Permalink
add country codes package
Browse files Browse the repository at this point in the history
  • Loading branch information
tomerlichtash committed Dec 29, 2024
1 parent 9765056 commit e4144ee
Show file tree
Hide file tree
Showing 10 changed files with 2,051 additions and 158 deletions.
90 changes: 90 additions & 0 deletions packages/libs/country-codes/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"root": true,
"env": {
"browser": true,
"es2021": true
},
"extends": [
"plugin:import/typescript",
"prettier",
"plugin:jest-dom/recommended"
],
"parser": "@typescript-eslint/parser",
"ignorePatterns": [
"build/*",
"dist/*",
"webpack.config.js",
"bundle/*",
"coverage/*",
"jest.config.cjs",
"rollup.config*.js"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": "latest",
"sourceType": "module",
"project": "./tsconfig.json",
"tsconfigRootDir": "./"
},
"plugins": [
"@typescript-eslint",
"prettier",
"import",
"prefer-arrow",
"jest-dom",
"jest",
"jest-formatting",
"no-only-tests"
],
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true
}
}
},
"rules": {
"no-tabs": ["error", { "allowIndentationTabs": true }],
"@typescript-eslint/indent": ["off"],
"quotes": [
"error",
"single",
{ "avoidEscape": true, "allowTemplateLiterals": true }
],
"@typescript-eslint/quotes": [
"error",
"single",
{ "avoidEscape": true, "allowTemplateLiterals": true }
],
"@typescript-eslint/comma-dangle": ["off"],
"comma-dangle": ["off"],
"no-console": 2,
"no-only-tests/no-only-tests": 2,
"no-warning-comments": 2,
"import/no-unresolved": 2,
"import/named": 2,
"import/no-relative-packages": 2,
"import/no-cycle": 2,
"import/newline-after-import": 2,
"import/no-namespace": 2,
"import/no-duplicates": 2,
"import/first": 2,
"import/exports-last": 2,
"import/no-absolute-path": 2,
"import/no-dynamic-require": 2,
"import/no-self-import": 2,
"import/no-useless-path-segments": 2,
"import/prefer-default-export": 0,
"import/no-extraneous-dependencies": [
2,
{
"devDependencies": ["!./src/**/*"]
}
]
}
}
33 changes: 33 additions & 0 deletions packages/libs/country-codes/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const { pathsToModuleNameMapper } = require('ts-jest');
const { compilerOptions } = require('./tsconfig.json');

module.exports = {
clearMocks: true,

collectCoverage: true,
coverageDirectory: 'coverage',
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
// A set of global variables that need to be available in all test environments
globals: {
'ts-jest': {
tsconfig: 'tsconfig.json',
},
BUILD_VERSION: 'one.two.three',
},

preset: 'ts-jest',
testEnvironment: 'jsdom',
moduleDirectories: ['node_modules', 'src'],

testTimeout: 2000,

roots: ['src', 'test'],
};
76 changes: 76 additions & 0 deletions packages/libs/country-codes/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"name": "@descope/country-codes",
"version": "0.1.0",
"author": "Descope Team <[email protected]>",
"homepage": "https://github.com/descope/descope-js",
"bugs": {
"url": "https://github.com/descope/descope-js/issues",
"email": "[email protected]"
},
"main": "dist/cjs/index.cjs.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"exports": {
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/cjs/index.cjs.js"
},
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.esm.js"
}
},
"type": "module",
"description": "Phone Country Codes",
"scripts": {
"build": "rimraf dist && rollup -c",
"test": "jest",
"format": "prettier . -w --ignore-path .gitignore",
"format-check": "prettier . --check --ignore-path .gitignore",
"lint": "eslint '+(src|test|examples)/**/*.ts'",
"lint-check": "eslint '+(src|test)/**/*.+(ts|tsx)'"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/descope/descope-js.git"
},
"files": [
"dist"
],
"keywords": [
"descope",
"authentication"
],
"devDependencies": {
"@rollup/plugin-terser": "^0.4.0",
"@rollup/plugin-typescript": "^11.0.0",
"@types/jest": "^29.0.0",
"@typescript-eslint/parser": "^7.0.0",
"eslint": "8.57.0",
"eslint-config-airbnb-typescript": "18.0.0",
"eslint-config-prettier": "9.1.0",
"eslint-config-standard": "17.1.0",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jest": "28.6.0",
"eslint-plugin-jest-dom": "5.4.0",
"eslint-plugin-jest-formatting": "3.1.0",
"eslint-plugin-n": "17.9.0",
"eslint-plugin-no-only-tests": "3.1.0",
"eslint-plugin-prefer-arrow": "1.2.3",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-promise": "6.2.0",
"jest": "^29.0.0",
"jest-environment-jsdom": "^29.0.0",
"prettier": "^3.0.0",
"rimraf": "^5.0.0",
"rollup": "^4.0.0",
"rollup-plugin-auto-external": "^2.0.0",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-dts": "^6.0.0",
"ts-jest": "^29.0.0",
"ts-node": "10.9.2",
"typescript": "^5.0.2"
}
}
65 changes: 65 additions & 0 deletions packages/libs/country-codes/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import typescript from '@rollup/plugin-typescript';
import fs from 'fs';
import del from 'rollup-plugin-delete';
import dts from 'rollup-plugin-dts';
import terser from '@rollup/plugin-terser';

import packageJson from './package.json' assert { type: 'json' };

const plugins = [
typescript({
tsconfig: './tsconfig.json',
}),
terser(),
];
const input = './src/index.ts';
const external = (id) =>
!id.startsWith('\0') && !id.startsWith('.') && !id.startsWith('/');

export default [
{
input,
output: {
file: packageJson.main,
format: 'cjs',
sourcemap: true,
exports: 'named',
interop: 'compat',
inlineDynamicImports: true,
},
plugins,
external,
},
{
input,
output: {
file: packageJson.module,
format: 'esm',
sourcemap: true,
inlineDynamicImports: true,
},
plugins,
external,
},
{
input: './dist/dts/src/index.d.ts',
output: [{ file: packageJson.types, format: 'esm' }],
plugins: [
dts(),
del({ hook: 'buildEnd', targets: ['./dist/dts', './dist/cjs/dts'] }),
cjsPackage(),
],
},
];

function cjsPackage() {
return {
name: 'cjsPackage',
buildEnd: () => {
fs.writeFileSync(
'./dist/cjs/package.json',
JSON.stringify({ type: 'commonjs' }),
);
},
};
}
Loading

0 comments on commit e4144ee

Please sign in to comment.