Skip to content

Commit

Permalink
change calls to use positional arguments over flags
Browse files Browse the repository at this point in the history
  • Loading branch information
behaviary committed Jun 4, 2019
1 parent b5ed5e1 commit 8da5fa0
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 15 deletions.
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -15,8 +15,9 @@ near <command>
```
### Commands:
```Bash
near create_account # create a developer account
near deploy # deploy your smart contract
near create_account <account_id> # create a developer account
near new_project [dir]
near deploy # deploy your smart contract
near call <contractName> <methodName> [args] # submits transaction, can change state, account required
near view <contractName> <methodName> [args] # cannot change state, account is contract name
```
Expand Down
4 changes: 2 additions & 2 deletions bin/near
Expand Up @@ -60,7 +60,7 @@ const build = {
};

const createAccount = {
command: 'create_account',
command: 'create_account <accountId>',
desc: 'create a developer account',
builder: (yargs) => yargs
.option('accountId', {
Expand All @@ -84,7 +84,7 @@ const clean = {
};

const newProject = {
command: 'new_project',
command: 'new_project [projectDir]',
desc: 'create a new blank project',
builder: (yargs) => yargs
.option('projectDir', {
Expand Down
2 changes: 1 addition & 1 deletion get-config.js
@@ -1,6 +1,6 @@

module.exports = function getConfig() {
const configPath = process.cwd() + '/src/config';
const configPath = process.cwd() + '/src/config.js';
try {
return require(configPath)(process.env.NODE_ENV || 'development');
} catch (e) {
Expand Down
1 change: 1 addition & 0 deletions gulp-utils.js
@@ -1,3 +1,4 @@
// FUTURE PEOPLE: This file is called "gulp-utils" but it's not related to the deprecated library called "gulp-utils". Don't panic.
function generateBindings(inputFile, outputFile, callback) {
const asc = getAsc();
asc.main([
Expand Down
30 changes: 30 additions & 0 deletions gulpfile.js
@@ -0,0 +1,30 @@
const gulp = require("gulp");
const nearUtils = require("near-shell/gulp-utils");

gulp.task("build:model", callback => {
nearUtils.generateBindings("model.ts", "../out/model.near.ts", callback);
});

gulp.task("build:bindings", ["build:model"], callback => {
nearUtils.generateBindings("main.ts", "../out/main.near.ts", callback);
});

gulp.task("build", ["build:bindings"], callback => {
nearUtils.compile("../out/main.near.ts", "../out/main.wasm", callback);
});

gulp.task("default", ["build"]);

// TODO: Extract all following boilerplate into library

// This task is not required when running the project locally. Its purpose is to set up the
// AssemblyScript compiler when a new project has been loaded in WebAssembly Studio.
gulp.task("project:load", () => {
const utils = require("@wasm/studio-utils");
utils.eval(utils.project.getFile("setup.js").getData(), {
logLn,
project,
monaco,
fileTypeForExtension,
});
});
14 changes: 7 additions & 7 deletions index.js
Expand Up @@ -10,14 +10,14 @@ ncp.limit = 16;

// TODO: Fix promisified wrappers to handle error properly

exports.newProject = async function() {
exports.newProject = async function(options) {
// Need to wait for the copy to finish, otherwise next tasks do not find files.
const projectDir = yargs.argv.projectDir;
const projectDir = options.projectDir;
const sourceDir = __dirname + "/blank_project";
console.log(`Copying files to new project directory (${projectDir}) from template source (${sourceDir}).`);
const copyDirFn = () => {
return new Promise(resolve => {
ncp (sourceDir, yargs.argv.projectDir, response => resolve(response));
ncp (sourceDir, options.projectDir, response => resolve(response));
})};
await copyDirFn();
console.log('Copying project files complete.')
Expand All @@ -35,18 +35,18 @@ exports.clean = async function() {
// Only works for dev environments
exports.createDevAccount = async function(options) {
const keyPair = await KeyPair.fromRandomSeed();

let accountId = options.accountId;
options.useDevAccount = true;
options.deps = {
keyStore: new InMemoryKeyStore(),
storage: {},
};

await neardev.connect(options);
await options.deps.createAccount(options.accountId, keyPair.getPublicKey());
await options.deps.createAccount(accountId, keyPair.getPublicKey());
const keyStore = new UnencryptedFileSystemKeyStore('./', options.networkId);
keyStore.setKey(options.accountId, keyPair);
console.log("Create account complete.");
keyStore.setKey(accountId, keyPair);
console.log("Create account complete for " + accountId);
};

async function connect(options) {
Expand Down
18 changes: 15 additions & 3 deletions test/new_project.sh
@@ -1,10 +1,22 @@
#!/bin/sh
set -ex
rm -rf tmp-project
# remove temporary blank project
rm -rf test/tmp-project
cd test/
# test generating new project in cwd
mkdir tmp-project
cd tmp-project
../bin/near new_project
../../bin/near new_project
npm install
npm uninstall near-shell
npm install ../
npm install ../../
NODE_ENV=development npm run test
cd ..
rm -rf tmp-project
# test generating new project in new dir
../bin/near new_project 'tmp-project'
cd tmp-project
npm install
npm uninstall near-shell
npm install ../../
NODE_ENV=development npm run test

0 comments on commit 8da5fa0

Please sign in to comment.