Skip to content

Commit 6126774

Browse files
committed
fix(ag-solo): reenable the ag-solo bundle command
Closes #606 Usage: `ag-solo bundle <PATH TO DAPP>/deploy.js` from within an ag-solo directory in order to run a deployment script.
1 parent 43ff0c1 commit 6126774

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

packages/agoric-cli/template/contract/deploy-autoswap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default async function deployContract(homeP, { bundleSource, pathResolve
1414
CONTRACT_NAME = 'autoswap') {
1515

1616
// Create a source bundle for the "myFirstDapp" smart contract.
17-
const { source, moduleFormat } = await bundleSource(`./${CONTRACT_NAME}.js`);
17+
const { source, moduleFormat } = await bundleSource(pathResolve(`./${CONTRACT_NAME}.js`));
1818

1919
// =====================
2020
// === AWAITING TURN ===

packages/agoric-cli/template/contract/deploy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default async function deployContract(homeP, { bundleSource, pathResolve
1414
CONTRACT_NAME = 'myFirstDapp') {
1515

1616
// Create a source bundle for the "myFirstDapp" smart contract.
17-
const { source, moduleFormat } = await bundleSource(`./${CONTRACT_NAME}.js`);
17+
const { source, moduleFormat } = await bundleSource(pathResolve(`./${CONTRACT_NAME}.js`));
1818

1919
// =====================
2020
// === AWAITING TURN ===

packages/cosmic-swingset/lib/ag-solo/bundle.js

+21-18
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { makeCapTP } from '@agoric/captp/lib/captp';
77
import fs from 'fs';
88
import path from 'path';
99

10-
import buildSourceBundle from '@agoric/bundle-source';
10+
import bundleSource from '@agoric/bundle-source';
1111

1212
const makePromise = () => {
1313
const pr = {};
@@ -27,27 +27,27 @@ const sendJSON = (ws, obj) => {
2727
};
2828

2929
export default async function bundle(insistIsBasedir, args) {
30-
const { _: a, evaluate, input, once, output, 'ag-solo': agSolo } = parseArgs(
31-
args,
32-
{
33-
boolean: ['once', 'evaluate', 'input'],
34-
alias: { o: 'output', e: 'evaluate', i: 'input' },
35-
stopEarly: true,
36-
},
37-
);
30+
const {
31+
_: a,
32+
evaluate: evflag,
33+
input,
34+
once,
35+
output,
36+
'ag-solo': agSolo,
37+
} = parseArgs(args, {
38+
boolean: ['once', 'evaluate', 'input'],
39+
alias: { o: 'output', e: 'evaluate', i: 'input' },
40+
stopEarly: true,
41+
});
3842

39-
if (!output && !evaluate) {
40-
console.error(
41-
`You must specify at least one of '--output' or '--evaluate'`,
42-
);
43-
return 1;
44-
}
43+
// Default to evaluate.
44+
const evaluate = evflag || !output;
4545

4646
const bundles = [];
4747
if (input) {
4848
const fileNames = a;
4949
for (const fileName of fileNames) {
50-
const contents = file.promises.readFile(fileName, 'utf-8');
50+
const contents = fs.promises.readFile(fileName, 'utf-8');
5151
bundles.push(JSON.parse(contents));
5252
}
5353
} else {
@@ -70,7 +70,8 @@ export default async function bundle(insistIsBasedir, args) {
7070
}
7171
const name = match[1];
7272
const filepath = match[2];
73-
bundled[name] = await buildSourceBundle(filepath);
73+
bundled[name] = await bundleSource(filepath);
74+
bundled[name].path = filepath;
7475
}),
7576
);
7677
bundles.push(bundled);
@@ -145,7 +146,9 @@ export default async function bundle(insistIsBasedir, args) {
145146
continue;
146147
}
147148

148-
await main({ bundle: bundled, home: boot });
149+
const pathResolve = (...resArgs) =>
150+
path.resolve(path.dirname(bundled.main.path), ...resArgs);
151+
await main(boot, { bundleSource, pathResolve });
149152
}
150153
console.error('Done!');
151154
if (once) {

0 commit comments

Comments
 (0)