diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 43a01f3..0000000 --- a/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "@babel/typescript", - [ - "@babel/preset-env", - { - "targets": { - "node": "10" - } - } - ] - ], - "plugins": ["@babel/plugin-proposal-class-properties"] -} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 310b1d3..af0883a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -35,7 +35,7 @@ jobs: - run: npm run lint - run: npm run build - run: npm run test - - run: npx testpack-cli --keep={@babel/*,ts-jest,typescript} .babelrc tsconfig*.json src/e2e.spec.ts + - run: npx testpack-cli --keep=@types/*,ts-jest,typescript jest.config.js tsconfig.json src/e2e.spec.ts src/tsconfig.test.json - name: Upload test coverage report to Codecov uses: codecov/codecov-action@v1 diff --git a/.gitignore b/.gitignore index 7a3fb24..6477d00 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ package-lock.json +*.tsbuildinfo coverage/ demo/lib/ diff --git a/.publishrc b/.publishrc deleted file mode 100644 index b90ef3a..0000000 --- a/.publishrc +++ /dev/null @@ -1,15 +0,0 @@ -{ - "validations": { - "vulnerableDependencies": false, - "uncommittedChanges": true, - "untrackedFiles": true, - "sensitiveData": true, - "branch": "main", - "gitTag": true - }, - "confirm": true, - "publishCommand": "npm publish", - "publishTag": "latest", - "prePublishScript": "npm run publish-please-prereqs", - "postPublishScript": false -} diff --git a/.release-it.json b/.release-it.json new file mode 100644 index 0000000..80315cf --- /dev/null +++ b/.release-it.json @@ -0,0 +1,13 @@ +{ + "hooks": { + "before:init": ["npm run lint", "npm test"], + "after:bump": "npm run build" + }, + "git": { + "changelog": false, + "commit": false, + "requireBranch": "main", + "requireCommits": true, + "tagName": "${version}" + } +} diff --git a/demo/tsconfig.json b/demo/tsconfig.json index 7c7adc1..4ddae6f 100644 --- a/demo/tsconfig.json +++ b/demo/tsconfig.json @@ -6,9 +6,11 @@ "es2015.core", "es2015.iterable", "es2016.array.include" - ] + ], + "noEmit": true, + "outDir": "./lib" }, "extends": "../tsconfig.json", - "include": ["src"], + "include": ["src", "webpack.config.js"], "references": [{ "path": "../src" }] } diff --git a/package.json b/package.json index d959c20..65d76cf 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,13 @@ { "name": "regex-to-strings", - "version": "2.0.2", + "version": "2.0.3", "repository": { "type": "git", "url": "git+https://github.com/wimpyprogrammer/regex-to-strings.git" }, + "publishConfig": { + "registry": "https://registry.npmjs.org/" + }, "bugs": { "url": "https://github.com/wimpyprogrammer/regex-to-strings/issues" }, @@ -15,7 +18,9 @@ "main": "lib/index.js", "types": "./lib/index.d.ts", "files": [ - "lib/" + "lib/**/*.js", + "lib/**/*.js.map", + "lib/**/*.d.ts" ], "sideEffects": [ "demo/**/polyfills.ts", @@ -26,24 +31,15 @@ }, "scripts": { "build": "run-s build:*", - "build:src": "babel src -d lib --extensions '.js,.ts' --ignore '**/*.spec.js','**/*.spec.ts' --delete-dir-on-start", + "build:src": "tsc -b --clean && tsc -b", "build:demo": "wp --config demo/webpack.config.js", - "build:types": "tsc --noEmit false --emitDeclarationOnly", "format": "prettier --write '{src,demo/src}/**'", - "lint": "tsc -b && eslint . --report-unused-disable-directives", + "lint": "tsc -b ./tsconfig.lint.json && eslint . --report-unused-disable-directives", "precommit": "pretty-quick --staged", - "prepublish": "npx publish-please guard", - "publish-please": "npx publish-please", - "publish-please-prereqs": "npm run lint && npm run test && npm run build", + "release": "npx release-it", "test": "jest --coverage" }, "devDependencies": { - "@babel/cli": "^7.13.10", - "@babel/core": "^7.13.10", - "@babel/plugin-proposal-class-properties": "^7.13.0", - "@babel/preset-env": "^7.13.10", - "@babel/preset-typescript": "^7.13.0", - "@types/escape-string-regexp": "^2.0.1", "@types/history": "^4.7.3", "@types/jest": "^26.0.10", "@types/jest-when": "^2.4.1", diff --git a/src/e2e.spec.ts b/src/e2e.spec.ts index 9d81cb1..f7aed4f 100644 --- a/src/e2e.spec.ts +++ b/src/e2e.spec.ts @@ -1,6 +1,13 @@ import { count, expand, expandAll, expandN } from '.'; describe('count end-to-end', () => { + it('includes typings', () => { + expect(() => { + // @ts-expect-error Accepts string | RegExp + count(123); + }).toThrow(); + }); + it('returns a count of potential strings that match pattern', () => { const numStrings = count(/[a-z]{5}/i); @@ -11,6 +18,13 @@ describe('count end-to-end', () => { describe('expand end-to-end', () => { const phoneNumberPattern = /((\(555\) ?)|(555-))?\d{3}-\d{4}/; + it('includes typings', () => { + expect(() => { + // @ts-expect-error Accepts string | RegExp + expand(123); + }).toThrow(); + }); + it('returns a count of potential strings that match pattern', () => { const phoneNumberExpander = expand(phoneNumberPattern); @@ -29,6 +43,13 @@ describe('expand end-to-end', () => { }); describe('expandAll end-to-end', () => { + it('includes typings', () => { + expect(() => { + // @ts-expect-error Accepts string | RegExp + expandAll(123); + }).toThrow(); + }); + it('returns all strings that match pattern', () => { const strings = expandAll(/\d/); @@ -40,6 +61,13 @@ describe('expandAll end-to-end', () => { }); describe('expandN end-to-end', () => { + it('includes typings', () => { + expect(() => { + // @ts-expect-error Accepts string | RegExp + expandN(123, 10); + }).toThrow(); + }); + it('returns no more than N strings that match pattern', () => { const pattern = /\d{3,5}/; const strings = expandN(pattern, 5); diff --git a/src/tsconfig.json b/src/tsconfig.json index 2c6c771..8400bb7 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -1,6 +1,8 @@ { "compilerOptions": { - "lib": ["es5", "es2015.core", "es2015.iterable", "es2016.array.include"] + "lib": ["es5", "es2015.core", "es2015.iterable", "es2016.array.include"], + "outDir": "../lib", + "rootDir": "./" }, "extends": "../tsconfig.json", "exclude": ["../**/*.spec.ts", "../**/*.config.js"], diff --git a/src/tsconfig.test.json b/src/tsconfig.test.json index c4ac774..6deedaf 100644 --- a/src/tsconfig.test.json +++ b/src/tsconfig.test.json @@ -7,9 +7,11 @@ "es2016.array.include", "es2017.string" ], + "noEmit": true, + "outDir": "../lib", "types": ["jest", "regexp-tree", "./types/regexp-tree"] }, "extends": "../tsconfig.json", - "include": ["./**/*.spec.ts", "../**/*.config.js"], + "include": ["./**/*.spec.ts", "../jest.config.js"], "references": [{ "path": "./" }] } diff --git a/tsconfig.json b/tsconfig.json index b9436d5..f1d3b95 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,15 +4,15 @@ "baseUrl": ".", "checkJs": true, "composite": true, + "declaration": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, - "module": "es2015", + "module": "CommonJS", "downlevelIteration": true, "moduleResolution": "node", "noImplicitReturns": true, "noUnusedLocals": true, "noUnusedParameters": true, - "outDir": "../lib", "pretty": true, "rootDir": ".", "skipLibCheck": true, diff --git a/tsconfig.lint.json b/tsconfig.lint.json new file mode 100644 index 0000000..67c49bd --- /dev/null +++ b/tsconfig.lint.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "noEmit": true + }, + "extends": "./tsconfig.json", + "references": [{ "path": "./" }] +}