Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ root = true

[*]
indent_style = space
indent_size = 4
indent_size = 3
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ A command line helper for our AppBuilder development.
$ sudo npm install -g CruGlobal/ab-cli
```

# Updating

To update to the latest version:

```sh
$ sudo npm update -g CruGlobal/ab-cli
```

Or reinstall to ensure you have the latest:

```sh
$ sudo npm install -g CruGlobal/ab-cli@latest
```

# Usage

## Development Install (local machine)
Expand Down
10 changes: 6 additions & 4 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,11 @@ function removeTempDBInitFiles(done) {
*/
async function installDeveloperFiles() {
if (!Options.develop) return;
if (!shell.which("tar")) {
console.error("Warning! 'tar' is not installed. If install fails, please install it before retrying.");
}
if (!shell.which("tar")) {
console.error(
"Warning! 'tar' is not installed. If install fails, please install it before retrying."
);
}

console.log("... installing developer files (this will take awhile)");
console.log(" ... download digiserve/ab-code-developer");
Expand All @@ -315,7 +317,7 @@ async function installDeveloperFiles() {
bar = utils.logFormatter.progressBar(" ");
bar.start(100, 0, { filename: "/developer" });
}
const checkpoint = 46130;
// const checkpoint = 46130;
/**
* checpoint for tar command, calulation:
* `du -sk --apparent-size developer.tar.bz2 | cut -f 1` / 45
Expand Down
114 changes: 114 additions & 0 deletions lib/oldPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
//
// oldPlugin
// manage plugin related tasks (old architecture)
//
// options:
// appbuilder oldPlugin new [name] : create a new plugin
// appbuilder oldPlugin page new [name] : create a new page within a plugin
//
var async = require("async");
var path = require("path");
var utils = require(path.join(__dirname, "utils", "utils"));

var oldPluginNew = require(path.join(__dirname, "tasks", "oldPluginNew.js"));
var oldPluginPage = require(path.join(__dirname, "tasks", "oldPluginPage.js"));

var Options = {}; // the running options for this command.

//
// Build the Service Command
//
var Command = new utils.Resource({
command: "oldPlugin",
params: "",
descriptionShort: "manage plugins (old architecture).",
descriptionLong: `
`,
});

module.exports = Command;

Command.help = function () {
console.log(`

usage: $ appbuilder oldPlugin [operation] [options]

[operation]s :
new : $ appbuilder oldPlugin new [name]
page: $ appbuilder oldPlugin page [plugin-name] [page-name]


[options] :
name: the name of the plugin

examples:

$ appbuilder oldPlugin new RemoteConnection
- creates new plugin in developer/plugins/RemoteConnection
`);
};

Command.run = function (options) {
return new Promise((resolve, reject) => {
async.series(
[
// copy our passed in options to our Options
(done) => {
for (var o in options) {
Options[o] = options[o];
}
Options.operation = options._.shift();

// check for valid params:
if (!Options.operation) {
Command.help();
process.exit(1);
}
done();
},
checkDependencies,
chooseTask,
],
(err) => {
if (err) {
reject(err);
return;
}
resolve();
}
);
});
};

/**
* @function checkDependencies
* verify the system has any required dependencies for our operations.
* @param {function} done node style callback(err)
*/
function checkDependencies(done) {
utils.checkDependencies(["git"], done);
}

/**
* @function chooseTask
* choose the proper subTask to perform.
* @param {cb(err)} done
*/
function chooseTask(done) {
var task;
switch (Options.operation.toLowerCase()) {
case "new":
task = oldPluginNew;
break;

case "page":
task = oldPluginPage;
break;
}
if (!task) {
Command.help();
process.exit(1);
}

task.run(Options).then(done).catch(done);
}
118 changes: 118 additions & 0 deletions lib/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
//
// plugin
// manage plugin related tasks (updated architecture)
//
var path = require("path");
var utils = require(path.join(__dirname, "utils", "utils"));

var pluginNew = require(path.join(__dirname, "tasks", "pluginNew.js"));
var pluginObject = require(path.join(__dirname, "tasks", "pluginObject.js"));
var pluginView = require(path.join(__dirname, "tasks", "pluginView.js"));

var Options = {}; // the running options for this command.

//
// Build the Plugin Command
//
var Command = new utils.Resource({
command: "plugin",
params: "",
descriptionShort: "manage plugins (updated architecture).",
descriptionLong: `
`,
});

module.exports = Command;

Command.help = function () {
console.log(`

usage: $ appbuilder plugin [operation] [options]

[operation]s :
new : $ appbuilder plugin new [name]
object : $ appbuilder plugin object [pluginName] [objectName]
view : $ appbuilder plugin view [pluginName] [viewName]

[options] :
name: the name of the plugin

examples:

$ appbuilder plugin new MyPlugin
- creates new plugin in developer/plugins/ab_plugin_my_plugin

$ appbuilder plugin object MyPlugin ObjectNetsuite
- adds object code (properties, service, and web) to existing plugin with object name
$ appbuilder plugin object MyPlugin
- adds object code, objectName defaults to pluginName
$ appbuilder plugin object
- prompts to select plugin and object name
$ appbuilder plugin view MyPlugin MyWidget
- adds view code (properties and web) to existing plugin with view name
$ appbuilder plugin view MyPlugin
- adds view code, viewName defaults to pluginName
$ appbuilder plugin view
- prompts to select plugin and view name
`);
};

Command.run = async function (options) {
// copy our passed in options to our Options
for (var o in options) {
Options[o] = options[o];
}
Options.operation = options._.shift();

// check for valid params:
if (!Options.operation) {
Command.help();
process.exit(1);
}

await checkDependencies();
await chooseTask();
};

/**
* @function checkDependencies
* verify the system has any required dependencies for our operations.
* @returns {Promise}
*/
function checkDependencies() {
return new Promise((resolve, reject) => {
utils.checkDependencies([], (err) => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}

/**
* @function chooseTask
* choose the proper subTask to perform.
* @returns {Promise}
*/
async function chooseTask() {
var task;
switch (Options.operation.toLowerCase()) {
case "new":
task = pluginNew;
break;
case "object":
task = pluginObject;
break;
case "view":
task = pluginView;
break;
}
if (!task) {
Command.help();
process.exit(1);
}

await task.run(Options);
}
Loading
Loading