Skip to content

Commit

Permalink
Change: default export to named export
Browse files Browse the repository at this point in the history
- [change] `default export` to `named export`
- [change] `rollup-plugin-dts` to `dts-bundle-generator`
- [change] custom `index.ts` to `ctix` generated
  • Loading branch information
imjuni committed Nov 12, 2023
1 parent a1ef82e commit 36c0ed2
Show file tree
Hide file tree
Showing 19 changed files with 713 additions and 90 deletions.
133 changes: 133 additions & 0 deletions .configs/.ctirc
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
// configuration file(.ctirc) path
"config": ".ctirc",

// Stream of cli spinner, you can pass stdout or stderr
//
// @mode all
// @default stdout
"spinnerStream": "stdout",

// Stream of cli progress, you can pass stdout or stderr
//
// @mode all
// @default stdout
"progressStream": "stdout",

// Stream of cli reasoner. Reasoner show name conflict error and already exist index.ts file error.
// You can pass stdout or stderr
//
// @mode all
// @default stderr
"reasonerStream": "stderr",

"options": [
{
// build mode
// - create: create an `index.ts` file in each directory
// - bundle: bundle all export information in one `index.ts` file
"mode": "bundle",

// tsconfig.json path: you must pass path with filename, like this "./tsconfig.json"
// only work root directory or cli parameter
//
// @mode all
"project": "tsconfig.prod.json",

// Export filename, if you not pass this field that use "index.ts" or "index.d.ts"
//
// @mode create, bundle, remove
// @default index.ts
"exportFilename": "index.ts",

// add ctix comment at first line of creted index.ts file, that remark created from ctix
//
// @mode create, bundle
// @default false
"useSemicolon": true,

// add ctix comment at first line of creted index.ts file, that remark created from ctix
//
// @mode create, bundle
// @default false
"useBanner": false,

// If specified as true, adds the created date to the top of the `index.ts` file,
// this option only works if the `useBanner` option is enabled
//
// @mode create, bundle
// @default false
"useTimestamp": false,

// quote mark " or '
// @mode create, bundle
//
// @default '
"quote": "'",

// Use to add a literal like `"use strict"` to the top. It will be added before the banner.
//
// @mode create, bundle
"directive": "",

// keep file extension in export statement path
//
// if this option set true that see below
// export * from './test.ts'
//
// @mode create, bundle
// @default none
"fileExt": "none",

// overwrite each index.ts file
// @mode create, bundle
// @default false
"overwrite": true,

// Create a backup file if the `index.ts` file already exists.
// This option only works if the `overwrite` option is enabled.
//
// @mode create, bundle
// @defulat true
"backup": false,

// When generating the `index.ts` file, decide how you want to generate it
//
// @mode create, bundle
// @default auto
"generationStyle": "auto",

// A list of files to use when generating the index.ts file. If no value is set,
// the value of the include setting set in the tsconfig.json file will be used
//
// @mode create, bundle
"include": ["src/**/*.ts"],

// A list of files to exclude when generating the index.ts file. If no value is set,
// the value of the exclude setting set in the tsconfig.json file is used
//
// @mode create, bundle
"exclude": ["dist/**", ".configs/**"],

// If `skipEmptyDir` is set to true, an empty directory with no files will not create an `index.ts` file
//
// @mode create
// @default true
"skipEmptyDir": true,

// Output directory. Default value is same project directory
// @mode bundle
"output": "src",

// remove with backup file
// @mode remove
// @default false
"removeBackup": false,

// answer `yes` to all questions
// @mode remove
// @default false
"forceYes": false
}
]
}
11 changes: 0 additions & 11 deletions .configs/rollup.mjs

This file was deleted.

62 changes: 57 additions & 5 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ module.exports = {
ignorePatterns: ['coverage/**', 'dist/**', '__test__/**', '__tests__/**'],
plugins: ['@typescript-eslint', 'prettier', 'import'],
rules: {
// ----------------------------------------------------------------------------------------------------------
// eslint
// ----------------------------------------------------------------------------------------------------------
'max-len': [
'error',
{
Expand All @@ -34,18 +37,67 @@ module.exports = {
code: 120,
},
],
'no-underscore-dangle': ['error', { allowAfterThis: true }],
'no-restricted-syntax': [
'error',
{
selector: 'TSEnumDeclaration:not([const=true])',
message: "Don't declare non-const enums",
},
],
// ----------------------------------------------------------------------------------------------------------
// @typescript-eslint
// ----------------------------------------------------------------------------------------------------------
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'interface',
format: ['PascalCase'],
custom: {
regex: '^I[A-Z]+',
match: true,
},
},
{
selector: 'typeAlias',
format: ['PascalCase'],
custom: {
regex: '^T[A-Z]+',
match: true,
},
},
],
'@typescript-eslint/member-delimiter-style': [
'off',
{
multiline: {
delimiter: 'none',
requireLast: true,
},
singleline: {
delimiter: 'semi',
requireLast: false,
},
},
],
'@typescript-eslint/no-unused-vars': [
'error',
{
varsIgnorePattern: '^_.+$',
argsIgnorePattern: '^_.+$',
},
],
'import/extensions': ['off'],
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
// static function use this: void
'@typescript-eslint/no-invalid-void-type': ['error', { allowAsThisParameter: true }],
'@typescript-eslint/no-unnecessary-boolean-literal-compare': ['off'],
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
},
],
// ----------------------------------------------------------------------------------------------------------
// eslint-plugin-import
// ----------------------------------------------------------------------------------------------------------
'import/prefer-default-export': ['off'],
'import/no-default-export': ['error'],
},
overrides: [
{
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ jobs:
- run: pnpm run build
- run: pnpm test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
[![NPM version](https://img.shields.io/npm/v/@maeum/i18n-controller.svg?style=flat-square)](https://www.npmjs.com/package/@maeum/i18n-controller)
[![@maeum/i18n-controller](https://github.com/maeumjs/i18n-controller/actions/workflows/ci.yml/badge.svg?style=flat-square)](https://github.com/maeumjs/i18n-controller/actions/workflows/ci.yml)
[![License](https://img.shields.io/npm/l/@maeum/i18n-controller.svg?style=flat-square)](https://github.com/maeumjs/i18n-controller/blob/master/LICENSE)
[![codecov](https://codecov.io/gh/imjuni/i18n-controller/branch/master/graph/badge.svg?token=cYJEAvZUFU)](https://codecov.io/gh/imjuni/i18n-controller)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

The `@maeum/i18n-controller` is a package that helps developer to integreate [node-polyglot](https://airbnb.io/polyglot.js/). Developer can generate a i18n resource via json format file and then use as a singletone class in application(eg. fastify.js or express.js).
Expand Down
19 changes: 9 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@
},
"scripts": {
"clean": "rimraf dist",
"prebuild": "pnpm run clean",
"build": "tsc --incremental --noEmit --project tsconfig.json --tsBuildInfoFile .tsbuildinfo",
"dts": "tsc --project tsconfig.prod.json --declaration --emitDeclarationOnly --declarationDir dist/types/origin",
"dts-gen": "rollup --config ./.configs/rollup.mjs",
"dts:clean": "rimraf dist/types/origin",
"ctix": "ctix build --config .configs/.ctirc",
"ctix-rm": "ctix remove -p ./tsconfig.json --config .configs/.ctirc --force-yes --remove-backup",
"build": "pnpm run clean && tsc --incremental --noEmit --project tsconfig.json",
"dts-gen": "dts-bundle-generator --project tsconfig.dts.json -o dist/types/index.d.ts --no-banner src/index.ts",
"esbuild-cjs": "FORMAT=cjs node .configs/esbuild.mjs",
"esbuild-esm": "FORMAT=esm node .configs/esbuild.mjs",
"bundle-pack": "run-p esbuild-cjs esbuild-esm dts",
"bundle": "run-s clean bundle-pack dts-gen dts:clean",
"bundle-pack": "pnpm run ctix && run-p esbuild-cjs esbuild-esm dts-gen && pnpm run ctix-rm",
"bundle": "run-s clean bundle-pack",
"test": "vitest run --coverage",
"lint": "eslint --cache .",
"lint-staged": "lint-staged",
"pub": "pnpm run bundle && cross-env RELEASE_MODE=true pnpm publish --registry http://localhost:8901",
"pub": "pnpm run bundle && cross-env RELEASE_MODE=true pnpm publish --registry http://localhost:8901 --no-git-checks",
"unpub": "pnpm unpublish $npm_package_name@$npm_package_version --registry http://localhost:8901 --force",
"pub:prod": "pnpm run bundle && cross-env RELEASE_MODE=true pnpm publish --access=public",
"dd": "deps-diff md -d prod -d dev --title-list-type '*' --deps-list-type '*' --content-list-type '*'",
Expand Down Expand Up @@ -70,7 +69,9 @@
"@vitest/coverage-istanbul": "^0.34.5",
"@vitest/coverage-v8": "^0.34.5",
"cross-env": "^7.0.3",
"ctix": "^2.0.0",
"deps-diff": "^1.0.2",
"dts-bundle-generator": "^8.1.2",
"esbuild": "0.19.2",
"eslint": "^8.48.0",
"eslint-config-airbnb-base": "^15.0.0",
Expand All @@ -90,8 +91,6 @@
"prettier-plugin-organize-imports": "^3.2.3",
"read-pkg": "^5.2.0",
"rimraf": "^5.0.1",
"rollup": "^3.29.2",
"rollup-plugin-dts": "^6.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
Expand Down

0 comments on commit 36c0ed2

Please sign in to comment.