sn-typescript-util 1.2.4 → 1.2.6

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/.eslintrc.yml ADDED
@@ -0,0 +1,5 @@
1
+
2
+ extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended']
3
+ parser: '@typescript-eslint/parser'
4
+ plugins: ['@typescript-eslint']
5
+ root: true
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/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
32
+ - A [project created](https://docs.servicenow.com/bundle/vancouver-application-development/page/build/applications/task/create-project.html) and [application imported](https://docs.servicenow.com/bundle/vancouver-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
@@ -7,125 +7,119 @@ import { fileURLToPath } from 'url';
7
7
  import { bold, red } from 'colorette';
8
8
  import { intro, outro, spinner } from '@clack/prompts';
9
9
  async function doBuild() {
10
- const s = startPrompts('Installing configs', 'Build started');
11
- return await execFile(getFilePath('init.rb'), (stdout) => {
12
- stopPrompt(s, 'Configs installed');
13
- runSync();
14
- return stdout;
15
- });
10
+ const s = startPrompts('Installing configs', 'Build started');
11
+ return await execFile(getFilePath('init.rb'), (stdout) => {
12
+ stopPrompt(s, 'Configs installed');
13
+ runSync();
14
+ return stdout;
15
+ });
16
16
  }
17
17
  async function doCompile() {
18
- const s = startPrompts('Processing', 'Compile started');
19
- return await execFile(getFilePath('compile.rb'), (stdout) => {
20
- stopPrompt(s, 'Completed');
21
- return stdout;
22
- });
18
+ const s = startPrompts('Processing', 'Compile started');
19
+ return await execFile(getFilePath('compile.rb'), (stdout) => {
20
+ stopPrompt(s, 'Completed');
21
+ return stdout;
22
+ });
23
23
  }
24
24
  function doOptions(program) {
25
- program.parse(process.argv).opts();
26
- const option = Object.keys(program.opts()).toString();
27
- const options = {
28
- build: () => {
29
- doBuild();
30
- },
31
- compile: () => {
32
- doCompile();
33
- },
34
- sync: () => {
35
- doSync();
36
- },
37
- default: () => {
38
- program.help();
39
- }
40
- };
41
- return ((hasApplication() && options[option]) || options['default'])();
25
+ program.parse(process.argv).opts();
26
+ const option = Object.keys(program.opts()).toString();
27
+ const options = {
28
+ build: () => {
29
+ doBuild();
30
+ },
31
+ compile: () => {
32
+ doCompile();
33
+ },
34
+ sync: () => {
35
+ doSync();
36
+ },
37
+ default: () => {
38
+ program.help();
39
+ }
40
+ };
41
+ return ((hasApplication() && options[option]) || options['default'])();
42
42
  }
43
43
  async function doSync() {
44
- const s = startPrompts('Processing', 'Sync started');
45
- return await execFile(getFilePath('sync.sh'), (stdout) => {
46
- stopPrompt(s, 'Completed');
47
- return stdout;
48
- });
49
- }
50
- function getBuildName() {
51
- const defaultBuild = 'utah';
52
- try {
53
- const workspace = getWorkspace();
54
- const app = workspace.ACTIVE_APPLICATION;
55
- const build = workspace.ALL_APPLICATIONS[app].BUILD_NAME;
56
- return Object.entries(build).length !== 0
57
- ? build.toLowerCase()
58
- : defaultBuild;
59
- }
60
- catch (e) {
61
- return defaultBuild;
62
- }
44
+ const s = startPrompts('Processing', 'Sync started');
45
+ return await execFile(getFilePath('sync.sh'), (stdout) => {
46
+ stopPrompt(s, 'Completed');
47
+ return stdout;
48
+ });
63
49
  }
64
50
  function getErrorMsg() {
65
- var url = `https://docs.servicenow.com/bundle/${getBuildName()}-application-development/page/build/applications/task/create-project.html`;
66
- var msg = `No active application detected. Please create a project with the ServiceNow Extension for VS Code.\n\n${url}`;
67
- return console.error(bold(red(msg)));
51
+ const url = `https://docs.servicenow.com/bundle/vancouver-application-development/page/build/applications/task/create-project.html`;
52
+ const msg = `No active application detected. Please create a project with the ServiceNow Extension for VS Code.\n\n${url}`;
53
+ return console.error(bold(red(msg)));
68
54
  }
69
55
  function getFilePath(file, dir = 'scripts') {
70
- const fileName = fileURLToPath(import.meta.url);
71
- const dirName = path.dirname(fileName);
72
- return `${path.join(dirName, `../${dir}`)}/${file}`;
56
+ const fileName = fileURLToPath(import.meta.url);
57
+ const dirName = path.dirname(fileName);
58
+ return `${path.join(dirName, `../${dir}`)}/${file}`;
73
59
  }
74
60
  async function getPackageInfo() {
75
- return JSON.parse(readFileSync(getFilePath('package.json', '.')).toString());
61
+ return JSON.parse(readFileSync(getFilePath('package.json', '.')).toString());
76
62
  }
77
63
  function getWorkspace() {
78
- return JSON.parse(readFileSync('./system/sn-workspace.json').toString());
64
+ return JSON.parse(readFileSync('./system/sn-workspace.json').toString());
79
65
  }
80
66
  async function hasApplication() {
81
- try {
82
- const workspace = await getWorkspace();
83
- var app = workspace.ACTIVE_APPLICATION;
84
- return Object.entries(app).length === 0 ? getErrorMsg() : true;
85
- }
86
- catch (e) {
87
- getErrorMsg();
88
- return process.exit(1);
89
- }
67
+ try {
68
+ const workspace = await getWorkspace();
69
+ const app = workspace.ACTIVE_APPLICATION;
70
+ return Object.entries(app).length === 0 ? getErrorMsg() : true;
71
+ } catch (e) {
72
+ getErrorMsg();
73
+ return process.exit(1);
74
+ }
90
75
  }
91
76
  (async () => {
92
- return init();
77
+ return init();
93
78
  })();
94
79
  async function init() {
95
- const program = new Command();
96
- const info = await getPackageInfo();
97
- program.description(info.description);
98
- program.version(info.version);
99
- program.option('-b, --build', 'build project utility files & package dependencies');
100
- program.option('-c, --compile', 'compile TypeScript files to JavaScript & move to src');
101
- program.option('-s, --sync', 'sync new instance-based src files to the ts directory');
102
- return doOptions(program);
80
+ const program = new Command();
81
+ const info = await getPackageInfo();
82
+ program.description(info.description);
83
+ program.version(info.version);
84
+ program.option(
85
+ '-b, --build',
86
+ 'build project utility files & package dependencies'
87
+ );
88
+ program.option(
89
+ '-c, --compile',
90
+ 'compile TypeScript files to JavaScript & move to src'
91
+ );
92
+ program.option(
93
+ '-s, --sync',
94
+ 'sync new instance-based src files to the ts directory'
95
+ );
96
+ return doOptions(program);
103
97
  }
104
98
  function introPrompt(msg) {
105
- return intro(msg);
99
+ return intro(msg);
106
100
  }
107
101
  async function runInstall() {
108
- const s = startPrompts('Installing packages', null);
109
- return await execFile(getFilePath('install.sh'), (stdout) => {
110
- stopPrompt(s, 'Packages installed');
111
- outro('Completed');
112
- return stdout;
113
- });
102
+ const s = startPrompts('Installing packages', null);
103
+ return await execFile(getFilePath('install.sh'), (stdout) => {
104
+ stopPrompt(s, 'Packages installed');
105
+ outro('Completed');
106
+ return stdout;
107
+ });
114
108
  }
115
109
  async function runSync() {
116
- const s = startPrompts('Syncing', null);
117
- return await execFile(getFilePath('sync.sh'), (stdout) => {
118
- stopPrompt(s, 'Sync completed');
119
- runInstall();
120
- return stdout;
121
- });
110
+ const s = startPrompts('Syncing', null);
111
+ return await execFile(getFilePath('sync.sh'), (stdout) => {
112
+ stopPrompt(s, 'Sync completed');
113
+ runInstall();
114
+ return stdout;
115
+ });
122
116
  }
123
117
  function startPrompts(start, intro) {
124
- intro && introPrompt(intro);
125
- const s = spinner();
126
- s.start(start);
127
- return s;
118
+ intro && introPrompt(intro);
119
+ const s = spinner();
120
+ s.start(start);
121
+ return s;
128
122
  }
129
123
  function stopPrompt(spinner, msg) {
130
- return spinner.stop(msg);
124
+ return spinner.stop(msg);
131
125
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sn-typescript-util",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "description": "A TypeScript utility for ServiceNow developers using VS Code",
5
5
  "bin": {
6
6
  "snts": "bin/snts.js"
@@ -17,19 +17,25 @@
17
17
  "url": "https://github.com/stevengregory/sn-typescript-util.git"
18
18
  },
19
19
  "scripts": {
20
+ "format": "prettier --write ./bin/*.js ./scripts/*.ts",
20
21
  "release": "./scripts/release.sh",
21
22
  "watch": "tsc --watch"
22
23
  },
23
24
  "type": "module",
24
25
  "dependencies": {
25
- "@clack/prompts": "^0.6.3",
26
- "@types/node": "^20.4.2",
26
+ "@clack/prompts": "^0.7.0",
27
+ "@types/node": "^20.5.9",
27
28
  "@types/servicenow": "^10.0.1",
28
29
  "colorette": "^2.0.20",
29
30
  "commander": "^11.0.0",
30
31
  "nodemon": "^3.0.1",
31
32
  "npm-add-script": "^1.1.0",
32
- "prettier": "^3.0.0",
33
- "typescript": "^5.1.6"
33
+ "prettier": "^3.0.3",
34
+ "typescript": "^5.2.2"
35
+ },
36
+ "devDependencies": {
37
+ "@typescript-eslint/eslint-plugin": "^6.5.0",
38
+ "@typescript-eslint/parser": "^6.5.0",
39
+ "eslint": "^8.48.0"
34
40
  }
35
41
  }
package/scripts/snts.ts CHANGED
@@ -28,8 +28,8 @@ async function doCompile() {
28
28
 
29
29
  function doOptions(program: any) {
30
30
  program.parse(process.argv).opts();
31
- const option = Object.keys(program.opts()).toString();
32
- const options = {
31
+ const option: string = Object.keys(program.opts()).toString();
32
+ const options: any = {
33
33
  build: () => {
34
34
  doBuild();
35
35
  },
@@ -54,23 +54,9 @@ async function doSync() {
54
54
  });
55
55
  }
56
56
 
57
- function getBuildName() {
58
- const defaultBuild: string = 'utah';
59
- try {
60
- const workspace: Workspace = getWorkspace();
61
- const app: string = workspace.ACTIVE_APPLICATION;
62
- const build: string = workspace.ALL_APPLICATIONS[app].BUILD_NAME;
63
- return Object.entries(build).length !== 0
64
- ? build.toLowerCase()
65
- : defaultBuild;
66
- } catch (e) {
67
- return defaultBuild;
68
- }
69
- }
70
-
71
57
  function getErrorMsg() {
72
- var url: string = `https://docs.servicenow.com/bundle/${getBuildName()}-application-development/page/build/applications/task/create-project.html`;
73
- var msg: string = `No active application detected. Please create a project with the ServiceNow Extension for VS Code.\n\n${url}`;
58
+ const url: string = `https://docs.servicenow.com/bundle/vancouver-application-development/page/build/applications/task/create-project.html`;
59
+ const msg: string = `No active application detected. Please create a project with the ServiceNow Extension for VS Code.\n\n${url}`;
74
60
  return console.error(bold(red(msg)));
75
61
  }
76
62
 
@@ -91,7 +77,7 @@ function getWorkspace() {
91
77
  async function hasApplication() {
92
78
  try {
93
79
  const workspace: Workspace = await getWorkspace();
94
- var app: string = workspace.ACTIVE_APPLICATION;
80
+ const app: string = workspace.ACTIVE_APPLICATION;
95
81
  return Object.entries(app).length === 0 ? getErrorMsg() : true;
96
82
  } catch (e) {
97
83
  getErrorMsg();
@@ -145,7 +131,7 @@ async function runSync() {
145
131
  });
146
132
  }
147
133
 
148
- function startPrompts(start: string, intro: string) {
134
+ function startPrompts(start: string, intro: string | null) {
149
135
  intro && introPrompt(intro);
150
136
  const s = spinner();
151
137
  s.start(start);
@@ -9,8 +9,7 @@
9
9
  },
10
10
  "include": [
11
11
  "./@project/ts/**/*",
12
- "./lib/dts/*.d.ts",
13
- "./@project/ts/Interfaces/*.ts"
12
+ "./lib/dts/*.d.ts"
14
13
  ],
15
14
  "exclude": ["node_modules"]
16
15
  }
package/tsconfig.json CHANGED
@@ -2,6 +2,7 @@
2
2
  "compilerOptions": {
3
3
  "target": "ESNext",
4
4
  "module": "NodeNext",
5
+ "noImplicitAny": true,
5
6
  "esModuleInterop": true,
6
7
  "outDir": "bin",
7
8
  "resolveJsonModule": true,