sn-typescript-util 1.0.18 → 1.1.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 +1 -1
- package/bin/snts.ts +54 -66
- package/package.json +7 -8
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Using TypeScript, the CLI provides an enhanced developer workflow.
|
|
|
29
29
|
- [Node.js](https://nodejs.org/)
|
|
30
30
|
- [Visual Studio Code](https://code.visualstudio.com/)
|
|
31
31
|
- [ServiceNow Extension for VS Code](https://marketplace.visualstudio.com/items?itemName=ServiceNow.now-vscode)
|
|
32
|
-
- A [project created](https://docs.servicenow.com/bundle/
|
|
32
|
+
- A [project created](https://docs.servicenow.com/bundle/utah-application-development/page/build/applications/task/create-project.html) and [application imported](https://docs.servicenow.com/bundle/utah-application-development/page/build/applications/task/vscode-import-application.html) in VS Code
|
|
33
33
|
|
|
34
34
|
**[Back to top](#table-of-contents)**
|
|
35
35
|
|
package/bin/snts.ts
CHANGED
|
@@ -1,22 +1,42 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const childProcess = require('child_process');
|
|
4
|
-
const cliProgress = require('cli-progress');
|
|
5
|
-
const colors = require('colors');
|
|
6
4
|
const fs = require('fs');
|
|
7
5
|
const path = require('path');
|
|
8
6
|
const util = require('util');
|
|
9
7
|
const exec = util.promisify(childProcess.exec);
|
|
10
8
|
const { description, version } = require('./../package.json');
|
|
11
9
|
const { program } = require('commander');
|
|
12
|
-
const { bold, red } = require('colorette');
|
|
10
|
+
const { bold, cyan, red } = require('colorette');
|
|
11
|
+
const { cancel, intro, outro, spinner } = require('@clack/prompts');
|
|
13
12
|
|
|
14
|
-
(
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
async function doBuild() {
|
|
14
|
+
const s = startPrompts('Installing configs', 'Build started');
|
|
15
|
+
return await exec(getFilePath('init.rb'), (stdout) => {
|
|
16
|
+
stopPrompt(s, 'Configs installed');
|
|
17
|
+
runSync();
|
|
18
|
+
return stdout;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function doCompile() {
|
|
23
|
+
const s = startPrompts('Processing', 'Compile started');
|
|
24
|
+
return await exec(getFilePath('compile.rb'), (stdout) => {
|
|
25
|
+
stopPrompt(s, 'Completed');
|
|
26
|
+
return stdout;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function doSync() {
|
|
31
|
+
const s = startPrompts('Processing', 'Sync started');
|
|
32
|
+
return await exec(getFilePath('sync.sh'), (stdout) => {
|
|
33
|
+
stopPrompt(s, 'Completed');
|
|
34
|
+
return stdout;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
17
37
|
|
|
18
38
|
function getBuildName() {
|
|
19
|
-
const defaultBuild = '
|
|
39
|
+
const defaultBuild = 'utah';
|
|
20
40
|
try {
|
|
21
41
|
const workspace = JSON.parse(getWorkspaceConfig());
|
|
22
42
|
const app = workspace.ACTIVE_APPLICATION;
|
|
@@ -35,17 +55,21 @@ function getErrorMsg() {
|
|
|
35
55
|
return console.error(bold(red(msg)));
|
|
36
56
|
}
|
|
37
57
|
|
|
58
|
+
function getFilePath(file) {
|
|
59
|
+
return `${path.join(__dirname, '../scripts')}/${file}`;
|
|
60
|
+
}
|
|
61
|
+
|
|
38
62
|
function getOption(opts) {
|
|
39
63
|
const option = Object.keys(opts).toString();
|
|
40
64
|
const options = {
|
|
41
65
|
build: () => {
|
|
42
|
-
|
|
66
|
+
doBuild();
|
|
43
67
|
},
|
|
44
68
|
compile: () => {
|
|
45
|
-
|
|
69
|
+
doCompile();
|
|
46
70
|
},
|
|
47
71
|
sync: () => {
|
|
48
|
-
|
|
72
|
+
doSync();
|
|
49
73
|
},
|
|
50
74
|
default: () => {
|
|
51
75
|
program.help();
|
|
@@ -54,18 +78,6 @@ function getOption(opts) {
|
|
|
54
78
|
return (options[option] || options['default'])();
|
|
55
79
|
}
|
|
56
80
|
|
|
57
|
-
function getProgressBar() {
|
|
58
|
-
return new cliProgress.SingleBar({
|
|
59
|
-
format:
|
|
60
|
-
'CLI Progress |' +
|
|
61
|
-
colors.cyan('{bar}') +
|
|
62
|
-
'| {percentage}% || {value}/{total} Chunks',
|
|
63
|
-
barCompleteChar: '\u2588',
|
|
64
|
-
barIncompleteChar: '\u2591',
|
|
65
|
-
hideCursor: true
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
81
|
function getWorkspaceConfig() {
|
|
70
82
|
return fs.readFileSync('./system/sn-workspace.json');
|
|
71
83
|
}
|
|
@@ -76,13 +88,13 @@ function hasApplication() {
|
|
|
76
88
|
return Object.entries(app).length === 0 ? getErrorMsg() : true;
|
|
77
89
|
} catch (e) {
|
|
78
90
|
getErrorMsg();
|
|
79
|
-
return process.exit(
|
|
91
|
+
return process.exit(1);
|
|
80
92
|
}
|
|
81
93
|
}
|
|
82
94
|
|
|
83
|
-
|
|
84
|
-
return
|
|
85
|
-
}
|
|
95
|
+
(() => {
|
|
96
|
+
return init();
|
|
97
|
+
})();
|
|
86
98
|
|
|
87
99
|
function init() {
|
|
88
100
|
program.description(description);
|
|
@@ -103,57 +115,33 @@ function init() {
|
|
|
103
115
|
return hasApplication() && getOption(program.opts());
|
|
104
116
|
}
|
|
105
117
|
|
|
106
|
-
function
|
|
107
|
-
|
|
108
|
-
bar.stop();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function progressStart(bar) {
|
|
112
|
-
bar.start(100, 0);
|
|
113
|
-
bar.update(1);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async function runConfigs(bar) {
|
|
117
|
-
return await exec(getFilePath('init.rb'), (stdout) => {
|
|
118
|
-
bar.update(10);
|
|
119
|
-
runSync(bar);
|
|
120
|
-
return stdout;
|
|
121
|
-
});
|
|
118
|
+
function introPrompt(msg) {
|
|
119
|
+
return intro(msg);
|
|
122
120
|
}
|
|
123
121
|
|
|
124
|
-
async function runInstall(
|
|
125
|
-
|
|
122
|
+
async function runInstall() {
|
|
123
|
+
const s = startPrompts('Installing packages', null);
|
|
126
124
|
return await exec(getFilePath('install.sh'), (stdout) => {
|
|
127
|
-
|
|
125
|
+
stopPrompt(s, 'Packages installed');
|
|
126
|
+
outro('Completed');
|
|
128
127
|
return stdout;
|
|
129
128
|
});
|
|
130
129
|
}
|
|
131
130
|
|
|
132
|
-
function
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return childProcess.exec(getFilePath(file), (stdout) => {
|
|
136
|
-
progressComplete(bar);
|
|
137
|
-
return stdout;
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function runScript(file) {
|
|
142
|
-
return childProcess.exec(getFilePath(file), (stdout) => {
|
|
131
|
+
async function runSync() {
|
|
132
|
+
return await exec(getFilePath('sync.sh'), (stdout) => {
|
|
133
|
+
runInstall();
|
|
143
134
|
return stdout;
|
|
144
135
|
});
|
|
145
136
|
}
|
|
146
137
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
});
|
|
138
|
+
function startPrompts(start, intro) {
|
|
139
|
+
intro && introPrompt(intro);
|
|
140
|
+
const s = spinner();
|
|
141
|
+
s.start(start);
|
|
142
|
+
return s;
|
|
153
143
|
}
|
|
154
144
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
progressStart(bar);
|
|
158
|
-
return await Promise.all([runConfigs(bar)]);
|
|
145
|
+
function stopPrompt(spinner, msg) {
|
|
146
|
+
return spinner.stop(msg);
|
|
159
147
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sn-typescript-util",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A TypeScript utility for ServiceNow developers using VS Code",
|
|
5
5
|
"bin": {
|
|
6
6
|
"snts": "bin/snts.ts"
|
|
@@ -17,16 +17,15 @@
|
|
|
17
17
|
"url": "https://github.com/stevengregory/sn-typescript-util.git"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@
|
|
20
|
+
"@clack/prompts": "^0.6.3",
|
|
21
|
+
"@types/node": "^18.15.11",
|
|
21
22
|
"@types/servicenow": "^10.0.1",
|
|
22
|
-
"cli-progress": "^3.11.2",
|
|
23
23
|
"colorette": "^2.0.19",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"nodemon": "^2.0.19",
|
|
24
|
+
"commander": "^10.0.0",
|
|
25
|
+
"nodemon": "^2.0.22",
|
|
27
26
|
"npm-add-script": "^1.1.0",
|
|
28
|
-
"prettier": "^2.7
|
|
27
|
+
"prettier": "^2.8.7",
|
|
29
28
|
"ts-node": "^10.9.1",
|
|
30
|
-
"typescript": "^
|
|
29
|
+
"typescript": "^5.0.4"
|
|
31
30
|
}
|
|
32
31
|
}
|