sn-typescript-util 1.3.5 → 1.3.7

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 CHANGED
@@ -133,7 +133,7 @@ snts --version
133
133
 
134
134
  # or
135
135
 
136
- snts -V
136
+ snts -v
137
137
  ```
138
138
 
139
139
  **[Back to top](#table-of-contents)**
package/bin/snts.js CHANGED
@@ -4,117 +4,137 @@ 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, red } from 'colorette';
7
+ import { bold, gray, magenta, red } from 'colorette';
8
8
  import { intro, outro, spinner } from '@clack/prompts';
9
9
  async function doBuild() {
10
- const s = startPrompts('Installing configs', 'Build started');
11
- return await execFile(getFilePath('init.rb'), (stdout) => {
12
- stopPrompt(s, 'Configs installed');
13
- runSync();
14
- return stdout;
15
- });
10
+ const s = startPrompts('Installing configs', 'Build started');
11
+ return await execFile(getFilePath('init.rb'), (stdout) => {
12
+ stopPrompt(s, 'Configs installed');
13
+ runSync();
14
+ return stdout;
15
+ });
16
16
  }
17
17
  async function doCompile() {
18
- const s = startPrompts('Processing', 'Compile started');
19
- return await execFile(getFilePath('compile.rb'), (stdout) => {
20
- stopPrompt(s, 'Completed');
21
- return stdout;
22
- });
18
+ const s = startPrompts('Processing', 'Compile started');
19
+ return await execFile(getFilePath('compile.rb'), (stdout) => {
20
+ stopPrompt(s, 'Completed');
21
+ return stdout;
22
+ });
23
23
  }
24
24
  function doOptions(program) {
25
- program.parse(process.argv).opts();
26
- const option = Object.keys(program.opts()).toString();
27
- const optionKey = option;
28
- const options = {
29
- build: () => {
30
- doBuild();
31
- },
32
- compile: () => {
33
- doCompile();
34
- },
35
- sync: () => {
36
- doSync();
37
- },
38
- default: () => {
39
- program.help();
40
- }
41
- };
42
- return handleOptions(program, options, optionKey);
25
+ program.parse(process.argv).opts();
26
+ const option = Object.keys(program.opts()).toString();
27
+ const optionKey = option;
28
+ const options = {
29
+ build: () => {
30
+ doBuild();
31
+ },
32
+ compile: () => {
33
+ doCompile();
34
+ },
35
+ sync: () => {
36
+ doSync();
37
+ },
38
+ default: () => {
39
+ program.help();
40
+ }
41
+ };
42
+ return handleOptions(program, options, optionKey);
43
43
  }
44
44
  async function doSync() {
45
- const s = startPrompts('Processing', 'Sync started');
46
- return await execFile(getFilePath('sync.sh'), (stdout) => {
47
- stopPrompt(s, 'Completed');
48
- return stdout;
49
- });
45
+ const s = startPrompts('Processing', 'Sync started');
46
+ return await execFile(getFilePath('sync.sh'), (stdout) => {
47
+ stopPrompt(s, 'Completed');
48
+ return stdout;
49
+ });
50
50
  }
51
51
  function getErrorMsg() {
52
- const url = `https://docs.servicenow.com/bundle/vancouver-application-development/page/build/applications/task/create-project.html`;
53
- const msg = `No active application detected. Please create a project with the ServiceNow Extension for VS Code.\n\n${url}`;
54
- return console.error(bold(red(msg)));
52
+ const url = `https://docs.servicenow.com/bundle/vancouver-application-development/page/build/applications/task/create-project.html`;
53
+ const msg = `No active application detected. Please create a project with the ServiceNow Extension for VS Code.\n\n${url}`;
54
+ return console.error(bold(red(msg)));
55
55
  }
56
56
  function getFilePath(file, dir = 'scripts') {
57
- const fileName = fileURLToPath(import.meta.url);
58
- const dirName = path.dirname(fileName);
59
- return `${path.join(dirName, `../${dir}`)}/${file}`;
57
+ const fileName = fileURLToPath(import.meta.url);
58
+ const dirName = path.dirname(fileName);
59
+ return `${path.join(dirName, `../${dir}`)}/${file}`;
60
60
  }
61
61
  async function getPackageInfo() {
62
- return JSON.parse(readFileSync(getFilePath('package.json', '.')).toString());
62
+ return JSON.parse(readFileSync(getFilePath('package.json', '.')).toString());
63
63
  }
64
64
  function getWorkspace() {
65
- return JSON.parse(readFileSync('./system/sn-workspace.json').toString());
65
+ return JSON.parse(readFileSync('./system/sn-workspace.json').toString());
66
+ }
67
+ function handleError() {
68
+ getErrorMsg();
69
+ return process.exit(1);
66
70
  }
67
71
  function handleOptions(program, options, option) {
68
- return (shouldShowHelp(program, option) ||
69
- ((hasApplication() && options[option]) || showHelp(program))());
72
+ return (
73
+ shouldShowHelp(program, option) ||
74
+ ((hasApplication() && options[option]) || showHelp(program))()
75
+ );
70
76
  }
71
77
  async function hasApplication() {
72
- try {
73
- const workspace = await getWorkspace();
74
- const app = workspace.ACTIVE_APPLICATION;
75
- return Object.entries(app).length === 0 ? getErrorMsg() : true;
76
- }
77
- catch (e) {
78
- getErrorMsg();
79
- return process.exit(1);
80
- }
78
+ try {
79
+ const workspace = await getWorkspace();
80
+ const app = workspace.ACTIVE_APPLICATION;
81
+ return Object.entries(app).length === 0 ? getErrorMsg() : true;
82
+ } catch {
83
+ return handleError();
84
+ }
81
85
  }
82
86
  (async () => {
83
- return init();
87
+ return init();
84
88
  })();
85
89
  async function init() {
86
- const program = new Command();
87
- const info = await getPackageInfo();
88
- program.description(info.description);
89
- program.version(info.version);
90
- program.option('-b, --build', 'build project utility files & package dependencies');
91
- program.option('-c, --compile', 'compile TypeScript files to JavaScript & move to src');
92
- program.option('-s, --sync', 'sync new instance-based src files to the ts directory');
93
- return doOptions(program);
90
+ const program = new Command();
91
+ 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');
101
+ program.option(
102
+ '-b, --build',
103
+ 'build project utility files & package dependencies'
104
+ );
105
+ program.option(
106
+ '-c, --compile',
107
+ 'compile TypeScript files to JavaScript & move to src'
108
+ );
109
+ program.option(
110
+ '-s, --sync',
111
+ 'sync new instance-based src files to the ts directory'
112
+ );
113
+ return doOptions(program);
94
114
  }
95
115
  function introPrompt(msg) {
96
- return intro(msg);
116
+ return intro(msg);
97
117
  }
98
118
  async function runSync() {
99
- const s = startPrompts('Syncing', null);
100
- return await execFile(getFilePath('sync.sh'), (stdout) => {
101
- stopPrompt(s, 'Sync completed');
102
- outro('Completed');
103
- return stdout;
104
- });
119
+ const s = startPrompts('Syncing', null);
120
+ return await execFile(getFilePath('sync.sh'), (stdout) => {
121
+ stopPrompt(s, 'Sync completed');
122
+ outro('Completed');
123
+ return stdout;
124
+ });
105
125
  }
106
126
  function shouldShowHelp(program, option) {
107
- return !option && showHelp(program);
127
+ return !option && showHelp(program);
108
128
  }
109
129
  function showHelp(program) {
110
- return program.help();
130
+ return program.help();
111
131
  }
112
132
  function startPrompts(start, intro) {
113
- intro && introPrompt(intro);
114
- const s = spinner();
115
- s.start(start);
116
- return s;
133
+ intro && introPrompt(intro);
134
+ const s = spinner();
135
+ s.start(start);
136
+ return s;
117
137
  }
118
138
  function stopPrompt(spinner, msg) {
119
- return spinner.stop(msg);
139
+ return spinner.stop(msg);
120
140
  }
package/bun.lockb CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sn-typescript-util",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "A TypeScript utility for ServiceNow developers using VS Code",
5
5
  "bin": {
6
6
  "snts": "bin/snts.js"
@@ -33,9 +33,9 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/commander": "^2.12.2",
36
- "@typescript-eslint/eslint-plugin": "^6.15.0",
37
- "@typescript-eslint/parser": "^6.15.0",
38
- "bun-types": "^1.0.19",
36
+ "@typescript-eslint/eslint-plugin": "^6.17.0",
37
+ "@typescript-eslint/parser": "^6.17.0",
38
+ "bun-types": "^1.0.21",
39
39
  "eslint": "^8.56.0",
40
40
  "prettier": "^3.1.1"
41
41
  }
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, red } from 'colorette';
8
+ import { bold, 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';
@@ -76,6 +76,11 @@ function getWorkspace() {
76
76
  return JSON.parse(readFileSync('./system/sn-workspace.json').toString());
77
77
  }
78
78
 
79
+ function handleError() {
80
+ getErrorMsg();
81
+ return process.exit(1);
82
+ }
83
+
79
84
  function handleOptions(
80
85
  program: Command,
81
86
  options: Options,
@@ -92,9 +97,8 @@ async function hasApplication() {
92
97
  const workspace: Workspace = await getWorkspace();
93
98
  const app: string = workspace.ACTIVE_APPLICATION;
94
99
  return Object.entries(app).length === 0 ? getErrorMsg() : true;
95
- } catch (e) {
96
- getErrorMsg();
97
- return process.exit(1);
100
+ } catch {
101
+ return handleError();
98
102
  }
99
103
  }
100
104
 
@@ -105,8 +109,15 @@ async function hasApplication() {
105
109
  async function init() {
106
110
  const program = new Command();
107
111
  const info = await getPackageInfo();
108
- program.description(info.description);
109
- program.version(info.version);
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');
110
121
  program.option(
111
122
  '-b, --build',
112
123
  'build project utility files & package dependencies'