From db5ee23edf8cf9f8c3ef55361b0bb4c2a9bafb8b Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Wed, 28 Apr 2021 12:49:26 +0200 Subject: [PATCH 01/86] test: update OpenSSL 3.0.0-alpha15 error messages PR-URL: https://github.com/nodejs/node/pull/38451 Fixes: https://github.com/nodejs/node/issues/38373 Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: James M Snell --- test/parallel/test-crypto-dh-stateless.js | 2 +- test/parallel/test-crypto-key-objects.js | 10 +++++++--- test/parallel/test-crypto-keygen.js | 15 ++++++++++----- .../test-crypto-private-decrypt-gh32240.js | 3 ++- test/parallel/test-crypto-rsa-dsa.js | 5 +++-- test/parallel/test-crypto-sign-verify.js | 4 +--- test/parallel/test-tls-passphrase.js | 5 ++--- 7 files changed, 26 insertions(+), 18 deletions(-) diff --git a/test/parallel/test-crypto-dh-stateless.js b/test/parallel/test-crypto-dh-stateless.js index 6f99ebfb111e8a..943ead06cda1fb 100644 --- a/test/parallel/test-crypto-dh-stateless.js +++ b/test/parallel/test-crypto-dh-stateless.js @@ -226,7 +226,7 @@ assert.throws(() => { crypto.generateKeyPairSync('ec', { namedCurve: not256k1 })); }, common.hasOpenSSL3 ? { name: 'Error', - code: 'ERR_OSSL_EC_INCOMPATIBLE_OBJECTS' + code: 'ERR_OSSL_MISMATCHING_SHARED_PARAMETERS' } : { name: 'Error', code: 'ERR_OSSL_EVP_DIFFERENT_PARAMETERS' diff --git a/test/parallel/test-crypto-key-objects.js b/test/parallel/test-crypto-key-objects.js index aa57aaa41f4813..e2e62c6892bbf2 100644 --- a/test/parallel/test-crypto-key-objects.js +++ b/test/parallel/test-crypto-key-objects.js @@ -328,7 +328,10 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem', type: 'pkcs1' }); createPrivateKey({ key, format: 'der', type: 'pkcs1' }); - }, { + }, common.hasOpenSSL3 ? { + message: /error:1E08010C:DECODER routines::unsupported/, + library: 'DECODER routines' + } : { message: /asn1 encoding/, library: 'asn1 encoding routines' }); @@ -514,7 +517,8 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem', // Reading an encrypted key without a passphrase should fail. assert.throws(() => createPrivateKey(privateDsa), common.hasOpenSSL3 ? { name: 'Error', - message: 'Failed to read private key', + message: 'error:07880109:common libcrypto routines::interrupted or ' + + 'cancelled', } : { name: 'TypeError', code: 'ERR_MISSING_PASSPHRASE', @@ -540,7 +544,7 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem', passphrase: Buffer.alloc(1024, 'a') }), { message: common.hasOpenSSL3 ? - 'Failed to read private key' : + 'error:07880109:common libcrypto routines::interrupted or cancelled' : /bad decrypt/ }); diff --git a/test/parallel/test-crypto-keygen.js b/test/parallel/test-crypto-keygen.js index a120a3838e2048..58e5d305b6b05a 100644 --- a/test/parallel/test-crypto-keygen.js +++ b/test/parallel/test-crypto-keygen.js @@ -213,7 +213,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); const publicKey = { key: publicKeyDER, ...publicKeyEncoding }; const expectedError = common.hasOpenSSL3 ? { name: 'Error', - message: 'Failed to read private key' + message: 'error:07880109:common libcrypto routines::interrupted or ' + + 'cancelled' } : { name: 'TypeError', code: 'ERR_MISSING_PASSPHRASE', @@ -477,7 +478,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); // Since the private key is encrypted, signing shouldn't work anymore. assert.throws(() => testSignVerify(publicKey, privateKey), common.hasOpenSSL3 ? { - message: 'Failed to read private key' + message: 'error:07880109:common libcrypto ' + + 'routines::interrupted or cancelled' } : { name: 'TypeError', code: 'ERR_MISSING_PASSPHRASE', @@ -510,7 +512,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); // Since the private key is encrypted, signing shouldn't work anymore. assert.throws(() => testSignVerify(publicKey, privateKey), common.hasOpenSSL3 ? { - message: 'Failed to read private key' + message: 'error:07880109:common libcrypto ' + + 'routines::interrupted or cancelled' } : { name: 'TypeError', code: 'ERR_MISSING_PASSPHRASE', @@ -546,7 +549,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); // Since the private key is encrypted, signing shouldn't work anymore. assert.throws(() => testSignVerify(publicKey, privateKey), common.hasOpenSSL3 ? { - message: 'Failed to read private key' + message: 'error:07880109:common libcrypto ' + + 'routines::interrupted or cancelled' } : { name: 'TypeError', code: 'ERR_MISSING_PASSPHRASE', @@ -583,7 +587,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); // Since the private key is encrypted, signing shouldn't work anymore. assert.throws(() => testSignVerify(publicKey, privateKey), common.hasOpenSSL3 ? { - message: 'Failed to read private key' + message: 'error:07880109:common libcrypto ' + + 'routines::interrupted or cancelled' } : { name: 'TypeError', code: 'ERR_MISSING_PASSPHRASE', diff --git a/test/parallel/test-crypto-private-decrypt-gh32240.js b/test/parallel/test-crypto-private-decrypt-gh32240.js index 875888622cb5f7..1785f5eef3d202 100644 --- a/test/parallel/test-crypto-private-decrypt-gh32240.js +++ b/test/parallel/test-crypto-private-decrypt-gh32240.js @@ -35,6 +35,7 @@ function decrypt(key) { decrypt(pkey); assert.throws(() => decrypt(pkeyEncrypted), common.hasOpenSSL3 ? - { message: 'Failed to read asymmetric key' } : + { message: 'error:07880109:common libcrypto routines::interrupted or ' + + 'cancelled' } : { code: 'ERR_MISSING_PASSPHRASE' }); decrypt(pkey); // Should not throw. diff --git a/test/parallel/test-crypto-rsa-dsa.js b/test/parallel/test-crypto-rsa-dsa.js index 94c810fa6f24c6..9afcb38616dafd 100644 --- a/test/parallel/test-crypto-rsa-dsa.js +++ b/test/parallel/test-crypto-rsa-dsa.js @@ -37,10 +37,11 @@ const openssl1DecryptError = { }; const decryptError = common.hasOpenSSL3 ? - { message: 'Failed to read asymmetric key' } : openssl1DecryptError; + { message: 'error:1C800064:Provider routines::bad decrypt' } : + openssl1DecryptError; const decryptPrivateKeyError = common.hasOpenSSL3 ? { - message: 'Failed to read private key', + message: 'error:1C800064:Provider routines::bad decrypt', } : openssl1DecryptError; function getBufferCopy(buf) { diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js index 1de8a42514e2b1..444135538ccff8 100644 --- a/test/parallel/test-crypto-sign-verify.js +++ b/test/parallel/test-crypto-sign-verify.js @@ -44,9 +44,7 @@ const keySize = 2048; `-----BEGIN RSA PRIVATE KEY----- AAAAAAAAAAAA -----END RSA PRIVATE KEY-----`); - }, { message: common.hasOpenSSL3 ? - 'Failed to read private key' : - 'bye, bye, library' }); + }, { message: 'bye, bye, library' }); delete Object.prototype.library; diff --git a/test/parallel/test-tls-passphrase.js b/test/parallel/test-tls-passphrase.js index c0d0051ff8bbc2..ce77dd18a6e620 100644 --- a/test/parallel/test-tls-passphrase.js +++ b/test/parallel/test-tls-passphrase.js @@ -224,7 +224,7 @@ server.listen(0, common.mustCall(function() { })).unref(); const errMessagePassword = common.hasOpenSSL3 ? - /Error: PEM_read_bio_PrivateKey/ : /bad decrypt/; + /Error: error:1400006B:UI routines::processing error/ : /bad decrypt/; // Missing passphrase assert.throws(function() { @@ -254,8 +254,7 @@ assert.throws(function() { }); }, errMessagePassword); -const errMessageDecrypt = common.hasOpenSSL3 ? - /Error: PEM_read_bio_PrivateKey/ : /bad decrypt/; +const errMessageDecrypt = /bad decrypt/; // Invalid passphrase assert.throws(function() { From b51b4feecea60e4bedd20056648974e74bc878f6 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Wed, 28 Apr 2021 12:26:03 +0200 Subject: [PATCH 02/86] test: skip tests for openssl-3.0.0-alpha15 This commit skips some test when OpenSSL 3.0.0-alpha15 is used as there is an issue that causes them to fail. This is only a temp solution until there is new OpenSSL release. Fixes: https://github.com/nodejs/node/issues/38373 PR-URL: https://github.com/nodejs/node/pull/38451 Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: James M Snell --- test/benchmark/test-benchmark-crypto.js | 4 ++++ test/parallel/test-crypto-async-sign-verify.js | 3 +++ test/parallel/test-crypto-dh-stateless.js | 3 +++ test/parallel/test-crypto-key-objects.js | 3 +++ test/parallel/test-crypto-keygen.js | 3 +++ test/parallel/test-crypto-rsa-dsa.js | 3 +++ test/parallel/test-crypto-sign-verify.js | 3 +++ test/parallel/test-webcrypto-derivebits-ecdh.js | 3 +++ test/parallel/test-webcrypto-derivebits-node-dh.js | 3 +++ test/parallel/test-webcrypto-derivekey-ecdh.js | 3 +++ test/parallel/test-webcrypto-encrypt-decrypt-rsa.js | 3 +++ test/parallel/test-webcrypto-export-import-dsa.js | 3 +++ test/parallel/test-webcrypto-export-import-ec.js | 3 +++ test/parallel/test-webcrypto-export-import-rsa.js | 3 +++ test/parallel/test-webcrypto-export-import.js | 3 +++ test/parallel/test-webcrypto-rsa-pss-params.js | 3 +++ test/parallel/test-webcrypto-sign-verify-ecdsa.js | 3 +++ test/parallel/test-webcrypto-sign-verify-node-dsa.js | 3 +++ test/parallel/test-webcrypto-sign-verify-rsa.js | 3 +++ test/parallel/test-webcrypto-wrap-unwrap.js | 3 +++ 20 files changed, 61 insertions(+) diff --git a/test/benchmark/test-benchmark-crypto.js b/test/benchmark/test-benchmark-crypto.js index 7f6988acf234d8..f7f155ac8e55d8 100644 --- a/test/benchmark/test-benchmark-crypto.js +++ b/test/benchmark/test-benchmark-crypto.js @@ -8,6 +8,10 @@ if (!common.hasCrypto) if (common.hasFipsCrypto) common.skip('some benchmarks are FIPS-incompatible'); +if (common.hasOpenSSL3) { + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); +} + const runBenchmark = require('../common/benchmark'); runBenchmark('crypto', { NODEJS_BENCHMARK_ZERO_ALLOWED: 1 }); diff --git a/test/parallel/test-crypto-async-sign-verify.js b/test/parallel/test-crypto-async-sign-verify.js index 4e3c32fdcd23fb..2e6c9e0bc539f4 100644 --- a/test/parallel/test-crypto-async-sign-verify.js +++ b/test/parallel/test-crypto-async-sign-verify.js @@ -3,6 +3,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const assert = require('assert'); const util = require('util'); const crypto = require('crypto'); diff --git a/test/parallel/test-crypto-dh-stateless.js b/test/parallel/test-crypto-dh-stateless.js index 943ead06cda1fb..658bd38fff655a 100644 --- a/test/parallel/test-crypto-dh-stateless.js +++ b/test/parallel/test-crypto-dh-stateless.js @@ -3,6 +3,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const assert = require('assert'); const crypto = require('crypto'); diff --git a/test/parallel/test-crypto-key-objects.js b/test/parallel/test-crypto-key-objects.js index e2e62c6892bbf2..6692dec4686e31 100644 --- a/test/parallel/test-crypto-key-objects.js +++ b/test/parallel/test-crypto-key-objects.js @@ -4,6 +4,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const assert = require('assert'); const { createCipheriv, diff --git a/test/parallel/test-crypto-keygen.js b/test/parallel/test-crypto-keygen.js index 58e5d305b6b05a..4612fc4a1ac40a 100644 --- a/test/parallel/test-crypto-keygen.js +++ b/test/parallel/test-crypto-keygen.js @@ -4,6 +4,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const assert = require('assert'); const { constants, diff --git a/test/parallel/test-crypto-rsa-dsa.js b/test/parallel/test-crypto-rsa-dsa.js index 9afcb38616dafd..567d8650c5a177 100644 --- a/test/parallel/test-crypto-rsa-dsa.js +++ b/test/parallel/test-crypto-rsa-dsa.js @@ -3,6 +3,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const assert = require('assert'); const crypto = require('crypto'); diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js index 444135538ccff8..15fa3db4a69f19 100644 --- a/test/parallel/test-crypto-sign-verify.js +++ b/test/parallel/test-crypto-sign-verify.js @@ -3,6 +3,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const assert = require('assert'); const fs = require('fs'); const path = require('path'); diff --git a/test/parallel/test-webcrypto-derivebits-ecdh.js b/test/parallel/test-webcrypto-derivebits-ecdh.js index 64cbae7cec6a03..49076ce443a54a 100644 --- a/test/parallel/test-webcrypto-derivebits-ecdh.js +++ b/test/parallel/test-webcrypto-derivebits-ecdh.js @@ -5,6 +5,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const assert = require('assert'); const { subtle, getRandomValues } = require('crypto').webcrypto; diff --git a/test/parallel/test-webcrypto-derivebits-node-dh.js b/test/parallel/test-webcrypto-derivebits-node-dh.js index 2503bc17032e0d..cab7d40c1a7abf 100644 --- a/test/parallel/test-webcrypto-derivebits-node-dh.js +++ b/test/parallel/test-webcrypto-derivebits-node-dh.js @@ -5,6 +5,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const assert = require('assert'); const { subtle } = require('crypto').webcrypto; diff --git a/test/parallel/test-webcrypto-derivekey-ecdh.js b/test/parallel/test-webcrypto-derivekey-ecdh.js index bdd9bd7588a763..a0bf28e89e4e3a 100644 --- a/test/parallel/test-webcrypto-derivekey-ecdh.js +++ b/test/parallel/test-webcrypto-derivekey-ecdh.js @@ -5,6 +5,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const assert = require('assert'); const { subtle, getRandomValues } = require('crypto').webcrypto; diff --git a/test/parallel/test-webcrypto-encrypt-decrypt-rsa.js b/test/parallel/test-webcrypto-encrypt-decrypt-rsa.js index 151eebd36c9765..e01152c07f294d 100644 --- a/test/parallel/test-webcrypto-encrypt-decrypt-rsa.js +++ b/test/parallel/test-webcrypto-encrypt-decrypt-rsa.js @@ -5,6 +5,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const assert = require('assert'); const { subtle } = require('crypto').webcrypto; diff --git a/test/parallel/test-webcrypto-export-import-dsa.js b/test/parallel/test-webcrypto-export-import-dsa.js index 3fddd9dd9c4559..6b47b99c1ddbf8 100644 --- a/test/parallel/test-webcrypto-export-import-dsa.js +++ b/test/parallel/test-webcrypto-export-import-dsa.js @@ -5,6 +5,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const assert = require('assert'); const { subtle } = require('crypto').webcrypto; diff --git a/test/parallel/test-webcrypto-export-import-ec.js b/test/parallel/test-webcrypto-export-import-ec.js index 31ab2c09cdb1f9..e5453878a19050 100644 --- a/test/parallel/test-webcrypto-export-import-ec.js +++ b/test/parallel/test-webcrypto-export-import-ec.js @@ -5,6 +5,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const assert = require('assert'); const { subtle } = require('crypto').webcrypto; diff --git a/test/parallel/test-webcrypto-export-import-rsa.js b/test/parallel/test-webcrypto-export-import-rsa.js index f43259fd22faea..46e96628a33f8c 100644 --- a/test/parallel/test-webcrypto-export-import-rsa.js +++ b/test/parallel/test-webcrypto-export-import-rsa.js @@ -5,6 +5,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const assert = require('assert'); const { subtle } = require('crypto').webcrypto; diff --git a/test/parallel/test-webcrypto-export-import.js b/test/parallel/test-webcrypto-export-import.js index d7db433b364011..9cf8833cecfc47 100644 --- a/test/parallel/test-webcrypto-export-import.js +++ b/test/parallel/test-webcrypto-export-import.js @@ -5,6 +5,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const assert = require('assert'); const { subtle, getRandomValues } = require('crypto').webcrypto; diff --git a/test/parallel/test-webcrypto-rsa-pss-params.js b/test/parallel/test-webcrypto-rsa-pss-params.js index 964eaf32e890fd..d52a9bf6add223 100644 --- a/test/parallel/test-webcrypto-rsa-pss-params.js +++ b/test/parallel/test-webcrypto-rsa-pss-params.js @@ -5,6 +5,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const { createPrivateKey, createPublicKey, diff --git a/test/parallel/test-webcrypto-sign-verify-ecdsa.js b/test/parallel/test-webcrypto-sign-verify-ecdsa.js index 2f8f3a2fd229bd..8620498d89b00c 100644 --- a/test/parallel/test-webcrypto-sign-verify-ecdsa.js +++ b/test/parallel/test-webcrypto-sign-verify-ecdsa.js @@ -5,6 +5,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const assert = require('assert'); const { subtle } = require('crypto').webcrypto; diff --git a/test/parallel/test-webcrypto-sign-verify-node-dsa.js b/test/parallel/test-webcrypto-sign-verify-node-dsa.js index 73b006b9236249..24d739062fb098 100644 --- a/test/parallel/test-webcrypto-sign-verify-node-dsa.js +++ b/test/parallel/test-webcrypto-sign-verify-node-dsa.js @@ -5,6 +5,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const assert = require('assert'); const { subtle } = require('crypto').webcrypto; diff --git a/test/parallel/test-webcrypto-sign-verify-rsa.js b/test/parallel/test-webcrypto-sign-verify-rsa.js index 60815c5ea0451d..2cfcf6e2ec02bd 100644 --- a/test/parallel/test-webcrypto-sign-verify-rsa.js +++ b/test/parallel/test-webcrypto-sign-verify-rsa.js @@ -5,6 +5,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const assert = require('assert'); const { subtle } = require('crypto').webcrypto; diff --git a/test/parallel/test-webcrypto-wrap-unwrap.js b/test/parallel/test-webcrypto-wrap-unwrap.js index 1094845c73e143..54a5a782a09586 100644 --- a/test/parallel/test-webcrypto-wrap-unwrap.js +++ b/test/parallel/test-webcrypto-wrap-unwrap.js @@ -5,6 +5,9 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +if (common.hasOpenSSL3) + common.skip('temporarily skipping for OpenSSL 3.0-alpha15'); + const assert = require('assert'); const { subtle } = require('crypto').webcrypto; From f31a6114a4139f4988a0eadb4b1766deee221de8 Mon Sep 17 00:00:00 2001 From: Milad Fa Date: Fri, 30 Apr 2021 14:15:53 -0400 Subject: [PATCH 03/86] deps: V8: cherry-pick 530080c44af2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit message: ``` PPC: Add Power10 to the supported list and enable related features This CL adds Power10 recognition to Linux, AIX as well as IBMi. Enabled features include: MODULO FPR_GPR_MOV SIMD LWSYNC ISELECT VSX Change-Id: Ifc337e6497a3efe9697bcf03063a2b94471f96e9 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2855041 Reviewed-by: Clemens Backes Reviewed-by: Junliang Yan Reviewed-by: Vasili Skurydzin Commit-Queue: Milad Fa Cr-Commit-Position: refs/heads/master@{#74279} ``` Refs: https://github.com/v8/v8/commit/530080c44af254646a3cc3f364aac26b1b5ac10c PR-URL: https://github.com/nodejs/node/pull/38489 Reviewed-By: Richard Lau Reviewed-By: Rich Trott Reviewed-By: Michaël Zasso Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil Reviewed-By: Ash Cripps Reviewed-By: Michael Dawson --- common.gypi | 2 +- deps/v8/src/base/cpu.cc | 10 +++++++++- deps/v8/src/base/cpu.h | 1 + deps/v8/src/codegen/ppc/assembler-ppc.cc | 12 ++++++++---- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/common.gypi b/common.gypi index be7c06d4c81882..e5f01195e63850 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.11', + 'v8_embedder_string': '-node.12', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/base/cpu.cc b/deps/v8/src/base/cpu.cc index abfd048ee46ecb..36f2e5f5e3b5e2 100644 --- a/deps/v8/src/base/cpu.cc +++ b/deps/v8/src/base/cpu.cc @@ -31,6 +31,9 @@ #ifndef POWER_9 #define POWER_9 0x20000 #endif +#ifndef POWER_10 +#define POWER_10 0x40000 +#endif #endif #if V8_OS_POSIX #include // sysconf() @@ -780,7 +783,10 @@ CPU::CPU() part_ = -1; if (auxv_cpu_type) { - if (strcmp(auxv_cpu_type, "power9") == 0) { + if (strcmp(auxv_cpu_type, "power10") == 0) { + part_ = PPC_POWER10; + } + else if (strcmp(auxv_cpu_type, "power9") == 0) { part_ = PPC_POWER9; } else if (strcmp(auxv_cpu_type, "power8") == 0) { part_ = PPC_POWER8; @@ -801,6 +807,8 @@ CPU::CPU() #elif V8_OS_AIX switch (_system_configuration.implementation) { + case POWER_10: + part_ = PPC_POWER10; case POWER_9: part_ = PPC_POWER9; break; diff --git a/deps/v8/src/base/cpu.h b/deps/v8/src/base/cpu.h index 5086584c130020..bfb7d7818a5186 100644 --- a/deps/v8/src/base/cpu.h +++ b/deps/v8/src/base/cpu.h @@ -70,6 +70,7 @@ class V8_BASE_EXPORT CPU final { PPC_POWER7, PPC_POWER8, PPC_POWER9, + PPC_POWER10, PPC_G4, PPC_G5, PPC_PA6T diff --git a/deps/v8/src/codegen/ppc/assembler-ppc.cc b/deps/v8/src/codegen/ppc/assembler-ppc.cc index 02e50e5fa3f1ac..7ea115ee401cc3 100644 --- a/deps/v8/src/codegen/ppc/assembler-ppc.cc +++ b/deps/v8/src/codegen/ppc/assembler-ppc.cc @@ -67,24 +67,28 @@ void CpuFeatures::ProbeImpl(bool cross_compile) { #ifndef USE_SIMULATOR // Probe for additional features at runtime. base::CPU cpu; - if (cpu.part() == base::CPU::PPC_POWER9) { + if (cpu.part() == base::CPU::PPC_POWER9 || + cpu.part() == base::CPU::PPC_POWER10) { supported_ |= (1u << MODULO); } #if V8_TARGET_ARCH_PPC64 if (cpu.part() == base::CPU::PPC_POWER8 || - cpu.part() == base::CPU::PPC_POWER9) { + cpu.part() == base::CPU::PPC_POWER9 || + cpu.part() == base::CPU::PPC_POWER10) { supported_ |= (1u << FPR_GPR_MOV); } #endif if (cpu.part() == base::CPU::PPC_POWER6 || cpu.part() == base::CPU::PPC_POWER7 || cpu.part() == base::CPU::PPC_POWER8 || - cpu.part() == base::CPU::PPC_POWER9) { + cpu.part() == base::CPU::PPC_POWER9 || + cpu.part() == base::CPU::PPC_POWER10) { supported_ |= (1u << LWSYNC); } if (cpu.part() == base::CPU::PPC_POWER7 || cpu.part() == base::CPU::PPC_POWER8 || - cpu.part() == base::CPU::PPC_POWER9) { + cpu.part() == base::CPU::PPC_POWER9 || + cpu.part() == base::CPU::PPC_POWER10) { supported_ |= (1u << ISELECT); supported_ |= (1u << VSX); } From e64ebac2da028448f7cec630877a3daab34a937d Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 26 Apr 2021 21:16:38 -0700 Subject: [PATCH 04/86] test: fix flaky inspector-cli tests when breakpionts are restored PR-URL: https://github.com/nodejs/node/pull/38431 Reviewed-By: Gireesh Punathil Reviewed-By: Richard Lau Reviewed-By: James M Snell --- test/common/inspector-cli.js | 5 ++++- test/inspector-cli/test-inspector-cli-pid.js | 11 +---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/test/common/inspector-cli.js b/test/common/inspector-cli.js index 36d6328dcc9b39..c127b1dc292e7f 100644 --- a/test/common/inspector-cli.js +++ b/test/common/inspector-cli.js @@ -23,7 +23,10 @@ function startCLI(args, flags = [], spawnOpts = {}) { if (this === child.stderr) { stderrOutput += chunk; } - outputBuffer.push(chunk); + // TODO(trott): Figure out why the "breakpoints restored." message appears + // in unpredictable places especially on AIX in CI. We shouldn't be + // excluding it, but it gets in the way of the output checking for tests. + outputBuffer.push(chunk.replace(/\n*\d+ breakpoints restored\.\n*/mg, '')); } function getOutput() { diff --git a/test/inspector-cli/test-inspector-cli-pid.js b/test/inspector-cli/test-inspector-cli-pid.js index 92c81177650af3..c94ab52031111f 100644 --- a/test/inspector-cli/test-inspector-cli-pid.js +++ b/test/inspector-cli/test-inspector-cli-pid.js @@ -40,16 +40,7 @@ function launchTarget(...args) { }) .then(() => cli.command('sb("alive.js", 3)')) .then(() => cli.waitFor(/break/)) - // TODO: There is a known issue on AIX and some other operating systems - // where the breakpoints aren't properly resolved yet when we reach this - // point. Eventually that should be figured out but for now we don't - // want to fail builds because of it. - // What it should be: - // - // .then(() => cli.waitForPrompt()) - // - // What we're diong for now: - .then(() => cli.waitFor(/>\s+(?:\n1 breakpoints restored\.)?$/)) + .then(() => cli.waitForPrompt()) .then(() => { assert.match( cli.output, From 727c2bcc2424b5edaa7a15e43aae0a92721fd3ed Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 28 Apr 2021 21:50:42 -0700 Subject: [PATCH 05/86] test: move test-net-connect-econnrefused from pummel to sequential test-net-connect-econnrefused esems to run quickly on all platforms and does not appear to need to be in the pummel directory. Move to sequential. PR-URL: https://github.com/nodejs/node/pull/38462 Reviewed-By: Anto Aravinth Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Luigi Pinca --- test/{pummel => sequential}/test-net-connect-econnrefused.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{pummel => sequential}/test-net-connect-econnrefused.js (100%) diff --git a/test/pummel/test-net-connect-econnrefused.js b/test/sequential/test-net-connect-econnrefused.js similarity index 100% rename from test/pummel/test-net-connect-econnrefused.js rename to test/sequential/test-net-connect-econnrefused.js From 38644d6f969d8473f2ebf06c06581273aeb4c713 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 3 May 2021 15:29:20 -0700 Subject: [PATCH 06/86] doc: use sentence case in headers in src/crypto/README.md Use sentence case consistently in headers in src/crypto/README.md. PR-URL: https://github.com/nodejs/node/pull/38524 Reviewed-By: Antoine du Hamel Reviewed-By: Colin Ihrig Reviewed-By: Zijian Liu Reviewed-By: Gireesh Punathil --- src/crypto/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/crypto/README.md b/src/crypto/README.md index 3317334cd71d3c..479ac3378ef7d0 100644 --- a/src/crypto/README.md +++ b/src/crypto/README.md @@ -1,4 +1,4 @@ -# Node.js src/crypto Documentation +# Node.js `src/crypto` documentation Welcome. You've found your way to the Node.js native crypto subsystem. @@ -64,7 +64,7 @@ instead.) This section aims to explain some of the utilities that have been provided to make working with the OpenSSL APIs a bit easier. -### Pointer Types +### Pointer types Most of the key OpenSSL types need to be explicitly freed when they are no longer needed. Failure to do so introduces memory leaks. To make this @@ -123,7 +123,7 @@ crypto functions (generated hash values, or ciphertext, for instance). to directly using the `v8::BackingStore` API. This will take some time. New uses of `AllocatedBuffer` should be avoided if possible.* -### Key Objects +### Key objects Most crypto operations involve the use of keys -- cryptographic inputs that protect data. There are three general types of keys: @@ -272,9 +272,9 @@ These can be called from within the C++ code as functions, like `THROW_ERR_CRYPTO_INVALID_IV(env)`. These methods should be used to throw JavaScript errors when necessary. -## Crypto API Patterns +## Crypto API patterns -### Operation Mode +### Operation mode All crypto functions in Node.js operate in one of three modes: From 9e10e1a76f077005b569584c182c694b3d57ac9b Mon Sep 17 00:00:00 2001 From: MrJithil Date: Sat, 1 May 2021 23:44:58 +0530 Subject: [PATCH 07/86] doc: corrected workload name as per the latest VS Installer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/38500 Reviewed-By: Michaël Zasso Reviewed-By: Adrian Estrada Reviewed-By: Rich Trott Reviewed-By: James M Snell --- BUILDING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILDING.md b/BUILDING.md index a84236bc6c84da..07f16f8bdcd3b0 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -563,7 +563,7 @@ to run it again before invoking `make -j4`. * [Python 3.9](https://www.microsoft.com/en-us/p/python-39/9p7qfqmjrfp7) * The "Desktop development with C++" workload from [Visual Studio 2019](https://visualstudio.microsoft.com/downloads/) or - the "Visual C++ build tools" workload from the + the "C++ build tools" workload from the [Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019), with the default optional components * Basic Unix tools required for some tests, From e0118f347ae70ecbc81800f1b8a9eb7bd5206a86 Mon Sep 17 00:00:00 2001 From: Rodolfo Carvalho Date: Tue, 4 May 2021 13:33:07 +0200 Subject: [PATCH 08/86] doc: remove extraneous dash from flag prefix When rendered by `man node`, all flags have a dash prepended to them. Prior to this change, the man page would incorrectly read `---unhandled-rejections=mode` The three dashes is invalid syntax and rejected by the `node` command. PR-URL: https://github.com/nodejs/node/pull/38532 Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott Reviewed-By: Darshan Sen Reviewed-By: James M Snell --- doc/node.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/node.1 b/doc/node.1 index d2d573151f879b..95fd700bc03310 100644 --- a/doc/node.1 +++ b/doc/node.1 @@ -454,7 +454,7 @@ Print stack traces for process warnings (including deprecations). .It Fl -track-heap-objects Track heap object allocations for heap snapshots. . -.It Fl --unhandled-rejections=mode +.It Fl -unhandled-rejections=mode Define the behavior for unhandled rejections. Can be one of `strict` (raise an error), `warn` (enforce warnings) or `none` (silence warnings). . .It Fl -use-bundled-ca , Fl -use-openssl-ca From 03b4a3a5bf022a98c01856e3836cf3285af6d29f Mon Sep 17 00:00:00 2001 From: Darshan Sen Date: Sun, 2 May 2021 19:14:58 +0530 Subject: [PATCH 09/86] build: compile with -std=gnu++14 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The name ‘gnu++1y’ is deprecated. Refs: https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html PR-URL: https://github.com/nodejs/node/pull/38504 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Richard Lau Reviewed-By: Rich Trott --- common.gypi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common.gypi b/common.gypi index e5f01195e63850..0cab2b8fd68591 100644 --- a/common.gypi +++ b/common.gypi @@ -375,7 +375,7 @@ }], [ 'OS in "linux freebsd openbsd solaris android aix cloudabi"', { 'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ], - 'cflags_cc': [ '-fno-rtti', '-fno-exceptions', '-std=gnu++1y' ], + 'cflags_cc': [ '-fno-rtti', '-fno-exceptions', '-std=gnu++14' ], 'defines': [ '__STDC_FORMAT_MACROS' ], 'ldflags': [ '-rdynamic' ], 'target_conditions': [ @@ -519,7 +519,7 @@ ['clang==1', { 'xcode_settings': { 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0', - 'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++1y', # -std=gnu++1y + 'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++14', # -std=gnu++14 'CLANG_CXX_LIBRARY': 'libc++', }, }], From 151488539b6c051e3bffbea4d98594725f55e3fa Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 3 May 2021 10:59:10 +0200 Subject: [PATCH 10/86] tools: make GH Actions workflows work if default branch is not master MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/38516 Reviewed-By: Michaël Zasso Reviewed-By: Rich Trott Reviewed-By: James M Snell Reviewed-By: Darshan Sen Reviewed-By: Mary Marchini --- .github/workflows/build-tarball.yml | 1 + .github/workflows/build-windows.yml | 1 + .github/workflows/commit-queue.yml | 8 +++----- .github/workflows/coverage-linux.yml | 1 + .github/workflows/coverage-windows.yml | 1 + .github/workflows/linters.yml | 1 + .github/workflows/misc.yml | 1 + .github/workflows/notify-force-push.yml | 3 ++- .github/workflows/test-asan.yml | 1 + .github/workflows/test-linux.yml | 1 + .github/workflows/test-macos.yml | 1 + 11 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-tarball.yml b/.github/workflows/build-tarball.yml index 226dc69f0e921b..1f802ca12b56c6 100644 --- a/.github/workflows/build-tarball.yml +++ b/.github/workflows/build-tarball.yml @@ -5,6 +5,7 @@ on: push: branches: - master + - main - v[0-9]+.x-staging - v[0-9]+.x diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index d3e1e4339245af..dea275876eacb3 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -5,6 +5,7 @@ on: push: branches: - master + - main - canary - v[0-9]+.x-staging - v[0-9]+.x diff --git a/.github/workflows/commit-queue.yml b/.github/workflows/commit-queue.yml index 5b36a358c61533..50d729aab55930 100644 --- a/.github/workflows/commit-queue.yml +++ b/.github/workflows/commit-queue.yml @@ -28,7 +28,7 @@ jobs: # See https://github.com/nodejs/node-core-utils/pull/486 fetch-depth: 0 # A personal token is required because pushing with GITHUB_TOKEN will - # prevent commits from running CI after they land on master. It needs + # prevent commits from running CI after they land. It needs # to be set here because `checkout` configures GitHub authentication # for push as well. token: ${{ secrets.GH_USER_TOKEN }} @@ -63,15 +63,13 @@ jobs: owner: ${{ env.OWNER }} repo: ${{ env.REPOSITORY }} # Commit queue is only enabled for the default branch on the repository - # TODO(mmarchini): get the default branch programmatically instead of - # assuming `master` - base_ref: "master" + base_ref: ${{ github.repository.default_branch }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Configure node-core-utils run: | - ncu-config set branch master + ncu-config set branch ${{ github.repository.default_branch }} ncu-config set upstream origin ncu-config set username "${{ secrets.GH_USER_NAME }}" ncu-config set token "${{ secrets.GH_USER_TOKEN }}" diff --git a/.github/workflows/coverage-linux.yml b/.github/workflows/coverage-linux.yml index 75f296230dfd37..62881f63724f1d 100644 --- a/.github/workflows/coverage-linux.yml +++ b/.github/workflows/coverage-linux.yml @@ -10,6 +10,7 @@ on: push: branches: - master + - main paths-ignore: - 'doc/**' - 'deps/**' diff --git a/.github/workflows/coverage-windows.yml b/.github/workflows/coverage-windows.yml index ac809f3f0be4a3..5387688e3c246a 100644 --- a/.github/workflows/coverage-windows.yml +++ b/.github/workflows/coverage-windows.yml @@ -10,6 +10,7 @@ on: push: branches: - master + - main paths-ignore: - 'doc/**' - 'deps/**' diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 1b0f8c868db25f..1fdcd6059bb2ad 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -5,6 +5,7 @@ on: push: branches: - master + - main - v[0-9]+.x-staging - v[0-9]+.x diff --git a/.github/workflows/misc.yml b/.github/workflows/misc.yml index 83c65225f0ac40..6167af045f0543 100644 --- a/.github/workflows/misc.yml +++ b/.github/workflows/misc.yml @@ -5,6 +5,7 @@ on: push: branches: - master + - main - v[0-9]+.x-staging - v[0-9]+.x diff --git a/.github/workflows/notify-force-push.yml b/.github/workflows/notify-force-push.yml index 079141bba2a8d8..e3bdc0353c60fb 100644 --- a/.github/workflows/notify-force-push.yml +++ b/.github/workflows/notify-force-push.yml @@ -2,6 +2,7 @@ on: push: branches: - master + - main name: Notify on Force Push jobs: @@ -17,7 +18,7 @@ jobs: SLACK_ICON: https://github.com/nodejs.png?size=48 SLACK_TITLE: '${{ github.actor }} force-pushed to ${{ github.ref }}' SLACK_MESSAGE: | - A commit was force-pushed to by + A commit was force-pushed to by Before: After: diff --git a/.github/workflows/test-asan.yml b/.github/workflows/test-asan.yml index 9e6192c32a37e9..d6dd1b7b7ec83f 100644 --- a/.github/workflows/test-asan.yml +++ b/.github/workflows/test-asan.yml @@ -4,6 +4,7 @@ on: push: branches: - master + - main - canary - v[0-9]+.x-staging - v[0-9]+.x diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index 41968139816c38..b191deb806ee1a 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -5,6 +5,7 @@ on: push: branches: - master + - main - canary - v[0-9]+.x-staging - v[0-9]+.x diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index 5f516608c267e4..725a3e4a8c9a26 100644 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -7,6 +7,7 @@ on: push: branches: - master + - main - canary - v[0-9]+.x-staging - v[0-9]+.x From 89e1daccf3c61746be3f0d0c15a38fdd45061eae Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Sat, 1 May 2021 18:54:27 -0400 Subject: [PATCH 11/86] test: run message and pseudo-tty tests in parallel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/38502 Reviewed-By: Anna Henningsen Reviewed-By: Michaël Zasso Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: James M Snell --- test/message/testcfg.py | 1 + test/pseudo-tty/testcfg.py | 1 + 2 files changed, 2 insertions(+) diff --git a/test/message/testcfg.py b/test/message/testcfg.py index bd56a8eba8c4ce..4be454b55c9053 100644 --- a/test/message/testcfg.py +++ b/test/message/testcfg.py @@ -43,6 +43,7 @@ def __init__(self, path, file, expected, arch, mode, context, config): self.config = config self.arch = arch self.mode = mode + self.parallel = True def IgnoreLine(self, str): """Ignore empty lines and valgrind output.""" diff --git a/test/pseudo-tty/testcfg.py b/test/pseudo-tty/testcfg.py index ad9461f026366f..df380ad31eff1e 100644 --- a/test/pseudo-tty/testcfg.py +++ b/test/pseudo-tty/testcfg.py @@ -48,6 +48,7 @@ def __init__(self, path, file, expected, input_arg, arch, mode, context, config) self.config = config self.arch = arch self.mode = mode + self.parallel = True def IgnoreLine(self, str_arg): """Ignore empty lines and valgrind output.""" From e9d4c8587a96fb79970e13e78e9433235858b77b Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 4 May 2021 06:29:25 -0700 Subject: [PATCH 12/86] doc: use AIX instead of Aix in fs.md Both for consistency within the doc and to conform with IBM's usage regarding their on product, refer to the operating system as AIX rather than Aix. PR-URL: https://github.com/nodejs/node/pull/38535 Reviewed-By: Gireesh Punathil Reviewed-By: Richard Lau Reviewed-By: Beth Griggs --- doc/api/fs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 11e5b2c39fb785..91a34b0e9c4e3b 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -3628,7 +3628,7 @@ to be notified of filesystem changes. directories. * On SunOS systems (including Solaris and SmartOS), this uses [`event ports`][]. * On Windows systems, this feature depends on [`ReadDirectoryChangesW`][]. -* On Aix systems, this feature depends on [`AHAFS`][], which must be enabled. +* On AIX systems, this feature depends on [`AHAFS`][], which must be enabled. * On IBM i systems, this feature is not supported. If the underlying functionality is not available for some reason, then From e59131d97fc1300379eceb95c3d7962aac0c5b50 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 4 May 2021 06:24:43 -0700 Subject: [PATCH 13/86] doc: fix broken AHAFS link in fs doc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The content we're linking to for AHAFS was published in 2011 but has now been archived. This updates the link to the archived version (as the current version results in a "Yikes!" page with an HTTP 400 response code). Unfortunately, the archived version does say "This content is no longer being updated or maintained. The content is provided “as is.” Given the rapid evolution of technology, some content, steps, or illustrations may have changed." So we'll want to update at some point I imagine. But for the moment, archived content with a notice like that is better than a broken link. PR-URL: https://github.com/nodejs/node/pull/38534 Reviewed-By: Richard Lau Reviewed-By: Ash Cripps Reviewed-By: Beth Griggs Reviewed-By: James M Snell --- doc/api/fs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 91a34b0e9c4e3b..7595c1e314e7cb 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -6672,7 +6672,7 @@ the file contents. [Readable Stream]: stream.md#stream_class_stream_readable [Writable Stream]: stream.md#stream_class_stream_writable [caveats]: #fs_caveats -[`AHAFS`]: https://www.ibm.com/developerworks/aix/library/au-aix_event_infrastructure/ +[`AHAFS`]: https://developer.ibm.com/articles/au-aix_event_infrastructure/ [`Buffer.byteLength`]: buffer.md#buffer_static_method_buffer_bytelength_string_encoding [`FSEvents`]: https://developer.apple.com/documentation/coreservices/file_system_events [`Number.MAX_SAFE_INTEGER`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER From c0f0c9a92d4efc56adb8e9bbef02dab97ab0236b Mon Sep 17 00:00:00 2001 From: Voltrex <62040526+VoltrexMaster@users.noreply.github.com> Date: Fri, 16 Apr 2021 02:31:29 +0430 Subject: [PATCH 14/86] typings: add JSDoc typings for readline Added JSDoc typings for the `readline` lib module. PR-URL: https://github.com/nodejs/node/pull/38253 Reviewed-By: James M Snell Reviewed-By: Rich Trott --- lib/readline.js | 92 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 84 insertions(+), 8 deletions(-) diff --git a/lib/readline.js b/lib/readline.js index 30762bb0bf71a9..b40c8019746120 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -107,6 +107,11 @@ const { StringDecoder } = require('string_decoder'); // Lazy load Readable for startup performance. let Readable; +/** + * @typedef {import('./stream.js').Readable} Readable + * @typedef {import('./stream.js').Writable} Writable + */ + const kHistorySize = 30; const kMincrlfDelay = 100; // \r\n, \n, or \r followed by something other than \n @@ -118,6 +123,27 @@ const kQuestionCancel = Symbol('kQuestionCancel'); // GNU readline library - keyseq-timeout is 500ms (default) const ESCAPE_CODE_TIMEOUT = 500; +/** + * Creates a new `readline.Interface` instance. + * @param {Readable | { + * input: Readable; + * output: Writable; + * completer?: Function; + * terminal?: boolean; + * history?: string[]; + * historySize?: number; + * removeHistoryDuplicates?: boolean; + * prompt?: string; + * crlfDelay?: number; + * escapeCodeTimeout?: number; + * tabSize?: number; + * signal?: AbortSignal; + * }} input + * @param {Writable} [output] + * @param {Function} [completer] + * @param {boolean} [terminal] + * @returns {Interface} + */ function createInterface(input, output, completer, terminal) { return new Interface(input, output, completer, terminal); } @@ -348,11 +374,19 @@ ObjectDefineProperty(Interface.prototype, 'columns', { } }); +/** + * Sets the prompt written to the output. + * @param {string} prompt + * @returns {void} + */ Interface.prototype.setPrompt = function(prompt) { this._prompt = prompt; }; - +/** + * Returns the current prompt used by `rl.prompt()`. + * @returns {string} + */ Interface.prototype.getPrompt = function() { return this._prompt; }; @@ -368,7 +402,11 @@ Interface.prototype._setRawMode = function(mode) { return wasInRawMode; }; - +/** + * Writes the configured `prompt` to a new line in `output`. + * @param {boolean} [preserveCursor] + * @returns {void} + */ Interface.prototype.prompt = function(preserveCursor) { if (this.paused) this.resume(); if (this.terminal && process.env.TERM !== 'dumb') { @@ -379,7 +417,13 @@ Interface.prototype.prompt = function(preserveCursor) { } }; - +/** + * Displays `query` by writing it to the `output`. + * @param {string} query + * @param {{ signal?: AbortSignal; }} [options] + * @param {Function} cb + * @returns {void} + */ Interface.prototype.question = function(query, options, cb) { cb = typeof options === 'function' ? options : cb; options = typeof options === 'object' && options !== null ? options : {}; @@ -528,7 +572,10 @@ Interface.prototype._refreshLine = function() { this.prevRows = cursorPos.rows; }; - +/** + * Closes the `readline.Interface` instance. + * @returns {void} + */ Interface.prototype.close = function() { if (this.closed) return; this.pause(); @@ -539,7 +586,10 @@ Interface.prototype.close = function() { this.emit('close'); }; - +/** + * Pauses the `input` stream. + * @returns {void | Interface} + */ Interface.prototype.pause = function() { if (this.paused) return; this.input.pause(); @@ -548,7 +598,10 @@ Interface.prototype.pause = function() { return this; }; - +/** + * Resumes the `input` stream if paused. + * @returns {void | Interface} + */ Interface.prototype.resume = function() { if (!this.paused) return; this.input.resume(); @@ -557,7 +610,18 @@ Interface.prototype.resume = function() { return this; }; - +/** + * Writes either `data` or a `key` sequence identified by + * `key` to the `output`. + * @param {string} d + * @param {{ + * ctrl?: boolean; + * meta?: boolean; + * shift?: boolean; + * name?: string; + * }} [key] + * @returns {void} + */ Interface.prototype.write = function(d, key) { if (this.paused) this.resume(); if (this.terminal) { @@ -868,7 +932,14 @@ Interface.prototype._getDisplayPos = function(str) { return { cols, rows }; }; -// Returns current cursor's position and line +/** + * Returns the real position of the cursor in relation + * to the input prompt + string. + * @returns {{ + * rows: number; + * cols: number; + * }} + */ Interface.prototype.getCursorPos = function() { const strBeforeCursor = this._prompt + StringPrototypeSlice(this.line, 0, this.cursor); @@ -1197,6 +1268,11 @@ Interface.prototype._ttyWrite = function(s, key) { } }; +/** + * Creates an `AsyncIterator` object that iterates through + * each line in the input stream as a string. + * @returns {Symbol.AsyncIterator} + */ Interface.prototype[SymbolAsyncIterator] = function() { if (this[kLineObjectStream] === undefined) { if (Readable === undefined) { From ae9128ec6190ca6529f693207c682e2bbc31a6d6 Mon Sep 17 00:00:00 2001 From: Nitzan Uziely Date: Thu, 22 Apr 2021 23:28:19 +0300 Subject: [PATCH 15/86] doc: clarify DiffieHellmanGroup class docs Make it clearer in the docs that DiffieHellmanGroup does not support changing the keys after creation. PR-URL: https://github.com/nodejs/node/pull/38363 Reviewed-By: James M Snell Reviewed-By: Adrian Estrada --- doc/api/crypto.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 9b4559473ca7e5..88d617949abdf4 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1114,8 +1114,10 @@ module): added: v0.7.5 --> -The `DiffieHellmanGroup` class takes a well-known modp group as its argument but -otherwise works the same as `DiffieHellman`. +The `DiffieHellmanGroup` class takes a well-known modp group as its argument. +It works the same as `DiffieHellman`, except that it does not allow changing +its keys after creation. In other words, it does not implement `setPublicKey()` +or `setPrivateKey()` methods. ```mjs const { createDiffieHellmanGroup } = await import('crypto'); From 14a2a00cda419b0e9d3ea430cb926d7e506b034b Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Sat, 1 May 2021 11:26:46 -0700 Subject: [PATCH 16/86] node-api: faster threadsafe_function Invoke threadsafe_function during the same tick and avoid marshalling costs between threads and/or churning event loop if either: 1. There's a queued call already 2. `Push()` is called while the main thread was running threadsafe_function PR-URL: https://github.com/nodejs/node/pull/38506 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott Reviewed-By: James M Snell --- src/node_api.cc | 88 ++++++++++++------- .../test_threadsafe_function/binding.c | 4 +- .../node-api/test_threadsafe_function/test.js | 9 ++ 3 files changed, 66 insertions(+), 35 deletions(-) diff --git a/src/node_api.cc b/src/node_api.cc index 8dbf48d466dfe1..4216356cb59593 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -12,6 +12,7 @@ #include "tracing/traced_value.h" #include "util-inl.h" +#include #include struct node_napi_env__ : public napi_env__ { @@ -137,6 +138,7 @@ class ThreadSafeFunction : public node::AsyncResource { *v8::String::Utf8Value(env_->isolate, name)), thread_count(thread_count_), is_closing(false), + dispatch_state(kDispatchIdle), context(context_), max_queue_size(max_queue_size_), env(env_), @@ -176,10 +178,8 @@ class ThreadSafeFunction : public node::AsyncResource { return napi_closing; } } else { - if (uv_async_send(&async) != 0) { - return napi_generic_failure; - } queue.push(data); + Send(); return napi_ok; } } @@ -211,9 +211,7 @@ class ThreadSafeFunction : public node::AsyncResource { if (is_closing && max_queue_size > 0) { cond->Signal(lock); } - if (uv_async_send(&async) != 0) { - return napi_generic_failure; - } + Send(); } } @@ -238,7 +236,6 @@ class ThreadSafeFunction : public node::AsyncResource { cond = std::make_unique(); } if (max_queue_size == 0 || cond) { - CHECK_EQ(0, uv_idle_init(loop, &idle)); return napi_ok; } @@ -263,21 +260,46 @@ class ThreadSafeFunction : public node::AsyncResource { napi_status Unref() { uv_unref(reinterpret_cast(&async)); - uv_unref(reinterpret_cast(&idle)); return napi_ok; } napi_status Ref() { uv_ref(reinterpret_cast(&async)); - uv_ref(reinterpret_cast(&idle)); return napi_ok; } - void DispatchOne() { + inline void* Context() { + return context; + } + + protected: + void Dispatch() { + bool has_more = true; + + // Limit maximum synchronous iteration count to prevent event loop + // starvation. See `src/node_messaging.cc` for an inspiration. + unsigned int iterations_left = kMaxIterationCount; + while (has_more && --iterations_left != 0) { + dispatch_state = kDispatchRunning; + has_more = DispatchOne(); + + // Send() was called while we were executing the JS function + if (dispatch_state.exchange(kDispatchIdle) != kDispatchRunning) { + has_more = true; + } + } + + if (has_more) { + Send(); + } + } + + bool DispatchOne() { void* data = nullptr; bool popped_value = false; + bool has_more = false; { node::Mutex::ScopedLock lock(this->mutex); @@ -302,9 +324,9 @@ class ThreadSafeFunction : public node::AsyncResource { cond->Signal(lock); } CloseHandlesAndMaybeDelete(); - } else { - CHECK_EQ(0, uv_idle_stop(&idle)); } + } else { + has_more = true; } } } @@ -322,6 +344,8 @@ class ThreadSafeFunction : public node::AsyncResource { call_js_cb(env, js_callback, context, data); }); } + + return has_more; } void Finalize() { @@ -335,10 +359,6 @@ class ThreadSafeFunction : public node::AsyncResource { EmptyQueueAndDelete(); } - inline void* Context() { - return context; - } - void CloseHandlesAndMaybeDelete(bool set_closing = false) { v8::HandleScope scope(env->isolate); if (set_closing) { @@ -358,18 +378,20 @@ class ThreadSafeFunction : public node::AsyncResource { ThreadSafeFunction* ts_fn = node::ContainerOf(&ThreadSafeFunction::async, reinterpret_cast(handle)); - v8::HandleScope scope(ts_fn->env->isolate); - ts_fn->env->node_env()->CloseHandle( - reinterpret_cast(&ts_fn->idle), - [](uv_handle_t* handle) -> void { - ThreadSafeFunction* ts_fn = - node::ContainerOf(&ThreadSafeFunction::idle, - reinterpret_cast(handle)); - ts_fn->Finalize(); - }); + ts_fn->Finalize(); }); } + void Send() { + // Ask currently running Dispatch() to make one more iteration + unsigned char current_state = dispatch_state.fetch_or(kDispatchPending); + if ((current_state & kDispatchRunning) == kDispatchRunning) { + return; + } + + CHECK_EQ(0, uv_async_send(&async)); + } + // Default way of calling into JavaScript. Used when ThreadSafeFunction is // without a call_js_cb_. static void CallJs(napi_env env, napi_value cb, void* context, void* data) { @@ -393,16 +415,10 @@ class ThreadSafeFunction : public node::AsyncResource { } } - static void IdleCb(uv_idle_t* idle) { - ThreadSafeFunction* ts_fn = - node::ContainerOf(&ThreadSafeFunction::idle, idle); - ts_fn->DispatchOne(); - } - static void AsyncCb(uv_async_t* async) { ThreadSafeFunction* ts_fn = node::ContainerOf(&ThreadSafeFunction::async, async); - CHECK_EQ(0, uv_idle_start(&ts_fn->idle, IdleCb)); + ts_fn->Dispatch(); } static void Cleanup(void* data) { @@ -411,14 +427,20 @@ class ThreadSafeFunction : public node::AsyncResource { } private: + static const unsigned char kDispatchIdle = 0; + static const unsigned char kDispatchRunning = 1 << 0; + static const unsigned char kDispatchPending = 1 << 1; + + static const unsigned int kMaxIterationCount = 1000; + // These are variables protected by the mutex. node::Mutex mutex; std::unique_ptr cond; std::queue queue; uv_async_t async; - uv_idle_t idle; size_t thread_count; bool is_closing; + std::atomic_uchar dispatch_state; // These are variables set once, upon creation, and then never again, which // means we don't need the mutex to read them. diff --git a/test/node-api/test_threadsafe_function/binding.c b/test/node-api/test_threadsafe_function/binding.c index 7e586aaba61c56..d64b9058b11326 100644 --- a/test/node-api/test_threadsafe_function/binding.c +++ b/test/node-api/test_threadsafe_function/binding.c @@ -7,7 +7,7 @@ #include #include "../../js-native-api/common.h" -#define ARRAY_LENGTH 10 +#define ARRAY_LENGTH 10000 #define MAX_QUEUE_SIZE 2 static uv_thread_t uv_threads[2]; @@ -72,7 +72,7 @@ static void data_source_thread(void* data) { for (index = ARRAY_LENGTH - 1; index > -1 && !queue_was_closing; index--) { status = napi_call_threadsafe_function(ts_fn, &ints[index], ts_fn_info->block_on_full); - if (ts_fn_info->max_queue_size == 0) { + if (ts_fn_info->max_queue_size == 0 && (index % 1000 == 0)) { // Let's make this thread really busy for 200 ms to give the main thread a // chance to abort. uint64_t start = uv_hrtime(); diff --git a/test/node-api/test_threadsafe_function/test.js b/test/node-api/test_threadsafe_function/test.js index 01542e4edb97e6..ff8a7d80849079 100644 --- a/test/node-api/test_threadsafe_function/test.js +++ b/test/node-api/test_threadsafe_function/test.js @@ -211,6 +211,15 @@ new Promise(function testWithoutJSMarshaller(resolve) { })) .then((result) => assert.strictEqual(result.indexOf(0), -1)) +// Make sure that threadsafe function isn't stalled when we hit +// `kMaxIterationCount` in `src/node_api.cc` +.then(() => testWithJSMarshaller({ + threadStarter: 'StartThreadNonblocking', + maxQueueSize: binding.ARRAY_LENGTH >>> 1, + quitAfter: binding.ARRAY_LENGTH +})) +.then((result) => assert.deepStrictEqual(result, expectedArray)) + // Start a child process to test rapid teardown .then(() => testUnref(binding.MAX_QUEUE_SIZE)) From 662265074c2d46273d637c179dd8e1b46919d9bd Mon Sep 17 00:00:00 2001 From: ZiJian Liu Date: Mon, 3 May 2021 16:51:43 +0800 Subject: [PATCH 17/86] test: increase coverage for Blob Refs: https://coverage.nodejs.org/coverage-68e6673224365120/lib/internal/blob.js.html#L132 PR-URL: https://github.com/nodejs/node/pull/38515 Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: James M Snell Reviewed-By: Darshan Sen --- test/parallel/test-blob.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/parallel/test-blob.js b/test/parallel/test-blob.js index 359ce3ba214412..6c880e9dea1c84 100644 --- a/test/parallel/test-blob.js +++ b/test/parallel/test-blob.js @@ -3,6 +3,7 @@ const common = require('../common'); const assert = require('assert'); const { Blob } = require('buffer'); +const { inspect } = require('util'); { const b = new Blob(); @@ -190,3 +191,10 @@ assert.throws(() => new Blob({}), { assert.strictEqual(text, 'test42'); })); } + +{ + const b = new Blob(); + assert.strictEqual(inspect(b, { depth: null }), + 'Blob { size: 0, type: \'\' }'); + assert.strictEqual(inspect(b, { depth: -1 }), '[Blob]'); +} From 5b44107ae95f33fb026404ade48a900feb7f8f37 Mon Sep 17 00:00:00 2001 From: ZiJian Liu Date: Mon, 3 May 2021 14:48:16 +0800 Subject: [PATCH 18/86] test: increase coverage for AbortController MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: https://coverage.nodejs.org/coverage-68e6673224365120/lib/internal/abort_controller.js.html#L126 PR-URL: https://github.com/nodejs/node/pull/38514 Reviewed-By: Antoine du Hamel Reviewed-By: Michaël Zasso Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: James M Snell Reviewed-By: Darshan Sen --- test/parallel/test-abortcontroller.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/parallel/test-abortcontroller.js b/test/parallel/test-abortcontroller.js index 2f4fb495c75590..f7a70fbddbc89e 100644 --- a/test/parallel/test-abortcontroller.js +++ b/test/parallel/test-abortcontroller.js @@ -2,6 +2,7 @@ 'use strict'; const common = require('../common'); +const { inspect } = require('util'); const { ok, strictEqual, throws } = require('assert'); @@ -132,3 +133,11 @@ const { ok, strictEqual, throws } = require('assert'); ); } } + +{ + const ac = new AbortController(); + strictEqual(inspect(ac, { depth: 1 }), + 'AbortController { signal: [AbortSignal] }'); + strictEqual(inspect(ac, { depth: null }), + 'AbortController { signal: AbortSignal { aborted: false } }'); +} From f2f768f261512822ad60b2131f70834c71d017a4 Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Mon, 3 May 2021 23:01:43 +0800 Subject: [PATCH 19/86] test: complete coverage of querystring PR-URL: https://github.com/nodejs/node/pull/38520 Refs: https://coverage.nodejs.org/coverage-68e6673224365120/lib/querystring.js.html#L179 Reviewed-By: Rich Trott Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Zijian Liu Reviewed-By: Darshan Sen --- test/parallel/test-querystring.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/parallel/test-querystring.js b/test/parallel/test-querystring.js index 105bcc56a9878e..eda94bf8df9164 100644 --- a/test/parallel/test-querystring.js +++ b/test/parallel/test-querystring.js @@ -307,6 +307,7 @@ assert.strictEqual(qs.stringify({ foo: -0 }), 'foo=0'); assert.strictEqual(qs.stringify({ foo: 3 }), 'foo=3'); assert.strictEqual(qs.stringify({ foo: -72.42 }), 'foo=-72.42'); assert.strictEqual(qs.stringify({ foo: NaN }), 'foo='); +assert.strictEqual(qs.stringify({ foo: 1e21 }), 'foo=1e%2B21'); assert.strictEqual(qs.stringify({ foo: Infinity }), 'foo='); // nested @@ -450,6 +451,14 @@ check(qs.parse('%\u0100=%\u0101'), { '%Ā': '%ā' }); 'a=a&b=b&c=c'); } +// Test custom encode for different types +{ + const obj = { number: 1, bigint: 2n, true: true, false: false, object: {} }; + assert.strictEqual( + qs.stringify(obj, null, null, { encodeURIComponent: (v) => v }), + 'number=1&bigint=2&true=true&false=false&object='); +} + // Test QueryString.unescapeBuffer qsUnescapeTestCases.forEach((testCase) => { assert.strictEqual(qs.unescape(testCase[0]), testCase[1]); From 4c70e42928d40b2a1726186f99e9c3ae50115c26 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 3 May 2021 11:15:35 +0200 Subject: [PATCH 20/86] doc: use `HEAD` instead of `master` for links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/38518 Reviewed-By: Michaël Zasso Reviewed-By: Rich Trott Reviewed-By: James M Snell Reviewed-By: Darshan Sen --- .github/PULL_REQUEST_TEMPLATE.md | 4 ++-- BUILDING.md | 4 ++-- GOVERNANCE.md | 2 +- README.md | 8 ++++---- SECURITY.md | 2 +- benchmark/_http-benchmarkers.js | 2 +- doc/node.1 | 4 ++-- glossary.md | 2 +- lib/internal/crypto/util.js | 2 +- lib/internal/freeze_intrinsics.js | 4 ++-- lib/internal/util/inspect.js | 2 +- lib/internal/util/iterable_weak_map.js | 2 +- src/node_version.h | 2 +- test/cctest/gtest/gtest-all.cc | 4 ++-- test/common/wpt.js | 2 +- tools/bootstrap/windows_boxstarter | 6 +++--- tools/doc/versions.js | 2 +- tools/inspector_protocol/lib/encoding_cpp.template | 2 +- tools/license-builder.sh | 2 +- vcbuild.bat | 2 +- 20 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 56632fda4c67eb..f99a8abb394d14 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,9 +1,9 @@ There was an attempt to use a `MessagePort` instance in a closed state, usually after `.close()` has been called. @@ -2466,16 +2476,6 @@ removed: v12.5.0 The value passed to `postMessage()` contained an object that is not supported for transferring. - -### `ERR_CLOSED_MESSAGE_PORT` - - -There was an attempt to use a `MessagePort` instance in a closed -state, usually after `.close()` has been called. - ### `ERR_CRYPTO_HASH_DIGEST_NO_UTF16` > Stability: 1 - Experimental diff --git a/lib/internal/modules/esm/loader.js b/lib/internal/modules/esm/loader.js index 8b2c89ba130aa7..de9863ed71ce8a 100644 --- a/lib/internal/modules/esm/loader.js +++ b/lib/internal/modules/esm/loader.js @@ -13,6 +13,7 @@ const { } = primordials; const { + ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_VALUE, ERR_INVALID_MODULE_SPECIFIER, ERR_INVALID_RETURN_PROPERTY, @@ -20,8 +21,7 @@ const { ERR_INVALID_RETURN_VALUE, ERR_UNKNOWN_MODULE_FORMAT } = require('internal/errors').codes; -const { URL, pathToFileURL } = require('internal/url'); -const { validateString } = require('internal/validators'); +const { URL, pathToFileURL, isURLInstance } = require('internal/url'); const ModuleMap = require('internal/modules/esm/module_map'); const ModuleJob = require('internal/modules/esm/module_job'); @@ -83,8 +83,8 @@ class Loader { async resolve(specifier, parentURL) { const isMain = parentURL === undefined; - if (!isMain) - validateString(parentURL, 'parentURL'); + if (!isMain && typeof parentURL !== 'string' && !isURLInstance(parentURL)) + throw new ERR_INVALID_ARG_TYPE('parentURL', ['string', 'URL'], parentURL); const resolveResponse = await this._resolve( specifier, { parentURL, conditions: DEFAULT_CONDITIONS }, defaultResolve); diff --git a/test/es-module/test-esm-import-meta-resolve.mjs b/test/es-module/test-esm-import-meta-resolve.mjs index 911225e13c9d66..1fac362172ae34 100644 --- a/test/es-module/test-esm-import-meta-resolve.mjs +++ b/test/es-module/test-esm-import-meta-resolve.mjs @@ -19,6 +19,19 @@ const fixtures = dirname.slice(0, dirname.lastIndexOf('/', dirname.length - 2) + await import.meta.resolve('../fixtures/empty-with-bom.txt'), fixtures + 'empty-with-bom.txt'); assert.strictEqual(await import.meta.resolve('../fixtures/'), fixtures); + assert.strictEqual( + await import.meta.resolve('../fixtures/', import.meta.url), + fixtures); + assert.strictEqual( + await import.meta.resolve('../fixtures/', new URL(import.meta.url)), + fixtures); + await Promise.all( + [[], {}, Symbol(), 0, 1, 1n, 1.1, () => {}, true, false].map((arg) => + assert.rejects(import.meta.resolve('../fixtures/', arg), { + code: 'ERR_INVALID_ARG_TYPE', + }) + ) + ); assert.strictEqual(await import.meta.resolve('baz/', fixtures), fixtures + 'node_modules/baz/'); })().then(mustCall()); From b0df28dea58433231ddcec7b87eb46b009fa327e Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Tue, 11 May 2021 06:03:37 -0400 Subject: [PATCH 53/86] build: add workaround for V8 builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit V8's build toolchain is not compatible with Python 3 and the CI job that tests V8 needs to be run with Python 2. Add a fallback to `find_executable` from `distutils.spawn` to allow the configure script to run in the V8 test job. PR-URL: https://github.com/nodejs/node/pull/38632 Reviewed-By: Michaël Zasso Reviewed-By: Darshan Sen Reviewed-By: James M Snell Reviewed-By: Rich Trott --- configure.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/configure.py b/configure.py index b877319841e1e2..9ec7da8924b132 100755 --- a/configure.py +++ b/configure.py @@ -14,7 +14,12 @@ import bz2 import io -from shutil import which +# Fallback to find_executable from distutils.spawn is a stopgap for +# supporting V8 builds, which do not yet support Python 3. +try: + from shutil import which +except ImportError: + from distutils.spawn import find_executable as which from distutils.version import StrictVersion # If not run from node/, cd to node/. From be4b3a4164d95045ae30a8b4bb3d0b6330680b85 Mon Sep 17 00:00:00 2001 From: Voltrex <62040526+VoltrexMaster@users.noreply.github.com> Date: Mon, 10 May 2021 01:24:43 +0430 Subject: [PATCH 54/86] path: inline conditions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This condition can be inlined in the first `if` statement since if the `path`'s length is 0, it'll be a empty string so we can return that as there's no need for an extra `if` statement. PR-URL: https://github.com/nodejs/node/pull/38613 Reviewed-By: James M Snell Reviewed-By: Michaël Zasso Reviewed-By: Richard Lau Reviewed-By: Darshan Sen Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott --- lib/path.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/path.js b/lib/path.js index f3e5a3b3416c4b..21bed936cadf70 100644 --- a/lib/path.js +++ b/lib/path.js @@ -617,13 +617,9 @@ const win32 = { */ toNamespacedPath(path) { // Note: this will *probably* throw somewhere. - if (typeof path !== 'string') + if (typeof path !== 'string' || path.length === 0) return path; - if (path.length === 0) { - return ''; - } - const resolvedPath = win32.resolve(path); if (resolvedPath.length <= 2) From 5c71f49d3f9edd458f9a408b95dd253a6f25d364 Mon Sep 17 00:00:00 2001 From: Ruy Adorno Date: Mon, 10 May 2021 17:31:02 -0400 Subject: [PATCH 55/86] deps: upgrade npm to 7.12.1 PR-URL: https://github.com/nodejs/node/pull/38628 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil Reviewed-By: Rich Trott Reviewed-By: Trivikram Kamat Reviewed-By: Myles Borins --- deps/npm/AUTHORS | 4 + deps/npm/CHANGELOG.md | 94 ++++++- deps/npm/CONTRIBUTING.md | 2 +- deps/npm/docs/content/commands/npm-cache.md | 10 +- deps/npm/docs/content/commands/npm-ci.md | 2 +- deps/npm/docs/content/commands/npm-dedupe.md | 8 +- .../docs/content/commands/npm-deprecate.md | 4 +- deps/npm/docs/content/commands/npm-explore.md | 1 - .../docs/content/commands/npm-find-dupes.md | 8 +- deps/npm/docs/content/commands/npm-install.md | 1 - .../docs/content/commands/npm-unpublish.md | 4 +- deps/npm/docs/content/commands/npm-view.md | 2 +- deps/npm/docs/content/commands/npm.md | 2 +- .../docs/content/configuring-npm/folders.md | 2 +- .../content/configuring-npm/package-json.md | 2 +- deps/npm/docs/content/using-npm/config.md | 5 +- deps/npm/docs/content/using-npm/scripts.md | 7 +- deps/npm/docs/output/commands/npm-cache.html | 10 +- deps/npm/docs/output/commands/npm-ci.html | 2 +- deps/npm/docs/output/commands/npm-dedupe.html | 8 +- .../docs/output/commands/npm-deprecate.html | 4 +- .../npm/docs/output/commands/npm-explore.html | 1 - .../docs/output/commands/npm-find-dupes.html | 8 +- .../npm/docs/output/commands/npm-install.html | 1 - deps/npm/docs/output/commands/npm-ls.html | 2 +- .../docs/output/commands/npm-unpublish.html | 4 +- deps/npm/docs/output/commands/npm-view.html | 2 +- deps/npm/docs/output/commands/npm.html | 4 +- .../docs/output/configuring-npm/folders.html | 2 +- .../output/configuring-npm/package-json.html | 2 +- deps/npm/docs/output/using-npm/config.html | 5 +- deps/npm/docs/output/using-npm/scripts.html | 9 +- deps/npm/lib/cache.js | 40 ++- deps/npm/lib/config.js | 4 +- deps/npm/lib/help.js | 2 +- deps/npm/lib/ls.js | 2 +- deps/npm/lib/outdated.js | 4 +- .../lib/utils/completion/installed-deep.js | 2 +- deps/npm/lib/utils/config/definitions.js | 7 + deps/npm/lib/utils/config/describe-all.js | 2 +- deps/npm/lib/utils/npm-usage.js | 2 +- deps/npm/lib/utils/tar.js | 4 +- deps/npm/lib/view.js | 5 +- deps/npm/man/man1/npm-access.1 | 2 +- deps/npm/man/man1/npm-adduser.1 | 2 +- deps/npm/man/man1/npm-audit.1 | 2 +- deps/npm/man/man1/npm-bin.1 | 2 +- deps/npm/man/man1/npm-bugs.1 | 2 +- deps/npm/man/man1/npm-cache.1 | 12 +- deps/npm/man/man1/npm-ci.1 | 4 +- deps/npm/man/man1/npm-completion.1 | 2 +- deps/npm/man/man1/npm-config.1 | 2 +- deps/npm/man/man1/npm-dedupe.1 | 10 +- deps/npm/man/man1/npm-deprecate.1 | 6 +- deps/npm/man/man1/npm-diff.1 | 2 +- deps/npm/man/man1/npm-dist-tag.1 | 2 +- deps/npm/man/man1/npm-docs.1 | 2 +- deps/npm/man/man1/npm-doctor.1 | 2 +- deps/npm/man/man1/npm-edit.1 | 2 +- deps/npm/man/man1/npm-exec.1 | 2 +- deps/npm/man/man1/npm-explain.1 | 2 +- deps/npm/man/man1/npm-explore.1 | 4 +- deps/npm/man/man1/npm-find-dupes.1 | 10 +- deps/npm/man/man1/npm-fund.1 | 2 +- deps/npm/man/man1/npm-help-search.1 | 2 +- deps/npm/man/man1/npm-help.1 | 2 +- deps/npm/man/man1/npm-hook.1 | 2 +- deps/npm/man/man1/npm-init.1 | 2 +- deps/npm/man/man1/npm-install-ci-test.1 | 2 +- deps/npm/man/man1/npm-install-test.1 | 2 +- deps/npm/man/man1/npm-install.1 | 4 +- deps/npm/man/man1/npm-link.1 | 2 +- deps/npm/man/man1/npm-logout.1 | 2 +- deps/npm/man/man1/npm-ls.1 | 4 +- deps/npm/man/man1/npm-org.1 | 2 +- deps/npm/man/man1/npm-outdated.1 | 2 +- deps/npm/man/man1/npm-owner.1 | 2 +- deps/npm/man/man1/npm-pack.1 | 2 +- deps/npm/man/man1/npm-ping.1 | 2 +- deps/npm/man/man1/npm-prefix.1 | 2 +- deps/npm/man/man1/npm-profile.1 | 2 +- deps/npm/man/man1/npm-prune.1 | 2 +- deps/npm/man/man1/npm-publish.1 | 2 +- deps/npm/man/man1/npm-rebuild.1 | 2 +- deps/npm/man/man1/npm-repo.1 | 2 +- deps/npm/man/man1/npm-restart.1 | 2 +- deps/npm/man/man1/npm-root.1 | 2 +- deps/npm/man/man1/npm-run-script.1 | 2 +- deps/npm/man/man1/npm-search.1 | 2 +- deps/npm/man/man1/npm-set-script.1 | 2 +- deps/npm/man/man1/npm-shrinkwrap.1 | 2 +- deps/npm/man/man1/npm-star.1 | 2 +- deps/npm/man/man1/npm-stars.1 | 2 +- deps/npm/man/man1/npm-start.1 | 2 +- deps/npm/man/man1/npm-stop.1 | 2 +- deps/npm/man/man1/npm-team.1 | 2 +- deps/npm/man/man1/npm-test.1 | 2 +- deps/npm/man/man1/npm-token.1 | 2 +- deps/npm/man/man1/npm-uninstall.1 | 2 +- deps/npm/man/man1/npm-unpublish.1 | 2 +- deps/npm/man/man1/npm-unstar.1 | 2 +- deps/npm/man/man1/npm-update.1 | 2 +- deps/npm/man/man1/npm-version.1 | 2 +- deps/npm/man/man1/npm-view.1 | 2 +- deps/npm/man/man1/npm-whoami.1 | 2 +- deps/npm/man/man1/npm.1 | 4 +- deps/npm/man/man1/npx.1 | 2 +- deps/npm/man/man5/folders.5 | 2 +- deps/npm/man/man5/install.5 | 2 +- deps/npm/man/man5/npm-shrinkwrap-json.5 | 2 +- deps/npm/man/man5/npmrc.5 | 2 +- deps/npm/man/man5/package-json.5 | 4 +- deps/npm/man/man5/package-lock-json.5 | 2 +- deps/npm/man/man7/config.7 | 8 +- deps/npm/man/man7/developers.7 | 2 +- deps/npm/man/man7/orgs.7 | 2 +- deps/npm/man/man7/registry.7 | 2 +- deps/npm/man/man7/removal.7 | 2 +- deps/npm/man/man7/scope.7 | 2 +- deps/npm/man/man7/scripts.7 | 9 +- deps/npm/man/man7/workspaces.7 | 2 +- .../@npmcli/arborist/CHANGELOG.md | 19 -- .../@npmcli/arborist/bin/license.js | 2 +- .../@npmcli/arborist/lib/add-rm-pkg-deps.js | 168 +++++------ .../arborist/lib/arborist/build-ideal-tree.js | 7 +- .../@npmcli/arborist/lib/arborist/index.js | 3 + .../arborist/lib/arborist/load-virtual.js | 4 +- .../@npmcli/arborist/lib/arborist/rebuild.js | 2 +- .../@npmcli/arborist/lib/arborist/reify.js | 74 +++-- .../@npmcli/arborist/lib/audit-report.js | 21 +- .../@npmcli/arborist/lib/dep-spec.js | 43 --- .../@npmcli/arborist/lib/inventory.js | 2 +- .../node_modules/@npmcli/arborist/lib/node.js | 45 +-- .../@npmcli/arborist/lib/printable.js | 12 +- .../@npmcli/arborist/lib/shrinkwrap.js | 12 +- .../arborist/lib/update-root-package-json.js | 16 +- .../node_modules/@npmcli/arborist/lib/vuln.js | 9 +- .../@npmcli/arborist/lib/yarn-lock.js | 12 +- .../@npmcli/arborist/package.json | 13 +- .../npm/node_modules/@npmcli/git/lib/clone.js | 2 +- .../npm/node_modules/@npmcli/git/lib/spawn.js | 11 +- .../npm/node_modules/@npmcli/git/package.json | 4 +- deps/npm/node_modules/glob/README.md | 2 +- deps/npm/node_modules/glob/common.js | 10 +- deps/npm/node_modules/glob/glob.js | 2 - deps/npm/node_modules/glob/package.json | 11 +- deps/npm/node_modules/glob/sync.js | 2 - deps/npm/node_modules/ignore-walk/index.js | 2 +- .../npm/node_modules/ignore-walk/package.json | 7 +- .../node_modules/json-stringify-nice/index.js | 2 +- .../json-stringify-nice/package.json | 17 +- deps/npm/node_modules/libnpmexec/CHANGELOG.md | 7 - deps/npm/node_modules/libnpmexec/README.md | 2 +- .../libnpmexec/lib/cache-install-dir.js | 2 +- .../libnpmexec/lib/file-exists.js | 29 ++ deps/npm/node_modules/libnpmexec/lib/index.js | 18 +- deps/npm/node_modules/libnpmexec/package.json | 7 +- .../node_modules/npm-packlist/bin/index.js | 5 +- deps/npm/node_modules/npm-packlist/index.js | 47 ++-- .../node_modules/npm-packlist/package.json | 21 +- deps/npm/package.json | 17 +- .../tap-snapshots/test/lib/config.js.test.cjs | 12 + .../npm/tap-snapshots/test/lib/ls.js.test.cjs | 164 +++++------ .../test/lib/outdated.js.test.cjs | 100 +++---- .../lib/utils/config/describe-all.js.test.cjs | 5 +- .../test/lib/utils/tar.js.test.cjs | 15 +- .../tap-snapshots/test/lib/view.js.test.cjs | 46 ++- deps/npm/test/fixtures/mock-npm.js | 8 +- deps/npm/test/lib/cache.js | 11 +- deps/npm/test/lib/config.js | 6 + deps/npm/test/lib/dist-tag.js | 9 +- deps/npm/test/lib/exec.js | 28 +- deps/npm/test/lib/link.js | 2 +- deps/npm/test/lib/load-all-commands.js | 2 +- deps/npm/test/lib/ls.js | 262 +++++++++--------- deps/npm/test/lib/outdated.js | 64 ++--- deps/npm/test/lib/utils/cleanup-log-files.js | 2 +- .../lib/utils/completion/installed-deep.js | 19 +- deps/npm/test/lib/utils/config/definitions.js | 19 +- deps/npm/test/lib/utils/tar.js | 3 + deps/npm/test/lib/utils/update-notifier.js | 8 +- deps/npm/test/lib/view.js | 48 ++-- 182 files changed, 1141 insertions(+), 890 deletions(-) delete mode 100644 deps/npm/node_modules/@npmcli/arborist/CHANGELOG.md delete mode 100644 deps/npm/node_modules/@npmcli/arborist/lib/dep-spec.js delete mode 100644 deps/npm/node_modules/libnpmexec/CHANGELOG.md create mode 100644 deps/npm/node_modules/libnpmexec/lib/file-exists.js diff --git a/deps/npm/AUTHORS b/deps/npm/AUTHORS index 2b3e48e7651636..3186985b8e3cbd 100644 --- a/deps/npm/AUTHORS +++ b/deps/npm/AUTHORS @@ -772,3 +772,7 @@ Seth Thomas Andreas Felipe Santos Luigi Pinca +Marco Sirabella +wangsai +Luke Hefson +mrmlnc diff --git a/deps/npm/CHANGELOG.md b/deps/npm/CHANGELOG.md index ce79e9368a6e58..bed0f87c2b80c9 100644 --- a/deps/npm/CHANGELOG.md +++ b/deps/npm/CHANGELOG.md @@ -1,3 +1,94 @@ +## v7.12.1 (2021-05-10) + +### BUG FIXES + +* [`de49f58f5`](https://github.com/npm/cli/commit/de49f58f55dc2ac3a5057cd492a43c32ae41381e) + [#3216](https://github.com/npm/cli/issues/3216) + fix(contributing): link to proper cli repo + ([@mrmlnc](https://github.com/mrmlnc)) +* [`1d092144e`](https://github.com/npm/cli/commit/1d092144eaaabff63ac8424b40b2286822be7677) + [#3203](https://github.com/npm/cli/issues/3203) + fix(packages): locale-agnostic string sorting + ([@isaacs](https://github.com/isaacs)) +* [`0696fca13`](https://github.com/npm/cli/commit/0696fca13d10726e04ca97ff50eef7bd7455a3ab) + [#3209](https://github.com/npm/cli/issues/3209) + fix(view): fix non-registry specs + ([@wraithgar](https://github.com/wraithgar)) +* [`71ac93597`](https://github.com/npm/cli/commit/71ac935976390e4fd05987ff510049f82bc6e2a9) + [#3206](https://github.com/npm/cli/issues/3206) + chore(github): Convert md issue template to yaml + ([@lukehefson](https://github.com/lukehefson)) +* [`6fb386d3b`](https://github.com/npm/cli/commit/6fb386d3bfbaa8e4771ff87a08de1f3aa6f9b34d) + [#3201](https://github.com/npm/cli/issues/3201) + fix(tests): increase test fuzziness + ([@wraithgar](https://github.com/wraithgar)) +* [`f3a662fcd`](https://github.com/npm/cli/commit/f3a662fcd869653f9753aef3d40cc96ed28ed509) + [#3211](https://github.com/npm/cli/issues/3211) + fix(tests): use config defaults + ([@wraithgar](https://github.com/wraithgar)) + +### DEPENDENCIES + +* [`285976fd1`](https://github.com/npm/cli/commit/285976fd12f037f59da47307d98df7ebda5278d9) + `@npmcli/arborist@2.4.4` + * fix(reify): properly save spec if prerelease +* [`f9f24d17c`](https://github.com/npm/cli/commit/f9f24d17c29c421de3c9b82c6b98a40268aeb920) + `libnpmexec@1.1.1` + * fix(add): Specify 'en' locale to String.localeCompare +* [`cb9f17499`](https://github.com/npm/cli/commit/cb9f174996dbb4779a1be82890564f9abffb11f4) + `glob@7.1.7` + * force 'en' locale in string sorting +* [`24b4e4a41`](https://github.com/npm/cli/commit/24b4e4a41b451db3de381fac6b719149db14c288) + `ignore-walk@3.0.4` + * Avoid locale-specific sorting issues +* [`1eb7e5c7d`](https://github.com/npm/cli/commit/1eb7e5c7d466293b472c2506c64e5a89ec84ac2f) + `@npmcli/arborist@2.4.3` + * guard against locale-specific sorting +* [`a6a826067`](https://github.com/npm/cli/commit/a6a826067cb46c711521772c2d0158257d54400a) + `npm-packlist@2.2.2`: + * fix(sort): avoid locale-dependent sorting issues + +## v7.12.0 (2021-05-06) + +### FEATURES + +* [`701627c51`](https://github.com/npm/cli/commit/701627c5169934e59da2959d76a49c77278cc9dc) + [#3098](https://github.com/npm/cli/issues/3098) + feat(cache): Allow `add` to accept multiple specs + ([@mjsir911](https://github.com/mjsir911)) +* [`59171f030`](https://github.com/npm/cli/commit/59171f0304f048a009f1697eec6f74f778bc52ff) + [#3187](https://github.com/npm/cli/issues/3187) + feat(config): add workspaces boolean to user-agent + ([@nlf](https://github.com/nlf)) + +### BUG FIXES + +* [`2c9b8713c`](https://github.com/npm/cli/commit/2c9b8713c4c88fbd0c3c48eb0de84dbd7269398f) + [#3182](https://github.com/npm/cli/issues/3182) + fix(docs): fix broken links + ([@wangsai](https://github.com/wangsai)) +* [`88cbc8c44`](https://github.com/npm/cli/commit/88cbc8c447cbaef20b5a8f19246211ce4918f4d8) + [#3198](https://github.com/npm/cli/issues/3198) + fix(tests): reflect new libnpmexec logic + +### DEPENDENCIES + +* [`d01ce5e13`](https://github.com/npm/cli/commit/d01ce5e132cb4661698012fd5017753c2bdb660b) + `libnpmexec@1.1.0`: + * feat: add walk up dir lookup to satisfy local bins +* [`81c1dfaaa`](https://github.com/npm/cli/commit/81c1dfaaaf918229316a975aa8075769ffafdb6d) + `@npmcli/arborist@2.4.2`: + * fix(add): save packages in the right place + * fix(reify): do not clean up nodes with no parent + * fix(audit): support alias specs & root package names +* [`87c2303ea`](https://github.com/npm/cli/commit/87c2303eaa6edfa5309da0a30f5ad291b6d57640) + `@npmcli/git@2.0.9`: + * fix(clone): Do not allow git replacement objects by default +* [`99ff40dff`](https://github.com/npm/cli/commit/99ff40dff5e5e55a5d5f045ba90e76c08174ca38) + `npm-packlist@2.2.0`: + * feat(npmignore): Do not force include history, changelogs, notice + * fix(package.json): add missing bin/index.js to files + ## v7.11.2 (2021-04-29) ### BUG FIXES @@ -76,8 +167,8 @@ [#3126](https://github.com/npm/cli/issues/3126) fix(logout): use isBasicAuth attribute ([@wraithgar](https://github.com/wraithgar)) -### DOCUMENTATION +### DOCUMENTATION * [`c93f1c39e`](https://github.com/npm/cli/commit/c93f1c39e326feff0857712a10ef6183fbafe1ab) [#3101](https://github.com/npm/cli/issues/3101) @@ -89,7 +180,6 @@ fix(usage): fix refs to ws shorthand ([@ruyadorno](https://github.com/ruyadorno)) - ### DEPENDENCIES * [`83166ebcc`](https://github.com/npm/cli/commit/83166ebcc4ba5e3bf215f08151437d96637f4f33) diff --git a/deps/npm/CONTRIBUTING.md b/deps/npm/CONTRIBUTING.md index 6821da895b3b51..558ce2a839b23d 100644 --- a/deps/npm/CONTRIBUTING.md +++ b/deps/npm/CONTRIBUTING.md @@ -9,7 +9,7 @@ All interactions in the **npm** organization on GitHub are considered to be cove **1. Clone this repository...** ```bash -$ git clone git@github.com:npm/cli.git +$ git clone git@github.com:npm/cli.git npm ``` **2. Navigate into project & install development-specific dependencies...** diff --git a/deps/npm/docs/content/commands/npm-cache.md b/deps/npm/docs/content/commands/npm-cache.md index bcc2989b7d3c3b..0bbb2756a40fee 100644 --- a/deps/npm/docs/content/commands/npm-cache.md +++ b/deps/npm/docs/content/commands/npm-cache.md @@ -7,10 +7,10 @@ description: Manipulates packages cache ### Synopsis ```bash -npm cache add -npm cache add -npm cache add -npm cache add @ +npm cache add ... +npm cache add ... +npm cache add ... +npm cache add @... npm cache clean aliases: npm cache clear, npm cache rm @@ -25,7 +25,7 @@ Note: This command is unaware of workspaces. Used to add, list, or clean the npm cache folder. * add: - Add the specified package to the local cache. This command is primarily + Add the specified packages to the local cache. This command is primarily intended to be used internally by npm, but it can provide a way to add data to the local installation cache explicitly. diff --git a/deps/npm/docs/content/commands/npm-ci.md b/deps/npm/docs/content/commands/npm-ci.md index 925ba8de2e5b7e..937553631ace5f 100644 --- a/deps/npm/docs/content/commands/npm-ci.md +++ b/deps/npm/docs/content/commands/npm-ci.md @@ -12,7 +12,7 @@ npm ci ### Description -This command is similar to [`npm install`](/cli-commands/install), except +This command is similar to [`npm install`](/commands/npm-install), except it's meant to be used in automated environments such as test platforms, continuous integration, and deployment -- or any situation where you want to make sure you're doing a clean install of your dependencies. diff --git a/deps/npm/docs/content/commands/npm-dedupe.md b/deps/npm/docs/content/commands/npm-dedupe.md index c6d26126d30775..f9bfd9e01532ef 100644 --- a/deps/npm/docs/content/commands/npm-dedupe.md +++ b/deps/npm/docs/content/commands/npm-dedupe.md @@ -74,7 +74,7 @@ Using `npm find-dupes` will run the command in `--dry-run` mode. ### See Also -* [npm find-dupes](/cli-commands/find-dupes) -* [npm ls](/cli-commands/ls) -* [npm update](/cli-commands/update) -* [npm install](/cli-commands/install) +* [npm find-dupes](/commands/npm-find-dupes) +* [npm ls](/commands/npm-ls) +* [npm update](/commands/npm-update) +* [npm install](/commands/npm-install) diff --git a/deps/npm/docs/content/commands/npm-deprecate.md b/deps/npm/docs/content/commands/npm-deprecate.md index 06037976610558..73d88b3717bd1d 100644 --- a/deps/npm/docs/content/commands/npm-deprecate.md +++ b/deps/npm/docs/content/commands/npm-deprecate.md @@ -44,5 +44,5 @@ format an empty string. * [npm publish](/commands/npm-publish) * [npm registry](/using-npm/registry) -* [npm owner](/cli-commands/owner) -* [npm owner](/cli-commands/adduser) +* [npm owner](/commands/npm-owner) +* [npm owner](/commands/npm-adduser) diff --git a/deps/npm/docs/content/commands/npm-explore.md b/deps/npm/docs/content/commands/npm-explore.md index 7e2004b84c0414..8bad293052eadd 100644 --- a/deps/npm/docs/content/commands/npm-explore.md +++ b/deps/npm/docs/content/commands/npm-explore.md @@ -44,5 +44,4 @@ The shell to run for the `npm explore` command. * [npm folders](/configuring-npm/folders) * [npm edit](/commands/npm-edit) * [npm rebuild](/commands/npm-rebuild) -* [npm build](/commands/npm-build) * [npm install](/commands/npm-install) diff --git a/deps/npm/docs/content/commands/npm-find-dupes.md b/deps/npm/docs/content/commands/npm-find-dupes.md index 6f55d47bfd7f32..6557a071c82c03 100644 --- a/deps/npm/docs/content/commands/npm-find-dupes.md +++ b/deps/npm/docs/content/commands/npm-find-dupes.md @@ -17,8 +17,8 @@ duplications, without actually changing the package tree. ### See Also -* [npm dedupe](/cli-commands/dedupe) -* [npm ls](/cli-commands/ls) -* [npm update](/cli-commands/update) -* [npm install](/cli-commands/install) +* [npm dedupe](/commands/npm-dedupe) +* [npm ls](/commands/npm-ls) +* [npm update](/commands/npm-update) +* [npm install](/commands/npm-install) diff --git a/deps/npm/docs/content/commands/npm-install.md b/deps/npm/docs/content/commands/npm-install.md index 5ab9275ee4eaf5..f81a8a24639898 100644 --- a/deps/npm/docs/content/commands/npm-install.md +++ b/deps/npm/docs/content/commands/npm-install.md @@ -538,7 +538,6 @@ the specific folder structures that npm creates. * [npm link](/commands/npm-link) * [npm rebuild](/commands/npm-rebuild) * [npm scripts](/using-npm/scripts) -* [npm build](/commands/npm-build) * [npm config](/commands/npm-config) * [npmrc](/configuring-npm/npmrc) * [npm registry](/using-npm/registry) diff --git a/deps/npm/docs/content/commands/npm-unpublish.md b/deps/npm/docs/content/commands/npm-unpublish.md index e9d6e9045c6f9e..2ce52d3f8cd446 100644 --- a/deps/npm/docs/content/commands/npm-unpublish.md +++ b/deps/npm/docs/content/commands/npm-unpublish.md @@ -34,7 +34,7 @@ This removes a package version from the registry, deleting its entry and removing the tarball. The npm registry will return an error if you are not [logged -in](/commands/npm-login). +in](/commands/npm-adduser). If you do not specify a version or if you remove all of a package's versions then the registry will remove the root package entry entirely. @@ -52,4 +52,4 @@ passed. * [npm registry](/using-npm/registry) * [npm adduser](/commands/npm-adduser) * [npm owner](/commands/npm-owner) -* [npm login](/commands/npm-login) +* [npm login](/commands/npm-adduser) diff --git a/deps/npm/docs/content/commands/npm-view.md b/deps/npm/docs/content/commands/npm-view.md index 8f7e886ed192a4..982ba29955179e 100644 --- a/deps/npm/docs/content/commands/npm-view.md +++ b/deps/npm/docs/content/commands/npm-view.md @@ -73,7 +73,7 @@ npm view express contributors.name contributors.email "Person" fields are shown as a string if they would be shown as an object. So, for example, this will show the list of `npm` contributors in -the shortened string format. (See [`package.json`](/configuring-npm/package.json) for more on this.) +the shortened string format. (See [`package.json`](/configuring-npm/package-json) for more on this.) ```bash npm view npm contributors diff --git a/deps/npm/docs/content/commands/npm.md b/deps/npm/docs/content/commands/npm.md index d01146d37041ca..2d86aa62c00807 100644 --- a/deps/npm/docs/content/commands/npm.md +++ b/deps/npm/docs/content/commands/npm.md @@ -107,7 +107,7 @@ following help topics: Create an account or log in. When you do this, npm will store credentials in the user config file config file. * publish: - Use the [`npm publish`](/commands/npm-publish`) command to upload your + Use the [`npm publish`](/commands/npm-publish) command to upload your code to the registry. #### Configuration diff --git a/deps/npm/docs/content/configuring-npm/folders.md b/deps/npm/docs/content/configuring-npm/folders.md index 3ec716f2c67fd5..75e31cd733161f 100644 --- a/deps/npm/docs/content/configuring-npm/folders.md +++ b/deps/npm/docs/content/configuring-npm/folders.md @@ -205,7 +205,7 @@ not be included in the package tarball. This allows a package maintainer to install all of their dependencies (and dev dependencies) locally, but only re-publish those items that -cannot be found elsewhere. See [`package.json`](/configuring-npm/package.json) for more information. +cannot be found elsewhere. See [`package.json`](/configuring-npm/package-json) for more information. ### See also diff --git a/deps/npm/docs/content/configuring-npm/package-json.md b/deps/npm/docs/content/configuring-npm/package-json.md index f5519f62bb32ef..3ed03990214470 100644 --- a/deps/npm/docs/content/configuring-npm/package-json.md +++ b/deps/npm/docs/content/configuring-npm/package-json.md @@ -566,7 +566,7 @@ tarball or git URL. **Please do not put test harnesses or transpilers or other "development" time tools in your `dependencies` object.** See `devDependencies`, below. -See [semver](/using-npm/semver#versions) for more details about specifying version ranges. +See [semver](https://github.com/npm/node-semver#versions) for more details about specifying version ranges. * `version` Must match `version` exactly * `>version` Must be greater than `version` diff --git a/deps/npm/docs/content/using-npm/config.md b/deps/npm/docs/content/using-npm/config.md index 76ac4192f1351e..d8fb70fb74bed8 100644 --- a/deps/npm/docs/content/using-npm/config.md +++ b/deps/npm/docs/content/using-npm/config.md @@ -1253,7 +1253,8 @@ Show short usage output about the command specified. #### `user-agent` -* Default: "npm/{npm-version} node/{node-version} {platform} {arch} {ci}" +* Default: "npm/{npm-version} node/{node-version} {platform} {arch} + workspaces/{workspaces} {ci}" * Type: String Sets the User-Agent request header. The following fields are replaced with @@ -1263,6 +1264,8 @@ their actual counterparts: * `{node-version}` - The Node.js version in use * `{platform}` - The value of `process.platform` * `{arch}` - The value of `process.arch` +* `{workspaces}` - Set to `true` if the `workspaces` or `workspace` options + are set. * `{ci}` - The value of the `ci-name` config, if set, prefixed with `ci/`, or an empty string if `ci-name` is empty. diff --git a/deps/npm/docs/content/using-npm/scripts.md b/deps/npm/docs/content/using-npm/scripts.md index 9312a21546d6fa..82cde7d79094d4 100644 --- a/deps/npm/docs/content/using-npm/scripts.md +++ b/deps/npm/docs/content/using-npm/scripts.md @@ -118,11 +118,6 @@ The advantage of doing these things at `prepublish` time is that they can be don * `prepare` -#### [`npm env`](/commands/npm-env) - -* `env` (You can override the default behavior of `npm env` by defining - a custom `env` entry in your `scripts` object) - #### [`npm install`](/commands/npm-install) These also run when you run `npm install -g ` @@ -179,7 +174,7 @@ If there is a `restart` script defined, these events are run, otherwise * `restart` * `postrestart` -#### [`npm run `](/commands/npm-run) +#### [`npm run `](/commands/npm-run-script) * `pre` * `` diff --git a/deps/npm/docs/output/commands/npm-cache.html b/deps/npm/docs/output/commands/npm-cache.html index 22ca6f1999ba06..cb886d3c7be36d 100644 --- a/deps/npm/docs/output/commands/npm-cache.html +++ b/deps/npm/docs/output/commands/npm-cache.html @@ -145,10 +145,10 @@

Table of contents

Synopsis

-
npm cache add <tarball file>
-npm cache add <folder>
-npm cache add <tarball url>
-npm cache add <name>@<version>
+
npm cache add <tarball file>...
+npm cache add <folder>...
+npm cache add <tarball url>...
+npm cache add <name>@<version>...
 
 npm cache clean
 aliases: npm cache clear, npm cache rm
@@ -161,7 +161,7 @@ 

Description

  • add: -Add the specified package to the local cache. This command is primarily +Add the specified packages to the local cache. This command is primarily intended to be used internally by npm, but it can provide a way to add data to the local installation cache explicitly.

  • diff --git a/deps/npm/docs/output/commands/npm-ci.html b/deps/npm/docs/output/commands/npm-ci.html index 8361e995b3a161..be6f8acb4c8776 100644 --- a/deps/npm/docs/output/commands/npm-ci.html +++ b/deps/npm/docs/output/commands/npm-ci.html @@ -148,7 +148,7 @@

    Table of contents

    npm ci
     

    Description

    -

    This command is similar to npm install, except +

    This command is similar to npm install, except it’s meant to be used in automated environments such as test platforms, continuous integration, and deployment – or any situation where you want to make sure you’re doing a clean install of your dependencies.

    diff --git a/deps/npm/docs/output/commands/npm-dedupe.html b/deps/npm/docs/output/commands/npm-dedupe.html index ccd9a03f4d828e..795659a6103b14 100644 --- a/deps/npm/docs/output/commands/npm-dedupe.html +++ b/deps/npm/docs/output/commands/npm-dedupe.html @@ -193,10 +193,10 @@

    Description

    Using npm find-dupes will run the command in --dry-run mode.

    See Also

diff --git a/deps/npm/docs/output/commands/npm-deprecate.html b/deps/npm/docs/output/commands/npm-deprecate.html index 88299a80bcfdaf..7f4409cd3ace3b 100644 --- a/deps/npm/docs/output/commands/npm-deprecate.html +++ b/deps/npm/docs/output/commands/npm-deprecate.html @@ -169,8 +169,8 @@

See Also

diff --git a/deps/npm/docs/output/commands/npm-explore.html b/deps/npm/docs/output/commands/npm-explore.html index cd52ff96a68486..8d1e2843d73eff 100644 --- a/deps/npm/docs/output/commands/npm-explore.html +++ b/deps/npm/docs/output/commands/npm-explore.html @@ -171,7 +171,6 @@

See Also

  • npm folders
  • npm edit
  • npm rebuild
  • -
  • npm build
  • npm install
  • diff --git a/deps/npm/docs/output/commands/npm-find-dupes.html b/deps/npm/docs/output/commands/npm-find-dupes.html index 32d8993b99cc4d..7f7f3c101b258a 100644 --- a/deps/npm/docs/output/commands/npm-find-dupes.html +++ b/deps/npm/docs/output/commands/npm-find-dupes.html @@ -152,10 +152,10 @@

    Description

    duplications, without actually changing the package tree.

    See Also

    diff --git a/deps/npm/docs/output/commands/npm-install.html b/deps/npm/docs/output/commands/npm-install.html index 2794b9a983d04c..8fff20fe836fad 100644 --- a/deps/npm/docs/output/commands/npm-install.html +++ b/deps/npm/docs/output/commands/npm-install.html @@ -614,7 +614,6 @@

    See Also

  • npm link
  • npm rebuild
  • npm scripts
  • -
  • npm build
  • npm config
  • npmrc
  • npm registry
  • diff --git a/deps/npm/docs/output/commands/npm-ls.html b/deps/npm/docs/output/commands/npm-ls.html index ede5cb042907a6..3d60f2baecd2b2 100644 --- a/deps/npm/docs/output/commands/npm-ls.html +++ b/deps/npm/docs/output/commands/npm-ls.html @@ -159,7 +159,7 @@

    Description

    the results to only the paths to the packages named. Note that nested packages will also show the paths to the specified packages. For example, running npm ls promzard in npm’s source tree will show:

    -
    npm@7.11.2 /path/to/npm
    +
    npm@7.12.1 /path/to/npm
     └─┬ init-package-json@0.0.4
       └── promzard@0.1.5
     
    diff --git a/deps/npm/docs/output/commands/npm-unpublish.html b/deps/npm/docs/output/commands/npm-unpublish.html index 75751d3408cfa1..737d5336c83b6e 100644 --- a/deps/npm/docs/output/commands/npm-unpublish.html +++ b/deps/npm/docs/output/commands/npm-unpublish.html @@ -159,7 +159,7 @@

    Warning

    Description

    This removes a package version from the registry, deleting its entry and removing the tarball.

    -

    The npm registry will return an error if you are not logged +

    The npm registry will return an error if you are not logged in.

    If you do not specify a version or if you remove all of a package’s versions then the registry will remove the root package entry entirely.

    @@ -175,7 +175,7 @@

    See Also

  • npm registry
  • npm adduser
  • npm owner
  • -
  • npm login
  • +
  • npm login
  • diff --git a/deps/npm/docs/output/commands/npm-view.html b/deps/npm/docs/output/commands/npm-view.html index 7489b17b1cd009..77786b74fd8c92 100644 --- a/deps/npm/docs/output/commands/npm-view.html +++ b/deps/npm/docs/output/commands/npm-view.html @@ -186,7 +186,7 @@

    Description

    “Person” fields are shown as a string if they would be shown as an object. So, for example, this will show the list of npm contributors in -the shortened string format. (See package.json for more on this.)

    +the shortened string format. (See package.json for more on this.)

    npm view npm contributors
     

    If a version range is provided, then data will be printed for every diff --git a/deps/npm/docs/output/commands/npm.html b/deps/npm/docs/output/commands/npm.html index 311c581f681df4..445abd0d5ce3e0 100644 --- a/deps/npm/docs/output/commands/npm.html +++ b/deps/npm/docs/output/commands/npm.html @@ -148,7 +148,7 @@

    Table of contents

    npm <command> [args]
     

    Version

    -

    7.11.2

    +

    7.12.1

    Description

    npm is the package manager for the Node JavaScript platform. It puts modules in place so that node can find them, and manages dependency @@ -222,7 +222,7 @@

    Developer Usage

    Create an account or log in. When you do this, npm will store credentials in the user config file config file.
  • publish: -Use the npm publish command to upload your +Use the npm publish command to upload your code to the registry.
  • Configuration

    diff --git a/deps/npm/docs/output/configuring-npm/folders.html b/deps/npm/docs/output/configuring-npm/folders.html index 20027ea3a9f41b..6cdae3cd1eca01 100644 --- a/deps/npm/docs/output/configuring-npm/folders.html +++ b/deps/npm/docs/output/configuring-npm/folders.html @@ -292,7 +292,7 @@

    Publishing

    not be included in the package tarball.

    This allows a package maintainer to install all of their dependencies (and dev dependencies) locally, but only re-publish those items that -cannot be found elsewhere. See package.json for more information.

    +cannot be found elsewhere. See package.json for more information.

    See also

    • package.json
    • diff --git a/deps/npm/docs/output/configuring-npm/package-json.html b/deps/npm/docs/output/configuring-npm/package-json.html index 84956dede7d296..f9c3ee6e4f5b83 100644 --- a/deps/npm/docs/output/configuring-npm/package-json.html +++ b/deps/npm/docs/output/configuring-npm/package-json.html @@ -567,7 +567,7 @@

      dependencies

      tarball or git URL.

      Please do not put test harnesses or transpilers or other “development” time tools in your dependencies object. See devDependencies, below.

      -

      See semver for more details about specifying version ranges.

      +

      See semver for more details about specifying version ranges.

      • version Must match version exactly
      • >version Must be greater than version
      • diff --git a/deps/npm/docs/output/using-npm/config.html b/deps/npm/docs/output/using-npm/config.html index 4435ce53bbaaca..881080eb121c06 100644 --- a/deps/npm/docs/output/using-npm/config.html +++ b/deps/npm/docs/output/using-npm/config.html @@ -1193,7 +1193,8 @@

        usage

        Show short usage output about the command specified.

        user-agent

          -
        • Default: “npm/{npm-version} node/{node-version} {platform} {arch} {ci}”
        • +
        • Default: “npm/{npm-version} node/{node-version} {platform} {arch} +workspaces/{workspaces} {ci}”
        • Type: String

        Sets the User-Agent request header. The following fields are replaced with @@ -1203,6 +1204,8 @@

        user-agent

      • {node-version} - The Node.js version in use
      • {platform} - The value of process.platform
      • {arch} - The value of process.arch
      • +
      • {workspaces} - Set to true if the workspaces or workspace options +are set.
      • {ci} - The value of the ci-name config, if set, prefixed with ci/, or an empty string if ci-name is empty.
      diff --git a/deps/npm/docs/output/using-npm/scripts.html b/deps/npm/docs/output/using-npm/scripts.html index e231cfec2ab81e..dde9b1b75d7194 100644 --- a/deps/npm/docs/output/using-npm/scripts.html +++ b/deps/npm/docs/output/using-npm/scripts.html @@ -141,7 +141,7 @@

      scripts

      Table of contents

      - +

      Description

      @@ -260,11 +260,6 @@

      npm diff<
      • prepare
      -

      npm env

      -
        -
      • env (You can override the default behavior of npm env by defining -a custom env entry in your scripts object)
      • -

      npm install

      These also run when you run npm install -g <pkg-name>

      -

      npm run <user defined>

      +

      npm run <user defined>

      • pre<user-defined>
      • <user-defined>
      • diff --git a/deps/npm/lib/cache.js b/deps/npm/lib/cache.js index 43902f43bbee19..5d544b2dbd185a 100644 --- a/deps/npm/lib/cache.js +++ b/deps/npm/lib/cache.js @@ -86,32 +86,30 @@ with --force.`) return rimraf(cachePath) } - // npm cache add - // npm cache add - // npm cache add - // npm cache add + // npm cache add ... + // npm cache add ... + // npm cache add ... + // npm cache add ... async add (args) { const usage = 'Usage:\n' + - ' npm cache add \n' + - ' npm cache add @\n' + - ' npm cache add \n' + - ' npm cache add \n' + ' npm cache add ...\n' + + ' npm cache add @...\n' + + ' npm cache add ...\n' + + ' npm cache add ...\n' log.silly('cache add', 'args', args) - const spec = args[0] && args[0] + - (args[1] === undefined || args[1] === null ? '' : `@${args[1]}`) - - if (!spec) + if (args.length === 0) throw Object.assign(new Error(usage), { code: 'EUSAGE' }) - log.silly('cache add', 'spec', spec) - - // we ask pacote for the thing, and then just throw the data - // away so that it tee-pipes it into the cache like it does - // for a normal request. - await pacote.tarball.stream(spec, stream => { - stream.resume() - return stream.promise() - }, this.npm.flatOptions) + return Promise.all(args.map(spec => { + log.silly('cache add', 'spec', spec) + // we ask pacote for the thing, and then just throw the data + // away so that it tee-pipes it into the cache like it does + // for a normal request. + return pacote.tarball.stream(spec, stream => { + stream.resume() + return stream.promise() + }, this.npm.flatOptions) + })) } async verify () { diff --git a/deps/npm/lib/config.js b/deps/npm/lib/config.js index f53d7e5ae271bc..4b3ac587365088 100644 --- a/deps/npm/lib/config.js +++ b/deps/npm/lib/config.js @@ -199,7 +199,7 @@ class Config extends BaseCommand { ; Configs like \`///:_authToken\` are auth that is restricted ; to the registry host specified. -${data.split('\n').sort((a, b) => a.localeCompare(b)).join('\n').trim()} +${data.split('\n').sort((a, b) => a.localeCompare(b, 'en')).join('\n').trim()} ;;;; ; all available options shown below with default values @@ -227,7 +227,7 @@ ${defData} if (where === 'default' && !long) continue - const keys = Object.keys(data).sort((a, b) => a.localeCompare(b)) + const keys = Object.keys(data).sort((a, b) => a.localeCompare(b, 'en')) if (!keys.length) continue diff --git a/deps/npm/lib/help.js b/deps/npm/lib/help.js index 589819eb02a454..e9aade5215a8ca 100644 --- a/deps/npm/lib/help.js +++ b/deps/npm/lib/help.js @@ -77,7 +77,7 @@ class Help extends BaseCommand { if (aManNumber !== bManNumber) return aManNumber - bManNumber - return a.localeCompare(b) + return a.localeCompare(b, 'en') }) const man = mans[0] diff --git a/deps/npm/lib/ls.js b/deps/npm/lib/ls.js index ccd8b2ff9dea71..9fa5fddd53f82e 100644 --- a/deps/npm/lib/ls.js +++ b/deps/npm/lib/ls.js @@ -443,7 +443,7 @@ const augmentNodesWithMetadata = ({ } const sortAlphabetically = (a, b) => - a.pkgid.localeCompare(b.pkgid) + a.pkgid.localeCompare(b.pkgid, 'en') const humanOutput = ({ color, result, seenItems, unicode }) => { // we need to traverse the entire tree in order to determine which items diff --git a/deps/npm/lib/outdated.js b/deps/npm/lib/outdated.js index 9b656d2aeede47..a436059e9e2dac 100644 --- a/deps/npm/lib/outdated.js +++ b/deps/npm/lib/outdated.js @@ -68,7 +68,7 @@ class Outdated extends BaseCommand { })) // sorts list alphabetically - const outdated = this.list.sort((a, b) => a.name.localeCompare(b.name)) + const outdated = this.list.sort((a, b) => a.name.localeCompare(b.name, 'en')) // return if no outdated packages if (outdated.length === 0 && !this.npm.config.get('json')) @@ -149,7 +149,7 @@ class Outdated extends BaseCommand { : edge.dev ? 'devDependencies' : 'dependencies' - for (const omitType of this.npm.config.get('omit') || []) { + for (const omitType of this.npm.config.get('omit')) { if (node[omitType]) return } diff --git a/deps/npm/lib/utils/completion/installed-deep.js b/deps/npm/lib/utils/completion/installed-deep.js index b65c17e41d743d..2430688612cd4d 100644 --- a/deps/npm/lib/utils/completion/installed-deep.js +++ b/deps/npm/lib/utils/completion/installed-deep.js @@ -16,7 +16,7 @@ const installedDeep = async (npm) => { }) .filter(i => (i.depth - 1) <= depth) .sort((a, b) => a.depth - b.depth) - .sort((a, b) => a.depth === b.depth ? a.name.localeCompare(b.name) : 0) + .sort((a, b) => a.depth === b.depth ? a.name.localeCompare(b.name, 'en') : 0) const res = new Set() const gArb = new Arborist({ global: true, path: resolve(npm.globalDir, '..') }) diff --git a/deps/npm/lib/utils/config/definitions.js b/deps/npm/lib/utils/config/definitions.js index 3a50175d5db649..aa90de8e760b7d 100644 --- a/deps/npm/lib/utils/config/definitions.js +++ b/deps/npm/lib/utils/config/definitions.js @@ -1943,6 +1943,7 @@ define('user-agent', { 'node/{node-version} ' + '{platform} ' + '{arch} ' + + 'workspaces/{workspaces} ' + '{ci}', type: String, description: ` @@ -1953,17 +1954,23 @@ define('user-agent', { * \`{node-version}\` - The Node.js version in use * \`{platform}\` - The value of \`process.platform\` * \`{arch}\` - The value of \`process.arch\` + * \`{workspaces}\` - Set to \`true\` if the \`workspaces\` or \`workspace\` + options are set. * \`{ci}\` - The value of the \`ci-name\` config, if set, prefixed with \`ci/\`, or an empty string if \`ci-name\` is empty. `, flatten (key, obj, flatOptions) { const value = obj[key] const ciName = obj['ci-name'] + let inWorkspaces = false + if (obj.workspaces || obj.workspace && obj.workspace.length) + inWorkspaces = true flatOptions.userAgent = value.replace(/\{node-version\}/gi, obj['node-version']) .replace(/\{npm-version\}/gi, obj['npm-version']) .replace(/\{platform\}/gi, process.platform) .replace(/\{arch\}/gi, process.arch) + .replace(/\{workspaces\}/gi, inWorkspaces) .replace(/\{ci\}/gi, ciName ? `ci/${ciName}` : '') .trim() // user-agent is a unique kind of config item that gets set from a template diff --git a/deps/npm/lib/utils/config/describe-all.js b/deps/npm/lib/utils/config/describe-all.js index ab3f3a63ea751c..5fb785f08310d0 100644 --- a/deps/npm/lib/utils/config/describe-all.js +++ b/deps/npm/lib/utils/config/describe-all.js @@ -7,7 +7,7 @@ const describeAll = () => { const sort = ([keya, {deprecated: depa}], [keyb, {deprecated: depb}]) => { return depa && !depb ? 1 : !depa && depb ? -1 - : keya.localeCompare(keyb) + : keya.localeCompare(keyb, 'en') } return Object.entries(definitions).sort(sort) .map(([key, def]) => def.describe()) diff --git a/deps/npm/lib/utils/npm-usage.js b/deps/npm/lib/utils/npm-usage.js index bc397cb4d95e66..ddb0bab0bc9a2d 100644 --- a/deps/npm/lib/utils/npm-usage.js +++ b/deps/npm/lib/utils/npm-usage.js @@ -62,7 +62,7 @@ const usages = (npm) => { maxLen = Math.max(maxLen, c.length) return set }, []) - .sort((a, b) => a[0].localeCompare(b[0])) + .sort((a, b) => a[0].localeCompare(b[0], 'en')) .map(([c, usage]) => `\n ${c}${' '.repeat(maxLen - c.length + 1)}${ (usage.split('\n').join('\n' + ' '.repeat(maxLen + 5)))}`) .join('\n') diff --git a/deps/npm/lib/utils/tar.js b/deps/npm/lib/utils/tar.js index 887c40a0f6ebee..9e7c3329530eeb 100644 --- a/deps/npm/lib/utils/tar.js +++ b/deps/npm/lib/utils/tar.js @@ -76,7 +76,7 @@ const getContents = async (manifest, tarball) => { }) const comparator = (a, b) => { - return a.path.localeCompare(b.path, undefined, { + return a.path.localeCompare(b.path, 'en', { sensitivity: 'case', numeric: true, }) @@ -84,7 +84,7 @@ const getContents = async (manifest, tarball) => { const isUpper = (str) => { const ch = str.charAt(0) - return ch >= 'A' && ch <= 'Z' + return ch === ch.toUpperCase() } const uppers = files.filter(file => isUpper(file.path)) diff --git a/deps/npm/lib/view.js b/deps/npm/lib/view.js index 91b32e2fd38fa3..9cc1aed914488d 100644 --- a/deps/npm/lib/view.js +++ b/deps/npm/lib/view.js @@ -202,7 +202,10 @@ class View extends BaseCommand { const spec = npa(pkg) // get the data about this package - let version = spec.rawSpec || this.npm.config.get('tag') + let version = this.npm.config.get('tag') + // rawSpec is the git url if this is from git + if (spec.type !== 'git' && spec.rawSpec) + version = spec.rawSpec const pckmnt = await packument(spec, opts) diff --git a/deps/npm/man/man1/npm-access.1 b/deps/npm/man/man1/npm-access.1 index f1deed4c428a55..8165ccd46d5c45 100644 --- a/deps/npm/man/man1/npm-access.1 +++ b/deps/npm/man/man1/npm-access.1 @@ -1,4 +1,4 @@ -.TH "NPM\-ACCESS" "1" "April 2021" "" "" +.TH "NPM\-ACCESS" "1" "May 2021" "" "" .SH "NAME" \fBnpm-access\fR \- Set access level on published packages .SS Synopsis diff --git a/deps/npm/man/man1/npm-adduser.1 b/deps/npm/man/man1/npm-adduser.1 index aa7d0e5e527a51..26f42858694ada 100644 --- a/deps/npm/man/man1/npm-adduser.1 +++ b/deps/npm/man/man1/npm-adduser.1 @@ -1,4 +1,4 @@ -.TH "NPM\-ADDUSER" "1" "April 2021" "" "" +.TH "NPM\-ADDUSER" "1" "May 2021" "" "" .SH "NAME" \fBnpm-adduser\fR \- Add a registry user account .SS Synopsis diff --git a/deps/npm/man/man1/npm-audit.1 b/deps/npm/man/man1/npm-audit.1 index ebbb019ec8a351..cd63c284730908 100644 --- a/deps/npm/man/man1/npm-audit.1 +++ b/deps/npm/man/man1/npm-audit.1 @@ -1,4 +1,4 @@ -.TH "NPM\-AUDIT" "1" "April 2021" "" "" +.TH "NPM\-AUDIT" "1" "May 2021" "" "" .SH "NAME" \fBnpm-audit\fR \- Run a security audit .SS Synopsis diff --git a/deps/npm/man/man1/npm-bin.1 b/deps/npm/man/man1/npm-bin.1 index d7ddf05cb757af..61e2ab1ea91cde 100644 --- a/deps/npm/man/man1/npm-bin.1 +++ b/deps/npm/man/man1/npm-bin.1 @@ -1,4 +1,4 @@ -.TH "NPM\-BIN" "1" "April 2021" "" "" +.TH "NPM\-BIN" "1" "May 2021" "" "" .SH "NAME" \fBnpm-bin\fR \- Display npm bin folder .SS Synopsis diff --git a/deps/npm/man/man1/npm-bugs.1 b/deps/npm/man/man1/npm-bugs.1 index 9d453b825b9f92..c4297521de2b5f 100644 --- a/deps/npm/man/man1/npm-bugs.1 +++ b/deps/npm/man/man1/npm-bugs.1 @@ -1,4 +1,4 @@ -.TH "NPM\-BUGS" "1" "April 2021" "" "" +.TH "NPM\-BUGS" "1" "May 2021" "" "" .SH "NAME" \fBnpm-bugs\fR \- Report bugs for a package in a web browser .SS Synopsis diff --git a/deps/npm/man/man1/npm-cache.1 b/deps/npm/man/man1/npm-cache.1 index 08913baa6325d6..25b9d0d79118df 100644 --- a/deps/npm/man/man1/npm-cache.1 +++ b/deps/npm/man/man1/npm-cache.1 @@ -1,14 +1,14 @@ -.TH "NPM\-CACHE" "1" "April 2021" "" "" +.TH "NPM\-CACHE" "1" "May 2021" "" "" .SH "NAME" \fBnpm-cache\fR \- Manipulates packages cache .SS Synopsis .P .RS 2 .nf -npm cache add -npm cache add -npm cache add -npm cache add @ +npm cache add \.\.\. +npm cache add \.\.\. +npm cache add \.\.\. +npm cache add @\.\.\. npm cache clean aliases: npm cache clear, npm cache rm @@ -24,7 +24,7 @@ Used to add, list, or clean the npm cache folder\. .RS 0 .IP \(bu 2 add: -Add the specified package to the local cache\. This command is primarily +Add the specified packages to the local cache\. This command is primarily intended to be used internally by npm, but it can provide a way to add data to the local installation cache explicitly\. .IP \(bu 2 diff --git a/deps/npm/man/man1/npm-ci.1 b/deps/npm/man/man1/npm-ci.1 index 67f7245d01b9e7..481d3d23c95b0f 100644 --- a/deps/npm/man/man1/npm-ci.1 +++ b/deps/npm/man/man1/npm-ci.1 @@ -1,4 +1,4 @@ -.TH "NPM\-CI" "1" "April 2021" "" "" +.TH "NPM\-CI" "1" "May 2021" "" "" .SH "NAME" \fBnpm-ci\fR \- Install a project with a clean slate .SS Synopsis @@ -10,7 +10,7 @@ npm ci .RE .SS Description .P -This command is similar to \fBnpm install\fP \fI/cli\-commands/install\fR, except +This command is similar to npm help \fBinstall\fP, except it's meant to be used in automated environments such as test platforms, continuous integration, and deployment \-\- or any situation where you want to make sure you're doing a clean install of your dependencies\. diff --git a/deps/npm/man/man1/npm-completion.1 b/deps/npm/man/man1/npm-completion.1 index cb3e2d994356c8..dffedb6b639e6a 100644 --- a/deps/npm/man/man1/npm-completion.1 +++ b/deps/npm/man/man1/npm-completion.1 @@ -1,4 +1,4 @@ -.TH "NPM\-COMPLETION" "1" "April 2021" "" "" +.TH "NPM\-COMPLETION" "1" "May 2021" "" "" .SH "NAME" \fBnpm-completion\fR \- Tab Completion for npm .SS Synopsis diff --git a/deps/npm/man/man1/npm-config.1 b/deps/npm/man/man1/npm-config.1 index c19d0411cb78b4..2ab14312a86a7d 100644 --- a/deps/npm/man/man1/npm-config.1 +++ b/deps/npm/man/man1/npm-config.1 @@ -1,4 +1,4 @@ -.TH "NPM\-CONFIG" "1" "April 2021" "" "" +.TH "NPM\-CONFIG" "1" "May 2021" "" "" .SH "NAME" \fBnpm-config\fR \- Manage the npm configuration files .SS Synopsis diff --git a/deps/npm/man/man1/npm-dedupe.1 b/deps/npm/man/man1/npm-dedupe.1 index fd6cce4bc1b287..bd65bd3853c26e 100644 --- a/deps/npm/man/man1/npm-dedupe.1 +++ b/deps/npm/man/man1/npm-dedupe.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DEDUPE" "1" "April 2021" "" "" +.TH "NPM\-DEDUPE" "1" "May 2021" "" "" .SH "NAME" \fBnpm-dedupe\fR \- Reduce duplication in the package tree .SS Synopsis @@ -78,12 +78,12 @@ Using \fBnpm find\-dupes\fP will run the command in \fB\-\-dry\-run\fP mode\. .SS See Also .RS 0 .IP \(bu 2 -npm find\-dupes \fI/cli\-commands/find\-dupes\fR +npm help find\-dupes .IP \(bu 2 -npm ls \fI/cli\-commands/ls\fR +npm help ls .IP \(bu 2 -npm update \fI/cli\-commands/update\fR +npm help update .IP \(bu 2 -npm install \fI/cli\-commands/install\fR +npm help install .RE diff --git a/deps/npm/man/man1/npm-deprecate.1 b/deps/npm/man/man1/npm-deprecate.1 index 33922d2e834c6f..c57decbba87bb4 100644 --- a/deps/npm/man/man1/npm-deprecate.1 +++ b/deps/npm/man/man1/npm-deprecate.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DEPRECATE" "1" "April 2021" "" "" +.TH "NPM\-DEPRECATE" "1" "May 2021" "" "" .SH "NAME" \fBnpm-deprecate\fR \- Deprecate a version of a package .SS Synopsis @@ -48,8 +48,8 @@ npm help publish .IP \(bu 2 npm help registry .IP \(bu 2 -npm owner \fI/cli\-commands/owner\fR +npm help owner .IP \(bu 2 -npm owner \fI/cli\-commands/adduser\fR +npm help owner .RE diff --git a/deps/npm/man/man1/npm-diff.1 b/deps/npm/man/man1/npm-diff.1 index 97092215bd89a3..079c73e46a44a3 100644 --- a/deps/npm/man/man1/npm-diff.1 +++ b/deps/npm/man/man1/npm-diff.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DIFF" "1" "April 2021" "" "" +.TH "NPM\-DIFF" "1" "May 2021" "" "" .SH "NAME" \fBnpm-diff\fR \- The registry diff command .SS Synopsis diff --git a/deps/npm/man/man1/npm-dist-tag.1 b/deps/npm/man/man1/npm-dist-tag.1 index 6be3351be3cf5b..95ed3584723186 100644 --- a/deps/npm/man/man1/npm-dist-tag.1 +++ b/deps/npm/man/man1/npm-dist-tag.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DIST\-TAG" "1" "April 2021" "" "" +.TH "NPM\-DIST\-TAG" "1" "May 2021" "" "" .SH "NAME" \fBnpm-dist-tag\fR \- Modify package distribution tags .SS Synopsis diff --git a/deps/npm/man/man1/npm-docs.1 b/deps/npm/man/man1/npm-docs.1 index 5da2b661a5498b..1aec0eb795f411 100644 --- a/deps/npm/man/man1/npm-docs.1 +++ b/deps/npm/man/man1/npm-docs.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DOCS" "1" "April 2021" "" "" +.TH "NPM\-DOCS" "1" "May 2021" "" "" .SH "NAME" \fBnpm-docs\fR \- Open documentation for a package in a web browser .SS Synopsis diff --git a/deps/npm/man/man1/npm-doctor.1 b/deps/npm/man/man1/npm-doctor.1 index c3b11a90259509..df05a562f95e80 100644 --- a/deps/npm/man/man1/npm-doctor.1 +++ b/deps/npm/man/man1/npm-doctor.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DOCTOR" "1" "April 2021" "" "" +.TH "NPM\-DOCTOR" "1" "May 2021" "" "" .SH "NAME" \fBnpm-doctor\fR \- Check your npm environment .SS Synopsis diff --git a/deps/npm/man/man1/npm-edit.1 b/deps/npm/man/man1/npm-edit.1 index 445439d1554b14..425c769cfed138 100644 --- a/deps/npm/man/man1/npm-edit.1 +++ b/deps/npm/man/man1/npm-edit.1 @@ -1,4 +1,4 @@ -.TH "NPM\-EDIT" "1" "April 2021" "" "" +.TH "NPM\-EDIT" "1" "May 2021" "" "" .SH "NAME" \fBnpm-edit\fR \- Edit an installed package .SS Synopsis diff --git a/deps/npm/man/man1/npm-exec.1 b/deps/npm/man/man1/npm-exec.1 index 1ac663ff18ef50..5bb3736ae6297f 100644 --- a/deps/npm/man/man1/npm-exec.1 +++ b/deps/npm/man/man1/npm-exec.1 @@ -1,4 +1,4 @@ -.TH "NPM\-EXEC" "1" "April 2021" "" "" +.TH "NPM\-EXEC" "1" "May 2021" "" "" .SH "NAME" \fBnpm-exec\fR \- Run a command from a local or remote npm package .SS Synopsis diff --git a/deps/npm/man/man1/npm-explain.1 b/deps/npm/man/man1/npm-explain.1 index efc5314788205b..87c84f1aaf2668 100644 --- a/deps/npm/man/man1/npm-explain.1 +++ b/deps/npm/man/man1/npm-explain.1 @@ -1,4 +1,4 @@ -.TH "NPM\-EXPLAIN" "1" "April 2021" "" "" +.TH "NPM\-EXPLAIN" "1" "May 2021" "" "" .SH "NAME" \fBnpm-explain\fR \- Explain installed packages .SS Synopsis diff --git a/deps/npm/man/man1/npm-explore.1 b/deps/npm/man/man1/npm-explore.1 index 7863f3a07115f6..205f0518e909fa 100644 --- a/deps/npm/man/man1/npm-explore.1 +++ b/deps/npm/man/man1/npm-explore.1 @@ -1,4 +1,4 @@ -.TH "NPM\-EXPLORE" "1" "April 2021" "" "" +.TH "NPM\-EXPLORE" "1" "May 2021" "" "" .SH "NAME" \fBnpm-explore\fR \- Browse an installed package .SS Synopsis @@ -49,8 +49,6 @@ npm help edit .IP \(bu 2 npm help rebuild .IP \(bu 2 -npm help build -.IP \(bu 2 npm help install .RE diff --git a/deps/npm/man/man1/npm-find-dupes.1 b/deps/npm/man/man1/npm-find-dupes.1 index 03ff67e95b5760..e88c89408b351e 100644 --- a/deps/npm/man/man1/npm-find-dupes.1 +++ b/deps/npm/man/man1/npm-find-dupes.1 @@ -1,4 +1,4 @@ -.TH "NPM\-FIND\-DUPES" "1" "April 2021" "" "" +.TH "NPM\-FIND\-DUPES" "1" "May 2021" "" "" .SH "NAME" \fBnpm-find-dupes\fR \- Find duplication in the package tree .SS Synopsis @@ -15,12 +15,12 @@ duplications, without actually changing the package tree\. .SS See Also .RS 0 .IP \(bu 2 -npm dedupe \fI/cli\-commands/dedupe\fR +npm help dedupe .IP \(bu 2 -npm ls \fI/cli\-commands/ls\fR +npm help ls .IP \(bu 2 -npm update \fI/cli\-commands/update\fR +npm help update .IP \(bu 2 -npm install \fI/cli\-commands/install\fR +npm help install .RE diff --git a/deps/npm/man/man1/npm-fund.1 b/deps/npm/man/man1/npm-fund.1 index dc67600e6ac2f9..81a277bb0087c2 100644 --- a/deps/npm/man/man1/npm-fund.1 +++ b/deps/npm/man/man1/npm-fund.1 @@ -1,4 +1,4 @@ -.TH "NPM\-FUND" "1" "April 2021" "" "" +.TH "NPM\-FUND" "1" "May 2021" "" "" .SH "NAME" \fBnpm-fund\fR \- Retrieve funding information .SS Synopsis diff --git a/deps/npm/man/man1/npm-help-search.1 b/deps/npm/man/man1/npm-help-search.1 index a7bc089b1962fc..2f85992550d9f2 100644 --- a/deps/npm/man/man1/npm-help-search.1 +++ b/deps/npm/man/man1/npm-help-search.1 @@ -1,4 +1,4 @@ -.TH "NPM\-HELP\-SEARCH" "1" "April 2021" "" "" +.TH "NPM\-HELP\-SEARCH" "1" "May 2021" "" "" .SH "NAME" \fBnpm-help-search\fR \- Search npm help documentation .SS Synopsis diff --git a/deps/npm/man/man1/npm-help.1 b/deps/npm/man/man1/npm-help.1 index 8e32829300023f..f97f9117b685ee 100644 --- a/deps/npm/man/man1/npm-help.1 +++ b/deps/npm/man/man1/npm-help.1 @@ -1,4 +1,4 @@ -.TH "NPM\-HELP" "1" "April 2021" "" "" +.TH "NPM\-HELP" "1" "May 2021" "" "" .SH "NAME" \fBnpm-help\fR \- Get help on npm .SS Synopsis diff --git a/deps/npm/man/man1/npm-hook.1 b/deps/npm/man/man1/npm-hook.1 index 06cb0959fcc99e..bb6b553a60c6ff 100644 --- a/deps/npm/man/man1/npm-hook.1 +++ b/deps/npm/man/man1/npm-hook.1 @@ -1,4 +1,4 @@ -.TH "NPM\-HOOK" "1" "April 2021" "" "" +.TH "NPM\-HOOK" "1" "May 2021" "" "" .SH "NAME" \fBnpm-hook\fR \- Manage registry hooks .SS Synopsis diff --git a/deps/npm/man/man1/npm-init.1 b/deps/npm/man/man1/npm-init.1 index b4b09e598d247b..9ba1cf0a6457dc 100644 --- a/deps/npm/man/man1/npm-init.1 +++ b/deps/npm/man/man1/npm-init.1 @@ -1,4 +1,4 @@ -.TH "NPM\-INIT" "1" "April 2021" "" "" +.TH "NPM\-INIT" "1" "May 2021" "" "" .SH "NAME" \fBnpm-init\fR \- Create a package\.json file .SS Synopsis diff --git a/deps/npm/man/man1/npm-install-ci-test.1 b/deps/npm/man/man1/npm-install-ci-test.1 index 22eb734e21e975..448a8514812d45 100644 --- a/deps/npm/man/man1/npm-install-ci-test.1 +++ b/deps/npm/man/man1/npm-install-ci-test.1 @@ -1,4 +1,4 @@ -.TH "NPM\-INSTALL\-CI\-TEST" "1" "April 2021" "" "" +.TH "NPM\-INSTALL\-CI\-TEST" "1" "May 2021" "" "" .SH "NAME" \fBnpm-install-ci-test\fR \- Install a project with a clean slate and run tests .SS Synopsis diff --git a/deps/npm/man/man1/npm-install-test.1 b/deps/npm/man/man1/npm-install-test.1 index 521d0bc5ebf490..03efe308f2edcd 100644 --- a/deps/npm/man/man1/npm-install-test.1 +++ b/deps/npm/man/man1/npm-install-test.1 @@ -1,4 +1,4 @@ -.TH "NPM\-INSTALL\-TEST" "1" "April 2021" "" "" +.TH "NPM\-INSTALL\-TEST" "1" "May 2021" "" "" .SH "NAME" \fBnpm-install-test\fR \- Install package(s) and run tests .SS Synopsis diff --git a/deps/npm/man/man1/npm-install.1 b/deps/npm/man/man1/npm-install.1 index 5ac2700d829880..c4567fb2920420 100644 --- a/deps/npm/man/man1/npm-install.1 +++ b/deps/npm/man/man1/npm-install.1 @@ -1,4 +1,4 @@ -.TH "NPM\-INSTALL" "1" "April 2021" "" "" +.TH "NPM\-INSTALL" "1" "May 2021" "" "" .SH "NAME" \fBnpm-install\fR \- Install a package .SS Synopsis @@ -576,8 +576,6 @@ npm help rebuild .IP \(bu 2 npm help scripts .IP \(bu 2 -npm help build -.IP \(bu 2 npm help config .IP \(bu 2 npm help npmrc diff --git a/deps/npm/man/man1/npm-link.1 b/deps/npm/man/man1/npm-link.1 index 94afe9c3fdf81f..404b04a5ce490e 100644 --- a/deps/npm/man/man1/npm-link.1 +++ b/deps/npm/man/man1/npm-link.1 @@ -1,4 +1,4 @@ -.TH "NPM\-LINK" "1" "April 2021" "" "" +.TH "NPM\-LINK" "1" "May 2021" "" "" .SH "NAME" \fBnpm-link\fR \- Symlink a package folder .SS Synopsis diff --git a/deps/npm/man/man1/npm-logout.1 b/deps/npm/man/man1/npm-logout.1 index 0f94b466398256..84a6851b284cba 100644 --- a/deps/npm/man/man1/npm-logout.1 +++ b/deps/npm/man/man1/npm-logout.1 @@ -1,4 +1,4 @@ -.TH "NPM\-LOGOUT" "1" "April 2021" "" "" +.TH "NPM\-LOGOUT" "1" "May 2021" "" "" .SH "NAME" \fBnpm-logout\fR \- Log out of the registry .SS Synopsis diff --git a/deps/npm/man/man1/npm-ls.1 b/deps/npm/man/man1/npm-ls.1 index 2d4720ad8a4a97..c47da91875482f 100644 --- a/deps/npm/man/man1/npm-ls.1 +++ b/deps/npm/man/man1/npm-ls.1 @@ -1,4 +1,4 @@ -.TH "NPM\-LS" "1" "April 2021" "" "" +.TH "NPM\-LS" "1" "May 2021" "" "" .SH "NAME" \fBnpm-ls\fR \- List installed packages .SS Synopsis @@ -26,7 +26,7 @@ example, running \fBnpm ls promzard\fP in npm's source tree will show: .P .RS 2 .nf -npm@7\.11\.2 /path/to/npm +npm@7\.12\.1 /path/to/npm └─┬ init\-package\-json@0\.0\.4 └── promzard@0\.1\.5 .fi diff --git a/deps/npm/man/man1/npm-org.1 b/deps/npm/man/man1/npm-org.1 index 7d85be8760a8ad..18cb791b071309 100644 --- a/deps/npm/man/man1/npm-org.1 +++ b/deps/npm/man/man1/npm-org.1 @@ -1,4 +1,4 @@ -.TH "NPM\-ORG" "1" "April 2021" "" "" +.TH "NPM\-ORG" "1" "May 2021" "" "" .SH "NAME" \fBnpm-org\fR \- Manage orgs .SS Synopsis diff --git a/deps/npm/man/man1/npm-outdated.1 b/deps/npm/man/man1/npm-outdated.1 index d90143428f2e57..a7309f2dfb994a 100644 --- a/deps/npm/man/man1/npm-outdated.1 +++ b/deps/npm/man/man1/npm-outdated.1 @@ -1,4 +1,4 @@ -.TH "NPM\-OUTDATED" "1" "April 2021" "" "" +.TH "NPM\-OUTDATED" "1" "May 2021" "" "" .SH "NAME" \fBnpm-outdated\fR \- Check for outdated packages .SS Synopsis diff --git a/deps/npm/man/man1/npm-owner.1 b/deps/npm/man/man1/npm-owner.1 index 3731b383d7618a..7140aef06b6144 100644 --- a/deps/npm/man/man1/npm-owner.1 +++ b/deps/npm/man/man1/npm-owner.1 @@ -1,4 +1,4 @@ -.TH "NPM\-OWNER" "1" "April 2021" "" "" +.TH "NPM\-OWNER" "1" "May 2021" "" "" .SH "NAME" \fBnpm-owner\fR \- Manage package owners .SS Synopsis diff --git a/deps/npm/man/man1/npm-pack.1 b/deps/npm/man/man1/npm-pack.1 index adedbef0c1f56c..ab34dc891d1c13 100644 --- a/deps/npm/man/man1/npm-pack.1 +++ b/deps/npm/man/man1/npm-pack.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PACK" "1" "April 2021" "" "" +.TH "NPM\-PACK" "1" "May 2021" "" "" .SH "NAME" \fBnpm-pack\fR \- Create a tarball from a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-ping.1 b/deps/npm/man/man1/npm-ping.1 index 9eb5ec12842bc7..385e4b8a810ba3 100644 --- a/deps/npm/man/man1/npm-ping.1 +++ b/deps/npm/man/man1/npm-ping.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PING" "1" "April 2021" "" "" +.TH "NPM\-PING" "1" "May 2021" "" "" .SH "NAME" \fBnpm-ping\fR \- Ping npm registry .SS Synopsis diff --git a/deps/npm/man/man1/npm-prefix.1 b/deps/npm/man/man1/npm-prefix.1 index c4b8a36e954c31..82de74199e923f 100644 --- a/deps/npm/man/man1/npm-prefix.1 +++ b/deps/npm/man/man1/npm-prefix.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PREFIX" "1" "April 2021" "" "" +.TH "NPM\-PREFIX" "1" "May 2021" "" "" .SH "NAME" \fBnpm-prefix\fR \- Display prefix .SS Synopsis diff --git a/deps/npm/man/man1/npm-profile.1 b/deps/npm/man/man1/npm-profile.1 index 7b2ff13efae4fe..d2d412fe8bfa9f 100644 --- a/deps/npm/man/man1/npm-profile.1 +++ b/deps/npm/man/man1/npm-profile.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PROFILE" "1" "April 2021" "" "" +.TH "NPM\-PROFILE" "1" "May 2021" "" "" .SH "NAME" \fBnpm-profile\fR \- Change settings on your registry profile .SS Synopsis diff --git a/deps/npm/man/man1/npm-prune.1 b/deps/npm/man/man1/npm-prune.1 index df8b82eb7b5169..18d5e14dd1a08f 100644 --- a/deps/npm/man/man1/npm-prune.1 +++ b/deps/npm/man/man1/npm-prune.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PRUNE" "1" "April 2021" "" "" +.TH "NPM\-PRUNE" "1" "May 2021" "" "" .SH "NAME" \fBnpm-prune\fR \- Remove extraneous packages .SS Synopsis diff --git a/deps/npm/man/man1/npm-publish.1 b/deps/npm/man/man1/npm-publish.1 index ac7a0323a72570..c405f64f27e361 100644 --- a/deps/npm/man/man1/npm-publish.1 +++ b/deps/npm/man/man1/npm-publish.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PUBLISH" "1" "April 2021" "" "" +.TH "NPM\-PUBLISH" "1" "May 2021" "" "" .SH "NAME" \fBnpm-publish\fR \- Publish a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-rebuild.1 b/deps/npm/man/man1/npm-rebuild.1 index 995c8ab5ea19b1..3a78852b5430ef 100644 --- a/deps/npm/man/man1/npm-rebuild.1 +++ b/deps/npm/man/man1/npm-rebuild.1 @@ -1,4 +1,4 @@ -.TH "NPM\-REBUILD" "1" "April 2021" "" "" +.TH "NPM\-REBUILD" "1" "May 2021" "" "" .SH "NAME" \fBnpm-rebuild\fR \- Rebuild a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-repo.1 b/deps/npm/man/man1/npm-repo.1 index 30b05534836db0..bdb5452181e77c 100644 --- a/deps/npm/man/man1/npm-repo.1 +++ b/deps/npm/man/man1/npm-repo.1 @@ -1,4 +1,4 @@ -.TH "NPM\-REPO" "1" "April 2021" "" "" +.TH "NPM\-REPO" "1" "May 2021" "" "" .SH "NAME" \fBnpm-repo\fR \- Open package repository page in the browser .SS Synopsis diff --git a/deps/npm/man/man1/npm-restart.1 b/deps/npm/man/man1/npm-restart.1 index bd212fb466a056..4ecb71f177e31d 100644 --- a/deps/npm/man/man1/npm-restart.1 +++ b/deps/npm/man/man1/npm-restart.1 @@ -1,4 +1,4 @@ -.TH "NPM\-RESTART" "1" "April 2021" "" "" +.TH "NPM\-RESTART" "1" "May 2021" "" "" .SH "NAME" \fBnpm-restart\fR \- Restart a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-root.1 b/deps/npm/man/man1/npm-root.1 index ddff01d429e204..e552a650986d8f 100644 --- a/deps/npm/man/man1/npm-root.1 +++ b/deps/npm/man/man1/npm-root.1 @@ -1,4 +1,4 @@ -.TH "NPM\-ROOT" "1" "April 2021" "" "" +.TH "NPM\-ROOT" "1" "May 2021" "" "" .SH "NAME" \fBnpm-root\fR \- Display npm root .SS Synopsis diff --git a/deps/npm/man/man1/npm-run-script.1 b/deps/npm/man/man1/npm-run-script.1 index 53b88e6fab99fd..22222c6541e968 100644 --- a/deps/npm/man/man1/npm-run-script.1 +++ b/deps/npm/man/man1/npm-run-script.1 @@ -1,4 +1,4 @@ -.TH "NPM\-RUN\-SCRIPT" "1" "April 2021" "" "" +.TH "NPM\-RUN\-SCRIPT" "1" "May 2021" "" "" .SH "NAME" \fBnpm-run-script\fR \- Run arbitrary package scripts .SS Synopsis diff --git a/deps/npm/man/man1/npm-search.1 b/deps/npm/man/man1/npm-search.1 index 068499dc99c291..5e889b15f62413 100644 --- a/deps/npm/man/man1/npm-search.1 +++ b/deps/npm/man/man1/npm-search.1 @@ -1,4 +1,4 @@ -.TH "NPM\-SEARCH" "1" "April 2021" "" "" +.TH "NPM\-SEARCH" "1" "May 2021" "" "" .SH "NAME" \fBnpm-search\fR \- Search for packages .SS Synopsis diff --git a/deps/npm/man/man1/npm-set-script.1 b/deps/npm/man/man1/npm-set-script.1 index f348099fb48aca..e9a380ee460e19 100644 --- a/deps/npm/man/man1/npm-set-script.1 +++ b/deps/npm/man/man1/npm-set-script.1 @@ -1,4 +1,4 @@ -.TH "NPM\-SET\-SCRIPT" "1" "April 2021" "" "" +.TH "NPM\-SET\-SCRIPT" "1" "May 2021" "" "" .SH "NAME" \fBnpm-set-script\fR \- Set tasks in the scripts section of package\.json .SS Synopsis diff --git a/deps/npm/man/man1/npm-shrinkwrap.1 b/deps/npm/man/man1/npm-shrinkwrap.1 index d349510e5a940c..a57ffb18187c21 100644 --- a/deps/npm/man/man1/npm-shrinkwrap.1 +++ b/deps/npm/man/man1/npm-shrinkwrap.1 @@ -1,4 +1,4 @@ -.TH "NPM\-SHRINKWRAP" "1" "April 2021" "" "" +.TH "NPM\-SHRINKWRAP" "1" "May 2021" "" "" .SH "NAME" \fBnpm-shrinkwrap\fR \- Lock down dependency versions for publication .SS Synopsis diff --git a/deps/npm/man/man1/npm-star.1 b/deps/npm/man/man1/npm-star.1 index e95168e243f948..49f91c6466e852 100644 --- a/deps/npm/man/man1/npm-star.1 +++ b/deps/npm/man/man1/npm-star.1 @@ -1,4 +1,4 @@ -.TH "NPM\-STAR" "1" "April 2021" "" "" +.TH "NPM\-STAR" "1" "May 2021" "" "" .SH "NAME" \fBnpm-star\fR \- Mark your favorite packages .SS Synopsis diff --git a/deps/npm/man/man1/npm-stars.1 b/deps/npm/man/man1/npm-stars.1 index fa16060953c24c..397cfea91fe5ec 100644 --- a/deps/npm/man/man1/npm-stars.1 +++ b/deps/npm/man/man1/npm-stars.1 @@ -1,4 +1,4 @@ -.TH "NPM\-STARS" "1" "April 2021" "" "" +.TH "NPM\-STARS" "1" "May 2021" "" "" .SH "NAME" \fBnpm-stars\fR \- View packages marked as favorites .SS Synopsis diff --git a/deps/npm/man/man1/npm-start.1 b/deps/npm/man/man1/npm-start.1 index 42d8b6cc96fe12..84bdff0140dd79 100644 --- a/deps/npm/man/man1/npm-start.1 +++ b/deps/npm/man/man1/npm-start.1 @@ -1,4 +1,4 @@ -.TH "NPM\-START" "1" "April 2021" "" "" +.TH "NPM\-START" "1" "May 2021" "" "" .SH "NAME" \fBnpm-start\fR \- Start a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-stop.1 b/deps/npm/man/man1/npm-stop.1 index 55be734ed48d3b..143aa56462d164 100644 --- a/deps/npm/man/man1/npm-stop.1 +++ b/deps/npm/man/man1/npm-stop.1 @@ -1,4 +1,4 @@ -.TH "NPM\-STOP" "1" "April 2021" "" "" +.TH "NPM\-STOP" "1" "May 2021" "" "" .SH "NAME" \fBnpm-stop\fR \- Stop a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-team.1 b/deps/npm/man/man1/npm-team.1 index 94aa9d89ccafd7..5816ea1d21bd7b 100644 --- a/deps/npm/man/man1/npm-team.1 +++ b/deps/npm/man/man1/npm-team.1 @@ -1,4 +1,4 @@ -.TH "NPM\-TEAM" "1" "April 2021" "" "" +.TH "NPM\-TEAM" "1" "May 2021" "" "" .SH "NAME" \fBnpm-team\fR \- Manage organization teams and team memberships .SS Synopsis diff --git a/deps/npm/man/man1/npm-test.1 b/deps/npm/man/man1/npm-test.1 index cedbe681982fcc..4dd4bc2335f758 100644 --- a/deps/npm/man/man1/npm-test.1 +++ b/deps/npm/man/man1/npm-test.1 @@ -1,4 +1,4 @@ -.TH "NPM\-TEST" "1" "April 2021" "" "" +.TH "NPM\-TEST" "1" "May 2021" "" "" .SH "NAME" \fBnpm-test\fR \- Test a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-token.1 b/deps/npm/man/man1/npm-token.1 index 5adf0cda6d8261..2b45db5fc4e03b 100644 --- a/deps/npm/man/man1/npm-token.1 +++ b/deps/npm/man/man1/npm-token.1 @@ -1,4 +1,4 @@ -.TH "NPM\-TOKEN" "1" "April 2021" "" "" +.TH "NPM\-TOKEN" "1" "May 2021" "" "" .SH "NAME" \fBnpm-token\fR \- Manage your authentication tokens .SS Synopsis diff --git a/deps/npm/man/man1/npm-uninstall.1 b/deps/npm/man/man1/npm-uninstall.1 index 0de9f431be36cd..0ee2fded986c47 100644 --- a/deps/npm/man/man1/npm-uninstall.1 +++ b/deps/npm/man/man1/npm-uninstall.1 @@ -1,4 +1,4 @@ -.TH "NPM\-UNINSTALL" "1" "April 2021" "" "" +.TH "NPM\-UNINSTALL" "1" "May 2021" "" "" .SH "NAME" \fBnpm-uninstall\fR \- Remove a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-unpublish.1 b/deps/npm/man/man1/npm-unpublish.1 index 9645ab106d0c11..e0e2a6c81b2f96 100644 --- a/deps/npm/man/man1/npm-unpublish.1 +++ b/deps/npm/man/man1/npm-unpublish.1 @@ -1,4 +1,4 @@ -.TH "NPM\-UNPUBLISH" "1" "April 2021" "" "" +.TH "NPM\-UNPUBLISH" "1" "May 2021" "" "" .SH "NAME" \fBnpm-unpublish\fR \- Remove a package from the registry .SS Synopsis diff --git a/deps/npm/man/man1/npm-unstar.1 b/deps/npm/man/man1/npm-unstar.1 index 86c152eb6d27fb..ec4cf6d2d1ff6f 100644 --- a/deps/npm/man/man1/npm-unstar.1 +++ b/deps/npm/man/man1/npm-unstar.1 @@ -1,4 +1,4 @@ -.TH "NPM\-UNSTAR" "1" "April 2021" "" "" +.TH "NPM\-UNSTAR" "1" "May 2021" "" "" .SH "NAME" \fBnpm-unstar\fR \- Remove an item from your favorite packages .SS Synopsis diff --git a/deps/npm/man/man1/npm-update.1 b/deps/npm/man/man1/npm-update.1 index adaebe92db336f..2ac1f9e8478e76 100644 --- a/deps/npm/man/man1/npm-update.1 +++ b/deps/npm/man/man1/npm-update.1 @@ -1,4 +1,4 @@ -.TH "NPM\-UPDATE" "1" "April 2021" "" "" +.TH "NPM\-UPDATE" "1" "May 2021" "" "" .SH "NAME" \fBnpm-update\fR \- Update packages .SS Synopsis diff --git a/deps/npm/man/man1/npm-version.1 b/deps/npm/man/man1/npm-version.1 index d926c9e5282eee..02de076a10c4c1 100644 --- a/deps/npm/man/man1/npm-version.1 +++ b/deps/npm/man/man1/npm-version.1 @@ -1,4 +1,4 @@ -.TH "NPM\-VERSION" "1" "April 2021" "" "" +.TH "NPM\-VERSION" "1" "May 2021" "" "" .SH "NAME" \fBnpm-version\fR \- Bump a package version .SS Synopsis diff --git a/deps/npm/man/man1/npm-view.1 b/deps/npm/man/man1/npm-view.1 index 498821fbb6ba9a..b3dac21b7572b1 100644 --- a/deps/npm/man/man1/npm-view.1 +++ b/deps/npm/man/man1/npm-view.1 @@ -1,4 +1,4 @@ -.TH "NPM\-VIEW" "1" "April 2021" "" "" +.TH "NPM\-VIEW" "1" "May 2021" "" "" .SH "NAME" \fBnpm-view\fR \- View registry info .SS Synopsis diff --git a/deps/npm/man/man1/npm-whoami.1 b/deps/npm/man/man1/npm-whoami.1 index c38b46dff07ab3..ed54f2f00bc682 100644 --- a/deps/npm/man/man1/npm-whoami.1 +++ b/deps/npm/man/man1/npm-whoami.1 @@ -1,4 +1,4 @@ -.TH "NPM\-WHOAMI" "1" "April 2021" "" "" +.TH "NPM\-WHOAMI" "1" "May 2021" "" "" .SH "NAME" \fBnpm-whoami\fR \- Display npm username .SS Synopsis diff --git a/deps/npm/man/man1/npm.1 b/deps/npm/man/man1/npm.1 index 8dbeca5362bba8..4562527e1b5ade 100644 --- a/deps/npm/man/man1/npm.1 +++ b/deps/npm/man/man1/npm.1 @@ -1,4 +1,4 @@ -.TH "NPM" "1" "April 2021" "" "" +.TH "NPM" "1" "May 2021" "" "" .SH "NAME" \fBnpm\fR \- javascript package manager .SS Synopsis @@ -10,7 +10,7 @@ npm [args] .RE .SS Version .P -7\.11\.2 +7\.12\.1 .SS Description .P npm is the package manager for the Node JavaScript platform\. It puts diff --git a/deps/npm/man/man1/npx.1 b/deps/npm/man/man1/npx.1 index 87c018f4121915..76305688fb0e73 100644 --- a/deps/npm/man/man1/npx.1 +++ b/deps/npm/man/man1/npx.1 @@ -1,4 +1,4 @@ -.TH "NPX" "1" "April 2021" "" "" +.TH "NPX" "1" "May 2021" "" "" .SH "NAME" \fBnpx\fR \- Run a command from a local or remote npm package .SS Synopsis diff --git a/deps/npm/man/man5/folders.5 b/deps/npm/man/man5/folders.5 index cacb710a03b030..ccf0c4f6e8f17a 100644 --- a/deps/npm/man/man5/folders.5 +++ b/deps/npm/man/man5/folders.5 @@ -1,4 +1,4 @@ -.TH "FOLDERS" "5" "April 2021" "" "" +.TH "FOLDERS" "5" "May 2021" "" "" .SH "NAME" \fBfolders\fR \- Folder Structures Used by npm .SS Description diff --git a/deps/npm/man/man5/install.5 b/deps/npm/man/man5/install.5 index 445353eb8565e0..5fc6f442a92268 100644 --- a/deps/npm/man/man5/install.5 +++ b/deps/npm/man/man5/install.5 @@ -1,4 +1,4 @@ -.TH "INSTALL" "5" "April 2021" "" "" +.TH "INSTALL" "5" "May 2021" "" "" .SH "NAME" \fBinstall\fR \- Download and install node and npm .SS Description diff --git a/deps/npm/man/man5/npm-shrinkwrap-json.5 b/deps/npm/man/man5/npm-shrinkwrap-json.5 index 27076ba3361fe9..2fdbdd139a9f82 100644 --- a/deps/npm/man/man5/npm-shrinkwrap-json.5 +++ b/deps/npm/man/man5/npm-shrinkwrap-json.5 @@ -1,4 +1,4 @@ -.TH "NPM\-SHRINKWRAP\.JSON" "5" "April 2021" "" "" +.TH "NPM\-SHRINKWRAP\.JSON" "5" "May 2021" "" "" .SH "NAME" \fBnpm-shrinkwrap.json\fR \- A publishable lockfile .SS Description diff --git a/deps/npm/man/man5/npmrc.5 b/deps/npm/man/man5/npmrc.5 index f880a269513a6b..1ecd71ff214540 100644 --- a/deps/npm/man/man5/npmrc.5 +++ b/deps/npm/man/man5/npmrc.5 @@ -1,4 +1,4 @@ -.TH "NPMRC" "5" "April 2021" "" "" +.TH "NPMRC" "5" "May 2021" "" "" .SH "NAME" \fBnpmrc\fR \- The npm config files .SS Description diff --git a/deps/npm/man/man5/package-json.5 b/deps/npm/man/man5/package-json.5 index a882e445ca0031..8b5b12e03829a6 100644 --- a/deps/npm/man/man5/package-json.5 +++ b/deps/npm/man/man5/package-json.5 @@ -1,4 +1,4 @@ -.TH "PACKAGE\.JSON" "5" "April 2021" "" "" +.TH "PACKAGE\.JSON" "5" "May 2021" "" "" .SH "NAME" \fBpackage.json\fR \- Specifics of npm's package\.json handling .SS Description @@ -624,7 +624,7 @@ tarball or git URL\. \fBPlease do not put test harnesses or transpilers or other "development" time tools in your \fBdependencies\fP object\.\fR See \fBdevDependencies\fP, below\. .P -See npm help semver for more details about specifying version ranges\. +See semver \fIhttps://github\.com/npm/node\-semver#versions\fR for more details about specifying version ranges\. .RS 0 .IP \(bu 2 \fBversion\fP Must match \fBversion\fP exactly diff --git a/deps/npm/man/man5/package-lock-json.5 b/deps/npm/man/man5/package-lock-json.5 index 765dd8499948a1..20bedd30009757 100644 --- a/deps/npm/man/man5/package-lock-json.5 +++ b/deps/npm/man/man5/package-lock-json.5 @@ -1,4 +1,4 @@ -.TH "PACKAGE\-LOCK\.JSON" "5" "April 2021" "" "" +.TH "PACKAGE\-LOCK\.JSON" "5" "May 2021" "" "" .SH "NAME" \fBpackage-lock.json\fR \- A manifestation of the manifest .SS Description diff --git a/deps/npm/man/man7/config.7 b/deps/npm/man/man7/config.7 index 522e974fc07089..b8884ded13e4d2 100644 --- a/deps/npm/man/man7/config.7 +++ b/deps/npm/man/man7/config.7 @@ -1,4 +1,4 @@ -.TH "CONFIG" "7" "April 2021" "" "" +.TH "CONFIG" "7" "May 2021" "" "" .SH "NAME" \fBconfig\fR \- More than you probably want to know about npm configuration .SS Description @@ -1666,7 +1666,8 @@ Show short usage output about the command specified\. .SS \fBuser\-agent\fP .RS 0 .IP \(bu 2 -Default: "npm/{npm\-version} node/{node\-version} {platform} {arch} {ci}" +Default: "npm/{npm\-version} node/{node\-version} {platform} {arch} +workspaces/{workspaces} {ci}" .IP \(bu 2 Type: String @@ -1684,6 +1685,9 @@ their actual counterparts: .IP \(bu 2 \fB{arch}\fP \- The value of \fBprocess\.arch\fP .IP \(bu 2 +\fB{workspaces}\fP \- Set to \fBtrue\fP if the \fBworkspaces\fP or \fBworkspace\fP options +are set\. +.IP \(bu 2 \fB{ci}\fP \- The value of the \fBci\-name\fP config, if set, prefixed with \fBci/\fP, or an empty string if \fBci\-name\fP is empty\. diff --git a/deps/npm/man/man7/developers.7 b/deps/npm/man/man7/developers.7 index 00dc1b14e2415b..0935fea65f509f 100644 --- a/deps/npm/man/man7/developers.7 +++ b/deps/npm/man/man7/developers.7 @@ -1,4 +1,4 @@ -.TH "DEVELOPERS" "7" "April 2021" "" "" +.TH "DEVELOPERS" "7" "May 2021" "" "" .SH "NAME" \fBdevelopers\fR \- Developer Guide .SS Description diff --git a/deps/npm/man/man7/orgs.7 b/deps/npm/man/man7/orgs.7 index 7f29cf2c239730..13c9b9dbadf1c3 100644 --- a/deps/npm/man/man7/orgs.7 +++ b/deps/npm/man/man7/orgs.7 @@ -1,4 +1,4 @@ -.TH "ORGS" "7" "April 2021" "" "" +.TH "ORGS" "7" "May 2021" "" "" .SH "NAME" \fBorgs\fR \- Working with Teams & Orgs .SS Description diff --git a/deps/npm/man/man7/registry.7 b/deps/npm/man/man7/registry.7 index 2ff87e4a4c45e8..941a1450073139 100644 --- a/deps/npm/man/man7/registry.7 +++ b/deps/npm/man/man7/registry.7 @@ -1,4 +1,4 @@ -.TH "REGISTRY" "7" "April 2021" "" "" +.TH "REGISTRY" "7" "May 2021" "" "" .SH "NAME" \fBregistry\fR \- The JavaScript Package Registry .SS Description diff --git a/deps/npm/man/man7/removal.7 b/deps/npm/man/man7/removal.7 index e3508f6696d720..ead032bfdf457d 100644 --- a/deps/npm/man/man7/removal.7 +++ b/deps/npm/man/man7/removal.7 @@ -1,4 +1,4 @@ -.TH "REMOVAL" "7" "April 2021" "" "" +.TH "REMOVAL" "7" "May 2021" "" "" .SH "NAME" \fBremoval\fR \- Cleaning the Slate .SS Synopsis diff --git a/deps/npm/man/man7/scope.7 b/deps/npm/man/man7/scope.7 index 2a0fa9e1c8ea7f..716946d732afb7 100644 --- a/deps/npm/man/man7/scope.7 +++ b/deps/npm/man/man7/scope.7 @@ -1,4 +1,4 @@ -.TH "SCOPE" "7" "April 2021" "" "" +.TH "SCOPE" "7" "May 2021" "" "" .SH "NAME" \fBscope\fR \- Scoped packages .SS Description diff --git a/deps/npm/man/man7/scripts.7 b/deps/npm/man/man7/scripts.7 index 2dc2486de7d51b..63ebce805b4d8f 100644 --- a/deps/npm/man/man7/scripts.7 +++ b/deps/npm/man/man7/scripts.7 @@ -1,4 +1,4 @@ -.TH "SCRIPTS" "7" "April 2021" "" "" +.TH "SCRIPTS" "7" "May 2021" "" "" .SH "NAME" \fBscripts\fR \- How npm handles the "scripts" field .SS Description @@ -160,13 +160,6 @@ These all run after the actual installation of modules into .IP \(bu 2 \fBprepare\fP -.RE -.SS npm help \fBenv\fP -.RS 0 -.IP \(bu 2 -\fBenv\fP (You can override the default behavior of \fBnpm env\fP by defining - a custom \fBenv\fP entry in your \fBscripts\fP object) - .RE .SS npm help \fBinstall\fP .P diff --git a/deps/npm/man/man7/workspaces.7 b/deps/npm/man/man7/workspaces.7 index 5b28ac54c5d1cb..dbb63528d6da75 100644 --- a/deps/npm/man/man7/workspaces.7 +++ b/deps/npm/man/man7/workspaces.7 @@ -1,4 +1,4 @@ -.TH "WORKSPACES" "7" "April 2021" "" "" +.TH "WORKSPACES" "7" "May 2021" "" "" .SH "NAME" \fBworkspaces\fR \- Working with workspaces .SS Description diff --git a/deps/npm/node_modules/@npmcli/arborist/CHANGELOG.md b/deps/npm/node_modules/@npmcli/arborist/CHANGELOG.md deleted file mode 100644 index 3cd36d027b6318..00000000000000 --- a/deps/npm/node_modules/@npmcli/arborist/CHANGELOG.md +++ /dev/null @@ -1,19 +0,0 @@ -# CHANGELOG - -## 2.0 - -* BREAKING CHANGE: root node is now included in inventory -* All parent/target/fsParent/etc. references set in `root` setter, rather - than the hodgepodge of setters that existed before. -* `treeCheck` function added, to enforce strict correctness guarantees when - `ARBORIST_DEBUG=1` in the environment (on by default in Arborist tests). - -## 1.0 - -* Release for npm v7 beta -* Fully functional - -## 0.0 - -* Proof of concept -* Before this, it was [`read-package-tree`](http://npm.im/read-package-tree) diff --git a/deps/npm/node_modules/@npmcli/arborist/bin/license.js b/deps/npm/node_modules/@npmcli/arborist/bin/license.js index 4083ddc695d467..89d0d879036b0c 100644 --- a/deps/npm/node_modules/@npmcli/arborist/bin/license.js +++ b/deps/npm/node_modules/@npmcli/arborist/bin/license.js @@ -22,7 +22,7 @@ a.loadVirtual().then(tree => { set.push([tree.inventory.query('license', license).size, license]) for (const [count, license] of set.sort((a, b) => - a[1] && b[1] ? b[0] - a[0] || a[1].localeCompare(b[1]) + a[1] && b[1] ? b[0] - a[0] || a[1].localeCompare(b[1], 'en') : a[1] ? -1 : b[1] ? 1 : 0)) diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/add-rm-pkg-deps.js b/deps/npm/node_modules/@npmcli/arborist/lib/add-rm-pkg-deps.js index 9a96fd1b3797cd..f78a43319be8cb 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/add-rm-pkg-deps.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/add-rm-pkg-deps.js @@ -1,60 +1,60 @@ // add and remove dependency specs to/from pkg manifest -const removeFromOthers = (name, type, pkg) => { - const others = new Set([ - 'dependencies', - 'optionalDependencies', - 'devDependencies', - 'peerDependenciesMeta', - 'peerDependencies', - ]) - - switch (type) { - case 'prod': - others.delete('dependencies') - break - case 'dev': - others.delete('devDependencies') - others.delete('peerDependencies') - others.delete('peerDependenciesMeta') - break - case 'optional': - others.delete('optionalDependencies') - break - case 'peer': - case 'peerOptional': - others.delete('devDependencies') - others.delete('peerDependencies') - others.delete('peerDependenciesMeta') - break - } - - for (const other of others) - deleteSubKey(pkg, other, name) -} - -const add = ({pkg, add, saveBundle, saveType}) => { +const add = ({pkg, add, saveBundle, saveType, log}) => { for (const spec of add) - addSingle({pkg, spec, saveBundle, saveType}) + addSingle({pkg, spec, saveBundle, saveType, log}) return pkg } -const addSingle = ({pkg, spec, saveBundle, saveType}) => { - if (!saveType) - saveType = getSaveType(pkg, spec) +// Canonical source of both the map between saveType and where it correlates to +// in the package, and the names of all our dependencies attributes +const saveTypeMap = new Map([ + ['dev', 'devDependencies'], + ['optional', 'optionalDependencies'], + ['prod', 'dependencies'], + ['peerOptional', 'peerDependencies'], + ['peer', 'peerDependencies'], +]) +const addSingle = ({pkg, spec, saveBundle, saveType, log}) => { const { name, rawSpec } = spec - removeFromOthers(name, saveType, pkg) - const type = saveType === 'prod' ? 'dependencies' - : saveType === 'optional' ? 'optionalDependencies' - : saveType === 'peer' || saveType === 'peerOptional' ? 'peerDependencies' - : saveType === 'dev' ? 'devDependencies' - : /* istanbul ignore next */ null - pkg[type] = pkg[type] || {} - if (rawSpec !== '' || pkg[type][name] === undefined) - pkg[type][name] = rawSpec || '*' + // if the user does not give us a type, we infer which type(s) + // to keep based on the same order of priority we do when + // building the tree as defined in the _loadDeps method of + // the node class. + if (!saveType) + saveType = inferSaveType(pkg, spec.name) + + if (saveType === 'prod') { + // a production dependency can only exist as production (rpj ensures it + // doesn't coexist w/ optional) + deleteSubKey(pkg, 'devDependencies', name, 'dependencies', log) + deleteSubKey(pkg, 'peerDependencies', name, 'dependencies', log) + } else if (saveType === 'dev') { + // a dev dependency may co-exist as peer, or optional, but not production + deleteSubKey(pkg, 'dependencies', name, 'devDependencies', log) + } else if (saveType === 'optional') { + // an optional dependency may co-exist as dev (rpj ensures it doesn't + // coexist w/ prod) + deleteSubKey(pkg, 'peerDependencies', name, 'optionalDependencies', log) + } else { // peer or peerOptional is all that's left + // a peer dependency may coexist as dev + deleteSubKey(pkg, 'dependencies', name, 'peerDependencies', log) + deleteSubKey(pkg, 'optionalDependencies', name, 'peerDependencies', log) + } + + const depType = saveTypeMap.get(saveType) + + pkg[depType] = pkg[depType] || {} + if (rawSpec !== '' || pkg[depType][name] === undefined) + pkg[depType][name] = rawSpec || '*' + if (saveType === 'optional') { + // Affordance for previous npm versions that require this behaviour + pkg.dependencies = pkg.dependencies || {} + pkg.dependencies[name] = pkg.optionalDependencies[name] + } if (saveType === 'peer' || saveType === 'peerOptional') { const pdm = pkg.peerDependenciesMeta || {} @@ -75,51 +75,53 @@ const addSingle = ({pkg, spec, saveBundle, saveType}) => { // keep it sorted, keep it unique const bd = new Set(pkg.bundleDependencies || []) bd.add(spec.name) - pkg.bundleDependencies = [...bd].sort((a, b) => a.localeCompare(b)) + pkg.bundleDependencies = [...bd].sort((a, b) => a.localeCompare(b, 'en')) } } -const getSaveType = (pkg, spec) => { - const {name} = spec - const { - // these names are so lonnnnngggg - devDependencies: devDeps, - optionalDependencies: optDeps, - peerDependencies: peerDeps, - peerDependenciesMeta: peerDepsMeta, - } = pkg - - if (peerDeps && peerDeps[name] !== undefined) { - if (peerDepsMeta && peerDepsMeta[name] && peerDepsMeta[name].optional) - return 'peerOptional' - else - return 'peer' - } else if (devDeps && devDeps[name] !== undefined) - return 'dev' - else if (optDeps && optDeps[name] !== undefined) - return 'optional' - else - return 'prod' +// Finds where the package is already in the spec and infers saveType from that +const inferSaveType = (pkg, name) => { + for (const saveType of saveTypeMap.keys()) { + if (hasSubKey(pkg, saveTypeMap.get(saveType), name)) { + if ( + saveType === 'peerOptional' && + (!hasSubKey(pkg, 'peerDependenciesMeta', name) || + !pkg.peerDependenciesMeta[name].optional) + ) + return 'peer' + return saveType + } + } + return 'prod' } -const deleteSubKey = (obj, k, sk) => { - if (obj[k]) { - delete obj[k][sk] - if (!Object.keys(obj[k]).length) - delete obj[k] +const hasSubKey = (pkg, depType, name) => { + return pkg[depType] && Object.prototype.hasOwnProperty.call(pkg[depType], name) +} + +// Removes a subkey and warns about it if it's being replaced +const deleteSubKey = (pkg, depType, name, replacedBy, log) => { + if (hasSubKey(pkg, depType, name)) { + if (replacedBy && log) + log.warn('idealTree', `Removing ${depType}.${name} in favor of ${replacedBy}.${name}`) + delete pkg[depType][name] + + // clean up peerDependenciesMeta if we are removing something from peerDependencies + if (depType === 'peerDependencies' && pkg.peerDependenciesMeta) { + delete pkg.peerDependenciesMeta[name] + if (!Object.keys(pkg.peerDependenciesMeta).length) + delete pkg.peerDependenciesMeta + } + + if (!Object.keys(pkg[depType]).length) + delete pkg[depType] } } const rm = (pkg, rm) => { - for (const type of [ - 'dependencies', - 'optionalDependencies', - 'peerDependencies', - 'peerDependenciesMeta', - 'devDependencies', - ]) { + for (const depType of new Set(saveTypeMap.values())) { for (const name of rm) - deleteSubKey(pkg, type, name) + deleteSubKey(pkg, depType, name) } if (pkg.bundleDependencies) { pkg.bundleDependencies = pkg.bundleDependencies @@ -130,4 +132,4 @@ const rm = (pkg, rm) => { return pkg } -module.exports = { add, rm } +module.exports = { add, rm, saveTypeMap, hasSubKey } diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js index 7ee8dae35be1b5..ade9bbf1a152f9 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js @@ -504,6 +504,7 @@ module.exports = cls => class IdealTreeBuilder extends cls { saveBundle, saveType, path: this.path, + log: this.log, }) }) } @@ -763,7 +764,7 @@ This is a one-time fix-up, please be patient... // sort physically shallower deps up to the front of the queue, // because they'll affect things deeper in, then alphabetical this[_depsQueue].sort((a, b) => - (a.depth - b.depth) || a.path.localeCompare(b.path)) + (a.depth - b.depth) || a.path.localeCompare(b.path, 'en')) const node = this[_depsQueue].shift() const bd = node.package.bundleDependencies @@ -901,7 +902,7 @@ This is a one-time fix-up, please be patient... } const placed = tasks - .sort((a, b) => a.edge.name.localeCompare(b.edge.name)) + .sort((a, b) => a.edge.name.localeCompare(b.edge.name, 'en')) .map(({ edge, dep }) => this[_placeDep](dep, node, edge)) const promises = [] @@ -1146,7 +1147,7 @@ This is a one-time fix-up, please be patient... // we typically only install non-optional peers, but we have to // factor them into the peerSet so that we can avoid conflicts .filter(e => e.peer && !(e.valid && e.to)) - .sort(({name: a}, {name: b}) => a.localeCompare(b)) + .sort(({name: a}, {name: b}) => a.localeCompare(b, 'en')) for (const edge of peerEdges) { // already placed this one, and we're happy with it. diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/index.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/index.js index 93b9aa38298208..3578d50389ea64 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/index.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/index.js @@ -29,6 +29,7 @@ const {resolve} = require('path') const {homedir} = require('os') const procLog = require('../proc-log.js') +const { saveTypeMap } = require('../add-rm-pkg-deps.js') const mixins = [ require('../tracker.js'), @@ -57,6 +58,8 @@ class Arborist extends Base { packumentCache: options.packumentCache || new Map(), log: options.log || procLog, } + if (options.saveType && !saveTypeMap.get(options.saveType)) + throw new Error(`Invalid saveType ${options.saveType}`) this.cache = resolve(this.options.cache) this.path = resolve(this.options.path) process.emit('timeEnd', 'arborist:ctor') diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js index 2a222249d7a482..a98ed23b2a458c 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js @@ -159,12 +159,12 @@ module.exports = cls => class VirtualLoader extends cls { ...depsToEdges('peerOptional', peerOptional), ...lockWS, ].sort(([atype, aname], [btype, bname]) => - atype.localeCompare(btype) || aname.localeCompare(bname)) + atype.localeCompare(btype, 'en') || aname.localeCompare(bname, 'en')) const rootEdges = [...root.edgesOut.values()] .map(e => [e.type, e.name, e.spec]) .sort(([atype, aname], [btype, bname]) => - atype.localeCompare(btype) || aname.localeCompare(bname)) + atype.localeCompare(btype, 'en') || aname.localeCompare(bname, 'en')) if (rootEdges.length !== lockEdges.length) { // something added or removed diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js index 390d3ce42aecd2..7cba1da00008ae 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js @@ -14,7 +14,7 @@ const { } = require('@npmcli/node-gyp') const boolEnv = b => b ? '1' : '' -const sortNodes = (a, b) => (a.depth - b.depth) || a.path.localeCompare(b.path) +const sortNodes = (a, b) => (a.depth - b.depth) || a.path.localeCompare(b.path, 'en') const _build = Symbol('build') const _resetQueues = Symbol('resetQueues') diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js index 64f08756263c72..b09a9e0fe16d7a 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js @@ -3,9 +3,8 @@ const onExit = require('../signal-handling.js') const pacote = require('pacote') const rpj = require('read-package-json-fast') -const { updateDepSpec } = require('../dep-spec.js') const AuditReport = require('../audit-report.js') -const {subset} = require('semver') +const {subset, intersects} = require('semver') const npa = require('npm-package-arg') const {dirname, resolve, relative} = require('path') @@ -28,6 +27,7 @@ const promiseAllRejectLate = require('promise-all-reject-late') const optionalSet = require('../optional-set.js') const updateRootPackageJson = require('../update-root-package-json.js') const calcDepFlags = require('../calc-dep-flags.js') +const { saveTypeMap, hasSubKey } = require('../add-rm-pkg-deps.js') const _retiredPaths = Symbol('retiredPaths') const _retiredUnchanged = Symbol('retiredUnchanged') @@ -406,11 +406,14 @@ module.exports = cls => class Reifier extends cls { return process.emit('time', 'reify:trashOmits') + // node.parent is checked to make sure this is a node that's in the tree, and + // not the parent-less top level nodes const filter = node => - node.peer && this[_omitPeer] || - node.dev && this[_omitDev] || - node.optional && this[_omitOptional] || - node.devOptional && this[_omitOptional] && this[_omitDev] + node.isDescendantOf(this.idealTree) && + (node.peer && this[_omitPeer] || + node.dev && this[_omitDev] || + node.optional && this[_omitOptional] || + node.devOptional && this[_omitOptional] && this[_omitDev]) for (const node of this.idealTree.inventory.filter(filter)) this[_addNodeToTrashList](node) @@ -539,8 +542,8 @@ module.exports = cls => class Reifier extends cls { // Do the best with what we have, or else remove it from the tree // entirely, since we can't possibly reify it. const res = node.resolved ? `${node.name}@${this[_registryResolved](node.resolved)}` - : node.package.name && node.version - ? `${node.package.name}@${node.version}` + : node.packageName && node.version + ? `${node.packageName}@${node.version}` : null // no idea what this thing is. remove it from the tree. @@ -959,6 +962,7 @@ module.exports = cls => class Reifier extends cls { const spec = subSpec ? subSpec.rawSpec : rawSpec const child = root.children.get(name) + let newSpec if (req.registry) { const version = child.version const prefixRange = version ? this[_savePrefix] + version : '*' @@ -968,18 +972,26 @@ module.exports = cls => class Reifier extends cls { // would allow versions outside the requested range. Tags and // specific versions save with the save-prefix. const isRange = (subSpec || req).type === 'range' - const range = !isRange || subset(prefixRange, spec, { loose: true }) - ? prefixRange : spec - const pname = child.package.name + + let range = spec + if ( + !isRange || + spec === '*' || + subset(prefixRange, spec, { loose: true }) + ) + range = prefixRange + + const pname = child.packageName const alias = name !== pname - updateDepSpec(pkg, name, (alias ? `npm:${pname}@` : '') + range) + newSpec = alias ? `npm:${pname}@${range}` : range } else if (req.hosted) { // save the git+https url if it has auth, otherwise shortcut const h = req.hosted const opt = { noCommittish: false } - const save = h.https && h.auth ? `git+${h.https(opt)}` - : h.shortcut(opt) - updateDepSpec(pkg, name, save) + if (h.https && h.auth) + newSpec = `git+${h.https(opt)}` + else + newSpec = h.shortcut(opt) } else if (req.type === 'directory' || req.type === 'file') { // save the relative path in package.json // Normally saveSpec is updated with the proper relative @@ -988,9 +1000,37 @@ module.exports = cls => class Reifier extends cls { // thing, so just get the ultimate fetchSpec and relativize it. const p = req.fetchSpec.replace(/^file:/, '') const rel = relpath(root.realpath, p) - updateDepSpec(pkg, name, `file:${rel}`) + newSpec = `file:${rel}` } else - updateDepSpec(pkg, name, req.saveSpec) + newSpec = req.saveSpec + + if (options.saveType) { + const depType = saveTypeMap.get(options.saveType) + pkg[depType][name] = newSpec + // rpj will have moved it here if it was in both + // if it is empty it will be deleted later + if (options.saveType === 'prod' && pkg.optionalDependencies) + delete pkg.optionalDependencies[name] + } else { + if (hasSubKey(pkg, 'dependencies', name)) + pkg.dependencies[name] = newSpec + + if (hasSubKey(pkg, 'devDependencies', name)) { + pkg.devDependencies[name] = newSpec + // don't update peer or optional if we don't have to + if (hasSubKey(pkg, 'peerDependencies', name) && !intersects(newSpec, pkg.peerDependencies[name])) + pkg.peerDependencies[name] = newSpec + + if (hasSubKey(pkg, 'optionalDependencies', name) && !intersects(newSpec, pkg.optionalDependencies[name])) + pkg.optionalDependencies[name] = newSpec + } else { + if (hasSubKey(pkg, 'peerDependencies', name)) + pkg.peerDependencies[name] = newSpec + + if (hasSubKey(pkg, 'optionalDependencies', name)) + pkg.optionalDependencies[name] = newSpec + } + } } // refresh the edges so they have the correct specs diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/audit-report.js b/deps/npm/node_modules/@npmcli/arborist/lib/audit-report.js index 77cd6511aea3b5..76387cde1d66ab 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/audit-report.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/audit-report.js @@ -78,7 +78,7 @@ class AuditReport extends Map { } obj.vulnerabilities = vulnerabilities - .sort(([a], [b]) => a.localeCompare(b)) + .sort(([a], [b]) => a.localeCompare(b, 'en')) .reduce((set, [name, vuln]) => { set[name] = vuln return set @@ -101,13 +101,14 @@ class AuditReport extends Map { async run () { this.report = await this[_getReport]() + this.log.silly('audit report', this.report) if (this.report) await this[_init]() return this } isVulnerable (node) { - const vuln = this.get(node.package.name) + const vuln = this.get(node.packageName) return !!(vuln && vuln.isVulnerable(node)) } @@ -144,7 +145,7 @@ class AuditReport extends Map { super.set(name, vuln) const p = [] - for (const node of this.tree.inventory.query('name', name)) { + for (const node of this.tree.inventory.query('packageName', name)) { if (shouldOmit(node, this[_omit])) continue @@ -167,7 +168,7 @@ class AuditReport extends Map { this[_checkTopNode](dep, vuln, spec) else { // calculate a metavuln, if necessary - p.push(this.calculator.calculate(dep.name, advisory).then(meta => { + p.push(this.calculator.calculate(dep.packageName, advisory).then(meta => { if (meta.testVersion(dep.version, spec)) advisories.add(meta) })) @@ -228,6 +229,9 @@ class AuditReport extends Map { if (!specObj.registry) return false + if (specObj.subSpec) + spec = specObj.subSpec.rawSpec + // We don't provide fixes for top nodes other than root, but we // still check to see if the node is fixable with a different version, // and if that is a semver major bump. @@ -289,6 +293,7 @@ class AuditReport extends Map { try { // first try the super fast bulk advisory listing const body = prepareBulkData(this.tree, this[_omit]) + this.log.silly('audit', 'bulk request', body) // no sense asking if we don't have anything to audit, // we know it'll be empty @@ -304,7 +309,8 @@ class AuditReport extends Map { }) return await res.json() - } catch (_) { + } catch (er) { + this.log.silly('audit', 'bulk request failed', String(er.body)) // that failed, try the quick audit endpoint const body = prepareData(this.tree, this.options) const res = await fetch('/-/npm/v1/security/audits/quick', { @@ -330,6 +336,7 @@ class AuditReport extends Map { // return true if we should ignore this one const shouldOmit = (node, omit) => !node.version ? true + : node.isRoot ? true : omit.size === 0 ? false : node.dev && omit.has('dev') || node.optional && omit.has('optional') || @@ -338,9 +345,9 @@ const shouldOmit = (node, omit) => const prepareBulkData = (tree, omit) => { const payload = {} - for (const name of tree.inventory.query('name')) { + for (const name of tree.inventory.query('packageName')) { const set = new Set() - for (const node of tree.inventory.query('name', name)) { + for (const node of tree.inventory.query('packageName', name)) { if (shouldOmit(node, omit)) continue diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/dep-spec.js b/deps/npm/node_modules/@npmcli/arborist/lib/dep-spec.js deleted file mode 100644 index 92911543e16841..00000000000000 --- a/deps/npm/node_modules/@npmcli/arborist/lib/dep-spec.js +++ /dev/null @@ -1,43 +0,0 @@ -const types = [ - 'peerDependencies', - 'devDependencies', - 'optionalDependencies', - 'dependencies', -] - -const findType = (pkg, name) => { - for (const t of types) { - if (pkg[t] && typeof pkg[t] === 'object' && pkg[t][name] !== undefined) - return t - } - return 'dependencies' -} - -// given a dep name and spec, update it wherever it exists in -// the manifest, or add the spec to 'dependencies' if not found. -const updateDepSpec = (pkg, name, newSpec) => { - const type = findType(pkg, name) - pkg[type] = pkg[type] || {} - pkg[type][name] = newSpec - return pkg -} - -// sort alphabetically all types of deps for a given package -const orderDeps = (pkg) => { - for (const type of types) { - if (pkg && pkg[type]) { - pkg[type] = Object.keys(pkg[type]) - .sort((a, b) => a.localeCompare(b)) - .reduce((res, key) => { - res[key] = pkg[type][key] - return res - }, {}) - } - } - return pkg -} - -module.exports = { - orderDeps, - updateDepSpec, -} diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/inventory.js b/deps/npm/node_modules/@npmcli/arborist/lib/inventory.js index cef0c4e2658998..75782918852232 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/inventory.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/inventory.js @@ -4,7 +4,7 @@ // keys is the set of fields to be able to query. const _primaryKey = Symbol('_primaryKey') const _index = Symbol('_index') -const defaultKeys = ['name', 'license', 'funding', 'realpath'] +const defaultKeys = ['name', 'license', 'funding', 'realpath', 'packageName'] const { hasOwnProperty } = Object.prototype const debug = require('./debug.js') class Inventory extends Map { diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/node.js b/deps/npm/node_modules/@npmcli/arborist/lib/node.js index a54f76afcdf3b3..370bfc9567d287 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/node.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/node.js @@ -291,6 +291,10 @@ class Node { return this[_package].version || '' } + get packageName () { + return this[_package].name || null + } + get pkgid () { const { name = '', version = '' } = this.package // root package will prefer package name over folder name, @@ -350,10 +354,10 @@ class Node { } const why = { - name: this.isProjectRoot ? this.package.name : this.name, + name: this.isProjectRoot ? this.packageName : this.name, version: this.package.version, } - if (this.errors.length || !this.package.name || !this.package.version) { + if (this.errors.length || !this.packageName || !this.package.version) { why.errors = this.errors.length ? this.errors : [ new Error('invalid package: lacks name and/or version'), ] @@ -460,7 +464,7 @@ class Node { if (this.isProjectRoot) return false const { root } = this - const { type, to } = root.edgesOut.get(this.package.name) || {} + const { type, to } = root.edgesOut.get(this.packageName) || {} return type === 'workspace' && to && (to.target === this || to === this) } @@ -730,20 +734,14 @@ class Node { [_loadDeps] () { // Caveat! Order is relevant! - // packages in optionalDependencies and prod/peer/dev are - // optional. Packages in both deps and devDeps are required. + // Packages in optionalDependencies are optional. + // Packages in both deps and devDeps are required. // Note the subtle breaking change from v6: it is no longer possible // to have a different spec for a devDep than production dep. - this[_loadDepType](this.package.optionalDependencies, 'optional') // Linked targets that are disconnected from the tree are tops, // but don't have a 'path' field, only a 'realpath', because we // don't know their canonical location. We don't need their devDeps. - const { isTop, path, sourceReference } = this - const { isTop: srcTop, path: srcPath } = sourceReference || {} - if (isTop && path && (!sourceReference || srcTop && srcPath)) - this[_loadDepType](this.package.devDependencies, 'dev') - const pd = this.package.peerDependencies if (pd && typeof pd === 'object' && !this.legacyPeerDeps) { const pm = this.package.peerDependenciesMeta || {} @@ -760,19 +758,22 @@ class Node { } this[_loadDepType](this.package.dependencies, 'prod') + this[_loadDepType](this.package.optionalDependencies, 'optional') + + const { isTop, path, sourceReference } = this + const { isTop: srcTop, path: srcPath } = sourceReference || {} + if (isTop && path && (!sourceReference || srcTop && srcPath)) + this[_loadDepType](this.package.devDependencies, 'dev') } - [_loadDepType] (obj, type) { - const from = this + [_loadDepType] (deps, type) { const ad = this.package.acceptDependencies || {} - for (const [name, spec] of Object.entries(obj || {})) { - const accept = ad[name] - // if it's already set, then we keep the existing edge - // Prod deps should not be marked as dev, however. - // NB: the Edge ctor adds itself to from.edgesOut + // Because of the order in which _loadDeps runs, we always want to + // prioritize a new edge over an existing one + for (const [name, spec] of Object.entries(deps || {})) { const current = this.edgesOut.get(name) - if (!current || current.dev && type === 'prod') - new Edge({ from, name, spec, accept, type }) + if (!current || current.type !== 'workspace') + new Edge({ from: this, name, spec, accept: ad[name], type }) } } @@ -965,8 +966,8 @@ class Node { // if no resolved, check both package name and version // otherwise, conclude that they are different things - return this.package.name && node.package.name && - this.package.name === node.package.name && + return this.packageName && node.packageName && + this.packageName === node.packageName && this.version && node.version && this.version === node.version } diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/printable.js b/deps/npm/node_modules/@npmcli/arborist/lib/printable.js index 79f46a9e93c4a6..ce764071dc62aa 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/printable.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/printable.js @@ -7,8 +7,8 @@ const relpath = require('./relpath.js') class ArboristNode { constructor (tree, path) { this.name = tree.name - if (tree.package.name && tree.package.name !== this.name) - this.packageName = tree.package.name + if (tree.packageName && tree.packageName !== this.name) + this.packageName = tree.packageName if (tree.version) this.version = tree.version this.location = tree.location @@ -46,14 +46,14 @@ class ArboristNode { // edgesOut sorted by name if (tree.edgesOut.size) { this.edgesOut = new Map([...tree.edgesOut.entries()] - .sort(([a], [b]) => a.localeCompare(b)) + .sort(([a], [b]) => a.localeCompare(b, 'en')) .map(([name, edge]) => [name, new EdgeOut(edge)])) } // edgesIn sorted by location if (tree.edgesIn.size) { this.edgesIn = new Set([...tree.edgesIn] - .sort((a, b) => a.from.location.localeCompare(b.from.location)) + .sort((a, b) => a.from.location.localeCompare(b.from.location, 'en')) .map(edge => new EdgeIn(edge))) } @@ -65,14 +65,14 @@ class ArboristNode { // fsChildren sorted by path if (tree.fsChildren.size) { this.fsChildren = new Set([...tree.fsChildren] - .sort(({path: a}, {path: b}) => a.localeCompare(b)) + .sort(({path: a}, {path: b}) => a.localeCompare(b, 'en')) .map(tree => printableTree(tree, path))) } // children sorted by name if (tree.children.size) { this.children = new Map([...tree.children.entries()] - .sort(([a], [b]) => a.localeCompare(b)) + .sort(([a], [b]) => a.localeCompare(b, 'en')) .map(([name, tree]) => [name, printableTree(tree, path)])) } } diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/shrinkwrap.js b/deps/npm/node_modules/@npmcli/arborist/lib/shrinkwrap.js index 342e78e9e3a7b1..cff9f09633dfce 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/shrinkwrap.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/shrinkwrap.js @@ -254,7 +254,7 @@ class Shrinkwrap { meta[key.replace(/^_/, '')] = val }) // we only include name if different from the node path name - const pname = node.package.name + const pname = node.packageName if (pname && pname !== node.name) meta.name = pname @@ -825,7 +825,7 @@ class Shrinkwrap { [_buildLegacyLockfile] (node, lock, path = []) { if (node === this.tree) { // the root node - lock.name = node.package.name || node.name + lock.name = node.packageName || node.name if (node.version) lock.version = node.version } @@ -844,7 +844,7 @@ class Shrinkwrap { /* istanbul ignore next - sort calling order is indeterminate */ return aloc.length > bloc.length ? 1 : bloc.length > aloc.length ? -1 - : aloc[aloc.length - 1].localeCompare(bloc[bloc.length - 1]) + : aloc[aloc.length - 1].localeCompare(bloc[bloc.length - 1], 'en') })[0] const res = consistentResolve(node.resolved, this.path, this.path, true) @@ -870,9 +870,9 @@ class Shrinkwrap { lock.from = spec.raw } else if (!node.isRoot && node.package && - node.package.name && - node.package.name !== node.name) - lock.version = `npm:${node.package.name}@${node.version}` + node.packageName && + node.packageName !== node.name) + lock.version = `npm:${node.packageName}@${node.version}` else if (node.package && node.version) lock.version = node.version diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/update-root-package-json.js b/deps/npm/node_modules/@npmcli/arborist/lib/update-root-package-json.js index aba5614924ec77..57ec414248756c 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/update-root-package-json.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/update-root-package-json.js @@ -6,8 +6,6 @@ const {resolve} = require('path') const parseJSON = require('json-parse-even-better-errors') -const { orderDeps } = require('./dep-spec.js') - const depTypes = new Set([ 'dependencies', 'optionalDependencies', @@ -15,6 +13,20 @@ const depTypes = new Set([ 'peerDependencies', ]) +// sort alphabetically all types of deps for a given package +const orderDeps = (pkg) => { + for (const type of depTypes) { + if (pkg && pkg[type]) { + pkg[type] = Object.keys(pkg[type]) + .sort((a, b) => a.localeCompare(b, 'en')) + .reduce((res, key) => { + res[key] = pkg[type][key] + return res + }, {}) + } + } + return pkg +} const parseJsonSafe = json => { try { return parseJSON(json) diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/vuln.js b/deps/npm/node_modules/@npmcli/arborist/lib/vuln.js index 8f887a3fc96cb0..5b1d1dc1ab83d5 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/vuln.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/vuln.js @@ -83,6 +83,9 @@ class Vuln { if (!specObj.registry) return true + if (specObj.subSpec) + spec = specObj.subSpec.rawSpec + for (const v of this.versions) { if (satisfies(v, spec) && !satisfies(v, this.range, semverOpt)) return false @@ -103,12 +106,12 @@ class Vuln { vulnerableVersions: undefined, id: undefined, }).sort((a, b) => - String(a.source || a).localeCompare(String(b.source || b))), + String(a.source || a).localeCompare(String(b.source || b, 'en'))), effects: [...this.effects].map(v => v.name) - .sort(/* istanbul ignore next */(a, b) => a.localeCompare(b)), + .sort(/* istanbul ignore next */(a, b) => a.localeCompare(b, 'en')), range: this.simpleRange, nodes: [...this.nodes].map(n => n.location) - .sort(/* istanbul ignore next */(a, b) => a.localeCompare(b)), + .sort(/* istanbul ignore next */(a, b) => a.localeCompare(b, 'en')), fixAvailable: this[_fixAvailable], } } diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/yarn-lock.js b/deps/npm/node_modules/@npmcli/arborist/lib/yarn-lock.js index 14c7691f1bd42c..e237cc5c6a4614 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/yarn-lock.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/yarn-lock.js @@ -34,7 +34,7 @@ const {breadth} = require('treeverse') // sort a key/value object into a string of JSON stringified keys and vals const sortKV = obj => Object.keys(obj) - .sort((a, b) => a.localeCompare(b)) + .sort((a, b) => a.localeCompare(b, 'en')) .map(k => ` ${JSON.stringify(k)} ${JSON.stringify(obj[k])}`) .join('\n') @@ -165,7 +165,7 @@ class YarnLock { toString () { return prefix + [...new Set([...this.entries.values()])] .map(e => e.toString()) - .sort((a, b) => a.localeCompare(b)).join('\n\n') + '\n' + .sort((a, b) => a.localeCompare(b, 'en')).join('\n\n') + '\n' } fromTree (tree) { @@ -175,7 +175,7 @@ class YarnLock { tree, visit: node => this.addEntryFromNode(node), getChildren: node => [...node.children.values(), ...node.fsChildren] - .sort((a, b) => a.depth - b.depth || a.name.localeCompare(b.name)), + .sort((a, b) => a.depth - b.depth || a.name.localeCompare(b.name, 'en')), }) return this } @@ -183,7 +183,7 @@ class YarnLock { addEntryFromNode (node) { const specs = [...node.edgesIn] .map(e => `${node.name}@${e.spec}`) - .sort((a, b) => a.localeCompare(b)) + .sort((a, b) => a.localeCompare(b, 'en')) // Note: // yarn will do excessive duplication in a case like this: @@ -309,7 +309,7 @@ class YarnLockEntry { toString () { // sort objects to the bottom, then alphabetical return ([...this[_specs]] - .sort((a, b) => a.localeCompare(b)) + .sort((a, b) => a.localeCompare(b, 'en')) .map(JSON.stringify).join(', ') + ':\n' + Object.getOwnPropertyNames(this) @@ -318,7 +318,7 @@ class YarnLockEntry { (a, b) => /* istanbul ignore next - sort call order is unpredictable */ (typeof this[a] === 'object') === (typeof this[b] === 'object') - ? a.localeCompare(b) + ? a.localeCompare(b, 'en') : typeof this[a] === 'object' ? 1 : -1) .map(prop => typeof this[prop] !== 'object' diff --git a/deps/npm/node_modules/@npmcli/arborist/package.json b/deps/npm/node_modules/@npmcli/arborist/package.json index e7ac932e08d8f3..bbe87d8bf97ad2 100644 --- a/deps/npm/node_modules/@npmcli/arborist/package.json +++ b/deps/npm/node_modules/@npmcli/arborist/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/arborist", - "version": "2.4.1", + "version": "2.4.4", "description": "Manage node_modules trees", "dependencies": { "@npmcli/installed-package-contents": "^1.0.7", @@ -14,7 +14,7 @@ "cacache": "^15.0.3", "common-ancestor-path": "^1.0.1", "json-parse-even-better-errors": "^2.3.1", - "json-stringify-nice": "^1.1.2", + "json-stringify-nice": "^1.1.4", "mkdirp-infer-owner": "^2.0.0", "npm-install-checks": "^4.0.0", "npm-package-arg": "^8.1.0", @@ -40,9 +40,8 @@ "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.1", "minify-registry-metadata": "^2.1.0", - "mutate-fs": "^2.1.1", - "tap": "^15.0.4", - "tcompare": "^3.0.4" + "tap": "^15.0.9", + "tcompare": "^5.0.6" }, "scripts": { "test": "npm run test-only --", @@ -74,11 +73,13 @@ "bin": { "arborist": "bin/index.js" }, + "//": "sk test-env locale to catch locale-specific sorting", "tap": { "after": "test/fixtures/cleanup.js", "coverage-map": "map.js", "test-env": [ - "NODE_OPTIONS=--no-warnings" + "NODE_OPTIONS=--no-warnings", + "LC_ALL=sk" ], "node-arg": [ "--no-warnings", diff --git a/deps/npm/node_modules/@npmcli/git/lib/clone.js b/deps/npm/node_modules/@npmcli/git/lib/clone.js index 1fea5acc846211..6754fd7606009d 100644 --- a/deps/npm/node_modules/@npmcli/git/lib/clone.js +++ b/deps/npm/node_modules/@npmcli/git/lib/clone.js @@ -30,7 +30,7 @@ const pickManifest = require('npm-pick-manifest') const fs = require('fs') const mkdirp = require('mkdirp') -module.exports = (repo, ref = 'HEAD', target = null, /* istanbul ignore next */ opts = {}) => +module.exports = (repo, ref = 'HEAD', target = null, opts = {}) => revs(repo, opts).then(revs => clone( repo, revs, diff --git a/deps/npm/node_modules/@npmcli/git/lib/spawn.js b/deps/npm/node_modules/@npmcli/git/lib/spawn.js index cee3a7baf40788..337164a9a012dc 100644 --- a/deps/npm/node_modules/@npmcli/git/lib/spawn.js +++ b/deps/npm/node_modules/@npmcli/git/lib/spawn.js @@ -10,6 +10,11 @@ module.exports = (gitArgs, opts = {}) => { if (gitPath instanceof Error) { return Promise.reject(gitPath) } + // undocumented option, mostly only here for tests + const args = opts.allowReplace || gitArgs[0] === '--no-replace-objects' + ? gitArgs + : ['--no-replace-objects', ...gitArgs] + const log = opts.log || procLog let retry = opts.retry if (retry === null || retry === undefined) { @@ -22,11 +27,11 @@ module.exports = (gitArgs, opts = {}) => { } return promiseRetry((retry, number) => { if (number !== 1) { - log.silly('pacote', `Retrying git command: ${ - gitArgs.join(' ')} attempt # ${number}`) + log.silly('git', `Retrying git command: ${ + args.join(' ')} attempt # ${number}`) } - return spawn(gitPath, gitArgs, makeOpts(opts)) + return spawn(gitPath, args, makeOpts(opts)) .catch(er => { if (!shouldRetry(er.stderr, number)) { throw er diff --git a/deps/npm/node_modules/@npmcli/git/package.json b/deps/npm/node_modules/@npmcli/git/package.json index 9b368c31e262db..0fe94686ece20c 100644 --- a/deps/npm/node_modules/@npmcli/git/package.json +++ b/deps/npm/node_modules/@npmcli/git/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/git", - "version": "2.0.8", + "version": "2.0.9", "main": "lib/index.js", "files": [ "lib/*.js" @@ -29,7 +29,7 @@ "devDependencies": { "slash": "^3.0.0", "standard": "^16.0.3", - "tap": "^14.11.0" + "tap": "^15.0.6" }, "dependencies": { "@npmcli/promise-spawn": "^1.3.2", diff --git a/deps/npm/node_modules/glob/README.md b/deps/npm/node_modules/glob/README.md index 0916a48255cd6f..2dde30a597d77c 100644 --- a/deps/npm/node_modules/glob/README.md +++ b/deps/npm/node_modules/glob/README.md @@ -7,7 +7,7 @@ Match files using the patterns the shell uses, like stars and stuff. This is a glob implementation in JavaScript. It uses the `minimatch` library to do its matching. -![](logo/glob.png) +![a fun cartoon logo made of glob characters](logo/glob.png) ## Usage diff --git a/deps/npm/node_modules/glob/common.js b/deps/npm/node_modules/glob/common.js index 66651bb3aac655..d14157a0aec8a2 100644 --- a/deps/npm/node_modules/glob/common.js +++ b/deps/npm/node_modules/glob/common.js @@ -1,5 +1,3 @@ -exports.alphasort = alphasort -exports.alphasorti = alphasorti exports.setopts = setopts exports.ownProp = ownProp exports.makeAbs = makeAbs @@ -17,12 +15,8 @@ var minimatch = require("minimatch") var isAbsolute = require("path-is-absolute") var Minimatch = minimatch.Minimatch -function alphasorti (a, b) { - return a.toLowerCase().localeCompare(b.toLowerCase()) -} - function alphasort (a, b) { - return a.localeCompare(b) + return a.localeCompare(b, 'en') } function setupIgnores (self, options) { @@ -150,7 +144,7 @@ function finish (self) { all = Object.keys(all) if (!self.nosort) - all = all.sort(self.nocase ? alphasorti : alphasort) + all = all.sort(alphasort) // at *some* point we statted all of these if (self.mark) { diff --git a/deps/npm/node_modules/glob/glob.js b/deps/npm/node_modules/glob/glob.js index 58dec0f6c2bd0b..dc27aef10b344c 100644 --- a/deps/npm/node_modules/glob/glob.js +++ b/deps/npm/node_modules/glob/glob.js @@ -51,8 +51,6 @@ var assert = require('assert') var isAbsolute = require('path-is-absolute') var globSync = require('./sync.js') var common = require('./common.js') -var alphasort = common.alphasort -var alphasorti = common.alphasorti var setopts = common.setopts var ownProp = common.ownProp var inflight = require('inflight') diff --git a/deps/npm/node_modules/glob/package.json b/deps/npm/node_modules/glob/package.json index 6477c3070cb14e..b345ae1e9fd833 100644 --- a/deps/npm/node_modules/glob/package.json +++ b/deps/npm/node_modules/glob/package.json @@ -2,7 +2,7 @@ "author": "Isaac Z. Schlueter (http://blog.izs.me/)", "name": "glob", "description": "a little globber", - "version": "7.1.6", + "version": "7.1.7", "repository": { "type": "git", "url": "git://github.com/isaacs/node-glob.git" @@ -27,13 +27,18 @@ "devDependencies": { "mkdirp": "0", "rimraf": "^2.2.8", - "tap": "^12.0.1", + "tap": "^15.0.6", "tick": "0.0.6" }, + "tap": { + "before": "test/00-setup.js", + "after": "test/zz-cleanup.js", + "jobs": 1 + }, "scripts": { "prepublish": "npm run benchclean", "profclean": "rm -f v8.log profile.txt", - "test": "tap test/*.js --cov", + "test": "tap", "test-regen": "npm run profclean && TEST_REGEN=1 node test/00-setup.js", "bench": "bash benchmark.sh", "prof": "bash prof.sh && cat profile.txt", diff --git a/deps/npm/node_modules/glob/sync.js b/deps/npm/node_modules/glob/sync.js index c952134baa7ec0..10b0ed2c0026b1 100644 --- a/deps/npm/node_modules/glob/sync.js +++ b/deps/npm/node_modules/glob/sync.js @@ -11,8 +11,6 @@ var path = require('path') var assert = require('assert') var isAbsolute = require('path-is-absolute') var common = require('./common.js') -var alphasort = common.alphasort -var alphasorti = common.alphasorti var setopts = common.setopts var ownProp = common.ownProp var childrenIgnored = common.childrenIgnored diff --git a/deps/npm/node_modules/ignore-walk/index.js b/deps/npm/node_modules/ignore-walk/index.js index eec6851804a996..c01d57de2a0391 100644 --- a/deps/npm/node_modules/ignore-walk/index.js +++ b/deps/npm/node_modules/ignore-walk/index.js @@ -23,7 +23,7 @@ class Walker extends EE { } sort (a, b) { - return a.localeCompare(b) + return a.localeCompare(b, 'en') } emit (ev, data) { diff --git a/deps/npm/node_modules/ignore-walk/package.json b/deps/npm/node_modules/ignore-walk/package.json index 99d2c2e64de9df..7d48b977e0702c 100644 --- a/deps/npm/node_modules/ignore-walk/package.json +++ b/deps/npm/node_modules/ignore-walk/package.json @@ -1,13 +1,13 @@ { "name": "ignore-walk", - "version": "3.0.3", + "version": "3.0.4", "description": "Nested/recursive `.gitignore`/`.npmignore` parsing and filtering.", "main": "index.js", "devDependencies": { "mkdirp": "^0.5.1", "mutate-fs": "^1.1.0", "rimraf": "^2.6.1", - "tap": "^14.6.9" + "tap": "^15.0.6" }, "scripts": { "test": "tap", @@ -36,6 +36,9 @@ "minimatch": "^3.0.4" }, "tap": { + "test-env": "LC_ALL=sk", + "before": "test/00-setup.js", + "after": "test/zz-cleanup.js", "jobs": 1 } } diff --git a/deps/npm/node_modules/json-stringify-nice/index.js b/deps/npm/node_modules/json-stringify-nice/index.js index 2c722a752c6855..36557bb055f01e 100644 --- a/deps/npm/node_modules/json-stringify-nice/index.js +++ b/deps/npm/node_modules/json-stringify-nice/index.js @@ -5,7 +5,7 @@ const compare = (ak, bk, prefKeys) => : prefKeys.includes(bk) && !prefKeys.includes(ak) ? 1 : prefKeys.includes(ak) && prefKeys.includes(bk) ? prefKeys.indexOf(ak) - prefKeys.indexOf(bk) - : ak.localeCompare(bk) + : ak.localeCompare(bk, 'en') const sort = (replacer, seen) => (key, val) => { const prefKeys = Array.isArray(replacer) ? replacer : [] diff --git a/deps/npm/node_modules/json-stringify-nice/package.json b/deps/npm/node_modules/json-stringify-nice/package.json index ea4f486c5e0b0c..c9663290ee4bc2 100644 --- a/deps/npm/node_modules/json-stringify-nice/package.json +++ b/deps/npm/node_modules/json-stringify-nice/package.json @@ -1,21 +1,34 @@ { "name": "json-stringify-nice", - "version": "1.1.3", + "version": "1.1.4", "description": "Stringify an object sorting scalars before objects, and defaulting to 2-space indent", "author": "Isaac Z. Schlueter (https://izs.me)", "license": "ISC", "scripts": { "test": "tap", + "posttest": "npm run lint", "snap": "tap", + "postsnap": "npm run lintfix", + "eslint": "eslint", + "lint": "npm run eslint -- index.js test/**/*.js", + "lintfix": "npm run lint -- --fix", "preversion": "npm test", "postversion": "npm publish", "postpublish": "git push origin --follow-tags" }, "tap": { + "test-env": [ + "LC_ALL=sk" + ], "check-coverage": true }, "devDependencies": { - "tap": "^14.9.2" + "eslint": "^7.25.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^5.1.0", + "eslint-plugin-standard": "^5.0.0", + "tap": "^15.0.6" }, "funding": { "url": "https://github.com/sponsors/isaacs" diff --git a/deps/npm/node_modules/libnpmexec/CHANGELOG.md b/deps/npm/node_modules/libnpmexec/CHANGELOG.md deleted file mode 100644 index 9de3013f0ad9d8..00000000000000 --- a/deps/npm/node_modules/libnpmexec/CHANGELOG.md +++ /dev/null @@ -1,7 +0,0 @@ -# Changelog - -## v1.0.0 - -- Initial implementation, moves the code that used to live in the **npm cli**, -ref: https://github.com/npm/cli/blob/release/v7.10.0/lib/exec.js into this -separate module, providing a programmatic API to the **npm exec** functionality. diff --git a/deps/npm/node_modules/libnpmexec/README.md b/deps/npm/node_modules/libnpmexec/README.md index a436c9a5a2bc1a..fb7a7717600197 100644 --- a/deps/npm/node_modules/libnpmexec/README.md +++ b/deps/npm/node_modules/libnpmexec/README.md @@ -31,7 +31,7 @@ await libexec({ - `call`: An alternative command to run when using `packages` option **String**, defaults to empty string. - `cache`: The path location to where the npm cache folder is placed **String** - `color`: Output should use color? **Boolean**, defaults to `false` - - `localBin`: Location to the `node_modules/.bin` folder of the local project **String**, defaults to empty string. + - `localBin`: Location to the `node_modules/.bin` folder of the local project to start scanning for bin files **String**, defaults to `./node_modules/.bin`. **libexec** will walk up the directory structure looking for `node_modules/.bin` folders in parent folders that might satisfy the current `arg` and will use that bin if found. - `locationMsg`: Overrides "at location" message when entering interactive mode **String** - `log`: Sets an optional logger **Object**, defaults to `proc-log` module usage. - `globalBin`: Location to the global space bin folder, same as: `$(npm bin -g)` **String**, defaults to empty string. diff --git a/deps/npm/node_modules/libnpmexec/lib/cache-install-dir.js b/deps/npm/node_modules/libnpmexec/lib/cache-install-dir.js index 1bee28989bf76d..9e30d62a1e102c 100644 --- a/deps/npm/node_modules/libnpmexec/lib/cache-install-dir.js +++ b/deps/npm/node_modules/libnpmexec/lib/cache-install-dir.js @@ -12,7 +12,7 @@ const cacheInstallDir = ({ cache, packages }) => { const getHash = (packages) => crypto.createHash('sha512') - .update(packages.sort((a, b) => a.localeCompare(b)).join('\n')) + .update(packages.sort((a, b) => a.localeCompare(b, 'en')).join('\n')) .digest('hex') .slice(0, 16) diff --git a/deps/npm/node_modules/libnpmexec/lib/file-exists.js b/deps/npm/node_modules/libnpmexec/lib/file-exists.js new file mode 100644 index 00000000000000..a115be14b00427 --- /dev/null +++ b/deps/npm/node_modules/libnpmexec/lib/file-exists.js @@ -0,0 +1,29 @@ +const { resolve } = require('path') +const { promisify } = require('util') +const stat = promisify(require('fs').stat) +const walkUp = require('walk-up-path') + +const fileExists = (file) => stat(file) + .then((stat) => stat.isFile()) + .catch(() => false) + +const localFileExists = async (dir, binName, root = '/') => { + root = resolve(root).toLowerCase() + + for (const path of walkUp(resolve(dir))) { + const binDir = resolve(path, 'node_modules', '.bin') + + if (await fileExists(resolve(binDir, binName))) + return binDir + + if (path.toLowerCase() === root) + return false + } + + return false +} + +module.exports = { + fileExists, + localFileExists, +} diff --git a/deps/npm/node_modules/libnpmexec/lib/index.js b/deps/npm/node_modules/libnpmexec/lib/index.js index 906a0b5407c13a..a48c654bf6a4f8 100644 --- a/deps/npm/node_modules/libnpmexec/lib/index.js +++ b/deps/npm/node_modules/libnpmexec/lib/index.js @@ -1,7 +1,6 @@ -const { delimiter, resolve } = require('path') +const { delimiter, dirname, resolve } = require('path') const { promisify } = require('util') const read = promisify(require('read')) -const stat = promisify(require('fs').stat) const Arborist = require('@npmcli/arborist') const ciDetect = require('@npmcli/ci-detect') @@ -12,15 +11,12 @@ const pacote = require('pacote') const readPackageJson = require('read-package-json-fast') const cacheInstallDir = require('./cache-install-dir.js') +const { fileExists, localFileExists } = require('./file-exists.js') const getBinFromManifest = require('./get-bin-from-manifest.js') const manifestMissing = require('./manifest-missing.js') const noTTY = require('./no-tty.js') const runScript = require('./run-script.js') -const fileExists = (file) => stat(file) - .then((stat) => stat.isFile()) - .catch(() => false) - /* istanbul ignore next */ const PATH = ( process.env.PATH || process.env.Path || process.env.path @@ -31,7 +27,7 @@ const exec = async (opts) => { args = [], call = '', color = false, - localBin = '', + localBin = resolve('./node_modules/.bin'), locationMsg = undefined, globalBin = '', output, @@ -72,8 +68,10 @@ const exec = async (opts) => { // the behavior of treating the single argument as a package name if (needPackageCommandSwap) { let binExists = false - if (await fileExists(`${localBin}/${args[0]}`)) { - pathArr.unshift(localBin) + const dir = dirname(dirname(localBin)) + const localBinPath = await localFileExists(dir, args[0]) + if (localBinPath) { + pathArr.unshift(localBinPath) binExists = true } else if (await fileExists(`${globalBin}/${args[0]}`)) { pathArr.unshift(globalBin) @@ -145,7 +143,7 @@ const exec = async (opts) => { }, })) .map(mani => mani._from) - .sort((a, b) => a.localeCompare(b)) + .sort((a, b) => a.localeCompare(b, 'en')) // no need to install if already present if (add.length) { diff --git a/deps/npm/node_modules/libnpmexec/package.json b/deps/npm/node_modules/libnpmexec/package.json index 1b7d24103be7af..c113ac6d0a6076 100644 --- a/deps/npm/node_modules/libnpmexec/package.json +++ b/deps/npm/node_modules/libnpmexec/package.json @@ -1,6 +1,6 @@ { "name": "libnpmexec", - "version": "1.0.1", + "version": "1.1.1", "files": [ "lib" ], @@ -46,7 +46,7 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^5.1.0", "eslint-plugin-standard": "^5.0.0", - "tap": "^15.0.2" + "tap": "^15.0.6" }, "dependencies": { "@npmcli/arborist": "^2.3.0", @@ -58,6 +58,7 @@ "pacote": "^11.3.1", "proc-log": "^1.0.0", "read": "^1.0.7", - "read-package-json-fast": "^2.0.2" + "read-package-json-fast": "^2.0.2", + "walk-up-path": "^1.0.0" } } diff --git a/deps/npm/node_modules/npm-packlist/bin/index.js b/deps/npm/node_modules/npm-packlist/bin/index.js index f06feffd9b55ae..40811db7d32e72 100755 --- a/deps/npm/node_modules/npm-packlist/bin/index.js +++ b/deps/npm/node_modules/npm-packlist/bin/index.js @@ -12,13 +12,14 @@ process.argv.slice(2).forEach(arg => { dirs.push(arg) }) -const sort = list => doSort ? list.sort((a, b) => a.localeCompare(b)) : list +const sort = list => doSort ? list.sort((a, b) => a.localeCompare(b, 'en')) : list const packlist = require('../') if (!dirs.length) console.log(sort(packlist.sync({ path: process.cwd() })).join('\n')) -else +else { dirs.forEach(path => { console.log(`> ${path}`) console.log(sort(packlist.sync({ path })).join('\n')) }) +} diff --git a/deps/npm/node_modules/npm-packlist/index.js b/deps/npm/node_modules/npm-packlist/index.js index 8f62983e6f6c0f..f498fa008ceca8 100644 --- a/deps/npm/node_modules/npm-packlist/index.js +++ b/deps/npm/node_modules/npm-packlist/index.js @@ -26,11 +26,10 @@ const normalizePackageBin = require('npm-normalize-package-bin') // localized documentation and other use cases. Adding a `/` to // these rules, while tempting and arguably more "correct", is a // significant change that will break existing use cases. -const packageMustHaveFileNames = - 'readme|copying|license|licence|notice|changes|changelog|history' +const packageMustHaveFileNames = 'readme|copying|license|licence' const packageMustHaves = `@(${packageMustHaveFileNames}){,.*[^~$]}` -const packageMustHavesRE = new RegExp(`^(${packageMustHaveFileNames})(\\..*[^~\$])?$`, 'i') +const packageMustHavesRE = new RegExp(`^(${packageMustHaveFileNames})(\\..*[^~$])?$`, 'i') const fs = require('fs') const glob = require('glob') @@ -76,13 +75,11 @@ const npmWalker = Class => class Walker extends Class { 'package.json', '.npmignore', '.gitignore', - packageNecessaryRules + packageNecessaryRules, ] opt.includeEmpty = false opt.path = opt.path || process.cwd() - const dirName = path.basename(opt.path) - const parentName = path.basename(path.dirname(opt.path)) // only follow links in the root node_modules folder, because if those // folders are included, it's because they're bundled, and bundles @@ -90,7 +87,7 @@ const npmWalker = Class => class Walker extends Class { // This regexp tests to see that we're either a node_modules folder, // or a @scope within a node_modules folder, in the root's node_modules // hierarchy (ie, not in test/foo/node_modules/ or something). - const followRe = /^(?:\/node_modules\/(?:@[^\/]+\/[^\/]+|[^\/]+)\/)*\/node_modules(?:\/@[^\/]+)?$/ + const followRe = /^(?:\/node_modules\/(?:@[^/]+\/[^/]+|[^/]+)\/)*\/node_modules(?:\/@[^/]+)?$/ const rootPath = opt.parent ? opt.parent.root : opt.path const followTestPath = opt.path.replace(/\\/g, '/').substr(rootPath.length) opt.follow = followRe.test(followTestPath) @@ -104,10 +101,10 @@ const npmWalker = Class => class Walker extends Class { this.bundled = opt.bundled || [] this.bundledScopes = Array.from(new Set( this.bundled.filter(f => /^@/.test(f)) - .map(f => f.split('/')[0]))) + .map(f => f.split('/')[0]))) const rules = defaultRules.join('\n') + '\n' this.packageJsonCache = opt.packageJsonCache || new Map() - super.onReadIgnoreFile(rootBuiltinRules, rules, _=>_) + super.onReadIgnoreFile(rootBuiltinRules, rules, _ => _) } else { this.bundled = [] this.bundledScopes = [] @@ -129,9 +126,8 @@ const npmWalker = Class => class Walker extends Class { // to be in the state the user wants to include them, and // a package.json somewhere else might be a template or // test or something else entirely. - if (this.parent || !entries.includes('package.json')) { + if (this.parent || !entries.includes('package.json')) return super.onReaddir(entries) - } // when the cache has been seeded with the root manifest, // we must respect that (it may differ from the filesystem) @@ -141,9 +137,8 @@ const npmWalker = Class => class Walker extends Class { const pkg = this.packageJsonCache.get(ig) // fall back to filesystem when seeded manifest is invalid - if (!pkg || typeof pkg !== 'object') { + if (!pkg || typeof pkg !== 'object') return this.readPackageJson(entries) - } // feels wonky, but this ensures package bin is _always_ // normalized, as well as guarding against invalid JSON @@ -175,7 +170,7 @@ const npmWalker = Class => class Walker extends Class { '/package.json', '/npm-shrinkwrap.json', '!/package-lock.json', - packageMustHaves, + packageMustHaves ) return files } @@ -233,9 +228,8 @@ const npmWalker = Class => class Walker extends Class { return this.emit('error', er) results[i] = { negate, fileList } - if (--n === 0) { + if (--n === 0) processResults(results) - } } const processResults = results => { for (const {negate, fileList} of results) { @@ -273,7 +267,7 @@ const npmWalker = Class => class Walker extends Class { filterEntry (entry, partial) { // get the partial path from the root of the walk const p = this.path.substr(this.root.length + 1) - const pkgre = /^node_modules\/(@[^\/]+\/?[^\/]+|[^\/]+)(\/.*)?$/ + const pkgre = /^node_modules\/(@[^/]+\/?[^/]+|[^/]+)(\/.*)?$/ const isRoot = !this.parent const pkg = isRoot && pkgre.test(entry) ? entry.replace(pkgre, '$1') : null @@ -283,7 +277,7 @@ const npmWalker = Class => class Walker extends Class { return ( // if we're in a bundled package, check with the parent. /^node_modules($|\/)/i.test(p) ? this.parent.filterEntry( - this.basename + '/' + entry, partial) + this.basename + '/' + entry, partial) // if package is bundled, all files included // also include @scope dirs for bundled scoped deps @@ -291,8 +285,8 @@ const npmWalker = Class => class Walker extends Class { // However, this only matters if we're in the root. // node_modules folders elsewhere, like lib/node_modules, // should be included normally unless ignored. - : pkg ? -1 !== this.bundled.indexOf(pkg) || - -1 !== this.bundledScopes.indexOf(pkg) + : pkg ? this.bundled.indexOf(pkg) !== -1 || + this.bundledScopes.indexOf(pkg) !== -1 // only walk top node_modules if we want to bundle something : rootNM ? !!this.bundled.length @@ -308,10 +302,10 @@ const npmWalker = Class => class Walker extends Class { ? true // package-lock never included - : isRoot && entry === 'package-lock.json' ? false + : isRoot && entry === 'package-lock.json' ? false - // otherwise, follow ignore-walk's logic - : super.filterEntry(entry, partial) + // otherwise, follow ignore-walk's logic + : super.filterEntry(entry, partial) ) } @@ -454,12 +448,11 @@ const sort = (a, b) => { const basea = path.basename(a).toLowerCase() const baseb = path.basename(b).toLowerCase() - return exta.localeCompare(extb) || - basea.localeCompare(baseb) || - a.localeCompare(b) + return exta.localeCompare(extb, 'en') || + basea.localeCompare(baseb, 'en') || + a.localeCompare(b, 'en') } - module.exports = walk walk.sync = walkSync walk.Walker = Walker diff --git a/deps/npm/node_modules/npm-packlist/package.json b/deps/npm/node_modules/npm-packlist/package.json index 1276b484136992..49fa947547b6cc 100644 --- a/deps/npm/node_modules/npm-packlist/package.json +++ b/deps/npm/node_modules/npm-packlist/package.json @@ -1,6 +1,6 @@ { "name": "npm-packlist", - "version": "2.1.5", + "version": "2.2.2", "description": "Get a list of the files to add from a folder into an npm package", "directories": { "test": "test" @@ -15,25 +15,38 @@ "author": "Isaac Z. Schlueter (http://blog.izs.me/)", "license": "ISC", "files": [ + "bin/index.js", "index.js" ], "devDependencies": { + "eslint": "^7.25.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^5.1.0", + "eslint-plugin-standard": "^5.0.0", "mutate-fs": "^2.1.1", - "require-inject": "^1.4.4", - "tap": "^14.10.8" + "tap": "^15.0.6" }, "scripts": { "test": "tap", + "posttest": "npm run lint", "snap": "tap", + "postsnap": "npm run lintfix", "preversion": "npm test", "postversion": "npm publish", - "prepublishOnly": "git push origin --follow-tags" + "prepublishOnly": "git push origin --follow-tags", + "eslint": "eslint", + "lint": "npm run eslint -- index.js bin/index.js \"test/**/*.js\"", + "lintfix": "npm run lint -- --fix" }, "repository": { "type": "git", "url": "git+https://github.com/npm/npm-packlist.git" }, "tap": { + "test-env": [ + "LC_ALL=sk" + ], "check-coverage": true, "nyc-arg": [ "--include=index.js", diff --git a/deps/npm/package.json b/deps/npm/package.json index 19326a9aa59df1..70f94838882b74 100644 --- a/deps/npm/package.json +++ b/deps/npm/package.json @@ -1,5 +1,5 @@ { - "version": "7.11.2", + "version": "7.12.1", "name": "npm", "description": "a package manager for JavaScript", "keywords": [ @@ -42,7 +42,7 @@ "./package.json": "./package.json" }, "dependencies": { - "@npmcli/arborist": "^2.4.1", + "@npmcli/arborist": "^2.4.4", "@npmcli/ci-detect": "^1.2.0", "@npmcli/config": "^2.2.0", "@npmcli/run-script": "^1.8.5", @@ -57,7 +57,7 @@ "cli-columns": "^3.1.2", "cli-table3": "^0.6.0", "columnify": "~1.5.4", - "glob": "^7.1.4", + "glob": "^7.1.7", "graceful-fs": "^4.2.6", "hosted-git-info": "^4.0.2", "ini": "^2.0.0", @@ -67,7 +67,7 @@ "leven": "^3.1.0", "libnpmaccess": "^4.0.2", "libnpmdiff": "^2.0.4", - "libnpmexec": "^1.0.1", + "libnpmexec": "^1.1.1", "libnpmfund": "^1.0.2", "libnpmhook": "^6.0.2", "libnpmorg": "^2.0.2", @@ -182,15 +182,15 @@ "devDependencies": { "@mdx-js/mdx": "^1.6.22", "cmark-gfm": "^0.8.5", - "eslint": "^7.23.0", + "eslint": "^7.26.0", "eslint-plugin-import": "^2.22.1", "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^4.3.1", + "eslint-plugin-promise": "^5.1.0", "eslint-plugin-standard": "^5.0.0", "jsdom": "^16.5.2", "licensee": "^8.1.0", "marked-man": "^0.7.0", - "tap": "^15.0.6", + "tap": "^15.0.9", "yaml": "^1.10.2" }, "scripts": { @@ -216,6 +216,9 @@ "Remove the 'files' below once we're done porting old tests over" ], "tap": { + "test-env": [ + "LC_ALL=sk" + ], "color": 1, "files": "test/{lib,bin}", "coverage-map": "test/coverage-map.js", diff --git a/deps/npm/tap-snapshots/test/lib/config.js.test.cjs b/deps/npm/tap-snapshots/test/lib/config.js.test.cjs index 68c50d699a430c..a293eda63a0b3a 100644 --- a/deps/npm/tap-snapshots/test/lib/config.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/config.js.test.cjs @@ -88,6 +88,9 @@ exports[`test/lib/config.js TAP config edit > should write config file 2`] = ` exports[`test/lib/config.js TAP config get no args > should list configs on config get no args 1`] = ` ; "cli" config from command line options +cat = true +chai = true +dog = true editor = "vi" global = false json = false @@ -109,6 +112,9 @@ init.version = "1.0.0" ; "cli" config from command line options +cat = true +chai = true +dog = true editor = "vi" global = false json = false @@ -118,6 +124,9 @@ long = true exports[`test/lib/config.js TAP config list > should list configs 1`] = ` ; "cli" config from command line options +cat = true +chai = true +dog = true editor = "vi" global = false json = false @@ -132,6 +141,9 @@ long = false exports[`test/lib/config.js TAP config list overrides > should list overridden configs 1`] = ` ; "cli" config from command line options +cat = true +chai = true +dog = true editor = "vi" global = false init.author.name = "Bar" diff --git a/deps/npm/tap-snapshots/test/lib/ls.js.test.cjs b/deps/npm/tap-snapshots/test/lib/ls.js.test.cjs index 0278f6af1f2e4c..67359f4b3a3483 100644 --- a/deps/npm/tap-snapshots/test/lib/ls.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/ls.js.test.cjs @@ -47,8 +47,8 @@ test-npm-ls-ignore-missing-optional@1.2.3 {project} exports[`test/lib/ls.js TAP ls --depth=0 > should output tree containing only top-level dependencies 1`] = ` test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls---depth-0 -+-- foo@1.0.0 -\`-- lorem@1.0.0 ++-- chai@1.0.0 +\`-- foo@1.0.0 ` @@ -64,7 +64,7 @@ exports[`test/lib/ls.js TAP ls --dev > should output tree containing dev deps 1` test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls---dev \`-- dev-dep@1.0.0 \`-- foo@1.0.0 - \`-- bar@1.0.0 + \`-- dog@1.0.0 ` @@ -78,10 +78,10 @@ exports[`test/lib/ls.js TAP ls --long --depth=0 > should output tree containing test-npm-ls@1.0.0 | {CWD}/tap-testdir-ls-ls---long---depth-0 | ++-- chai@1.0.0 +| +-- dev-dep@1.0.0 | A DEV dep kind of dep -+-- lorem@1.0.0 -| +-- optional-dep@1.0.0 | Maybe a dep? +-- peer-dep@1.0.0 @@ -95,13 +95,13 @@ exports[`test/lib/ls.js TAP ls --long > should output tree info with description test-npm-ls@1.0.0 | {CWD}/tap-testdir-ls-ls---long | ++-- chai@1.0.0 +| +-- dev-dep@1.0.0 | | A DEV dep kind of dep | \`-- foo@1.0.0 | | -| \`-- bar@1.0.0 -| -+-- lorem@1.0.0 +| \`-- dog@1.0.0 | +-- optional-dep@1.0.0 | Maybe a dep? @@ -109,7 +109,7 @@ test-npm-ls@1.0.0 | Peer-dep description here \`-- prod-dep@1.0.0 | A PROD dep kind of dep - \`-- bar@2.0.0 + \`-- dog@2.0.0 A dep that bars ` @@ -118,37 +118,37 @@ exports[`test/lib/ls.js TAP ls --only=development > should output tree containin test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls---only-development \`-- dev-dep@1.0.0 \`-- foo@1.0.0 - \`-- bar@1.0.0 + \`-- dog@1.0.0 ` exports[`test/lib/ls.js TAP ls --only=prod > should output tree containing only prod deps 1`] = ` test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls---only-prod -+-- lorem@1.0.0 ++-- chai@1.0.0 +-- optional-dep@1.0.0 \`-- prod-dep@1.0.0 - \`-- bar@2.0.0 + \`-- dog@2.0.0 ` exports[`test/lib/ls.js TAP ls --parseable --depth=0 > should output tree containing only top-level dependencies 1`] = ` {CWD}/tap-testdir-ls-ls---parseable---depth-0 +{CWD}/tap-testdir-ls-ls---parseable---depth-0/node_modules/chai {CWD}/tap-testdir-ls-ls---parseable---depth-0/node_modules/foo -{CWD}/tap-testdir-ls-ls---parseable---depth-0/node_modules/lorem ` exports[`test/lib/ls.js TAP ls --parseable --depth=1 > should output parseable containing top-level deps and their deps only 1`] = ` {CWD}/tap-testdir-ls-ls---parseable---depth-1 +{CWD}/tap-testdir-ls-ls---parseable---depth-1/node_modules/chai {CWD}/tap-testdir-ls-ls---parseable---depth-1/node_modules/foo -{CWD}/tap-testdir-ls-ls---parseable---depth-1/node_modules/lorem -{CWD}/tap-testdir-ls-ls---parseable---depth-1/node_modules/bar +{CWD}/tap-testdir-ls-ls---parseable---depth-1/node_modules/dog ` exports[`test/lib/ls.js TAP ls --parseable --dev > should output tree containing dev deps 1`] = ` {CWD}/tap-testdir-ls-ls---parseable---dev {CWD}/tap-testdir-ls-ls---parseable---dev/node_modules/dev-dep {CWD}/tap-testdir-ls-ls---parseable---dev/node_modules/foo -{CWD}/tap-testdir-ls-ls---parseable---dev/node_modules/bar +{CWD}/tap-testdir-ls-ls---parseable---dev/node_modules/dog ` exports[`test/lib/ls.js TAP ls --parseable --link > should output tree containing linked deps 1`] = ` @@ -158,8 +158,8 @@ exports[`test/lib/ls.js TAP ls --parseable --link > should output tree containin exports[`test/lib/ls.js TAP ls --parseable --long --depth=0 > should output tree containing top-level deps with descriptions 1`] = ` {CWD}/tap-testdir-ls-ls---parseable---long---depth-0:test-npm-ls@1.0.0 +{CWD}/tap-testdir-ls-ls---parseable---long---depth-0/node_modules/chai:chai@1.0.0 {CWD}/tap-testdir-ls-ls---parseable---long---depth-0/node_modules/dev-dep:dev-dep@1.0.0 -{CWD}/tap-testdir-ls-ls---parseable---long---depth-0/node_modules/lorem:lorem@1.0.0 {CWD}/tap-testdir-ls-ls---parseable---long---depth-0/node_modules/optional-dep:optional-dep@1.0.0 {CWD}/tap-testdir-ls-ls---parseable---long---depth-0/node_modules/peer-dep:peer-dep@1.0.0 {CWD}/tap-testdir-ls-ls---parseable---long---depth-0/node_modules/prod-dep:prod-dep@1.0.0 @@ -167,64 +167,64 @@ exports[`test/lib/ls.js TAP ls --parseable --long --depth=0 > should output tree exports[`test/lib/ls.js TAP ls --parseable --long > should output tree info with descriptions 1`] = ` {CWD}/tap-testdir-ls-ls---parseable---long:test-npm-ls@1.0.0 +{CWD}/tap-testdir-ls-ls---parseable---long/node_modules/chai:chai@1.0.0 {CWD}/tap-testdir-ls-ls---parseable---long/node_modules/dev-dep:dev-dep@1.0.0 -{CWD}/tap-testdir-ls-ls---parseable---long/node_modules/lorem:lorem@1.0.0 {CWD}/tap-testdir-ls-ls---parseable---long/node_modules/optional-dep:optional-dep@1.0.0 {CWD}/tap-testdir-ls-ls---parseable---long/node_modules/peer-dep:peer-dep@1.0.0 {CWD}/tap-testdir-ls-ls---parseable---long/node_modules/prod-dep:prod-dep@1.0.0 {CWD}/tap-testdir-ls-ls---parseable---long/node_modules/foo:foo@1.0.0 -{CWD}/tap-testdir-ls-ls---parseable---long/node_modules/prod-dep/node_modules/bar:bar@2.0.0 -{CWD}/tap-testdir-ls-ls---parseable---long/node_modules/bar:bar@1.0.0 +{CWD}/tap-testdir-ls-ls---parseable---long/node_modules/prod-dep/node_modules/dog:dog@2.0.0 +{CWD}/tap-testdir-ls-ls---parseable---long/node_modules/dog:dog@1.0.0 ` exports[`test/lib/ls.js TAP ls --parseable --long missing/invalid/extraneous > should output parseable result containing EXTRANEOUS/INVALID labels 1`] = ` {CWD}/tap-testdir-ls-ls---parseable---long-missing-invalid-extraneous:test-npm-ls@1.0.0 +{CWD}/tap-testdir-ls-ls---parseable---long-missing-invalid-extraneous/node_modules/chai:chai@1.0.0:EXTRANEOUS {CWD}/tap-testdir-ls-ls---parseable---long-missing-invalid-extraneous/node_modules/foo:foo@1.0.0:INVALID -{CWD}/tap-testdir-ls-ls---parseable---long-missing-invalid-extraneous/node_modules/lorem:lorem@1.0.0:EXTRANEOUS -{CWD}/tap-testdir-ls-ls---parseable---long-missing-invalid-extraneous/node_modules/bar:bar@1.0.0 +{CWD}/tap-testdir-ls-ls---parseable---long-missing-invalid-extraneous/node_modules/dog:dog@1.0.0 ` exports[`test/lib/ls.js TAP ls --parseable --long print symlink target location > should output parseable results with symlink targets 1`] = ` {CWD}/tap-testdir-ls-ls---parseable---long-print-symlink-target-location:test-npm-ls@1.0.0 +{CWD}/tap-testdir-ls-ls---parseable---long-print-symlink-target-location/node_modules/chai:chai@1.0.0 {CWD}/tap-testdir-ls-ls---parseable---long-print-symlink-target-location/node_modules/dev-dep:dev-dep@1.0.0 {CWD}/tap-testdir-ls-ls---parseable---long-print-symlink-target-location/node_modules/linked-dep:linked-dep@1.0.0:{CWD}/tap-testdir-ls-ls---parseable---long-print-symlink-target-location/linked-dep -{CWD}/tap-testdir-ls-ls---parseable---long-print-symlink-target-location/node_modules/lorem:lorem@1.0.0 {CWD}/tap-testdir-ls-ls---parseable---long-print-symlink-target-location/node_modules/optional-dep:optional-dep@1.0.0 {CWD}/tap-testdir-ls-ls---parseable---long-print-symlink-target-location/node_modules/peer-dep:peer-dep@1.0.0 {CWD}/tap-testdir-ls-ls---parseable---long-print-symlink-target-location/node_modules/prod-dep:prod-dep@1.0.0 {CWD}/tap-testdir-ls-ls---parseable---long-print-symlink-target-location/node_modules/foo:foo@1.0.0 -{CWD}/tap-testdir-ls-ls---parseable---long-print-symlink-target-location/node_modules/prod-dep/node_modules/bar:bar@2.0.0 -{CWD}/tap-testdir-ls-ls---parseable---long-print-symlink-target-location/node_modules/bar:bar@1.0.0 +{CWD}/tap-testdir-ls-ls---parseable---long-print-symlink-target-location/node_modules/prod-dep/node_modules/dog:dog@2.0.0 +{CWD}/tap-testdir-ls-ls---parseable---long-print-symlink-target-location/node_modules/dog:dog@1.0.0 ` exports[`test/lib/ls.js TAP ls --parseable --long with extraneous deps > should output long parseable output with extraneous info 1`] = ` {CWD}/tap-testdir-ls-ls---parseable---long-with-extraneous-deps:test-npm-ls@1.0.0 +{CWD}/tap-testdir-ls-ls---parseable---long-with-extraneous-deps/node_modules/chai:chai@1.0.0:EXTRANEOUS {CWD}/tap-testdir-ls-ls---parseable---long-with-extraneous-deps/node_modules/foo:foo@1.0.0 -{CWD}/tap-testdir-ls-ls---parseable---long-with-extraneous-deps/node_modules/lorem:lorem@1.0.0:EXTRANEOUS -{CWD}/tap-testdir-ls-ls---parseable---long-with-extraneous-deps/node_modules/bar:bar@1.0.0 +{CWD}/tap-testdir-ls-ls---parseable---long-with-extraneous-deps/node_modules/dog:dog@1.0.0 ` exports[`test/lib/ls.js TAP ls --parseable --only=development > should output tree containing only development deps 1`] = ` {CWD}/tap-testdir-ls-ls---parseable---only-development {CWD}/tap-testdir-ls-ls---parseable---only-development/node_modules/dev-dep {CWD}/tap-testdir-ls-ls---parseable---only-development/node_modules/foo -{CWD}/tap-testdir-ls-ls---parseable---only-development/node_modules/bar +{CWD}/tap-testdir-ls-ls---parseable---only-development/node_modules/dog ` exports[`test/lib/ls.js TAP ls --parseable --only=prod > should output tree containing only prod deps 1`] = ` {CWD}/tap-testdir-ls-ls---parseable---only-prod -{CWD}/tap-testdir-ls-ls---parseable---only-prod/node_modules/lorem +{CWD}/tap-testdir-ls-ls---parseable---only-prod/node_modules/chai {CWD}/tap-testdir-ls-ls---parseable---only-prod/node_modules/optional-dep {CWD}/tap-testdir-ls-ls---parseable---only-prod/node_modules/prod-dep -{CWD}/tap-testdir-ls-ls---parseable---only-prod/node_modules/prod-dep/node_modules/bar +{CWD}/tap-testdir-ls-ls---parseable---only-prod/node_modules/prod-dep/node_modules/dog ` exports[`test/lib/ls.js TAP ls --parseable --production > should output tree containing production deps 1`] = ` {CWD}/tap-testdir-ls-ls---parseable---production -{CWD}/tap-testdir-ls-ls---parseable---production/node_modules/lorem +{CWD}/tap-testdir-ls-ls---parseable---production/node_modules/chai {CWD}/tap-testdir-ls-ls---parseable---production/node_modules/optional-dep {CWD}/tap-testdir-ls-ls---parseable---production/node_modules/prod-dep -{CWD}/tap-testdir-ls-ls---parseable---production/node_modules/prod-dep/node_modules/bar +{CWD}/tap-testdir-ls-ls---parseable---production/node_modules/prod-dep/node_modules/dog ` exports[`test/lib/ls.js TAP ls --parseable cycle deps > should print tree output omitting deduped ref 1`] = ` @@ -235,8 +235,8 @@ exports[`test/lib/ls.js TAP ls --parseable cycle deps > should print tree output exports[`test/lib/ls.js TAP ls --parseable default --depth value should be 0 > should output parseable output containing only top-level dependencies 1`] = ` {CWD}/tap-testdir-ls-ls---parseable-default---depth-value-should-be-0 +{CWD}/tap-testdir-ls-ls---parseable-default---depth-value-should-be-0/node_modules/chai {CWD}/tap-testdir-ls-ls---parseable-default---depth-value-should-be-0/node_modules/foo -{CWD}/tap-testdir-ls-ls---parseable-default---depth-value-should-be-0/node_modules/lorem ` exports[`test/lib/ls.js TAP ls --parseable empty location > should print empty result 1`] = ` @@ -245,9 +245,9 @@ exports[`test/lib/ls.js TAP ls --parseable empty location > should print empty r exports[`test/lib/ls.js TAP ls --parseable extraneous deps > should output containing problems info 1`] = ` {CWD}/tap-testdir-ls-ls---parseable-extraneous-deps +{CWD}/tap-testdir-ls-ls---parseable-extraneous-deps/node_modules/chai {CWD}/tap-testdir-ls-ls---parseable-extraneous-deps/node_modules/foo -{CWD}/tap-testdir-ls-ls---parseable-extraneous-deps/node_modules/lorem -{CWD}/tap-testdir-ls-ls---parseable-extraneous-deps/node_modules/bar +{CWD}/tap-testdir-ls-ls---parseable-extraneous-deps/node_modules/dog ` exports[`test/lib/ls.js TAP ls --parseable from and resolved properties > should not be printed in tree output 1`] = ` @@ -268,23 +268,23 @@ exports[`test/lib/ls.js TAP ls --parseable json read problems > should print emp exports[`test/lib/ls.js TAP ls --parseable missing package.json > should output parseable missing name/version of top-level package 1`] = ` {CWD}/tap-testdir-ls-ls---parseable-missing-package.json -{CWD}/tap-testdir-ls-ls---parseable-missing-package.json/node_modules/bar +{CWD}/tap-testdir-ls-ls---parseable-missing-package.json/node_modules/chai +{CWD}/tap-testdir-ls-ls---parseable-missing-package.json/node_modules/dog {CWD}/tap-testdir-ls-ls---parseable-missing-package.json/node_modules/foo -{CWD}/tap-testdir-ls-ls---parseable-missing-package.json/node_modules/lorem ` exports[`test/lib/ls.js TAP ls --parseable missing/invalid/extraneous > should output parseable containing top-level deps and their deps only 1`] = ` {CWD}/tap-testdir-ls-ls---parseable-missing-invalid-extraneous +{CWD}/tap-testdir-ls-ls---parseable-missing-invalid-extraneous/node_modules/chai {CWD}/tap-testdir-ls-ls---parseable-missing-invalid-extraneous/node_modules/foo -{CWD}/tap-testdir-ls-ls---parseable-missing-invalid-extraneous/node_modules/lorem -{CWD}/tap-testdir-ls-ls---parseable-missing-invalid-extraneous/node_modules/bar +{CWD}/tap-testdir-ls-ls---parseable-missing-invalid-extraneous/node_modules/dog ` exports[`test/lib/ls.js TAP ls --parseable no args > should output parseable representation of dependencies structure 1`] = ` {CWD}/tap-testdir-ls-ls---parseable-no-args +{CWD}/tap-testdir-ls-ls---parseable-no-args/node_modules/chai {CWD}/tap-testdir-ls-ls---parseable-no-args/node_modules/foo -{CWD}/tap-testdir-ls-ls---parseable-no-args/node_modules/lorem -{CWD}/tap-testdir-ls-ls---parseable-no-args/node_modules/bar +{CWD}/tap-testdir-ls-ls---parseable-no-args/node_modules/dog ` exports[`test/lib/ls.js TAP ls --parseable resolved points to git ref > should output tree containing git refs 1`] = ` @@ -294,26 +294,26 @@ exports[`test/lib/ls.js TAP ls --parseable resolved points to git ref > should o exports[`test/lib/ls.js TAP ls --parseable unmet optional dep > should output parseable with empty entry for missing optional deps 1`] = ` {CWD}/tap-testdir-ls-ls---parseable-unmet-optional-dep +{CWD}/tap-testdir-ls-ls---parseable-unmet-optional-dep/node_modules/chai {CWD}/tap-testdir-ls-ls---parseable-unmet-optional-dep/node_modules/dev-dep -{CWD}/tap-testdir-ls-ls---parseable-unmet-optional-dep/node_modules/lorem {CWD}/tap-testdir-ls-ls---parseable-unmet-optional-dep/node_modules/optional-dep {CWD}/tap-testdir-ls-ls---parseable-unmet-optional-dep/node_modules/peer-dep {CWD}/tap-testdir-ls-ls---parseable-unmet-optional-dep/node_modules/prod-dep {CWD}/tap-testdir-ls-ls---parseable-unmet-optional-dep/node_modules/foo -{CWD}/tap-testdir-ls-ls---parseable-unmet-optional-dep/node_modules/prod-dep/node_modules/bar -{CWD}/tap-testdir-ls-ls---parseable-unmet-optional-dep/node_modules/bar +{CWD}/tap-testdir-ls-ls---parseable-unmet-optional-dep/node_modules/prod-dep/node_modules/dog +{CWD}/tap-testdir-ls-ls---parseable-unmet-optional-dep/node_modules/dog ` exports[`test/lib/ls.js TAP ls --parseable unmet peer dep > should output parseable signaling missing peer dep in problems 1`] = ` {CWD}/tap-testdir-ls-ls---parseable-unmet-peer-dep +{CWD}/tap-testdir-ls-ls---parseable-unmet-peer-dep/node_modules/chai {CWD}/tap-testdir-ls-ls---parseable-unmet-peer-dep/node_modules/dev-dep -{CWD}/tap-testdir-ls-ls---parseable-unmet-peer-dep/node_modules/lorem {CWD}/tap-testdir-ls-ls---parseable-unmet-peer-dep/node_modules/optional-dep {CWD}/tap-testdir-ls-ls---parseable-unmet-peer-dep/node_modules/peer-dep {CWD}/tap-testdir-ls-ls---parseable-unmet-peer-dep/node_modules/prod-dep {CWD}/tap-testdir-ls-ls---parseable-unmet-peer-dep/node_modules/foo -{CWD}/tap-testdir-ls-ls---parseable-unmet-peer-dep/node_modules/prod-dep/node_modules/bar -{CWD}/tap-testdir-ls-ls---parseable-unmet-peer-dep/node_modules/bar +{CWD}/tap-testdir-ls-ls---parseable-unmet-peer-dep/node_modules/prod-dep/node_modules/dog +{CWD}/tap-testdir-ls-ls---parseable-unmet-peer-dep/node_modules/dog ` exports[`test/lib/ls.js TAP ls --parseable using aliases > should output tree containing aliases 1`] = ` @@ -322,11 +322,11 @@ exports[`test/lib/ls.js TAP ls --parseable using aliases > should output tree co ` exports[`test/lib/ls.js TAP ls --parseable with filter arg > should output parseable contaning only occurrences of filtered by package 1`] = ` -{CWD}/tap-testdir-ls-ls---parseable-with-filter-arg/node_modules/lorem +{CWD}/tap-testdir-ls-ls---parseable-with-filter-arg/node_modules/chai ` exports[`test/lib/ls.js TAP ls --parseable with filter arg nested dep > should output parseable contaning only occurrences of filtered package 1`] = ` -{CWD}/tap-testdir-ls-ls---parseable-with-filter-arg-nested-dep/node_modules/bar +{CWD}/tap-testdir-ls-ls---parseable-with-filter-arg-nested-dep/node_modules/dog ` exports[`test/lib/ls.js TAP ls --parseable with missing filter arg > should output parseable output containing no dependencies info 1`] = ` @@ -334,16 +334,16 @@ exports[`test/lib/ls.js TAP ls --parseable with missing filter arg > should outp ` exports[`test/lib/ls.js TAP ls --parseable with multiple filter args > should output parseable contaning only occurrences of multiple filtered packages and their ancestors 1`] = ` -{CWD}/tap-testdir-ls-ls---parseable-with-multiple-filter-args/node_modules/lorem -{CWD}/tap-testdir-ls-ls---parseable-with-multiple-filter-args/node_modules/bar +{CWD}/tap-testdir-ls-ls---parseable-with-multiple-filter-args/node_modules/chai +{CWD}/tap-testdir-ls-ls---parseable-with-multiple-filter-args/node_modules/dog ` exports[`test/lib/ls.js TAP ls --production > should output tree containing production deps 1`] = ` test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls---production -+-- lorem@1.0.0 ++-- chai@1.0.0 +-- optional-dep@1.0.0 \`-- prod-dep@1.0.0 - \`-- bar@2.0.0 + \`-- dog@2.0.0 ` @@ -355,10 +355,10 @@ npm-broken-resolved-field-test@1.0.0 {CWD}/tap-testdir-ls-ls-broken-resolved-fie exports[`test/lib/ls.js TAP ls colored output > should output tree containing color info 1`] = ` test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls-colored-output ++-- chai@1.0.0 extraneous +-- foo@1.0.0 invalid -| \`-- bar@1.0.0 -+-- UNMET DEPENDENCY ipsum@^1.0.0 -\`-- lorem@1.0.0 extraneous +| \`-- dog@1.0.0 +\`-- UNMET DEPENDENCY ipsum@^1.0.0  ` @@ -388,8 +388,8 @@ test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls-deduped-missing-dep exports[`test/lib/ls.js TAP ls default --depth value should be 0 > should output tree containing only top-level dependencies 1`] = ` test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls-default---depth-value-should-be-0 -+-- foo@1.0.0 -\`-- lorem@1.0.0 ++-- chai@1.0.0 +\`-- foo@1.0.0 ` @@ -401,9 +401,9 @@ exports[`test/lib/ls.js TAP ls empty location > should print empty result 1`] = exports[`test/lib/ls.js TAP ls extraneous deps > should output containing problems info 1`] = ` test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls-extraneous-deps -+-- foo@1.0.0 -| \`-- bar@1.0.0 -\`-- lorem@1.0.0 extraneous ++-- chai@1.0.0 extraneous +\`-- foo@1.0.0 + \`-- dog@1.0.0 ` @@ -461,14 +461,14 @@ exports[`test/lib/ls.js TAP ls invalid deduped dep > should output tree signalin exports[`test/lib/ls.js TAP ls invalid peer dep > should output tree signaling mismatching peer dep in problems 1`] = ` test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls-invalid-peer-dep ++-- chai@1.0.0 +-- dev-dep@1.0.0 | \`-- foo@1.0.0 -| \`-- bar@1.0.0 -+-- lorem@1.0.0 +| \`-- dog@1.0.0 +-- optional-dep@1.0.0 +-- peer-dep@1.0.0 invalid \`-- prod-dep@1.0.0 - \`-- bar@2.0.0 + \`-- dog@2.0.0 ` @@ -494,27 +494,27 @@ filter-by-child-of-missing-dep@1.0.0 {CWD}/tap-testdir-ls-ls-loading-a-tree-cont exports[`test/lib/ls.js TAP ls missing package.json > should output tree missing name/version of top-level package 1`] = ` {CWD}/tap-testdir-ls-ls-missing-package.json -+-- bar@1.0.0 extraneous -+-- foo@1.0.0 extraneous -| \`-- bar@1.0.0 deduped -\`-- lorem@1.0.0 extraneous ++-- chai@1.0.0 extraneous ++-- dog@1.0.0 extraneous +\`-- foo@1.0.0 extraneous + \`-- dog@1.0.0 deduped ` exports[`test/lib/ls.js TAP ls missing/invalid/extraneous > should output tree containing missing, invalid, extraneous labels 1`] = ` test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls-missing-invalid-extraneous ++-- chai@1.0.0 extraneous +-- foo@1.0.0 invalid -| \`-- bar@1.0.0 -+-- UNMET DEPENDENCY ipsum@^1.0.0 -\`-- lorem@1.0.0 extraneous +| \`-- dog@1.0.0 +\`-- UNMET DEPENDENCY ipsum@^1.0.0 ` exports[`test/lib/ls.js TAP ls no args > should output tree representation of dependencies structure 1`] = ` test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls-no-args -+-- foo@1.0.0 -| \`-- bar@1.0.0 -\`-- lorem@1.0.0 ++-- chai@1.0.0 +\`-- foo@1.0.0 + \`-- dog@1.0.0 ` @@ -534,15 +534,15 @@ test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls-resolved-points-to-git-ref exports[`test/lib/ls.js TAP ls unmet optional dep > should output tree with empty entry for missing optional deps 1`] = ` test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls-unmet-optional-dep ++-- chai@1.0.0 +-- dev-dep@1.0.0 | \`-- foo@1.0.0 -| \`-- bar@1.0.0 -+-- lorem@1.0.0 +| \`-- dog@1.0.0 +-- UNMET OPTIONAL DEPENDENCY missing-optional-dep@^1.0.0 +-- optional-dep@1.0.0 invalid +-- peer-dep@1.0.0 \`-- prod-dep@1.0.0 - \`-- bar@2.0.0 + \`-- dog@2.0.0  ` @@ -586,14 +586,14 @@ test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls-with-dot-filter-arg exports[`test/lib/ls.js TAP ls with filter arg > should output tree contaning only occurrences of filtered by package and colored output 1`] = ` test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls-with-filter-arg -\`-- lorem@1.0.0 +\`-- chai@1.0.0  ` exports[`test/lib/ls.js TAP ls with filter arg nested dep > should output tree contaning only occurrences of filtered package and its ancestors 1`] = ` test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls-with-filter-arg-nested-dep \`-- foo@1.0.0 - \`-- bar@1.0.0 + \`-- dog@1.0.0 ` @@ -605,9 +605,9 @@ test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls-with-missing-filter-arg exports[`test/lib/ls.js TAP ls with multiple filter args > should output tree contaning only occurrences of multiple filtered packages and their ancestors 1`] = ` test-npm-ls@1.0.0 {CWD}/tap-testdir-ls-ls-with-multiple-filter-args -+-- foo@1.0.0 -| \`-- bar@1.0.0 -\`-- lorem@1.0.0 ++-- chai@1.0.0 +\`-- foo@1.0.0 + \`-- dog@1.0.0 ` diff --git a/deps/npm/tap-snapshots/test/lib/outdated.js.test.cjs b/deps/npm/tap-snapshots/test/lib/outdated.js.test.cjs index e57d7110b2275a..fdb25e90eb8c3b 100644 --- a/deps/npm/tap-snapshots/test/lib/outdated.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/outdated.js.test.cjs @@ -7,38 +7,38 @@ 'use strict' exports[`test/lib/outdated.js TAP should display outdated deps outdated --all > must match snapshot 1`] = ` -Package Current Wanted Latest Location Depended by -alpha 1.0.0 1.0.1 1.0.1 node_modules/alpha tap-testdir-outdated-should-display-outdated-deps -beta 1.0.0 1.0.1 1.0.1 node_modules/beta tap-testdir-outdated-should-display-outdated-deps -gamma 1.0.1 1.0.1 2.0.0 node_modules/gamma tap-testdir-outdated-should-display-outdated-deps -theta MISSING 1.0.1 1.0.1 - tap-testdir-outdated-should-display-outdated-deps +Package Current Wanted Latest Location Depended by +cat 1.0.0 1.0.1 1.0.1 node_modules/cat tap-testdir-outdated-should-display-outdated-deps +chai 1.0.0 1.0.1 1.0.1 node_modules/chai tap-testdir-outdated-should-display-outdated-deps +dog 1.0.1 1.0.1 2.0.0 node_modules/dog tap-testdir-outdated-should-display-outdated-deps +theta MISSING 1.0.1 1.0.1 - tap-testdir-outdated-should-display-outdated-deps ` exports[`test/lib/outdated.js TAP should display outdated deps outdated --json --long > must match snapshot 1`] = ` { - "alpha": { + "cat": { "current": "1.0.0", "wanted": "1.0.1", "latest": "1.0.1", "dependent": "tap-testdir-outdated-should-display-outdated-deps", - "location": "{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/alpha", + "location": "{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/cat", "type": "dependencies" }, - "beta": { + "chai": { "current": "1.0.0", "wanted": "1.0.1", "latest": "1.0.1", "dependent": "tap-testdir-outdated-should-display-outdated-deps", - "location": "{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/beta", + "location": "{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/chai", "type": "peerDependencies" }, - "gamma": { + "dog": { "current": "1.0.1", "wanted": "1.0.1", "latest": "2.0.0", "dependent": "tap-testdir-outdated-should-display-outdated-deps", - "location": "{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/gamma", + "location": "{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/dog", "type": "dependencies" }, "theta": { @@ -53,26 +53,26 @@ exports[`test/lib/outdated.js TAP should display outdated deps outdated --json - exports[`test/lib/outdated.js TAP should display outdated deps outdated --json > must match snapshot 1`] = ` { - "alpha": { + "cat": { "current": "1.0.0", "wanted": "1.0.1", "latest": "1.0.1", "dependent": "tap-testdir-outdated-should-display-outdated-deps", - "location": "{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/alpha" + "location": "{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/cat" }, - "beta": { + "chai": { "current": "1.0.0", "wanted": "1.0.1", "latest": "1.0.1", "dependent": "tap-testdir-outdated-should-display-outdated-deps", - "location": "{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/beta" + "location": "{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/chai" }, - "gamma": { + "dog": { "current": "1.0.1", "wanted": "1.0.1", "latest": "2.0.0", "dependent": "tap-testdir-outdated-should-display-outdated-deps", - "location": "{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/gamma" + "location": "{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/dog" }, "theta": { "wanted": "1.0.1", @@ -84,71 +84,71 @@ exports[`test/lib/outdated.js TAP should display outdated deps outdated --json > exports[`test/lib/outdated.js TAP should display outdated deps outdated --long > must match snapshot 1`] = ` -Package Current Wanted Latest Location Depended by Package Type Homepage -alpha 1.0.0 1.0.1 1.0.1 node_modules/alpha tap-testdir-outdated-should-display-outdated-deps dependencies -beta 1.0.0 1.0.1 1.0.1 node_modules/beta tap-testdir-outdated-should-display-outdated-deps peerDependencies -gamma 1.0.1 1.0.1 2.0.0 node_modules/gamma tap-testdir-outdated-should-display-outdated-deps dependencies -theta MISSING 1.0.1 1.0.1 - tap-testdir-outdated-should-display-outdated-deps dependencies +Package Current Wanted Latest Location Depended by Package Type Homepage +cat 1.0.0 1.0.1 1.0.1 node_modules/cat tap-testdir-outdated-should-display-outdated-deps dependencies +chai 1.0.0 1.0.1 1.0.1 node_modules/chai tap-testdir-outdated-should-display-outdated-deps peerDependencies +dog 1.0.1 1.0.1 2.0.0 node_modules/dog tap-testdir-outdated-should-display-outdated-deps dependencies +theta MISSING 1.0.1 1.0.1 - tap-testdir-outdated-should-display-outdated-deps dependencies ` exports[`test/lib/outdated.js TAP should display outdated deps outdated --omit=dev --omit=peer > must match snapshot 1`] = ` -Package Current Wanted Latest Location Depended by -alpha 1.0.0 1.0.1 1.0.1 node_modules/alpha tap-testdir-outdated-should-display-outdated-deps -gamma 1.0.1 1.0.1 2.0.0 node_modules/gamma tap-testdir-outdated-should-display-outdated-deps -theta MISSING 1.0.1 1.0.1 - tap-testdir-outdated-should-display-outdated-deps +Package Current Wanted Latest Location Depended by +cat 1.0.0 1.0.1 1.0.1 node_modules/cat tap-testdir-outdated-should-display-outdated-deps +dog 1.0.1 1.0.1 2.0.0 node_modules/dog tap-testdir-outdated-should-display-outdated-deps +theta MISSING 1.0.1 1.0.1 - tap-testdir-outdated-should-display-outdated-deps ` exports[`test/lib/outdated.js TAP should display outdated deps outdated --omit=dev > must match snapshot 1`] = ` -Package Current Wanted Latest Location Depended by -alpha 1.0.0 1.0.1 1.0.1 node_modules/alpha tap-testdir-outdated-should-display-outdated-deps -beta 1.0.0 1.0.1 1.0.1 node_modules/beta tap-testdir-outdated-should-display-outdated-deps -gamma 1.0.1 1.0.1 2.0.0 node_modules/gamma tap-testdir-outdated-should-display-outdated-deps -theta MISSING 1.0.1 1.0.1 - tap-testdir-outdated-should-display-outdated-deps +Package Current Wanted Latest Location Depended by +cat 1.0.0 1.0.1 1.0.1 node_modules/cat tap-testdir-outdated-should-display-outdated-deps +chai 1.0.0 1.0.1 1.0.1 node_modules/chai tap-testdir-outdated-should-display-outdated-deps +dog 1.0.1 1.0.1 2.0.0 node_modules/dog tap-testdir-outdated-should-display-outdated-deps +theta MISSING 1.0.1 1.0.1 - tap-testdir-outdated-should-display-outdated-deps ` exports[`test/lib/outdated.js TAP should display outdated deps outdated --omit=prod > must match snapshot 1`] = ` -Package Current Wanted Latest Location Depended by -alpha 1.0.0 1.0.1 1.0.1 node_modules/alpha tap-testdir-outdated-should-display-outdated-deps -beta 1.0.0 1.0.1 1.0.1 node_modules/beta tap-testdir-outdated-should-display-outdated-deps -gamma 1.0.1 1.0.1 2.0.0 node_modules/gamma tap-testdir-outdated-should-display-outdated-deps +Package Current Wanted Latest Location Depended by +cat 1.0.0 1.0.1 1.0.1 node_modules/cat tap-testdir-outdated-should-display-outdated-deps +chai 1.0.0 1.0.1 1.0.1 node_modules/chai tap-testdir-outdated-should-display-outdated-deps +dog 1.0.1 1.0.1 2.0.0 node_modules/dog tap-testdir-outdated-should-display-outdated-deps ` exports[`test/lib/outdated.js TAP should display outdated deps outdated --parseable --long > must match snapshot 1`] = ` -{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/alpha:alpha@1.0.1:alpha@1.0.0:alpha@1.0.1:tap-testdir-outdated-should-display-outdated-deps:dependencies: -{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/beta:beta@1.0.1:beta@1.0.0:beta@1.0.1:tap-testdir-outdated-should-display-outdated-deps:peerDependencies: -{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/gamma:gamma@1.0.1:gamma@1.0.1:gamma@2.0.0:tap-testdir-outdated-should-display-outdated-deps:dependencies: +{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/cat:cat@1.0.1:cat@1.0.0:cat@1.0.1:tap-testdir-outdated-should-display-outdated-deps:dependencies: +{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/chai:chai@1.0.1:chai@1.0.0:chai@1.0.1:tap-testdir-outdated-should-display-outdated-deps:peerDependencies: +{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/dog:dog@1.0.1:dog@1.0.1:dog@2.0.0:tap-testdir-outdated-should-display-outdated-deps:dependencies: :theta@1.0.1:MISSING:theta@1.0.1:tap-testdir-outdated-should-display-outdated-deps:dependencies: ` exports[`test/lib/outdated.js TAP should display outdated deps outdated --parseable > must match snapshot 1`] = ` -{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/alpha:alpha@1.0.1:alpha@1.0.0:alpha@1.0.1:tap-testdir-outdated-should-display-outdated-deps -{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/beta:beta@1.0.1:beta@1.0.0:beta@1.0.1:tap-testdir-outdated-should-display-outdated-deps -{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/gamma:gamma@1.0.1:gamma@1.0.1:gamma@2.0.0:tap-testdir-outdated-should-display-outdated-deps +{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/cat:cat@1.0.1:cat@1.0.0:cat@1.0.1:tap-testdir-outdated-should-display-outdated-deps +{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/chai:chai@1.0.1:chai@1.0.0:chai@1.0.1:tap-testdir-outdated-should-display-outdated-deps +{CWD}/test/lib/tap-testdir-outdated-should-display-outdated-deps/node_modules/dog:dog@1.0.1:dog@1.0.1:dog@2.0.0:tap-testdir-outdated-should-display-outdated-deps :theta@1.0.1:MISSING:theta@1.0.1:tap-testdir-outdated-should-display-outdated-deps ` exports[`test/lib/outdated.js TAP should display outdated deps outdated > must match snapshot 1`] = ` -Package Current Wanted Latest Location Depended by -alpha 1.0.0 1.0.1 1.0.1 node_modules/alpha tap-testdir-outdated-should-display-outdated-deps -beta 1.0.0 1.0.1 1.0.1 node_modules/beta tap-testdir-outdated-should-display-outdated-deps -gamma 1.0.1 1.0.1 2.0.0 node_modules/gamma tap-testdir-outdated-should-display-outdated-deps -theta MISSING 1.0.1 1.0.1 - tap-testdir-outdated-should-display-outdated-deps +Package Current Wanted Latest Location Depended by +cat 1.0.0 1.0.1 1.0.1 node_modules/cat tap-testdir-outdated-should-display-outdated-deps +chai 1.0.0 1.0.1 1.0.1 node_modules/chai tap-testdir-outdated-should-display-outdated-deps +dog 1.0.1 1.0.1 2.0.0 node_modules/dog tap-testdir-outdated-should-display-outdated-deps +theta MISSING 1.0.1 1.0.1 - tap-testdir-outdated-should-display-outdated-deps ` exports[`test/lib/outdated.js TAP should display outdated deps outdated global > must match snapshot 1`] = ` -Package Current Wanted Latest Location Depended by -alpha 1.0.0 1.0.1 1.0.1 node_modules/alpha global +Package Current Wanted Latest Location Depended by +cat 1.0.0 1.0.1 1.0.1 node_modules/cat global ` exports[`test/lib/outdated.js TAP should display outdated deps outdated specific dep > must match snapshot 1`] = ` -Package Current Wanted Latest Location Depended by -alpha 1.0.0 1.0.1 1.0.1 node_modules/alpha tap-testdir-outdated-should-display-outdated-deps +Package Current Wanted Latest Location Depended by +cat 1.0.0 1.0.1 1.0.1 node_modules/cat tap-testdir-outdated-should-display-outdated-deps ` diff --git a/deps/npm/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs b/deps/npm/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs index d6761ea30c74b5..53aef86f79d1bd 100644 --- a/deps/npm/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs @@ -1132,7 +1132,8 @@ Show short usage output about the command specified. #### \`user-agent\` -* Default: "npm/{npm-version} node/{node-version} {platform} {arch} {ci}" +* Default: "npm/{npm-version} node/{node-version} {platform} {arch} + workspaces/{workspaces} {ci}" * Type: String Sets the User-Agent request header. The following fields are replaced with @@ -1142,6 +1143,8 @@ their actual counterparts: * \`{node-version}\` - The Node.js version in use * \`{platform}\` - The value of \`process.platform\` * \`{arch}\` - The value of \`process.arch\` +* \`{workspaces}\` - Set to \`true\` if the \`workspaces\` or \`workspace\` options + are set. * \`{ci}\` - The value of the \`ci-name\` config, if set, prefixed with \`ci/\`, or an empty string if \`ci-name\` is empty. diff --git a/deps/npm/tap-snapshots/test/lib/utils/tar.js.test.cjs b/deps/npm/tap-snapshots/test/lib/utils/tar.js.test.cjs index e117b38def9b23..af0b1454b2624c 100644 --- a/deps/npm/tap-snapshots/test/lib/utils/tar.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/utils/tar.js.test.cjs @@ -11,6 +11,9 @@ exports[`test/lib/utils/tar.js TAP should log tarball contents > must match snap package: my-cool-pkg@1.0.0 === Tarball Contents === +4B cat +4B chai +4B dog 97B package.json === Bundled Dependencies === @@ -20,14 +23,14 @@ bundle-dep name: my-cool-pkg version: 1.0.0 filename: my-cool-pkg-1.0.0.tgz -package size: 216 B -unpacked size: 101 B -shasum: a604258e06adecec0b18f48e901c5802f19f7dab -integrity: sha512-fnN6NmI8DerTt[...]6rH17jx7OIFig== +package size: 274 B +unpacked size: 113 B +shasum: cd0dfccff77dff944eb761854bc0b0497d974f67 +integrity: sha512-qeFip1jH05vkW[...]zHSdMdPpYogMA== bundled deps: 1 bundled files: 0 -own files: 2 -total files: 2 +own files: 5 +total files: 5 ` diff --git a/deps/npm/tap-snapshots/test/lib/view.js.test.cjs b/deps/npm/tap-snapshots/test/lib/view.js.test.cjs index 1cdf356356af98..9aafe50e41896f 100644 --- a/deps/npm/tap-snapshots/test/lib/view.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/view.js.test.cjs @@ -80,7 +80,7 @@ dist .unpackedSize:1 B dist-tags: - +latest: 1.0.0 published a year ago ` @@ -97,18 +97,50 @@ dist .unpackedSize:1 B dist-tags: - +latest: 1.0.0 published a year ago ` +exports[`test/lib/view.js TAP should log package info package from git > must match snapshot 1`] = ` + + +green@1.0.0 | ACME | deps: 2 | versions: 2 +green is a very important color + +DEPRECATED!! - true + +keywords:colors, green, crayola + +bin:green + +dist +.tarball:http://hm.green.com/1.0.0.tgz +.shasum:123 +.integrity:--- +.unpackedSize:1 B + +dependencies: +red: 1.0.0 +yellow: 1.0.0 + +maintainers: +-claudia <c@yellow.com> +-isaacs <i@yellow.com> + +dist-tags: +latest: 1.0.0 +` + exports[`test/lib/view.js TAP should log package info package with --json and semver range > must match snapshot 1`] = ` [ { "_npmUser": "claudia ", "name": "cyan", - "dist-tags": {}, + "dist-tags": { + "latest": "1.0.0" + }, "versions": [ "1.0.0", "1.0.1" @@ -125,7 +157,9 @@ exports[`test/lib/view.js TAP should log package info package with --json and se { "_npmUser": "claudia ", "name": "cyan", - "dist-tags": {}, + "dist-tags": { + "latest": "1.0.0" + }, "versions": [ "1.0.0", "1.0.1" @@ -249,7 +283,7 @@ dist .unpackedSize:1 B dist-tags: - +latest: 1.0.0 published by claudia <claudia@cyan.com> ` @@ -266,7 +300,7 @@ dist .unpackedSize:1 B dist-tags: - +latest: 1.0.0 published a year ago ` diff --git a/deps/npm/test/fixtures/mock-npm.js b/deps/npm/test/fixtures/mock-npm.js index 01f482bde291b9..aa8d44020ee361 100644 --- a/deps/npm/test/fixtures/mock-npm.js +++ b/deps/npm/test/fixtures/mock-npm.js @@ -2,6 +2,8 @@ // npm.config You still need a separate flatOptions but this is the first step // to eventually just using npm itself +const realConfig = require('../../lib/utils/config') + const mockLog = { clearProgress: () => {}, disableProgress: () => {}, @@ -25,10 +27,10 @@ const mockNpm = (base = {}) => { config: { // for now just set `find` to what config.find should return // this works cause `find` is not an existing config entry - find: (k) => config[k], - get: (k) => config[k], + find: (k) => ({...realConfig.defaults, ...config})[k], + get: (k) => ({...realConfig.defaults, ...config})[k], set: (k, v) => config[k] = v, - list: [config] + list: [{ ...realConfig.defaults, ...config}] }, } } diff --git a/deps/npm/test/lib/cache.js b/deps/npm/test/lib/cache.js index bbebae8894babe..bad0ede89e1013 100644 --- a/deps/npm/test/lib/cache.js +++ b/deps/npm/test/lib/cache.js @@ -134,20 +134,21 @@ t.test('cache add pkg only', t => { }) }) -t.test('cache add pkg w/ spec modifier', t => { +t.test('cache add multiple pkgs', t => { t.teardown(() => { logOutput = [] tarballStreamSpec = '' tarballStreamOpts = {} }) - cache.exec(['add', 'mypkg', 'latest'], err => { + cache.exec(['add', 'mypkg', 'anotherpkg'], err => { t.error(err) t.strictSame(logOutput, [ - ['silly', 'cache add', 'args', ['mypkg', 'latest']], - ['silly', 'cache add', 'spec', 'mypkg@latest'], + ['silly', 'cache add', 'args', ['mypkg', 'anotherpkg']], + ['silly', 'cache add', 'spec', 'mypkg'], + ['silly', 'cache add', 'spec', 'anotherpkg'], ], 'logs correctly') - t.equal(tarballStreamSpec, 'mypkg@latest', 'passes the correct spec to pacote') + t.equal(tarballStreamSpec, 'anotherpkg', 'passes the correct spec to pacote') t.same(tarballStreamOpts, npm.flatOptions, 'passes the correct options to pacote') t.end() }) diff --git a/deps/npm/test/lib/config.js b/deps/npm/test/lib/config.js index 155ad0bcfb1b45..6c04293137af9e 100644 --- a/deps/npm/test/lib/config.js +++ b/deps/npm/test/lib/config.js @@ -49,6 +49,9 @@ const cliConfig = { json: false, long: false, global: false, + cat: true, + chai: true, + dog: true, } const npm = { @@ -197,6 +200,9 @@ t.test('config list --json', t => { json: true, long: false, global: false, + cat: true, + chai: true, + dog: true, }, 'should list configs usin json' ) diff --git a/deps/npm/test/lib/dist-tag.js b/deps/npm/test/lib/dist-tag.js index 701bdc6e48c35b..6bc17168cdce0f 100644 --- a/deps/npm/test/lib/dist-tag.js +++ b/deps/npm/test/lib/dist-tag.js @@ -68,10 +68,9 @@ const DistTag = t.mock('../../lib/dist-tag.js', { }, }) +const config = {} const npm = mockNpm({ - config: { - global: false, - }, + config, output: msg => { result = result ? [result, msg].join('\n') : msg }, @@ -349,6 +348,10 @@ t.test('add using valid semver range as name', (t) => { t.test('add missing args', (t) => { npm.prefix = t.testdir({}) + config.tag = '' + t.teardown(() => { + delete config.tag + }) distTag.exec(['add', '@scoped/another@7.7.7'], (err) => { t.matchSnapshot(err, 'should exit usage error message') t.end() diff --git a/deps/npm/test/lib/exec.js b/deps/npm/test/lib/exec.js index 5ecc73274876a6..33e30e24f84e0a 100644 --- a/deps/npm/test/lib/exec.js +++ b/deps/npm/test/lib/exec.js @@ -121,11 +121,15 @@ t.afterEach(() => { t.test('npx foo, bin already exists locally', t => { const path = t.testdir({ - foo: 'just some file', + node_modules: { + '.bin': { + foo: 'just some file', + }, + }, }) PROGRESS_IGNORED = true - npm.localBin = path + npm.localBin = resolve(path, 'node_modules', '.bin') exec.exec(['foo', 'one arg', 'two arg'], er => { t.error(er, 'npm exec') @@ -137,7 +141,7 @@ t.test('npx foo, bin already exists locally', t => { stdioString: true, event: 'npx', env: { - PATH: [path, ...PATH].join(delimiter), + PATH: [npm.localBin, ...PATH].join(delimiter), }, stdio: 'inherit', }]) @@ -147,11 +151,15 @@ t.test('npx foo, bin already exists locally', t => { t.test('npx foo, bin already exists globally', t => { const path = t.testdir({ - foo: 'just some file', + node_modules: { + '.bin': { + foo: 'just some file', + }, + }, }) PROGRESS_IGNORED = true - npm.globalBin = path + npm.globalBin = resolve(path, 'node_modules', '.bin') exec.exec(['foo', 'one arg', 'two arg'], er => { t.error(er, 'npm exec') @@ -163,7 +171,7 @@ t.test('npx foo, bin already exists globally', t => { stdioString: true, event: 'npx', env: { - PATH: [path, ...PATH].join(delimiter), + PATH: [npm.globalBin, ...PATH].join(delimiter), }, stdio: 'inherit', }]) @@ -593,7 +601,7 @@ t.test('run command with 2 packages, need install, verify sort', t => { for (const packages of cases) { t.test(packages.join(', '), t => { config.package = packages - const add = packages.map(p => `${p}@`).sort((a, b) => a.localeCompare(b)) + const add = packages.map(p => `${p}@`).sort((a, b) => a.localeCompare(b, 'en')) const path = t.testdir() const installDir = resolve('cache-dir/_npx/07de77790e5f40f2') npm.localPrefix = path @@ -748,7 +756,7 @@ t.test('prompt when installs are needed if not already present and shell is a TT config.package = packages config.yes = undefined - const add = packages.map(p => `${p}@`).sort((a, b) => a.localeCompare(b)) + const add = packages.map(p => `${p}@`).sort((a, b) => a.localeCompare(b, 'en')) const path = t.testdir() const installDir = resolve('cache-dir/_npx/07de77790e5f40f2') npm.localPrefix = path @@ -817,7 +825,7 @@ t.test('skip prompt when installs are needed if not already present and shell is config.package = packages config.yes = undefined - const add = packages.map(p => `${p}@`).sort((a, b) => a.localeCompare(b)) + const add = packages.map(p => `${p}@`).sort((a, b) => a.localeCompare(b, 'en')) const path = t.testdir() const installDir = resolve('cache-dir/_npx/07de77790e5f40f2') npm.localPrefix = path @@ -884,7 +892,7 @@ t.test('skip prompt when installs are needed if not already present and shell is config.package = packages config.yes = undefined - const add = packages.map(p => `${p}@`).sort((a, b) => a.localeCompare(b)) + const add = packages.map(p => `${p}@`).sort((a, b) => a.localeCompare(b, 'en')) const path = t.testdir() const installDir = resolve('cache-dir/_npx/f7fbba6e0636f890') npm.localPrefix = path diff --git a/deps/npm/test/lib/link.js b/deps/npm/test/lib/link.js index 34c533fb72cd58..d3e66185280ae0 100644 --- a/deps/npm/test/lib/link.js +++ b/deps/npm/test/lib/link.js @@ -27,7 +27,7 @@ const printLinks = async (opts) => { const arb = new Arborist(opts) const tree = await arb.loadActual() const linkedItems = [...tree.inventory.values()] - .sort((a, b) => a.pkgid.localeCompare(b.pkgid)) + .sort((a, b) => a.pkgid.localeCompare(b.pkgid, 'en')) for (const item of linkedItems) { if (item.target) res += `${item.path} -> ${item.target.path}\n` diff --git a/deps/npm/test/lib/load-all-commands.js b/deps/npm/test/lib/load-all-commands.js index 8267cd5437ec86..935019756e282a 100644 --- a/deps/npm/test/lib/load-all-commands.js +++ b/deps/npm/test/lib/load-all-commands.js @@ -15,7 +15,7 @@ t.test('load each command', t => { npm.load((er) => { t.notOk(er) npm.config.set('usage', true) - for (const cmd of cmdList.sort((a, b) => a.localeCompare(b))) { + for (const cmd of cmdList.sort((a, b) => a.localeCompare(b, 'en'))) { t.test(cmd, t => { const impl = npm.commands[cmd] if (impl.completion) diff --git a/deps/npm/test/lib/ls.js b/deps/npm/test/lib/ls.js index 6eeaf0ad671bc6..276a06180f6549 100644 --- a/deps/npm/test/lib/ls.js +++ b/deps/npm/test/lib/ls.js @@ -21,19 +21,19 @@ const simpleNmFixture = { name: 'foo', version: '1.0.0', dependencies: { - bar: '^1.0.0', + dog: '^1.0.0', }, }), }, - bar: { + dog: { 'package.json': JSON.stringify({ - name: 'bar', + name: 'dog', version: '1.0.0', }), }, - lorem: { + chai: { 'package.json': JSON.stringify({ - name: 'lorem', + name: 'chai', version: '1.0.0', }), }, @@ -58,13 +58,13 @@ const diffDepTypesNmFixture = { description: 'A PROD dep kind of dep', version: '1.0.0', dependencies: { - bar: '^2.0.0', + dog: '^2.0.0', }, }), node_modules: { - bar: { + dog: { 'package.json': JSON.stringify({ - name: 'bar', + name: 'dog', description: 'A dep that bars', version: '2.0.0', }), @@ -132,7 +132,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -181,12 +181,12 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, }) - ls.exec(['lorem'], (err) => { + ls.exec(['chai'], (err) => { t.error(err, 'npm ls') t.matchSnapshot(redactCwd(result), 'should output tree contaning only occurrences of filtered by package and colored output') npm.color = false @@ -224,12 +224,12 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, }) - ls.exec(['bar'], (err) => { + ls.exec(['dog'], (err) => { t.error(err, 'npm ls') t.matchSnapshot(redactCwd(result), 'should output tree contaning only occurrences of filtered package and its ancestors') t.end() @@ -243,7 +243,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', ipsum: '^1.0.0', }, }), @@ -257,7 +257,7 @@ t.test('ls', (t) => { }, }, }) - ls.exec(['bar@*', 'lorem@1.0.0'], (err) => { + ls.exec(['dog@*', 'chai@1.0.0'], (err) => { t.error(err, 'npm ls') t.matchSnapshot(redactCwd(result), 'should output tree contaning only occurrences of multiple filtered packages and their ancestors') t.end() @@ -271,7 +271,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -298,7 +298,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -321,7 +321,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -412,9 +412,9 @@ t.test('ls', (t) => { t.equal(err.code, 'ELSPROBLEMS', 'should have error code') t.equal( redactCwd(err.message).replace(/\r\n/g, '\n'), + 'extraneous: chai@1.0.0 {CWD}/tap-testdir-ls-ls-missing-invalid-extraneous/node_modules/chai\n' + 'invalid: foo@1.0.0 {CWD}/tap-testdir-ls-ls-missing-invalid-extraneous/node_modules/foo\n' + - 'missing: ipsum@^1.0.0, required by test-npm-ls@1.0.0\n' + - 'extraneous: lorem@1.0.0 {CWD}/tap-testdir-ls-ls-missing-invalid-extraneous/node_modules/lorem', + 'missing: ipsum@^1.0.0, required by test-npm-ls@1.0.0', 'should log missing/invalid/extraneous errors' ) t.matchSnapshot(redactCwd(result), 'should output tree containing missing, invalid, extraneous labels') @@ -451,7 +451,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -480,7 +480,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -509,7 +509,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', 'linked-dep': '^1.0.0', }, devDependencies: { @@ -584,7 +584,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -613,7 +613,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -642,7 +642,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -673,7 +673,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -723,7 +723,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -835,7 +835,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -1243,7 +1243,7 @@ t.test('ls', (t) => { dependencies: { a: { version: '1.0.1', - resolved: 'foo@bar://b8f3a2fc0c3bb8ffd8b0d0072cc6b5a3667e963c', + resolved: 'foo@dog://b8f3a2fc0c3bb8ffd8b0d0072cc6b5a3667e963c', integrity: 'sha512-8AN9lNCcBt5Xeje7fMEEpp5K3rgcAzIpTtAjYb/YMUYu8SbIVF6wz0WqACDVKvpQOUcSfNHZQNLNmue0QSwXOQ==', }, }, @@ -1544,7 +1544,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -1592,12 +1592,12 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, }) - ls.exec(['lorem'], (err) => { + ls.exec(['chai'], (err) => { t.error(err, 'npm ls') t.matchSnapshot(redactCwd(result), 'should output parseable contaning only occurrences of filtered by package') t.end() @@ -1611,12 +1611,12 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, }) - ls.exec(['bar'], (err) => { + ls.exec(['dog'], (err) => { t.error(err, 'npm ls') t.matchSnapshot(redactCwd(result), 'should output parseable contaning only occurrences of filtered package') t.end() @@ -1630,7 +1630,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', ipsum: '^1.0.0', }, }), @@ -1644,7 +1644,7 @@ t.test('ls --parseable', (t) => { }, }, }) - ls.exec(['bar@*', 'lorem@1.0.0'], (err) => { + ls.exec(['dog@*', 'chai@1.0.0'], (err) => { t.error(err, 'npm ls') t.matchSnapshot(redactCwd(result), 'should output parseable contaning only occurrences of multiple filtered packages and their ancestors') t.end() @@ -1658,7 +1658,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -1685,7 +1685,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -1708,7 +1708,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -1731,7 +1731,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -1772,7 +1772,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -1801,7 +1801,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -1830,7 +1830,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', 'linked-dep': '^1.0.0', }, devDependencies: { @@ -1869,7 +1869,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -1898,7 +1898,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -1927,7 +1927,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -1995,7 +1995,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', 'linked-dep': '^1.0.0', }, devDependencies: { @@ -2037,7 +2037,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -2087,7 +2087,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -2114,7 +2114,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -2463,7 +2463,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -2479,12 +2479,12 @@ t.test('ls --json', (t) => { foo: { version: '1.0.0', dependencies: { - bar: { + dog: { version: '1.0.0', }, }, }, - lorem: { + chai: { version: '1.0.0', }, }, @@ -2505,16 +2505,16 @@ t.test('ls --json', (t) => { jsonParse(result), { problems: [ - 'extraneous: bar@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/bar', + 'extraneous: chai@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/chai', + 'extraneous: dog@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/dog', 'extraneous: foo@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/foo', - 'extraneous: lorem@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/lorem', ], dependencies: { - bar: { + dog: { version: '1.0.0', extraneous: true, problems: [ - 'extraneous: bar@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/bar', + 'extraneous: dog@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/dog', ], }, foo: { @@ -2524,16 +2524,16 @@ t.test('ls --json', (t) => { 'extraneous: foo@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/foo', ], dependencies: { - bar: { + dog: { version: '1.0.0', }, }, }, - lorem: { + chai: { version: '1.0.0', extraneous: true, problems: [ - 'extraneous: lorem@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/lorem', + 'extraneous: chai@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/chai', ], }, }, @@ -2563,22 +2563,22 @@ t.test('ls --json', (t) => { name: 'test-npm-ls', version: '1.0.0', problems: [ - 'extraneous: lorem@1.0.0 {CWD}/tap-testdir-ls-ls---json-extraneous-deps/node_modules/lorem', + 'extraneous: chai@1.0.0 {CWD}/tap-testdir-ls-ls---json-extraneous-deps/node_modules/chai', ], dependencies: { foo: { version: '1.0.0', dependencies: { - bar: { + dog: { version: '1.0.0', }, }, }, - lorem: { + chai: { version: '1.0.0', extraneous: true, problems: [ - 'extraneous: lorem@1.0.0 {CWD}/tap-testdir-ls-ls---json-extraneous-deps/node_modules/lorem', + 'extraneous: chai@1.0.0 {CWD}/tap-testdir-ls-ls---json-extraneous-deps/node_modules/chai', ], }, }, @@ -2597,8 +2597,8 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - bar: '^1.0.0', - lorem: '^1.0.0', + dog: '^1.0.0', + chai: '^1.0.0', ipsum: '^1.0.0', }, }), @@ -2638,12 +2638,12 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, }) - ls.exec(['lorem'], (err) => { + ls.exec(['chai'], (err) => { t.error(err, 'npm ls') t.same( jsonParse(result), @@ -2651,7 +2651,7 @@ t.test('ls --json', (t) => { name: 'test-npm-ls', version: '1.0.0', dependencies: { - lorem: { + chai: { version: '1.0.0', }, }, @@ -2674,12 +2674,12 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, }) - ls.exec(['bar'], (err) => { + ls.exec(['dog'], (err) => { t.error(err, 'npm ls') t.same( jsonParse(result), @@ -2690,7 +2690,7 @@ t.test('ls --json', (t) => { foo: { version: '1.0.0', dependencies: { - bar: { + dog: { version: '1.0.0', }, }, @@ -2710,7 +2710,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', ipsum: '^1.0.0', }, }), @@ -2724,7 +2724,7 @@ t.test('ls --json', (t) => { }, }, }) - ls.exec(['bar@*', 'lorem@1.0.0'], (err) => { + ls.exec(['dog@*', 'chai@1.0.0'], (err) => { t.error(err, 'npm ls') t.same( jsonParse(result), @@ -2735,12 +2735,12 @@ t.test('ls --json', (t) => { foo: { version: '1.0.0', dependencies: { - bar: { + dog: { version: '1.0.0', }, }, }, - lorem: { + chai: { version: '1.0.0', }, }, @@ -2758,7 +2758,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -2792,7 +2792,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -2808,7 +2808,7 @@ t.test('ls --json', (t) => { foo: { version: '1.0.0', }, - lorem: { + chai: { version: '1.0.0', }, }, @@ -2830,7 +2830,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -2846,7 +2846,7 @@ t.test('ls --json', (t) => { foo: { version: '1.0.0', }, - lorem: { + chai: { version: '1.0.0', }, }, @@ -2868,7 +2868,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -2884,12 +2884,12 @@ t.test('ls --json', (t) => { foo: { version: '1.0.0', dependencies: { - bar: { + dog: { version: '1.0.0', }, }, }, - lorem: { + chai: { version: '1.0.0', }, }, @@ -2922,9 +2922,9 @@ t.test('ls --json', (t) => { name: 'test-npm-ls', version: '1.0.0', problems: [ + 'extraneous: chai@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-invalid-extraneous/node_modules/chai', 'invalid: foo@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-invalid-extraneous/node_modules/foo', 'missing: ipsum@^1.0.0, required by test-npm-ls@1.0.0', - 'extraneous: lorem@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-invalid-extraneous/node_modules/lorem', ], dependencies: { foo: { @@ -2934,16 +2934,16 @@ t.test('ls --json', (t) => { 'invalid: foo@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-invalid-extraneous/node_modules/foo', ], dependencies: { - bar: { + dog: { version: '1.0.0', }, }, }, - lorem: { + chai: { version: '1.0.0', extraneous: true, problems: [ - 'extraneous: lorem@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-invalid-extraneous/node_modules/lorem', + 'extraneous: chai@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-invalid-extraneous/node_modules/chai', ], }, ipsum: { @@ -2969,7 +2969,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -2995,7 +2995,7 @@ t.test('ls --json', (t) => { dependencies: { foo: { version: '1.0.0', - dependencies: { bar: { version: '1.0.0' } }, + dependencies: { dog: { version: '1.0.0' } }, }, }, }, @@ -3016,7 +3016,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -3042,7 +3042,7 @@ t.test('ls --json', (t) => { dependencies: { foo: { version: '1.0.0', - dependencies: { bar: { version: '1.0.0' } }, + dependencies: { dog: { version: '1.0.0' } }, }, }, }, @@ -3063,7 +3063,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', 'linked-dep': '^1.0.0', }, devDependencies: { @@ -3115,7 +3115,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -3136,9 +3136,9 @@ t.test('ls --json', (t) => { name: 'test-npm-ls', version: '1.0.0', dependencies: { - lorem: { version: '1.0.0' }, + chai: { version: '1.0.0' }, 'optional-dep': { version: '1.0.0' }, - 'prod-dep': { version: '1.0.0', dependencies: { bar: { version: '2.0.0' } } }, + 'prod-dep': { version: '1.0.0', dependencies: { dog: { version: '2.0.0' } } }, }, }, 'should output json containing production deps' @@ -3156,7 +3156,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -3177,9 +3177,9 @@ t.test('ls --json', (t) => { name: 'test-npm-ls', version: '1.0.0', dependencies: { - lorem: { version: '1.0.0' }, + chai: { version: '1.0.0' }, 'optional-dep': { version: '1.0.0' }, - 'prod-dep': { version: '1.0.0', dependencies: { bar: { version: '2.0.0' } } }, + 'prod-dep': { version: '1.0.0', dependencies: { dog: { version: '2.0.0' } } }, }, }, 'should output json containing only prod deps' @@ -3326,7 +3326,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -3367,21 +3367,21 @@ t.test('ls --json', (t) => { name: 'foo', version: '1.0.0', dependencies: { - bar: { - name: 'bar', + dog: { + name: 'dog', version: '1.0.0', - _id: 'bar@1.0.0', + _id: 'dog@1.0.0', devDependencies: {}, peerDependencies: {}, _dependencies: {}, - path: '{CWD}/tap-testdir-ls-ls---json---long/node_modules/bar', + path: '{CWD}/tap-testdir-ls-ls---json---long/node_modules/dog', extraneous: false, }, }, _id: 'foo@1.0.0', devDependencies: {}, peerDependencies: {}, - _dependencies: { bar: '^1.0.0' }, + _dependencies: { dog: '^1.0.0' }, path: '{CWD}/tap-testdir-ls-ls---json---long/node_modules/foo', extraneous: false, }, @@ -3393,14 +3393,14 @@ t.test('ls --json', (t) => { path: '{CWD}/tap-testdir-ls-ls---json---long/node_modules/dev-dep', extraneous: false, }, - lorem: { - name: 'lorem', + chai: { + name: 'chai', version: '1.0.0', - _id: 'lorem@1.0.0', + _id: 'chai@1.0.0', devDependencies: {}, peerDependencies: {}, _dependencies: {}, - path: '{CWD}/tap-testdir-ls-ls---json---long/node_modules/lorem', + path: '{CWD}/tap-testdir-ls-ls---json---long/node_modules/chai', extraneous: false, }, 'optional-dep': { @@ -3419,22 +3419,22 @@ t.test('ls --json', (t) => { description: 'A PROD dep kind of dep', version: '1.0.0', dependencies: { - bar: { - name: 'bar', + dog: { + name: 'dog', description: 'A dep that bars', version: '2.0.0', - _id: 'bar@2.0.0', + _id: 'dog@2.0.0', devDependencies: {}, peerDependencies: {}, _dependencies: {}, - path: '{CWD}/tap-testdir-ls-ls---json---long/node_modules/prod-dep/node_modules/bar', + path: '{CWD}/tap-testdir-ls-ls---json---long/node_modules/prod-dep/node_modules/dog', extraneous: false, }, }, _id: 'prod-dep@1.0.0', devDependencies: {}, peerDependencies: {}, - _dependencies: { bar: '^2.0.0' }, + _dependencies: { dog: '^2.0.0' }, path: '{CWD}/tap-testdir-ls-ls---json---long/node_modules/prod-dep', extraneous: false, }, @@ -3443,7 +3443,7 @@ t.test('ls --json', (t) => { optionalDependencies: { 'optional-dep': '^1.0.0' }, peerDependencies: { 'peer-dep': '^1.0.0' }, _id: 'test-npm-ls@1.0.0', - _dependencies: { 'prod-dep': '^1.0.0', lorem: '^1.0.0', 'optional-dep': '^1.0.0' }, + _dependencies: { 'prod-dep': '^1.0.0', chai: '^1.0.0', 'optional-dep': '^1.0.0' }, path: '{CWD}/tap-testdir-ls-ls---json---long', extraneous: false, }, @@ -3464,7 +3464,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -3507,14 +3507,14 @@ t.test('ls --json', (t) => { path: '{CWD}/tap-testdir-ls-ls---json---long---depth-0/node_modules/dev-dep', extraneous: false, }, - lorem: { - name: 'lorem', + chai: { + name: 'chai', version: '1.0.0', - _id: 'lorem@1.0.0', + _id: 'chai@1.0.0', devDependencies: {}, peerDependencies: {}, _dependencies: {}, - path: '{CWD}/tap-testdir-ls-ls---json---long---depth-0/node_modules/lorem', + path: '{CWD}/tap-testdir-ls-ls---json---long---depth-0/node_modules/chai', extraneous: false, }, 'optional-dep': { @@ -3535,7 +3535,7 @@ t.test('ls --json', (t) => { _id: 'prod-dep@1.0.0', devDependencies: {}, peerDependencies: {}, - _dependencies: { bar: '^2.0.0' }, + _dependencies: { dog: '^2.0.0' }, path: '{CWD}/tap-testdir-ls-ls---json---long---depth-0/node_modules/prod-dep', extraneous: false, }, @@ -3544,7 +3544,7 @@ t.test('ls --json', (t) => { optionalDependencies: { 'optional-dep': '^1.0.0' }, peerDependencies: { 'peer-dep': '^1.0.0' }, _id: 'test-npm-ls@1.0.0', - _dependencies: { 'prod-dep': '^1.0.0', lorem: '^1.0.0', 'optional-dep': '^1.0.0' }, + _dependencies: { 'prod-dep': '^1.0.0', chai: '^1.0.0', 'optional-dep': '^1.0.0' }, path: '{CWD}/tap-testdir-ls-ls---json---long---depth-0', extraneous: false, }, @@ -3598,7 +3598,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -3635,13 +3635,13 @@ t.test('ls --json', (t) => { dependencies: { foo: { version: '1.0.0', - dependencies: { bar: { version: '1.0.0' } }, + dependencies: { dog: { version: '1.0.0' } }, }, }, }, - lorem: { version: '1.0.0' }, + chai: { version: '1.0.0' }, 'optional-dep': { version: '1.0.0' }, - 'prod-dep': { version: '1.0.0', dependencies: { bar: { version: '2.0.0' } } }, + 'prod-dep': { version: '1.0.0', dependencies: { dog: { version: '2.0.0' } } }, }, }, 'should output json signaling missing peer dep in problems' @@ -3657,7 +3657,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -3699,12 +3699,12 @@ t.test('ls --json', (t) => { dependencies: { foo: { version: '1.0.0', - dependencies: { bar: { version: '1.0.0' } }, + dependencies: { dog: { version: '1.0.0' } }, }, }, }, - lorem: { version: '1.0.0' }, - 'prod-dep': { version: '1.0.0', dependencies: { bar: { version: '2.0.0' } } }, + chai: { version: '1.0.0' }, + 'prod-dep': { version: '1.0.0', dependencies: { dog: { version: '2.0.0' } } }, 'missing-optional-dep': {}, // missing optional dep has an empty entry in json output }, }, diff --git a/deps/npm/test/lib/outdated.js b/deps/npm/test/lib/outdated.js index 605853056a000f..f7d572821275f4 100644 --- a/deps/npm/test/lib/outdated.js +++ b/deps/npm/test/lib/outdated.js @@ -3,8 +3,8 @@ const mockNpm = require('../fixtures/mock-npm') const packument = spec => { const mocks = { - alpha: { - name: 'alpha', + cat: { + name: 'cat', 'dist-tags': { latest: '1.0.1', }, @@ -12,13 +12,13 @@ const packument = spec => { '1.0.1': { version: '1.0.1', dependencies: { - gamma: '2.0.0', + dog: '2.0.0', }, }, }, }, - beta: { - name: 'beta', + chai: { + name: 'chai', 'dist-tags': { latest: '1.0.1', }, @@ -28,8 +28,8 @@ const packument = spec => { }, }, }, - gamma: { - name: 'gamma', + dog: { + name: 'dog', 'dist-tags': { latest: '2.0.0', }, @@ -74,9 +74,9 @@ const output = (msg) => { const globalDir = t.testdir({ node_modules: { - alpha: { + cat: { 'package.json': JSON.stringify({ - name: 'alpha', + name: 'cat', version: '1.0.0', }, null, 2), }, @@ -116,8 +116,8 @@ t.test('should display outdated deps', t => { name: 'delta', version: '1.0.0', dependencies: { - alpha: '^1.0.0', - gamma: '^1.0.0', + cat: '^1.0.0', + dog: '^1.0.0', theta: '^1.0.0', }, devDependencies: { @@ -127,36 +127,36 @@ t.test('should display outdated deps', t => { lorem: '^1.0.0', }, peerDependencies: { - beta: '^1.0.0', + chai: '^1.0.0', }, }, null, 2), node_modules: { - alpha: { + cat: { 'package.json': JSON.stringify({ - name: 'alpha', + name: 'cat', version: '1.0.0', dependencies: { - gamma: '2.0.0', + dog: '2.0.0', }, }, null, 2), node_modules: { - gamma: { + dog: { 'package.json': JSON.stringify({ - name: 'gamma', + name: 'dog', version: '2.0.0', }, null, 2), }, }, }, - beta: { + chai: { 'package.json': JSON.stringify({ - name: 'beta', + name: 'chai', version: '1.0.0', }, null, 2), }, - gamma: { + dog: { 'package.json': JSON.stringify({ - name: 'gamma', + name: 'dog', version: '1.0.1', }, null, 2), }, @@ -307,7 +307,7 @@ t.test('should display outdated deps', t => { config: { global: false, }, - }).exec(['alpha'], () => { + }).exec(['cat'], () => { t.matchSnapshot(logs) t.end() }) @@ -322,13 +322,13 @@ t.test('should return if no outdated deps', t => { name: 'delta', version: '1.0.0', dependencies: { - alpha: '^1.0.0', + cat: '^1.0.0', }, }, null, 2), node_modules: { - alpha: { + cat: { 'package.json': JSON.stringify({ - name: 'alpha', + name: 'cat', version: '1.0.1', }, null, 2), }, @@ -376,7 +376,7 @@ t.test('should skip missing non-prod deps', t => { name: 'delta', version: '1.0.0', devDependencies: { - beta: '^1.0.0', + chai: '^1.0.0', }, }, null, 2), node_modules: {}, @@ -396,13 +396,13 @@ t.test('should skip invalid pkg ranges', t => { name: 'delta', version: '1.0.0', dependencies: { - alpha: '>=^2', + cat: '>=^2', }, }, null, 2), node_modules: { - alpha: { + cat: { 'package.json': JSON.stringify({ - name: 'alpha', + name: 'cat', version: '1.0.0', }, null, 2), }, @@ -421,13 +421,13 @@ t.test('should skip git specs', t => { name: 'delta', version: '1.0.0', dependencies: { - alpha: 'github:username/foo', + cat: 'github:username/foo', }, }, null, 2), node_modules: { - alpha: { + cat: { 'package.json': JSON.stringify({ - name: 'alpha', + name: 'cat', version: '1.0.0', }, null, 2), }, diff --git a/deps/npm/test/lib/utils/cleanup-log-files.js b/deps/npm/test/lib/utils/cleanup-log-files.js index 61240b7b523dea..e97cf36b55dec0 100644 --- a/deps/npm/test/lib/utils/cleanup-log-files.js +++ b/deps/npm/test/lib/utils/cleanup-log-files.js @@ -71,7 +71,7 @@ t.test('rimraf fail', t => { const warnings = [] const warn = (...warning) => warnings.push(basename(warning[2])) return cleanup(cache, 3, warn).then(() => { - t.strictSame(warnings.sort((a, b) => a.localeCompare(b)), [ + t.strictSame(warnings.sort((a, b) => a.localeCompare(b, 'en')), [ '1-debug.log', '2-debug.log', ]) diff --git a/deps/npm/test/lib/utils/completion/installed-deep.js b/deps/npm/test/lib/utils/completion/installed-deep.js index ba14798bbec18f..21e77a568bd8a7 100644 --- a/deps/npm/test/lib/utils/completion/installed-deep.js +++ b/deps/npm/test/lib/utils/completion/installed-deep.js @@ -63,6 +63,15 @@ const fixture = { 'package.json': JSON.stringify({ name: 'c', version: '1.0.0', + dependencies: { + ch: '1.0.0', + }, + }), + }, + ch: { + 'package.json': JSON.stringify({ + name: 'ch', + version: '1.0.0', }), }, d: { @@ -160,8 +169,8 @@ t.test('get list of package names', async t => { ['foo', '-g'], ['a-bar', '-g'], 'a', 'b', 'c', - 'd', 'e', 'f', - 'g', 'bb', + 'ch', 'd', 'e', + 'f', 'g', 'bb', ], 'should return list of package names and global flag' ) @@ -211,9 +220,9 @@ t.test('limit depth', async t => { ['bar', '-g'], ['foo', '-g'], 'a', 'b', - 'c', 'd', - 'e', 'f', - 'g', + 'c', 'ch', + 'd', 'e', + 'f', 'g', ], 'should print only packages up to the specified depth' ) diff --git a/deps/npm/test/lib/utils/config/definitions.js b/deps/npm/test/lib/utils/config/definitions.js index f735223655f505..49e4152883795d 100644 --- a/deps/npm/test/lib/utils/config/definitions.js +++ b/deps/npm/test/lib/utils/config/definitions.js @@ -729,7 +729,7 @@ t.test('user-agent', t => { } const flat = {} const expectNoCI = `npm/1.2.3 node/9.8.7 ` + - `${process.platform} ${process.arch}` + `${process.platform} ${process.arch} workspaces/false` definitions['user-agent'].flatten('user-agent', obj, flat) t.equal(flat.userAgent, expectNoCI) t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set') @@ -742,6 +742,23 @@ t.test('user-agent', t => { t.equal(flat.userAgent, expectCI) t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set') t.equal(obj['user-agent'], flat.userAgent, 'config user-agent template is translated') + + delete obj['ci-name'] + obj.workspaces = true + obj['user-agent'] = definitions['user-agent'].default + const expectWorkspaces = expectNoCI.replace('workspaces/false', 'workspaces/true') + definitions['user-agent'].flatten('user-agent', obj, flat) + t.equal(flat.userAgent, expectWorkspaces) + t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set') + t.equal(obj['user-agent'], flat.userAgent, 'config user-agent template is translated') + + delete obj.workspaces + obj.workspace = ['foo'] + obj['user-agent'] = definitions['user-agent'].default + definitions['user-agent'].flatten('user-agent', obj, flat) + t.equal(flat.userAgent, expectWorkspaces) + t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set') + t.equal(obj['user-agent'], flat.userAgent, 'config user-agent template is translated') t.end() }) diff --git a/deps/npm/test/lib/utils/tar.js b/deps/npm/test/lib/utils/tar.js index 5758442fcb6f69..2662d47ace4863 100644 --- a/deps/npm/test/lib/utils/tar.js +++ b/deps/npm/test/lib/utils/tar.js @@ -26,6 +26,9 @@ t.test('should log tarball contents', async (t) => { 'bundle-dep', ], }, null, 2), + cat: 'meow', + chai: 'blub', + dog: 'woof', node_modules: { 'bundle-dep': 'toto', }, diff --git a/deps/npm/test/lib/utils/update-notifier.js b/deps/npm/test/lib/utils/update-notifier.js index 1735b31057b146..ad4d407728f93f 100644 --- a/deps/npm/test/lib/utils/update-notifier.js +++ b/deps/npm/test/lib/utils/update-notifier.js @@ -145,15 +145,15 @@ t.test('situations in which we do not notify', t => { }) t.test('only check weekly for GA releases', async t => { - // the 10 is fuzz factor for test environment - STAT_MTIME = Date.now() - (1000 * 60 * 60 * 24 * 7) + 10 + // One week (plus five minutes to account for test environment fuzziness) + STAT_MTIME = Date.now() - (1000 * 60 * 60 * 24 * 7) + (1000 * 60 * 5) t.equal(await updateNotifier(npm), null) t.strictSame(MANIFEST_REQUEST, [], 'no requests for manifests') }) t.test('only check daily for betas', async t => { - // the 10 is fuzz factor for test environment - STAT_MTIME = Date.now() - (1000 * 60 * 60 * 24) + 10 + // One day (plus five minutes to account for test environment fuzziness) + STAT_MTIME = Date.now() - (1000 * 60 * 60 * 24) + (1000 * 60 * 5) t.equal(await updateNotifier({ ...npm, version: HAVE_BETA }), null) t.strictSame(MANIFEST_REQUEST, [], 'no requests for manifests') }) diff --git a/deps/npm/test/lib/view.js b/deps/npm/test/lib/view.js index eb2beb9ff5864b..4544d7d5d1a94a 100644 --- a/deps/npm/test/lib/view.js +++ b/deps/npm/test/lib/view.js @@ -34,7 +34,9 @@ const packument = (nv, opts) => { }, blue: { name: 'blue', - 'dist-tags': {}, + 'dist-tags': { + latest: '1.0.0', + }, time: { '1.0.0': '2019-08-06T16:21:09.842Z', }, @@ -59,7 +61,9 @@ const packument = (nv, opts) => { email: 'claudia@cyan.com', }, name: 'cyan', - 'dist-tags': {}, + 'dist-tags': { + latest: '1.0.0', + }, versions: { '1.0.0': { version: '1.0.0', @@ -236,6 +240,8 @@ const packument = (nv, opts) => { }, }, } + if (nv.type === 'git') + return mocks[nv.hosted.project] return mocks[nv.name] } @@ -248,7 +254,7 @@ t.test('should log package info', t => { }, }) const npm = mockNpm({ - config: { global: false }, + config: { unicode: false }, }) const view = new View(npm) @@ -258,7 +264,10 @@ t.test('should log package info', t => { }, }) const jsonNpm = mockNpm({ - config: { json: true }, + config: { + json: true, + tag: 'latest', + }, }) const viewJson = new ViewJson(jsonNpm) @@ -268,13 +277,17 @@ t.test('should log package info', t => { }, }) const unicodeNpm = mockNpm({ - config: { - global: false, - unicode: true, - }, + config: { unicode: true }, }) const viewUnicode = new ViewUnicode(unicodeNpm) + t.test('package from git', t => { + view.exec(['https://github.com/npm/green'], () => { + t.matchSnapshot(logs) + t.end() + }) + }) + t.test('package with license, bugs, repository and other fields', t => { view.exec(['green@1.0.0'], () => { t.matchSnapshot(logs) @@ -358,7 +371,6 @@ t.test('should log info of package in current working dir', t => { prefix: testDir, config: { tag: '1.0.0', - global: false, }, }) const view = new View(npm) @@ -388,8 +400,8 @@ t.test('should log info by field name', t => { }) const jsonNpm = mockNpm({ config: { + tag: 'latest', json: true, - global: false, }, }) @@ -400,9 +412,7 @@ t.test('should log info by field name', t => { packument, }, }) - const npm = mockNpm({ - config: { global: false }, - }) + const npm = mockNpm() const view = new View(npm) t.test('readme', t => { @@ -474,7 +484,10 @@ t.test('should log info by field name', t => { t.test('throw error if global mode', (t) => { const View = t.mock('../../lib/view.js') const npm = mockNpm({ - config: { global: true }, + config: { + global: true, + tag: 'latest', + }, }) const view = new View(npm) view.exec([], (err) => { @@ -489,7 +502,6 @@ t.test('throw ENOENT error if package.json misisng', (t) => { const View = t.mock('../../lib/view.js') const npm = mockNpm({ prefix: testDir, - config: { global: false }, }) const view = new View(npm) view.exec([], (err) => { @@ -506,7 +518,6 @@ t.test('throw EJSONPARSE error if package.json not json', (t) => { const View = t.mock('../../lib/view.js') const npm = mockNpm({ prefix: testDir, - config: { global: false }, }) const view = new View(npm) view.exec([], (err) => { @@ -523,7 +534,6 @@ t.test('throw error if package.json has no name', (t) => { const View = t.mock('../../lib/view.js') const npm = mockNpm({ prefix: testDir, - config: { global: false }, }) const view = new View(npm) view.exec([], (err) => { @@ -541,7 +551,6 @@ t.test('throws when unpublished', (t) => { const npm = mockNpm({ config: { tag: '1.0.1', - global: false, }, }) const view = new View(npm) @@ -581,6 +590,7 @@ t.test('workspaces', t => { }, }) const config = { + unicode: false, tag: 'latest', } let warnMsg @@ -684,7 +694,6 @@ t.test('completion', async t => { const npm = mockNpm({ config: { tag: '1.0.1', - global: false, }, }) const view = new View(npm) @@ -700,7 +709,6 @@ t.test('no registry completion', async t => { const npm = mockNpm({ config: { tag: '1.0.1', - global: false, }, }) const view = new View(npm) From c182198c44e71bd0e62af84c79f9a116807cea72 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Wed, 12 May 2021 15:10:32 -0700 Subject: [PATCH 56/86] process: add `'worker'` event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provides a new `process.on('worker', (worker) => {})` event that is triggered by the creation of a new `worker_thread.Worker`. The use case is to allow hooks to be installed for monitoring workers without having to modify the call sites around those. Signed-off-by: James M Snell PR-URL: https://github.com/nodejs/node/pull/38659 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott Reviewed-By: Gerhard Stöbich --- doc/api/process.md | 9 +++++++++ lib/internal/worker.js | 2 ++ test/parallel/test-worker-event.js | 13 +++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 test/parallel/test-worker-event.js diff --git a/doc/api/process.md b/doc/api/process.md index 95dd6a87855954..0e852dcb100acc 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -457,6 +457,15 @@ of the custom deprecation. The `*-deprecation` command-line flags only affect warnings that use the name `'DeprecationWarning'`. +### Event: `'worker'` + + +* `worker` {Worker} The {Worker} that was created. + +The `'worker'` event is emitted after a new {Worker} thread has been created. + #### Emitting custom warnings See the [`process.emitWarning()`][process_emit_warning] method for issuing diff --git a/lib/internal/worker.js b/lib/internal/worker.js index f1da0d4ded4cea..f2414ebeec4aae 100644 --- a/lib/internal/worker.js +++ b/lib/internal/worker.js @@ -266,6 +266,8 @@ class Worker extends EventEmitter { }; // Actually start the new thread now that everything is in place. this[kHandle].startThread(); + + process.nextTick(() => process.emit('worker', this)); } [kOnExit](code, customErr, customErrReason) { diff --git a/test/parallel/test-worker-event.js b/test/parallel/test-worker-event.js new file mode 100644 index 00000000000000..9d6056e1091468 --- /dev/null +++ b/test/parallel/test-worker-event.js @@ -0,0 +1,13 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const { + Worker, +} = require('worker_threads'); + +process.on('worker', common.mustCall(({ threadId }) => { + assert.strictEqual(threadId, 1); +})); + +new Worker('', { eval: true }); From ec8ab22ce6d641edaa23b4e0c41b2e7bec5605da Mon Sep 17 00:00:00 2001 From: James M Snell Date: Wed, 12 May 2021 15:34:29 -0700 Subject: [PATCH 57/86] tools: add `Worker` to type-parser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: James M Snell PR-URL: https://github.com/nodejs/node/pull/38659 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott Reviewed-By: Gerhard Stöbich --- test/parallel/test-worker-event.js | 3 ++- tools/doc/type-parser.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-worker-event.js b/test/parallel/test-worker-event.js index 9d6056e1091468..01e95ead8316cb 100644 --- a/test/parallel/test-worker-event.js +++ b/test/parallel/test-worker-event.js @@ -4,10 +4,11 @@ const common = require('../common'); const assert = require('assert'); const { Worker, + threadId: parentThreadId, } = require('worker_threads'); process.on('worker', common.mustCall(({ threadId }) => { - assert.strictEqual(threadId, 1); + assert.strictEqual(threadId, parentThreadId + 1); })); new Worker('', { eval: true }); diff --git a/tools/doc/type-parser.js b/tools/doc/type-parser.js index f2b953358d03ce..4fd91f4b478149 100644 --- a/tools/doc/type-parser.js +++ b/tools/doc/type-parser.js @@ -223,6 +223,7 @@ const customTypesMap = { 'vm.SourceTextModule': 'vm.html#vm_class_vm_sourcetextmodule', 'MessagePort': 'worker_threads.html#worker_threads_class_messageport', + 'Worker': 'worker_threads.html#worker_threads_class_worker', 'X509Certificate': 'crypto.html#crypto_class_x509certificate', From 3d8b8e133f04ce4d892bd57b4d819cd7f9b347fa Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Sat, 8 May 2021 17:09:18 +0800 Subject: [PATCH 58/86] http: refactor to remove redundant argument of _deferToConnect PR-URL: https://github.com/nodejs/node/pull/38598 Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca Reviewed-By: Antoine du Hamel --- lib/_http_client.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/_http_client.js b/lib/_http_client.js index 4184191c0fbabc..f3b88b62730175 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -818,7 +818,7 @@ function onSocketNT(req, socket, err) { } ClientRequest.prototype._deferToConnect = _deferToConnect; -function _deferToConnect(method, arguments_, cb) { +function _deferToConnect(method, arguments_) { // This function is for calls that need to happen once the socket is // assigned to this request and writable. It's an important promisy // thing for all the socket calls that happen either now @@ -828,9 +828,6 @@ function _deferToConnect(method, arguments_, cb) { const callSocketMethod = () => { if (method) ReflectApply(this.socket[method], this.socket, arguments_); - - if (typeof cb === 'function') - cb(); }; const onSocket = () => { From 3d0fad3840ba40ae2faebe88abb18ef4e5349419 Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Wed, 12 May 2021 22:53:04 +0800 Subject: [PATCH 59/86] test: improve coverage of lib/os.js PR-URL: https://github.com/nodejs/node/pull/38653 Refs: https://coverage.nodejs.org/coverage-52e4fb5b23157222/lib/os.js.html#L96 Reviewed-By: Darshan Sen Reviewed-By: Antoine du Hamel Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Michael Dawson --- test/parallel/test-os.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/parallel/test-os.js b/test/parallel/test-os.js index 5ee0fb9ca8dadb..6a5b43368249db 100644 --- a/test/parallel/test-os.js +++ b/test/parallel/test-os.js @@ -247,6 +247,7 @@ assert.strictEqual(`${os.endianness}`, os.endianness()); assert.strictEqual(`${os.tmpdir}`, os.tmpdir()); assert.strictEqual(`${os.arch}`, os.arch()); assert.strictEqual(`${os.platform}`, os.platform()); +assert.strictEqual(`${os.version}`, os.version()); assert.strictEqual(+os.totalmem, os.totalmem()); From 4296591154fcccd830f6abe36e9420d8eadafaff Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 26 Apr 2021 05:52:16 +0200 Subject: [PATCH 60/86] build,src,test,doc: enable FIPS for OpenSSL 3.0 This commit enables FIPS when Node.js is dynamically linking against quictls/openssl-3.0. BUILDING.md has been updated with instructions to configure and build quictls/openssl 3.0.0-alpha-15 and includes a couple of work-arounds which I believe are fixed in alpha-16 and can be removed when alpha-16 is available. The information might be a little too detailed/verbose but I thought it would be helpful to at least initially include all the steps. PR-URL: https://github.com/nodejs/node/pull/38633 Reviewed-By: James M Snell Reviewed-By: Rich Trott Reviewed-By: Richard Lau Reviewed-By: Michael Dawson --- BUILDING.md | 130 +++++++++++++++++++++++++++++- common.gypi | 2 +- configure.py | 6 ++ src/crypto/crypto_util.cc | 15 ++++ src/crypto/crypto_util.h | 2 +- test/parallel/test-crypto-fips.js | 6 +- 6 files changed, 157 insertions(+), 4 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 973c87b73ea1a5..6ebe84f6e1aad5 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -759,7 +759,135 @@ as `deps/icu` (You'll have: `deps/icu/source/...`) ## Building Node.js with FIPS-compliant OpenSSL -The current version of Node.js does not support FIPS. +The current version of Node.js does not support FIPS when statically linking +(the default) with OpenSSL 1.1.1 but for dynamically linking it is possible +to enable FIPS using the configuration flag `--openssl-is-fips`. + +### Configuring and building quictls/openssl for FIPS + +For quictls/openssl 3.0 it is possible to enable FIPS when dynamically linking. +Node.js currently uses openssl-3.0.0+quic which can be configured as +follows: +```console +$ git clone git@github.com:quictls/openssl.git +$ cd openssl +$ ./config --prefix=/path/to/install/dir/ shared enable-fips linux-x86_64 +``` +This can be compiled and installed using the following commands: +```console +$ make -j8 +$ make install_ssldirs +$ make install_fips +``` + +After the FIPS module and configuration file have been installed by the above +instructions we also need to update `/path/to/install/dir/ssl/openssl.cnf` to +use the generated FIPS configuration file (`fipsmodule.cnf`): +```text +.include fipsmodule.cnf + +# List of providers to load +[provider_sect] +default = default_sect +# The fips section name should match the section name inside the +# included /path/to/install/dir/ssl/fipsmodule.cnf. +fips = fips_sect + +[default_sect] +activate = 1 +``` + +In the above case OpenSSL is not installed in the default location so two +environment variables need to be set, `OPENSSL_CONF`, and `OPENSSL_MODULES` +which should point to the OpenSSL configuration file and the directory where +OpenSSL modules are located: +```console +$ export OPENSSL_CONF=/path/to/install/dir/ssl/openssl.cnf +$ export OPENSSL_MODULES=/path/to/install/dir/lib/ossl-modules +``` + +Node.js can then be configured to enable FIPS: +```console +$ ./configure --shared-openssl --shared-openssl-libpath=/path/to/install/dir/lib --shared-openssl-includes=/path/to/install/dir/include --shared-openssl-libname=crypto,ssl --openssl-is-fips +$ export LD_LIBRARY_PATH=/path/to/install/dir/lib +$ make -j8 +``` + +Verify the produced executable: +```console +$ ldd ./node + linux-vdso.so.1 (0x00007ffd7917b000) + libcrypto.so.81.3 => /path/to/install/dir/lib/libcrypto.so.81.3 (0x00007fd911321000) + libssl.so.81.3 => /path/to/install/dir/lib/libssl.so.81.3 (0x00007fd91125e000) + libdl.so.2 => /usr/lib64/libdl.so.2 (0x00007fd911232000) + libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fd911039000) + libm.so.6 => /usr/lib64/libm.so.6 (0x00007fd910ef3000) + libgcc_s.so.1 => /usr/lib64/libgcc_s.so.1 (0x00007fd910ed9000) + libpthread.so.0 => /usr/lib64/libpthread.so.0 (0x00007fd910eb5000) + libc.so.6 => /usr/lib64/libc.so.6 (0x00007fd910cec000) + /lib64/ld-linux-x86-64.so.2 (0x00007fd9117f2000) +``` +If the `ldd` command says that `libcrypto` cannot be found one needs to set +`LD_LIBRARY_PATH` to point to the directory used above for +`--shared-openssl-libpath` (see previous step). + +Verify the OpenSSL version: +```console +$ ./node -p process.versions.openssl +3.0.0-alpha16+quic +``` + +Verify that FIPS is available: +```console +$ ./node -p 'process.config.variables.openssl_is_fips' +true +$ ./node --enable-fips -p 'crypto.getFips()' +1 +``` + +FIPS support can then be enable via the OpenSSL configuration file or +using `--enable-fips` or `--force-fips` command line options to the Node.js +executable. See sections +[Enabling FIPS using Node.js options](#enabling-fips-using-node.js-options) and +[Enabling FIPS using OpenSSL config](#enabling-fips-using-openssl-config) below. + +### Enabling FIPS using Node.js options +This is done using one of the Node.js options `--enable-fips` or +`--force-fips`, for example: +```console +$ node --enable-fips -p 'crypto.getFips()' +``` + +### Enabling FIPS using OpenSSL config +This example show that using OpenSSL's configuration file, FIPS can be enabled +without specifying the `--enable-fips` or `--force-fips` options by setting +`default_properties = fips=yes` in the FIPS configuration file. See +[link](https://github.com/openssl/openssl/blob/master/README-FIPS.md#loading-the-fips-module-at-the-same-time-as-other-providers) +for details. + +For this to work the OpenSSL configuration file (default openssl.cnf) needs to +be updated. The following shows an example: +```console +openssl_conf = openssl_init + +.include /path/to/install/dir/ssl/fipsmodule.cnf + +[openssl_init] +providers = prov +alg_section = algorithm_sect + +[prov] +fips = fips_sect +default = default_sect + +[default_sect] +activate = 1 + +[algorithm_sect] +default_properties = fips=yes +``` +After this change Node.js can be run without the `--enable-fips` or `--force-fips` +options. ## Building Node.js with external core modules diff --git a/common.gypi b/common.gypi index 75d4b692e9b62b..4bc75c7c41c6dd 100644 --- a/common.gypi +++ b/common.gypi @@ -99,7 +99,7 @@ 'v8_base': '<(PRODUCT_DIR)/obj.target/tools/v8_gypfiles/libv8_snapshot.a', }], ['openssl_fips != ""', { - 'openssl_product': '<(STATIC_LIB_PREFIX)crypto<(STATIC_LIB_SUFFIX)', + 'openssl_product': '<(STATIC_LIB_PREFIX)openssl<(STATIC_LIB_SUFFIX)', }, { 'openssl_product': '<(STATIC_LIB_PREFIX)openssl<(STATIC_LIB_SUFFIX)', }], diff --git a/configure.py b/configure.py index 9ec7da8924b132..895a0869cbc9d1 100755 --- a/configure.py +++ b/configure.py @@ -1456,6 +1456,12 @@ def without_ssl_error(option): if options.openssl_fips or options.openssl_fips == '': error('FIPS is not supported in this version of Node.js') + if options.openssl_is_fips and not options.shared_openssl: + error('--openssl-is-fips is only available with --shared-openssl') + + if options.openssl_is_fips: + o['defines'] += ['OPENSSL_FIPS'] + if options.shared_openssl: variables['openssl_quic'] = b(getsharedopensslhasquic.get_has_quic(options.__dict__['shared_openssl_includes'])) diff --git a/src/crypto/crypto_util.cc b/src/crypto/crypto_util.cc index 9c35a7cabbf551..0d533ce42531d1 100644 --- a/src/crypto/crypto_util.cc +++ b/src/crypto/crypto_util.cc @@ -14,6 +14,12 @@ #include "math.h" +#ifdef OPENSSL_FIPS +#if OPENSSL_VERSION_MAJOR >= 3 +#include "openssl/provider.h" +#endif +#endif + namespace node { using v8::ArrayBuffer; @@ -197,7 +203,16 @@ void SetFipsCrypto(const FunctionCallbackInfo& args) { void TestFipsCrypto(const v8::FunctionCallbackInfo& args) { #ifdef OPENSSL_FIPS +#if OPENSSL_VERSION_MAJOR >= 3 + OSSL_PROVIDER* fips_provider = nullptr; + if (OSSL_PROVIDER_available(nullptr, "fips")) { + fips_provider = OSSL_PROVIDER_load(nullptr, "fips"); + } + const auto enabled = fips_provider == nullptr ? 0 : + OSSL_PROVIDER_self_test(fips_provider) ? 1 : 0; +#else const auto enabled = FIPS_selftest() ? 1 : 0; +#endif #else // OPENSSL_FIPS const auto enabled = 0; #endif // OPENSSL_FIPS diff --git a/src/crypto/crypto_util.h b/src/crypto/crypto_util.h index 27bb6310b884d1..f2f61aa4518581 100644 --- a/src/crypto/crypto_util.h +++ b/src/crypto/crypto_util.h @@ -24,7 +24,7 @@ #endif // !OPENSSL_NO_ENGINE // The FIPS-related functions are only available // when the OpenSSL itself was compiled with FIPS support. -#ifdef OPENSSL_FIPS +#if defined(OPENSSL_FIPS) && OPENSSL_VERSION_MAJOR < 3 # include #endif // OPENSSL_FIPS diff --git a/test/parallel/test-crypto-fips.js b/test/parallel/test-crypto-fips.js index 204951514a8ede..b6e70b62be68b9 100644 --- a/test/parallel/test-crypto-fips.js +++ b/test/parallel/test-crypto-fips.js @@ -66,6 +66,10 @@ testHelper( 'require("crypto").getFips()', { ...process.env, 'OPENSSL_CONF': '' }); +// This should succeed for both FIPS and non-FIPS builds in combination with +// OpenSSL 1.1.1 or OpenSSL 3.0 +const test_result = testFipsCrypto(); +assert.ok(test_result === 1 || test_result === 0); // If Node was configured using --shared-openssl fips support might be // available depending on how OpenSSL was built. If fips support is @@ -79,7 +83,7 @@ testHelper( // ("Error: Cannot set FIPS mode in a non-FIPS build."). // Due to this uncertainty the following tests are skipped when configured // with --shared-openssl. -if (!sharedOpenSSL()) { +if (!sharedOpenSSL() && !common.hasOpenSSL3) { // OpenSSL config file should be able to turn on FIPS mode testHelper( 'stdout', From 36bb7243ffd7a2d1c5a3252dff9af46800916c61 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 27 Apr 2021 12:27:39 +0200 Subject: [PATCH 61/86] debugger: refactor `inspect_repl` to use primordials PR-URL: https://github.com/nodejs/node/pull/38551 Reviewed-By: Rich Trott Reviewed-By: James M Snell --- lib/internal/inspector/inspect_repl.js | 567 ++++++++++++++----------- 1 file changed, 316 insertions(+), 251 deletions(-) diff --git a/lib/internal/inspector/inspect_repl.js b/lib/internal/inspector/inspect_repl.js index 1b23196b2138de..0fcde39bfc3e2c 100644 --- a/lib/internal/inspector/inspect_repl.js +++ b/lib/internal/inspector/inspect_repl.js @@ -21,10 +21,57 @@ */ // TODO(trott): enable ESLint -/* eslint-disable getter-return, no-restricted-syntax, - node-core/prefer-primordials */ +/* eslint-disable getter-return, no-restricted-syntax */ 'use strict'; + +const { + Array, + ArrayFrom, + ArrayPrototypeFilter, + ArrayPrototypeFind, + ArrayPrototypeForEach, + ArrayPrototypeIncludes, + ArrayPrototypeIndexOf, + ArrayPrototypeJoin, + ArrayPrototypeMap, + ArrayPrototypePush, + ArrayPrototypeSlice, + ArrayPrototypeSome, + ArrayPrototypeSplice, + Date, + Error, + FunctionPrototypeCall, + JSONStringify, + MathMax, + ObjectAssign, + ObjectDefineProperty, + ObjectKeys, + ObjectValues, + Promise, + PromiseAll, + PromisePrototypeCatch, + PromisePrototypeThen, + PromiseResolve, + ReflectGetOwnPropertyDescriptor, + ReflectOwnKeys, + RegExpPrototypeSymbolMatch, + RegExpPrototypeSymbolReplace, + SafeArrayIterator, + SafeMap, + String, + StringFromCharCode, + StringPrototypeEndsWith, + StringPrototypeIncludes, + StringPrototypeRepeat, + StringPrototypeSlice, + StringPrototypeSplit, + StringPrototypeStartsWith, + StringPrototypeToUpperCase, + StringPrototypeTrim, + TypeError, +} = primordials; + const FS = require('fs'); const Path = require('path'); const Repl = require('repl'); @@ -46,7 +93,7 @@ const SHORTCUTS = { run: 'r', }; -const HELP = ` +const HELP = StringPrototypeTrim(` run, restart, r Run the application or reconnect kill Kill a running application or disconnect @@ -83,88 +130,83 @@ profiles[n].save(filepath = 'node.cpuprofile') takeHeapSnapshot(filepath = 'node.heapsnapshot') Take a heap snapshot and save to disk as JSON. -`.trim(); +`); const FUNCTION_NAME_PATTERN = /^(?:function\*? )?([^(\s]+)\(/; function extractFunctionName(description) { - const fnNameMatch = description.match(FUNCTION_NAME_PATTERN); + const fnNameMatch = + RegExpPrototypeSymbolMatch(FUNCTION_NAME_PATTERN, description); return fnNameMatch ? `: ${fnNameMatch[1]}` : ''; } -const PUBLIC_BUILTINS = require('module').builtinModules; -const NATIVES = PUBLIC_BUILTINS ? internalBinding('natives') : {}; +const { + moduleIds: PUBLIC_BUILTINS, +} = internalBinding('native_module'); +const NATIVES = internalBinding('natives'); function isNativeUrl(url) { - url = url.replace(/\.js$/, ''); - if (PUBLIC_BUILTINS) { - if (url.startsWith('node:internal/') || PUBLIC_BUILTINS.includes(url)) - return true; - } + url = RegExpPrototypeSymbolReplace(/\.js$/, url, ''); - return url in NATIVES || url === 'bootstrap_node'; + return StringPrototypeStartsWith(url, 'node:internal/') || + ArrayPrototypeIncludes(PUBLIC_BUILTINS, url) || + url in NATIVES || url === 'bootstrap_node'; } function getRelativePath(filenameOrURL) { - const dir = Path.join(Path.resolve(), 'x').slice(0, -1); + const dir = StringPrototypeSlice(Path.join(Path.resolve(), 'x'), 0, -1); - const filename = filenameOrURL.startsWith('file://') ? + const filename = StringPrototypeStartsWith(filenameOrURL, 'file://') ? fileURLToPath(filenameOrURL) : filenameOrURL; // Change path to relative, if possible - if (filename.indexOf(dir) === 0) { - return filename.slice(dir.length); + if (StringPrototypeStartsWith(filename, dir)) { + return StringPrototypeSlice(filename, dir.length); } return filename; } -function toCallback(promise, callback) { - function forward(...args) { - process.nextTick(() => callback(...args)); - } - promise.then(forward.bind(null, null), forward); -} - // Adds spaces and prefix to number // maxN is a maximum number we should have space for function leftPad(n, prefix, maxN) { const s = n.toString(); - const nchars = Math.max(2, String(maxN).length) + 1; - const nspaces = nchars - s.length - 1; + const nchars = MathMax(2, String(maxN).length); + const nspaces = nchars - s.length; - return prefix + ' '.repeat(nspaces) + s; + return prefix + StringPrototypeRepeat(' ', nspaces) + s; } function markSourceColumn(sourceText, position, useColors) { if (!sourceText) return ''; - const head = sourceText.slice(0, position); - let tail = sourceText.slice(position); + const head = StringPrototypeSlice(sourceText, 0, position); + let tail = StringPrototypeSlice(sourceText, position); // Colourize char if stdout supports colours if (useColors) { - tail = tail.replace(/(.+?)([^\w]|$)/, '\u001b[32m$1\u001b[39m$2'); + tail = RegExpPrototypeSymbolReplace(/(.+?)([^\w]|$)/, tail, + '\u001b[32m$1\u001b[39m$2'); } // Return source line with coloured char at `position` - return [head, tail].join(''); + return head + tail; } function extractErrorMessage(stack) { if (!stack) return ''; - const m = stack.match(/^\w+: ([^\n]+)/); - return m ? m[1] : stack; + const m = RegExpPrototypeSymbolMatch(/^\w+: ([^\n]+)/, stack); + return m?.[1] ?? stack; } function convertResultToError(result) { const { className, description } = result; const err = new Error(extractErrorMessage(description)); err.stack = description; - Object.defineProperty(err, 'name', { value: className }); + ObjectDefineProperty(err, 'name', { value: className }); return err; } class RemoteObject { constructor(attributes) { - Object.assign(this, attributes); + ObjectAssign(this, attributes); if (this.type === 'number') { this.value = this.unserializableValue ? +this.unserializableValue : +this.value; @@ -227,18 +269,21 @@ class RemoteObject { break; } if (this.preview) { - const props = this.preview.properties - .map((prop, idx) => { + const props = ArrayPrototypeMap( + this.preview.properties, + (prop, idx) => { const value = formatProperty(prop); if (prop.name === `${idx}`) return value; return `${prop.name}: ${value}`; }); if (this.preview.overflow) { - props.push('...'); + ArrayPrototypePush(props, '...'); } - const singleLine = props.join(', '); + const singleLine = ArrayPrototypeJoin(props, ', '); const propString = - singleLine.length > 60 ? props.join(',\n ') : singleLine; + singleLine.length > 60 ? + ArrayPrototypeJoin(props, ',\n ') : + singleLine; return this.subtype === 'array' ? `[ ${propString} ]` : `{ ${propString} }`; @@ -258,34 +303,39 @@ class RemoteObject { class ScopeSnapshot { constructor(scope, properties) { - Object.assign(this, scope); - this.properties = new Map(properties.map((prop) => { + ObjectAssign(this, scope); + this.properties = new SafeMap(); + this.completionGroup = ArrayPrototypeMap(properties, (prop) => { const value = new RemoteObject(prop.value); - return [prop.name, value]; - })); - this.completionGroup = properties.map((prop) => prop.name); + this.properties.set(prop.name, value); + return prop.name; + }); } [customInspectSymbol](depth, opts) { - const type = `${this.type[0].toUpperCase()}${this.type.slice(1)}`; + const type = StringPrototypeToUpperCase(this.type[0]) + + StringPrototypeSlice(this.type, 1); const name = this.name ? `<${this.name}>` : ''; const prefix = `${type}${name} `; - return utilInspect(this.properties, opts) - .replace(/^Map /, prefix); + return RegExpPrototypeSymbolReplace(/^Map /, + utilInspect(this.properties, opts), + prefix); } } function copyOwnProperties(target, source) { - Object.getOwnPropertyNames(source).forEach((prop) => { - const descriptor = Object.getOwnPropertyDescriptor(source, prop); - Object.defineProperty(target, prop, descriptor); - }); + ArrayPrototypeForEach( + ReflectOwnKeys(source), + (prop) => { + const desc = ReflectGetOwnPropertyDescriptor(source, prop); + ObjectDefineProperty(target, prop, desc); + }); } function aliasProperties(target, mapping) { - Object.keys(mapping).forEach((key) => { - const descriptor = Object.getOwnPropertyDescriptor(target, key); - Object.defineProperty(target, mapping[key], descriptor); + ArrayPrototypeForEach(ObjectKeys(mapping), (key) => { + const desc = ReflectGetOwnPropertyDescriptor(target, key); + ObjectDefineProperty(target, mapping[key], desc); }); } @@ -344,16 +394,14 @@ function createRepl(inspector) { return !script.isNative || isCurrentScript(script); } - return Object.keys(knownScripts) - .map((scriptId) => knownScripts[scriptId]) - .filter(isVisible) - .map((script) => { + return ArrayPrototypeJoin(ArrayPrototypeMap( + ArrayPrototypeFilter(ObjectValues(knownScripts), isVisible), + (script) => { const isCurrent = isCurrentScript(script); const { isNative, url } = script; const name = `${getRelativePath(url)}${isNative ? ' ' : ''}`; return `${isCurrent ? '*' : ' '} ${script.scriptId}: ${name}`; - }) - .join('\n'); + }), '\n'); } function listScripts(displayNatives = false) { @@ -371,19 +419,19 @@ function createRepl(inspector) { static createAndRegister({ profile }) { const p = new Profile(profile); - profiles.push(p); + ArrayPrototypePush(profiles, p); return p; } [customInspectSymbol](depth, { stylize }) { const { startTime, endTime } = this.data; - const MU = String.fromChar(956); + const MU = StringFromCharCode(956); return stylize(`[Profile ${endTime - startTime}${MU}s]`, 'special'); } save(filename = 'node.cpuprofile') { const absoluteFile = Path.resolve(filename); - const json = JSON.stringify(this.data); + const json = JSONStringify(this.data); FS.writeFileSync(absoluteFile, json); print('Saved profile to ' + absoluteFile); } @@ -391,68 +439,75 @@ function createRepl(inspector) { class SourceSnippet { constructor(location, delta, scriptSource) { - Object.assign(this, location); + ObjectAssign(this, location); this.scriptSource = scriptSource; this.delta = delta; } [customInspectSymbol](depth, options) { const { scriptId, lineNumber, columnNumber, delta, scriptSource } = this; - const start = Math.max(1, lineNumber - delta + 1); + const start = MathMax(1, lineNumber - delta + 1); const end = lineNumber + delta + 1; - const lines = scriptSource.split('\n'); - return lines.slice(start - 1, end).map((lineText, offset) => { - const i = start + offset; - const isCurrent = i === (lineNumber + 1); - - const markedLine = isCurrent ? - markSourceColumn(lineText, columnNumber, options.colors) : - lineText; - - let isBreakpoint = false; - knownBreakpoints.forEach(({ location }) => { - if (!location) return; - if (scriptId === location.scriptId && + const lines = StringPrototypeSplit(scriptSource, '\n'); + return ArrayPrototypeJoin( + ArrayPrototypeMap( + ArrayPrototypeSlice(lines, start - 1, end), + (lineText, offset) => { + const i = start + offset; + const isCurrent = i === (lineNumber + 1); + + const markedLine = isCurrent ? + markSourceColumn(lineText, columnNumber, options.colors) : + lineText; + + let isBreakpoint = false; + ArrayPrototypeForEach(knownBreakpoints, ({ location }) => { + if (!location) return; + if (scriptId === location.scriptId && i === (location.lineNumber + 1)) { - isBreakpoint = true; - } - }); + isBreakpoint = true; + } + }); - let prefixChar = ' '; - if (isCurrent) { - prefixChar = '>'; - } else if (isBreakpoint) { - prefixChar = '*'; - } - return `${leftPad(i, prefixChar, end)} ${markedLine}`; - }).join('\n'); + let prefixChar = ' '; + if (isCurrent) { + prefixChar = '>'; + } else if (isBreakpoint) { + prefixChar = '*'; + } + return `${leftPad(i, prefixChar, end)} ${markedLine}`; + }), '\n'); } } - function getSourceSnippet(location, delta = 5) { + async function getSourceSnippet(location, delta = 5) { const { scriptId } = location; - return Debugger.getScriptSource({ scriptId }) - .then(({ scriptSource }) => - new SourceSnippet(location, delta, scriptSource)); + const { scriptSource } = await Debugger.getScriptSource({ scriptId }); + return new SourceSnippet(location, delta, scriptSource); } class CallFrame { constructor(callFrame) { - Object.assign(this, callFrame); + ObjectAssign(this, callFrame); } loadScopes() { - return Promise.all( - this.scopeChain - .filter((scope) => scope.type !== 'global') - .map((scope) => { + return PromiseAll( + new SafeArrayIterator(ArrayPrototypeMap( + ArrayPrototypeFilter( + this.scopeChain, + (scope) => scope.type !== 'global' + ), + async (scope) => { const { objectId } = scope.object; - return Runtime.getProperties({ + const { result } = await Runtime.getProperties({ objectId, generatePreview: true, - }).then(({ result }) => new ScopeSnapshot(scope, result)); + }); + return new ScopeSnapshot(scope, result); }) + ) ); } @@ -463,69 +518,72 @@ function createRepl(inspector) { class Backtrace extends Array { [customInspectSymbol]() { - return this.map((callFrame, idx) => { - const { - location: { scriptId, lineNumber, columnNumber }, - functionName - } = callFrame; - const name = functionName || '(anonymous)'; - - const script = knownScripts[scriptId]; - const relativeUrl = + return ArrayPrototypeJoin( + ArrayPrototypeMap(this, (callFrame, idx) => { + const { + location: { scriptId, lineNumber, columnNumber }, + functionName + } = callFrame; + const name = functionName || '(anonymous)'; + + const script = knownScripts[scriptId]; + const relativeUrl = (script && getRelativePath(script.url)) || ''; - const frameLocation = + const frameLocation = `${relativeUrl}:${lineNumber + 1}:${columnNumber}`; - return `#${idx} ${name} ${frameLocation}`; - }).join('\n'); + return `#${idx} ${name} ${frameLocation}`; + }), '\n'); } static from(callFrames) { - return super.from(Array.from(callFrames).map((callFrame) => { - if (callFrame instanceof CallFrame) { - return callFrame; - } - return new CallFrame(callFrame); - })); + return FunctionPrototypeCall( + ArrayFrom, + this, + callFrames, + (callFrame) => + (callFrame instanceof CallFrame ? + callFrame : + new CallFrame(callFrame)) + ); } } function prepareControlCode(input) { if (input === '\n') return lastCommand; // Add parentheses: exec process.title => exec("process.title"); - const match = input.match(/^\s*exec\s+([^\n]*)/); + const match = RegExpPrototypeSymbolMatch(/^\s*exec\s+([^\n]*)/, input); if (match) { - lastCommand = `exec(${JSON.stringify(match[1])})`; + lastCommand = `exec(${JSONStringify(match[1])})`; } else { lastCommand = input; } return lastCommand; } - function evalInCurrentContext(code) { + async function evalInCurrentContext(code) { // Repl asked for scope variables if (code === '.scope') { if (!selectedFrame) { - return Promise.reject(new Error('Requires execution to be paused')); + throw new Error('Requires execution to be paused'); } - return selectedFrame.loadScopes().then((scopes) => { - return scopes.map((scope) => scope.completionGroup); - }); + const scopes = await selectedFrame.loadScopes(); + return ArrayPrototypeMap(scopes, (scope) => scope.completionGroup); } if (selectedFrame) { - return Debugger.evaluateOnCallFrame({ + return PromisePrototypeThen(Debugger.evaluateOnCallFrame({ callFrameId: selectedFrame.callFrameId, expression: code, objectGroup: 'node-inspect', generatePreview: true, - }).then(RemoteObject.fromEvalResult); + }), RemoteObject.fromEvalResult); } - return Runtime.evaluate({ + return PromisePrototypeThen(Runtime.evaluate({ expression: code, objectGroup: 'node-inspect', generatePreview: true, - }).then(RemoteObject.fromEvalResult); + }), RemoteObject.fromEvalResult); } function controlEval(input, context, filename, callback) { @@ -539,11 +597,16 @@ function createRepl(inspector) { const code = prepareControlCode(input); const result = vm.runInContext(code, context, filename); - if (result && typeof result.then === 'function') { - toCallback(result, returnToCallback); - return; + const then = result?.then; + if (typeof then === 'function') { + FunctionPrototypeCall( + then, result, + (result) => returnToCallback(null, result), + returnToCallback + ); + } else { + returnToCallback(null, result); } - returnToCallback(null, result); } catch (e) { returnToCallback(e); } @@ -556,76 +619,63 @@ function createRepl(inspector) { callback(error, result); } - try { - const result = evalInCurrentContext(input); - - if (result && typeof result.then === 'function') { - toCallback(result, returnToCallback); - return; - } - returnToCallback(null, result); - } catch (e) { - returnToCallback(e); - } + PromisePrototypeThen(evalInCurrentContext(input), + (result) => returnToCallback(null, result), + returnToCallback + ); } - function formatWatchers(verbose = false) { + async function formatWatchers(verbose = false) { if (!watchedExpressions.length) { - return Promise.resolve(''); + return ''; } const inspectValue = (expr) => - evalInCurrentContext(expr) - // .then(formatValue) - .catch((error) => `<${error.message}>`); + PromisePrototypeCatch(evalInCurrentContext(expr), + (error) => `<${error.message}>`); const lastIndex = watchedExpressions.length - 1; - return Promise.all(watchedExpressions.map(inspectValue)) - .then((values) => { - const lines = watchedExpressions - .map((expr, idx) => { - const prefix = `${leftPad(idx, ' ', lastIndex)}: ${expr} =`; - const value = inspect(values[idx]); - if (value.indexOf('\n') === -1) { - return `${prefix} ${value}`; - } - return `${prefix}\n ${value.split('\n').join('\n ')}`; - }); - return lines.join('\n'); - }) - .then((valueList) => { - return verbose ? `Watchers:\n${valueList}\n` : valueList; - }); + const values = await PromiseAll(new SafeArrayIterator( + ArrayPrototypeMap(watchedExpressions, inspectValue))); + const lines = ArrayPrototypeMap(watchedExpressions, (expr, idx) => { + const prefix = `${leftPad(idx, ' ', lastIndex)}: ${expr} =`; + const value = inspect(values[idx], { colors: true }); + if (!StringPrototypeIncludes(value, '\n')) { + return `${prefix} ${value}`; + } + return `${prefix}\n ${RegExpPrototypeSymbolReplace(/\n/g, value, '\n ')}`; + }); + const valueList = ArrayPrototypeJoin(lines, '\n'); + return verbose ? `Watchers:\n${valueList}\n` : valueList; } function watchers(verbose = false) { - return formatWatchers(verbose).then(print); + return PromisePrototypeThen(formatWatchers(verbose), print); } // List source code function list(delta = 5) { - return selectedFrame.list(delta) - .then(null, (error) => { - print('You can\'t list source code right now'); - throw error; - }); + return selectedFrame.list(delta).then(null, (error) => { + print("You can't list source code right now"); + throw error; + }); } function handleBreakpointResolved({ breakpointId, location }) { const script = knownScripts[location.scriptId]; const scriptUrl = script && script.url; if (scriptUrl) { - Object.assign(location, { scriptUrl }); + ObjectAssign(location, { scriptUrl }); } - const isExisting = knownBreakpoints.some((bp) => { + const isExisting = ArrayPrototypeSome(knownBreakpoints, (bp) => { if (bp.breakpointId === breakpointId) { - Object.assign(bp, { location }); + ObjectAssign(bp, { location }); return true; } return false; }); if (!isExisting) { - knownBreakpoints.push({ breakpointId, location }); + ArrayPrototypePush(knownBreakpoints, { breakpointId, location }); } } @@ -641,9 +691,11 @@ function createRepl(inspector) { const scriptUrl = script ? script.url : location.scriptUrl; return `${getRelativePath(scriptUrl)}:${location.lineNumber + 1}`; } - const breaklist = knownBreakpoints - .map((bp, idx) => `#${idx} ${formatLocation(bp.location)}`) - .join('\n'); + const breaklist = ArrayPrototypeJoin( + ArrayPrototypeMap( + knownBreakpoints, + (bp, idx) => `#${idx} ${formatLocation(bp.location)}`), + '\n'); print(breaklist); } @@ -660,9 +712,9 @@ function createRepl(inspector) { // setBreakpoint(): set breakpoint at current location if (script === undefined) { - return Debugger - .setBreakpoint({ location: getCurrentLocation(), condition }) - .then(registerBreakpoint); + return PromisePrototypeThen( + Debugger.setBreakpoint({ location: getCurrentLocation(), condition }), + registerBreakpoint); } // setBreakpoint(line): set breakpoint in current script at specific line @@ -671,8 +723,9 @@ function createRepl(inspector) { scriptId: getCurrentLocation().scriptId, lineNumber: script - 1, }; - return Debugger.setBreakpoint({ location, condition }) - .then(registerBreakpoint); + return PromisePrototypeThen( + Debugger.setBreakpoint({ location, condition }), + registerBreakpoint); } if (typeof script !== 'string') { @@ -680,7 +733,7 @@ function createRepl(inspector) { } // setBreakpoint('fn()'): Break when a function is called - if (script.endsWith('()')) { + if (StringPrototypeEndsWith(script, '()')) { const debugExpr = `debug(${script.slice(0, -2)})`; const debugCall = selectedFrame ? Debugger.evaluateOnCallFrame({ @@ -692,7 +745,7 @@ function createRepl(inspector) { expression: debugExpr, includeCommandLineAPI: true, }); - return debugCall.then(({ result, wasThrown }) => { + return PromisePrototypeThen(debugCall, ({ result, wasThrown }) => { if (wasThrown) return convertResultToError(result); return undefined; // This breakpoint can't be removed the same way }); @@ -704,15 +757,15 @@ function createRepl(inspector) { if (knownScripts[script]) { scriptId = script; } else { - for (const id of Object.keys(knownScripts)) { + ArrayPrototypeForEach(ObjectKeys(knownScripts), (id) => { const scriptUrl = knownScripts[id].url; - if (scriptUrl && scriptUrl.indexOf(script) !== -1) { + if (scriptUrl && StringPrototypeIncludes(scriptUrl, script)) { if (scriptId !== null) { ambiguous = true; } scriptId = id; } - } + }); } if (ambiguous) { @@ -726,19 +779,25 @@ function createRepl(inspector) { if (scriptId !== null) { const location = { scriptId, lineNumber: line - 1 }; - return Debugger.setBreakpoint({ location, condition }) - .then(registerBreakpoint); + return PromisePrototypeThen( + Debugger.setBreakpoint({ location, condition }), + registerBreakpoint); } - const escapedPath = script.replace(/([/\\.?*()^${}|[\]])/g, '\\$1'); + const escapedPath = RegExpPrototypeSymbolReplace(/([/\\.?*()^${}|[\]])/g, + script, '\\$1'); const urlRegex = `^(.*[\\/\\\\])?${escapedPath}$`; - return Debugger - .setBreakpointByUrl({ urlRegex, lineNumber: line - 1, condition }) - .then((bp) => { + return PromisePrototypeThen( + Debugger.setBreakpointByUrl({ + urlRegex, + lineNumber: line - 1, + condition, + }), + (bp) => { // TODO: handle bp.locations in case the regex matches existing files if (!bp.location) { // Fake it for now. - Object.assign(bp, { + ObjectAssign(bp, { actualLocation: { scriptUrl: `.*/${script}$`, lineNumber: line - 1, @@ -750,41 +809,46 @@ function createRepl(inspector) { } function clearBreakpoint(url, line) { - const breakpoint = knownBreakpoints.find(({ location }) => { + const breakpoint = ArrayPrototypeFind(knownBreakpoints, ({ location }) => { if (!location) return false; const script = knownScripts[location.scriptId]; if (!script) return false; return ( - script.url.indexOf(url) !== -1 && (location.lineNumber + 1) === line + StringPrototypeIncludes(script.url, url) && + (location.lineNumber + 1) === line ); }); if (!breakpoint) { print(`Could not find breakpoint at ${url}:${line}`); - return Promise.resolve(); + return PromiseResolve(); } - return Debugger.removeBreakpoint({ breakpointId: breakpoint.breakpointId }) - .then(() => { - const idx = knownBreakpoints.indexOf(breakpoint); - knownBreakpoints.splice(idx, 1); + return PromisePrototypeThen( + Debugger.removeBreakpoint({ breakpointId: breakpoint.breakpointId }), + () => { + const idx = ArrayPrototypeIndexOf(knownBreakpoints, breakpoint); + ArrayPrototypeSplice(knownBreakpoints, idx, 1); }); } function restoreBreakpoints() { - const lastBreakpoints = knownBreakpoints.slice(); - knownBreakpoints.length = 0; - const newBreakpoints = lastBreakpoints - .filter(({ location }) => !!location.scriptUrl) - .map(({ location }) => - setBreakpoint(location.scriptUrl, location.lineNumber + 1)); - if (!newBreakpoints.length) return Promise.resolve(); - return Promise.all(newBreakpoints).then((results) => { - print(`${results.length} breakpoints restored.`); - }); + const lastBreakpoints = ArrayPrototypeSplice(knownBreakpoints, 0); + const newBreakpoints = ArrayPrototypeMap( + ArrayPrototypeFilter(lastBreakpoints, + ({ location }) => !!location.scriptUrl), + ({ location }) => setBreakpoint(location.scriptUrl, + location.lineNumber + 1)); + if (!newBreakpoints.length) return PromiseResolve(); + return PromisePrototypeThen( + PromiseAll(new SafeArrayIterator(newBreakpoints)), + (results) => { + print(`${results.length} breakpoints restored.`); + }); } function setPauseOnExceptions(state) { - return Debugger.setPauseOnExceptions({ state }) - .then(() => { + return PromisePrototypeThen( + Debugger.setPauseOnExceptions({ state }), + () => { pauseOnExceptionState = state; }); } @@ -810,13 +874,13 @@ function createRepl(inspector) { const header = `${breakType} in ${scriptUrl}:${lineNumber + 1}`; inspector.suspendReplWhile(() => - Promise.all([formatWatchers(true), selectedFrame.list(2)]) - .then(({ 0: watcherList, 1: context }) => { - if (watcherList) { - return `${watcherList}\n${inspect(context)}`; - } - return inspect(context); - }).then((breakContext) => { + PromisePrototypeThen( + PromiseAll(new SafeArrayIterator( + [formatWatchers(true), selectedFrame.list(2)])), + ({ 0: watcherList, 1: context }) => { + const breakContext = watcherList ? + `${watcherList}\n${inspect(context)}` : + inspect(context); print(`${header}\n${breakContext}`); })); }); @@ -839,15 +903,15 @@ function createRepl(inspector) { Profiler.on('consoleProfileFinished', ({ profile }) => { Profile.createAndRegister({ profile }); - print([ - 'Captured new CPU profile.', - `Access it with profiles[${profiles.length - 1}]`, - ].join('\n')); + print( + 'Captured new CPU profile.\n' + + `Access it with profiles[${profiles.length - 1}]` + ); }); function initializeContext(context) { - inspector.domainNames.forEach((domain) => { - Object.defineProperty(context, domain, { + ArrayPrototypeForEach(inspector.domainNames, (domain) => { + ObjectDefineProperty(context, domain, { value: inspector[domain], enumerable: true, configurable: true, @@ -913,8 +977,8 @@ function createRepl(inspector) { }, get profileEnd() { - return Profiler.stop() - .then(Profile.createAndRegister); + return PromisePrototypeThen(Profiler.stop(), + Profile.createAndRegister); }, get profiles() { @@ -963,8 +1027,9 @@ function createRepl(inspector) { HeapProfiler.on('addHeapSnapshotChunk', onChunk); print('Heap snapshot: 0/0', false); - HeapProfiler.takeHeapSnapshot({ reportProgress: true }) - .then(onResolve, onReject); + PromisePrototypeThen( + HeapProfiler.takeHeapSnapshot({ reportProgress: true }), + onResolve, onReject); }); }, @@ -973,21 +1038,22 @@ function createRepl(inspector) { }, watch(expr) { - watchedExpressions.push(expr); + ArrayPrototypePush(watchedExpressions, expr); }, unwatch(expr) { - const index = watchedExpressions.indexOf(expr); + const index = ArrayPrototypeIndexOf(watchedExpressions, expr); // Unwatch by expression // or // Unwatch by watcher number - watchedExpressions.splice(index !== -1 ? index : +expr, 1); + ArrayPrototypeSplice(watchedExpressions, + index !== -1 ? index : +expr, 1); }, get repl() { // Don't display any default messages - const listeners = repl.listeners('SIGINT').slice(0); + const listeners = ArrayPrototypeSlice(repl.listeners('SIGINT')); repl.removeAllListeners('SIGINT'); const oldContext = repl.context; @@ -995,7 +1061,7 @@ function createRepl(inspector) { exitDebugRepl = () => { // Restore all listeners process.nextTick(() => { - listeners.forEach((listener) => { + ArrayPrototypeForEach(listeners, (listener) => { repl.on('SIGINT', listener); }); }); @@ -1038,11 +1104,11 @@ function createRepl(inspector) { }, get version() { - return Runtime.evaluate({ + return PromisePrototypeThen(Runtime.evaluate({ expression: 'process.versions.v8', contextId: 1, returnByValue: true, - }).then(({ result }) => { + }), ({ result }) => { print(result.value); }); }, @@ -1067,18 +1133,17 @@ function createRepl(inspector) { aliasProperties(context, SHORTCUTS); } - function initAfterStart() { - return Runtime.enable() - .then(() => Profiler.enable()) - .then(() => Profiler.setSamplingInterval({ interval: 100 })) - .then(() => Debugger.enable()) - .then(() => Debugger.setPauseOnExceptions({ state: 'none' })) - .then(() => Debugger.setAsyncCallStackDepth({ maxDepth: 0 })) - .then(() => Debugger.setBlackboxPatterns({ patterns: [] })) - .then(() => - Debugger.setPauseOnExceptions({ state: pauseOnExceptionState })) - .then(() => restoreBreakpoints()) - .then(() => Runtime.runIfWaitingForDebugger()); + async function initAfterStart() { + await Runtime.enable(); + await Profiler.enable(); + await Profiler.setSamplingInterval({ interval: 100 }); + await Debugger.enable(); + await Debugger.setPauseOnExceptions({ state: 'none' }); + await Debugger.setAsyncCallStackDepth({ maxDepth: 0 }); + await Debugger.setBlackboxPatterns({ patterns: [] }); + await Debugger.setPauseOnExceptions({ state: pauseOnExceptionState }); + await restoreBreakpoints(); + return Runtime.runIfWaitingForDebugger(); } return function startRepl() { From 5a0b52120a6ccaf80b01f61dfb2d5b50d27c544b Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Sat, 8 May 2021 19:01:04 +0800 Subject: [PATCH 62/86] test: improve coverage of lib/_http_client.js PR-URL: https://github.com/nodejs/node/pull/38599 Refs: https://coverage.nodejs.org/coverage-f37c26b8a2e10d0a/lib/_http_client.js.html#L200 Reviewed-By: Rich Trott Reviewed-By: Antoine du Hamel Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat --- test/parallel/test-http-createConnection.js | 56 +++++++++++-------- .../test-http-insecure-parser-per-stream.js | 12 ++++ 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/test/parallel/test-http-createConnection.js b/test/parallel/test-http-createConnection.js index a65b9a158c679d..1425b964a75aa3 100644 --- a/test/parallel/test-http-createConnection.js +++ b/test/parallel/test-http-createConnection.js @@ -25,32 +25,36 @@ const http = require('http'); const net = require('net'); const assert = require('assert'); +function commonHttpGet(fn) { + if (typeof fn === 'function') { + fn = common.mustCall(fn); + } + return new Promise((resolve, reject) => { + http.get({ createConnection: fn }, (res) => { + resolve(res); + }).on('error', (err) => { + reject(err); + }); + }); +} + const server = http.createServer(common.mustCall(function(req, res) { res.end(); -}, 4)).listen(0, '127.0.0.1', function() { - let fn = common.mustCall(createConnection); - http.get({ createConnection: fn }, function(res) { - res.resume(); - fn = common.mustCall(createConnectionAsync); - http.get({ createConnection: fn }, function(res) { - res.resume(); - fn = common.mustCall(createConnectionBoth1); - http.get({ createConnection: fn }, function(res) { - res.resume(); - fn = common.mustCall(createConnectionBoth2); - http.get({ createConnection: fn }, function(res) { - res.resume(); - fn = common.mustCall(createConnectionError); - http.get({ createConnection: fn }, function(res) { - assert.fail('Unexpected response callback'); - }).on('error', common.mustCall(function(err) { - assert.strictEqual(err.message, 'Could not create socket'); - server.close(); - })); - }); - }); - }); +}, 4)).listen(0, '127.0.0.1', async () => { + await commonHttpGet(createConnection); + await commonHttpGet(createConnectionAsync); + await commonHttpGet(createConnectionBoth1); + await commonHttpGet(createConnectionBoth2); + + // Errors + await assert.rejects(() => commonHttpGet(createConnectionError), { + message: 'sync' + }); + await assert.rejects(() => commonHttpGet(createConnectionAsyncError), { + message: 'async' }); + + server.close(); }); function createConnection() { @@ -78,5 +82,9 @@ function createConnectionBoth2(options, cb) { } function createConnectionError(options, cb) { - process.nextTick(cb, new Error('Could not create socket')); + throw new Error('sync'); +} + +function createConnectionAsyncError(options, cb) { + process.nextTick(cb, new Error('async')); } diff --git a/test/parallel/test-http-insecure-parser-per-stream.js b/test/parallel/test-http-insecure-parser-per-stream.js index d2b8ffe708770c..2ba245c8f419b1 100644 --- a/test/parallel/test-http-insecure-parser-per-stream.js +++ b/test/parallel/test-http-insecure-parser-per-stream.js @@ -80,3 +80,15 @@ const MakeDuplexPair = require('../common/duplexpair'); 'Hello: foo\x08foo\r\n' + '\r\n\r\n'); } + +// Test 5: Invalid argument type +{ + assert.throws( + () => http.request({ insecureHTTPParser: 0 }, common.mustNotCall()), + common.expectsError({ + code: 'ERR_INVALID_ARG_TYPE', + message: 'The "options.insecureHTTPParser" property must be of' + + ' type boolean. Received type number (0)' + }) + ); +} From 6620a3182e1dd6f0c0dd6361ce0d37f42f65a4fc Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Wed, 12 May 2021 12:13:16 +0200 Subject: [PATCH 63/86] doc: add ESM code examples in url.md PR-URL: https://github.com/nodejs/node/pull/38651 Reviewed-By: James M Snell Reviewed-By: Masashi Hirano --- doc/api/url.md | 79 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 13 deletions(-) diff --git a/doc/api/url.md b/doc/api/url.md index ce528f5f6c8007..b64bbc405f455e 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -9,7 +9,11 @@ The `url` module provides utilities for URL resolution and parsing. It can be accessed using: -```js +```mjs +import url from 'url'; +``` + +```cjs const url = require('url'); ``` @@ -61,7 +65,13 @@ const myURL = Parsing the URL string using the Legacy API: -```js +```mjs +import url from 'url'; +const myURL = + url.parse('https://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash'); +``` + +```cjs const url = require('url'); const myURL = url.parse('https://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash'); @@ -135,7 +145,12 @@ const myURL = new URL('/foo', 'https://example.org/'); The URL constructor is accessible as a property on the global object. It can also be imported from the built-in url module: -```js +```mjs +import { URL } from 'url'; +console.log(URL === globalThis.URL); // Prints 'true'. +``` + +```cjs console.log(URL === require('url').URL); // Prints 'true'. ``` @@ -573,10 +588,6 @@ and [`url.format()`][] methods would produce. The `toString()` method on the `URL` object returns the serialized URL. The value returned is equivalent to that of [`url.href`][] and [`url.toJSON()`][]. -Because of the need for standard compliance, this method does not allow users -to customize the serialization process of the URL. For more flexibility, -[`require('url').format()`][] method might be of interest. - #### `url.toJSON()` * Returns: {string} @@ -931,8 +942,20 @@ invalid domain, the empty string is returned. It performs the inverse operation to [`url.domainToUnicode()`][]. -```js +```mjs +import url from 'url'; + +console.log(url.domainToASCII('español.com')); +// Prints xn--espaol-zwa.com +console.log(url.domainToASCII('中文.com')); +// Prints xn--fiq228c.com +console.log(url.domainToASCII('xn--iñvalid.com')); +// Prints an empty string +``` + +```cjs const url = require('url'); + console.log(url.domainToASCII('español.com')); // Prints xn--espaol-zwa.com console.log(url.domainToASCII('中文.com')); @@ -956,8 +979,20 @@ domain, the empty string is returned. It performs the inverse operation to [`url.domainToASCII()`][]. -```js +```mjs +import url from 'url'; + +console.log(url.domainToUnicode('xn--espaol-zwa.com')); +// Prints español.com +console.log(url.domainToUnicode('xn--fiq228c.com')); +// Prints 中文.com +console.log(url.domainToUnicode('xn--iñvalid.com')); +// Prints an empty string +``` + +```cjs const url = require('url'); + console.log(url.domainToUnicode('xn--espaol-zwa.com')); // Prints español.com console.log(url.domainToUnicode('xn--fiq228c.com')); @@ -1079,7 +1114,26 @@ added: v15.7.0 This utility function converts a URL object into an ordinary options object as expected by the [`http.request()`][] and [`https.request()`][] APIs. -```js +```mjs +import { urlToHttpOptions } from 'url'; +const myURL = new URL('https://a:b@測試?abc#foo'); + +console.log(urlToHttpOptions(myUrl)); +/** +{ + protocol: 'https:', + hostname: 'xn--g6w251d', + hash: '#foo', + search: '?abc', + pathname: '/', + path: '/?abc', + href: 'https://a:b@xn--g6w251d/?abc#foo', + auth: 'a:b' +} +*/ +``` + +```cjs const { urlToHttpOptions } = require('url'); const myURL = new URL('https://a:b@測試?abc#foo'); @@ -1124,8 +1178,8 @@ changes: > Stability: 3 - Legacy: Use the WHATWG URL API instead. -The legacy `urlObject` (`require('url').Url`) is created and returned by the -`url.parse()` function. +The legacy `urlObject` (`require('url').Url` or `import { Url } from 'url'`) is +created and returned by the `url.parse()` function. #### `urlObject.auth` @@ -1499,7 +1553,6 @@ console.log(myURL.origin); [`https.request()`]: https.md#https_https_request_options_callback [`new URL()`]: #url_new_url_input_base [`querystring`]: querystring.md -[`require('url').format()`]: #url_url_format_url_options [`url.domainToASCII()`]: #url_url_domaintoascii_domain [`url.domainToUnicode()`]: #url_url_domaintounicode_domain [`url.format()`]: #url_url_format_urlobject From c4b161cb8952b4da0e6f5528fa59bf93d62d76c0 Mon Sep 17 00:00:00 2001 From: Qingyu Deng Date: Wed, 12 May 2021 19:58:49 +0800 Subject: [PATCH 64/86] doc: change color of doctag on night mode Fixes: https://github.com/nodejs/node/issues/38641 PR-URL: https://github.com/nodejs/node/pull/38652 Reviewed-By: Antoine du Hamel Reviewed-By: Derek Lewis Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott Reviewed-By: Zijian Liu Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- doc/api_assets/hljs.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/api_assets/hljs.css b/doc/api_assets/hljs.css index dc5f1d41a65945..bbf076987530d6 100644 --- a/doc/api_assets/hljs.css +++ b/doc/api_assets/hljs.css @@ -36,7 +36,8 @@ } .dark-mode .hljs-keyword, -.dark-mode .hljs-attribute { +.dark-mode .hljs-attribute, +.dark-mode .hljs-doctag { color: #66d9ef; } From 1765e32c45a3904cc250bc1bdb2333afb970b5e8 Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Fri, 14 May 2021 08:41:24 -0700 Subject: [PATCH 65/86] doc: update contact info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gabriel Schulhof PR-URL: https://github.com/nodejs/node/pull/38689 Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Richard Lau Reviewed-By: Michael Dawson Reviewed-By: Juan José Arboleda --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cb52be2efb7436..7dd77cb0cedf55 100644 --- a/README.md +++ b/README.md @@ -176,7 +176,7 @@ For information about the governance of the Node.js project, see * [fhinkel](https://github.com/fhinkel) - **Franziska Hinkelmann** <franziska.hinkelmann@gmail.com> (she/her) * [gabrielschulhof](https://github.com/gabrielschulhof) - -**Gabriel Schulhof** <gabriel.schulhof@intel.com> +**Gabriel Schulhof** <gabrielschulhof@gmail.com> * [gireeshpunathil](https://github.com/gireeshpunathil) - **Gireesh Punathil** <gpunathi@in.ibm.com> (he/him) * [jasnell](https://github.com/jasnell) - @@ -314,7 +314,7 @@ For information about the governance of the Node.js project, see * [Flarna](https://github.com/Flarna) - **Gerhard Stöbich** <deb2001-github@yahoo.de> (he/they) * [gabrielschulhof](https://github.com/gabrielschulhof) - -**Gabriel Schulhof** <gabriel.schulhof@intel.com> +**Gabriel Schulhof** <gabrielschulhof@gmail.com> * [gdams](https://github.com/gdams) - **George Adams** <george.adams@uk.ibm.com> (he/him) * [geek](https://github.com/geek) - From 608d0e11f3007648276520e81d6d9672a434f10b Mon Sep 17 00:00:00 2001 From: Ruy Adorno Date: Thu, 13 May 2021 16:18:53 -0400 Subject: [PATCH 66/86] deps: upgrade npm to 7.13.0 PR-URL: https://github.com/nodejs/node/pull/38682 Reviewed-By: Rich Trott Reviewed-By: Danielle Adams Reviewed-By: Trivikram Kamat Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig --- deps/npm/CHANGELOG.md | 18 +++ deps/npm/docs/content/commands/npm-fund.md | 56 ++++++++ deps/npm/docs/content/commands/npm-publish.md | 7 + deps/npm/docs/output/commands/npm-fund.html | 45 ++++++ deps/npm/docs/output/commands/npm-ls.html | 2 +- .../npm/docs/output/commands/npm-publish.html | 9 ++ deps/npm/docs/output/commands/npm.html | 2 +- deps/npm/lib/fund.js | 16 ++- deps/npm/lib/publish.js | 76 ++++++---- deps/npm/lib/workspaces/arborist-cmd.js | 24 ++++ deps/npm/man/man1/npm-fund.1 | 67 +++++++++ deps/npm/man/man1/npm-ls.1 | 2 +- deps/npm/man/man1/npm-publish.1 | 7 + deps/npm/man/man1/npm.1 | 2 +- .../@npmcli/arborist/lib/arborist/index.js | 23 +++ .../arborist/lib/get-workspace-nodes.js | 33 +++++ .../@npmcli/arborist/package.json | 2 +- deps/npm/node_modules/libnpmfund/CHANGELOG.md | 6 - deps/npm/node_modules/libnpmfund/README.md | 5 +- deps/npm/node_modules/libnpmfund/index.js | 63 +++++---- deps/npm/node_modules/libnpmfund/package.json | 19 ++- deps/npm/package.json | 8 +- .../tap-snapshots/test/lib/fund.js.test.cjs | 20 +++ .../test/lib/publish.js.test.cjs | 103 ++++++++++++++ .../test/lib/utils/npm-usage.js.test.cjs | 3 + deps/npm/test/lib/fund.js | 86 ++++++++++++ deps/npm/test/lib/publish.js | 132 +++++++++++++++--- deps/npm/test/lib/workspaces/arborist-cmd.js | 109 +++++++++++++++ 28 files changed, 846 insertions(+), 99 deletions(-) create mode 100644 deps/npm/lib/workspaces/arborist-cmd.js create mode 100644 deps/npm/node_modules/@npmcli/arborist/lib/get-workspace-nodes.js delete mode 100644 deps/npm/node_modules/libnpmfund/CHANGELOG.md create mode 100644 deps/npm/test/lib/workspaces/arborist-cmd.js diff --git a/deps/npm/CHANGELOG.md b/deps/npm/CHANGELOG.md index bed0f87c2b80c9..1c36c70875f722 100644 --- a/deps/npm/CHANGELOG.md +++ b/deps/npm/CHANGELOG.md @@ -1,3 +1,21 @@ +## v7.13.0 (2021-05-13) + +* [`076420c14`](https://github.com/npm/cli/commit/076420c149d097056f687e44e21744b743b86e4e) + [#3231](https://github.com/npm/cli/issues/3231) + feat(publish): add workspace support + ([@wraithgar](https://github.com/wraithgar)) +* [`370b36a36`](https://github.com/npm/cli/commit/370b36a36ca226840761e4214cbccaf2a1a90e3c) + [#3241](https://github.com/npm/cli/issues/3241) + feat(fund): add workspaces support + ([@ruyadorno](https://github.com/ruyadorno)) + +### DEPENDENCIES + +* [`0c18e4f77`](https://github.com/npm/cli/commit/0c18e4f774562fa054fedf323bea25805ebf39b3) + `@npmcli/arborist@2.5.0` +* [`b551c6811`](https://github.com/npm/cli/commit/b551c6811251dbc901f47fea3c137f93e205a9e4) + `libnpmfund@1.1.0` + ## v7.12.1 (2021-05-10) ### BUG FIXES diff --git a/deps/npm/docs/content/commands/npm-fund.md b/deps/npm/docs/content/commands/npm-fund.md index aa1b26b9a8971b..45c5dfaac2afc2 100644 --- a/deps/npm/docs/content/commands/npm-fund.md +++ b/deps/npm/docs/content/commands/npm-fund.md @@ -8,6 +8,7 @@ description: Retrieve funding information ```bash npm fund [] +npm fund [-w ] ``` ### Description @@ -24,6 +25,43 @@ The list will avoid duplicated entries and will stack all packages that share the same url as a single entry. Thus, the list does not have the same shape of the output from `npm ls`. +#### Example + +### Workspaces support + +It's possible to filter the results to only include a single workspace and its +dependencies using the `workspace` config option. + +#### Example: + +Here's an example running `npm fund` in a project with a configured +workspace `a`: + +```bash +$ npm fund +test-workspaces-fund@1.0.0 ++-- https://example.com/a +| | `-- a@1.0.0 +| `-- https://example.com/maintainer +| `-- foo@1.0.0 ++-- https://example.com/npmcli-funding +| `-- @npmcli/test-funding +`-- https://example.com/org + `-- bar@2.0.0 +``` + +And here is an example of the expected result when filtering only by +a specific workspace `a` in the same project: + +```bash +$ npm fund -w a +test-workspaces-fund@1.0.0 +`-- https://example.com/a + | `-- a@1.0.0 + `-- https://example.com/maintainer + `-- foo@2.0.0 +``` + ### Configuration #### browser @@ -48,6 +86,23 @@ Show information in JSON format. Whether to represent the tree structure using unicode characters. Set it to `false` in order to use all-ansi output. +#### `workspace` + +* Default: +* Type: String (can be set multiple times) + +Enable running a command in the context of the configured workspaces of the +current project while filtering by running only the workspaces defined by +this configuration option. + +Valid values for the `workspace` config are either: +* Workspace names +* Path to a workspace directory +* Path to a parent workspace directory (will result to selecting all of the +nested workspaces) + +This value is not exported to the environment for child processes. + #### which * Type: Number @@ -61,3 +116,4 @@ If there are multiple funding sources, which 1-indexed source URL to open. * [npm docs](/commands/npm-docs) * [npm ls](/commands/npm-ls) * [npm config](/commands/npm-config) +* [npm workspaces](/using-npm/workspaces) diff --git a/deps/npm/docs/content/commands/npm-publish.md b/deps/npm/docs/content/commands/npm-publish.md index fc13e672223589..10e65f895ec5bc 100644 --- a/deps/npm/docs/content/commands/npm-publish.md +++ b/deps/npm/docs/content/commands/npm-publish.md @@ -47,6 +47,13 @@ by specifying a different default registry or using a actually publishing to the registry. Reports the details of what would have been published. +* `[--workspaces]`: Enables workspace context while publishing. All + workspace packages will be published. + +* `[--workspace]`: Enables workspaces context and limits results to only + those specified by this config item. Only the packages in the + workspaces given will be published. + The publish will fail if the package name and version combination already exists in the specified registry. diff --git a/deps/npm/docs/output/commands/npm-fund.html b/deps/npm/docs/output/commands/npm-fund.html index bd9118fe326559..16539cfd998685 100644 --- a/deps/npm/docs/output/commands/npm-fund.html +++ b/deps/npm/docs/output/commands/npm-fund.html @@ -146,6 +146,7 @@

        Table of contents

        Synopsis

        npm fund [<pkg>]
        +npm fund [-w <workspace-name>]
         

        Description

        This command retrieves information on how to fund the dependencies of a @@ -158,6 +159,33 @@

        Description

        The list will avoid duplicated entries and will stack all packages that share the same url as a single entry. Thus, the list does not have the same shape of the output from npm ls.

        +

        Example

        +

        Workspaces support

        +

        It’s possible to filter the results to only include a single workspace and its +dependencies using the workspace config option.

        +

        Example:

        +

        Here’s an example running npm fund in a project with a configured +workspace a:

        +
        $ npm fund
        +test-workspaces-fund@1.0.0
        ++-- https://example.com/a
        +| | `-- a@1.0.0
        +| `-- https://example.com/maintainer
        +|     `-- foo@1.0.0
        ++-- https://example.com/npmcli-funding
        +|   `-- @npmcli/test-funding
        +`-- https://example.com/org
        +    `-- bar@2.0.0
        +
        +

        And here is an example of the expected result when filtering only by +a specific workspace a in the same project:

        +
        $ npm fund -w a
        +test-workspaces-fund@1.0.0
        +`-- https://example.com/a
        +  | `-- a@1.0.0
        +  `-- https://example.com/maintainer
        +      `-- foo@2.0.0
        +

        Configuration

        browser

          @@ -178,6 +206,22 @@

          unicode

        Whether to represent the tree structure using unicode characters. Set it to false in order to use all-ansi output.

        +

        workspace

        +
          +
        • Default:
        • +
        • Type: String (can be set multiple times)
        • +
        +

        Enable running a command in the context of the configured workspaces of the +current project while filtering by running only the workspaces defined by +this configuration option.

        +

        Valid values for the workspace config are either:

        +
          +
        • Workspace names
        • +
        • Path to a workspace directory
        • +
        • Path to a parent workspace directory (will result to selecting all of the +nested workspaces)
        • +
        +

        This value is not exported to the environment for child processes.

        which

        diff --git a/deps/npm/docs/output/commands/npm-ls.html b/deps/npm/docs/output/commands/npm-ls.html index 3d60f2baecd2b2..be1f7cd94a62a4 100644 --- a/deps/npm/docs/output/commands/npm-ls.html +++ b/deps/npm/docs/output/commands/npm-ls.html @@ -159,7 +159,7 @@

        Description

        the results to only the paths to the packages named. Note that nested packages will also show the paths to the specified packages. For example, running npm ls promzard in npm’s source tree will show:

        -
        npm@7.12.1 /path/to/npm
        +
        npm@7.13.0 /path/to/npm
         └─┬ init-package-json@0.0.4
           └── promzard@0.1.5
         
        diff --git a/deps/npm/docs/output/commands/npm-publish.html b/deps/npm/docs/output/commands/npm-publish.html index fc9136d356b481..159566e09a0706 100644 --- a/deps/npm/docs/output/commands/npm-publish.html +++ b/deps/npm/docs/output/commands/npm-publish.html @@ -188,6 +188,15 @@

        Description

        actually publishing to the registry. Reports the details of what would have been published.

        +
      • +

        [--workspaces]: Enables workspace context while publishing. All +workspace packages will be published.

        +
      • +
      • +

        [--workspace]: Enables workspaces context and limits results to only +those specified by this config item. Only the packages in the +workspaces given will be published.

        +

      The publish will fail if the package name and version combination already exists in the specified registry.

      diff --git a/deps/npm/docs/output/commands/npm.html b/deps/npm/docs/output/commands/npm.html index 445abd0d5ce3e0..1adcb07e046c33 100644 --- a/deps/npm/docs/output/commands/npm.html +++ b/deps/npm/docs/output/commands/npm.html @@ -148,7 +148,7 @@

      Table of contents

      npm <command> [args]
       

      Version

      -

      7.12.1

      +

      7.13.0

      Description

      npm is the package manager for the Node JavaScript platform. It puts modules in place so that node can find them, and manages dependency diff --git a/deps/npm/lib/fund.js b/deps/npm/lib/fund.js index 25d3462f638693..55d2f65dc4b55c 100644 --- a/deps/npm/lib/fund.js +++ b/deps/npm/lib/fund.js @@ -13,15 +13,14 @@ const { const completion = require('./utils/completion/installed-deep.js') const openUrl = require('./utils/open-url.js') +const ArboristWorkspaceCmd = require('./workspaces/arborist-cmd.js') const getPrintableName = ({ name, version }) => { const printableVersion = version ? `@${version}` : '' return `${name}${printableVersion}` } -const BaseCommand = require('./base-command.js') - -class Fund extends BaseCommand { +class Fund extends ArboristWorkspaceCmd { /* istanbul ignore next - see test/lib/load-all-commands.js */ static get description () { return 'Retrieve funding information' @@ -38,6 +37,7 @@ class Fund extends BaseCommand { 'json', 'browser', 'unicode', + 'workspace', 'which', ] } @@ -92,10 +92,16 @@ class Fund extends BaseCommand { return } + const fundingInfo = getFundingInfo(tree, { + ...this.flatOptions, + log: this.npm.log, + workspaces: this.workspaces, + }) + if (this.npm.config.get('json')) - this.npm.output(this.printJSON(getFundingInfo(tree))) + this.npm.output(this.printJSON(fundingInfo)) else - this.npm.output(this.printHuman(getFundingInfo(tree))) + this.npm.output(this.printHuman(fundingInfo)) } printJSON (fundingInfo) { diff --git a/deps/npm/lib/publish.js b/deps/npm/lib/publish.js index b121cb3d36773a..b33839903a266d 100644 --- a/deps/npm/lib/publish.js +++ b/deps/npm/lib/publish.js @@ -8,13 +8,19 @@ const pacote = require('pacote') const npa = require('npm-package-arg') const npmFetch = require('npm-registry-fetch') -const flatten = require('./utils/config/flatten.js') const otplease = require('./utils/otplease.js') const { getContents, logTar } = require('./utils/tar.js') +const getWorkspaces = require('./workspaces/get-workspaces.js') + +// for historical reasons, publishConfig in package.json can contain ANY config +// keys that npm supports in .npmrc files and elsewhere. We *may* want to +// revisit this at some point, and have a minimal set that's a SemVer-major +// change that ought to get a RFC written on it. +const flatten = require('./utils/config/flatten.js') -// this is the only case in the CLI where we use the old full slow -// 'read-package-json' module, because we want to pull in all the -// defaults and metadata, like git sha's and default scripts and all that. +// this is the only case in the CLI where we want to use the old full slow +// 'read-package-json' module, because we want to pull in all the defaults and +// metadata, like git sha's and default scripts and all that. const readJson = util.promisify(require('read-package-json')) const BaseCommand = require('./base-command.js') @@ -30,7 +36,7 @@ class Publish extends BaseCommand { /* istanbul ignore next - see test/lib/load-all-commands.js */ static get params () { - return ['tag', 'access', 'dry-run'] + return ['tag', 'access', 'dry-run', 'workspace', 'workspaces'] } /* istanbul ignore next - see test/lib/load-all-commands.js */ @@ -44,6 +50,10 @@ class Publish extends BaseCommand { this.publish(args).then(() => cb()).catch(cb) } + execWorkspaces (args, filters, cb) { + this.publishWorkspaces(args, filters).then(() => cb()).catch(cb) + } + async publish (args) { if (args.length === 0) args = ['.'] @@ -56,6 +66,7 @@ class Publish extends BaseCommand { const dryRun = this.npm.config.get('dry-run') const json = this.npm.config.get('json') const defaultTag = this.npm.config.get('tag') + const silent = log.level === 'silent' if (semver.validRange(defaultTag)) throw new Error('Tag name must not be a valid SemVer range: ' + defaultTag.trim()) @@ -68,7 +79,7 @@ class Publish extends BaseCommand { let manifest = await this.getManifest(spec, opts) if (manifest.publishConfig) - Object.assign(opts, this.publishConfigToOpts(manifest.publishConfig)) + flatten(manifest.publishConfig, opts) // only run scripts for directory type publishes if (spec.type === 'directory') { @@ -77,7 +88,7 @@ class Publish extends BaseCommand { path: spec.fetchSpec, stdio: 'inherit', pkg: manifest, - banner: log.level !== 'silent', + banner: !silent, }) } @@ -89,7 +100,7 @@ class Publish extends BaseCommand { // note that publishConfig might have changed as well! manifest = await this.getManifest(spec, opts) if (manifest.publishConfig) - Object.assign(opts, this.publishConfigToOpts(manifest.publishConfig)) + flatten(manifest.publishConfig, opts) // note that logTar calls npmlog.notice(), so if we ARE in silent mode, // this will do nothing, but we still want it in the debuglog if it fails. @@ -114,7 +125,7 @@ class Publish extends BaseCommand { path: spec.fetchSpec, stdio: 'inherit', pkg: manifest, - banner: log.level !== 'silent', + banner: !silent, }) await runScript({ @@ -122,19 +133,43 @@ class Publish extends BaseCommand { path: spec.fetchSpec, stdio: 'inherit', pkg: manifest, - banner: log.level !== 'silent', + banner: !silent, }) } - const silent = log.level === 'silent' - if (!silent && json) - this.npm.output(JSON.stringify(pkgContents, null, 2)) - else if (!silent) - this.npm.output(`+ ${pkgContents.id}`) + if (!this.workspaces) { + if (!silent && json) + this.npm.output(JSON.stringify(pkgContents, null, 2)) + else if (!silent) + this.npm.output(`+ ${pkgContents.id}`) + } return pkgContents } + async publishWorkspaces (args, filters) { + // Suppresses JSON output in publish() so we can handle it here + this.workspaces = true + + const results = {} + const json = this.npm.config.get('json') + const silent = log.level === 'silent' + const workspaces = + await getWorkspaces(filters, { path: this.npm.localPrefix }) + for (const [name, workspace] of workspaces.entries()) { + const pkgContents = await this.publish([workspace]) + // This needs to be in-line w/ the rest of the output that non-JSON + // publish generates + if (!silent && !json) + this.npm.output(`+ ${pkgContents.id}`) + else + results[name] = pkgContents + } + + if (!silent && json) + this.npm.output(JSON.stringify(results, null, 2)) + } + // if it's a directory, read it from the file system // otherwise, get the full metadata from whatever it is getManifest (spec, opts) { @@ -142,16 +177,5 @@ class Publish extends BaseCommand { return readJson(`${spec.fetchSpec}/package.json`) return pacote.manifest(spec, { ...opts, fullMetadata: true }) } - - // for historical reasons, publishConfig in package.json can contain - // ANY config keys that npm supports in .npmrc files and elsewhere. - // We *may* want to revisit this at some point, and have a minimal set - // that's a SemVer-major change that ought to get a RFC written on it. - publishConfigToOpts (publishConfig) { - // create a new object that inherits from the config stack - // then squash the css-case into camelCase opts, like we do - // this is Object.assign()'ed onto the base npm.flatOptions - return flatten(publishConfig, {}) - } } module.exports = Publish diff --git a/deps/npm/lib/workspaces/arborist-cmd.js b/deps/npm/lib/workspaces/arborist-cmd.js new file mode 100644 index 00000000000000..f08843bd9ea5a8 --- /dev/null +++ b/deps/npm/lib/workspaces/arborist-cmd.js @@ -0,0 +1,24 @@ +// This is the base for all commands whose execWorkspaces just gets +// a list of workspace names and passes it on to new Arborist() to +// be able to run a filtered Arborist.reify() at some point. + +const BaseCommand = require('../base-command.js') +const getWorkspaces = require('../workspaces/get-workspaces.js') +class ArboristCmd extends BaseCommand { + /* istanbul ignore next - see test/lib/load-all-commands.js */ + static get params () { + return [ + 'workspace', + ] + } + + execWorkspaces (args, filters, cb) { + getWorkspaces(filters, { path: this.npm.localPrefix }) + .then(workspaces => { + this.workspaces = [...workspaces.keys()] + this.exec(args, cb) + }) + } +} + +module.exports = ArboristCmd diff --git a/deps/npm/man/man1/npm-fund.1 b/deps/npm/man/man1/npm-fund.1 index 81a277bb0087c2..aa21dad231882a 100644 --- a/deps/npm/man/man1/npm-fund.1 +++ b/deps/npm/man/man1/npm-fund.1 @@ -6,6 +6,7 @@ .RS 2 .nf npm fund [] +npm fund [\-w ] .fi .RE .SS Description @@ -21,6 +22,44 @@ to pass the \fB\-\-which\fP option to disambiguate\. The list will avoid duplicated entries and will stack all packages that share the same url as a single entry\. Thus, the list does not have the same shape of the output from \fBnpm ls\fP\|\. +.SS Example +.SS Workspaces support +.P +It's possible to filter the results to only include a single workspace and its +dependencies using the \fBworkspace\fP config option\. +.SS Example: +.P +Here's an example running \fBnpm fund\fP in a project with a configured +workspace \fBa\fP: +.P +.RS 2 +.nf +$ npm fund +test\-workspaces\-fund@1\.0\.0 ++\-\- https://example\.com/a +| | `\-\- a@1\.0\.0 +| `\-\- https://example\.com/maintainer +| `\-\- foo@1\.0\.0 ++\-\- https://example\.com/npmcli\-funding +| `\-\- @npmcli/test\-funding +`\-\- https://example\.com/org + `\-\- bar@2\.0\.0 +.fi +.RE +.P +And here is an example of the expected result when filtering only by +a specific workspace \fBa\fP in the same project: +.P +.RS 2 +.nf +$ npm fund \-w a +test\-workspaces\-fund@1\.0\.0 +`\-\- https://example\.com/a + | `\-\- a@1\.0\.0 + `\-\- https://example\.com/maintainer + `\-\- foo@2\.0\.0 +.fi +.RE .SS Configuration .SS browser .RS 0 @@ -53,6 +92,32 @@ Default: true .P Whether to represent the tree structure using unicode characters\. Set it to \fBfalse\fP in order to use all\-ansi output\. +.SS \fBworkspace\fP +.RS 0 +.IP \(bu 2 +Default: +.IP \(bu 2 +Type: String (can be set multiple times) + +.RE +.P +Enable running a command in the context of the configured workspaces of the +current project while filtering by running only the workspaces defined by +this configuration option\. +.P +Valid values for the \fBworkspace\fP config are either: +.RS 0 +.IP \(bu 2 +Workspace names +.IP \(bu 2 +Path to a workspace directory +.IP \(bu 2 +Path to a parent workspace directory (will result to selecting all of the +nested workspaces) + +.RE +.P +This value is not exported to the environment for child processes\. .SS which .RS 0 .IP \(bu 2 @@ -73,5 +138,7 @@ npm help docs npm help ls .IP \(bu 2 npm help config +.IP \(bu 2 +npm help workspaces .RE diff --git a/deps/npm/man/man1/npm-ls.1 b/deps/npm/man/man1/npm-ls.1 index c47da91875482f..d7013b296440c0 100644 --- a/deps/npm/man/man1/npm-ls.1 +++ b/deps/npm/man/man1/npm-ls.1 @@ -26,7 +26,7 @@ example, running \fBnpm ls promzard\fP in npm's source tree will show: .P .RS 2 .nf -npm@7\.12\.1 /path/to/npm +npm@7\.13\.0 /path/to/npm └─┬ init\-package\-json@0\.0\.4 └── promzard@0\.1\.5 .fi diff --git a/deps/npm/man/man1/npm-publish.1 b/deps/npm/man/man1/npm-publish.1 index c405f64f27e361..906c5a36e194fe 100644 --- a/deps/npm/man/man1/npm-publish.1 +++ b/deps/npm/man/man1/npm-publish.1 @@ -45,6 +45,13 @@ from a TTY then you'll be prompted\. \fB[\-\-dry\-run]\fP: As of \fBnpm@6\fP, does everything publish would do except actually publishing to the registry\. Reports the details of what would have been published\. +.IP \(bu 2 +\fB[\-\-workspaces]\fP: Enables workspace context while publishing\. All +workspace packages will be published\. +.IP \(bu 2 +\fB[\-\-workspace]\fP: Enables workspaces context and limits results to only +those specified by this config item\. Only the packages in the +workspaces given will be published\. .RE .P diff --git a/deps/npm/man/man1/npm.1 b/deps/npm/man/man1/npm.1 index 4562527e1b5ade..4921bcc656a555 100644 --- a/deps/npm/man/man1/npm.1 +++ b/deps/npm/man/man1/npm.1 @@ -10,7 +10,7 @@ npm [args] .RE .SS Version .P -7\.12\.1 +7\.13\.0 .SS Description .P npm is the package manager for the Node JavaScript platform\. It puts diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/index.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/index.js index 3578d50389ea64..cd39df01af6c6f 100644 --- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/index.js +++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/index.js @@ -45,6 +45,7 @@ const mixins = [ ] const Base = mixins.reduce((a, b) => b(a), require('events')) +const getWorkspaceNodes = require('../get-workspace-nodes.js') class Arborist extends Base { constructor (options = {}) { @@ -64,6 +65,28 @@ class Arborist extends Base { this.path = resolve(this.options.path) process.emit('timeEnd', 'arborist:ctor') } + + // returns an array of the actual nodes for all the workspaces + workspaceNodes (tree, workspaces) { + return getWorkspaceNodes(tree, workspaces, this.log) + } + + // returns a set of workspace nodes and all their deps + workspaceDependencySet (tree, workspaces) { + const wsNodes = this.workspaceNodes(tree, workspaces) + const set = new Set(wsNodes) + for (const node of set) { + for (const edge of node.edgesOut.values()) { + const dep = edge.to + if (dep) { + set.add(dep) + if (dep.target) + set.add(dep.target) + } + } + } + return set + } } module.exports = Arborist diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/get-workspace-nodes.js b/deps/npm/node_modules/@npmcli/arborist/lib/get-workspace-nodes.js new file mode 100644 index 00000000000000..6db489f69c5185 --- /dev/null +++ b/deps/npm/node_modules/@npmcli/arborist/lib/get-workspace-nodes.js @@ -0,0 +1,33 @@ +// Get the actual nodes corresponding to a root node's child workspaces, +// given a list of workspace names. +const relpath = require('./relpath.js') +const getWorkspaceNodes = (tree, workspaces, log) => { + const wsMap = tree.workspaces + if (!wsMap) { + log.warn('workspaces', 'filter set, but no workspaces present') + return [] + } + + const nodes = [] + for (const name of workspaces) { + const path = wsMap.get(name) + if (!path) { + log.warn('workspaces', `${name} in filter set, but not in workspaces`) + continue + } + + const loc = relpath(tree.realpath, path) + const node = tree.inventory.get(loc) + + if (!node) { + log.warn('workspaces', `${name} in filter set, but no workspace folder present`) + continue + } + + nodes.push(node) + } + + return nodes +} + +module.exports = getWorkspaceNodes diff --git a/deps/npm/node_modules/@npmcli/arborist/package.json b/deps/npm/node_modules/@npmcli/arborist/package.json index bbe87d8bf97ad2..fd579cbf27fdc8 100644 --- a/deps/npm/node_modules/@npmcli/arborist/package.json +++ b/deps/npm/node_modules/@npmcli/arborist/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/arborist", - "version": "2.4.4", + "version": "2.5.0", "description": "Manage node_modules trees", "dependencies": { "@npmcli/installed-package-contents": "^1.0.7", diff --git a/deps/npm/node_modules/libnpmfund/CHANGELOG.md b/deps/npm/node_modules/libnpmfund/CHANGELOG.md deleted file mode 100644 index b890b58e1405ae..00000000000000 --- a/deps/npm/node_modules/libnpmfund/CHANGELOG.md +++ /dev/null @@ -1,6 +0,0 @@ -# Changelog - -## 0.0.0-pre.0 - -- Initial pre-release. - diff --git a/deps/npm/node_modules/libnpmfund/README.md b/deps/npm/node_modules/libnpmfund/README.md index c373a9ceb7dd57..8ab663f634d6fb 100644 --- a/deps/npm/node_modules/libnpmfund/README.md +++ b/deps/npm/node_modules/libnpmfund/README.md @@ -73,7 +73,10 @@ Options: - `countOnly`: Uses the tree-traversal logic from **npm fund** but skips over any obj definition and just returns an obj containing `{ length }` - useful for things such as printing a `6 packages are looking for funding` msg. -- `path`: Location to current working directory +- `workspaces`: `Array` List of workspaces names to filter for, +the result will only include a subset of the resulting tree that includes +only the nodes that are children of the listed workspaces names. +- `path`, `registry` and more [Arborist](https://github.com/npm/arborist/) options. ##### `> fund.readTree(tree, [opts]) -> Promise` diff --git a/deps/npm/node_modules/libnpmfund/index.js b/deps/npm/node_modules/libnpmfund/index.js index 58aba028e36221..37bc1dd0b79165 100644 --- a/deps/npm/node_modules/libnpmfund/index.js +++ b/deps/npm/node_modules/libnpmfund/index.js @@ -15,11 +15,11 @@ function normalizeFunding (funding) { // Is the value of a `funding` property of a `package.json` // a valid type+url for `npm fund` to display? function isValidFunding (funding) { - if (!funding) return false + if (!funding) + return false - if (Array.isArray(funding)) { + if (Array.isArray(funding)) return funding.every(f => !Array.isArray(f) && isValidFunding(f)) - } try { var parsed = new URL(funding.url || funding) @@ -30,7 +30,8 @@ function isValidFunding (funding) { if ( parsed.protocol !== 'https:' && parsed.protocol !== 'http:' - ) return false + ) + return false return Boolean(parsed.host) } @@ -43,11 +44,18 @@ function readTree (tree, opts) { const { countOnly } = opts || {} const _trailingDependencies = Symbol('trailingDependencies') + let filterSet + + if (opts && opts.workspaces && opts.workspaces.length) { + const arb = new Arborist(opts) + filterSet = arb.workspaceDependencySet(tree, opts.workspaces) + } + function tracked (name, version) { const key = String(name) + String(version) - if (seen.has(key)) { + if (seen.has(key)) return true - } + seen.add(key) } @@ -81,30 +89,36 @@ function readTree (tree, opts) { function getFundingDependencies (tree) { const edges = tree && tree.edgesOut && tree.edgesOut.values() - if (!edges) return empty() + if (!edges) + return empty() const directDepsWithFunding = Array.from(edges).map(edge => { - if (!edge || !edge.to) return empty() + if (!edge || !edge.to) + return empty() const node = edge.to.target || edge.to - if (!node.package) return empty() + if (!node.package) + return empty() + + if (filterSet && filterSet.size > 0 && !filterSet.has(node)) + return empty() const { name, funding, version } = node.package // avoids duplicated items within the funding tree - if (tracked(name, version)) return empty() + if (tracked(name, version)) + return empty() const fundingItem = {} - if (version) { + if (version) fundingItem.version = version - } attachFundingInfo(fundingItem, funding) return { node, - fundingItem + fundingItem, } }) @@ -112,7 +126,8 @@ function readTree (tree, opts) { (res, { node, fundingItem }, i) => { if (!fundingItem || fundingItem.length === 0 || - !node) return res + !node) + return res // recurse const transitiveDependencies = node.edgesOut && @@ -121,16 +136,17 @@ function readTree (tree, opts) { // if we're only counting items there's no need // to add all the data to the resulting object - if (countOnly) return null + if (countOnly) + return null if (hasDependencies(transitiveDependencies)) { fundingItem.dependencies = retrieveDependencies(transitiveDependencies) } - if (isValidFunding(fundingItem.funding)) { + if (isValidFunding(fundingItem.funding)) res[node.package.name] = fundingItem - } else if (hasDependencies(fundingItem.dependencies)) { + else if (hasDependencies(fundingItem.dependencies)) { res[_trailingDependencies] = Object.assign( empty(), @@ -145,7 +161,7 @@ function readTree (tree, opts) { const treeDependencies = getFundingDependencies(tree) const result = { - length: packageWithFundingCount + length: packageWithFundingCount, } if (!countOnly) { @@ -154,13 +170,11 @@ function readTree (tree, opts) { (tree && tree.name) result.name = name || (tree && tree.path) - if (tree && tree.package && tree.package.version) { + if (tree && tree.package && tree.package.version) result.version = tree.package.version - } - if (tree && tree.package && tree.package.funding) { + if (tree && tree.package && tree.package.funding) result.funding = normalizeFunding(tree.package.funding) - } result.dependencies = retrieveDependencies(treeDependencies) } @@ -170,8 +184,7 @@ function readTree (tree, opts) { async function read (opts) { const arb = new Arborist(opts) - const tree = await arb.loadActual() - + const tree = await arb.loadActual(opts) return readTree(tree, opts) } @@ -179,5 +192,5 @@ module.exports = { read, readTree, normalizeFunding, - isValidFunding + isValidFunding, } diff --git a/deps/npm/node_modules/libnpmfund/package.json b/deps/npm/node_modules/libnpmfund/package.json index b25d3aa6b520eb..7f4acad383bb80 100644 --- a/deps/npm/node_modules/libnpmfund/package.json +++ b/deps/npm/node_modules/libnpmfund/package.json @@ -1,6 +1,6 @@ { "name": "libnpmfund", - "version": "1.0.2", + "version": "1.1.0", "files": [ "index.js" ], @@ -25,8 +25,10 @@ ], "license": "ISC", "scripts": { - "lint": "standard", - "pretest": "npm run lint", + "eslint": "eslint", + "lint": "npm run eslint -- index.js test.js", + "lintfix": "npm run lint -- --fix", + "posttest": "npm run lint", "test": "tap", "snap": "tap", "preversion": "npm test", @@ -42,11 +44,14 @@ ] }, "devDependencies": { - "require-inject": "^1.4.4", - "standard": "^14.3.4", - "tap": "^14.10.7" + "eslint": "^7.26.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^5.1.0", + "eslint-plugin-standard": "^5.0.0", + "tap": "^15.0.9" }, "dependencies": { - "@npmcli/arborist": "^2.0.0" + "@npmcli/arborist": "^2.5.0" } } diff --git a/deps/npm/package.json b/deps/npm/package.json index 70f94838882b74..f939dacadf23f9 100644 --- a/deps/npm/package.json +++ b/deps/npm/package.json @@ -1,5 +1,5 @@ { - "version": "7.12.1", + "version": "7.13.0", "name": "npm", "description": "a package manager for JavaScript", "keywords": [ @@ -42,7 +42,7 @@ "./package.json": "./package.json" }, "dependencies": { - "@npmcli/arborist": "^2.4.4", + "@npmcli/arborist": "^2.5.0", "@npmcli/ci-detect": "^1.2.0", "@npmcli/config": "^2.2.0", "@npmcli/run-script": "^1.8.5", @@ -68,7 +68,7 @@ "libnpmaccess": "^4.0.2", "libnpmdiff": "^2.0.4", "libnpmexec": "^1.1.1", - "libnpmfund": "^1.0.2", + "libnpmfund": "^1.1.0", "libnpmhook": "^6.0.2", "libnpmorg": "^2.0.2", "libnpmpack": "^2.0.1", @@ -205,7 +205,7 @@ "sudotest:nocleanup": "sudo NO_TEST_CLEANUP=1 npm run test --", "posttest": "npm run lint", "eslint": "eslint", - "lint": "npm run eslint -- test/lib test/bin \"lib/**/*.js\"", + "lint": "npm run eslint -- test/lib test/bin lib", "lintfix": "npm run lint -- --fix", "prelint": "rimraf test/npm_cache*", "resetdeps": "bash scripts/resetdeps.sh", diff --git a/deps/npm/tap-snapshots/test/lib/fund.js.test.cjs b/deps/npm/tap-snapshots/test/lib/fund.js.test.cjs index 7ad86ebeea7e93..c078beb7d98665 100644 --- a/deps/npm/tap-snapshots/test/lib/fund.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/fund.js.test.cjs @@ -92,3 +92,23 @@ test-multiple-funding-sources@1.0.0 ` + +exports[`test/lib/fund.js TAP workspaces filter funding info by a specific workspace > should display only filtered workspace name and its deps 1`] = ` +workspaces-support@1.0.0 +\`-- https://example.com/a + | \`-- a@1.0.0 + \`-- http://example.com/c + \`-- c@1.0.0 + + +` + +exports[`test/lib/fund.js TAP workspaces filter funding info by a specific workspace > should display only filtered workspace path and its deps 1`] = ` +workspaces-support@1.0.0 +\`-- https://example.com/a + | \`-- a@1.0.0 + \`-- http://example.com/c + \`-- c@1.0.0 + + +` diff --git a/deps/npm/tap-snapshots/test/lib/publish.js.test.cjs b/deps/npm/tap-snapshots/test/lib/publish.js.test.cjs index 172ed5b29f478e..0d652e289a822d 100644 --- a/deps/npm/tap-snapshots/test/lib/publish.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/publish.js.test.cjs @@ -15,6 +15,109 @@ npm publish [] Options: [--tag ] [--access ] [--dry-run] +[-w|--workspace [-w|--workspace ...]] +[-ws|--workspaces] Run "npm help publish" for more info ` + +exports[`test/lib/publish.js TAP workspaces all workspaces > should output all publishes 1`] = ` +Array [ + "+ workspace-a@1.2.3-a", + "+ workspace-b@1.2.3-n", +] +` + +exports[`test/lib/publish.js TAP workspaces all workspaces > should publish all workspaces 1`] = ` +Array [ + Object { + "_id": "workspace-a@1.2.3-a", + "name": "workspace-a", + "readme": "ERROR: No README data found!", + "repository": Object { + "type": "git", + "url": "http://repo.workspace-a/", + }, + "version": "1.2.3-a", + }, + Object { + "_id": "workspace-b@1.2.3-n", + "bugs": Object { + "url": "https://github.com/npm/workspace-b/issues", + }, + "homepage": "https://github.com/npm/workspace-b#readme", + "name": "workspace-b", + "readme": "ERROR: No README data found!", + "repository": Object { + "type": "git", + "url": "git+https://github.com/npm/workspace-b.git", + }, + "version": "1.2.3-n", + }, +] +` + +exports[`test/lib/publish.js TAP workspaces json > should output all publishes as json 1`] = ` +Array [ + String( + { + "workspace-a": { + "id": "workspace-a@1.2.3-a" + }, + "workspace-b": { + "id": "workspace-b@1.2.3-n" + } + } + ), +] +` + +exports[`test/lib/publish.js TAP workspaces json > should publish all workspaces 1`] = ` +Array [ + Object { + "_id": "workspace-a@1.2.3-a", + "name": "workspace-a", + "readme": "ERROR: No README data found!", + "repository": Object { + "type": "git", + "url": "http://repo.workspace-a/", + }, + "version": "1.2.3-a", + }, + Object { + "_id": "workspace-b@1.2.3-n", + "bugs": Object { + "url": "https://github.com/npm/workspace-b/issues", + }, + "homepage": "https://github.com/npm/workspace-b#readme", + "name": "workspace-b", + "readme": "ERROR: No README data found!", + "repository": Object { + "type": "git", + "url": "git+https://github.com/npm/workspace-b.git", + }, + "version": "1.2.3-n", + }, +] +` + +exports[`test/lib/publish.js TAP workspaces one workspace > should output one publish 1`] = ` +Array [ + "+ workspace-a@1.2.3-a", +] +` + +exports[`test/lib/publish.js TAP workspaces one workspace > should publish given workspace 1`] = ` +Array [ + Object { + "_id": "workspace-a@1.2.3-a", + "name": "workspace-a", + "readme": "ERROR: No README data found!", + "repository": Object { + "type": "git", + "url": "http://repo.workspace-a/", + }, + "version": "1.2.3-a", + }, +] +` diff --git a/deps/npm/tap-snapshots/test/lib/utils/npm-usage.js.test.cjs b/deps/npm/tap-snapshots/test/lib/utils/npm-usage.js.test.cjs index c0cb3241d93c68..3b007a83c95d0d 100644 --- a/deps/npm/tap-snapshots/test/lib/utils/npm-usage.js.test.cjs +++ b/deps/npm/tap-snapshots/test/lib/utils/npm-usage.js.test.cjs @@ -422,6 +422,7 @@ All commands: Options: [--json] [--browser|--browser ] [--unicode] + [-w|--workspace [-w|--workspace ...]] [--which ] Run "npm help fund" for more info @@ -697,6 +698,8 @@ All commands: Options: [--tag ] [--access ] [--dry-run] + [-w|--workspace [-w|--workspace ...]] + [-ws|--workspaces] Run "npm help publish" for more info diff --git a/deps/npm/test/lib/fund.js b/deps/npm/test/lib/fund.js index 41754d51f35894..65778fca50bd71 100644 --- a/deps/npm/test/lib/fund.js +++ b/deps/npm/test/lib/fund.js @@ -839,3 +839,89 @@ t.test('sub dep with fund info and a parent with no funding info', t => { t.end() }) }) + +t.test('workspaces', t => { + t.test('filter funding info by a specific workspace', async t => { + npm.localPrefix = npm.prefix = t.testdir({ + 'package.json': JSON.stringify({ + name: 'workspaces-support', + version: '1.0.0', + workspaces: ['packages/*'], + dependencies: { + d: '^1.0.0', + }, + }), + node_modules: { + a: t.fixture('symlink', '../packages/a'), + b: t.fixture('symlink', '../packages/b'), + c: { + 'package.json': JSON.stringify({ + name: 'c', + version: '1.0.0', + funding: [ + 'http://example.com/c', + 'http://example.com/c-other', + ], + }), + }, + d: { + 'package.json': JSON.stringify({ + name: 'd', + version: '1.0.0', + funding: 'http://example.com/d', + }), + }, + }, + packages: { + a: { + 'package.json': JSON.stringify({ + name: 'a', + version: '1.0.0', + funding: 'https://example.com/a', + dependencies: { + c: '^1.0.0', + }, + }), + }, + b: { + 'package.json': JSON.stringify({ + name: 'b', + version: '1.0.0', + funding: 'http://example.com/b', + dependencies: { + d: '^1.0.0', + }, + }), + }, + }, + }) + + await new Promise((res, rej) => { + fund.execWorkspaces([], ['a'], (err) => { + if (err) + rej(err) + + t.matchSnapshot(result, + 'should display only filtered workspace name and its deps') + + result = '' + res() + }) + }) + + await new Promise((res, rej) => { + fund.execWorkspaces([], ['./packages/a'], (err) => { + if (err) + rej(err) + + t.matchSnapshot(result, + 'should display only filtered workspace path and its deps') + + result = '' + res() + }) + }) + }) + + t.end() +}) diff --git a/deps/npm/test/lib/publish.js b/deps/npm/test/lib/publish.js index 57574b22a56eaf..7aff7b08c1971c 100644 --- a/deps/npm/test/lib/publish.js +++ b/deps/npm/test/lib/publish.js @@ -9,15 +9,12 @@ const fs = require('fs') const log = require('npmlog') log.level = 'silent' -// mock config const {definitions} = require('../../lib/utils/config') const defaults = Object.entries(definitions).reduce((defaults, [key, def]) => { defaults[key] = def.default return defaults }, {}) -const config = defaults - t.afterEach(() => log.level = 'silent') t.test('should publish with libnpmpublish, passing through flatOptions and respecting publishConfig.registry', (t) => { @@ -54,7 +51,6 @@ t.test('should publish with libnpmpublish, passing through flatOptions and respe }, }) const npm = mockNpm({ - config, flatOptions: { customValue: true, }, @@ -102,7 +98,7 @@ t.test('re-loads publishConfig.registry if added during script process', (t) => }, }, }) - const npm = mockNpm({ config }) + const npm = mockNpm() npm.config.getCredentialsByURI = (uri) => { t.same(uri, registry, 'gets credentials for expected registry') return { token: 'some.registry.token' } @@ -144,13 +140,13 @@ t.test('if loglevel=info and json, should not output package contents', (t) => { }, }) const npm = mockNpm({ - config: { ...config, json: true }, + config: { json: true }, output: () => { t.pass('output is called') }, }) npm.config.getCredentialsByURI = (uri) => { - t.same(uri, defaults.registry, 'gets credentials for expected registry') + t.same(uri, npm.config.get('registry'), 'gets credentials for expected registry') return { token: 'some.registry.token' } } const publish = new Publish(npm) @@ -190,7 +186,7 @@ t.test('if loglevel=silent and dry-run, should not output package contents or pu }, }) const npm = mockNpm({ - config: { ...config, 'dry-run': true }, + config: { 'dry-run': true }, output: () => { throw new Error('should not output in dry run mode') }, @@ -236,7 +232,7 @@ t.test('if loglevel=info and dry-run, should not publish, should log package con }, }) const npm = mockNpm({ - config: { ...config, 'dry-run': true }, + config: { 'dry-run': true }, output: () => { t.pass('output fn is called') }, @@ -270,7 +266,7 @@ t.test('throws when invalid tag', (t) => { const Publish = t.mock('../../lib/publish.js') const npm = mockNpm({ - config: { ...config, tag: '0.0.13' }, + config: { tag: '0.0.13' }, }) const publish = new Publish(npm) @@ -313,9 +309,9 @@ t.test('can publish a tarball', t => { }, }, }) - const npm = mockNpm({ config }) + const npm = mockNpm() npm.config.getCredentialsByURI = (uri) => { - t.same(uri, defaults.registry, 'gets credentials for expected registry') + t.same(uri, npm.config.get('registry'), 'gets credentials for expected registry') return { token: 'some.registry.token' } } const publish = new Publish(npm) @@ -331,9 +327,9 @@ t.test('can publish a tarball', t => { t.test('should check auth for default registry', t => { t.plan(2) const Publish = t.mock('../../lib/publish.js') - const npm = mockNpm({ config }) + const npm = mockNpm() npm.config.getCredentialsByURI = (uri) => { - t.same(uri, defaults.registry, 'gets credentials for expected registry') + t.same(uri, npm.config.get('registry'), 'gets credentials for expected registry') return {} } const publish = new Publish(npm) @@ -352,7 +348,6 @@ t.test('should check auth for configured registry', t => { const registry = 'https://some.registry' const Publish = t.mock('../../lib/publish.js') const npm = mockNpm({ - config, flatOptions: { registry }, }) npm.config.getCredentialsByURI = (uri) => { @@ -382,7 +377,6 @@ t.test('should check auth for scope specific registry', t => { const Publish = t.mock('../../lib/publish.js') const npm = mockNpm({ - config, flatOptions: { '@npm:registry': registry }, }) npm.config.getCredentialsByURI = (uri) => { @@ -419,7 +413,6 @@ t.test('should use auth for scope specific registry', t => { }, }) const npm = mockNpm({ - config, flatOptions: { '@npm:registry': registry }, }) npm.config.getCredentialsByURI = (uri) => { @@ -457,9 +450,7 @@ t.test('read registry only from publishConfig', t => { }, }, }) - const npm = mockNpm({ - config, - }) + const npm = mockNpm() npm.config.getCredentialsByURI = (uri) => { t.same(uri, registry, 'gets credentials for expected registry') return { token: 'some.registry.token' } @@ -525,3 +516,104 @@ t.test('able to publish after if encountered multiple configs', t => { t.end() }) }) + +t.test('workspaces', (t) => { + const testDir = t.testdir({ + 'package.json': JSON.stringify({ + name: 'my-cool-pkg', + version: '1.0.0', + workspaces: ['workspace-a', 'workspace-b', 'workspace-c'], + }, null, 2), + 'workspace-a': { + 'package.json': JSON.stringify({ + name: 'workspace-a', + version: '1.2.3-a', + repository: 'http://repo.workspace-a/', + }), + }, + 'workspace-b': { + 'package.json': JSON.stringify({ + name: 'workspace-b', + version: '1.2.3-n', + repository: 'https://github.com/npm/workspace-b', + }), + }, + 'workspace-c': JSON.stringify({ + 'package.json': { + name: 'workspace-n', + version: '1.2.3-n', + }, + }), + }) + + const publishes = [] + const outputs = [] + t.beforeEach(() => { + npm.config.set('json', false) + outputs.length = 0 + publishes.length = 0 + }) + const Publish = t.mock('../../lib/publish.js', { + '../../lib/utils/tar.js': { + getContents: (manifest) => ({ + id: manifest._id, + }), + logTar: () => {}, + }, + libnpmpublish: { + publish: (manifest, tarballData, opts) => { + publishes.push(manifest) + }, + }, + }) + const npm = mockNpm({ + output: (o) => { + outputs.push(o) + }, + }) + npm.localPrefix = testDir + npm.config.getCredentialsByURI = (uri) => { + return { token: 'some.registry.token' } + } + const publish = new Publish(npm) + + t.test('all workspaces', (t) => { + log.level = 'info' + publish.execWorkspaces([], [], (err) => { + t.notOk(err) + t.matchSnapshot(publishes, 'should publish all workspaces') + t.matchSnapshot(outputs, 'should output all publishes') + t.end() + }) + }) + + t.test('one workspace', t => { + log.level = 'info' + publish.execWorkspaces([], ['workspace-a'], (err) => { + t.notOk(err) + t.matchSnapshot(publishes, 'should publish given workspace') + t.matchSnapshot(outputs, 'should output one publish') + t.end() + }) + }) + + t.test('invalid workspace', t => { + publish.execWorkspaces([], ['workspace-x'], (err) => { + t.match(err, /No workspaces found/) + t.match(err, /workspace-x/) + t.end() + }) + }) + + t.test('json', t => { + log.level = 'info' + npm.config.set('json', true) + publish.execWorkspaces([], [], (err) => { + t.notOk(err) + t.matchSnapshot(publishes, 'should publish all workspaces') + t.matchSnapshot(outputs, 'should output all publishes as json') + t.end() + }) + }) + t.end() +}) diff --git a/deps/npm/test/lib/workspaces/arborist-cmd.js b/deps/npm/test/lib/workspaces/arborist-cmd.js new file mode 100644 index 00000000000000..cceeb68dbd42ae --- /dev/null +++ b/deps/npm/test/lib/workspaces/arborist-cmd.js @@ -0,0 +1,109 @@ +const { resolve } = require('path') +const t = require('tap') +const ArboristCmd = require('../../../lib/workspaces/arborist-cmd.js') + +t.test('arborist-cmd', async t => { + const path = t.testdir({ + 'package.json': JSON.stringify({ + name: 'simple-workspaces-list', + version: '1.1.1', + workspaces: [ + 'a', + 'b', + 'group/*', + ], + }), + node_modules: { + abbrev: { + 'package.json': JSON.stringify({ name: 'abbrev', version: '1.1.1' }), + }, + a: t.fixture('symlink', '../a'), + b: t.fixture('symlink', '../b'), + }, + a: { + 'package.json': JSON.stringify({ name: 'a', version: '1.0.0' }), + }, + b: { + 'package.json': JSON.stringify({ name: 'b', version: '1.0.0' }), + }, + group: { + c: { + 'package.json': JSON.stringify({ + name: 'c', + version: '1.0.0', + dependencies: { + abbrev: '^1.1.1', + }, + }), + }, + d: { + 'package.json': JSON.stringify({ name: 'd', version: '1.0.0' }), + }, + }, + }) + + class TestCmd extends ArboristCmd {} + + const cmd = new TestCmd() + cmd.npm = { localPrefix: path } + + // check filtering for a single workspace name + cmd.exec = function (args, cb) { + t.same(this.workspaces, ['a'], 'should set array with single ws name') + t.same(args, ['foo'], 'should get received args') + cb() + } + await new Promise(res => { + cmd.execWorkspaces(['foo'], ['a'], res) + }) + + // check filtering single workspace by path + cmd.exec = function (args, cb) { + t.same(this.workspaces, ['a'], + 'should set array with single ws name from path') + cb() + } + await new Promise(res => { + cmd.execWorkspaces([], ['./a'], res) + }) + + // check filtering single workspace by full path + cmd.exec = function (args, cb) { + t.same(this.workspaces, ['a'], + 'should set array with single ws name from full path') + cb() + } + await new Promise(res => { + cmd.execWorkspaces([], [resolve(path, './a')], res) + }) + + // filtering multiple workspaces by name + cmd.exec = function (args, cb) { + t.same(this.workspaces, ['a', 'c'], + 'should set array with multiple listed ws names') + cb() + } + await new Promise(res => { + cmd.execWorkspaces([], ['a', 'c'], res) + }) + + // filtering multiple workspaces by path names + cmd.exec = function (args, cb) { + t.same(this.workspaces, ['a', 'c'], + 'should set array with multiple ws names from paths') + cb() + } + await new Promise(res => { + cmd.execWorkspaces([], ['./a', 'group/c'], res) + }) + + // filtering multiple workspaces by parent path name + cmd.exec = function (args, cb) { + t.same(this.workspaces, ['c', 'd'], + 'should set array with multiple ws names from a parent folder name') + cb() + } + await new Promise(res => { + cmd.execWorkspaces([], ['./group'], res) + }) +}) From e2b8454582ff3051e2333102640c8d97f6007faf Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Wed, 12 May 2021 19:17:43 +0200 Subject: [PATCH 67/86] repl: fix Ctrl+C on top level await PR-URL: https://github.com/nodejs/node/pull/38656 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen --- lib/repl.js | 37 ++++++++++++---------- test/parallel/test-repl-top-level-await.js | 12 ++----- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/lib/repl.js b/lib/repl.js index cf544fb224a446..2e80d652669ec5 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -74,8 +74,6 @@ const { ObjectKeys, ObjectSetPrototypeOf, Promise, - PromisePrototypeFinally, - PromisePrototypeThen, PromiseRace, ReflectApply, RegExp, @@ -566,21 +564,24 @@ function REPLServer(prompt, promise = PromiseRace([promise, interrupt]); } - PromisePrototypeFinally(PromisePrototypeThen(promise, (result) => { - finishExecution(null, result); - }, (err) => { - if (err && process.domain) { - debug('not recoverable, send to domain'); - process.domain.emit('error', err); - process.domain.exit(); - return; + (async () => { + try { + const result = await promise; + finishExecution(null, result); + } catch (err) { + if (err && process.domain) { + debug('not recoverable, send to domain'); + process.domain.emit('error', err); + process.domain.exit(); + return; + } + finishExecution(err); + } finally { + // Remove prioritized SIGINT listener if it was not called. + prioritizedSigintQueue.delete(sigintListener); + unpause(); } - finishExecution(err); - }), () => { - // Remove prioritized SIGINT listener if it was not called. - prioritizedSigintQueue.delete(sigintListener); - unpause(); - }); + })(); } } @@ -768,7 +769,9 @@ function REPLServer(prompt, const prioritizedSigintQueue = new SafeSet(); self.on('SIGINT', function onSigInt() { if (prioritizedSigintQueue.size > 0) { - ArrayPrototypeForEach(prioritizedSigintQueue, (task) => task()); + for (const task of prioritizedSigintQueue) { + task(); + } return; } diff --git a/test/parallel/test-repl-top-level-await.js b/test/parallel/test-repl-top-level-await.js index 464aae9b076d4b..39227d4f8bad29 100644 --- a/test/parallel/test-repl-top-level-await.js +++ b/test/parallel/test-repl-top-level-await.js @@ -164,18 +164,12 @@ async function ordinaryTests() { } async function ctrlCTest() { - putIn.run([ - `const timeout = (msecs) => new Promise((resolve) => { - setTimeout(resolve, msecs).unref(); - });`, - ]); - console.log('Testing Ctrl+C'); assert.deepStrictEqual(await runAndWait([ - 'await timeout(100000)', + 'await new Promise(() => {})', { ctrl: true, name: 'c' }, ]), [ - 'await timeout(100000)\r', + 'await new Promise(() => {})\r', 'Uncaught:', '[Error [ERR_SCRIPT_EXECUTION_INTERRUPTED]: ' + 'Script execution was interrupted by `SIGINT`] {', @@ -190,4 +184,4 @@ async function main() { await ctrlCTest(); } -main(); +main().then(common.mustCall()); From 6b409cf664e2a95b706ec0ce35b5519b9bed29b2 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Fri, 14 May 2021 13:54:45 +0200 Subject: [PATCH 68/86] src: remove extra semi after member fn MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/38686 Reviewed-By: Colin Ihrig Reviewed-By: Richard Lau Reviewed-By: Darshan Sen Reviewed-By: James M Snell Reviewed-By: Juan José Arboleda Reviewed-By: Rich Trott --- src/cares_wrap.h | 4 ++-- src/timer_wrap.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cares_wrap.h b/src/cares_wrap.h index bceafcb8b7f46b..20d350a76321e8 100644 --- a/src/cares_wrap.h +++ b/src/cares_wrap.h @@ -141,8 +141,8 @@ struct NodeAresTask final : public MemoryRetainer { uv_poll_t poll_watcher; inline void MemoryInfo(MemoryTracker* trakcer) const override; - SET_MEMORY_INFO_NAME(NodeAresTask); - SET_SELF_SIZE(NodeAresTask); + SET_MEMORY_INFO_NAME(NodeAresTask) + SET_SELF_SIZE(NodeAresTask) struct Hash { inline size_t operator()(NodeAresTask* a) const { diff --git a/src/timer_wrap.h b/src/timer_wrap.h index b2c20bf24d8746..dbc23b442bea39 100644 --- a/src/timer_wrap.h +++ b/src/timer_wrap.h @@ -32,7 +32,7 @@ class TimerWrap final : public MemoryRetainer { void Ref(); void Unref(); - SET_NO_MEMORY_INFO(); + SET_NO_MEMORY_INFO() SET_MEMORY_INFO_NAME(TimerWrap) SET_SELF_SIZE(TimerWrap) From a028805f1bba6f8e7776d398f65b10307bc89f6c Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sat, 8 May 2021 15:35:55 -0400 Subject: [PATCH 69/86] tools: update ESLint to 7.26.0 Update ESLint to 7.26.0 PR-URL: https://github.com/nodejs/node/pull/38605 Reviewed-By: Rich Trott Reviewed-By: Yongsheng Zhang Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell --- .../node_modules/remark-parse/index.js | 21 +- .../remark-parse/lib/block-elements.js | 70 ++ .../remark-parse/lib/block-elements.json | 68 -- .../node_modules/remark-parse/lib/decode.js | 64 +- .../node_modules/remark-parse/lib/defaults.js | 6 +- .../remark-parse/lib/locate/break.js | 12 +- .../remark-parse/lib/locate/code-inline.js | 6 +- .../remark-parse/lib/locate/delete.js | 6 +- .../remark-parse/lib/locate/emphasis.js | 14 +- .../remark-parse/lib/locate/escape.js | 6 +- .../remark-parse/lib/locate/link.js | 16 +- .../remark-parse/lib/locate/strong.js | 14 +- .../remark-parse/lib/locate/tag.js | 6 +- .../remark-parse/lib/locate/url.js | 22 +- .../node_modules/remark-parse/lib/parse.js | 57 +- .../node_modules/remark-parse/lib/parser.js | 163 ++- .../remark-parse/lib/set-options.js | 43 +- .../remark-parse/lib/tokenize/auto-link.js | 166 ++- .../remark-parse/lib/tokenize/blockquote.js | 145 ++- .../remark-parse/lib/tokenize/break.js | 40 +- .../remark-parse/lib/tokenize/code-fenced.js | 291 +++--- .../lib/tokenize/code-indented.js | 108 +- .../remark-parse/lib/tokenize/code-inline.js | 147 ++- .../remark-parse/lib/tokenize/definition.js | 313 +++--- .../remark-parse/lib/tokenize/delete.js | 64 +- .../remark-parse/lib/tokenize/emphasis.js | 97 +- .../remark-parse/lib/tokenize/escape.js | 34 +- .../lib/tokenize/footnote-definition.js | 213 ++-- .../remark-parse/lib/tokenize/heading-atx.js | 164 ++- .../lib/tokenize/heading-setext.js | 121 ++- .../remark-parse/lib/tokenize/html-block.js | 131 +-- .../remark-parse/lib/tokenize/html-inline.js | 61 +- .../remark-parse/lib/tokenize/link.js | 467 +++++---- .../remark-parse/lib/tokenize/list.js | 555 +++++----- .../remark-parse/lib/tokenize/newline.js | 51 +- .../remark-parse/lib/tokenize/paragraph.js | 131 ++- .../remark-parse/lib/tokenize/reference.js | 281 ++--- .../remark-parse/lib/tokenize/strong.js | 85 +- .../remark-parse/lib/tokenize/table.js | 306 +++--- .../remark-parse/lib/tokenize/text.js | 65 +- .../lib/tokenize/thematic-break.js | 80 +- .../remark-parse/lib/tokenize/url.js | 171 ++-- .../remark-parse/lib/tokenizer.js | 371 ++++--- .../node_modules/remark-parse/lib/unescape.js | 41 +- .../remark-parse/lib/util/get-indentation.js | 39 +- .../remark-parse/lib/util/html.js | 53 +- .../remark-parse/lib/util/interrupt.js | 52 +- .../util/is-markdown-whitespace-character.js | 27 + .../remark-parse/lib/util/normalize.js | 12 +- .../lib/util/remove-indentation.js | 73 +- .../node_modules/remark-parse/package.json | 30 +- .../node_modules/remark-parse/readme.md | 488 +++++---- .../eslint-plugin-markdown/package.json | 4 +- tools/node_modules/eslint/README.md | 2 +- .../eslint/lib/cli-engine/cli-engine.js | 9 +- .../eslint/lib/init/config-file.js | 1 + .../eslint/lib/init/config-initializer.js | 15 +- .../node_modules/eslint/lib/init/npm-utils.js | 1 + tools/node_modules/eslint/lib/rules/radix.js | 22 +- .../lib/rules/require-atomic-updates.js | 43 +- .../lib/identifier.js | 17 +- .../helper-validator-identifier/package.json | 8 +- .../scripts/generate-identifier-regex.js | 4 +- .../@babel/highlight/package.json | 4 +- .../@eslint/eslintrc/lib/index.js | 2 +- .../eslintrc/lib/shared/config-validator.js | 2 + .../@eslint/eslintrc/package.json | 11 +- .../eslint-visitor-keys/README.md | 2 +- .../eslint-visitor-keys/lib/visitor-keys.json | 5 + .../eslint-visitor-keys/package.json | 2 +- .../eslint/node_modules/glob/README.md | 2 +- .../eslint/node_modules/glob/common.js | 10 +- .../eslint/node_modules/glob/glob.js | 2 - .../eslint/node_modules/glob/package.json | 11 +- .../eslint/node_modules/glob/sync.js | 2 - .../node_modules/lodash.flatten/LICENSE | 47 - .../node_modules/lodash.flatten/README.md | 18 - .../node_modules/lodash.flatten/index.js | 349 ------- .../node_modules/lodash.flatten/package.json | 17 - .../eslint/node_modules/table/README.md | 841 ++++++++------- .../node_modules/table/dist/alignString.js | 34 +- .../node_modules/table/dist/alignTableData.js | 21 +- .../table/dist/calculateCellHeight.js | 17 +- ...llWidthIndex.js => calculateCellWidths.js} | 12 +- .../table/dist/calculateColumnWidths.js | 16 + .../dist/calculateMaximumColumnWidthIndex.js | 24 - .../table/dist/calculateRowHeightIndex.js | 21 - .../table/dist/calculateRowHeights.js | 18 + .../node_modules/table/dist/createStream.js | 59 +- .../node_modules/table/dist/drawBorder.js | 74 +- .../node_modules/table/dist/drawContent.js | 26 + .../node_modules/table/dist/drawHeader.js | 29 + .../table/dist/drawHorizontalContent.js | 18 - .../eslint/node_modules/table/dist/drawRow.js | 28 +- .../node_modules/table/dist/drawTable.js | 62 +- .../table/dist/generated/validators.js | 956 ++++++++++++------ .../table/dist/getBorderCharacters.js | 8 +- .../eslint/node_modules/table/dist/index.js | 16 +- .../table/dist/makeStreamConfig.js | 40 +- .../{makeConfig.js => makeTableConfig.js} | 50 +- .../table/dist/mapDataUsingRowHeightIndex.js | 26 - .../table/dist/mapDataUsingRowHeights.js | 44 + .../node_modules/table/dist/padTableData.js | 14 +- .../table/dist/stringifyTableData.js | 9 +- .../eslint/node_modules/table/dist/table.js | 47 +- .../table/dist/truncateTableData.js | 16 +- .../eslint/node_modules/table/dist/utils.js | 93 ++ .../node_modules/table/dist/validateConfig.js | 4 +- .../table/dist/validateTableData.js | 7 +- .../node_modules/table/dist/wrapCell.js | 33 +- .../node_modules/table/dist/wrapString.js | 4 +- .../node_modules/table/dist/wrapWord.js | 4 +- .../table/node_modules/ajv/README.md | 18 + .../table/node_modules/ajv/package.json | 12 +- .../eslint/node_modules/table/package.json | 9 +- tools/node_modules/eslint/package.json | 5 +- 116 files changed, 4828 insertions(+), 4566 deletions(-) create mode 100644 tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/block-elements.js delete mode 100644 tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/block-elements.json create mode 100644 tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/is-markdown-whitespace-character.js delete mode 100644 tools/node_modules/eslint/node_modules/lodash.flatten/LICENSE delete mode 100644 tools/node_modules/eslint/node_modules/lodash.flatten/README.md delete mode 100644 tools/node_modules/eslint/node_modules/lodash.flatten/index.js delete mode 100644 tools/node_modules/eslint/node_modules/lodash.flatten/package.json rename tools/node_modules/eslint/node_modules/table/dist/{calculateCellWidthIndex.js => calculateCellWidths.js} (50%) create mode 100644 tools/node_modules/eslint/node_modules/table/dist/calculateColumnWidths.js delete mode 100644 tools/node_modules/eslint/node_modules/table/dist/calculateMaximumColumnWidthIndex.js delete mode 100644 tools/node_modules/eslint/node_modules/table/dist/calculateRowHeightIndex.js create mode 100644 tools/node_modules/eslint/node_modules/table/dist/calculateRowHeights.js create mode 100644 tools/node_modules/eslint/node_modules/table/dist/drawContent.js create mode 100644 tools/node_modules/eslint/node_modules/table/dist/drawHeader.js delete mode 100644 tools/node_modules/eslint/node_modules/table/dist/drawHorizontalContent.js rename tools/node_modules/eslint/node_modules/table/dist/{makeConfig.js => makeTableConfig.js} (55%) delete mode 100644 tools/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js create mode 100644 tools/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeights.js create mode 100644 tools/node_modules/eslint/node_modules/table/dist/utils.js diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/index.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/index.js index 1579e35518c582..39cc24a23aecd1 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/index.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/index.js @@ -1,14 +1,17 @@ -'use strict'; +'use strict' -var unherit = require('unherit'); -var xtend = require('xtend'); -var Parser = require('./lib/parser.js'); +var unherit = require('unherit') +var xtend = require('xtend') +var Parser = require('./lib/parser.js') -module.exports = parse; -parse.Parser = Parser; +module.exports = parse +parse.Parser = Parser function parse(options) { - var Local = unherit(Parser); - Local.prototype.options = xtend(Local.prototype.options, this.data('settings'), options); - this.Parser = Local; + var settings = this.data('settings') + var Local = unherit(Parser) + + Local.prototype.options = xtend(Local.prototype.options, settings, options) + + this.Parser = Local } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/block-elements.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/block-elements.js new file mode 100644 index 00000000000000..c73efac9bb2786 --- /dev/null +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/block-elements.js @@ -0,0 +1,70 @@ +'use strict' + +module.exports = [ + 'address', + 'article', + 'aside', + 'base', + 'basefont', + 'blockquote', + 'body', + 'caption', + 'center', + 'col', + 'colgroup', + 'dd', + 'details', + 'dialog', + 'dir', + 'div', + 'dl', + 'dt', + 'fieldset', + 'figcaption', + 'figure', + 'footer', + 'form', + 'frame', + 'frameset', + 'h1', + 'h2', + 'h3', + 'h4', + 'h5', + 'h6', + 'head', + 'header', + 'hgroup', + 'hr', + 'html', + 'iframe', + 'legend', + 'li', + 'link', + 'main', + 'menu', + 'menuitem', + 'meta', + 'nav', + 'noframes', + 'ol', + 'optgroup', + 'option', + 'p', + 'param', + 'pre', + 'section', + 'source', + 'title', + 'summary', + 'table', + 'tbody', + 'td', + 'tfoot', + 'th', + 'thead', + 'title', + 'tr', + 'track', + 'ul' +] diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/block-elements.json b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/block-elements.json deleted file mode 100644 index 2d13b561792d65..00000000000000 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/block-elements.json +++ /dev/null @@ -1,68 +0,0 @@ -[ - "address", - "article", - "aside", - "base", - "basefont", - "blockquote", - "body", - "caption", - "center", - "col", - "colgroup", - "dd", - "details", - "dialog", - "dir", - "div", - "dl", - "dt", - "fieldset", - "figcaption", - "figure", - "footer", - "form", - "frame", - "frameset", - "h1", - "h2", - "h3", - "h4", - "h5", - "h6", - "head", - "header", - "hgroup", - "hr", - "html", - "iframe", - "legend", - "li", - "link", - "main", - "menu", - "menuitem", - "meta", - "nav", - "noframes", - "ol", - "optgroup", - "option", - "p", - "param", - "pre", - "section", - "source", - "title", - "summary", - "table", - "tbody", - "td", - "tfoot", - "th", - "thead", - "title", - "tr", - "track", - "ul" -] diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/decode.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/decode.js index fd45b729d069e1..3a1edc0be754cd 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/decode.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/decode.js @@ -1,48 +1,34 @@ -'use strict'; +'use strict' -var xtend = require('xtend'); -var entities = require('parse-entities'); +var xtend = require('xtend') +var entities = require('parse-entities') -module.exports = factory; +module.exports = factory -/* Factory to create an entity decoder. */ +// Factory to create an entity decoder. function factory(ctx) { - decoder.raw = decodeRaw; + decoder.raw = decodeRaw - return decoder; + return decoder - /* Normalize `position` to add an `indent`. */ + // Normalize `position` to add an `indent`. function normalize(position) { - var offsets = ctx.offset; - var line = position.line; - var result = []; + var offsets = ctx.offset + var line = position.line + var result = [] while (++line) { if (!(line in offsets)) { - break; + break } - result.push((offsets[line] || 0) + 1); + result.push((offsets[line] || 0) + 1) } - return { - start: position, - indent: result - }; + return {start: position, indent: result} } - /* Handle a warning. - * See https://github.com/wooorm/parse-entities - * for the warnings. */ - function handleWarning(reason, position, code) { - if (code === 3) { - return; - } - - ctx.file.message(reason, position); - } - - /* Decode `value` (at `position`) into text-nodes. */ + // Decode `value` (at `position`) into text-nodes. function decoder(value, position, handler) { entities(value, { position: normalize(position), @@ -51,14 +37,22 @@ function factory(ctx) { reference: handler, textContext: ctx, referenceContext: ctx - }); + }) } - /* Decode `value` (at `position`) into a string. */ + // Decode `value` (at `position`) into a string. function decodeRaw(value, position, options) { - return entities(value, xtend(options, { - position: normalize(position), - warning: handleWarning - })); + return entities( + value, + xtend(options, {position: normalize(position), warning: handleWarning}) + ) + } + + // Handle a warning. + // See for the warnings. + function handleWarning(reason, position, code) { + if (code !== 3) { + ctx.file.message(reason, position) + } } } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/defaults.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/defaults.js index 37846f3930a35a..7776e3c0889d85 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/defaults.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/defaults.js @@ -1,4 +1,4 @@ -'use strict'; +'use strict' module.exports = { position: true, @@ -6,5 +6,5 @@ module.exports = { commonmark: false, footnotes: false, pedantic: false, - blocks: require('./block-elements.json') -}; + blocks: require('./block-elements') +} diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/break.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/break.js index 295bdc9855126e..f5479e7c6e74ef 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/break.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/break.js @@ -1,17 +1,17 @@ -'use strict'; +'use strict' -module.exports = locate; +module.exports = locate function locate(value, fromIndex) { - var index = value.indexOf('\n', fromIndex); + var index = value.indexOf('\n', fromIndex) while (index > fromIndex) { if (value.charAt(index - 1) !== ' ') { - break; + break } - index--; + index-- } - return index; + return index } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/code-inline.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/code-inline.js index 981c81698254fe..241971709e4b66 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/code-inline.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/code-inline.js @@ -1,7 +1,7 @@ -'use strict'; +'use strict' -module.exports = locate; +module.exports = locate function locate(value, fromIndex) { - return value.indexOf('`', fromIndex); + return value.indexOf('`', fromIndex) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/delete.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/delete.js index d208aef2fff386..18b2f6305bb565 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/delete.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/delete.js @@ -1,7 +1,7 @@ -'use strict'; +'use strict' -module.exports = locate; +module.exports = locate function locate(value, fromIndex) { - return value.indexOf('~~', fromIndex); + return value.indexOf('~~', fromIndex) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/emphasis.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/emphasis.js index 6a1f24227d05bb..afec4ff893e28e 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/emphasis.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/emphasis.js @@ -1,18 +1,18 @@ -'use strict'; +'use strict' -module.exports = locate; +module.exports = locate function locate(value, fromIndex) { - var asterisk = value.indexOf('*', fromIndex); - var underscore = value.indexOf('_', fromIndex); + var asterisk = value.indexOf('*', fromIndex) + var underscore = value.indexOf('_', fromIndex) if (underscore === -1) { - return asterisk; + return asterisk } if (asterisk === -1) { - return underscore; + return underscore } - return underscore < asterisk ? underscore : asterisk; + return underscore < asterisk ? underscore : asterisk } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/escape.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/escape.js index f6c63715827ef3..9f61acff23ad54 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/escape.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/escape.js @@ -1,7 +1,7 @@ -'use strict'; +'use strict' -module.exports = locate; +module.exports = locate function locate(value, fromIndex) { - return value.indexOf('\\', fromIndex); + return value.indexOf('\\', fromIndex) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/link.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/link.js index 0f16fd8016bd36..df7b33bcfbe307 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/link.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/link.js @@ -1,16 +1,16 @@ -'use strict'; +'use strict' -module.exports = locate; +module.exports = locate function locate(value, fromIndex) { - var link = value.indexOf('[', fromIndex); - var image = value.indexOf('![', fromIndex); + var link = value.indexOf('[', fromIndex) + var image = value.indexOf('![', fromIndex) if (image === -1) { - return link; + return link } - /* Link can never be `-1` if an image is found, so we don’t need - * to check for that :) */ - return link < image ? link : image; + // Link can never be `-1` if an image is found, so we don’t need to check + // for that :) + return link < image ? link : image } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/strong.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/strong.js index da1cac0a499f2e..44b95cd02082ef 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/strong.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/strong.js @@ -1,18 +1,18 @@ -'use strict'; +'use strict' -module.exports = locate; +module.exports = locate function locate(value, fromIndex) { - var asterisk = value.indexOf('**', fromIndex); - var underscore = value.indexOf('__', fromIndex); + var asterisk = value.indexOf('**', fromIndex) + var underscore = value.indexOf('__', fromIndex) if (underscore === -1) { - return asterisk; + return asterisk } if (asterisk === -1) { - return underscore; + return underscore } - return underscore < asterisk ? underscore : asterisk; + return underscore < asterisk ? underscore : asterisk } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/tag.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/tag.js index 3c5534268abe1d..6a5d210b49109b 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/tag.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/tag.js @@ -1,7 +1,7 @@ -'use strict'; +'use strict' -module.exports = locate; +module.exports = locate function locate(value, fromIndex) { - return value.indexOf('<', fromIndex); + return value.indexOf('<', fromIndex) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/url.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/url.js index 59b63e2563693e..e5bf5bfa4c469b 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/url.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/locate/url.js @@ -1,26 +1,26 @@ -'use strict'; +'use strict' -module.exports = locate; +module.exports = locate -var PROTOCOLS = ['https://', 'http://', 'mailto:']; +var protocols = ['https://', 'http://', 'mailto:'] function locate(value, fromIndex) { - var length = PROTOCOLS.length; - var index = -1; - var min = -1; - var position; + var length = protocols.length + var index = -1 + var min = -1 + var position if (!this.options.gfm) { - return -1; + return -1 } while (++index < length) { - position = value.indexOf(PROTOCOLS[index], fromIndex); + position = value.indexOf(protocols[index], fromIndex) if (position !== -1 && (position < min || min === -1)) { - min = position; + min = position } } - return min; + return min } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/parse.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/parse.js index 5a8d8119556792..59aac694bceebd 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/parse.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/parse.js @@ -1,45 +1,42 @@ -'use strict'; +'use strict' -var xtend = require('xtend'); -var removePosition = require('unist-util-remove-position'); +var xtend = require('xtend') +var removePosition = require('unist-util-remove-position') -module.exports = parse; +module.exports = parse -var C_NEWLINE = '\n'; -var EXPRESSION_LINE_BREAKS = /\r\n|\r/g; +var lineFeed = '\n' +var lineBreaksExpression = /\r\n|\r/g -/* Parse the bound file. */ +// Parse the bound file. function parse() { - var self = this; - var value = String(self.file); - var start = {line: 1, column: 1, offset: 0}; - var content = xtend(start); - var node; - - /* Clean non-unix newlines: `\r\n` and `\r` are all - * changed to `\n`. This should not affect positional - * information. */ - value = value.replace(EXPRESSION_LINE_BREAKS, C_NEWLINE); - - if (value.charCodeAt(0) === 0xFEFF) { - value = value.slice(1); - - content.column++; - content.offset++; + var self = this + var value = String(self.file) + var start = {line: 1, column: 1, offset: 0} + var content = xtend(start) + var node + + // Clean non-unix newlines: `\r\n` and `\r` are all changed to `\n`. + // This should not affect positional information. + value = value.replace(lineBreaksExpression, lineFeed) + + // BOM. + if (value.charCodeAt(0) === 0xfeff) { + value = value.slice(1) + + content.column++ + content.offset++ } node = { type: 'root', children: self.tokenizeBlock(value, content), - position: { - start: start, - end: self.eof || xtend(start) - } - }; + position: {start: start, end: self.eof || xtend(start)} + } if (!self.options.position) { - removePosition(node, true); + removePosition(node, true) } - return node; + return node } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/parser.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/parser.js index 9291109f16f3ec..4add90e01e891a 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/parser.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/parser.js @@ -1,54 +1,53 @@ -'use strict'; +'use strict' -var xtend = require('xtend'); -var toggle = require('state-toggle'); -var vfileLocation = require('vfile-location'); -var unescape = require('./unescape'); -var decode = require('./decode'); -var tokenizer = require('./tokenizer'); +var xtend = require('xtend') +var toggle = require('state-toggle') +var vfileLocation = require('vfile-location') +var unescape = require('./unescape') +var decode = require('./decode') +var tokenizer = require('./tokenizer') -module.exports = Parser; +module.exports = Parser function Parser(doc, file) { - this.file = file; - this.offset = {}; - this.options = xtend(this.options); - this.setOptions({}); - - this.inList = false; - this.inBlock = false; - this.inLink = false; - this.atStart = true; - - this.toOffset = vfileLocation(file).toOffset; - this.unescape = unescape(this, 'escape'); - this.decode = decode(this); + this.file = file + this.offset = {} + this.options = xtend(this.options) + this.setOptions({}) + + this.inList = false + this.inBlock = false + this.inLink = false + this.atStart = true + + this.toOffset = vfileLocation(file).toOffset + this.unescape = unescape(this, 'escape') + this.decode = decode(this) } -var proto = Parser.prototype; - -/* Expose core. */ -proto.setOptions = require('./set-options'); -proto.parse = require('./parse'); - -/* Expose `defaults`. */ -proto.options = require('./defaults'); - -/* Enter and exit helpers. */ -proto.exitStart = toggle('atStart', true); -proto.enterList = toggle('inList', false); -proto.enterLink = toggle('inLink', false); -proto.enterBlock = toggle('inBlock', false); - -/* Nodes that can interupt a paragraph: - * - * ```markdown - * A paragraph, followed by a thematic break. - * ___ - * ``` - * - * In the above example, the thematic break “interupts” - * the paragraph. */ +var proto = Parser.prototype + +// Expose core. +proto.setOptions = require('./set-options') +proto.parse = require('./parse') + +// Expose `defaults`. +proto.options = require('./defaults') + +// Enter and exit helpers. +proto.exitStart = toggle('atStart', true) +proto.enterList = toggle('inList', false) +proto.enterLink = toggle('inLink', false) +proto.enterBlock = toggle('inBlock', false) + +// Nodes that can interupt a paragraph: +// +// ```markdown +// A paragraph, followed by a thematic break. +// ___ +// ``` +// +// In the above example, the thematic break “interupts” the paragraph. proto.interruptParagraph = [ ['thematicBreak'], ['atxHeading'], @@ -58,34 +57,32 @@ proto.interruptParagraph = [ ['setextHeading', {commonmark: false}], ['definition', {commonmark: false}], ['footnote', {commonmark: false}] -]; - -/* Nodes that can interupt a list: - * - * ```markdown - * - One - * ___ - * ``` - * - * In the above example, the thematic break “interupts” - * the list. */ +] + +// Nodes that can interupt a list: +// +// ```markdown +// - One +// ___ +// ``` +// +// In the above example, the thematic break “interupts” the list. proto.interruptList = [ ['atxHeading', {pedantic: false}], ['fencedCode', {pedantic: false}], ['thematicBreak', {pedantic: false}], ['definition', {commonmark: false}], ['footnote', {commonmark: false}] -]; - -/* Nodes that can interupt a blockquote: - * - * ```markdown - * > A paragraph. - * ___ - * ``` - * - * In the above example, the thematic break “interupts” - * the blockquote. */ +] + +// Nodes that can interupt a blockquote: +// +// ```markdown +// > A paragraph. +// ___ +// ``` +// +// In the above example, the thematic break “interupts” the blockquote. proto.interruptBlockquote = [ ['indentedCode', {commonmark: true}], ['fencedCode', {commonmark: true}], @@ -96,9 +93,9 @@ proto.interruptBlockquote = [ ['list', {commonmark: true}], ['definition', {commonmark: false}], ['footnote', {commonmark: false}] -]; +] -/* Handlers. */ +// Handlers. proto.blockTokenizers = { newline: require('./tokenize/newline'), indentedCode: require('./tokenize/code-indented'), @@ -113,7 +110,7 @@ proto.blockTokenizers = { definition: require('./tokenize/definition'), table: require('./tokenize/table'), paragraph: require('./tokenize/paragraph') -}; +} proto.inlineTokenizers = { escape: require('./tokenize/escape'), @@ -128,25 +125,25 @@ proto.inlineTokenizers = { code: require('./tokenize/code-inline'), break: require('./tokenize/break'), text: require('./tokenize/text') -}; +} -/* Expose precedence. */ -proto.blockMethods = keys(proto.blockTokenizers); -proto.inlineMethods = keys(proto.inlineTokenizers); +// Expose precedence. +proto.blockMethods = keys(proto.blockTokenizers) +proto.inlineMethods = keys(proto.inlineTokenizers) -/* Tokenizers. */ -proto.tokenizeBlock = tokenizer('block'); -proto.tokenizeInline = tokenizer('inline'); -proto.tokenizeFactory = tokenizer; +// Tokenizers. +proto.tokenizeBlock = tokenizer('block') +proto.tokenizeInline = tokenizer('inline') +proto.tokenizeFactory = tokenizer -/* Get all keys in `value`. */ +// Get all keys in `value`. function keys(value) { - var result = []; - var key; + var result = [] + var key for (key in value) { - result.push(key); + result.push(key) } - return result; + return result } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/set-options.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/set-options.js index c55f7f32f31def..5877099e393cb5 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/set-options.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/set-options.js @@ -1,47 +1,46 @@ -'use strict'; +'use strict' -var xtend = require('xtend'); -var escapes = require('markdown-escapes'); -var defaults = require('./defaults'); +var xtend = require('xtend') +var escapes = require('markdown-escapes') +var defaults = require('./defaults') -module.exports = setOptions; +module.exports = setOptions function setOptions(options) { - var self = this; - var current = self.options; - var key; - var value; + var self = this + var current = self.options + var key + var value if (options == null) { - options = {}; + options = {} } else if (typeof options === 'object') { - options = xtend(options); + options = xtend(options) } else { - throw new Error( - 'Invalid value `' + options + '` ' + - 'for setting `options`' - ); + throw new Error('Invalid value `' + options + '` for setting `options`') } for (key in defaults) { - value = options[key]; + value = options[key] if (value == null) { - value = current[key]; + value = current[key] } if ( (key !== 'blocks' && typeof value !== 'boolean') || (key === 'blocks' && typeof value !== 'object') ) { - throw new Error('Invalid value `' + value + '` for setting `options.' + key + '`'); + throw new Error( + 'Invalid value `' + value + '` for setting `options.' + key + '`' + ) } - options[key] = value; + options[key] = value } - self.options = options; - self.escape = escapes(options); + self.options = options + self.escape = escapes(options) - return self; + return self } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/auto-link.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/auto-link.js index c945a2c1f88f58..f5bcb8900a701a 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/auto-link.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/auto-link.js @@ -1,145 +1,133 @@ -'use strict'; +'use strict' -var whitespace = require('is-whitespace-character'); -var decode = require('parse-entities'); -var locate = require('../locate/tag'); +var whitespace = require('is-whitespace-character') +var decode = require('parse-entities') +var locate = require('../locate/tag') -module.exports = autoLink; -autoLink.locator = locate; -autoLink.notInLink = true; +module.exports = autoLink +autoLink.locator = locate +autoLink.notInLink = true -var C_LT = '<'; -var C_GT = '>'; -var C_AT_SIGN = '@'; -var C_SLASH = '/'; -var MAILTO = 'mailto:'; -var MAILTO_LENGTH = MAILTO.length; +var lessThan = '<' +var greaterThan = '>' +var atSign = '@' +var slash = '/' +var mailto = 'mailto:' +var mailtoLength = mailto.length -/* Tokenise a link. */ function autoLink(eat, value, silent) { - var self; - var subvalue; - var length; - var index; - var queue; - var character; - var hasAtCharacter; - var link; - var now; - var content; - var tokenizers; - var exit; - - if (value.charAt(0) !== C_LT) { - return; + var self = this + var subvalue = '' + var length = value.length + var index = 0 + var queue = '' + var hasAtCharacter = false + var link = '' + var character + var now + var content + var tokenizers + var exit + + if (value.charAt(0) !== lessThan) { + return } - self = this; - subvalue = ''; - length = value.length; - index = 0; - queue = ''; - hasAtCharacter = false; - link = ''; - - index++; - subvalue = C_LT; + index++ + subvalue = lessThan while (index < length) { - character = value.charAt(index); + character = value.charAt(index) if ( whitespace(character) || - character === C_GT || - character === C_AT_SIGN || - (character === ':' && value.charAt(index + 1) === C_SLASH) + character === greaterThan || + character === atSign || + (character === ':' && value.charAt(index + 1) === slash) ) { - break; + break } - queue += character; - index++; + queue += character + index++ } if (!queue) { - return; + return } - link += queue; - queue = ''; + link += queue + queue = '' - character = value.charAt(index); - link += character; - index++; + character = value.charAt(index) + link += character + index++ - if (character === C_AT_SIGN) { - hasAtCharacter = true; + if (character === atSign) { + hasAtCharacter = true } else { - if ( - character !== ':' || - value.charAt(index + 1) !== C_SLASH - ) { - return; + if (character !== ':' || value.charAt(index + 1) !== slash) { + return } - link += C_SLASH; - index++; + link += slash + index++ } while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (whitespace(character) || character === C_GT) { - break; + if (whitespace(character) || character === greaterThan) { + break } - queue += character; - index++; + queue += character + index++ } - character = value.charAt(index); + character = value.charAt(index) - if (!queue || character !== C_GT) { - return; + if (!queue || character !== greaterThan) { + return } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - link += queue; - content = link; - subvalue += link + character; - now = eat.now(); - now.column++; - now.offset++; + link += queue + content = link + subvalue += link + character + now = eat.now() + now.column++ + now.offset++ if (hasAtCharacter) { - if (link.slice(0, MAILTO_LENGTH).toLowerCase() === MAILTO) { - content = content.substr(MAILTO_LENGTH); - now.column += MAILTO_LENGTH; - now.offset += MAILTO_LENGTH; + if (link.slice(0, mailtoLength).toLowerCase() === mailto) { + content = content.slice(mailtoLength) + now.column += mailtoLength + now.offset += mailtoLength } else { - link = MAILTO + link; + link = mailto + link } } - /* Temporarily remove all tokenizers except text in autolinks. */ - tokenizers = self.inlineTokenizers; - self.inlineTokenizers = {text: tokenizers.text}; + // Temporarily remove all tokenizers except text in autolinks. + tokenizers = self.inlineTokenizers + self.inlineTokenizers = {text: tokenizers.text} - exit = self.enterLink(); + exit = self.enterLink() - content = self.tokenizeInline(content, now); + content = self.tokenizeInline(content, now) - self.inlineTokenizers = tokenizers; - exit(); + self.inlineTokenizers = tokenizers + exit() return eat(subvalue)({ type: 'link', title: null, url: decode(link, {nonTerminated: false}), children: content - }); + }) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/blockquote.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/blockquote.js index bd700d6a6c8276..2960e85afaa644 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/blockquote.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/blockquote.js @@ -1,129 +1,124 @@ -'use strict'; +'use strict' -var trim = require('trim'); -var interrupt = require('../util/interrupt'); +var trim = require('trim') +var interrupt = require('../util/interrupt') -module.exports = blockquote; +module.exports = blockquote -var C_NEWLINE = '\n'; -var C_TAB = '\t'; -var C_SPACE = ' '; -var C_GT = '>'; +var lineFeed = '\n' +var tab = '\t' +var space = ' ' +var greaterThan = '>' -/* Tokenise a blockquote. */ function blockquote(eat, value, silent) { - var self = this; - var offsets = self.offset; - var tokenizers = self.blockTokenizers; - var interruptors = self.interruptBlockquote; - var now = eat.now(); - var currentLine = now.line; - var length = value.length; - var values = []; - var contents = []; - var indents = []; - var add; - var index = 0; - var character; - var rest; - var nextIndex; - var content; - var line; - var startIndex; - var prefixed; - var exit; + var self = this + var offsets = self.offset + var tokenizers = self.blockTokenizers + var interruptors = self.interruptBlockquote + var now = eat.now() + var currentLine = now.line + var length = value.length + var values = [] + var contents = [] + var indents = [] + var add + var index = 0 + var character + var rest + var nextIndex + var content + var line + var startIndex + var prefixed + var exit while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character !== C_SPACE && character !== C_TAB) { - break; + if (character !== space && character !== tab) { + break } - index++; + index++ } - if (value.charAt(index) !== C_GT) { - return; + if (value.charAt(index) !== greaterThan) { + return } if (silent) { - return true; + return true } - index = 0; + index = 0 while (index < length) { - nextIndex = value.indexOf(C_NEWLINE, index); - startIndex = index; - prefixed = false; + nextIndex = value.indexOf(lineFeed, index) + startIndex = index + prefixed = false if (nextIndex === -1) { - nextIndex = length; + nextIndex = length } while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character !== C_SPACE && character !== C_TAB) { - break; + if (character !== space && character !== tab) { + break } - index++; + index++ } - if (value.charAt(index) === C_GT) { - index++; - prefixed = true; + if (value.charAt(index) === greaterThan) { + index++ + prefixed = true - if (value.charAt(index) === C_SPACE) { - index++; + if (value.charAt(index) === space) { + index++ } } else { - index = startIndex; + index = startIndex } - content = value.slice(index, nextIndex); + content = value.slice(index, nextIndex) if (!prefixed && !trim(content)) { - index = startIndex; - break; + index = startIndex + break } if (!prefixed) { - rest = value.slice(index); + rest = value.slice(index) - /* Check if the following code contains a possible - * block. */ + // Check if the following code contains a possible block. if (interrupt(interruptors, tokenizers, self, [eat, rest, true])) { - break; + break } } - line = startIndex === index ? content : value.slice(startIndex, nextIndex); + line = startIndex === index ? content : value.slice(startIndex, nextIndex) - indents.push(index - startIndex); - values.push(line); - contents.push(content); + indents.push(index - startIndex) + values.push(line) + contents.push(content) - index = nextIndex + 1; + index = nextIndex + 1 } - index = -1; - length = indents.length; - add = eat(values.join(C_NEWLINE)); + index = -1 + length = indents.length + add = eat(values.join(lineFeed)) while (++index < length) { - offsets[currentLine] = (offsets[currentLine] || 0) + indents[index]; - currentLine++; + offsets[currentLine] = (offsets[currentLine] || 0) + indents[index] + currentLine++ } - exit = self.enterBlock(); - contents = self.tokenizeBlock(contents.join(C_NEWLINE), now); - exit(); + exit = self.enterBlock() + contents = self.tokenizeBlock(contents.join(lineFeed), now) + exit() - return add({ - type: 'blockquote', - children: contents - }); + return add({type: 'blockquote', children: contents}) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/break.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/break.js index eb531342bfebcb..b68ca6d7e2a47e 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/break.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/break.js @@ -1,40 +1,42 @@ -'use strict'; +'use strict' -var locate = require('../locate/break'); +var locate = require('../locate/break') -module.exports = hardBreak; -hardBreak.locator = locate; +module.exports = hardBreak +hardBreak.locator = locate -var MIN_BREAK_LENGTH = 2; +var space = ' ' +var lineFeed = '\n' +var minBreakLength = 2 function hardBreak(eat, value, silent) { - var length = value.length; - var index = -1; - var queue = ''; - var character; + var length = value.length + var index = -1 + var queue = '' + var character while (++index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character === '\n') { - if (index < MIN_BREAK_LENGTH) { - return; + if (character === lineFeed) { + if (index < minBreakLength) { + return } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - queue += character; + queue += character - return eat(queue)({type: 'break'}); + return eat(queue)({type: 'break'}) } - if (character !== ' ') { - return; + if (character !== space) { + return } - queue += character; + queue += character } } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/code-fenced.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/code-fenced.js index 65f2bc73273ab3..e690814f9c61f4 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/code-fenced.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/code-fenced.js @@ -1,236 +1,253 @@ -'use strict'; +'use strict' -var trim = require('trim-trailing-lines'); +module.exports = fencedCode -module.exports = fencedCode; +var lineFeed = '\n' +var tab = '\t' +var space = ' ' +var tilde = '~' +var graveAccent = '`' -var C_NEWLINE = '\n'; -var C_TAB = '\t'; -var C_SPACE = ' '; -var C_TILDE = '~'; -var C_TICK = '`'; - -var MIN_FENCE_COUNT = 3; -var CODE_INDENT_COUNT = 4; +var minFenceCount = 3 +var tabSize = 4 function fencedCode(eat, value, silent) { - var self = this; - var settings = self.options; - var length = value.length + 1; - var index = 0; - var subvalue = ''; - var fenceCount; - var marker; - var character; - var flag; - var queue; - var content; - var exdentedContent; - var closing; - var exdentedClosing; - var indent; - var now; - - if (!settings.gfm) { - return; + var self = this + var gfm = self.options.gfm + var length = value.length + 1 + var index = 0 + var subvalue = '' + var fenceCount + var marker + var character + var flag + var lang + var meta + var queue + var content + var exdentedContent + var closing + var exdentedClosing + var indent + var now + + if (!gfm) { + return } - /* Eat initial spacing. */ + // Eat initial spacing. while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character !== C_SPACE && character !== C_TAB) { - break; + if (character !== space && character !== tab) { + break } - subvalue += character; - index++; + subvalue += character + index++ } - indent = index; + indent = index - /* Eat the fence. */ - character = value.charAt(index); + // Eat the fence. + character = value.charAt(index) - if (character !== C_TILDE && character !== C_TICK) { - return; + if (character !== tilde && character !== graveAccent) { + return } - index++; - marker = character; - fenceCount = 1; - subvalue += character; + index++ + marker = character + fenceCount = 1 + subvalue += character while (index < length) { - character = value.charAt(index); + character = value.charAt(index) if (character !== marker) { - break; + break } - subvalue += character; - fenceCount++; - index++; + subvalue += character + fenceCount++ + index++ } - if (fenceCount < MIN_FENCE_COUNT) { - return; + if (fenceCount < minFenceCount) { + return } - /* Eat spacing before flag. */ + // Eat spacing before flag. while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character !== C_SPACE && character !== C_TAB) { - break; + if (character !== space && character !== tab) { + break } - subvalue += character; - index++; + subvalue += character + index++ } - /* Eat flag. */ - flag = ''; - queue = ''; + // Eat flag. + flag = '' + queue = '' while (index < length) { - character = value.charAt(index); + character = value.charAt(index) if ( - character === C_NEWLINE || - character === C_TILDE || - character === C_TICK + character === lineFeed || + (marker === graveAccent && character === marker) ) { - break; + break } - if (character === C_SPACE || character === C_TAB) { - queue += character; + if (character === space || character === tab) { + queue += character } else { - flag += queue + character; - queue = ''; + flag += queue + character + queue = '' } - index++; + index++ } - character = value.charAt(index); + character = value.charAt(index) - if (character && character !== C_NEWLINE) { - return; + if (character && character !== lineFeed) { + return } if (silent) { - return true; + return true } - now = eat.now(); - now.column += subvalue.length; - now.offset += subvalue.length; + now = eat.now() + now.column += subvalue.length + now.offset += subvalue.length - subvalue += flag; - flag = self.decode.raw(self.unescape(flag), now); + subvalue += flag + flag = self.decode.raw(self.unescape(flag), now) if (queue) { - subvalue += queue; + subvalue += queue } - queue = ''; - closing = ''; - exdentedClosing = ''; - content = ''; - exdentedContent = ''; + queue = '' + closing = '' + exdentedClosing = '' + content = '' + exdentedContent = '' + var skip = true - /* Eat content. */ + // Eat content. while (index < length) { - character = value.charAt(index); - content += closing; - exdentedContent += exdentedClosing; - closing = ''; - exdentedClosing = ''; - - if (character !== C_NEWLINE) { - content += character; - exdentedClosing += character; - index++; - continue; + character = value.charAt(index) + content += closing + exdentedContent += exdentedClosing + closing = '' + exdentedClosing = '' + + if (character !== lineFeed) { + content += character + exdentedClosing += character + index++ + continue } - /* Add the newline to `subvalue` if its the first - * character. Otherwise, add it to the `closing` - * queue. */ - if (content) { - closing += character; - exdentedClosing += character; + // The first line feed is ignored. Others aren’t. + if (skip) { + subvalue += character + skip = false } else { - subvalue += character; + closing += character + exdentedClosing += character } - queue = ''; - index++; + queue = '' + index++ while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character !== C_SPACE) { - break; + if (character !== space) { + break } - queue += character; - index++; + queue += character + index++ } - closing += queue; - exdentedClosing += queue.slice(indent); + closing += queue + exdentedClosing += queue.slice(indent) - if (queue.length >= CODE_INDENT_COUNT) { - continue; + if (queue.length >= tabSize) { + continue } - queue = ''; + queue = '' while (index < length) { - character = value.charAt(index); + character = value.charAt(index) if (character !== marker) { - break; + break } - queue += character; - index++; + queue += character + index++ } - closing += queue; - exdentedClosing += queue; + closing += queue + exdentedClosing += queue if (queue.length < fenceCount) { - continue; + continue } - queue = ''; + queue = '' while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character !== C_SPACE && character !== C_TAB) { - break; + if (character !== space && character !== tab) { + break } - closing += character; - exdentedClosing += character; - index++; + closing += character + exdentedClosing += character + index++ } - if (!character || character === C_NEWLINE) { - break; + if (!character || character === lineFeed) { + break } } - subvalue += content + closing; + subvalue += content + closing + + // Get lang and meta from the flag. + index = -1 + length = flag.length + + while (++index < length) { + character = flag.charAt(index) + + if (character === space || character === tab) { + if (!lang) { + lang = flag.slice(0, index) + } + } else if (lang) { + meta = flag.slice(index) + break + } + } return eat(subvalue)({ type: 'code', - lang: flag || null, - value: trim(exdentedContent) - }); + lang: lang || flag || null, + meta: meta || null, + value: exdentedContent + }) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/code-indented.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/code-indented.js index c73849d9ad8bf2..53a666fb6def8a 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/code-indented.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/code-indented.js @@ -1,98 +1,98 @@ -'use strict'; +'use strict' -var repeat = require('repeat-string'); -var trim = require('trim-trailing-lines'); +var repeat = require('repeat-string') +var trim = require('trim-trailing-lines') -module.exports = indentedCode; +module.exports = indentedCode -var C_NEWLINE = '\n'; -var C_TAB = '\t'; -var C_SPACE = ' '; +var lineFeed = '\n' +var tab = '\t' +var space = ' ' -var CODE_INDENT_COUNT = 4; -var CODE_INDENT = repeat(C_SPACE, CODE_INDENT_COUNT); +var tabSize = 4 +var codeIndent = repeat(space, tabSize) -/* Tokenise indented code. */ function indentedCode(eat, value, silent) { - var index = -1; - var length = value.length; - var subvalue = ''; - var content = ''; - var subvalueQueue = ''; - var contentQueue = ''; - var character; - var blankQueue; - var indent; + var index = -1 + var length = value.length + var subvalue = '' + var content = '' + var subvalueQueue = '' + var contentQueue = '' + var character + var blankQueue + var indent while (++index < length) { - character = value.charAt(index); + character = value.charAt(index) if (indent) { - indent = false; + indent = false - subvalue += subvalueQueue; - content += contentQueue; - subvalueQueue = ''; - contentQueue = ''; + subvalue += subvalueQueue + content += contentQueue + subvalueQueue = '' + contentQueue = '' - if (character === C_NEWLINE) { - subvalueQueue = character; - contentQueue = character; + if (character === lineFeed) { + subvalueQueue = character + contentQueue = character } else { - subvalue += character; - content += character; + subvalue += character + content += character while (++index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (!character || character === C_NEWLINE) { - contentQueue = character; - subvalueQueue = character; - break; + if (!character || character === lineFeed) { + contentQueue = character + subvalueQueue = character + break } - subvalue += character; - content += character; + subvalue += character + content += character } } } else if ( - character === C_SPACE && + character === space && value.charAt(index + 1) === character && value.charAt(index + 2) === character && value.charAt(index + 3) === character ) { - subvalueQueue += CODE_INDENT; - index += 3; - indent = true; - } else if (character === C_TAB) { - subvalueQueue += character; - indent = true; + subvalueQueue += codeIndent + index += 3 + indent = true + } else if (character === tab) { + subvalueQueue += character + indent = true } else { - blankQueue = ''; + blankQueue = '' - while (character === C_TAB || character === C_SPACE) { - blankQueue += character; - character = value.charAt(++index); + while (character === tab || character === space) { + blankQueue += character + character = value.charAt(++index) } - if (character !== C_NEWLINE) { - break; + if (character !== lineFeed) { + break } - subvalueQueue += blankQueue + character; - contentQueue += character; + subvalueQueue += blankQueue + character + contentQueue += character } } if (content) { if (silent) { - return true; + return true } return eat(subvalue)({ type: 'code', lang: null, + meta: null, value: trim(content) - }); + }) } } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/code-inline.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/code-inline.js index c0a496b49255ba..66da0f35488e8f 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/code-inline.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/code-inline.js @@ -1,112 +1,109 @@ -'use strict'; +'use strict' -var whitespace = require('is-whitespace-character'); -var locate = require('../locate/code-inline'); +var locate = require('../locate/code-inline') -module.exports = inlineCode; -inlineCode.locator = locate; +module.exports = inlineCode +inlineCode.locator = locate -var C_TICK = '`'; +var lineFeed = 10 // '\n' +var space = 32 // ' ' +var graveAccent = 96 // '`' -/* Tokenise inline code. */ function inlineCode(eat, value, silent) { - var length = value.length; - var index = 0; - var queue = ''; - var tickQueue = ''; - var contentQueue; - var subqueue; - var count; - var openingCount; - var subvalue; - var character; - var found; - var next; + var length = value.length + var index = 0 + var openingFenceEnd + var closingFenceStart + var closingFenceEnd + var code + var next + var found while (index < length) { - if (value.charAt(index) !== C_TICK) { - break; + if (value.charCodeAt(index) !== graveAccent) { + break } - queue += C_TICK; - index++; + index++ } - if (!queue) { - return; + if (index === 0 || index === length) { + return } - subvalue = queue; - openingCount = index; - queue = ''; - next = value.charAt(index); - count = 0; + openingFenceEnd = index + next = value.charCodeAt(index) while (index < length) { - character = next; - next = value.charAt(index + 1); - - if (character === C_TICK) { - count++; - tickQueue += character; - } else { - count = 0; - queue += character; - } + code = next + next = value.charCodeAt(index + 1) - if (count && next !== C_TICK) { - if (count === openingCount) { - subvalue += queue + tickQueue; - found = true; - break; + if (code === graveAccent) { + if (closingFenceStart === undefined) { + closingFenceStart = index } - queue += tickQueue; - tickQueue = ''; + closingFenceEnd = index + 1 + + if ( + next !== graveAccent && + closingFenceEnd - closingFenceStart === openingFenceEnd + ) { + found = true + break + } + } else if (closingFenceStart !== undefined) { + closingFenceStart = undefined + closingFenceEnd = undefined } - index++; + index++ } if (!found) { - if (openingCount % 2 !== 0) { - return; - } - - queue = ''; + return } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - contentQueue = ''; - subqueue = ''; - length = queue.length; - index = -1; - - while (++index < length) { - character = queue.charAt(index); - - if (whitespace(character)) { - subqueue += character; - continue; - } - - if (subqueue) { - if (contentQueue) { - contentQueue += subqueue; + // Remove the initial and final space (or line feed), iff they exist and there + // are non-space characters in the content. + index = openingFenceEnd + length = closingFenceStart + code = value.charCodeAt(index) + next = value.charCodeAt(length - 1) + found = false + + if ( + length - index > 2 && + (code === space || code === lineFeed) && + (next === space || next === lineFeed) + ) { + index++ + length-- + + while (index < length) { + code = value.charCodeAt(index) + + if (code !== space && code !== lineFeed) { + found = true + break } - subqueue = ''; + index++ } - contentQueue += character; + if (found === true) { + openingFenceEnd++ + closingFenceStart-- + } } - return eat(subvalue)({ + return eat(value.slice(0, closingFenceEnd))({ type: 'inlineCode', - value: contentQueue - }); + value: value.slice(openingFenceEnd, closingFenceStart) + }) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/definition.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/definition.js index 1cce274cfbdd71..ec56f0c41a595e 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/definition.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/definition.js @@ -1,278 +1,273 @@ -'use strict'; - -var whitespace = require('is-whitespace-character'); -var normalize = require('../util/normalize'); - -module.exports = definition; -definition.notInList = true; -definition.notInBlock = true; - -var C_DOUBLE_QUOTE = '"'; -var C_SINGLE_QUOTE = '\''; -var C_BACKSLASH = '\\'; -var C_NEWLINE = '\n'; -var C_TAB = '\t'; -var C_SPACE = ' '; -var C_BRACKET_OPEN = '['; -var C_BRACKET_CLOSE = ']'; -var C_PAREN_OPEN = '('; -var C_PAREN_CLOSE = ')'; -var C_COLON = ':'; -var C_LT = '<'; -var C_GT = '>'; +'use strict' + +var whitespace = require('is-whitespace-character') +var normalize = require('../util/normalize') + +module.exports = definition + +var quotationMark = '"' +var apostrophe = "'" +var backslash = '\\' +var lineFeed = '\n' +var tab = '\t' +var space = ' ' +var leftSquareBracket = '[' +var rightSquareBracket = ']' +var leftParenthesis = '(' +var rightParenthesis = ')' +var colon = ':' +var lessThan = '<' +var greaterThan = '>' function definition(eat, value, silent) { - var self = this; - var commonmark = self.options.commonmark; - var index = 0; - var length = value.length; - var subvalue = ''; - var beforeURL; - var beforeTitle; - var queue; - var character; - var test; - var identifier; - var url; - var title; + var self = this + var commonmark = self.options.commonmark + var index = 0 + var length = value.length + var subvalue = '' + var beforeURL + var beforeTitle + var queue + var character + var test + var identifier + var url + var title while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character !== C_SPACE && character !== C_TAB) { - break; + if (character !== space && character !== tab) { + break } - subvalue += character; - index++; + subvalue += character + index++ } - character = value.charAt(index); + character = value.charAt(index) - if (character !== C_BRACKET_OPEN) { - return; + if (character !== leftSquareBracket) { + return } - index++; - subvalue += character; - queue = ''; + index++ + subvalue += character + queue = '' while (index < length) { - character = value.charAt(index); - - if (character === C_BRACKET_CLOSE) { - break; - } else if (character === C_BACKSLASH) { - queue += character; - index++; - character = value.charAt(index); + character = value.charAt(index) + + if (character === rightSquareBracket) { + break + } else if (character === backslash) { + queue += character + index++ + character = value.charAt(index) } - queue += character; - index++; + queue += character + index++ } if ( !queue || - value.charAt(index) !== C_BRACKET_CLOSE || - value.charAt(index + 1) !== C_COLON + value.charAt(index) !== rightSquareBracket || + value.charAt(index + 1) !== colon ) { - return; + return } - identifier = queue; - subvalue += queue + C_BRACKET_CLOSE + C_COLON; - index = subvalue.length; - queue = ''; + identifier = queue + subvalue += queue + rightSquareBracket + colon + index = subvalue.length + queue = '' while (index < length) { - character = value.charAt(index); - - if ( - character !== C_TAB && - character !== C_SPACE && - character !== C_NEWLINE - ) { - break; + character = value.charAt(index) + + if (character !== tab && character !== space && character !== lineFeed) { + break } - subvalue += character; - index++; + subvalue += character + index++ } - character = value.charAt(index); - queue = ''; - beforeURL = subvalue; + character = value.charAt(index) + queue = '' + beforeURL = subvalue - if (character === C_LT) { - index++; + if (character === lessThan) { + index++ while (index < length) { - character = value.charAt(index); + character = value.charAt(index) if (!isEnclosedURLCharacter(character)) { - break; + break } - queue += character; - index++; + queue += character + index++ } - character = value.charAt(index); + character = value.charAt(index) if (character === isEnclosedURLCharacter.delimiter) { - subvalue += C_LT + queue + character; - index++; + subvalue += lessThan + queue + character + index++ } else { if (commonmark) { - return; + return } - index -= queue.length + 1; - queue = ''; + index -= queue.length + 1 + queue = '' } } if (!queue) { while (index < length) { - character = value.charAt(index); + character = value.charAt(index) if (!isUnclosedURLCharacter(character)) { - break; + break } - queue += character; - index++; + queue += character + index++ } - subvalue += queue; + subvalue += queue } if (!queue) { - return; + return } - url = queue; - queue = ''; + url = queue + queue = '' while (index < length) { - character = value.charAt(index); - - if ( - character !== C_TAB && - character !== C_SPACE && - character !== C_NEWLINE - ) { - break; + character = value.charAt(index) + + if (character !== tab && character !== space && character !== lineFeed) { + break } - queue += character; - index++; + queue += character + index++ } - character = value.charAt(index); - test = null; + character = value.charAt(index) + test = null - if (character === C_DOUBLE_QUOTE) { - test = C_DOUBLE_QUOTE; - } else if (character === C_SINGLE_QUOTE) { - test = C_SINGLE_QUOTE; - } else if (character === C_PAREN_OPEN) { - test = C_PAREN_CLOSE; + if (character === quotationMark) { + test = quotationMark + } else if (character === apostrophe) { + test = apostrophe + } else if (character === leftParenthesis) { + test = rightParenthesis } if (!test) { - queue = ''; - index = subvalue.length; + queue = '' + index = subvalue.length } else if (queue) { - subvalue += queue + character; - index = subvalue.length; - queue = ''; + subvalue += queue + character + index = subvalue.length + queue = '' while (index < length) { - character = value.charAt(index); + character = value.charAt(index) if (character === test) { - break; + break } - if (character === C_NEWLINE) { - index++; - character = value.charAt(index); + if (character === lineFeed) { + index++ + character = value.charAt(index) - if (character === C_NEWLINE || character === test) { - return; + if (character === lineFeed || character === test) { + return } - queue += C_NEWLINE; + queue += lineFeed } - queue += character; - index++; + queue += character + index++ } - character = value.charAt(index); + character = value.charAt(index) if (character !== test) { - return; + return } - beforeTitle = subvalue; - subvalue += queue + character; - index++; - title = queue; - queue = ''; + beforeTitle = subvalue + subvalue += queue + character + index++ + title = queue + queue = '' } else { - return; + return } while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character !== C_TAB && character !== C_SPACE) { - break; + if (character !== tab && character !== space) { + break } - subvalue += character; - index++; + subvalue += character + index++ } - character = value.charAt(index); + character = value.charAt(index) - if (!character || character === C_NEWLINE) { + if (!character || character === lineFeed) { if (silent) { - return true; + return true } - beforeURL = eat(beforeURL).test().end; - url = self.decode.raw(self.unescape(url), beforeURL, {nonTerminated: false}); + beforeURL = eat(beforeURL).test().end + url = self.decode.raw(self.unescape(url), beforeURL, {nonTerminated: false}) if (title) { - beforeTitle = eat(beforeTitle).test().end; - title = self.decode.raw(self.unescape(title), beforeTitle); + beforeTitle = eat(beforeTitle).test().end + title = self.decode.raw(self.unescape(title), beforeTitle) } return eat(subvalue)({ type: 'definition', identifier: normalize(identifier), + label: identifier, title: title || null, url: url - }); + }) } } -/* Check if `character` can be inside an enclosed URI. */ +// Check if `character` can be inside an enclosed URI. function isEnclosedURLCharacter(character) { - return character !== C_GT && - character !== C_BRACKET_OPEN && - character !== C_BRACKET_CLOSE; + return ( + character !== greaterThan && + character !== leftSquareBracket && + character !== rightSquareBracket + ) } -isEnclosedURLCharacter.delimiter = C_GT; +isEnclosedURLCharacter.delimiter = greaterThan -/* Check if `character` can be inside an unclosed URI. */ +// Check if `character` can be inside an unclosed URI. function isUnclosedURLCharacter(character) { - return character !== C_BRACKET_OPEN && - character !== C_BRACKET_CLOSE && - !whitespace(character); + return ( + character !== leftSquareBracket && + character !== rightSquareBracket && + !whitespace(character) + ) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/delete.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/delete.js index ca7c68a8c5c1be..3513634b9557d9 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/delete.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/delete.js @@ -1,60 +1,60 @@ -'use strict'; +'use strict' -var whitespace = require('is-whitespace-character'); -var locate = require('../locate/delete'); +var whitespace = require('is-whitespace-character') +var locate = require('../locate/delete') -module.exports = strikethrough; -strikethrough.locator = locate; +module.exports = strikethrough +strikethrough.locator = locate -var C_TILDE = '~'; -var DOUBLE = '~~'; +var tilde = '~' +var fence = '~~' function strikethrough(eat, value, silent) { - var self = this; - var character = ''; - var previous = ''; - var preceding = ''; - var subvalue = ''; - var index; - var length; - var now; + var self = this + var character = '' + var previous = '' + var preceding = '' + var subvalue = '' + var index + var length + var now if ( !self.options.gfm || - value.charAt(0) !== C_TILDE || - value.charAt(1) !== C_TILDE || + value.charAt(0) !== tilde || + value.charAt(1) !== tilde || whitespace(value.charAt(2)) ) { - return; + return } - index = 1; - length = value.length; - now = eat.now(); - now.column += 2; - now.offset += 2; + index = 1 + length = value.length + now = eat.now() + now.column += 2 + now.offset += 2 while (++index < length) { - character = value.charAt(index); + character = value.charAt(index) if ( - character === C_TILDE && - previous === C_TILDE && + character === tilde && + previous === tilde && (!preceding || !whitespace(preceding)) ) { /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - return eat(DOUBLE + subvalue + DOUBLE)({ + return eat(fence + subvalue + fence)({ type: 'delete', children: self.tokenizeInline(subvalue, now) - }); + }) } - subvalue += previous; - preceding = previous; - previous = character; + subvalue += previous + preceding = previous + previous = character } } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/emphasis.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/emphasis.js index b2c87b4497de38..2cbfd314a3f2a9 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/emphasis.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/emphasis.js @@ -1,85 +1,86 @@ -'use strict'; +'use strict' -var trim = require('trim'); -var word = require('is-word-character'); -var whitespace = require('is-whitespace-character'); -var locate = require('../locate/emphasis'); +var trim = require('trim') +var word = require('is-word-character') +var whitespace = require('is-whitespace-character') +var locate = require('../locate/emphasis') -module.exports = emphasis; -emphasis.locator = locate; +module.exports = emphasis +emphasis.locator = locate -var C_ASTERISK = '*'; -var C_UNDERSCORE = '_'; +var asterisk = '*' +var underscore = '_' +var backslash = '\\' function emphasis(eat, value, silent) { - var self = this; - var index = 0; - var character = value.charAt(index); - var now; - var pedantic; - var marker; - var queue; - var subvalue; - var length; - var prev; - - if (character !== C_ASTERISK && character !== C_UNDERSCORE) { - return; + var self = this + var index = 0 + var character = value.charAt(index) + var now + var pedantic + var marker + var queue + var subvalue + var length + var prev + + if (character !== asterisk && character !== underscore) { + return } - pedantic = self.options.pedantic; - subvalue = character; - marker = character; - length = value.length; - index++; - queue = ''; - character = ''; + pedantic = self.options.pedantic + subvalue = character + marker = character + length = value.length + index++ + queue = '' + character = '' if (pedantic && whitespace(value.charAt(index))) { - return; + return } while (index < length) { - prev = character; - character = value.charAt(index); + prev = character + character = value.charAt(index) if (character === marker && (!pedantic || !whitespace(prev))) { - character = value.charAt(++index); + character = value.charAt(++index) if (character !== marker) { if (!trim(queue) || prev === marker) { - return; + return } - if (!pedantic && marker === C_UNDERSCORE && word(character)) { - queue += marker; - continue; + if (!pedantic && marker === underscore && word(character)) { + queue += marker + continue } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - now = eat.now(); - now.column++; - now.offset++; + now = eat.now() + now.column++ + now.offset++ return eat(subvalue + queue + marker)({ type: 'emphasis', children: self.tokenizeInline(queue, now) - }); + }) } - queue += marker; + queue += marker } - if (!pedantic && character === '\\') { - queue += character; - character = value.charAt(++index); + if (!pedantic && character === backslash) { + queue += character + character = value.charAt(++index) } - queue += character; - index++; + queue += character + index++ } } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/escape.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/escape.js index d6f99bcc10381d..1cac3532aa2c63 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/escape.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/escape.js @@ -1,34 +1,34 @@ -'use strict'; +'use strict' -var locate = require('../locate/escape'); +var locate = require('../locate/escape') -module.exports = escape; -escape.locator = locate; +module.exports = escape +escape.locator = locate + +var lineFeed = '\n' +var backslash = '\\' function escape(eat, value, silent) { - var self = this; - var character; - var node; + var self = this + var character + var node - if (value.charAt(0) === '\\') { - character = value.charAt(1); + if (value.charAt(0) === backslash) { + character = value.charAt(1) if (self.escape.indexOf(character) !== -1) { /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - if (character === '\n') { - node = {type: 'break'}; + if (character === lineFeed) { + node = {type: 'break'} } else { - node = { - type: 'text', - value: character - }; + node = {type: 'text', value: character} } - return eat('\\' + character)(node); + return eat(backslash + character)(node) } } } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/footnote-definition.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/footnote-definition.js index f48ff9bb7eb187..62d8ce7b2c967d 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/footnote-definition.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/footnote-definition.js @@ -1,185 +1,186 @@ -'use strict'; +'use strict' -var whitespace = require('is-whitespace-character'); -var normalize = require('../util/normalize'); +var whitespace = require('is-whitespace-character') +var normalize = require('../util/normalize') -module.exports = footnoteDefinition; -footnoteDefinition.notInList = true; -footnoteDefinition.notInBlock = true; +module.exports = footnoteDefinition +footnoteDefinition.notInList = true +footnoteDefinition.notInBlock = true -var C_BACKSLASH = '\\'; -var C_NEWLINE = '\n'; -var C_TAB = '\t'; -var C_SPACE = ' '; -var C_BRACKET_OPEN = '['; -var C_BRACKET_CLOSE = ']'; -var C_CARET = '^'; -var C_COLON = ':'; +var backslash = '\\' +var lineFeed = '\n' +var tab = '\t' +var space = ' ' +var leftSquareBracket = '[' +var rightSquareBracket = ']' +var caret = '^' +var colon = ':' -var EXPRESSION_INITIAL_TAB = /^( {4}|\t)?/gm; +var EXPRESSION_INITIAL_TAB = /^( {4}|\t)?/gm function footnoteDefinition(eat, value, silent) { - var self = this; - var offsets = self.offset; - var index; - var length; - var subvalue; - var now; - var currentLine; - var content; - var queue; - var subqueue; - var character; - var identifier; - var add; - var exit; + var self = this + var offsets = self.offset + var index + var length + var subvalue + var now + var currentLine + var content + var queue + var subqueue + var character + var identifier + var add + var exit if (!self.options.footnotes) { - return; + return } - index = 0; - length = value.length; - subvalue = ''; - now = eat.now(); - currentLine = now.line; + index = 0 + length = value.length + subvalue = '' + now = eat.now() + currentLine = now.line while (index < length) { - character = value.charAt(index); + character = value.charAt(index) if (!whitespace(character)) { - break; + break } - subvalue += character; - index++; + subvalue += character + index++ } if ( - value.charAt(index) !== C_BRACKET_OPEN || - value.charAt(index + 1) !== C_CARET + value.charAt(index) !== leftSquareBracket || + value.charAt(index + 1) !== caret ) { - return; + return } - subvalue += C_BRACKET_OPEN + C_CARET; - index = subvalue.length; - queue = ''; + subvalue += leftSquareBracket + caret + index = subvalue.length + queue = '' while (index < length) { - character = value.charAt(index); - - if (character === C_BRACKET_CLOSE) { - break; - } else if (character === C_BACKSLASH) { - queue += character; - index++; - character = value.charAt(index); + character = value.charAt(index) + + if (character === rightSquareBracket) { + break + } else if (character === backslash) { + queue += character + index++ + character = value.charAt(index) } - queue += character; - index++; + queue += character + index++ } if ( !queue || - value.charAt(index) !== C_BRACKET_CLOSE || - value.charAt(index + 1) !== C_COLON + value.charAt(index) !== rightSquareBracket || + value.charAt(index + 1) !== colon ) { - return; + return } if (silent) { - return true; + return true } - identifier = normalize(queue); - subvalue += queue + C_BRACKET_CLOSE + C_COLON; - index = subvalue.length; + identifier = queue + subvalue += queue + rightSquareBracket + colon + index = subvalue.length while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character !== C_TAB && character !== C_SPACE) { - break; + if (character !== tab && character !== space) { + break } - subvalue += character; - index++; + subvalue += character + index++ } - now.column += subvalue.length; - now.offset += subvalue.length; - queue = ''; - content = ''; - subqueue = ''; + now.column += subvalue.length + now.offset += subvalue.length + queue = '' + content = '' + subqueue = '' while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character === C_NEWLINE) { - subqueue = character; - index++; + if (character === lineFeed) { + subqueue = character + index++ while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character !== C_NEWLINE) { - break; + if (character !== lineFeed) { + break } - subqueue += character; - index++; + subqueue += character + index++ } - queue += subqueue; - subqueue = ''; + queue += subqueue + subqueue = '' while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character !== C_SPACE) { - break; + if (character !== space) { + break } - subqueue += character; - index++; + subqueue += character + index++ } if (subqueue.length === 0) { - break; + break } - queue += subqueue; + queue += subqueue } if (queue) { - content += queue; - queue = ''; + content += queue + queue = '' } - content += character; - index++; + content += character + index++ } - subvalue += content; + subvalue += content - content = content.replace(EXPRESSION_INITIAL_TAB, function (line) { - offsets[currentLine] = (offsets[currentLine] || 0) + line.length; - currentLine++; + content = content.replace(EXPRESSION_INITIAL_TAB, function(line) { + offsets[currentLine] = (offsets[currentLine] || 0) + line.length + currentLine++ - return ''; - }); + return '' + }) - add = eat(subvalue); + add = eat(subvalue) - exit = self.enterBlock(); - content = self.tokenizeBlock(content, now); - exit(); + exit = self.enterBlock() + content = self.tokenizeBlock(content, now) + exit() return add({ type: 'footnoteDefinition', - identifier: identifier, + identifier: normalize(identifier), + label: identifier, children: content - }); + }) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/heading-atx.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/heading-atx.js index aafeabb54910f6..dfa2849fb77e9b 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/heading-atx.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/heading-atx.js @@ -1,141 +1,135 @@ -'use strict'; +'use strict' -module.exports = atxHeading; +module.exports = atxHeading -var C_NEWLINE = '\n'; -var C_TAB = '\t'; -var C_SPACE = ' '; -var C_HASH = '#'; +var lineFeed = '\n' +var tab = '\t' +var space = ' ' +var numberSign = '#' -var MAX_ATX_COUNT = 6; +var maxFenceCount = 6 function atxHeading(eat, value, silent) { - var self = this; - var settings = self.options; - var length = value.length + 1; - var index = -1; - var now = eat.now(); - var subvalue = ''; - var content = ''; - var character; - var queue; - var depth; - - /* Eat initial spacing. */ + var self = this + var pedantic = self.options.pedantic + var length = value.length + 1 + var index = -1 + var now = eat.now() + var subvalue = '' + var content = '' + var character + var queue + var depth + + // Eat initial spacing. while (++index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character !== C_SPACE && character !== C_TAB) { - index--; - break; + if (character !== space && character !== tab) { + index-- + break } - subvalue += character; + subvalue += character } - /* Eat hashes. */ - depth = 0; + // Eat hashes. + depth = 0 while (++index <= length) { - character = value.charAt(index); + character = value.charAt(index) - if (character !== C_HASH) { - index--; - break; + if (character !== numberSign) { + index-- + break } - subvalue += character; - depth++; + subvalue += character + depth++ } - if (depth > MAX_ATX_COUNT) { - return; + if (depth > maxFenceCount) { + return } - if ( - !depth || - (!settings.pedantic && value.charAt(index + 1) === C_HASH) - ) { - return; + if (!depth || (!pedantic && value.charAt(index + 1) === numberSign)) { + return } - length = value.length + 1; + length = value.length + 1 - /* Eat intermediate white-space. */ - queue = ''; + // Eat intermediate white-space. + queue = '' while (++index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character !== C_SPACE && character !== C_TAB) { - index--; - break; + if (character !== space && character !== tab) { + index-- + break } - queue += character; + queue += character } - /* Exit when not in pedantic mode without spacing. */ - if ( - !settings.pedantic && - queue.length === 0 && - character && - character !== C_NEWLINE - ) { - return; + // Exit when not in pedantic mode without spacing. + if (!pedantic && queue.length === 0 && character && character !== lineFeed) { + return } if (silent) { - return true; + return true } - /* Eat content. */ - subvalue += queue; - queue = ''; - content = ''; + // Eat content. + subvalue += queue + queue = '' + content = '' while (++index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (!character || character === C_NEWLINE) { - break; + if (!character || character === lineFeed) { + break } - if ( - character !== C_SPACE && - character !== C_TAB && - character !== C_HASH - ) { - content += queue + character; - queue = ''; - continue; + if (character !== space && character !== tab && character !== numberSign) { + content += queue + character + queue = '' + continue } - while (character === C_SPACE || character === C_TAB) { - queue += character; - character = value.charAt(++index); + while (character === space || character === tab) { + queue += character + character = value.charAt(++index) } - while (character === C_HASH) { - queue += character; - character = value.charAt(++index); + // `#` without a queue is part of the content. + if (!pedantic && content && !queue && character === numberSign) { + content += character + continue } - while (character === C_SPACE || character === C_TAB) { - queue += character; - character = value.charAt(++index); + while (character === numberSign) { + queue += character + character = value.charAt(++index) } - index--; + while (character === space || character === tab) { + queue += character + character = value.charAt(++index) + } + + index-- } - now.column += subvalue.length; - now.offset += subvalue.length; - subvalue += content + queue; + now.column += subvalue.length + now.offset += subvalue.length + subvalue += content + queue return eat(subvalue)({ type: 'heading', depth: depth, children: self.tokenizeInline(content, now) - }); + }) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/heading-setext.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/heading-setext.js index 96c6130da744e1..1427623458c8b0 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/heading-setext.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/heading-setext.js @@ -1,107 +1,102 @@ -'use strict'; +'use strict' -module.exports = setextHeading; +module.exports = setextHeading -var C_NEWLINE = '\n'; -var C_TAB = '\t'; -var C_SPACE = ' '; -var C_EQUALS = '='; -var C_DASH = '-'; +var lineFeed = '\n' +var tab = '\t' +var space = ' ' +var equalsTo = '=' +var dash = '-' -var MAX_HEADING_INDENT = 3; +var maxIndent = 3 -/* Map of characters which can be used to mark setext - * headers, mapping to their corresponding depth. */ -var SETEXT_MARKERS = {}; - -SETEXT_MARKERS[C_EQUALS] = 1; -SETEXT_MARKERS[C_DASH] = 2; +var equalsToDepth = 1 +var dashDepth = 2 function setextHeading(eat, value, silent) { - var self = this; - var now = eat.now(); - var length = value.length; - var index = -1; - var subvalue = ''; - var content; - var queue; - var character; - var marker; - var depth; - - /* Eat initial indentation. */ + var self = this + var now = eat.now() + var length = value.length + var index = -1 + var subvalue = '' + var content + var queue + var character + var marker + var depth + + // Eat initial indentation. while (++index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character !== C_SPACE || index >= MAX_HEADING_INDENT) { - index--; - break; + if (character !== space || index >= maxIndent) { + index-- + break } - subvalue += character; + subvalue += character } - /* Eat content. */ - content = ''; - queue = ''; + // Eat content. + content = '' + queue = '' while (++index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character === C_NEWLINE) { - index--; - break; + if (character === lineFeed) { + index-- + break } - if (character === C_SPACE || character === C_TAB) { - queue += character; + if (character === space || character === tab) { + queue += character } else { - content += queue + character; - queue = ''; + content += queue + character + queue = '' } } - now.column += subvalue.length; - now.offset += subvalue.length; - subvalue += content + queue; + now.column += subvalue.length + now.offset += subvalue.length + subvalue += content + queue - /* Ensure the content is followed by a newline and a - * valid marker. */ - character = value.charAt(++index); - marker = value.charAt(++index); + // Ensure the content is followed by a newline and a valid marker. + character = value.charAt(++index) + marker = value.charAt(++index) - if (character !== C_NEWLINE || !SETEXT_MARKERS[marker]) { - return; + if (character !== lineFeed || (marker !== equalsTo && marker !== dash)) { + return } - subvalue += character; + subvalue += character - /* Eat Setext-line. */ - queue = marker; - depth = SETEXT_MARKERS[marker]; + // Eat Setext-line. + queue = marker + depth = marker === equalsTo ? equalsToDepth : dashDepth while (++index < length) { - character = value.charAt(index); + character = value.charAt(index) if (character !== marker) { - if (character !== C_NEWLINE) { - return; + if (character !== lineFeed) { + return } - index--; - break; + index-- + break } - queue += character; + queue += character } if (silent) { - return true; + return true } return eat(subvalue + queue)({ type: 'heading', depth: depth, children: self.tokenizeInline(content, now) - }); + }) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/html-block.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/html-block.js index 6e81eb290a3993..149a71860f0460 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/html-block.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/html-block.js @@ -1,94 +1,111 @@ -'use strict'; - -var openCloseTag = require('../util/html').openCloseTag; - -module.exports = blockHTML; - -var C_TAB = '\t'; -var C_SPACE = ' '; -var C_NEWLINE = '\n'; -var C_LT = '<'; - -function blockHTML(eat, value, silent) { - var self = this; - var blocks = self.options.blocks; - var length = value.length; - var index = 0; - var next; - var line; - var offset; - var character; - var count; - var sequence; - var subvalue; +'use strict' + +var openCloseTag = require('../util/html').openCloseTag + +module.exports = blockHtml + +var tab = '\t' +var space = ' ' +var lineFeed = '\n' +var lessThan = '<' + +var rawOpenExpression = /^<(script|pre|style)(?=(\s|>|$))/i +var rawCloseExpression = /<\/(script|pre|style)>/i +var commentOpenExpression = /^/ +var instructionOpenExpression = /^<\?/ +var instructionCloseExpression = /\?>/ +var directiveOpenExpression = /^/ +var cdataOpenExpression = /^/ +var elementCloseExpression = /^$/ +var otherElementOpenExpression = new RegExp(openCloseTag.source + '\\s*$') + +function blockHtml(eat, value, silent) { + var self = this + var blocks = self.options.blocks.join('|') + var elementOpenExpression = new RegExp( + '^|$))', + 'i' + ) + var length = value.length + var index = 0 + var next + var line + var offset + var character + var count + var sequence + var subvalue var sequences = [ - [/^<(script|pre|style)(?=(\s|>|$))/i, /<\/(script|pre|style)>/i, true], - [/^/, true], - [/^<\?/, /\?>/, true], - [/^/, true], - [/^/, true], - [new RegExp('^|$))', 'i'), /^$/, true], - [new RegExp(openCloseTag.source + '\\s*$'), /^$/, false] - ]; - - /* Eat initial spacing. */ + [rawOpenExpression, rawCloseExpression, true], + [commentOpenExpression, commentCloseExpression, true], + [instructionOpenExpression, instructionCloseExpression, true], + [directiveOpenExpression, directiveCloseExpression, true], + [cdataOpenExpression, cdataCloseExpression, true], + [elementOpenExpression, elementCloseExpression, true], + [otherElementOpenExpression, elementCloseExpression, false] + ] + + // Eat initial spacing. while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character !== C_TAB && character !== C_SPACE) { - break; + if (character !== tab && character !== space) { + break } - index++; + index++ } - if (value.charAt(index) !== C_LT) { - return; + if (value.charAt(index) !== lessThan) { + return } - next = value.indexOf(C_NEWLINE, index + 1); - next = next === -1 ? length : next; - line = value.slice(index, next); - offset = -1; - count = sequences.length; + next = value.indexOf(lineFeed, index + 1) + next = next === -1 ? length : next + line = value.slice(index, next) + offset = -1 + count = sequences.length while (++offset < count) { if (sequences[offset][0].test(line)) { - sequence = sequences[offset]; - break; + sequence = sequences[offset] + break } } if (!sequence) { - return; + return } if (silent) { - return sequence[2]; + return sequence[2] } - index = next; + index = next if (!sequence[1].test(line)) { while (index < length) { - next = value.indexOf(C_NEWLINE, index + 1); - next = next === -1 ? length : next; - line = value.slice(index + 1, next); + next = value.indexOf(lineFeed, index + 1) + next = next === -1 ? length : next + line = value.slice(index + 1, next) if (sequence[1].test(line)) { if (line) { - index = next; + index = next } - break; + break } - index = next; + index = next } } - subvalue = value.slice(0, index); + subvalue = value.slice(0, index) - return eat(subvalue)({type: 'html', value: subvalue}); + return eat(subvalue)({type: 'html', value: subvalue}) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/html-inline.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/html-inline.js index c204e962b15ae8..cca4fb40a36341 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/html-inline.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/html-inline.js @@ -1,54 +1,59 @@ -'use strict'; +'use strict' -var alphabetical = require('is-alphabetical'); -var locate = require('../locate/tag'); -var tag = require('../util/html').tag; +var alphabetical = require('is-alphabetical') +var locate = require('../locate/tag') +var tag = require('../util/html').tag -module.exports = inlineHTML; -inlineHTML.locator = locate; +module.exports = inlineHTML +inlineHTML.locator = locate -var EXPRESSION_HTML_LINK_OPEN = /^/i; +var lessThan = '<' +var questionMark = '?' +var exclamationMark = '!' +var slash = '/' + +var htmlLinkOpenExpression = /^/i function inlineHTML(eat, value, silent) { - var self = this; - var length = value.length; - var character; - var subvalue; + var self = this + var length = value.length + var character + var subvalue - if (value.charAt(0) !== '<' || length < 3) { - return; + if (value.charAt(0) !== lessThan || length < 3) { + return } - character = value.charAt(1); + character = value.charAt(1) if ( !alphabetical(character) && - character !== '?' && - character !== '!' && - character !== '/' + character !== questionMark && + character !== exclamationMark && + character !== slash ) { - return; + return } - subvalue = value.match(tag); + subvalue = value.match(tag) if (!subvalue) { - return; + return } /* istanbul ignore if - not used yet. */ if (silent) { - return true; + return true } - subvalue = subvalue[0]; + subvalue = subvalue[0] - if (!self.inLink && EXPRESSION_HTML_LINK_OPEN.test(subvalue)) { - self.inLink = true; - } else if (self.inLink && EXPRESSION_HTML_LINK_CLOSE.test(subvalue)) { - self.inLink = false; + if (!self.inLink && htmlLinkOpenExpression.test(subvalue)) { + self.inLink = true + } else if (self.inLink && htmlLinkCloseExpression.test(subvalue)) { + self.inLink = false } - return eat(subvalue)({type: 'html', value: subvalue}); + return eat(subvalue)({type: 'html', value: subvalue}) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/link.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/link.js index 3ef5e1ba312d75..ab4d3fa3c5af54 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/link.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/link.js @@ -1,392 +1,381 @@ -'use strict'; - -var whitespace = require('is-whitespace-character'); -var locate = require('../locate/link'); - -module.exports = link; -link.locator = locate; - -var own = {}.hasOwnProperty; - -var C_BACKSLASH = '\\'; -var C_BRACKET_OPEN = '['; -var C_BRACKET_CLOSE = ']'; -var C_PAREN_OPEN = '('; -var C_PAREN_CLOSE = ')'; -var C_LT = '<'; -var C_GT = '>'; -var C_TICK = '`'; -var C_DOUBLE_QUOTE = '"'; -var C_SINGLE_QUOTE = '\''; - -/* Map of characters, which can be used to mark link - * and image titles. */ -var LINK_MARKERS = {}; - -LINK_MARKERS[C_DOUBLE_QUOTE] = C_DOUBLE_QUOTE; -LINK_MARKERS[C_SINGLE_QUOTE] = C_SINGLE_QUOTE; - -/* Map of characters, which can be used to mark link - * and image titles in commonmark-mode. */ -var COMMONMARK_LINK_MARKERS = {}; - -COMMONMARK_LINK_MARKERS[C_DOUBLE_QUOTE] = C_DOUBLE_QUOTE; -COMMONMARK_LINK_MARKERS[C_SINGLE_QUOTE] = C_SINGLE_QUOTE; -COMMONMARK_LINK_MARKERS[C_PAREN_OPEN] = C_PAREN_CLOSE; +'use strict' + +var whitespace = require('is-whitespace-character') +var locate = require('../locate/link') + +module.exports = link +link.locator = locate + +var lineFeed = '\n' +var exclamationMark = '!' +var quotationMark = '"' +var apostrophe = "'" +var leftParenthesis = '(' +var rightParenthesis = ')' +var lessThan = '<' +var greaterThan = '>' +var leftSquareBracket = '[' +var backslash = '\\' +var rightSquareBracket = ']' +var graveAccent = '`' function link(eat, value, silent) { - var self = this; - var subvalue = ''; - var index = 0; - var character = value.charAt(0); - var pedantic = self.options.pedantic; - var commonmark = self.options.commonmark; - var gfm = self.options.gfm; - var closed; - var count; - var opening; - var beforeURL; - var beforeTitle; - var subqueue; - var hasMarker; - var markers; - var isImage; - var content; - var marker; - var length; - var title; - var depth; - var queue; - var url; - var now; - var exit; - var node; - - /* Detect whether this is an image. */ - if (character === '!') { - isImage = true; - subvalue = character; - character = value.charAt(++index); + var self = this + var subvalue = '' + var index = 0 + var character = value.charAt(0) + var pedantic = self.options.pedantic + var commonmark = self.options.commonmark + var gfm = self.options.gfm + var closed + var count + var opening + var beforeURL + var beforeTitle + var subqueue + var hasMarker + var isImage + var content + var marker + var length + var title + var depth + var queue + var url + var now + var exit + var node + + // Detect whether this is an image. + if (character === exclamationMark) { + isImage = true + subvalue = character + character = value.charAt(++index) } - /* Eat the opening. */ - if (character !== C_BRACKET_OPEN) { - return; + // Eat the opening. + if (character !== leftSquareBracket) { + return } - /* Exit when this is a link and we’re already inside - * a link. */ + // Exit when this is a link and we’re already inside a link. if (!isImage && self.inLink) { - return; + return } - subvalue += character; - queue = ''; - index++; + subvalue += character + queue = '' + index++ - /* Eat the content. */ - length = value.length; - now = eat.now(); - depth = 0; + // Eat the content. + length = value.length + now = eat.now() + depth = 0 - now.column += index; - now.offset += index; + now.column += index + now.offset += index while (index < length) { - character = value.charAt(index); - subqueue = character; + character = value.charAt(index) + subqueue = character - if (character === C_TICK) { - /* Inline-code in link content. */ - count = 1; + if (character === graveAccent) { + // Inline-code in link content. + count = 1 - while (value.charAt(index + 1) === C_TICK) { - subqueue += character; - index++; - count++; + while (value.charAt(index + 1) === graveAccent) { + subqueue += character + index++ + count++ } if (!opening) { - opening = count; + opening = count } else if (count >= opening) { - opening = 0; + opening = 0 } - } else if (character === C_BACKSLASH) { - /* Allow brackets to be escaped. */ - index++; - subqueue += value.charAt(index); - /* In GFM mode, brackets in code still count. - * In all other modes, they don’t. This empty - * block prevents the next statements are - * entered. */ - } else if ((!opening || gfm) && character === C_BRACKET_OPEN) { - depth++; - } else if ((!opening || gfm) && character === C_BRACKET_CLOSE) { + } else if (character === backslash) { + // Allow brackets to be escaped. + index++ + subqueue += value.charAt(index) + } else if ((!opening || gfm) && character === leftSquareBracket) { + // In GFM mode, brackets in code still count. In all other modes, + // they don’t. + depth++ + } else if ((!opening || gfm) && character === rightSquareBracket) { if (depth) { - depth--; + depth-- } else { - /* Allow white-space between content and - * url in GFM mode. */ + // Allow white-space between content and url in GFM mode. if (!pedantic) { while (index < length) { - character = value.charAt(index + 1); + character = value.charAt(index + 1) if (!whitespace(character)) { - break; + break } - subqueue += character; - index++; + subqueue += character + index++ } } - if (value.charAt(index + 1) !== C_PAREN_OPEN) { - return; + if (value.charAt(index + 1) !== leftParenthesis) { + return } - subqueue += C_PAREN_OPEN; - closed = true; - index++; + subqueue += leftParenthesis + closed = true + index++ - break; + break } } - queue += subqueue; - subqueue = ''; - index++; + queue += subqueue + subqueue = '' + index++ } - /* Eat the content closing. */ + // Eat the content closing. if (!closed) { - return; + return } - content = queue; - subvalue += queue + subqueue; - index++; + content = queue + subvalue += queue + subqueue + index++ - /* Eat white-space. */ + // Eat white-space. while (index < length) { - character = value.charAt(index); + character = value.charAt(index) if (!whitespace(character)) { - break; + break } - subvalue += character; - index++; + subvalue += character + index++ } - /* Eat the URL. */ - character = value.charAt(index); - markers = commonmark ? COMMONMARK_LINK_MARKERS : LINK_MARKERS; - queue = ''; - beforeURL = subvalue; + // Eat the URL. + character = value.charAt(index) + queue = '' + beforeURL = subvalue - if (character === C_LT) { - index++; - beforeURL += C_LT; + if (character === lessThan) { + index++ + beforeURL += lessThan while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character === C_GT) { - break; + if (character === greaterThan) { + break } - if (commonmark && character === '\n') { - return; + if (commonmark && character === lineFeed) { + return } - queue += character; - index++; + queue += character + index++ } - if (value.charAt(index) !== C_GT) { - return; + if (value.charAt(index) !== greaterThan) { + return } - subvalue += C_LT + queue + C_GT; - url = queue; - index++; + subvalue += lessThan + queue + greaterThan + url = queue + index++ } else { - character = null; - subqueue = ''; + character = null + subqueue = '' while (index < length) { - character = value.charAt(index); - - if (subqueue && own.call(markers, character)) { - break; + character = value.charAt(index) + + if ( + subqueue && + (character === quotationMark || + character === apostrophe || + (commonmark && character === leftParenthesis)) + ) { + break } if (whitespace(character)) { if (!pedantic) { - break; + break } - subqueue += character; + subqueue += character } else { - if (character === C_PAREN_OPEN) { - depth++; - } else if (character === C_PAREN_CLOSE) { + if (character === leftParenthesis) { + depth++ + } else if (character === rightParenthesis) { if (depth === 0) { - break; + break } - depth--; + depth-- } - queue += subqueue; - subqueue = ''; + queue += subqueue + subqueue = '' - if (character === C_BACKSLASH) { - queue += C_BACKSLASH; - character = value.charAt(++index); + if (character === backslash) { + queue += backslash + character = value.charAt(++index) } - queue += character; + queue += character } - index++; + index++ } - subvalue += queue; - url = queue; - index = subvalue.length; + subvalue += queue + url = queue + index = subvalue.length } - /* Eat white-space. */ - queue = ''; + // Eat white-space. + queue = '' while (index < length) { - character = value.charAt(index); + character = value.charAt(index) if (!whitespace(character)) { - break; + break } - queue += character; - index++; + queue += character + index++ } - character = value.charAt(index); - subvalue += queue; - - /* Eat the title. */ - if (queue && own.call(markers, character)) { - index++; - subvalue += character; - queue = ''; - marker = markers[character]; - beforeTitle = subvalue; - - /* In commonmark-mode, things are pretty easy: the - * marker cannot occur inside the title. - * - * Non-commonmark does, however, support nested - * delimiters. */ + character = value.charAt(index) + subvalue += queue + + // Eat the title. + if ( + queue && + (character === quotationMark || + character === apostrophe || + (commonmark && character === leftParenthesis)) + ) { + index++ + subvalue += character + queue = '' + marker = character === leftParenthesis ? rightParenthesis : character + beforeTitle = subvalue + + // In commonmark-mode, things are pretty easy: the marker cannot occur + // inside the title. Non-commonmark does, however, support nested + // delimiters. if (commonmark) { while (index < length) { - character = value.charAt(index); + character = value.charAt(index) if (character === marker) { - break; + break } - if (character === C_BACKSLASH) { - queue += C_BACKSLASH; - character = value.charAt(++index); + if (character === backslash) { + queue += backslash + character = value.charAt(++index) } - index++; - queue += character; + index++ + queue += character } - character = value.charAt(index); + character = value.charAt(index) if (character !== marker) { - return; + return } - title = queue; - subvalue += queue + character; - index++; + title = queue + subvalue += queue + character + index++ while (index < length) { - character = value.charAt(index); + character = value.charAt(index) if (!whitespace(character)) { - break; + break } - subvalue += character; - index++; + subvalue += character + index++ } } else { - subqueue = ''; + subqueue = '' while (index < length) { - character = value.charAt(index); + character = value.charAt(index) if (character === marker) { if (hasMarker) { - queue += marker + subqueue; - subqueue = ''; + queue += marker + subqueue + subqueue = '' } - hasMarker = true; + hasMarker = true } else if (!hasMarker) { - queue += character; - } else if (character === C_PAREN_CLOSE) { - subvalue += queue + marker + subqueue; - title = queue; - break; + queue += character + } else if (character === rightParenthesis) { + subvalue += queue + marker + subqueue + title = queue + break } else if (whitespace(character)) { - subqueue += character; + subqueue += character } else { - queue += marker + subqueue + character; - subqueue = ''; - hasMarker = false; + queue += marker + subqueue + character + subqueue = '' + hasMarker = false } - index++; + index++ } } } - if (value.charAt(index) !== C_PAREN_CLOSE) { - return; + if (value.charAt(index) !== rightParenthesis) { + return } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - subvalue += C_PAREN_CLOSE; + subvalue += rightParenthesis - url = self.decode.raw(self.unescape(url), eat(beforeURL).test().end, {nonTerminated: false}); + url = self.decode.raw(self.unescape(url), eat(beforeURL).test().end, { + nonTerminated: false + }) if (title) { - beforeTitle = eat(beforeTitle).test().end; - title = self.decode.raw(self.unescape(title), beforeTitle); + beforeTitle = eat(beforeTitle).test().end + title = self.decode.raw(self.unescape(title), beforeTitle) } node = { type: isImage ? 'image' : 'link', title: title || null, url: url - }; + } if (isImage) { - node.alt = self.decode.raw(self.unescape(content), now) || null; + node.alt = self.decode.raw(self.unescape(content), now) || null } else { - exit = self.enterLink(); - node.children = self.tokenizeInline(content, now); - exit(); + exit = self.enterLink() + node.children = self.tokenizeInline(content, now) + exit() } - return eat(subvalue)(node); + return eat(subvalue)(node) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/list.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/list.js index 9164c8167f8dc1..3eef0d668f0c2c 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/list.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/list.js @@ -1,474 +1,451 @@ -'use strict'; - -/* eslint-disable max-params */ - -var trim = require('trim'); -var repeat = require('repeat-string'); -var decimal = require('is-decimal'); -var getIndent = require('../util/get-indentation'); -var removeIndent = require('../util/remove-indentation'); -var interrupt = require('../util/interrupt'); - -module.exports = list; - -var C_ASTERISK = '*'; -var C_UNDERSCORE = '_'; -var C_PLUS = '+'; -var C_DASH = '-'; -var C_DOT = '.'; -var C_SPACE = ' '; -var C_NEWLINE = '\n'; -var C_TAB = '\t'; -var C_PAREN_CLOSE = ')'; -var C_X_LOWER = 'x'; - -var TAB_SIZE = 4; -var EXPRESSION_LOOSE_LIST_ITEM = /\n\n(?!\s*$)/; -var EXPRESSION_TASK_ITEM = /^\[([ \t]|x|X)][ \t]/; -var EXPRESSION_BULLET = /^([ \t]*)([*+-]|\d+[.)])( {1,4}(?! )| |\t|$|(?=\n))([^\n]*)/; -var EXPRESSION_PEDANTIC_BULLET = /^([ \t]*)([*+-]|\d+[.)])([ \t]+)/; -var EXPRESSION_INITIAL_INDENT = /^( {1,4}|\t)?/gm; - -/* Map of characters which can be used to mark - * list-items. */ -var LIST_UNORDERED_MARKERS = {}; - -LIST_UNORDERED_MARKERS[C_ASTERISK] = true; -LIST_UNORDERED_MARKERS[C_PLUS] = true; -LIST_UNORDERED_MARKERS[C_DASH] = true; - -/* Map of characters which can be used to mark - * list-items after a digit. */ -var LIST_ORDERED_MARKERS = {}; - -LIST_ORDERED_MARKERS[C_DOT] = true; - -/* Map of characters which can be used to mark - * list-items after a digit. */ -var LIST_ORDERED_COMMONMARK_MARKERS = {}; - -LIST_ORDERED_COMMONMARK_MARKERS[C_DOT] = true; -LIST_ORDERED_COMMONMARK_MARKERS[C_PAREN_CLOSE] = true; +'use strict' + +var trim = require('trim') +var repeat = require('repeat-string') +var decimal = require('is-decimal') +var getIndent = require('../util/get-indentation') +var removeIndent = require('../util/remove-indentation') +var interrupt = require('../util/interrupt') + +module.exports = list + +var asterisk = '*' +var underscore = '_' +var plusSign = '+' +var dash = '-' +var dot = '.' +var space = ' ' +var lineFeed = '\n' +var tab = '\t' +var rightParenthesis = ')' +var lowercaseX = 'x' + +var tabSize = 4 +var looseListItemExpression = /\n\n(?!\s*$)/ +var taskItemExpression = /^\[([ \t]|x|X)][ \t]/ +var bulletExpression = /^([ \t]*)([*+-]|\d+[.)])( {1,4}(?! )| |\t|$|(?=\n))([^\n]*)/ +var pedanticBulletExpression = /^([ \t]*)([*+-]|\d+[.)])([ \t]+)/ +var initialIndentExpression = /^( {1,4}|\t)?/gm function list(eat, value, silent) { - var self = this; - var commonmark = self.options.commonmark; - var pedantic = self.options.pedantic; - var tokenizers = self.blockTokenizers; - var interuptors = self.interruptList; - var markers; - var index = 0; - var length = value.length; - var start = null; - var size = 0; - var queue; - var ordered; - var character; - var marker; - var nextIndex; - var startIndex; - var prefixed; - var currentMarker; - var content; - var line; - var prevEmpty; - var empty; - var items; - var allLines; - var emptyLines; - var item; - var enterTop; - var exitBlockquote; - var isLoose; - var node; - var now; - var end; - var indented; + var self = this + var commonmark = self.options.commonmark + var pedantic = self.options.pedantic + var tokenizers = self.blockTokenizers + var interuptors = self.interruptList + var index = 0 + var length = value.length + var start = null + var size = 0 + var queue + var ordered + var character + var marker + var nextIndex + var startIndex + var prefixed + var currentMarker + var content + var line + var prevEmpty + var empty + var items + var allLines + var emptyLines + var item + var enterTop + var exitBlockquote + var spread = false + var node + var now + var end + var indented while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character === C_TAB) { - size += TAB_SIZE - (size % TAB_SIZE); - } else if (character === C_SPACE) { - size++; + if (character === tab) { + size += tabSize - (size % tabSize) + } else if (character === space) { + size++ } else { - break; + break } - index++; + index++ } - if (size >= TAB_SIZE) { - return; + if (size >= tabSize) { + return } - character = value.charAt(index); + character = value.charAt(index) - markers = commonmark ? - LIST_ORDERED_COMMONMARK_MARKERS : - LIST_ORDERED_MARKERS; - - if (LIST_UNORDERED_MARKERS[character] === true) { - marker = character; - ordered = false; + if (character === asterisk || character === plusSign || character === dash) { + marker = character + ordered = false } else { - ordered = true; - queue = ''; + ordered = true + queue = '' while (index < length) { - character = value.charAt(index); + character = value.charAt(index) if (!decimal(character)) { - break; + break } - queue += character; - index++; + queue += character + index++ } - character = value.charAt(index); + character = value.charAt(index) - if (!queue || markers[character] !== true) { - return; + if ( + !queue || + !(character === dot || (commonmark && character === rightParenthesis)) + ) { + return } - start = parseInt(queue, 10); - marker = character; + start = parseInt(queue, 10) + marker = character } - character = value.charAt(++index); + character = value.charAt(++index) - if (character !== C_SPACE && character !== C_TAB) { - return; + if ( + character !== space && + character !== tab && + (pedantic || (character !== lineFeed && character !== '')) + ) { + return } if (silent) { - return true; + return true } - index = 0; - items = []; - allLines = []; - emptyLines = []; + index = 0 + items = [] + allLines = [] + emptyLines = [] while (index < length) { - nextIndex = value.indexOf(C_NEWLINE, index); - startIndex = index; - prefixed = false; - indented = false; + nextIndex = value.indexOf(lineFeed, index) + startIndex = index + prefixed = false + indented = false if (nextIndex === -1) { - nextIndex = length; + nextIndex = length } - end = index + TAB_SIZE; - size = 0; + end = index + tabSize + size = 0 while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character === C_TAB) { - size += TAB_SIZE - (size % TAB_SIZE); - } else if (character === C_SPACE) { - size++; + if (character === tab) { + size += tabSize - (size % tabSize) + } else if (character === space) { + size++ } else { - break; + break } - index++; + index++ } - if (size >= TAB_SIZE) { - indented = true; + if (size >= tabSize) { + indented = true } if (item && size >= item.indent) { - indented = true; + indented = true } - character = value.charAt(index); - currentMarker = null; + character = value.charAt(index) + currentMarker = null if (!indented) { - if (LIST_UNORDERED_MARKERS[character] === true) { - currentMarker = character; - index++; - size++; + if ( + character === asterisk || + character === plusSign || + character === dash + ) { + currentMarker = character + index++ + size++ } else { - queue = ''; + queue = '' while (index < length) { - character = value.charAt(index); + character = value.charAt(index) if (!decimal(character)) { - break; + break } - queue += character; - index++; + queue += character + index++ } - character = value.charAt(index); - index++; + character = value.charAt(index) + index++ - if (queue && markers[character] === true) { - currentMarker = character; - size += queue.length + 1; + if ( + queue && + (character === dot || (commonmark && character === rightParenthesis)) + ) { + currentMarker = character + size += queue.length + 1 } } if (currentMarker) { - character = value.charAt(index); + character = value.charAt(index) - if (character === C_TAB) { - size += TAB_SIZE - (size % TAB_SIZE); - index++; - } else if (character === C_SPACE) { - end = index + TAB_SIZE; + if (character === tab) { + size += tabSize - (size % tabSize) + index++ + } else if (character === space) { + end = index + tabSize while (index < end) { - if (value.charAt(index) !== C_SPACE) { - break; + if (value.charAt(index) !== space) { + break } - index++; - size++; + index++ + size++ } - if (index === end && value.charAt(index) === C_SPACE) { - index -= TAB_SIZE - 1; - size -= TAB_SIZE - 1; + if (index === end && value.charAt(index) === space) { + index -= tabSize - 1 + size -= tabSize - 1 } - } else if (character !== C_NEWLINE && character !== '') { - currentMarker = null; + } else if (character !== lineFeed && character !== '') { + currentMarker = null } } } if (currentMarker) { if (!pedantic && marker !== currentMarker) { - break; + break } - prefixed = true; + prefixed = true } else { - if (!commonmark && !indented && value.charAt(startIndex) === C_SPACE) { - indented = true; + if (!commonmark && !indented && value.charAt(startIndex) === space) { + indented = true } else if (commonmark && item) { - indented = size >= item.indent || size > TAB_SIZE; + indented = size >= item.indent || size > tabSize } - prefixed = false; - index = startIndex; + prefixed = false + index = startIndex } - line = value.slice(startIndex, nextIndex); - content = startIndex === index ? line : value.slice(index, nextIndex); + line = value.slice(startIndex, nextIndex) + content = startIndex === index ? line : value.slice(index, nextIndex) if ( - currentMarker === C_ASTERISK || - currentMarker === C_UNDERSCORE || - currentMarker === C_DASH + currentMarker === asterisk || + currentMarker === underscore || + currentMarker === dash ) { if (tokenizers.thematicBreak.call(self, eat, line, true)) { - break; + break } } - prevEmpty = empty; - empty = !trim(content).length; + prevEmpty = empty + empty = !prefixed && !trim(content).length if (indented && item) { - item.value = item.value.concat(emptyLines, line); - allLines = allLines.concat(emptyLines, line); - emptyLines = []; + item.value = item.value.concat(emptyLines, line) + allLines = allLines.concat(emptyLines, line) + emptyLines = [] } else if (prefixed) { if (emptyLines.length !== 0) { - item.value.push(''); - item.trail = emptyLines.concat(); + spread = true + item.value.push('') + item.trail = emptyLines.concat() } item = { value: [line], indent: size, trail: [] - }; + } - items.push(item); - allLines = allLines.concat(emptyLines, line); - emptyLines = []; + items.push(item) + allLines = allLines.concat(emptyLines, line) + emptyLines = [] } else if (empty) { - if (prevEmpty) { - break; + if (prevEmpty && !commonmark) { + break } - emptyLines.push(line); + emptyLines.push(line) } else { if (prevEmpty) { - break; + break } if (interrupt(interuptors, tokenizers, self, [eat, line, true])) { - break; + break } - item.value = item.value.concat(emptyLines, line); - allLines = allLines.concat(emptyLines, line); - emptyLines = []; + item.value = item.value.concat(emptyLines, line) + allLines = allLines.concat(emptyLines, line) + emptyLines = [] } - index = nextIndex + 1; + index = nextIndex + 1 } - node = eat(allLines.join(C_NEWLINE)).reset({ + node = eat(allLines.join(lineFeed)).reset({ type: 'list', ordered: ordered, start: start, - loose: null, + spread: spread, children: [] - }); + }) - enterTop = self.enterList(); - exitBlockquote = self.enterBlock(); - isLoose = false; - index = -1; - length = items.length; + enterTop = self.enterList() + exitBlockquote = self.enterBlock() + index = -1 + length = items.length while (++index < length) { - item = items[index].value.join(C_NEWLINE); - now = eat.now(); + item = items[index].value.join(lineFeed) + now = eat.now() - item = eat(item)(listItem(self, item, now), node); + eat(item)(listItem(self, item, now), node) - if (item.loose) { - isLoose = true; - } - - item = items[index].trail.join(C_NEWLINE); + item = items[index].trail.join(lineFeed) if (index !== length - 1) { - item += C_NEWLINE; + item += lineFeed } - eat(item); + eat(item) } - enterTop(); - exitBlockquote(); + enterTop() + exitBlockquote() - node.loose = isLoose; - - return node; + return node } function listItem(ctx, value, position) { - var offsets = ctx.offset; - var fn = ctx.options.pedantic ? pedanticListItem : normalListItem; - var checked = null; - var task; - var indent; + var offsets = ctx.offset + var fn = ctx.options.pedantic ? pedanticListItem : normalListItem + var checked = null + var task + var indent - value = fn.apply(null, arguments); + value = fn.apply(null, arguments) if (ctx.options.gfm) { - task = value.match(EXPRESSION_TASK_ITEM); + task = value.match(taskItemExpression) if (task) { - indent = task[0].length; - checked = task[1].toLowerCase() === C_X_LOWER; - offsets[position.line] += indent; - value = value.slice(indent); + indent = task[0].length + checked = task[1].toLowerCase() === lowercaseX + offsets[position.line] += indent + value = value.slice(indent) } } return { type: 'listItem', - loose: EXPRESSION_LOOSE_LIST_ITEM.test(value) || - value.charAt(value.length - 1) === C_NEWLINE, + spread: looseListItemExpression.test(value), checked: checked, children: ctx.tokenizeBlock(value, position) - }; + } } -/* Create a list-item using overly simple mechanics. */ +// Create a list-item using overly simple mechanics. function pedanticListItem(ctx, value, position) { - var offsets = ctx.offset; - var line = position.line; + var offsets = ctx.offset + var line = position.line - /* Remove the list-item’s bullet. */ - value = value.replace(EXPRESSION_PEDANTIC_BULLET, replacer); + // Remove the list-item’s bullet. + value = value.replace(pedanticBulletExpression, replacer) - /* The initial line was also matched by the below, so - * we reset the `line`. */ - line = position.line; + // The initial line was also matched by the below, so we reset the `line`. + line = position.line - return value.replace(EXPRESSION_INITIAL_INDENT, replacer); + return value.replace(initialIndentExpression, replacer) - /* A simple replacer which removed all matches, - * and adds their length to `offset`. */ + // A simple replacer which removed all matches, and adds their length to + // `offset`. function replacer($0) { - offsets[line] = (offsets[line] || 0) + $0.length; - line++; + offsets[line] = (offsets[line] || 0) + $0.length + line++ - return ''; + return '' } } -/* Create a list-item using sane mechanics. */ +// Create a list-item using sane mechanics. function normalListItem(ctx, value, position) { - var offsets = ctx.offset; - var line = position.line; - var max; - var bullet; - var rest; - var lines; - var trimmedLines; - var index; - var length; + var offsets = ctx.offset + var line = position.line + var max + var bullet + var rest + var lines + var trimmedLines + var index + var length - /* Remove the list-item’s bullet. */ - value = value.replace(EXPRESSION_BULLET, replacer); + // Remove the list-item’s bullet. + value = value.replace(bulletExpression, replacer) - lines = value.split(C_NEWLINE); + lines = value.split(lineFeed) - trimmedLines = removeIndent(value, getIndent(max).indent).split(C_NEWLINE); + trimmedLines = removeIndent(value, getIndent(max).indent).split(lineFeed) - /* We replaced the initial bullet with something - * else above, which was used to trick - * `removeIndentation` into removing some more - * characters when possible. However, that could - * result in the initial line to be stripped more - * than it should be. */ - trimmedLines[0] = rest; + // We replaced the initial bullet with something else above, which was used + // to trick `removeIndentation` into removing some more characters when + // possible. However, that could result in the initial line to be stripped + // more than it should be. + trimmedLines[0] = rest - offsets[line] = (offsets[line] || 0) + bullet.length; - line++; + offsets[line] = (offsets[line] || 0) + bullet.length + line++ - index = 0; - length = lines.length; + index = 0 + length = lines.length while (++index < length) { - offsets[line] = (offsets[line] || 0) + - lines[index].length - trimmedLines[index].length; - line++; + offsets[line] = + (offsets[line] || 0) + lines[index].length - trimmedLines[index].length + line++ } - return trimmedLines.join(C_NEWLINE); + return trimmedLines.join(lineFeed) + /* eslint-disable-next-line max-params */ function replacer($0, $1, $2, $3, $4) { - bullet = $1 + $2 + $3; - rest = $4; + bullet = $1 + $2 + $3 + rest = $4 - /* Make sure that the first nine numbered list items - * can indent with an extra space. That is, when - * the bullet did not receive an extra final space. */ + // Make sure that the first nine numbered list items can indent with an + // extra space. That is, when the bullet did not receive an extra final + // space. if (Number($2) < 10 && bullet.length % 2 === 1) { - $2 = C_SPACE + $2; + $2 = space + $2 } - max = $1 + repeat(C_SPACE, $2.length) + $3; + max = $1 + repeat(space, $2.length) + $3 - return max + rest; + return max + rest } } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/newline.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/newline.js index 6008670cc5e742..680020cf09f47d 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/newline.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/newline.js @@ -1,47 +1,48 @@ -'use strict'; +'use strict' -var whitespace = require('is-whitespace-character'); +var whitespace = require('is-whitespace-character') -module.exports = newline; +module.exports = newline + +var lineFeed = '\n' -/* Tokenise newline. */ function newline(eat, value, silent) { - var character = value.charAt(0); - var length; - var subvalue; - var queue; - var index; - - if (character !== '\n') { - return; + var character = value.charAt(0) + var length + var subvalue + var queue + var index + + if (character !== lineFeed) { + return } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - index = 1; - length = value.length; - subvalue = character; - queue = ''; + index = 1 + length = value.length + subvalue = character + queue = '' while (index < length) { - character = value.charAt(index); + character = value.charAt(index) if (!whitespace(character)) { - break; + break } - queue += character; + queue += character - if (character === '\n') { - subvalue += queue; - queue = ''; + if (character === lineFeed) { + subvalue += queue + queue = '' } - index++; + index++ } - eat(subvalue); + eat(subvalue) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/paragraph.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/paragraph.js index 1492a027e78237..13db0ff4065cde 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/paragraph.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/paragraph.js @@ -1,122 +1,117 @@ -'use strict'; +'use strict' -var trim = require('trim'); -var decimal = require('is-decimal'); -var trimTrailingLines = require('trim-trailing-lines'); -var interrupt = require('../util/interrupt'); +var trim = require('trim') +var decimal = require('is-decimal') +var trimTrailingLines = require('trim-trailing-lines') +var interrupt = require('../util/interrupt') -module.exports = paragraph; +module.exports = paragraph -var C_NEWLINE = '\n'; -var C_TAB = '\t'; -var C_SPACE = ' '; +var tab = '\t' +var lineFeed = '\n' +var space = ' ' -var TAB_SIZE = 4; +var tabSize = 4 -/* Tokenise paragraph. */ +// Tokenise paragraph. function paragraph(eat, value, silent) { - var self = this; - var settings = self.options; - var commonmark = settings.commonmark; - var gfm = settings.gfm; - var tokenizers = self.blockTokenizers; - var interruptors = self.interruptParagraph; - var index = value.indexOf(C_NEWLINE); - var length = value.length; - var position; - var subvalue; - var character; - var size; - var now; + var self = this + var settings = self.options + var commonmark = settings.commonmark + var gfm = settings.gfm + var tokenizers = self.blockTokenizers + var interruptors = self.interruptParagraph + var index = value.indexOf(lineFeed) + var length = value.length + var position + var subvalue + var character + var size + var now while (index < length) { - /* Eat everything if there’s no following newline. */ + // Eat everything if there’s no following newline. if (index === -1) { - index = length; - break; + index = length + break } - /* Stop if the next character is NEWLINE. */ - if (value.charAt(index + 1) === C_NEWLINE) { - break; + // Stop if the next character is NEWLINE. + if (value.charAt(index + 1) === lineFeed) { + break } - /* In commonmark-mode, following indented lines - * are part of the paragraph. */ + // In commonmark-mode, following indented lines are part of the paragraph. if (commonmark) { - size = 0; - position = index + 1; + size = 0 + position = index + 1 while (position < length) { - character = value.charAt(position); + character = value.charAt(position) - if (character === C_TAB) { - size = TAB_SIZE; - break; - } else if (character === C_SPACE) { - size++; + if (character === tab) { + size = tabSize + break + } else if (character === space) { + size++ } else { - break; + break } - position++; + position++ } - if (size >= TAB_SIZE) { - index = value.indexOf(C_NEWLINE, index + 1); - continue; + if (size >= tabSize && character !== lineFeed) { + index = value.indexOf(lineFeed, index + 1) + continue } } - subvalue = value.slice(index + 1); + subvalue = value.slice(index + 1) - /* Check if the following code contains a possible - * block. */ + // Check if the following code contains a possible block. if (interrupt(interruptors, tokenizers, self, [eat, subvalue, true])) { - break; + break } - /* Break if the following line starts a list, when - * already in a list, or when in commonmark, or when - * in gfm mode and the bullet is *not* numeric. */ + // Break if the following line starts a list, when already in a list, or + // when in commonmark, or when in gfm mode and the bullet is *not* numeric. if ( tokenizers.list.call(self, eat, subvalue, true) && - ( - self.inList || + (self.inList || commonmark || - (gfm && !decimal(trim.left(subvalue).charAt(0))) - ) + (gfm && !decimal(trim.left(subvalue).charAt(0)))) ) { - break; + break } - position = index; - index = value.indexOf(C_NEWLINE, index + 1); + position = index + index = value.indexOf(lineFeed, index + 1) if (index !== -1 && trim(value.slice(position, index)) === '') { - index = position; - break; + index = position + break } } - subvalue = value.slice(0, index); + subvalue = value.slice(0, index) if (trim(subvalue) === '') { - eat(subvalue); + eat(subvalue) - return null; + return null } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - now = eat.now(); - subvalue = trimTrailingLines(subvalue); + now = eat.now() + subvalue = trimTrailingLines(subvalue) return eat(subvalue)({ type: 'paragraph', children: self.tokenizeInline(subvalue, now) - }); + }) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/reference.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/reference.js index 50713f1ccfc8fa..fdf753f73198e8 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/reference.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/reference.js @@ -1,206 +1,221 @@ -'use strict'; - -var whitespace = require('is-whitespace-character'); -var locate = require('../locate/link'); -var normalize = require('../util/normalize'); - -module.exports = reference; -reference.locator = locate; - -var T_LINK = 'link'; -var T_IMAGE = 'image'; -var T_FOOTNOTE = 'footnote'; -var REFERENCE_TYPE_SHORTCUT = 'shortcut'; -var REFERENCE_TYPE_COLLAPSED = 'collapsed'; -var REFERENCE_TYPE_FULL = 'full'; -var C_CARET = '^'; -var C_BACKSLASH = '\\'; -var C_BRACKET_OPEN = '['; -var C_BRACKET_CLOSE = ']'; +'use strict' + +var whitespace = require('is-whitespace-character') +var locate = require('../locate/link') +var normalize = require('../util/normalize') + +module.exports = reference +reference.locator = locate + +var link = 'link' +var image = 'image' +var footnote = 'footnote' +var shortcut = 'shortcut' +var collapsed = 'collapsed' +var full = 'full' +var space = ' ' +var exclamationMark = '!' +var leftSquareBracket = '[' +var backslash = '\\' +var rightSquareBracket = ']' +var caret = '^' function reference(eat, value, silent) { - var self = this; - var character = value.charAt(0); - var index = 0; - var length = value.length; - var subvalue = ''; - var intro = ''; - var type = T_LINK; - var referenceType = REFERENCE_TYPE_SHORTCUT; - var content; - var identifier; - var now; - var node; - var exit; - var queue; - var bracketed; - var depth; - - /* Check whether we’re eating an image. */ - if (character === '!') { - type = T_IMAGE; - intro = character; - character = value.charAt(++index); + var self = this + var commonmark = self.options.commonmark + var footnotes = self.options.footnotes + var character = value.charAt(0) + var index = 0 + var length = value.length + var subvalue = '' + var intro = '' + var type = link + var referenceType = shortcut + var content + var identifier + var now + var node + var exit + var queue + var bracketed + var depth + + // Check whether we’re eating an image. + if (character === exclamationMark) { + type = image + intro = character + character = value.charAt(++index) } - if (character !== C_BRACKET_OPEN) { - return; + if (character !== leftSquareBracket) { + return } - index++; - intro += character; - queue = ''; + index++ + intro += character + queue = '' - /* Check whether we’re eating a footnote. */ - if (self.options.footnotes && value.charAt(index) === C_CARET) { - /* Exit if `![^` is found, so the `!` will be seen as text after this, - * and we’ll enter this function again when `[^` is found. */ - if (type === T_IMAGE) { - return; + // Check whether we’re eating a footnote. + if (footnotes && value.charAt(index) === caret) { + // Exit if `![^` is found, so the `!` will be seen as text after this, + // and we’ll enter this function again when `[^` is found. + if (type === image) { + return } - intro += C_CARET; - index++; - type = T_FOOTNOTE; + intro += caret + index++ + type = footnote } - /* Eat the text. */ - depth = 0; + // Eat the text. + depth = 0 while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character === C_BRACKET_OPEN) { - bracketed = true; - depth++; - } else if (character === C_BRACKET_CLOSE) { + if (character === leftSquareBracket) { + bracketed = true + depth++ + } else if (character === rightSquareBracket) { if (!depth) { - break; + break } - depth--; + depth-- } - if (character === C_BACKSLASH) { - queue += C_BACKSLASH; - character = value.charAt(++index); + if (character === backslash) { + queue += backslash + character = value.charAt(++index) } - queue += character; - index++; + queue += character + index++ } - subvalue = queue; - content = queue; - character = value.charAt(index); + subvalue = queue + content = queue + character = value.charAt(index) - if (character !== C_BRACKET_CLOSE) { - return; + if (character !== rightSquareBracket) { + return } - index++; - subvalue += character; - queue = ''; + index++ + subvalue += character + queue = '' - while (index < length) { - character = value.charAt(index); + if (!commonmark) { + // The original markdown syntax definition explicitly allows for whitespace + // between the link text and link label; commonmark departs from this, in + // part to improve support for shortcut reference links + while (index < length) { + character = value.charAt(index) - if (!whitespace(character)) { - break; - } + if (!whitespace(character)) { + break + } - queue += character; - index++; + queue += character + index++ + } } - character = value.charAt(index); + character = value.charAt(index) - /* Inline footnotes cannot have an identifier. */ - if (type !== T_FOOTNOTE && character === C_BRACKET_OPEN) { - identifier = ''; - queue += character; - index++; + // Inline footnotes cannot have a label. + // If footnotes are enabled, link labels cannot start with a caret. + if ( + type !== footnote && + character === leftSquareBracket && + (!footnotes || value.charAt(index + 1) !== caret) + ) { + identifier = '' + queue += character + index++ while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character === C_BRACKET_OPEN || character === C_BRACKET_CLOSE) { - break; + if (character === leftSquareBracket || character === rightSquareBracket) { + break } - if (character === C_BACKSLASH) { - identifier += C_BACKSLASH; - character = value.charAt(++index); + if (character === backslash) { + identifier += backslash + character = value.charAt(++index) } - identifier += character; - index++; + identifier += character + index++ } - character = value.charAt(index); + character = value.charAt(index) - if (character === C_BRACKET_CLOSE) { - referenceType = identifier ? REFERENCE_TYPE_FULL : REFERENCE_TYPE_COLLAPSED; - queue += identifier + character; - index++; + if (character === rightSquareBracket) { + referenceType = identifier ? full : collapsed + queue += identifier + character + index++ } else { - identifier = ''; + identifier = '' } - subvalue += queue; - queue = ''; + subvalue += queue + queue = '' } else { if (!content) { - return; + return } - identifier = content; + identifier = content } - /* Brackets cannot be inside the identifier. */ - if (referenceType !== REFERENCE_TYPE_FULL && bracketed) { - return; + // Brackets cannot be inside the identifier. + if (referenceType !== full && bracketed) { + return } - subvalue = intro + subvalue; + subvalue = intro + subvalue - if (type === T_LINK && self.inLink) { - return null; + if (type === link && self.inLink) { + return null } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - if (type === T_FOOTNOTE && content.indexOf(' ') !== -1) { + if (type === footnote && content.indexOf(space) !== -1) { return eat(subvalue)({ - type: 'footnote', + type: footnote, children: this.tokenizeInline(content, eat.now()) - }); + }) } - now = eat.now(); - now.column += intro.length; - now.offset += intro.length; - identifier = referenceType === REFERENCE_TYPE_FULL ? identifier : content; + now = eat.now() + now.column += intro.length + now.offset += intro.length + identifier = referenceType === full ? identifier : content node = { type: type + 'Reference', - identifier: normalize(identifier) - }; + identifier: normalize(identifier), + label: identifier + } - if (type === T_LINK || type === T_IMAGE) { - node.referenceType = referenceType; + if (type === link || type === image) { + node.referenceType = referenceType } - if (type === T_LINK) { - exit = self.enterLink(); - node.children = self.tokenizeInline(content, now); - exit(); - } else if (type === T_IMAGE) { - node.alt = self.decode.raw(self.unescape(content), now) || null; + if (type === link) { + exit = self.enterLink() + node.children = self.tokenizeInline(content, now) + exit() + } else if (type === image) { + node.alt = self.decode.raw(self.unescape(content), now) || null } - return eat(subvalue)(node); + return eat(subvalue)(node) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/strong.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/strong.js index 12d5785bc64a74..3e36462a774aa2 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/strong.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/strong.js @@ -1,84 +1,85 @@ -'use strict'; +'use strict' -var trim = require('trim'); -var whitespace = require('is-whitespace-character'); -var locate = require('../locate/strong'); +var trim = require('trim') +var whitespace = require('is-whitespace-character') +var locate = require('../locate/strong') -module.exports = strong; -strong.locator = locate; +module.exports = strong +strong.locator = locate -var C_ASTERISK = '*'; -var C_UNDERSCORE = '_'; +var backslash = '\\' +var asterisk = '*' +var underscore = '_' function strong(eat, value, silent) { - var self = this; - var index = 0; - var character = value.charAt(index); - var now; - var pedantic; - var marker; - var queue; - var subvalue; - var length; - var prev; + var self = this + var index = 0 + var character = value.charAt(index) + var now + var pedantic + var marker + var queue + var subvalue + var length + var prev if ( - (character !== C_ASTERISK && character !== C_UNDERSCORE) || + (character !== asterisk && character !== underscore) || value.charAt(++index) !== character ) { - return; + return } - pedantic = self.options.pedantic; - marker = character; - subvalue = marker + marker; - length = value.length; - index++; - queue = ''; - character = ''; + pedantic = self.options.pedantic + marker = character + subvalue = marker + marker + length = value.length + index++ + queue = '' + character = '' if (pedantic && whitespace(value.charAt(index))) { - return; + return } while (index < length) { - prev = character; - character = value.charAt(index); + prev = character + character = value.charAt(index) if ( character === marker && value.charAt(index + 1) === marker && (!pedantic || !whitespace(prev)) ) { - character = value.charAt(index + 2); + character = value.charAt(index + 2) if (character !== marker) { if (!trim(queue)) { - return; + return } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - now = eat.now(); - now.column += 2; - now.offset += 2; + now = eat.now() + now.column += 2 + now.offset += 2 return eat(subvalue + queue + subvalue)({ type: 'strong', children: self.tokenizeInline(queue, now) - }); + }) } } - if (!pedantic && character === '\\') { - queue += character; - character = value.charAt(++index); + if (!pedantic && character === backslash) { + queue += character + character = value.charAt(++index) } - queue += character; - index++; + queue += character + index++ } } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/table.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/table.js index ce93b1d22f0f31..ba165d78e8336c 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/table.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/table.js @@ -1,266 +1,232 @@ -'use strict'; +'use strict' -var whitespace = require('is-whitespace-character'); +var whitespace = require('is-whitespace-character') -module.exports = table; +module.exports = table -var C_BACKSLASH = '\\'; -var C_TICK = '`'; -var C_DASH = '-'; -var C_PIPE = '|'; -var C_COLON = ':'; -var C_SPACE = ' '; -var C_NEWLINE = '\n'; -var C_TAB = '\t'; +var tab = '\t' +var lineFeed = '\n' +var space = ' ' +var dash = '-' +var colon = ':' +var backslash = '\\' +var verticalBar = '|' -var MIN_TABLE_COLUMNS = 1; -var MIN_TABLE_ROWS = 2; +var minColumns = 1 +var minRows = 2 -var TABLE_ALIGN_LEFT = 'left'; -var TABLE_ALIGN_CENTER = 'center'; -var TABLE_ALIGN_RIGHT = 'right'; -var TABLE_ALIGN_NONE = null; +var left = 'left' +var center = 'center' +var right = 'right' function table(eat, value, silent) { - var self = this; - var index; - var alignments; - var alignment; - var subvalue; - var row; - var length; - var lines; - var queue; - var character; - var hasDash; - var align; - var cell; - var preamble; - var count; - var opening; - var now; - var position; - var lineCount; - var line; - var rows; - var table; - var lineIndex; - var pipeIndex; - var first; - - /* Exit when not in gfm-mode. */ + var self = this + var index + var alignments + var alignment + var subvalue + var row + var length + var lines + var queue + var character + var hasDash + var align + var cell + var preamble + var now + var position + var lineCount + var line + var rows + var table + var lineIndex + var pipeIndex + var first + + // Exit when not in gfm-mode. if (!self.options.gfm) { - return; + return } - /* Get the rows. - * Detecting tables soon is hard, so there are some - * checks for performance here, such as the minimum - * number of rows, and allowed characters in the - * alignment row. */ - index = 0; - lineCount = 0; - length = value.length + 1; - lines = []; + // Get the rows. + // Detecting tables soon is hard, so there are some checks for performance + // here, such as the minimum number of rows, and allowed characters in the + // alignment row. + index = 0 + lineCount = 0 + length = value.length + 1 + lines = [] while (index < length) { - lineIndex = value.indexOf(C_NEWLINE, index); - pipeIndex = value.indexOf(C_PIPE, index + 1); + lineIndex = value.indexOf(lineFeed, index) + pipeIndex = value.indexOf(verticalBar, index + 1) if (lineIndex === -1) { - lineIndex = value.length; + lineIndex = value.length } if (pipeIndex === -1 || pipeIndex > lineIndex) { - if (lineCount < MIN_TABLE_ROWS) { - return; + if (lineCount < minRows) { + return } - break; + break } - lines.push(value.slice(index, lineIndex)); - lineCount++; - index = lineIndex + 1; + lines.push(value.slice(index, lineIndex)) + lineCount++ + index = lineIndex + 1 } - /* Parse the alignment row. */ - subvalue = lines.join(C_NEWLINE); - alignments = lines.splice(1, 1)[0] || []; - index = 0; - length = alignments.length; - lineCount--; - alignment = false; - align = []; + // Parse the alignment row. + subvalue = lines.join(lineFeed) + alignments = lines.splice(1, 1)[0] || [] + index = 0 + length = alignments.length + lineCount-- + alignment = false + align = [] while (index < length) { - character = alignments.charAt(index); + character = alignments.charAt(index) - if (character === C_PIPE) { - hasDash = null; + if (character === verticalBar) { + hasDash = null if (alignment === false) { if (first === false) { - return; + return } } else { - align.push(alignment); - alignment = false; + align.push(alignment) + alignment = false } - first = false; - } else if (character === C_DASH) { - hasDash = true; - alignment = alignment || TABLE_ALIGN_NONE; - } else if (character === C_COLON) { - if (alignment === TABLE_ALIGN_LEFT) { - alignment = TABLE_ALIGN_CENTER; - } else if (hasDash && alignment === TABLE_ALIGN_NONE) { - alignment = TABLE_ALIGN_RIGHT; + first = false + } else if (character === dash) { + hasDash = true + alignment = alignment || null + } else if (character === colon) { + if (alignment === left) { + alignment = center + } else if (hasDash && alignment === null) { + alignment = right } else { - alignment = TABLE_ALIGN_LEFT; + alignment = left } } else if (!whitespace(character)) { - return; + return } - index++; + index++ } if (alignment !== false) { - align.push(alignment); + align.push(alignment) } - /* Exit when without enough columns. */ - if (align.length < MIN_TABLE_COLUMNS) { - return; + // Exit when without enough columns. + if (align.length < minColumns) { + return } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - /* Parse the rows. */ - position = -1; - rows = []; + // Parse the rows. + position = -1 + rows = [] - table = eat(subvalue).reset({ - type: 'table', - align: align, - children: rows - }); + table = eat(subvalue).reset({type: 'table', align: align, children: rows}) while (++position < lineCount) { - line = lines[position]; - row = {type: 'tableRow', children: []}; + line = lines[position] + row = {type: 'tableRow', children: []} - /* Eat a newline character when this is not the - * first row. */ + // Eat a newline character when this is not the first row. if (position) { - eat(C_NEWLINE); + eat(lineFeed) } - /* Eat the row. */ - eat(line).reset(row, table); + // Eat the row. + eat(line).reset(row, table) - length = line.length + 1; - index = 0; - queue = ''; - cell = ''; - preamble = true; - count = null; - opening = null; + length = line.length + 1 + index = 0 + queue = '' + cell = '' + preamble = true while (index < length) { - character = line.charAt(index); + character = line.charAt(index) - if (character === C_TAB || character === C_SPACE) { + if (character === tab || character === space) { if (cell) { - queue += character; + queue += character } else { - eat(character); + eat(character) } - index++; - continue; + index++ + continue } - if (character === '' || character === C_PIPE) { + if (character === '' || character === verticalBar) { if (preamble) { - eat(character); + eat(character) } else { - if (character && opening) { - queue += character; - index++; - continue; - } - if ((cell || character) && !preamble) { - subvalue = cell; + subvalue = cell if (queue.length > 1) { if (character) { - subvalue += queue.slice(0, queue.length - 1); - queue = queue.charAt(queue.length - 1); + subvalue += queue.slice(0, queue.length - 1) + queue = queue.charAt(queue.length - 1) } else { - subvalue += queue; - queue = ''; + subvalue += queue + queue = '' } } - now = eat.now(); + now = eat.now() - eat(subvalue)({ - type: 'tableCell', - children: self.tokenizeInline(cell, now) - }, row); + eat(subvalue)( + {type: 'tableCell', children: self.tokenizeInline(cell, now)}, + row + ) } - eat(queue + character); + eat(queue + character) - queue = ''; - cell = ''; + queue = '' + cell = '' } } else { if (queue) { - cell += queue; - queue = ''; - } - - cell += character; - - if (character === C_BACKSLASH && index !== length - 2) { - cell += line.charAt(index + 1); - index++; + cell += queue + queue = '' } - if (character === C_TICK) { - count = 1; - - while (line.charAt(index + 1) === character) { - cell += character; - index++; - count++; - } + cell += character - if (!opening) { - opening = count; - } else if (count >= opening) { - opening = 0; - } + if (character === backslash && index !== length - 2) { + cell += line.charAt(index + 1) + index++ } } - preamble = false; - index++; + preamble = false + index++ } - /* Eat the alignment row. */ + // Eat the alignment row. if (!position) { - eat(C_NEWLINE + alignments); + eat(lineFeed + alignments) } } - return table; + return table } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/text.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/text.js index 4aedfa90d5d9b8..c9085ee3011d0e 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/text.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/text.js @@ -1,58 +1,57 @@ -'use strict'; +'use strict' -module.exports = text; +module.exports = text function text(eat, value, silent) { - var self = this; - var methods; - var tokenizers; - var index; - var length; - var subvalue; - var position; - var tokenizer; - var name; - var min; - var now; + var self = this + var methods + var tokenizers + var index + var length + var subvalue + var position + var tokenizer + var name + var min + var now /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - methods = self.inlineMethods; - length = methods.length; - tokenizers = self.inlineTokenizers; - index = -1; - min = value.length; + methods = self.inlineMethods + length = methods.length + tokenizers = self.inlineTokenizers + index = -1 + min = value.length while (++index < length) { - name = methods[index]; + name = methods[index] if (name === 'text' || !tokenizers[name]) { - continue; + continue } - tokenizer = tokenizers[name].locator; + tokenizer = tokenizers[name].locator if (!tokenizer) { - eat.file.fail('Missing locator: `' + name + '`'); + eat.file.fail('Missing locator: `' + name + '`') } - position = tokenizer.call(self, value, 1); + position = tokenizer.call(self, value, 1) if (position !== -1 && position < min) { - min = position; + min = position } } - subvalue = value.slice(0, min); - now = eat.now(); + subvalue = value.slice(0, min) + now = eat.now() - self.decode(subvalue, now, function (content, position, source) { - eat(source || content)({ - type: 'text', - value: content - }); - }); + self.decode(subvalue, now, handler) + + function handler(content, position, source) { + eat(source || content)({type: 'text', value: content}) + } } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/thematic-break.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/thematic-break.js index 2391e3f592cb25..6844c8c705af8c 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/thematic-break.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/thematic-break.js @@ -1,70 +1,70 @@ -'use strict'; +'use strict' -module.exports = thematicBreak; +module.exports = thematicBreak -var C_NEWLINE = '\n'; -var C_TAB = '\t'; -var C_SPACE = ' '; -var C_ASTERISK = '*'; -var C_UNDERSCORE = '_'; -var C_DASH = '-'; +var tab = '\t' +var lineFeed = '\n' +var space = ' ' +var asterisk = '*' +var dash = '-' +var underscore = '_' -var THEMATIC_BREAK_MARKER_COUNT = 3; +var maxCount = 3 function thematicBreak(eat, value, silent) { - var index = -1; - var length = value.length + 1; - var subvalue = ''; - var character; - var marker; - var markerCount; - var queue; + var index = -1 + var length = value.length + 1 + var subvalue = '' + var character + var marker + var markerCount + var queue while (++index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (character !== C_TAB && character !== C_SPACE) { - break; + if (character !== tab && character !== space) { + break } - subvalue += character; + subvalue += character } if ( - character !== C_ASTERISK && - character !== C_DASH && - character !== C_UNDERSCORE + character !== asterisk && + character !== dash && + character !== underscore ) { - return; + return } - marker = character; - subvalue += character; - markerCount = 1; - queue = ''; + marker = character + subvalue += character + markerCount = 1 + queue = '' while (++index < length) { - character = value.charAt(index); + character = value.charAt(index) if (character === marker) { - markerCount++; - subvalue += queue + marker; - queue = ''; - } else if (character === C_SPACE) { - queue += character; + markerCount++ + subvalue += queue + marker + queue = '' + } else if (character === space) { + queue += character } else if ( - markerCount >= THEMATIC_BREAK_MARKER_COUNT && - (!character || character === C_NEWLINE) + markerCount >= maxCount && + (!character || character === lineFeed) ) { - subvalue += queue; + subvalue += queue if (silent) { - return true; + return true } - return eat(subvalue)({type: 'thematicBreak'}); + return eat(subvalue)({type: 'thematicBreak'}) } else { - return; + return } } } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/url.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/url.js index 297940bf4ab922..92d1c6229bb27c 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/url.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenize/url.js @@ -1,144 +1,153 @@ -'use strict'; +'use strict' -var decode = require('parse-entities'); -var whitespace = require('is-whitespace-character'); -var locate = require('../locate/url'); +var decode = require('parse-entities') +var whitespace = require('is-whitespace-character') +var locate = require('../locate/url') -module.exports = url; -url.locator = locate; -url.notInLink = true; +module.exports = url +url.locator = locate +url.notInLink = true -var C_BRACKET_OPEN = '['; -var C_BRACKET_CLOSE = ']'; -var C_PAREN_OPEN = '('; -var C_PAREN_CLOSE = ')'; -var C_LT = '<'; -var C_AT_SIGN = '@'; +var quotationMark = '"' +var apostrophe = "'" +var leftParenthesis = '(' +var rightParenthesis = ')' +var comma = ',' +var dot = '.' +var colon = ':' +var semicolon = ';' +var lessThan = '<' +var atSign = '@' +var leftSquareBracket = '[' +var rightSquareBracket = ']' -var HTTP_PROTOCOL = 'http://'; -var HTTPS_PROTOCOL = 'https://'; -var MAILTO_PROTOCOL = 'mailto:'; +var http = 'http://' +var https = 'https://' +var mailto = 'mailto:' -var PROTOCOLS = [ - HTTP_PROTOCOL, - HTTPS_PROTOCOL, - MAILTO_PROTOCOL -]; +var protocols = [http, https, mailto] -var PROTOCOLS_LENGTH = PROTOCOLS.length; +var protocolsLength = protocols.length function url(eat, value, silent) { - var self = this; - var subvalue; - var content; - var character; - var index; - var position; - var protocol; - var match; - var length; - var queue; - var parenCount; - var nextCharacter; - var exit; + var self = this + var subvalue + var content + var character + var index + var position + var protocol + var match + var length + var queue + var parenCount + var nextCharacter + var tokenizers + var exit if (!self.options.gfm) { - return; + return } - subvalue = ''; - index = -1; - length = PROTOCOLS_LENGTH; + subvalue = '' + index = -1 - while (++index < length) { - protocol = PROTOCOLS[index]; - match = value.slice(0, protocol.length); + while (++index < protocolsLength) { + protocol = protocols[index] + match = value.slice(0, protocol.length) if (match.toLowerCase() === protocol) { - subvalue = match; - break; + subvalue = match + break } } if (!subvalue) { - return; + return } - index = subvalue.length; - length = value.length; - queue = ''; - parenCount = 0; + index = subvalue.length + length = value.length + queue = '' + parenCount = 0 while (index < length) { - character = value.charAt(index); + character = value.charAt(index) - if (whitespace(character) || character === C_LT) { - break; + if (whitespace(character) || character === lessThan) { + break } if ( - character === '.' || - character === ',' || - character === ':' || - character === ';' || - character === '"' || - character === '\'' || - character === ')' || - character === ']' + character === dot || + character === comma || + character === colon || + character === semicolon || + character === quotationMark || + character === apostrophe || + character === rightParenthesis || + character === rightSquareBracket ) { - nextCharacter = value.charAt(index + 1); + nextCharacter = value.charAt(index + 1) if (!nextCharacter || whitespace(nextCharacter)) { - break; + break } } - if (character === C_PAREN_OPEN || character === C_BRACKET_OPEN) { - parenCount++; + if (character === leftParenthesis || character === leftSquareBracket) { + parenCount++ } - if (character === C_PAREN_CLOSE || character === C_BRACKET_CLOSE) { - parenCount--; + if (character === rightParenthesis || character === rightSquareBracket) { + parenCount-- if (parenCount < 0) { - break; + break } } - queue += character; - index++; + queue += character + index++ } if (!queue) { - return; + return } - subvalue += queue; - content = subvalue; + subvalue += queue + content = subvalue - if (protocol === MAILTO_PROTOCOL) { - position = queue.indexOf(C_AT_SIGN); + if (protocol === mailto) { + position = queue.indexOf(atSign) if (position === -1 || position === length - 1) { - return; + return } - content = content.substr(MAILTO_PROTOCOL.length); + content = content.slice(mailto.length) } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - exit = self.enterLink(); - content = self.tokenizeInline(content, eat.now()); - exit(); + exit = self.enterLink() + + // Temporarily remove all tokenizers except text in url. + tokenizers = self.inlineTokenizers + self.inlineTokenizers = {text: tokenizers.text} + + content = self.tokenizeInline(content, eat.now()) + + self.inlineTokenizers = tokenizers + exit() return eat(subvalue)({ type: 'link', title: null, url: decode(subvalue, {nonTerminated: false}), children: content - }); + }) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenizer.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenizer.js index 498ef22ad949af..a4e2b4cf965090 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenizer.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/tokenizer.js @@ -1,95 +1,50 @@ -'use strict'; +'use strict' -module.exports = factory; +module.exports = factory -var MERGEABLE_NODES = { - text: mergeText, - blockquote: mergeBlockquote -}; - -/* Check whether a node is mergeable with adjacent nodes. */ -function mergeable(node) { - var start; - var end; - - if (node.type !== 'text' || !node.position) { - return true; - } - - start = node.position.start; - end = node.position.end; - - /* Only merge nodes which occupy the same size as their - * `value`. */ - return start.line !== end.line || - end.column - start.column === node.value.length; -} - -/* Merge two text nodes: `node` into `prev`. */ -function mergeText(prev, node) { - prev.value += node.value; - - return prev; -} - -/* Merge two blockquotes: `node` into `prev`, unless in - * CommonMark mode. */ -function mergeBlockquote(prev, node) { - if (this.options.commonmark) { - return node; - } - - prev.children = prev.children.concat(node.children); - - return prev; -} - -/* Construct a tokenizer. This creates both - * `tokenizeInline` and `tokenizeBlock`. */ +// Construct a tokenizer. This creates both `tokenizeInline` and `tokenizeBlock`. function factory(type) { - return tokenize; + return tokenize - /* Tokenizer for a bound `type`. */ + // Tokenizer for a bound `type`. function tokenize(value, location) { - var self = this; - var offset = self.offset; - var tokens = []; - var methods = self[type + 'Methods']; - var tokenizers = self[type + 'Tokenizers']; - var line = location.line; - var column = location.column; - var index; - var length; - var method; - var name; - var matched; - var valueLength; - - /* Trim white space only lines. */ + var self = this + var offset = self.offset + var tokens = [] + var methods = self[type + 'Methods'] + var tokenizers = self[type + 'Tokenizers'] + var line = location.line + var column = location.column + var index + var length + var method + var name + var matched + var valueLength + + // Trim white space only lines. if (!value) { - return tokens; + return tokens } - /* Expose on `eat`. */ - eat.now = now; - eat.file = self.file; + // Expose on `eat`. + eat.now = now + eat.file = self.file - /* Sync initial offset. */ - updatePosition(''); + // Sync initial offset. + updatePosition('') - /* Iterate over `value`, and iterate over all - * tokenizers. When one eats something, re-iterate - * with the remaining value. If no tokenizer eats, - * something failed (should not happen) and an - * exception is thrown. */ + // Iterate over `value`, and iterate over all tokenizers. When one eats + // something, re-iterate with the remaining value. If no tokenizer eats, + // something failed (should not happen) and an exception is thrown. while (value) { - index = -1; - length = methods.length; - matched = false; + index = -1 + length = methods.length + matched = false while (++index < length) { - name = methods[index]; - method = tokenizers[name]; + name = methods[index] + method = tokenizers[name] if ( method && @@ -98,234 +53,262 @@ function factory(type) { (!method.notInBlock || !self.inBlock) && (!method.notInLink || !self.inLink) ) { - valueLength = value.length; + valueLength = value.length - method.apply(self, [eat, value]); + method.apply(self, [eat, value]) - matched = valueLength !== value.length; + matched = valueLength !== value.length if (matched) { - break; + break } } } /* istanbul ignore if */ if (!matched) { - self.file.fail(new Error('Infinite loop'), eat.now()); + self.file.fail(new Error('Infinite loop'), eat.now()) } } - self.eof = now(); + self.eof = now() - return tokens; + return tokens - /* Update line, column, and offset based on - * `value`. */ + // Update line, column, and offset based on `value`. function updatePosition(subvalue) { - var lastIndex = -1; - var index = subvalue.indexOf('\n'); + var lastIndex = -1 + var index = subvalue.indexOf('\n') while (index !== -1) { - line++; - lastIndex = index; - index = subvalue.indexOf('\n', index + 1); + line++ + lastIndex = index + index = subvalue.indexOf('\n', index + 1) } if (lastIndex === -1) { - column += subvalue.length; + column += subvalue.length } else { - column = subvalue.length - lastIndex; + column = subvalue.length - lastIndex } if (line in offset) { if (lastIndex !== -1) { - column += offset[line]; + column += offset[line] } else if (column <= offset[line]) { - column = offset[line] + 1; + column = offset[line] + 1 } } } - /* Get offset. Called before the first character is - * eaten to retrieve the range's offsets. */ + // Get offset. Called before the first character is eaten to retrieve the + // range’s offsets. function getOffset() { - var indentation = []; - var pos = line + 1; + var indentation = [] + var pos = line + 1 - /* Done. Called when the last character is - * eaten to retrieve the range’s offsets. */ - return function () { - var last = line + 1; + // Done. Called when the last character is eaten to retrieve the range’s + // offsets. + return function() { + var last = line + 1 while (pos < last) { - indentation.push((offset[pos] || 0) + 1); + indentation.push((offset[pos] || 0) + 1) - pos++; + pos++ } - return indentation; - }; + return indentation + } } - /* Get the current position. */ + // Get the current position. function now() { - var pos = {line: line, column: column}; + var pos = {line: line, column: column} - pos.offset = self.toOffset(pos); + pos.offset = self.toOffset(pos) - return pos; + return pos } - /* Store position information for a node. */ + // Store position information for a node. function Position(start) { - this.start = start; - this.end = now(); + this.start = start + this.end = now() } - /* Throw when a value is incorrectly eaten. - * This shouldn’t happen but will throw on new, - * incorrect rules. */ + // Throw when a value is incorrectly eaten. This shouldn’t happen but will + // throw on new, incorrect rules. function validateEat(subvalue) { /* istanbul ignore if */ - if (value.substring(0, subvalue.length) !== subvalue) { - /* Capture stack-trace. */ + if (value.slice(0, subvalue.length) !== subvalue) { + // Capture stack-trace. self.file.fail( new Error( - 'Incorrectly eaten value: please report this ' + - 'warning on http://git.io/vg5Ft' + 'Incorrectly eaten value: please report this warning on https://git.io/vg5Ft' ), now() - ); + ) } } - /* Mark position and patch `node.position`. */ + // Mark position and patch `node.position`. function position() { - var before = now(); + var before = now() - return update; + return update - /* Add the position to a node. */ + // Add the position to a node. function update(node, indent) { - var prev = node.position; - var start = prev ? prev.start : before; - var combined = []; - var n = prev && prev.end.line; - var l = before.line; - - node.position = new Position(start); - - /* If there was already a `position`, this - * node was merged. Fixing `start` wasn’t - * hard, but the indent is different. - * Especially because some information, the - * indent between `n` and `l` wasn’t - * tracked. Luckily, that space is - * (should be?) empty, so we can safely - * check for it now. */ + var prev = node.position + var start = prev ? prev.start : before + var combined = [] + var n = prev && prev.end.line + var l = before.line + + node.position = new Position(start) + + // If there was already a `position`, this node was merged. Fixing + // `start` wasn’t hard, but the indent is different. Especially + // because some information, the indent between `n` and `l` wasn’t + // tracked. Luckily, that space is (should be?) empty, so we can + // safely check for it now. if (prev && indent && prev.indent) { - combined = prev.indent; + combined = prev.indent if (n < l) { while (++n < l) { - combined.push((offset[n] || 0) + 1); + combined.push((offset[n] || 0) + 1) } - combined.push(before.column); + combined.push(before.column) } - indent = combined.concat(indent); + indent = combined.concat(indent) } - node.position.indent = indent || []; + node.position.indent = indent || [] - return node; + return node } } - /* Add `node` to `parent`s children or to `tokens`. - * Performs merges where possible. */ + // Add `node` to `parent`s children or to `tokens`. Performs merges where + // possible. function add(node, parent) { - var children = parent ? parent.children : tokens; - var prev = children[children.length - 1]; + var children = parent ? parent.children : tokens + var prev = children[children.length - 1] + var fn if ( prev && node.type === prev.type && - node.type in MERGEABLE_NODES && + (node.type === 'text' || node.type === 'blockquote') && mergeable(prev) && mergeable(node) ) { - node = MERGEABLE_NODES[node.type].call(self, prev, node); + fn = node.type === 'text' ? mergeText : mergeBlockquote + node = fn.call(self, prev, node) } if (node !== prev) { - children.push(node); + children.push(node) } if (self.atStart && tokens.length !== 0) { - self.exitStart(); + self.exitStart() } - return node; + return node } - /* Remove `subvalue` from `value`. - * `subvalue` must be at the start of `value`. */ + // Remove `subvalue` from `value`. `subvalue` must be at the start of + // `value`. function eat(subvalue) { - var indent = getOffset(); - var pos = position(); - var current = now(); + var indent = getOffset() + var pos = position() + var current = now() - validateEat(subvalue); + validateEat(subvalue) - apply.reset = reset; - reset.test = test; - apply.test = test; + apply.reset = reset + reset.test = test + apply.test = test - value = value.substring(subvalue.length); + value = value.slice(subvalue.length) - updatePosition(subvalue); + updatePosition(subvalue) - indent = indent(); + indent = indent() - return apply; + return apply - /* Add the given arguments, add `position` to - * the returned node, and return the node. */ + // Add the given arguments, add `position` to the returned node, and + // return the node. function apply(node, parent) { - return pos(add(pos(node), parent), indent); + return pos(add(pos(node), parent), indent) } - /* Functions just like apply, but resets the - * content: the line and column are reversed, - * and the eaten value is re-added. - * This is useful for nodes with a single - * type of content, such as lists and tables. - * See `apply` above for what parameters are - * expected. */ + // Functions just like apply, but resets the content: the line and + // column are reversed, and the eaten value is re-added. This is + // useful for nodes with a single type of content, such as lists and + // tables. See `apply` above for what parameters are expected. function reset() { - var node = apply.apply(null, arguments); + var node = apply.apply(null, arguments) - line = current.line; - column = current.column; - value = subvalue + value; + line = current.line + column = current.column + value = subvalue + value - return node; + return node } - /* Test the position, after eating, and reverse - * to a not-eaten state. */ + // Test the position, after eating, and reverse to a not-eaten state. function test() { - var result = pos({}); + var result = pos({}) - line = current.line; - column = current.column; - value = subvalue + value; + line = current.line + column = current.column + value = subvalue + value - return result.position; + return result.position } } } } + +// Check whether a node is mergeable with adjacent nodes. +function mergeable(node) { + var start + var end + + if (node.type !== 'text' || !node.position) { + return true + } + + start = node.position.start + end = node.position.end + + // Only merge nodes which occupy the same size as their `value`. + return ( + start.line !== end.line || end.column - start.column === node.value.length + ) +} + +// Merge two text nodes: `node` into `prev`. +function mergeText(prev, node) { + prev.value += node.value + + return prev +} + +// Merge two blockquotes: `node` into `prev`, unless in CommonMark or gfm modes. +function mergeBlockquote(prev, node) { + if (this.options.commonmark || this.options.gfm) { + return node + } + + prev.children = prev.children.concat(node.children) + + return prev +} diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/unescape.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/unescape.js index 321900e7eacd73..90cdb74c09925b 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/unescape.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/unescape.js @@ -1,37 +1,36 @@ -'use strict'; +'use strict' -module.exports = factory; +module.exports = factory -/* Factory to de-escape a value, based on a list at `key` - * in `ctx`. */ +var backslash = '\\' + +// Factory to de-escape a value, based on a list at `key` in `ctx`. function factory(ctx, key) { - return unescape; + return unescape - /* De-escape a string using the expression at `key` - * in `ctx`. */ + // De-escape a string using the expression at `key` in `ctx`. function unescape(value) { - var prev = 0; - var index = value.indexOf('\\'); - var escape = ctx[key]; - var queue = []; - var character; + var prev = 0 + var index = value.indexOf(backslash) + var escape = ctx[key] + var queue = [] + var character while (index !== -1) { - queue.push(value.slice(prev, index)); - prev = index + 1; - character = value.charAt(prev); + queue.push(value.slice(prev, index)) + prev = index + 1 + character = value.charAt(prev) - /* If the following character is not a valid escape, - * add the slash. */ + // If the following character is not a valid escape, add the slash. if (!character || escape.indexOf(character) === -1) { - queue.push('\\'); + queue.push(backslash) } - index = value.indexOf('\\', prev); + index = value.indexOf(backslash, prev + 1) } - queue.push(value.slice(prev)); + queue.push(value.slice(prev)) - return queue.join(''); + return queue.join('') } } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/get-indentation.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/get-indentation.js index 3e09e1411ed67c..5ab3efd73f7d00 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/get-indentation.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/get-indentation.js @@ -1,32 +1,33 @@ -'use strict'; +'use strict' -module.exports = indentation; +module.exports = indentation -/* Map of characters, and their column length, - * which can be used as indentation. */ -var characters = {' ': 1, '\t': 4}; +var tab = '\t' +var space = ' ' -/* Gets indentation information for a line. */ +var spaceSize = 1 +var tabSize = 4 + +// Gets indentation information for a line. function indentation(value) { - var index = 0; - var indent = 0; - var character = value.charAt(index); - var stops = {}; - var size; + var index = 0 + var indent = 0 + var character = value.charAt(index) + var stops = {} + var size - while (character in characters) { - size = characters[character]; + while (character === tab || character === space) { + size = character === tab ? tabSize : spaceSize - indent += size; + indent += size if (size > 1) { - indent = Math.floor(indent / size) * size; + indent = Math.floor(indent / size) * size } - stops[indent] = index; - - character = value.charAt(++index); + stops[indent] = index + character = value.charAt(++index) } - return {indent: indent, stops: stops}; + return {indent: indent, stops: stops} } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/html.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/html.js index 5f211f13f8f534..49b7a38fca1746 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/html.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/html.js @@ -1,25 +1,34 @@ -'use strict'; +'use strict' -var attributeName = '[a-zA-Z_:][a-zA-Z0-9:._-]*'; -var unquoted = '[^"\'=<>`\\u0000-\\u0020]+'; -var singleQuoted = '\'[^\']*\''; -var doubleQuoted = '"[^"]*"'; -var attributeValue = '(?:' + unquoted + '|' + singleQuoted + '|' + doubleQuoted + ')'; -var attribute = '(?:\\s+' + attributeName + '(?:\\s*=\\s*' + attributeValue + ')?)'; -var openTag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>'; -var closeTag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>'; -var comment = '|'; -var processing = '<[?].*?[?]>'; -var declaration = ']*>'; -var cdata = ''; +var attributeName = '[a-zA-Z_:][a-zA-Z0-9:._-]*' +var unquoted = '[^"\'=<>`\\u0000-\\u0020]+' +var singleQuoted = "'[^']*'" +var doubleQuoted = '"[^"]*"' +var attributeValue = + '(?:' + unquoted + '|' + singleQuoted + '|' + doubleQuoted + ')' +var attribute = + '(?:\\s+' + attributeName + '(?:\\s*=\\s*' + attributeValue + ')?)' +var openTag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>' +var closeTag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>' +var comment = '|' +var processing = '<[?].*?[?]>' +var declaration = ']*>' +var cdata = '' -exports.openCloseTag = new RegExp('^(?:' + openTag + '|' + closeTag + ')'); +exports.openCloseTag = new RegExp('^(?:' + openTag + '|' + closeTag + ')') -exports.tag = new RegExp('^(?:' + - openTag + '|' + - closeTag + '|' + - comment + '|' + - processing + '|' + - declaration + '|' + - cdata + -')'); +exports.tag = new RegExp( + '^(?:' + + openTag + + '|' + + closeTag + + '|' + + comment + + '|' + + processing + + '|' + + declaration + + '|' + + cdata + + ')' +) diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/interrupt.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/interrupt.js index e3178ab45c60df..e707c8b13c394d 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/interrupt.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/interrupt.js @@ -1,43 +1,35 @@ -'use strict'; +'use strict' -module.exports = interrupt; +module.exports = interrupt function interrupt(interruptors, tokenizers, ctx, params) { - var bools = ['pedantic', 'commonmark']; - var count = bools.length; - var length = interruptors.length; - var index = -1; - var interruptor; - var config; - var fn; - var offset; - var bool; - var ignore; + var length = interruptors.length + var index = -1 + var interruptor + var config while (++index < length) { - interruptor = interruptors[index]; - config = interruptor[1] || {}; - fn = interruptor[0]; - offset = -1; - ignore = false; - - while (++offset < count) { - bool = bools[offset]; - - if (config[bool] !== undefined && config[bool] !== ctx.options[bool]) { - ignore = true; - break; - } + interruptor = interruptors[index] + config = interruptor[1] || {} + + if ( + config.pedantic !== undefined && + config.pedantic !== ctx.options.pedantic + ) { + continue } - if (ignore) { - continue; + if ( + config.commonmark !== undefined && + config.commonmark !== ctx.options.commonmark + ) { + continue } - if (tokenizers[fn].apply(ctx, params)) { - return true; + if (tokenizers[interruptor[0]].apply(ctx, params)) { + return true } } - return false; + return false } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/is-markdown-whitespace-character.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/is-markdown-whitespace-character.js new file mode 100644 index 00000000000000..ff6f4bbd4b91ed --- /dev/null +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/is-markdown-whitespace-character.js @@ -0,0 +1,27 @@ +'use strict' + +module.exports = whitespace + +var tab = 9 // '\t' +var lineFeed = 10 // '\n' +var lineTabulation = 11 // '\v' +var formFeed = 12 // '\f' +var carriageReturn = 13 // '\r' +var space = 32 // ' ' + +function whitespace(char) { + /* istanbul ignore next - `number` handling for future */ + var code = typeof char === 'number' ? char : char.charCodeAt(0) + + switch (code) { + case tab: + case lineFeed: + case lineTabulation: + case formFeed: + case carriageReturn: + case space: + return true + default: + return false + } +} diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/normalize.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/normalize.js index 846ceeecac5ade..7057c0a1e5e737 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/normalize.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/normalize.js @@ -1,11 +1,11 @@ -'use strict'; +'use strict' -var collapseWhiteSpace = require('collapse-white-space'); +var collapseWhiteSpace = require('collapse-white-space') -module.exports = normalize; +module.exports = normalize -/* Normalize an identifier. Collapses multiple white space - * characters into a single space, and removes casing. */ +// Normalize an identifier. Collapses multiple white space characters into a +// single space, and removes casing. function normalize(value) { - return collapseWhiteSpace(value).toLowerCase(); + return collapseWhiteSpace(value).toLowerCase() } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/remove-indentation.js b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/remove-indentation.js index 20f18be74087eb..06b6a781dfd61f 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/remove-indentation.js +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/lib/util/remove-indentation.js @@ -1,59 +1,59 @@ -'use strict'; +'use strict' -var trim = require('trim'); -var repeat = require('repeat-string'); -var getIndent = require('./get-indentation'); +var trim = require('trim') +var repeat = require('repeat-string') +var getIndent = require('./get-indentation') -module.exports = indentation; +module.exports = indentation -var C_SPACE = ' '; -var C_NEWLINE = '\n'; -var C_TAB = '\t'; +var tab = '\t' +var lineFeed = '\n' +var space = ' ' +var exclamationMark = '!' -/* Remove the minimum indent from every line in `value`. - * Supports both tab, spaced, and mixed indentation (as - * well as possible). */ +// Remove the minimum indent from every line in `value`. Supports both tab, +// spaced, and mixed indentation (as well as possible). function indentation(value, maximum) { - var values = value.split(C_NEWLINE); - var position = values.length + 1; - var minIndent = Infinity; - var matrix = []; - var index; - var indentation; - var stops; - var padding; + var values = value.split(lineFeed) + var position = values.length + 1 + var minIndent = Infinity + var matrix = [] + var index + var indentation + var stops + var padding - values.unshift(repeat(C_SPACE, maximum) + '!'); + values.unshift(repeat(space, maximum) + exclamationMark) while (position--) { - indentation = getIndent(values[position]); + indentation = getIndent(values[position]) - matrix[position] = indentation.stops; + matrix[position] = indentation.stops if (trim(values[position]).length === 0) { - continue; + continue } if (indentation.indent) { if (indentation.indent > 0 && indentation.indent < minIndent) { - minIndent = indentation.indent; + minIndent = indentation.indent } } else { - minIndent = Infinity; + minIndent = Infinity - break; + break } } if (minIndent !== Infinity) { - position = values.length; + position = values.length while (position--) { - stops = matrix[position]; - index = minIndent; + stops = matrix[position] + index = minIndent while (index && !(index in stops)) { - index--; + index-- } if ( @@ -61,18 +61,17 @@ function indentation(value, maximum) { minIndent && index !== minIndent ) { - padding = C_TAB; + padding = tab } else { - padding = ''; + padding = '' } - values[position] = padding + values[position].slice( - index in stops ? stops[index] + 1 : 0 - ); + values[position] = + padding + values[position].slice(index in stops ? stops[index] + 1 : 0) } } - values.shift(); + values.shift() - return values.join(C_NEWLINE); + return values.join(lineFeed) } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/package.json b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/package.json index 822420cb25200a..e5fc0656ccf665 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/package.json +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/package.json @@ -1,27 +1,40 @@ { "name": "remark-parse", - "version": "5.0.0", - "description": "Markdown parser for remark", + "version": "7.0.2", + "description": "remark plugin to parse Markdown", "license": "MIT", "keywords": [ + "unified", + "remark", + "plugin", "markdown", + "mdast", "abstract", "syntax", "tree", "ast", "parse" ], - "homepage": "http://remark.js.org", + "types": "types/index.d.ts", + "homepage": "https://remark.js.org", "repository": "https://github.com/remarkjs/remark/tree/master/packages/remark-parse", "bugs": "https://github.com/remarkjs/remark/issues", - "author": "Titus Wormer (http://wooorm.com)", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + }, + "author": "Titus Wormer (https://wooorm.com)", "contributors": [ - "Titus Wormer (http://wooorm.com)", - "Eugene Sharygin " + "Titus Wormer (https://wooorm.com)", + "Eugene Sharygin ", + "Junyoung Choi ", + "Elijah Hamovitz ", + "Ika " ], "files": [ "index.js", - "lib" + "lib", + "types/index.d.ts" ], "dependencies": { "collapse-white-space": "^1.0.2", @@ -40,5 +53,8 @@ "vfile-location": "^2.0.0", "xtend": "^4.0.1" }, + "scripts": { + "test": "tape test.js" + }, "xo": false } diff --git a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/readme.md b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/readme.md index ecaa6c093c0ab2..f9d1e8ae5751a4 100644 --- a/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/readme.md +++ b/tools/node_modules/eslint-plugin-markdown/node_modules/remark-parse/readme.md @@ -1,11 +1,54 @@ -# remark-parse [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status] [![Chat][chat-badge]][chat] - -[Parser][] for [**unified**][unified]. Parses markdown to an -[**MDAST**][mdast] syntax tree. Used in the [**remark** -processor][processor]. Can be [extended][extend] to change how -markdown is parsed. - -## Installation +# remark-parse + +[![Build][build-badge]][build] +[![Coverage][coverage-badge]][coverage] +[![Downloads][downloads-badge]][downloads] +[![Size][size-badge]][size] +[![Sponsors][sponsors-badge]][collective] +[![Backers][backers-badge]][collective] +[![Chat][chat-badge]][chat] + +[Parser][] for [**unified**][unified]. +Parses Markdown to [**mdast**][mdast] syntax trees. +Used in the [**remark** processor][remark] but can be used on its own as well. +Can be [extended][extend] to change how markdown is parsed. + +## Sponsors + + + + + + + + + + + +
      + +

      🥇 + ZEIT +
      + +

      🥇 + Gatsby +
      + +

      🥇 + Netlify +
      + +

      + Holloway +
      +



      + You? +
      + +[**Read more about the unified collective on Medium »**][announcement] + +## Install [npm][]: @@ -13,97 +56,110 @@ markdown is parsed. npm install remark-parse ``` -## Usage +## Use ```js -var unified = require('unified'); -var createStream = require('unified-stream'); -var markdown = require('remark-parse'); -var html = require('remark-html'); +var unified = require('unified') +var createStream = require('unified-stream') +var markdown = require('remark-parse') +var remark2rehype = require('remark-rehype') +var html = require('rehype-stringify') var processor = unified() .use(markdown, {commonmark: true}) + .use(remark2rehype) .use(html) -process.stdin - .pipe(createStream(processor)) - .pipe(process.stdout); +process.stdin.pipe(createStream(processor)).pipe(process.stdout) ``` +[See **unified** for more examples »][unified] + ## Table of Contents * [API](#api) - * [processor.use(parse\[, options\])](#processoruseparse-options) - * [parse.Parser](#parseparser) + * [`processor().use(parse[, options])`](#processoruseparse-options) + * [`parse.Parser`](#parseparser) * [Extending the Parser](#extending-the-parser) - * [Parser#blockTokenizers](#parserblocktokenizers) - * [Parser#blockMethods](#parserblockmethods) - * [Parser#inlineTokenizers](#parserinlinetokenizers) - * [Parser#inlineMethods](#parserinlinemethods) - * [function tokenizer(eat, value, silent)](#function-tokenizereat-value-silent) - * [tokenizer.locator(value, fromIndex)](#tokenizerlocatorvalue-fromindex) - * [eat(subvalue)](#eatsubvalue) - * [add(node\[, parent\])](#addnode-parent) - * [add.test()](#addtest) - * [add.reset(node\[, parent\])](#addresetnode-parent) + * [`Parser#blockTokenizers`](#parserblocktokenizers) + * [`Parser#blockMethods`](#parserblockmethods) + * [`Parser#inlineTokenizers`](#parserinlinetokenizers) + * [`Parser#inlineMethods`](#parserinlinemethods) + * [`function tokenizer(eat, value, silent)`](#function-tokenizereat-value-silent) + * [`tokenizer.locator(value, fromIndex)`](#tokenizerlocatorvalue-fromindex) + * [`eat(subvalue)`](#eatsubvalue) + * [`add(node[, parent])`](#addnode-parent) + * [`add.test()`](#addtest) + * [`add.reset(node[, parent])`](#addresetnode-parent) * [Turning off a tokenizer](#turning-off-a-tokenizer) +* [Security](#security) +* [Contribute](#contribute) * [License](#license) ## API -### `processor.use(parse[, options])` +[See **unified** for API docs »][unified] + +### `processor().use(parse[, options])` -Configure the `processor` to read markdown as input and process an -[**MDAST**][mdast] syntax tree. +Configure the `processor` to read Markdown as input and process +[**mdast**][mdast] syntax trees. ##### `options` -Options are passed directly, or passed later through [`processor.data()`][data]. +Options can be passed directly, or passed later through +[`processor.data()`][data]. -##### `options.gfm` +###### `options.gfm` -```md +GFM mode (`boolean`, default: `true`). + +```markdown hello ~~hi~~ world ``` -GFM mode (`boolean`, default: `true`) turns on: +Turns on: + +* [Fenced code blocks](https://help.github.com/articles/creating-and-highlighting-code-blocks#fenced-code-blocks) +* [Autolinking of URLs](https://help.github.com/articles/autolinked-references-and-urls) +* [Deletions (strikethrough)](https://help.github.com/articles/basic-writing-and-formatting-syntax#styling-text) +* [Task lists](https://help.github.com/articles/basic-writing-and-formatting-syntax#task-lists) +* [Tables](https://help.github.com/articles/organizing-information-with-tables) -* [Fenced code blocks](https://help.github.com/articles/github-flavored-markdown/#fenced-code-blocks) -* [Autolinking of URLs](https://help.github.com/articles/github-flavored-markdown/#url-autolinking) -* [Deletions (strikethrough)](https://help.github.com/articles/github-flavored-markdown/#strikethrough) -* [Task lists](https://help.github.com/articles/writing-on-github/#task-lists) -* [Tables](https://help.github.com/articles/github-flavored-markdown/#tables) +###### `options.commonmark` -##### `options.commonmark` +CommonMark mode (`boolean`, default: `false`). -```md +```markdown This is a paragraph and this is also part of the preceding paragraph. ``` -CommonMark mode (`boolean`, default: `false`) allows: +Allows: * Empty lines to split blockquotes -* Parentheses (`(` and `)`) around for link and image titles -* Any escaped [ASCII-punctuation][escapes] character +* Parentheses (`(` and `)`) around link and image titles +* Any escaped [ASCII punctuation][escapes] character * Closing parenthesis (`)`) as an ordered list marker * URL definitions (and footnotes, when enabled) in blockquotes -CommonMark mode disallows: +Disallows: -* Code directly following a paragraph -* ATX-headings (`# Hash headings`) without spacing after opening hashes - or and before closing hashes +* Indented code blocks directly following a paragraph +* ATX headings (`# Hash headings`) without spacing after opening hashes or and + before closing hashes * Setext headings (`Underline headings\n---`) when following a paragraph * Newlines in link and image titles -* White space in link and image URLs in auto-links (links in brackets, - `<` and `>`) -* Lazy blockquote continuation, lines not preceded by a closing angle - bracket (`>`), for lists, code, and thematicBreak +* White space in link and image URLs in auto-links (links in brackets, `<` and + `>`) +* Lazy blockquote continuation, lines not preceded by a greater than character + (`>`), for lists, code, and thematic breaks -##### `options.footnotes` +###### `options.footnotes` -```md +Footnotes mode (`boolean`, default: `false`). + +```markdown Something something[^or something?]. And something else[^1]. @@ -113,35 +169,37 @@ And something else[^1]. * ...and a list ``` -Footnotes mode (`boolean`, default: `false`) enables reference footnotes and -inline footnotes. Both are wrapped in square brackets and preceded by a caret -(`^`), and can be referenced from inside other footnotes. +Enables reference footnotes and inline footnotes. +Both are wrapped in square brackets and preceded by a caret (`^`), and can be +referenced from inside other footnotes. -##### `options.blocks` +###### `options.pedantic` -```md -foo - -``` - -Blocks (`Array.`, default: list of [block HTML elements][blocks]) -exposes let’s users define block-level HTML elements. - -##### `options.pedantic` +Pedantic mode (`boolean`, default: `false`). -```md +```markdown Check out some_file_name.txt ``` -Pedantic mode (`boolean`, default: `false`) turns on: +Turns on: -* Emphasis (`_alpha_`) and importance (`__bravo__`) with underscores - in words +* Emphasis (`_alpha_`) and importance (`__bravo__`) with underscores in words * Unordered lists with different markers (`*`, `-`, `+`) -* If `commonmark` is also turned on, ordered lists with different - markers (`.`, `)`) -* And pedantic mode removes less spaces in list-items (at most four, - instead of the whole indent) +* If `commonmark` is also turned on, ordered lists with different markers + (`.`, `)`) +* And removes less spaces in list items (at most four, instead of the whole + indent) + +###### `options.blocks` + +Blocks (`Array.`, default: list of [block HTML elements][blocks]). + +```markdown +foo + +``` + +Defines which HTML elements are seen as block level. ### `parse.Parser` @@ -149,46 +207,48 @@ Access to the [parser][], if you need it. ## Extending the Parser -Most often, using transformers to manipulate a syntax tree produces -the desired output. Sometimes, mainly when introducing new syntactic -entities with a certain level of precedence, interfacing with the parser -is necessary. +Typically, using [*transformers*][transformer] to manipulate a syntax tree +produces the desired output. +Sometimes, such as when introducing new syntactic entities with a certain +precedence, interfacing with the parser is necessary. If the `remark-parse` plugin is used, it adds a [`Parser`][parser] constructor -to the `processor`. Other plugins can add tokenizers to the parser’s prototype -to change how markdown is parsed. +function to the `processor`. +Other plugins can add tokenizers to its prototype to change how Markdown is +parsed. The below plugin adds a [tokenizer][] for at-mentions. ```js -module.exports = mentions; +module.exports = mentions function mentions() { - var Parser = this.Parser; - var tokenizers = Parser.prototype.inlineTokenizers; - var methods = Parser.prototype.inlineMethods; + var Parser = this.Parser + var tokenizers = Parser.prototype.inlineTokenizers + var methods = Parser.prototype.inlineMethods - /* Add an inline tokenizer (defined in the following example). */ - tokenizers.mention = tokenizeMention; + // Add an inline tokenizer (defined in the following example). + tokenizers.mention = tokenizeMention - /* Run it just before `text`. */ - methods.splice(methods.indexOf('text'), 0, 'mention'); + // Run it just before `text`. + methods.splice(methods.indexOf('text'), 0, 'mention') } ``` ### `Parser#blockTokenizers` -An object mapping tokenizer names to [tokenizer][]s. These -tokenizers (for example: `fencedCode`, `table`, and `paragraph`) eat -from the start of a value to a line ending. +Map of names to [tokenizer][]s (`Object.`). +These tokenizers (such as `fencedCode`, `table`, and `paragraph`) eat from the +start of a value to a line ending. -See `#blockMethods` below for a list of methods that are included by -default. +See `#blockMethods` below for a list of methods that are included by default. ### `Parser#blockMethods` -Array of `blockTokenizers` names (`string`) specifying the order in -which they run. +List of `blockTokenizers` names (`Array.`). +Specifies the order in which tokenizers run. + +Precedence of default block methods is as follows: @@ -210,17 +270,19 @@ which they run. ### `Parser#inlineTokenizers` -An object mapping tokenizer names to [tokenizer][]s. These tokenizers -(for example: `url`, `reference`, and `emphasis`) eat from the start -of a value. To increase performance, they depend on [locator][]s. +Map of names to [tokenizer][]s (`Object.`). +These tokenizers (such as `url`, `reference`, and `emphasis`) eat from the start +of a value. +To increase performance, they depend on [locator][]s. -See `#inlineMethods` below for a list of methods that are included by -default. +See `#inlineMethods` below for a list of methods that are included by default. ### `Parser#inlineMethods` -Array of `inlineTokenizers` names (`string`) specifying the order in -which they run. +List of `inlineTokenizers` names (`Array.`). +Specifies the order in which tokenizers run. + +Precedence of default inline methods is as follows: @@ -241,36 +303,40 @@ which they run. ### `function tokenizer(eat, value, silent)` +There are two types of tokenizers: block level and inline level. +Both are functions, and work the same, but inline tokenizers must have a +[locator][]. + +The following example shows an inline tokenizer that is added by the mentions +plugin above. + ```js -tokenizeMention.notInLink = true; -tokenizeMention.locator = locateMention; +tokenizeMention.notInLink = true +tokenizeMention.locator = locateMention function tokenizeMention(eat, value, silent) { - var match = /^@(\w+)/.exec(value); + var match = /^@(\w+)/.exec(value) if (match) { if (silent) { - return true; + return true } return eat(match[0])({ type: 'link', url: 'https://social-network/' + match[1], children: [{type: 'text', value: match[0]}] - }); + }) } } ``` -The parser knows two types of tokenizers: block level and inline level. -Block level tokenizers are the same as inline level tokenizers, with -the exception that the latter must have a [locator][]. +Tokenizers *test* whether a document starts with a certain syntactic entity. +In *silent* mode, they return whether that test passes. +In *normal* mode, they consume that token, a process which is called “eating”. -Tokenizers _test_ whether a document starts with a certain syntactic -entity. In _silent_ mode, they return whether that test passes. -In _normal_ mode, they consume that token, a process which is called -“eating”. Locators enable tokenizers to function faster by providing -information on where the next entity may occur. +Locators enable inline tokenizers to function faster by providing where the next +entity may occur. ###### Signatures @@ -285,36 +351,39 @@ information on where the next entity may occur. ###### Properties -* `locator` ([`Function`][locator]) - — Required for inline tokenizers -* `onlyAtStart` (`boolean`) - — Whether nodes can only be found at the beginning of the document -* `notInBlock` (`boolean`) - — Whether nodes cannot be in blockquotes, lists, or footnote - definitions -* `notInList` (`boolean`) - — Whether nodes cannot be in lists -* `notInLink` (`boolean`) - — Whether nodes cannot be in links +* `locator` ([`Function`][locator]) — Required for inline tokenizers +* `onlyAtStart` (`boolean`) — Whether nodes can only be found at the beginning + of the document +* `notInBlock` (`boolean`) — Whether nodes cannot be in blockquotes, lists, or + footnote definitions +* `notInList` (`boolean`) — Whether nodes cannot be in lists +* `notInLink` (`boolean`) — Whether nodes cannot be in links ###### Returns -* In _silent_ mode, whether a node can be found at the start of `value` -* In _normal_ mode, a node if it can be found at the start of `value` +* `boolean?`, in *silent* mode — whether a node can be found at the start of + `value` +* [`Node?`][node], In *normal* mode — If it can be found at the start of + `value` ### `tokenizer.locator(value, fromIndex)` +Locators are required for inline tokenizers. +Their role is to keep parsing performant. + +The following example shows a locator that is added by the mentions tokenizer +above. + ```js function locateMention(value, fromIndex) { - return value.indexOf('@', fromIndex); + return value.indexOf('@', fromIndex) } ``` -Locators are required for inline tokenization to keep the process -performant. Locators enable inline tokenizers to function faster by -providing information on the where the next entity occurs. Locators -may be wrong, it’s OK if there actually isn’t a node to be found at -the index they return, but they must skip any nodes. +Locators enable inline tokenizers to function faster by providing information on +where the next entity *may* occur. +Locators may be wrong, it’s OK if there actually isn’t a node to be found at the +index they return. ###### Parameters @@ -323,21 +392,20 @@ the index they return, but they must skip any nodes. ###### Returns -Index at which an entity may start, and `-1` otherwise. +`number` — Index at which an entity may start, and `-1` otherwise. ### `eat(subvalue)` ```js -var add = eat('foo'); +var add = eat('foo') ``` -Eat `subvalue`, which is a string at the start of the -[tokenize][tokenizer]d `value` (it’s tracked to ensure the correct -value is eaten). +Eat `subvalue`, which is a string at the start of the [tokenized][tokenizer] +`value`. ###### Parameters -* `subvalue` (`string`) - Value to eat. +* `subvalue` (`string`) - Value to eat ###### Returns @@ -346,60 +414,96 @@ value is eaten). ### `add(node[, parent])` ```js -var add = eat('foo'); -add({type: 'text', value: 'foo'}); +var add = eat('foo') + +add({type: 'text', value: 'foo'}) ``` -Add [positional information][location] to `node` and add it to `parent`. +Add [positional information][position] to `node` and add `node` to `parent`. ###### Parameters -* `node` ([`Node`][node]) - Node to patch position on and insert -* `parent` ([`Node`][node], optional) - Place to add `node` to in - the syntax tree. Defaults to the currently processed node +* `node` ([`Node`][node]) - Node to patch position on and to add +* `parent` ([`Parent`][parent], optional) - Place to add `node` to in the + syntax tree. + Defaults to the currently processed node ###### Returns -The given `node`. +[`Node`][node] — The given `node`. ### `add.test()` -Get the [positional information][location] which would be patched on -`node` by `add`. +Get the [positional information][position] that would be patched on `node` by +`add`. ###### Returns -[`Location`][location]. +[`Position`][position]. ### `add.reset(node[, parent])` -`add`, but resets the internal location. Useful for example in -lists, where the same content is first eaten for a list, and later -for list items +`add`, but resets the internal position. +Useful for example in lists, where the same content is first eaten for a list, +and later for list items. ###### Parameters * `node` ([`Node`][node]) - Node to patch position on and insert * `parent` ([`Node`][node], optional) - Place to add `node` to in - the syntax tree. Defaults to the currently processed node + the syntax tree. + Defaults to the currently processed node ###### Returns -The given `node`. +[`Node`][node] — The given node. ### Turning off a tokenizer -In rare situations, you may want to turn off a tokenizer to avoid parsing -that syntactic feature. This can be done by deleting the tokenizer from -your Parser’s `blockTokenizers` (or `blockMethods`) or `inlineTokenizers` -(or `inlineMethods`). +In some situations, you may want to turn off a tokenizer to avoid parsing that +syntactic feature. + +Preferably, use the [`remark-disable-tokenizers`][remark-disable-tokenizers] +plugin to turn off tokenizers. + +Alternatively, this can be done by replacing the tokenizer from +`blockTokenizers` (or `blockMethods`) or `inlineTokenizers` (or +`inlineMethods`). The following example turns off indented code blocks: ```js -delete remarkParse.Parser.prototype.blockTokenizers.indentedCode; +remarkParse.Parser.prototype.blockTokenizers.indentedCode = indentedCode + +function indentedCode() { + return true +} ``` +## Security + +As Markdown is sometimes used for HTML, and improper use of HTML can open you up +to a [cross-site scripting (XSS)][xss] attack, use of remark can also be unsafe. +When going to HTML, use remark in combination with the [**rehype**][rehype] +ecosystem, and use [`rehype-sanitize`][sanitize] to make the tree safe. + +Use of remark plugins could also open you up to other attacks. +Carefully assess each plugin and the risks involved in using them. + +## Contribute + +See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways +to get started. +See [`support.md`][support] for ways to get help. +Ideas for new plugins and tools can be posted in [`remarkjs/ideas`][ideas]. + +A curated list of awesome remark resources can be found in [**awesome +remark**][awesome]. + +This project has a [Code of Conduct][coc]. +By interacting with this repository, organisation, or community you agree to +abide by its terms. + ## License [MIT][license] © [Titus Wormer][author] @@ -408,19 +512,45 @@ delete remarkParse.Parser.prototype.blockTokenizers.indentedCode; [build-badge]: https://img.shields.io/travis/remarkjs/remark.svg -[build-status]: https://travis-ci.org/remarkjs/remark +[build]: https://travis-ci.org/remarkjs/remark [coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark.svg -[coverage-status]: https://codecov.io/github/remarkjs/remark +[coverage]: https://codecov.io/github/remarkjs/remark + +[downloads-badge]: https://img.shields.io/npm/dm/remark-parse.svg + +[downloads]: https://www.npmjs.com/package/remark-parse + +[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-parse.svg + +[size]: https://bundlephobia.com/result?p=remark-parse + +[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg + +[backers-badge]: https://opencollective.com/unified/backers/badge.svg -[chat-badge]: https://img.shields.io/gitter/room/remarkjs/Lobby.svg +[collective]: https://opencollective.com/unified -[chat]: https://gitter.im/remarkjs/Lobby +[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg -[license]: https://github.com/remarkjs/remark/blob/master/LICENSE +[chat]: https://spectrum.chat/unified/remark -[author]: http://wooorm.com +[health]: https://github.com/remarkjs/.github + +[contributing]: https://github.com/remarkjs/.github/blob/master/contributing.md + +[support]: https://github.com/remarkjs/.github/blob/master/support.md + +[coc]: https://github.com/remarkjs/.github/blob/master/code-of-conduct.md + +[ideas]: https://github.com/remarkjs/ideas + +[awesome]: https://github.com/remarkjs/awesome-remark + +[license]: https://github.com/remarkjs/remark/blob/master/license + +[author]: https://wooorm.com [npm]: https://docs.npmjs.com/cli/install @@ -428,18 +558,24 @@ delete remarkParse.Parser.prototype.blockTokenizers.indentedCode; [data]: https://github.com/unifiedjs/unified#processordatakey-value -[processor]: https://github.com/unifiedjs/remark/blob/master/packages/remark +[remark]: https://github.com/remarkjs/remark/tree/master/packages/remark + +[blocks]: https://github.com/remarkjs/remark/blob/master/packages/remark-parse/lib/block-elements.js [mdast]: https://github.com/syntax-tree/mdast -[escapes]: http://spec.commonmark.org/0.25/#backslash-escapes +[escapes]: https://spec.commonmark.org/0.29/#backslash-escapes [node]: https://github.com/syntax-tree/unist#node -[location]: https://github.com/syntax-tree/unist#location +[parent]: https://github.com/syntax-tree/unist#parent + +[position]: https://github.com/syntax-tree/unist#position [parser]: https://github.com/unifiedjs/unified#processorparser +[transformer]: https://github.com/unifiedjs/unified#function-transformernode-file-next + [extend]: #extending-the-parser [tokenizer]: #function-tokenizereat-value-silent @@ -450,4 +586,12 @@ delete remarkParse.Parser.prototype.blockTokenizers.indentedCode; [add]: #addnode-parent -[blocks]: https://github.com/remarkjs/remark/blob/master/packages/remark-parse/lib/block-elements.json +[announcement]: https://medium.com/unifiedjs/collectively-evolving-through-crowdsourcing-22c359ea95cc + +[remark-disable-tokenizers]: https://github.com/zestedesavoir/zmarkdown/tree/master/packages/remark-disable-tokenizers + +[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting + +[rehype]: https://github.com/rehypejs/rehype + +[sanitize]: https://github.com/rehypejs/rehype-sanitize diff --git a/tools/node_modules/eslint-plugin-markdown/package.json b/tools/node_modules/eslint-plugin-markdown/package.json index f371a4610eea62..ab5f376e690980 100644 --- a/tools/node_modules/eslint-plugin-markdown/package.json +++ b/tools/node_modules/eslint-plugin-markdown/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-markdown", - "version": "2.0.1", + "version": "2.1.0", "description": "An ESLint plugin to lint JavaScript in Markdown code fences.", "license": "MIT", "author": { @@ -47,7 +47,7 @@ "nyc": "^14.1.1" }, "dependencies": { - "remark-parse": "^5.0.0", + "remark-parse": "^7.0.0", "unified": "^6.1.2" }, "peerDependencies": { diff --git a/tools/node_modules/eslint/README.md b/tools/node_modules/eslint/README.md index 1aa25ee3d1d47b..f53e35ce8eeb82 100644 --- a/tools/node_modules/eslint/README.md +++ b/tools/node_modules/eslint/README.md @@ -281,7 +281,7 @@ The following companies, organizations, and individuals support ESLint's ongoing

      Platinum Sponsors

      Automattic

      Gold Sponsors

      -

      Nx (by Nrwl) Chrome's Web Framework & Tools Performance Fund Shopify Salesforce Airbnb Microsoft Substack

      Silver Sponsors

      +

      Nx (by Nrwl) Chrome's Web Framework & Tools Performance Fund Salesforce Airbnb Microsoft Substack

      Silver Sponsors

      Retool Liftoff

      Bronze Sponsors

      Buy.Fineproxy.Org Anagram Solver Bugsnag Stability Monitoring Mixpanel VPS Server Icons8: free icons, photos, illustrations, and music Discord ThemeIsle Fire Stick Tricks

      diff --git a/tools/node_modules/eslint/lib/cli-engine/cli-engine.js b/tools/node_modules/eslint/lib/cli-engine/cli-engine.js index b1befaa04fcc77..ca298f9c356c3c 100644 --- a/tools/node_modules/eslint/lib/cli-engine/cli-engine.js +++ b/tools/node_modules/eslint/lib/cli-engine/cli-engine.js @@ -27,16 +27,11 @@ const { naming, CascadingConfigArrayFactory, IgnorePattern, - getUsedExtractedConfigs + getUsedExtractedConfigs, + ModuleResolver } } = require("@eslint/eslintrc"); -/* - * For some reason, ModuleResolver must be included via filepath instead of by - * API exports in order to work properly. That's why this is separated out onto - * its own require() statement. - */ -const ModuleResolver = require("@eslint/eslintrc/lib/shared/relative-module-resolver"); const { FileEnumerator } = require("./file-enumerator"); const { Linter } = require("../linter"); diff --git a/tools/node_modules/eslint/lib/init/config-file.js b/tools/node_modules/eslint/lib/init/config-file.js index fc62b81525e66b..4c648ac05517df 100644 --- a/tools/node_modules/eslint/lib/init/config-file.js +++ b/tools/node_modules/eslint/lib/init/config-file.js @@ -117,6 +117,7 @@ function writeJSConfigFile(config, filePath) { function write(config, filePath) { switch (path.extname(filePath)) { case ".js": + case ".cjs": writeJSConfigFile(config, filePath); break; diff --git a/tools/node_modules/eslint/lib/init/config-initializer.js b/tools/node_modules/eslint/lib/init/config-initializer.js index 6f62e7db87e7f7..3c7f2ba0944f29 100644 --- a/tools/node_modules/eslint/lib/init/config-initializer.js +++ b/tools/node_modules/eslint/lib/init/config-initializer.js @@ -12,6 +12,7 @@ const util = require("util"), path = require("path"), + fs = require("fs"), enquirer = require("enquirer"), ProgressBar = require("progress"), semver = require("semver"), @@ -48,6 +49,16 @@ function writeFile(config, format) { extname = ".yml"; } else if (format === "JSON") { extname = ".json"; + } else if (format === "JavaScript") { + const pkgJSONPath = npmUtils.findPackageJson(); + + if (pkgJSONPath) { + const pkgJSONContents = JSON.parse(fs.readFileSync(pkgJSONPath, "utf8")); + + if (pkgJSONContents.type === "module") { + extname = ".cjs"; + } + } } const installedESLint = config.installedESLint; @@ -531,7 +542,8 @@ function promptUser() { choices: [ { message: "Airbnb: https://github.com/airbnb/javascript", name: "airbnb" }, { message: "Standard: https://github.com/standard/standard", name: "standard" }, - { message: "Google: https://github.com/google/eslint-config-google", name: "google" } + { message: "Google: https://github.com/google/eslint-config-google", name: "google" }, + { message: "XO: https://github.com/xojs/eslint-config-xo", name: "xo" } ], skip() { this.state.answers.packageJsonExists = npmUtils.checkPackageJson(); @@ -683,6 +695,7 @@ const init = { hasESLintVersionConflict, installModules, processAnswers, + writeFile, /* istanbul ignore next */initializeConfig() { return promptUser(); } diff --git a/tools/node_modules/eslint/lib/init/npm-utils.js b/tools/node_modules/eslint/lib/init/npm-utils.js index 555ea2b2b28cb2..35191cc08764c0 100644 --- a/tools/node_modules/eslint/lib/init/npm-utils.js +++ b/tools/node_modules/eslint/lib/init/npm-utils.js @@ -172,6 +172,7 @@ function checkPackageJson(startDir) { module.exports = { installSyncSaveDev, fetchPeerDependencies, + findPackageJson, checkDeps, checkDevDeps, checkPackageJson diff --git a/tools/node_modules/eslint/lib/rules/radix.js b/tools/node_modules/eslint/lib/rules/radix.js index e322566238809b..d1b67e5e280b93 100644 --- a/tools/node_modules/eslint/lib/rules/radix.js +++ b/tools/node_modules/eslint/lib/rules/radix.js @@ -82,7 +82,8 @@ module.exports = { description: "enforce the consistent use of the radix argument when using `parseInt()`", category: "Best Practices", recommended: false, - url: "https://eslint.org/docs/rules/radix" + url: "https://eslint.org/docs/rules/radix", + suggestion: true }, schema: [ @@ -95,7 +96,8 @@ module.exports = { missingParameters: "Missing parameters.", redundantRadix: "Redundant radix parameter.", missingRadix: "Missing radix parameter.", - invalidRadix: "Invalid radix parameter, must be an integer between 2 and 36." + invalidRadix: "Invalid radix parameter, must be an integer between 2 and 36.", + addRadixParameter10: "Add radix parameter `10` for parsing decimal numbers." } }, @@ -123,7 +125,21 @@ module.exports = { if (mode === MODE_ALWAYS) { context.report({ node, - messageId: "missingRadix" + messageId: "missingRadix", + suggest: [ + { + messageId: "addRadixParameter10", + fix(fixer) { + const sourceCode = context.getSourceCode(); + const tokens = sourceCode.getTokens(node); + const lastToken = tokens[tokens.length - 1]; // Parenthesis. + const secondToLastToken = tokens[tokens.length - 2]; // May or may not be a comma. + const hasTrailingComma = secondToLastToken.type === "Punctuator" && secondToLastToken.value === ","; + + return fixer.insertTextBefore(lastToken, hasTrailingComma ? " 10," : ", 10"); + } + } + ] }); } break; diff --git a/tools/node_modules/eslint/lib/rules/require-atomic-updates.js b/tools/node_modules/eslint/lib/rules/require-atomic-updates.js index c552f1bd8258b8..b3df907420c040 100644 --- a/tools/node_modules/eslint/lib/rules/require-atomic-updates.js +++ b/tools/node_modules/eslint/lib/rules/require-atomic-updates.js @@ -13,6 +13,10 @@ */ function createReferenceMap(scope, outReferenceMap = new Map()) { for (const reference of scope.references) { + if (reference.resolved === null) { + continue; + } + outReferenceMap.set(reference.identifier, reference); } for (const childScope of scope.childScopes) { @@ -86,42 +90,42 @@ class SegmentInfo { * @returns {void} */ initialize(segment) { - const outdatedReadVariableNames = new Set(); - const freshReadVariableNames = new Set(); + const outdatedReadVariables = new Set(); + const freshReadVariables = new Set(); for (const prevSegment of segment.prevSegments) { const info = this.info.get(prevSegment); if (info) { - info.outdatedReadVariableNames.forEach(Set.prototype.add, outdatedReadVariableNames); - info.freshReadVariableNames.forEach(Set.prototype.add, freshReadVariableNames); + info.outdatedReadVariables.forEach(Set.prototype.add, outdatedReadVariables); + info.freshReadVariables.forEach(Set.prototype.add, freshReadVariables); } } - this.info.set(segment, { outdatedReadVariableNames, freshReadVariableNames }); + this.info.set(segment, { outdatedReadVariables, freshReadVariables }); } /** * Mark a given variable as read on given segments. * @param {PathSegment[]} segments The segments that it read the variable on. - * @param {string} variableName The variable name to be read. + * @param {Variable} variable The variable to be read. * @returns {void} */ - markAsRead(segments, variableName) { + markAsRead(segments, variable) { for (const segment of segments) { const info = this.info.get(segment); if (info) { - info.freshReadVariableNames.add(variableName); + info.freshReadVariables.add(variable); // If a variable is freshly read again, then it's no more out-dated. - info.outdatedReadVariableNames.delete(variableName); + info.outdatedReadVariables.delete(variable); } } } /** - * Move `freshReadVariableNames` to `outdatedReadVariableNames`. + * Move `freshReadVariables` to `outdatedReadVariables`. * @param {PathSegment[]} segments The segments to process. * @returns {void} */ @@ -130,8 +134,8 @@ class SegmentInfo { const info = this.info.get(segment); if (info) { - info.freshReadVariableNames.forEach(Set.prototype.add, info.outdatedReadVariableNames); - info.freshReadVariableNames.clear(); + info.freshReadVariables.forEach(Set.prototype.add, info.outdatedReadVariables); + info.freshReadVariables.clear(); } } } @@ -139,14 +143,14 @@ class SegmentInfo { /** * Check if a given variable is outdated on the current segments. * @param {PathSegment[]} segments The current segments. - * @param {string} variableName The variable name to check. + * @param {Variable} variable The variable to check. * @returns {boolean} `true` if the variable is outdated on the segments. */ - isOutdated(segments, variableName) { + isOutdated(segments, variable) { for (const segment of segments) { const info = this.info.get(segment); - if (info && info.outdatedReadVariableNames.has(variableName)) { + if (info && info.outdatedReadVariables.has(variable)) { return true; } } @@ -214,14 +218,13 @@ module.exports = { if (!reference) { return; } - const name = reference.identifier.name; const variable = reference.resolved; const writeExpr = getWriteExpr(reference); const isMemberAccess = reference.identifier.parent.type === "MemberExpression"; // Add a fresh read variable. if (reference.isRead() && !(writeExpr && writeExpr.parent.operator === "=")) { - segmentInfo.markAsRead(codePath.currentSegments, name); + segmentInfo.markAsRead(codePath.currentSegments, variable); } /* @@ -245,7 +248,7 @@ module.exports = { /* * Verify assignments. - * If the reference exists in `outdatedReadVariableNames` list, report it. + * If the reference exists in `outdatedReadVariables` list, report it. */ ":expression:exit"(node) { const { codePath, referenceMap } = stack; @@ -267,9 +270,9 @@ module.exports = { assignmentReferences.delete(node); for (const reference of references) { - const name = reference.identifier.name; + const variable = reference.resolved; - if (segmentInfo.isOutdated(codePath.currentSegments, name)) { + if (segmentInfo.isOutdated(codePath.currentSegments, variable)) { context.report({ node: node.parent, messageId: "nonAtomicUpdate", diff --git a/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/lib/identifier.js b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/lib/identifier.js index 51ec76370ccfc6..71310db1f39d08 100644 --- a/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/lib/identifier.js +++ b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/lib/identifier.js @@ -58,16 +58,23 @@ function isIdentifierChar(code) { function isIdentifierName(name) { let isFirst = true; - for (let _i = 0, _Array$from = Array.from(name); _i < _Array$from.length; _i++) { - const char = _Array$from[_i]; - const cp = char.codePointAt(0); + for (let i = 0; i < name.length; i++) { + let cp = name.charCodeAt(i); + + if ((cp & 0xfc00) === 0xd800 && i + 1 < name.length) { + const trail = name.charCodeAt(++i); + + if ((trail & 0xfc00) === 0xdc00) { + cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff); + } + } if (isFirst) { + isFirst = false; + if (!isIdentifierStart(cp)) { return false; } - - isFirst = false; } else if (!isIdentifierChar(cp)) { return false; } diff --git a/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/package.json b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/package.json index 464dbfa3aace49..3e5438db25c4bf 100644 --- a/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/package.json +++ b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-validator-identifier", - "version": "7.12.11", + "version": "7.14.0", "description": "Validate identifier/keywords name", "repository": { "type": "git", @@ -14,7 +14,9 @@ "main": "./lib/index.js", "exports": "./lib/index.js", "devDependencies": { - "charcodes": "^0.2.0", - "unicode-13.0.0": "^0.8.0" + "@babel/helper-validator-identifier-baseline": "npm:@babel/helper-validator-identifier@7.10.4", + "@unicode/unicode-13.0.0": "^1.0.6", + "benchmark": "^2.1.4", + "charcodes": "^0.2.0" } } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/scripts/generate-identifier-regex.js b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/scripts/generate-identifier-regex.js index 70b371508bdb1b..45276d51b2dc82 100644 --- a/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/scripts/generate-identifier-regex.js +++ b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/scripts/generate-identifier-regex.js @@ -4,14 +4,14 @@ // https://tc39.github.io/ecma262/#sec-conformance const version = "13.0.0"; -const start = require("unicode-" + +const start = require("@unicode/unicode-" + version + "/Binary_Property/ID_Start/code-points.js").filter(function (ch) { return ch > 0x7f; }); let last = -1; const cont = [0x200c, 0x200d].concat( - require("unicode-" + + require("@unicode/unicode-" + version + "/Binary_Property/ID_Continue/code-points.js").filter(function (ch) { return ch > 0x7f && search(start, ch, last + 1) == -1; diff --git a/tools/node_modules/eslint/node_modules/@babel/highlight/package.json b/tools/node_modules/eslint/node_modules/@babel/highlight/package.json index 9f10f180c27ba2..6d177994476a36 100644 --- a/tools/node_modules/eslint/node_modules/@babel/highlight/package.json +++ b/tools/node_modules/eslint/node_modules/@babel/highlight/package.json @@ -1,6 +1,6 @@ { "name": "@babel/highlight", - "version": "7.13.10", + "version": "7.14.0", "description": "Syntax highlight JavaScript strings for output in terminals.", "author": "suchipi ", "homepage": "https://babel.dev/docs/en/next/babel-highlight", @@ -15,7 +15,7 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/helper-validator-identifier": "^7.12.11", + "@babel/helper-validator-identifier": "^7.14.0", "chalk": "^2.0.0", "js-tokens": "^4.0.0" }, diff --git a/tools/node_modules/eslint/node_modules/@eslint/eslintrc/lib/index.js b/tools/node_modules/eslint/node_modules/@eslint/eslintrc/lib/index.js index 3e8dd90e6a3dea..de2a95d986abbc 100644 --- a/tools/node_modules/eslint/node_modules/@eslint/eslintrc/lib/index.js +++ b/tools/node_modules/eslint/node_modules/@eslint/eslintrc/lib/index.js @@ -14,7 +14,7 @@ const { } = require("./config-array-factory"); const { CascadingConfigArrayFactory } = require("./cascading-config-array-factory"); -const { ModuleResolver } = require("./shared/relative-module-resolver"); +const ModuleResolver = require("./shared/relative-module-resolver"); const { ConfigArray, getUsedExtractedConfigs } = require("./config-array"); const { ConfigDependency } = require("./config-array/config-dependency"); const { ExtractedConfig } = require("./config-array/extracted-config"); diff --git a/tools/node_modules/eslint/node_modules/@eslint/eslintrc/lib/shared/config-validator.js b/tools/node_modules/eslint/node_modules/@eslint/eslintrc/lib/shared/config-validator.js index dbc6f3f389e800..90869739ca479d 100644 --- a/tools/node_modules/eslint/node_modules/@eslint/eslintrc/lib/shared/config-validator.js +++ b/tools/node_modules/eslint/node_modules/@eslint/eslintrc/lib/shared/config-validator.js @@ -5,6 +5,8 @@ "use strict"; +/* eslint class-methods-use-this: "off" */ + //------------------------------------------------------------------------------ // Requirements //------------------------------------------------------------------------------ diff --git a/tools/node_modules/eslint/node_modules/@eslint/eslintrc/package.json b/tools/node_modules/eslint/node_modules/@eslint/eslintrc/package.json index d4dbb4b71342c2..a75ea6c9b63d71 100644 --- a/tools/node_modules/eslint/node_modules/@eslint/eslintrc/package.json +++ b/tools/node_modules/eslint/node_modules/@eslint/eslintrc/package.json @@ -1,6 +1,6 @@ { "name": "@eslint/eslintrc", - "version": "0.4.0", + "version": "0.4.1", "description": "The legacy ESLintRC config file format for ESLint", "main": "lib/index.js", "files": [ @@ -12,7 +12,8 @@ "access": "public" }, "scripts": { - "lint": "eslint .", + "lint": "eslint . --report-unused-disable-directives", + "fix": "npm run lint -- --fix", "test": "mocha -R progress -c 'tests/lib/**/*.js'", "generate-release": "eslint-generate-release", "generate-alpharelease": "eslint-generate-prerelease alpha", @@ -34,9 +35,9 @@ "homepage": "https://github.com/eslint/eslintrc#readme", "devDependencies": { "chai": "^4.2.0", - "eslint": "^7.7.0", - "eslint-config-eslint": "^6.0.0", - "eslint-plugin-jsdoc": "^22.1.0", + "eslint": "^7.21.0", + "eslint-config-eslint": "^7.0.0", + "eslint-plugin-jsdoc": "^32.2.0", "eslint-plugin-node": "^11.1.0", "eslint-release": "^3.1.2", "fs-teardown": "^0.1.0", diff --git a/tools/node_modules/eslint/node_modules/eslint-visitor-keys/README.md b/tools/node_modules/eslint/node_modules/eslint-visitor-keys/README.md index 250f5fa31a681d..d7dbe65fa010bc 100644 --- a/tools/node_modules/eslint/node_modules/eslint-visitor-keys/README.md +++ b/tools/node_modules/eslint/node_modules/eslint-visitor-keys/README.md @@ -17,7 +17,7 @@ $ npm install eslint-visitor-keys ### Requirements -- [Node.js] 4.0.0 or later. +- [Node.js] 10.0.0 or later. ## 📖 Usage diff --git a/tools/node_modules/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.json b/tools/node_modules/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.json index a33bbc66005b6a..e648ee125acd58 100644 --- a/tools/node_modules/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.json +++ b/tools/node_modules/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.json @@ -211,6 +211,7 @@ "ObjectPattern": [ "properties" ], + "PrivateIdentifier": [], "Program": [ "body" ], @@ -218,6 +219,10 @@ "key", "value" ], + "PropertyDefinition": [ + "key", + "value" + ], "RestElement": [ "argument" ], diff --git a/tools/node_modules/eslint/node_modules/eslint-visitor-keys/package.json b/tools/node_modules/eslint/node_modules/eslint-visitor-keys/package.json index a3b8dd684ab145..775706ba4b4ed6 100644 --- a/tools/node_modules/eslint/node_modules/eslint-visitor-keys/package.json +++ b/tools/node_modules/eslint/node_modules/eslint-visitor-keys/package.json @@ -1,6 +1,6 @@ { "name": "eslint-visitor-keys", - "version": "2.0.0", + "version": "2.1.0", "description": "Constants and utilities about visitor keys to traverse AST.", "main": "lib/index.js", "files": [ diff --git a/tools/node_modules/eslint/node_modules/glob/README.md b/tools/node_modules/eslint/node_modules/glob/README.md index 0916a48255cd6f..2dde30a597d77c 100644 --- a/tools/node_modules/eslint/node_modules/glob/README.md +++ b/tools/node_modules/eslint/node_modules/glob/README.md @@ -7,7 +7,7 @@ Match files using the patterns the shell uses, like stars and stuff. This is a glob implementation in JavaScript. It uses the `minimatch` library to do its matching. -![](logo/glob.png) +![a fun cartoon logo made of glob characters](logo/glob.png) ## Usage diff --git a/tools/node_modules/eslint/node_modules/glob/common.js b/tools/node_modules/eslint/node_modules/glob/common.js index 66651bb3aac655..d14157a0aec8a2 100644 --- a/tools/node_modules/eslint/node_modules/glob/common.js +++ b/tools/node_modules/eslint/node_modules/glob/common.js @@ -1,5 +1,3 @@ -exports.alphasort = alphasort -exports.alphasorti = alphasorti exports.setopts = setopts exports.ownProp = ownProp exports.makeAbs = makeAbs @@ -17,12 +15,8 @@ var minimatch = require("minimatch") var isAbsolute = require("path-is-absolute") var Minimatch = minimatch.Minimatch -function alphasorti (a, b) { - return a.toLowerCase().localeCompare(b.toLowerCase()) -} - function alphasort (a, b) { - return a.localeCompare(b) + return a.localeCompare(b, 'en') } function setupIgnores (self, options) { @@ -150,7 +144,7 @@ function finish (self) { all = Object.keys(all) if (!self.nosort) - all = all.sort(self.nocase ? alphasorti : alphasort) + all = all.sort(alphasort) // at *some* point we statted all of these if (self.mark) { diff --git a/tools/node_modules/eslint/node_modules/glob/glob.js b/tools/node_modules/eslint/node_modules/glob/glob.js index 58dec0f6c2bd0b..dc27aef10b344c 100644 --- a/tools/node_modules/eslint/node_modules/glob/glob.js +++ b/tools/node_modules/eslint/node_modules/glob/glob.js @@ -51,8 +51,6 @@ var assert = require('assert') var isAbsolute = require('path-is-absolute') var globSync = require('./sync.js') var common = require('./common.js') -var alphasort = common.alphasort -var alphasorti = common.alphasorti var setopts = common.setopts var ownProp = common.ownProp var inflight = require('inflight') diff --git a/tools/node_modules/eslint/node_modules/glob/package.json b/tools/node_modules/eslint/node_modules/glob/package.json index 6477c3070cb14e..b345ae1e9fd833 100644 --- a/tools/node_modules/eslint/node_modules/glob/package.json +++ b/tools/node_modules/eslint/node_modules/glob/package.json @@ -2,7 +2,7 @@ "author": "Isaac Z. Schlueter (http://blog.izs.me/)", "name": "glob", "description": "a little globber", - "version": "7.1.6", + "version": "7.1.7", "repository": { "type": "git", "url": "git://github.com/isaacs/node-glob.git" @@ -27,13 +27,18 @@ "devDependencies": { "mkdirp": "0", "rimraf": "^2.2.8", - "tap": "^12.0.1", + "tap": "^15.0.6", "tick": "0.0.6" }, + "tap": { + "before": "test/00-setup.js", + "after": "test/zz-cleanup.js", + "jobs": 1 + }, "scripts": { "prepublish": "npm run benchclean", "profclean": "rm -f v8.log profile.txt", - "test": "tap test/*.js --cov", + "test": "tap", "test-regen": "npm run profclean && TEST_REGEN=1 node test/00-setup.js", "bench": "bash benchmark.sh", "prof": "bash prof.sh && cat profile.txt", diff --git a/tools/node_modules/eslint/node_modules/glob/sync.js b/tools/node_modules/eslint/node_modules/glob/sync.js index c952134baa7ec0..10b0ed2c0026b1 100644 --- a/tools/node_modules/eslint/node_modules/glob/sync.js +++ b/tools/node_modules/eslint/node_modules/glob/sync.js @@ -11,8 +11,6 @@ var path = require('path') var assert = require('assert') var isAbsolute = require('path-is-absolute') var common = require('./common.js') -var alphasort = common.alphasort -var alphasorti = common.alphasorti var setopts = common.setopts var ownProp = common.ownProp var childrenIgnored = common.childrenIgnored diff --git a/tools/node_modules/eslint/node_modules/lodash.flatten/LICENSE b/tools/node_modules/eslint/node_modules/lodash.flatten/LICENSE deleted file mode 100644 index e0c69d56032d15..00000000000000 --- a/tools/node_modules/eslint/node_modules/lodash.flatten/LICENSE +++ /dev/null @@ -1,47 +0,0 @@ -Copyright jQuery Foundation and other contributors - -Based on Underscore.js, copyright Jeremy Ashkenas, -DocumentCloud and Investigative Reporters & Editors - -This software consists of voluntary contributions made by many -individuals. For exact contribution history, see the revision history -available at https://github.com/lodash/lodash - -The following license applies to all parts of this software except as -documented below: - -==== - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -==== - -Copyright and related rights for sample code are waived via CC0. Sample -code is defined as all source code displayed within the prose of the -documentation. - -CC0: http://creativecommons.org/publicdomain/zero/1.0/ - -==== - -Files located in the node_modules and vendor directories are externally -maintained libraries used by this software which have their own -licenses; we recommend you read them, as their terms may differ from the -terms above. diff --git a/tools/node_modules/eslint/node_modules/lodash.flatten/README.md b/tools/node_modules/eslint/node_modules/lodash.flatten/README.md deleted file mode 100644 index 526fa738606573..00000000000000 --- a/tools/node_modules/eslint/node_modules/lodash.flatten/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# lodash.flatten v4.4.0 - -The [lodash](https://lodash.com/) method `_.flatten` exported as a [Node.js](https://nodejs.org/) module. - -## Installation - -Using npm: -```bash -$ {sudo -H} npm i -g npm -$ npm i --save lodash.flatten -``` - -In Node.js: -```js -var flatten = require('lodash.flatten'); -``` - -See the [documentation](https://lodash.com/docs#flatten) or [package source](https://github.com/lodash/lodash/blob/4.4.0-npm-packages/lodash.flatten) for more details. diff --git a/tools/node_modules/eslint/node_modules/lodash.flatten/index.js b/tools/node_modules/eslint/node_modules/lodash.flatten/index.js deleted file mode 100644 index 09ae7a66eb460f..00000000000000 --- a/tools/node_modules/eslint/node_modules/lodash.flatten/index.js +++ /dev/null @@ -1,349 +0,0 @@ -/** - * lodash (Custom Build) - * Build: `lodash modularize exports="npm" -o ./` - * Copyright jQuery Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */ - -/** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER = 9007199254740991; - -/** `Object#toString` result references. */ -var argsTag = '[object Arguments]', - funcTag = '[object Function]', - genTag = '[object GeneratorFunction]'; - -/** Detect free variable `global` from Node.js. */ -var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; - -/** Detect free variable `self`. */ -var freeSelf = typeof self == 'object' && self && self.Object === Object && self; - -/** Used as a reference to the global object. */ -var root = freeGlobal || freeSelf || Function('return this')(); - -/** - * Appends the elements of `values` to `array`. - * - * @private - * @param {Array} array The array to modify. - * @param {Array} values The values to append. - * @returns {Array} Returns `array`. - */ -function arrayPush(array, values) { - var index = -1, - length = values.length, - offset = array.length; - - while (++index < length) { - array[offset + index] = values[index]; - } - return array; -} - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ -var objectToString = objectProto.toString; - -/** Built-in value references. */ -var Symbol = root.Symbol, - propertyIsEnumerable = objectProto.propertyIsEnumerable, - spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined; - -/** - * The base implementation of `_.flatten` with support for restricting flattening. - * - * @private - * @param {Array} array The array to flatten. - * @param {number} depth The maximum recursion depth. - * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. - * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. - * @param {Array} [result=[]] The initial result value. - * @returns {Array} Returns the new flattened array. - */ -function baseFlatten(array, depth, predicate, isStrict, result) { - var index = -1, - length = array.length; - - predicate || (predicate = isFlattenable); - result || (result = []); - - while (++index < length) { - var value = array[index]; - if (depth > 0 && predicate(value)) { - if (depth > 1) { - // Recursively flatten arrays (susceptible to call stack limits). - baseFlatten(value, depth - 1, predicate, isStrict, result); - } else { - arrayPush(result, value); - } - } else if (!isStrict) { - result[result.length] = value; - } - } - return result; -} - -/** - * Checks if `value` is a flattenable `arguments` object or array. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. - */ -function isFlattenable(value) { - return isArray(value) || isArguments(value) || - !!(spreadableSymbol && value && value[spreadableSymbol]); -} - -/** - * Flattens `array` a single level deep. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to flatten. - * @returns {Array} Returns the new flattened array. - * @example - * - * _.flatten([1, [2, [3, [4]], 5]]); - * // => [1, 2, [3, [4]], 5] - */ -function flatten(array) { - var length = array ? array.length : 0; - return length ? baseFlatten(array, 1) : []; -} - -/** - * Checks if `value` is likely an `arguments` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an `arguments` object, - * else `false`. - * @example - * - * _.isArguments(function() { return arguments; }()); - * // => true - * - * _.isArguments([1, 2, 3]); - * // => false - */ -function isArguments(value) { - // Safari 8.1 makes `arguments.callee` enumerable in strict mode. - return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && - (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag); -} - -/** - * Checks if `value` is classified as an `Array` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array, else `false`. - * @example - * - * _.isArray([1, 2, 3]); - * // => true - * - * _.isArray(document.body.children); - * // => false - * - * _.isArray('abc'); - * // => false - * - * _.isArray(_.noop); - * // => false - */ -var isArray = Array.isArray; - -/** - * Checks if `value` is array-like. A value is considered array-like if it's - * not a function and has a `value.length` that's an integer greater than or - * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - * @example - * - * _.isArrayLike([1, 2, 3]); - * // => true - * - * _.isArrayLike(document.body.children); - * // => true - * - * _.isArrayLike('abc'); - * // => true - * - * _.isArrayLike(_.noop); - * // => false - */ -function isArrayLike(value) { - return value != null && isLength(value.length) && !isFunction(value); -} - -/** - * This method is like `_.isArrayLike` except that it also checks if `value` - * is an object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array-like object, - * else `false`. - * @example - * - * _.isArrayLikeObject([1, 2, 3]); - * // => true - * - * _.isArrayLikeObject(document.body.children); - * // => true - * - * _.isArrayLikeObject('abc'); - * // => false - * - * _.isArrayLikeObject(_.noop); - * // => false - */ -function isArrayLikeObject(value) { - return isObjectLike(value) && isArrayLike(value); -} - -/** - * Checks if `value` is classified as a `Function` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a function, else `false`. - * @example - * - * _.isFunction(_); - * // => true - * - * _.isFunction(/abc/); - * // => false - */ -function isFunction(value) { - // The use of `Object#toString` avoids issues with the `typeof` operator - // in Safari 8-9 which returns 'object' for typed array and other constructors. - var tag = isObject(value) ? objectToString.call(value) : ''; - return tag == funcTag || tag == genTag; -} - -/** - * Checks if `value` is a valid array-like length. - * - * **Note:** This method is loosely based on - * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - * @example - * - * _.isLength(3); - * // => true - * - * _.isLength(Number.MIN_VALUE); - * // => false - * - * _.isLength(Infinity); - * // => false - * - * _.isLength('3'); - * // => false - */ -function isLength(value) { - return typeof value == 'number' && - value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; -} - -/** - * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) - * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(_.noop); - * // => true - * - * _.isObject(null); - * // => false - */ -function isObject(value) { - var type = typeof value; - return !!value && (type == 'object' || type == 'function'); -} - -/** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false - * - * _.isObjectLike(null); - * // => false - */ -function isObjectLike(value) { - return !!value && typeof value == 'object'; -} - -module.exports = flatten; diff --git a/tools/node_modules/eslint/node_modules/lodash.flatten/package.json b/tools/node_modules/eslint/node_modules/lodash.flatten/package.json deleted file mode 100644 index 045cd056058fd2..00000000000000 --- a/tools/node_modules/eslint/node_modules/lodash.flatten/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "lodash.flatten", - "version": "4.4.0", - "description": "The lodash method `_.flatten` exported as a module.", - "homepage": "https://lodash.com/", - "icon": "https://lodash.com/icon.svg", - "license": "MIT", - "keywords": "lodash-modularized, flatten", - "author": "John-David Dalton (http://allyoucanleet.com/)", - "contributors": [ - "John-David Dalton (http://allyoucanleet.com/)", - "Blaine Bublitz (https://github.com/phated)", - "Mathias Bynens (https://mathiasbynens.be/)" - ], - "repository": "lodash/lodash", - "scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" } -} diff --git a/tools/node_modules/eslint/node_modules/table/README.md b/tools/node_modules/eslint/node_modules/table/README.md index f34656c5021aa7..b96006e54f4290 100644 --- a/tools/node_modules/eslint/node_modules/table/README.md +++ b/tools/node_modules/eslint/node_modules/table/README.md @@ -1,6 +1,8 @@ # Table +> Produces a string that represents array data in a text table. + [![Travis build status](http://img.shields.io/travis/gajus/table/master.svg?style=flat-square)](https://travis-ci.org/gajus/table) [![Coveralls](https://img.shields.io/coveralls/gajus/table.svg?style=flat-square)](https://coveralls.io/github/gajus/table) [![NPM version](http://img.shields.io/npm/v/table.svg?style=flat-square)](https://www.npmjs.org/package/table) @@ -11,20 +13,11 @@ * [Features](#table-features) * [Install](#table-install) * [Usage](#table-usage) - * [Cell Content Alignment](#table-usage-cell-content-alignment) - * [Column Width](#table-usage-column-width) - * [Custom Border](#table-usage-custom-border) - * [Draw Vertical Line](#table-usage-draw-vertical-line) - * [Draw Horizontal Line](#table-usage-draw-horizontal-line) - * [Single Line Mode](#table-usage-single-line-mode) - * [Padding Cell Content](#table-usage-padding-cell-content) - * [Predefined Border Templates](#table-usage-predefined-border-templates) - * [Streaming](#table-usage-streaming) - * [Text Truncation](#table-usage-text-truncation) - * [Text Wrapping](#table-usage-text-wrapping) - + * [API](#table-api) + * [table](#table-api-table-1) + * [createStream](#table-api-createstream) + * [getBorderCharacters](#table-api-getbordercharacters) -Produces a string that represents array data in a text table. ![Demo of table displaying a list of missions to the Moon.](./.README/demo.png) @@ -44,98 +37,28 @@ Produces a string that represents array data in a text table. ```bash npm install table - ``` [![Buy Me A Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/gajus) [![Become a Patron](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/gajus) + ## Usage -Table data is described using an array (rows) of array (cells). - ```js -import { - table -} from 'table'; +import { table } from 'table'; // Using commonjs? -// const {table} = require('table'); - -let data, - output; +// const { table } = require('table'); -data = [ +const data = [ ['0A', '0B', '0C'], ['1A', '1B', '1C'], ['2A', '2B', '2C'] ]; -/** - * @typedef {string} table~cell - */ - -/** - * @typedef {table~cell[]} table~row - */ - -/** - * @typedef {Object} table~columns - * @property {string} alignment Cell content alignment (enum: left, center, right) (default: left). - * @property {number} width Column width (default: auto). - * @property {number} truncate Number of characters are which the content will be truncated (default: Infinity). - * @property {number} paddingLeft Cell content padding width left (default: 1). - * @property {number} paddingRight Cell content padding width right (default: 1). - */ - -/** - * @typedef {Object} table~border - * @property {string} topBody - * @property {string} topJoin - * @property {string} topLeft - * @property {string} topRight - * @property {string} bottomBody - * @property {string} bottomJoin - * @property {string} bottomLeft - * @property {string} bottomRight - * @property {string} bodyLeft - * @property {string} bodyRight - * @property {string} bodyJoin - * @property {string} joinBody - * @property {string} joinLeft - * @property {string} joinRight - * @property {string} joinJoin - */ - -/** - * Used to dynamically tell table whether to draw a line separating rows or not. - * The default behavior is to always return true. - * - * @typedef {function} drawHorizontalLine - * @param {number} index - * @param {number} size - * @return {boolean} - */ - -/** - * @typedef {Object} table~config - * @property {table~border} border - * @property {table~columns[]} columns Column specific configuration. - * @property {table~columns} columnDefault Default values for all columns. Column specific settings overwrite the default values. - * @property {table~drawHorizontalLine} drawHorizontalLine - */ - -/** - * Generates a text table. - * - * @param {table~row[]} rows - * @param {table~config} config - * @return {String} - */ -output = table(data); - -console.log(output); +console.log(table(data)); ``` ``` @@ -150,112 +73,44 @@ console.log(output); ``` - -### Cell Content Alignment - -`{string} config.columns[{number}].alignment` property controls content horizontal alignment within a cell. - -Valid values are: "left", "right" and "center". - -```js -let config, - data, - output; + +## API -data = [ - ['0A', '0B', '0C'], - ['1A', '1B', '1C'], - ['2A', '2B', '2C'] -]; + +### table -config = { - columns: { - 0: { - alignment: 'left', - width: 10 - }, - 1: { - alignment: 'center', - width: 10 - }, - 2: { - alignment: 'right', - width: 10 - } - } -}; +Returns the string in the table format -output = table(data, config); +**Parameters:** +- **_data_:** The data to display + - Type: `any[][]` + - Required: `true` -console.log(output); -``` +- **_config_:** Table configuration + - Type: `object` + - Required: `false` -``` -╔════════════╤════════════╤════════════╗ -║ 0A │ 0B │ 0C ║ -╟────────────┼────────────┼────────────╢ -║ 1A │ 1B │ 1C ║ -╟────────────┼────────────┼────────────╢ -║ 2A │ 2B │ 2C ║ -╚════════════╧════════════╧════════════╝ -``` + +##### config.border - -### Column Width +Type: `{ [type: string]: string }`\ +Default: `honeywell` [template](#getbordercharacters) -`{number} config.columns[{number}].width` property restricts column width to a fixed width. +Custom borders. The keys are any of: +- `topLeft`, `topRight`, `topBody`,`topJoin` +- `bottomLeft`, `bottomRight`, `bottomBody`, `bottomJoin` +- `joinLeft`, `joinRight`, `joinBody`, `joinJoin` +- `bodyLeft`, `bodyRight`, `bodyJoin` +- `headerJoin` ```js -let data, - output, - options; - -data = [ - ['0A', '0B', '0C'], - ['1A', '1B', '1C'], - ['2A', '2B', '2C'] -]; - -options = { - columns: { - 1: { - width: 10 - } - } -}; - -output = table(data, options); - -console.log(output); -``` - -``` -╔════╤════════════╤════╗ -║ 0A │ 0B │ 0C ║ -╟────┼────────────┼────╢ -║ 1A │ 1B │ 1C ║ -╟────┼────────────┼────╢ -║ 2A │ 2B │ 2C ║ -╚════╧════════════╧════╝ -``` - - -### Custom Border - -`{object} config.border` property describes characters used to draw the table border. - -```js -let config, - data, - output; - -data = [ +const data = [ ['0A', '0B', '0C'], ['1A', '1B', '1C'], ['2A', '2B', '2C'] ]; -config = { +const config = { border: { topBody: `─`, topJoin: `┬`, @@ -278,9 +133,7 @@ config = { } }; -output = table(data, config); - -console.log(output); +console.log(table(data, config)); ``` ``` @@ -293,17 +146,17 @@ console.log(output); └────┴────┴────┘ ``` - -### Draw Vertical Line + +##### config.drawVerticalLine -`{function} config.drawVerticalLine` property is a function that is called for every non-content column in the table. The result of the function `{boolean}` determines whether a border is drawn. +Type: `(lineIndex: number, columnCount: number) => boolean`\ +Default: `() => true` -```js -let data, - output, - options; +It is used to tell whether to draw a vertical line. This callback is called for each vertical border of the table. +If the table has `n` columns, then the `index` parameter is alternatively received all numbers in range `[0, n]` inclusively. -data = [ +```js +const data = [ ['0A', '0B', '0C'], ['1A', '1B', '1C'], ['2A', '2B', '2C'], @@ -311,21 +164,13 @@ data = [ ['4A', '4B', '4C'] ]; -options = { - /** - * @typedef {function} drawVerticalLine - * @param {number} index - * @param {number} size - * @return {boolean} - */ - drawVerticalLine: (index, size) => { - return index === 0 || index === size; +const config = { + drawVerticalLine: (lineIndex, columnCount) => { + return lineIndex === 0 || lineIndex === columnCount; } }; -output = table(data, options); - -console.log(output); +console.log(table(data, config)); ``` @@ -344,17 +189,18 @@ console.log(output); ``` - -### Draw Horizontal Line + +##### config.drawHorizontalLine -`{function} config.drawHorizontalLine` property is a function that is called for every non-content row in the table. The result of the function `{boolean}` determines whether a row is drawn. +Type: `(lineIndex: number, rowCount: number) => boolean`\ +Default: `() => true` -```js -let data, - output, - options; +It is used to tell whether to draw a horizontal line. This callback is called for each horizontal border of the table. +If the table has `n` rows, then the `index` parameter is alternatively received all numbers in range `[0, n]` inclusively. +If the table has `n` rows and contains the header, then the range will be `[0, n+1]` inclusively. -data = [ +```js +const data = [ ['0A', '0B', '0C'], ['1A', '1B', '1C'], ['2A', '2B', '2C'], @@ -362,21 +208,13 @@ data = [ ['4A', '4B', '4C'] ]; -options = { - /** - * @typedef {function} drawHorizontalLine - * @param {number} index - * @param {number} size - * @return {boolean} - */ - drawHorizontalLine: (index, size) => { - return index === 0 || index === 1 || index === size - 1 || index === size; +const config = { + drawHorizontalLine: (lineIndex, rowCount) => { + return lineIndex === 0 || lineIndex === 1 || lineIndex === rowCount - 1 || lineIndex === rowCount; } }; -output = table(data, options); - -console.log(output); +console.log(table(data, config)); ``` @@ -393,17 +231,15 @@ console.log(output); ``` - -### Single Line Mode + +##### config.singleLine -Horizontal lines inside the table are not drawn. +Type: `boolean`\ +Default: `false` -```js -import { - table, - getBorderCharacters -} from 'table'; +If `true`, horizontal lines inside the table are not drawn. This option also overrides the `config.drawHorizontalLine` if specified. +```js const data = [ ['-rw-r--r--', '1', 'pandorym', 'staff', '1529', 'May 23 11:25', 'LICENSE'], ['-rw-r--r--', '1', 'pandorym', 'staff', '16327', 'May 23 11:58', 'README.md'], @@ -419,8 +255,7 @@ const config = { singleLine: true }; -const output = table(data, config); -console.log(output); +console.log(table(data, config)); ``` ``` @@ -436,37 +271,163 @@ console.log(output); ╚═════════════╧═════╧══════════╧═══════╧════════╧══════════════╧═══════════════════╝ ``` - -### Padding Cell Content -`{number} config.columns[{number}].paddingLeft` and `{number} config.columns[{number}].paddingRight` properties control content padding within a cell. Property value represents a number of whitespaces used to pad the content. + +##### config.columns + +Type: `Column[] | { [columnIndex: number]: Column }` + +Column specific configurations. + + +###### config.columns[*].width + +Type: `number`\ +Default: the maximum cell widths of the column + +Column width (excluding the paddings). ```js -let config, - data, - output; -data = [ - ['0A', 'AABBCC', '0C'], +const data = [ + ['0A', '0B', '0C'], ['1A', '1B', '1C'], ['2A', '2B', '2C'] ]; -config = { +const config = { columns: { - 0: { + 1: { width: 10 } + } +}; + +console.log(table(data, config)); +``` + +``` +╔════╤════════════╤════╗ +║ 0A │ 0B │ 0C ║ +╟────┼────────────┼────╢ +║ 1A │ 1B │ 1C ║ +╟────┼────────────┼────╢ +║ 2A │ 2B │ 2C ║ +╚════╧════════════╧════╝ +``` + + +###### config.columns[*].alignment + +Type: `'center' | 'justify' | 'left' | 'right'`\ +Default: `'left'` + +Cell content horizontal alignment + +```js +const data = [ + ['0A', '0B', '0C', '0D 0E 0F'], + ['1A', '1B', '1C', '1D 1E 1F'], + ['2A', '2B', '2C', '2D 2E 2F'], +]; + +const config = { + columnDefault: { + width: 10, + }, + columns: [ + { alignment: 'left' }, + { alignment: 'center' }, + { alignment: 'right' }, + { alignment: 'justify' } + ], +}; + +console.log(table(data, config)); +``` + +``` +╔════════════╤════════════╤════════════╤════════════╗ +║ 0A │ 0B │ 0C │ 0D 0E 0F ║ +╟────────────┼────────────┼────────────┼────────────╢ +║ 1A │ 1B │ 1C │ 1D 1E 1F ║ +╟────────────┼────────────┼────────────┼────────────╢ +║ 2A │ 2B │ 2C │ 2D 2E 2F ║ +╚════════════╧════════════╧════════════╧════════════╝ +``` + + +###### config.columns[*].verticalAlignment + +Type: `'top' | 'middle' | 'bottom'`\ +Default: `'top'` + +Cell content vertical alignment + +```js +const data = [ + ['A', 'B', 'C', 'DEF'], +]; + +const config = { + columnDefault: { + width: 1, + }, + columns: [ + { verticalAlignment: 'top' }, + { verticalAlignment: 'middle' }, + { verticalAlignment: 'bottom' }, + ], +}; + +console.log(table(data, config)); +``` + +``` +╔═══╤═══╤═══╤═══╗ +║ A │ │ │ D ║ +║ │ B │ │ E ║ +║ │ │ C │ F ║ +╚═══╧═══╧═══╧═══╝ +``` + + +###### config.columns[*].paddingLeft + +Type: `number`\ +Default: `1` + +The number of whitespaces used to pad the content on the left. + + +###### config.columns[*].paddingRight + +Type: `number`\ +Default: `1` + +The number of whitespaces used to pad the content on the right. + +The `paddingLeft` and `paddingRight` options do not count on the column width. So the column has `width = 5`, `paddingLeft = 2` and `paddingRight = 2` will have the total width is `9`. + + +```js +const data = [ + ['0A', 'AABBCC', '0C'], + ['1A', '1B', '1C'], + ['2A', '2B', '2C'] +]; + +const config = { + columns: [ + { paddingLeft: 3 }, - 1: { + { width: 2, paddingRight: 3 } - } + ] }; -output = table(data, config); - -console.log(output); +console.log(table(data, config)); ``` ``` @@ -481,136 +442,180 @@ console.log(output); ╚══════╧══════╧════╝ ``` - -### Predefined Border Templates - -You can load one of the predefined border templates using `getBorderCharacters` function. + +###### config.columns[*].truncate -```js -import { - table, - getBorderCharacters -} from 'table'; +Type: `number`\ +Default: `Infinity` -let config, - data; +The number of characters is which the content will be truncated. +To handle a content that overflows the container width, `table` package implements [text wrapping](#config.columns[*].wrapWord). However, sometimes you may want to truncate content that is too long to be displayed in the table. -data = [ - ['0A', '0B', '0C'], - ['1A', '1B', '1C'], - ['2A', '2B', '2C'] +```js +const data = [ + ['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.'] ]; -config = { - border: getBorderCharacters(`name of the template`) +const config = { + columns: [ + { + width: 20, + truncate: 100 + } + ] }; -table(data, config); +console.log(table(data, config)); ``` ``` -# honeywell +╔══════════════════════╗ +║ Lorem ipsum dolor si ║ +║ t amet, consectetur ║ +║ adipiscing elit. Pha ║ +║ sellus pulvinar nibh ║ +║ sed mauris convall… ║ +╚══════════════════════╝ +``` -╔════╤════╤════╗ -║ 0A │ 0B │ 0C ║ -╟────┼────┼────╢ -║ 1A │ 1B │ 1C ║ -╟────┼────┼────╢ -║ 2A │ 2B │ 2C ║ -╚════╧════╧════╝ + +###### config.columns[*].wrapWord -# norc +Type: `boolean`\ +Default: `false` -┌────┬────┬────┐ -│ 0A │ 0B │ 0C │ -├────┼────┼────┤ -│ 1A │ 1B │ 1C │ -├────┼────┼────┤ -│ 2A │ 2B │ 2C │ -└────┴────┴────┘ +The `table` package implements auto text wrapping, i.e., text that has the width greater than the container width will be separated into multiple lines at the nearest space or one of the special characters: `\|/_.,;-`. -# ramac (ASCII; for use in terminals that do not support Unicode characters) +When `wrapWord` is `false`: -+----+----+----+ -| 0A | 0B | 0C | -|----|----|----| -| 1A | 1B | 1C | -|----|----|----| -| 2A | 2B | 2C | -+----+----+----+ +```js +const data = [ + ['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.'] +]; -# void (no borders; see "bordless table" section of the documentation) +const config = { + columns: [ { width: 20 } ] +}; - 0A 0B 0C +console.log(table(data, config)); +``` - 1A 1B 1C +``` +╔══════════════════════╗ +║ Lorem ipsum dolor si ║ +║ t amet, consectetur ║ +║ adipiscing elit. Pha ║ +║ sellus pulvinar nibh ║ +║ sed mauris convallis ║ +║ dapibus. Nunc venena ║ +║ tis tempus nulla sit ║ +║ amet viverra. ║ +╚══════════════════════╝ +``` - 2A 2B 2C +When `wrapWord` is `true`: ``` +╔══════════════════════╗ +║ Lorem ipsum dolor ║ +║ sit amet, ║ +║ consectetur ║ +║ adipiscing elit. ║ +║ Phasellus pulvinar ║ +║ nibh sed mauris ║ +║ convallis dapibus. ║ +║ Nunc venenatis ║ +║ tempus nulla sit ║ +║ amet viverra. ║ +╚══════════════════════╝ -Raise [an issue](https://github.com/gajus/table/issues) if you'd like to contribute a new border template. +``` - -#### Borderless Table -Simply using "void" border character template creates a table with a lot of unnecessary spacing. + +##### config.columnDefault + +Type: `Column`\ +Default: `{}` + +The default configuration for all columns. Column-specific settings will overwrite the default values. + + + +##### config.header + +Type: `object` -To create a more plesant to the eye table, reset the padding and remove the joining rows, e.g. +Header configuration. + +The header configuration inherits the most of the column's, except: +- `content` **{string}**: the header content. +- `width:` calculate based on the content width automatically. +- `alignment:` `center` be default. +- `verticalAlignment:` is not supported. +- `config.border.topJoin` will be `config.border.topBody` for prettier. ```js -let output; +const data = [ + ['0A', '0B', '0C'], + ['1A', '1B', '1C'], + ['2A', '2B', '2C'], + ]; -output = table(data, { - border: getBorderCharacters(`void`), - columnDefault: { - paddingLeft: 0, - paddingRight: 1 - }, - drawHorizontalLine: () => { - return false - } -}); +const config = { + columnDefault: { + width: 10, + }, + header: { + alignment: 'center', + content: 'THE HEADER\nThis is the table about something', + }, +} -console.log(output); +console.log(table(data, config)); ``` ``` -0A 0B 0C -1A 1B 1C -2A 2B 2C +╔══════════════════════════════════════╗ +║ THE HEADER ║ +║ This is the table about something ║ +╟────────────┬────────────┬────────────╢ +║ 0A │ 0B │ 0C ║ +╟────────────┼────────────┼────────────╢ +║ 1A │ 1B │ 1C ║ +╟────────────┼────────────┼────────────╢ +║ 2A │ 2B │ 2C ║ +╚════════════╧════════════╧════════════╝ ``` - -### Streaming + + +### createStream `table` package exports `createStream` function used to draw a table and append rows. -`createStream` requires `{number} columnDefault.width` and `{number} columnCount` configuration properties. +**Parameter:** + - _**config:**_ the same as `table`'s, except `config.columnDefault.width` and `config.columnCount` must be provided. -```js -import { - createStream -} from 'table'; -let config, - stream; +```js +import { createStream } from 'table'; -config = { +const config = { columnDefault: { width: 50 }, columnCount: 1 }; -stream = createStream(config); +const stream = createStream(config); setInterval(() => { stream.write([new Date()]); }, 500); ``` -![Streaming current date.](./.README/streaming.gif) +![Streaming current date.](./.README/api/stream/streaming.gif) `table` package uses ANSI escape codes to overwrite the output of the last line when a new row is printed. @@ -619,38 +624,29 @@ The underlying implementation is explained in this [Stack Overflow answer](http: Streaming supports all of the configuration properties and functionality of a static table (such as auto text wrapping, alignment and padding), e.g. ```js -import { - createStream -} from 'table'; +import { createStream } from 'table'; import _ from 'lodash'; -let config, - stream, - i; - -config = { +const config = { columnDefault: { width: 50 }, columnCount: 3, - columns: { - 0: { + columns: [ + { width: 10, alignment: 'right' }, - 1: { - alignment: 'center', - }, - 2: { - width: 10 - } - } + { alignment: 'center' }, + { width: 10 } + + ] }; -stream = createStream(config); +const stream = createStream(config); -i = 0; +let i = 0; setInterval(() => { let random; @@ -661,126 +657,103 @@ setInterval(() => { }, 500); ``` -![Streaming random data.](./.README/streaming-random.gif) +![Streaming random data.](./.README/api/stream/streaming-random.gif) - -### Text Truncation -To handle a content that overflows the container width, `table` package implements [text wrapping](#table-usage-text-wrapping). However, sometimes you may want to truncate content that is too long to be displayed in the table. + +### getBorderCharacters -`{number} config.columns[{number}].truncate` property (default: `Infinity`) truncates the text at the specified length. +**Parameter:** + - **_template_** + - Type: `'honeywell' | 'norc' | 'ramac' | 'void'` + - Required: `true` + +You can load one of the predefined border templates using `getBorderCharacters` function. ```js -let config, - data, - output; +import { table, getBorderCharacters } from 'table'; -data = [ - ['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.'] +const data = [ + ['0A', '0B', '0C'], + ['1A', '1B', '1C'], + ['2A', '2B', '2C'] ]; -config = { - columns: { - 0: { - width: 20, - truncate: 100 - } - } +const config = { + border: getBorderCharacters(`name of the template`) }; -output = table(data, config); - -console.log(output); +console.log(table(data, config)); ``` ``` -╔══════════════════════╗ -║ Lorem ipsum dolor si ║ -║ t amet, consectetur ║ -║ adipiscing elit. Pha ║ -║ sellus pulvinar nibh ║ -║ sed mauris convall… ║ -╚══════════════════════╝ -``` +# honeywell - -### Text Wrapping +╔════╤════╤════╗ +║ 0A │ 0B │ 0C ║ +╟────┼────┼────╢ +║ 1A │ 1B │ 1C ║ +╟────┼────┼────╢ +║ 2A │ 2B │ 2C ║ +╚════╧════╧════╝ -`table` package implements auto text wrapping, i.e. text that has width greater than the container width will be separated into multiple lines, e.g. +# norc -```js -let config, - data, - output; +┌────┬────┬────┐ +│ 0A │ 0B │ 0C │ +├────┼────┼────┤ +│ 1A │ 1B │ 1C │ +├────┼────┼────┤ +│ 2A │ 2B │ 2C │ +└────┴────┴────┘ -data = [ - ['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.'] -]; +# ramac (ASCII; for use in terminals that do not support Unicode characters) -config = { - columns: { - 0: { - width: 20 - } - } -}; ++----+----+----+ +| 0A | 0B | 0C | +|----|----|----| +| 1A | 1B | 1C | +|----|----|----| +| 2A | 2B | 2C | ++----+----+----+ -output = table(data, config); +# void (no borders; see "borderless table" section of the documentation) -console.log(output); -``` + 0A 0B 0C + + 1A 1B 1C + + 2A 2B 2C -``` -╔══════════════════════╗ -║ Lorem ipsum dolor si ║ -║ t amet, consectetur ║ -║ adipiscing elit. Pha ║ -║ sellus pulvinar nibh ║ -║ sed mauris convallis ║ -║ dapibus. Nunc venena ║ -║ tis tempus nulla sit ║ -║ amet viverra. ║ -╚══════════════════════╝ ``` -When `wrapWord` is `true` the text is broken at the nearest space or one of the special characters ("-", "_", "\", "/", ".", ",", ";"), e.g. +Raise [an issue](https://github.com/gajus/table/issues) if you'd like to contribute a new border template. -```js -let config, - data, - output; + +#### Borderless Table -data = [ - ['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.'] -]; +Simply using `void` border character template creates a table with a lot of unnecessary spacing. -config = { - columns: { - 0: { - width: 20, - wrapWord: true - } - } -}; +To create a more pleasant to the eye table, reset the padding and remove the joining rows, e.g. -output = table(data, config); +```js + +const output = table(data, { + border: getBorderCharacters('void'), + columnDefault: { + paddingLeft: 0, + paddingRight: 1 + }, + drawHorizontalLine: () => false + } +); console.log(output); ``` ``` -╔══════════════════════╗ -║ Lorem ipsum dolor ║ -║ sit amet, ║ -║ consectetur ║ -║ adipiscing elit. ║ -║ Phasellus pulvinar ║ -║ nibh sed mauris ║ -║ convallis dapibus. ║ -║ Nunc venenatis ║ -║ tempus nulla sit ║ -║ amet viverra. ║ -╚══════════════════════╝ - +0A 0B 0C +1A 1B 1C +2A 2B 2C ``` diff --git a/tools/node_modules/eslint/node_modules/table/dist/alignString.js b/tools/node_modules/eslint/node_modules/table/dist/alignString.js index c3ff7f3d631a7a..61dc552c948a98 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/alignString.js +++ b/tools/node_modules/eslint/node_modules/table/dist/alignString.js @@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); +exports.alignString = void 0; const string_width_1 = __importDefault(require("string-width")); +const utils_1 = require("./utils"); const alignLeft = (subject, width) => { return subject + ' '.repeat(width); }; @@ -11,25 +13,31 @@ const alignRight = (subject, width) => { return ' '.repeat(width) + subject; }; const alignCenter = (subject, width) => { - let halfWidth; - halfWidth = width / 2; - if (width % 2 === 0) { - return ' '.repeat(halfWidth) + subject + ' '.repeat(halfWidth); + return ' '.repeat(Math.floor(width / 2)) + subject + ' '.repeat(Math.ceil(width / 2)); +}; +const alignJustify = (subject, width) => { + const spaceSequenceCount = utils_1.countSpaceSequence(subject); + if (spaceSequenceCount === 0) { + return alignLeft(subject, width); } - else { - halfWidth = Math.floor(halfWidth); - return ' '.repeat(halfWidth) + subject + ' '.repeat(halfWidth + 1); + const addingSpaces = utils_1.distributeUnevenly(width, spaceSequenceCount); + if (Math.max(...addingSpaces) > 3) { + return alignLeft(subject, width); } + let spaceSequenceIndex = 0; + return subject.replace(/\s+/g, (groupSpace) => { + return groupSpace + ' '.repeat(addingSpaces[spaceSequenceIndex++]); + }); }; /** * Pads a string to the left and/or right to position the subject * text in a desired alignment within a container. */ -exports.default = (subject, containerWidth, alignment) => { - if (typeof subject !== 'string') { - throw new TypeError('Subject parameter value must be a string.'); - } +const alignString = (subject, containerWidth, alignment) => { const subjectWidth = string_width_1.default(subject); + if (subjectWidth === containerWidth) { + return subject; + } if (subjectWidth > containerWidth) { throw new Error('Subject parameter value width cannot be greater than the container width.'); } @@ -43,5 +51,9 @@ exports.default = (subject, containerWidth, alignment) => { if (alignment === 'right') { return alignRight(subject, availableWidth); } + if (alignment === 'justify') { + return alignJustify(subject, availableWidth); + } return alignCenter(subject, availableWidth); }; +exports.alignString = alignString; diff --git a/tools/node_modules/eslint/node_modules/table/dist/alignTableData.js b/tools/node_modules/eslint/node_modules/table/dist/alignTableData.js index 884a26ba5f58dd..5daa581a53d556 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/alignTableData.js +++ b/tools/node_modules/eslint/node_modules/table/dist/alignTableData.js @@ -1,20 +1,13 @@ "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); -const string_width_1 = __importDefault(require("string-width")); -const alignString_1 = __importDefault(require("./alignString")); -exports.default = (rows, config) => { +exports.alignTableData = void 0; +const alignString_1 = require("./alignString"); +const alignTableData = (rows, config) => { return rows.map((row) => { - return row.map((cell, index) => { - const column = config.columns[index]; - if (string_width_1.default(cell) === column.width) { - return cell; - } - else { - return alignString_1.default(cell, column.width, column.alignment); - } + return row.map((cell, cellIndex) => { + const { width, alignment } = config.columns[cellIndex]; + return alignString_1.alignString(cell, width, alignment); }); }); }; +exports.alignTableData = alignTableData; diff --git a/tools/node_modules/eslint/node_modules/table/dist/calculateCellHeight.js b/tools/node_modules/eslint/node_modules/table/dist/calculateCellHeight.js index fbe9aa9cf424c6..372943ad582e05 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/calculateCellHeight.js +++ b/tools/node_modules/eslint/node_modules/table/dist/calculateCellHeight.js @@ -1,12 +1,11 @@ "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); -const wrapCell_1 = __importDefault(require("./wrapCell")); -exports.default = (value, columnWidth, useWrapWord = false) => { - if (typeof value !== 'string') { - throw new TypeError('Value must be a string.'); - } - return wrapCell_1.default(value, columnWidth, useWrapWord).length; +exports.calculateCellHeight = void 0; +const wrapCell_1 = require("./wrapCell"); +/** + * Calculates height of cell content in regard to its width and word wrapping. + */ +const calculateCellHeight = (value, columnWidth, useWrapWord = false) => { + return wrapCell_1.wrapCell(value, columnWidth, useWrapWord).length; }; +exports.calculateCellHeight = calculateCellHeight; diff --git a/tools/node_modules/eslint/node_modules/table/dist/calculateCellWidthIndex.js b/tools/node_modules/eslint/node_modules/table/dist/calculateCellWidths.js similarity index 50% rename from tools/node_modules/eslint/node_modules/table/dist/calculateCellWidthIndex.js rename to tools/node_modules/eslint/node_modules/table/dist/calculateCellWidths.js index d267e7906d1475..684115dd5cd3ab 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/calculateCellWidthIndex.js +++ b/tools/node_modules/eslint/node_modules/table/dist/calculateCellWidths.js @@ -3,14 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); +exports.calculateCellWidths = void 0; const string_width_1 = __importDefault(require("string-width")); /** - * Calculates width of each cell contents. + * Calculates width of each cell contents in a row. */ -exports.default = (cells) => { - return cells.map((value) => { - return Math.max(...value.split('\n').map((line) => { - return string_width_1.default(line); - })); +const calculateCellWidths = (cells) => { + return cells.map((cell) => { + return Math.max(...cell.split('\n').map(string_width_1.default)); }); }; +exports.calculateCellWidths = calculateCellWidths; diff --git a/tools/node_modules/eslint/node_modules/table/dist/calculateColumnWidths.js b/tools/node_modules/eslint/node_modules/table/dist/calculateColumnWidths.js new file mode 100644 index 00000000000000..b4f80a380a4870 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/calculateColumnWidths.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const calculateCellWidths_1 = require("./calculateCellWidths"); +/** + * Produces an array of values that describe the largest value length (width) in every column. + */ +exports.default = (rows) => { + const columnWidths = new Array(rows[0].length).fill(0); + rows.forEach((row) => { + const cellWidths = calculateCellWidths_1.calculateCellWidths(row); + cellWidths.forEach((cellWidth, cellIndex) => { + columnWidths[cellIndex] = Math.max(columnWidths[cellIndex], cellWidth); + }); + }); + return columnWidths; +}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/calculateMaximumColumnWidthIndex.js b/tools/node_modules/eslint/node_modules/table/dist/calculateMaximumColumnWidthIndex.js deleted file mode 100644 index 3312f451d876ea..00000000000000 --- a/tools/node_modules/eslint/node_modules/table/dist/calculateMaximumColumnWidthIndex.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const calculateCellWidthIndex_1 = __importDefault(require("./calculateCellWidthIndex")); -/** - * Produces an array of values that describe the largest value length (width) in every column. - */ -exports.default = (rows) => { - if (!rows[0]) { - throw new Error('Dataset must have at least one row.'); - } - const columns = new Array(rows[0].length).fill(0); - rows.forEach((row) => { - const columnWidthIndex = calculateCellWidthIndex_1.default(row); - columnWidthIndex.forEach((valueWidth, index0) => { - if (columns[index0] < valueWidth) { - columns[index0] = valueWidth; - } - }); - }); - return columns; -}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/calculateRowHeightIndex.js b/tools/node_modules/eslint/node_modules/table/dist/calculateRowHeightIndex.js deleted file mode 100644 index 3db65542cd9bfe..00000000000000 --- a/tools/node_modules/eslint/node_modules/table/dist/calculateRowHeightIndex.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const calculateCellHeight_1 = __importDefault(require("./calculateCellHeight")); -/** - * Calculates the vertical row span index. - */ -exports.default = (rows, config) => { - const tableWidth = rows[0].length; - const rowSpanIndex = []; - rows.forEach((cells) => { - const cellHeightIndex = new Array(tableWidth).fill(1); - cells.forEach((value, index1) => { - cellHeightIndex[index1] = calculateCellHeight_1.default(value, config.columns[index1].width, config.columns[index1].wrapWord); - }); - rowSpanIndex.push(Math.max(...cellHeightIndex)); - }); - return rowSpanIndex; -}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/calculateRowHeights.js b/tools/node_modules/eslint/node_modules/table/dist/calculateRowHeights.js new file mode 100644 index 00000000000000..d3411f89baf47b --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/calculateRowHeights.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.calculateRowHeights = void 0; +const calculateCellHeight_1 = require("./calculateCellHeight"); +/** + * Produces an array of values that describe the largest value length (height) in every row. + */ +const calculateRowHeights = (rows, config) => { + return rows.map((row) => { + let rowHeight = 1; + row.forEach((cell, cellIndex) => { + const cellHeight = calculateCellHeight_1.calculateCellHeight(cell, config.columns[cellIndex].width, config.columns[cellIndex].wrapWord); + rowHeight = Math.max(rowHeight, cellHeight); + }); + return rowHeight; + }); +}; +exports.calculateRowHeights = calculateRowHeights; diff --git a/tools/node_modules/eslint/node_modules/table/dist/createStream.js b/tools/node_modules/eslint/node_modules/table/dist/createStream.js index ffe611f8fb2dc3..d941b4b6f963f8 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/createStream.js +++ b/tools/node_modules/eslint/node_modules/table/dist/createStream.js @@ -1,58 +1,56 @@ "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); -const alignTableData_1 = __importDefault(require("./alignTableData")); -const calculateRowHeightIndex_1 = __importDefault(require("./calculateRowHeightIndex")); +exports.createStream = void 0; +const alignTableData_1 = require("./alignTableData"); +const calculateRowHeights_1 = require("./calculateRowHeights"); const drawBorder_1 = require("./drawBorder"); -const drawRow_1 = __importDefault(require("./drawRow")); -const makeStreamConfig_1 = __importDefault(require("./makeStreamConfig")); -const mapDataUsingRowHeightIndex_1 = __importDefault(require("./mapDataUsingRowHeightIndex")); -const padTableData_1 = __importDefault(require("./padTableData")); -const stringifyTableData_1 = __importDefault(require("./stringifyTableData")); -const truncateTableData_1 = __importDefault(require("./truncateTableData")); +const drawRow_1 = require("./drawRow"); +const makeStreamConfig_1 = require("./makeStreamConfig"); +const mapDataUsingRowHeights_1 = require("./mapDataUsingRowHeights"); +const padTableData_1 = require("./padTableData"); +const stringifyTableData_1 = require("./stringifyTableData"); +const truncateTableData_1 = require("./truncateTableData"); const prepareData = (data, config) => { - let rows = stringifyTableData_1.default(data); - rows = truncateTableData_1.default(rows, config); - const rowHeightIndex = calculateRowHeightIndex_1.default(rows, config); - rows = mapDataUsingRowHeightIndex_1.default(rows, rowHeightIndex, config); - rows = alignTableData_1.default(rows, config); - rows = padTableData_1.default(rows, config); + let rows = stringifyTableData_1.stringifyTableData(data); + rows = truncateTableData_1.truncateTableData(rows, config); + const rowHeights = calculateRowHeights_1.calculateRowHeights(rows, config); + rows = mapDataUsingRowHeights_1.mapDataUsingRowHeights(rows, rowHeights, config); + rows = alignTableData_1.alignTableData(rows, config); + rows = padTableData_1.padTableData(rows, config); return rows; }; -const create = (row, columnWidthIndex, config) => { +const create = (row, columnWidths, config) => { const rows = prepareData([row], config); const body = rows.map((literalRow) => { - return drawRow_1.default(literalRow, config); + return drawRow_1.drawRow(literalRow, config); }).join(''); let output; output = ''; - output += drawBorder_1.drawBorderTop(columnWidthIndex, config); + output += drawBorder_1.drawBorderTop(columnWidths, config); output += body; - output += drawBorder_1.drawBorderBottom(columnWidthIndex, config); + output += drawBorder_1.drawBorderBottom(columnWidths, config); output = output.trimEnd(); process.stdout.write(output); }; -const append = (row, columnWidthIndex, config) => { +const append = (row, columnWidths, config) => { const rows = prepareData([row], config); const body = rows.map((literalRow) => { - return drawRow_1.default(literalRow, config); + return drawRow_1.drawRow(literalRow, config); }).join(''); let output = ''; - const bottom = drawBorder_1.drawBorderBottom(columnWidthIndex, config); + const bottom = drawBorder_1.drawBorderBottom(columnWidths, config); if (bottom !== '\n') { output = '\r\u001B[K'; } - output += drawBorder_1.drawBorderJoin(columnWidthIndex, config); + output += drawBorder_1.drawBorderJoin(columnWidths, config); output += body; output += bottom; output = output.trimEnd(); process.stdout.write(output); }; -exports.default = (userConfig) => { - const config = makeStreamConfig_1.default(userConfig); - const columnWidthIndex = Object.values(config.columns).map((column) => { +const createStream = (userConfig) => { + const config = makeStreamConfig_1.makeStreamConfig(userConfig); + const columnWidths = Object.values(config.columns).map((column) => { return column.width + column.paddingLeft + column.paddingRight; }); let empty = true; @@ -63,11 +61,12 @@ exports.default = (userConfig) => { } if (empty) { empty = false; - create(row, columnWidthIndex, config); + create(row, columnWidths, config); } else { - append(row, columnWidthIndex, config); + append(row, columnWidths, config); } }, }; }; +exports.createStream = createStream; diff --git a/tools/node_modules/eslint/node_modules/table/dist/drawBorder.js b/tools/node_modules/eslint/node_modules/table/dist/drawBorder.js index 7620eba3dd5cdf..1b158d9667d266 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/drawBorder.js +++ b/tools/node_modules/eslint/node_modules/table/dist/drawBorder.js @@ -1,19 +1,28 @@ "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); -exports.drawBorderTop = exports.drawBorderJoin = exports.drawBorderBottom = exports.drawBorder = void 0; -const drawHorizontalContent_1 = __importDefault(require("./drawHorizontalContent")); -const drawBorder = (columnSizeIndex, config) => { - const columns = columnSizeIndex.map((size) => { +exports.drawBorderTop = exports.drawBorderJoin = exports.drawBorderBottom = exports.drawBorder = exports.createTableBorderGetter = void 0; +const drawContent_1 = require("./drawContent"); +const drawBorder = (columnWidths, config) => { + const { separator, drawVerticalLine } = config; + const columns = columnWidths.map((size) => { return config.separator.body.repeat(size); }); - return drawHorizontalContent_1.default(columns, config); + return drawContent_1.drawContent(columns, { + drawSeparator: drawVerticalLine, + separatorGetter: (index, columnCount) => { + if (index === 0) { + return separator.left; + } + if (index === columnCount) { + return separator.right; + } + return separator.join; + }, + }) + '\n'; }; exports.drawBorder = drawBorder; -const drawBorderTop = (columnSizeIndex, config) => { - const result = drawBorder(columnSizeIndex, { +const drawBorderTop = (columnWidths, config) => { + const result = drawBorder(columnWidths, { ...config, separator: { body: config.border.topBody, @@ -28,8 +37,8 @@ const drawBorderTop = (columnSizeIndex, config) => { return result; }; exports.drawBorderTop = drawBorderTop; -const drawBorderJoin = (columnSizeIndex, config) => { - return drawBorder(columnSizeIndex, { +const drawBorderJoin = (columnWidths, config) => { + return drawBorder(columnWidths, { ...config, separator: { body: config.border.joinBody, @@ -40,8 +49,8 @@ const drawBorderJoin = (columnSizeIndex, config) => { }); }; exports.drawBorderJoin = drawBorderJoin; -const drawBorderBottom = (columnSizeIndex, config) => { - return drawBorder(columnSizeIndex, { +const drawBorderBottom = (columnWidths, config) => { + return drawBorder(columnWidths, { ...config, separator: { body: config.border.bottomBody, @@ -52,3 +61,40 @@ const drawBorderBottom = (columnSizeIndex, config) => { }); }; exports.drawBorderBottom = drawBorderBottom; +const createTableBorderGetter = (columnWidths, config) => { + return (index, size) => { + if (!config.header) { + if (index === 0) { + return drawBorderTop(columnWidths, config); + } + if (index === size) { + return drawBorderBottom(columnWidths, config); + } + return drawBorderJoin(columnWidths, config); + } + // Deal with the header + if (index === 0) { + return drawBorderTop(columnWidths, { + ...config, + border: { + ...config.border, + topJoin: config.border.topBody, + }, + }); + } + if (index === 1) { + return drawBorderJoin(columnWidths, { + ...config, + border: { + ...config.border, + joinJoin: config.border.headerJoin, + }, + }); + } + if (index === size) { + return drawBorderBottom(columnWidths, config); + } + return drawBorderJoin(columnWidths, config); + }; +}; +exports.createTableBorderGetter = createTableBorderGetter; diff --git a/tools/node_modules/eslint/node_modules/table/dist/drawContent.js b/tools/node_modules/eslint/node_modules/table/dist/drawContent.js new file mode 100644 index 00000000000000..ce084dc530357e --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/drawContent.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.drawContent = void 0; +/** + * Shared function to draw horizontal borders, rows or the entire table + */ +const drawContent = (contents, separatorConfig) => { + const { separatorGetter, drawSeparator } = separatorConfig; + const contentSize = contents.length; + const result = []; + if (drawSeparator(0, contentSize)) { + result.push(separatorGetter(0, contentSize)); + } + contents.forEach((content, contentIndex) => { + result.push(content); + // Only append the middle separator if the content is not the last + if (contentIndex + 1 < contentSize && drawSeparator(contentIndex + 1, contentSize)) { + result.push(separatorGetter(contentIndex + 1, contentSize)); + } + }); + if (drawSeparator(contentSize, contentSize)) { + result.push(separatorGetter(contentSize, contentSize)); + } + return result.join(''); +}; +exports.drawContent = drawContent; diff --git a/tools/node_modules/eslint/node_modules/table/dist/drawHeader.js b/tools/node_modules/eslint/node_modules/table/dist/drawHeader.js new file mode 100644 index 00000000000000..4ef46e9816af2b --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/drawHeader.js @@ -0,0 +1,29 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.drawHeader = void 0; +const alignString_1 = require("./alignString"); +const drawRow_1 = require("./drawRow"); +const padTableData_1 = require("./padTableData"); +const truncateTableData_1 = require("./truncateTableData"); +const wrapCell_1 = require("./wrapCell"); +const drawHeader = (width, config) => { + if (!config.header) { + throw new Error('Can not draw header without header configuration'); + } + const { alignment, paddingRight, paddingLeft, wrapWord } = config.header; + let content = config.header.content; + content = truncateTableData_1.truncateString(content, config.header.truncate); + const headerLines = wrapCell_1.wrapCell(content, width, wrapWord); + return headerLines.map((headerLine) => { + let line = alignString_1.alignString(headerLine, width, alignment); + line = padTableData_1.padString(line, paddingLeft, paddingRight); + return drawRow_1.drawRow([line], { + ...config, + drawVerticalLine: (index) => { + const columnCount = config.columns.length; + return config.drawVerticalLine(index === 0 ? 0 : columnCount, columnCount); + }, + }); + }).join(''); +}; +exports.drawHeader = drawHeader; diff --git a/tools/node_modules/eslint/node_modules/table/dist/drawHorizontalContent.js b/tools/node_modules/eslint/node_modules/table/dist/drawHorizontalContent.js deleted file mode 100644 index ceee448495f579..00000000000000 --- a/tools/node_modules/eslint/node_modules/table/dist/drawHorizontalContent.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -function drawHorizontalContent(contents, config) { - const { separator, drawVerticalLine } = config; - const contentSize = contents.length; - const result = []; - result.push(drawVerticalLine(0, contentSize) ? separator.left : ''); - contents.forEach((content, index) => { - result.push(content); - // Only append the join separator if it is not the last content - if (index + 1 < contentSize) { - result.push(drawVerticalLine(index + 1, contentSize) ? separator.join : ''); - } - }); - result.push(drawVerticalLine(contentSize, contentSize) ? separator.right : ''); - return result.join('') + '\n'; -} -exports.default = drawHorizontalContent; diff --git a/tools/node_modules/eslint/node_modules/table/dist/drawRow.js b/tools/node_modules/eslint/node_modules/table/dist/drawRow.js index c03fb780b1174e..7d5756b176f3f0 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/drawRow.js +++ b/tools/node_modules/eslint/node_modules/table/dist/drawRow.js @@ -1,16 +1,20 @@ "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); -const drawHorizontalContent_1 = __importDefault(require("./drawHorizontalContent")); -exports.default = (row, config) => { - return drawHorizontalContent_1.default(row, { - ...config, - separator: { - join: config.border.bodyJoin, - left: config.border.bodyLeft, - right: config.border.bodyRight, +exports.drawRow = void 0; +const drawContent_1 = require("./drawContent"); +const drawRow = (row, config) => { + const { border, drawVerticalLine } = config; + return drawContent_1.drawContent(row, { + drawSeparator: drawVerticalLine, + separatorGetter: (index, columnCount) => { + if (index === 0) { + return border.bodyLeft; + } + if (index === columnCount) { + return border.bodyRight; + } + return border.bodyJoin; }, - }); + }) + '\n'; }; +exports.drawRow = drawRow; diff --git a/tools/node_modules/eslint/node_modules/table/dist/drawTable.js b/tools/node_modules/eslint/node_modules/table/dist/drawTable.js index a7e10193d62d45..60685dd95babb4 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/drawTable.js +++ b/tools/node_modules/eslint/node_modules/table/dist/drawTable.js @@ -3,46 +3,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); +exports.drawTable = void 0; +const string_width_1 = __importDefault(require("string-width")); const drawBorder_1 = require("./drawBorder"); -const drawRow_1 = __importDefault(require("./drawRow")); -/** - * Group the array into sub-arrays by sizes. - * - * @example - * chunkBySizes(['a', 'b', 'c', 'd', 'e'], [2, 1, 2]) = [ ['a', 'b'], ['c'], ['d', 'e'] ] - */ -const groupBySizes = (array, sizes) => { - let startIndex = 0; - return sizes.map((rowHeight) => { - const chunk = array.slice(startIndex, startIndex + rowHeight); - startIndex += rowHeight; - return chunk; - }); -}; -const shouldDrawBorderJoin = (rowIndex, rowCount, config) => { - const { singleLine, drawHorizontalLine } = config; - return !singleLine && rowIndex + 1 < rowCount && drawHorizontalLine(rowIndex + 1, rowCount); -}; -exports.default = (rows, columnWidths, rowHeights, config) => { - const { drawHorizontalLine, } = config; - const groupedRows = groupBySizes(rows, rowHeights).map((group) => { +const drawContent_1 = require("./drawContent"); +const drawHeader_1 = require("./drawHeader"); +const drawRow_1 = require("./drawRow"); +const utils_1 = require("./utils"); +const drawTable = (rows, columnWidths, rowHeights, config) => { + const { drawHorizontalLine, singleLine, } = config; + const contents = utils_1.groupBySizes(rows, rowHeights).map((group) => { return group.map((row) => { - return drawRow_1.default(row, config); + return drawRow_1.drawRow(row, config); }).join(''); }); - const rowCount = groupedRows.length; - let output = ''; - if (drawHorizontalLine(0, rowCount)) { - output += drawBorder_1.drawBorderTop(columnWidths, config); + if (config.header) { + // assume that topLeft/right border have width = 1 + const headerWidth = string_width_1.default(drawRow_1.drawRow(rows[0], config)) - 2 - + config.header.paddingLeft - config.header.paddingRight; + const header = drawHeader_1.drawHeader(headerWidth, config); + contents.unshift(header); } - groupedRows.forEach((row, rowIndex) => { - output += row; - if (shouldDrawBorderJoin(rowIndex, rowCount, config)) { - output += drawBorder_1.drawBorderJoin(columnWidths, config); - } + return drawContent_1.drawContent(contents, { + drawSeparator: (index, size) => { + // Top/bottom border + if (index === 0 || index === size) { + return drawHorizontalLine(index, size); + } + return !singleLine && drawHorizontalLine(index, size); + }, + separatorGetter: drawBorder_1.createTableBorderGetter(columnWidths, config), }); - if (drawHorizontalLine(rowCount, rowCount)) { - output += drawBorder_1.drawBorderBottom(columnWidths, config); - } - return output; }; +exports.drawTable = drawTable; diff --git a/tools/node_modules/eslint/node_modules/table/dist/generated/validators.js b/tools/node_modules/eslint/node_modules/table/dist/generated/validators.js index 99119828de034a..6291447bc6cec8 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/generated/validators.js +++ b/tools/node_modules/eslint/node_modules/table/dist/generated/validators.js @@ -8,6 +8,31 @@ const schema13 = { "border": { "$ref": "shared.json#/definitions/borders" }, + "header": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "alignment": { + "$ref": "shared.json#/definitions/alignment" + }, + "wrapWord": { + "type": "boolean" + }, + "truncate": { + "type": "integer" + }, + "paddingLeft": { + "type": "integer" + }, + "paddingRight": { + "type": "integer" + } + }, + "required": ["content"], + "additionalProperties": false + }, "columns": { "$ref": "shared.json#/definitions/columns" }, @@ -62,6 +87,9 @@ const schema15 = { "bodyJoin": { "$ref": "#/definitions/border" }, + "headerJoin": { + "$ref": "#/definitions/border" + }, "joinBody": { "$ref": "#/definitions/border" }, @@ -250,6 +278,17 @@ function validate45(data, { instancePath = "", parentData, parentDataProperty, r errors = vErrors.length; } } + if (data.headerJoin !== undefined) { + if (!(validate46(data.headerJoin, { + instancePath: instancePath + "/headerJoin", + parentData: data, + parentDataProperty: "headerJoin", + rootData + }))) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } if (data.joinBody !== undefined) { if (!(validate46(data.joinBody, { instancePath: instancePath + "/joinBody", @@ -317,6 +356,53 @@ function validate45(data, { instancePath = "", parentData, parentDataProperty, r return errors === 0; } const schema17 = { + "type": "string", + "enum": ["left", "right", "center", "justify"] +}; +const func0 = require("ajv/dist/runtime/equal").default; +function validate64(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { + let vErrors = null; + let errors = 0; + if (typeof data !== "string") { + const err0 = { + instancePath, + schemaPath: "#/type", + keyword: "type", + params: { + type: "string" + }, + message: "must be string" + }; + if (vErrors === null) { + vErrors = [err0]; + } + else { + vErrors.push(err0); + } + errors++; + } + if (!((((data === "left") || (data === "right")) || (data === "center")) || (data === "justify"))) { + const err1 = { + instancePath, + schemaPath: "#/enum", + keyword: "enum", + params: { + allowedValues: schema17.enum + }, + message: "must be equal to one of the allowed values" + }; + if (vErrors === null) { + vErrors = [err1]; + } + else { + vErrors.push(err1); + } + errors++; + } + validate64.errors = vErrors; + return errors === 0; +} +const schema18 = { "oneOf": [{ "type": "object", "patternProperties": { @@ -333,40 +419,83 @@ const schema17 = { }] }; const pattern0 = new RegExp("^[0-9]+$", "u"); -const schema18 = { +const schema19 = { "type": "object", "properties": { "alignment": { + "$ref": "#/definitions/alignment" + }, + "verticalAlignment": { "type": "string", - "enum": ["left", "right", "center"] + "enum": ["top", "middle", "bottom"] }, "width": { - "type": "number", - "minimum": 1, - "multipleOf": 1 + "type": "integer", + "minimum": 1 }, "wrapWord": { "type": "boolean" }, "truncate": { - "type": "number" + "type": "integer" }, "paddingLeft": { - "type": "number" + "type": "integer" }, "paddingRight": { - "type": "number" + "type": "integer" } }, "additionalProperties": false }; -const func0 = require("ajv/dist/runtime/equal").default; -function validate64(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { +function validate68(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { + let vErrors = null; + let errors = 0; + if (typeof data !== "string") { + const err0 = { + instancePath, + schemaPath: "#/type", + keyword: "type", + params: { + type: "string" + }, + message: "must be string" + }; + if (vErrors === null) { + vErrors = [err0]; + } + else { + vErrors.push(err0); + } + errors++; + } + if (!((((data === "left") || (data === "right")) || (data === "center")) || (data === "justify"))) { + const err1 = { + instancePath, + schemaPath: "#/enum", + keyword: "enum", + params: { + allowedValues: schema17.enum + }, + message: "must be equal to one of the allowed values" + }; + if (vErrors === null) { + vErrors = [err1]; + } + else { + vErrors.push(err1); + } + errors++; + } + validate68.errors = vErrors; + return errors === 0; +} +function validate67(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { let vErrors = null; let errors = 0; if (data && typeof data == "object" && !Array.isArray(data)) { for (const key0 in data) { - if (!((((((key0 === "alignment") || (key0 === "width")) || (key0 === "wrapWord")) || (key0 === "truncate")) || (key0 === "paddingLeft")) || (key0 === "paddingRight"))) { + if (!(((((((key0 === "alignment") || (key0 === "verticalAlignment")) || (key0 === "width")) || (key0 === "wrapWord")) || (key0 === "truncate")) || (key0 === "paddingLeft")) || (key0 === "paddingRight"))) { const err0 = { instancePath, schemaPath: "#/additionalProperties", @@ -386,11 +515,22 @@ function validate64(data, { instancePath = "", parentData, parentDataProperty, r } } if (data.alignment !== undefined) { - let data0 = data.alignment; - if (typeof data0 !== "string") { + if (!(validate68(data.alignment, { + instancePath: instancePath + "/alignment", + parentData: data, + parentDataProperty: "alignment", + rootData + }))) { + vErrors = vErrors === null ? validate68.errors : vErrors.concat(validate68.errors); + errors = vErrors.length; + } + } + if (data.verticalAlignment !== undefined) { + let data1 = data.verticalAlignment; + if (typeof data1 !== "string") { const err1 = { - instancePath: instancePath + "/alignment", - schemaPath: "#/properties/alignment/type", + instancePath: instancePath + "/verticalAlignment", + schemaPath: "#/properties/verticalAlignment/type", keyword: "type", params: { type: "string" @@ -405,13 +545,13 @@ function validate64(data, { instancePath = "", parentData, parentDataProperty, r } errors++; } - if (!(((data0 === "left") || (data0 === "right")) || (data0 === "center"))) { + if (!(((data1 === "top") || (data1 === "middle")) || (data1 === "bottom"))) { const err2 = { - instancePath: instancePath + "/alignment", - schemaPath: "#/properties/alignment/enum", + instancePath: instancePath + "/verticalAlignment", + schemaPath: "#/properties/verticalAlignment/enum", keyword: "enum", params: { - allowedValues: schema18.properties.alignment.enum + allowedValues: schema19.properties.verticalAlignment.enum }, message: "must be equal to one of the allowed values" }; @@ -425,10 +565,28 @@ function validate64(data, { instancePath = "", parentData, parentDataProperty, r } } if (data.width !== undefined) { - let data1 = data.width; - if ((typeof data1 == "number") && (isFinite(data1))) { - if (data1 < 1 || isNaN(data1)) { - const err3 = { + let data2 = data.width; + if (!(((typeof data2 == "number") && (!(data2 % 1) && !isNaN(data2))) && (isFinite(data2)))) { + const err3 = { + instancePath: instancePath + "/width", + schemaPath: "#/properties/width/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err3]; + } + else { + vErrors.push(err3); + } + errors++; + } + if ((typeof data2 == "number") && (isFinite(data2))) { + if (data2 < 1 || isNaN(data2)) { + const err4 = { instancePath: instancePath + "/width", schemaPath: "#/properties/width/minimum", keyword: "minimum", @@ -438,25 +596,6 @@ function validate64(data, { instancePath = "", parentData, parentDataProperty, r }, message: "must be >= 1" }; - if (vErrors === null) { - vErrors = [err3]; - } - else { - vErrors.push(err3); - } - errors++; - } - let res0; - if ((1 === 0 || (res0 = data1 / 1, res0 !== parseInt(res0)))) { - const err4 = { - instancePath: instancePath + "/width", - schemaPath: "#/properties/width/multipleOf", - keyword: "multipleOf", - params: { - multipleOf: 1 - }, - message: "must be multiple of 1" - }; if (vErrors === null) { vErrors = [err4]; } @@ -466,28 +605,10 @@ function validate64(data, { instancePath = "", parentData, parentDataProperty, r errors++; } } - else { - const err5 = { - instancePath: instancePath + "/width", - schemaPath: "#/properties/width/type", - keyword: "type", - params: { - type: "number" - }, - message: "must be number" - }; - if (vErrors === null) { - vErrors = [err5]; - } - else { - vErrors.push(err5); - } - errors++; - } } if (data.wrapWord !== undefined) { if (typeof data.wrapWord !== "boolean") { - const err6 = { + const err5 = { instancePath: instancePath + "/wrapWord", schemaPath: "#/properties/wrapWord/type", keyword: "type", @@ -497,80 +618,80 @@ function validate64(data, { instancePath = "", parentData, parentDataProperty, r message: "must be boolean" }; if (vErrors === null) { - vErrors = [err6]; + vErrors = [err5]; } else { - vErrors.push(err6); + vErrors.push(err5); } errors++; } } if (data.truncate !== undefined) { - let data3 = data.truncate; - if (!((typeof data3 == "number") && (isFinite(data3)))) { - const err7 = { + let data4 = data.truncate; + if (!(((typeof data4 == "number") && (!(data4 % 1) && !isNaN(data4))) && (isFinite(data4)))) { + const err6 = { instancePath: instancePath + "/truncate", schemaPath: "#/properties/truncate/type", keyword: "type", params: { - type: "number" + type: "integer" }, - message: "must be number" + message: "must be integer" }; if (vErrors === null) { - vErrors = [err7]; + vErrors = [err6]; } else { - vErrors.push(err7); + vErrors.push(err6); } errors++; } } if (data.paddingLeft !== undefined) { - let data4 = data.paddingLeft; - if (!((typeof data4 == "number") && (isFinite(data4)))) { - const err8 = { + let data5 = data.paddingLeft; + if (!(((typeof data5 == "number") && (!(data5 % 1) && !isNaN(data5))) && (isFinite(data5)))) { + const err7 = { instancePath: instancePath + "/paddingLeft", schemaPath: "#/properties/paddingLeft/type", keyword: "type", params: { - type: "number" + type: "integer" }, - message: "must be number" + message: "must be integer" }; if (vErrors === null) { - vErrors = [err8]; + vErrors = [err7]; } else { - vErrors.push(err8); + vErrors.push(err7); } errors++; } } if (data.paddingRight !== undefined) { - let data5 = data.paddingRight; - if (!((typeof data5 == "number") && (isFinite(data5)))) { - const err9 = { + let data6 = data.paddingRight; + if (!(((typeof data6 == "number") && (!(data6 % 1) && !isNaN(data6))) && (isFinite(data6)))) { + const err8 = { instancePath: instancePath + "/paddingRight", schemaPath: "#/properties/paddingRight/type", keyword: "type", params: { - type: "number" + type: "integer" }, - message: "must be number" + message: "must be integer" }; if (vErrors === null) { - vErrors = [err9]; + vErrors = [err8]; } else { - vErrors.push(err9); + vErrors.push(err8); } errors++; } } } else { - const err10 = { + const err9 = { instancePath, schemaPath: "#/type", keyword: "type", @@ -580,17 +701,17 @@ function validate64(data, { instancePath = "", parentData, parentDataProperty, r message: "must be object" }; if (vErrors === null) { - vErrors = [err10]; + vErrors = [err9]; } else { - vErrors.push(err10); + vErrors.push(err9); } errors++; } - validate64.errors = vErrors; + validate67.errors = vErrors; return errors === 0; } -function validate63(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { +function validate66(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { let vErrors = null; let errors = 0; const _errs0 = errors; @@ -620,13 +741,13 @@ function validate63(data, { instancePath = "", parentData, parentDataProperty, r } for (const key1 in data) { if (pattern0.test(key1)) { - if (!(validate64(data[key1], { + if (!(validate67(data[key1], { instancePath: instancePath + "/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), parentData: data, parentDataProperty: key1, rootData }))) { - vErrors = vErrors === null ? validate64.errors : vErrors.concat(validate64.errors); + vErrors = vErrors === null ? validate67.errors : vErrors.concat(validate67.errors); errors = vErrors.length; } } @@ -659,13 +780,13 @@ function validate63(data, { instancePath = "", parentData, parentDataProperty, r if (Array.isArray(data)) { const len0 = data.length; for (let i0 = 0; i0 < len0; i0++) { - if (!(validate64(data[i0], { + if (!(validate67(data[i0], { instancePath: instancePath + "/" + i0, parentData: data, parentDataProperty: i0, rootData }))) { - vErrors = vErrors === null ? validate64.errors : vErrors.concat(validate64.errors); + vErrors = vErrors === null ? validate67.errors : vErrors.concat(validate67.errors); errors = vErrors.length; } } @@ -728,15 +849,15 @@ function validate63(data, { instancePath = "", parentData, parentDataProperty, r } } } - validate63.errors = vErrors; + validate66.errors = vErrors; return errors === 0; } -function validate68(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { +function validate73(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { let vErrors = null; let errors = 0; if (data && typeof data == "object" && !Array.isArray(data)) { for (const key0 in data) { - if (!((((((key0 === "alignment") || (key0 === "width")) || (key0 === "wrapWord")) || (key0 === "truncate")) || (key0 === "paddingLeft")) || (key0 === "paddingRight"))) { + if (!(((((((key0 === "alignment") || (key0 === "verticalAlignment")) || (key0 === "width")) || (key0 === "wrapWord")) || (key0 === "truncate")) || (key0 === "paddingLeft")) || (key0 === "paddingRight"))) { const err0 = { instancePath, schemaPath: "#/additionalProperties", @@ -756,11 +877,22 @@ function validate68(data, { instancePath = "", parentData, parentDataProperty, r } } if (data.alignment !== undefined) { - let data0 = data.alignment; - if (typeof data0 !== "string") { + if (!(validate68(data.alignment, { + instancePath: instancePath + "/alignment", + parentData: data, + parentDataProperty: "alignment", + rootData + }))) { + vErrors = vErrors === null ? validate68.errors : vErrors.concat(validate68.errors); + errors = vErrors.length; + } + } + if (data.verticalAlignment !== undefined) { + let data1 = data.verticalAlignment; + if (typeof data1 !== "string") { const err1 = { - instancePath: instancePath + "/alignment", - schemaPath: "#/properties/alignment/type", + instancePath: instancePath + "/verticalAlignment", + schemaPath: "#/properties/verticalAlignment/type", keyword: "type", params: { type: "string" @@ -775,13 +907,13 @@ function validate68(data, { instancePath = "", parentData, parentDataProperty, r } errors++; } - if (!(((data0 === "left") || (data0 === "right")) || (data0 === "center"))) { + if (!(((data1 === "top") || (data1 === "middle")) || (data1 === "bottom"))) { const err2 = { - instancePath: instancePath + "/alignment", - schemaPath: "#/properties/alignment/enum", + instancePath: instancePath + "/verticalAlignment", + schemaPath: "#/properties/verticalAlignment/enum", keyword: "enum", params: { - allowedValues: schema18.properties.alignment.enum + allowedValues: schema19.properties.verticalAlignment.enum }, message: "must be equal to one of the allowed values" }; @@ -795,10 +927,28 @@ function validate68(data, { instancePath = "", parentData, parentDataProperty, r } } if (data.width !== undefined) { - let data1 = data.width; - if ((typeof data1 == "number") && (isFinite(data1))) { - if (data1 < 1 || isNaN(data1)) { - const err3 = { + let data2 = data.width; + if (!(((typeof data2 == "number") && (!(data2 % 1) && !isNaN(data2))) && (isFinite(data2)))) { + const err3 = { + instancePath: instancePath + "/width", + schemaPath: "#/properties/width/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err3]; + } + else { + vErrors.push(err3); + } + errors++; + } + if ((typeof data2 == "number") && (isFinite(data2))) { + if (data2 < 1 || isNaN(data2)) { + const err4 = { instancePath: instancePath + "/width", schemaPath: "#/properties/width/minimum", keyword: "minimum", @@ -808,25 +958,6 @@ function validate68(data, { instancePath = "", parentData, parentDataProperty, r }, message: "must be >= 1" }; - if (vErrors === null) { - vErrors = [err3]; - } - else { - vErrors.push(err3); - } - errors++; - } - let res0; - if ((1 === 0 || (res0 = data1 / 1, res0 !== parseInt(res0)))) { - const err4 = { - instancePath: instancePath + "/width", - schemaPath: "#/properties/width/multipleOf", - keyword: "multipleOf", - params: { - multipleOf: 1 - }, - message: "must be multiple of 1" - }; if (vErrors === null) { vErrors = [err4]; } @@ -836,28 +967,10 @@ function validate68(data, { instancePath = "", parentData, parentDataProperty, r errors++; } } - else { - const err5 = { - instancePath: instancePath + "/width", - schemaPath: "#/properties/width/type", - keyword: "type", - params: { - type: "number" - }, - message: "must be number" - }; - if (vErrors === null) { - vErrors = [err5]; - } - else { - vErrors.push(err5); - } - errors++; - } } if (data.wrapWord !== undefined) { if (typeof data.wrapWord !== "boolean") { - const err6 = { + const err5 = { instancePath: instancePath + "/wrapWord", schemaPath: "#/properties/wrapWord/type", keyword: "type", @@ -867,80 +980,80 @@ function validate68(data, { instancePath = "", parentData, parentDataProperty, r message: "must be boolean" }; if (vErrors === null) { - vErrors = [err6]; + vErrors = [err5]; } else { - vErrors.push(err6); + vErrors.push(err5); } errors++; } } if (data.truncate !== undefined) { - let data3 = data.truncate; - if (!((typeof data3 == "number") && (isFinite(data3)))) { - const err7 = { + let data4 = data.truncate; + if (!(((typeof data4 == "number") && (!(data4 % 1) && !isNaN(data4))) && (isFinite(data4)))) { + const err6 = { instancePath: instancePath + "/truncate", schemaPath: "#/properties/truncate/type", keyword: "type", params: { - type: "number" + type: "integer" }, - message: "must be number" + message: "must be integer" }; if (vErrors === null) { - vErrors = [err7]; + vErrors = [err6]; } else { - vErrors.push(err7); + vErrors.push(err6); } errors++; } } if (data.paddingLeft !== undefined) { - let data4 = data.paddingLeft; - if (!((typeof data4 == "number") && (isFinite(data4)))) { - const err8 = { + let data5 = data.paddingLeft; + if (!(((typeof data5 == "number") && (!(data5 % 1) && !isNaN(data5))) && (isFinite(data5)))) { + const err7 = { instancePath: instancePath + "/paddingLeft", schemaPath: "#/properties/paddingLeft/type", keyword: "type", params: { - type: "number" + type: "integer" }, - message: "must be number" + message: "must be integer" }; if (vErrors === null) { - vErrors = [err8]; + vErrors = [err7]; } else { - vErrors.push(err8); + vErrors.push(err7); } errors++; } } if (data.paddingRight !== undefined) { - let data5 = data.paddingRight; - if (!((typeof data5 == "number") && (isFinite(data5)))) { - const err9 = { + let data6 = data.paddingRight; + if (!(((typeof data6 == "number") && (!(data6 % 1) && !isNaN(data6))) && (isFinite(data6)))) { + const err8 = { instancePath: instancePath + "/paddingRight", schemaPath: "#/properties/paddingRight/type", keyword: "type", params: { - type: "number" + type: "integer" }, - message: "must be number" + message: "must be integer" }; if (vErrors === null) { - vErrors = [err9]; + vErrors = [err8]; } else { - vErrors.push(err9); + vErrors.push(err8); } errors++; } } } else { - const err10 = { + const err9 = { instancePath, schemaPath: "#/type", keyword: "type", @@ -950,14 +1063,14 @@ function validate68(data, { instancePath = "", parentData, parentDataProperty, r message: "must be object" }; if (vErrors === null) { - vErrors = [err10]; + vErrors = [err9]; } else { - vErrors.push(err10); + vErrors.push(err9); } errors++; } - validate68.errors = vErrors; + validate73.errors = vErrors; return errors === 0; } function validate43(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { @@ -966,7 +1079,7 @@ function validate43(data, { instancePath = "", parentData, parentDataProperty, r let errors = 0; if (data && typeof data == "object" && !Array.isArray(data)) { for (const key0 in data) { - if (!((((((key0 === "border") || (key0 === "columns")) || (key0 === "columnDefault")) || (key0 === "drawVerticalLine")) || (key0 === "drawHorizontalLine")) || (key0 === "singleLine"))) { + if (!(((((((key0 === "border") || (key0 === "header")) || (key0 === "columns")) || (key0 === "columnDefault")) || (key0 === "drawVerticalLine")) || (key0 === "drawHorizontalLine")) || (key0 === "singleLine"))) { const err0 = { instancePath, schemaPath: "#/additionalProperties", @@ -996,31 +1109,206 @@ function validate43(data, { instancePath = "", parentData, parentDataProperty, r errors = vErrors.length; } } + if (data.header !== undefined) { + let data1 = data.header; + if (data1 && typeof data1 == "object" && !Array.isArray(data1)) { + if (data1.content === undefined) { + const err1 = { + instancePath: instancePath + "/header", + schemaPath: "#/properties/header/required", + keyword: "required", + params: { + missingProperty: "content" + }, + message: "must have required property '" + "content" + "'" + }; + if (vErrors === null) { + vErrors = [err1]; + } + else { + vErrors.push(err1); + } + errors++; + } + for (const key1 in data1) { + if (!((((((key1 === "content") || (key1 === "alignment")) || (key1 === "wrapWord")) || (key1 === "truncate")) || (key1 === "paddingLeft")) || (key1 === "paddingRight"))) { + const err2 = { + instancePath: instancePath + "/header", + schemaPath: "#/properties/header/additionalProperties", + keyword: "additionalProperties", + params: { + additionalProperty: key1 + }, + message: "must NOT have additional properties" + }; + if (vErrors === null) { + vErrors = [err2]; + } + else { + vErrors.push(err2); + } + errors++; + } + } + if (data1.content !== undefined) { + if (typeof data1.content !== "string") { + const err3 = { + instancePath: instancePath + "/header/content", + schemaPath: "#/properties/header/properties/content/type", + keyword: "type", + params: { + type: "string" + }, + message: "must be string" + }; + if (vErrors === null) { + vErrors = [err3]; + } + else { + vErrors.push(err3); + } + errors++; + } + } + if (data1.alignment !== undefined) { + if (!(validate64(data1.alignment, { + instancePath: instancePath + "/header/alignment", + parentData: data1, + parentDataProperty: "alignment", + rootData + }))) { + vErrors = vErrors === null ? validate64.errors : vErrors.concat(validate64.errors); + errors = vErrors.length; + } + } + if (data1.wrapWord !== undefined) { + if (typeof data1.wrapWord !== "boolean") { + const err4 = { + instancePath: instancePath + "/header/wrapWord", + schemaPath: "#/properties/header/properties/wrapWord/type", + keyword: "type", + params: { + type: "boolean" + }, + message: "must be boolean" + }; + if (vErrors === null) { + vErrors = [err4]; + } + else { + vErrors.push(err4); + } + errors++; + } + } + if (data1.truncate !== undefined) { + let data5 = data1.truncate; + if (!(((typeof data5 == "number") && (!(data5 % 1) && !isNaN(data5))) && (isFinite(data5)))) { + const err5 = { + instancePath: instancePath + "/header/truncate", + schemaPath: "#/properties/header/properties/truncate/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err5]; + } + else { + vErrors.push(err5); + } + errors++; + } + } + if (data1.paddingLeft !== undefined) { + let data6 = data1.paddingLeft; + if (!(((typeof data6 == "number") && (!(data6 % 1) && !isNaN(data6))) && (isFinite(data6)))) { + const err6 = { + instancePath: instancePath + "/header/paddingLeft", + schemaPath: "#/properties/header/properties/paddingLeft/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err6]; + } + else { + vErrors.push(err6); + } + errors++; + } + } + if (data1.paddingRight !== undefined) { + let data7 = data1.paddingRight; + if (!(((typeof data7 == "number") && (!(data7 % 1) && !isNaN(data7))) && (isFinite(data7)))) { + const err7 = { + instancePath: instancePath + "/header/paddingRight", + schemaPath: "#/properties/header/properties/paddingRight/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err7]; + } + else { + vErrors.push(err7); + } + errors++; + } + } + } + else { + const err8 = { + instancePath: instancePath + "/header", + schemaPath: "#/properties/header/type", + keyword: "type", + params: { + type: "object" + }, + message: "must be object" + }; + if (vErrors === null) { + vErrors = [err8]; + } + else { + vErrors.push(err8); + } + errors++; + } + } if (data.columns !== undefined) { - if (!(validate63(data.columns, { + if (!(validate66(data.columns, { instancePath: instancePath + "/columns", parentData: data, parentDataProperty: "columns", rootData }))) { - vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors); + vErrors = vErrors === null ? validate66.errors : vErrors.concat(validate66.errors); errors = vErrors.length; } } if (data.columnDefault !== undefined) { - if (!(validate68(data.columnDefault, { + if (!(validate73(data.columnDefault, { instancePath: instancePath + "/columnDefault", parentData: data, parentDataProperty: "columnDefault", rootData }))) { - vErrors = vErrors === null ? validate68.errors : vErrors.concat(validate68.errors); + vErrors = vErrors === null ? validate73.errors : vErrors.concat(validate73.errors); errors = vErrors.length; } } if (data.drawVerticalLine !== undefined) { if (typeof data.drawVerticalLine != "function") { - const err1 = { + const err9 = { instancePath: instancePath + "/drawVerticalLine", schemaPath: "#/properties/drawVerticalLine/typeof", keyword: "typeof", @@ -1028,17 +1316,17 @@ function validate43(data, { instancePath = "", parentData, parentDataProperty, r message: "should pass \"typeof\" keyword validation" }; if (vErrors === null) { - vErrors = [err1]; + vErrors = [err9]; } else { - vErrors.push(err1); + vErrors.push(err9); } errors++; } } if (data.drawHorizontalLine !== undefined) { if (typeof data.drawHorizontalLine != "function") { - const err2 = { + const err10 = { instancePath: instancePath + "/drawHorizontalLine", schemaPath: "#/properties/drawHorizontalLine/typeof", keyword: "typeof", @@ -1046,17 +1334,17 @@ function validate43(data, { instancePath = "", parentData, parentDataProperty, r message: "should pass \"typeof\" keyword validation" }; if (vErrors === null) { - vErrors = [err2]; + vErrors = [err10]; } else { - vErrors.push(err2); + vErrors.push(err10); } errors++; } } if (data.singleLine !== undefined) { if (typeof data.singleLine != "boolean") { - const err3 = { + const err11 = { instancePath: instancePath + "/singleLine", schemaPath: "#/properties/singleLine/typeof", keyword: "typeof", @@ -1064,17 +1352,17 @@ function validate43(data, { instancePath = "", parentData, parentDataProperty, r message: "should pass \"typeof\" keyword validation" }; if (vErrors === null) { - vErrors = [err3]; + vErrors = [err11]; } else { - vErrors.push(err3); + vErrors.push(err11); } errors++; } } } else { - const err4 = { + const err12 = { instancePath, schemaPath: "#/type", keyword: "type", @@ -1084,18 +1372,18 @@ function validate43(data, { instancePath = "", parentData, parentDataProperty, r message: "must be object" }; if (vErrors === null) { - vErrors = [err4]; + vErrors = [err12]; } else { - vErrors.push(err4); + vErrors.push(err12); } errors++; } validate43.errors = vErrors; return errors === 0; } -exports["streamConfig.json"] = validate70; -const schema20 = { +exports["streamConfig.json"] = validate76; +const schema22 = { "$id": "streamConfig.json", "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", @@ -1110,15 +1398,17 @@ const schema20 = { "$ref": "shared.json#/definitions/column" }, "columnCount": { - "type": "number" + "type": "integer", + "minimum": 1 }, "drawVerticalLine": { "typeof": "function" } }, + "required": ["columnDefault", "columnCount"], "additionalProperties": false }; -function validate71(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { +function validate77(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { let vErrors = null; let errors = 0; if (data && typeof data == "object" && !Array.isArray(data)) { @@ -1263,6 +1553,17 @@ function validate71(data, { instancePath = "", parentData, parentDataProperty, r errors = vErrors.length; } } + if (data.headerJoin !== undefined) { + if (!(validate46(data.headerJoin, { + instancePath: instancePath + "/headerJoin", + parentData: data, + parentDataProperty: "headerJoin", + rootData + }))) { + vErrors = vErrors === null ? validate46.errors : vErrors.concat(validate46.errors); + errors = vErrors.length; + } + } if (data.joinBody !== undefined) { if (!(validate46(data.joinBody, { instancePath: instancePath + "/joinBody", @@ -1326,10 +1627,10 @@ function validate71(data, { instancePath = "", parentData, parentDataProperty, r } errors++; } - validate71.errors = vErrors; + validate77.errors = vErrors; return errors === 0; } -function validate88(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { +function validate95(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { let vErrors = null; let errors = 0; const _errs0 = errors; @@ -1359,13 +1660,13 @@ function validate88(data, { instancePath = "", parentData, parentDataProperty, r } for (const key1 in data) { if (pattern0.test(key1)) { - if (!(validate64(data[key1], { + if (!(validate67(data[key1], { instancePath: instancePath + "/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), parentData: data, parentDataProperty: key1, rootData }))) { - vErrors = vErrors === null ? validate64.errors : vErrors.concat(validate64.errors); + vErrors = vErrors === null ? validate67.errors : vErrors.concat(validate67.errors); errors = vErrors.length; } } @@ -1398,13 +1699,13 @@ function validate88(data, { instancePath = "", parentData, parentDataProperty, r if (Array.isArray(data)) { const len0 = data.length; for (let i0 = 0; i0 < len0; i0++) { - if (!(validate64(data[i0], { + if (!(validate67(data[i0], { instancePath: instancePath + "/" + i0, parentData: data, parentDataProperty: i0, rootData }))) { - vErrors = vErrors === null ? validate64.errors : vErrors.concat(validate64.errors); + vErrors = vErrors === null ? validate67.errors : vErrors.concat(validate67.errors); errors = vErrors.length; } } @@ -1467,15 +1768,15 @@ function validate88(data, { instancePath = "", parentData, parentDataProperty, r } } } - validate88.errors = vErrors; + validate95.errors = vErrors; return errors === 0; } -function validate92(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { +function validate99(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { let vErrors = null; let errors = 0; if (data && typeof data == "object" && !Array.isArray(data)) { for (const key0 in data) { - if (!((((((key0 === "alignment") || (key0 === "width")) || (key0 === "wrapWord")) || (key0 === "truncate")) || (key0 === "paddingLeft")) || (key0 === "paddingRight"))) { + if (!(((((((key0 === "alignment") || (key0 === "verticalAlignment")) || (key0 === "width")) || (key0 === "wrapWord")) || (key0 === "truncate")) || (key0 === "paddingLeft")) || (key0 === "paddingRight"))) { const err0 = { instancePath, schemaPath: "#/additionalProperties", @@ -1495,11 +1796,22 @@ function validate92(data, { instancePath = "", parentData, parentDataProperty, r } } if (data.alignment !== undefined) { - let data0 = data.alignment; - if (typeof data0 !== "string") { + if (!(validate68(data.alignment, { + instancePath: instancePath + "/alignment", + parentData: data, + parentDataProperty: "alignment", + rootData + }))) { + vErrors = vErrors === null ? validate68.errors : vErrors.concat(validate68.errors); + errors = vErrors.length; + } + } + if (data.verticalAlignment !== undefined) { + let data1 = data.verticalAlignment; + if (typeof data1 !== "string") { const err1 = { - instancePath: instancePath + "/alignment", - schemaPath: "#/properties/alignment/type", + instancePath: instancePath + "/verticalAlignment", + schemaPath: "#/properties/verticalAlignment/type", keyword: "type", params: { type: "string" @@ -1514,13 +1826,13 @@ function validate92(data, { instancePath = "", parentData, parentDataProperty, r } errors++; } - if (!(((data0 === "left") || (data0 === "right")) || (data0 === "center"))) { + if (!(((data1 === "top") || (data1 === "middle")) || (data1 === "bottom"))) { const err2 = { - instancePath: instancePath + "/alignment", - schemaPath: "#/properties/alignment/enum", + instancePath: instancePath + "/verticalAlignment", + schemaPath: "#/properties/verticalAlignment/enum", keyword: "enum", params: { - allowedValues: schema18.properties.alignment.enum + allowedValues: schema19.properties.verticalAlignment.enum }, message: "must be equal to one of the allowed values" }; @@ -1534,10 +1846,28 @@ function validate92(data, { instancePath = "", parentData, parentDataProperty, r } } if (data.width !== undefined) { - let data1 = data.width; - if ((typeof data1 == "number") && (isFinite(data1))) { - if (data1 < 1 || isNaN(data1)) { - const err3 = { + let data2 = data.width; + if (!(((typeof data2 == "number") && (!(data2 % 1) && !isNaN(data2))) && (isFinite(data2)))) { + const err3 = { + instancePath: instancePath + "/width", + schemaPath: "#/properties/width/type", + keyword: "type", + params: { + type: "integer" + }, + message: "must be integer" + }; + if (vErrors === null) { + vErrors = [err3]; + } + else { + vErrors.push(err3); + } + errors++; + } + if ((typeof data2 == "number") && (isFinite(data2))) { + if (data2 < 1 || isNaN(data2)) { + const err4 = { instancePath: instancePath + "/width", schemaPath: "#/properties/width/minimum", keyword: "minimum", @@ -1547,25 +1877,6 @@ function validate92(data, { instancePath = "", parentData, parentDataProperty, r }, message: "must be >= 1" }; - if (vErrors === null) { - vErrors = [err3]; - } - else { - vErrors.push(err3); - } - errors++; - } - let res0; - if ((1 === 0 || (res0 = data1 / 1, res0 !== parseInt(res0)))) { - const err4 = { - instancePath: instancePath + "/width", - schemaPath: "#/properties/width/multipleOf", - keyword: "multipleOf", - params: { - multipleOf: 1 - }, - message: "must be multiple of 1" - }; if (vErrors === null) { vErrors = [err4]; } @@ -1575,28 +1886,10 @@ function validate92(data, { instancePath = "", parentData, parentDataProperty, r errors++; } } - else { - const err5 = { - instancePath: instancePath + "/width", - schemaPath: "#/properties/width/type", - keyword: "type", - params: { - type: "number" - }, - message: "must be number" - }; - if (vErrors === null) { - vErrors = [err5]; - } - else { - vErrors.push(err5); - } - errors++; - } } if (data.wrapWord !== undefined) { if (typeof data.wrapWord !== "boolean") { - const err6 = { + const err5 = { instancePath: instancePath + "/wrapWord", schemaPath: "#/properties/wrapWord/type", keyword: "type", @@ -1606,80 +1899,80 @@ function validate92(data, { instancePath = "", parentData, parentDataProperty, r message: "must be boolean" }; if (vErrors === null) { - vErrors = [err6]; + vErrors = [err5]; } else { - vErrors.push(err6); + vErrors.push(err5); } errors++; } } if (data.truncate !== undefined) { - let data3 = data.truncate; - if (!((typeof data3 == "number") && (isFinite(data3)))) { - const err7 = { + let data4 = data.truncate; + if (!(((typeof data4 == "number") && (!(data4 % 1) && !isNaN(data4))) && (isFinite(data4)))) { + const err6 = { instancePath: instancePath + "/truncate", schemaPath: "#/properties/truncate/type", keyword: "type", params: { - type: "number" + type: "integer" }, - message: "must be number" + message: "must be integer" }; if (vErrors === null) { - vErrors = [err7]; + vErrors = [err6]; } else { - vErrors.push(err7); + vErrors.push(err6); } errors++; } } if (data.paddingLeft !== undefined) { - let data4 = data.paddingLeft; - if (!((typeof data4 == "number") && (isFinite(data4)))) { - const err8 = { + let data5 = data.paddingLeft; + if (!(((typeof data5 == "number") && (!(data5 % 1) && !isNaN(data5))) && (isFinite(data5)))) { + const err7 = { instancePath: instancePath + "/paddingLeft", schemaPath: "#/properties/paddingLeft/type", keyword: "type", params: { - type: "number" + type: "integer" }, - message: "must be number" + message: "must be integer" }; if (vErrors === null) { - vErrors = [err8]; + vErrors = [err7]; } else { - vErrors.push(err8); + vErrors.push(err7); } errors++; } } if (data.paddingRight !== undefined) { - let data5 = data.paddingRight; - if (!((typeof data5 == "number") && (isFinite(data5)))) { - const err9 = { + let data6 = data.paddingRight; + if (!(((typeof data6 == "number") && (!(data6 % 1) && !isNaN(data6))) && (isFinite(data6)))) { + const err8 = { instancePath: instancePath + "/paddingRight", schemaPath: "#/properties/paddingRight/type", keyword: "type", params: { - type: "number" + type: "integer" }, - message: "must be number" + message: "must be integer" }; if (vErrors === null) { - vErrors = [err9]; + vErrors = [err8]; } else { - vErrors.push(err9); + vErrors.push(err8); } errors++; } } } else { - const err10 = { + const err9 = { instancePath, schemaPath: "#/type", keyword: "type", @@ -1689,24 +1982,60 @@ function validate92(data, { instancePath = "", parentData, parentDataProperty, r message: "must be object" }; if (vErrors === null) { - vErrors = [err10]; + vErrors = [err9]; } else { - vErrors.push(err10); + vErrors.push(err9); } errors++; } - validate92.errors = vErrors; + validate99.errors = vErrors; return errors === 0; } -function validate70(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { +function validate76(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { /*# sourceURL="streamConfig.json" */ ; let vErrors = null; let errors = 0; if (data && typeof data == "object" && !Array.isArray(data)) { + if (data.columnDefault === undefined) { + const err0 = { + instancePath, + schemaPath: "#/required", + keyword: "required", + params: { + missingProperty: "columnDefault" + }, + message: "must have required property '" + "columnDefault" + "'" + }; + if (vErrors === null) { + vErrors = [err0]; + } + else { + vErrors.push(err0); + } + errors++; + } + if (data.columnCount === undefined) { + const err1 = { + instancePath, + schemaPath: "#/required", + keyword: "required", + params: { + missingProperty: "columnCount" + }, + message: "must have required property '" + "columnCount" + "'" + }; + if (vErrors === null) { + vErrors = [err1]; + } + else { + vErrors.push(err1); + } + errors++; + } for (const key0 in data) { if (!(((((key0 === "border") || (key0 === "columns")) || (key0 === "columnDefault")) || (key0 === "columnCount")) || (key0 === "drawVerticalLine"))) { - const err0 = { + const err2 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", @@ -1716,71 +2045,92 @@ function validate70(data, { instancePath = "", parentData, parentDataProperty, r message: "must NOT have additional properties" }; if (vErrors === null) { - vErrors = [err0]; + vErrors = [err2]; } else { - vErrors.push(err0); + vErrors.push(err2); } errors++; } } if (data.border !== undefined) { - if (!(validate71(data.border, { + if (!(validate77(data.border, { instancePath: instancePath + "/border", parentData: data, parentDataProperty: "border", rootData }))) { - vErrors = vErrors === null ? validate71.errors : vErrors.concat(validate71.errors); + vErrors = vErrors === null ? validate77.errors : vErrors.concat(validate77.errors); errors = vErrors.length; } } if (data.columns !== undefined) { - if (!(validate88(data.columns, { + if (!(validate95(data.columns, { instancePath: instancePath + "/columns", parentData: data, parentDataProperty: "columns", rootData }))) { - vErrors = vErrors === null ? validate88.errors : vErrors.concat(validate88.errors); + vErrors = vErrors === null ? validate95.errors : vErrors.concat(validate95.errors); errors = vErrors.length; } } if (data.columnDefault !== undefined) { - if (!(validate92(data.columnDefault, { + if (!(validate99(data.columnDefault, { instancePath: instancePath + "/columnDefault", parentData: data, parentDataProperty: "columnDefault", rootData }))) { - vErrors = vErrors === null ? validate92.errors : vErrors.concat(validate92.errors); + vErrors = vErrors === null ? validate99.errors : vErrors.concat(validate99.errors); errors = vErrors.length; } } if (data.columnCount !== undefined) { let data3 = data.columnCount; - if (!((typeof data3 == "number") && (isFinite(data3)))) { - const err1 = { + if (!(((typeof data3 == "number") && (!(data3 % 1) && !isNaN(data3))) && (isFinite(data3)))) { + const err3 = { instancePath: instancePath + "/columnCount", schemaPath: "#/properties/columnCount/type", keyword: "type", params: { - type: "number" + type: "integer" }, - message: "must be number" + message: "must be integer" }; if (vErrors === null) { - vErrors = [err1]; + vErrors = [err3]; } else { - vErrors.push(err1); + vErrors.push(err3); } errors++; } + if ((typeof data3 == "number") && (isFinite(data3))) { + if (data3 < 1 || isNaN(data3)) { + const err4 = { + instancePath: instancePath + "/columnCount", + schemaPath: "#/properties/columnCount/minimum", + keyword: "minimum", + params: { + comparison: ">=", + limit: 1 + }, + message: "must be >= 1" + }; + if (vErrors === null) { + vErrors = [err4]; + } + else { + vErrors.push(err4); + } + errors++; + } + } } if (data.drawVerticalLine !== undefined) { if (typeof data.drawVerticalLine != "function") { - const err2 = { + const err5 = { instancePath: instancePath + "/drawVerticalLine", schemaPath: "#/properties/drawVerticalLine/typeof", keyword: "typeof", @@ -1788,17 +2138,17 @@ function validate70(data, { instancePath = "", parentData, parentDataProperty, r message: "should pass \"typeof\" keyword validation" }; if (vErrors === null) { - vErrors = [err2]; + vErrors = [err5]; } else { - vErrors.push(err2); + vErrors.push(err5); } errors++; } } } else { - const err3 = { + const err6 = { instancePath, schemaPath: "#/type", keyword: "type", @@ -1808,13 +2158,13 @@ function validate70(data, { instancePath = "", parentData, parentDataProperty, r message: "must be object" }; if (vErrors === null) { - vErrors = [err3]; + vErrors = [err6]; } else { - vErrors.push(err3); + vErrors.push(err6); } errors++; } - validate70.errors = vErrors; + validate76.errors = vErrors; return errors === 0; } diff --git a/tools/node_modules/eslint/node_modules/table/dist/getBorderCharacters.js b/tools/node_modules/eslint/node_modules/table/dist/getBorderCharacters.js index 6d96a0ce29863e..3662a8a2ef09a8 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/getBorderCharacters.js +++ b/tools/node_modules/eslint/node_modules/table/dist/getBorderCharacters.js @@ -1,7 +1,8 @@ "use strict"; /* eslint-disable sort-keys-fix/sort-keys-fix */ Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = (name) => { +exports.getBorderCharacters = void 0; +const getBorderCharacters = (name) => { if (name === 'honeywell') { return { topBody: '═', @@ -15,6 +16,7 @@ exports.default = (name) => { bodyLeft: '║', bodyRight: '║', bodyJoin: '│', + headerJoin: '┬', joinBody: '─', joinLeft: '╟', joinRight: '╢', @@ -34,6 +36,7 @@ exports.default = (name) => { bodyLeft: '│', bodyRight: '│', bodyJoin: '│', + headerJoin: '┬', joinBody: '─', joinLeft: '├', joinRight: '┤', @@ -53,6 +56,7 @@ exports.default = (name) => { bodyLeft: '|', bodyRight: '|', bodyJoin: '|', + headerJoin: '+', joinBody: '-', joinLeft: '|', joinRight: '|', @@ -72,6 +76,7 @@ exports.default = (name) => { bodyLeft: '', bodyRight: '', bodyJoin: '', + headerJoin: '', joinBody: '', joinLeft: '', joinRight: '', @@ -80,3 +85,4 @@ exports.default = (name) => { } throw new Error('Unknown border template "' + name + '".'); }; +exports.getBorderCharacters = getBorderCharacters; diff --git a/tools/node_modules/eslint/node_modules/table/dist/index.js b/tools/node_modules/eslint/node_modules/table/dist/index.js index 6e93edc0317f71..711de3fb631d0f 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/index.js +++ b/tools/node_modules/eslint/node_modules/table/dist/index.js @@ -9,15 +9,13 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); exports.getBorderCharacters = exports.createStream = exports.table = void 0; -const createStream_1 = __importDefault(require("./createStream")); -exports.createStream = createStream_1.default; -const getBorderCharacters_1 = __importDefault(require("./getBorderCharacters")); -exports.getBorderCharacters = getBorderCharacters_1.default; -const table_1 = __importDefault(require("./table")); -exports.table = table_1.default; +// import chalk from 'chalk'; +const createStream_1 = require("./createStream"); +Object.defineProperty(exports, "createStream", { enumerable: true, get: function () { return createStream_1.createStream; } }); +const getBorderCharacters_1 = require("./getBorderCharacters"); +Object.defineProperty(exports, "getBorderCharacters", { enumerable: true, get: function () { return getBorderCharacters_1.getBorderCharacters; } }); +const table_1 = require("./table"); +Object.defineProperty(exports, "table", { enumerable: true, get: function () { return table_1.table; } }); __exportStar(require("./types/api"), exports); diff --git a/tools/node_modules/eslint/node_modules/table/dist/makeStreamConfig.js b/tools/node_modules/eslint/node_modules/table/dist/makeStreamConfig.js index 92f577adbff1aa..b8ae96f40be412 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/makeStreamConfig.js +++ b/tools/node_modules/eslint/node_modules/table/dist/makeStreamConfig.js @@ -3,30 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); +exports.makeStreamConfig = void 0; const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep")); -const getBorderCharacters_1 = __importDefault(require("./getBorderCharacters")); -const validateConfig_1 = __importDefault(require("./validateConfig")); -/** - * Merges user provided border characters with the default border ("honeywell") characters. - * - */ -const makeBorder = (border) => { - return { - ...getBorderCharacters_1.default('honeywell'), - ...border, - }; -}; +const utils_1 = require("./utils"); +const validateConfig_1 = require("./validateConfig"); /** * Creates a configuration for every column using default * values for the missing configuration properties. */ -const makeColumns = (columnCount, columns = {}, columnDefault) => { +const makeColumnsConfig = (columnCount, columns = {}, columnDefault) => { return Array.from({ length: columnCount }).map((_, index) => { return { alignment: 'left', paddingLeft: 1, paddingRight: 1, truncate: Number.POSITIVE_INFINITY, + verticalAlignment: 'top', wrapWord: false, ...columnDefault, ...columns[index], @@ -37,23 +29,19 @@ const makeColumns = (columnCount, columns = {}, columnDefault) => { * Makes a new configuration object out of the userConfig object * using default values for the missing configuration properties. */ -exports.default = (userConfig) => { - var _a; - validateConfig_1.default('streamConfig.json', userConfig); +const makeStreamConfig = (userConfig) => { + validateConfig_1.validateConfig('streamConfig.json', userConfig); const config = lodash_clonedeep_1.default(userConfig); - if (!config.columnDefault || !config.columnDefault.width) { + if (config.columnDefault.width === undefined) { throw new Error('Must provide config.columnDefault.width when creating a stream.'); } - if (!config.columnCount) { - throw new Error('Must provide config.columnCount.'); - } return { - ...config, - border: makeBorder(config.border), - columnCount: config.columnCount, - columns: makeColumns(config.columnCount, config.columns, config.columnDefault), - drawVerticalLine: (_a = config.drawVerticalLine) !== null && _a !== void 0 ? _a : (() => { + drawVerticalLine: () => { return true; - }), + }, + ...config, + border: utils_1.makeBorderConfig(config.border), + columns: makeColumnsConfig(config.columnCount, config.columns, config.columnDefault), }; }; +exports.makeStreamConfig = makeStreamConfig; diff --git a/tools/node_modules/eslint/node_modules/table/dist/makeConfig.js b/tools/node_modules/eslint/node_modules/table/dist/makeTableConfig.js similarity index 55% rename from tools/node_modules/eslint/node_modules/table/dist/makeConfig.js rename to tools/node_modules/eslint/node_modules/table/dist/makeTableConfig.js index 4189a6d21b544e..e37dd75836b3e2 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/makeConfig.js +++ b/tools/node_modules/eslint/node_modules/table/dist/makeTableConfig.js @@ -3,56 +3,64 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); +exports.makeTableConfig = void 0; const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep")); -const calculateMaximumColumnWidthIndex_1 = __importDefault(require("./calculateMaximumColumnWidthIndex")); -const getBorderCharacters_1 = __importDefault(require("./getBorderCharacters")); -const validateConfig_1 = __importDefault(require("./validateConfig")); -/** - * Merges user provided border characters with the default border ("honeywell") characters. - */ -const makeBorder = (border) => { - return { - ...getBorderCharacters_1.default('honeywell'), - ...border, - }; -}; +const calculateColumnWidths_1 = __importDefault(require("./calculateColumnWidths")); +const utils_1 = require("./utils"); +const validateConfig_1 = require("./validateConfig"); /** * Creates a configuration for every column using default * values for the missing configuration properties. */ -const makeColumns = (rows, columns, columnDefault) => { - const maximumColumnWidthIndex = calculateMaximumColumnWidthIndex_1.default(rows); - return rows[0].map((_cell, index) => { +const makeColumnsConfig = (rows, columns, columnDefault) => { + const columnWidths = calculateColumnWidths_1.default(rows); + return rows[0].map((_, columnIndex) => { return { alignment: 'left', paddingLeft: 1, paddingRight: 1, truncate: Number.POSITIVE_INFINITY, - width: maximumColumnWidthIndex[index], + verticalAlignment: 'top', + width: columnWidths[columnIndex], wrapWord: false, ...columnDefault, - ...columns === null || columns === void 0 ? void 0 : columns[index], + ...columns === null || columns === void 0 ? void 0 : columns[columnIndex], }; }); }; +const makeHeaderConfig = (config) => { + if (!config.header) { + return undefined; + } + return { + alignment: 'center', + paddingLeft: 1, + paddingRight: 1, + truncate: Number.POSITIVE_INFINITY, + wrapWord: false, + ...config.header, + }; +}; /** * Makes a new configuration object out of the userConfig object * using default values for the missing configuration properties. */ -exports.default = (rows, userConfig = {}) => { +const makeTableConfig = (rows, userConfig = {}) => { var _a, _b, _c; - validateConfig_1.default('config.json', userConfig); + validateConfig_1.validateConfig('config.json', userConfig); const config = lodash_clonedeep_1.default(userConfig); return { ...config, - border: makeBorder(config.border), - columns: makeColumns(rows, config.columns, config.columnDefault), + border: utils_1.makeBorderConfig(config.border), + columns: makeColumnsConfig(rows, config.columns, config.columnDefault), drawHorizontalLine: (_a = config.drawHorizontalLine) !== null && _a !== void 0 ? _a : (() => { return true; }), drawVerticalLine: (_b = config.drawVerticalLine) !== null && _b !== void 0 ? _b : (() => { return true; }), + header: makeHeaderConfig(config), singleLine: (_c = config.singleLine) !== null && _c !== void 0 ? _c : false, }; }; +exports.makeTableConfig = makeTableConfig; diff --git a/tools/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js b/tools/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js deleted file mode 100644 index 4b79669cf5081c..00000000000000 --- a/tools/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js +++ /dev/null @@ -1,26 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const lodash_flatten_1 = __importDefault(require("lodash.flatten")); -const wrapCell_1 = __importDefault(require("./wrapCell")); -exports.default = (unmappedRows, rowHeightIndex, config) => { - const tableWidth = unmappedRows[0].length; - const mappedRows = unmappedRows.map((row, index0) => { - const rowHeight = Array.from({ length: rowHeightIndex[index0] }, () => { - return new Array(tableWidth).fill(''); - }); - // rowHeight - // [{row index within rowSaw; index2}] - // [{cell index within a virtual row; index1}] - row.forEach((cell, index1) => { - const cellLines = wrapCell_1.default(cell, config.columns[index1].width, config.columns[index1].wrapWord); - cellLines.forEach((cellLine, index2) => { - rowHeight[index2][index1] = cellLine; - }); - }); - return rowHeight; - }); - return lodash_flatten_1.default(mappedRows); -}; diff --git a/tools/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeights.js b/tools/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeights.js new file mode 100644 index 00000000000000..5727681d4e0394 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/mapDataUsingRowHeights.js @@ -0,0 +1,44 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.mapDataUsingRowHeights = void 0; +const wrapCell_1 = require("./wrapCell"); +const createEmptyStrings = (length) => { + return new Array(length).fill(''); +}; +const padCellVertically = (lines, rowHeight, columnConfig) => { + const { verticalAlignment } = columnConfig; + const availableLines = rowHeight - lines.length; + if (verticalAlignment === 'top') { + return [...lines, ...createEmptyStrings(availableLines)]; + } + if (verticalAlignment === 'bottom') { + return [...createEmptyStrings(availableLines), ...lines]; + } + return [ + ...createEmptyStrings(Math.floor(availableLines / 2)), + ...lines, + ...createEmptyStrings(Math.ceil(availableLines / 2)), + ]; +}; +const flatten = (array) => { + return [].concat(...array); +}; +const mapDataUsingRowHeights = (unmappedRows, rowHeights, config) => { + const tableWidth = unmappedRows[0].length; + const mappedRows = unmappedRows.map((unmappedRow, unmappedRowIndex) => { + const outputRowHeight = rowHeights[unmappedRowIndex]; + const outputRow = Array.from({ length: outputRowHeight }, () => { + return new Array(tableWidth).fill(''); + }); + unmappedRow.forEach((cell, cellIndex) => { + const cellLines = wrapCell_1.wrapCell(cell, config.columns[cellIndex].width, config.columns[cellIndex].wrapWord); + const paddedCellLines = padCellVertically(cellLines, outputRowHeight, config.columns[cellIndex]); + paddedCellLines.forEach((cellLine, cellLineIndex) => { + outputRow[cellLineIndex][cellIndex] = cellLine; + }); + }); + return outputRow; + }); + return flatten(mappedRows); +}; +exports.mapDataUsingRowHeights = mapDataUsingRowHeights; diff --git a/tools/node_modules/eslint/node_modules/table/dist/padTableData.js b/tools/node_modules/eslint/node_modules/table/dist/padTableData.js index e539f3d7a08629..c0016ab5cde67b 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/padTableData.js +++ b/tools/node_modules/eslint/node_modules/table/dist/padTableData.js @@ -1,10 +1,16 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = (rows, config) => { +exports.padTableData = exports.padString = void 0; +const padString = (input, paddingLeft, paddingRight) => { + return ' '.repeat(paddingLeft) + input + ' '.repeat(paddingRight); +}; +exports.padString = padString; +const padTableData = (rows, config) => { return rows.map((cells) => { - return cells.map((value, index1) => { - const column = config.columns[index1]; - return ' '.repeat(column.paddingLeft) + value + ' '.repeat(column.paddingRight); + return cells.map((cell, cellIndex) => { + const { paddingLeft, paddingRight } = config.columns[cellIndex]; + return exports.padString(cell, paddingLeft, paddingRight); }); }); }; +exports.padTableData = padTableData; diff --git a/tools/node_modules/eslint/node_modules/table/dist/stringifyTableData.js b/tools/node_modules/eslint/node_modules/table/dist/stringifyTableData.js index 16d88d553c2886..961b78d0bb574e 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/stringifyTableData.js +++ b/tools/node_modules/eslint/node_modules/table/dist/stringifyTableData.js @@ -1,7 +1,12 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = (rows) => { +exports.stringifyTableData = void 0; +const utils_1 = require("./utils"); +const stringifyTableData = (rows) => { return rows.map((cells) => { - return cells.map(String); + return cells.map((cell) => { + return utils_1.normalizeString(String(cell)); + }); }); }; +exports.stringifyTableData = stringifyTableData; diff --git a/tools/node_modules/eslint/node_modules/table/dist/table.js b/tools/node_modules/eslint/node_modules/table/dist/table.js index 94177acc7bd101..72c879dc4184ed 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/table.js +++ b/tools/node_modules/eslint/node_modules/table/dist/table.js @@ -1,27 +1,26 @@ "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); -const alignTableData_1 = __importDefault(require("./alignTableData")); -const calculateCellWidthIndex_1 = __importDefault(require("./calculateCellWidthIndex")); -const calculateRowHeightIndex_1 = __importDefault(require("./calculateRowHeightIndex")); -const drawTable_1 = __importDefault(require("./drawTable")); -const makeConfig_1 = __importDefault(require("./makeConfig")); -const mapDataUsingRowHeightIndex_1 = __importDefault(require("./mapDataUsingRowHeightIndex")); -const padTableData_1 = __importDefault(require("./padTableData")); -const stringifyTableData_1 = __importDefault(require("./stringifyTableData")); -const truncateTableData_1 = __importDefault(require("./truncateTableData")); -const validateTableData_1 = __importDefault(require("./validateTableData")); -exports.default = (data, userConfig = {}) => { - validateTableData_1.default(data); - let rows = stringifyTableData_1.default(data); - const config = makeConfig_1.default(rows, userConfig); - rows = truncateTableData_1.default(rows, config); - const rowHeightIndex = calculateRowHeightIndex_1.default(rows, config); - rows = mapDataUsingRowHeightIndex_1.default(rows, rowHeightIndex, config); - rows = alignTableData_1.default(rows, config); - rows = padTableData_1.default(rows, config); - const cellWidthIndex = calculateCellWidthIndex_1.default(rows[0]); - return drawTable_1.default(rows, cellWidthIndex, rowHeightIndex, config); +exports.table = void 0; +const alignTableData_1 = require("./alignTableData"); +const calculateCellWidths_1 = require("./calculateCellWidths"); +const calculateRowHeights_1 = require("./calculateRowHeights"); +const drawTable_1 = require("./drawTable"); +const makeTableConfig_1 = require("./makeTableConfig"); +const mapDataUsingRowHeights_1 = require("./mapDataUsingRowHeights"); +const padTableData_1 = require("./padTableData"); +const stringifyTableData_1 = require("./stringifyTableData"); +const truncateTableData_1 = require("./truncateTableData"); +const validateTableData_1 = require("./validateTableData"); +const table = (data, userConfig = {}) => { + validateTableData_1.validateTableData(data); + let rows = stringifyTableData_1.stringifyTableData(data); + const config = makeTableConfig_1.makeTableConfig(rows, userConfig); + rows = truncateTableData_1.truncateTableData(rows, config); + const rowHeights = calculateRowHeights_1.calculateRowHeights(rows, config); + rows = mapDataUsingRowHeights_1.mapDataUsingRowHeights(rows, rowHeights, config); + rows = alignTableData_1.alignTableData(rows, config); + rows = padTableData_1.padTableData(rows, config); + const cellWidths = calculateCellWidths_1.calculateCellWidths(rows[0]); + return drawTable_1.drawTable(rows, cellWidths, rowHeights, config); }; +exports.table = table; diff --git a/tools/node_modules/eslint/node_modules/table/dist/truncateTableData.js b/tools/node_modules/eslint/node_modules/table/dist/truncateTableData.js index 8d0f7a31a4d669..5810242a3d5837 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/truncateTableData.js +++ b/tools/node_modules/eslint/node_modules/table/dist/truncateTableData.js @@ -3,17 +3,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); +exports.truncateTableData = exports.truncateString = void 0; const lodash_truncate_1 = __importDefault(require("lodash.truncate")); +const truncateString = (input, length) => { + return lodash_truncate_1.default(input, { length, + omission: '…' }); +}; +exports.truncateString = truncateString; /** * @todo Make it work with ASCII content. */ -exports.default = (rows, config) => { +const truncateTableData = (rows, config) => { return rows.map((cells) => { - return cells.map((content, index) => { - return lodash_truncate_1.default(content, { - length: config.columns[index].truncate, - omission: '…', - }); + return cells.map((cell, cellIndex) => { + return exports.truncateString(cell, config.columns[cellIndex].truncate); }); }); }; +exports.truncateTableData = truncateTableData; diff --git a/tools/node_modules/eslint/node_modules/table/dist/utils.js b/tools/node_modules/eslint/node_modules/table/dist/utils.js new file mode 100644 index 00000000000000..2d398b0ee45e85 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/dist/utils.js @@ -0,0 +1,93 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.distributeUnevenly = exports.countSpaceSequence = exports.groupBySizes = exports.makeBorderConfig = exports.splitAnsi = exports.normalizeString = void 0; +const slice_ansi_1 = __importDefault(require("slice-ansi")); +const strip_ansi_1 = __importDefault(require("strip-ansi")); +const getBorderCharacters_1 = require("./getBorderCharacters"); +/** + * Converts Windows-style newline to Unix-style + * + * @internal + */ +const normalizeString = (input) => { + return input.replace(/\r\n/g, '\n'); +}; +exports.normalizeString = normalizeString; +/** + * Splits ansi string by newlines + * + * @internal + */ +const splitAnsi = (input) => { + const lengths = strip_ansi_1.default(input).split('\n').map(({ length }) => { + return length; + }); + const result = []; + let startIndex = 0; + lengths.forEach((length) => { + result.push(length === 0 ? '' : slice_ansi_1.default(input, startIndex, startIndex + length)); + // Plus 1 for the newline character itself + startIndex += length + 1; + }); + return result; +}; +exports.splitAnsi = splitAnsi; +/** + * Merges user provided border characters with the default border ("honeywell") characters. + * + * @internal + */ +const makeBorderConfig = (border) => { + return { + ...getBorderCharacters_1.getBorderCharacters('honeywell'), + ...border, + }; +}; +exports.makeBorderConfig = makeBorderConfig; +/** + * Groups the array into sub-arrays by sizes. + * + * @internal + * @example + * groupBySizes(['a', 'b', 'c', 'd', 'e'], [2, 1, 2]) = [ ['a', 'b'], ['c'], ['d', 'e'] ] + */ +const groupBySizes = (array, sizes) => { + let startIndex = 0; + return sizes.map((size) => { + const group = array.slice(startIndex, startIndex + size); + startIndex += size; + return group; + }); +}; +exports.groupBySizes = groupBySizes; +/** + * Counts the number of continuous spaces in a string + * + * @internal + * @example + * countGroupSpaces('a bc de f') = 3 + */ +const countSpaceSequence = (input) => { + var _a, _b; + return (_b = (_a = input.match(/\s+/g)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0; +}; +exports.countSpaceSequence = countSpaceSequence; +/** + * Creates the non-increasing number array given sum and length + * whose the difference between maximum and minimum is not greater than 1 + * + * @internal + * @example + * distributeUnevenly(6, 3) = [2, 2, 2] + * distributeUnevenly(8, 3) = [3, 3, 2] + */ +const distributeUnevenly = (sum, length) => { + const result = Array.from({ length }).fill(Math.floor(sum / length)); + return result.map((element, index) => { + return element + (index < sum % length ? 1 : 0); + }); +}; +exports.distributeUnevenly = distributeUnevenly; diff --git a/tools/node_modules/eslint/node_modules/table/dist/validateConfig.js b/tools/node_modules/eslint/node_modules/table/dist/validateConfig.js index 50d837c00ec7e0..f1a743bc1dc34f 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/validateConfig.js +++ b/tools/node_modules/eslint/node_modules/table/dist/validateConfig.js @@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); +exports.validateConfig = void 0; const validators_1 = __importDefault(require("./generated/validators")); -exports.default = (schemaId, config) => { +const validateConfig = (schemaId, config) => { const validate = validators_1.default[schemaId]; if (!validate(config) && validate.errors) { const errors = validate.errors.map((error) => { @@ -21,3 +22,4 @@ exports.default = (schemaId, config) => { throw new Error('Invalid config.'); } }; +exports.validateConfig = validateConfig; diff --git a/tools/node_modules/eslint/node_modules/table/dist/validateTableData.js b/tools/node_modules/eslint/node_modules/table/dist/validateTableData.js index 3a11457c714660..60ae3074093ddb 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/validateTableData.js +++ b/tools/node_modules/eslint/node_modules/table/dist/validateTableData.js @@ -1,6 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = (rows) => { +exports.validateTableData = void 0; +const utils_1 = require("./utils"); +const validateTableData = (rows) => { if (!Array.isArray(rows)) { throw new TypeError('Table data must be an array.'); } @@ -20,9 +22,10 @@ exports.default = (rows) => { } for (const cell of row) { // eslint-disable-next-line no-control-regex - if (/[\u0001-\u0006\u0008\u0009\u000B-\u001A]/.test(cell)) { + if (/[\u0001-\u0006\u0008\u0009\u000B-\u001A]/.test(utils_1.normalizeString(String(cell)))) { throw new Error('Table data must not contain control characters.'); } } } }; +exports.validateTableData = validateTableData; diff --git a/tools/node_modules/eslint/node_modules/table/dist/wrapCell.js b/tools/node_modules/eslint/node_modules/table/dist/wrapCell.js index df64e7568c0756..64229d2553358f 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/wrapCell.js +++ b/tools/node_modules/eslint/node_modules/table/dist/wrapCell.js @@ -1,25 +1,9 @@ "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); -const slice_ansi_1 = __importDefault(require("slice-ansi")); -const strip_ansi_1 = __importDefault(require("strip-ansi")); -const wrapString_1 = __importDefault(require("./wrapString")); -const wrapWord_1 = __importDefault(require("./wrapWord")); -const splitAnsi = (input) => { - const lengths = strip_ansi_1.default(input).split('\n').map(({ length }) => { - return length; - }); - const result = []; - let startIndex = 0; - lengths.forEach((length) => { - result.push(length === 0 ? '' : slice_ansi_1.default(input, startIndex, startIndex + length)); - // Plus 1 for the newline character itself - startIndex += length + 1; - }); - return result; -}; +exports.wrapCell = void 0; +const utils_1 = require("./utils"); +const wrapString_1 = require("./wrapString"); +const wrapWord_1 = require("./wrapWord"); /** * Wrap a single cell value into a list of lines * @@ -27,17 +11,17 @@ const splitAnsi = (input) => { * depending on user configuration. * */ -exports.default = (cellValue, columnWidth, useWrapWord) => { +const wrapCell = (cellValue, cellWidth, useWrapWord) => { // First split on literal newlines - const cellLines = splitAnsi(cellValue); + const cellLines = utils_1.splitAnsi(cellValue); // Then iterate over the list and word-wrap every remaining line if necessary. for (let lineNr = 0; lineNr < cellLines.length;) { let lineChunks; if (useWrapWord) { - lineChunks = wrapWord_1.default(cellLines[lineNr], columnWidth); + lineChunks = wrapWord_1.wrapWord(cellLines[lineNr], cellWidth); } else { - lineChunks = wrapString_1.default(cellLines[lineNr], columnWidth); + lineChunks = wrapString_1.wrapString(cellLines[lineNr], cellWidth); } // Replace our original array element with whatever the wrapping returned cellLines.splice(lineNr, 1, ...lineChunks); @@ -45,3 +29,4 @@ exports.default = (cellValue, columnWidth, useWrapWord) => { } return cellLines; }; +exports.wrapCell = wrapCell; diff --git a/tools/node_modules/eslint/node_modules/table/dist/wrapString.js b/tools/node_modules/eslint/node_modules/table/dist/wrapString.js index d61620857e2e17..08fcc3fee5bd06 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/wrapString.js +++ b/tools/node_modules/eslint/node_modules/table/dist/wrapString.js @@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); +exports.wrapString = void 0; const slice_ansi_1 = __importDefault(require("slice-ansi")); const string_width_1 = __importDefault(require("string-width")); /** @@ -13,7 +14,7 @@ const string_width_1 = __importDefault(require("string-width")); * in that whitespace characters that occur on a chunk size limit are trimmed. * */ -exports.default = (subject, size) => { +const wrapString = (subject, size) => { let subjectSlice = subject; const chunks = []; do { @@ -22,3 +23,4 @@ exports.default = (subject, size) => { } while (string_width_1.default(subjectSlice)); return chunks; }; +exports.wrapString = wrapString; diff --git a/tools/node_modules/eslint/node_modules/table/dist/wrapWord.js b/tools/node_modules/eslint/node_modules/table/dist/wrapWord.js index bc864ace513b35..1f2da3c570320a 100644 --- a/tools/node_modules/eslint/node_modules/table/dist/wrapWord.js +++ b/tools/node_modules/eslint/node_modules/table/dist/wrapWord.js @@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); +exports.wrapWord = void 0; const slice_ansi_1 = __importDefault(require("slice-ansi")); const strip_ansi_1 = __importDefault(require("strip-ansi")); const calculateStringLengths = (input, size) => { @@ -28,7 +29,7 @@ const calculateStringLengths = (input, size) => { } while (subject.length); return chunks; }; -exports.default = (input, size) => { +const wrapWord = (input, size) => { const result = []; let startIndex = 0; calculateStringLengths(input, size).forEach(([length, offset]) => { @@ -37,3 +38,4 @@ exports.default = (input, size) => { }); return result; }; +exports.wrapWord = wrapWord; diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/README.md b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/README.md index f9273a3fdf6f46..269f2605db654a 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/README.md +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/README.md @@ -19,6 +19,24 @@ Supports JSON Schema draft-06/07/2019-09/2020-12 (draft-04 is supported in [vers [](https://www.mozilla.org)[](https://opencollective.com/ajv) +## Ajv online event - May 20, 10am PT / 6pm UK + +We will talk about: +- new features of Ajv version 8. +- the improvements sponsored by Mozilla's MOSS grant. +- how Ajv is used in JavaScript applications. + +Speakers: +- [Evgeny Poberezkin](https://github.com/epoberezkin), the creator of Ajv. +- [Mehan Jayasuriya](https://github.com/mehan), Program Officer at Mozilla Foundation, leading the [MOSS](https://www.mozilla.org/en-US/moss/) and other programs investing in the open source and community ecosystems. +- [Matteo Collina](https://github.com/mcollina), Technical Director at NearForm and Node.js Technical Steering Committee member, creator of Fastify web framework. +- [Kin Lane](https://github.com/kinlane), Chief Evangelist at Postman. Studying the tech, business & politics of APIs since 2010. Presidential Innovation Fellow during the Obama administration. +- [Ulysse Carion](https://github.com/ucarion), the creator of JSON Type Definition specification. + +[Gajus Kuizinas](https://github.com/gajus) will host the event. + +Please [register here](https://us02web.zoom.us/webinar/register/2716192553618/WN_erJ_t4ICTHOnGC1SOybNnw). + ## Contributing More than 100 people contributed to Ajv, and we would love to have you join the development. We welcome implementing new features that will benefit many users and ideas to improve our documentation. diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/package.json b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/package.json index 22f7a782c40b27..054cde613577db 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/package.json +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/package.json @@ -1,6 +1,6 @@ { "name": "ajv", - "version": "8.1.0", + "version": "8.2.0", "description": "Another JSON Schema Validator", "main": "dist/ajv.js", "types": "dist/ajv.d.ts", @@ -17,7 +17,7 @@ "test-codegen": "nyc cross-env TS_NODE_PROJECT=spec/tsconfig.json mocha -r ts-node/register 'spec/codegen.spec.ts' -R spec", "test-debug": "npm run test-spec -- --inspect-brk", "test-cov": "nyc npm run test-spec", - "bundle": "rm -rf bundle && node ./scripts/bundle.js ajv ajv7 ajv7 && node ./scripts/bundle.js 2019 ajv2019 ajv2019 && node ./scripts/bundle.js jtd ajvJTD ajvJTD", + "bundle": "rm -rf bundle && rollup -c", "build": "rm -rf dist && tsc && cp -r lib/refs dist && rm dist/refs/json-schema-2019-09/index.ts && rm dist/refs/json-schema-2020-12/index.ts && rm dist/refs/jtd-schema.ts", "json-tests": "rm -rf spec/_json/*.js && node scripts/jsontests", "test-karma": "karma start", @@ -64,6 +64,10 @@ }, "devDependencies": { "@ajv-validator/config": "^0.3.0", + "@rollup/plugin-commonjs": "^18.0.0", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-node-resolve": "^11.2.1", + "@rollup/plugin-typescript": "^8.2.1", "@types/chai": "^4.2.12", "@types/mocha": "^8.0.3", "@types/node": "^14.0.27", @@ -72,7 +76,6 @@ "@typescript-eslint/parser": "^3.8.0", "@vuepress/shared-utils": "^1.8.2", "ajv-formats": "^2.0.0", - "browserify": "^17.0.0", "chai": "^4.0.1", "cross-env": "^7.0.2", "dayjs": "^1.10.4", @@ -93,7 +96,8 @@ "node-fetch": "^2.6.1", "nyc": "^15.0.0", "prettier": "^2.0.5", - "terser": "^5.2.1", + "rollup": "^2.44.0", + "rollup-plugin-terser": "^7.0.2", "ts-node": "^9.0.0", "tsify": "^5.0.2", "typescript": "^4.2.0", diff --git a/tools/node_modules/eslint/node_modules/table/package.json b/tools/node_modules/eslint/node_modules/table/package.json index 5d331e4b5287bf..04210d11c5b71a 100644 --- a/tools/node_modules/eslint/node_modules/table/package.json +++ b/tools/node_modules/eslint/node_modules/table/package.json @@ -7,7 +7,6 @@ "dependencies": { "ajv": "^8.0.1", "lodash.clonedeep": "^4.5.0", - "lodash.flatten": "^4.4.0", "lodash.truncate": "^4.4.2", "slice-ansi": "^4.0.0", "string-width": "^4.2.0", @@ -17,7 +16,6 @@ "devDependencies": { "@types/chai": "^4.2.16", "@types/lodash.clonedeep": "^4.5.6", - "@types/lodash.flatten": "^4.4.6", "@types/lodash.mapvalues": "^4.6.6", "@types/lodash.truncate": "^4.4.6", "@types/mocha": "^8.2.2", @@ -75,7 +73,8 @@ "test/**/*.ts" ], "reporter": [ - "text-lcov" + "text-lcov", + "text" ] }, "repository": { @@ -89,7 +88,7 @@ "create-readme": "gitdown ./.README/README.md --output-file ./README.md", "create-validators": "rm -fr ./src/generated && mkdirp ./src/generated && ajv compile --all-errors --inline-refs=false -s src/schemas/config -s src/schemas/streamConfig -r src/schemas/shared -c ajv-keywords/dist/keywords/typeof -o | js-beautify > ./src/generated/validators.js", "lint": "eslint --ignore-path .gitignore ./src ./test", - "test": "npm run create-validators && mocha --require ts-node/register ./test/**/*.ts" + "test": "npm run create-validators && mocha --require ts-node/register \"./test/**/*.ts\"" }, - "version": "6.5.1" + "version": "6.7.0" } diff --git a/tools/node_modules/eslint/package.json b/tools/node_modules/eslint/package.json index 4f87ef6403bc82..51a76ec31c8449 100644 --- a/tools/node_modules/eslint/package.json +++ b/tools/node_modules/eslint/package.json @@ -1,6 +1,6 @@ { "name": "eslint", - "version": "7.25.0", + "version": "7.26.0", "author": "Nicholas C. Zakas ", "description": "An AST-based pattern checker for JavaScript.", "bin": { @@ -44,7 +44,7 @@ "bugs": "https://github.com/eslint/eslint/issues/", "dependencies": { "@babel/code-frame": "7.12.11", - "@eslint/eslintrc": "^0.4.0", + "@eslint/eslintrc": "^0.4.1", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -84,7 +84,6 @@ "devDependencies": { "@babel/core": "^7.4.3", "@babel/preset-env": "^7.4.3", - "acorn": "^7.2.0", "babel-loader": "^8.0.5", "chai": "^4.0.1", "cheerio": "^0.22.0", From 36bb8daba527af0ce9689dbca504f6b261ec4e21 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Thu, 13 May 2021 10:45:11 +0200 Subject: [PATCH 70/86] crypto: forbid NODE-ED25519 and NODE-ED448 "raw" key export closes #38655 PR-URL: https://github.com/nodejs/node/pull/38668 Reviewed-By: Gus Caplan Reviewed-By: James M Snell Reviewed-By: Rich Trott --- lib/internal/crypto/webcrypto.js | 7 +++++-- test/parallel/test-webcrypto-ed25519-ed448.js | 15 ++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/internal/crypto/webcrypto.js b/lib/internal/crypto/webcrypto.js index b28ee9b8167be5..900ac7a6e8ad7b 100644 --- a/lib/internal/crypto/webcrypto.js +++ b/lib/internal/crypto/webcrypto.js @@ -288,8 +288,11 @@ async function exportKeyRaw(key) { case 'NODE-ED25519': // Fall through case 'NODE-ED448': - return lazyRequire('internal/crypto/ec') - .ecExportKey(key, kWebCryptoKeyFormatRaw); + if (key.type === 'public') { + return lazyRequire('internal/crypto/ec') + .ecExportKey(key, kWebCryptoKeyFormatRaw); + } + break; case 'ECDSA': // Fall through case 'ECDH': diff --git a/test/parallel/test-webcrypto-ed25519-ed448.js b/test/parallel/test-webcrypto-ed25519-ed448.js index 91e0fb8bf3fe0d..9c60ceff64b1b4 100644 --- a/test/parallel/test-webcrypto-ed25519-ed448.js +++ b/test/parallel/test-webcrypto-ed25519-ed448.js @@ -268,15 +268,12 @@ async function test2(namedCurve) { true, ['verify']), ]); - const [ - rawKey1, - rawKey2, - ] = await Promise.all([ - subtle.exportKey('raw', privateKey), - subtle.exportKey('raw', publicKey), - ]); - assert.deepStrictEqual(Buffer.from(rawKey1), vector.privateKey); - assert.deepStrictEqual(Buffer.from(rawKey2), vector.publicKey); + const rawPublicKey = await subtle.exportKey('raw', publicKey); + assert.deepStrictEqual(Buffer.from(rawPublicKey), vector.publicKey); + + assert.rejects(subtle.exportKey('raw', privateKey), { + message: new RegExp(`Unable to export a raw ${namedCurve} private key`) + }).then(common.mustCall()); const sig = await subtle.sign( { name: namedCurve }, From fbf02e3198f04efa94aa643a62c4dd734afab75b Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Mon, 10 May 2021 12:33:11 +0200 Subject: [PATCH 71/86] util: add util.types.isKeyObject and util.types.isCryptoKey MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #38611 PR-URL: https://github.com/nodejs/node/pull/38619 Reviewed-By: James M Snell Reviewed-By: Tobias Nießen --- doc/api/util.md | 20 +++++++++++++ lib/internal/crypto/keys.js | 4 +-- lib/internal/util/types.js | 37 ++++++++++++++++++++++++ test/parallel/test-crypto-key-objects.js | 25 +++++++++++++++- test/parallel/test-util-types.js | 10 +++++++ test/parallel/test-webcrypto-keygen.js | 23 ++++++++++++++- 6 files changed, 115 insertions(+), 4 deletions(-) diff --git a/doc/api/util.md b/doc/api/util.md index 4f3ff2e7358df9..93042b3d5ff58e 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -1483,6 +1483,16 @@ util.types.isBoxedPrimitive(Object(Symbol('foo'))); // Returns true util.types.isBoxedPrimitive(Object(BigInt(5))); // Returns true ``` +### `util.types.isCryptoKey(value)` + + +* `value` {Object} +* Returns: {boolean} + +Returns `true` if `value` is a {CryptoKey}, `false` otherwise. + ### `util.types.isDataView(value)` + +* `value` {Object} +* Returns: {boolean} + +Returns `true` if `value` is a {KeyObject}, `false` otherwise. + ### `util.types.isMap(value)` + +The `TZ` environment variable is used to specify the timezone configuration. + +While the Node.js support for `TZ` will not handle all of the various +[ways that `TZ` is handled in other environments][], it will support basic +[timezone IDs][] (such as `'Etc/UTC'`, `'Europe/Paris'` or `'America/New_York'`. +It may support a few other abbreviations or aliases, but these are strongly +discouraged and not guaranteed. + +```console +$ TZ=Europe/Dublin node -pe "new Date().toString()" +Wed May 12 2021 20:30:48 GMT+0100 (Irish Standard Time) +``` + ### `UV_THREADPOOL_SIZE=size` Set the number of threads used in libuv's threadpool to `size` threads. @@ -1741,3 +1772,5 @@ $ node --max-old-space-size=1536 index.js [jitless]: https://v8.dev/blog/jitless [libuv threadpool documentation]: https://docs.libuv.org/en/latest/threadpool.html [remote code execution]: https://www.owasp.org/index.php/Code_Injection +[timezone IDs]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones +[ways that `TZ` is handled in other environments]: https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html diff --git a/src/node.cc b/src/node.cc index b757013ce125cd..bf041fb682a2c2 100644 --- a/src/node.cc +++ b/src/node.cc @@ -937,6 +937,14 @@ int InitializeNodeWithArgs(std::vector* argv, return 9; } per_process::metadata.versions.InitializeIntlVersions(); + +# ifndef __POSIX__ + std::string tz; + if (credentials::SafeGetenv("TZ", &tz) && !tz.empty()) { + i18n::SetDefaultTimeZone(tz.c_str()); + } +# endif + #endif NativeModuleEnv::InitializeCodeCache(); diff --git a/src/node_env_var.cc b/src/node_env_var.cc index e6d9573ca7ccef..b13f7fcd16fd50 100644 --- a/src/node_env_var.cc +++ b/src/node_env_var.cc @@ -2,6 +2,7 @@ #include "env-inl.h" #include "node_errors.h" #include "node_external_reference.h" +#include "node_i18n.h" #include "node_process.h" #include // tzset(), _tzset() @@ -69,15 +70,32 @@ std::shared_ptr system_environment = std::make_shared(); } // namespace per_process template -void DateTimeConfigurationChangeNotification(Isolate* isolate, const T& key) { +void DateTimeConfigurationChangeNotification( + Isolate* isolate, + const T& key, + const char* val = nullptr) { if (key.length() == 2 && key[0] == 'T' && key[1] == 'Z') { #ifdef __POSIX__ tzset(); + isolate->DateTimeConfigurationChangeNotification( + Isolate::TimeZoneDetection::kRedetect); #else _tzset(); + +# if defined(NODE_HAVE_I18N_SUPPORT) + isolate->DateTimeConfigurationChangeNotification( + Isolate::TimeZoneDetection::kSkip); + + // On windows, the TZ environment is not supported out of the box. + // By default, v8 will only be able to detect the system configured + // timezone. This supports using the TZ environment variable to set + // the default timezone instead. + if (val != nullptr) i18n::SetDefaultTimeZone(val); +# else + isolate->DateTimeConfigurationChangeNotification( + Isolate::TimeZoneDetection::kRedetect); +# endif #endif - auto constexpr time_zone_detection = Isolate::TimeZoneDetection::kRedetect; - isolate->DateTimeConfigurationChangeNotification(time_zone_detection); } } @@ -128,7 +146,7 @@ void RealEnvStore::Set(Isolate* isolate, if (key.length() > 0 && key[0] == '=') return; #endif uv_os_setenv(*key, *val); - DateTimeConfigurationChangeNotification(isolate, key); + DateTimeConfigurationChangeNotification(isolate, key, *val); } int32_t RealEnvStore::Query(const char* key) const { diff --git a/src/node_i18n.cc b/src/node_i18n.cc index 42e618ac30181f..1b105cc9e56cd6 100644 --- a/src/node_i18n.cc +++ b/src/node_i18n.cc @@ -542,6 +542,16 @@ bool InitializeICUDirectory(const std::string& path) { return status == U_ZERO_ERROR; } +void SetDefaultTimeZone(const char* tzid) { + size_t tzidlen = strlen(tzid) + 1; + UErrorCode status = U_ZERO_ERROR; + MaybeStackBuffer id(tzidlen); + u_charsToUChars(tzid, id.out(), tzidlen); + // This is threadsafe: + ucal_setDefaultTimeZone(id.out(), &status); + CHECK(U_SUCCESS(status)); +} + int32_t ToUnicode(MaybeStackBuffer* buf, const char* input, size_t length) { diff --git a/src/node_i18n.h b/src/node_i18n.h index 22164e6647d913..1e9f13ebc93f02 100644 --- a/src/node_i18n.h +++ b/src/node_i18n.h @@ -40,6 +40,8 @@ namespace i18n { bool InitializeICUDirectory(const std::string& path); +void SetDefaultTimeZone(const char* tzid); + enum idna_mode { // Default mode for maximum compatibility. IDNA_DEFAULT, diff --git a/test/parallel/test-datetime-change-notify.js b/test/parallel/test-datetime-change-notify.js new file mode 100644 index 00000000000000..94f126179b79de --- /dev/null +++ b/test/parallel/test-datetime-change-notify.js @@ -0,0 +1,24 @@ +'use strict'; + +const common = require('../common'); +const { isMainThread } = require('worker_threads'); + +if (!common.hasIntl) + common.skip('Intl not present.'); + +if (!isMainThread) + common.skip('Test not support running within a worker'); + +const assert = require('assert'); + +process.env.TZ = 'Etc/UTC'; +assert.match(new Date().toString(), /GMT\+0000/); + +process.env.TZ = 'America/New_York'; +assert.match(new Date().toString(), /Eastern (Standard|Daylight) Time/); + +process.env.TZ = 'America/Los_Angeles'; +assert.match(new Date().toString(), /Pacific (Standard|Daylight) Time/); + +process.env.TZ = 'Europe/Dublin'; +assert.match(new Date().toString(), /Irish/); From 5c38a554ece48eae6bc9ac86f84c5908feb11eb9 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Wed, 12 May 2021 13:36:56 -0700 Subject: [PATCH 74/86] doc: clarify synchronous blocking of Worker stdio Fixes: https://github.com/nodejs/node/issues/25630 Signed-off-by: James M Snell PR-URL: https://github.com/nodejs/node/pull/38658 Reviewed-By: Anna Henningsen Reviewed-By: Antoine du Hamel --- doc/api/worker_threads.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md index 5d0781751ca6b2..f345b9dba76913 100644 --- a/doc/api/worker_threads.md +++ b/doc/api/worker_threads.md @@ -1191,6 +1191,45 @@ active handle in the event system. If the worker is already `unref()`ed calling ## Notes +### Synchronous blocking of stdio + +`Worker`s utilize message passing via {MessagePort} to implement interactions +with `stdio`. This means that `stdio` output originating from a `Worker` can +get blocked by synchronous code on the receiving end that is blocking the +Node.js event loop. + +```mjs +import { + Worker, + isMainThread, +} from 'worker_threads'; + +if (isMainThread) { + new Worker(new URL(import.meta.url)); + for (let n = 0; n < 1e10; n++) {} +} else { + // This output will be blocked by the for loop in the main thread. + console.log('foo'); +} +``` + +```cjs +'use strict'; + +const { + Worker, + isMainThread, +} = require('worker_threads'); + +if (isMainThread) { + new Worker(__filename); + for (let n = 0; n < 1e10; n++) {} +} else { + // This output will be blocked by the for loop in the main thread. + console.log('foo'); +} +``` + ### Launching worker threads from preload scripts Take care when launching worker threads from preload scripts (scripts loaded From 3a5856cbc3876ff67a7315bdfff776a26ace2ad6 Mon Sep 17 00:00:00 2001 From: Nitzan Uziely Date: Mon, 10 May 2021 01:45:52 +0300 Subject: [PATCH 75/86] fs: fix async iterator partial writes fix an issue where chunks might be partially written when using writeFile with an async iterator. PR-URL: https://github.com/nodejs/node/pull/38615 Reviewed-By: Antoine du Hamel Reviewed-By: Rich Trott Reviewed-By: James M Snell --- lib/internal/fs/promises.js | 14 ++++++++++---- test/parallel/test-fs-promises-writefile.js | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/lib/internal/fs/promises.js b/lib/internal/fs/promises.js index 55c6f731587351..ced98ae30a293d 100644 --- a/lib/internal/fs/promises.js +++ b/lib/internal/fs/promises.js @@ -281,10 +281,16 @@ async function writeFileHandle(filehandle, data, signal, encoding) { if (isCustomIterable(data)) { for await (const buf of data) { checkAborted(signal); - await write( - filehandle, buf, undefined, - isArrayBufferView(buf) ? buf.byteLength : encoding); - checkAborted(signal); + const toWrite = + isArrayBufferView(buf) ? buf : Buffer.from(buf, encoding || 'utf8'); + let remaining = toWrite.byteLength; + while (remaining > 0) { + const writeSize = MathMin(kWriteFileMaxChunkSize, remaining); + const { bytesWritten } = await write( + filehandle, toWrite, toWrite.byteLength - remaining, writeSize); + remaining -= bytesWritten; + checkAborted(signal); + } } return; } diff --git a/test/parallel/test-fs-promises-writefile.js b/test/parallel/test-fs-promises-writefile.js index a3a5937e9b0724..494a9015773d13 100644 --- a/test/parallel/test-fs-promises-writefile.js +++ b/test/parallel/test-fs-promises-writefile.js @@ -25,6 +25,14 @@ const iterable = { yield 'c'; } }; + +const veryLargeBuffer = { + expected: 'dogs running'.repeat(512 * 1024), + *[Symbol.iterator]() { + yield Buffer.from('dogs running'.repeat(512 * 1024), 'utf8'); + } +}; + function iterableWith(value) { return { *[Symbol.iterator]() { @@ -106,6 +114,12 @@ async function doWriteAsyncIterable() { assert.deepStrictEqual(data, asyncIterable.expected); } +async function doWriteAsyncLargeIterable() { + await fsPromises.writeFile(dest, veryLargeBuffer); + const data = fs.readFileSync(dest, 'utf-8'); + assert.deepStrictEqual(data, veryLargeBuffer.expected); +} + async function doWriteInvalidValues() { await Promise.all( [42, 42n, {}, Symbol('42'), true, undefined, null, NaN].map((value) => @@ -158,5 +172,6 @@ async function doReadWithEncoding() { await doWriteIterableWithEncoding(); await doWriteBufferIterable(); await doWriteAsyncIterable(); + await doWriteAsyncLargeIterable(); await doWriteInvalidValues(); })().then(common.mustCall()); From 347b9f23043a0b76bd2e4ab91f474ef4c90e1088 Mon Sep 17 00:00:00 2001 From: moander Date: Sun, 9 May 2021 22:43:57 +0200 Subject: [PATCH 76/86] errors: remove input from ERR_INVALID_URL message Avoid potentially huge messages and leaked secrets. PR-URL: https://github.com/nodejs/node/pull/38614 Reviewed-By: James M Snell Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: Joyee Cheung Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott Reviewed-By: Darshan Sen --- lib/internal/errors.js | 4 +++- test/es-module/test-esm-loader-invalid-url.mjs | 12 ++++++++---- test/parallel/test-whatwg-url-custom-parsing.js | 7 ++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 352f8d49ef5f20..a226b2d6898d4c 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -1265,7 +1265,9 @@ E('ERR_INVALID_TUPLE', '%s must be an iterable %s tuple', TypeError); E('ERR_INVALID_URI', 'URI malformed', URIError); E('ERR_INVALID_URL', function(input) { this.input = input; - return `Invalid URL: ${input}`; + // Don't include URL in message. + // (See https://github.com/nodejs/node/pull/38614) + return 'Invalid URL'; }, TypeError); E('ERR_INVALID_URL_SCHEME', (expected) => { diff --git a/test/es-module/test-esm-loader-invalid-url.mjs b/test/es-module/test-esm-loader-invalid-url.mjs index e9f04d0af4d4fe..7dce946da2c3c3 100644 --- a/test/es-module/test-esm-loader-invalid-url.mjs +++ b/test/es-module/test-esm-loader-invalid-url.mjs @@ -3,8 +3,12 @@ import { expectsError, mustCall } from '../common/index.mjs'; import assert from 'assert'; import('../fixtures/es-modules/test-esm-ok.mjs') -.then(assert.fail, expectsError({ - code: 'ERR_INVALID_URL', - message: 'Invalid URL: ../fixtures/es-modules/test-esm-ok.mjs' -})) +.then(assert.fail, (error) => { + expectsError({ + code: 'ERR_INVALID_URL', + message: 'Invalid URL' + })(error); + + assert.strictEqual(error.input, '../fixtures/es-modules/test-esm-ok.mjs'); +}) .then(mustCall()); diff --git a/test/parallel/test-whatwg-url-custom-parsing.js b/test/parallel/test-whatwg-url-custom-parsing.js index a07d776d0a25cc..a3532374ca684e 100644 --- a/test/parallel/test-whatwg-url-custom-parsing.js +++ b/test/parallel/test-whatwg-url-custom-parsing.js @@ -55,11 +55,8 @@ for (const test of failureTests) { () => new URL(test.input, test.base), (error) => { assert.throws(() => { throw error; }, expectedError); - - // The input could be processed, so we don't do strict matching here - let match; - assert(match = (`${error}`).match(/Invalid URL: (.*)$/)); - assert.strictEqual(error.input, match[1]); + assert.strictEqual(`${error}`, 'TypeError [ERR_INVALID_URL]: Invalid URL'); + assert.strictEqual(error.message, 'Invalid URL'); return true; }); } From 0100a3b02643593eead80d74a576abcdf648f188 Mon Sep 17 00:00:00 2001 From: Hitesh Sharma Date: Sun, 9 May 2021 19:59:52 +0530 Subject: [PATCH 77/86] doc: add documentation for fs.WriteStream.close() PR-URL: https://github.com/nodejs/node/pull/38610 Fixes: https://github.com/nodejs/node/issues/38606 Reviewed-By: James M Snell Reviewed-By: Rich Trott Reviewed-By: Darshan Sen --- doc/api/fs.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/api/fs.md b/doc/api/fs.md index ae1db3899f4fe8..9f7ea62ad12e42 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -5948,6 +5948,18 @@ added: v0.4.7 The number of bytes written so far. Does not include data that is still queued for writing. +#### `writeStream.close([callback])` + + +* `callback` {Function} + * `err` {Error} + +Closes `writeStream`. Optionally accepts a +callback that will be executed once the `writeStream` +is closed. + #### `writeStream.path` - * `path` {string|Buffer|URL} * `options` {string|Object} * `encoding` {string} **Default:** `'utf8'` @@ -1316,8 +1318,12 @@ try { const controller = new AbortController(); const { signal } = controller; const data = new Uint8Array(Buffer.from('Hello Node.js')); - writeFile('message.txt', data, { signal }); + const promise = writeFile('message.txt', data, { signal }); + + // Abort the request before the promise settles. controller.abort(); + + await promise; } catch (err) { // When a request is aborted - err is an AbortError console.error(err); From 5b40e2f596971d430abd5a26d9cc0c8e7c519780 Mon Sep 17 00:00:00 2001 From: Voltrex <62040526+VoltrexMaster@users.noreply.github.com> Date: Wed, 21 Apr 2021 09:00:12 +0430 Subject: [PATCH 80/86] events: use nullish coalencing operator PR-URL: https://github.com/nodejs/node/pull/38328 Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott --- benchmark/events/ee-add-remove.js | 18 ++++++++++++++---- lib/events.js | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/benchmark/events/ee-add-remove.js b/benchmark/events/ee-add-remove.js index 715eab29a59c4c..8769125ced6f5f 100644 --- a/benchmark/events/ee-add-remove.js +++ b/benchmark/events/ee-add-remove.js @@ -1,16 +1,26 @@ 'use strict'; const common = require('../common.js'); -const events = require('events'); +const { EventEmitter } = require('events'); -const bench = common.createBenchmark(main, { n: [1e6] }); +const bench = common.createBenchmark(main, { + newListener: [0, 1], + removeListener: [0, 1], + n: [1e6], +}); -function main({ n }) { - const ee = new events.EventEmitter(); +function main({ newListener, removeListener, n }) { + const ee = new EventEmitter(); const listeners = []; for (let k = 0; k < 10; k += 1) listeners.push(() => {}); + if (newListener === 1) + ee.on('newListener', (event, listener) => {}); + + if (removeListener === 1) + ee.on('removeListener', (event, listener) => {}); + bench.start(); for (let i = 0; i < n; i += 1) { const dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1'; diff --git a/lib/events.js b/lib/events.js index cc29b3358e0ce2..7d219606a28b1b 100644 --- a/lib/events.js +++ b/lib/events.js @@ -406,7 +406,7 @@ function _addListener(target, type, listener, prepend) { // adding it to the listeners, first emit "newListener". if (events.newListener !== undefined) { target.emit('newListener', type, - listener.listener ? listener.listener : listener); + listener.listener ?? listener); // Re-assign `events` because a newListener handler could have caused the // this._events to be assigned to a new object From 8eea3172271cbd021ae2f6d5881e4af6480bb3e9 Mon Sep 17 00:00:00 2001 From: Nitzan Uziely Date: Thu, 13 May 2021 02:26:48 +0300 Subject: [PATCH 81/86] test: stream.finished detects a destroyed IncomingMessage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a test to verify that stream.finished works correctly on IncomingMessage refs: https://github.com/nodejs/node/issues/38657 PR-URL: https://github.com/nodejs/node/pull/38661 Refs: https://github.com/nodejs/node/issues/38657 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Juan José Arboleda Reviewed-By: Luigi Pinca --- test/parallel/test-stream-finished.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-stream-finished.js b/test/parallel/test-stream-finished.js index d1652396dae25d..43b1e36a547402 100644 --- a/test/parallel/test-stream-finished.js +++ b/test/parallel/test-stream-finished.js @@ -553,14 +553,14 @@ testClosed((opts) => new Writable({ write() {}, ...opts })); } { - const server = http.createServer((req, res) => { - res.on('close', () => { + const server = http.createServer(common.mustCall((req, res) => { + res.on('close', common.mustCall(() => { finished(res, common.mustCall(() => { server.close(); })); - }); + })); res.end(); - }) + })) .listen(0, function() { http.request({ method: 'GET', @@ -570,6 +570,22 @@ testClosed((opts) => new Writable({ write() {}, ...opts })); }); } +{ + const server = http.createServer(common.mustCall((req, res) => { + req.on('close', common.mustCall(() => { + finished(req, common.mustCall(() => { + server.close(); + })); + })); + req.destroy(); + })).listen(0, function() { + http.request({ + method: 'GET', + port: this.address().port + }).end().on('error', common.mustCall()); + }); +} + { const w = new Writable({ From ff1b4322f57702bc8d900ceac8fb39a7ab581f27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Arboleda?= Date: Fri, 14 May 2021 18:25:35 -0500 Subject: [PATCH 82/86] test: refactor `test-readline-interface` to be shorter PR-URL: https://github.com/nodejs/node/pull/38691 Reviewed-By: Anna Henningsen Reviewed-By: Darshan Sen Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: James M Snell --- test/parallel/test-readline-interface.js | 36 ++++++------------------ 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js index a3020181b3532e..5e05610aeae8f4 100644 --- a/test/parallel/test-readline-interface.js +++ b/test/parallel/test-readline-interface.js @@ -87,34 +87,16 @@ function assertCursorRowsAndCols(rli, rows, cols) { const input = new FakeInput(); // Constructor throws if completer is not a function or undefined - assert.throws(() => { - readline.createInterface({ - input, - completer: 'string is not valid' - }); - }, { - name: 'TypeError', - code: 'ERR_INVALID_ARG_VALUE' - }); - - assert.throws(() => { - readline.createInterface({ - input, - completer: '' - }); - }, { - name: 'TypeError', - code: 'ERR_INVALID_ARG_VALUE' - }); - - assert.throws(() => { - readline.createInterface({ - input, - completer: false + ['not an array', 123, 123n, {}, true, Symbol(), null].forEach((invalid) => { + assert.throws(() => { + readline.createInterface({ + input, + completer: invalid + }); + }, { + name: 'TypeError', + code: 'ERR_INVALID_ARG_VALUE' }); - }, { - name: 'TypeError', - code: 'ERR_INVALID_ARG_VALUE' }); // Constructor throws if history is not an array From a0dc194e3174dd18ba3686fe1be7b5cb106a58a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Fri, 14 May 2021 16:01:46 +0200 Subject: [PATCH 83/86] doc: document buffer.kStringMaxLength PR-URL: https://github.com/nodejs/node/pull/38688 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Rich Trott Reviewed-By: Darshan Sen Reviewed-By: Colin Ihrig Reviewed-By: Harshitha K P Reviewed-By: Luigi Pinca --- doc/api/buffer.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 3c8dc975e4248b..1ad3bf7cb78b09 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -3343,6 +3343,15 @@ added: v3.0.0 An alias for [`buffer.constants.MAX_LENGTH`][]. +### `buffer.kStringMaxLength` + + +* {integer} The largest length allowed for a single `string` instance. + +An alias for [`buffer.constants.MAX_STRING_LENGTH`][]. + ### `buffer.transcode(source, fromEnc, toEnc)` diff --git a/doc/api/esm.md b/doc/api/esm.md index f9787129db4337..a25a13806d787a 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -285,7 +285,7 @@ added: - v13.9.0 - v12.16.2 changes: - - version: REPLACEME + - version: v16.2.0 pr-url: https://github.com/nodejs/node/pull/38587 description: Add support for WHATWG `URL` object to `parentURL` parameter. --> diff --git a/doc/api/process.md b/doc/api/process.md index 0e852dcb100acc..9cbcd0d5ac69eb 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -459,7 +459,7 @@ The `*-deprecation` command-line flags only affect warnings that use the name ### Event: `'worker'` * `worker` {Worker} The {Worker} that was created. diff --git a/doc/api/util.md b/doc/api/util.md index 93042b3d5ff58e..321f3c34616243 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -1485,7 +1485,7 @@ util.types.isBoxedPrimitive(Object(BigInt(5))); // Returns true ### `util.types.isCryptoKey(value)` * `value` {Object} @@ -1690,7 +1690,7 @@ util.types.isInt32Array(new Float64Array()); // Returns false ### `util.types.isKeyObject(value)` * `value` {Object} diff --git a/doc/changelogs/CHANGELOG_V16.md b/doc/changelogs/CHANGELOG_V16.md index 08ce83663289d5..4c11c1f5f58896 100644 --- a/doc/changelogs/CHANGELOG_V16.md +++ b/doc/changelogs/CHANGELOG_V16.md @@ -10,6 +10,7 @@ +16.2.0
      16.1.0
      16.0.0
      @@ -34,6 +35,105 @@ * [io.js](CHANGELOG_IOJS.md) * [Archive](CHANGELOG_ARCHIVE.md) + +## 2021-05-19, Version 16.2.0 (Current), @targos + +### Notable Changes + +* [[`36b948560c`](https://github.com/nodejs/node/commit/36b948560c)] - **(SEMVER-MINOR)** **async_hooks**: use new v8::Context PromiseHook API (Stephen Belanger) [#36394](https://github.com/nodejs/node/pull/36394) +* [[`c0deeeacb2`](https://github.com/nodejs/node/commit/c0deeeacb2)] - **lib**: support setting process.env.TZ on windows (James M Snell) [#38642](https://github.com/nodejs/node/pull/38642) +* [[`4c4902748c`](https://github.com/nodejs/node/commit/4c4902748c)] - **(SEMVER-MINOR)** **module**: add support for `URL` to `import.meta.resolve` (Antoine du Hamel) [#38587](https://github.com/nodejs/node/pull/38587) +* [[`c182198c44`](https://github.com/nodejs/node/commit/c182198c44)] - **(SEMVER-MINOR)** **process**: add `'worker'` event (James M Snell) [#38659](https://github.com/nodejs/node/pull/38659) +* [[`fbf02e3198`](https://github.com/nodejs/node/commit/fbf02e3198)] - **(SEMVER-MINOR)** **util**: add util.types.isKeyObject and util.types.isCryptoKey (Filip Skokan) [#38619](https://github.com/nodejs/node/pull/38619) + +### Commits + +* [[`36b948560c`](https://github.com/nodejs/node/commit/36b948560c)] - **(SEMVER-MINOR)** **async_hooks**: use new v8::Context PromiseHook API (Stephen Belanger) [#36394](https://github.com/nodejs/node/pull/36394) +* [[`dcae03203e`](https://github.com/nodejs/node/commit/dcae03203e)] - **buffer**: remove TODOs in `atob` / `btoa` (Khaidi Chu) [#38548](https://github.com/nodejs/node/pull/38548) +* [[`48b557e904`](https://github.com/nodejs/node/commit/48b557e904)] - **buffer**: remove unreachable code (Rongjian Zhang) [#38537](https://github.com/nodejs/node/pull/38537) +* [[`b0df28dea5`](https://github.com/nodejs/node/commit/b0df28dea5)] - **build**: add workaround for V8 builds (Richard Lau) [#38632](https://github.com/nodejs/node/pull/38632) +* [[`3bb12db255`](https://github.com/nodejs/node/commit/3bb12db255)] - **build**: remove dependency on `distutils.spawn` (Richard Lau) [#38600](https://github.com/nodejs/node/pull/38600) +* [[`10aaf30da1`](https://github.com/nodejs/node/commit/10aaf30da1)] - **build**: add missing torque output sources (Richard Lau) [#38576](https://github.com/nodejs/node/pull/38576) +* [[`03b4a3a5bf`](https://github.com/nodejs/node/commit/03b4a3a5bf)] - **build**: compile with -std=gnu++14 (Darshan Sen) [#38504](https://github.com/nodejs/node/pull/38504) +* [[`4296591154`](https://github.com/nodejs/node/commit/4296591154)] - **build,src,test,doc**: enable FIPS for OpenSSL 3.0 (Daniel Bevenius) [#38633](https://github.com/nodejs/node/pull/38633) +* [[`36bb8daba5`](https://github.com/nodejs/node/commit/36bb8daba5)] - **crypto**: forbid NODE-ED25519 and NODE-ED448 "raw" key export (Filip Skokan) [#38668](https://github.com/nodejs/node/pull/38668) +* [[`36bb7243ff`](https://github.com/nodejs/node/commit/36bb7243ff)] - **debugger**: refactor `inspect_repl` to use primordials (Antoine du Hamel) [#38551](https://github.com/nodejs/node/pull/38551) +* [[`16a6c8d5a6`](https://github.com/nodejs/node/commit/16a6c8d5a6)] - **debugger**: refactor to use internal modules (Antoine du Hamel) [#38550](https://github.com/nodejs/node/pull/38550) +* [[`11dd9a6838`](https://github.com/nodejs/node/commit/11dd9a6838)] - **debugger**: disable only the lint rules required by current file state (Rich Trott) [#38529](https://github.com/nodejs/node/pull/38529) +* [[`e79f540fa0`](https://github.com/nodejs/node/commit/e79f540fa0)] - **debugger**: avoid non-ASCII char in code file (Rich Trott) [#38529](https://github.com/nodejs/node/pull/38529) +* [[`d9867b9358`](https://github.com/nodejs/node/commit/d9867b9358)] - **debugger**: wrap lines longer than 80 chars (Rich Trott) [#38529](https://github.com/nodejs/node/pull/38529) +* [[`352a600142`](https://github.com/nodejs/node/commit/352a600142)] - **debugger**: rename inspector-cli test module to debugger (Rich Trott) [#38530](https://github.com/nodejs/node/pull/38530) +* [[`608d0e11f3`](https://github.com/nodejs/node/commit/608d0e11f3)] - **deps**: upgrade npm to 7.13.0 (Ruy Adorno) [#38682](https://github.com/nodejs/node/pull/38682) +* [[`5c71f49d3f`](https://github.com/nodejs/node/commit/5c71f49d3f)] - **deps**: upgrade npm to 7.12.1 (Ruy Adorno) [#38628](https://github.com/nodejs/node/pull/38628) +* [[`ec2dbfb200`](https://github.com/nodejs/node/commit/ec2dbfb200)] - **deps**: patch V8 to 9.0.257.25 (Michaël Zasso) [#38556](https://github.com/nodejs/node/pull/38556) +* [[`ab298723b5`](https://github.com/nodejs/node/commit/ab298723b5)] - **(SEMVER-MINOR)** **deps**: V8: cherry-pick fa4cb172cde2 (Stephen Belanger) [#36394](https://github.com/nodejs/node/pull/36394) +* [[`a84e9b3e7d`](https://github.com/nodejs/node/commit/a84e9b3e7d)] - **(SEMVER-MINOR)** **deps**: V8: cherry-pick 4c074516397b (Stephen Belanger) [#36394](https://github.com/nodejs/node/pull/36394) +* [[`043b1aaa3f`](https://github.com/nodejs/node/commit/043b1aaa3f)] - **(SEMVER-MINOR)** **deps**: V8: cherry-pick 5f4413194480 (Stephen Belanger) [#36394](https://github.com/nodejs/node/pull/36394) +* [[`1a104bac74`](https://github.com/nodejs/node/commit/1a104bac74)] - **(SEMVER-MINOR)** **deps**: V8: cherry-pick 272445f10927 (Stephen Belanger) [#36394](https://github.com/nodejs/node/pull/36394) +* [[`827ae05538`](https://github.com/nodejs/node/commit/827ae05538)] - **(SEMVER-MINOR)** **deps**: V8: backport c0fceaa0669b (Stephen Belanger) [#36394](https://github.com/nodejs/node/pull/36394) +* [[`f31a6114a4`](https://github.com/nodejs/node/commit/f31a6114a4)] - **deps**: V8: cherry-pick 530080c44af2 (Milad Fa) [#38489](https://github.com/nodejs/node/pull/38489) +* [[`4001dd28ba`](https://github.com/nodejs/node/commit/4001dd28ba)] - **dgram**: extract cluster lazy loading method to make it testable (Rongjian Zhang) [#38563](https://github.com/nodejs/node/pull/38563) +* [[`a0dc194e31`](https://github.com/nodejs/node/commit/a0dc194e31)] - **doc**: document buffer.kStringMaxLength (Tobias Nießen) [#38688](https://github.com/nodejs/node/pull/38688) +* [[`8590c151cd`](https://github.com/nodejs/node/commit/8590c151cd)] - **doc**: update abort signal in fs promise api example (Moritz Kneilmann) [#38669](https://github.com/nodejs/node/pull/38669) +* [[`0100a3b026`](https://github.com/nodejs/node/commit/0100a3b026)] - **doc**: add documentation for fs.WriteStream.close() (Hitesh Sharma) [#38610](https://github.com/nodejs/node/pull/38610) +* [[`5c38a554ec`](https://github.com/nodejs/node/commit/5c38a554ec)] - **doc**: clarify synchronous blocking of Worker stdio (James M Snell) [#38658](https://github.com/nodejs/node/pull/38658) +* [[`1765e32c45`](https://github.com/nodejs/node/commit/1765e32c45)] - **doc**: update contact info (Gabriel Schulhof) [#38689](https://github.com/nodejs/node/pull/38689) +* [[`c4b161cb89`](https://github.com/nodejs/node/commit/c4b161cb89)] - **doc**: change color of doctag on night mode (Qingyu Deng) [#38652](https://github.com/nodejs/node/pull/38652) +* [[`6620a3182e`](https://github.com/nodejs/node/commit/6620a3182e)] - **doc**: add ESM code examples in url.md (Antoine du Hamel) [#38651](https://github.com/nodejs/node/pull/38651) +* [[`d3de0ef5d4`](https://github.com/nodejs/node/commit/d3de0ef5d4)] - **doc**: fix fs.openSync() signature (Luigi Pinca) [#38591](https://github.com/nodejs/node/pull/38591) +* [[`56bf6c1bcd`](https://github.com/nodejs/node/commit/56bf6c1bcd)] - **doc**: typo stats() should be stat(); clarity (Bryan Field) [#38541](https://github.com/nodejs/node/pull/38541) +* [[`1d9fd49f41`](https://github.com/nodejs/node/commit/1d9fd49f41)] - **doc**: fix code example in ecdh.setPublicKey() (Jordan Baczuk) [#38542](https://github.com/nodejs/node/pull/38542) +* [[`4c70e42928`](https://github.com/nodejs/node/commit/4c70e42928)] - **doc**: use `HEAD` instead of `master` for links (Antoine du Hamel) [#38518](https://github.com/nodejs/node/pull/38518) +* [[`ae9128ec61`](https://github.com/nodejs/node/commit/ae9128ec61)] - **doc**: clarify DiffieHellmanGroup class docs (Nitzan Uziely) [#38363](https://github.com/nodejs/node/pull/38363) +* [[`e59131d97f`](https://github.com/nodejs/node/commit/e59131d97f)] - **doc**: fix broken AHAFS link in fs doc (Rich Trott) [#38534](https://github.com/nodejs/node/pull/38534) +* [[`e9d4c8587a`](https://github.com/nodejs/node/commit/e9d4c8587a)] - **doc**: use AIX instead of Aix in fs.md (Rich Trott) [#38535](https://github.com/nodejs/node/pull/38535) +* [[`e0118f347a`](https://github.com/nodejs/node/commit/e0118f347a)] - **doc**: remove extraneous dash from flag prefix (Rodolfo Carvalho) [#38532](https://github.com/nodejs/node/pull/38532) +* [[`9e10e1a76f`](https://github.com/nodejs/node/commit/9e10e1a76f)] - **doc**: corrected workload name as per the latest VS Installer (MrJithil) [#38500](https://github.com/nodejs/node/pull/38500) +* [[`38644d6f96`](https://github.com/nodejs/node/commit/38644d6f96)] - **doc**: use sentence case in headers in src/crypto/README.md (Rich Trott) [#38524](https://github.com/nodejs/node/pull/38524) +* [[`347b9f2304`](https://github.com/nodejs/node/commit/347b9f2304)] - **errors**: remove input from ERR\_INVALID\_URL message (moander) [#38614](https://github.com/nodejs/node/pull/38614) +* [[`5b40e2f596`](https://github.com/nodejs/node/commit/5b40e2f596)] - **events**: use nullish coalencing operator (Voltrex) [#38328](https://github.com/nodejs/node/pull/38328) +* [[`3a5856cbc3`](https://github.com/nodejs/node/commit/3a5856cbc3)] - **fs**: fix async iterator partial writes (Nitzan Uziely) [#38615](https://github.com/nodejs/node/pull/38615) +* [[`e8761186a5`](https://github.com/nodejs/node/commit/e8761186a5)] - **fs**: fix error when writing buffers \> INT32\_MAX (Zach Bjornson) [#38546](https://github.com/nodejs/node/pull/38546) +* [[`47080bcfc8`](https://github.com/nodejs/node/commit/47080bcfc8)] - **fs**: use `assert` in `fsCall` argument checking (Rongjian Zhang) [#38519](https://github.com/nodejs/node/pull/38519) +* [[`3d8b8e133f`](https://github.com/nodejs/node/commit/3d8b8e133f)] - **http**: refactor to remove redundant argument of \_deferToConnect (Rongjian Zhang) [#38598](https://github.com/nodejs/node/pull/38598) +* [[`c0deeeacb2`](https://github.com/nodejs/node/commit/c0deeeacb2)] - **lib**: support setting process.env.TZ on windows (James M Snell) [#38642](https://github.com/nodejs/node/pull/38642) +* [[`cf4dc80d5f`](https://github.com/nodejs/node/commit/cf4dc80d5f)] - **lib**: make `IterableWeakMap` safe to iterate (Antoine du Hamel) [#38523](https://github.com/nodejs/node/pull/38523) +* [[`90b640efb1`](https://github.com/nodejs/node/commit/90b640efb1)] - **meta**: add v8 team (Jiawen Geng) [#38566](https://github.com/nodejs/node/pull/38566) +* [[`4c4902748c`](https://github.com/nodejs/node/commit/4c4902748c)] - **(SEMVER-MINOR)** **module**: add support for `URL` to `import.meta.resolve` (Antoine du Hamel) [#38587](https://github.com/nodejs/node/pull/38587) +* [[`14a2a00cda`](https://github.com/nodejs/node/commit/14a2a00cda)] - **node-api**: faster threadsafe\_function (Fedor Indutny) [#38506](https://github.com/nodejs/node/pull/38506) +* [[`be4b3a4164`](https://github.com/nodejs/node/commit/be4b3a4164)] - **path**: inline conditions (Voltrex) [#38613](https://github.com/nodejs/node/pull/38613) +* [[`c182198c44`](https://github.com/nodejs/node/commit/c182198c44)] - **(SEMVER-MINOR)** **process**: add `'worker'` event (James M Snell) [#38659](https://github.com/nodejs/node/pull/38659) +* [[`e2b8454582`](https://github.com/nodejs/node/commit/e2b8454582)] - **repl**: fix Ctrl+C on top level await (Antoine du Hamel) [#38656](https://github.com/nodejs/node/pull/38656) +* [[`718ad105e5`](https://github.com/nodejs/node/commit/718ad105e5)] - **src**: fix fatal errors when a current isolate not exist (legendecas) [#38624](https://github.com/nodejs/node/pull/38624) +* [[`524a9d6fcd`](https://github.com/nodejs/node/commit/524a9d6fcd)] - **src**: update cares\_wrap OpenBSD defines (Anna Henningsen) [#38670](https://github.com/nodejs/node/pull/38670) +* [[`6b409cf664`](https://github.com/nodejs/node/commit/6b409cf664)] - **src**: remove extra semi after member fn (Shelley Vohr) [#38686](https://github.com/nodejs/node/pull/38686) +* [[`bfec80fd66`](https://github.com/nodejs/node/commit/bfec80fd66)] - **src**: make workers messaging more resilient (Juan José Arboleda) [#38510](https://github.com/nodejs/node/pull/38510) +* [[`ff1b4322f5`](https://github.com/nodejs/node/commit/ff1b4322f5)] - **test**: refactor `test-readline-interface` to be shorter (Juan José Arboleda) [#38691](https://github.com/nodejs/node/pull/38691) +* [[`8eea317227`](https://github.com/nodejs/node/commit/8eea317227)] - **test**: stream.finished detects a destroyed IncomingMessage (Nitzan Uziely) [#38661](https://github.com/nodejs/node/pull/38661) +* [[`5b25fbe266`](https://github.com/nodejs/node/commit/5b25fbe266)] - **test**: set common.bits to 64 for riscv64 (Andreas Schwab) [#38626](https://github.com/nodejs/node/pull/38626) +* [[`5a0b52120a`](https://github.com/nodejs/node/commit/5a0b52120a)] - **test**: improve coverage of lib/\_http\_client.js (Rongjian Zhang) [#38599](https://github.com/nodejs/node/pull/38599) +* [[`3d0fad3840`](https://github.com/nodejs/node/commit/3d0fad3840)] - **test**: improve coverage of lib/os.js (Rongjian Zhang) [#38653](https://github.com/nodejs/node/pull/38653) +* [[`16b2fb4e0c`](https://github.com/nodejs/node/commit/16b2fb4e0c)] - **test**: increase coverage for repl (ZiJian Liu) [#38559](https://github.com/nodejs/node/pull/38559) +* [[`8f78c6646e`](https://github.com/nodejs/node/commit/8f78c6646e)] - **test**: call functions internally (Voltrex) [#38560](https://github.com/nodejs/node/pull/38560) +* [[`178fe215a4`](https://github.com/nodejs/node/commit/178fe215a4)] - **test**: increase coverage for Histogram (ZiJian Liu) [#38555](https://github.com/nodejs/node/pull/38555) +* [[`95db7d5afc`](https://github.com/nodejs/node/commit/95db7d5afc)] - **test**: improve fs coverage (Rongjian Zhang) [#38517](https://github.com/nodejs/node/pull/38517) +* [[`f2f768f261`](https://github.com/nodejs/node/commit/f2f768f261)] - **test**: complete coverage of querystring (Rongjian Zhang) [#38520](https://github.com/nodejs/node/pull/38520) +* [[`5b44107ae9`](https://github.com/nodejs/node/commit/5b44107ae9)] - **test**: increase coverage for AbortController (ZiJian Liu) [#38514](https://github.com/nodejs/node/pull/38514) +* [[`662265074c`](https://github.com/nodejs/node/commit/662265074c)] - **test**: increase coverage for Blob (ZiJian Liu) [#38515](https://github.com/nodejs/node/pull/38515) +* [[`89e1daccf3`](https://github.com/nodejs/node/commit/89e1daccf3)] - **test**: run message and pseudo-tty tests in parallel (Richard Lau) [#38502](https://github.com/nodejs/node/pull/38502) +* [[`727c2bcc24`](https://github.com/nodejs/node/commit/727c2bcc24)] - **test**: move test-net-connect-econnrefused from pummel to sequential (Rich Trott) [#38462](https://github.com/nodejs/node/pull/38462) +* [[`e64ebac2da`](https://github.com/nodejs/node/commit/e64ebac2da)] - **test**: fix flaky inspector-cli tests when breakpionts are restored (Rich Trott) [#38431](https://github.com/nodejs/node/pull/38431) +* [[`b51b4feece`](https://github.com/nodejs/node/commit/b51b4feece)] - **test**: skip tests for openssl-3.0.0-alpha15 (Daniel Bevenius) [#38451](https://github.com/nodejs/node/pull/38451) +* [[`db5ee23edf`](https://github.com/nodejs/node/commit/db5ee23edf)] - **test**: update OpenSSL 3.0.0-alpha15 error messages (Daniel Bevenius) [#38451](https://github.com/nodejs/node/pull/38451) +* [[`24472d9e0c`](https://github.com/nodejs/node/commit/24472d9e0c)] - **test,repl**: fix tests when inspector is disabled (Antoine du Hamel) [#38564](https://github.com/nodejs/node/pull/38564) +* [[`267a84f5e1`](https://github.com/nodejs/node/commit/267a84f5e1)] - **tools**: remove redundant v8 config (Jiawen Geng) [#38565](https://github.com/nodejs/node/pull/38565) +* [[`a028805f1b`](https://github.com/nodejs/node/commit/a028805f1b)] - **tools**: update ESLint to 7.26.0 (Colin Ihrig) [#38605](https://github.com/nodejs/node/pull/38605) +* [[`ec8ab22ce6`](https://github.com/nodejs/node/commit/ec8ab22ce6)] - **(SEMVER-MINOR)** **tools**: add `Worker` to type-parser (James M Snell) [#38659](https://github.com/nodejs/node/pull/38659) +* [[`151488539b`](https://github.com/nodejs/node/commit/151488539b)] - **tools**: make GH Actions workflows work if default branch is not master (Antoine du Hamel) [#38516](https://github.com/nodejs/node/pull/38516) +* [[`c0f0c9a92d`](https://github.com/nodejs/node/commit/c0f0c9a92d)] - **typings**: add JSDoc typings for readline (Voltrex) [#38253](https://github.com/nodejs/node/pull/38253) +* [[`fbf02e3198`](https://github.com/nodejs/node/commit/fbf02e3198)] - **(SEMVER-MINOR)** **util**: add util.types.isKeyObject and util.types.isCryptoKey (Filip Skokan) [#38619](https://github.com/nodejs/node/pull/38619) +* [[`070ee4bb94`](https://github.com/nodejs/node/commit/070ee4bb94)] - ***Revert*** "**worker**: remove `ERR_CLOSED_MESSAGE_PORT`" (Juan José Arboleda) [#38510](https://github.com/nodejs/node/pull/38510) + ## 2021-05-04, Version 16.1.0 (Current), @targos diff --git a/src/node_version.h b/src/node_version.h index 385fc6dfc87f24..810425a5562f6a 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -23,13 +23,13 @@ #define SRC_NODE_VERSION_H_ #define NODE_MAJOR_VERSION 16 -#define NODE_MINOR_VERSION 1 -#define NODE_PATCH_VERSION 1 +#define NODE_MINOR_VERSION 2 +#define NODE_PATCH_VERSION 0 #define NODE_VERSION_IS_LTS 0 #define NODE_VERSION_LTS_CODENAME "" -#define NODE_VERSION_IS_RELEASE 0 +#define NODE_VERSION_IS_RELEASE 1 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n)