sn-typescript-util 1.3.18 → 1.4.1

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
@@ -28,7 +28,6 @@ Using TypeScript, the CLI provides an enhanced developer workflow.
28
28
  ## Prerequisites
29
29
 
30
30
  - [Node.js](https://nodejs.org/)
31
- - [Ruby](https://www.ruby-lang.org/en/documentation/installation/)
32
31
  - [ServiceNow Extension for VS Code](https://marketplace.visualstudio.com/items?itemName=ServiceNow.now-vscode)
33
32
  - An [imported application](https://docs.servicenow.com/bundle/vancouver-application-development/page/build/applications/task/vscode-import-application.html) in VS Code
34
33
 
package/bin/snts.js CHANGED
@@ -3,17 +3,22 @@ import { $ } from 'execa';
3
3
  import { Command } from 'commander';
4
4
  import { execFile } from 'node:child_process';
5
5
  import path from 'path';
6
- import { readFileSync } from 'fs';
6
+ import { readFileSync, writeFileSync } from 'fs';
7
7
  import { fileURLToPath } from 'url';
8
8
  import { bold, cyan, gray, magenta, red } from 'colorette';
9
9
  import { intro, outro, spinner } from '@clack/prompts';
10
+ async function createTemplate(file, path) {
11
+ const project = await getProject();
12
+ const template = readFileSync(path, 'utf8');
13
+ const updatedContent = template.replace(/@project/g, project);
14
+ return await writeFile(file, updatedContent);
15
+ }
10
16
  async function doBuild() {
11
17
  const s = startPrompts('Installing configs', 'Build started');
12
- return await execFile(getFilePath('init.rb', 'scripts/build'), (stdout) => {
13
- stopPrompt(s, 'Configs installed');
14
- runSync();
15
- return stdout;
16
- });
18
+ const filePath = getFilePath('tsconfig.json', 'scripts/templates');
19
+ await createTemplate('tsconfig.json', filePath);
20
+ stopPrompt(s, 'Configs installed');
21
+ runSync();
17
22
  }
18
23
  async function doClean() {
19
24
  const project = await getProject();
@@ -185,3 +190,10 @@ function stopPrompt(spinner, msg) {
185
190
  async function transpile() {
186
191
  return await $`tsc`;
187
192
  }
193
+ async function writeFile(file, data) {
194
+ try {
195
+ return writeFileSync(file, data, { encoding: 'utf-8' });
196
+ } catch (error) {
197
+ console.error(`Error writing file: ${error}`);
198
+ }
199
+ }
package/bun.lockb CHANGED
Binary file
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+
3
+ import eslint from '@eslint/js';
4
+ import tseslint from 'typescript-eslint';
5
+
6
+ export default tseslint.config(
7
+ eslint.configs.recommended,
8
+ ...tseslint.configs.recommended,
9
+ {
10
+ ignores: ['node_modules', 'tmp']
11
+ }
12
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sn-typescript-util",
3
- "version": "1.3.18",
3
+ "version": "1.4.1",
4
4
  "description": "A TypeScript utility for ServiceNow developers using VS Code",
5
5
  "bin": {
6
6
  "snts": "bin/snts.js"
@@ -18,25 +18,24 @@
18
18
  },
19
19
  "scripts": {
20
20
  "format": "prettier --write ./bin/*.js ./scripts/*.ts",
21
- "lint": "eslint .",
21
+ "lint": "bun eslint .",
22
22
  "release": "bun ./scripts/utils/release.ts",
23
23
  "watch": "tsc --watch"
24
24
  },
25
25
  "type": "module",
26
26
  "dependencies": {
27
27
  "@clack/prompts": "^0.7.0",
28
- "@types/servicenow": "^10.0.4",
29
28
  "colorette": "^2.0.20",
30
- "commander": "^11.1.0",
29
+ "commander": "^12.0.0",
31
30
  "execa": "^8.0.1",
32
- "typescript": "^5.3.3"
31
+ "typescript": "^5.4.5"
33
32
  },
34
33
  "devDependencies": {
34
+ "@eslint/js": "^9.0.0",
35
35
  "@types/commander": "^2.12.2",
36
- "@typescript-eslint/eslint-plugin": "^6.19.1",
37
- "@typescript-eslint/parser": "^6.19.1",
38
- "bun-types": "^1.0.25",
39
- "eslint": "^8.56.0",
40
- "prettier": "^3.2.4"
36
+ "bun-types": "^1.1.3",
37
+ "eslint": "^9.0.0",
38
+ "prettier": "^3.2.5",
39
+ "typescript-eslint": "^7.7.0"
41
40
  }
42
41
  }
package/scripts/snts.ts CHANGED
@@ -4,23 +4,26 @@ import { $ } from 'execa';
4
4
  import { Command } from 'commander';
5
5
  import { execFile } from 'node:child_process';
6
6
  import path from 'path';
7
- import { readFileSync } from 'fs';
7
+ import { readFileSync, writeFileSync } from 'fs';
8
8
  import { fileURLToPath } from 'url';
9
9
  import { bold, cyan, gray, magenta, red } from 'colorette';
10
10
  import { intro, outro, spinner } from '@clack/prompts';
11
11
  import { Options } from './types/options.js';
12
12
  import { Workspace } from './types/workspace.js';
13
13
 
14
+ async function createTemplate(file: string, path: string): Promise<void> {
15
+ const project = await getProject();
16
+ const template = readFileSync(path, 'utf8');
17
+ const updatedContent = template.replace(/@project/g, project);
18
+ return await writeFile(file, updatedContent);
19
+ }
20
+
14
21
  async function doBuild() {
15
22
  const s = startPrompts('Installing configs', 'Build started');
16
- return await execFile(
17
- getFilePath('init.rb', 'scripts/build'),
18
- (stdout: unknown) => {
19
- stopPrompt(s, 'Configs installed');
20
- runSync();
21
- return stdout;
22
- }
23
- );
23
+ const filePath = getFilePath('tsconfig.json', 'scripts/templates');
24
+ await createTemplate('tsconfig.json', filePath);
25
+ stopPrompt(s, 'Configs installed');
26
+ runSync();
24
27
  }
25
28
 
26
29
  async function doClean() {
@@ -221,3 +224,11 @@ function stopPrompt(spinner: any, msg: string) {
221
224
  async function transpile() {
222
225
  return await $`tsc`;
223
226
  }
227
+
228
+ async function writeFile(file: string, data: string) {
229
+ try {
230
+ return writeFileSync(file, data, { encoding: 'utf-8' });
231
+ } catch (error) {
232
+ console.error(`Error writing file: ${error}`);
233
+ }
234
+ }
package/.eslintignore DELETED
@@ -1,2 +0,0 @@
1
- node_modules
2
- tmp
@@ -1,56 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require_relative File.join(__dir__, './../utils/utils')
4
-
5
- module ServiceNow
6
- class Build
7
- def initialize
8
- @app = ServiceNow::Utils.new.get_application
9
- end
10
-
11
- def create_prettier_config
12
- config = '.prettierrc.json'
13
- file = ServiceNow::Utils.new.fetch_file 'templates', config
14
- File.write(config, file)
15
- end
16
-
17
- def create_tsconfig
18
- config = 'tsconfig.json'
19
- file = ServiceNow::Utils.new.fetch_file 'templates', config
20
- File.write(config, file)
21
- ServiceNow::Utils.new.replace_content config
22
- end
23
-
24
- def get_config_types
25
- [
26
- '.prettierrc',
27
- '.prettierrc.json',
28
- '.prettierrc.yml',
29
- '.prettierrc.yaml',
30
- '.prettierrc.json5',
31
- '.prettierrc.js',
32
- '.prettierrc.cjs',
33
- 'prettier.config.js',
34
- 'prettier.config.cjs',
35
- '.prettierrc.toml'
36
- ]
37
- end
38
-
39
- def has_prettier_config
40
- get_config_types.any? do |item|
41
- ServiceNow::Utils.new.has_file item
42
- end
43
- end
44
-
45
- def init
46
- make_configs
47
- end
48
-
49
- def make_configs
50
- create_tsconfig
51
- if has_prettier_config === false
52
- create_prettier_config
53
- end
54
- end
55
- end
56
- end
@@ -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.init
7
- end
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'fileutils'
4
- require 'json'
5
-
6
- module ServiceNow
7
- class Utils
8
- def has_file(file)
9
- File.file?("#{file}")
10
- end
11
-
12
- def fetch_file(dir, file)
13
- File.read(File.join(File.expand_path('..', __dir__), "#{dir}/#{file}"))
14
- end
15
-
16
- def get_application
17
- file_path = File.read('system/sn-workspace.json')
18
- JSON.parse(file_path)['ACTIVE_APPLICATION']
19
- end
20
-
21
- def replace_content(item)
22
- File.write(item, File.open(item, &:read).gsub('@project', get_application))
23
- end
24
- end
25
- end