@suitegeezus/suitecloud-cli 3.1.6-3 → 3.1.6-6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/DELTA.md CHANGED
@@ -17,7 +17,7 @@
17
17
  - `customflag` option available on any command including in interactive
18
18
  - `customoptions` option available on any command including in interactive
19
19
  - `debug` option available on any command including in interactive
20
- - `skiphooks` option available on any command including in interactive
20
+ - `runhooks` option available on any command including in interactive
21
21
 
22
22
  <p align="left"><a href="#"><img width="250" src="resources/Netsuite-logo-ocean-150-bg.png"></a></p>
23
23
 
package/README.md CHANGED
@@ -21,7 +21,7 @@ Read the full list of prerequisites in [SuiteCloud CLI for Node.js Installation
21
21
  ## Supported Versions
22
22
  This is a fork of `@oracle/suitecloud-cli`. It supports older command lines but with a new binary `sdf`.
23
23
 
24
- It is enhanced for easier customizing via hooks. See [./DELTA.md] for more
24
+ It is enhanced for easier customizing via hooks. See [DELTA.md](./DELTA.md) for more
25
25
 
26
26
 
27
27
  ## Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suitegeezus/suitecloud-cli",
3
- "version": "3.1.6-3",
3
+ "version": "3.1.6-6",
4
4
  "license": "UPL-1.0",
5
5
  "description": "SuiteCloud CLI for Node.js",
6
6
  "keywords": [
package/src/CLI.js CHANGED
@@ -91,21 +91,22 @@ const UBIQUITOUS_OPTIONS = {
91
91
  "defaultOption": false,
92
92
  "disableInIntegrationMode": false
93
93
  },
94
- "skiphooks": {
95
- "name": "skiphooks",
96
- "option": "skiphooks",
94
+ "runhooks": {
95
+ "name": "runhooks",
96
+ "option": "runhooks",
97
97
  "description": "Skip hook execution. Usage:\n" + [
98
- '"--skiphooks all" (skip all)',
99
- '"--skiphooks pre" (skip beforeExecuting)',
100
- '"--skiphooks post" (skip onCompleted/onError)',
101
- '"--skiphooks none" (skip nothing -- default)'
98
+ '"--runhooks all" (run all -- default)',
99
+ '"--runhooks pre" (run beforeExecuting only)',
100
+ '"--runhooks post" (run onCompleted/onError)',
101
+ '"--runhooks quiet" (same as all but if you are creating interactions you can use this as a clue to avoid interactions)',
102
+ '"--runhooks none" (run nothing)'
102
103
  ].join('\n'),
103
104
  "allowInteractive":true,
104
105
  "forceinclude": true,
105
106
  "mandatory": false,
106
107
  "type": "SINGLE",
107
108
  "usage": "\"pre|post|all|none\"",
108
- "defaultOption": "none",
109
+ "defaultOption": "all",
109
110
  "disableInIntegrationMode": false
110
111
  }
111
112
  };
@@ -157,7 +158,7 @@ module.exports = class CLI {
157
158
  .option(
158
159
  `${INTERACTIVE_ALIAS}, ${INTERACTIVE_OPTION}`,
159
160
  NodeTranslationService.getMessage(INTERACTIVE_OPTION_DESCRIPTION),
160
- this._validateInteractive(commandMetadataList[thirdArgument].options)
161
+ this._validateInteractive(commandMetadataList[thirdArgument]?.options)
161
162
  )
162
163
  .helpOption(`${HELP_ALIAS}, ${HELP_OPTION}`, NodeTranslationService.getMessage(COMMAND_OPTIONS.HELP))
163
164
  .addHelpCommand(`${HELP_COMMAND} ${COMMAND_ALIAS}`, NodeTranslationService.getMessage(COMMAND_OPTIONS.HELP))
@@ -187,19 +188,21 @@ module.exports = class CLI {
187
188
 
188
189
  _validateInteractive(additionalOptions) {
189
190
  let additionalAllowed = 0;
190
- const ubiquitousValuesThatAreInteractive = Object.values(UBIQUITOUS_OPTIONS)
191
- .concat(Object.values(additionalOptions))
192
- .filter((o)=>o.allowInteractive)
193
- .map((o)=>({
194
- name: o.name,
195
- additionalAllowed: o.type === "SINGLE" ? 2 : 1
196
- }))
197
- process.argv.forEach((arg)=>{
198
- const mactchingOption = ubiquitousValuesThatAreInteractive.find(
199
- (o)=>(`--${o.name}` === arg)
200
- );
201
- additionalAllowed += mactchingOption?.additionalAllowed || 0;
202
- });
191
+ if( additionalOptions) {
192
+ const ubiquitousValuesThatAreInteractive = Object.values(UBIQUITOUS_OPTIONS)
193
+ .concat(Object.values(additionalOptions))
194
+ .filter((o) => o.allowInteractive)
195
+ .map((o) => ({
196
+ name: o.name,
197
+ additionalAllowed: o.type === "SINGLE" ? 2 : 1
198
+ }))
199
+ process.argv.forEach((arg) => {
200
+ const mactchingOption = ubiquitousValuesThatAreInteractive.find(
201
+ (o) => (`--${o.name}` === arg)
202
+ );
203
+ additionalAllowed += mactchingOption?.additionalAllowed || 0;
204
+ });
205
+ }
203
206
  return ()=> {
204
207
  if (process.argv.length > (4 + additionalAllowed)) {
205
208
  // There are more options apart from -i or --interactive
@@ -25,7 +25,7 @@ const NEVER_PARAMS = {
25
25
  'CUSTOMFLAG': 'customflag',
26
26
  'CUSTOMOPTIONS': 'customoptions',
27
27
  'DEBUG': 'debug',
28
- 'SKIPHOOKS': 'skiphooks'
28
+ 'RUNHOOKS': 'runhooks'
29
29
  };
30
30
 
31
31
  /** @type {import('./Command')} */
@@ -53,7 +53,8 @@ module.exports = class CommandActionExecutor {
53
53
  let commandUserExtension;
54
54
  const commandName = context.commandName;
55
55
  const debugFilePath = this._getDebugFilePath(context.arguments.debug, commandName);
56
- const skipHooks = context.arguments.skiphooks;
56
+ /** @type {'pre'|'post'|'quiet'|'none'|'all'} */
57
+ const runHooks = context.arguments.runhooks;
57
58
  try {
58
59
  const commandMetadata = this._commandsMetadataService.getCommandMetadataByName(commandName);
59
60
  if (context.arguments.config) {
@@ -148,7 +149,7 @@ module.exports = class CommandActionExecutor {
148
149
  process.env[ENV_VARS.SUITECLOUD_EXE] = this._binaryName;
149
150
  // this might modified but we need the user's hooks to take advantage of their current values
150
151
  process.env[ENV_VARS.SUITECLOUD_AUTHID] = authId;
151
- const skipPre = skipHooks === 'pre' || skipHooks === 'all';
152
+ const skipPre = runHooks === 'post' || runHooks === 'none';
152
153
  this._dumpDebugFile(debugFilePath, undefined, 'FIRST', runInInteractiveMode, skipPre);
153
154
  this._dumpDebugFile(debugFilePath, 'beforeExecuting', beforeExecutingOptions, runInInteractiveMode, skipPre);
154
155
  const beforeExecutingOutput = skipPre
@@ -180,7 +181,7 @@ module.exports = class CommandActionExecutor {
180
181
  // command execution
181
182
  // src/commands/Command.js, run(inputParams) => execution flow for all commands
182
183
  const actionResult = await command.run(overriddenArguments);
183
- const skipPost = skipHooks === 'post' || skipHooks === 'all';
184
+ const skipPost = runHooks === 'pre' || runHooks === 'none';
184
185
 
185
186
  if (context.runInInteractiveMode) {
186
187
  // generate non-interactive equivalent
@@ -202,7 +203,7 @@ module.exports = class CommandActionExecutor {
202
203
 
203
204
  } catch (error) {
204
205
  let errorMessage = this._logGenericError(error);
205
- const skipPostHooksCatch = skipHooks === 'post' || skipHooks === 'all';
206
+ const skipPostHooksCatch = runHooks === 'pre' || runHooks === 'none';
206
207
  if (commandUserExtension && commandUserExtension.onError) {
207
208
  // run onError(error) from suitecloud.config.js
208
209
  this._dumpDebugFile(debugFilePath, 'onError', error, context.runInInteractiveMode, skipPostHooksCatch);