Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to Yarn 4 and clean up some deps #99

Merged
merged 15 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: yarn install
run: yarn
- run: corepack enable
- run: yarn install
- name: yarn lint
run: yarn lint
- name: yarn build
Expand All @@ -33,15 +33,15 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: "18.18"
- name: yarn install
run: yarn
- run: corepack enable
- run: yarn install
- name: yarn start:docker
run: yarn start:docker
- name: yarn build
run: yarn build
- name: yarn start:contract
run: yarn start:contract

- name: Install linux deps
run: |
sudo apt-get install --no-install-recommends -y \
Expand All @@ -54,13 +54,13 @@ jobs:
fluxbox &
env:
DISPLAY: :0.0

- name: Run e2e tests
uses: cypress-io/github-action@248bde77443c376edc45906ede03a1aba9da0462
with:
start: npx serve ui/dist -p 5173
command: yarn test:e2e
wait-on: 'http://localhost:5173'
wait-on: "http://localhost:5173"
wait-on-timeout: 120
browser: chrome
env:
Expand All @@ -73,6 +73,6 @@ jobs:
with:
name: e2e-artifacts
path: |
ui/test/e2e/videos
ui/test/e2e/screenshots
continue-on-error: true
ui/test/e2e/videos
ui/test/e2e/screenshots
continue-on-error: true
12 changes: 9 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ dist-ssr
screenshots
videos

# Yarn related
.yarn/install-state.gz
# Yarn (https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored)
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# contract tx
contract/,tx.json
contract/,tx.json
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
2 changes: 1 addition & 1 deletion _agstate/agoric-servers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"author": "Agoric",
"license": "Apache-2.0",
"dependencies": {
"@agoric/cosmic-swingset": "^0.41.3"
"@agoric/cosmic-swingset": "^0.42.0-u16.2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't have to maintain _agstate like this. Marking this one as tech debt:

}
}
35 changes: 17 additions & 18 deletions contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,17 @@
"make:waitForBlocks": "make wait-for-blocks"
},
"devDependencies": {
"@agoric/deploy-script-support": "^0.10.4-u12.0",
"@agoric/eslint-config": "dev",
"@endo/bundle-source": "^2.8.0",
"@endo/eslint-plugin": "^0.5.2",
"@endo/init": "^0.5.60",
"@endo/promise-kit": "0.2.56",
"@endo/ses-ava": "^0.2.44",
"@jessie.js/eslint-plugin": "^0.4.0",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"agoric": "^0.21.2-u12.0",
"@agoric/deploy-script-support": "^0.10.4-u16.2",
"@agoric/eslint-config": "^0.4.1-u16.0",
"@endo/bundle-source": "^3.4.0",
"@endo/eslint-plugin": "^2.2.1",
"@endo/init": "^1.1.4",
"@endo/promise-kit": "^1.1.5",
"@endo/ses-ava": "^1.2.5",
"@jessie.js/eslint-plugin": "^0.4.1",
"agoric": "^0.22.0-u16.2",
"ava": "^5.3.0",
"eslint": "^8.47.0",
"eslint": "^8.57.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-jessie": "^0.0.6",
"eslint-config-prettier": "^9.0.0",
Expand All @@ -43,14 +41,15 @@
"prettier": "^3.0.3",
"prettier-plugin-jsdoc": "^1.0.0",
"type-coverage": "^2.26.3",
"typescript": "~5.2.2"
"typescript": "~5.2.2",
"typescript-eslint": "^7.13.1"
},
"dependencies": {
"@agoric/ertp": "^0.16.3-u12.0",
"@agoric/zoe": "^0.26.3-u12.0",
"@endo/far": "^0.2.22",
"@endo/marshal": "^0.8.9",
"@endo/patterns": "^0.2.5"
"@agoric/ertp": "^0.16.3-u16.1",
"@agoric/zoe": "^0.26.3-u16.1",
"@endo/far": "^1.1.5",
"@endo/marshal": "^1.5.3",
"@endo/patterns": "^1.4.3"
},
"ava": {
"files": [
Expand Down
2 changes: 2 additions & 0 deletions contract/src/offer-up.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ export const meta = {
{ maxItems: M.bigint() },
),
};
harden(meta);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this enforced by this change? if so, cool!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by the updated Endo lint config

// compatibility with an earlier contract metadata API
export const customTermsShape = meta.customTermsShape;
harden(customTermsShape);

/**
* Start a contract that
Expand Down
59 changes: 32 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,38 @@
"version": "0.1.0",
"license": "Apache-2.0",
"private": true,
"packageManager": "[email protected]",
"useWorkspaces": true,
"workspaces": [
"contract",
"ui"
],
"resolutions-note": "work-around for https://github.com/Agoric/agoric-sdk/issues/8621",
"resolutions": {
"ses": "1.3.0",
"@endo/bundle-source": "2.5.2-upstream-rollup",
"@endo/captp": "3.1.1",
Comment on lines 13 to -15
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 excellent!

Get rid of resolutions-note too, please?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this looked like the resolutions are gone, but they're just updated. I hope to obviate them eventually but didn't manage yet

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops. reading too fast.

"@endo/compartment-mapper": "0.8.4",
"@endo/far": "0.2.18",
"@endo/init": "0.5.56",
"@endo/marshal": "0.8.5",
"@endo/nat": "4.1.27",
"@endo/promise-kit": "0.2.56",
"@endo/lockdown": "0.1.28",
"@endo/import-bundle": "0.3.4",
"@endo/base64": "0.2.31",
"@endo/zip": "0.2.31",
"@endo/eventual-send": "0.17.2",
"@endo/patterns": "0.2.2",
"@endo/stream": "0.3.25",
"@endo/exo": "0.2.2",
"@endo/pass-style": "0.1.3",
"@endo/check-bundle": "0.2.18",
"@endo/ses-ava": "0.2.40",
"@endo/netstring": "0.3.26",
"@endo/stream-node": "0.2.26",
"agoric": "^0.22.0-u16.2",
"ses": "1.8.0",
"@agoric/notifier": "^0.7.0-u16.1",
"@endo/bundle-source": "^3.4.0",
"@endo/captp": "^4.3.0",
"@endo/compartment-mapper": "^1.2.2",
"@endo/far": "^1.1.5",
"@endo/init": "^1.1.4",
"@endo/marshal": "^1.5.3",
"@endo/nat": "^5.0.10",
"@endo/promise-kit": "^1.1.5",
"@endo/lockdown": "^1.0.10",
"@endo/import-bundle": "^1.2.2",
"@endo/base64": "^1.0.7",
"@endo/zip": "^1.0.7",
"@endo/eventual-send": "^1.2.5",
"@endo/patterns": "^1.4.3",
"@endo/stream": "^1.2.5",
"@endo/exo": "^1.5.3",
"@endo/pass-style": "^1.4.3",
"@endo/check-bundle": "^1.0.9",
"@endo/ses-ava": "^1.2.5",
"@endo/netstring": "^1.0.10",
"@endo/stream-node": "^1.1.5",
"@babel/code-frame": "7.18.6",
"@babel/highlight": "7.22.5"
},
Expand All @@ -43,12 +46,15 @@
"make:help": "make -C contract list",
"start:contract": "cd contract && yarn start",
"start:ui": "cd ui && yarn dev",
"lint": "yarn workspaces run lint",
"test": "yarn workspaces run test",
"lint": "yarn workspaces foreach --all run lint",
"test": "yarn workspaces foreach --all run test",
"test:e2e": "yarn workspace offer-up-ui test:e2e",
"build": "yarn workspaces run build",
"build": "yarn workspaces foreach --all run build",
"runWaitForBlocks": "cd contract && yarn make:waitForBlocks"
},
"dependencies": {
"eslint": "^8.57.0"
},
"devDependencies": {
"@agoric/synpress": "^3.8.1",
"eslint-config-turbo": "^1.13.0",
Expand All @@ -57,6 +63,5 @@
"eslint-plugin-testing-library": "^6.2.0",
"eslint-plugin-ui-testing": "^2.0.1",
"serve": "^14.2.1"
},
"dependencies": {}
}
}
85 changes: 85 additions & 0 deletions scripts/update-dependencies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env node
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Help me understand the workflow around this? How do I know when I should use it?

In general, if I want to yarn add foo, will I need this every time? or every time foo is @agoric/*? How about endo?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a note.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An entry in the scripts key of package.json would make it more discoverable, too. yarn fix-deps?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for now it's a "if you know you know" kind of tool. I think we need some design discussion around the UX to solve this problem consistently across repos. It should be something you can run with the agoric command or an npx so you don't need the script copied everywhere.

/** @file Utility to update dependencies through the repo to a specified tag
*
* Agoric and Endo repos each release in one go, but with their packages all at different versions.
* To find what packages all work together (that were in CI together at the same time) you
* can set all your deps to a particular NPM dist tag.
*
* e.g. `scripts/update-dependencies.js agoric agoric-upgrade-16`
*
* Endo doesn't have any dist tags other than the default, `latest`, which should should suffice.
*/
const fs = require("fs");
const path = require("path");
const glob = require("glob");
const { execSync } = require("child_process");

// Get the arguments: package name regex and npm tag
const [packageNameRegex, npmTag] = process.argv.slice(2);
if (!packageNameRegex || !npmTag) {
console.error(
'Usage: node update-dependencies.js "<package-regex>" <npm-tag>'
);
process.exit(1);
}

// Function to get the latest version of a package with the specified tag
const getLatestVersion = (packageName, tag) => {
try {
const result = execSync(`npm info ${packageName} dist-tags.${tag}`, {
encoding: "utf-8",
});
return result.trim();
} catch (error) {
console.error(
`Error fetching version for ${packageName} with tag ${tag}:`,
error.message
);
return null;
}
};

// Function to update dependencies in the package.json section
const updateDependencies = (dependencies, tag) => {
if (!dependencies) return;

for (const [packageName, currentVersion] of Object.entries(dependencies)) {
if (new RegExp(packageNameRegex).test(packageName)) {
const latestVersion = getLatestVersion(packageName, tag);
if (latestVersion) {
console.log(
`Updating ${packageName} from ${currentVersion} to ${latestVersion}`
);
dependencies[packageName] = `^${latestVersion}`;
}
}
}
};

// Find all package.json files in the workspace
glob("**/package.json", { ignore: "**/node_modules/**" }, (err, files) => {
if (err) {
console.error("Error finding package.json files:", err);
process.exit(1);
}

files.forEach((file) => {
const packageJsonPath = path.resolve(file);
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));

// Update dependencies, devDependencies, and resolutions
updateDependencies(packageJson.dependencies, npmTag);
updateDependencies(packageJson.devDependencies, npmTag);
updateDependencies(packageJson.resolutions, npmTag);

// Write the updated package.json back to the file, ensuring newline at the end
fs.writeFileSync(
packageJsonPath,
JSON.stringify(packageJson, null, 2) + "\n",
"utf-8"
);
console.log(`Updated dependencies in ${packageJsonPath}`);
});

console.log("Dependency update complete.");
});
20 changes: 7 additions & 13 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,30 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@agoric/eventual-send": "^0.14.1",
"@agoric/notifier": "^0.6.2",
"@agoric/rpc": "0.9.1-dev-f471a83.0",
"@agoric/store": "^0.9.2",
"@agoric/notifier": "^0.7.0-u16.1",
"@agoric/rpc": "0.10.0",
"@agoric/store": "^0.9.3-u16.0",
"@agoric/ui-components": "^0.9.0",
"@agoric/web-components": "^0.15.0",
"@agoric/web-components": "^0.16.0",
"@testing-library/react": "^14.1.2",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vitejs/plugin-react": "^4.0.3",
"eslint": "^8.45.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"happy-dom": "^13.3.1",
"prettier": "^3.2.4",
"puppeteer": "^21.9.0",
"ses": "1.3.0",
"ses": "^1.8.0",
"typescript": "^5.0.2",
"typescript-eslint": "^7.13.1",
"vite": "^4.4.5",
"vitest": "^1.2.1",
"zustand": "^4.4.1"
},
"resolutions": {
"**/ses": "^1.3.0",
"**/@agoric/xsnap": "0.14.3-dev-9f085d3.0"
},
"prettier": {
"trailingComma": "all",
"arrowParens": "avoid",
Expand Down
2 changes: 1 addition & 1 deletion ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const connectWallet = async () => {
const wallet = await makeAgoricWalletConnection(watcher, ENDPOINTS.RPC);
useAppStore.setState({ wallet });
const { pursesNotifier } = wallet;
for await (const purses of subscribeLatest(pursesNotifier)) {
for await (const purses of subscribeLatest<Purse[]>(pursesNotifier)) {
console.log('got purses', purses);
useAppStore.setState({ purses });
}
Expand Down
Loading
Loading