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

fewer packageManager assumptions #11012

Merged
merged 8 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion a3p-integration/scripts/build-submission.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ shift || true
sdkroot=$(git rev-parse --show-toplevel)
(
cd "$sdkroot"
yarn agoric run --verbose "packages/builders/scripts/$builderScript" "$@"
npm exec agoric run -- --verbose "packages/builders/scripts/$builderScript" "$@"
)

# Create and populate the submission directory.
Expand Down
1 change: 0 additions & 1 deletion golang/cosmos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"engines": {
"node": "^18.12 || ^20.9"
},
"packageManager": "[email protected]",
"scripts": {
"test": "exit 0",
"build:all": "make",
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
},
"scripts": {
"clean": "yarn lerna run --no-bail clean",
"check-dependencies": "node ./scripts/check-mismatched-dependencies.cjs",
"docs": "run-s docs:build docs:update-functions-path",
"docs:build": "typedoc --tsconfig tsconfig.build.json",
"docs:markdown-for-agoric-documentation-repo": "run-s docs:markdown-build 'docs:update-functions-path md'",
Expand Down
35 changes: 10 additions & 25 deletions packages/agoric-cli/scripts/get-sdk-package-names.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,19 @@
#! /usr/bin/env node
// @ts-check
/* eslint-env node */
import { spawn } from 'child_process';
import { execFileSync } from 'child_process';
import { basename } from 'path';
import { listWorkspaces } from '../src/lib/packageManager.js';

const ps = spawn('yarn', ['workspaces', '--silent', 'info'], {
stdio: ['ignore', 'pipe', 'inherit'],
shell: true,
});
const workspaces = listWorkspaces({ execFileSync });

// Get Buffers of output.
const chunks = [];
ps.stdout.on('data', data => chunks.push(data));
const packageNames = workspaces.map(w => w.name);

// Wait for the process to exit.
ps.on('close', code => {
if (code !== 0) {
throw Error(`yarn info exited with code ${code}`);
}

// Get the output.
const json = Buffer.concat(chunks).toString('utf8');
// process.stderr.write(json);

// Write the module.
const workspaces = Object.keys(JSON.parse(json)).sort();
process.stdout.write(`\
// Write the module.
process.stdout.write(`\
// DO NOT EDIT - automatically generated by ${basename(
new URL(import.meta.url).pathname,
)}
new URL(import.meta.url).pathname,
)}
// prettier-ignore
export default ${JSON.stringify(workspaces, null, 2)};
export default ${JSON.stringify(packageNames.sort(), null, 2)};
`);
});
14 changes: 3 additions & 11 deletions packages/agoric-cli/src/install.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* eslint-env node */
import path from 'path';
import chalk from 'chalk';
import { execFileSync } from 'child_process';
import { makePspawn } from './helpers.js';
import DEFAULT_SDK_PACKAGE_NAMES from './sdk-package-names.js';
import { listWorkspaces } from './lib/packageManager.js';

const REQUIRED_AGORIC_START_PACKAGES = [
'@agoric/solo',
Expand Down Expand Up @@ -30,17 +32,7 @@ export default async function installMain(progname, rawArgs, powers, opts) {
const rimraf = file => pspawn('rm', ['-rf', file]);

async function getWorktreePackagePaths(cwd = '.', map = new Map()) {
// run `yarn workspaces info` to get the list of directories to
// use, instead of a hard-coded list
const p = pspawn('yarn', ['workspaces', '--silent', 'info'], {
cwd,
stdio: ['inherit', 'pipe', 'inherit'],
});
const stdout = [];
p.childProcess.stdout?.on('data', out => stdout.push(out));
await p;
const d = JSON.parse(Buffer.concat(stdout).toString('utf-8'));
for (const [name, { location }] of Object.entries(d)) {
for (const { name, location } of listWorkspaces({ execFileSync })) {
map.set(name, path.resolve(cwd, location));
}
return map;
Expand Down
22 changes: 22 additions & 0 deletions packages/agoric-cli/src/lib/packageManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// @ts-check

/**
* @import { execFileSync } from 'child_process';
*/

/**
* Omits the root
*
* @param {{ execFileSync: execFileSync }} io
* @returns {Array<{ location: string, name: string }>}
*/
export const listWorkspaces = ({ execFileSync }) => {
const out = execFileSync('npm', ['query', '.workspace'], {
stdio: ['ignore', 'pipe', 'inherit'],
shell: true,
encoding: 'utf-8',
});
/** @type {Array<{ location: string, name: string, description: string }>} */
const result = JSON.parse(out);
return result.filter(({ location }) => location !== '.');
};
18 changes: 18 additions & 0 deletions packages/agoric-cli/test/helpers.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** @file the `helpers` module is exported to test its API */

import '@endo/init/debug.js';

import test from 'ava';

import { getSDKBinaries } from '../src/helpers.js';

test('getSDKBinaries', t => {
const binaries = getSDKBinaries();
t.log(binaries);
t.is(typeof binaries.agSolo, 'string');
t.is(typeof binaries.agSoloBuild, 'object');
t.is(typeof binaries.cosmosChain, 'string');
t.is(typeof binaries.cosmosChainBuild, 'object');
t.is(typeof binaries.cosmosClientBuild, 'object');
t.is(typeof binaries.cosmosHelper, 'string');
});
10 changes: 5 additions & 5 deletions packages/boot/tools/supports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ import { icaMocks, protoMsgMockMap, protoMsgMocks } from './ibc/mocks.js';

const trace = makeTracer('BSTSupport', false);

const cliEntrypoint = new URL(
importMetaResolve('agoric/src/entrypoint.js', import.meta.url),
).pathname;

type ConsumeBootrapItem = <N extends string>(
name: N,
) => N extends keyof FastUSDCCorePowers['consume']
Expand Down Expand Up @@ -176,12 +180,8 @@ export const makeProposalExtractor = ({ childProcess, fs }: Powers) => {
cliArgs: string[] = [],
) => {
console.info('running package script:', scriptPath);
const out = childProcess.execFileSync('yarn', ['bin', 'agoric'], {
cwd: outputDir,
env,
});
return childProcess.execFileSync(
out.toString().trim(),
cliEntrypoint,
['run', scriptPath, ...cliArgs],
{
cwd: outputDir,
Expand Down
34 changes: 0 additions & 34 deletions scripts/check-mismatched-dependencies.cjs

This file was deleted.

10 changes: 2 additions & 8 deletions scripts/check-untested-packages.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@
import fs from 'fs';
import path from 'path';
import { execFileSync } from 'child_process';
import { listWorkspaces } from '../packages/agoric-cli/src/lib/packageManager.js';

const parent = new URL('..', import.meta.url).pathname;
const yarnCmd = ['yarn', '--silent', 'workspaces', 'info'];
console.log('Getting', yarnCmd.join(' '));
const workspacesInfo = execFileSync(yarnCmd[0], yarnCmd.slice(1), {
cwd: parent,
encoding: 'utf8',
});
const workspacesInfoJson = JSON.parse(workspacesInfo);

const testYaml = path.resolve(
parent,
Expand All @@ -22,7 +16,7 @@ const testYamlContent = fs.readFileSync(testYaml, 'utf-8');

console.log('Searching for "cd <location> && yarn test"...');
let status = 0;
for (const [pkg, { location }] of Object.entries(workspacesInfoJson)) {
for (const { name: pkg, location } of listWorkspaces({ execFileSync })) {
const cmd = `cd ${location} && yarn \${{ steps.vars.outputs.test }}`;
if (!testYamlContent.includes(cmd)) {
console.error(`Cannot find ${location} (${pkg})`);
Expand Down
Empty file modified scripts/run-deployment-integration.sh
100644 → 100755
Empty file.
Empty file modified scripts/update-typedoc-functions-path.cjs
100644 → 100755
Empty file.
Loading