From eadfae2c88db31a87b39132c4134a5a5d3159912 Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Tue, 31 Aug 2021 16:01:06 +0200 Subject: [PATCH 01/21] chore: add package manager ci workflow --- .github/workflows/package-manager-ci.yml | 52 ++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/package-manager-ci.yml diff --git a/.github/workflows/package-manager-ci.yml b/.github/workflows/package-manager-ci.yml new file mode 100644 index 000000000..b057c8a7b --- /dev/null +++ b/.github/workflows/package-manager-ci.yml @@ -0,0 +1,52 @@ +name: package-manager-ci +on: + push: + paths-ignore: + - 'docs/**' + - '*.md' + pull_request: + paths-ignore: + - 'docs/**' + - '*.md' +jobs: + pnpm: + name: pnpm package manager on ${{ matrix.node-version }} ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macOS-latest, windows-latest] + node-version: [12, 14, 16] + steps: + - uses: actions/checkout@v2.3.4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2.4.0 + with: + node-version: ${{ matrix.node-version }} + - name: Use pnpm + uses: pnpm/action-setup@v2.0.1 + with: + version: ^6.0.0 + - name: Tests + run: pnpm run test-ci + + yarn: + name: yarn package manager on ${{ matrix.node-version }} ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macOS-latest] + node-version: [12, 14, 16] + steps: + - uses: actions/checkout@v2.3.4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2.4.0 + with: + node-version: ${{ matrix.node-version }} + - name: Use yarn + run: | + curl -o- -L https://yarnpkg.com/install.sh | bash + yarn install --ignore-engines + - name: Tests + run: yarn run test-ci From 5b7a873aa298f3e30fcab5e16475822087dcc8cb Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Tue, 31 Aug 2021 17:06:07 +0200 Subject: [PATCH 02/21] chore: add yarn-pnp into ci --- .github/workflows/package-manager-ci.yml | 29 ++++++++++++++++++++++-- .gitignore | 6 +++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package-manager-ci.yml b/.github/workflows/package-manager-ci.yml index b057c8a7b..1ee1b057e 100644 --- a/.github/workflows/package-manager-ci.yml +++ b/.github/workflows/package-manager-ci.yml @@ -46,7 +46,32 @@ jobs: node-version: ${{ matrix.node-version }} - name: Use yarn run: | - curl -o- -L https://yarnpkg.com/install.sh | bash - yarn install --ignore-engines + npm install -g yarn + yarn set version berry + yarn install + - name: Tests + run: yarn run test-ci + + yarn-pnp: + name: yarn-pnp package manager on ${{ matrix.node-version }} ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macOS-latest] + node-version: [12, 14, 16] + steps: + - uses: actions/checkout@v2.3.4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2.4.0 + with: + node-version: ${{ matrix.node-version }} + - name: Use yarn + run: | + npm install -g yarn + yarn set version berry + echo "nodeLinker: pnp" >> .yarnrc.yml + echo "pnpMode: loose" >> .yarnrc.yml + yarn install - name: Tests run: yarn run test-ci diff --git a/.gitignore b/.gitignore index b552ce577..bab272c8f 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,12 @@ build/Release # Dependency directory node_modules +# yarn cache +.yarn +.yarnrc.yml +.pnp +.pnp.* + # Optional npm cache directory .npm From ca4d45c15219fedd4796b47ad468e03ace62b20f Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Wed, 1 Sep 2021 10:43:25 +0200 Subject: [PATCH 03/21] fix pnpm setup --- .github/workflows/package-manager-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/package-manager-ci.yml b/.github/workflows/package-manager-ci.yml index 1ee1b057e..bfeef70df 100644 --- a/.github/workflows/package-manager-ci.yml +++ b/.github/workflows/package-manager-ci.yml @@ -27,6 +27,8 @@ jobs: uses: pnpm/action-setup@v2.0.1 with: version: ^6.0.0 + - name: Install dependancies + run: pnpm install - name: Tests run: pnpm run test-ci From f9086607996cda0b04980a5976ec1c4d0d66b7fa Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Wed, 1 Sep 2021 11:49:41 +0200 Subject: [PATCH 04/21] fix yarn ci installation fails --- .github/workflows/package-manager-ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/package-manager-ci.yml b/.github/workflows/package-manager-ci.yml index bfeef70df..aec4ca70d 100644 --- a/.github/workflows/package-manager-ci.yml +++ b/.github/workflows/package-manager-ci.yml @@ -51,6 +51,9 @@ jobs: npm install -g yarn yarn set version berry yarn install + env: + # needed due the yarn.lock file in pino's .gitignore + YARN_ENABLE_IMMUTABLE_INSTALLS: false - name: Tests run: yarn run test-ci @@ -75,5 +78,8 @@ jobs: echo "nodeLinker: pnp" >> .yarnrc.yml echo "pnpMode: loose" >> .yarnrc.yml yarn install + env: + # needed due the yarn.lock file in pino's .gitignore + YARN_ENABLE_IMMUTABLE_INSTALLS: false - name: Tests run: yarn run test-ci From d68e8c962cb3b46b23ebc8c2f96384cc3d65787c Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Wed, 1 Sep 2021 12:48:02 +0200 Subject: [PATCH 05/21] fix yarn usage v2 --- .github/workflows/package-manager-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/package-manager-ci.yml b/.github/workflows/package-manager-ci.yml index aec4ca70d..dea870eea 100644 --- a/.github/workflows/package-manager-ci.yml +++ b/.github/workflows/package-manager-ci.yml @@ -49,7 +49,8 @@ jobs: - name: Use yarn run: | npm install -g yarn - yarn set version berry + yarn set version berry && yarn set version 2.4.2 + echo "nodeLinker: node-modules" >> .yarnrc.yml yarn install env: # needed due the yarn.lock file in pino's .gitignore From 32693fe4632ce025313c568f0b0d41ce0e9b9a4a Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Wed, 1 Sep 2021 13:11:33 +0200 Subject: [PATCH 06/21] workaround yarn isssue yarnpkg/berry/issues/2935 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 32161e79b..1b67d58da 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,7 @@ "through2": "^4.0.0", "ts-node": "^10.2.1", "tsd": "^0.17.0", - "typescript": "^4.4.2", + "typescript": "4.3.2", "winston": "^3.3.3" }, "dependencies": { From 62eed3034a553038bd74f6ad63ee78d1505da17b Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Wed, 1 Sep 2021 14:56:32 +0200 Subject: [PATCH 07/21] add pino-elastiseach test loading --- package.json | 1 + test/transport.test.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/package.json b/package.json index 1b67d58da..86826cbee 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,7 @@ "import-fresh": "^3.2.1", "log": "^6.0.0", "loglevel": "^1.6.7", + "pino-elasticsearch": "^6.1.0", "pino-pretty": "^5.1.0", "pre-commit": "^1.2.2", "proxyquire": "^2.1.3", diff --git a/test/transport.test.js b/test/transport.test.js index 4451c55b4..c40b35327 100644 --- a/test/transport.test.js +++ b/test/transport.test.js @@ -83,6 +83,29 @@ test('pino.transport with package', { skip: isWin }, async ({ same, teardown }) }) }) +test('pino.transport loads the pino-elasticsearch package', ({ plan, ok, fail, equal, pass }) => { + plan(3) + const transport = pino.transport({ + target: 'pino-elasticsearch', + options: { + node: null // triggers the error if the module is loaded correctly + } + }) + + const instance = pino(transport) + instance.info('hello') + + transport.on('ready', function () { + fail('ready event should not be emitted') + }) + transport.on('error', function (err) { + ok(err) + equal(err.message, 'Missing node(s) option', 'pino-elastisearch trigger an error') + }) + + pass('pino instance created') +}) + test('pino.transport with file URL', async ({ same, teardown }) => { const destination = join( os.tmpdir(), From 25771d916b9ddccd45e9f4f26249a6b0fea26af6 Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Wed, 1 Sep 2021 16:34:55 +0200 Subject: [PATCH 08/21] skip yarn pnp tests --- test/transport.test.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/transport.test.js b/test/transport.test.js index c40b35327..166de5bac 100644 --- a/test/transport.test.js +++ b/test/transport.test.js @@ -15,6 +15,8 @@ const writer = require('flush-write-stream') const { pid } = process const hostname = os.hostname() +const isYarnPnp = process.versions.pnp !== undefined + test('pino.transport with file', async ({ same, teardown }) => { const destination = join( os.tmpdir(), @@ -47,7 +49,7 @@ test('pino.transport with file (no options + error handling)', async ({ equal }) }) // TODO make this test pass on Windows -test('pino.transport with package', { skip: isWin }, async ({ same, teardown }) => { +test('pino.transport with package', { skip: isWin || isYarnPnp }, async ({ same, teardown }) => { const destination = join( os.tmpdir(), '_' + Math.random().toString(36).substr(2, 9) @@ -100,7 +102,7 @@ test('pino.transport loads the pino-elasticsearch package', ({ plan, ok, fail, e }) transport.on('error', function (err) { ok(err) - equal(err.message, 'Missing node(s) option', 'pino-elastisearch trigger an error') + equal(err.message, 'Missing node(s) option', 'pino-elastisearch trigger a valid error', { skip: isYarnPnp }) }) pass('pino instance created') @@ -314,7 +316,7 @@ test('pino.transport with target and targets', async ({ fail, equal }) => { }) // TODO make this test pass on Windows -test('pino.transport with package as a target', { skip: isWin }, async ({ same, teardown }) => { +test('pino.transport with package as a target', { skip: isWin || isYarnPnp }, async ({ same, teardown }) => { const destination = join( os.tmpdir(), '_' + Math.random().toString(36).substr(2, 9) From 043e2d1dee83a63fe3c7d9952a37d10f6390ba03 Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Thu, 2 Sep 2021 10:14:19 +0200 Subject: [PATCH 09/21] test: remove skip flag --- .github/workflows/package-manager-ci.yml | 1 + package.json | 2 +- test/helper.js | 3 +- test/transport.test.js | 54 ++++++++++++++---------- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/.github/workflows/package-manager-ci.yml b/.github/workflows/package-manager-ci.yml index dea870eea..e52ec1dee 100644 --- a/.github/workflows/package-manager-ci.yml +++ b/.github/workflows/package-manager-ci.yml @@ -79,6 +79,7 @@ jobs: echo "nodeLinker: pnp" >> .yarnrc.yml echo "pnpMode: loose" >> .yarnrc.yml yarn install + yarn add --dev transport@link:./test/fixtures/transport env: # needed due the yarn.lock file in pino's .gitignore YARN_ENABLE_IMMUTABLE_INSTALLS: false diff --git a/package.json b/package.json index 86826cbee..a386a590c 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "through2": "^4.0.0", "ts-node": "^10.2.1", "tsd": "^0.17.0", - "typescript": "4.3.2", + "typescript": "~4.3.2", "winston": "^3.3.3" }, "dependencies": { diff --git a/test/helper.js b/test/helper.js index ed8073453..f2f468008 100644 --- a/test/helper.js +++ b/test/helper.js @@ -8,6 +8,7 @@ const pid = process.pid const hostname = os.hostname() const isWin = process.platform === 'win32' +const isYarnPnp = process.versions.pnp !== undefined function getPathToNull () { return isWin ? '\\\\.\\NUL' : '/dev/null' @@ -72,4 +73,4 @@ function watchFileCreated (filename) { }) } -module.exports = { getPathToNull, sink, check, once, sleep, watchFileCreated, isWin } +module.exports = { getPathToNull, sink, check, once, sleep, watchFileCreated, isWin, isYarnPnp } diff --git a/test/transport.test.js b/test/transport.test.js index 166de5bac..386e2aa4f 100644 --- a/test/transport.test.js +++ b/test/transport.test.js @@ -5,7 +5,7 @@ const { join } = require('path') const { once } = require('events') const { readFile, symlink, unlink } = require('fs').promises const { test } = require('tap') -const { isWin, watchFileCreated } = require('./helper') +const { isWin, isYarnPnp, watchFileCreated } = require('./helper') const pino = require('../') const url = require('url') const strip = require('strip-ansi') @@ -15,7 +15,31 @@ const writer = require('flush-write-stream') const { pid } = process const hostname = os.hostname() -const isYarnPnp = process.versions.pnp !== undefined +async function installTransportModule () { + try { + await uninstallTransportModule() + } catch {} + try { + await symlink( + join(__dirname, 'fixtures', 'transport'), + join(__dirname, '..', 'node_modules', 'transport') + ) + } catch (err) { + if (!isYarnPnp) { + throw err + } + } +} + +async function uninstallTransportModule () { + try { + await unlink(join(__dirname, '..', 'node_modules', 'transport')) + } catch (err) { + if (!isYarnPnp) { + throw err + } + } +} test('pino.transport with file', async ({ same, teardown }) => { const destination = join( @@ -49,27 +73,20 @@ test('pino.transport with file (no options + error handling)', async ({ equal }) }) // TODO make this test pass on Windows -test('pino.transport with package', { skip: isWin || isYarnPnp }, async ({ same, teardown }) => { +test('pino.transport with package', { skip: isWin }, async ({ same, teardown }) => { const destination = join( os.tmpdir(), '_' + Math.random().toString(36).substr(2, 9) ) - try { - await unlink(join(__dirname, '..', 'node_modules', 'transport')) - } catch {} - - await symlink( - join(__dirname, 'fixtures', 'transport'), - join(__dirname, '..', 'node_modules', 'transport') - ) + await installTransportModule() const transport = pino.transport({ target: 'transport', options: { destination } }) teardown(async () => { - await unlink(join(__dirname, '..', 'node_modules', 'transport')) + await uninstallTransportModule() transport.end() }) const instance = pino(transport) @@ -316,20 +333,13 @@ test('pino.transport with target and targets', async ({ fail, equal }) => { }) // TODO make this test pass on Windows -test('pino.transport with package as a target', { skip: isWin || isYarnPnp }, async ({ same, teardown }) => { +test('pino.transport with package as a target', { skip: isWin }, async ({ same, teardown }) => { const destination = join( os.tmpdir(), '_' + Math.random().toString(36).substr(2, 9) ) - try { - await unlink(join(__dirname, '..', 'node_modules', 'transport')) - } catch {} - - await symlink( - join(__dirname, 'fixtures', 'transport'), - join(__dirname, '..', 'node_modules', 'transport') - ) + await installTransportModule() const transport = pino.transport({ targets: [{ @@ -338,7 +348,7 @@ test('pino.transport with package as a target', { skip: isWin || isYarnPnp }, as }] }) teardown(async () => { - await unlink(join(__dirname, '..', 'node_modules', 'transport')) + await uninstallTransportModule() transport.end() }) const instance = pino(transport) From abeaca5d460457558dc22b42094ec6d95b95660b Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Thu, 2 Sep 2021 13:46:18 +0200 Subject: [PATCH 10/21] removed sticked dependancy --- .github/workflows/package-manager-ci.yml | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/package-manager-ci.yml b/.github/workflows/package-manager-ci.yml index e52ec1dee..5e3a92e45 100644 --- a/.github/workflows/package-manager-ci.yml +++ b/.github/workflows/package-manager-ci.yml @@ -51,6 +51,8 @@ jobs: npm install -g yarn yarn set version berry && yarn set version 2.4.2 echo "nodeLinker: node-modules" >> .yarnrc.yml + # see https://github.com/yarnpkg/berry/issues/2935#issuecomment-911299992 + yarn add --dev typescript@~4.3.2 yarn install env: # needed due the yarn.lock file in pino's .gitignore diff --git a/package.json b/package.json index a386a590c..3b26e8156 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "through2": "^4.0.0", "ts-node": "^10.2.1", "tsd": "^0.17.0", - "typescript": "~4.3.2", + "typescript": "^4.4.2", "winston": "^3.3.3" }, "dependencies": { From f54d8074cc01311e1bbe34a30e6ed05dba0d6574 Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Sun, 5 Sep 2021 19:16:56 +0200 Subject: [PATCH 11/21] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3b26e8156..0e44e225d 100644 --- a/package.json +++ b/package.json @@ -109,7 +109,7 @@ "json-stringify-safe": "^5.0.1", "quick-format-unescaped": "^4.0.3", "sonic-boom": "^2.1.0", - "thread-stream": "^0.11.0" + "thread-stream": "^0.11.1" }, "tsd": { "directory": "test/types" From 41b82b8ac5143478284b2a5f7c0726b1e9d23409 Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Sun, 5 Sep 2021 19:18:03 +0200 Subject: [PATCH 12/21] remove skip for yarn --- test/transport.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/transport.test.js b/test/transport.test.js index 386e2aa4f..b953911ff 100644 --- a/test/transport.test.js +++ b/test/transport.test.js @@ -119,7 +119,7 @@ test('pino.transport loads the pino-elasticsearch package', ({ plan, ok, fail, e }) transport.on('error', function (err) { ok(err) - equal(err.message, 'Missing node(s) option', 'pino-elastisearch trigger a valid error', { skip: isYarnPnp }) + equal(err.message, 'Missing node(s) option', 'pino-elastisearch trigger a valid error') }) pass('pino instance created') From dc49760c4da750310ebf44567ddbe6eb9ec70a0f Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Mon, 6 Sep 2021 09:28:16 +0200 Subject: [PATCH 13/21] skip esm test with yarn --- .github/workflows/package-manager-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/package-manager-ci.yml b/.github/workflows/package-manager-ci.yml index 5e3a92e45..e518918ec 100644 --- a/.github/workflows/package-manager-ci.yml +++ b/.github/workflows/package-manager-ci.yml @@ -58,7 +58,10 @@ jobs: # needed due the yarn.lock file in pino's .gitignore YARN_ENABLE_IMMUTABLE_INSTALLS: false - name: Tests - run: yarn run test-ci + run: | + # yarn doesn't support ESM yet + mv ./test/esm/index.test.js ./test/esm/index.test.skip.js + yarn run test-ci yarn-pnp: name: yarn-pnp package manager on ${{ matrix.node-version }} ${{ matrix.os }} From 2e2d6f466bcf370f3a1d7cf91cfa0d251eb364ad Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Mon, 6 Sep 2021 09:58:23 +0200 Subject: [PATCH 14/21] fix skipping --- .github/workflows/package-manager-ci.yml | 16 +++++++++------- test/esm/index.test.js | 6 ++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/package-manager-ci.yml b/.github/workflows/package-manager-ci.yml index e518918ec..b51ce9a9b 100644 --- a/.github/workflows/package-manager-ci.yml +++ b/.github/workflows/package-manager-ci.yml @@ -50,7 +50,7 @@ jobs: run: | npm install -g yarn yarn set version berry && yarn set version 2.4.2 - echo "nodeLinker: node-modules" >> .yarnrc.yml + echo 'nodeLinker: node_modules >> .yarnrc.yml # see https://github.com/yarnpkg/berry/issues/2935#issuecomment-911299992 yarn add --dev typescript@~4.3.2 yarn install @@ -58,10 +58,7 @@ jobs: # needed due the yarn.lock file in pino's .gitignore YARN_ENABLE_IMMUTABLE_INSTALLS: false - name: Tests - run: | - # yarn doesn't support ESM yet - mv ./test/esm/index.test.js ./test/esm/index.test.skip.js - yarn run test-ci + run: yarn run test-ci yarn-pnp: name: yarn-pnp package manager on ${{ matrix.node-version }} ${{ matrix.os }} @@ -81,8 +78,13 @@ jobs: run: | npm install -g yarn yarn set version berry - echo "nodeLinker: pnp" >> .yarnrc.yml - echo "pnpMode: loose" >> .yarnrc.yml + echo 'nodeLinker: pnp + pnpMode: loose + packageExtensions: + debug@*: + dependencies: + supports-color: "*" + ' >> .yarnrc.yml yarn install yarn add --dev transport@link:./test/fixtures/transport env: diff --git a/test/esm/index.test.js b/test/esm/index.test.js index 0d1a96cc8..80ac19212 100644 --- a/test/esm/index.test.js +++ b/test/esm/index.test.js @@ -3,7 +3,9 @@ const t = require('tap') const semver = require('semver') -if (!semver.satisfies(process.versions.node, '^13.3.0 || ^12.10.0 || >= 14.0.0')) { +const { isYarnPnp } = require('../helper') + +if (!semver.satisfies(process.versions.node, '^13.3.0 || ^12.10.0 || >= 14.0.0') || isYarnPnp) { t.skip('Skip esm because not supported by Node') } else { // Node v8 throw a `SyntaxError: Unexpected token import` @@ -17,7 +19,7 @@ if (!semver.satisfies(process.versions.node, '^13.3.0 || ^12.10.0 || >= 14.0.0') }) } -if (!semver.satisfies(process.versions.node, '>= 14.13.0 || ^12.20.0')) { +if (!semver.satisfies(process.versions.node, '>= 14.13.0 || ^12.20.0') || isYarnPnp) { t.skip('Skip named exports because not supported by Node') } else { // Node v8 throw a `SyntaxError: Unexpected token import` From 3bdba23da7bebc74ae424338070f4588f27aa947 Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Mon, 6 Sep 2021 11:59:06 +0200 Subject: [PATCH 15/21] fix typescript compilation --- .github/workflows/package-manager-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/package-manager-ci.yml b/.github/workflows/package-manager-ci.yml index b51ce9a9b..9b1ab354d 100644 --- a/.github/workflows/package-manager-ci.yml +++ b/.github/workflows/package-manager-ci.yml @@ -50,7 +50,7 @@ jobs: run: | npm install -g yarn yarn set version berry && yarn set version 2.4.2 - echo 'nodeLinker: node_modules >> .yarnrc.yml + echo "nodeLinker: node-modules" >> .yarnrc.yml # see https://github.com/yarnpkg/berry/issues/2935#issuecomment-911299992 yarn add --dev typescript@~4.3.2 yarn install @@ -85,6 +85,7 @@ jobs: dependencies: supports-color: "*" ' >> .yarnrc.yml + yarn add --dev typescript@~4.3.2 yarn install yarn add --dev transport@link:./test/fixtures/transport env: From a31da829faa96247faca1707c3e002d9d70073a0 Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Tue, 7 Sep 2021 12:12:37 +0200 Subject: [PATCH 16/21] skip typescript test on yarn pnp --- .github/workflows/package-manager-ci.yml | 6 ++++-- package.json | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package-manager-ci.yml b/.github/workflows/package-manager-ci.yml index 9b1ab354d..9c75901e5 100644 --- a/.github/workflows/package-manager-ci.yml +++ b/.github/workflows/package-manager-ci.yml @@ -79,11 +79,13 @@ jobs: npm install -g yarn yarn set version berry echo 'nodeLinker: pnp - pnpMode: loose packageExtensions: debug@*: dependencies: supports-color: "*" + treport@*: + dependencies: + tap-yaml: "*" ' >> .yarnrc.yml yarn add --dev typescript@~4.3.2 yarn install @@ -92,4 +94,4 @@ jobs: # needed due the yarn.lock file in pino's .gitignore YARN_ENABLE_IMMUTABLE_INSTALLS: false - name: Tests - run: yarn run test-ci + run: yarn run test-ci-yarn-pnp diff --git a/package.json b/package.json index 0e44e225d..06977de93 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "lint": "eslint .", "test": "npm run lint && tap test/*test.js test/*/*test.js && npm run test-types", "test-ci": "npm run lint && tap --no-check-coverage test/*test.js test/*/*test.js --coverage-report=lcovonly && npm run test-types", + "test-ci-yarn-pnp": "npm run lint && tap --no-check-coverage test/*test.js test/*/*test.js --coverage-report=lcovonly", "test-types": "tsc && tsd && ts-node test/types/pino.ts", "cov-ui": "tap --coverage-report=html test/*test.js test/*/*test.js", "bench": "node benchmarks/utils/runbench all", From 72298d31be6cd354ce31edc0d97c67d4ca5f3d76 Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Tue, 7 Sep 2021 12:49:32 +0200 Subject: [PATCH 17/21] fix pino-pretty test --- .github/workflows/package-manager-ci.yml | 4 +--- lib/worker.js | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/package-manager-ci.yml b/.github/workflows/package-manager-ci.yml index 9c75901e5..de98d7e91 100644 --- a/.github/workflows/package-manager-ci.yml +++ b/.github/workflows/package-manager-ci.yml @@ -48,8 +48,7 @@ jobs: node-version: ${{ matrix.node-version }} - name: Use yarn run: | - npm install -g yarn - yarn set version berry && yarn set version 2.4.2 + yarn set version berry && yarn set version 2 echo "nodeLinker: node-modules" >> .yarnrc.yml # see https://github.com/yarnpkg/berry/issues/2935#issuecomment-911299992 yarn add --dev typescript@~4.3.2 @@ -76,7 +75,6 @@ jobs: node-version: ${{ matrix.node-version }} - name: Use yarn run: | - npm install -g yarn yarn set version berry echo 'nodeLinker: pnp packageExtensions: diff --git a/lib/worker.js b/lib/worker.js index 0b6c4989b..184ade043 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -10,8 +10,19 @@ const build = require('pino-abstract-transport') module.exports = async function ({ targets }) { targets = await Promise.all(targets.map(async (t) => { - const toLoad = 'file://' + t.target - const stream = await (await import(toLoad)).default(t.options) + let fn + try { + const toLoad = 'file://' + t.target + fn = (await import(toLoad)).default + } catch (error) { + // See this PR for details: https://github.com/pinojs/thread-stream/pull/34 + if ((error.code === 'ENOTDIR' || error.code === 'ERR_MODULE_NOT_FOUND')) { + fn = require(t.target) + } else { + throw error + } + } + const stream = await fn(t.options) return { level: t.level, stream From 660b89a7490bb6e58611fe9d36dfa2c502db7a8b Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Tue, 7 Sep 2021 15:27:25 +0200 Subject: [PATCH 18/21] fix pnpm flaky test --- .github/workflows/package-manager-ci.yml | 2 +- package.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/package-manager-ci.yml b/.github/workflows/package-manager-ci.yml index de98d7e91..67e9cbd30 100644 --- a/.github/workflows/package-manager-ci.yml +++ b/.github/workflows/package-manager-ci.yml @@ -30,7 +30,7 @@ jobs: - name: Install dependancies run: pnpm install - name: Tests - run: pnpm run test-ci + run: pnpm run test-ci-pnpm yarn: name: yarn package manager on ${{ matrix.node-version }} ${{ matrix.os }} diff --git a/package.json b/package.json index 11bd1ec33..169bcb90d 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "lint": "eslint .", "test": "npm run lint && tap test/*test.js test/*/*test.js && npm run test-types", "test-ci": "npm run lint && tap --no-check-coverage test/*test.js test/*/*test.js --coverage-report=lcovonly && npm run test-types", + "test-ci-pnpm": "npm run lint && tap --no-coverage --no-check-coverage test/*test.js test/*/*test.js && npm run test-types", "test-ci-yarn-pnp": "npm run lint && tap --no-check-coverage test/*test.js test/*/*test.js --coverage-report=lcovonly", "test-types": "tsc && tsd && ts-node test/types/pino.ts", "cov-ui": "tap --coverage-report=html test/*test.js test/*/*test.js", From a53e698b1152e16ad059c79b22821b5f2e024ba0 Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Tue, 7 Sep 2021 15:59:08 +0200 Subject: [PATCH 19/21] fix GH action os matix --- .github/workflows/package-manager-ci.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/package-manager-ci.yml b/.github/workflows/package-manager-ci.yml index 67e9cbd30..939d39682 100644 --- a/.github/workflows/package-manager-ci.yml +++ b/.github/workflows/package-manager-ci.yml @@ -1,13 +1,8 @@ name: package-manager-ci on: push: - paths-ignore: - - 'docs/**' - - '*.md' - pull_request: - paths-ignore: - - 'docs/**' - - '*.md' + branches: + - main jobs: pnpm: name: pnpm package manager on ${{ matrix.node-version }} ${{ matrix.os }} @@ -15,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macOS-latest, windows-latest] + os: [windows-latest, ubuntu-latest] node-version: [12, 14, 16] steps: - uses: actions/checkout@v2.3.4 @@ -38,7 +33,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macOS-latest] + os: [windows-latest, ubuntu-latest] node-version: [12, 14, 16] steps: - uses: actions/checkout@v2.3.4 @@ -65,7 +60,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macOS-latest] + os: [windows-latest, ubuntu-latest] node-version: [12, 14, 16] steps: - uses: actions/checkout@v2.3.4 From 715fb8576e056f7ce982db33fd1c2cb9ea088ebf Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Tue, 7 Sep 2021 16:02:16 +0200 Subject: [PATCH 20/21] run pm ci on node 14 only --- .github/workflows/package-manager-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/package-manager-ci.yml b/.github/workflows/package-manager-ci.yml index 939d39682..d0cad8b6a 100644 --- a/.github/workflows/package-manager-ci.yml +++ b/.github/workflows/package-manager-ci.yml @@ -11,7 +11,7 @@ jobs: fail-fast: false matrix: os: [windows-latest, ubuntu-latest] - node-version: [12, 14, 16] + node-version: [14] steps: - uses: actions/checkout@v2.3.4 - name: Use Node.js ${{ matrix.node-version }} @@ -34,7 +34,7 @@ jobs: fail-fast: false matrix: os: [windows-latest, ubuntu-latest] - node-version: [12, 14, 16] + node-version: [14] steps: - uses: actions/checkout@v2.3.4 - name: Use Node.js ${{ matrix.node-version }} @@ -61,7 +61,7 @@ jobs: fail-fast: false matrix: os: [windows-latest, ubuntu-latest] - node-version: [12, 14, 16] + node-version: [14] steps: - uses: actions/checkout@v2.3.4 - name: Use Node.js ${{ matrix.node-version }} From 6cde872160337707b7f4c6bf0d0a91c70cc7bf3f Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Tue, 7 Sep 2021 18:23:43 +0200 Subject: [PATCH 21/21] fix pr feedback --- .github/workflows/package-manager-ci.yml | 1 + package.json | 5 +-- test/transport.test.js | 49 +++++------------------- 3 files changed, 13 insertions(+), 42 deletions(-) diff --git a/.github/workflows/package-manager-ci.yml b/.github/workflows/package-manager-ci.yml index d0cad8b6a..20bd81cd8 100644 --- a/.github/workflows/package-manager-ci.yml +++ b/.github/workflows/package-manager-ci.yml @@ -3,6 +3,7 @@ on: push: branches: - main + - package-manager-load jobs: pnpm: name: pnpm package manager on ${{ matrix.node-version }} ${{ matrix.os }} diff --git a/package.json b/package.json index 169bcb90d..2e157e20e 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,8 @@ "lint": "eslint .", "test": "npm run lint && tap test/*test.js test/*/*test.js && npm run test-types", "test-ci": "npm run lint && tap --no-check-coverage test/*test.js test/*/*test.js --coverage-report=lcovonly && npm run test-types", - "test-ci-pnpm": "npm run lint && tap --no-coverage --no-check-coverage test/*test.js test/*/*test.js && npm run test-types", - "test-ci-yarn-pnp": "npm run lint && tap --no-check-coverage test/*test.js test/*/*test.js --coverage-report=lcovonly", + "test-ci-pnpm": "pnpm run lint && tap --no-coverage --no-check-coverage test/*test.js test/*/*test.js && pnpm run test-types", + "test-ci-yarn-pnp": "yarn run lint && tap --no-check-coverage test/*test.js test/*/*test.js --coverage-report=lcovonly", "test-types": "tsc && tsd && ts-node test/types/pino.ts", "cov-ui": "tap --coverage-report=html test/*test.js test/*/*test.js", "bench": "node benchmarks/utils/runbench all", @@ -83,7 +83,6 @@ "import-fresh": "^3.2.1", "log": "^6.0.0", "loglevel": "^1.6.7", - "pino-elasticsearch": "^6.1.0", "pino-pretty": "pinojs/pino-pretty#master", "pre-commit": "^1.2.2", "proxyquire": "^2.1.3", diff --git a/test/transport.test.js b/test/transport.test.js index bf8ae2ed9..d77e99843 100644 --- a/test/transport.test.js +++ b/test/transport.test.js @@ -16,29 +16,23 @@ const { pid } = process const hostname = os.hostname() async function installTransportModule () { + if (isYarnPnp) { + return + } try { await uninstallTransportModule() } catch {} - try { - await symlink( - join(__dirname, 'fixtures', 'transport'), - join(__dirname, '..', 'node_modules', 'transport') - ) - } catch (err) { - if (!isYarnPnp) { - throw err - } - } + await symlink( + join(__dirname, 'fixtures', 'transport'), + join(__dirname, '..', 'node_modules', 'transport') + ) } async function uninstallTransportModule () { - try { - await unlink(join(__dirname, '..', 'node_modules', 'transport')) - } catch (err) { - if (!isYarnPnp) { - throw err - } + if (isYarnPnp) { + return } + await unlink(join(__dirname, '..', 'node_modules', 'transport')) } test('pino.transport with file', async ({ same, teardown }) => { @@ -102,29 +96,6 @@ test('pino.transport with package', { skip: isWin }, async ({ same, teardown }) }) }) -test('pino.transport loads the pino-elasticsearch package', ({ plan, ok, fail, equal, pass }) => { - plan(3) - const transport = pino.transport({ - target: 'pino-elasticsearch', - options: { - node: null // triggers the error if the module is loaded correctly - } - }) - - const instance = pino(transport) - instance.info('hello') - - transport.on('ready', function () { - fail('ready event should not be emitted') - }) - transport.on('error', function (err) { - ok(err) - equal(err.message, 'Missing node(s) option', 'pino-elastisearch trigger a valid error') - }) - - pass('pino instance created') -}) - test('pino.transport with file URL', async ({ same, teardown }) => { const destination = join( os.tmpdir(),