From 314f4740e7ea210dfd35f294f5e9a15a7486ac9f Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 27 Aug 2024 14:15:10 -0700 Subject: [PATCH 01/29] publish tag init commit --- .../templates/steps/npm-release-task.yml | 5 + eng/scripts/verify-npm-tags.ps1 | 46 ++++++ package/LICENSE | 21 +++ package/README.md | 107 ++++++++++++ package/package.json | 156 ++++++++++++++++++ 5 files changed, 335 insertions(+) create mode 100644 eng/scripts/verify-npm-tags.ps1 create mode 100644 package/LICENSE create mode 100644 package/README.md create mode 100644 package/package.json diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index e5d52c9a8b95..d8899808c66f 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -47,3 +47,8 @@ steps: arguments: -pathToArtifacts ${{parameters.PathToArtifacts}} -accessLevel "public" -tag "${{parameters.Tag}}" -additionalTag "${{parameters.AdditionalTag}}" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token) pwsh: true condition: succeeded() + + - task: Powershell@2 + displayName: Verify package tags + inputs: + \ No newline at end of file diff --git a/eng/scripts/verify-npm-tags.ps1 b/eng/scripts/verify-npm-tags.ps1 new file mode 100644 index 000000000000..0a741a451f08 --- /dev/null +++ b/eng/scripts/verify-npm-tags.ps1 @@ -0,0 +1,46 @@ +param ( + [Parameter(mandatory = $true)] + $packageArtifact, + [Parameter(mandatory = $true)] + $workingDirectory +) + +$HelpersPath = Join-Path $PSScriptRoot "helpers" +. (Join-Path $HelpersPath npm-helpers.ps1) + +# $pkgProps = Get-javascript-PackageInfoFromPackageFile -pkg $packageArtifact -workingDirectory $workingDirectory +# if ($pkgProps -eq $null) +# { +# Write-Error "Failed to parse package artifact $packageArtifact to get package name" +# exit 1 +# } + +$packageName = '@azure/eventhubs-checkpointstore-table'#'@azure/openai'#'@azure/video-indexer-widgets'#'@azure/template'#$pkgProps.PackageId +$packageVersions = npm view $packageName versions --json | ConvertFrom-Json +$validDev = $packageVersions | ? { $_ -match "alpha" } | Select-Object -Last 1 +$validNext = $packageVersions | ? { $_ -match "beta" } | Select-Object -Last 1 +$validLatest = $packageVersions | ? { !($_ -match "alpha") -and !($_ -match "beta") } | Select-Object -Last 1 +if (!$validLAtest) { + Write-Host "No GA package found" + $validLatest = $packageVersions | ? { $_ -match "beta" } | Select-Object -Last 1 +} +if (!$validLAtest) { + Write-Host "No beta package found" + $validLatest = $packageVersions | ? { $_ -match "alpha" } | Select-Object -Last 1 +} + +$currentDev = npm view $packageName@dev version +$currentNext = npm view $packageName@next version +$currentLatest = npm view $packageName@latest version + +# if ($validDev -ne $currentDev) { + Write-Host "Dev version should be: $validDev, current dev version: $currentDev" +# } +# if ($validNext -ne $currentNext) { + Write-Host "Next version should be: $validNext, current next version: $currentNext" +# } +# if ($validLatest -ne $currentLatest) { + Write-Host "Latest version should be: $validLatest, current latest version: $currentLatest" +# } + +return $result diff --git a/package/LICENSE b/package/LICENSE new file mode 100644 index 000000000000..ea8fb1516028 --- /dev/null +++ b/package/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/package/README.md b/package/README.md new file mode 100644 index 000000000000..e790f70b882b --- /dev/null +++ b/package/README.md @@ -0,0 +1,107 @@ +# Azure Template client library for JavaScript + + + +This project is used as a template package for the Azure SDK for JavaScript. It is intended to help Azure SDK developers bootstrap new packages, and it provides an example of how to organize the code and documentation of a client library for an Azure service. + +## Getting started + +### Currently supported environments + +- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule) +- Latest versions of Safari, Chrome, Edge, and Firefox. + +See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details. + +### Prerequisites + +- An [Azure subscription][azure_sub]. + +Usually you'd put a shell command for provisioning the necessary Azure services here. + +### Install the `@azure/template` package + +Install the Template client library for JavaScript with `npm`: + +```bash +npm install @azure/template +``` + +### Browser support + +#### JavaScript Bundle + +To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). + +#### CORS + + + +You need to set up [Cross-Origin Resource Sharing (CORS)](https://docs.microsoft.com/rest/api/storageservices/cross-origin-resource-sharing--cors--support-for-the-azure-storage-services) rules for your storage account if you need to develop for browsers. Go to Azure portal and Azure Storage Explorer, find your storage account, create new CORS rules for blob/queue/file/table service(s). + +For example, you can create the following CORS settings for debugging. But please customize the settings carefully according to your requirements in a production environment. + +- Allowed origins: \* +- Allowed verbs: DELETE,GET,HEAD,MERGE,POST,OPTIONS,PUT +- Allowed headers: \* +- Exposed headers: \* +- Maximum age (seconds): 86400 + +### Further examples + +Top-level examples usually include things like creating and authenticating the main Client. If your service supports multiple means of authenticating (e.g. key-based and Azure Active Directory) you can give a separate example of each. + +## Key concepts + +### ConfigurationClient + +Describe your primary client here. Talk about what operations it can do and when a developer would want to use it. + +### Additional Examples + +Create a section for each top-level service concept you want to explain. + +## Examples + +### First Example + + + +Create several code examples for how someone would use your library to accomplish a common task with the service. + +## Troubleshooting + +### Logging + +Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`: + +```javascript +const { setLogLevel } = require("@azure/logger"); + +setLogLevel("info"); +``` + +For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger). + +## Next steps + +Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/template/template/samples) directory for detailed examples that demonstrate how to use the client libraries. + +## Contributing + +If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code. + +## Related projects + +- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Ftemplate%2Ftemplate%2FREADME.png) + +[azure_cli]: https://docs.microsoft.com/cli/azure +[azure_sub]: https://azure.microsoft.com/free/ diff --git a/package/package.json b/package/package.json new file mode 100644 index 000000000000..2e0ed17017b6 --- /dev/null +++ b/package/package.json @@ -0,0 +1,156 @@ +{ + "name": "@azure/template", + "version": "1.0.12-alpha.20240725.1", + "description": "Example project for learning how to build a client library", + "sdk-type": "client", + "main": "./dist/commonjs/index.js", + "types": "./dist/commonjs/index.d.ts", + "//metadata": { + "constantPaths": [ + { + "path": "src/generated/generatedClientContext.ts", + "prefix": "packageDetails" + }, + { + "path": "src/constants.ts", + "prefix": "SDK_VERSION" + }, + { + "path": "swagger/README.md", + "prefix": "package-version" + } + ], + "sampleConfiguration": { + "skipFolder": false, + "disableDocsMs": true, + "productName": "Azure Template", + "productSlugs": [], + "apiRefLink": "https://docs.microsoft.com/javascript/api/", + "requiredResources": { + "Azure App Configuration": "https://docs.microsoft.com/azure/azure-app-configuration/" + } + }, + "migrationDate": "2023-03-08T18:36:03.000Z" + }, + "scripts": { + "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", + "build:node": "tshy", + "build:samples": "echo Skipped.", + "build:test": "echo skipped. actual commands inlined in browser test scripts", + "build": "npm run clean && tshy && dev-tool run extract-api", + "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", + "clean": "rimraf --glob dist dist-* temp types *.tgz *.log", + "execute:samples": "dev-tool samples run samples-dev", + "extract-api": "tshy && dev-tool run extract-api", + "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", + "generate:client": "autorest --typescript ./swagger/README.md", + "integration-test:browser": "tshy && dev-tool run build-test && dev-tool run test:vitest --browser", + "integration-test:node": "dev-tool run test:vitest", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "lint:fix": "eslint README.md package.json api-extractor.json src test --ext .ts,.javascript,.js --fix --fix-type [problem,suggestion]", + "lint": "eslint README.md package.json api-extractor.json src test --ext .ts,.javascript,.js", + "pack": "npm pack 2>&1", + "test:browser": "npm run clean && npm run integration-test:browser", + "test:node": "npm run clean && npm run build:test && npm run integration-test:node", + "test": "npm run clean && tshy && npm run unit-test:node && dev-tool run bundle && npm run unit-test:browser && npm run integration-test", + "unit-test:browser": "npm run integration-test:browser", + "unit-test:node": "npm run integration-test:node", + "unit-test": "npm run unit-test:node && npm run unit-test:browser" + }, + "files": [ + "dist/", + "README.md", + "LICENSE" + ], + "repository": "github:Azure/azure-sdk-for-js", + "engines": { + "node": ">=18.0.0" + }, + "keywords": [ + "azure", + "cloud", + "typescript" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/template/template/README.md", + "sideEffects": false, + "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", + "dependencies": { + "@azure/core-auth": "^1.3.0", + "@azure/core-client": "^1.4.0", + "@azure/core-lro": "^2.7.0", + "@azure/core-rest-pipeline": "^1.4.0", + "@azure/core-tracing": "^1.0.0", + "@azure/logger": "^1.0.0", + "tslib": "^2.6.2" + }, + "devDependencies": { + "@azure-tools/test-credential": "^2.0.0", + "@azure-tools/test-recorder": "^4.0.0", + "@azure-tools/vite-plugin-browser-test-map": ">=1.0.0-alpha <1.0.0-alphb", + "@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb", + "@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb", + "@azure/identity": "^4.0.1", + "@azure-tools/test-utils": "^1.0.1", + "@microsoft/api-extractor": "^7.40.3", + "@types/node": "^18.0.0", + "@vitest/browser": "^1.5.3", + "@vitest/coverage-istanbul": "^1.5.3", + "cross-env": "^7.0.2", + "dotenv": "^16.0.0", + "eslint": "^8.56.0", + "loupe": "^3.1.0", + "playwright": "^1.41.2", + "rimraf": "^5.0.5", + "source-map-support": "^0.5.9", + "tshy": "^1.17.0", + "typescript": "~5.5.3", + "vitest": "^1.5.3" + }, + "tshy": { + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts" + }, + "dialects": [ + "esm", + "commonjs" + ], + "esmDialects": [ + "browser", + "react-native" + ], + "selfLink": false + }, + "exports": { + "./package.json": "./package.json", + ".": { + "browser": { + "source": "./src/index.ts", + "types": "./dist/browser/index.d.ts", + "default": "./dist/browser/index.js" + }, + "react-native": { + "source": "./src/index.ts", + "types": "./dist/react-native/index.d.ts", + "default": "./dist/react-native/index.js" + }, + "import": { + "source": "./src/index.ts", + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" + }, + "require": { + "source": "./src/index.ts", + "types": "./dist/commonjs/index.d.ts", + "default": "./dist/commonjs/index.js" + } + } + }, + "type": "module", + "module": "./dist/esm/index.js" +} From d98f3f0c3f4d54347db470fea66ad3593ab61076 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 2 Oct 2024 11:27:50 -0700 Subject: [PATCH 02/29] cleanup --- package/LICENSE | 21 ------ package/README.md | 107 ----------------------------- package/package.json | 156 ------------------------------------------- 3 files changed, 284 deletions(-) delete mode 100644 package/LICENSE delete mode 100644 package/README.md delete mode 100644 package/package.json diff --git a/package/LICENSE b/package/LICENSE deleted file mode 100644 index ea8fb1516028..000000000000 --- a/package/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2020 Microsoft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/package/README.md b/package/README.md deleted file mode 100644 index e790f70b882b..000000000000 --- a/package/README.md +++ /dev/null @@ -1,107 +0,0 @@ -# Azure Template client library for JavaScript - - - -This project is used as a template package for the Azure SDK for JavaScript. It is intended to help Azure SDK developers bootstrap new packages, and it provides an example of how to organize the code and documentation of a client library for an Azure service. - -## Getting started - -### Currently supported environments - -- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule) -- Latest versions of Safari, Chrome, Edge, and Firefox. - -See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details. - -### Prerequisites - -- An [Azure subscription][azure_sub]. - -Usually you'd put a shell command for provisioning the necessary Azure services here. - -### Install the `@azure/template` package - -Install the Template client library for JavaScript with `npm`: - -```bash -npm install @azure/template -``` - -### Browser support - -#### JavaScript Bundle - -To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). - -#### CORS - - - -You need to set up [Cross-Origin Resource Sharing (CORS)](https://docs.microsoft.com/rest/api/storageservices/cross-origin-resource-sharing--cors--support-for-the-azure-storage-services) rules for your storage account if you need to develop for browsers. Go to Azure portal and Azure Storage Explorer, find your storage account, create new CORS rules for blob/queue/file/table service(s). - -For example, you can create the following CORS settings for debugging. But please customize the settings carefully according to your requirements in a production environment. - -- Allowed origins: \* -- Allowed verbs: DELETE,GET,HEAD,MERGE,POST,OPTIONS,PUT -- Allowed headers: \* -- Exposed headers: \* -- Maximum age (seconds): 86400 - -### Further examples - -Top-level examples usually include things like creating and authenticating the main Client. If your service supports multiple means of authenticating (e.g. key-based and Azure Active Directory) you can give a separate example of each. - -## Key concepts - -### ConfigurationClient - -Describe your primary client here. Talk about what operations it can do and when a developer would want to use it. - -### Additional Examples - -Create a section for each top-level service concept you want to explain. - -## Examples - -### First Example - - - -Create several code examples for how someone would use your library to accomplish a common task with the service. - -## Troubleshooting - -### Logging - -Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`: - -```javascript -const { setLogLevel } = require("@azure/logger"); - -setLogLevel("info"); -``` - -For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger). - -## Next steps - -Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/template/template/samples) directory for detailed examples that demonstrate how to use the client libraries. - -## Contributing - -If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code. - -## Related projects - -- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Ftemplate%2Ftemplate%2FREADME.png) - -[azure_cli]: https://docs.microsoft.com/cli/azure -[azure_sub]: https://azure.microsoft.com/free/ diff --git a/package/package.json b/package/package.json deleted file mode 100644 index 2e0ed17017b6..000000000000 --- a/package/package.json +++ /dev/null @@ -1,156 +0,0 @@ -{ - "name": "@azure/template", - "version": "1.0.12-alpha.20240725.1", - "description": "Example project for learning how to build a client library", - "sdk-type": "client", - "main": "./dist/commonjs/index.js", - "types": "./dist/commonjs/index.d.ts", - "//metadata": { - "constantPaths": [ - { - "path": "src/generated/generatedClientContext.ts", - "prefix": "packageDetails" - }, - { - "path": "src/constants.ts", - "prefix": "SDK_VERSION" - }, - { - "path": "swagger/README.md", - "prefix": "package-version" - } - ], - "sampleConfiguration": { - "skipFolder": false, - "disableDocsMs": true, - "productName": "Azure Template", - "productSlugs": [], - "apiRefLink": "https://docs.microsoft.com/javascript/api/", - "requiredResources": { - "Azure App Configuration": "https://docs.microsoft.com/azure/azure-app-configuration/" - } - }, - "migrationDate": "2023-03-08T18:36:03.000Z" - }, - "scripts": { - "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", - "build:node": "tshy", - "build:samples": "echo Skipped.", - "build:test": "echo skipped. actual commands inlined in browser test scripts", - "build": "npm run clean && tshy && dev-tool run extract-api", - "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", - "clean": "rimraf --glob dist dist-* temp types *.tgz *.log", - "execute:samples": "dev-tool samples run samples-dev", - "extract-api": "tshy && dev-tool run extract-api", - "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", - "generate:client": "autorest --typescript ./swagger/README.md", - "integration-test:browser": "tshy && dev-tool run build-test && dev-tool run test:vitest --browser", - "integration-test:node": "dev-tool run test:vitest", - "integration-test": "npm run integration-test:node && npm run integration-test:browser", - "lint:fix": "eslint README.md package.json api-extractor.json src test --ext .ts,.javascript,.js --fix --fix-type [problem,suggestion]", - "lint": "eslint README.md package.json api-extractor.json src test --ext .ts,.javascript,.js", - "pack": "npm pack 2>&1", - "test:browser": "npm run clean && npm run integration-test:browser", - "test:node": "npm run clean && npm run build:test && npm run integration-test:node", - "test": "npm run clean && tshy && npm run unit-test:node && dev-tool run bundle && npm run unit-test:browser && npm run integration-test", - "unit-test:browser": "npm run integration-test:browser", - "unit-test:node": "npm run integration-test:node", - "unit-test": "npm run unit-test:node && npm run unit-test:browser" - }, - "files": [ - "dist/", - "README.md", - "LICENSE" - ], - "repository": "github:Azure/azure-sdk-for-js", - "engines": { - "node": ">=18.0.0" - }, - "keywords": [ - "azure", - "cloud", - "typescript" - ], - "author": "Microsoft Corporation", - "license": "MIT", - "bugs": { - "url": "https://github.com/Azure/azure-sdk-for-js/issues" - }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/template/template/README.md", - "sideEffects": false, - "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", - "dependencies": { - "@azure/core-auth": "^1.3.0", - "@azure/core-client": "^1.4.0", - "@azure/core-lro": "^2.7.0", - "@azure/core-rest-pipeline": "^1.4.0", - "@azure/core-tracing": "^1.0.0", - "@azure/logger": "^1.0.0", - "tslib": "^2.6.2" - }, - "devDependencies": { - "@azure-tools/test-credential": "^2.0.0", - "@azure-tools/test-recorder": "^4.0.0", - "@azure-tools/vite-plugin-browser-test-map": ">=1.0.0-alpha <1.0.0-alphb", - "@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb", - "@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb", - "@azure/identity": "^4.0.1", - "@azure-tools/test-utils": "^1.0.1", - "@microsoft/api-extractor": "^7.40.3", - "@types/node": "^18.0.0", - "@vitest/browser": "^1.5.3", - "@vitest/coverage-istanbul": "^1.5.3", - "cross-env": "^7.0.2", - "dotenv": "^16.0.0", - "eslint": "^8.56.0", - "loupe": "^3.1.0", - "playwright": "^1.41.2", - "rimraf": "^5.0.5", - "source-map-support": "^0.5.9", - "tshy": "^1.17.0", - "typescript": "~5.5.3", - "vitest": "^1.5.3" - }, - "tshy": { - "exports": { - "./package.json": "./package.json", - ".": "./src/index.ts" - }, - "dialects": [ - "esm", - "commonjs" - ], - "esmDialects": [ - "browser", - "react-native" - ], - "selfLink": false - }, - "exports": { - "./package.json": "./package.json", - ".": { - "browser": { - "source": "./src/index.ts", - "types": "./dist/browser/index.d.ts", - "default": "./dist/browser/index.js" - }, - "react-native": { - "source": "./src/index.ts", - "types": "./dist/react-native/index.d.ts", - "default": "./dist/react-native/index.js" - }, - "import": { - "source": "./src/index.ts", - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - }, - "require": { - "source": "./src/index.ts", - "types": "./dist/commonjs/index.d.ts", - "default": "./dist/commonjs/index.js" - } - } - }, - "type": "module", - "module": "./dist/esm/index.js" -} From 96eee5133836afb5ea578e07ed0ef8ac887ae2f0 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 2 Oct 2024 13:43:23 -0700 Subject: [PATCH 03/29] publish tag testing before actual npm tag change --- .../templates/stages/archetype-js-release.yml | 2 - .../templates/stages/partner-release.yml | 1 - .../templates/steps/npm-release-task.yml | 5 +- eng/scripts/verify-npm-tags.ps1 | 59 ++++++++++++------- 4 files changed, 42 insertions(+), 25 deletions(-) diff --git a/eng/pipelines/templates/stages/archetype-js-release.yml b/eng/pipelines/templates/stages/archetype-js-release.yml index 6078b56f993d..cd4558d1621f 100644 --- a/eng/pipelines/templates/stages/archetype-js-release.yml +++ b/eng/pipelines/templates/stages/archetype-js-release.yml @@ -94,7 +94,6 @@ stages: condition: succeeded() - template: /eng/pipelines/templates/steps/npm-release-task.yml parameters: - ArtifactName: ${{parameters.ArtifactName}} Artifact: ${{artifact}} Registry: ${{parameters.Registry}} PathToArtifacts: $(Pipeline.Workspace)/${{parameters.ArtifactName}}/${{artifact.name}} @@ -258,7 +257,6 @@ stages: displayName: Detecting package archive_${{artifact.name}} - template: /eng/pipelines/templates/steps/npm-release-task.yml parameters: - ArtifactName: ${{parameters.ArtifactName}} Artifact: ${{artifact}} Registry: ${{parameters.Registry}} PathToArtifacts: $(Pipeline.Workspace)/${{parameters.ArtifactName}}/${{artifact.name}} diff --git a/eng/pipelines/templates/stages/partner-release.yml b/eng/pipelines/templates/stages/partner-release.yml index 29de2a7ee059..f023a303f02e 100644 --- a/eng/pipelines/templates/stages/partner-release.yml +++ b/eng/pipelines/templates/stages/partner-release.yml @@ -58,7 +58,6 @@ extends: - template: /eng/pipelines/templates/steps/npm-release-task.yml parameters: - ArtifactName: Partner Drop Artifact: name: Partner Drop path: $(Artifacts) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index adef0178476c..3daa9c7e6f64 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -1,5 +1,4 @@ parameters: - ArtifactName: '' Artifact: {} Registry: '' PathToArtifacts: '' @@ -50,5 +49,7 @@ steps: - task: Powershell@2 displayName: Verify package tags - inputs: + inputs: + packageArtifact: ${{parameters.Artifact.name}} + workingDirectory: $(System.DefaultWorkingDirectory) \ No newline at end of file diff --git a/eng/scripts/verify-npm-tags.ps1 b/eng/scripts/verify-npm-tags.ps1 index 0a741a451f08..e5df23cb2f8b 100644 --- a/eng/scripts/verify-npm-tags.ps1 +++ b/eng/scripts/verify-npm-tags.ps1 @@ -8,39 +8,58 @@ param ( $HelpersPath = Join-Path $PSScriptRoot "helpers" . (Join-Path $HelpersPath npm-helpers.ps1) -# $pkgProps = Get-javascript-PackageInfoFromPackageFile -pkg $packageArtifact -workingDirectory $workingDirectory -# if ($pkgProps -eq $null) -# { -# Write-Error "Failed to parse package artifact $packageArtifact to get package name" -# exit 1 -# } +$pkgProps = Get-javascript-PackageInfoFromPackageFile -pkg $packageArtifact -workingDirectory $workingDirectory +if (!$pkgProps) +{ + Write-Error "Failed to parse package artifact $packageArtifact to get package name" + exit 1 +} -$packageName = '@azure/eventhubs-checkpointstore-table'#'@azure/openai'#'@azure/video-indexer-widgets'#'@azure/template'#$pkgProps.PackageId +$packageName = $pkgProps.PackageId +# TODO: delete testing comments below +#'@azure/eventhubs-checkpointstore-table' alpha, no beta, no GA +#'@azure/openai' alpha, beta, no GA +#'@azure/video-indexer-widgets' no alpha, no beta, GA +#'@azure/template' alpha, beta, GA +#$pkgProps.PackageId +Write-Host "Verify npm tag versions for package $packageName" $packageVersions = npm view $packageName versions --json | ConvertFrom-Json $validDev = $packageVersions | ? { $_ -match "alpha" } | Select-Object -Last 1 $validNext = $packageVersions | ? { $_ -match "beta" } | Select-Object -Last 1 $validLatest = $packageVersions | ? { !($_ -match "alpha") -and !($_ -match "beta") } | Select-Object -Last 1 -if (!$validLAtest) { +if (!$validLatest) { Write-Host "No GA package found" $validLatest = $packageVersions | ? { $_ -match "beta" } | Select-Object -Last 1 } -if (!$validLAtest) { +if (!$validLatest) { Write-Host "No beta package found" $validLatest = $packageVersions | ? { $_ -match "alpha" } | Select-Object -Last 1 } -$currentDev = npm view $packageName@dev version -$currentNext = npm view $packageName@next version -$currentLatest = npm view $packageName@latest version +$currentDev = npm view $packageName@dev version --silent +$currentNext = npm view $packageName@next version --silent +$currentLatest = npm view $packageName@latest version --silent -# if ($validDev -ne $currentDev) { +if ($validDev) { Write-Host "Dev version should be: $validDev, current dev version: $currentDev" -# } -# if ($validNext -ne $currentNext) { + if ($validDev -ne $currentDev) { + Write-Host "Changing dev version from $currentDev to $validDev" + # TODO: add npm command for tag change + } +} + +if ($validNext) { Write-Host "Next version should be: $validNext, current next version: $currentNext" -# } -# if ($validLatest -ne $currentLatest) { - Write-Host "Latest version should be: $validLatest, current latest version: $currentLatest" -# } + if ($validNext -ne $currentNext) { + Write-Host "Changing next version from $currentNext to $validNext" + # TODO: add npm command for tag change + } +} -return $result +if ($validLatest) { + Write-Host "Latest version should be: $validLatest, current latest version: $currentLatest" + if ($validLatest -ne $currentLatest) { + Write-Host "Changing latest version from $currentLatest to $validLatest" + # TODO: add npm command for tag change + } +} From 3ceb25074f0afc549581e20de2e3a44338db4baa Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 2 Oct 2024 14:10:19 -0700 Subject: [PATCH 04/29] temporarily removing unit test --- eng/pipelines/templates/stages/archetype-sdk-client.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/stages/archetype-sdk-client.yml b/eng/pipelines/templates/stages/archetype-sdk-client.yml index 0e959477dd2a..8aa8e06db7f4 100644 --- a/eng/pipelines/templates/stages/archetype-sdk-client.yml +++ b/eng/pipelines/templates/stages/archetype-sdk-client.yml @@ -57,7 +57,7 @@ extends: Artifacts: ${{ parameters.Artifacts }} ${{ if eq(parameters.ServiceDirectory, 'template') }}: TestPipeline: true - RunUnitTests: ${{ parameters.RunUnitTests }} + RunUnitTests: false MatrixConfigs: - ${{ each config in parameters.MatrixConfigs }}: - ${{ config }} From 8a39825804984495e7ed682a6431686e94f8a275 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 2 Oct 2024 14:57:03 -0700 Subject: [PATCH 05/29] add verify npm tag pwsh path --- eng/pipelines/templates/steps/npm-release-task.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 3daa9c7e6f64..16879d4adbe6 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -50,6 +50,7 @@ steps: - task: Powershell@2 displayName: Verify package tags inputs: - packageArtifact: ${{parameters.Artifact.name}} - workingDirectory: $(System.DefaultWorkingDirectory) - \ No newline at end of file + targetType: filePath + filePath: eng/scripts/verify-npm-tags.ps1 + arguments: -packageArtifact ${{parameters.Artifact.name}} -workingDirectory $(System.DefaultWorkingDirectory) + pwsh: true From 003579375af5541a9f31442f8e1d0c16a6577fd6 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 10 Oct 2024 09:35:11 -0700 Subject: [PATCH 06/29] add npm dist tag change --- eng/scripts/verify-npm-tags.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/scripts/verify-npm-tags.ps1 b/eng/scripts/verify-npm-tags.ps1 index e5df23cb2f8b..277bd00b16f5 100644 --- a/eng/scripts/verify-npm-tags.ps1 +++ b/eng/scripts/verify-npm-tags.ps1 @@ -44,7 +44,7 @@ if ($validDev) { Write-Host "Dev version should be: $validDev, current dev version: $currentDev" if ($validDev -ne $currentDev) { Write-Host "Changing dev version from $currentDev to $validDev" - # TODO: add npm command for tag change + npm dist-tag add $packageName@$validDev dev } } @@ -52,7 +52,7 @@ if ($validNext) { Write-Host "Next version should be: $validNext, current next version: $currentNext" if ($validNext -ne $currentNext) { Write-Host "Changing next version from $currentNext to $validNext" - # TODO: add npm command for tag change + npm dist-tag add $packageName@$validNext next } } @@ -60,6 +60,6 @@ if ($validLatest) { Write-Host "Latest version should be: $validLatest, current latest version: $currentLatest" if ($validLatest -ne $currentLatest) { Write-Host "Changing latest version from $currentLatest to $validLatest" - # TODO: add npm command for tag change + npm dist-tag add $packageName@$validLatest latest } } From dd1ad959b4d98591e0f3757ce9e05ca95acd181f Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 10 Oct 2024 13:18:27 -0700 Subject: [PATCH 07/29] add artifacts --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 16879d4adbe6..a3d32de49231 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -52,5 +52,5 @@ steps: inputs: targetType: filePath filePath: eng/scripts/verify-npm-tags.ps1 - arguments: -packageArtifact ${{parameters.Artifact.name}} -workingDirectory $(System.DefaultWorkingDirectory) + arguments: -packageArtifact ${{parameters.Artifact}} -workingDirectory $(System.DefaultWorkingDirectory) pwsh: true From 63038a6d855e238c4ec3752fd053b06444e6f80f Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 10 Oct 2024 13:26:12 -0700 Subject: [PATCH 08/29] add artifacts --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index a3d32de49231..f5243cf36e5a 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -52,5 +52,5 @@ steps: inputs: targetType: filePath filePath: eng/scripts/verify-npm-tags.ps1 - arguments: -packageArtifact ${{parameters.Artifact}} -workingDirectory $(System.DefaultWorkingDirectory) + arguments: -packageArtifact '${{ convertToJson(parameters.Artifact) }}' -workingDirectory $(System.DefaultWorkingDirectory) pwsh: true From 7e09bb7d0bc3dcc401dadd5dbebd7f8aa5ae132f Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 10 Oct 2024 14:24:19 -0700 Subject: [PATCH 09/29] package name --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- eng/scripts/verify-npm-tags.ps1 | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index f5243cf36e5a..143c9fa62034 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -52,5 +52,5 @@ steps: inputs: targetType: filePath filePath: eng/scripts/verify-npm-tags.ps1 - arguments: -packageArtifact '${{ convertToJson(parameters.Artifact) }}' -workingDirectory $(System.DefaultWorkingDirectory) + arguments: -packageName ${{parameters.Artifact.name}} -workingDirectory $(System.DefaultWorkingDirectory) pwsh: true diff --git a/eng/scripts/verify-npm-tags.ps1 b/eng/scripts/verify-npm-tags.ps1 index 277bd00b16f5..7c7b3e62295e 100644 --- a/eng/scripts/verify-npm-tags.ps1 +++ b/eng/scripts/verify-npm-tags.ps1 @@ -1,21 +1,10 @@ param ( [Parameter(mandatory = $true)] - $packageArtifact, + $packageName, [Parameter(mandatory = $true)] $workingDirectory ) -$HelpersPath = Join-Path $PSScriptRoot "helpers" -. (Join-Path $HelpersPath npm-helpers.ps1) - -$pkgProps = Get-javascript-PackageInfoFromPackageFile -pkg $packageArtifact -workingDirectory $workingDirectory -if (!$pkgProps) -{ - Write-Error "Failed to parse package artifact $packageArtifact to get package name" - exit 1 -} - -$packageName = $pkgProps.PackageId # TODO: delete testing comments below #'@azure/eventhubs-checkpointstore-table' alpha, no beta, no GA #'@azure/openai' alpha, beta, no GA From 4e175da6094f5d22386d714f5c7d0bed6d730a38 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Fri, 11 Oct 2024 12:34:38 -0700 Subject: [PATCH 10/29] update package name --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- eng/scripts/verify-npm-tags.ps1 | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 143c9fa62034..c0f5cb09231a 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -52,5 +52,5 @@ steps: inputs: targetType: filePath filePath: eng/scripts/verify-npm-tags.ps1 - arguments: -packageName ${{parameters.Artifact.name}} -workingDirectory $(System.DefaultWorkingDirectory) + arguments: -artifactName ${{parameters.Artifact.name}} -workingDirectory $(System.DefaultWorkingDirectory) pwsh: true diff --git a/eng/scripts/verify-npm-tags.ps1 b/eng/scripts/verify-npm-tags.ps1 index 7c7b3e62295e..6da404446d99 100644 --- a/eng/scripts/verify-npm-tags.ps1 +++ b/eng/scripts/verify-npm-tags.ps1 @@ -1,6 +1,6 @@ param ( [Parameter(mandatory = $true)] - $packageName, + $artifactName, [Parameter(mandatory = $true)] $workingDirectory ) @@ -11,6 +11,11 @@ param ( #'@azure/video-indexer-widgets' no alpha, no beta, GA #'@azure/template' alpha, beta, GA #$pkgProps.PackageId + +. (Join-Path $PSScriptRoot "../common/scripts/common.ps1") + +$packageProperties = Get-PkgProperties -PackageName $artifactName +$packageName = $packageProperties.Name Write-Host "Verify npm tag versions for package $packageName" $packageVersions = npm view $packageName versions --json | ConvertFrom-Json $validDev = $packageVersions | ? { $_ -match "alpha" } | Select-Object -Last 1 From 431696755e084108e304c080947e3c163eb43709 Mon Sep 17 00:00:00 2001 From: Albert Cheng <38804567+ckairen@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:11:59 -0700 Subject: [PATCH 11/29] Update eng/scripts/verify-npm-tags.ps1 Co-authored-by: Ben Broderick Phillips --- eng/scripts/verify-npm-tags.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eng/scripts/verify-npm-tags.ps1 b/eng/scripts/verify-npm-tags.ps1 index 6da404446d99..4de0ded21a30 100644 --- a/eng/scripts/verify-npm-tags.ps1 +++ b/eng/scripts/verify-npm-tags.ps1 @@ -12,6 +12,9 @@ param ( #'@azure/template' alpha, beta, GA #$pkgProps.PackageId +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $true + . (Join-Path $PSScriptRoot "../common/scripts/common.ps1") $packageProperties = Get-PkgProperties -PackageName $artifactName From e071b59f547aa6526d6434db68e0c963ca779b8f Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 22 Oct 2024 15:17:24 -0700 Subject: [PATCH 12/29] pr adjustments --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- eng/scripts/verify-npm-tags.ps1 | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index c0f5cb09231a..143c9fa62034 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -52,5 +52,5 @@ steps: inputs: targetType: filePath filePath: eng/scripts/verify-npm-tags.ps1 - arguments: -artifactName ${{parameters.Artifact.name}} -workingDirectory $(System.DefaultWorkingDirectory) + arguments: -packageName ${{parameters.Artifact.name}} -workingDirectory $(System.DefaultWorkingDirectory) pwsh: true diff --git a/eng/scripts/verify-npm-tags.ps1 b/eng/scripts/verify-npm-tags.ps1 index 4de0ded21a30..b89a12ca0db3 100644 --- a/eng/scripts/verify-npm-tags.ps1 +++ b/eng/scripts/verify-npm-tags.ps1 @@ -2,7 +2,7 @@ param ( [Parameter(mandatory = $true)] $artifactName, [Parameter(mandatory = $true)] - $workingDirectory + $packageName ) # TODO: delete testing comments below @@ -17,7 +17,7 @@ $PSNativeCommandUseErrorActionPreference = $true . (Join-Path $PSScriptRoot "../common/scripts/common.ps1") -$packageProperties = Get-PkgProperties -PackageName $artifactName +$packageProperties = Get-PkgProperties -PackageName $packageName $packageName = $packageProperties.Name Write-Host "Verify npm tag versions for package $packageName" $packageVersions = npm view $packageName versions --json | ConvertFrom-Json @@ -33,9 +33,9 @@ if (!$validLatest) { $validLatest = $packageVersions | ? { $_ -match "alpha" } | Select-Object -Last 1 } -$currentDev = npm view $packageName@dev version --silent -$currentNext = npm view $packageName@next version --silent -$currentLatest = npm view $packageName@latest version --silent +$currentDev = $packageVersions."dist-tags"."dev" +$currentNext = $packageVersions."dist-tags"."next" +$currentLatest = $packageVersions."dist-tags"."latest" if ($validDev) { Write-Host "Dev version should be: $validDev, current dev version: $currentDev" From 3d89b5632969f0662a7a9133fc2653763f07705b Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 4 Nov 2024 09:56:37 -0800 Subject: [PATCH 13/29] change verify npm tags script to check for intended tags --- .../templates/steps/npm-release-task.yml | 32 ++++++--- eng/scripts/verify-npm-tags.ps1 | 67 ++++++++----------- 2 files changed, 51 insertions(+), 48 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 143c9fa62034..5c89217af8a2 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -9,6 +9,22 @@ steps: - template: /eng/common/pipelines/templates/steps/set-default-branch.yml - ${{ if eq(parameters.Registry, 'https://registry.npmjs.org/') }}: + - pwsh: | + set -o xtrace + $tarFile = (Get-ChildItem -Path "${{parameters.Artifact.name}}*.tgz")?.Name + $tempDir = "temp_decompress" + New-Item -ItemType Directory -Force -Path $tempDir + tar -xzf $tarFile -C $tempDir + $pkg = Get-Content -Raw "$tempDir\package\package.json" | ConvertFrom-Json + $packageName = $pkg.Name + $packageVersion = $pkg.Version + $packageProps = npm view $packageName -json | ConvertFrom-Json + $originalTags = $packageProps.'dist-tags'" | ConvertTo-Json -Compress + echo "##vso[task.setvariable variable=OriginalTags]$originalTags + echo "##vso[task.setvariable variable=IntendedTagVersion]$packageVersion + Remove-Item -Force -Recurse $tempDir + displayName: Get original tags + - task: EsrpRelease@7 inputs: displayName: 'Publish ${{parameters.Artifact.name}} to ESRP' @@ -27,6 +43,14 @@ steps: DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47' productstate: ${{parameters.Tag}} + - task: Powershell@2 + displayName: Verify package tags + inputs: + targetType: filePath + filePath: eng/scripts/verify-npm-tags.ps1 + arguments: -pathToArtifacts ${{parameters.PathToArtifacts}} -originalDistTags $(OriginalTags) -intendedTag ${{parameters.Tag}} -intendedTagVersion $(IntendedTagVersion) + pwsh: true + - ${{ if ne(parameters.AdditionalTag, '') }}: - task: PowerShell@2 displayName: Add Additional Tag @@ -46,11 +70,3 @@ steps: arguments: -pathToArtifacts ${{parameters.PathToArtifacts}} -accessLevel "public" -tag "${{parameters.Tag}}" -additionalTag "${{parameters.AdditionalTag}}" -registry ${{parameters.Registry}} -npmToken $(azure-sdk-npm-token) pwsh: true condition: succeeded() - - - task: Powershell@2 - displayName: Verify package tags - inputs: - targetType: filePath - filePath: eng/scripts/verify-npm-tags.ps1 - arguments: -packageName ${{parameters.Artifact.name}} -workingDirectory $(System.DefaultWorkingDirectory) - pwsh: true diff --git a/eng/scripts/verify-npm-tags.ps1 b/eng/scripts/verify-npm-tags.ps1 index b89a12ca0db3..e56c3a660278 100644 --- a/eng/scripts/verify-npm-tags.ps1 +++ b/eng/scripts/verify-npm-tags.ps1 @@ -1,8 +1,12 @@ param ( [Parameter(mandatory = $true)] - $artifactName, + $pathToArtifacts, [Parameter(mandatory = $true)] - $packageName + $originalDistTags, + [Parameter(mandatory = $true)] + $intendedTag, + [Parameter(mandatory = $true)] + $intendedTagVersion ) # TODO: delete testing comments below @@ -15,48 +19,31 @@ param ( $ErrorActionPreference = 'Stop' $PSNativeCommandUseErrorActionPreference = $true -. (Join-Path $PSScriptRoot "../common/scripts/common.ps1") +$tarFile = (Get-ChildItem -Path "$pathToArtifacts/*.tgz")?.Name +$tempDir = "temp_decompress" +New-Item -ItemType Directory -Force -Path $tempDir +tar -xzf $tarFile -C $tempDir +$pkg = Get-Content -Raw "$tempDir\package\package.json" | ConvertFrom-Json +$packageName = $pkg.Name +Remove-Item -Force -Recurse $tempDir -$packageProperties = Get-PkgProperties -PackageName $packageName -$packageName = $packageProperties.Name Write-Host "Verify npm tag versions for package $packageName" -$packageVersions = npm view $packageName versions --json | ConvertFrom-Json -$validDev = $packageVersions | ? { $_ -match "alpha" } | Select-Object -Last 1 -$validNext = $packageVersions | ? { $_ -match "beta" } | Select-Object -Last 1 -$validLatest = $packageVersions | ? { !($_ -match "alpha") -and !($_ -match "beta") } | Select-Object -Last 1 -if (!$validLatest) { - Write-Host "No GA package found" - $validLatest = $packageVersions | ? { $_ -match "beta" } | Select-Object -Last 1 -} -if (!$validLatest) { - Write-Host "No beta package found" - $validLatest = $packageVersions | ? { $_ -match "alpha" } | Select-Object -Last 1 -} -$currentDev = $packageVersions."dist-tags"."dev" -$currentNext = $packageVersions."dist-tags"."next" -$currentLatest = $packageVersions."dist-tags"."latest" +$parsedOriginalDistTags = $originalDistTags | ConvertFrom-Json -if ($validDev) { - Write-Host "Dev version should be: $validDev, current dev version: $currentDev" - if ($validDev -ne $currentDev) { - Write-Host "Changing dev version from $currentDev to $validDev" - npm dist-tag add $packageName@$validDev dev - } -} - -if ($validNext) { - Write-Host "Next version should be: $validNext, current next version: $currentNext" - if ($validNext -ne $currentNext) { - Write-Host "Changing next version from $currentNext to $validNext" - npm dist-tag add $packageName@$validNext next - } -} +$npmPkgProp = npm view $packageName --json | ConvertFrom-Json +$packageDistTags = $npmPkgProp."dist-tags" +Write-Host "Current dist-tag: $packageDistTags" -if ($validLatest) { - Write-Host "Latest version should be: $validLatest, current latest version: $currentLatest" - if ($validLatest -ne $currentLatest) { - Write-Host "Changing latest version from $currentLatest to $validLatest" - npm dist-tag add $packageName@$validLatest latest +if ($packageDistTags."$intendedTag" -ne $intendedTagVersion) { + Write-Host "Tag not correctly set, current $intendedTag tag is version $packageDistTags.'$intendedTag' instead of $intendedTagVersion." + $correctDistTags = $parsedOriginalDistTags + $correctDistTags."$intendedTag" = $intendedTagVersion + foreach($tag in $correctDistTags.PSObject.Properties) { + Write-Host "npm dist-tag add $packageName@$tag.value $tag.Name" + npm dist-tag add $packageName@$tag.value $tag.Name } + $npmPkgProp = npm view $packageName --json | ConvertFrom-Json + $packageDistTags = $npmPkgProp."dist-tags" + Write-Host "Corrected dist tags to: $packageDistTags" } From 36420bf65c75fb45572e1901b7be9923213a9ebd Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 4 Nov 2024 11:24:35 -0800 Subject: [PATCH 14/29] bug fix --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 5c89217af8a2..44a2787f13d5 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -19,7 +19,7 @@ steps: $packageName = $pkg.Name $packageVersion = $pkg.Version $packageProps = npm view $packageName -json | ConvertFrom-Json - $originalTags = $packageProps.'dist-tags'" | ConvertTo-Json -Compress + $originalTags = $packageProps.'dist-tags' | ConvertTo-Json -Compress echo "##vso[task.setvariable variable=OriginalTags]$originalTags echo "##vso[task.setvariable variable=IntendedTagVersion]$packageVersion Remove-Item -Force -Recurse $tempDir From 864ff4f27882f98f5f584fa1ce97f33e41d7a339 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 4 Nov 2024 23:07:45 -0800 Subject: [PATCH 15/29] set debug trace --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 44a2787f13d5..f88373081bbb 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -10,7 +10,7 @@ steps: - ${{ if eq(parameters.Registry, 'https://registry.npmjs.org/') }}: - pwsh: | - set -o xtrace + Set-PSDebug -Trace 1 $tarFile = (Get-ChildItem -Path "${{parameters.Artifact.name}}*.tgz")?.Name $tempDir = "temp_decompress" New-Item -ItemType Directory -Force -Path $tempDir From 69b6268618eef9a558a44685624231e686535e5f Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 4 Nov 2024 23:32:44 -0800 Subject: [PATCH 16/29] temp dir --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index f88373081bbb..d1970f9ad130 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -12,7 +12,7 @@ steps: - pwsh: | Set-PSDebug -Trace 1 $tarFile = (Get-ChildItem -Path "${{parameters.Artifact.name}}*.tgz")?.Name - $tempDir = "temp_decompress" + $tempDir = "$(System.DefaultWorkingDirectory)/temp_decompress" New-Item -ItemType Directory -Force -Path $tempDir tar -xzf $tarFile -C $tempDir $pkg = Get-Content -Raw "$tempDir\package\package.json" | ConvertFrom-Json From 7e268589cda0419608cb23a0cb49bac540e46124 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 5 Nov 2024 00:35:03 -0800 Subject: [PATCH 17/29] tar file location --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index d1970f9ad130..e5c6859da459 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -11,7 +11,7 @@ steps: - ${{ if eq(parameters.Registry, 'https://registry.npmjs.org/') }}: - pwsh: | Set-PSDebug -Trace 1 - $tarFile = (Get-ChildItem -Path "${{parameters.Artifact.name}}*.tgz")?.Name + $tarFile = (Get-ChildItem -Path "${{parameters.PathToArtifacts}}/${{parameters.Artifact.name}}/*.tgz")?.Name $tempDir = "$(System.DefaultWorkingDirectory)/temp_decompress" New-Item -ItemType Directory -Force -Path $tempDir tar -xzf $tarFile -C $tempDir From 8ddb743c2d283ef63b5a5ff2a12f65556943675c Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 5 Nov 2024 01:07:12 -0800 Subject: [PATCH 18/29] tar file location --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index e5c6859da459..6cdeb0a245a3 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -11,7 +11,7 @@ steps: - ${{ if eq(parameters.Registry, 'https://registry.npmjs.org/') }}: - pwsh: | Set-PSDebug -Trace 1 - $tarFile = (Get-ChildItem -Path "${{parameters.PathToArtifacts}}/${{parameters.Artifact.name}}/*.tgz")?.Name + $tarFile = (Get-ChildItem -Path "${{parameters.PathToArtifacts}}/*.tgz")?.Name $tempDir = "$(System.DefaultWorkingDirectory)/temp_decompress" New-Item -ItemType Directory -Force -Path $tempDir tar -xzf $tarFile -C $tempDir From ab8e65773266d5f9535118cf4d6c23228d5e787a Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 5 Nov 2024 01:32:35 -0800 Subject: [PATCH 19/29] tar file full path --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 6cdeb0a245a3..0e8ce3c632e6 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -11,7 +11,7 @@ steps: - ${{ if eq(parameters.Registry, 'https://registry.npmjs.org/') }}: - pwsh: | Set-PSDebug -Trace 1 - $tarFile = (Get-ChildItem -Path "${{parameters.PathToArtifacts}}/*.tgz")?.Name + $tarFile = (Get-ChildItem -Path "${{parameters.PathToArtifacts}}/*.tgz").FullName $tempDir = "$(System.DefaultWorkingDirectory)/temp_decompress" New-Item -ItemType Directory -Force -Path $tempDir tar -xzf $tarFile -C $tempDir From a10ca8d953c093ed53a1c7f183a1532bf62bb1f7 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 5 Nov 2024 02:05:14 -0800 Subject: [PATCH 20/29] json object as parameter --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 0e8ce3c632e6..db269b51d7de 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -48,7 +48,7 @@ steps: inputs: targetType: filePath filePath: eng/scripts/verify-npm-tags.ps1 - arguments: -pathToArtifacts ${{parameters.PathToArtifacts}} -originalDistTags $(OriginalTags) -intendedTag ${{parameters.Tag}} -intendedTagVersion $(IntendedTagVersion) + arguments: -pathToArtifacts ${{parameters.PathToArtifacts}} -originalDistTags '$(OriginalTags)' -intendedTag ${{parameters.Tag}} -intendedTagVersion $(IntendedTagVersion) pwsh: true - ${{ if ne(parameters.AdditionalTag, '') }}: From a1cf0c34cfb81b0bae14943d8ad8a7b703d57fb8 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 5 Nov 2024 09:51:07 -0800 Subject: [PATCH 21/29] quote --- eng/pipelines/templates/steps/npm-release-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index db269b51d7de..aa6e7c6fb22c 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -48,7 +48,7 @@ steps: inputs: targetType: filePath filePath: eng/scripts/verify-npm-tags.ps1 - arguments: -pathToArtifacts ${{parameters.PathToArtifacts}} -originalDistTags '$(OriginalTags)' -intendedTag ${{parameters.Tag}} -intendedTagVersion $(IntendedTagVersion) + arguments: -pathToArtifacts ${{parameters.PathToArtifacts}} -originalDistTags '$(OriginalTags)' -intendedTag ${{parameters.Tag}} -intendedTagVersion '$(IntendedTagVersion)' pwsh: true - ${{ if ne(parameters.AdditionalTag, '') }}: From 37ac3f803ccc88c885a1f96f7c07ebabf525bd4d Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 5 Nov 2024 10:52:33 -0800 Subject: [PATCH 22/29] pck name --- eng/pipelines/templates/steps/npm-release-task.yml | 1 - eng/scripts/verify-npm-tags.ps1 | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index aa6e7c6fb22c..40d52a026635 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -22,7 +22,6 @@ steps: $originalTags = $packageProps.'dist-tags' | ConvertTo-Json -Compress echo "##vso[task.setvariable variable=OriginalTags]$originalTags echo "##vso[task.setvariable variable=IntendedTagVersion]$packageVersion - Remove-Item -Force -Recurse $tempDir displayName: Get original tags - task: EsrpRelease@7 diff --git a/eng/scripts/verify-npm-tags.ps1 b/eng/scripts/verify-npm-tags.ps1 index e56c3a660278..14c742454ddf 100644 --- a/eng/scripts/verify-npm-tags.ps1 +++ b/eng/scripts/verify-npm-tags.ps1 @@ -19,13 +19,8 @@ param ( $ErrorActionPreference = 'Stop' $PSNativeCommandUseErrorActionPreference = $true -$tarFile = (Get-ChildItem -Path "$pathToArtifacts/*.tgz")?.Name -$tempDir = "temp_decompress" -New-Item -ItemType Directory -Force -Path $tempDir -tar -xzf $tarFile -C $tempDir -$pkg = Get-Content -Raw "$tempDir\package\package.json" | ConvertFrom-Json +$pkg = Get-Content -Raw "temp_decompress\package\package.json" | ConvertFrom-Json $packageName = $pkg.Name -Remove-Item -Force -Recurse $tempDir Write-Host "Verify npm tag versions for package $packageName" From b98af61e29cc7a7c30a33fd870f464b303a8699e Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 5 Nov 2024 10:55:48 -0800 Subject: [PATCH 23/29] warning --- eng/scripts/verify-npm-tags.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/scripts/verify-npm-tags.ps1 b/eng/scripts/verify-npm-tags.ps1 index 14c742454ddf..926105c9455b 100644 --- a/eng/scripts/verify-npm-tags.ps1 +++ b/eng/scripts/verify-npm-tags.ps1 @@ -31,7 +31,7 @@ $packageDistTags = $npmPkgProp."dist-tags" Write-Host "Current dist-tag: $packageDistTags" if ($packageDistTags."$intendedTag" -ne $intendedTagVersion) { - Write-Host "Tag not correctly set, current $intendedTag tag is version $packageDistTags.'$intendedTag' instead of $intendedTagVersion." + Write-Warning "Tag not correctly set, current $intendedTag tag is version $packageDistTags.'$intendedTag' instead of $intendedTagVersion." $correctDistTags = $parsedOriginalDistTags $correctDistTags."$intendedTag" = $intendedTagVersion foreach($tag in $correctDistTags.PSObject.Properties) { From ce82b77a8cadea7f5b4f54c1926ff07a0bea616c Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 5 Nov 2024 11:29:25 -0800 Subject: [PATCH 24/29] tag variable --- eng/scripts/verify-npm-tags.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/scripts/verify-npm-tags.ps1 b/eng/scripts/verify-npm-tags.ps1 index 926105c9455b..e9f1b875d368 100644 --- a/eng/scripts/verify-npm-tags.ps1 +++ b/eng/scripts/verify-npm-tags.ps1 @@ -35,7 +35,7 @@ if ($packageDistTags."$intendedTag" -ne $intendedTagVersion) { $correctDistTags = $parsedOriginalDistTags $correctDistTags."$intendedTag" = $intendedTagVersion foreach($tag in $correctDistTags.PSObject.Properties) { - Write-Host "npm dist-tag add $packageName@$tag.value $tag.Name" + Write-Host "npm dist-tag add $packageName@$($tag.value) $tag.Name" npm dist-tag add $packageName@$tag.value $tag.Name } $npmPkgProp = npm view $packageName --json | ConvertFrom-Json From 93f2cfa3685dfd8d8bcc9ffe110561d1bf765ccb Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 5 Nov 2024 11:41:55 -0800 Subject: [PATCH 25/29] telem --- eng/pipelines/templates/steps/npm-release-task.yml | 5 +++++ eng/scripts/verify-npm-tags.ps1 | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 40d52a026635..982387c2fa50 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -22,6 +22,11 @@ steps: $originalTags = $packageProps.'dist-tags' | ConvertTo-Json -Compress echo "##vso[task.setvariable variable=OriginalTags]$originalTags echo "##vso[task.setvariable variable=IntendedTagVersion]$packageVersion + + Write-Host "PackageProps: $packageProps" + Write-Host "packageName: $packageName" + Write-Host "originalTags: $originalTags" + Write-Host "packageVersion: $packageVersion" displayName: Get original tags - task: EsrpRelease@7 diff --git a/eng/scripts/verify-npm-tags.ps1 b/eng/scripts/verify-npm-tags.ps1 index e9f1b875d368..09d87ca009a2 100644 --- a/eng/scripts/verify-npm-tags.ps1 +++ b/eng/scripts/verify-npm-tags.ps1 @@ -30,8 +30,13 @@ $npmPkgProp = npm view $packageName --json | ConvertFrom-Json $packageDistTags = $npmPkgProp."dist-tags" Write-Host "Current dist-tag: $packageDistTags" +Write-Host "parsedOriginalDistTags: $parsedOriginalDistTags" +Write-Host "packageDistTags: $packageDistTags" +Write-Host "intendedTag: $($packageDistTags."$intendedTag")" +Write-Host "intendedTagVersion: $intendedTagVersion" + if ($packageDistTags."$intendedTag" -ne $intendedTagVersion) { - Write-Warning "Tag not correctly set, current $intendedTag tag is version $packageDistTags.'$intendedTag' instead of $intendedTagVersion." + Write-Warning "Tag not correctly set, current $intendedTag tag is version $($packageDistTags."$intendedTag") instead of $intendedTagVersion." $correctDistTags = $parsedOriginalDistTags $correctDistTags."$intendedTag" = $intendedTagVersion foreach($tag in $correctDistTags.PSObject.Properties) { From cf0823200ddbbc21f87f0e01ecaaeca887a7e8ed Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 5 Nov 2024 15:42:17 -0800 Subject: [PATCH 26/29] quote --- eng/pipelines/templates/steps/npm-release-task.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 982387c2fa50..337f1b1b00db 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -20,9 +20,8 @@ steps: $packageVersion = $pkg.Version $packageProps = npm view $packageName -json | ConvertFrom-Json $originalTags = $packageProps.'dist-tags' | ConvertTo-Json -Compress - echo "##vso[task.setvariable variable=OriginalTags]$originalTags - echo "##vso[task.setvariable variable=IntendedTagVersion]$packageVersion - + echo "##vso[task.setvariable variable=OriginalTags]$originalTags" + echo "##vso[task.setvariable variable=IntendedTagVersion]$packageVersion" Write-Host "PackageProps: $packageProps" Write-Host "packageName: $packageName" Write-Host "originalTags: $originalTags" From 25812750a6fb2401fae2d3e001d66e4628ee9cb5 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 7 Nov 2024 03:12:47 -0800 Subject: [PATCH 27/29] json file path --- eng/pipelines/templates/steps/npm-release-task.yml | 6 ++++-- eng/scripts/verify-npm-tags.ps1 | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 337f1b1b00db..2ccc169e94f4 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -15,7 +15,9 @@ steps: $tempDir = "$(System.DefaultWorkingDirectory)/temp_decompress" New-Item -ItemType Directory -Force -Path $tempDir tar -xzf $tarFile -C $tempDir - $pkg = Get-Content -Raw "$tempDir\package\package.json" | ConvertFrom-Json + $packageJsonDir = "$tempDir\package\package.json" + echo "##vso[task.setvariable variable=PackageJsonDir]$packageJsonDir" + $pkg = Get-Content -Raw "$packageJsonDir"" | ConvertFrom-Json $packageName = $pkg.Name $packageVersion = $pkg.Version $packageProps = npm view $packageName -json | ConvertFrom-Json @@ -51,7 +53,7 @@ steps: inputs: targetType: filePath filePath: eng/scripts/verify-npm-tags.ps1 - arguments: -pathToArtifacts ${{parameters.PathToArtifacts}} -originalDistTags '$(OriginalTags)' -intendedTag ${{parameters.Tag}} -intendedTagVersion '$(IntendedTagVersion)' + arguments: -pathToArtifacts ${{parameters.PathToArtifacts}} -originalDistTags '$(OriginalTags)' -intendedTag ${{parameters.Tag}} -intendedTagVersion '$(IntendedTagVersion)' -packageJson $(PackageJsonDir) pwsh: true - ${{ if ne(parameters.AdditionalTag, '') }}: diff --git a/eng/scripts/verify-npm-tags.ps1 b/eng/scripts/verify-npm-tags.ps1 index 09d87ca009a2..ba0eeaa92c7d 100644 --- a/eng/scripts/verify-npm-tags.ps1 +++ b/eng/scripts/verify-npm-tags.ps1 @@ -6,7 +6,9 @@ param ( [Parameter(mandatory = $true)] $intendedTag, [Parameter(mandatory = $true)] - $intendedTagVersion + $intendedTagVersion, + [Parameter(mandatory = $true)] + $packageJson ) # TODO: delete testing comments below @@ -19,7 +21,7 @@ param ( $ErrorActionPreference = 'Stop' $PSNativeCommandUseErrorActionPreference = $true -$pkg = Get-Content -Raw "temp_decompress\package\package.json" | ConvertFrom-Json +$pkg = Get-Content -Raw $packageJson | ConvertFrom-Json $packageName = $pkg.Name Write-Host "Verify npm tag versions for package $packageName" From 7f8247e9cc2206ff010e2c76b7701eae9c1d7a03 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 7 Nov 2024 09:28:56 -0800 Subject: [PATCH 28/29] json file path --- eng/pipelines/templates/steps/npm-release-task.yml | 4 ++-- eng/scripts/verify-npm-tags.ps1 | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 2ccc169e94f4..7a780ca01707 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -17,7 +17,7 @@ steps: tar -xzf $tarFile -C $tempDir $packageJsonDir = "$tempDir\package\package.json" echo "##vso[task.setvariable variable=PackageJsonDir]$packageJsonDir" - $pkg = Get-Content -Raw "$packageJsonDir"" | ConvertFrom-Json + $pkg = Get-Content -Raw "$packageJsonDir" | ConvertFrom-Json $packageName = $pkg.Name $packageVersion = $pkg.Version $packageProps = npm view $packageName -json | ConvertFrom-Json @@ -53,7 +53,7 @@ steps: inputs: targetType: filePath filePath: eng/scripts/verify-npm-tags.ps1 - arguments: -pathToArtifacts ${{parameters.PathToArtifacts}} -originalDistTags '$(OriginalTags)' -intendedTag ${{parameters.Tag}} -intendedTagVersion '$(IntendedTagVersion)' -packageJson $(PackageJsonDir) + arguments: -originalDistTags '$(OriginalTags)' -intendedTag ${{parameters.Tag}} -intendedTagVersion '$(IntendedTagVersion)' -packageJson $(PackageJsonDir) pwsh: true - ${{ if ne(parameters.AdditionalTag, '') }}: diff --git a/eng/scripts/verify-npm-tags.ps1 b/eng/scripts/verify-npm-tags.ps1 index ba0eeaa92c7d..b05212bdec5a 100644 --- a/eng/scripts/verify-npm-tags.ps1 +++ b/eng/scripts/verify-npm-tags.ps1 @@ -1,6 +1,4 @@ param ( - [Parameter(mandatory = $true)] - $pathToArtifacts, [Parameter(mandatory = $true)] $originalDistTags, [Parameter(mandatory = $true)] From 45670de29eb544a0718b16e9a3240c9887415973 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 7 Nov 2024 10:32:23 -0800 Subject: [PATCH 29/29] cleanup --- eng/pipelines/templates/steps/npm-release-task.yml | 5 ----- eng/scripts/verify-npm-tags.ps1 | 14 +++++++------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/eng/pipelines/templates/steps/npm-release-task.yml b/eng/pipelines/templates/steps/npm-release-task.yml index 7a780ca01707..ba3f9adc6f5e 100644 --- a/eng/pipelines/templates/steps/npm-release-task.yml +++ b/eng/pipelines/templates/steps/npm-release-task.yml @@ -10,7 +10,6 @@ steps: - ${{ if eq(parameters.Registry, 'https://registry.npmjs.org/') }}: - pwsh: | - Set-PSDebug -Trace 1 $tarFile = (Get-ChildItem -Path "${{parameters.PathToArtifacts}}/*.tgz").FullName $tempDir = "$(System.DefaultWorkingDirectory)/temp_decompress" New-Item -ItemType Directory -Force -Path $tempDir @@ -24,10 +23,6 @@ steps: $originalTags = $packageProps.'dist-tags' | ConvertTo-Json -Compress echo "##vso[task.setvariable variable=OriginalTags]$originalTags" echo "##vso[task.setvariable variable=IntendedTagVersion]$packageVersion" - Write-Host "PackageProps: $packageProps" - Write-Host "packageName: $packageName" - Write-Host "originalTags: $originalTags" - Write-Host "packageVersion: $packageVersion" displayName: Get original tags - task: EsrpRelease@7 diff --git a/eng/scripts/verify-npm-tags.ps1 b/eng/scripts/verify-npm-tags.ps1 index b05212bdec5a..347c07c4dca7 100644 --- a/eng/scripts/verify-npm-tags.ps1 +++ b/eng/scripts/verify-npm-tags.ps1 @@ -28,22 +28,22 @@ $parsedOriginalDistTags = $originalDistTags | ConvertFrom-Json $npmPkgProp = npm view $packageName --json | ConvertFrom-Json $packageDistTags = $npmPkgProp."dist-tags" -Write-Host "Current dist-tag: $packageDistTags" -Write-Host "parsedOriginalDistTags: $parsedOriginalDistTags" -Write-Host "packageDistTags: $packageDistTags" -Write-Host "intendedTag: $($packageDistTags."$intendedTag")" -Write-Host "intendedTagVersion: $intendedTagVersion" +Write-Host "Original dist-tag: $parsedOriginalDistTags" +Write-Host "Current dist-tag: $packageDistTags" +Write-Host "Intend to add tag $intendedTag to version $intendedTagVersion" if ($packageDistTags."$intendedTag" -ne $intendedTagVersion) { Write-Warning "Tag not correctly set, current $intendedTag tag is version $($packageDistTags."$intendedTag") instead of $intendedTagVersion." $correctDistTags = $parsedOriginalDistTags $correctDistTags."$intendedTag" = $intendedTagVersion foreach($tag in $correctDistTags.PSObject.Properties) { - Write-Host "npm dist-tag add $packageName@$($tag.value) $tag.Name" - npm dist-tag add $packageName@$tag.value $tag.Name + Write-Host "npm dist-tag add $packageName@$($tag.value) $($tag.Name)" + npm dist-tag add $packageName@$($tag.value) $($tag.Name) } $npmPkgProp = npm view $packageName --json | ConvertFrom-Json $packageDistTags = $npmPkgProp."dist-tags" Write-Host "Corrected dist tags to: $packageDistTags" +} else { + Write-Host "Tag verified." }