sn-typescript-util 1.3.13 → 1.3.14
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/.eslintignore +1 -0
- package/.eslintrc.yml +0 -1
- package/README.md +2 -6
- package/bin/snts.js +10 -6
- package/bun.lockb +0 -0
- package/package.json +2 -3
- package/scripts/snts.ts +12 -8
- package/scripts/types/version.ts +6 -0
- package/scripts/utils/release.ts +80 -0
- package/scripts/utils/release.sh +0 -21
package/.eslintignore
CHANGED
package/.eslintrc.yml
CHANGED
package/README.md
CHANGED
|
@@ -54,14 +54,10 @@ In the application directory created by the ServiceNow Extension for VS Code, th
|
|
|
54
54
|
|
|
55
55
|
## Basic Workflow
|
|
56
56
|
|
|
57
|
-
After installation & setup, simply run the
|
|
57
|
+
After installation & setup, simply run the TypeScript compiler `--watch` command to start looking for TypeScript code changes in the `ts` directory.
|
|
58
58
|
|
|
59
59
|
```bash
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
# or
|
|
63
|
-
|
|
64
|
-
yarn watch
|
|
60
|
+
tsc --watch
|
|
65
61
|
```
|
|
66
62
|
|
|
67
63
|
Any JavaScript ES2015 (ES6) code added will get converted down to ES5 and moved to the `src` directory. Then changes are ready to sync with the target instance using the ServiceNow Extension for VS Code.
|
package/bin/snts.js
CHANGED
|
@@ -24,10 +24,10 @@ async function doCompile() {
|
|
|
24
24
|
}
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
|
-
function doOptions(program
|
|
27
|
+
function doOptions(program) {
|
|
28
28
|
const options = parseOptions(program);
|
|
29
29
|
const optionKey = options;
|
|
30
|
-
return handleOptions(program, getOptions(program), optionKey
|
|
30
|
+
return handleOptions(program, getOptions(program), optionKey);
|
|
31
31
|
}
|
|
32
32
|
async function doSync() {
|
|
33
33
|
const s = startPrompts('Processing', 'Sync started');
|
|
@@ -95,6 +95,10 @@ function getOptions(program) {
|
|
|
95
95
|
async function getPackageInfo() {
|
|
96
96
|
return JSON.parse(readFileSync(getFilePath('package.json', '.')).toString());
|
|
97
97
|
}
|
|
98
|
+
async function getVersion() {
|
|
99
|
+
const info = await getPackageInfo();
|
|
100
|
+
return info.version;
|
|
101
|
+
}
|
|
98
102
|
function getWorkspace() {
|
|
99
103
|
return JSON.parse(readFileSync('./system/sn-workspace.json').toString());
|
|
100
104
|
}
|
|
@@ -102,8 +106,9 @@ function handleError() {
|
|
|
102
106
|
getErrorMsg();
|
|
103
107
|
return process.exit(1);
|
|
104
108
|
}
|
|
105
|
-
function handleOptions(program, options, option
|
|
109
|
+
async function handleOptions(program, options, option) {
|
|
106
110
|
if (option === 'help' || !option) {
|
|
111
|
+
const version = await getVersion();
|
|
107
112
|
console.log(getDescription(version));
|
|
108
113
|
showHelp(program);
|
|
109
114
|
}
|
|
@@ -126,16 +131,15 @@ async function hasApplication() {
|
|
|
126
131
|
})();
|
|
127
132
|
async function init() {
|
|
128
133
|
const program = new Command();
|
|
129
|
-
const info = await getPackageInfo();
|
|
130
134
|
const constants = getConstants();
|
|
131
|
-
const version =
|
|
135
|
+
const version = await getVersion();
|
|
132
136
|
program.option('-b, --build', constants.buildOption);
|
|
133
137
|
program.option('-c, --compile', constants.compileOption);
|
|
134
138
|
program.option('-h, --help', constants.helpOption);
|
|
135
139
|
program.option('-s, --sync', constants.syncOption);
|
|
136
140
|
program.version(version, '-v, --version', constants.versionOption);
|
|
137
141
|
program.usage(cyan('[options]'));
|
|
138
|
-
return doOptions(program
|
|
142
|
+
return doOptions(program);
|
|
139
143
|
}
|
|
140
144
|
function introPrompt(msg) {
|
|
141
145
|
return intro(msg);
|
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.14",
|
|
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/utils/release.
|
|
22
|
+
"release": "bun ./scripts/utils/release.ts",
|
|
23
23
|
"watch": "tsc --watch"
|
|
24
24
|
},
|
|
25
25
|
"type": "module",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"@types/servicenow": "^10.0.4",
|
|
29
29
|
"colorette": "^2.0.20",
|
|
30
30
|
"commander": "^11.1.0",
|
|
31
|
-
"npm-add-script": "^1.1.0",
|
|
32
31
|
"typescript": "^5.3.3"
|
|
33
32
|
},
|
|
34
33
|
"devDependencies": {
|
package/scripts/snts.ts
CHANGED
|
@@ -33,10 +33,10 @@ async function doCompile() {
|
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
function doOptions(program: Command
|
|
36
|
+
function doOptions(program: Command) {
|
|
37
37
|
const options = parseOptions(program);
|
|
38
38
|
const optionKey = options as keyof Options;
|
|
39
|
-
return handleOptions(program, getOptions(program), optionKey
|
|
39
|
+
return handleOptions(program, getOptions(program), optionKey);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
async function doSync() {
|
|
@@ -108,6 +108,11 @@ async function getPackageInfo() {
|
|
|
108
108
|
return JSON.parse(readFileSync(getFilePath('package.json', '.')).toString());
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
async function getVersion() {
|
|
112
|
+
const info = await getPackageInfo();
|
|
113
|
+
return info.version;
|
|
114
|
+
}
|
|
115
|
+
|
|
111
116
|
function getWorkspace() {
|
|
112
117
|
return JSON.parse(readFileSync('./system/sn-workspace.json').toString());
|
|
113
118
|
}
|
|
@@ -117,13 +122,13 @@ function handleError() {
|
|
|
117
122
|
return process.exit(1);
|
|
118
123
|
}
|
|
119
124
|
|
|
120
|
-
function handleOptions(
|
|
125
|
+
async function handleOptions(
|
|
121
126
|
program: Command,
|
|
122
127
|
options: Options,
|
|
123
|
-
option: keyof Options
|
|
124
|
-
version: string
|
|
128
|
+
option: keyof Options
|
|
125
129
|
) {
|
|
126
130
|
if (option === 'help' || !option) {
|
|
131
|
+
const version = await getVersion();
|
|
127
132
|
console.log(getDescription(version));
|
|
128
133
|
showHelp(program);
|
|
129
134
|
}
|
|
@@ -149,16 +154,15 @@ async function hasApplication() {
|
|
|
149
154
|
|
|
150
155
|
async function init() {
|
|
151
156
|
const program = new Command();
|
|
152
|
-
const info = await getPackageInfo();
|
|
153
157
|
const constants = getConstants();
|
|
154
|
-
const version =
|
|
158
|
+
const version = await getVersion();
|
|
155
159
|
program.option('-b, --build', constants.buildOption);
|
|
156
160
|
program.option('-c, --compile', constants.compileOption);
|
|
157
161
|
program.option('-h, --help', constants.helpOption);
|
|
158
162
|
program.option('-s, --sync', constants.syncOption);
|
|
159
163
|
program.version(version, '-v, --version', constants.versionOption);
|
|
160
164
|
program.usage(cyan('[options]'));
|
|
161
|
-
return doOptions(program
|
|
165
|
+
return doOptions(program);
|
|
162
166
|
}
|
|
163
167
|
|
|
164
168
|
function introPrompt(msg: string) {
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { $ } from 'execa';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { cancel, confirm, intro, outro, select, spinner } from '@clack/prompts';
|
|
6
|
+
import { Version } from './../types/version.js';
|
|
7
|
+
|
|
8
|
+
async function bumpVersion(releaseType) {
|
|
9
|
+
return await $`npm version ${releaseType} --no-git-tag-version`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async function confirmVersion(version: string) {
|
|
13
|
+
return await confirm({
|
|
14
|
+
message: `Bump to ${version}?`
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function doGitOperation(version: string) {
|
|
19
|
+
const msg = 'chore: bump the version';
|
|
20
|
+
await $`git commit -a -m ${msg}`;
|
|
21
|
+
await $`git tag ${version}`;
|
|
22
|
+
await $`git push`;
|
|
23
|
+
await $`git push origin ${version}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function doOperation(shouldContinue, version: string) {
|
|
27
|
+
if (shouldContinue) {
|
|
28
|
+
const s = spinner();
|
|
29
|
+
s.start('Start release');
|
|
30
|
+
await doGitOperation(version);
|
|
31
|
+
await doPublish();
|
|
32
|
+
s.stop('Done.');
|
|
33
|
+
outro("You're all set!");
|
|
34
|
+
} else {
|
|
35
|
+
cancel('Operation cancelled.');
|
|
36
|
+
await $`git checkout package.json`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function doPublish() {
|
|
41
|
+
return await $`npm publish`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function getFilePath(file: string, dir: string) {
|
|
45
|
+
const fileName = fileURLToPath(import.meta.url);
|
|
46
|
+
const dirName = path.dirname(fileName);
|
|
47
|
+
return `${path.join(dirName, `./../../${dir}`)}/${file}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function getPackageInfo() {
|
|
51
|
+
return JSON.parse(readFileSync(getFilePath('package.json', '.')).toString());
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function getReleaseTypes() {
|
|
55
|
+
return select({
|
|
56
|
+
message: 'Please pick a release type.',
|
|
57
|
+
options: getOptions()
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getOptions(): Version[] {
|
|
62
|
+
return [
|
|
63
|
+
{ value: 'patch', label: 'Patch' },
|
|
64
|
+
{ value: 'minor', label: 'Minor' },
|
|
65
|
+
{ value: 'major', label: 'Major' }
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function getVersion() {
|
|
70
|
+
const file = await getPackageInfo();
|
|
71
|
+
return file.version;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
(async function init() {
|
|
75
|
+
intro('Release Utils');
|
|
76
|
+
const releaseType = await getReleaseTypes();
|
|
77
|
+
const version = (await bumpVersion(releaseType)) && (await getVersion());
|
|
78
|
+
const shouldContinue = await confirmVersion(version);
|
|
79
|
+
return await doOperation(shouldContinue, version);
|
|
80
|
+
})();
|
package/scripts/utils/release.sh
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
bump_version() {
|
|
4
|
-
version=$(npm version "$1" --no-git-tag-version)
|
|
5
|
-
echo "version bumped to $version"
|
|
6
|
-
do_git_operation
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
do_git_operation() {
|
|
10
|
-
git commit -a -m "chore: bump the version"
|
|
11
|
-
git tag $(get_package_version)
|
|
12
|
-
git push
|
|
13
|
-
git push origin $(get_package_version)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
get_package_version() {
|
|
17
|
-
version=`node -p "require('./package.json').version"`
|
|
18
|
-
echo "v$version"
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
bump_version "$1"
|