sn-typescript-util 1.5.8 → 1.5.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/README.md +1 -1
- package/bin/snts.js +6 -6
- package/bun.lock +2 -2
- package/package.json +4 -4
- package/scripts/{utils/release.ts → release.ts} +4 -3
- package/{scripts → src}/snts.ts +14 -14
- package/{scripts → src}/types/workspace.ts +1 -1
- package/tsconfig.json +5 -2
- /package/scripts/{build/sync.sh → sync.sh} +0 -0
- /package/{scripts → src}/templates/.prettierrc.json +0 -0
- /package/{scripts → src}/templates/base-table.ts +0 -0
- /package/{scripts → src}/templates/tsconfig.json +0 -0
- /package/{scripts → src}/types/config.ts +0 -0
- /package/{scripts → src}/types/metadata.ts +0 -0
- /package/{scripts → src}/types/options.ts +0 -0
- /package/{scripts → src}/types/version.ts +0 -0
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Using TypeScript, the CLI provides an enhanced developer workflow.
|
|
|
29
29
|
|
|
30
30
|
- [Node.js](https://nodejs.org/)
|
|
31
31
|
- [ServiceNow Extension for VS Code](https://marketplace.visualstudio.com/items?itemName=ServiceNow.now-vscode)
|
|
32
|
-
- An [imported application](https://www.servicenow.com/docs/bundle/
|
|
32
|
+
- An [imported application](https://www.servicenow.com/docs/bundle/yokohama-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.js
CHANGED
|
@@ -17,7 +17,7 @@ async function addFile(sourcefile, sourceDir, targetFile, targetDir, message) {
|
|
|
17
17
|
async function addInterfaceFile() {
|
|
18
18
|
return await addFile(
|
|
19
19
|
'base-table.ts',
|
|
20
|
-
'
|
|
20
|
+
'src/templates',
|
|
21
21
|
'BaseTable.ts',
|
|
22
22
|
'ts/Types',
|
|
23
23
|
`Add a ${cyan('BaseTable.ts')} interface with global default fields?`
|
|
@@ -26,7 +26,7 @@ async function addInterfaceFile() {
|
|
|
26
26
|
async function addPrettierFile() {
|
|
27
27
|
return await addFile(
|
|
28
28
|
'.prettierrc.json',
|
|
29
|
-
'
|
|
29
|
+
'src/templates',
|
|
30
30
|
'.prettierrc.json',
|
|
31
31
|
null,
|
|
32
32
|
`Add a ${cyan('.prettierrc.json')} default config?`
|
|
@@ -54,7 +54,7 @@ async function doBuild() {
|
|
|
54
54
|
await addPrettierFile();
|
|
55
55
|
await initGitRepo();
|
|
56
56
|
const s = startPrompts('Installing config(s)', null);
|
|
57
|
-
const filePath = getFilePath('tsconfig.json', '
|
|
57
|
+
const filePath = getFilePath('tsconfig.json', 'src/templates');
|
|
58
58
|
await createTemplate('tsconfig.json', filePath);
|
|
59
59
|
const template = readFileSync('tsconfig.json', 'utf8');
|
|
60
60
|
const data = template.replace(/@version/g, esVersion);
|
|
@@ -80,7 +80,7 @@ function doOptions(program) {
|
|
|
80
80
|
}
|
|
81
81
|
async function doSync() {
|
|
82
82
|
const s = startPrompts('Processing', 'Sync started');
|
|
83
|
-
return await execFile(getFilePath('sync.sh', 'scripts
|
|
83
|
+
return await execFile(getFilePath('sync.sh', 'scripts'), (stdout) => {
|
|
84
84
|
stopPrompt(s, 'Completed');
|
|
85
85
|
return stdout;
|
|
86
86
|
});
|
|
@@ -107,7 +107,7 @@ function getConstants() {
|
|
|
107
107
|
Constants['errorMsg'] =
|
|
108
108
|
'No active application detected. Please create a project with the ServiceNow Extension for VS Code.';
|
|
109
109
|
Constants['docsUrl'] =
|
|
110
|
-
'https://
|
|
110
|
+
'https://www.servicenow.com/docs/bundle/yokohama-application-development/page/build/applications/task/create-project.html';
|
|
111
111
|
Constants['buildOption'] =
|
|
112
112
|
'Build project utility files & package dependencies';
|
|
113
113
|
Constants['compileOption'] =
|
|
@@ -234,7 +234,7 @@ function parseOptions(program) {
|
|
|
234
234
|
async function runSync() {
|
|
235
235
|
const project = await getProject();
|
|
236
236
|
const s = startPrompts('Syncing', null);
|
|
237
|
-
return await execFile(getFilePath('sync.sh', 'scripts
|
|
237
|
+
return await execFile(getFilePath('sync.sh', 'scripts'), (stdout) => {
|
|
238
238
|
stopPrompt(
|
|
239
239
|
s,
|
|
240
240
|
`TypeScript files constructed in the ${cyan(project + '/ts')} directory.`
|
package/bun.lock
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"@clack/prompts": "^0.10.1",
|
|
8
8
|
"colorette": "^2.0.20",
|
|
9
9
|
"commander": "^13.1.0",
|
|
10
|
-
"execa": "^9.5.
|
|
10
|
+
"execa": "^9.5.3",
|
|
11
11
|
"typescript": "^5.8.3",
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
|
|
186
186
|
"eventsource-parser": ["eventsource-parser@3.0.1", "", {}, "sha512-VARTJ9CYeuQYb0pZEPbzi740OWFgpHe7AYJ2WFZVnUDUQp5Dk2yJUgF36YsZ81cOyxT0QxmXD2EQpapAouzWVA=="],
|
|
187
187
|
|
|
188
|
-
"execa": ["execa@9.5.
|
|
188
|
+
"execa": ["execa@9.5.3", "", { "dependencies": { "@sindresorhus/merge-streams": "^4.0.0", "cross-spawn": "^7.0.3", "figures": "^6.1.0", "get-stream": "^9.0.0", "human-signals": "^8.0.0", "is-plain-obj": "^4.1.0", "is-stream": "^4.0.1", "npm-run-path": "^6.0.0", "pretty-ms": "^9.0.0", "signal-exit": "^4.1.0", "strip-final-newline": "^4.0.0", "yoctocolors": "^2.0.0" } }, "sha512-QFNnTvU3UjgWFy8Ef9iDHvIdcgZ344ebkwYx4/KLbR+CKQA4xBaHzv+iRpp86QfMHP8faFQLh8iOc57215y4Rg=="],
|
|
189
189
|
|
|
190
190
|
"express": ["express@5.1.0", "", { "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.0", "content-disposition": "^1.0.0", "content-type": "^1.0.5", "cookie": "^0.7.1", "cookie-signature": "^1.2.1", "debug": "^4.4.0", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "etag": "^1.8.1", "finalhandler": "^2.1.0", "fresh": "^2.0.0", "http-errors": "^2.0.0", "merge-descriptors": "^2.0.0", "mime-types": "^3.0.0", "on-finished": "^2.4.1", "once": "^1.4.0", "parseurl": "^1.3.3", "proxy-addr": "^2.0.7", "qs": "^6.14.0", "range-parser": "^1.2.1", "router": "^2.2.0", "send": "^1.1.0", "serve-static": "^2.2.0", "statuses": "^2.0.1", "type-is": "^2.0.1", "vary": "^1.1.2" } }, "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA=="],
|
|
191
191
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sn-typescript-util",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.10",
|
|
4
4
|
"description": "A TypeScript utility for ServiceNow developers using VS Code",
|
|
5
5
|
"bin": {
|
|
6
6
|
"snts": "bin/snts.js"
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"url": "git+https://github.com/stevengregory/sn-typescript-util.git"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
|
-
"format": "prettier --write ./bin/*.js ./
|
|
20
|
+
"format": "prettier --write ./bin/*.js ./src/*.ts",
|
|
21
21
|
"lint": "bun eslint .",
|
|
22
|
-
"release": "bun ./scripts/
|
|
22
|
+
"release": "bun ./scripts/release.ts",
|
|
23
23
|
"watch": "tsc --watch"
|
|
24
24
|
},
|
|
25
25
|
"type": "module",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@clack/prompts": "^0.10.1",
|
|
28
28
|
"colorette": "^2.0.20",
|
|
29
29
|
"commander": "^13.1.0",
|
|
30
|
-
"execa": "^9.5.
|
|
30
|
+
"execa": "^9.5.3",
|
|
31
31
|
"typescript": "^5.8.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
@@ -3,8 +3,8 @@ import path from 'path';
|
|
|
3
3
|
import { readFileSync } from 'fs';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import { cancel, confirm, intro, outro, select, spinner } from '@clack/prompts';
|
|
6
|
-
import { Version, VersionType } from '
|
|
7
|
-
import { Metadata } from '
|
|
6
|
+
import type { Version, VersionType } from '../src/types/version.js';
|
|
7
|
+
import type { Metadata } from '../src/types/metadata.js';
|
|
8
8
|
|
|
9
9
|
async function bumpVersion(releaseType: VersionType) {
|
|
10
10
|
return await $`npm version ${releaseType} --no-git-tag-version`;
|
|
@@ -50,7 +50,8 @@ async function doPublish() {
|
|
|
50
50
|
function getFilePath(file: string, dir: string): string {
|
|
51
51
|
const fileName = fileURLToPath(import.meta.url);
|
|
52
52
|
const dirName = path.dirname(fileName);
|
|
53
|
-
|
|
53
|
+
const projectRoot = path.join(dirName, '..');
|
|
54
|
+
return path.join(projectRoot, dir, file);
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
async function getPackageInfo(): Promise<Metadata & { version: string }> {
|
package/{scripts → src}/snts.ts
RENAMED
|
@@ -8,15 +8,15 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
|
8
8
|
import { fileURLToPath } from 'url';
|
|
9
9
|
import { bold, cyan, gray, green, magenta, red } from 'colorette';
|
|
10
10
|
import { confirm, intro, outro, select, spinner } from '@clack/prompts';
|
|
11
|
-
import { Options } from './types/options.js';
|
|
12
|
-
import { Workspace } from './types/workspace.js';
|
|
13
|
-
import { ConfigTarget } from './types/config.js';
|
|
11
|
+
import type { Options } from './types/options.js';
|
|
12
|
+
import type { Workspace } from './types/workspace.js';
|
|
13
|
+
import type { ConfigTarget } from './types/config.js';
|
|
14
14
|
|
|
15
15
|
async function addFile(
|
|
16
16
|
sourcefile: string,
|
|
17
17
|
sourceDir: string,
|
|
18
18
|
targetFile: string,
|
|
19
|
-
targetDir: string |
|
|
19
|
+
targetDir: string | null,
|
|
20
20
|
message: string
|
|
21
21
|
) {
|
|
22
22
|
if (await confirmFile(message)) {
|
|
@@ -29,7 +29,7 @@ async function addFile(
|
|
|
29
29
|
async function addInterfaceFile() {
|
|
30
30
|
return await addFile(
|
|
31
31
|
'base-table.ts',
|
|
32
|
-
'
|
|
32
|
+
'src/templates',
|
|
33
33
|
'BaseTable.ts',
|
|
34
34
|
'ts/Types',
|
|
35
35
|
`Add a ${cyan('BaseTable.ts')} interface with global default fields?`
|
|
@@ -39,7 +39,7 @@ async function addInterfaceFile() {
|
|
|
39
39
|
async function addPrettierFile() {
|
|
40
40
|
return await addFile(
|
|
41
41
|
'.prettierrc.json',
|
|
42
|
-
'
|
|
42
|
+
'src/templates',
|
|
43
43
|
'.prettierrc.json',
|
|
44
44
|
null,
|
|
45
45
|
`Add a ${cyan('.prettierrc.json')} default config?`
|
|
@@ -66,15 +66,15 @@ async function createTemplate(file: string, path: string): Promise<void> {
|
|
|
66
66
|
|
|
67
67
|
async function doBuild() {
|
|
68
68
|
introPrompt(`${bold(magenta(getConstants().projectName))}: Build`);
|
|
69
|
-
const esVersion
|
|
69
|
+
const esVersion = await getConfigTypes();
|
|
70
70
|
await addInterfaceFile();
|
|
71
71
|
await addPrettierFile();
|
|
72
72
|
await initGitRepo();
|
|
73
73
|
const s = startPrompts('Installing config(s)', null);
|
|
74
|
-
const filePath = getFilePath('tsconfig.json', '
|
|
74
|
+
const filePath = getFilePath('tsconfig.json', 'src/templates');
|
|
75
75
|
await createTemplate('tsconfig.json', filePath);
|
|
76
76
|
const template = readFileSync('tsconfig.json', 'utf8');
|
|
77
|
-
const data = template.replace(/@version/g, esVersion);
|
|
77
|
+
const data = template.replace(/@version/g, esVersion as string);
|
|
78
78
|
await writeFile('tsconfig.json', data);
|
|
79
79
|
stopPrompt(s, `The ${cyan('tsconfig.json')} file was bootstrapped.`);
|
|
80
80
|
runSync();
|
|
@@ -102,7 +102,7 @@ function doOptions(program: Command) {
|
|
|
102
102
|
async function doSync() {
|
|
103
103
|
const s = startPrompts('Processing', 'Sync started');
|
|
104
104
|
return await execFile(
|
|
105
|
-
getFilePath('sync.sh', 'scripts
|
|
105
|
+
getFilePath('sync.sh', 'scripts'),
|
|
106
106
|
(stdout: unknown) => {
|
|
107
107
|
stopPrompt(s, 'Completed');
|
|
108
108
|
return stdout;
|
|
@@ -130,7 +130,7 @@ function getConstants() {
|
|
|
130
130
|
projectName = 'SN TypeScript Util',
|
|
131
131
|
projectDescription = 'is a TS utility for ServiceNow developers using VS Code.',
|
|
132
132
|
errorMsg = 'No active application detected. Please create a project with the ServiceNow Extension for VS Code.',
|
|
133
|
-
docsUrl = 'https://
|
|
133
|
+
docsUrl = 'https://www.servicenow.com/docs/bundle/yokohama-application-development/page/build/applications/task/create-project.html',
|
|
134
134
|
buildOption = 'Build project utility files & package dependencies',
|
|
135
135
|
compileOption = 'Compile TypeScript files to JavaScript & move to src',
|
|
136
136
|
helpOption = 'Display help for command',
|
|
@@ -192,7 +192,7 @@ async function getProject(): Promise<string> {
|
|
|
192
192
|
return workspace.ACTIVE_APPLICATION;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
async function getTargetPath(file: string, dir: string) {
|
|
195
|
+
async function getTargetPath(file: string, dir: string | null) {
|
|
196
196
|
const project = await getProject();
|
|
197
197
|
const path = dir ? `${project}/${dir}/` : '.';
|
|
198
198
|
if (dir && !existsSync(path)) {
|
|
@@ -277,7 +277,7 @@ async function runSync() {
|
|
|
277
277
|
const project = await getProject();
|
|
278
278
|
const s = startPrompts('Syncing', null);
|
|
279
279
|
return await execFile(
|
|
280
|
-
getFilePath('sync.sh', 'scripts
|
|
280
|
+
getFilePath('sync.sh', 'scripts'),
|
|
281
281
|
(stdout: unknown) => {
|
|
282
282
|
stopPrompt(
|
|
283
283
|
s,
|
|
@@ -306,7 +306,7 @@ function startPrompts(start: string, intro: string | null) {
|
|
|
306
306
|
return s;
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
-
function stopPrompt(spinner:
|
|
309
|
+
function stopPrompt(spinner: { stop: (msg: string) => void }, msg: string) {
|
|
310
310
|
return spinner.stop(msg);
|
|
311
311
|
}
|
|
312
312
|
|
package/tsconfig.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|