diff --git a/.circleci/config.yml b/.circleci/config.yml index a1023cf1f..cd520e858 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,7 +6,7 @@ orbs: executors: linux: docker: - - image: cimg/base:2021.07 + - image: cimg/base:2024.01 defaults: default-branch: &default-branch develop @@ -26,6 +26,7 @@ defaults: - &node-active-lts "18.17" - &node-current "20.5" pkg-cache-path: &pkg-cache-path /tmp/pkg-node-binaries + ldid-version: &ldid-version 2.1.5-procursus7 # https://github.com/ProcursusTeam/ldid commands: compute-hashes: @@ -64,12 +65,39 @@ commands: parameters: targets: type: string + node-version: + type: string + default: *node-active-lts + bytecode: + type: boolean + default: true steps: + - restore_cache: + name: Restore pkg cache + keys: + - &pkg-cache-key pkg-cache-<< parameters.targets >>-<< parameters.node-version >> - run: name: Create the Spectral Binary environment: PKG_CACHE_PATH: *pkg-cache-path - command: yarn workspace @stoplight/spectral-cli pkg . --public --targets << parameters.targets >> --output binaries/spectral + command: | + NODE_VERSION=$(echo "<< parameters.node-version >>" | awk -F "." '{ print $1 }') + TARGETS=$(echo "<< parameters.targets >>" | awk -v node_version="$NODE_VERSION" -F "," '{for (i=1;i<=NF;i++) printf "node" node_version "-" $i "," }' | sed "s/,$/\n/") + export ARCH=$(echo << parameters.targets >> | awk 'match($0, /-(arm64|x64)/){ print substr($0, RSTART+1, RLENGTH-1) }') + + if [ "<< parameters.bytecode >>" = true ] + then + yarn workspace @stoplight/spectral-cli pkg . --public --public-packages "*" --targets $TARGETS --output binaries/spectral + else + yarn workspace @stoplight/spectral-cli pkg . --no-bytecode --public --public-packages "*" --targets $TARGETS --output binaries/spectral + fi + + (cd packages/cli/binaries && ls . | sed -n -E 's/^(spectral)-(alpine|linux|macos)$/mv "\1-\2" "\1-\2"-$ARCH/p' | sh) + - save_cache: + name: Retain pkg cache + key: *pkg-cache-key + paths: + - *pkg-cache-path install-and-build: description: >- @@ -78,6 +106,39 @@ commands: - cached-dependencies - build + install-ldid: + description: Install ldid + parameters: + version: + type: string + default: *ldid-version + steps: + - restore_cache: + name: Restore built ldid binary + keys: + - ldid-binary-<< parameters.version >>-{{ arch }} + - run: + name: Build ldid + working_directory: /tmp + command: | + sudo apt-get update -y + sudo apt-get -y install libplist-dev + if [ ! -d ldid ] + then + curl -L https://github.com/ProcursusTeam/ldid/archive/refs/tags/v<< parameters.version >>.tar.gz | tar -xz + mv ldid-<< parameters.version >> ldid + make -C ldid + fi + - save_cache: + name: Retain ldid binary + key: ldid-binary-<< parameters.version >>-{{ arch }} + paths: + - /tmp/ldid + - run: + name: Install ldid + working_directory: /tmp/ldid + command: make install + lint-code: steps: - run: @@ -130,6 +191,7 @@ commands: - test-harness-{{ checksum "/tmp/previous-commit-sha" }}-<< parameters.os >>-<< parameters.node-version >> - build-binary: targets: << parameters.os >> + node-version: << parameters.node-version >> - run: name: Run harness tests command: yarn test.harness --maxWorkers=<< parameters.max-workers >> @@ -138,7 +200,6 @@ commands: key: test-harness-{{ checksum "/tmp/current-commit-sha" }}-<< parameters.os >>-<< parameters.node-version >> paths: - ./.cache/spectral-test-harness - - *pkg-cache-path - ./test-harness/tests/ when: always @@ -217,9 +278,13 @@ jobs: - image: cimg/node:lts steps: - checkout + - install-ldid - install-and-build - build-binary: - targets: linux-x64,linux-arm64,macos-x64,macos-arm64,alpine-x64,alpine-arm64 + targets: linux-x64,macos-x64,alpine-x64 + - build-binary: + targets: macos-arm64,linux-arm64,alpine-arm64 + bytecode: false - persist_to_workspace: root: ./packages/cli/ paths: diff --git a/packages/cli/package.json b/packages/cli/package.json index d99f3305a..ab1e8a6c4 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -58,9 +58,9 @@ "@types/es-aggregate-error": "^1.0.2", "@types/xml2js": "^0.4.9", "@types/yargs": "^17.0.8", + "@yao-pkg/pkg": "^5.11.1", "es-aggregate-error": "^1.0.7", "nock": "^13.1.3", - "pkg": "^5.8.0", "xml2js": "^0.5.0" }, "pkg": { diff --git a/yarn.lock b/yarn.lock index fa4994ff5..4782b56b6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -76,18 +76,7 @@ __metadata: languageName: node linkType: hard -"@babel/generator@npm:7.18.2": - version: 7.18.2 - resolution: "@babel/generator@npm:7.18.2" - dependencies: - "@babel/types": ^7.18.2 - "@jridgewell/gen-mapping": ^0.3.0 - jsesc: ^2.5.1 - checksum: d0661e95532ddd97566d41fec26355a7b28d1cbc4df95fe80cc084c413342935911b48db20910708db39714844ddd614f61c2ec4cca3fb10181418bdcaa2e7a3 - languageName: node - linkType: hard - -"@babel/generator@npm:^7.18.9, @babel/generator@npm:^7.23.0, @babel/generator@npm:^7.7.2": +"@babel/generator@npm:7.23.0, @babel/generator@npm:^7.18.9, @babel/generator@npm:^7.23.0, @babel/generator@npm:^7.7.2": version: 7.23.0 resolution: "@babel/generator@npm:7.23.0" dependencies: @@ -312,7 +301,7 @@ __metadata: languageName: node linkType: hard -"@babel/helper-validator-identifier@npm:^7.10.4, @babel/helper-validator-identifier@npm:^7.16.7, @babel/helper-validator-identifier@npm:^7.18.6, @babel/helper-validator-identifier@npm:^7.22.20": +"@babel/helper-validator-identifier@npm:^7.10.4, @babel/helper-validator-identifier@npm:^7.18.6, @babel/helper-validator-identifier@npm:^7.22.20": version: 7.22.20 resolution: "@babel/helper-validator-identifier@npm:7.22.20" checksum: 136412784d9428266bcdd4d91c32bcf9ff0e8d25534a9d94b044f77fe76bc50f941a90319b05aafd1ec04f7d127cd57a179a3716009ff7f3412ef835ada95bdc @@ -360,16 +349,7 @@ __metadata: languageName: node linkType: hard -"@babel/parser@npm:7.18.4": - version: 7.18.4 - resolution: "@babel/parser@npm:7.18.4" - bin: - parser: ./bin/babel-parser.js - checksum: e05b2dc720c4b200e088258f3c2a2de5041c140444edc38181d1217b10074e881a7133162c5b62356061f26279f08df5a06ec14c5842996ee8601ad03c57a44f - languageName: node - linkType: hard - -"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.18.9, @babel/parser@npm:^7.22.15, @babel/parser@npm:^7.23.0": +"@babel/parser@npm:7.23.0, @babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.18.9, @babel/parser@npm:^7.22.15, @babel/parser@npm:^7.23.0": version: 7.23.0 resolution: "@babel/parser@npm:7.23.0" bin: @@ -1208,17 +1188,7 @@ __metadata: languageName: node linkType: hard -"@babel/types@npm:7.18.4": - version: 7.18.4 - resolution: "@babel/types@npm:7.18.4" - dependencies: - "@babel/helper-validator-identifier": ^7.16.7 - to-fast-properties: ^2.0.0 - checksum: 85df59beb99c1b95e9e41590442f2ffa1e5b1b558d025489db40c9f7c906bd03a17da26c3ec486e5800e80af27c42ca7eee9506d9212ab17766d2d68d30fbf52 - languageName: node - linkType: hard - -"@babel/types@npm:^7.0.0, @babel/types@npm:^7.10.4, @babel/types@npm:^7.10.5, @babel/types@npm:^7.12.1, @babel/types@npm:^7.12.10, @babel/types@npm:^7.12.11, @babel/types@npm:^7.14.5, @babel/types@npm:^7.18.2, @babel/types@npm:^7.18.6, @babel/types@npm:^7.18.9, @babel/types@npm:^7.22.15, @babel/types@npm:^7.22.5, @babel/types@npm:^7.23.0, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4, @babel/types@npm:^7.8.3": +"@babel/types@npm:7.23.0, @babel/types@npm:^7.0.0, @babel/types@npm:^7.10.4, @babel/types@npm:^7.10.5, @babel/types@npm:^7.12.1, @babel/types@npm:^7.12.10, @babel/types@npm:^7.12.11, @babel/types@npm:^7.14.5, @babel/types@npm:^7.18.6, @babel/types@npm:^7.18.9, @babel/types@npm:^7.22.15, @babel/types@npm:^7.22.5, @babel/types@npm:^7.23.0, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4, @babel/types@npm:^7.8.3": version: 7.23.0 resolution: "@babel/types@npm:7.23.0" dependencies: @@ -1785,7 +1755,7 @@ __metadata: languageName: node linkType: hard -"@jridgewell/gen-mapping@npm:^0.3.0, @jridgewell/gen-mapping@npm:^0.3.2": +"@jridgewell/gen-mapping@npm:^0.3.2": version: 0.3.2 resolution: "@jridgewell/gen-mapping@npm:0.3.2" dependencies: @@ -2670,13 +2640,13 @@ __metadata: "@types/es-aggregate-error": ^1.0.2 "@types/xml2js": ^0.4.9 "@types/yargs": ^17.0.8 + "@yao-pkg/pkg": ^5.11.1 chalk: 4.1.2 es-aggregate-error: ^1.0.7 fast-glob: ~3.2.12 hpagent: ~1.2.0 lodash: ~4.17.21 nock: ^13.1.3 - pkg: ^5.8.0 pony-cause: ^1.0.0 stacktracey: ^2.1.7 tslib: ^2.3.0 @@ -3554,6 +3524,48 @@ __metadata: languageName: node linkType: hard +"@yao-pkg/pkg-fetch@npm:3.5.7": + version: 3.5.7 + resolution: "@yao-pkg/pkg-fetch@npm:3.5.7" + dependencies: + chalk: ^4.1.2 + fs-extra: ^9.1.0 + https-proxy-agent: ^5.0.0 + node-fetch: ^2.6.6 + progress: ^2.0.3 + semver: ^7.3.5 + tar-fs: ^2.1.1 + yargs: ^16.2.0 + bin: + pkg-fetch: lib-es5/bin.js + checksum: df339cabeef44ce7d9edeea18fa6313686d2ad864a0e67c715ee293bd9ee982e3dc7055c40559e5d6b905468c93a1c630b6f1d694d7c1322b6f7f8bbe7a59f1b + languageName: node + linkType: hard + +"@yao-pkg/pkg@npm:^5.11.1": + version: 5.11.1 + resolution: "@yao-pkg/pkg@npm:5.11.1" + dependencies: + "@babel/generator": 7.23.0 + "@babel/parser": 7.23.0 + "@babel/types": 7.23.0 + "@yao-pkg/pkg-fetch": 3.5.7 + chalk: ^4.1.2 + fs-extra: ^9.1.0 + globby: ^11.1.0 + into-stream: ^6.0.0 + is-core-module: 2.9.0 + minimist: ^1.2.6 + multistream: ^4.1.0 + prebuild-install: 7.1.1 + resolve: ^1.22.0 + stream-meter: ^1.0.4 + bin: + pkg: lib-es5/bin.js + checksum: aba36e68411953169f7bf29229f7e18835b671fa25ff12c72d899e6a18b33f2e8edc40f762cad1ef3e331ccbea4dceb807a6adf7d3dcfeb4b09a6819054c9a92 + languageName: node + linkType: hard + "@yarnpkg/lockfile@npm:^1.1.0": version: 1.1.0 resolution: "@yarnpkg/lockfile@npm:1.1.0" @@ -5295,12 +5307,12 @@ __metadata: languageName: node linkType: hard -"decompress-response@npm:^4.2.0": - version: 4.2.1 - resolution: "decompress-response@npm:4.2.1" +"decompress-response@npm:^6.0.0": + version: 6.0.0 + resolution: "decompress-response@npm:6.0.0" dependencies: - mimic-response: ^2.0.0 - checksum: 4e783ca4dfe9417354d61349750fe05236f565a4415a6ca20983a311be2371debaedd9104c0b0e7b36e5f167aeaae04f84f1a0b3f8be4162f1d7d15598b8fdba + mimic-response: ^3.1.0 + checksum: d377cf47e02d805e283866c3f50d3d21578b779731e8c5072d6ce8c13cc31493db1c2f6784da9d1d5250822120cefa44f1deab112d5981015f2e17444b763812 languageName: node linkType: hard @@ -5418,12 +5430,10 @@ __metadata: languageName: node linkType: hard -"detect-libc@npm:^1.0.3": - version: 1.0.3 - resolution: "detect-libc@npm:1.0.3" - bin: - detect-libc: ./bin/detect-libc.js - checksum: daaaed925ffa7889bd91d56e9624e6c8033911bb60f3a50a74a87500680652969dbaab9526d1e200a4c94acf80fc862a22131841145a0a8482d60a99c24f4a3e +"detect-libc@npm:^2.0.0": + version: 2.0.2 + resolution: "detect-libc@npm:2.0.2" + checksum: 2b2cd3649b83d576f4be7cc37eb3b1815c79969c8b1a03a40a4d55d83bc74d010753485753448eacb98784abf22f7dbd3911fd3b60e29fda28fed2d1a997944d languageName: node linkType: hard @@ -9346,10 +9356,10 @@ __metadata: languageName: node linkType: hard -"mimic-response@npm:^2.0.0": - version: 2.1.0 - resolution: "mimic-response@npm:2.1.0" - checksum: 014fad6ab936657e5f2f48bd87af62a8e928ebe84472aaf9e14fec4fcb31257a5edff77324d8ac13ddc6685ba5135cf16e381efac324e5f174fb4ddbf902bf07 +"mimic-response@npm:^3.1.0": + version: 3.1.0 + resolution: "mimic-response@npm:3.1.0" + checksum: 25739fee32c17f433626bf19f016df9036b75b3d84a3046c7d156e72ec963dd29d7fc8a302f55a3d6c5a4ff24259676b15d915aad6480815a969ff2ec0836867 languageName: node linkType: hard @@ -9404,9 +9414,9 @@ __metadata: linkType: hard "minimist@npm:^1.2.0, minimist@npm:^1.2.3, minimist@npm:^1.2.5, minimist@npm:^1.2.6": - version: 1.2.6 - resolution: "minimist@npm:1.2.6" - checksum: d15428cd1e11eb14e1233bcfb88ae07ed7a147de251441d61158619dfb32c4d7e9061d09cab4825fdee18ecd6fce323228c8c47b5ba7cd20af378ca4048fb3fb + version: 1.2.8 + resolution: "minimist@npm:1.2.8" + checksum: 75a6d645fb122dad29c06a7597bddea977258957ed88d7a6df59b5cd3fe4a527e253e9bbf2e783e4b73657f9098b96a5fe96ab8a113655d4109108577ecf85b0 languageName: node linkType: hard @@ -9735,12 +9745,12 @@ __metadata: languageName: node linkType: hard -"node-abi@npm:^2.21.0": - version: 2.30.1 - resolution: "node-abi@npm:2.30.1" +"node-abi@npm:^3.3.0": + version: 3.52.0 + resolution: "node-abi@npm:3.52.0" dependencies: - semver: ^5.4.1 - checksum: 3f4b0c912ce4befcd7ceab4493ba90b51d60dfcc90f567c93f731d897ef8691add601cb64c181683b800f21d479d68f9a6e15d8ab8acd16a5706333b9e30a881 + semver: ^7.3.5 + checksum: 2ef47937d058fa1f0817294fe5ac3ec1d370d3f8eb4931ea920b7e147033390058d3bc35b64d9161036ad2fda191aa1155005cea20ec50984312637221559354 languageName: node linkType: hard @@ -9754,8 +9764,8 @@ __metadata: linkType: hard "node-fetch@npm:^2.6.0, node-fetch@npm:^2.6.1, node-fetch@npm:^2.6.6, node-fetch@npm:^2.6.7": - version: 2.6.7 - resolution: "node-fetch@npm:2.6.7" + version: 2.7.0 + resolution: "node-fetch@npm:2.7.0" dependencies: whatwg-url: ^5.0.0 peerDependencies: @@ -9763,7 +9773,7 @@ __metadata: peerDependenciesMeta: encoding: optional: true - checksum: 8d816ffd1ee22cab8301c7756ef04f3437f18dace86a1dae22cf81db8ef29c0bf6655f3215cb0cdb22b420b6fe141e64b26905e7f33f9377a7fa59135ea3e10b + checksum: d76d2f5edb451a3f05b15115ec89fc6be39de37c6089f1b6368df03b91e1633fd379a7e01b7ab05089a25034b2023d959b47e59759cb38d88341b2459e89d6e5 languageName: node linkType: hard @@ -10145,7 +10155,7 @@ __metadata: languageName: node linkType: hard -"npmlog@npm:^4.0.1, npmlog@npm:^4.1.2": +"npmlog@npm:^4.1.2": version: 4.1.2 resolution: "npmlog@npm:4.1.2" dependencies: @@ -10687,53 +10697,6 @@ __metadata: languageName: node linkType: hard -"pkg-fetch@npm:3.4.2": - version: 3.4.2 - resolution: "pkg-fetch@npm:3.4.2" - dependencies: - chalk: ^4.1.2 - fs-extra: ^9.1.0 - https-proxy-agent: ^5.0.0 - node-fetch: ^2.6.6 - progress: ^2.0.3 - semver: ^7.3.5 - tar-fs: ^2.1.1 - yargs: ^16.2.0 - bin: - pkg-fetch: lib-es5/bin.js - checksum: e0f73cedf6cb8882e4d998700031443e6542d213f9817d66deb03fb89c122ca7f7505f11401f85a760a2d3951f9b793d0f78782be220c46c56ccf70f9915812a - languageName: node - linkType: hard - -"pkg@npm:^5.8.0": - version: 5.8.0 - resolution: "pkg@npm:5.8.0" - dependencies: - "@babel/generator": 7.18.2 - "@babel/parser": 7.18.4 - "@babel/types": 7.18.4 - chalk: ^4.1.2 - fs-extra: ^9.1.0 - globby: ^11.1.0 - into-stream: ^6.0.0 - is-core-module: 2.9.0 - minimist: ^1.2.6 - multistream: ^4.1.0 - pkg-fetch: 3.4.2 - prebuild-install: 6.1.4 - resolve: ^1.22.0 - stream-meter: ^1.0.4 - peerDependencies: - node-notifier: ">=9.0.1" - peerDependenciesMeta: - node-notifier: - optional: true - bin: - pkg: lib-es5/bin.js - checksum: eb85975275ab4c5760884c1cc9b6251a17a8c15eb1b5a13183d0a5a0385650459e44d8438af7ecf5c5d185b55046cce9ce705b5b6d59ae058a157f49f6fb56a0 - languageName: node - linkType: hard - "please-upgrade-node@npm:^3.2.0": version: 3.2.0 resolution: "please-upgrade-node@npm:3.2.0" @@ -10760,26 +10723,25 @@ __metadata: languageName: node linkType: hard -"prebuild-install@npm:6.1.4": - version: 6.1.4 - resolution: "prebuild-install@npm:6.1.4" +"prebuild-install@npm:7.1.1": + version: 7.1.1 + resolution: "prebuild-install@npm:7.1.1" dependencies: - detect-libc: ^1.0.3 + detect-libc: ^2.0.0 expand-template: ^2.0.3 github-from-package: 0.0.0 minimist: ^1.2.3 mkdirp-classic: ^0.5.3 napi-build-utils: ^1.0.1 - node-abi: ^2.21.0 - npmlog: ^4.0.1 + node-abi: ^3.3.0 pump: ^3.0.0 rc: ^1.2.7 - simple-get: ^3.0.3 + simple-get: ^4.0.0 tar-fs: ^2.0.0 tunnel-agent: ^0.6.0 bin: prebuild-install: bin.js - checksum: de4313eda821305912af922700a2db04bb8e77fe8aa9c2788550f1000c026cbefc82da468ec0c0a37764c5417bd8169dbd540928535fb38d00bb9bbd673dd217 + checksum: dbf96d0146b6b5827fc8f67f72074d2e19c69628b9a7a0a17d0fad1bf37e9f06922896972e074197fc00a52eae912993e6ef5a0d471652f561df5cb516f3f467 languageName: node linkType: hard @@ -11177,8 +11139,8 @@ __metadata: linkType: hard "readable-stream@npm:^2.0.0, readable-stream@npm:^2.0.2, readable-stream@npm:^2.0.6, readable-stream@npm:^2.1.4, readable-stream@npm:~2.3.6": - version: 2.3.7 - resolution: "readable-stream@npm:2.3.7" + version: 2.3.8 + resolution: "readable-stream@npm:2.3.8" dependencies: core-util-is: ~1.0.0 inherits: ~2.0.3 @@ -11187,7 +11149,7 @@ __metadata: safe-buffer: ~5.1.1 string_decoder: ~1.1.1 util-deprecate: ~1.0.1 - checksum: e4920cf7549a60f8aaf694d483a0e61b2a878b969d224f89b3bc788b8d920075132c4b55a7494ee944c7b6a9a0eada28a7f6220d80b0312ece70bbf08eeca755 + checksum: 65645467038704f0c8aaf026a72fbb588a9e2ef7a75cd57a01702ee9db1c4a1e4b03aaad36861a6a0926546a74d174149c8c207527963e0c2d3eee2f37678a42 languageName: node linkType: hard @@ -11654,7 +11616,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:2 || 3 || 4 || 5, semver@npm:^5.4.1, semver@npm:^5.5.0, semver@npm:^5.6.0": +"semver@npm:2 || 3 || 4 || 5, semver@npm:^5.5.0, semver@npm:^5.6.0": version: 5.7.2 resolution: "semver@npm:5.7.2" bin: @@ -11822,14 +11784,14 @@ __metadata: languageName: node linkType: hard -"simple-get@npm:^3.0.3": - version: 3.1.1 - resolution: "simple-get@npm:3.1.1" +"simple-get@npm:^4.0.0": + version: 4.0.1 + resolution: "simple-get@npm:4.0.1" dependencies: - decompress-response: ^4.2.0 + decompress-response: ^6.0.0 once: ^1.3.1 simple-concat: ^1.0.0 - checksum: 80195e70bf171486e75c31e28e5485468195cc42f85940f8b45c4a68472160144d223eb4d07bc82ef80cb974b7c401db021a540deb2d34ac4b3b8883da2d6401 + checksum: e4132fd27cf7af230d853fa45c1b8ce900cb430dd0a3c6d3829649fe4f2b26574c803698076c4006450efb0fad2ba8c5455fbb5755d4b0a5ec42d4f12b31d27e languageName: node linkType: hard