3.5.0 • Published 4 years ago

dxpcloud-cli v3.5.0

Weekly downloads
-
License
BSD-3-Clause
Repository
-
Last release
4 years ago

Liferay Cloud Platform CLI tool

Command line tool for Liferay DXP Cloud

Install

  1. For Mac and Linux:
curl https://cdn.liferay.cloud/lcp/stable/latest/install.sh -fsSL | bash
  1. For Windows:

Download the Windows installer from https://cdn.liferay.cloud/lcp/stable/latest/lcp-install.exe. Run the installer and follow the steps in the wizard.

Getting Started

Usage: lcp <cmd> [args]

Commands:
  lcp deploy  Deploy to DXP Cloud
  lcp docs    Open the documentation of DXP Cloud in your browser
  lcp list    Show list of projects and services
  lcp log     Show logs of project, service or instance
  lcp login   Login to DXP Cloud
  lcp logout  Logout from DXP Cloud
  lcp remote  Configure DXP Cloud remotes
  lcp restart Restart a DXP Cloud service
  lcp scale   Change the number of service instances
  lcp shell   Open a shell to a service
  lcp update  Update DXP Cloud CLI
  lcp version Show CLI version

Options:
  -v, --verbose  Show more information about an operation                                                      [boolean]
  --version      Show version number                                                                           [boolean]
  --help         Show help                                                                                     [boolean]

Development

  1. Clone the repo, then run:
$ npm i
  1. Run the program by executing:
$ ./bin/index.js <cmd> [args]
  1. Run the tests by executing:
$ npm run test

Releasing

  1. Build executable files by running npm run release. This will create binary files in dist folder.

  2. Preparing to push to the CDN

Execute node .update_cdn.js update. The following arguments are supported:

$ node .update_cdn.js update --help
.update_cdn.js update

Updates given channel with a new CLI version

Options:
  --version          Show version number                                                                       [boolean]
  --help             Show help                                                                                 [boolean]
  --channel          The channel to update                  [string] [choices: "stable", "unstable"] [default: "stable"]
  --cdn              CDN sources                                                    [string] [default: "../cdn/cli"]
  --cli-version      The CLI version to publish                                             [string] [default: "latest"]
  --package-version  The package version to specify                                          [string] [default: "1.0.0"]

Note: package-version value is read automatically from version property in package.json. It is not hardcoded.

This will update the CDN project with the new binary files. Then, deploy a new version of the CDN project.

Making installers and uninstallers

Build installers by executing node .make_installer.js make. The following arguments are supported:

$ node .make_installer.js make --help
.make_installer.js make

Generates an installer for the CLI

Options:
  --version           Show version number                                                                      [boolean]
  --help              Show help                                                                                [boolean]
  --platform          The target operating system                [string] [choices: "unix", "windows"] [default: "unix"]
  --channel           The channel to target                 [string] [choices: "stable", "unstable"] [default: "stable"]
  --cli-version       The CLI version to target                         [string] [choices: "latest"] [default: "latest"]
  --make-uninstaller  Whether to make the Windows uninstaller-generator binary                [boolean] [default: false]
  --unsigned          Generate the installer without signing                                  [boolean] [default: false]

This will generate an installer at /installers/< --platform >/dist/ using the current configuration found in /config/app.config.js and /config/installer.config.js.

UNIX-compatible installer and uninstaller

Installer

Run the following command:

node ./.make_installer.js make --platform unix

Then, retrieve the install.sh script from /installer/unix/dist/.

Uninstaller

Run the following command:

node ./.make_installer.js make --platform unix

Then, retrieve the uninstall.sh script from /installer/unix/dist/.

Windows installer and uninstaller

The Windows installer and uninstaller cannot be differentiated since the uninstaller is packaged in the installer. In other words, the installer delivers the uninstaller binary into the install location upon installation. So, in order for the Windows installer binary to be properly created, the uninstaller must be pre-generated and then inserted into the resources directory so that it can be packaged into the installer binary. This flow is necessary in the particular case that the code must be signed, since the uninstaller would not be signed if it were merely generated by the installer upon installation.

The uninstaller binary is pre-generated using an "uninstaller-generator" EXE file, which is actually a blank installer which writes the uninstaller binary when it's run. This allows the developer to insert the newly created uninstaller into the resources directory, where it can be packaged into the installer binary.

To create the uninstaller-generator file, the --make-uninstaller parameter must be set to true when running the .make_installer.js script. The uninstaller-generator file must then be executed on a Windows machine or VM not in a network drive in order to properly generate the uninstaller binary. The new uninstaller binary must then be placed in the resources directory. This is where it will be found by the NSIS compiler when running the lcp-cli-makeinstall script, which packages the uninstaller into the final installer binary. The lcp-cli-makeinstall script is executed by running .make_installer.js with --platform windows. The resulting Windows installer can then be found in the dist directory.

So, the steps for releasing a signed Windows installer are: 1) Run .make_installer.js with --platform windows and --make-uninstaller true to generate a win-uninstaller-generator.exe file.

node ./.make_installer.js make --platform windows --make-uninstaller true

2) On a Windows machine or VM, run win-uninstaller-generator.exe. If done correctly, a new uninstaller binary will be created. Make sure to run win-uninstaller-generator.exe in a non-network drive for it to work properly. 3) Move the newly created uninstaller binary to the resources directory on your host machine. 4) Run .make_installer.js with --platform windows to output the final, signed Windows installer in the dist directory.

node ./.make_installer.js make --platform windows

If you do not have access to the code signing certificate or wish to generate an unsigned Windows installer, run the following command:

node ./.make_installer.js make --platform windows --unsigned true

Note: Code signing can only be performed on MacOS and Linux machines at this time.

Note: Because the config files will be used to configure the installer, it is good to understand the relevant config variables that will be primarily used. They are listed below. These variables can be overridden in /config/installer.config.js.

  • appName: provides the name of the CLI to Windows
  • appVersion: from the package.json, provides the version of the CLI to Windows
  • binName: used by Windows and UNIX installers to specify the CLI binary
  • cdnHost: used by Windows and UNIX installers to reach CDN
  • cdnPathBase: used by Windows and UNIX installers to reach CDN
  • companyName: provides the name of the company to Windows
  • description: provides the CLI app description to Windows
  • docUrl: provides a link to documentation for Windows
  • helpUrl: provides a link to customer service for Windows
  • versionMajor: provides the version of the CLI to Windows
  • versionMinor: provides the version of the CLI to Windows
  • versionPatch: provides the version of the CLI to Windows
  • windows
    • certificateName: the name of the certificate file and auth item to fetch (for code signing)
    • installerAppName: provides the name of the CLI Windows installer program to Windows
    • installerFileName: the name of the Windows installer binary
    • uninstallerFileName: the name of the Windows uninstaller binary

Uninstall

  1. For Mac and Linux:
curl https://cdn.liferay.cloud/lcp/stable/latest/uninstall.sh -fsSL | bash
  1. For Windows:

Navigate to Control Panel -> Add or Remove Programs. Find "LCP CLI" in the list of programs, select it, and click "Uninstall". Follow the steps in the wizard.

License

BSD-3-Clause, © Liferay, Inc.