Skip to content

Commit

Permalink
feat(init): more templates
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Nov 2, 2019
1 parent b8069f9 commit 2d19210
Show file tree
Hide file tree
Showing 31 changed files with 14,167 additions and 22 deletions.
21 changes: 11 additions & 10 deletions lib/init.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import parseArgs from 'minimist';
import fs from 'fs';
import path from 'path';

import templateMain from './template';
import chalk from 'chalk';

export default async function initMain(progname, rawArgs, priv) {
const { console, error } = priv;
Expand Down Expand Up @@ -31,6 +29,9 @@ export default async function initMain(progname, rawArgs, priv) {
const cur = `${templateDir}${suffix}`;
const list = await readdir(cur);
await Promise.all(list.map(async name => {
if (name === 'node_modules') {
return;
}
const stem = `${suffix}/${name}`;
const st = await lstat(`${templateDir}${stem}`);
let target;
Expand All @@ -52,14 +53,12 @@ export default async function initMain(progname, rawArgs, priv) {
};
await recursiveTemplate(templateDir);

const agservers = path.join(DIR, '.agservers');
await mkdir(agservers);

const solo = path.join(agservers, 'solo');
const chain = path.join(agservers, 'chain');
const agservers = `${DIR}/.agservers`;
const solo = `${agservers}/solo`;
const chain = `${agservers}/chain`;
await Promise.all([mkdir(solo), mkdir(chain)]);
const chainSolo = path.join(chain, 'solo');
const chainCosmos = path.join(chain, 'cosmos');
const chainSolo = `${chain}/solo`;
const chainCosmos = `${chain}/cosmos`;
await Promise.all([mkdir(chainSolo), mkdir(chainCosmos)]);

// Create links to all the solo nodes' html directories.
Expand All @@ -72,4 +71,6 @@ export default async function initMain(progname, rawArgs, priv) {
symlink('../../../ui/build', `${chainSolo}/dapp-html`),
symlink('../../ui/build', `${solo}/dapp-html`),
]);

console.log(chalk.bold.yellow(`Done initializing; you should 'cd ${DIR} && ${progname} install'`));
}
18 changes: 16 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import chalk from 'chalk';
import parseArgs from 'minimist';
import fs from 'fs';
import { insist } from '../../ertp/util/insist';

const VERSION = 'Agoric 0.1.0';
const STAMP = '.agservers';

const main = async (progname, rawArgs, privs) => {
const { console, error } = privs;
Expand All @@ -10,10 +13,17 @@ const main = async (progname, rawArgs, privs) => {
stopEarly: true,
});

const insistIsBasedir = async () => {
try {
await fs.promises.stat('.agservers');
} catch (e) {
error(`current directory wasn't created by '${progname} init'`);
}
};

const subMain = (fn, args) => {
const subProgname = `${progname}: ${args[0]}`;
const subError = (...rest) => error(`${args[0]}:`, ...rest);
return fn(subProgname, args.slice(1), { ...privs, error: subError });
return fn(progname, args.slice(1), { ...privs, error: subError });
};

const usage = status => {
Expand Down Expand Up @@ -47,7 +57,11 @@ help display this help and exit
return usage(1);
case 'help':
return usage(0);
case 'deploy':
await insistIsBasedir();
return subMain((await import('./deploy')).default, args);
case 'start':
await insistIsBasedir();
return subMain((await import('./start')).default, args);
// TODO
case 'template':
Expand Down
80 changes: 80 additions & 0 deletions template/.agservers/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# emacs
*~

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

.idea/

# dist files
/dist

# generated integration-test files
integration-test/.cache
integration-test/bundles
integration-test/transform-tests/output

# generated Sphinx/ReadTheDocs files
/docs/build/

/solo
/chain
Loading

0 comments on commit 2d19210

Please sign in to comment.