Skip to content

Commit

Permalink
fix: monorepo dependency issues - upgrade to yarn 3 (#2429)
Browse files Browse the repository at this point in the history
* chore: no longer build all apps for cli unit tests. Update stale yarn.lock.

* refactor: upgrade to yarn 3

* refactor: continue yarn 3 upgrade

* fix: upgrade to latest oclif release to it can handle yarn 3

* fix: change yarn flags in ci to match upgraded version. Handle date-fns major version changes to imports.

* fix: move yarn install to root. Shouldn't cause any problems besides being slower

* fix: try focus

* fix: missed a broken install

* fix: go for full install

* fix: move oclif to repo root for scripts

* fix: add script dependencies to root

* fix: not building greatly improved unit test times

* fix: attempt to speed up tests

* fix: account for yarn3 not running `yarn pretest` before `yarn test`

* fix: remove ignored yarn flag

* fix: use build from root

* fix: don't add beta releases to versions index in S3

* fix: revert unimplemented change

* fix: accommodate for GHA only passing strings, not bools.

* whitespace for version bump

* Revert "whitespace for version bump"

This reverts commit b5e88ab.

* fix: downgrade @oclif/plugin-plugins so legacy plugin installs work again

* fix: typo in beta cache invalidation
  • Loading branch information
ryandagg authored Aug 10, 2023
1 parent 76b3dc3 commit 0d7e5ca
Show file tree
Hide file tree
Showing 29 changed files with 18,472 additions and 12,477 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn --frozen-lockfile --network-timeout 1000000
- run: yarn --immutable --network-timeout 1000000
- run: yarn test

integration:
Expand All @@ -37,7 +37,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn --frozen-lockfile --network-timeout 1000000
- run: yarn --immutable --network-timeout 1000000
- run: yarn lerna run test:integration

acceptance:
Expand All @@ -57,7 +57,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn --frozen-lockfile --network-timeout 1000000
- run: yarn --immutable --network-timeout 1000000
- name: Build packages
run: yarn lerna run prepack
- run: ./bin/run whoami
Expand Down
15 changes: 3 additions & 12 deletions .github/workflows/pack-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ jobs:
sudo apt-get install -y nsis p7zip-full
- run: sudo mkdir -p /build
- name: Install package deps
run: |
cp yarn.lock packages/cli
cd packages/cli
yarn --frozen-lockfile --network-timeout 1000000
run: yarn --immutable --network-timeout 1000000
- name: Building deb
run: yarn oclif pack:deb --root="./packages/cli"
- uses: actions/upload-artifact@v3
Expand All @@ -40,10 +37,7 @@ jobs:
sudo apt-get install -y nsis p7zip-full
- run: sudo mkdir -p /build
- name: Install package deps
run: |
cp yarn.lock packages/cli
cd packages/cli
yarn --frozen-lockfile --network-timeout 1000000
run: yarn --immutable --network-timeout 1000000
- name: Building tarballs
run: yarn oclif pack tarballs --root="./packages/cli"
- uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -103,10 +97,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y awscli
- name: yarn install
run: |
cp yarn.lock packages/cli
cd packages/cli
yarn --frozen-lockfile --prefer-offline --network-timeout 1000000
run: yarn --immutable --network-timeout 1000000
- name: Upload production artifacts
run: |
cd packages/cli
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/promote-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: |
yarn --frozen-lockfile --network-timeout 1000000
yarn --immutable --network-timeout 1000000
./scripts/postrelease/change_management
4 changes: 2 additions & 2 deletions .github/workflows/promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
with:
node-version: 16.x
cache: yarn
- run: yarn --frozen-lockfile --network-timeout 1000000
- run: yarn --immutable --network-timeout 1000000
- name: install apt-get dependencies
run: |
sudo apt-get update
Expand All @@ -57,7 +57,7 @@ jobs:
# get SHA directly from NPM
SHA=$(npm view heroku@${{ inputs.version }} --json | jq -r '.gitHead[0:7]')
fi
yarn oclif promote --deb --xz --root="./packages/cli" --indexes --version=${{ inputs.version }} --sha="$SHA" --channel=${{ fromJSON(inputs.isStableRelease) && 'stable' || 'beta' }}
yarn oclif promote --deb --xz --root="./packages/cli" --sha="$SHA" ${{ fromJSON(inputs.isStableRelease) && '--indexes' || ''}} --version=${{ inputs.version }} --channel=${{ fromJSON(inputs.isStableRelease) && 'stable' || 'beta' }}
shell: bash
- name: promote Linux install scripts
run: node ./scripts/postrelease/install_scripts.js
2 changes: 1 addition & 1 deletion .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
node-version: 16.x
cache: yarn
- run: yarn --frozen-lockfile --network-timeout 1000000
- run: yarn --immutable --network-timeout 1000000
- name: set NPM auth
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_PUBLISH_KEY }}" > ~/.npmrc
- name: Publish to NPM
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/release-homebrew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y awscli
- name: yarn install
run: |
cp yarn.lock packages/cli
cd packages/cli
yarn --frozen-lockfile --network-timeout 1000000
run: yarn --immutable --network-timeout 1000000
- run: echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-7)" >> $GITHUB_ENV
- name: release homebrew
run: ./scripts/release/homebrew.js
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 16.x
- run: yarn --frozen-lockfile --network-timeout 1000000
- run: yarn --immutable --network-timeout 1000000
- run: yarn global add snyk
- run: snyk test --all-projects --fail-on=all
- run: snyk monitor --all-projects --org=hit
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ node_modules
.vscode
**/.nyc_output


.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
28 changes: 28 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

874 changes: 874 additions & 0 deletions .yarn/releases/yarn-3.6.1.cjs

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: .yarn/releases/yarn-3.6.1.cjs

# nmHoistingLimits setting prevents any node_modules from being hoisted to root. This prevents errors that only show up in built packages.
nmHoistingLimits: workspaces
15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
"eslint-config-oclif-typescript": "^1.0.2",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"execa": "5.1.1",
"lerna": "^6.4.1",
"mkdirp": "^0.5.2",
"oclif": "3.11.3",
"promise-request-retry": "^1.0.2",
"qqjs": "0.3.11",
"standard": "12.0.1",
"tmp": "^0.2.1"
},
Expand All @@ -28,9 +32,12 @@
"build": "lerna run prepack --concurrency 4",
"test": "lerna run test --concurrency 4",
"version": "cp packages/cli/CHANGELOG.md CHANGELOG.md && git add CHANGELOG.md",
"cleanNodeModules": "rm -rf ./packages/*/node_modules && rm -rf ./node_modules"
"cleanNodeModules": "rm -rf ./packages/*/node_modules && rm -rf ./node_modules && rm -rf ./.yarn/cache"
},
"workspaces": [
"packages/*"
]
"workspaces": {
"packages": [
"packages/*"
]
},
"packageManager": "[email protected]"
}
2 changes: 1 addition & 1 deletion packages/addons-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"mocha": "^5.2.0",
"nock": "9.0.13",
"nyc": "^15.1.0",
"oclif": "3.8.1",
"oclif": "3.11.3",
"proxyquire": "^2.1.0",
"sinon": "^6.3.5"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/apps-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"netrc-parser": "^3.1.6",
"nock": "^10.0.6",
"nyc": "^15.1.0",
"oclif": "3.8.1",
"oclif": "3.11.3",
"proxyquire": "^2.1.0",
"rimraf": "3.0.2",
"set-tz": "^0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/certs-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"mocha": "^5.2.0",
"nock": "^10.0.6",
"nyc": "^15.1.0",
"oclif": "3.8.1",
"oclif": "3.11.3",
"proxyquire": "^2.1.0",
"set-tz": "^0.1.0",
"sinon": "^2.3.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/ci-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"mocha": "^5.1.1",
"nock": "^10.0.6",
"nyc": "^15.1.0",
"oclif": "3.8.1",
"oclif": "3.11.3",
"sinon": "^1.17.6",
"std-mocks": "^1.0.1"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@oclif/plugin-help": "^5",
"@oclif/plugin-legacy": "^1.3.0",
"@oclif/plugin-not-found": "2.3.16",
"@oclif/plugin-plugins": "2.4.7",
"@oclif/plugin-plugins": "2.4.3",
"@oclif/plugin-update": "3.1.10",
"@oclif/plugin-version": "^1.2.1",
"@oclif/plugin-warn-if-update-available": "2.0.29",
Expand Down Expand Up @@ -96,7 +96,7 @@
"mocha": "^5.2.0",
"nock": "^10.0.6",
"nyc": "^15.1.0",
"oclif": "3.8.1",
"oclif": "3.11.3",
"open": "^8.4.2",
"proxyquire": "^2.1.0",
"qqjs": "0.3.11",
Expand Down Expand Up @@ -315,8 +315,8 @@
"build": "rm -rf lib && tsc",
"postpublish": "rm -f oclif.manifest.json",
"prepack": "yarn run build && oclif manifest",
"pretest": "lerna run prepack --concurrency 4 && tsc -p test --noEmit",
"test": "nyc mocha --forbid-only \"test/**/*.unit.test.ts\"",
"pretest": "tsc -p test --noEmit && cd ../.. && yarn build",
"test": "yarn pretest && nyc mocha --forbid-only \"test/**/*.unit.test.ts\"",
"test:acceptance": "mocha --forbid-only \"test/**/*.acceptance.test.ts\" && node ./bin/bats-test-runner",
"test:integration": "mocha --forbid-only \"test/**/*.integration.test.ts\"",
"test:smoke": "mocha --forbid-only \"test/**/smoke.acceptance.test.ts\"",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/status.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import color from '@heroku-cli/color'
import {Command, Flags, ux} from '@oclif/core'
import * as distanceInWordsToNow from 'date-fns/distance_in_words_to_now'
import {formatDistanceToNow} from 'date-fns'
import HTTP from 'http-call'

import {maxBy} from '../lib/status/util'
Expand Down Expand Up @@ -49,7 +49,7 @@ export default class Status extends Command {

const padding = maxBy(incident.updates, (i: any) => i.update_type.length).update_type.length + 0
for (const u of incident.updates) {
ux.log(`${color.yellow(u.update_type.padEnd(padding))} ${new Date(u.updated_at).toISOString()} (${distanceInWordsToNow(new Date(u.updated_at))} ago)`)
ux.log(`${color.yellow(u.update_type.padEnd(padding))} ${new Date(u.updated_at).toISOString()} (${formatDistanceToNow(new Date(u.updated_at))} ago)`)
ux.log(`${u.contents}\n`)
}
}
Expand Down
7 changes: 3 additions & 4 deletions packages/cli/src/lib/authorizations/authorizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import * as Heroku from '@heroku-cli/schema'
import {ux} from '@oclif/core'
import * as addSeconds from 'date-fns/add_seconds'
import * as distanceInWordsToNow from 'date-fns/distance_in_words_to_now'
import {formatDistanceToNow, addSeconds} from 'date-fns'

export function display(auth: Heroku.OAuthAuthorization) {
interface StyledObject {
Expand Down Expand Up @@ -32,12 +31,12 @@ export function display(auth: Heroku.OAuthAuthorization) {
if (auth.access_token) {
obj.Token = auth.access_token.token
if (auth.updated_at) {
obj['Updated at'] = `${addSeconds(auth.updated_at, 0)} (${distanceInWordsToNow(auth.updated_at)} ago)`
obj['Updated at'] = `${addSeconds(new Date(auth.updated_at), 0)} (${formatDistanceToNow(new Date(auth.updated_at))} ago)`
}

if (auth.access_token.expires_in) {
const date = addSeconds(new Date(), auth.access_token.expires_in)
obj['Expires at'] = `${date} (in ${distanceInWordsToNow(date)})`
obj['Expires at'] = `${date} (in ${formatDistanceToNow(date)})`
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {expect, test} from '@oclif/test'
import * as distanceInWordsToNow from 'date-fns/distance_in_words_to_now'

import {formatDistanceToNow} from 'date-fns'
describe('authorizations:info', () => {
const authorizationID = '4UTHOri24tIoN-iD-3X4mPl3'
const authorization = {
Expand Down Expand Up @@ -33,7 +32,7 @@ describe('authorizations:info', () => {
'Description: desc\n' +
'Scope: global\n' +
'Token: secrettoken\n' +
`Updated at: ${new Date(0)} (${distanceInWordsToNow(new Date(0))} ago)\n`,
`Updated at: ${new Date(0)} (${formatDistanceToNow(new Date(0))} ago)\n`,
)
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import * as Heroku from '@heroku-cli/schema'
import {expect, test} from '@oclif/test'
import * as addSeconds from 'date-fns/add_seconds'
import * as distanceInWordsToNow from 'date-fns/distance_in_words_to_now'

import {formatDistanceToNow, addSeconds} from 'date-fns'
import {display} from '../../../../src/lib/authorizations/authorizations'

const setupDisplay = (auth: Heroku.OAuthAuthorization) =>
Expand Down Expand Up @@ -59,11 +57,11 @@ describe('display', () => {

expect(ctx.stdout).to.contain(`ID: ${authId}\n`)
expect(ctx.stdout).to.contain(`Updated at: ${new Date(0)}`)
expect(ctx.stdout).to.contain(`(${distanceInWordsToNow(new Date(0))} ago)`)
expect(ctx.stdout).to.contain(`(${formatDistanceToNow(new Date(0))} ago)`)

const expirationDate = addSeconds(new Date(), 10000)
expect(ctx.stdout).to.contain(`Expires at: ${expirationDate}`)
expect(ctx.stdout).to.contain(`(in ${distanceInWordsToNow(expirationDate)})`)
expect(ctx.stdout).to.contain(`(in ${formatDistanceToNow(expirationDate)})`)
})
})

Expand Down
2 changes: 1 addition & 1 deletion packages/container-registry-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"mockdate": "^2.0.2",
"nock": "^10.0.6",
"nyc": "^15.1.0",
"oclif": "3.8.1",
"oclif": "3.11.3",
"sinon": "^5.0.7",
"std-mocks": "^1.0.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/orgs-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"mocha": "^5.2.0",
"nock": "^10.0.6",
"nyc": "^15.1.0",
"oclif": "3.8.1",
"oclif": "3.11.3",
"proxyquire": "^2.1.0",
"sinon": "^6.3.5"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/pg-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"mocha": "^5.1.1",
"nock": "^10.0.6",
"nyc": "^15.1.0",
"oclif": "3.8.1",
"oclif": "3.11.3",
"proxyquire": "^2.1.0",
"sinon": "^7.2.3",
"standard": "^12.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/redis-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"mocha": "^5.2.0",
"nock": "^10.0.6",
"nyc": "^15.1.0",
"oclif": "3.8.1",
"oclif": "3.11.3",
"proxyquire": "^2.1.0",
"sinon": "^7.2.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/run-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"netrc": "0.1.4",
"nock": "^10.0.6",
"nyc": "^15.1.0",
"oclif": "3.8.1",
"oclif": "3.11.3",
"sinon": "^7.2.3"
},
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/spaces/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"mocha": "^5.2.0",
"nock": "^10.0.6",
"nyc": "^15.1.0",
"oclif": "3.8.1",
"oclif": "3.11.3",
"sinon": "^7.2.3"
},
"files": [
Expand Down
2 changes: 1 addition & 1 deletion scripts/postrelease/invalidate_cdn_cache
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
invalidationResponse=''
if [[ "$GITHUB_REF_TYPE" == "tag" && "$GITHUB_REF_NAME" = v* ]]; then
invalidationResponse=$(aws cloudfront create-invalidation --distribution-id "$CLOUDFRONT_DISTRIBUTION" --paths "/*")
elif [[ "$CURRENT_BRANCH" == "prerelease-"* ]]; then
elif [[ "$CURRENT_BRANCH" == "prerelease/"* ]]; then
invalidationResponse=$(aws cloudfront create-invalidation --distribution-id "$CLOUDFRONT_DISTRIBUTION" --paths "/channels/beta/*")
else
echo "Not on stable or beta release, skipping invalidate cdn cache"
Expand Down
Loading

0 comments on commit 0d7e5ca

Please sign in to comment.