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

allow .ts for package exports #10495

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@google-cloud/monitoring": "^4.1.0",
"@jessie.js/eslint-plugin": "^0.4.1",
"@types/express": "^4.17.17",
"@types/node": "^22.0.0",
"@types/node": "^22.9.0",
"ava": "^5.3.0",
"c8": "^9.1.0",
"conventional-changelog-conventionalcommits": "^4.6.0",
Expand All @@ -36,7 +36,7 @@
"type-coverage": "^2.27.1",
"typedoc": "^0.26.7",
"typedoc-plugin-markdown": "^4.2.1",
"typescript": "^5.6.2",
"typescript": "~5.7.1-rc",
"typescript-eslint": "^7.18.0"
},
"resolutions": {
Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"devDependencies": {
"@agoric/swingset-vat": "^0.32.2",
"@endo/bundle-source": "^3.4.2",
"@endo/bundle-source": "^3.5.0",
"@fast-check/ava": "^1.1.5",
"ava": "^5.3.0",
"tsd": "^0.31.1"
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
"@agoric/vat-data": "^0.5.2",
"@agoric/xsnap-lockdown": "^0.14.0",
"@endo/base64": "^1.0.8",
"@endo/bundle-source": "^3.4.2",
"@endo/bundle-source": "^3.5.0",
"@endo/captp": "^4.4.2",
"@endo/check-bundle": "^1.0.11",
"@endo/compartment-mapper": "^1.3.1",
"@endo/compartment-mapper": "^1.4.0",
"@endo/eventual-send": "^1.2.7",
"@endo/far": "^1.1.8",
"@endo/import-bundle": "^1.3.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/agoric-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
"@cosmjs/math": "^0.32.3",
"@cosmjs/proto-signing": "^0.32.3",
"@cosmjs/stargate": "^0.32.3",
"@endo/bundle-source": "^3.4.2",
"@endo/bundle-source": "^3.5.0",
"@endo/captp": "^4.4.2",
"@endo/compartment-mapper": "^1.3.1",
"@endo/compartment-mapper": "^1.4.0",
"@endo/env-options": "^1.1.7",
"@endo/far": "^1.1.8",
"@endo/init": "^1.1.6",
Expand Down
4 changes: 2 additions & 2 deletions packages/boot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@agoric/vow": "^0.1.0",
"@agoric/zoe": "^0.26.2",
"@agoric/zone": "^0.2.2",
"@endo/bundle-source": "^3.4.2",
"@endo/bundle-source": "^3.5.0",
"@endo/captp": "^4.4.2",
"@endo/eventual-send": "^1.2.7",
"@endo/far": "^1.1.8",
Expand All @@ -59,7 +59,7 @@
"@endo/patterns": "^1.4.6",
"ava": "^5.3.0",
"c8": "^9.1.0",
"ts-blank-space": "^0.4.1"
"ts-blank-space": "^0.4.3"
},
"files": [
"CHANGELOG.md",
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@agoric/vat-data": "^0.5.2",
"@agoric/vats": "^0.15.1",
"@agoric/zoe": "^0.26.2",
"@endo/bundle-source": "^3.4.2",
"@endo/bundle-source": "^3.5.0",
"@endo/captp": "^4.4.2",
"@endo/eventual-send": "^1.2.7",
"@endo/far": "^1.1.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/client-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"devDependencies": {
"ava": "^5.3.0",
"c8": "^9.1.0",
"ts-blank-space": "^0.4.1"
"ts-blank-space": "^0.4.3"
},
"dependencies": {
"@agoric/casting": "^0.4.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/cosmic-proto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@
"@agoric/cosmos": "^0.34.1",
"@ava/typescript": "^4.1.0",
"@cosmology/telescope": "https://gitpkg.vercel.app/agoric-labs/telescope/packages/telescope?8d2c2f6ba637a5578eead09a7368dc41c262a9d0",
"@endo/bundle-source": "^3.4.2",
"@endo/bundle-source": "^3.5.0",
"@endo/import-bundle": "^1.3.1",
"ava": "^5.3.1",
"rimraf": "^5.0.0",
"tsd": "^0.31.1",
"tsimp": "^2.0.11",
"typescript": "~5.6.2"
"typescript": "~5.7.1-rc"
},
"dependencies": {
"@endo/base64": "^1.0.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@agoric/swingset-vat": "^0.32.2",
"@agoric/telemetry": "^0.6.2",
"@agoric/vm-config": "^0.1.0",
"@endo/bundle-source": "^3.4.2",
"@endo/bundle-source": "^3.5.0",
"@endo/env-options": "^1.1.7",
"@endo/errors": "^1.2.7",
"@endo/import-bundle": "^1.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/deploy-script-support/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@agoric/time": "^0.3.2",
"@agoric/zoe": "^0.26.2",
"@endo/base64": "^1.0.8",
"@endo/bundle-source": "^3.4.2",
"@endo/bundle-source": "^3.5.0",
"@endo/far": "^1.1.8",
"@endo/marshal": "^1.6.1",
"@endo/nat": "^5.0.12",
Expand Down
9 changes: 5 additions & 4 deletions packages/fast-usdc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"@fast-check/ava": "^2.0.1",
"ava": "^5.3.0",
"c8": "^9.1.0",
"ts-blank-space": "^0.4.1"
"execa": "^9.5.1",
"ts-blank-space": "^0.4.3"
},
"dependencies": {
"@agoric/client-utils": "^0.1.0",
Expand All @@ -39,18 +40,18 @@
"@agoric/store": "^0.9.2",
"@agoric/vow": "^0.1.0",
"@agoric/zoe": "^0.26.2",
"@cosmjs/proto-signing": "^0.32.4",
"@cosmjs/stargate": "^0.32.4",
"@endo/base64": "^1.0.8",
"@endo/common": "^1.2.7",
"@endo/errors": "^1.2.7",
"@endo/eventual-send": "^1.2.7",
"@endo/far": "^1.1.8",
"@endo/init": "^1.1.6",
"@endo/marshal": "^1.6.1",
"@endo/pass-style": "^1.4.6",
"@endo/patterns": "^1.4.6",
"@endo/promise-kit": "^1.1.7",
"@cosmjs/proto-signing": "^0.32.4",
"@cosmjs/stargate": "^0.32.4",
"@endo/init": "^1.1.6",
"@nick134-bit/noblejs": "0.0.2",
"agoric": "^0.21.1",
"bech32": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/fast-usdc/src/cli/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
#!/usr/bin/env -S TS_BLANK_SPACE_EMIT=false node --import ts-blank-space/register
import '@endo/init/legacy.js';
import { initProgram } from './cli.js';

Expand Down
111 changes: 30 additions & 81 deletions packages/fast-usdc/test/cli/cli.test.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,22 @@
import '@endo/init/legacy.js';
import test from 'ava';
import { spawn } from 'child_process';
import { execa } from 'execa';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
import { initProgram } from '../../src/cli/cli.js';

const dir = dirname(fileURLToPath(import.meta.url));
const CLI_PATH = join(dir, '../../src/cli/index.js');

const collectStdErr = (cmd: string[]) =>
new Promise(resolve => {
const child = spawn('node', cmd);
let stderr = '';

child.stderr.on('data', data => {
stderr += data.toString();
});

child.on('close', () => {
resolve(stderr);
});
});

const collectStdOut = (cmd: string[]) =>
new Promise(resolve => {
const child = spawn('node', cmd);
let stdout = '';

child.stdout.on('data', data => {
stdout += data.toString();
});

child.on('close', () => {
resolve(stdout);
});
});
const runCli = async (args: string[]) => {
await null;
try {
const { stdout } = await execa(CLI_PATH, args);
return stdout;
} catch (error: any) {
return error.stderr || error.stdout || error.message;
}
};

const mockConfig = () => {
let initArgs: any[];
Expand Down Expand Up @@ -67,155 +49,122 @@ const mockTransfer = () => {
};

test('shows help when run without arguments', async t => {
const output = await collectStdErr([CLI_PATH]);
const output = await runCli([]);
// Replace home path (e.g. "/home/samsiegart/.fast-usdc") with "~/.fast-usdc" so snapshots work on different machines.
const regex = /"\/(.+\/)?\.fast-usdc\/"/g;
const result = (output as string).replace(regex, '"~/.fast-usdc"');
const result = output.replace(regex, '"~/.fast-usdc"');

t.snapshot(result);
});

test('shows help for transfer command', async t => {
const output = await collectStdOut([CLI_PATH, 'transfer', '-h']);

const output = await runCli(['transfer', '-h']);
t.snapshot(output);
});

test('shows help for config command', async t => {
const output = await collectStdOut([CLI_PATH, 'config', '-h']);

const output = await runCli(['config', '-h']);
t.snapshot(output);
});

test('shows help for config init command', async t => {
const output = await collectStdOut([CLI_PATH, 'config', 'init', '-h']);

const output = await runCli(['config', 'init', '-h']);
t.snapshot(output);
});

test('shows help for config update command', async t => {
const output = await collectStdOut([CLI_PATH, 'config', 'update', '-h']);

const output = await runCli(['config', 'update', '-h']);
t.snapshot(output);
});

test('shows help for config show command', async t => {
const output = await collectStdOut([CLI_PATH, 'config', 'show', '-h']);

const output = await runCli(['config', 'show', '-h']);
t.snapshot(output);
});

test('shows help for deposit command', async t => {
const output = await collectStdOut([CLI_PATH, 'deposit', '-h']);

const output = await runCli(['deposit', '-h']);
t.snapshot(output);
});

test('shows help for withdraw command', async t => {
const output = await collectStdOut([CLI_PATH, 'withdraw', '-h']);

const output = await runCli(['withdraw', '-h']);
t.snapshot(output);
});

test('shows error when deposit command is run without options', async t => {
const output = await collectStdErr([CLI_PATH, 'deposit']);

const output = await runCli(['deposit']);
t.snapshot(output);
});

test('shows error when deposit command is run with invalid amount', async t => {
const output = await collectStdErr([CLI_PATH, 'deposit', 'not-a-number']);

const output = await runCli(['deposit', 'not-a-number']);
t.snapshot(output);
});

test('shows error when deposit command is run with invalid fee', async t => {
const output = await collectStdErr([
CLI_PATH,
'deposit',
'50',
'--fee',
'not-a-number',
]);

const output = await runCli(['deposit', '50', '--fee', 'not-a-number']);
t.snapshot(output);
});

test('shows error when withdraw command is run without options', async t => {
const output = await collectStdErr([CLI_PATH, 'withdraw']);

const output = await runCli(['withdraw']);
t.snapshot(output);
});

test('shows error when withdraw command is run with invalid amount', async t => {
const output = await collectStdErr([CLI_PATH, 'withdraw', 'not-a-number']);

const output = await runCli(['withdraw', 'not-a-number']);
t.snapshot(output);
});

test('shows error when withdraw command is run with invalid fee', async t => {
const output = await collectStdErr([
CLI_PATH,
'withdraw',
'50',
'--fee',
'not-a-number',
]);

const output = await runCli(['withdraw', '50', '--fee', 'not-a-number']);
t.snapshot(output);
});

test('shows error when config init command is run without options', async t => {
const output = await collectStdErr([CLI_PATH, 'config', 'init']);

const output = await runCli(['config', 'init']);
t.snapshot(output);
});

test('shows error when transfer command is run without options', async t => {
const output = await collectStdErr([CLI_PATH, 'transfer']);

const output = await runCli(['transfer']);
t.snapshot(output);
});

test('shows error when config init command is run without eth seed', async t => {
const output = await collectStdErr([
CLI_PATH,
const output = await runCli([
'config',
'init',
'--noble-seed',
'foo',
'--agoric-seed',
'bar',
]);

t.snapshot(output);
});

test('shows error when config init command is run without agoric seed', async t => {
const output = await collectStdErr([
CLI_PATH,
const output = await runCli([
'config',
'init',
'--noble-seed',
'foo',
'--eth-seed',
'bar',
]);

t.snapshot(output);
});

test('shows error when config init command is run without noble seed', async t => {
const output = await collectStdErr([
CLI_PATH,
const output = await runCli([
'config',
'init',
'--agoric-seed',
'foo',
'--eth-seed',
'bar',
]);

t.snapshot(output);
});

Expand Down
Loading
Loading