From d602dd8f69e3dd69e1c2b1bc94b61f8c85fc6435 Mon Sep 17 00:00:00 2001 From: Steve Calvert Date: Mon, 10 May 2021 14:52:07 -0700 Subject: [PATCH] chore: Converts package to publishing only .js/.d.ts files --- .gitignore | 3 +- package.json | 16 +++-- {lib => src}/cache-group.ts | 0 {lib => src}/cache.ts | 0 index.ts => src/index.ts | 9 +-- {lib => src}/resolve-package-path.ts | 0 {lib => src}/should-preserve-symlinks.ts | 0 tests/index-test.ts | 4 +- tests/resolve-package-path-test.ts | 6 +- tests/should-preserve-symlinks-test.ts | 2 +- tsconfig.json | 8 ++- yarn.lock | 85 +++++++++++++++++++++++- 12 files changed, 112 insertions(+), 21 deletions(-) rename {lib => src}/cache-group.ts (100%) rename {lib => src}/cache.ts (100%) rename index.ts => src/index.ts (96%) rename {lib => src}/resolve-package-path.ts (100%) rename {lib => src}/should-preserve-symlinks.ts (100%) diff --git a/.gitignore b/.gitignore index 7879096..8f028e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ /node_modules/ -**/*.js -**/*.d.ts +/lib/ diff --git a/package.json b/package.json index f1a74ef..419ddb4 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "description": "a special purpose fast memoizing way to resolve a node modules package.json", "version": "3.1.0", "repository": "git@github.com:stefanpenner/resolve-package-path.git", - "main": "index.js", - "types": "index.d.ts", + "main": "lib/index.js", + "types": "lib/index.d.ts", "license": "MIT", "dependencies": { "path-root": "^0.1.1", @@ -29,19 +29,23 @@ "mocha": "^8.1.3", "npm-run-all": "^4.1.5", "prettier": "^2.1.2", + "ts-mocha": "^8.0.0", "typescript": "^4.0.3" }, "scripts": { "build": "tsc -b .", "watch": "tsc --watch .", "clean": "tsc -b --clean .", - "test": "npm-run-all build lint test:js", - "test:js": "mocha tests/*-test.js", - "test:js:debug": "mocha debug tests/*-test.js", + "test": "npm-run-all build lint test:ts", + "test:ts": "ts-mocha tests/*-test.ts", + "test:ts:debug": "ts-mocha debug tests/*-test.ts", "lint": "eslint ." }, + "files": [ + "lib/" + ], "engines": { - "node": "10.* || >= 12" + "node": ">= 12" }, "volta": { "node": "12.19.0", diff --git a/lib/cache-group.ts b/src/cache-group.ts similarity index 100% rename from lib/cache-group.ts rename to src/cache-group.ts diff --git a/lib/cache.ts b/src/cache.ts similarity index 100% rename from lib/cache.ts rename to src/cache.ts diff --git a/index.ts b/src/index.ts similarity index 96% rename from index.ts rename to src/index.ts index 384584a..fa1fb32 100644 --- a/index.ts +++ b/src/index.ts @@ -1,7 +1,8 @@ 'use strict'; -import path = require('path'); -const customResolvePackagePath = require('./lib/resolve-package-path'); +import path from 'path'; +import customResolvePackagePath from './resolve-package-path'; + const ALLOWED_ERROR_CODES: { [key: string]: boolean } = { // resolve package error codes MODULE_NOT_FOUND: true, @@ -12,8 +13,8 @@ const ALLOWED_ERROR_CODES: { [key: string]: boolean } = { MISSING_DEPENDENCY: true, }; -import CacheGroup = require('./lib/cache-group'); -import Cache = require('./lib/cache'); +import CacheGroup = require('./cache-group'); +import Cache = require('./cache'); const getRealFilePath = customResolvePackagePath._getRealFilePath; const getRealDirectoryPath = customResolvePackagePath._getRealDirectoryPath; const __findUpPackagePath = customResolvePackagePath._findUpPackagePath; diff --git a/lib/resolve-package-path.ts b/src/resolve-package-path.ts similarity index 100% rename from lib/resolve-package-path.ts rename to src/resolve-package-path.ts diff --git a/lib/should-preserve-symlinks.ts b/src/should-preserve-symlinks.ts similarity index 100% rename from lib/should-preserve-symlinks.ts rename to src/should-preserve-symlinks.ts diff --git a/tests/index-test.ts b/tests/index-test.ts index 0a03bad..c9ea9a4 100644 --- a/tests/index-test.ts +++ b/tests/index-test.ts @@ -1,8 +1,8 @@ 'use strict'; -import resolvePackagePath = require('../index'); +import resolvePackagePath = require('../src/index'); import Project = require('fixturify-project'); -import Cache = require('../lib/cache'); +import Cache = require('../src/cache'); import fixturify = require('fixturify'); import fs = require('fs-extra'); import chai = require('chai'); diff --git a/tests/resolve-package-path-test.ts b/tests/resolve-package-path-test.ts index 1f62818..599ac4a 100644 --- a/tests/resolve-package-path-test.ts +++ b/tests/resolve-package-path-test.ts @@ -1,9 +1,9 @@ 'use strict'; import path = require('path'); import chai = require('chai'); -import resolvePackagePath = require('../lib/resolve-package-path'); -import Cache = require('../lib/cache'); -import CacheGroup = require('../lib/cache-group'); +import resolvePackagePath = require('../src/resolve-package-path'); +import Cache = require('../src/cache'); +import CacheGroup = require('../src/cache-group'); import fs = require('fs'); import Project = require('fixturify-project'); diff --git a/tests/should-preserve-symlinks-test.ts b/tests/should-preserve-symlinks-test.ts index 167131c..9fee744 100644 --- a/tests/should-preserve-symlinks-test.ts +++ b/tests/should-preserve-symlinks-test.ts @@ -1,4 +1,4 @@ -import shouldPreserveSymlinks = require('../lib/should-preserve-symlinks'); +import shouldPreserveSymlinks = require('../src/should-preserve-symlinks'); import chai = require('chai'); const expect = chai.expect; diff --git a/tsconfig.json b/tsconfig.json index 1874265..a22314c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,10 +5,14 @@ "moduleResolution": "node", "module": "commonjs", "esModuleInterop": true, - "target": "es5", + "target": "es2018", "baseUrl": ".", + "outDir": "lib", + "rootDir": "src", "paths": { "*": ["types/*"] } - } + }, + "include": ["src"], + "exclude": ["tests"] } diff --git a/yarn.lock b/yarn.lock index 677398f..21563f8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -98,6 +98,11 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0" integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw== +"@types/json5@^0.0.29": + version "0.0.29" + resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" + integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4= + "@types/minimatch@*", "@types/minimatch@^3.0.3": version "3.0.3" resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" @@ -280,6 +285,11 @@ array.prototype.map@^1.0.1: es-array-method-boxes-properly "^1.0.0" is-string "^1.0.4" +arrify@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + integrity sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0= + assertion-error@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" @@ -325,6 +335,11 @@ browser-stdout@1.3.1: resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== +buffer-from@^1.0.0, buffer-from@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" + integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== + callsites@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" @@ -499,6 +514,11 @@ diff@4.0.2: resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== +diff@^3.1.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" + integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== + dir-glob@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" @@ -1240,6 +1260,13 @@ json-stable-stringify-without-jsonify@^1.0.1: resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= +json5@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe" + integrity sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow== + dependencies: + minimist "^1.2.0" + jsonfile@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" @@ -1306,6 +1333,11 @@ log-symbols@4.0.0: dependencies: chalk "^4.0.0" +make-error@^1.1.1: + version "1.3.6" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== + matcher-collection@^2.0.0, matcher-collection@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/matcher-collection/-/matcher-collection-2.0.1.tgz#90be1a4cf58d6f2949864f65bb3b0f3e41303b29" @@ -1349,7 +1381,7 @@ minimatch@3.0.4, minimatch@^3.0.2, minimatch@^3.0.4: dependencies: brace-expansion "^1.1.7" -minimist@^1.2.5: +minimist@^1.2.0, minimist@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== @@ -1835,6 +1867,19 @@ slice-ansi@^2.1.0: astral-regex "^1.0.0" is-fullwidth-code-point "^2.0.0" +source-map-support@^0.5.6: + version "0.5.19" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" + integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map@^0.6.0: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + spdx-correct@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" @@ -1998,6 +2043,39 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" +ts-mocha@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/ts-mocha/-/ts-mocha-8.0.0.tgz#962d0fa12eeb6468aa1a6b594bb3bbc818da3ef0" + integrity sha512-Kou1yxTlubLnD5C3unlCVO7nh0HERTezjoVhVw/M5S1SqoUec0WgllQvPk3vzPMc6by8m6xD1uR1yRf8lnVUbA== + dependencies: + ts-node "7.0.1" + optionalDependencies: + tsconfig-paths "^3.5.0" + +ts-node@7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-7.0.1.tgz#9562dc2d1e6d248d24bc55f773e3f614337d9baf" + integrity sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw== + dependencies: + arrify "^1.0.0" + buffer-from "^1.1.0" + diff "^3.1.0" + make-error "^1.1.1" + minimist "^1.2.0" + mkdirp "^0.5.1" + source-map-support "^0.5.6" + yn "^2.0.0" + +tsconfig-paths@^3.5.0: + version "3.9.0" + resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz#098547a6c4448807e8fcb8eae081064ee9a3c90b" + integrity sha512-dRcuzokWhajtZWkQsDVKbWyY+jgcLC5sqJhg2PSgf4ZkH2aHPvaOY8YWGhmjb68b5qqTfasSsDO9k7RUiEmZAw== + dependencies: + "@types/json5" "^0.0.29" + json5 "^1.0.1" + minimist "^1.2.0" + strip-bom "^3.0.0" + tslib@^1.8.1: version "1.14.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" @@ -2198,3 +2276,8 @@ yargs@^14.2.3: which-module "^2.0.0" y18n "^4.0.0" yargs-parser "^15.0.1" + +yn@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/yn/-/yn-2.0.0.tgz#e5adabc8acf408f6385fc76495684c88e6af689a" + integrity sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=