sn-typescript-util 1.3.16 → 1.3.18

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 CHANGED
@@ -108,6 +108,18 @@ snts --help
108
108
  snts -h
109
109
  ```
110
110
 
111
+ ### Remove
112
+
113
+ Remove & clean the `ts` build directory.
114
+
115
+ ```bash
116
+ snts --remove
117
+
118
+ # or
119
+
120
+ snts -r
121
+ ```
122
+
111
123
  ### Sync
112
124
 
113
125
  Sync new instance-based `src` files to the `ts` directory.
package/bin/snts.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { $ } from 'execa';
2
3
  import { Command } from 'commander';
3
4
  import { execFile } from 'node:child_process';
4
5
  import path from 'path';
@@ -14,15 +15,16 @@ async function doBuild() {
14
15
  return stdout;
15
16
  });
16
17
  }
18
+ async function doClean() {
19
+ const project = await getProject();
20
+ const dirName = path.dirname(project);
21
+ const buildDir = `${path.join(dirName, project)}/ts`;
22
+ return await $`rm -rf ${buildDir}`;
23
+ }
17
24
  async function doCompile() {
18
25
  const s = startPrompts('Processing', 'Compile started');
19
- return await execFile(
20
- getFilePath('compile.rb', 'scripts/build'),
21
- (stdout) => {
22
- stopPrompt(s, 'Completed');
23
- return stdout;
24
- }
25
- );
26
+ const compile = await transpile();
27
+ return compile && stopPrompt(s, 'Completed');
26
28
  }
27
29
  function doOptions(program) {
28
30
  const options = parseOptions(program);
@@ -51,6 +53,7 @@ function getConstants() {
51
53
  Constants['compileOption'] =
52
54
  'Compile TypeScript files to JavaScript & move to src';
53
55
  Constants['helpOption'] = 'Display help for command';
56
+ Constants['removeOption'] = 'Remove & clean the ts build directory';
54
57
  Constants['syncOption'] =
55
58
  'Sync new instance-based src files to the ts directory';
56
59
  Constants['versionOption'] = 'Output the current version';
@@ -84,6 +87,9 @@ function getOptions(program) {
84
87
  help: () => {
85
88
  showHelp(program);
86
89
  },
90
+ remove: () => {
91
+ doClean();
92
+ },
87
93
  sync: () => {
88
94
  doSync();
89
95
  },
@@ -95,6 +101,10 @@ function getOptions(program) {
95
101
  async function getPackageInfo() {
96
102
  return JSON.parse(readFileSync(getFilePath('package.json', '.')).toString());
97
103
  }
104
+ async function getProject() {
105
+ const workspace = await getWorkspace();
106
+ return workspace.ACTIVE_APPLICATION;
107
+ }
98
108
  async function getVersion() {
99
109
  const info = await getPackageInfo();
100
110
  return info.version;
@@ -136,6 +146,7 @@ async function init() {
136
146
  program.option('-b, --build', constants.buildOption);
137
147
  program.option('-c, --compile', constants.compileOption);
138
148
  program.option('-h, --help', constants.helpOption);
149
+ program.option('-r, --remove', constants.removeOption);
139
150
  program.option('-s, --sync', constants.syncOption);
140
151
  program.version(version, '-v, --version', constants.versionOption);
141
152
  program.usage(cyan('[options]'));
@@ -171,3 +182,6 @@ function startPrompts(start, intro) {
171
182
  function stopPrompt(spinner, msg) {
172
183
  return spinner.stop(msg);
173
184
  }
185
+ async function transpile() {
186
+ return await $`tsc`;
187
+ }
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.16",
3
+ "version": "1.3.18",
4
4
  "description": "A TypeScript utility for ServiceNow developers using VS Code",
5
5
  "bin": {
6
6
  "snts": "bin/snts.js"
@@ -28,14 +28,15 @@
28
28
  "@types/servicenow": "^10.0.4",
29
29
  "colorette": "^2.0.20",
30
30
  "commander": "^11.1.0",
31
+ "execa": "^8.0.1",
31
32
  "typescript": "^5.3.3"
32
33
  },
33
34
  "devDependencies": {
34
35
  "@types/commander": "^2.12.2",
35
- "@typescript-eslint/eslint-plugin": "^6.19.0",
36
- "@typescript-eslint/parser": "^6.19.0",
37
- "bun-types": "^1.0.24",
36
+ "@typescript-eslint/eslint-plugin": "^6.19.1",
37
+ "@typescript-eslint/parser": "^6.19.1",
38
+ "bun-types": "^1.0.25",
38
39
  "eslint": "^8.56.0",
39
- "prettier": "^3.2.2"
40
+ "prettier": "^3.2.4"
40
41
  }
41
42
  }
@@ -52,9 +52,5 @@ module ServiceNow
52
52
  create_prettier_config
53
53
  end
54
54
  end
55
-
56
- def transpile
57
- %x( tsc )
58
- end
59
55
  end
60
56
  end
package/scripts/snts.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import { $ } from 'execa';
3
4
  import { Command } from 'commander';
4
5
  import { execFile } from 'node:child_process';
5
6
  import path from 'path';
@@ -22,15 +23,17 @@ async function doBuild() {
22
23
  );
23
24
  }
24
25
 
26
+ async function doClean() {
27
+ const project = await getProject();
28
+ const dirName = path.dirname(project);
29
+ const buildDir = `${path.join(dirName, project)}/ts`;
30
+ return await $`rm -rf ${buildDir}`;
31
+ }
32
+
25
33
  async function doCompile() {
26
34
  const s = startPrompts('Processing', 'Compile started');
27
- return await execFile(
28
- getFilePath('compile.rb', 'scripts/build'),
29
- (stdout: unknown) => {
30
- stopPrompt(s, 'Completed');
31
- return stdout;
32
- }
33
- );
35
+ const compile = await transpile();
36
+ return compile && stopPrompt(s, 'Completed');
34
37
  }
35
38
 
36
39
  function doOptions(program: Command) {
@@ -59,6 +62,7 @@ function getConstants() {
59
62
  buildOption = 'Build project utility files & package dependencies',
60
63
  compileOption = 'Compile TypeScript files to JavaScript & move to src',
61
64
  helpOption = 'Display help for command',
65
+ removeOption = 'Remove & clean the ts build directory',
62
66
  syncOption = 'Sync new instance-based src files to the ts directory',
63
67
  versionOption = 'Output the current version'
64
68
  }
@@ -95,6 +99,9 @@ function getOptions(program: Command): Options {
95
99
  help: () => {
96
100
  showHelp(program);
97
101
  },
102
+ remove: () => {
103
+ doClean();
104
+ },
98
105
  sync: () => {
99
106
  doSync();
100
107
  },
@@ -108,6 +115,11 @@ async function getPackageInfo() {
108
115
  return JSON.parse(readFileSync(getFilePath('package.json', '.')).toString());
109
116
  }
110
117
 
118
+ async function getProject() {
119
+ const workspace = await getWorkspace();
120
+ return workspace.ACTIVE_APPLICATION;
121
+ }
122
+
111
123
  async function getVersion() {
112
124
  const info = await getPackageInfo();
113
125
  return info.version;
@@ -159,6 +171,7 @@ async function init() {
159
171
  program.option('-b, --build', constants.buildOption);
160
172
  program.option('-c, --compile', constants.compileOption);
161
173
  program.option('-h, --help', constants.helpOption);
174
+ program.option('-r, --remove', constants.removeOption);
162
175
  program.option('-s, --sync', constants.syncOption);
163
176
  program.version(version, '-v, --version', constants.versionOption);
164
177
  program.usage(cyan('[options]'));
@@ -204,3 +217,7 @@ function startPrompts(start: string, intro: string | null) {
204
217
  function stopPrompt(spinner: any, msg: string) {
205
218
  return spinner.stop(msg);
206
219
  }
220
+
221
+ async function transpile() {
222
+ return await $`tsc`;
223
+ }
@@ -2,6 +2,7 @@ export interface Options {
2
2
  build: () => void;
3
3
  compile: () => void;
4
4
  help: () => void;
5
+ remove: () => void;
5
6
  sync: () => void;
6
7
  default: () => void;
7
8
  }
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require_relative File.join(__dir__, 'build')
4
-
5
- module ServiceNow
6
- ServiceNow::Build.new.transpile
7
- end