Moralis Admin CLI deploy help is not sync with its real usage

Moralis Admin CLI not pick up the neither folderPath nor moralisSubdomain from local .env file at the root next to package.json.

This is the script I try to run:

...
"scripts": {
  "deploy": "moralis-admin-cli deploy"
},
...
"devDependencies": {
  ...
  "moralis-admin-cli": "2.1.13"
  ...
}
...

deploy command only works with explicit -p and -d flags, but I do not want to expose those private information.

Summary: moralisApiKey is picked up, but neither the folderPath nor moralisSubdomain

Thanks for helping me, this is an issue for me a long time.

1 Like

Hi,
The code from admin cli is like this:
for deploy:

        // Get path of the folder to deploy
        let folderPath = grab('--folderPath') || grab('-p') || '.';

            // get server list
            const servers = await utils.getUserServers();

            // Get selected server
            const server = utils.getSelectedServer(servers.filter(item => item.updateCloudError === 0 && item.update === 0))


and for watchCloudFolder is like this:

    // Get path to the cloud folder
    const folderPath = grab('--moralisCloudfolder') || grab('-p') || process.env.moralisCloudFolder || utils.getFilePath("Specify path to cloud functions folder: ");

    // Get server to use
    let subdomain = grab('--moralisSubdomain') || grab('-d') || process.env.moralisSubdomain;

It looks like the deploy command doesn’t look in process.env for those two variables in particular.

You could modify admin cli source code to handle your case until we find a better solution.

I see your point @cryptokid, but then the usage is not in sync with it’s help documentation. (Also could you please show me how can I contribute to the moralis-admin-cli source code, did not find in guthub yet, appreciate)

Run: npx moralis-admin-cli deploy help

The deploy command allows you to publish you dapp to you Moralis server.

The command requires 3 parameters:

--moralisApiKey / -k
This is the API key that lets you authenticate with Moralis via the CLI

--moralisApiSecret / -s
This is the API secret that lets you authenticate with Moralis via the CLI

--moralisSubdomain / -d
The Moralis server you want to deploy to

If left out, you will get to choose from a list.

You can find all three of these (apiKey, apiSecret and subdomain) 
in the Admin panel by clicking on view details 
on the server you are working with.

--folderPath / -p (optional)
The path to the folder where your dapp is located.
 (Default is the folder the command is executed from.)
You can provide these variables in a combination of three ways:

1. Provide them as arguments to the command 
Example: 
moralis-admin-cli deploy --moralisApiKey d4djh56kjhgkj535

2. Specify the arguments in a .env file located in the same 
directory when running the command.
Example: 
moralisApiKey=d4djh56kjhgkj535

3. Store the variables as environment variables on the machine. 

Anyway thanks for the source code details :slight_smile: