Skip to content

Commit

Permalink
refactor(telemetry-generator): Use pnpm (#23327)
Browse files Browse the repository at this point in the history
## Description

Telemetry-generator was the last bit of the repo still using `npm`
instead of `pnpm`. This fixes that and updates all places where we use
it to reflect the change.

Took the chance to update its dependencies to more recent versions,
syncing some (e.g. typescript) with the version we use in the client
release group.
  • Loading branch information
alexvy86 authored Dec 16, 2024
1 parent 489c5cc commit 35e9227
Show file tree
Hide file tree
Showing 12 changed files with 3,808 additions and 5,962 deletions.
6 changes: 0 additions & 6 deletions fluidBuild.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,6 @@ module.exports = {
],
// Exclusion per handler
handlerExclusions: {
"extraneous-lockfiles": [
"tools/telemetry-generator/package-lock.json", // Workaround to allow version 2 while we move it to pnpm
],
"fluid-build-tasks-eslint": [
// eslint doesn't really depend on build. Doing so just slows down a package build.
"^packages/test/snapshots/package.json",
Expand Down Expand Up @@ -374,9 +371,6 @@ module.exports = {
// The root package.json is not checked temporarily due to AB#8640
"^package.json",
],
"package-lockfiles-npm-version": [
"tools/telemetry-generator/package-lock.json", // Workaround to allow version 2 while we move it to pnpm
],
"npm-package-json-prettier": [
// This rule is temporarily disabled for all projects while we update the repo to use different formatting
".*",
Expand Down
38 changes: 28 additions & 10 deletions tools/pipelines/templates/include-telemetry-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ steps:
- checkout: self
clean: true

- template: include-use-node-version.yml
- template: /tools/pipelines/templates/include-use-node-version.yml@self

- template: include-install-pnpm.yml
parameters:
buildDirectory: ${{ parameters.pathToTelemetryGenerator }}

- task: Bash@3
displayName: Print parameter/variable values for template
Expand Down Expand Up @@ -63,6 +67,12 @@ steps:
npm init --yes
echo Generating .npmrc
echo "engine-strict=true" >> ./.npmrc
echo "frozen-lockfile=true" >> ./.npmrc
echo "strict-peer-dependencies=true" >> ./.npmrc
echo "# Don't use new lockfile format because component governance does not yet support it" >> ./.npmrc
echo "use-lockfile-v6=false" >> ./.npmrc
echo "registry=https://registry.npmjs.org" >> ./.npmrc
echo "always-auth=false" >> ./.npmrc
Expand All @@ -83,23 +93,31 @@ steps:
inputs:
workingFile: ${{ parameters.pathToTelemetryGenerator }}/.npmrc

# Install logger package
- task: Npm@1
displayName: 'npm install aria logger'
- task: Bash@3
displayName: 'Install dependencies for telemetry-generator'
retryCountOnTaskFailure: 1
inputs:
workingDir: ${{ parameters.pathToTelemetryGenerator }}
targetType: 'inline'
workingDirectory: ${{ parameters.pathToTelemetryGenerator }}
script: |
set -eu -o pipefail
pnpm i;
- task: Npm@1
displayName: 'Build telemetry-generator'
inputs:
command: 'custom'
customCommand: 'install @ff-internal/aria-logger'
customRegistry: 'useNpmrc'
workingDir: ${{ parameters.pathToTelemetryGenerator }}
customCommand: run build:compile

- task: Bash@3
displayName: 'Prepare telemetry-generator'
displayName: 'Install aria-logger'
retryCountOnTaskFailure: 1
inputs:
targetType: 'inline'
workingDirectory: ${{ parameters.pathToTelemetryGenerator }}
script: |
set -eu -o pipefail
npm i;
npm run build:compile;
# The telemetry-generator package is the root of its workspace so we do want to install this for the workspace
# root with '-w'. Without it, the install will complain and fail.
pnpm install -w @ff-internal/aria-logger;
12 changes: 12 additions & 0 deletions tools/telemetry-generator/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,16 @@ module.exports = {
// This package is exclusively used in a Node.js context
"import/no-nodejs-modules": "off",
},
overrides: [
{
// Rules only for test files
files: ["*.spec.ts", "src/test/**"],
rules: {
// TODO: AB#26776 - See if we can use imports instead. Disabling for now.
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-var-requires": "off",
"import/no-internal-modules": "off",
},
},
],
};
8 changes: 8 additions & 0 deletions tools/telemetry-generator/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
engine-strict=true
frozen-lockfile=true
strict-peer-dependencies=true

# Disable pnpm update notifications since we use corepack to install package managers
update-notifier=false
# Don't use new lockfile format because component governance does not yet support it
use-lockfile-v6=false
2 changes: 1 addition & 1 deletion tools/telemetry-generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ to process the output of our performance tests and write relevant metrics to our
Install dependencies and build the project:

```bash
npm i
pnpm i
npm run build
```

Expand Down
Loading

0 comments on commit 35e9227

Please sign in to comment.