diff --git a/docs/using-node.md b/docs/using-node.md new file mode 100644 index 00000000..adadb866 --- /dev/null +++ b/docs/using-node.md @@ -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 +``` \ No newline at end of file diff --git a/docs/using_npm_package.md b/docs/using_npm_package.md new file mode 100644 index 00000000..c0642777 --- /dev/null +++ b/docs/using_npm_package.md @@ -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 +``` \ No newline at end of file diff --git a/main.js b/main.js index a35ea92c..fba7f7cb 100644 --- a/main.js +++ b/main.js @@ -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) => { @@ -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 = {}; @@ -208,6 +267,8 @@ function main() { option = args._[0]; } else { log.error("Invalid Arguments"); + console.log("Invalid Arguments"); + helper(); return; } @@ -286,6 +347,8 @@ function main() { default: log.error("Invalid Arguments"); + console.log("Invalid Arguments"); + helper(); break; } } diff --git a/npm-wrapper.js b/npm-wrapper.js index 36cba7bb..313e603f 100644 --- a/npm-wrapper.js +++ b/npm-wrapper.js @@ -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)); @@ -39,6 +56,8 @@ function main() { option = args._[0]; } else { log.error("Invalid Arguments"); + console.log("Invalid Arguments"); + help(); return; } @@ -221,8 +240,13 @@ function main() { } } break; + + case "help": + help(); + break; default: log.error("Invalid Arguments"); + help(); break; } } diff --git a/package.json b/package.json index e751f989..9645c559 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@virtual-labs/buildexp", - "version": "1.0.2", + "version": "1.0.4", "bin": { "buildexp": "npm-wrapper.js" },