Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #57

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# nodecloud-cli

nodecloud-cli is an unified command line interface for open cloud based on [nodecloud](https://github.com/cloudlibz/nodecloud). nodecloud-cli supports cloud providers like AWS, Azure, GCP and many more.

Very Simple to Use.
Allows you to use emojis.
## 🚀 Install

Using npm
Expand Down Expand Up @@ -163,3 +164,4 @@ $ yarn test
## 📜 License

MIT

4 changes: 3 additions & 1 deletion lib/compute.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

class Compute {
constructor(program, ncProviders, options) {
if (program.type == "AWS" || "aws") {
Expand All @@ -7,7 +8,8 @@ class Compute {
} else if (program.type == "Azure") {
this._compute = ncProviders.azure.compute(options);
} else {
throw new Error("Please specify a provider by flag -p --provider");
const emoji = require("node-emoji");
throw new Error(emoji.get("x")+" Please specify a provider by flag -p --provider");
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { exec } = require("child_process");
function installDependencies(path, cb) {
exec(`cd ${path} && npm install`, (error, stdout, stderr) => {
if (error) {
console.log("error", error);
console.log(emoji.get("x"), " ","error", error);
cb(error, null);
}
cb(null, true);
Expand Down
3 changes: 2 additions & 1 deletion lib/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class Database {
} else if (program.type == "Azure" || "azure") {
this._database = nodecloud.azure.compute(options);
} else {
throw new Error("Please specify a provider by flag -p --provider");
const emoji = require("node-emoji");
throw new Error(emoji.get("x")+" Please specify a provider by flag -p --provider");
}
}

Expand Down
7 changes: 4 additions & 3 deletions lib/iam.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
class Iam {
constructor(program, nodecloud, options) {
const emoji = require("node-emoji");
if (program.type == "AWS" || "aws") {
this._iam = nodecloud.aws.iam(options);
} else if (program.type == "GCP") {
throw new Error(
"Identity & Access Management (IAM) for GCP is not available"
emoji.get("x")+" Identity & Access Management (IAM) for GCP is not available"
);
// this._iam = nodecloud.gcp.iam(options);
} else if (program.type == "Azure") {
//this._iam = nodecloud.azure.iam(options);
throw new Error(
"Identity & Access Management (IAM) for Azure is not available"
emoji.get("x")+" Identity & Access Management (IAM) for Azure is not available"
);
} else {
throw new Error("Please specify a provider by flag -p --provider");
throw new Error(emoji.get("x")+" Please specify a provider by flag -p --provider");
}
}

Expand Down
13 changes: 7 additions & 6 deletions lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,35 +68,36 @@ class Init {
let instance = this;
let data = `
const ${providers.require} = require('${providers.package}');

const providers = [
${providers.provider}
];

module.exports = providers;
`;

instance
.writeFile(data)
.then(function(response) {
const emoji = require("node-emoji");
if (response.state) {
if (response.exists) {
instance._spinner.warn("Configuration file exist");
} else {
instance._spinner.succeed(
"Configuration file generated successfully"
emoji.get("tada")+" Configuration file generated successfully"
);
}
instance
.installPlugin(providers)
.then(status => {
if (!status) {
instance._spinner.fail(
`Installing package ${providers.package} failed`
`${emoji.get("x")} Installing package ${providers.package} failed`
);
}
instance._spinner.succeed(
`Installed ${providers.package} successfully`
`${emoji.get("tada")} Installed ${providers.package} successfully`
);
})
.catch(err => {
Expand All @@ -105,7 +106,7 @@ class Init {
}
})
.catch(function(err) {
instance._spinner.fail("Configuration file generation Failed");
instance._spinner.fail(emoji.get("x")+" Configuration file generation Failed");
});
}

Expand Down
9 changes: 5 additions & 4 deletions lib/network.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
class Network {
constructor(program, nodecloud, options) {
const emoji = require("node-emoji");
this._program = program;
if (program.type == "AWS" || "aws") {
if (program.service === "dns") {
this._network = nodecloud.aws.dns(options);
} else if (program.service === "lb") {
this._network = nodecloud.aws.loadbalancer(options);
} else {
throw new Error("Please select a service type");
throw new Error(emoji.get("x")+" Please select a service type");
}
} else if (program.type == "GCP" || "gcp") {
if (program.service == "dns") {
this._network = nodecloud.gcp.dns(options);
} else {
throw new Error("Please select a service type");
throw new Error(emoji.get("x")+" Please select a service type");
}
throw new Error("Network for GCP is not available");
} else if (program.type == "Azure" || "azure") {
//this._network = nodecloud.azure.network(options);
throw new Error("Network for Azure is not available");
throw new Error(emoji.get("x")+" Network for Azure is not available");
} else {
throw new Error("Please specify a provider by flag -p --provider");
throw new Error(emoji.get("x")+" Please specify a provider by flag -p --provider");
}
}

Expand Down
3 changes: 2 additions & 1 deletion lib/storage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Storage {
constructor(program, nodecloud, options) {
const emoji = require("node-emoji");
this._program = program;
if (program.type == "AWS" || "aws") {
this._storage = nodecloud.aws.bucket(options);
Expand All @@ -8,7 +9,7 @@ class Storage {
} else if (program.type == "Azure" || "azure") {
this._storage = nodecloud.azure.blob(options);
} else {
throw new Error("Please specify a provider by flag -p --provider");
throw new Error(emoji.get("x")+" Please specify a provider by flag -p --provider");
}
}

Expand Down