sn-typescript-util 1.3.9 → 1.3.11
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 +17 -14
- package/bun.lockb +0 -0
- package/package.json +5 -5
- package/scripts/{build.rb → build/build.rb} +1 -1
- package/scripts/{sync.sh → build/sync.sh} +2 -2
- package/scripts/snts.ts +39 -27
- package/scripts/types/metadata.ts +8 -0
- package/scripts/types/workspace.ts +8 -0
- package/scripts/workspace.ts +0 -4
- /package/scripts/{compile.rb → build/compile.rb} +0 -0
- /package/scripts/{init.rb → build/init.rb} +0 -0
- /package/{templates → scripts/templates}/.prettierrc.json +0 -0
- /package/{templates → scripts/templates}/tsconfig.json +0 -0
- /package/scripts/{options.ts → types/options.ts} +0 -0
- /package/scripts/{release.sh → utils/release.sh} +0 -0
- /package/scripts/{utils.rb → utils/util.rb} +0 -0
package/bin/snts.js
CHANGED
|
@@ -8,7 +8,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');
|
|
11
|
-
return await execFile(getFilePath('init.rb'), (stdout) => {
|
|
11
|
+
return await execFile(getFilePath('init.rb', 'scripts/build'), (stdout) => {
|
|
12
12
|
stopPrompt(s, 'Configs installed');
|
|
13
13
|
runSync();
|
|
14
14
|
return stdout;
|
|
@@ -16,10 +16,13 @@ async function doBuild() {
|
|
|
16
16
|
}
|
|
17
17
|
async function doCompile() {
|
|
18
18
|
const s = startPrompts('Processing', 'Compile started');
|
|
19
|
-
return await execFile(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
return await execFile(
|
|
20
|
+
getFilePath('compile.rb', 'scripts/build'),
|
|
21
|
+
(stdout) => {
|
|
22
|
+
stopPrompt(s, 'Completed');
|
|
23
|
+
return stdout;
|
|
24
|
+
}
|
|
25
|
+
);
|
|
23
26
|
}
|
|
24
27
|
function doOptions(program, version) {
|
|
25
28
|
program.parse(process.argv).opts();
|
|
@@ -33,20 +36,20 @@ function doOptions(program, version) {
|
|
|
33
36
|
doCompile();
|
|
34
37
|
},
|
|
35
38
|
help: () => {
|
|
36
|
-
program
|
|
39
|
+
showHelp(program);
|
|
37
40
|
},
|
|
38
41
|
sync: () => {
|
|
39
42
|
doSync();
|
|
40
43
|
},
|
|
41
44
|
default: () => {
|
|
42
|
-
program
|
|
45
|
+
showHelp(program);
|
|
43
46
|
}
|
|
44
47
|
};
|
|
45
48
|
return handleOptions(program, options, optionKey, version);
|
|
46
49
|
}
|
|
47
50
|
async function doSync() {
|
|
48
51
|
const s = startPrompts('Processing', 'Sync started');
|
|
49
|
-
return await execFile(getFilePath('sync.sh'), (stdout) => {
|
|
52
|
+
return await execFile(getFilePath('sync.sh', 'scripts/build'), (stdout) => {
|
|
50
53
|
stopPrompt(s, 'Completed');
|
|
51
54
|
return stdout;
|
|
52
55
|
});
|
|
@@ -55,14 +58,14 @@ function getDescription(version) {
|
|
|
55
58
|
const title = 'SN TypeScript Util';
|
|
56
59
|
const description =
|
|
57
60
|
'is a TS utility for ServiceNow developers using VS Code.';
|
|
58
|
-
return `${bold(magenta(title))} ${description} ${gray(`(${version})`)}\n`;
|
|
61
|
+
return `${bold(magenta(title))} ${description} ${gray(`(v${version})`)}\n`;
|
|
59
62
|
}
|
|
60
63
|
function getErrorMsg() {
|
|
61
64
|
const url = `https://docs.servicenow.com/bundle/vancouver-application-development/page/build/applications/task/create-project.html`;
|
|
62
65
|
const msg = `No active application detected. Please create a project with the ServiceNow Extension for VS Code.\n\n${url}`;
|
|
63
66
|
return console.error(bold(red(msg)));
|
|
64
67
|
}
|
|
65
|
-
function getFilePath(file, dir = 'scripts') {
|
|
68
|
+
function getFilePath(file, dir = 'scripts/build') {
|
|
66
69
|
const fileName = fileURLToPath(import.meta.url);
|
|
67
70
|
const dirName = path.dirname(fileName);
|
|
68
71
|
return `${path.join(dirName, `../${dir}`)}/${file}`;
|
|
@@ -80,7 +83,7 @@ function handleError() {
|
|
|
80
83
|
function handleOptions(program, options, option, version) {
|
|
81
84
|
if (option === 'help' || !option) {
|
|
82
85
|
console.log(getDescription(version));
|
|
83
|
-
program
|
|
86
|
+
showHelp(program);
|
|
84
87
|
}
|
|
85
88
|
return (
|
|
86
89
|
shouldShowHelp(program, option) ||
|
|
@@ -103,7 +106,6 @@ async function init() {
|
|
|
103
106
|
const program = new Command();
|
|
104
107
|
const info = await getPackageInfo();
|
|
105
108
|
const version = info.version;
|
|
106
|
-
program.version(version, '-v, --version', 'output the current version');
|
|
107
109
|
program.option(
|
|
108
110
|
'-b, --build',
|
|
109
111
|
'build project utility files & package dependencies'
|
|
@@ -112,11 +114,12 @@ async function init() {
|
|
|
112
114
|
'-c, --compile',
|
|
113
115
|
'compile TypeScript files to JavaScript & move to src'
|
|
114
116
|
);
|
|
117
|
+
program.option('-h, --help', 'display help for command');
|
|
115
118
|
program.option(
|
|
116
119
|
'-s, --sync',
|
|
117
120
|
'sync new instance-based src files to the ts directory'
|
|
118
121
|
);
|
|
119
|
-
program.
|
|
122
|
+
program.version(version, '-v, --version', 'output the current version');
|
|
120
123
|
program.usage(cyan('[options]'));
|
|
121
124
|
return doOptions(program, version);
|
|
122
125
|
}
|
|
@@ -125,7 +128,7 @@ function introPrompt(msg) {
|
|
|
125
128
|
}
|
|
126
129
|
async function runSync() {
|
|
127
130
|
const s = startPrompts('Syncing', null);
|
|
128
|
-
return await execFile(getFilePath('sync.sh'), (stdout) => {
|
|
131
|
+
return await execFile(getFilePath('sync.sh', 'scripts/build'), (stdout) => {
|
|
129
132
|
stopPrompt(s, 'Sync completed');
|
|
130
133
|
outro('Completed');
|
|
131
134
|
return stdout;
|
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.
|
|
3
|
+
"version": "1.3.11",
|
|
4
4
|
"description": "A TypeScript utility for ServiceNow developers using VS Code",
|
|
5
5
|
"bin": {
|
|
6
6
|
"snts": "bin/snts.js"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"format": "prettier --write ./bin/*.js ./scripts/*.ts",
|
|
21
21
|
"lint": "eslint .",
|
|
22
|
-
"release": "./scripts/release.sh",
|
|
22
|
+
"release": "./scripts/utils/release.sh",
|
|
23
23
|
"watch": "tsc --watch"
|
|
24
24
|
},
|
|
25
25
|
"type": "module",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/commander": "^2.12.2",
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
37
|
-
"@typescript-eslint/parser": "^6.
|
|
38
|
-
"bun-types": "^1.0.
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "^6.18.1",
|
|
37
|
+
"@typescript-eslint/parser": "^6.18.1",
|
|
38
|
+
"bun-types": "^1.0.22",
|
|
39
39
|
"eslint": "^8.56.0",
|
|
40
40
|
"prettier": "^3.1.1"
|
|
41
41
|
}
|
|
@@ -15,14 +15,14 @@ get_project_name() {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
sync() {
|
|
18
|
-
|
|
18
|
+
types_dir="Types"
|
|
19
19
|
src_path="$(get_project_name system/sn-workspace.json ACTIVE_APPLICATION)/src"
|
|
20
20
|
ts_path="$(get_project_name system/sn-workspace.json ACTIVE_APPLICATION)/ts"
|
|
21
21
|
clean_build "$build_dir"
|
|
22
22
|
if [ -d "$ts_path" ]; then
|
|
23
23
|
find "$ts_path" -name "*.ts" -exec sh -c 'mv "$0" "${0%.ts}.js"' {} \;
|
|
24
24
|
fi
|
|
25
|
-
rsync --ignore-existing --delete-after -raz --progress --prune-empty-dirs --include "*/" --include "*.js" --exclude="*" "$
|
|
25
|
+
rsync --ignore-existing --delete-after -raz --progress --prune-empty-dirs --include "*/" --include "*.js" --exclude="*" "$types_dir" "$src_path/" "$ts_path"
|
|
26
26
|
find "$ts_path" -name "*.js" -exec sh -c 'mv "$0" "${0%.js}.ts"' {} \;
|
|
27
27
|
}
|
|
28
28
|
|
package/scripts/snts.ts
CHANGED
|
@@ -7,24 +7,30 @@ import { readFileSync } from 'fs';
|
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
import { bold, cyan, gray, magenta, red } from 'colorette';
|
|
9
9
|
import { intro, outro, spinner } from '@clack/prompts';
|
|
10
|
-
import { Options } from './options.js';
|
|
11
|
-
import { Workspace } from './workspace.js';
|
|
10
|
+
import { Options } from './types/options.js';
|
|
11
|
+
import { Workspace } from './types/workspace.js';
|
|
12
12
|
|
|
13
13
|
async function doBuild() {
|
|
14
14
|
const s = startPrompts('Installing configs', 'Build started');
|
|
15
|
-
return await execFile(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
return await execFile(
|
|
16
|
+
getFilePath('init.rb', 'scripts/build'),
|
|
17
|
+
(stdout: unknown) => {
|
|
18
|
+
stopPrompt(s, 'Configs installed');
|
|
19
|
+
runSync();
|
|
20
|
+
return stdout;
|
|
21
|
+
}
|
|
22
|
+
);
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
async function doCompile() {
|
|
23
26
|
const s = startPrompts('Processing', 'Compile started');
|
|
24
|
-
return await execFile(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
return await execFile(
|
|
28
|
+
getFilePath('compile.rb', 'scripts/build'),
|
|
29
|
+
(stdout: unknown) => {
|
|
30
|
+
stopPrompt(s, 'Completed');
|
|
31
|
+
return stdout;
|
|
32
|
+
}
|
|
33
|
+
);
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
function doOptions(program: Command, version: string) {
|
|
@@ -39,13 +45,13 @@ function doOptions(program: Command, version: string) {
|
|
|
39
45
|
doCompile();
|
|
40
46
|
},
|
|
41
47
|
help: () => {
|
|
42
|
-
program
|
|
48
|
+
showHelp(program);
|
|
43
49
|
},
|
|
44
50
|
sync: () => {
|
|
45
51
|
doSync();
|
|
46
52
|
},
|
|
47
53
|
default: () => {
|
|
48
|
-
program
|
|
54
|
+
showHelp(program);
|
|
49
55
|
}
|
|
50
56
|
};
|
|
51
57
|
return handleOptions(program, options, optionKey, version);
|
|
@@ -53,17 +59,20 @@ function doOptions(program: Command, version: string) {
|
|
|
53
59
|
|
|
54
60
|
async function doSync() {
|
|
55
61
|
const s = startPrompts('Processing', 'Sync started');
|
|
56
|
-
return await execFile(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
return await execFile(
|
|
63
|
+
getFilePath('sync.sh', 'scripts/build'),
|
|
64
|
+
(stdout: unknown) => {
|
|
65
|
+
stopPrompt(s, 'Completed');
|
|
66
|
+
return stdout;
|
|
67
|
+
}
|
|
68
|
+
);
|
|
60
69
|
}
|
|
61
70
|
|
|
62
71
|
function getDescription(version: string) {
|
|
63
72
|
const title = 'SN TypeScript Util';
|
|
64
73
|
const description =
|
|
65
74
|
'is a TS utility for ServiceNow developers using VS Code.';
|
|
66
|
-
return `${bold(magenta(title))} ${description} ${gray(`(${version})`)}\n`;
|
|
75
|
+
return `${bold(magenta(title))} ${description} ${gray(`(v${version})`)}\n`;
|
|
67
76
|
}
|
|
68
77
|
|
|
69
78
|
function getErrorMsg() {
|
|
@@ -72,7 +81,7 @@ function getErrorMsg() {
|
|
|
72
81
|
return console.error(bold(red(msg)));
|
|
73
82
|
}
|
|
74
83
|
|
|
75
|
-
function getFilePath(file: string, dir: string = 'scripts') {
|
|
84
|
+
function getFilePath(file: string, dir: string = 'scripts/build') {
|
|
76
85
|
const fileName = fileURLToPath(import.meta.url);
|
|
77
86
|
const dirName = path.dirname(fileName);
|
|
78
87
|
return `${path.join(dirName, `../${dir}`)}/${file}`;
|
|
@@ -99,7 +108,7 @@ function handleOptions(
|
|
|
99
108
|
) {
|
|
100
109
|
if (option === 'help' || !option) {
|
|
101
110
|
console.log(getDescription(version));
|
|
102
|
-
program
|
|
111
|
+
showHelp(program);
|
|
103
112
|
}
|
|
104
113
|
return (
|
|
105
114
|
shouldShowHelp(program, option) ||
|
|
@@ -125,7 +134,6 @@ async function init() {
|
|
|
125
134
|
const program = new Command();
|
|
126
135
|
const info = await getPackageInfo();
|
|
127
136
|
const version = info.version;
|
|
128
|
-
program.version(version, '-v, --version', 'output the current version');
|
|
129
137
|
program.option(
|
|
130
138
|
'-b, --build',
|
|
131
139
|
'build project utility files & package dependencies'
|
|
@@ -134,11 +142,12 @@ async function init() {
|
|
|
134
142
|
'-c, --compile',
|
|
135
143
|
'compile TypeScript files to JavaScript & move to src'
|
|
136
144
|
);
|
|
145
|
+
program.option('-h, --help', 'display help for command');
|
|
137
146
|
program.option(
|
|
138
147
|
'-s, --sync',
|
|
139
148
|
'sync new instance-based src files to the ts directory'
|
|
140
149
|
);
|
|
141
|
-
program.
|
|
150
|
+
program.version(version, '-v, --version', 'output the current version');
|
|
142
151
|
program.usage(cyan('[options]'));
|
|
143
152
|
return doOptions(program, version);
|
|
144
153
|
}
|
|
@@ -149,11 +158,14 @@ function introPrompt(msg: string) {
|
|
|
149
158
|
|
|
150
159
|
async function runSync() {
|
|
151
160
|
const s = startPrompts('Syncing', null);
|
|
152
|
-
return await execFile(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
161
|
+
return await execFile(
|
|
162
|
+
getFilePath('sync.sh', 'scripts/build'),
|
|
163
|
+
(stdout: unknown) => {
|
|
164
|
+
stopPrompt(s, 'Sync completed');
|
|
165
|
+
outro('Completed');
|
|
166
|
+
return stdout;
|
|
167
|
+
}
|
|
168
|
+
);
|
|
157
169
|
}
|
|
158
170
|
|
|
159
171
|
function shouldShowHelp(program: Command, option: string) {
|
package/scripts/workspace.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|