-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
account:setup cli mode executes in interactive mode without -i #812
Comments
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? |
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
<#812 (comment)>,
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.
|
So just to understand. Your need is that, As a user, you should be able to run account:setup command 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. |
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
<#812 (comment)>,
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.
|
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.
The text was updated successfully, but these errors were encountered: