netsuite-suitecloud-sdk icon indicating copy to clipboard operation
netsuite-suitecloud-sdk copied to clipboard

account:setup cli mode executes in interactive mode without -i

Open ricardoavelocity opened this issue 1 year ago • 4 comments

Select the SuiteCloud tool where you encountered the issue

SuiteCloud CLI

Version of the SuiteCloud Tool

1.9.0

Operating system

Sonoma 14.5

Node Version / VSCode Version

node v20.10.0

JAVA Version

n/a

Bug description

When trying to get the current environment, or set a new environment, account:setup always triggers the interactive interface making programatic tasks impossible. There's no way to confirm which environment the user is connected to, nor to change it.

Steps To Reproduce

suitecloud account:setup

Actual Output

? Select or create an authentication ID (a custom alias you give to a specific account-role combination): ***The authentication ID that you select or create will be set up as default. (Use arrow keys) ❯ Create a new authentication ID. ────────────── Select a configured authentication ID: etc.

Expected Output

The currently selected authentication ID.

Anything else?

This makes building safe scripts inviable, we're at risk of a user running scripts against production unintentionally.

ricardoavelocity avatar Jun 28 '24 17:06 ricardoavelocity

Hi @ricardoavelocity,

Can you please give more details how you are trying to set up the environment so that we can have a better understanding of your use case?

antoniofruci avatar Jul 01 '24 10:07 antoniofruci

Hey Antonio,

We're trying to create a script that compares the files in the local git repository to the files in NetSuite production prior to a deploy, to avoid accidental overwrites of code changes done through other channels other than the repository. We plan on running the script in local dev machines (Mac and PC), using node as the runtime. We would also like to eventually apply continuous deployment and have this step done from within a runner in Gitlab.

Thank you

On Mon, Jul 1, 2024 at 3:29 AM Antonio Fruci @.***> wrote:

Hi @ricardoavelocity https://github.com/ricardoavelocity,

Can you please give more details how you are trying to set up the environment so that we can have a better understanding of your use case?

— Reply to this email directly, view it on GitHub https://github.com/oracle/netsuite-suitecloud-sdk/issues/812#issuecomment-2199787707, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4F3VMAH3FMA6Q32DMD37MDZKEVQPAVCNFSM6AAAAABKCIN2MGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJZG44DONZQG4 . You are receiving this because you were mentioned.Message ID: @.***>

-- *CONFIDENTIALITY NOTICE: *The information contained in this message may contain legally privileged and/or confidential information intended for the use of the individual or entity named above. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any release, dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the author immediately by replying to this message and delete the original message.

ricardoavelocity avatar Jul 02 '24 15:07 ricardoavelocity

@ricardoavelocity

So just to understand. Your need is that, As a user, you should be able to run account:setup command non-interactively. And by running that command you should be able to see your currently set authid (the default account) for the project, and also should be able to change it non-interactively?

FYI: You can programatically check the current authid (account set for the project), in project.json file, and also you can write a script to change the authid in that file.

alisyed-19 avatar Jul 04 '24 07:07 alisyed-19

Correct! I did notice after opening the issue that it was as simple as changing the JSON file by looking at the code. I'm calling pieces of the SDK directly since there's no CLI command for them.

So I'm using getProjectDefaultAuthId to get the value I need. If it could receive CLI access it'd be great. Or make the SDK an npm package that we can use from inside node.js? A node API wouldn't be bad either :)

And I improved this code to preserve any other content in the project.json file:

function setDefaultAuthentication(projectFolder, authId) { try {

    // it now preserves other configuration values, it doesn't in

the original SDK file const projectConfiguration =FileUtils.readAsJson(path.join(projectFolder, FILES.PROJECT_JSON)); projectConfiguration[DEFAULT_AUTH_ID_PROPERTY] = authId;

    FileUtils.create(path.join(projectFolder, FILES.PROJECT_JSON),

projectConfiguration); } catch (error) { const errorMessage = error != null ? error.message : ''; throw new Error(Error writing project.json: ${errorMessage}); } }

What I'm really looking for is the type of account. If there would be a JSON output flag for --info, it'd also be great.

async function getAccountType() { const currentAuthId = getProjectDefaultAuthId('.'); const manageAuthResult = await exec(suitecloud account:manageauth --info ${currentAuthId}); /** @type {AccountInfo} */ const authConfigInfo = manageAuthResult.stdout .toString() .trim() .replace('\x1B[2K\x1B[1G', '') .split('\n') .reduce((acc, item) => { const index = item.indexOf(':'); const key = item.substring(0, index).replace(' ', ''); acc[key] = item.substring(index + 1).trim(); return acc; }, {}); if (verbose) console.log(JSON.stringify(authConfigInfo, null, 2)); return authConfigInfo.AccountType; }

/**

  • @typedef {Object} AccountInfo
  • @property {string} AuthenticationID - The authentication ID.
  • @property {string} AccountName - The name of the account.
  • @property {string} AccountID - The ID of the account.
  • @property {string} Role - The role associated with the account.
  • @property {string} Domain - The domain of the account.
  • @property {string} AccountType - The type of the account. */

Finally I check if it's production, which is what I need from the SDK. After that I'm importing files from production to confirm my repo is still in sync and I won't be overwriting any changes made directly to prod by other means.

const accountType = await getAccountType(); if (accountType !== 'Production') { throw new Error(Account type is ${accountType}; expected Production); } else { console.info('Account type is Production; continuing...'); }

Cheers!

On Thu, Jul 4, 2024 at 12:50 AM Syed Mohammad Ali @.***> wrote:

@ricardoavelocity https://github.com/ricardoavelocity

So just to understand. Your need is that, As a user, you should be able to run account:setup command non-interactively. And by running that command you should be able to see your currently set authid (the default account) for the project, and also should be able to change it non-interactively?

FYI: You can programatically check the current authid (account set for the project), in project.json file, and also you can write a script to change the authid in that file.

— Reply to this email directly, view it on GitHub https://github.com/oracle/netsuite-suitecloud-sdk/issues/812#issuecomment-2208334824, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4F3VMEE6GZX7LXCTIKEHRDZKT5FVAVCNFSM6AAAAABKCIN2MGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBYGMZTIOBSGQ . You are receiving this because you were mentioned.Message ID: @.***>

-- *CONFIDENTIALITY NOTICE: *The information contained in this message may contain legally privileged and/or confidential information intended for the use of the individual or entity named above. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any release, dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the author immediately by replying to this message and delete the original message.

ricardoavelocity avatar Jul 04 '24 15:07 ricardoavelocity

Hi @ricardoavelocity,

We’re excited to announce a new feature in the SuiteCloud CLI for Node! The latest release includes a new flag for the account:setup:ci command, allowing you to configure your authentication ID for your SuiteCloud project in CI mode—no browser-based login required.

You can download the latest release here: https://github.com/oracle/netsuite-suitecloud-sdk/releases Learn more about the new command flag in our documentation: https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/article_81134826821.html Let us know if you have any questions!

veronicacbs avatar Oct 20 '25 10:10 veronicacbs

Thank you! Will definitely check it out. Have a great day

On Mon, Oct 20, 2025 at 3:30 AM Veronica Cabanillas Sanchez < @.***> wrote:

veronicacbs left a comment (oracle/netsuite-suitecloud-sdk#812) https://github.com/oracle/netsuite-suitecloud-sdk/issues/812#issuecomment-3421490426

Hi @ricardoavelocity https://github.com/ricardoavelocity,

We’re excited to announce a new feature in the SuiteCloud CLI for Node! The latest release includes a new flag for the account:setup:ci command, allowing you to configure your authentication ID for your SuiteCloud project in CI mode—no browser-based login required.

You can download the latest release here: https://github.com/oracle/netsuite-suitecloud-sdk/releases Learn more about the new command flag in our documentation: https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/article_81134826821.html

Let us know if you have any questions!

— Reply to this email directly, view it on GitHub https://github.com/oracle/netsuite-suitecloud-sdk/issues/812#issuecomment-3421490426, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4F3VMHUX26KVXWYVHR7EUT3YS2STAVCNFSM6AAAAACJVJFMDOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTIMRRGQ4TANBSGY . You are receiving this because you were mentioned.Message ID: @.***>

-- *CONFIDENTIALITY NOTICE: *The information contained in this message may contain legally privileged and/or confidential information intended for the use of the individual or entity named above. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any release, dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the author immediately by replying to this message and delete the original message.

ricardoavelocity avatar Oct 20 '25 17:10 ricardoavelocity