@sonisoft/now-sdk-ext-cli 1.0.0-alpha.0
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/README.md +392 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +6 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +5 -0
- package/dist/commands/exec/index.d.ts +13 -0
- package/dist/commands/exec/index.d.ts.map +1 -0
- package/dist/commands/exec/index.js +51 -0
- package/dist/commands/exec/index.js.map +1 -0
- package/dist/common/authenticated-command.d.ts +21 -0
- package/dist/common/authenticated-command.d.ts.map +1 -0
- package/dist/common/authenticated-command.js +60 -0
- package/dist/common/authenticated-command.js.map +1 -0
- package/dist/common/base-command.d.ts +19 -0
- package/dist/common/base-command.d.ts.map +1 -0
- package/dist/common/base-command.js +43 -0
- package/dist/common/base-command.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/oclif.manifest.json +73 -0
- package/package.json +111 -0
package/README.md
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
@sonisoft/now-sdk-ext-cli
|
|
2
|
+
=================
|
|
3
|
+
|
|
4
|
+
A CLI extending the functionality of the ServiceNow SDK.
|
|
5
|
+
|
|
6
|
+
Future capabilities will be expanded, but currently this CLI will allow you to execute a javascript file that resides on your local computer in a ServiceNow instance remotely.
|
|
7
|
+
This mimicks the functionality of using Scripts - Background and has all of the caveats and warnings carried in doing so.
|
|
8
|
+
|
|
9
|
+
This library extends the ServiceNow SDK published originally in Washington DC. Currently you must use the ServiceNow SDK to configure your authentication credentials for a particular ServiceNow instance. Then the credential alias configured using the ServiceNow SDK can be passed
|
|
10
|
+
to the command(s) below.
|
|
11
|
+
|
|
12
|
+
The library has a built in dependency for @servicenow/sdk version 2.0.1.
|
|
13
|
+
You will need to install the SDK globally separately in order to use the now-sdk command.
|
|
14
|
+
|
|
15
|
+
Note:
|
|
16
|
+
One of the current limitations of the ServiceNow SDK is that it does not work if Multifactor Authentication is enable on the user that is being used with the SDK.
|
|
17
|
+
Either MFA on the instance needs to be turned off, or the local user account being used needs to be excluded from the MFA configuration.
|
|
18
|
+
-- Future work of this CLI is intended to overcome this issue.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<!-- toc -->
|
|
22
|
+
* [Usage](#usage)
|
|
23
|
+
* [Commands](#commands)
|
|
24
|
+
<!-- tocstop -->
|
|
25
|
+
# Usage
|
|
26
|
+
<!-- usage -->
|
|
27
|
+
```sh-session
|
|
28
|
+
$ npm install -g @sonisoft/now-sdk-ext-cli
|
|
29
|
+
$ nex COMMAND
|
|
30
|
+
running command...
|
|
31
|
+
$ nex (--version)
|
|
32
|
+
@sonisoft/now-sdk-ext-cli/1.0.0-alpha.0 darwin-arm64 node-v22.2.0
|
|
33
|
+
$ nex --help [COMMAND]
|
|
34
|
+
USAGE
|
|
35
|
+
$ nex COMMAND
|
|
36
|
+
...
|
|
37
|
+
```
|
|
38
|
+
<!-- usagestop -->
|
|
39
|
+
# Commands
|
|
40
|
+
<!-- commands -->
|
|
41
|
+
* [`nex exec SCOPE FILE`](#nex-exec-scope-file)
|
|
42
|
+
* [`nex help [COMMAND]`](#nex-help-command)
|
|
43
|
+
* [`nex plugins`](#nex-plugins)
|
|
44
|
+
* [`nex plugins add PLUGIN`](#nex-plugins-add-plugin)
|
|
45
|
+
* [`nex plugins:inspect PLUGIN...`](#nex-pluginsinspect-plugin)
|
|
46
|
+
* [`nex plugins install PLUGIN`](#nex-plugins-install-plugin)
|
|
47
|
+
* [`nex plugins link PATH`](#nex-plugins-link-path)
|
|
48
|
+
* [`nex plugins remove [PLUGIN]`](#nex-plugins-remove-plugin)
|
|
49
|
+
* [`nex plugins reset`](#nex-plugins-reset)
|
|
50
|
+
* [`nex plugins uninstall [PLUGIN]`](#nex-plugins-uninstall-plugin)
|
|
51
|
+
* [`nex plugins unlink [PLUGIN]`](#nex-plugins-unlink-plugin)
|
|
52
|
+
* [`nex plugins update`](#nex-plugins-update)
|
|
53
|
+
|
|
54
|
+
## `nex exec SCOPE FILE`
|
|
55
|
+
|
|
56
|
+
Execute a local javascript file on a ServiceNow instance using Scripts - Background remotely. Returns the output/raw console output that Scripts - Background outputs to the browser in order to support the execution and result being piped to another command.
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
USAGE
|
|
60
|
+
$ nex exec SCOPE FILE [--json] [-a <value>] [--log-level debug|warn|error|info|trace]
|
|
61
|
+
|
|
62
|
+
ARGUMENTS
|
|
63
|
+
SCOPE Scope to execute file in.
|
|
64
|
+
FILE File to execute in scripts background.
|
|
65
|
+
|
|
66
|
+
FLAGS
|
|
67
|
+
-a, --auth=<value> Auth alias to use.
|
|
68
|
+
|
|
69
|
+
GLOBAL FLAGS
|
|
70
|
+
--json Format output as json.
|
|
71
|
+
--log-level=<option> [default: info] Specify level for logging.
|
|
72
|
+
<options: debug|warn|error|info|trace>
|
|
73
|
+
|
|
74
|
+
DESCRIPTION
|
|
75
|
+
Execute a local javascript file on a ServiceNow instance using Scripts - Background remotely. Returns the output/raw
|
|
76
|
+
console output that Scripts - Background outputs to the browser in order to support the execution and result being
|
|
77
|
+
piped to another command.
|
|
78
|
+
|
|
79
|
+
EXAMPLES
|
|
80
|
+
$ nex exec exec global test.js --auth sn_alias
|
|
81
|
+
test
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## `nex help [COMMAND]`
|
|
85
|
+
|
|
86
|
+
Display help for nex.
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
USAGE
|
|
90
|
+
$ nex help [COMMAND...] [-n]
|
|
91
|
+
|
|
92
|
+
ARGUMENTS
|
|
93
|
+
COMMAND... Command to show help for.
|
|
94
|
+
|
|
95
|
+
FLAGS
|
|
96
|
+
-n, --nested-commands Include all nested commands in the output.
|
|
97
|
+
|
|
98
|
+
DESCRIPTION
|
|
99
|
+
Display help for nex.
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.13/src/commands/help.ts)_
|
|
103
|
+
|
|
104
|
+
## `nex plugins`
|
|
105
|
+
|
|
106
|
+
List installed plugins.
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
USAGE
|
|
110
|
+
$ nex plugins [--json] [--core]
|
|
111
|
+
|
|
112
|
+
FLAGS
|
|
113
|
+
--core Show core plugins.
|
|
114
|
+
|
|
115
|
+
GLOBAL FLAGS
|
|
116
|
+
--json Format output as json.
|
|
117
|
+
|
|
118
|
+
DESCRIPTION
|
|
119
|
+
List installed plugins.
|
|
120
|
+
|
|
121
|
+
EXAMPLES
|
|
122
|
+
$ nex plugins
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.10/src/commands/plugins/index.ts)_
|
|
126
|
+
|
|
127
|
+
## `nex plugins add PLUGIN`
|
|
128
|
+
|
|
129
|
+
Installs a plugin into nex.
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
USAGE
|
|
133
|
+
$ nex plugins add PLUGIN... [--json] [-f] [-h] [-s | -v]
|
|
134
|
+
|
|
135
|
+
ARGUMENTS
|
|
136
|
+
PLUGIN... Plugin to install.
|
|
137
|
+
|
|
138
|
+
FLAGS
|
|
139
|
+
-f, --force Force npm to fetch remote resources even if a local copy exists on disk.
|
|
140
|
+
-h, --help Show CLI help.
|
|
141
|
+
-s, --silent Silences npm output.
|
|
142
|
+
-v, --verbose Show verbose npm output.
|
|
143
|
+
|
|
144
|
+
GLOBAL FLAGS
|
|
145
|
+
--json Format output as json.
|
|
146
|
+
|
|
147
|
+
DESCRIPTION
|
|
148
|
+
Installs a plugin into nex.
|
|
149
|
+
|
|
150
|
+
Uses npm to install plugins.
|
|
151
|
+
|
|
152
|
+
Installation of a user-installed plugin will override a core plugin.
|
|
153
|
+
|
|
154
|
+
Use the NEX_NPM_LOG_LEVEL environment variable to set the npm loglevel.
|
|
155
|
+
Use the NEX_NPM_REGISTRY environment variable to set the npm registry.
|
|
156
|
+
|
|
157
|
+
ALIASES
|
|
158
|
+
$ nex plugins add
|
|
159
|
+
|
|
160
|
+
EXAMPLES
|
|
161
|
+
Install a plugin from npm registry.
|
|
162
|
+
|
|
163
|
+
$ nex plugins add myplugin
|
|
164
|
+
|
|
165
|
+
Install a plugin from a github url.
|
|
166
|
+
|
|
167
|
+
$ nex plugins add https://github.com/someuser/someplugin
|
|
168
|
+
|
|
169
|
+
Install a plugin from a github slug.
|
|
170
|
+
|
|
171
|
+
$ nex plugins add someuser/someplugin
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## `nex plugins:inspect PLUGIN...`
|
|
175
|
+
|
|
176
|
+
Displays installation properties of a plugin.
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
USAGE
|
|
180
|
+
$ nex plugins inspect PLUGIN...
|
|
181
|
+
|
|
182
|
+
ARGUMENTS
|
|
183
|
+
PLUGIN... [default: .] Plugin to inspect.
|
|
184
|
+
|
|
185
|
+
FLAGS
|
|
186
|
+
-h, --help Show CLI help.
|
|
187
|
+
-v, --verbose
|
|
188
|
+
|
|
189
|
+
GLOBAL FLAGS
|
|
190
|
+
--json Format output as json.
|
|
191
|
+
|
|
192
|
+
DESCRIPTION
|
|
193
|
+
Displays installation properties of a plugin.
|
|
194
|
+
|
|
195
|
+
EXAMPLES
|
|
196
|
+
$ nex plugins inspect myplugin
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.10/src/commands/plugins/inspect.ts)_
|
|
200
|
+
|
|
201
|
+
## `nex plugins install PLUGIN`
|
|
202
|
+
|
|
203
|
+
Installs a plugin into nex.
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
USAGE
|
|
207
|
+
$ nex plugins install PLUGIN... [--json] [-f] [-h] [-s | -v]
|
|
208
|
+
|
|
209
|
+
ARGUMENTS
|
|
210
|
+
PLUGIN... Plugin to install.
|
|
211
|
+
|
|
212
|
+
FLAGS
|
|
213
|
+
-f, --force Force npm to fetch remote resources even if a local copy exists on disk.
|
|
214
|
+
-h, --help Show CLI help.
|
|
215
|
+
-s, --silent Silences npm output.
|
|
216
|
+
-v, --verbose Show verbose npm output.
|
|
217
|
+
|
|
218
|
+
GLOBAL FLAGS
|
|
219
|
+
--json Format output as json.
|
|
220
|
+
|
|
221
|
+
DESCRIPTION
|
|
222
|
+
Installs a plugin into nex.
|
|
223
|
+
|
|
224
|
+
Uses npm to install plugins.
|
|
225
|
+
|
|
226
|
+
Installation of a user-installed plugin will override a core plugin.
|
|
227
|
+
|
|
228
|
+
Use the NEX_NPM_LOG_LEVEL environment variable to set the npm loglevel.
|
|
229
|
+
Use the NEX_NPM_REGISTRY environment variable to set the npm registry.
|
|
230
|
+
|
|
231
|
+
ALIASES
|
|
232
|
+
$ nex plugins add
|
|
233
|
+
|
|
234
|
+
EXAMPLES
|
|
235
|
+
Install a plugin from npm registry.
|
|
236
|
+
|
|
237
|
+
$ nex plugins install myplugin
|
|
238
|
+
|
|
239
|
+
Install a plugin from a github url.
|
|
240
|
+
|
|
241
|
+
$ nex plugins install https://github.com/someuser/someplugin
|
|
242
|
+
|
|
243
|
+
Install a plugin from a github slug.
|
|
244
|
+
|
|
245
|
+
$ nex plugins install someuser/someplugin
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.10/src/commands/plugins/install.ts)_
|
|
249
|
+
|
|
250
|
+
## `nex plugins link PATH`
|
|
251
|
+
|
|
252
|
+
Links a plugin into the CLI for development.
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
USAGE
|
|
256
|
+
$ nex plugins link PATH [-h] [--install] [-v]
|
|
257
|
+
|
|
258
|
+
ARGUMENTS
|
|
259
|
+
PATH [default: .] path to plugin
|
|
260
|
+
|
|
261
|
+
FLAGS
|
|
262
|
+
-h, --help Show CLI help.
|
|
263
|
+
-v, --verbose
|
|
264
|
+
--[no-]install Install dependencies after linking the plugin.
|
|
265
|
+
|
|
266
|
+
DESCRIPTION
|
|
267
|
+
Links a plugin into the CLI for development.
|
|
268
|
+
Installation of a linked plugin will override a user-installed or core plugin.
|
|
269
|
+
|
|
270
|
+
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
|
|
271
|
+
command will override the user-installed or core plugin implementation. This is useful for development work.
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
EXAMPLES
|
|
275
|
+
$ nex plugins link myplugin
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.10/src/commands/plugins/link.ts)_
|
|
279
|
+
|
|
280
|
+
## `nex plugins remove [PLUGIN]`
|
|
281
|
+
|
|
282
|
+
Removes a plugin from the CLI.
|
|
283
|
+
|
|
284
|
+
```
|
|
285
|
+
USAGE
|
|
286
|
+
$ nex plugins remove [PLUGIN...] [-h] [-v]
|
|
287
|
+
|
|
288
|
+
ARGUMENTS
|
|
289
|
+
PLUGIN... plugin to uninstall
|
|
290
|
+
|
|
291
|
+
FLAGS
|
|
292
|
+
-h, --help Show CLI help.
|
|
293
|
+
-v, --verbose
|
|
294
|
+
|
|
295
|
+
DESCRIPTION
|
|
296
|
+
Removes a plugin from the CLI.
|
|
297
|
+
|
|
298
|
+
ALIASES
|
|
299
|
+
$ nex plugins unlink
|
|
300
|
+
$ nex plugins remove
|
|
301
|
+
|
|
302
|
+
EXAMPLES
|
|
303
|
+
$ nex plugins remove myplugin
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## `nex plugins reset`
|
|
307
|
+
|
|
308
|
+
Remove all user-installed and linked plugins.
|
|
309
|
+
|
|
310
|
+
```
|
|
311
|
+
USAGE
|
|
312
|
+
$ nex plugins reset [--hard] [--reinstall]
|
|
313
|
+
|
|
314
|
+
FLAGS
|
|
315
|
+
--hard Delete node_modules and package manager related files in addition to uninstalling plugins.
|
|
316
|
+
--reinstall Reinstall all plugins after uninstalling.
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.10/src/commands/plugins/reset.ts)_
|
|
320
|
+
|
|
321
|
+
## `nex plugins uninstall [PLUGIN]`
|
|
322
|
+
|
|
323
|
+
Removes a plugin from the CLI.
|
|
324
|
+
|
|
325
|
+
```
|
|
326
|
+
USAGE
|
|
327
|
+
$ nex plugins uninstall [PLUGIN...] [-h] [-v]
|
|
328
|
+
|
|
329
|
+
ARGUMENTS
|
|
330
|
+
PLUGIN... plugin to uninstall
|
|
331
|
+
|
|
332
|
+
FLAGS
|
|
333
|
+
-h, --help Show CLI help.
|
|
334
|
+
-v, --verbose
|
|
335
|
+
|
|
336
|
+
DESCRIPTION
|
|
337
|
+
Removes a plugin from the CLI.
|
|
338
|
+
|
|
339
|
+
ALIASES
|
|
340
|
+
$ nex plugins unlink
|
|
341
|
+
$ nex plugins remove
|
|
342
|
+
|
|
343
|
+
EXAMPLES
|
|
344
|
+
$ nex plugins uninstall myplugin
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.10/src/commands/plugins/uninstall.ts)_
|
|
348
|
+
|
|
349
|
+
## `nex plugins unlink [PLUGIN]`
|
|
350
|
+
|
|
351
|
+
Removes a plugin from the CLI.
|
|
352
|
+
|
|
353
|
+
```
|
|
354
|
+
USAGE
|
|
355
|
+
$ nex plugins unlink [PLUGIN...] [-h] [-v]
|
|
356
|
+
|
|
357
|
+
ARGUMENTS
|
|
358
|
+
PLUGIN... plugin to uninstall
|
|
359
|
+
|
|
360
|
+
FLAGS
|
|
361
|
+
-h, --help Show CLI help.
|
|
362
|
+
-v, --verbose
|
|
363
|
+
|
|
364
|
+
DESCRIPTION
|
|
365
|
+
Removes a plugin from the CLI.
|
|
366
|
+
|
|
367
|
+
ALIASES
|
|
368
|
+
$ nex plugins unlink
|
|
369
|
+
$ nex plugins remove
|
|
370
|
+
|
|
371
|
+
EXAMPLES
|
|
372
|
+
$ nex plugins unlink myplugin
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
## `nex plugins update`
|
|
376
|
+
|
|
377
|
+
Update installed plugins.
|
|
378
|
+
|
|
379
|
+
```
|
|
380
|
+
USAGE
|
|
381
|
+
$ nex plugins update [-h] [-v]
|
|
382
|
+
|
|
383
|
+
FLAGS
|
|
384
|
+
-h, --help Show CLI help.
|
|
385
|
+
-v, --verbose
|
|
386
|
+
|
|
387
|
+
DESCRIPTION
|
|
388
|
+
Update installed plugins.
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.10/src/commands/plugins/update.ts)_
|
|
392
|
+
<!-- commandsstop -->
|
package/bin/dev.cmd
ADDED
package/bin/dev.js
ADDED
package/bin/run.cmd
ADDED
package/bin/run.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AuthenticatedCommand } from '../../common/authenticated-command.js';
|
|
2
|
+
export declare class Exec extends AuthenticatedCommand<typeof Exec> {
|
|
3
|
+
static args: {
|
|
4
|
+
scope: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
|
|
5
|
+
file: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
static description: string;
|
|
8
|
+
static examples: string[];
|
|
9
|
+
static flags: {};
|
|
10
|
+
private _logger;
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/exec/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAE5E,qBAAa,IAAK,SAAQ,oBAAoB,CAAC,OAAO,IAAI,CAAC;IAEzD,MAAM,CAAC,IAAI;;;MAGV;IAED,MAAM,CAAC,WAAW,SAAuQ;IAEzR,MAAM,CAAC,QAAQ,WAId;IAED,MAAM,CAAC,KAAK,KAEX;IAED,OAAO,CAAC,OAAO,CAAoC;IAE7C,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA+B3B"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
/* eslint-disable perfectionist/sort-objects */
|
|
3
|
+
import { Args } from '@oclif/core';
|
|
4
|
+
import { BackgroundScriptExecutor, Logger, NowStringUtil } from '@sonisoft/now-sdk-ext-core';
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { AuthenticatedCommand } from '../../common/authenticated-command.js';
|
|
8
|
+
export class Exec extends AuthenticatedCommand {
|
|
9
|
+
static args = {
|
|
10
|
+
scope: Args.string({ description: 'Scope to execute file in.', required: true }),
|
|
11
|
+
file: Args.string({ description: 'File to execute in scripts background.', required: true }),
|
|
12
|
+
};
|
|
13
|
+
static description = 'Execute a local javascript file on a ServiceNow instance using Scripts - Background remotely. Returns the output/raw console output that Scripts - Background outputs to the browser in order to support the execution and result being piped to another command.';
|
|
14
|
+
static examples = [
|
|
15
|
+
`<%= config.bin %> <%= command.id %> exec global test.js --auth sn_alias
|
|
16
|
+
test
|
|
17
|
+
`,
|
|
18
|
+
];
|
|
19
|
+
static flags = {
|
|
20
|
+
// from: Flags.string({char: 'f', description: 'Who is saying hello', required: true}),
|
|
21
|
+
};
|
|
22
|
+
_logger = new Logger("ExecCommand");
|
|
23
|
+
async run() {
|
|
24
|
+
const { args, flags } = await this.parse(Exec);
|
|
25
|
+
if (!NowStringUtil.isStringEmpty(args.file) && !NowStringUtil.isStringEmpty(args.scope)) {
|
|
26
|
+
try {
|
|
27
|
+
const filePath = path.resolve(args.file);
|
|
28
|
+
const script = fs.readFileSync(filePath).toString('utf8');
|
|
29
|
+
const scope = args.scope ?? "global";
|
|
30
|
+
const executor = new BackgroundScriptExecutor(this.instance, args.scope);
|
|
31
|
+
;
|
|
32
|
+
const result = await executor.executeScript(script, scope, this.instance);
|
|
33
|
+
this._logger.debug("Ran background script", result);
|
|
34
|
+
if (result !== null && result.scriptResults !== null) {
|
|
35
|
+
const { scriptResults } = result;
|
|
36
|
+
for (const scriptResult of scriptResults) {
|
|
37
|
+
this.log(scriptResult.line);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
throw new Error("Response from script execution was null or undefined. Please review logs to identify the problem.");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
this._logger.error("Error occurred when executing background script.", error);
|
|
46
|
+
this.error(error);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/exec/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,+CAA+C;AAC/C,OAAO,EAAC,IAAI,EAAiB,MAAM,aAAa,CAAA;AAChD,OAAO,EAAmC,wBAAwB,EAAG,MAAM,EAAE,aAAa,EAAuB,MAAM,4BAA4B,CAAC;AACpJ,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAE5E,MAAM,OAAO,IAAK,SAAQ,oBAAiC;IAEzD,MAAM,CAAC,IAAI,GAAG;QACZ,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,EAAC,WAAW,EAAE,2BAA2B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,MAAM,CAAC,aAAa,KAAK,IAAI,EAAC,CAAC;oBACnD,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,CAAC;oBAC/B,KAAI,MAAM,YAAY,IAAI,aAAa,EAAC,CAAC;wBACvC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;oBAC9B,CAAC;gBAEH,CAAC;qBAAI,CAAC;oBACJ,MAAM,IAAI,KAAK,CAAC,mGAAmG,CAAC,CAAC;gBACvH,CAAC;YAEH,CAAC;YAAA,OAAM,KAAK,EAAC,CAAC;gBACZ,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,kDAAkD,EAAE,KAAc,CAAC,CAAC;gBACvF,IAAI,CAAC,KAAK,CAAC,KAAc,CAAC,CAAC;YAC7B,CAAC;QAGH,CAAC;IAEH,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Command, Interfaces } from '@oclif/core';
|
|
2
|
+
import { Logger, ServiceNowInstance } from '@sonisoft/now-sdk-ext-core';
|
|
3
|
+
export type Flags<T extends typeof Command> = Interfaces.InferredFlags<T['flags'] & typeof AuthenticatedCommand['baseFlags']>;
|
|
4
|
+
export type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
|
|
5
|
+
export declare abstract class AuthenticatedCommand<T extends typeof Command> extends Command {
|
|
6
|
+
static baseFlags: {
|
|
7
|
+
auth: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
8
|
+
'log-level': Interfaces.OptionFlag<"info" | "debug" | "warn" | "error" | "trace", Interfaces.CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
static enableJsonFlag: boolean;
|
|
11
|
+
protected args: Args<T>;
|
|
12
|
+
protected authLogger: Logger;
|
|
13
|
+
protected flags: Flags<T>;
|
|
14
|
+
protected instance: ServiceNowInstance;
|
|
15
|
+
protected catch(err: {
|
|
16
|
+
exitCode?: number;
|
|
17
|
+
} & Error): Promise<any>;
|
|
18
|
+
protected finally(_: Error | undefined): Promise<any>;
|
|
19
|
+
init(): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=authenticated-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticated-command.d.ts","sourceRoot":"","sources":["../../src/common/authenticated-command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAS,UAAU,EAAE,MAAM,aAAa,CAAA;AAExD,OAAO,EAAsB,MAAM,EAAE,kBAAkB,EAA8B,MAAM,4BAA4B,CAAC;AAExH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,OAAO,OAAO,IAAI,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,OAAO,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAA;AAC7H,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS,OAAO,OAAO,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;AAE/E,8BAAsB,oBAAoB,CAAC,CAAC,SAAS,OAAO,OAAO,CAAE,SAAQ,OAAO;IAElF,MAAM,CAAC,SAAS;;;MASf;IAGC,MAAM,CAAC,cAAc,UAAO;IAE5B,SAAS,CAAC,IAAI,EAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,SAAS,CAAC,UAAU,EAAC,MAAM,CAAsC;IACjE,SAAS,CAAC,KAAK,EAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAG3B,SAAS,CAAC,QAAQ,EAAE,kBAAkB,CAAC;cAEzB,KAAK,CAAC,GAAG,EAAE;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC;cAQrD,OAAO,CAAC,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC;IAK9C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CA+BnC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { Command, Flags } from '@oclif/core';
|
|
3
|
+
import { CredentialWrapper, Logger, ServiceNowInstance } from '@sonisoft/now-sdk-ext-core';
|
|
4
|
+
export class AuthenticatedCommand extends Command {
|
|
5
|
+
// // define flags that can be inherited by any command that extends BaseCommand
|
|
6
|
+
static baseFlags = {
|
|
7
|
+
'auth': Flags.string({ char: 'a', description: 'Auth alias to use.', required: false }),
|
|
8
|
+
'log-level': Flags.option({
|
|
9
|
+
default: 'info',
|
|
10
|
+
helpGroup: 'GLOBAL',
|
|
11
|
+
options: ['debug', 'warn', 'error', 'info', 'trace'],
|
|
12
|
+
summary: 'Specify level for logging.',
|
|
13
|
+
})(),
|
|
14
|
+
};
|
|
15
|
+
// add the --json flag
|
|
16
|
+
static enableJsonFlag = true;
|
|
17
|
+
args;
|
|
18
|
+
authLogger = new Logger("AuthenticatedCommand");
|
|
19
|
+
flags;
|
|
20
|
+
instance;
|
|
21
|
+
async catch(err) {
|
|
22
|
+
// add any custom logic to handle errors from the command
|
|
23
|
+
// or simply return the parent class error handling
|
|
24
|
+
this.authLogger.error("Globally caught exception occurred.", err);
|
|
25
|
+
return super.catch(err);
|
|
26
|
+
}
|
|
27
|
+
async finally(_) {
|
|
28
|
+
// called after run and catch regardless of whether or not the command errored
|
|
29
|
+
return super.finally(_);
|
|
30
|
+
}
|
|
31
|
+
async init() {
|
|
32
|
+
await super.init();
|
|
33
|
+
const { args, flags } = await this.parse({
|
|
34
|
+
args: this.ctor.args,
|
|
35
|
+
baseFlags: super.ctor.baseFlags,
|
|
36
|
+
enableJsonFlag: this.ctor.enableJsonFlag,
|
|
37
|
+
flags: this.ctor.flags,
|
|
38
|
+
strict: this.ctor.strict,
|
|
39
|
+
});
|
|
40
|
+
this.flags = flags;
|
|
41
|
+
this.args = args;
|
|
42
|
+
const wrapper = new CredentialWrapper();
|
|
43
|
+
const credential = await (flags.auth ? wrapper.getStoredCredentialsByAlias(flags.auth) : wrapper.getStoredCredentialsByAlias('fluent-default'));
|
|
44
|
+
this.authLogger.debug("Credentials Received: ", credential);
|
|
45
|
+
if (credential) {
|
|
46
|
+
const snSettings = {
|
|
47
|
+
alias: flags.auth,
|
|
48
|
+
host: credential.host,
|
|
49
|
+
password: credential.password,
|
|
50
|
+
username: credential.username,
|
|
51
|
+
};
|
|
52
|
+
this.authLogger.debug("SN auth settings to instantiate ServiceNowInstance object: ", snSettings);
|
|
53
|
+
this.instance = new ServiceNowInstance(snSettings);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
this.authLogger.error("Either credential not found or no credentials created.", { args: this.args, flags: this.flags });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=authenticated-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticated-command.js","sourceRoot":"","sources":["../../src/common/authenticated-command.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAc,MAAM,aAAa,CAAA;AAExD,OAAO,EAAE,iBAAiB,EAAG,MAAM,EAAE,kBAAkB,EAA8B,MAAM,4BAA4B,CAAC;AAKxH,MAAM,OAAgB,oBAA+C,SAAQ,OAAO;IACpF,kFAAkF;IAChF,MAAM,CAAC,SAAS,GAAG;QACjB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,EAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,oBAAoB,EAAE,QAAQ,EAAE,KAAK,EAAC,CAAC;QACrF,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC;YACxB,OAAO,EAAE,MAAM;YACf,SAAS,EAAE,QAAQ;YACnB,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAU;YAC7D,OAAO,EAAE,4BAA4B;SAEtC,CAAC,EAAE;KACL,CAAA;IAE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ACvJ,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAC;QAC5D,IAAG,UAAU,EAAC,CAAC;YACZ,MAAM,UAAU,GAA8B;gBACzC,KAAK,EAAE,KAAK,CAAC,IAAI;gBACjB,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,QAAQ,EAAE,UAAU,CAAC,QAAQ;gBAC7B,QAAQ,EAAE,UAAU,CAAC,QAAQ;aAChC,CAAA;YACD,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,6DAA6D,EAAE,UAAU,CAAC,CAAC;YACjG,IAAI,CAAC,QAAQ,GAAG,IAAI,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACvD,CAAC;aAAI,CAAC;YACF,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,wDAAwD,EAAE,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAC,CAAC,CAAC;QAC1H,CAAC;IAEH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Command, Interfaces } from '@oclif/core';
|
|
2
|
+
import { Logger } from '@sonisoft/now-sdk-ext-core';
|
|
3
|
+
export type Flags<T extends typeof Command> = Interfaces.InferredFlags<T['flags'] & typeof BaseCommand['baseFlags']>;
|
|
4
|
+
export type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
|
|
5
|
+
export declare abstract class BaseCommand<T extends typeof Command> extends Command {
|
|
6
|
+
static baseFlags: {
|
|
7
|
+
'log-level': Interfaces.OptionFlag<"info" | "debug" | "warn" | "error" | "trace", Interfaces.CustomOptions>;
|
|
8
|
+
};
|
|
9
|
+
static enableJsonFlag: boolean;
|
|
10
|
+
protected args: Args<T>;
|
|
11
|
+
protected flags: Flags<T>;
|
|
12
|
+
protected logger: Logger;
|
|
13
|
+
protected catch(err: {
|
|
14
|
+
exitCode?: number;
|
|
15
|
+
} & Error): Promise<any>;
|
|
16
|
+
protected finally(_: Error | undefined): Promise<any>;
|
|
17
|
+
init(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=base-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-command.d.ts","sourceRoot":"","sources":["../../src/common/base-command.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAS,UAAU,EAAC,MAAM,aAAa,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAEnD,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,OAAO,OAAO,IAAI,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,OAAO,WAAW,CAAC,WAAW,CAAC,CAAC,CAAA;AACpH,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS,OAAO,OAAO,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;AAE/E,8BAAsB,WAAW,CAAC,CAAC,SAAS,OAAO,OAAO,CAAE,SAAQ,OAAO;IAEzE,MAAM,CAAC,SAAS;;MAOf;IAGD,MAAM,CAAC,cAAc,UAAO;IAE5B,SAAS,CAAC,IAAI,EAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,SAAS,CAAC,KAAK,EAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;cAET,KAAK,CAAC,GAAG,EAAE;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC;cAQrD,OAAO,CAAC,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC;IAO9C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAenC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { Command, Flags } from '@oclif/core';
|
|
3
|
+
import { Logger } from '@sonisoft/now-sdk-ext-core';
|
|
4
|
+
export class BaseCommand extends Command {
|
|
5
|
+
// define flags that can be inherited by any command that extends BaseCommand
|
|
6
|
+
static baseFlags = {
|
|
7
|
+
'log-level': Flags.option({
|
|
8
|
+
default: 'info',
|
|
9
|
+
helpGroup: 'GLOBAL',
|
|
10
|
+
options: ['debug', 'warn', 'error', 'info', 'trace'],
|
|
11
|
+
summary: 'Specify level for logging.',
|
|
12
|
+
})(),
|
|
13
|
+
};
|
|
14
|
+
// add the --json flag
|
|
15
|
+
static enableJsonFlag = true;
|
|
16
|
+
args;
|
|
17
|
+
flags;
|
|
18
|
+
logger;
|
|
19
|
+
async catch(err) {
|
|
20
|
+
// add any custom logic to handle errors from the command
|
|
21
|
+
// or simply return the parent class error handling
|
|
22
|
+
this.logger.error("Globally caught exception occurred.", err);
|
|
23
|
+
return super.catch(err);
|
|
24
|
+
}
|
|
25
|
+
async finally(_) {
|
|
26
|
+
// called after run and catch regardless of whether or not the command errored
|
|
27
|
+
return super.finally(_);
|
|
28
|
+
}
|
|
29
|
+
async init() {
|
|
30
|
+
await super.init();
|
|
31
|
+
const { args, flags } = await this.parse({
|
|
32
|
+
args: this.ctor.args,
|
|
33
|
+
baseFlags: super.ctor.baseFlags,
|
|
34
|
+
enableJsonFlag: this.ctor.enableJsonFlag,
|
|
35
|
+
flags: this.ctor.flags,
|
|
36
|
+
strict: this.ctor.strict,
|
|
37
|
+
});
|
|
38
|
+
this.flags = flags;
|
|
39
|
+
this.args = args;
|
|
40
|
+
this.logger = new Logger("");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=base-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../src/common/base-command.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,EAAC,OAAO,EAAE,KAAK,EAAa,MAAM,aAAa,CAA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GAAG,KAAiB,CAAA;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAe,CAAA;QAG3B,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"commands": {
|
|
3
|
+
"exec": {
|
|
4
|
+
"aliases": [],
|
|
5
|
+
"args": {
|
|
6
|
+
"scope": {
|
|
7
|
+
"description": "Scope to execute file in.",
|
|
8
|
+
"name": "scope",
|
|
9
|
+
"required": true
|
|
10
|
+
},
|
|
11
|
+
"file": {
|
|
12
|
+
"description": "File to execute in scripts background.",
|
|
13
|
+
"name": "file",
|
|
14
|
+
"required": true
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"description": "Execute a local javascript file on a ServiceNow instance using Scripts - Background remotely. Returns the output/raw console output that Scripts - Background outputs to the browser in order to support the execution and result being piped to another command.",
|
|
18
|
+
"examples": [
|
|
19
|
+
"<%= config.bin %> <%= command.id %> exec global test.js --auth sn_alias\ntest\n"
|
|
20
|
+
],
|
|
21
|
+
"flags": {
|
|
22
|
+
"json": {
|
|
23
|
+
"description": "Format output as json.",
|
|
24
|
+
"helpGroup": "GLOBAL",
|
|
25
|
+
"name": "json",
|
|
26
|
+
"allowNo": false,
|
|
27
|
+
"type": "boolean"
|
|
28
|
+
},
|
|
29
|
+
"auth": {
|
|
30
|
+
"char": "a",
|
|
31
|
+
"description": "Auth alias to use.",
|
|
32
|
+
"name": "auth",
|
|
33
|
+
"required": false,
|
|
34
|
+
"hasDynamicHelp": false,
|
|
35
|
+
"multiple": false,
|
|
36
|
+
"type": "option"
|
|
37
|
+
},
|
|
38
|
+
"log-level": {
|
|
39
|
+
"helpGroup": "GLOBAL",
|
|
40
|
+
"name": "log-level",
|
|
41
|
+
"summary": "Specify level for logging.",
|
|
42
|
+
"default": "info",
|
|
43
|
+
"hasDynamicHelp": false,
|
|
44
|
+
"multiple": false,
|
|
45
|
+
"options": [
|
|
46
|
+
"debug",
|
|
47
|
+
"warn",
|
|
48
|
+
"error",
|
|
49
|
+
"info",
|
|
50
|
+
"trace"
|
|
51
|
+
],
|
|
52
|
+
"type": "option"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"hasDynamicHelp": false,
|
|
56
|
+
"hiddenAliases": [],
|
|
57
|
+
"id": "exec",
|
|
58
|
+
"pluginAlias": "@sonisoft/now-sdk-ext-cli",
|
|
59
|
+
"pluginName": "@sonisoft/now-sdk-ext-cli",
|
|
60
|
+
"pluginType": "core",
|
|
61
|
+
"strict": true,
|
|
62
|
+
"enableJsonFlag": true,
|
|
63
|
+
"isESM": true,
|
|
64
|
+
"relativePath": [
|
|
65
|
+
"dist",
|
|
66
|
+
"commands",
|
|
67
|
+
"exec",
|
|
68
|
+
"index.js"
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"version": "1.0.0-alpha.0"
|
|
73
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sonisoft/now-sdk-ext-cli",
|
|
3
|
+
"description": "A CLI extending the functionality of the ServiceNow SDK.",
|
|
4
|
+
"version": "1.0.0-alpha.0",
|
|
5
|
+
"author": "Chris Nanda",
|
|
6
|
+
"bin": {
|
|
7
|
+
"nex": "./bin/run.js"
|
|
8
|
+
},
|
|
9
|
+
"bugs": "",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@oclif/core": "^4.0.2",
|
|
12
|
+
"@oclif/plugin-help": "^6.2.10",
|
|
13
|
+
"@oclif/plugin-plugins": "^5.4.6",
|
|
14
|
+
"@servicenow/glide": "^26.0.1",
|
|
15
|
+
"@servicenow/sdk": "2.0.1",
|
|
16
|
+
"@servicenow/sdk-build": "2.0.1",
|
|
17
|
+
"@servicenow/sdk-cli": "2.0.1",
|
|
18
|
+
"@servicenow/sdk-cli-core": "2.0.1",
|
|
19
|
+
"@servicenow/sdk-core": "2.0.1",
|
|
20
|
+
"@servicenow/sdk-project": "2.0.1",
|
|
21
|
+
"@sonisoft/now-sdk-ext-core": "^1.0.0-alpha.6",
|
|
22
|
+
"@ts-morph/common": "^0.24.0",
|
|
23
|
+
"cometd": "^8.0.4",
|
|
24
|
+
"cometd-nodejs-client": "^2.0.0",
|
|
25
|
+
"fast-xml-parser": "^4.4.1",
|
|
26
|
+
"fs-extra": "^11.2.0",
|
|
27
|
+
"winston": "3.14.2",
|
|
28
|
+
"ws": "^8.18.0",
|
|
29
|
+
"zod": "^3.23.8"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@jest/globals": "^29.7.0",
|
|
33
|
+
"@oclif/prettier-config": "^0.2.1",
|
|
34
|
+
"@oclif/test": "^4",
|
|
35
|
+
"@supercharge/fs": "^3.4.2",
|
|
36
|
+
"@types/chai": "^4",
|
|
37
|
+
"@types/jest": "^29.5.12",
|
|
38
|
+
"@types/mocha": "^10",
|
|
39
|
+
"@types/node": "^18",
|
|
40
|
+
"@typescript-eslint/typescript-estree": "^8.4.0",
|
|
41
|
+
"chai": "^4",
|
|
42
|
+
"eslint": "^8",
|
|
43
|
+
"eslint-config-oclif": "^5.2.1",
|
|
44
|
+
"eslint-config-oclif-typescript": "^3.1.10",
|
|
45
|
+
"eslint-config-prettier": "^9",
|
|
46
|
+
"jest": "^29.7.0",
|
|
47
|
+
"jest-junit": "^16.0.0",
|
|
48
|
+
"oclif": "^4",
|
|
49
|
+
"rimraf": "^6.0.1",
|
|
50
|
+
"shx": "^0.3.3",
|
|
51
|
+
"ts-jest": "^29.2.5",
|
|
52
|
+
"ts-jest-mocker": "^1.0.0",
|
|
53
|
+
"ts-node": "10.9.2",
|
|
54
|
+
"tslint": "^5.20.1",
|
|
55
|
+
"typescript": "^5.5.4"
|
|
56
|
+
},
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=18.0.0"
|
|
59
|
+
},
|
|
60
|
+
"files": [
|
|
61
|
+
"/bin",
|
|
62
|
+
"/dist",
|
|
63
|
+
"/oclif.manifest.json"
|
|
64
|
+
],
|
|
65
|
+
"homepage": "",
|
|
66
|
+
"keywords": [
|
|
67
|
+
"oclif"
|
|
68
|
+
],
|
|
69
|
+
"license": "MIT",
|
|
70
|
+
"main": "dist/index.js",
|
|
71
|
+
"type": "module",
|
|
72
|
+
"oclif": {
|
|
73
|
+
"bin": "nex",
|
|
74
|
+
"commands": {
|
|
75
|
+
"strategy": "pattern",
|
|
76
|
+
"target": "./dist/commands",
|
|
77
|
+
"globPatterns": [
|
|
78
|
+
"**/*.+(js|cjs|mjs|ts|tsx|mts|cts)",
|
|
79
|
+
"!**/*.+(d.*|test.*|spec.*|helpers.*)?(x)"
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
"plugins": [
|
|
83
|
+
"@oclif/plugin-help",
|
|
84
|
+
"@oclif/plugin-plugins"
|
|
85
|
+
],
|
|
86
|
+
"topicSeparator": " ",
|
|
87
|
+
"topics": {
|
|
88
|
+
"exec": {
|
|
89
|
+
"description": "Execute scripts remotely on a ServiceNow instance. Immitates using Scripts - Background from within ServiceNow."
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"repository": "",
|
|
94
|
+
"scripts": {
|
|
95
|
+
"prepublish": "npm version prerelease",
|
|
96
|
+
"publish-registry": "npm publish",
|
|
97
|
+
"clean": "rimraf dist && rimraf tsconfig.tsbuildinfo",
|
|
98
|
+
"alpha": "npm version premajor --preid alpha",
|
|
99
|
+
"beta": " npm version premajor --preid beta",
|
|
100
|
+
"buildts": "tsc -p ./",
|
|
101
|
+
"buildp": "npm run buildts && npm run lint",
|
|
102
|
+
"build": "npm run clean && npm run buildts",
|
|
103
|
+
"lint": "eslint . --ext .ts",
|
|
104
|
+
"postpack": "shx rm -f oclif.manifest.json",
|
|
105
|
+
"posttest": "npm run lint",
|
|
106
|
+
"prepack": "oclif manifest && oclif readme",
|
|
107
|
+
"test": "node --experimental-vm-modules node_modules/.bin/jest --forceExit --verbose=true --silent=false --json=false --useStderr=false",
|
|
108
|
+
"version": "oclif readme && git add README.md"
|
|
109
|
+
},
|
|
110
|
+
"types": "dist/index.d.ts"
|
|
111
|
+
}
|