From f99c509dba6fcd4452b4dc24ea268cd3f644e4b2 Mon Sep 17 00:00:00 2001 From: Matthew B White Date: Tue, 23 Jun 2020 16:58:14 +0100 Subject: [PATCH] wip Signed-off-by: Matthew B White --- README.md | 6 + apis/fabric-contract-api/package.json | 10 +- common/config/rush/pnpm-lock.yaml | 318 +++++--- common/scripts/install-run-rush.js | 132 ++-- common/scripts/install-run.js | 850 +++++++++++----------- libraries/fabric-shim-crypto/package.json | 4 +- libraries/fabric-shim/lib/server.js | 6 +- libraries/fabric-shim/package.json | 16 +- libraries/fabric-shim/test/unit/server.js | 20 +- rush.json | 4 +- test/e2e/package.json | 2 +- test/fv/package.json | 2 +- tools/toolchain/package.json | 2 +- 13 files changed, 746 insertions(+), 626 deletions(-) diff --git a/README.md b/README.md index e09e13457..bb7ba7543 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,12 @@ As an application developer, to learn about how to implement **"Smart Contracts" For details on what Nodejs runtime and versions of Hyperledger Fabric can be used please see the [compatibility document](COMPATIBILITY.md). +## npm Shrinkwrap + +In line with the advice from [npm on shrinkwrap](https://docs.npmjs.com/files/shrinkwrap.json#description) the modules published do not contain a `npm-shrinkwrap.json` file. + +It is **STRONGLY** recommended therefore that after testing, and before putting your contract into production a `npm-shrinkwrap.json` file is created. When the chaincode is install it will be via a `npm install --production` command. + --- ## License diff --git a/apis/fabric-contract-api/package.json b/apis/fabric-contract-api/package.json index f825d1d0c..6959618c2 100644 --- a/apis/fabric-contract-api/package.json +++ b/apis/fabric-contract-api/package.json @@ -48,14 +48,14 @@ "dependencies": { "fabric-shim-api": "2.1.5-unstable", "class-transformer": "^0.2.2", - "fast-safe-stringify": "~2.0.7", + "fast-safe-stringify": "^2.0.7", "get-params": "^0.1.2", - "reflect-metadata": "^0.1.12", - "winston": "3.2.1" + "reflect-metadata": "^0.1.13", + "winston": "^3.3.2" }, "devDependencies": { - "ajv": "^6.5.5", - "ajv-cli": "^3.0.0", + "ajv": "^6.12.2", + "ajv-cli": "^3.2.1", "chai": "^4.1.1", "chai-as-promised": "^7.1.1", "chai-things": "^0.2.0", diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 7961865c5..b02d6403c 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -1,6 +1,6 @@ dependencies: '@fidm/x509': 1.2.1 - '@grpc/grpc-js': 1.0.3 + '@grpc/grpc-js': 1.1.1 '@grpc/proto-loader': 0.5.4 '@rush-temp/azure-mocha-reporter': 'file:projects/azure-mocha-reporter.tgz' '@rush-temp/fabric-contract-api': 'file:projects/fabric-contract-api.tgz' @@ -13,9 +13,7 @@ dependencies: '@rush-temp/fvtests': 'file:projects/fvtests.tgz' '@rush-temp/toolchain': 'file:projects/toolchain.tgz' '@sinonjs/referee-sinon': 5.0.0 - '@types/node': 8.10.60 - ajv: 6.12.2 - ajv-cli: 3.1.0 + '@types/node': 14.0.13 chai: 4.2.0 chai-as-promised: 7.1.1_chai@4.2.0 chai-things: 0.2.0 @@ -23,10 +21,10 @@ dependencies: cpx: 1.5.0 del: 3.0.0 delay: 4.3.0 - elliptic: 6.5.2 + elliptic: 6.5.3 eslint: 6.6.0 fast-safe-stringify: 2.0.7 - fs-extra: 8.1.0 + fs-extra: 9.0.1 get-params: 0.1.2 git-rev-sync: 1.12.0 gulp: 4.0.2 @@ -38,7 +36,7 @@ dependencies: ip: 1.1.5 istanbul-api: 1.3.7 jsdoc: 3.6.4 - jsrsasign: 8.0.15 + jsrsasign: 8.0.19 jsverify: 0.8.4 merge-stream: 2.0.0 mocha: 6.2.2 @@ -52,9 +50,9 @@ dependencies: sinon: 7.5.0 sinon-test: 2.4.3_sinon@7.5.0 typescript: 3.0.1 - winston: 3.2.1 - yargs: 13.3.2 - yargs-parser: 13.1.2 + winston: 3.3.2 + yargs: 15.3.1 + yargs-parser: 18.1.3 lockfileVersion: 5.1 packages: /@babel/code-frame/7.8.3: @@ -141,6 +139,14 @@ packages: dev: false resolution: integrity: sha512-qxXzvBO//jO9ZnoasKF1uJzHd2+M6Q2ZPIVfnFps8JJvXy0ZBbwbNOmE6SGIY5XOY6d1Bo5lb9d9RJ8nv3WSeA== + /@dabh/diagnostics/2.0.2: + dependencies: + colorspace: 1.1.2 + enabled: 2.0.0 + kuler: 2.0.0 + dev: false + resolution: + integrity: sha512-+A1YivoVDNNVCdfozHSR8v/jyuuLTMXwjWuxPFlFlUapXoGc+Gj9mDlTDDfrwl7rXCl2tNZ0kE8sIBO6YOn96Q== /@fidm/asn1/1.0.4: dev: false engines: @@ -156,14 +162,16 @@ packages: node: '>= 8' resolution: integrity: sha512-nwc2iesjyc9hkuzcrMCBXQRn653XuAUKorfWM8PZyJawiy1QzLj4vahwzaI25+pfpwOLvMzbJ0uKpWLDNmo16w== - /@grpc/grpc-js/1.0.3: + /@grpc/grpc-js/1.1.1: dependencies: semver: 6.3.0 dev: false engines: node: ^8.13.0 || >=10.10.0 + peerDependencies: + google-auth-library: 5.x || 6.x resolution: - integrity: sha512-JKV3f5Bv2TZxK6eJSB9EarsZrnLxrvcFNwI9goq0YRXa3S6NNoCSnI3cG3lkXVIJ03Wng1WXe76kc2JQtRe7AQ== + integrity: sha512-mhZRszS0SKwnWPJaNyrECePZ9U7vaHFGqrzxQbWinWR3WznBIU+nmh2L5J3elF+lp5DEUIzARXkifbs6LQVAHA== /@grpc/proto-loader/0.5.4: dependencies: lodash.camelcase: 4.3.0 @@ -501,6 +509,10 @@ packages: dev: false resolution: integrity: sha512-3ySmiBYJPqgjiHA7oEaIo2Rzz0HrOZ7yrNO5HWyaE5q0lQ3BppDZ3N53Miz8bw2I7gh1/zir2MGVZBvpb1zq9g== + /@types/node/14.0.13: + dev: false + resolution: + integrity: sha512-rouEWBImiRaSJsVA+ITTFM6ZxibuAlTuNOCyxVbwreu6k6+ujs7DfnU9o+PShFhET78pMBl3eH+AGSI5eOTkPA== /@types/node/6.14.10: dev: false resolution: @@ -594,6 +606,20 @@ packages: hasBin: true resolution: integrity: sha512-QSHstRjJin970EspY92Qr8lDGYE9C88AwW7LJYJ/MFhKDsE6I75H2b8WObCeF+2q/1fJiolm0xX7I/VyGmw/JQ== + /ajv-cli/3.2.1: + dependencies: + ajv: 6.12.2 + ajv-pack: 0.3.1 + fast-json-patch: 2.2.1 + glob: 7.1.6 + js-yaml: 3.13.1 + json-schema-migrate: 0.2.0 + json5: 2.1.3 + minimist: 1.2.5 + dev: false + hasBin: true + resolution: + integrity: sha512-EZW2fqkQVMvp3oPfVrUZnh4nl/sENKpSG1q+R5wHqaM71EU7JAxzxYzvkjcgIRer6Y4HFkY1uCEHT/DMWE5apw== /ajv-keywords/2.1.1_ajv@5.5.2: dependencies: ajv: 5.5.2 @@ -976,10 +1002,20 @@ packages: dev: false resolution: integrity: sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg== + /async/3.2.0: + dev: false + resolution: + integrity: sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw== /asynckit/0.4.0: dev: false resolution: integrity: sha1-x57Zf380y48robyXkLzDZkdLS3k= + /at-least-node/1.0.0: + dev: false + engines: + node: '>= 4.0.0' + resolution: + integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg== /atob/2.1.2: dev: false engines: @@ -1508,6 +1544,14 @@ packages: dev: false resolution: integrity: sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA== + /cliui/6.0.0: + dependencies: + string-width: 4.2.0 + strip-ansi: 6.0.0 + wrap-ansi: 6.2.0 + dev: false + resolution: + integrity: sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ== /clone-buffer/1.0.0: dev: false engines: @@ -1605,10 +1649,6 @@ packages: dev: false resolution: integrity: sha512-jCpd5+s0s0t7p3pHQKpnJ0TpQKKdleP71LWcA0aqiljpiuAkOSUFN/dyH8ZwF0hRmFlrIuRhufds1QyEP9EB+w== - /colornames/1.1.1: - dev: false - resolution: - integrity: sha1-+IiQMGhcfE/54qVZ9Qd+t2qBb5Y= /colors/1.4.0: dev: false engines: @@ -1982,14 +2022,6 @@ packages: node: '>=0.10.0' resolution: integrity: sha1-920GQ1LN9Docts5hnE7jqUdd4gg= - /diagnostics/1.1.1: - dependencies: - colorspace: 1.1.2 - enabled: 1.0.2 - kuler: 1.0.1 - dev: false - resolution: - integrity: sha512-8wn1PmdunLJ9Tqbx+Fx/ZEuHfJf4NKSN2ZBj7SJC/OWRWha843+WsTjqMe1B5E3p28jqBlp+mJ2fPVxPyNgYKQ== /diff/3.5.0: dev: false engines: @@ -2112,7 +2144,7 @@ packages: hasBin: true resolution: integrity: sha512-M9wIMFx96vq0R4F+gRpY3o2exzb8hEj/n9S8unZtHSvYjibBp/iMufSzvmOcV/laG0ZtuTVGtiJggPOSW2r93g== - /elliptic/6.5.2: + /elliptic/6.5.3: dependencies: bn.js: 4.11.8 brorand: 1.1.0 @@ -2123,7 +2155,7 @@ packages: minimalistic-crypto-utils: 1.0.1 dev: false resolution: - integrity: sha512-f4x70okzZbIQl/NSRLkI/+tteV/9WqL98zx+SQ69KbXxmVrmjwsNUPn/gYJJ0sHvEak24cZgHIPegRePAtA/xw== + integrity: sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw== /email-validator/2.0.4: dev: false engines: @@ -2138,12 +2170,10 @@ packages: dev: false resolution: integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - /enabled/1.0.2: - dependencies: - env-variable: 0.0.6 + /enabled/2.0.0: dev: false resolution: - integrity: sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M= + integrity: sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ== /end-of-stream/1.4.4: dependencies: once: 1.4.0 @@ -2154,10 +2184,6 @@ packages: dev: false resolution: integrity: sha512-dmD3AvJQBUjKpcNkoqr+x+IF0SdRtPz9Vk0uTy4yWqga9ibB6s4v++QFWNohjiUGoMlF552ZvNyXDxz5iW0qmw== - /env-variable/0.0.6: - dev: false - resolution: - integrity: sha512-bHz59NlBbtS0NhftmR8+ExBEekE7br0e01jw+kk0NDro7TtZzBYZ5ScGPs3OmwnpyfHTHOtr1Y6uedCdrIldtg== /error-ex/1.3.2: dependencies: is-arrayish: 0.2.1 @@ -2649,10 +2675,10 @@ packages: dev: false resolution: integrity: sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA== - /fecha/2.3.3: + /fecha/4.2.0: dev: false resolution: - integrity: sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg== + integrity: sha512-aN3pcx/DSmtyoovUudctc8+6Hl4T+hI9GBBHLjA76jdZl7+b1sgh5g4k+u/GL3dTy1/pnYzKp69FpJ0OicE3Wg== /figures/2.0.0: dependencies: escape-string-regexp: 1.0.5 @@ -2757,6 +2783,15 @@ packages: node: '>=6' resolution: integrity: sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== + /find-up/4.1.0: + dependencies: + locate-path: 5.0.0 + path-exists: 4.0.0 + dev: false + engines: + node: '>=8' + resolution: + integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== /findup-sync/2.0.0: dependencies: detect-file: 1.0.0 @@ -2836,6 +2871,10 @@ packages: dev: false resolution: integrity: sha512-3Z4XhFZ3992uIq0XOqb9AreonueSYphE6oYbpt5+3u06JWklbsPkNv3ZKkP9Bz/r+1MWCaMoSQ28P85+1Yc77w== + /fn.name/1.1.0: + dev: false + resolution: + integrity: sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw== /for-in/1.0.2: dev: false engines: @@ -2891,16 +2930,17 @@ packages: dev: false resolution: integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow== - /fs-extra/8.1.0: + /fs-extra/9.0.1: dependencies: + at-least-node: 1.0.0 graceful-fs: 4.2.4 - jsonfile: 4.0.0 - universalify: 0.1.2 + jsonfile: 6.0.1 + universalify: 1.0.0 dev: false engines: - node: '>=6 <7 || >=8' + node: '>=10' resolution: - integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g== + integrity: sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ== /fs-mkdirp-stream/1.0.0: dependencies: graceful-fs: 4.2.4 @@ -4017,6 +4057,12 @@ packages: node: '>=0.10.0' resolution: integrity: sha1-EtSj3U5o4Lec6428hBc66A2RykQ= + /is-stream/2.0.0: + dev: false + engines: + node: '>=8' + resolution: + integrity: sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw== /is-symbol/1.0.3: dependencies: has-symbols: 1.0.1 @@ -4313,12 +4359,23 @@ packages: dev: false resolution: integrity: sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= - /jsonfile/4.0.0: + /json5/2.1.3: + dependencies: + minimist: 1.2.5 + dev: false + engines: + node: '>=6' + hasBin: true + resolution: + integrity: sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA== + /jsonfile/6.0.1: + dependencies: + universalify: 1.0.0 dev: false optionalDependencies: graceful-fs: 4.2.4 resolution: - integrity: sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss= + integrity: sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg== /jsprim/1.4.1: dependencies: assert-plus: 1.0.0 @@ -4330,10 +4387,10 @@ packages: '0': node >=0.6.0 resolution: integrity: sha1-MT5mvB5cwG5Di8G3SZwuXFastqI= - /jsrsasign/8.0.15: + /jsrsasign/8.0.19: dev: false resolution: - integrity: sha512-6UKHqnNs5lYROn03wf1BTw7DQx5tW616DTigjbo0JHV97D3HzIqYmPVCBSNsfEfQOrfpFqmPZJvaC3cMNOT0Yw== + integrity: sha512-qf+F41huTh9ThXj5n3yfAJJRp8vx05JYbGlGvCjusYX50rsfqY6ASK08LCOutl0yA1BHIpGG8bd1w5x9aGy7Zg== /jsverify/0.8.4: dependencies: lazy-seq: 1.0.0 @@ -4406,12 +4463,10 @@ packages: dev: false resolution: integrity: sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g== - /kuler/1.0.1: - dependencies: - colornames: 1.1.1 + /kuler/2.0.0: dev: false resolution: - integrity: sha512-J9nVUucG1p/skKul6DU3PUZrhs0LPulNaeUOox0IyXDi8S4CztTHs1gQphhuZmzXG7VOQSf6NJfKuzteQLv9gQ== + integrity: sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A== /last-run/1.1.1: dependencies: default-resolution: 2.0.0 @@ -4533,6 +4588,14 @@ packages: node: '>=6' resolution: integrity: sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== + /locate-path/5.0.0: + dependencies: + p-locate: 4.1.0 + dev: false + engines: + node: '>=8' + resolution: + integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== /lodash._reinterpolate/3.0.0: dev: false resolution: @@ -4626,16 +4689,16 @@ packages: node: '>=4' resolution: integrity: sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg== - /logform/2.1.2: + /logform/2.2.0: dependencies: colors: 1.4.0 fast-safe-stringify: 2.0.7 - fecha: 2.3.3 + fecha: 4.2.0 ms: 2.1.2 triple-beam: 1.3.0 dev: false resolution: - integrity: sha512-+lZh4OpERDBLqjiwDLpAWNQu6KMjnlXH2ByZwCuSqVPJletw0kTWJf5CgSNAUKn1KUkv3m2cUz/LK8zyEy7wzQ== + integrity: sha512-N0qPlqfypFx7UHNn4B3lzS/b0uLqt2hmuoa+PpuXNYgozdJYAyauF5Ky0BWVjrxDlMWiT3qN4zPq3vVAfZy7Yg== /lolex/4.2.0: dev: false resolution: @@ -5338,10 +5401,12 @@ packages: dev: false resolution: integrity: sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - /one-time/0.0.4: + /one-time/1.0.0: + dependencies: + fn.name: 1.1.0 dev: false resolution: - integrity: sha1-+M33eISCb+Tf+T46nMN7HkSAdC4= + integrity: sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g== /onetime/2.0.1: dependencies: mimic-fn: 1.2.0 @@ -5448,6 +5513,14 @@ packages: node: '>=6' resolution: integrity: sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== + /p-locate/4.1.0: + dependencies: + p-limit: 2.3.0 + dev: false + engines: + node: '>=8' + resolution: + integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== /p-map/1.2.0: dev: false engines: @@ -5613,6 +5686,12 @@ packages: node: '>=4' resolution: integrity: sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= + /path-exists/4.0.0: + dev: false + engines: + node: '>=8' + resolution: + integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== /path-is-absolute/1.0.1: dev: false engines: @@ -7613,12 +7692,12 @@ packages: node: '>=4' resolution: integrity: sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo= - /universalify/0.1.2: + /universalify/1.0.0: dev: false engines: - node: '>= 4.0.0' + node: '>= 10.0.0' resolution: - integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== + integrity: sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug== /unpipe/1.0.0: dev: false engines: @@ -7820,7 +7899,7 @@ packages: node: '>=6' resolution: integrity: sha512-2HetyTg1Y+R+rUgrKeUEhAG/ZuOmTrI1NBb3ZyAGQMYmOJjBBPe4MTodghRkmLJZHwkuPi02anbeGP+Zf401LQ== - /winston-transport/4.3.0: + /winston-transport/4.4.0: dependencies: readable-stream: 2.3.7 triple-beam: 1.3.0 @@ -7828,23 +7907,23 @@ packages: engines: node: '>= 6.4.0' resolution: - integrity: sha512-B2wPuwUi3vhzn/51Uukcao4dIduEiPOcOt9HJ3QeaXgkJ5Z7UwpBzxS4ZGNHtrxrUvTwemsQiSys0ihOf8Mp1A== - /winston/3.2.1: + integrity: sha512-Lc7/p3GtqtqPBYYtS6KCN3c77/2QCev51DvcJKbkFPQNoj1sinkGwLGFDxkXY9J6p9+EPnYs+D90uwbnaiURTw== + /winston/3.3.2: dependencies: - async: 2.6.3 - diagnostics: 1.1.1 - is-stream: 1.1.0 - logform: 2.1.2 - one-time: 0.0.4 + '@dabh/diagnostics': 2.0.2 + async: 3.2.0 + is-stream: 2.0.0 + logform: 2.2.0 + one-time: 1.0.0 readable-stream: 3.6.0 stack-trace: 0.0.10 triple-beam: 1.3.0 - winston-transport: 4.3.0 + winston-transport: 4.4.0 dev: false engines: node: '>= 6.4.0' resolution: - integrity: sha512-zU6vgnS9dAWCEKg/QYigd6cgMVVNwyTzKs81XZtTFuRwJOcDdBg7AU0mXVyNbs7O5RH2zdv+BdNZUlx7mXPuOw== + integrity: sha512-vTOrUZlyQPS8VpCcQ1JT8BumDAUe4awCHZ9nmGgO7LqkV4atj0dKa5suA7Trf7QKtBszE2yUs9d8744Kz9j4jQ== /word-wrap/1.2.3: dev: false engines: @@ -7874,6 +7953,16 @@ packages: node: '>=6' resolution: integrity: sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q== + /wrap-ansi/6.2.0: + dependencies: + ansi-styles: 4.2.1 + string-width: 4.2.0 + strip-ansi: 6.0.0 + dev: false + engines: + node: '>=8' + resolution: + integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA== /wrappy/1.0.2: dev: false resolution: @@ -7971,6 +8060,15 @@ packages: dev: false resolution: integrity: sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg== + /yargs-parser/18.1.3: + dependencies: + camelcase: 5.3.1 + decamelize: 1.2.0 + dev: false + engines: + node: '>=6' + resolution: + integrity: sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ== /yargs-parser/5.0.0: dependencies: camelcase: 3.0.0 @@ -8017,6 +8115,24 @@ packages: dev: false resolution: integrity: sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw== + /yargs/15.3.1: + dependencies: + cliui: 6.0.0 + decamelize: 1.2.0 + find-up: 4.1.0 + get-caller-file: 2.0.5 + require-directory: 2.1.1 + require-main-filename: 2.0.0 + set-blocking: 2.0.0 + string-width: 4.2.0 + which-module: 2.0.0 + y18n: 4.0.0 + yargs-parser: 18.1.3 + dev: false + engines: + node: '>=8' + resolution: + integrity: sha512-92O1HWEjw27sBfgmXiixJWT5hRBp2eobqXicLtPBIDBhYB+1HpwZlXmbW2luivBJHBzki+7VyCLRtAkScbTBQA== /yargs/3.32.0: dependencies: camelcase: 2.1.1 @@ -8054,13 +8170,13 @@ packages: dev: false name: '@rush-temp/azure-mocha-reporter' resolution: - integrity: sha512-+PLeufpL0gCUyoJgQQXHoPookA5P7N8fOWDclGUgWs4w/1gUKmxgS8oY6q/bqv9cPulFNkJ9tjmn58TkxbfW4A== + integrity: sha512-K4uN3hTX4mFlvlWpjhZJzwgvGRt6CM0/AkCiSk49gydKZfjpWGkWLN6jrrl4WV1HH5ZzMdSw1E3Mk8ENr9BFIA== tarball: 'file:projects/azure-mocha-reporter.tgz' version: 0.0.0 'file:projects/fabric-contract-api.tgz': dependencies: ajv: 6.12.2 - ajv-cli: 3.1.0 + ajv-cli: 3.2.1 chai: 4.2.0 chai-as-promised: 7.1.1_chai@4.2.0 chai-things: 0.2.0 @@ -8077,11 +8193,11 @@ packages: rewire: 4.0.1 sinon: 7.5.0 typescript: 3.0.1 - winston: 3.2.1 + winston: 3.3.2 dev: false name: '@rush-temp/fabric-contract-api' resolution: - integrity: sha512-SzNzf83jW0tkvBlJ2D1WydryQuJAz9gLf/c38SXKLREa0dL8iIg+471zyiSU9Ne0o0Y+McbxRgzGhRdZ4i7N0A== + integrity: sha512-8HUd54wBQ9Q9rGcnyiJOOeydUqJqsULo8+mPx48/zOfvDjfOO4hNTq7pN+R0z8l9U8skD1DhPUrHySZtHPlI3Q== tarball: 'file:projects/fabric-contract-api.tgz' version: 0.0.0 'file:projects/fabric-e2e-tests.tgz': @@ -8089,14 +8205,14 @@ packages: ajv: 6.12.2 ajv-cli: 3.1.0 delay: 4.3.0 - fs-extra: 8.1.0 + fs-extra: 9.0.1 git-rev-sync: 1.12.0 gulp: 4.0.2 ip: 1.1.5 dev: false name: '@rush-temp/fabric-e2e-tests' resolution: - integrity: sha512-F9yBWUJRhzfQwfBDAzAAlh5r4XMJq21tlPJXAMcwdrdeW5c6LXXh9Mhe5kH2QYh4Keiwnw3JSln3JglcwmvbUg== + integrity: sha512-3k6jsEKg2jlFSihY7glByTBJaeIOE080uLbGm8N/zgqOuTT37JS9FyafUxSohpMj9+5ew6hNEsDjrXuQiUmcKQ== tarball: 'file:projects/fabric-e2e-tests.tgz' version: 0.0.0 'file:projects/fabric-nodeenv.tgz': @@ -8106,14 +8222,14 @@ packages: dev: false name: '@rush-temp/fabric-nodeenv' resolution: - integrity: sha512-XEvG1TN8UuhiSLATQdjfxeqNQ0Nb4dzqcF9n6E6gtV4rBCfYyemyJEOhRJZUeWdERPmoQlOY3ahqqm6N+ixjow== + integrity: sha512-W6+8KwlqUyP5/D/YFLdbJODDvPaWP97H62UlV2VbQda3GZn8N3/EbPZTUmCwaQMQzRaWMrWSs1H6rygNJOkcdg== tarball: 'file:projects/fabric-nodeenv.tgz' version: 0.0.0 'file:projects/fabric-shim-api.tgz': dev: false name: '@rush-temp/fabric-shim-api' resolution: - integrity: sha512-C/wQBEkPZ8oDtDyx5A7L6osaFEtkhQI+0ACY6c5yUKM0GsB5OSo0gvwjupszGYPxQ0HIB9YFyuAV1tQnHnPr9g== + integrity: sha512-RhCwa6ZEGj0wSQAsW2Lw7LoN+EyUFA13itX0jCX39t1vIty7NWzemqxt5cI1FuqmcxRbhu0J4E3mfjNAxsJ/tA== tarball: 'file:projects/fabric-shim-api.tgz' version: 0.0.0 'file:projects/fabric-shim-crypto.tgz': @@ -8121,9 +8237,9 @@ packages: chai: 4.2.0 chai-as-promised: 7.1.1_chai@4.2.0 chai-things: 0.2.0 - elliptic: 6.5.2 + elliptic: 6.5.3 eslint: 6.6.0 - jsrsasign: 8.0.15 + jsrsasign: 8.0.19 mocha: 6.2.2 nyc: 14.1.1 rewire: 4.0.1 @@ -8132,7 +8248,7 @@ packages: dev: false name: '@rush-temp/fabric-shim-crypto' resolution: - integrity: sha512-G1AoFVJ7puQCxGmbVC7XYVqe0V2BWC2dojI//HQfrSDrDMNsEPa98sZ5if44/FcZoHKqoke5HarbpknQXrVOJw== + integrity: sha512-J5aiqTMtBpLRAOiDZLDCcQ7WeOuMmJvT8xVB/ka5URu4GvaM+dB9Q33AaxvywUrozTV8IEgxbs9bRop8NWUYDQ== tarball: 'file:projects/fabric-shim-crypto.tgz' version: 0.0.0 'file:projects/fabric-shim-docs.tgz': @@ -8143,22 +8259,22 @@ packages: dev: false name: '@rush-temp/fabric-shim-docs' resolution: - integrity: sha512-cDXaZSoeWlDSDxoEgEM9B4HI6f2ivsttzl+HI8jwhcUHZ5B5Fa0bSbenb4IIBimVUbpWHpc5GMBgSRdGPH3oyA== + integrity: sha512-WnGbGQKWGXIG1Mfr0VR1Sxj1ColMNfOB2hDOJRY3yTpSUkg5lHaAA5UThKL4orrqQ4Oeq0LVy7gIRNylibcaYA== tarball: 'file:projects/fabric-shim-docs.tgz' version: 0.0.0 'file:projects/fabric-shim.tgz': dependencies: '@fidm/x509': 1.2.1 - '@grpc/grpc-js': 1.0.3 + '@grpc/grpc-js': 1.1.1 '@grpc/proto-loader': 0.5.4 - '@types/node': 8.10.60 + '@types/node': 14.0.13 ajv: 6.12.2 chai: 4.2.0 chai-as-promised: 7.1.1_chai@4.2.0 chai-things: 0.2.0 cpx: 1.5.0 eslint: 6.6.0 - fs-extra: 8.1.0 + fs-extra: 9.0.1 grpc: 1.24.2 mocha: 6.2.2 mockery: 2.1.0 @@ -8167,13 +8283,13 @@ packages: rewire: 4.0.1 rimraf: 3.0.2 sinon: 7.5.0 - winston: 3.2.1 - yargs: 13.3.2 - yargs-parser: 13.1.2 + winston: 3.3.2 + yargs: 15.3.1 + yargs-parser: 18.1.3 dev: false name: '@rush-temp/fabric-shim' resolution: - integrity: sha512-ZV+wiU1qpTnk7AN78F353V7XA3hgXZDnjKvj50kjg3dNbhfufv+beq5MPAa4IqdhR0VVpaxabNp2c2SUBy9iig== + integrity: sha512-hzhRnIxsa+ac4K44tRdRNnCmZn2OZCEsAi1soYRmNVoECi4Pv0MLyrQsVrQGghAIKyOKS7oMXVVMqQGVjFwCCw== tarball: 'file:projects/fabric-shim.tgz' version: 0.0.0 'file:projects/fvtests.tgz': @@ -8187,7 +8303,7 @@ packages: del: 3.0.0 delay: 4.3.0 eslint: 6.6.0 - fs-extra: 8.1.0 + fs-extra: 9.0.1 git-rev-sync: 1.12.0 gulp: 4.0.2 ip: 1.1.5 @@ -8201,13 +8317,13 @@ packages: dev: false name: '@rush-temp/fvtests' resolution: - integrity: sha512-LwG4nNueXaKRm7BlUYYF1GDTkv1k5O46FHlZmmVy06aA5ZmEb/KE/EufoDX8hNBoZIHF+ANvvffSYd1489jN9A== + integrity: sha512-CJYd7AQxwOLQfKLfUJyC98zWuTEZDwmqT83C9/VB9paZuMT4GqwJchV6Rl+80NJP61wMk+b+HQS13r6T9eEGEA== tarball: 'file:projects/fvtests.tgz' version: 0.0.0 'file:projects/toolchain.tgz': dependencies: delay: 4.3.0 - fs-extra: 8.1.0 + fs-extra: 9.0.1 git-rev-sync: 1.12.0 gulp: 4.0.2 gulp-debug: 4.0.0_gulp@4.0.2 @@ -8219,13 +8335,13 @@ packages: dev: false name: '@rush-temp/toolchain' resolution: - integrity: sha512-+toP8l9dcrKyCdR66r+tNGb5eU0AJNhuAXIM9s45OIkCNCd/0eUSkOm28mOPVozUYTPlLcvwulh10rAJmwSZ+w== + integrity: sha512-zcwQ437gyMgDN9ksy1TJ0tczvnoUdMExPxvi+22vbpp/dkao/cphxpnZW8vfTFgE+z6cCLSpPLog1UwZpiQepg== tarball: 'file:projects/toolchain.tgz' version: 0.0.0 registry: '' specifiers: '@fidm/x509': ^1.2.1 - '@grpc/grpc-js': ^1.0.3 + '@grpc/grpc-js': 1.1.1 '@grpc/proto-loader': ^0.5.4 '@rush-temp/azure-mocha-reporter': 'file:./projects/azure-mocha-reporter.tgz' '@rush-temp/fabric-contract-api': 'file:./projects/fabric-contract-api.tgz' @@ -8238,9 +8354,7 @@ specifiers: '@rush-temp/fvtests': 'file:./projects/fvtests.tgz' '@rush-temp/toolchain': 'file:./projects/toolchain.tgz' '@sinonjs/referee-sinon': ~5.0.0 - '@types/node': ^8.9.4 - ajv: ^6.5.5 - ajv-cli: ^3.0.0 + '@types/node': ^14.0.13 chai: ^4.1.1 chai-as-promised: ^7.1.1 chai-things: ^0.2.0 @@ -8248,10 +8362,10 @@ specifiers: cpx: ^1.5.0 del: ^3.0.0 delay: 4.3.0 - elliptic: ^6.4.0 + elliptic: ^6.5.3 eslint: 6.6.0 - fast-safe-stringify: ~2.0.7 - fs-extra: 8.1.0 + fast-safe-stringify: ^2.0.7 + fs-extra: ^9.0.1 get-params: ^0.1.2 git-rev-sync: 1.12.0 gulp: ^4.0.0 @@ -8263,7 +8377,7 @@ specifiers: ip: ^1.1.5 istanbul-api: ^1.1.13 jsdoc: ^3.6.3 - jsrsasign: ^8.0.4 + jsrsasign: ^8.0.19 jsverify: ~0.8.4 merge-stream: ~2.0.0 mocha: 6.2.2 @@ -8271,12 +8385,12 @@ specifiers: mockery: ^2.1.0 npm-cli-login: ~0.1.1 nyc: 14.1.1 - reflect-metadata: ^0.1.12 + reflect-metadata: ^0.1.13 rewire: 4.0.1 rimraf: ^3.0.0 sinon: 7.5.0 sinon-test: ^2.2.0 typescript: 3.0.1 - winston: ^3.2.1 - yargs: '^13.3.0 ' - yargs-parser: ^13.1.1 + winston: ^3.3.2 + yargs: ^15.3.1 + yargs-parser: ^18.1.3 diff --git a/common/scripts/install-run-rush.js b/common/scripts/install-run-rush.js index ed21abf85..4cc67a75b 100644 --- a/common/scripts/install-run-rush.js +++ b/common/scripts/install-run-rush.js @@ -1,67 +1,67 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. -// See the @microsoft/rush package's LICENSE file for license information. -Object.defineProperty(exports, "__esModule", { value: true }); -// THIS FILE WAS GENERATED BY A TOOL. ANY MANUAL MODIFICATIONS WILL GET OVERWRITTEN WHENEVER RUSH IS UPGRADED. -// -// This script is intended for usage in an automated build environment where the Rush command may not have -// been preinstalled, or may have an unpredictable version. This script will automatically install the version of Rush -// specified in the rush.json configuration file (if not already installed), and then pass a command-line to it. -// An example usage would be: -// -// node common/scripts/install-run-rush.js install -// -// For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/ -const path = require("path"); -const fs = require("fs"); -const install_run_1 = require("./install-run"); -const PACKAGE_NAME = '@microsoft/rush'; -const RUSH_PREVIEW_VERSION = 'RUSH_PREVIEW_VERSION'; -function _getRushVersion() { - const rushPreviewVersion = process.env[RUSH_PREVIEW_VERSION]; - if (rushPreviewVersion !== undefined) { - console.log(`Using Rush version from environment variable ${RUSH_PREVIEW_VERSION}=${rushPreviewVersion}`); - return rushPreviewVersion; - } - const rushJsonFolder = install_run_1.findRushJsonFolder(); - const rushJsonPath = path.join(rushJsonFolder, install_run_1.RUSH_JSON_FILENAME); - try { - const rushJsonContents = fs.readFileSync(rushJsonPath, 'utf-8'); - // Use a regular expression to parse out the rushVersion value because rush.json supports comments, - // but JSON.parse does not and we don't want to pull in more dependencies than we need to in this script. - const rushJsonMatches = rushJsonContents.match(/\"rushVersion\"\s*\:\s*\"([0-9a-zA-Z.+\-]+)\"/); - return rushJsonMatches[1]; - } - catch (e) { - throw new Error(`Unable to determine the required version of Rush from rush.json (${rushJsonFolder}). ` + - 'The \'rushVersion\' field is either not assigned in rush.json or was specified ' + - 'using an unexpected syntax.'); - } -} -function _run() { - const [nodePath, /* Ex: /bin/node */ scriptPath, /* /repo/common/scripts/install-run-rush.js */ ...packageBinArgs /* [build, --to, myproject] */] = process.argv; - // Detect if this script was directly invoked, or if the install-run-rushx script was invokved to select the - // appropriate binary inside the rush package to run - const scriptName = path.basename(scriptPath); - const bin = scriptName.toLowerCase() === 'install-run-rushx.js' ? 'rushx' : 'rush'; - if (!nodePath || !scriptPath) { - throw new Error('Unexpected exception: could not detect node path or script path'); - } - if (process.argv.length < 3) { - console.log(`Usage: ${scriptName} [args...]`); - if (scriptName === 'install-run-rush.js') { - console.log(`Example: ${scriptName} build --to myproject`); - } - else { - console.log(`Example: ${scriptName} custom-command`); - } - process.exit(1); - } - install_run_1.runWithErrorAndStatusCode(() => { - const version = _getRushVersion(); - console.log(`The rush.json configuration requests Rush version ${version}`); - return install_run_1.installAndRun(PACKAGE_NAME, version, bin, packageBinArgs); - }); -} -_run(); +"use strict"; +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See the @microsoft/rush package's LICENSE file for license information. +Object.defineProperty(exports, "__esModule", { value: true }); +// THIS FILE WAS GENERATED BY A TOOL. ANY MANUAL MODIFICATIONS WILL GET OVERWRITTEN WHENEVER RUSH IS UPGRADED. +// +// This script is intended for usage in an automated build environment where the Rush command may not have +// been preinstalled, or may have an unpredictable version. This script will automatically install the version of Rush +// specified in the rush.json configuration file (if not already installed), and then pass a command-line to it. +// An example usage would be: +// +// node common/scripts/install-run-rush.js install +// +// For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/ +const path = require("path"); +const fs = require("fs"); +const install_run_1 = require("./install-run"); +const PACKAGE_NAME = '@microsoft/rush'; +const RUSH_PREVIEW_VERSION = 'RUSH_PREVIEW_VERSION'; +function _getRushVersion() { + const rushPreviewVersion = process.env[RUSH_PREVIEW_VERSION]; + if (rushPreviewVersion !== undefined) { + console.log(`Using Rush version from environment variable ${RUSH_PREVIEW_VERSION}=${rushPreviewVersion}`); + return rushPreviewVersion; + } + const rushJsonFolder = install_run_1.findRushJsonFolder(); + const rushJsonPath = path.join(rushJsonFolder, install_run_1.RUSH_JSON_FILENAME); + try { + const rushJsonContents = fs.readFileSync(rushJsonPath, 'utf-8'); + // Use a regular expression to parse out the rushVersion value because rush.json supports comments, + // but JSON.parse does not and we don't want to pull in more dependencies than we need to in this script. + const rushJsonMatches = rushJsonContents.match(/\"rushVersion\"\s*\:\s*\"([0-9a-zA-Z.+\-]+)\"/); + return rushJsonMatches[1]; + } + catch (e) { + throw new Error(`Unable to determine the required version of Rush from rush.json (${rushJsonFolder}). ` + + "The 'rushVersion' field is either not assigned in rush.json or was specified " + + 'using an unexpected syntax.'); + } +} +function _run() { + const [nodePath /* Ex: /bin/node */, scriptPath /* /repo/common/scripts/install-run-rush.js */, ...packageBinArgs /* [build, --to, myproject] */] = process.argv; + // Detect if this script was directly invoked, or if the install-run-rushx script was invokved to select the + // appropriate binary inside the rush package to run + const scriptName = path.basename(scriptPath); + const bin = scriptName.toLowerCase() === 'install-run-rushx.js' ? 'rushx' : 'rush'; + if (!nodePath || !scriptPath) { + throw new Error('Unexpected exception: could not detect node path or script path'); + } + if (process.argv.length < 3) { + console.log(`Usage: ${scriptName} [args...]`); + if (scriptName === 'install-run-rush.js') { + console.log(`Example: ${scriptName} build --to myproject`); + } + else { + console.log(`Example: ${scriptName} custom-command`); + } + process.exit(1); + } + install_run_1.runWithErrorAndStatusCode(() => { + const version = _getRushVersion(); + console.log(`The rush.json configuration requests Rush version ${version}`); + return install_run_1.installAndRun(PACKAGE_NAME, version, bin, packageBinArgs); + }); +} +_run(); //# sourceMappingURL=install-run-rush.js.map \ No newline at end of file diff --git a/common/scripts/install-run.js b/common/scripts/install-run.js index d810f7cc4..53e27aa69 100644 --- a/common/scripts/install-run.js +++ b/common/scripts/install-run.js @@ -1,418 +1,434 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. -// See the @microsoft/rush package's LICENSE file for license information. -Object.defineProperty(exports, "__esModule", { value: true }); -// THIS FILE WAS GENERATED BY A TOOL. ANY MANUAL MODIFICATIONS WILL GET OVERWRITTEN WHENEVER RUSH IS UPGRADED. -// -// This script is intended for usage in an automated build environment where a Node tool may not have -// been preinstalled, or may have an unpredictable version. This script will automatically install the specified -// version of the specified tool (if not already installed), and then pass a command-line to it. -// An example usage would be: -// -// node common/scripts/install-run.js qrcode@1.2.2 qrcode https://rushjs.io -// -// For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/ -const childProcess = require("child_process"); -const fs = require("fs"); -const os = require("os"); -const path = require("path"); -exports.RUSH_JSON_FILENAME = 'rush.json'; -const RUSH_TEMP_FOLDER_ENV_VARIABLE_NAME = 'RUSH_TEMP_FOLDER'; -const INSTALLED_FLAG_FILENAME = 'installed.flag'; -const NODE_MODULES_FOLDER_NAME = 'node_modules'; -const PACKAGE_JSON_FILENAME = 'package.json'; -/** - * Parse a package specifier (in the form of name\@version) into name and version parts. - */ -function _parsePackageSpecifier(rawPackageSpecifier) { - rawPackageSpecifier = (rawPackageSpecifier || '').trim(); - const separatorIndex = rawPackageSpecifier.lastIndexOf('@'); - let name; - let version = undefined; - if (separatorIndex === 0) { - // The specifier starts with a scope and doesn't have a version specified - name = rawPackageSpecifier; - } - else if (separatorIndex === -1) { - // The specifier doesn't have a version - name = rawPackageSpecifier; - } - else { - name = rawPackageSpecifier.substring(0, separatorIndex); - version = rawPackageSpecifier.substring(separatorIndex + 1); - } - if (!name) { - throw new Error(`Invalid package specifier: ${rawPackageSpecifier}`); - } - return { name, version }; -} -/** - * Resolve a package specifier to a static version - */ -function _resolvePackageVersion(rushCommonFolder, { name, version }) { - if (!version) { - version = '*'; // If no version is specified, use the latest version - } - if (version.match(/^[a-zA-Z0-9\-\+\.]+$/)) { - // If the version contains only characters that we recognize to be used in static version specifiers, - // pass the version through - return version; - } - else { - // version resolves to - try { - const rushTempFolder = _getRushTempFolder(rushCommonFolder); - const sourceNpmrcFolder = path.join(rushCommonFolder, 'config', 'rush'); - _syncNpmrc(sourceNpmrcFolder, rushTempFolder); - const npmPath = getNpmPath(); - // This returns something that looks like: - // @microsoft/rush@3.0.0 '3.0.0' - // @microsoft/rush@3.0.1 '3.0.1' - // ... - // @microsoft/rush@3.0.20 '3.0.20' - // - const npmVersionSpawnResult = childProcess.spawnSync(npmPath, ['view', `${name}@${version}`, 'version', '--no-update-notifier'], { - cwd: rushTempFolder, - stdio: [] - }); - if (npmVersionSpawnResult.status !== 0) { - throw new Error(`"npm view" returned error code ${npmVersionSpawnResult.status}`); - } - const npmViewVersionOutput = npmVersionSpawnResult.stdout.toString(); - const versionLines = npmViewVersionOutput.split('\n').filter((line) => !!line); - const latestVersion = versionLines[versionLines.length - 1]; - if (!latestVersion) { - throw new Error('No versions found for the specified version range.'); - } - const versionMatches = latestVersion.match(/^.+\s\'(.+)\'$/); - if (!versionMatches) { - throw new Error(`Invalid npm output ${latestVersion}`); - } - return versionMatches[1]; - } - catch (e) { - throw new Error(`Unable to resolve version ${version} of package ${name}: ${e}`); - } - } -} -let _npmPath = undefined; -/** - * Get the absolute path to the npm executable - */ -function getNpmPath() { - if (!_npmPath) { - try { - if (os.platform() === 'win32') { - // We're on Windows - const whereOutput = childProcess.execSync('where npm', { stdio: [] }).toString(); - const lines = whereOutput.split(os.EOL).filter((line) => !!line); - // take the last result, we are looking for a .cmd command - // see https://github.com/microsoft/rushstack/issues/759 - _npmPath = lines[lines.length - 1]; - } - else { - // We aren't on Windows - assume we're on *NIX or Darwin - _npmPath = childProcess.execSync('which npm', { stdio: [] }).toString(); - } - } - catch (e) { - throw new Error(`Unable to determine the path to the NPM tool: ${e}`); - } - _npmPath = _npmPath.trim(); - if (!fs.existsSync(_npmPath)) { - throw new Error('The NPM executable does not exist'); - } - } - return _npmPath; -} -exports.getNpmPath = getNpmPath; -let _rushJsonFolder; -/** - * Find the absolute path to the folder containing rush.json - */ -function findRushJsonFolder() { - if (!_rushJsonFolder) { - let basePath = __dirname; - let tempPath = __dirname; - do { - const testRushJsonPath = path.join(basePath, exports.RUSH_JSON_FILENAME); - if (fs.existsSync(testRushJsonPath)) { - _rushJsonFolder = basePath; - break; - } - else { - basePath = tempPath; - } - } while (basePath !== (tempPath = path.dirname(basePath))); // Exit the loop when we hit the disk root - if (!_rushJsonFolder) { - throw new Error('Unable to find rush.json.'); - } - } - return _rushJsonFolder; -} -exports.findRushJsonFolder = findRushJsonFolder; -/** - * Create missing directories under the specified base directory, and return the resolved directory. - * - * Does not support "." or ".." path segments. - * Assumes the baseFolder exists. - */ -function _ensureAndJoinPath(baseFolder, ...pathSegments) { - let joinedPath = baseFolder; - try { - for (let pathSegment of pathSegments) { - pathSegment = pathSegment.replace(/[\\\/]/g, '+'); - joinedPath = path.join(joinedPath, pathSegment); - if (!fs.existsSync(joinedPath)) { - fs.mkdirSync(joinedPath); - } - } - } - catch (e) { - throw new Error(`Error building local installation folder (${path.join(baseFolder, ...pathSegments)}): ${e}`); - } - return joinedPath; -} -/** - * As a workaround, _syncNpmrc() copies the .npmrc file to the target folder, and also trims - * unusable lines from the .npmrc file. If the source .npmrc file not exist, then _syncNpmrc() - * will delete an .npmrc that is found in the target folder. - * - * Why are we trimming the .npmrc lines? NPM allows environment variables to be specified in - * the .npmrc file to provide different authentication tokens for different registry. - * However, if the environment variable is undefined, it expands to an empty string, which - * produces a valid-looking mapping with an invalid URL that causes an error. Instead, - * we'd prefer to skip that line and continue looking in other places such as the user's - * home directory. - * - * IMPORTANT: THIS CODE SHOULD BE KEPT UP TO DATE WITH Utilities._syncNpmrc() - */ -function _syncNpmrc(sourceNpmrcFolder, targetNpmrcFolder) { - const sourceNpmrcPath = path.join(sourceNpmrcFolder, '.npmrc'); - const targetNpmrcPath = path.join(targetNpmrcFolder, '.npmrc'); - try { - if (fs.existsSync(sourceNpmrcPath)) { - let npmrcFileLines = fs.readFileSync(sourceNpmrcPath).toString().split('\n'); - npmrcFileLines = npmrcFileLines.map((line) => (line || '').trim()); - const resultLines = []; - // Trim out lines that reference environment variables that aren't defined - for (const line of npmrcFileLines) { - // This finds environment variable tokens that look like "${VAR_NAME}" - const regex = /\$\{([^\}]+)\}/g; - const environmentVariables = line.match(regex); - let lineShouldBeTrimmed = false; - if (environmentVariables) { - for (const token of environmentVariables) { - // Remove the leading "${" and the trailing "}" from the token - const environmentVariableName = token.substring(2, token.length - 1); - if (!process.env[environmentVariableName]) { - lineShouldBeTrimmed = true; - break; - } - } - } - if (lineShouldBeTrimmed) { - // Example output: - // "; MISSING ENVIRONMENT VARIABLE: //my-registry.com/npm/:_authToken=${MY_AUTH_TOKEN}" - resultLines.push('; MISSING ENVIRONMENT VARIABLE: ' + line); - } - else { - resultLines.push(line); - } - } - fs.writeFileSync(targetNpmrcPath, resultLines.join(os.EOL)); - } - else if (fs.existsSync(targetNpmrcPath)) { - // If the source .npmrc doesn't exist and there is one in the target, delete the one in the target - fs.unlinkSync(targetNpmrcPath); - } - } - catch (e) { - throw new Error(`Error syncing .npmrc file: ${e}`); - } -} -/** - * Detects if the package in the specified directory is installed - */ -function _isPackageAlreadyInstalled(packageInstallFolder) { - try { - const flagFilePath = path.join(packageInstallFolder, INSTALLED_FLAG_FILENAME); - if (!fs.existsSync(flagFilePath)) { - return false; - } - const fileContents = fs.readFileSync(flagFilePath).toString(); - return fileContents.trim() === process.version; - } - catch (e) { - return false; - } -} -/** - * Removes the following files and directories under the specified folder path: - * - installed.flag - * - - * - node_modules - */ -function _cleanInstallFolder(rushTempFolder, packageInstallFolder) { - try { - const flagFile = path.resolve(packageInstallFolder, INSTALLED_FLAG_FILENAME); - if (fs.existsSync(flagFile)) { - fs.unlinkSync(flagFile); - } - const packageLockFile = path.resolve(packageInstallFolder, 'package-lock.json'); - if (fs.existsSync(packageLockFile)) { - fs.unlinkSync(packageLockFile); - } - const nodeModulesFolder = path.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME); - if (fs.existsSync(nodeModulesFolder)) { - const rushRecyclerFolder = _ensureAndJoinPath(rushTempFolder, 'rush-recycler', `install-run-${Date.now().toString()}`); - fs.renameSync(nodeModulesFolder, rushRecyclerFolder); - } - } - catch (e) { - throw new Error(`Error cleaning the package install folder (${packageInstallFolder}): ${e}`); - } -} -function _createPackageJson(packageInstallFolder, name, version) { - try { - const packageJsonContents = { - 'name': 'ci-rush', - 'version': '0.0.0', - 'dependencies': { - [name]: version - }, - 'description': 'DON\'T WARN', - 'repository': 'DON\'T WARN', - 'license': 'MIT' - }; - const packageJsonPath = path.join(packageInstallFolder, PACKAGE_JSON_FILENAME); - fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContents, undefined, 2)); - } - catch (e) { - throw new Error(`Unable to create package.json: ${e}`); - } -} -/** - * Run "npm install" in the package install folder. - */ -function _installPackage(packageInstallFolder, name, version) { - try { - console.log(`Installing ${name}...`); - const npmPath = getNpmPath(); - const result = childProcess.spawnSync(npmPath, ['install'], { - stdio: 'inherit', - cwd: packageInstallFolder, - env: process.env - }); - if (result.status !== 0) { - throw new Error('"npm install" encountered an error'); - } - console.log(`Successfully installed ${name}@${version}`); - } - catch (e) { - throw new Error(`Unable to install package: ${e}`); - } -} -/** - * Get the ".bin" path for the package. - */ -function _getBinPath(packageInstallFolder, binName) { - const binFolderPath = path.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME, '.bin'); - const resolvedBinName = (os.platform() === 'win32') ? `${binName}.cmd` : binName; - return path.resolve(binFolderPath, resolvedBinName); -} -/** - * Write a flag file to the package's install directory, signifying that the install was successful. - */ -function _writeFlagFile(packageInstallFolder) { - try { - const flagFilePath = path.join(packageInstallFolder, INSTALLED_FLAG_FILENAME); - fs.writeFileSync(flagFilePath, process.version); - } - catch (e) { - throw new Error(`Unable to create installed.flag file in ${packageInstallFolder}`); - } -} -function _getRushTempFolder(rushCommonFolder) { - const rushTempFolder = process.env[RUSH_TEMP_FOLDER_ENV_VARIABLE_NAME]; - if (rushTempFolder !== undefined) { - _ensureFolder(rushTempFolder); - return rushTempFolder; - } - else { - return _ensureAndJoinPath(rushCommonFolder, 'temp'); - } -} -function _ensureFolder(folderPath) { - if (!fs.existsSync(folderPath)) { - const parentDir = path.dirname(folderPath); - _ensureFolder(parentDir); - fs.mkdirSync(folderPath); - } -} -function installAndRun(packageName, packageVersion, packageBinName, packageBinArgs) { - const rushJsonFolder = findRushJsonFolder(); - const rushCommonFolder = path.join(rushJsonFolder, 'common'); - const rushTempFolder = _getRushTempFolder(rushCommonFolder); - const packageInstallFolder = _ensureAndJoinPath(rushTempFolder, 'install-run', `${packageName}@${packageVersion}`); - if (!_isPackageAlreadyInstalled(packageInstallFolder)) { - // The package isn't already installed - _cleanInstallFolder(rushTempFolder, packageInstallFolder); - const sourceNpmrcFolder = path.join(rushCommonFolder, 'config', 'rush'); - _syncNpmrc(sourceNpmrcFolder, packageInstallFolder); - _createPackageJson(packageInstallFolder, packageName, packageVersion); - _installPackage(packageInstallFolder, packageName, packageVersion); - _writeFlagFile(packageInstallFolder); - } - const statusMessage = `Invoking "${packageBinName} ${packageBinArgs.join(' ')}"`; - const statusMessageLine = new Array(statusMessage.length + 1).join('-'); - console.log(os.EOL + statusMessage + os.EOL + statusMessageLine + os.EOL); - const binPath = _getBinPath(packageInstallFolder, packageBinName); - const result = childProcess.spawnSync(binPath, packageBinArgs, { - stdio: 'inherit', - cwd: process.cwd(), - env: process.env - }); - return result.status; -} -exports.installAndRun = installAndRun; -function runWithErrorAndStatusCode(fn) { - process.exitCode = 1; - try { - const exitCode = fn(); - process.exitCode = exitCode; - } - catch (e) { - console.error(os.EOL + os.EOL + e.toString() + os.EOL + os.EOL); - } -} -exports.runWithErrorAndStatusCode = runWithErrorAndStatusCode; -function _run() { - const [nodePath, /* Ex: /bin/node */ scriptPath, /* /repo/common/scripts/install-run-rush.js */ rawPackageSpecifier, /* qrcode@^1.2.0 */ packageBinName, /* qrcode */ ...packageBinArgs /* [-f, myproject/lib] */] = process.argv; - if (!nodePath) { - throw new Error('Unexpected exception: could not detect node path'); - } - if (path.basename(scriptPath).toLowerCase() !== 'install-run.js') { - // If install-run.js wasn't directly invoked, don't execute the rest of this function. Return control - // to the script that (presumably) imported this file - return; - } - if (process.argv.length < 4) { - console.log('Usage: install-run.js @ [args...]'); - console.log('Example: install-run.js qrcode@1.2.2 qrcode https://rushjs.io'); - process.exit(1); - } - runWithErrorAndStatusCode(() => { - const rushJsonFolder = findRushJsonFolder(); - const rushCommonFolder = _ensureAndJoinPath(rushJsonFolder, 'common'); - const packageSpecifier = _parsePackageSpecifier(rawPackageSpecifier); - const name = packageSpecifier.name; - const version = _resolvePackageVersion(rushCommonFolder, packageSpecifier); - if (packageSpecifier.version !== version) { - console.log(`Resolved to ${name}@${version}`); - } - return installAndRun(name, version, packageBinName, packageBinArgs); - }); -} -_run(); +"use strict"; +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See the @microsoft/rush package's LICENSE file for license information. +Object.defineProperty(exports, "__esModule", { value: true }); +// THIS FILE WAS GENERATED BY A TOOL. ANY MANUAL MODIFICATIONS WILL GET OVERWRITTEN WHENEVER RUSH IS UPGRADED. +// +// This script is intended for usage in an automated build environment where a Node tool may not have +// been preinstalled, or may have an unpredictable version. This script will automatically install the specified +// version of the specified tool (if not already installed), and then pass a command-line to it. +// An example usage would be: +// +// node common/scripts/install-run.js qrcode@1.2.2 qrcode https://rushjs.io +// +// For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/ +const childProcess = require("child_process"); +const fs = require("fs"); +const os = require("os"); +const path = require("path"); +exports.RUSH_JSON_FILENAME = 'rush.json'; +const RUSH_TEMP_FOLDER_ENV_VARIABLE_NAME = 'RUSH_TEMP_FOLDER'; +const INSTALLED_FLAG_FILENAME = 'installed.flag'; +const NODE_MODULES_FOLDER_NAME = 'node_modules'; +const PACKAGE_JSON_FILENAME = 'package.json'; +/** + * Parse a package specifier (in the form of name\@version) into name and version parts. + */ +function _parsePackageSpecifier(rawPackageSpecifier) { + rawPackageSpecifier = (rawPackageSpecifier || '').trim(); + const separatorIndex = rawPackageSpecifier.lastIndexOf('@'); + let name; + let version = undefined; + if (separatorIndex === 0) { + // The specifier starts with a scope and doesn't have a version specified + name = rawPackageSpecifier; + } + else if (separatorIndex === -1) { + // The specifier doesn't have a version + name = rawPackageSpecifier; + } + else { + name = rawPackageSpecifier.substring(0, separatorIndex); + version = rawPackageSpecifier.substring(separatorIndex + 1); + } + if (!name) { + throw new Error(`Invalid package specifier: ${rawPackageSpecifier}`); + } + return { name, version }; +} +/** + * As a workaround, copyAndTrimNpmrcFile() copies the .npmrc file to the target folder, and also trims + * unusable lines from the .npmrc file. + * + * Why are we trimming the .npmrc lines? NPM allows environment variables to be specified in + * the .npmrc file to provide different authentication tokens for different registry. + * However, if the environment variable is undefined, it expands to an empty string, which + * produces a valid-looking mapping with an invalid URL that causes an error. Instead, + * we'd prefer to skip that line and continue looking in other places such as the user's + * home directory. + * + * IMPORTANT: THIS CODE SHOULD BE KEPT UP TO DATE WITH Utilities._copyNpmrcFile() + */ +function _copyAndTrimNpmrcFile(sourceNpmrcPath, targetNpmrcPath) { + console.log(`Copying ${sourceNpmrcPath} --> ${targetNpmrcPath}`); // Verbose + let npmrcFileLines = fs.readFileSync(sourceNpmrcPath).toString().split('\n'); + npmrcFileLines = npmrcFileLines.map((line) => (line || '').trim()); + const resultLines = []; + // Trim out lines that reference environment variables that aren't defined + for (const line of npmrcFileLines) { + // This finds environment variable tokens that look like "${VAR_NAME}" + const regex = /\$\{([^\}]+)\}/g; + const environmentVariables = line.match(regex); + let lineShouldBeTrimmed = false; + if (environmentVariables) { + for (const token of environmentVariables) { + // Remove the leading "${" and the trailing "}" from the token + const environmentVariableName = token.substring(2, token.length - 1); + if (!process.env[environmentVariableName]) { + lineShouldBeTrimmed = true; + break; + } + } + } + if (lineShouldBeTrimmed) { + // Example output: + // "; MISSING ENVIRONMENT VARIABLE: //my-registry.com/npm/:_authToken=${MY_AUTH_TOKEN}" + resultLines.push('; MISSING ENVIRONMENT VARIABLE: ' + line); + } + else { + resultLines.push(line); + } + } + fs.writeFileSync(targetNpmrcPath, resultLines.join(os.EOL)); +} +/** + * syncNpmrc() copies the .npmrc file to the target folder, and also trims unusable lines from the .npmrc file. + * If the source .npmrc file not exist, then syncNpmrc() will delete an .npmrc that is found in the target folder. + * + * IMPORTANT: THIS CODE SHOULD BE KEPT UP TO DATE WITH Utilities._syncNpmrc() + */ +function _syncNpmrc(sourceNpmrcFolder, targetNpmrcFolder, useNpmrcPublish) { + const sourceNpmrcPath = path.join(sourceNpmrcFolder, !useNpmrcPublish ? '.npmrc' : '.npmrc-publish'); + const targetNpmrcPath = path.join(targetNpmrcFolder, '.npmrc'); + try { + if (fs.existsSync(sourceNpmrcPath)) { + _copyAndTrimNpmrcFile(sourceNpmrcPath, targetNpmrcPath); + } + else if (fs.existsSync(targetNpmrcPath)) { + // If the source .npmrc doesn't exist and there is one in the target, delete the one in the target + console.log(`Deleting ${targetNpmrcPath}`); // Verbose + fs.unlinkSync(targetNpmrcPath); + } + } + catch (e) { + throw new Error(`Error syncing .npmrc file: ${e}`); + } +} +let _npmPath = undefined; +/** + * Get the absolute path to the npm executable + */ +function getNpmPath() { + if (!_npmPath) { + try { + if (os.platform() === 'win32') { + // We're on Windows + const whereOutput = childProcess.execSync('where npm', { stdio: [] }).toString(); + const lines = whereOutput.split(os.EOL).filter((line) => !!line); + // take the last result, we are looking for a .cmd command + // see https://github.com/microsoft/rushstack/issues/759 + _npmPath = lines[lines.length - 1]; + } + else { + // We aren't on Windows - assume we're on *NIX or Darwin + _npmPath = childProcess.execSync('command -v npm', { stdio: [] }).toString(); + } + } + catch (e) { + throw new Error(`Unable to determine the path to the NPM tool: ${e}`); + } + _npmPath = _npmPath.trim(); + if (!fs.existsSync(_npmPath)) { + throw new Error('The NPM executable does not exist'); + } + } + return _npmPath; +} +exports.getNpmPath = getNpmPath; +function _ensureFolder(folderPath) { + if (!fs.existsSync(folderPath)) { + const parentDir = path.dirname(folderPath); + _ensureFolder(parentDir); + fs.mkdirSync(folderPath); + } +} +/** + * Create missing directories under the specified base directory, and return the resolved directory. + * + * Does not support "." or ".." path segments. + * Assumes the baseFolder exists. + */ +function _ensureAndJoinPath(baseFolder, ...pathSegments) { + let joinedPath = baseFolder; + try { + for (let pathSegment of pathSegments) { + pathSegment = pathSegment.replace(/[\\\/]/g, '+'); + joinedPath = path.join(joinedPath, pathSegment); + if (!fs.existsSync(joinedPath)) { + fs.mkdirSync(joinedPath); + } + } + } + catch (e) { + throw new Error(`Error building local installation folder (${path.join(baseFolder, ...pathSegments)}): ${e}`); + } + return joinedPath; +} +function _getRushTempFolder(rushCommonFolder) { + const rushTempFolder = process.env[RUSH_TEMP_FOLDER_ENV_VARIABLE_NAME]; + if (rushTempFolder !== undefined) { + _ensureFolder(rushTempFolder); + return rushTempFolder; + } + else { + return _ensureAndJoinPath(rushCommonFolder, 'temp'); + } +} +/** + * Resolve a package specifier to a static version + */ +function _resolvePackageVersion(rushCommonFolder, { name, version }) { + if (!version) { + version = '*'; // If no version is specified, use the latest version + } + if (version.match(/^[a-zA-Z0-9\-\+\.]+$/)) { + // If the version contains only characters that we recognize to be used in static version specifiers, + // pass the version through + return version; + } + else { + // version resolves to + try { + const rushTempFolder = _getRushTempFolder(rushCommonFolder); + const sourceNpmrcFolder = path.join(rushCommonFolder, 'config', 'rush'); + _syncNpmrc(sourceNpmrcFolder, rushTempFolder); + const npmPath = getNpmPath(); + // This returns something that looks like: + // @microsoft/rush@3.0.0 '3.0.0' + // @microsoft/rush@3.0.1 '3.0.1' + // ... + // @microsoft/rush@3.0.20 '3.0.20' + // + const npmVersionSpawnResult = childProcess.spawnSync(npmPath, ['view', `${name}@${version}`, 'version', '--no-update-notifier'], { + cwd: rushTempFolder, + stdio: [] + }); + if (npmVersionSpawnResult.status !== 0) { + throw new Error(`"npm view" returned error code ${npmVersionSpawnResult.status}`); + } + const npmViewVersionOutput = npmVersionSpawnResult.stdout.toString(); + const versionLines = npmViewVersionOutput.split('\n').filter((line) => !!line); + const latestVersion = versionLines[versionLines.length - 1]; + if (!latestVersion) { + throw new Error('No versions found for the specified version range.'); + } + const versionMatches = latestVersion.match(/^.+\s\'(.+)\'$/); + if (!versionMatches) { + throw new Error(`Invalid npm output ${latestVersion}`); + } + return versionMatches[1]; + } + catch (e) { + throw new Error(`Unable to resolve version ${version} of package ${name}: ${e}`); + } + } +} +let _rushJsonFolder; +/** + * Find the absolute path to the folder containing rush.json + */ +function findRushJsonFolder() { + if (!_rushJsonFolder) { + let basePath = __dirname; + let tempPath = __dirname; + do { + const testRushJsonPath = path.join(basePath, exports.RUSH_JSON_FILENAME); + if (fs.existsSync(testRushJsonPath)) { + _rushJsonFolder = basePath; + break; + } + else { + basePath = tempPath; + } + } while (basePath !== (tempPath = path.dirname(basePath))); // Exit the loop when we hit the disk root + if (!_rushJsonFolder) { + throw new Error('Unable to find rush.json.'); + } + } + return _rushJsonFolder; +} +exports.findRushJsonFolder = findRushJsonFolder; +/** + * Detects if the package in the specified directory is installed + */ +function _isPackageAlreadyInstalled(packageInstallFolder) { + try { + const flagFilePath = path.join(packageInstallFolder, INSTALLED_FLAG_FILENAME); + if (!fs.existsSync(flagFilePath)) { + return false; + } + const fileContents = fs.readFileSync(flagFilePath).toString(); + return fileContents.trim() === process.version; + } + catch (e) { + return false; + } +} +/** + * Removes the following files and directories under the specified folder path: + * - installed.flag + * - + * - node_modules + */ +function _cleanInstallFolder(rushTempFolder, packageInstallFolder) { + try { + const flagFile = path.resolve(packageInstallFolder, INSTALLED_FLAG_FILENAME); + if (fs.existsSync(flagFile)) { + fs.unlinkSync(flagFile); + } + const packageLockFile = path.resolve(packageInstallFolder, 'package-lock.json'); + if (fs.existsSync(packageLockFile)) { + fs.unlinkSync(packageLockFile); + } + const nodeModulesFolder = path.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME); + if (fs.existsSync(nodeModulesFolder)) { + const rushRecyclerFolder = _ensureAndJoinPath(rushTempFolder, 'rush-recycler'); + fs.renameSync(nodeModulesFolder, path.join(rushRecyclerFolder, `install-run-${Date.now().toString()}`)); + } + } + catch (e) { + throw new Error(`Error cleaning the package install folder (${packageInstallFolder}): ${e}`); + } +} +function _createPackageJson(packageInstallFolder, name, version) { + try { + const packageJsonContents = { + name: 'ci-rush', + version: '0.0.0', + dependencies: { + [name]: version + }, + description: "DON'T WARN", + repository: "DON'T WARN", + license: 'MIT' + }; + const packageJsonPath = path.join(packageInstallFolder, PACKAGE_JSON_FILENAME); + fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContents, undefined, 2)); + } + catch (e) { + throw new Error(`Unable to create package.json: ${e}`); + } +} +/** + * Run "npm install" in the package install folder. + */ +function _installPackage(packageInstallFolder, name, version) { + try { + console.log(`Installing ${name}...`); + const npmPath = getNpmPath(); + const result = childProcess.spawnSync(npmPath, ['install'], { + stdio: 'inherit', + cwd: packageInstallFolder, + env: process.env + }); + if (result.status !== 0) { + throw new Error('"npm install" encountered an error'); + } + console.log(`Successfully installed ${name}@${version}`); + } + catch (e) { + throw new Error(`Unable to install package: ${e}`); + } +} +/** + * Get the ".bin" path for the package. + */ +function _getBinPath(packageInstallFolder, binName) { + const binFolderPath = path.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME, '.bin'); + const resolvedBinName = os.platform() === 'win32' ? `${binName}.cmd` : binName; + return path.resolve(binFolderPath, resolvedBinName); +} +/** + * Write a flag file to the package's install directory, signifying that the install was successful. + */ +function _writeFlagFile(packageInstallFolder) { + try { + const flagFilePath = path.join(packageInstallFolder, INSTALLED_FLAG_FILENAME); + fs.writeFileSync(flagFilePath, process.version); + } + catch (e) { + throw new Error(`Unable to create installed.flag file in ${packageInstallFolder}`); + } +} +function installAndRun(packageName, packageVersion, packageBinName, packageBinArgs) { + const rushJsonFolder = findRushJsonFolder(); + const rushCommonFolder = path.join(rushJsonFolder, 'common'); + const rushTempFolder = _getRushTempFolder(rushCommonFolder); + const packageInstallFolder = _ensureAndJoinPath(rushTempFolder, 'install-run', `${packageName}@${packageVersion}`); + if (!_isPackageAlreadyInstalled(packageInstallFolder)) { + // The package isn't already installed + _cleanInstallFolder(rushTempFolder, packageInstallFolder); + const sourceNpmrcFolder = path.join(rushCommonFolder, 'config', 'rush'); + _syncNpmrc(sourceNpmrcFolder, packageInstallFolder); + _createPackageJson(packageInstallFolder, packageName, packageVersion); + _installPackage(packageInstallFolder, packageName, packageVersion); + _writeFlagFile(packageInstallFolder); + } + const statusMessage = `Invoking "${packageBinName} ${packageBinArgs.join(' ')}"`; + const statusMessageLine = new Array(statusMessage.length + 1).join('-'); + console.log(os.EOL + statusMessage + os.EOL + statusMessageLine + os.EOL); + const binPath = _getBinPath(packageInstallFolder, packageBinName); + const binFolderPath = path.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME, '.bin'); + const result = childProcess.spawnSync(binPath, packageBinArgs, { + stdio: 'inherit', + cwd: process.cwd(), + env: Object.assign({}, process.env, { PATH: [binFolderPath, process.env.PATH].join(path.delimiter) }) + }); + if (result.status !== null) { + return result.status; + } + else { + throw result.error || new Error('An unknown error occurred.'); + } +} +exports.installAndRun = installAndRun; +function runWithErrorAndStatusCode(fn) { + process.exitCode = 1; + try { + const exitCode = fn(); + process.exitCode = exitCode; + } + catch (e) { + console.error(os.EOL + os.EOL + e.toString() + os.EOL + os.EOL); + } +} +exports.runWithErrorAndStatusCode = runWithErrorAndStatusCode; +function _run() { + const [nodePath /* Ex: /bin/node */, scriptPath /* /repo/common/scripts/install-run-rush.js */, rawPackageSpecifier /* qrcode@^1.2.0 */, packageBinName /* qrcode */, ...packageBinArgs /* [-f, myproject/lib] */] = process.argv; + if (!nodePath) { + throw new Error('Unexpected exception: could not detect node path'); + } + if (path.basename(scriptPath).toLowerCase() !== 'install-run.js') { + // If install-run.js wasn't directly invoked, don't execute the rest of this function. Return control + // to the script that (presumably) imported this file + return; + } + if (process.argv.length < 4) { + console.log('Usage: install-run.js @ [args...]'); + console.log('Example: install-run.js qrcode@1.2.2 qrcode https://rushjs.io'); + process.exit(1); + } + runWithErrorAndStatusCode(() => { + const rushJsonFolder = findRushJsonFolder(); + const rushCommonFolder = _ensureAndJoinPath(rushJsonFolder, 'common'); + const packageSpecifier = _parsePackageSpecifier(rawPackageSpecifier); + const name = packageSpecifier.name; + const version = _resolvePackageVersion(rushCommonFolder, packageSpecifier); + if (packageSpecifier.version !== version) { + console.log(`Resolved to ${name}@${version}`); + } + return installAndRun(name, version, packageBinName, packageBinArgs); + }); +} +_run(); //# sourceMappingURL=install-run.js.map \ No newline at end of file diff --git a/libraries/fabric-shim-crypto/package.json b/libraries/fabric-shim-crypto/package.json index 022b225e9..85dc16cdb 100644 --- a/libraries/fabric-shim-crypto/package.json +++ b/libraries/fabric-shim-crypto/package.json @@ -25,8 +25,8 @@ }, "license": "Apache-2.0", "dependencies": { - "elliptic": "^6.4.0", - "jsrsasign": "^8.0.4" + "elliptic": "^6.5.3", + "jsrsasign": "^8.0.19" }, "devDependencies": { "mocha": "6.2.2", diff --git a/libraries/fabric-shim/lib/server.js b/libraries/fabric-shim/lib/server.js index 005c5a476..c0d0cc073 100644 --- a/libraries/fabric-shim/lib/server.js +++ b/libraries/fabric-shim/lib/server.js @@ -79,12 +79,8 @@ class ChaincodeServer { // Create GRPC Server and register RPC handler this._server = new grpc.Server(); - const self = this; - this._server.addService(protoDescriptor.protos.Chaincode.service, { - connect: (stream) => { - self.connect(stream); - } + connect: this.connect }); this._serverOpts = serverOpts; diff --git a/libraries/fabric-shim/package.json b/libraries/fabric-shim/package.json index 0689be1ae..45c056dcb 100644 --- a/libraries/fabric-shim/package.json +++ b/libraries/fabric-shim/package.json @@ -55,17 +55,17 @@ }, "dependencies": { "@fidm/x509": "^1.2.1", - "@grpc/grpc-js": "1.0.3", + "@grpc/grpc-js": "1.1.1", "@grpc/proto-loader": "^0.5.4", - "@types/node": "^8.9.4", - "ajv": "^6.5.5", + "@types/node": "^14.0.13", + "ajv": "^6.12.2", "fabric-contract-api": "2.1.5-unstable", "fabric-shim-api": "2.1.5-unstable", - "fs-extra": "8.1.0", - "reflect-metadata": "^0.1.12", - "winston": "3.2.1", - "yargs": "^13.3.0 ", - "yargs-parser": "^13.1.1" + "fs-extra": "^9.0.1", + "reflect-metadata": "^0.1.13", + "winston": "^3.3.2", + "yargs": "^15.3.1", + "yargs-parser": "^18.1.3" }, "devDependencies": { "chai": "^4.1.1", diff --git a/libraries/fabric-shim/test/unit/server.js b/libraries/fabric-shim/test/unit/server.js index 04c3520a2..6da399815 100644 --- a/libraries/fabric-shim/test/unit/server.js +++ b/libraries/fabric-shim/test/unit/server.js @@ -76,9 +76,6 @@ describe('ChaincodeServer', () => { it('should create a gRPC server instance and call addService in the constructor', () => { const server = new ChaincodeServer(mockChaincode, serverOpts); - expect(grpcServerStub.calledOnce).to.be.ok; - expect(server._server).to.deep.equal(mockGrpcServerInstance); - expect(server._server.addService.calledOnce).to.be.ok; expect(server._chaincode).to.deep.equal(mockChaincode); expect(server._serverOpts).to.deep.equal(serverOpts); expect(server._credentials).to.deep.equal(mockCredentials); @@ -88,9 +85,6 @@ describe('ChaincodeServer', () => { it('should create a gRPC server instance with TLS credentials and call addService in the constructor', () => { const server = new ChaincodeServer(mockChaincode, serverTLSOpts); - expect(grpcServerStub.calledOnce).to.be.ok; - expect(server._server).to.deep.equal(mockGrpcServerInstance); - expect(server._server.addService.calledOnce).to.be.ok; expect(server._chaincode).to.deep.equal(mockChaincode); expect(server._serverOpts).to.deep.equal(serverTLSOpts); expect(server._credentials).to.deep.equal(mockTLSCredentials); @@ -106,9 +100,6 @@ describe('ChaincodeServer', () => { it('should create a gRPC server instance with mutual TLS credentials and call addService in the constructor', () => { const server = new ChaincodeServer(mockChaincode, serverMutualTLSOpts); - expect(grpcServerStub.calledOnce).to.be.ok; - expect(server._server).to.deep.equal(mockGrpcServerInstance); - expect(server._server.addService.calledOnce).to.be.ok; expect(server._chaincode).to.deep.equal(mockChaincode); expect(server._serverOpts).to.deep.equal(serverMutualTLSOpts); expect(server._credentials).to.deep.equal(mockTLSCredentials); @@ -192,11 +183,10 @@ describe('ChaincodeServer', () => { ChaincodeServer.__set__('ChaincodeMessageHandler', mockHandlerStub); const server = new ChaincodeServer(mockChaincode, serverOpts); - - const serviceImpl = server._server.addService.firstCall.args[1]; const mockStream = {on: sinon.stub(), write: sinon.stub()}; + + server.connect(mockStream); - expect(serviceImpl.connect(mockStream)).not.to.throw; expect(mockHandlerStub.calledOnce).to.be.ok; expect(mockHandler.chat.calledOnce).to.be.ok; expect(mockHandler.chat.firstCall.args).to.deep.equal([{ @@ -214,12 +204,10 @@ describe('ChaincodeServer', () => { const mockHandlerStub = sinon.stub().returns(mockHandler); ChaincodeServer.__set__('ChaincodeMessageHandler', mockHandlerStub); - const server = new ChaincodeServer(mockChaincode, serverOpts); - - const serviceImpl = server._server.addService.firstCall.args[1]; + const server = new ChaincodeServer(mockChaincode, serverOpts); const mockStream = {on: sinon.stub(), write: sinon.stub()}; - expect(serviceImpl.connect(mockStream)).not.to.throw; + server.connect(mockStream); expect(mockHandlerStub.calledOnce).to.be.ok; expect(mockHandler.chat.calledOnce).to.be.ok; }); diff --git a/rush.json b/rush.json index ec081e06e..d35b2a08a 100644 --- a/rush.json +++ b/rush.json @@ -15,7 +15,7 @@ * path segment in the "$schema" field for all your Rush config files. This will ensure * correct error-underlining and tab-completion for editors such as VS Code. */ - "rushVersion": "5.16.0", + "rushVersion": "5.27.0", /** * The next field selects which package manager should be installed and determines its version. * Rush installs its own local copy of the package manager to ensure that your build process @@ -39,7 +39,7 @@ * The default value is false to avoid legacy compatibility issues. * It is strongly recommended to set strictPeerDependencies=true. */ - // "strictPeerDependencies": true, + // "strictPeerDependencies": true, /** * Configures the strategy used to select versions during installation. * diff --git a/test/e2e/package.json b/test/e2e/package.json index 161838b93..eae460542 100644 --- a/test/e2e/package.json +++ b/test/e2e/package.json @@ -15,7 +15,7 @@ "gulp": "^4.0.0", "toolchain": "1.0.0", "delay": "4.3.0", - "fs-extra": "8.1.0", + "fs-extra": "^9.0.1", "ip": "^1.1.5", "ajv": "^6.5.5", "ajv-cli": "^3.0.0", diff --git a/test/fv/package.json b/test/fv/package.json index 210a0ce24..d0dc9d3df 100644 --- a/test/fv/package.json +++ b/test/fv/package.json @@ -30,7 +30,7 @@ "fabric-shim": "2.1.5-unstable", "fabric-shim-api": "2.1.5-unstable", "fabric-shim-crypto": "2.1.5-unstable", - "fs-extra": "8.1.0", + "fs-extra": "^9.0.1", "git-rev-sync": "1.12.0", "gulp": "^4.0.0", "ip": "^1.1.5", diff --git a/tools/toolchain/package.json b/tools/toolchain/package.json index 74ec537c3..0d06ca02f 100644 --- a/tools/toolchain/package.json +++ b/tools/toolchain/package.json @@ -12,7 +12,7 @@ "license": "Apache-2.0", "dependencies": { "delay": "4.3.0", - "fs-extra": "8.1.0", + "fs-extra": "^9.0.1", "git-rev-sync": "1.12.0", "gulp-debug": "~4.0.0", "gulp-eslint": "~6.0.0",