sn-typescript-util 1.0.13 → 1.0.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.
Files changed (2) hide show
  1. package/bin/snts.ts +21 -5
  2. package/package.json +1 -1
package/bin/snts.ts CHANGED
@@ -15,10 +15,23 @@ const { bold, red } = require('colorette');
15
15
  return init();
16
16
  })();
17
17
 
18
+ function getBuildName() {
19
+ const defaultBuild = 'rome';
20
+ try {
21
+ const workspace = JSON.parse(getWorkspaceConfig());
22
+ const app = workspace.ACTIVE_APPLICATION;
23
+ const build = workspace.ALL_APPLICATIONS[app].BUILD_NAME;
24
+ return Object.entries(build).length !== 0
25
+ ? build.toLowerCase()
26
+ : defaultBuild;
27
+ } catch (e) {
28
+ return defaultBuild;
29
+ }
30
+ }
31
+
18
32
  function getErrorMsg() {
19
- var msg =
20
- 'No active application detected. Please create a project with the ServiceNow Extension for VS Code.\n\n' +
21
- 'https://docs.servicenow.com/bundle/quebec-application-development/page/build/applications/task/create-project.html';
33
+ var url = `https://docs.servicenow.com/bundle/${getBuildName()}-application-development/page/build/applications/task/create-project.html`;
34
+ var msg = `No active application detected. Please create a project with the ServiceNow Extension for VS Code.\n\n${url}`;
22
35
  return console.error(bold(red(msg)));
23
36
  }
24
37
 
@@ -53,10 +66,13 @@ function getProgressBar() {
53
66
  });
54
67
  }
55
68
 
69
+ function getWorkspaceConfig() {
70
+ return fs.readFileSync('./system/sn-workspace.json');
71
+ }
72
+
56
73
  function hasApplication() {
57
74
  try {
58
- const workspace = fs.readFileSync('system/sn-workspace.json');
59
- const app = JSON.parse(workspace).ACTIVE_APPLICATION;
75
+ const app = JSON.parse(getWorkspaceConfig()).ACTIVE_APPLICATION;
60
76
  return Object.entries(app).length === 0 ? getErrorMsg() : true;
61
77
  } catch (e) {
62
78
  getErrorMsg();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sn-typescript-util",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "A TypeScript utility for ServiceNow developers using VS Code",
5
5
  "bin": {
6
6
  "snts": "bin/snts.ts"