Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/node-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ Since CLI for Node.js is a development tool, use a global instance to install it
```
npm install -g @oracle/suitecloud-cli
```
When installing the SuiteCloud CLI for Node.js via script, for instance in a CI environment, you can skip the license prompt presented during the normal installation process by adding the --supressSuiteCloudSDKLicensePrompt flag to the install script as shown below. Note that by adding the mentioned flag to the script, you confirm that you have read and accepted the Oracle Free Use Terms and Conditions license. See the [License](#license) section for details.
When installing the SuiteCloud CLI for Node.js via script, for instance in a CI environment, you can skip showing the license presented during the normal installation process by adding the --acceptSuiteCloudSDKLicense flag to the install script as shown below. Note that by adding the mentioned flag to the script, you confirm that you have read and accepted the Oracle Free Use Terms and Conditions license. See the [License](#license) section for details.

```
npm install -g --supressSuiteCloudSDKLicensePrompt @oracle/suitecloud-cli
npm install -g --acceptSuiteCloudSDKLicense @oracle/suitecloud-cli
```


Expand All @@ -61,7 +61,7 @@ suitecloud <command> <option> <argument>
|[`file:upload`](https://system.netsuite.com/app/help/helpcenter.nl?fid=section_159066070687.html)|Uploads files from your project to an account.|
|[`object:import`](https://system.netsuite.com/app/help/helpcenter.nl?fid=section_156042181820.html)|Imports custom objects from an account to your SuiteCloud project.|
|[`object:list`](https://system.netsuite.com/app/help/helpcenter.nl?fid=section_156043303237.html)|Lists the custom objects deployed in an account.|
|[`object:update`](https://system.netsuite.com/app/help/helpcenter.nl?fid=section_156050566547.html)|Overwrite the custom objects in the project with the custom objects in an account.|
|[`object:update`](https://system.netsuite.com/app/help/helpcenter.nl?fid=section_156050566547.html)|Overwrites the custom objects in the project with the custom objects from an account.|
|[`project:adddependencies`](https://system.netsuite.com/app/help/helpcenter.nl?fid=section_155981452469.html)| Adds missing dependencies to the manifest file.|
|[`project:create`](https://system.netsuite.com/app/help/helpcenter.nl?fid=section_156041348327.html)|Creates a SuiteCloud project, either a SuiteApp or an account customization project (ACP).|
|[`project:deploy`](https://system.netsuite.com/app/help/helpcenter.nl?fid=section_156044636320.html)|Deploys the folder containing the project.|
Expand Down
2 changes: 0 additions & 2 deletions packages/node-cli/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,9 @@

"NO": "No",

"SDK_DOWNLOAD_SERVICE_DOWNLOADING": "Downloading SuiteCloud SDK dependency...",
"SDK_DOWNLOAD_SERVICE_ERROR": "There was an error when downloading SuiteCloud SDK dependency from {0}\n{1}",
"SDK_DOWNLOAD_SERVICE_FILE_NOT_AVAILABLE_ERROR": "The JAR file is not available from this URL.",
"SDK_DOWNLOAD_SERVICE_GET_TIMEOUT": "GET request timeout.",
"SDK_DOWNLOAD_SERVICE_SUCCESS": "SuiteCloud SDK dependency downloaded successfully.",
"SDK_DOWNLOAD_SERVICE_WRONG_DOWNLOAD_URL_PROTOCOL": "Invalid SDK jar file download url protocol. Only http: or https: are allowed.",

"UNIT_TEST_TEST_FAILED": "The tests failed.",
Expand Down
12 changes: 4 additions & 8 deletions packages/node-cli/src/core/sdksetup/SdkDownloadService.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@ const HOME_PATH = require('os').homedir();

const { FOLDERS } = require('../../ApplicationConstants');

const NodeConsoleLogger = require('../../loggers/NodeConsoleLogger');
const unwrapExceptionMessage = require('../../utils/ExceptionUtils').unwrapExceptionMessage;

const NodeTranslationService = require('../../services/NodeTranslationService');
const FileSystemService = require('../../services/FileSystemService');
const { executeWithSpinner } = require('../../ui/CliSpinner');

const { SDK_DOWNLOAD_SERVICE } = require('../../services/TranslationKeys');

const VALID_JAR_CONTENT_TYPES = ['application/java-archive', 'application/x-java-archive', 'application/x-jar'];
const ERROR_CODE = -1;

class SdkDownloadService {
constructor() {
Expand All @@ -46,13 +45,10 @@ class SdkDownloadService {
const skipProxy = SdkProperties.configFileExists();

try {
await executeWithSpinner({
action: this._downloadJarFilePromise(fullURL, destinationFilePath, proxy, skipProxy),
message: NodeTranslationService.getMessage(SDK_DOWNLOAD_SERVICE.DOWNLOADING, fullURL),
});
NodeConsoleLogger.info(NodeTranslationService.getMessage(SDK_DOWNLOAD_SERVICE.SUCCESS));
await this._downloadJarFilePromise(fullURL, destinationFilePath, proxy, skipProxy);
} catch (error) {
NodeConsoleLogger.error(NodeTranslationService.getMessage(SDK_DOWNLOAD_SERVICE.ERROR, fullURL, unwrapExceptionMessage(error)));
console.error(NodeTranslationService.getMessage(SDK_DOWNLOAD_SERVICE.ERROR, fullURL, unwrapExceptionMessage(error)));
process.exit(ERROR_CODE);
}
}

Expand Down
39 changes: 39 additions & 0 deletions packages/node-cli/src/core/sdksetup/SdkLicense.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict';
const os = require('os');
const path = require('path');
const { spawnSync } = require('child_process');

const LICENSE_PATH = path.normalize('./resources/FUTC-LICENSE.txt');
const WINDOWS_PLATFORM = 'win32';
const LINUX_PLATFORM = 'linux';
const OSX_PLATFORM = 'darwin';
const WINDOWS_CMD = 'start';
const LINUX_CMD = 'xdg-open';
const OSX_CMD = 'open';
const ERROR_MESSAGE = 'Something went wrong.';
const LICENSE_MESSAGE = 'Use the --acceptsuitecloudsdklicense flag to accept the FUTC license:' +
' https://www.oracle.com/downloads/licenses/oracle-free-license.html';
const supportedPlatformsCommands = {
[WINDOWS_PLATFORM]: WINDOWS_CMD,
[LINUX_PLATFORM]: LINUX_CMD,
[OSX_PLATFORM]: OSX_CMD,
};

class SdkLicense {

show() {
if (process.env.npm_config_acceptsuitecloudsdklicense || process.env.npm_config_acceptSuiteCloudSDKLicense) {
return;
}
const currentPlatform = os.platform();
const command = supportedPlatformsCommands[currentPlatform];
const execution = spawnSync(command, [LICENSE_PATH], { stdio: 'ignore', detached: true, shell: true });
if (execution.error || execution.status !== 0) {
console.error(ERROR_MESSAGE);
console.error(LICENSE_MESSAGE);
return process.exit(execution.error?.errno || execution.status);
}
}
}

module.exports = new SdkLicense();
3 changes: 1 addition & 2 deletions packages/node-cli/src/services/TranslationKeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,7 @@ module.exports = {
},
NO: 'NO',
SDK_DOWNLOAD_SERVICE: {
DOWNLOADING: 'SDK_DOWNLOAD_SERVICE_DOWNLOADING',
SUCCESS: 'SDK_DOWNLOAD_SERVICE_SUCCESS',
GET_TIMEOUT: 'SDK_DOWNLOAD_SERVICE_GET_TIMEOUT',
ERROR: 'SDK_DOWNLOAD_SERVICE_ERROR',
FILE_NOT_AVAILABLE_ERROR: 'SDK_DOWNLOAD_SERVICE_FILE_NOT_AVAILABLE_ERROR',
WRONG_DOWNLOAD_URL_PROTOCOL: 'SDK_DOWNLOAD_SERVICE_WRONG_DOWNLOAD_URL_PROTOCOL'
Expand Down
17 changes: 10 additions & 7 deletions packages/node-cli/src/utils/http/ProxyAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ class ProxyAgent {
}

initProxyURL() {
// throws error if proxyString is invalid
const proxy = new URL(this.proxyString);

proxy.host = proxy.hostname || proxy.host;
proxy.port = +proxy.port || (proxy.protocol.toLowerCase() === PROTOCOL.HTTPS ? 443 : 80);
this.proxyURL = proxy;
try {
const proxy = new URL(this.proxyString);
proxy.host = proxy.hostname || proxy.host;
proxy.port = +proxy.port || (proxy.protocol.toLowerCase() === PROTOCOL.HTTPS ? 443 : 80);
this.proxyURL = proxy;
} catch (err) {
throw new ProxyAgentError(`${err.input} ${ERROR_MESSAGES.BAD_PROXY}`);
}
}

addRequest(req, options) {
Expand Down Expand Up @@ -101,7 +103,8 @@ class ProxyAgentError extends Error {

const ERROR_MESSAGES = {
CONNECT_TIMEOUT: 'CONNECT request timeout.',
SERVER_CLOSE_EVENT: 'Tunnel failed. Socket closed prematurely.'
SERVER_CLOSE_EVENT: 'Tunnel failed. Socket closed prematurely.',
BAD_PROXY: 'is not a valid value for proxy.'
}

module.exports = ProxyAgent;