tsconfck
Advanced tools
Comparing version 1.2.2 to 2.0.0
{ | ||
"name": "tsconfck", | ||
"version": "1.2.2", | ||
"version": "2.0.0", | ||
"description": "A utility to work with tsconfig.json without typescript", | ||
@@ -49,14 +49,14 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@commitlint/cli": "^16.2.3", | ||
"@commitlint/config-conventional": "^16.2.1", | ||
"@tsconfig/node12": "^1.0.9", | ||
"@commitlint/cli": "^16.2.4", | ||
"@commitlint/config-conventional": "^16.2.4", | ||
"@tsconfig/node14": "^1.0.1", | ||
"@types/node": "^17.0.21", | ||
"@typescript-eslint/eslint-plugin": "^5.17.0", | ||
"@typescript-eslint/parser": "^5.17.0", | ||
"c8": "^7.11.0", | ||
"@typescript-eslint/eslint-plugin": "^5.23.0", | ||
"@typescript-eslint/parser": "^5.23.0", | ||
"c8": "^7.11.2", | ||
"chalk": "^5.0.1", | ||
"conventional-changelog-cli": "^2.2.2", | ||
"enquirer": "^2.3.6", | ||
"esbuild": "^0.14.31", | ||
"eslint": "^8.12.0", | ||
"esbuild": "^0.14.38", | ||
"eslint": "^8.15.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
@@ -68,3 +68,3 @@ "eslint-plugin-markdown": "^2.2.1", | ||
"husky": "^7.0.4", | ||
"lint-staged": "^12.3.7", | ||
"lint-staged": "^12.4.1", | ||
"minimist": "^1.2.6", | ||
@@ -74,7 +74,7 @@ "npm-run-all": "^4.1.5", | ||
"rimraf": "^3.0.2", | ||
"semver": "^7.3.5", | ||
"semver": "^7.3.7", | ||
"tiny-glob": "^0.2.9", | ||
"tsm": "^2.2.1", | ||
"tsup": "^5.12.4", | ||
"typescript": "^4.6.3", | ||
"tsup": "^5.12.7", | ||
"typescript": "^4.6.4", | ||
"uvu": "^0.5.3", | ||
@@ -89,24 +89,24 @@ "watchlist": "^0.3.1" | ||
}, | ||
"packageManager": "pnpm@6", | ||
"packageManager": "pnpm@7.0.1", | ||
"engines": { | ||
"node": "^12.20 || ^14.13.1 || >= 16" | ||
"node": "^14.13.1 || ^16 || >=18", | ||
"pnpm": "^7.0.1" | ||
}, | ||
"scripts": { | ||
"dev": "pnpm run build:ci -- --watch src", | ||
"build:ci": "rimraf dist && tsup-node src/index.ts --format esm,cjs --no-splitting", | ||
"build": "pnpm run build:ci -- --dts --sourcemap && node scripts/generate-api-docs.js", | ||
"dev": "pnpm build:ci --watch src", | ||
"build:ci": "rimraf dist && tsup-node src/index.ts --format esm,cjs --no-splitting --target node14.13.1", | ||
"build": "pnpm build:ci --dts --sourcemap && node scripts/generate-api-docs.js", | ||
"test": "node --experimental-loader tsm node_modules/uvu/bin.js tests -i fixtures -i temp -i util/", | ||
"test:watch": "pnpm test; watchlist tests src -- pnpm test", | ||
"test:coverage": "c8 --include=src --clean pnpm run test", | ||
"test:coverage": "c8 --include=src --clean pnpm test", | ||
"test:report": "c8 report --reporter=text-lcov > coverage/coverage.lcov", | ||
"lint": "eslint --ignore-path .gitignore '**/*.{cjs,js,ts,md}'", | ||
"lint:fix": "pnpm run lint -- --fix", | ||
"lint:fix": "pnpm lint --fix", | ||
"format": "prettier --ignore-path .gitignore '**/*.{cjs,js,ts,md}' --check", | ||
"format:fix": "pnpm run format -- --write", | ||
"format:fix": "pnpm format --write", | ||
"fixup": "run-s lint:fix format:fix", | ||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -l tsconfck", | ||
"release": "node scripts/release.js", | ||
"release:dry": "pnpm run release -- --dry" | ||
}, | ||
"readme": "# tsconfck\n\n[![npm version](https://img.shields.io/npm/v/tsconfck)](https://www.npmjs.com/package/tsconfck)\n[![CI](https://github.com/dominikg/tsconfck/actions/workflows/test.yml/badge.svg)](https://github.com/dominikg/tsconfck/actions/workflows/test.yml)\n\nA utility to find and parse tsconfig files without depending on typescript\n\n# Why\n\nBecause no simple official api exists and tsconfig.json isn't actual json.\n\n# Features\n\n- [x] find closest tsconfig.json\n- [x] convert tsconfig.json to actual json and parse it\n- [x] resolve \"extends\"\n- [x] resolve \"references\" of solution-style tsconfig\n- [x] optional findNative and parseNative to use official typescript api\n- [x] zero dependencies (typescript optional)\n- [x] extensive testsuite\n\n# Install\n\n```shell\nnpm install --save-dev tsconfck # or pnpm, yarn\n```\n\n# Usage\n\n## without typescript installed\n\n```js\nimport { parse } from 'tsconfck';\nconst {\n\ttsconfigFile, // full path to found tsconfig\n\ttsconfig, // tsconfig object including merged values from extended configs\n\textended, // separate unmerged results of all tsconfig files that contributed to tsconfig\n\tsolution, // solution result if tsconfig is part of a solution\n\treferenced // referenced tsconfig results if tsconfig is a solution\n} = await parse('foo/bar.ts');\n```\n\n## with typescript\n\n```js\nimport { parseNative } from 'tsconfck';\nconst {\n\ttsconfigFile, // full path to found tsconfig\n\ttsconfig, // tsconfig object including merged values from extended configs, normalized\n\tresult, // output of ts.parseJsonConfigFileContent\n\tsolution, // solution result if tsconfig is part of a solution\n\treferenced // referenced tsconfig results if tsconfig is a solution\n} = await parseNative('foo/bar.ts');\n```\n\n## API\n\nsee [API-DOCS](docs/api.md)\n\n## Advanced\n\n### caching\n\nYou can use a map to cache results and avoid reparsing if you process multiple ts files that share few tsconfig files\n\n```js\nimport { parse } from 'tsconfck';\n// 1. create cache instance\nconst cache = new Map();\n// 2. pass cache instance in options\nconst fooResult = await parse('src/foo.ts', { cache });\n// 3. profit (if they share the same tsconfig.json, it is not parsed again)\nconst barResult = await parse('src/bar.ts', { cache });\n```\n\n> You are responsible for clearing the cache if tsconfig files change on disk during its lifetime.\n>\n> Always clear the whole cache if anything changes as objects in the cache can ref each other\n\n> Returned results are direct cache objects.\n>\n> If you want to modify them, deep-clone first.\n\n### reduce fs.stat overhead\n\nYou can specify a root directory and provide a set of known tsconfig locations to improve performance in large projects\n\n```js\nimport { parse, findAll } from 'tsconfck';\nconst root = '.';\nconst tsConfigPaths = new Set([\n\t...(await findAll(root, { skip: (dir) => dir === 'node_modules' || dir === '.git' }))\n]);\nconst cache = new Map();\nconst parseOptions = { cache, root, tsConfigPaths };\n// these calls use minimal fs\nconst fooResult = await parse('src/foo.ts', parseOptions);\nconst barResult = await parse('src/bar.ts', parseOptions);\n```\n\n> Using the root option can lead to errors if there is no tsconfig inside root.\n\n> You are responsible for updating tsConfigPaths if tsconfig files are added/removed on disk during its lifetime.\n\n### error handling\n\nfind and parse reject for all errors they encounter.\n\nFor parse, you can choose to resolve with an empty result instead if no tsconfig file was found\n\n```js\nimport { parse } from 'tsconfck';\nconst result = await parse('some/path/without/tsconfig/foo.ts', {\n\tresolveWithEmptyIfConfigNotFound: true\n});\n// result = { tsconfigFile: 'no_tsconfig_file_found',tsconfig: {} }\n```\n\n### TSConfig type (optional, requires typescript as devDependency)\n\n```ts\nimport type { TSConfig } from 'pkg-types';\n```\n\nCheck out https://github.com/unjs/pkg-types\n\n### cli\n\nA simple cli wrapper is included, you can use it like this\n\n#### find\n\n```shell\n# prints /path/to/tsconfig.json on stdout\ntsconfck find src/index.ts\n```\n\n#### find-all\n\n```shell\n# prints all tsconfig.json in dir on stdout\ntsconfck find-all src/\n```\n\n#### parse\n\n```shell\n# print content of ParseResult.tsconfig on stdout\ntsconfck parse src/index.ts\n\n# print to file\ntsconfck parse src/index.ts > output.json\n```\n\n#### parse-result\n\n```shell\n# print content of ParseResult on stdout\ntsconfck parse-result src/index.ts\n\n# print to file\ntsconfck parse-result src/index.ts > output.json\n```\n\n#### help\n\n```shell\n# print usage\ntsconfck -h # or --help, -?, help\n```\n\n# Links\n\n- [changelog](CHANGELOG.md)\n\n# Develop\n\nThis repo uses\n\n- [pnpm](https://pnpm.io)\n- [conventional-changelog/commitlint](https://github.com/conventional-changelog/commitlint#what-is-commitlint)\n\nIn addition to default commit-msg prefixes you can use 'wip: ' for commit messages in branches.\nPRs are going to be squash-merged\n\n```shell\n# install dependencies\npnpm install\n# run tests\npnpm test\n#run tests in watch mode (doesn't require dev in parallel)\npnpm test:watch\n```\n\n# License\n\n[MIT](./LICENSE)\n" | ||
"release:dry": "pnpm release --dry" | ||
} | ||
} |
209943