@adminjs/cloud-cli
Advanced tools
Comparing version 1.2.0-dev.2 to 1.2.0-dev.3
@@ -62,2 +62,5 @@ import fs from 'fs'; | ||
const envFile = path.join(localPath, '.env'); | ||
if (!fs.existsSync(envFile)) { | ||
createEnvFile(envFile, `${key}=${value}`); | ||
} | ||
const data = fs.readFileSync(envFile, 'utf8'); | ||
@@ -78,2 +81,5 @@ const result = data.replace(new RegExp(`${key}=.*`, 'g'), `${key}=${value}`); | ||
}; | ||
const createEnvFile = (localPath, data) => { | ||
fs.writeFileSync(localPath, data, { encoding: 'utf8', flag: 'w' }); | ||
}; | ||
export default create; |
{ | ||
"name": "@adminjs/cloud-cli", | ||
"version": "1.2.0-dev.2", | ||
"version": "1.2.0-dev.3", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "", |
103
README.md
@@ -1,5 +0,100 @@ | ||
## Usage | ||
AdminJS Cloud Hosting comes with a CLI tool which you can use locally or inside your CI/CD to deploy your application. | ||
```typescript | ||
adminjsHub publish -a test -s secret | ||
``` | ||
## Requierments | ||
Before you will make installation and configuration steps make sure you met all the requirements below. | ||
- Node.js >=18 (we recommend latest LTS version) | ||
- yarn installed globally (`npm install --global yarn`) | ||
## Installation | ||
```bash | ||
yarn global add @adminjs/cloud-cli | ||
``` | ||
## Configuration | ||
`@adminjs/cloud-cli` relies on configuration file to be present in your source code. The default file name is `adminjs-cloud.json` but you can provide a custom file path using `--config` option in a CLI command. | ||
### Options | ||
``` | ||
include string[] A list of files/directories you wish to deploy. | ||
``` | ||
### Example | ||
```json | ||
{ | ||
"include": [ | ||
"public", | ||
"dist", | ||
"src", | ||
".env", | ||
"package.json", | ||
"tsconfig.json", | ||
"yarn.lock" | ||
] | ||
} | ||
``` | ||
### Starting the application | ||
Currently, AdminJS Cloud Hosting requires `start` script to be present in your `package.json` file. This is the command you use to start your application: | ||
```json | ||
{ | ||
..., | ||
"scripts": { | ||
..., | ||
"start": "node app.js" | ||
} | ||
} | ||
``` | ||
In the future, we plan to extend application's configuration so that you can provide a custom start command. | ||
## Commands | ||
As of version `1.2.0` the CLI only allows you to create and deploy your application. | ||
To use `@adminjs/cloud-cli` you must first request an application in [Pricing](https://adminjs.co/pricing) page and generate an API Key & API Secret. | ||
### create | ||
The `create` command allows you to create basic AdminJS application with basic authentication. The CLI generates only code for running it, you have to use commands `yarn && yarn build && yarn start` to check if setup is complete succesfully, if you follow all the steps correctly. | ||
#### Parameters | ||
``` | ||
name string required The name of your application | ||
database string required The connection string to database eg. `postgres://adminjs:adminjs@localhost:5432/adminjs` | ||
apiKey string required Your API Key | ||
apiSecret string required Your API Secret | ||
config string optional Path to your configuration file (relative to PWD) | ||
``` | ||
#### Usage | ||
```bash | ||
adminjs-cloud create --name=<string> --database=<string> --apiKey=<string> --apiSecret=<string> | ||
``` | ||
### deploy | ||
The `deploy` command allows you to deploy your source code. The CLI assumes your code is already built and whatever files you choose to `include` in your configuration file are enough to start your application. | ||
#### Parameters | ||
``` | ||
apiKey string required Your API Key | ||
apiSecret string required Your API Secret | ||
config string optional Path to your configuration file (relative to PWD) | ||
``` | ||
#### Usage | ||
```bash | ||
adminjs-cloud deploy --apiKey=<string> --apiSecret=<string> --config=[string] | ||
``` |
@@ -83,2 +83,5 @@ import fs from 'fs'; | ||
const envFile = path.join(localPath, '.env'); | ||
if (!fs.existsSync(envFile)) { | ||
createEnvFile(envFile, `${key}=${value}`); | ||
} | ||
const data = fs.readFileSync(envFile, 'utf8'); | ||
@@ -99,2 +102,6 @@ const result = data.replace(new RegExp(`${key}=.*`, 'g'), `${key}=${value}`); | ||
const createEnvFile = (localPath: string, data: string): void => { | ||
fs.writeFileSync(localPath, data, { encoding: 'utf8', flag: 'w' }); | ||
}; | ||
export default create; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
328611
883
101
1