From f8c4d2c4c327afb199dbdc053fc591938fde0ee1 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 27 Nov 2023 18:56:14 -0800 Subject: [PATCH] extract `lib/` to `tape-lib` subpackage --- .github/workflows/node-pretest.yml | 18 +++++++- .gitignore | 1 + bin/tape | 2 +- index.js | 2 +- lib/.npmrc | 3 ++ lib/package.json | 70 ++++++++++++++++++++++++++++++ package.json | 25 ++++------- test/common.js | 3 +- 8 files changed, 104 insertions(+), 20 deletions(-) create mode 100644 lib/.npmrc create mode 100644 lib/package.json diff --git a/.github/workflows/node-pretest.yml b/.github/workflows/node-pretest.yml index 72bdfa3a..0bf404c6 100644 --- a/.github/workflows/node-pretest.yml +++ b/.github/workflows/node-pretest.yml @@ -6,4 +6,20 @@ jobs: tests: uses: ljharb/actions/.github/workflows/pretest.yml@main with: - skip-engines: true # bin/tape requires node 8+, but the rest of tape supports 0.4+ + skip-engines: true # bin/tape requires node 8+, but tape-lib supports 0.4+. TODO: fix and add engines.node in v6 + + engines-lib: + defaults: + run: + working-directory: lib + runs-on: ubuntu-latest + steps: + - uses: ljharb/actions/node/engines@main + + pack-lib: + defaults: + run: + working-directory: lib + runs-on: ubuntu-latest + steps: + - uses: ljharb/actions/node/pack@main diff --git a/.gitignore b/.gitignore index a63afe6d..6a2f2f8d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # gitignore /node_modules +**/node_modules # Only apps should have lockfiles yarn.lock diff --git a/bin/tape b/bin/tape index 3b41be76..47e16f67 100755 --- a/bin/tape +++ b/bin/tape @@ -79,7 +79,7 @@ var files = opts._.reduce(function (result, arg) { var hasImport = require('has-dynamic-import'); -var tape = require('../'); +var tape = require('tape-lib'); function importFiles(hasSupport) { if (!hasSupport) { diff --git a/index.js b/index.js index 288ce9a8..ea90786e 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,3 @@ 'use strict'; -module.exports = require('./lib'); +module.exports = require('tape-lib'); diff --git a/lib/.npmrc b/lib/.npmrc new file mode 100644 index 00000000..eacea13e --- /dev/null +++ b/lib/.npmrc @@ -0,0 +1,3 @@ +package-lock=false +allow-same-version=true +message=v%s diff --git a/lib/package.json b/lib/package.json new file mode 100644 index 00000000..5e90f4a4 --- /dev/null +++ b/lib/package.json @@ -0,0 +1,70 @@ +{ + "name": "tape-lib", + "version": "0.0.0", + "description": "TAP-producing test harness library for node and browsers", + "main": "index.js", + "browser": { + "fs": false + }, + "exports": { + ".": "./index.js", + "./default_stream": "./default_stream.js", + "./results": "./results.js", + "./test": "./test.js", + "./package.json": "./package.json" + }, + "scripts": { + "prepack": "npmignore --auto --commentLines=autogenerated --gitignore=../.gitignore", + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"", + "prepublishOnly": "safe-publish-latest", + "prepublish": "not-in-publish || npm run prepublishOnly", + "test": "echo tests are run in the parent repo && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/ljharb/tape.git", + "directory": "lib" + }, + "author": "Jordan Harband ", + "license": "MIT", + "bugs": { + "url": "https://github.com/ljharb/tape/issues" + }, + "homepage": "https://github.com/ljharb/tape/#readme", + "keywords": [ + "tap", + "test", + "harness", + "assert", + "browser" + ], + "dependencies": { + "@ljharb/resumer": "^0.0.1", + "@ljharb/through": "^2.3.11", + "array.prototype.every": "^1.1.5", + "call-bind": "^1.0.5", + "deep-equal": "^2.2.3", + "defined": "^1.0.1", + "for-each": "^0.3.3", + "hasown": "^2.0.0", + "inherits": "^2.0.4", + "is-regex": "^1.1.4", + "mock-property": "^1.0.3", + "object-inspect": "^1.13.1", + "object-is": "^1.1.5", + "object-keys": "^1.1.1", + "string.prototype.trim": "^1.2.8" + }, + "engines": { + "node": ">= 0.4" + }, + "publishConfig": { + "ignore": [] + }, + "devDependencies": { + "in-publish": "^2.0.1", + "npmignore": "^0.3.0", + "safe-publish-latest": "^2.0.0" + } +} diff --git a/package.json b/package.json index 0aca5f05..ff8da6d7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tape", "version": "5.7.2", - "description": "tap-producing test harness for node and browsers", + "description": "TAP-producing test harness for node and browsers", "main": "index.js", "browser": { "fs": false @@ -20,31 +20,20 @@ "test": "test" }, "dependencies": { - "@ljharb/resumer": "^0.0.1", - "@ljharb/through": "^2.3.11", - "array.prototype.every": "^1.1.5", - "call-bind": "^1.0.5", - "deep-equal": "^2.2.3", - "defined": "^1.0.1", "dotignore": "^0.1.2", "for-each": "^0.3.3", "get-package-type": "^0.1.0", "glob": "^7.2.3", "has-dynamic-import": "^2.0.1", - "hasown": "^2.0.0", - "inherits": "^2.0.4", - "is-regex": "^1.1.4", "minimist": "^1.2.8", - "mock-property": "^1.0.3", - "object-inspect": "^1.13.1", - "object-is": "^1.1.5", "object-keys": "^1.1.1", "object.assign": "^4.1.4", "resolve": "^2.0.0-next.5", - "string.prototype.trim": "^1.2.8" + "tape-lib": "file:./lib" }, "devDependencies": { "@ljharb/eslint-config": "^21.1.0", + "@ljharb/through": "^2.3.11", "array.prototype.flatmap": "^1.3.2", "aud": "^2.0.3", "auto-changelog": "^2.4.0", @@ -54,11 +43,12 @@ "es-value-fixtures": "^1.4.2", "eslint": "=8.8.0", "falafel": "^2.2.5", - "intl-fallback-symbol": "^1.0.0", + "in-publish": "^2.0.1", "jackspeak": "=2.1.1", "js-yaml": "^3.14.0", "npm-run-posix-or-windows": "^2.0.2", "npmignore": "^0.3.0", + "object-inspect": "^1.13.1", "safe-publish-latest": "^2.0.0", "tap": "^8.0.1", "tap-parser": "^5.4.0" @@ -119,7 +109,10 @@ }, "publishConfig": { "ignore": [ - ".github/workflows" + ".github/workflows", + "lib/*", + "!lib/{default_stream,results,test}.js", + "**/node_modules" ] } } diff --git a/test/common.js b/test/common.js index f2098225..071c6f61 100644 --- a/test/common.js +++ b/test/common.js @@ -42,7 +42,8 @@ var stripChangingData = function (line) { var withoutTestDir = line.replace(__dirname, '$TEST'); var withoutPackageDir = withoutTestDir.replace(path.dirname(__dirname), '$TAPE'); var withoutPathSep = withoutPackageDir.replace(new RegExp('\\' + path.sep, 'g'), '/'); - var withoutLineNumbers = withoutPathSep.replace(/:\d+:\d+/g, ':$LINE:$COL'); + var withoutLibDir = withoutPathSep.replace('$TAPE/node_modules/tape-lib/', '$TAPE/lib/'); + var withoutLineNumbers = withoutLibDir.replace(/:\d+:\d+/g, ':$LINE:$COL'); var withoutNestedLineNumbers = withoutLineNumbers.replace(/, :\$LINE:\$COL\)$/, ')'); return withoutNestedLineNumbers; };