Comparing version 1.3.1 to 1.3.2
{ | ||
"name": "ctix", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "Automatic create index.ts file", | ||
@@ -9,9 +9,7 @@ "scripts": { | ||
"test:debug": "node --nolazy --inspect ./node_modules/jest/bin/jest --runInBand", | ||
"start": "cross-env TS_NODE_PROJECT=tsconfig.json node -r ts-node/register -r tsconfig-paths/register ./src/cli.ts", | ||
"dts-bundle": "dts-bundle-generator dist/src/ctix.d.ts -o dist/ctix.d.ts --no-banner", | ||
"postdts-bundle": "npm run clean:dts", | ||
"webpack:prod": "cross-env NODE_ENV=production webpack --config ./.configs/webpack.config.prod.cjs", | ||
"postwebpack:prod": "npm run dts-bundle", | ||
"webpack:dev": "cross-env NODE_ENV=production webpack --config ./.configs/webpack.config.dev.cjs", | ||
"postwebpack:dev": "npm run dts-bundle", | ||
"dev": "cross-env TS_NODE_PROJECT=tsconfig.json node -r ts-node/register -r tsconfig-paths/register ./src/cli.ts", | ||
"prerollup:dev": "npm run clean", | ||
"rollup:dev": "cross-env NODE_ENV=develop rollup --config ./.configs/rollup.config.dev.ts --configPlugin typescript", | ||
"prerollup:prod": "npm run clean", | ||
"rollup:prod": "cross-env NODE_ENV=production rollup --config ./.configs/rollup.config.prod.ts --configPlugin typescript", | ||
"debug": "cross-env TS_NODE_PROJECT=tsconfig.json node -r ts-node/register -r tsconfig-paths/register --nolazy --inspect-brk=9229 ./src/cli.ts ", | ||
@@ -22,7 +20,11 @@ "prebuild": "npm run clean", | ||
"clean:dts": "rimraf ./dist/src", | ||
"prepub": "npm run clean && npm run webpack:prod", | ||
"prepub": "npm run clean && npm run rollup:prod", | ||
"pub": "npm publish --registry http://localhost:8901 --force", | ||
"prepub:prod": "npm run clean && npm run webpack:prod", | ||
"prepub:prod": "npm run clean && npm run rollup:prod", | ||
"pub:prod": "npm publish", | ||
"lint": "eslint --ext ts,tsx ./src/*" | ||
"lint": "eslint --ext ts,tsx ./src/*", | ||
"docs:dev": "vuepress dev docs --config ./.configs/vuepress.config.ts", | ||
"docs:build": "vuepress build docs --config ./.configs/vuepress.config.ts", | ||
"predocs:deploy": "npm run docs:build", | ||
"docs:deploy": "cross-env PUBLIC_URL=\"ctix\" gh-pages -d docs/.vuepress/dist" | ||
}, | ||
@@ -40,7 +42,14 @@ "repository": { | ||
"homepage": "https://github.com/imjuni/ctix#readme", | ||
"main": "dist/ctix.js", | ||
"types": "./dist/ctix.d.ts", | ||
"main": "dist/cjs/ctix.js", | ||
"types": "dist/cjs/ctix.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"exports": { | ||
".": { | ||
"types": "./dist/esm/ctix.d.ts", | ||
"require": "./dist/cjs/ctix.js", | ||
"import": "./dist/esm/ctix.js" | ||
} | ||
}, | ||
"bin": { | ||
@@ -51,2 +60,5 @@ "ctix": "./dist/cli.js" | ||
"@jest/test-sequencer": "^28.1.0", | ||
"@renovamen/vuepress-plugin-mermaid": "^2.0.0-alpha.25", | ||
"@rollup/plugin-node-resolve": "^13.3.0", | ||
"@rollup/plugin-typescript": "^8.3.4", | ||
"@tsconfig/node16": "^1.0.2", | ||
@@ -62,2 +74,3 @@ "@types/cli-progress": "^3.11.0", | ||
"@types/parse-gitignore": "^1.0.0", | ||
"@types/source-map-support": "^0.5.4", | ||
"@types/yargs": "^17.0.10", | ||
@@ -68,3 +81,2 @@ "@typescript-eslint/eslint-plugin": "^5.27.0", | ||
"cross-env": "^7.0.3", | ||
"dts-bundle-generator": "^6.12.0", | ||
"eslint": "^8.16.0", | ||
@@ -76,6 +88,13 @@ "eslint-config-airbnb-typescript": "^17.0.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"gh-pages": "^4.0.0", | ||
"jest": "^28.1.0", | ||
"mermaid": "^9.1.4", | ||
"prettier-eslint": "^15.0.1", | ||
"prettier-plugin-organize-imports": "^2.3.4", | ||
"read-pkg": "^5.2.0", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.77.2", | ||
"rollup-plugin-sourcemaps": "^0.6.3", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"rollup-plugin-ts": "^3.0.2", | ||
"ts-jest": "^28.0.3", | ||
@@ -85,8 +104,7 @@ "ts-loader": "^9.3.0", | ||
"tsconfig-paths": "^4.0.0", | ||
"tsconfig-paths-webpack-plugin": "^3.5.2", | ||
"webpack": "^5.72.1", | ||
"webpack-cli": "^4.9.2", | ||
"webpack-merge": "^5.8.0", | ||
"webpack-node-externals": "^3.0.0", | ||
"webpackbar": "^5.0.2" | ||
"typedoc": "^0.23.10", | ||
"typedoc-plugin-markdown": "^3.13.4", | ||
"typescript": "^4.7.4", | ||
"vuepress": "^2.0.0-beta.49", | ||
"vuepress-plugin-typedoc": "^0.11.0" | ||
}, | ||
@@ -116,3 +134,2 @@ "dependencies": { | ||
"type-fest": "^2.18.0", | ||
"typescript": "^4.7.2", | ||
"upper-case-first": "^2.0.2", | ||
@@ -119,0 +136,0 @@ "yargs": "^17.5.1" |
247
README.md
@@ -1,6 +0,6 @@ | ||
## ctix - Next generation Create TypeScript Index file | ||
# ctix - Next generation Create TypeScript Index file | ||
[![Download Status](https://img.shields.io/npm/dw/ctix.svg)](https://npmcharts.com/compare/ctix?minimal=true) [![Github Star](https://img.shields.io/github/stars/imjuni/ctix.svg?style=popout)](https://github.com/imjuni/ctix) [![Github Issues](https://img.shields.io/github/issues-raw/imjuni/ctix.svg)](https://github.com/imjuni/ctix/issues) [![NPM version](https://img.shields.io/npm/v/ctix.svg)](https://www.npmjs.com/package/ctix) [![License](https://img.shields.io/npm/l/ctix.svg)](https://github.com/imjuni/ctix/blob/master/LICENSE) [![ctix](https://circleci.com/gh/imjuni/ctix.svg?style=shield)](https://app.circleci.com/pipelines/github/imjuni/ctix?branch=master) | ||
# Installation | ||
## Installation | ||
@@ -11,13 +11,13 @@ ```bash | ||
# Usage | ||
## Usage | ||
``` | ||
```bash | ||
ctix create -p ./tsconfig.json | ||
``` | ||
# Introduction | ||
## Introduction | ||
You have to create a list of files when bundling with [webpack](https://webpack.js.org/) and [rollup.js](https://rollupjs.org/guide/en/), or creating documents with [typedoc](https://typedoc.org/). It's boring to re-list files every time they change files change. ctix is a simple tool that automates the creation of file lists. | ||
# Why ctix? | ||
## Why ctix? | ||
@@ -31,72 +31,140 @@ An application project has a clear [entry point](https://webpack.js.org/concepts/entry-points/), but if it is a library project, the entry point is not clear, so you have to create it yourself. typedoc have to explicitly specify what to document, even for an application project. | ||
# Installation | ||
## Important | ||
`ctix` does not work in JavaScript code because it uses TypeScript API, please use it **`before`** Babel translation or TypeScript compilation. | ||
## How to works? | ||
ctix use TypeScript Compiler API and directory structure. Export something from TypeScript source file after run ctix to create `index.ts` file. | ||
### Create mode: As-Is tree structure | ||
```text | ||
├─ src/ | ||
│ ├─ component/ | ||
│ │ ├─ Nav.tsx | ||
│ │ ├─ Button.tsx | ||
│ │ ├─ Input.tsx | ||
│ ├─ pages/ | ||
│ │ ├─ Hero.tsx | ||
│ │ ├─ User.tsx | ||
├─ App.tsx | ||
``` | ||
npm install ctix --save-dev | ||
``` | ||
# Usage | ||
### Create mode: To-Be tree structure | ||
After `ctix create -p ./tsconfig.json` command. | ||
```text | ||
# To-Be | ||
├─ src/ | ||
│ ├─ component/ | ||
│ │ ├─ Nav.tsx | ||
│ │ ├─ Button.tsx | ||
│ │ ├─ Input.tsx | ||
│ │ ├─ index.ts # created | ||
│ ├─ pages/ | ||
│ │ ├─ Hero.tsx | ||
│ │ ├─ User.tsx | ||
│ │ ├─ index.ts # created | ||
│ ├─ index.ts # created | ||
├─ App.tsx | ||
├─ index.ts # created | ||
``` | ||
ctix single -p [tsconfig.json file path] | ||
``` | ||
# How to works? | ||
Each file is as belows: | ||
Manage index.ts(export file), not so convenience. If you add file or class, function you rewrite export file over and over again. `ctix` help this work. `ctix` read .npmignore, .ctiignore file after ignore there also you can use exclude configuration in tsconfig.json. See below example, | ||
#### Create mode: `src/component/index.ts` | ||
```ts | ||
// created from 'ctix' | ||
export * from './Nav'; | ||
export * from './Button'; | ||
export * from './Input'; | ||
``` | ||
src/ | ||
app.ts | ||
component/ | ||
Nav.ts | ||
Button.ts | ||
#### Create mode: `src/pages/index.ts` | ||
```ts | ||
// created from 'ctix' | ||
export * from './Hero'; | ||
export * from './User'; | ||
``` | ||
ctix create sub-command create index.ts file below. | ||
#### Create mode: `src/index.ts` | ||
```ts | ||
// created from 'ctix' | ||
export * from './component'; | ||
export * from './pages'; | ||
``` | ||
src/ | ||
app.ts | ||
> index.ts | ||
// created from 'ctix' | ||
export * from './component'; | ||
export * from './app'; | ||
component/ | ||
Nav.ts | ||
Button.ts | ||
> index.ts | ||
// created from 'ctix' | ||
export * from './Nav'; | ||
export * from './Button'; | ||
#### Create mode: `index.ts` | ||
```ts | ||
// created from 'ctix' | ||
export * from './App'; | ||
export * from './src'; | ||
``` | ||
ctix single mode generate single file. This file suitable for webpack entrypoint. | ||
### Single mode: As-Is tree structure | ||
```text | ||
├─ src/ | ||
│ ├─ component/ | ||
│ │ ├─ Nav.tsx | ||
│ │ ├─ Button.tsx | ||
│ │ ├─ Input.tsx | ||
│ ├─ pages/ | ||
│ │ ├─ Hero.tsx | ||
│ │ ├─ User.tsx | ||
├─ App.tsx | ||
``` | ||
src/ | ||
app.ts | ||
component/ | ||
Nav.ts | ||
Button.ts | ||
> entrypoint.ts | ||
// created from 'ctix' | ||
export * from './src/app.ts' | ||
export * from './src/component/Nav.ts' | ||
export * from './src/component/Button.ts' | ||
### Single mode: To-Be tree structure | ||
After `ctix single -p ./tsconfig.json` command. single mode create one `index.ts` file. | ||
```text | ||
├─ src/ | ||
│ ├─ component/ | ||
│ │ ├─ Nav.tsx | ||
│ │ ├─ Button.tsx | ||
│ │ ├─ Input.tsx | ||
│ ├─ pages/ | ||
│ │ ├─ Hero.tsx | ||
│ │ ├─ User.tsx | ||
├─ App.tsx | ||
├─ index.ts # created | ||
``` | ||
# Pros & Cons | ||
Each file is as belows: | ||
## Pros | ||
#### Single mode: `index.ts` | ||
```text | ||
// created from 'ctix' | ||
export * from './component/Nav'; | ||
export * from './component/Button'; | ||
export * from './component/Input'; | ||
export * from './pages/Hero'; | ||
export * from './pages/User'; | ||
export * from './App'; | ||
``` | ||
## Pros & Cons | ||
### Pros | ||
1. pass tsconfig.json file, another process don't care about | ||
1. Support default exportation | ||
- using TypeScript API so detect default export and named export | ||
- my_default_index.test.ts file create `export { default as myDefaultIndexTest } from './my_default_index.test.ts'` | ||
1. Partial ignore | ||
- specific export statement exclude on index.ts file. | ||
- ex> { "my_lib_package.ts": ["exists", "temp"] } | ||
- eg. `{ "my_lib_package.ts": ["exists", "temp"] }` | ||
1. Skip empty directory | ||
1. isolatedModules support | ||
## Cons | ||
### Cons | ||
@@ -106,52 +174,36 @@ 1. It may be slow for some project | ||
# What is difference module resolution? | ||
## What is difference Re-Map paths? | ||
Most inconvenience from import statement that solve [module resolution](https://www.typescriptlang.org/docs/handbook/module-resolution.html). But module resolution don't helpful for entrypoint create for bundling. ctix helpful this work. | ||
It is not recommanded to use `index.ts` file to re-map paths or shorten the paths. If you want to shorten the paths use [Re-Map paths](https://www.typescriptlang.org/tsconfig#paths) feature in TypeScript compilerOptions. `ctix` is recommanded for webpack and rollup.js, typedoc entrypoint and TypeScript declaration file bundling. | ||
# Example | ||
## Option | ||
Example of each command. | ||
| Name | Short | Default | Command | Description | | ||
| :--------------- | ----- | -------- | ---------------------- | ---------------------------------------------------------------------------------------------------------- | | ||
| --config | -c | | All | configuration file(.ctirc) path | | ||
| --project | -p | required | All | tsconfig.json path: you must pass path with filename, like this "./tsconfig.json" | | ||
| --exportFilename | -f | index.ts | create, single, remove | Export filename, if you not pass this field that use "index.ts" or "index.d.ts" | | ||
| --useSemicolon | -s | true | create, single | add semicolon on line ending at every export statement | | ||
| --useTimestamp | -t | false | create, single | timestamp write on ctix comment right-side, only works in useComment option set true | | ||
| --useComment | -m | true | create, single | ctix comment add on first line of creted export file(default index.ts) file, that remark created from ctix | | ||
| --quote | -q | ' | create, single | change quote character at export syntax | | ||
| --keepFileExt | -k | ' | create, single | keep file extension on export statement path literal | | ||
| --overwrite | -w | ' | create, single | overwrite each index.ts file | | ||
| --skipEmptyDir | -e | ' | create | empty directory skip create index.ts file | | ||
| --output | -o | N/A | single | output directory | | ||
| --useRootDir | -r | false | single | output file under rootDir in tsconfig.json. | | ||
| --includeBackup | N/A | false | remove | If this option set true on remove mode what will be delete backup file. | | ||
```bash | ||
# create | ||
ctix create -p ./tsconfig.json | ||
ctix c -p ./tsconfig.json | ||
## Ignore | ||
# single | ||
ctix single -p ./tsconfig.json | ||
ctix s -p ./tsconfig.json | ||
Ignore file 3 way belows: | ||
# clean | ||
ctix remove -p ./tsconfig.json | ||
ctix r -p ./tsconfig.json | ||
- `.gitignore` | ||
- `.npmignore` | ||
- `.ctiignore` | ||
# init | ||
ctix init | ||
ctix i | ||
``` | ||
`.gitignore` file follow [.gitignore spec 2.22.1](http://git-scm.com/docs/gitignore). `.ctiignore` file key follow [.gitignore spec 2.22.1](http://git-scm.com/docs/gitignore). `.gitignore spec 2.22.` spec using by [ignore](https://github.com/kaelzhang/node-ignore) package. `.npmignore` spec using by [minimatch](https://github.com/isaacs/minimatch) | ||
## Option | ||
### .ctiignore | ||
| Name | Short | Default | Command | Description | | ||
| :--------------: | ----- | -------- | --------------------- | ---------------------------------------------------------------------------------------------------------- | | ||
| --config | -c | | All | configuration file(.ctirc) path | | ||
| --project | -p | required | All | tsconfig.json path: you must pass path with filename, like this "./tsconfig.json" | | ||
| --exportFilename | -f | index.ts | create, single, clean | Export filename, if you not pass this field that use "index.ts" or "index.d.ts" | | ||
| --useSemicolon | -s | true | create, single | add semicolon on line ending at every export statement | | ||
| --useTimestamp | -t | false | create, single | timestamp write on ctix comment right-side, only works in useComment option set true | | ||
| --useComment | -m | true | create, single | ctix comment add on first line of creted export file(default index.ts) file, that remark created from ctix | | ||
| --quote | -q | ' | create, single | change quote character at export syntax | | ||
| --keepFileExt | -k | ' | create, single | keep file extension on export statement path literal | | ||
| --overwrite | -w | ' | create, single | overwrite each index.ts file | | ||
| --skipEmptyDir | -e | ' | create | empty directory skip create index.ts file | | ||
| --output | -o | N/A | single | output directory | | ||
| --useRootDir | -r | false | single | output file under rootDir in tsconfig.json. | | ||
| --includeBackup | N/A | false | clean | If this option set true on clean mode what will be delete backup file. | | ||
# Ignore | ||
Ignore file 3 way that is `.gitignore`, `.npmignore`, `.ctiignore`. | ||
## .ctiignore | ||
.ctiignore file is json with comments. See below. | ||
@@ -168,5 +220,5 @@ | ||
json key indicate file path. You can use glob pattern. If set `'*'` character at value that is totally ignore file or glob pattern. If set string array that is ignore type name array. | ||
json key indicate ignore file path. You can use glob pattern like `.gitignore`. If set `'*'` character at value that is totally ignore file or glob pattern. If set string array that is ignore type name array. | ||
## ignore testcase | ||
### ignore testcase | ||
@@ -184,7 +236,7 @@ testcase directory ignore using glob pattern. | ||
## rootDir, rootDirs | ||
### rootDir, rootDirs | ||
useRootDir option activate using rootDir option in tsconfig.json. This option run below [flowchart](https://github.com/imjuni/ctix/blob/master/docs/UseRootDir.md). | ||
# CLI with .ctirc | ||
## CLI with .ctirc | ||
@@ -205,7 +257,7 @@ ctix cli support `.ctirc` configuration file. Available name is only `.ctirc`. Also cti cli arguments forced applied. And `.ctirc` file can write [json with comments](https://www.npmjs.com/package/jsonc-parser). | ||
# Breaking Change | ||
## Breaking Change | ||
0.6.x and 1.x version big different. See [migration guide](https://github.com/imjuni/ctix/blob/master/docs/MigrationGuide.md). cli command, option, ignore file changed. Support TypeScript `4.7.2` and `new file extensions(.mts, .cts, etc)`. | ||
# Programming interface | ||
## Programming interface | ||
@@ -220,6 +272,1 @@ Each command can use that function. Each function can pass isMessageDisplay flag second parameter. isMessageDisplay pass false or undefined after not display console message and progress. | ||
| createInitFile | TTInitOptionWithDirInfo, isMessageDisplay | init | | ||
# Language | ||
- [English](https://github.com/imjuni/ctix/blob/master/README.md) | ||
- [Korean](https://github.com/imjuni/ctix/blob/master/README.ko.md) |
Sorry, the diff of this file is too big to display
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
24
14
266
594600
46
5346
1
3
1
- Removedtypescript@^4.7.2
- Removedtypescript@4.9.5(transitive)