Skip to content

Commit

Permalink
Merge pull request #120 from virtual-labs/help-commands
Browse files Browse the repository at this point in the history
Help commands
  • Loading branch information
raj-vlabs authored May 12, 2023
2 parents 308f855 + 9dd99c4 commit c103609
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 1 deletion.
63 changes: 63 additions & 0 deletions docs/using-node.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
1. To run the build script using nodejs, you have to clone this repository in your experiment project folder.
2. Then, you have to install the dependencies using the following command:
```bash
npm install
```
3. After that, you can run the build script using the following commands and options:
```bash
Usage: node main.js [mode] [options]
Modes:
build Build the experiment
validate Validate the code and content
clean Clean the build and plugins
deploy Deploy the experiment locally
buildLab Build the lab
deployLab Deploy the lab locally


Common Options:
--src path to the experiment, default is parent directory
--debug enable debug mode
--help display help for command


Mode: build
Usage: build [options]
Options:
--clean clean build folder
--validateEslint validate the code using eslint
--validateExpDesc validate the experiment description and assessment files
--disablePlugin disable the plugins
--deploy deploy the experiment locally
--env environment to build the experiment


Mode: Validate
Usage: validate [options]
Options:
--validateEslint validate the code using eslint
--validateExpDesc validate the experiment description and assessment files


Mode: clean
Usage: clean


Mode: deploy
Usage: deploy


Mode: buildLab
Usage: buildLab [options]
Options:
--src path to the lab, default is parent directory
--deploy deploy the lab locally
--release release type of the lab, default is minor


Mode: deployLab
Usage: deployLab [options]
Options:
--src path to the lab, default is parent directory
--release release type of the lab, default is minor
```
21 changes: 21 additions & 0 deletions docs/using_npm_package.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
1. To run the build script using the npm package you need to make sure that the experiment has package.json file in the root directory. If you don't have one, you can create it by running the following command in the root directory of your experiment:
```bash
npm init -y
```
2. After initialising the experiment as a node project, you can run the build script by running the following command:
```bash
Usage: npx @virtual-labs/buildexp [command]
Options:
Commands:
build-exp Build the experiment
build-exp-deploy Build the experiment and deploy locally
build-exp-noplugin Build the experiment without using any plugins
clean-build-exp Clean and build the experiment
validate Validate the code and content
clean Clean the build and plugins
deploy Deploy the experiment locally
build-lab Build the lab
deploy-lab Deploy the lab locally
build-and-deploy-lab Build and deploy the lab locally
help Display help for command
```
63 changes: 63 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,59 @@ const {buildLab, deployLab,validation} = require("./lab_build/lab_gen.js");
// Build/run
// Flags = clean build, with plugin, without plugin, validation on off, also deploy locally

function helper() {
console.log("Usage: node main.js [mode] [options]");
console.log("Modes:");
console.log(" build Build the experiment");
console.log(" validate Validate the code and content");
console.log(" clean Clean the build and plugins");
console.log(" deploy Deploy the experiment locally");
console.log(" buildLab Build the lab");
console.log(" deployLab Deploy the lab locally");
console.log("\n");
console.log("Common Options:");
console.log(" --src path to the experiment, default is parent directory");
console.log(" --debug enable debug mode");
console.log(" --help display help for command");
console.log("\n");
console.log("Mode: build");
console.log("Usage: build [options]");
console.log("Options:");
console.log(" --clean clean build folder");
console.log(" --validateEslint validate the code using eslint");
console.log(" --validateExpDesc validate the experiment description and assessment files");
console.log(" --disablePlugin disable the plugins");
console.log(" --deploy deploy the experiment locally");
console.log(" --env environment to build the experiment");
console.log("\n");
console.log("Mode: Validate");
console.log("Usage: validate [options]");
console.log("Options:");
console.log(" --validateEslint validate the code using eslint");
console.log(" --validateExpDesc validate the experiment description and assessment files");
console.log("\n");
console.log("Mode: clean");
console.log("Usage: clean");
console.log("\n");
console.log("Mode: deploy");
console.log("Usage: deploy");
console.log("\n");
console.log("Mode: buildLab");
console.log("Usage: buildLab [options]");
console.log("Options:");
console.log(" --src path to the lab, default is parent directory");
console.log(" --deploy deploy the lab locally");
console.log(" --release release type of the lab, default is minor");
console.log("\n");
console.log("Mode: deployLab");
console.log("Usage: deployLab [options]");
console.log("Options:");
console.log(" --src path to the lab, default is parent directory");
console.log(" --release release type of the lab, default is minor");
console.log("\n");
}


function getAssessmentPath(src,units){
let assessmentPath = [];
units.forEach((unit) => {
Expand Down Expand Up @@ -177,6 +230,12 @@ function deployLocal(src) {
function main() {
const args = minimist(process.argv.slice(2));

// check for help flag
if (args.help) {
helper();
return;
}

// for backwards compatibility if the env is not given assume it to
// be testing.
const build_options = {};
Expand Down Expand Up @@ -208,6 +267,8 @@ function main() {
option = args._[0];
} else {
log.error("Invalid Arguments");
console.log("Invalid Arguments");
helper();
return;
}

Expand Down Expand Up @@ -286,6 +347,8 @@ function main() {

default:
log.error("Invalid Arguments");
console.log("Invalid Arguments");
helper();
break;
}
}
Expand Down
24 changes: 24 additions & 0 deletions npm-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ const { BuildEnvs, validBuildEnv } = require("./enums.js");
const log = require("./logger");
const path = require("path");

function help(){
console.log("Usage: npx @virtual-labs/buildexp [command]");
console.log("Options:");
console.log("Commands:");
console.log(" build-exp Build the experiment");
console.log(" build-exp-deploy Build the experiment and deploy locally");
console.log(" build-exp-noplugin Build the experiment without using any plugins");
console.log(" clean-build-exp Clean and build the experiment");
console.log(" validate Validate the code and content");
console.log(" clean Clean the build and plugins");
console.log(" deploy Deploy the experiment locally");
console.log(" build-lab Build the lab");
console.log(" deploy-lab Deploy the lab locally");
console.log(" build-and-deploy-lab Build and deploy the lab locally");
console.log(" help Display help for command");
}

function main() {
// console.log("Vlabs Build Exp");
const args = minimist(process.argv.slice(2));
Expand Down Expand Up @@ -39,6 +56,8 @@ function main() {
option = args._[0];
} else {
log.error("Invalid Arguments");
console.log("Invalid Arguments");
help();
return;
}

Expand Down Expand Up @@ -221,8 +240,13 @@ function main() {
}
}
break;

case "help":
help();
break;
default:
log.error("Invalid Arguments");
help();
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@virtual-labs/buildexp",
"version": "1.0.2",
"version": "1.0.4",
"bin": {
"buildexp": "npm-wrapper.js"
},
Expand Down

0 comments on commit c103609

Please sign in to comment.