sn-typescript-util 1.3.8 → 1.3.10
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 +15 -8
- package/package.json +1 -1
- package/scripts/options.ts +1 -0
- package/scripts/snts.ts +16 -8
- package/scripts/sync.sh +2 -2
package/bin/snts.js
CHANGED
|
@@ -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,14 +32,17 @@ function doOptions(program) {
|
|
|
32
32
|
compile: () => {
|
|
33
33
|
doCompile();
|
|
34
34
|
},
|
|
35
|
+
help: () => {
|
|
36
|
+
showHelp(program);
|
|
37
|
+
},
|
|
35
38
|
sync: () => {
|
|
36
39
|
doSync();
|
|
37
40
|
},
|
|
38
41
|
default: () => {
|
|
39
|
-
program
|
|
42
|
+
showHelp(program);
|
|
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');
|
|
@@ -52,7 +55,7 @@ function getDescription(version) {
|
|
|
52
55
|
const title = 'SN TypeScript Util';
|
|
53
56
|
const description =
|
|
54
57
|
'is a TS utility for ServiceNow developers using VS Code.';
|
|
55
|
-
return `${bold(magenta(title))} ${description} ${gray(`(${version})`)}\n`;
|
|
58
|
+
return `${bold(magenta(title))} ${description} ${gray(`(v${version})`)}\n`;
|
|
56
59
|
}
|
|
57
60
|
function getErrorMsg() {
|
|
58
61
|
const url = `https://docs.servicenow.com/bundle/vancouver-application-development/page/build/applications/task/create-project.html`;
|
|
@@ -74,7 +77,11 @@ function handleError() {
|
|
|
74
77
|
getErrorMsg();
|
|
75
78
|
return process.exit(1);
|
|
76
79
|
}
|
|
77
|
-
function handleOptions(program, options, option) {
|
|
80
|
+
function handleOptions(program, options, option, version) {
|
|
81
|
+
if (option === 'help' || !option) {
|
|
82
|
+
console.log(getDescription(version));
|
|
83
|
+
showHelp(program);
|
|
84
|
+
}
|
|
78
85
|
return (
|
|
79
86
|
shouldShowHelp(program, option) ||
|
|
80
87
|
((hasApplication() && options[option]) || showHelp(program))()
|
|
@@ -96,7 +103,6 @@ async function init() {
|
|
|
96
103
|
const program = new Command();
|
|
97
104
|
const info = await getPackageInfo();
|
|
98
105
|
const version = info.version;
|
|
99
|
-
program.version(version, '-v, --version', 'output the current version');
|
|
100
106
|
program.option(
|
|
101
107
|
'-b, --build',
|
|
102
108
|
'build project utility files & package dependencies'
|
|
@@ -105,13 +111,14 @@ async function init() {
|
|
|
105
111
|
'-c, --compile',
|
|
106
112
|
'compile TypeScript files to JavaScript & move to src'
|
|
107
113
|
);
|
|
114
|
+
program.option('-h, --help', 'display help for command');
|
|
108
115
|
program.option(
|
|
109
116
|
'-s, --sync',
|
|
110
117
|
'sync new instance-based src files to the ts directory'
|
|
111
118
|
);
|
|
119
|
+
program.version(version, '-v, --version', 'output the current version');
|
|
112
120
|
program.usage(cyan('[options]'));
|
|
113
|
-
|
|
114
|
-
return doOptions(program);
|
|
121
|
+
return doOptions(program, version);
|
|
115
122
|
}
|
|
116
123
|
function introPrompt(msg) {
|
|
117
124
|
return intro(msg);
|
package/package.json
CHANGED
package/scripts/options.ts
CHANGED
package/scripts/snts.ts
CHANGED
|
@@ -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,14 +38,17 @@ function doOptions(program: Command) {
|
|
|
38
38
|
compile: () => {
|
|
39
39
|
doCompile();
|
|
40
40
|
},
|
|
41
|
+
help: () => {
|
|
42
|
+
showHelp(program);
|
|
43
|
+
},
|
|
41
44
|
sync: () => {
|
|
42
45
|
doSync();
|
|
43
46
|
},
|
|
44
47
|
default: () => {
|
|
45
|
-
program
|
|
48
|
+
showHelp(program);
|
|
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() {
|
|
@@ -60,7 +63,7 @@ function getDescription(version: string) {
|
|
|
60
63
|
const title = 'SN TypeScript Util';
|
|
61
64
|
const description =
|
|
62
65
|
'is a TS utility for ServiceNow developers using VS Code.';
|
|
63
|
-
return `${bold(magenta(title))} ${description} ${gray(`(${version})`)}\n`;
|
|
66
|
+
return `${bold(magenta(title))} ${description} ${gray(`(v${version})`)}\n`;
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
function getErrorMsg() {
|
|
@@ -91,8 +94,13 @@ function handleError() {
|
|
|
91
94
|
function handleOptions(
|
|
92
95
|
program: Command,
|
|
93
96
|
options: Options,
|
|
94
|
-
option: keyof Options
|
|
97
|
+
option: keyof Options,
|
|
98
|
+
version: string
|
|
95
99
|
) {
|
|
100
|
+
if (option === 'help' || !option) {
|
|
101
|
+
console.log(getDescription(version));
|
|
102
|
+
showHelp(program);
|
|
103
|
+
}
|
|
96
104
|
return (
|
|
97
105
|
shouldShowHelp(program, option) ||
|
|
98
106
|
((hasApplication() && options[option]) || showHelp(program))()
|
|
@@ -117,7 +125,6 @@ async function init() {
|
|
|
117
125
|
const program = new Command();
|
|
118
126
|
const info = await getPackageInfo();
|
|
119
127
|
const version = info.version;
|
|
120
|
-
program.version(version, '-v, --version', 'output the current version');
|
|
121
128
|
program.option(
|
|
122
129
|
'-b, --build',
|
|
123
130
|
'build project utility files & package dependencies'
|
|
@@ -126,13 +133,14 @@ async function init() {
|
|
|
126
133
|
'-c, --compile',
|
|
127
134
|
'compile TypeScript files to JavaScript & move to src'
|
|
128
135
|
);
|
|
136
|
+
program.option('-h, --help', 'display help for command');
|
|
129
137
|
program.option(
|
|
130
138
|
'-s, --sync',
|
|
131
139
|
'sync new instance-based src files to the ts directory'
|
|
132
140
|
);
|
|
141
|
+
program.version(version, '-v, --version', 'output the current version');
|
|
133
142
|
program.usage(cyan('[options]'));
|
|
134
|
-
|
|
135
|
-
return doOptions(program);
|
|
143
|
+
return doOptions(program, version);
|
|
136
144
|
}
|
|
137
145
|
|
|
138
146
|
function introPrompt(msg: string) {
|
package/scripts/sync.sh
CHANGED
|
@@ -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
|
|