Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@stackpath/edgeengine-cli
Advanced tools
Readme
EdgeEngine is StackPath's serverless platform. It allows you to add custom logic to your applications or even build entire applications on the edge. With a simple deploy your scripts are deployed to StackPath's vast network containing over 45 POP's. This CLI makes deploying as easy as running a single command, no matter the amount of scripts you have.
This CLI makes deploying to EdgeEngine as easy as running a single command. It's easy to use, but allows for a variety of use-cases. You can run the CLI locally to make deploying a whole lot quicker, run it in a CI/CD pipeline to automate the deployments, or implement it in any way you can think of.
How to get started?
Depending on your platform and your own preferences there are a couple of ways to get the CLI. The preferred way is probably to install it through NPM.
npm install -g @stackpath/edgeengine-cli
to install globally
The CLI saves your authentication data in a file in your home directory (~/.stackpath/credentials
). Once you have set this up, the CLI will continue to read the credentials from the file, meaning that you don't have to provide your credentials over and over again.
In order to authenticate yourself, you need a client ID and a client secret. You can find them in the StackPath client portal.
👉 To authenticate in an interactive environment you can simply run
edgeengine auth
. The CLI will prompt you for required details.
Are you integrating the CLI with a non-interactive environment? Then provide the client ID and the client secret as flags of the command. For example:
edgeengine auth --client_id example-client-id --client_secret example-client-secret --force
Use the --force
(or -f
) flag so that the credentials file is always overwritten, even if it already exists.
The EdgeEngine CLI works with a per-project (or per-directory) based configuration. Each project should have its own configuration file defining the scripts that apply to that project. You might use it to order scripts by website, category (such as firewalls), or otherwise.
Start by including a edgeengine.json
-file in your project directory. The required contents can be found below 👇.
When deploying (edgeengine deploy
), the CLI tries to find the edgeengine.json
configuration file in the directory you're running the command from. Through this file you can configure which scripts you'd like to deploy to which site.
Here's an example:
{
"stack_id": "2dad0e92-61f1-4fb2-bbc0-0c26466e91bf",
"site_id": "1cb3a9ba-06a4-4528-96a4-c4e04598c856",
"scripts": [
{
"name": "Admin IP firewall",
"paths": [
"admin/*"
],
"file": "edgeengine_scripts/ip-firewall.js",
// The ID is generated on first deploy, or - optionally - you can configure it yourself.
"id": "dcdf7824-b6bd-42b8-9b16-9235eefd583d"
},
{
"name": "Script to show a deploy to a different site",
"paths": [
"demo/*"
],
"file": "edgeengine_scripts/demo.js",
"site_id": "15ece821-9eed-4590-9577-b83beda947f7"
},
{
"name": "Script to show a deploy to a different site and stack",
"paths": [
"demo/*"
],
"file": "edgeengine_scripts/demo.js",
"site_id": "15ece821-9eed-4590-9577-b83beda947f7",
"stack_id": "7be2de57-d6d9-4c27-8361-aef01e1870f0"
}
]
}
Note that you can define the
site_id
either in a global scope or in a per-script scope. This allows you to deploy to different sites from a single configuration file.
Key | Description |
---|---|
stack_id | The ID of the stack where your site is in. |
site_id | The ID of the site you'd like to apply the scripts to. |
scripts[name] | The name of the script. Should be descriptive and unique to each site. |
scripts[paths][] | The paths the script should apply to. Relative to your site. Without starting / . If you'd like to apply the script to http://site.com/admin/* you'd use the admin/* path. |
scripts[file] | The file where the required JS is in. Define the path relative to the EdgeEngine configuration JSON. Without a starting / . |
scripts[id] | The ID of the script in the EdgeEngine. Will be created after first deploy. Should be checked into version control after being created. |
You can find the stack and site ID in the URL when you're logged into the StackPath client portal and have selected the CDN site you'd like to deploy scripts to. See the illustration below for more information on which IDs to copy.
When talking about deploying in the context of the EdgeEngine we mean getting local code onto the StackPath Edge. You might also call it "updating" or "pushing" code.
👉 Deploying is as easy as running
edgeengine deploy
from your project directory (given it has theedgeengine.json
-file).
During the deployment the CLI might prompt you in certain situations. For example, when your edgeengine.json
holds an ID that can not be found in the EdgeEngine. The CLI will then prompt you if you'd like to re-create the script. In non-interactive environments you can use the --force
or -f
flag to always try to re-create the script.
$ npm install -g @stackpath/edgeengine-cli
$ edgeengine COMMAND
running command...
$ edgeengine (-v|--version|version)
@stackpath/edgeengine-cli/1.1.0 darwin-x64 node-v9.6.1
$ edgeengine --help [COMMAND]
USAGE
$ edgeengine COMMAND
...
edgeengine auth
Configures StackPath's authentication details.
USAGE
$ edgeengine auth
OPTIONS
-c, --client_id=client_id StackPath Client ID used to authenticate with
-f, --force Set this to always overwrite current credential file, defaults to false.
-h, --help show CLI help
-s, --client_secret=client_secret StackPath Client Secret used to authenticate with
-v, --verbose Turns on verbose logging. Defaults to false
EXAMPLE
$ edgeengine auth
See code: src/commands/auth.ts
edgeengine deploy
Deploys the scripts in the working directory according to its edgeengine.json configuration file.
USAGE
$ edgeengine deploy
OPTIONS
-f, --force Force recreation of scripts if they do not exist. Defaults to false
-h, --help show CLI help
-v, --verbose Turns on verbose logging. Defaults to false
EXAMPLE
$ edgeengine deploy
See code: src/commands/deploy.ts
edgeengine help [COMMAND]
display help for edgeengine
USAGE
$ edgeengine help [COMMAND]
ARGUMENTS
COMMAND command to show help for
OPTIONS
--all see all commands in CLI
See code: @oclif/plugin-help
We welcome contributions and pull requests to this plugin. See our contributing guide for more information.
FAQs
Deploy to Stackpath EdgeEngine from your local machine.
The npm package @stackpath/edgeengine-cli receives a total of 4 weekly downloads. As such, @stackpath/edgeengine-cli popularity was classified as not popular.
We found that @stackpath/edgeengine-cli demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.