Skip to content

Commit

Permalink
fix(ag-solo): reenable the ag-solo bundle command
Browse files Browse the repository at this point in the history
Closes #606

Usage: `ag-solo bundle <PATH TO DAPP>/deploy.js`
from within an ag-solo directory in order to run a deployment script.
  • Loading branch information
michaelfig committed Feb 29, 2020
1 parent 43ff0c1 commit 6126774
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/agoric-cli/template/contract/deploy-autoswap.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default async function deployContract(homeP, { bundleSource, pathResolve
CONTRACT_NAME = 'autoswap') {

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

// =====================
// === AWAITING TURN ===
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/template/contract/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default async function deployContract(homeP, { bundleSource, pathResolve
CONTRACT_NAME = 'myFirstDapp') {

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

// =====================
// === AWAITING TURN ===
Expand Down
39 changes: 21 additions & 18 deletions packages/cosmic-swingset/lib/ag-solo/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { makeCapTP } from '@agoric/captp/lib/captp';
import fs from 'fs';
import path from 'path';

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

const makePromise = () => {
const pr = {};
Expand All @@ -27,27 +27,27 @@ const sendJSON = (ws, obj) => {
};

export default async function bundle(insistIsBasedir, args) {
const { _: a, evaluate, input, once, output, 'ag-solo': agSolo } = parseArgs(
args,
{
boolean: ['once', 'evaluate', 'input'],
alias: { o: 'output', e: 'evaluate', i: 'input' },
stopEarly: true,
},
);
const {
_: a,
evaluate: evflag,
input,
once,
output,
'ag-solo': agSolo,
} = parseArgs(args, {
boolean: ['once', 'evaluate', 'input'],
alias: { o: 'output', e: 'evaluate', i: 'input' },
stopEarly: true,
});

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

const bundles = [];
if (input) {
const fileNames = a;
for (const fileName of fileNames) {
const contents = file.promises.readFile(fileName, 'utf-8');
const contents = fs.promises.readFile(fileName, 'utf-8');
bundles.push(JSON.parse(contents));
}
} else {
Expand All @@ -70,7 +70,8 @@ export default async function bundle(insistIsBasedir, args) {
}
const name = match[1];
const filepath = match[2];
bundled[name] = await buildSourceBundle(filepath);
bundled[name] = await bundleSource(filepath);
bundled[name].path = filepath;
}),
);
bundles.push(bundled);
Expand Down Expand Up @@ -145,7 +146,9 @@ export default async function bundle(insistIsBasedir, args) {
continue;
}

await main({ bundle: bundled, home: boot });
const pathResolve = (...resArgs) =>
path.resolve(path.dirname(bundled.main.path), ...resArgs);
await main(boot, { bundleSource, pathResolve });
}
console.error('Done!');
if (once) {
Expand Down

0 comments on commit 6126774

Please sign in to comment.