Skip to content

Commit

Permalink
WIP agoric-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Aug 12, 2021
1 parent 20c9935 commit a285e20
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion packages/agoric-cli/lib/deploy.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
/* global process setTimeout setInterval clearInterval */
/* eslint-disable no-await-in-loop */

import { E, makeCapTP } from '@agoric/captp';
import { makePromiseKit } from '@agoric/promise-kit';
import bundleSource from '@agoric/bundle-source';
import path from 'path';
import inquirer from 'inquirer';
import createRequire from 'esm';

import { getAccessToken } from '@agoric/access-token';

const require = createRequire({});

// note: CapTP has its own HandledPromise instantiation, and the contract
// must use the same one that CapTP uses. We achieve this by not bundling
// captp, and doing a (non-isolated) dynamic import of the deploy script
Expand Down Expand Up @@ -220,7 +224,11 @@ export { bootPlugin } from ${JSON.stringify(absPath)};
}

// use a dynamic import to load the deploy script, it is unconfined
const mainNS = await import(pathResolve(moduleFile));
// eslint-disable-next-line import/no-dynamic-require
const mainNS = require(moduleFile);
// TODO Node.js ESM support if package.json of template says "type":
// "module":
// const mainNS = await import(pathResolve(moduleFile));
const main = mainNS.default;
if (typeof main !== 'function') {
console.error(
Expand Down
3 changes: 2 additions & 1 deletion packages/agoric-cli/lib/entrypoint.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env -S node

/* global process */
// TODO Remove babel-standalone preinitialization
// TODO Remove babel-standalone and esm preinitialization
// https://github.com/endojs/endo/issues/768
import 'esm';
import '@agoric/babel-standalone';
import '@agoric/install-ses';

Expand Down
1 change: 1 addition & 0 deletions packages/agoric-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"chalk": "^2.4.2",
"commander": "^5.0.0",
"deterministic-json": "^1.0.5",
"esm": "agoric-labs/esm#Agoric-built",
"inquirer": "^6.3.1",
"opener": "^1.5.2",
"ws": "^7.2.0"
Expand Down

0 comments on commit a285e20

Please sign in to comment.