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

Add a Node.js CLI that interfaces with the generators directly #356

Open
mhkarimi1383 opened this issue May 12, 2022 · 8 comments
Open

Add a Node.js CLI that interfaces with the generators directly #356

mhkarimi1383 opened this issue May 12, 2022 · 8 comments
Labels
enhancement New feature or request hacktoberfest Issues folks can work on for Hacktoberfest help wanted Extra attention is needed

Comments

@mhkarimi1383
Copy link

Feature request

Just a simple API giving parameters and return the confirmation

Feature description

For automation reasons I need such API for that reason

How the feature is useful

Using Automation tools like Ansible or making a simple cli

@MattIPv4 MattIPv4 added the enhancement New feature or request label May 13, 2022
@MattIPv4
Copy link
Member

I think an API itself would be out-of-scope for this project, as it's a client-side tool built for the browser.

That being said, we do have the config generators themselves exposed in such a way that it'd likely be pretty simple for someone to add a CLI interface to the project that just reads in a large config JSON file (similar to the JSON data stored in the URL when using the in-browser version) and running it through the generators: https://github.com/digitalocean/nginxconfig.io/tree/master/src/nginxconfig/generators

@MattIPv4 MattIPv4 added help wanted Extra attention is needed hacktoberfest Issues folks can work on for Hacktoberfest labels May 13, 2022
@MarryJane89
Copy link

Me too

@MrJmpl3
Copy link
Contributor

MrJmpl3 commented Oct 4, 2022

@MattIPv4 Maybe a CLI can be work as a NPM package.

  • Install NPM package in global (example: nginxconfig-io)
  • Write a JSON with the config
  • Execute 'nginxconfig-io [Path of the JSON config]'

But I don't sure about some things

  • Where storage the files? In nginx folder Or using another param or the path where execute the CLI?
  • How the files can be generate? In nginx config or bundle in tar file
  • The ifs in the generator using computed value, how can simulate that in Node CLI?

@MattIPv4
Copy link
Member

MattIPv4 commented Oct 4, 2022

Where storage the files?

As in, within the repo? src/nginxconfig/cli feels like the logical location. Assuming the correct bin entry is added to the package.json, it doesn't actually matter where the entrypoint script is.

How the files can be generate?

I would probably expect the CLI to take a directory argument, and the CLI then writes the files directly to there. I like the idea of adding an optional --tar flag though that outputs the single tar file instead.

The ifs in the generator using computed value, how can simulate that in Node CLI?

Some logic will need to be written that takes the provided JSON data and gives each property a new sub-object with the value as the computed property. OR, the opposite could be done where the generators are updated to remove the computed property, and the data from the Vue client is transformed to remove that property before being passed to the generators.

@MattIPv4 MattIPv4 changed the title Need an API Add a Node.js CLI that interfaces with the generators directly Oct 4, 2022
@mhkarimi1383
Copy link
Author

Where storage the files?

As in, within the repo? src/nginxconfig/cli feels like the logical location. Assuming the correct bin entry is added to the package.json, it doesn't actually matter where the entrypoint script is.

How the files can be generate?

I would probably expect the CLI to take a directory argument, and the CLI then writes the files directly to there. I like the idea of adding an optional --tar flag though that outputs the single tar file instead.

The ifs in the generator using computed value, how can simulate that in Node CLI?

Some logic will need to be written that takes the provided JSON data and gives each property a new sub-object with the value as the computed property. OR, the opposite could be done where the generators are updated to remove the computed property, and the data from the Vue client is transformed to remove that property before being passed to the generators.

I would love to have it as a parameter since I want to use it within my automation scripts or my ansible plays
Also would be nice to get all of the parameters as a yaml or json file or using environment variables

@MattIPv4
Copy link
Member

MattIPv4 commented Oct 4, 2022

Yah, I'd expect this to take a JSON file as the config input (representing what you normally be in the UI):

nginxconfig --config whatever.json --out /etc/nginx

@Siddharth9890
Copy link

hey @MattIPv4 i would like to work on this is this issue still open to work?

@MattIPv4
Copy link
Member

MattIPv4 commented Oct 5, 2023

Go for it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest Issues folks can work on for Hacktoberfest help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants
@MattIPv4 @MrJmpl3 @mhkarimi1383 @Siddharth9890 @MarryJane89 and others