diff --git a/tools/js-sdk-release-tools/package-lock.json b/tools/js-sdk-release-tools/package-lock.json index c9328998a4e..2ebc2e8901f 100644 --- a/tools/js-sdk-release-tools/package-lock.json +++ b/tools/js-sdk-release-tools/package-lock.json @@ -1,12 +1,12 @@ { "name": "@azure-tools/js-sdk-release-tools", - "version": "2.7.9", + "version": "2.7.10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@azure-tools/js-sdk-release-tools", - "version": "2.7.9", + "version": "2.7.10", "license": "MIT", "dependencies": { "@azure-tools/openapi-tools-common": "^1.2.2", @@ -31,7 +31,11 @@ "rlc-code-gen": "dist/rlcCodegenCli.js" }, "devDependencies": { + "@types/node": "^20.12.12", + "@types/shelljs": "^0.8.15", + "nodemon": "^3.1.0", "rimraf": "^3.0.2", + "ts-node": "^10.9.2", "typescript": "^3.9.7" } }, @@ -148,6 +152,43 @@ "tslib": "^1.9.3" } }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@kwsites/file-exists": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz", @@ -580,6 +621,30 @@ "path-browserify": "^1.0.1" } }, + "node_modules/@tsconfig/node10": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, "node_modules/@types/archiver": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/@types/archiver/-/archiver-3.1.1.tgz", @@ -621,9 +686,12 @@ "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==" }, "node_modules/@types/node": { - "version": "18.8.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.8.5.tgz", - "integrity": "sha512-Bq7G3AErwe5A/Zki5fdD3O6+0zDChhg671NfPjtIcbtzDNZTv4NPKMRFr7gtYPG7y+B8uTiNK4Ngd9T0FTar6Q==" + "version": "20.12.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz", + "integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==", + "dependencies": { + "undici-types": "~5.26.4" + } }, "node_modules/@types/node-fetch": { "version": "2.6.2", @@ -639,6 +707,26 @@ "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.2.tgz", "integrity": "sha512-XISRgDJ2Tc5q4TRqvgJtzsRkFYNJzZrhTdtMoGVBttwzzQJkPnS3WWTFc7kuDRoPtPakl+T+OfdEUjYJj7Jbow==" }, + "node_modules/@types/shelljs": { + "version": "0.8.15", + "resolved": "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.8.15.tgz", + "integrity": "sha512-vzmnCHl6hViPu9GNLQJ+DZFd6BQI2DBTUeOvYHqkWQLMfKAAQYMb/xAmZkTogZI/vqXHCWkqDRymDI5p0QTi5Q==", + "dev": true, + "dependencies": { + "@types/glob": "~7.2.0", + "@types/node": "*" + } + }, + "node_modules/@types/shelljs/node_modules/@types/glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==", + "dev": true, + "dependencies": { + "@types/minimatch": "*", + "@types/node": "*" + } + }, "node_modules/abort-controller": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", @@ -650,6 +738,27 @@ "node": ">=6.5" } }, + "node_modules/acorn": { + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", + "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/ansi-regex": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", @@ -669,6 +778,19 @@ "node": ">=4" } }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/archiver": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/archiver/-/archiver-4.0.2.tgz", @@ -720,6 +842,12 @@ "util-deprecate": "~1.0.1" } }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "node_modules/argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -798,6 +926,18 @@ "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==" }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/bl": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", @@ -872,6 +1012,30 @@ "node": ">=6" } }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, "node_modules/clean-git-ref": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/clean-git-ref/-/clean-git-ref-2.0.1.tgz", @@ -1039,6 +1203,12 @@ "node": ">= 6.9.0" } }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "node_modules/cross-spawn": { "version": "6.0.5", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", @@ -1113,6 +1283,15 @@ "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/diff3": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/diff3/-/diff3-0.0.3.tgz", @@ -1280,6 +1459,20 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -1350,6 +1543,15 @@ "node": ">= 0.4.0" } }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/has-own-prop": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-own-prop/-/has-own-prop-2.0.0.tgz", @@ -1385,6 +1587,12 @@ "node": ">= 4" } }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "dev": true + }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -1415,6 +1623,18 @@ "node": ">=4" } }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/is-core-module": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.10.0.tgz", @@ -1619,17 +1839,6 @@ "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", "integrity": "sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==" }, - "node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/macos-release": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/macos-release/-/macos-release-2.5.0.tgz", @@ -1641,6 +1850,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, "node_modules/mdurl": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", @@ -1763,6 +1978,34 @@ } } }, + "node_modules/nodemon": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.0.tgz", + "integrity": "sha512-xqlktYlDMCepBJd43ZQhjWwMw2obW/JRvkrLxq5RCNcuDDX1DbcPT+qT1IlIIdf+DhnWs90JpTMe+Y5KxOchvA==", + "dev": true, + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^4", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -1927,6 +2170,12 @@ "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==" }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true + }, "node_modules/pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", @@ -1976,6 +2225,18 @@ "node": ">= 6" } }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, "node_modules/rechoir": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", @@ -2089,12 +2350,9 @@ "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" }, "node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", - "dependencies": { - "lru-cache": "^6.0.0" - }, + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", + "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", "bin": { "semver": "bin/semver.js" }, @@ -2216,6 +2474,18 @@ "url": "https://github.com/steveukx/git-js?sponsor=1" } }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dev": true, + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -2266,6 +2536,18 @@ "node": ">=0.10.0" } }, + "node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/supports-preserve-symlinks-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", @@ -2303,6 +2585,15 @@ "node": ">=8.0" } }, + "node_modules/touch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", + "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", + "dev": true, + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, "node_modules/tough-cookie": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-3.0.1.tgz", @@ -2330,6 +2621,49 @@ "code-block-writer": "^10.1.1" } }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, "node_modules/tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", @@ -2363,6 +2697,17 @@ "node": ">=8" } }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + }, "node_modules/universal-user-agent": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-4.0.1.tgz", @@ -2384,6 +2729,12 @@ "uuid": "dist/bin/uuid" } }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", @@ -2459,11 +2810,6 @@ "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==" }, - "node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "node_modules/yaml": { "version": "1.10.2", "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", @@ -2499,6 +2845,15 @@ "decamelize": "^1.2.0" } }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/zip-stream": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/zip-stream/-/zip-stream-3.0.1.tgz", diff --git a/tools/js-sdk-release-tools/package.json b/tools/js-sdk-release-tools/package.json index 7b55e35bdb4..9fd378ff847 100644 --- a/tools/js-sdk-release-tools/package.json +++ b/tools/js-sdk-release-tools/package.json @@ -1,8 +1,9 @@ { "name": "@azure-tools/js-sdk-release-tools", - "version": "2.7.9", + "version": "2.7.10", "description": "", "scripts": { + "dev": "nodemon src/changelogToolCli.ts", "start": "node dist/changelogToolCli.js", "debug": "node --inspect-brk dist/changelogToolCli.js", "build": "rimraf dist && tsc -p .", @@ -33,7 +34,11 @@ "yaml": "^1.10.2" }, "devDependencies": { + "@types/node": "^20.12.12", + "@types/shelljs": "^0.8.15", + "nodemon": "^3.1.0", "rimraf": "^3.0.2", + "ts-node": "^10.9.2", "typescript": "^3.9.7" } } diff --git a/tools/js-sdk-release-tools/src/common/interfaces.ts b/tools/js-sdk-release-tools/src/common/interfaces.ts new file mode 100644 index 00000000000..165579494f6 --- /dev/null +++ b/tools/js-sdk-release-tools/src/common/interfaces.ts @@ -0,0 +1,5 @@ +import { ApiVersionType } from "./types"; + +export interface IApiVersionTypeExtractor { + (packageRoot: string): ApiVersionType; +} \ No newline at end of file diff --git a/tools/js-sdk-release-tools/src/common/types.ts b/tools/js-sdk-release-tools/src/common/types.ts new file mode 100644 index 00000000000..c1db6dccf6a --- /dev/null +++ b/tools/js-sdk-release-tools/src/common/types.ts @@ -0,0 +1,11 @@ +export enum SDKType { + HighLevelClient = 'HighLevelClient', + RestLevelClient = 'RestLevelClient', + ModularClient = 'ModularClient', +}; + +export enum ApiVersionType { + None = 'None', + Stable = 'Stable', + Preview = 'Preview', +} \ No newline at end of file diff --git a/tools/js-sdk-release-tools/src/common/utils.ts b/tools/js-sdk-release-tools/src/common/utils.ts new file mode 100644 index 00000000000..0be2cf98329 --- /dev/null +++ b/tools/js-sdk-release-tools/src/common/utils.ts @@ -0,0 +1,51 @@ +import shell from 'shelljs'; +import path from 'path'; +import fs from 'fs'; + +import { SDKType } from './types' +import { logger } from "../utils/logger"; +import { Project, ScriptTarget, SourceFile } from 'ts-morph'; + +export function getClassicClientParametersPath(packageRoot: string): string { + return path.join(packageRoot, 'src', 'models', 'parameters.ts'); +} + +export function getSDKType(packageRoot: string): SDKType { + const paraPath = getClassicClientParametersPath(packageRoot); + const exist = shell.test('-e', paraPath); + const type = exist ? SDKType.HighLevelClient : SDKType.ModularClient; + logger.logInfo(`SDK type: ${type} detected in ${packageRoot}`); + return type; +} + +export function getNpmPackageName(packageRoot: string): string { + const packageJsonPath = path.join(packageRoot, 'package.json'); + const packageJson = fs.readFileSync(packageJsonPath, { encoding: 'utf-8' }); + const packageName = JSON.parse(packageJson).name; + return packageName; +} + +export function getApiReviewPath(packageRoot: string): string { + const sdkType = getSDKType(packageRoot); + const reviewDir = path.join(packageRoot, 'review'); + switch (sdkType) { + case SDKType.ModularClient: + const npmPackageName = getNpmPackageName(packageRoot); + const packageName = npmPackageName.substring("@azure/".length); + const apiViewFileName = `${packageName}.api.md`; + return path.join(packageRoot, 'review', apiViewFileName); + case SDKType.HighLevelClient: + case SDKType.RestLevelClient: + default: + // only one xxx.api.md + return path.join(packageRoot, 'review', fs.readdirSync(reviewDir)[0]); + } +} + +export function getTsSourceFile(filePath: string): SourceFile | undefined { + const target = ScriptTarget.ES2015; + const compilerOptions = { target }; + const project = new Project({ compilerOptions }); + project.addSourceFileAtPath(filePath); + return project.getSourceFile(filePath); +} \ No newline at end of file diff --git a/tools/js-sdk-release-tools/src/hlc/apiVersion/apiVersionTypeExtractor.ts b/tools/js-sdk-release-tools/src/hlc/apiVersion/apiVersionTypeExtractor.ts new file mode 100644 index 00000000000..31c6b0a641e --- /dev/null +++ b/tools/js-sdk-release-tools/src/hlc/apiVersion/apiVersionTypeExtractor.ts @@ -0,0 +1,24 @@ +import { ApiVersionType } from "../../common/types" +import { IApiVersionTypeExtractor } from "../../common/interfaces"; +import { getClassicClientParametersPath, getTsSourceFile } from "../../common/utils"; + +// TODO: add unit test +export const getApiVersionType: IApiVersionTypeExtractor = (packageRoot: string): ApiVersionType => { + const paraPath = getClassicClientParametersPath(packageRoot); + const source = getTsSourceFile(paraPath); + const variableDeclarations = source?.getVariableDeclarations(); + if (!variableDeclarations) return ApiVersionType.Stable; + for (const variableDeclaration of variableDeclarations) { + const fullText = variableDeclaration.getFullText(); + if (fullText.toLowerCase().includes('apiversion')) { + const match = fullText.match(/defaultValue: "([0-9a-z-]+)"/); + if (!match || match.length !== 2) { + continue; + } + if (match[1].includes('preview')) { + return ApiVersionType.Preview; + } + } + } + return ApiVersionType.Stable; +} \ No newline at end of file diff --git a/tools/js-sdk-release-tools/src/hlc/utils/automaticGenerateChangeLogAndBumpVersion.ts b/tools/js-sdk-release-tools/src/hlc/utils/automaticGenerateChangeLogAndBumpVersion.ts index 0dd92798a45..2a4047c527f 100644 --- a/tools/js-sdk-release-tools/src/hlc/utils/automaticGenerateChangeLogAndBumpVersion.ts +++ b/tools/js-sdk-release-tools/src/hlc/utils/automaticGenerateChangeLogAndBumpVersion.ts @@ -1,3 +1,7 @@ +import fs from 'fs'; +import path from 'path'; +import shell from 'shelljs'; + import {extractExportAndGenerateChangelog, readSourceAndExtractMetaData} from "../../changelog/extractMetaData"; import {Changelog, changelogGenerator} from "../../changelog/changelogGenerator"; import {NPMScope, NPMViewResult} from "@ts-common/azure-js-dev-tools"; @@ -14,19 +18,18 @@ import { getVersion, isBetaVersion } from "../../utils/version"; -import {isGeneratedCodeStable} from "./isGeneratedCodeStable"; import {execSync} from "child_process"; import { getversionDate } from "../../utils/version"; - -const fs = require('fs'); -const path = require('path'); +import { ApiVersionType } from "../../common/types" +import { getApiVersionType } from '../../xlc/apiVersion/apiVersionTypeExtractor' +import { getApiReviewPath, getNpmPackageName } from '../../common/utils'; export async function generateChangelogAndBumpVersion(packageFolderPath: string) { - const shell = require('shelljs'); const jsSdkRepoPath = String(shell.pwd()); packageFolderPath = path.join(jsSdkRepoPath, packageFolderPath); - const isStableRelease = isGeneratedCodeStable(path.join(packageFolderPath, 'src', 'models', 'parameters.ts')); - const packageName = JSON.parse(fs.readFileSync(path.join(packageFolderPath, 'package.json'), {encoding: 'utf-8'})).name; + const ApiType = getApiVersionType(packageFolderPath); + const isStableRelease = ApiType != ApiVersionType.Preview; + const packageName = getNpmPackageName(packageFolderPath); const npm = new NPMScope({ executionFolderPath: packageFolderPath }); const npmViewResult: NPMViewResult = await npm.view({ packageName }); const stableVersion = getVersion(npmViewResult,"latest"); @@ -45,29 +48,31 @@ export async function generateChangelogAndBumpVersion(packageFolderPath: string) const usedVersions = npmViewResult['versions']; // in our rule, we always compare to stableVersion. But here wo should pay attention to the some stableVersion which contains beta, which means the package has not been GA. try { - await shell.mkdir(path.join(packageFolderPath, 'changelog-temp')); - await shell.cd(path.join(packageFolderPath, 'changelog-temp')); - await shell.exec(`npm pack ${packageName}@${stableVersion}`); - await shell.exec('tar -xzf *.tgz'); - await shell.cd(packageFolderPath); + shell.mkdir(path.join(packageFolderPath, 'changelog-temp')); + shell.cd(path.join(packageFolderPath, 'changelog-temp')); + shell.exec(`npm pack ${packageName}@${stableVersion}`); + const files = shell.ls('*.tgz'); + shell.exec(`tar -xzf ${files[0]}`); + shell.cd(packageFolderPath); // only track2 sdk includes sdk-type with value mgmt const sdkType = JSON.parse(fs.readFileSync(path.join(packageFolderPath, 'changelog-temp', 'package', 'package.json'), {encoding: 'utf-8'}))['sdk-type']; if (sdkType && sdkType === 'mgmt') { logger.log(`Package ${packageName} released before is track2 sdk`); logger.log('Generating changelog by comparing api.md...'); - const reviewFolder = path.join(packageFolderPath, 'changelog-temp', 'package', 'review'); - let apiMdFileNPM: string = path.join(reviewFolder, fs.readdirSync(reviewFolder)[0]); - let apiMdFileLocal: string = path.join(packageFolderPath, 'review', fs.readdirSync(path.join(packageFolderPath, 'review'))[0]); + const npmPackageRoot = path.join(packageFolderPath, 'changelog-temp', 'package'); + const apiMdFileNPM = getApiReviewPath(npmPackageRoot); + const apiMdFileLocal = getApiReviewPath(packageFolderPath); const changelog: Changelog = await extractExportAndGenerateChangelog(apiMdFileNPM, apiMdFileLocal); let originalChangeLogContent = fs.readFileSync(path.join(packageFolderPath, 'changelog-temp', 'package', 'CHANGELOG.md'), {encoding: 'utf-8'}); if(nextVersion){ - await shell.cd(path.join(packageFolderPath, 'changelog-temp')); - await shell.mkdir(path.join(packageFolderPath, 'changelog-temp', 'next')); - await shell.cd(path.join(packageFolderPath,'changelog-temp', 'next')); - await shell.exec(`npm pack ${packageName}@${nextVersion}`); - await shell.exec('tar -xzf *.tgz'); - await shell.cd(packageFolderPath); + shell.cd(path.join(packageFolderPath, 'changelog-temp')); + shell.mkdir(path.join(packageFolderPath, 'changelog-temp', 'next')); + shell.cd(path.join(packageFolderPath,'changelog-temp', 'next')); + shell.exec(`npm pack ${packageName}@${nextVersion}`); + const files = shell.ls('*.tgz'); + shell.exec(`tar -xzf ${files[0]}`); + shell.cd(packageFolderPath); logger.log("Create next folder successfully") const latestDate = getversionDate(npmViewResult, stableVersion); @@ -106,8 +111,8 @@ export async function generateChangelogAndBumpVersion(packageFolderPath: string) logger.log('Generate changelogs and setting version for migrating track1 to track2 successfully'); } } finally { - await shell.exec(`rm -r ${path.join(packageFolderPath, 'changelog-temp')}`); - await shell.cd(jsSdkRepoPath); + shell.rm('-r', `${path.join(packageFolderPath, 'changelog-temp')}`); + shell.cd(jsSdkRepoPath); } } } diff --git a/tools/js-sdk-release-tools/src/hlc/utils/isGeneratedCodeStable.ts b/tools/js-sdk-release-tools/src/hlc/utils/isGeneratedCodeStable.ts deleted file mode 100644 index 1d81fbb28a0..00000000000 --- a/tools/js-sdk-release-tools/src/hlc/utils/isGeneratedCodeStable.ts +++ /dev/null @@ -1,26 +0,0 @@ -import {Project, ScriptTarget} from "ts-morph"; - -export function isGeneratedCodeStable(filePath: string) { - const project = new Project({ - compilerOptions: { - target: ScriptTarget.ES2015, - }, - }); - project.addSourceFileAtPath(filePath); - const source = project.getSourceFile(filePath); - const variableDeclarations = source?.getVariableDeclarations(); - if (!variableDeclarations) return true; - for (const variableDeclaration of variableDeclarations) { - const fullText = variableDeclaration.getFullText(); - if (fullText.toLowerCase().includes('apiversion')) { - const match = fullText.match(/defaultValue: "([0-9a-z-]+)"/); - if (!match || match.length !== 2) { - continue; - } - if (match[1].includes('preview')) { - return false; - } - } - } - return true; -} \ No newline at end of file diff --git a/tools/js-sdk-release-tools/src/llc/utils/generateChangelog.ts b/tools/js-sdk-release-tools/src/llc/utils/generateChangelog.ts index 2398a8e1f49..3619f23d353 100644 --- a/tools/js-sdk-release-tools/src/llc/utils/generateChangelog.ts +++ b/tools/js-sdk-release-tools/src/llc/utils/generateChangelog.ts @@ -4,6 +4,7 @@ import {NPMScope} from "@ts-common/azure-js-dev-tools"; import {logger} from "../../utils/logger"; import {getLatestStableVersion} from "../../utils/version"; import {extractExportAndGenerateChangelog} from "../../changelog/extractMetaData"; +import { getApiReviewPath } from "../../common/utils"; const shell = require('shelljs'); const todayDate = new Date(); @@ -60,8 +61,10 @@ export async function generateChangelog(packagePath) { logger.logWarn("The latest package released in NPM doesn't contain review folder, so generate changelog same as first release"); generateChangelogForFirstRelease(packagePath, version); } else { - let apiMdFileNPM = path.join(tempReviewFolder, fs.readdirSync(tempReviewFolder)[0]); - let apiMdFileLocal = path.join(packagePath, 'review', fs.readdirSync(path.join(packagePath, 'review'))[0]); + const npmPackageRoot = path.join(packagePath, 'changelog-temp', 'package'); + // TODO: error out if it's comparing between RLC and HLC or Modular api layer and HLC + const apiMdFileNPM = getApiReviewPath(npmPackageRoot); + const apiMdFileLocal = getApiReviewPath(packagePath); const changelog = await extractExportAndGenerateChangelog(apiMdFileNPM, apiMdFileLocal); if (!changelog.hasBreakingChange && !changelog.hasFeature) { logger.logError('Cannot generate changelog because the codes of local and npm may be the same.'); diff --git a/tools/js-sdk-release-tools/src/mlc/apiVersion/apiVersionTypeExtractor.ts b/tools/js-sdk-release-tools/src/mlc/apiVersion/apiVersionTypeExtractor.ts new file mode 100644 index 00000000000..c385a2cd07c --- /dev/null +++ b/tools/js-sdk-release-tools/src/mlc/apiVersion/apiVersionTypeExtractor.ts @@ -0,0 +1,81 @@ +import { SourceFile, SyntaxKind } from "ts-morph"; +import shell from 'shelljs'; +import path from 'path'; + +import { ApiVersionType } from "../../common/types" +import { IApiVersionTypeExtractor } from "../../common/interfaces"; +import { getTsSourceFile } from "../../common/utils"; + +const findRestClientPath = (packageRoot: string): string => { + const restPath = path.join(packageRoot, 'src/rest/'); + const fileNames = shell.ls(restPath); + const clientFiles = fileNames.filter(f => f.endsWith("Client.ts")); + if (clientFiles.length !== 1) throw new Error(`Single client is supported, but found ${clientFiles}`); + + const clientPath = path.join(restPath, clientFiles[0]); + return clientPath; +}; + +const matchPattern = (text: string, pattern: RegExp): string | undefined => { + const match = text.match(pattern); + const found = match != null && match.length === 2; + return found ? match?.at(1) : undefined; +} + +const findApiVersionInRestClient = (clientPath: string): string | undefined => { + const sourceFile = getTsSourceFile(clientPath); + const createClientFunction = sourceFile?.getFunction("createClient"); + if (!createClientFunction) throw new Error("Function 'createClient' not found."); + + const apiVersionStatements = createClientFunction.getStatements() + .filter(s => + s.getKind() === SyntaxKind.ExpressionStatement && + s.getText().indexOf("options.apiVersion") > -1); + if (apiVersionStatements.length === 0) return undefined; + + const text = apiVersionStatements[apiVersionStatements.length - 1].getText(); + const pattern = /(\d{4}-\d{2}-\d{2}(?:-preview)?)/; + const apiVersion = matchPattern(text, pattern); + return apiVersion; +}; + +const getApiVersionTypeFromRestClient: IApiVersionTypeExtractor = (packageRoot: string): ApiVersionType => { + const clientPath = findRestClientPath(packageRoot); + const apiVersion = findApiVersionInRestClient(clientPath); + if (apiVersion && apiVersion.indexOf("-preview") >= 0) return ApiVersionType.Preview; + if (apiVersion && apiVersion.indexOf("-preview") < 0) return ApiVersionType.Stable; + return ApiVersionType.None; +}; + +const findApiVersionsInOperations = (sourceFile: SourceFile | undefined): Array | undefined => { + const interfaces = sourceFile?.getInterfaces(); + const interfacesWithApiVersion = interfaces?.filter(itf => itf.getProperty('"api-version"')); + const apiVersions = interfacesWithApiVersion?.map(itf => { + const property = itf.getMembers() + .filter(m => { + const defaultValue = m.getChildrenOfKind(SyntaxKind.StringLiteral)[0]; + return defaultValue && defaultValue.getText() === '"api-version"'; + })[0]; + const apiVersion = property.getChildrenOfKind(SyntaxKind.LiteralType)[0].getText(); + return apiVersion; + }); + return apiVersions; +} + +const getApiVersionTypeFromOperations: IApiVersionTypeExtractor = (packageRoot: string): ApiVersionType => { + const paraPath = path.join(packageRoot, 'src/rest/parameters.ts'); + const sourceFile = getTsSourceFile(paraPath); + const apiVersions = findApiVersionsInOperations(sourceFile); + if (!apiVersions) return ApiVersionType.None; + const previewVersions = apiVersions.filter(v => v.indexOf("-preview") >= 0); + return previewVersions.length > 0 ? ApiVersionType.Preview : ApiVersionType.Stable; +}; + +// TODO: add unit test +export const getApiVersionType: IApiVersionTypeExtractor = (packageRoot: string): ApiVersionType => { + const typeFromClient = getApiVersionTypeFromRestClient(packageRoot); + if (typeFromClient !== ApiVersionType.None) return typeFromClient; + const typeFromOperations = getApiVersionTypeFromOperations(packageRoot); + if (typeFromOperations !== ApiVersionType.None) return typeFromOperations; + return ApiVersionType.Stable; +} diff --git a/tools/js-sdk-release-tools/src/xlc/apiVersion/apiVersionTypeExtractor.ts b/tools/js-sdk-release-tools/src/xlc/apiVersion/apiVersionTypeExtractor.ts new file mode 100644 index 00000000000..797b0340c2e --- /dev/null +++ b/tools/js-sdk-release-tools/src/xlc/apiVersion/apiVersionTypeExtractor.ts @@ -0,0 +1,19 @@ +import { getSDKType } from "../../common/utils"; +import { ApiVersionType, SDKType } from "../../common/types"; +import { IApiVersionTypeExtractor } from "../../common/interfaces"; +import * as mlcApi from '../../mlc/apiVersion/apiVersionTypeExtractor' +import * as hlcApi from '../../hlc/apiVersion/apiVersionTypeExtractor' + +// TODO: move to x-level-client folder +export const getApiVersionType: IApiVersionTypeExtractor = (packageRoot: string): ApiVersionType => { + const sdkType = getSDKType(packageRoot); + switch (sdkType) { + case SDKType.ModularClient: + return mlcApi.getApiVersionType(packageRoot); + case SDKType.HighLevelClient: + return hlcApi.getApiVersionType(packageRoot); + default: + console.warn(`Unsupported SDK type ${sdkType} to get detact api version`); + return ApiVersionType.None; + } +} \ No newline at end of file