sn-typescript-util 1.3.7 → 1.3.9

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/bin/snts.js CHANGED
@@ -4,7 +4,7 @@ import { execFile } from 'node:child_process';
4
4
  import path from 'path';
5
5
  import { readFileSync } from 'fs';
6
6
  import { fileURLToPath } from 'url';
7
- import { bold, gray, magenta, red } from 'colorette';
7
+ import { bold, cyan, gray, magenta, red } from 'colorette';
8
8
  import { intro, outro, spinner } from '@clack/prompts';
9
9
  async function doBuild() {
10
10
  const s = startPrompts('Installing configs', 'Build started');
@@ -21,7 +21,7 @@ async function doCompile() {
21
21
  return stdout;
22
22
  });
23
23
  }
24
- function doOptions(program) {
24
+ function doOptions(program, version) {
25
25
  program.parse(process.argv).opts();
26
26
  const option = Object.keys(program.opts()).toString();
27
27
  const optionKey = option;
@@ -32,6 +32,9 @@ function doOptions(program) {
32
32
  compile: () => {
33
33
  doCompile();
34
34
  },
35
+ help: () => {
36
+ program.help();
37
+ },
35
38
  sync: () => {
36
39
  doSync();
37
40
  },
@@ -39,7 +42,7 @@ function doOptions(program) {
39
42
  program.help();
40
43
  }
41
44
  };
42
- return handleOptions(program, options, optionKey);
45
+ return handleOptions(program, options, optionKey, version);
43
46
  }
44
47
  async function doSync() {
45
48
  const s = startPrompts('Processing', 'Sync started');
@@ -48,6 +51,12 @@ async function doSync() {
48
51
  return stdout;
49
52
  });
50
53
  }
54
+ function getDescription(version) {
55
+ const title = 'SN TypeScript Util';
56
+ const description =
57
+ 'is a TS utility for ServiceNow developers using VS Code.';
58
+ return `${bold(magenta(title))} ${description} ${gray(`(${version})`)}\n`;
59
+ }
51
60
  function getErrorMsg() {
52
61
  const url = `https://docs.servicenow.com/bundle/vancouver-application-development/page/build/applications/task/create-project.html`;
53
62
  const msg = `No active application detected. Please create a project with the ServiceNow Extension for VS Code.\n\n${url}`;
@@ -68,7 +77,11 @@ function handleError() {
68
77
  getErrorMsg();
69
78
  return process.exit(1);
70
79
  }
71
- function handleOptions(program, options, option) {
80
+ function handleOptions(program, options, option, version) {
81
+ if (option === 'help' || !option) {
82
+ console.log(getDescription(version));
83
+ program.help();
84
+ }
72
85
  return (
73
86
  shouldShowHelp(program, option) ||
74
87
  ((hasApplication() && options[option]) || showHelp(program))()
@@ -89,15 +102,8 @@ async function hasApplication() {
89
102
  async function init() {
90
103
  const program = new Command();
91
104
  const info = await getPackageInfo();
92
- const version = `(${info.version})`;
93
- program.description(
94
- `${bold(
95
- magenta('SN TypeScript Util')
96
- )} is a TS utility for ServiceNow developers using VS Code. ${gray(
97
- version
98
- )}`
99
- );
100
- program.version(info.version, '-v, --version', 'output the current version');
105
+ const version = info.version;
106
+ program.version(version, '-v, --version', 'output the current version');
101
107
  program.option(
102
108
  '-b, --build',
103
109
  'build project utility files & package dependencies'
@@ -110,7 +116,9 @@ async function init() {
110
116
  '-s, --sync',
111
117
  'sync new instance-based src files to the ts directory'
112
118
  );
113
- return doOptions(program);
119
+ program.option('-h, --help', 'display help for command');
120
+ program.usage(cyan('[options]'));
121
+ return doOptions(program, version);
114
122
  }
115
123
  function introPrompt(msg) {
116
124
  return intro(msg);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sn-typescript-util",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "description": "A TypeScript utility for ServiceNow developers using VS Code",
5
5
  "bin": {
6
6
  "snts": "bin/snts.js"
@@ -1,6 +1,7 @@
1
1
  export interface Options {
2
2
  build: () => void;
3
3
  compile: () => void;
4
+ help: () => void;
4
5
  sync: () => void;
5
6
  default: () => void;
6
7
  }
package/scripts/snts.ts CHANGED
@@ -5,7 +5,7 @@ import { execFile } from 'node:child_process';
5
5
  import path from 'path';
6
6
  import { readFileSync } from 'fs';
7
7
  import { fileURLToPath } from 'url';
8
- import { bold, gray, magenta, red } from 'colorette';
8
+ import { bold, cyan, gray, magenta, red } from 'colorette';
9
9
  import { intro, outro, spinner } from '@clack/prompts';
10
10
  import { Options } from './options.js';
11
11
  import { Workspace } from './workspace.js';
@@ -27,7 +27,7 @@ async function doCompile() {
27
27
  });
28
28
  }
29
29
 
30
- function doOptions(program: Command) {
30
+ function doOptions(program: Command, version: string) {
31
31
  program.parse(process.argv).opts();
32
32
  const option: string = Object.keys(program.opts()).toString();
33
33
  const optionKey = option as keyof Options;
@@ -38,6 +38,9 @@ function doOptions(program: Command) {
38
38
  compile: () => {
39
39
  doCompile();
40
40
  },
41
+ help: () => {
42
+ program.help();
43
+ },
41
44
  sync: () => {
42
45
  doSync();
43
46
  },
@@ -45,7 +48,7 @@ function doOptions(program: Command) {
45
48
  program.help();
46
49
  }
47
50
  };
48
- return handleOptions(program, options, optionKey);
51
+ return handleOptions(program, options, optionKey, version);
49
52
  }
50
53
 
51
54
  async function doSync() {
@@ -56,6 +59,13 @@ async function doSync() {
56
59
  });
57
60
  }
58
61
 
62
+ function getDescription(version: string) {
63
+ const title = 'SN TypeScript Util';
64
+ const description =
65
+ 'is a TS utility for ServiceNow developers using VS Code.';
66
+ return `${bold(magenta(title))} ${description} ${gray(`(${version})`)}\n`;
67
+ }
68
+
59
69
  function getErrorMsg() {
60
70
  const url: string = `https://docs.servicenow.com/bundle/vancouver-application-development/page/build/applications/task/create-project.html`;
61
71
  const msg: string = `No active application detected. Please create a project with the ServiceNow Extension for VS Code.\n\n${url}`;
@@ -84,8 +94,13 @@ function handleError() {
84
94
  function handleOptions(
85
95
  program: Command,
86
96
  options: Options,
87
- option: keyof Options
97
+ option: keyof Options,
98
+ version: string
88
99
  ) {
100
+ if (option === 'help' || !option) {
101
+ console.log(getDescription(version));
102
+ program.help();
103
+ }
89
104
  return (
90
105
  shouldShowHelp(program, option) ||
91
106
  ((hasApplication() && options[option]) || showHelp(program))()
@@ -109,15 +124,8 @@ async function hasApplication() {
109
124
  async function init() {
110
125
  const program = new Command();
111
126
  const info = await getPackageInfo();
112
- const version = `(${info.version})`;
113
- program.description(
114
- `${bold(
115
- magenta('SN TypeScript Util')
116
- )} is a TS utility for ServiceNow developers using VS Code. ${gray(
117
- version
118
- )}`
119
- );
120
- program.version(info.version, '-v, --version', 'output the current version');
127
+ const version = info.version;
128
+ program.version(version, '-v, --version', 'output the current version');
121
129
  program.option(
122
130
  '-b, --build',
123
131
  'build project utility files & package dependencies'
@@ -130,7 +138,9 @@ async function init() {
130
138
  '-s, --sync',
131
139
  'sync new instance-based src files to the ts directory'
132
140
  );
133
- return doOptions(program);
141
+ program.option('-h, --help', 'display help for command');
142
+ program.usage(cyan('[options]'));
143
+ return doOptions(program, version);
134
144
  }
135
145
 
136
146
  function introPrompt(msg: string) {