@aneuhold/be-ts-lib 1.0.78 → 2.0.0

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 (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -1
  3. package/lib/index.d.ts +4 -11
  4. package/lib/index.d.ts.map +1 -1
  5. package/lib/index.js +5 -51
  6. package/lib/index.js.map +1 -0
  7. package/lib/index.ts +11 -0
  8. package/lib/services/ConfigService/ConfigDefinition.d.ts.map +1 -1
  9. package/lib/services/ConfigService/ConfigDefinition.js +2 -2
  10. package/lib/services/ConfigService/ConfigDefinition.js.map +1 -0
  11. package/lib/services/ConfigService/ConfigDefinition.ts +10 -0
  12. package/lib/services/ConfigService/ConfigService.d.ts +25 -4
  13. package/lib/services/ConfigService/ConfigService.d.ts.map +1 -1
  14. package/lib/services/ConfigService/ConfigService.js +33 -17
  15. package/lib/services/ConfigService/ConfigService.js.map +1 -0
  16. package/lib/services/ConfigService/ConfigService.spec.ts +17 -0
  17. package/lib/services/ConfigService/ConfigService.ts +88 -0
  18. package/lib/services/GitHubService.d.ts +10 -0
  19. package/lib/services/GitHubService.d.ts.map +1 -1
  20. package/lib/services/GitHubService.js +17 -9
  21. package/lib/services/GitHubService.js.map +1 -0
  22. package/lib/services/GitHubService.ts +63 -0
  23. package/lib/services/TranslationService/TranslationService.d.ts +7 -1
  24. package/lib/services/TranslationService/TranslationService.d.ts.map +1 -1
  25. package/lib/services/TranslationService/TranslationService.js +17 -17
  26. package/lib/services/TranslationService/TranslationService.js.map +1 -0
  27. package/lib/services/TranslationService/TranslationService.spec.ts +18 -0
  28. package/lib/services/TranslationService/TranslationService.ts +40 -0
  29. package/package.json +37 -28
  30. package/lib/services/CLIService.d.ts +0 -69
  31. package/lib/services/CLIService.d.ts.map +0 -1
  32. package/lib/services/CLIService.js +0 -193
  33. package/lib/services/ConfigService/ConfigService.spec.d.ts +0 -2
  34. package/lib/services/ConfigService/ConfigService.spec.d.ts.map +0 -1
  35. package/lib/services/ConfigService/ConfigService.spec.js +0 -20
  36. package/lib/services/TranslationService/TranslationService.spec.d.ts +0 -2
  37. package/lib/services/TranslationService/TranslationService.spec.d.ts.map +0 -1
  38. package/lib/services/TranslationService/TranslationService.spec.js +0 -39
  39. package/lib/services/applications/ChromeService.d.ts +0 -20
  40. package/lib/services/applications/ChromeService.d.ts.map +0 -1
  41. package/lib/services/applications/ChromeService.js +0 -60
  42. package/lib/services/applications/DockerService.d.ts +0 -21
  43. package/lib/services/applications/DockerService.d.ts.map +0 -1
  44. package/lib/services/applications/DockerService.js +0 -86
  45. package/lib/services/applications/ITermService.d.ts +0 -8
  46. package/lib/services/applications/ITermService.d.ts.map +0 -1
  47. package/lib/services/applications/ITermService.js +0 -45
  48. package/lib/services/applications/OSFileSystemService.d.ts +0 -19
  49. package/lib/services/applications/OSFileSystemService.d.ts.map +0 -1
  50. package/lib/services/applications/OSFileSystemService.js +0 -90
  51. package/lib/utils/CurrentEnv.d.ts +0 -63
  52. package/lib/utils/CurrentEnv.d.ts.map +0 -1
  53. package/lib/utils/CurrentEnv.js +0 -137
  54. package/lib/utils/OsaScriptBuilder.d.ts +0 -45
  55. package/lib/utils/OsaScriptBuilder.d.ts.map +0 -1
  56. package/lib/utils/OsaScriptBuilder.js +0 -53
@@ -1,35 +1,35 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TranslationSource = void 0;
7
- require("dotenv/config");
8
- const core_ts_lib_1 = require("@aneuhold/core-ts-lib");
9
- const jsonc_parser_1 = require("jsonc-parser");
10
- const GitHubService_1 = __importDefault(require("../GitHubService"));
11
- var TranslationSource;
1
+ import { Logger } from '@aneuhold/core-ts-lib';
2
+ import 'dotenv/config';
3
+ import { parse } from 'jsonc-parser';
4
+ import GitHubService from '../GitHubService.js';
5
+ /**
6
+ * An enum which defines the sources of translations which can be loaded.
7
+ */
8
+ export var TranslationSource;
12
9
  (function (TranslationSource) {
13
10
  TranslationSource["dashboard"] = "dashboard";
14
- })(TranslationSource || (exports.TranslationSource = TranslationSource = {}));
11
+ })(TranslationSource || (TranslationSource = {}));
15
12
  /**
16
13
  * A class which can be used to get translations for personal projects. It is
17
14
  * expected that the translations will be loaded in fresh each time this class
18
15
  * is called.
19
16
  */
20
- class TranslationService {
17
+ export default class TranslationService {
21
18
  /**
22
19
  * Gets translations for the provided source.
20
+ *
21
+ * @param source - The source of the translations.
22
+ * @returns The translations for the provided source.
23
23
  */
24
24
  static async getTranslations(source) {
25
25
  try {
26
- const jsonString = await GitHubService_1.default.getContentFromRepo('translations', `${source}.jsonc`);
27
- return (0, jsonc_parser_1.parse)(jsonString);
26
+ const jsonString = await GitHubService.getContentFromRepo('translations', `${source}.jsonc`);
27
+ return parse(jsonString);
28
28
  }
29
29
  catch (error) {
30
- core_ts_lib_1.Logger.error(`Failed to load ${source}.json, error: ${error}`);
30
+ Logger.error(`Failed to load ${source}.json, error: ${error}`);
31
31
  throw error;
32
32
  }
33
33
  }
34
34
  }
35
- exports.default = TranslationService;
35
+ //# sourceMappingURL=TranslationService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TranslationService.js","sourceRoot":"./src/","sources":["services/TranslationService/TranslationService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAEhD;;GAEG;AACH,MAAM,CAAN,IAAY,iBAEX;AAFD,WAAY,iBAAiB;IAC3B,4CAAuB,CAAA;AACzB,CAAC,EAFW,iBAAiB,KAAjB,iBAAiB,QAE5B;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACrC;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,eAAe,CAC1B,MAAyB;QAEzB,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,kBAAkB,CACvD,cAAc,EACd,GAAG,MAAM,QAAQ,CAClB,CAAC;YACF,OAAO,KAAK,CAAC,UAAU,CAAiB,CAAC;QAC3C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,kBAAkB,MAAM,iBAAiB,KAAe,EAAE,CAAC,CAAC;YACzE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,18 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import TranslationService, { TranslationSource } from './TranslationService.js';
3
+
4
+ describe('TranslationService', () => {
5
+ describe('getTranslations', () => {
6
+ /**
7
+ * Depends upon a GitHub token being available in the local environment.
8
+ * This will be a local `.env` file with the CONFIG_GITHUB_TOKEN variable
9
+ * set.
10
+ */
11
+ it('should load translations from GitHub', async () => {
12
+ const translations = await TranslationService.getTranslations(
13
+ TranslationSource.dashboard
14
+ );
15
+ expect(translations['test-translation'].value).toEqual('something');
16
+ });
17
+ });
18
+ });
@@ -0,0 +1,40 @@
1
+ import { Translations } from '@aneuhold/core-ts-api-lib';
2
+ import { Logger } from '@aneuhold/core-ts-lib';
3
+ import 'dotenv/config';
4
+ import { parse } from 'jsonc-parser';
5
+ import GitHubService from '../GitHubService.js';
6
+
7
+ /**
8
+ * An enum which defines the sources of translations which can be loaded.
9
+ */
10
+ export enum TranslationSource {
11
+ dashboard = 'dashboard'
12
+ }
13
+
14
+ /**
15
+ * A class which can be used to get translations for personal projects. It is
16
+ * expected that the translations will be loaded in fresh each time this class
17
+ * is called.
18
+ */
19
+ export default class TranslationService {
20
+ /**
21
+ * Gets translations for the provided source.
22
+ *
23
+ * @param source - The source of the translations.
24
+ * @returns The translations for the provided source.
25
+ */
26
+ static async getTranslations(
27
+ source: TranslationSource
28
+ ): Promise<Translations> {
29
+ try {
30
+ const jsonString = await GitHubService.getContentFromRepo(
31
+ 'translations',
32
+ `${source}.jsonc`
33
+ );
34
+ return parse(jsonString) as Translations;
35
+ } catch (error) {
36
+ Logger.error(`Failed to load ${source}.json, error: ${error as string}`);
37
+ throw error;
38
+ }
39
+ }
40
+ }
package/package.json CHANGED
@@ -1,12 +1,33 @@
1
1
  {
2
2
  "name": "@aneuhold/be-ts-lib",
3
- "version": "1.0.78",
3
+ "author": "Anton G. Neuhold Jr.",
4
+ "license": "MIT",
5
+ "version": "2.0.0",
4
6
  "description": "A backend TypeScript library used for common functionality in personal backend projects.",
7
+ "packageManager": "yarn@4.5.1",
8
+ "type": "module",
9
+ "scripts": {
10
+ "build": "rimraf lib && tsc --project tsconfig.build.json && tsx ./scripts/copyTsFiles.ts",
11
+ "lint": "eslint",
12
+ "test": "vitest run",
13
+ "jsr:validate": "tb pkg validateJsr",
14
+ "checkAll": "yarn build && yarn lint && yarn test && yarn jsr:validate",
15
+ "jsr:publish": "tb pkg publishJsr",
16
+ "upgrade:core": "yarn up '@aneuhold/*'",
17
+ "upgrade:all": "yarn up"
18
+ },
5
19
  "main": "lib/index.js",
20
+ "module": "lib/index.js",
6
21
  "types": "lib/index.d.ts",
7
- "author": "Anton G Neuhold Jr <agneuhold@gmail.com>",
8
- "license": "MIT",
9
- "packageManager": "yarn@4.5.1",
22
+ "files": [
23
+ "lib/**/*"
24
+ ],
25
+ "exports": {
26
+ ".": {
27
+ "types": "./lib/index.d.ts",
28
+ "import": "./lib/index.js"
29
+ }
30
+ },
10
31
  "repository": {
11
32
  "type": "git",
12
33
  "url": "git+https://github.com/aneuhold/be-ts-lib.git"
@@ -15,42 +36,30 @@
15
36
  "url": "https://github.com/aneuhold/be-ts-lib/issues"
16
37
  },
17
38
  "homepage": "https://github.com/aneuhold/be-ts-lib#readme",
18
- "files": [
19
- "lib/**/*"
20
- ],
21
39
  "keywords": [
22
- "Scripting",
23
- "Node.js"
40
+ "Backend",
41
+ "Node.js",
42
+ "TypeScript"
24
43
  ],
25
- "scripts": {
26
- "pushpub": "yarn build && npm version patch && git push",
27
- "build": "tsc",
28
- "watch": "tsc -w",
29
- "link:local": "cd lib && yarn link",
30
- "unlink:local": "cd lib && yarn unlink",
31
- "upgrade:all": "yarn up",
32
- "upgrade:core": "yarn up '@aneuhold/*'",
33
- "test": "jest",
34
- "lint": "eslint"
35
- },
36
44
  "dependencies": {
37
- "@aneuhold/core-ts-api-lib": "^1.0.114",
38
- "@aneuhold/core-ts-lib": "^1.1.52",
45
+ "@aneuhold/core-ts-api-lib": "^2.0.0",
46
+ "@aneuhold/core-ts-lib": "^2.0.6",
39
47
  "dotenv": "^16.4.5",
40
48
  "jsonc-parser": "^3.3.1",
41
49
  "node-fetch": "^2",
42
50
  "octokit": "^3.1.2"
43
51
  },
44
52
  "devDependencies": {
45
- "@aneuhold/eslint-config": "^1.0.37",
46
- "@types/jest": "^29.5.13",
53
+ "@aneuhold/eslint-config": "^1.0.40",
54
+ "@aneuhold/main-scripts": "^2.0.6",
47
55
  "@types/node": "^20.16.13",
48
56
  "@types/node-fetch": "^2.6.11",
49
57
  "eslint": "^9.13.0",
50
- "jest": "^29.7.0",
58
+ "jsr": "^0.13.2",
51
59
  "prettier": "^3.3.3",
52
- "ts-jest": "^29.2.5",
53
- "ts-node": "^10.9.2",
54
- "typescript": "^5.6.3"
60
+ "rimraf": "^6.0.1",
61
+ "tsx": "^4.19.1",
62
+ "typescript": "^5.6.3",
63
+ "vitest": "^2.1.3"
55
64
  }
56
65
  }
@@ -1,69 +0,0 @@
1
- type ExecCmdReturnType = {
2
- didComplete: boolean;
3
- output: string;
4
- };
5
- /**
6
- * A service which can be used to interact with the command line on the current
7
- * system.
8
- */
9
- export default class CLIService {
10
- private static POWERSHELL_PREFIX;
11
- /**
12
- * Executes the given command in a shell environment. Spins up a separate
13
- * process to execute the command and returns a promise once it is completely
14
- * finished.
15
- *
16
- * The shell environment chosen is determined by the `CurrentEnv` class.
17
- *
18
- * @param cmd the command to run. This is ran as a normal execution where the
19
- * output is all returned at once after completion. For example this could be
20
- * `ls -a`.
21
- *
22
- * @param logError if set to false, it will not output a log if an error
23
- * occurs in `stderr` when executing the function. This can be useful if
24
- * a command regularly outputs an error even when it succeeds. This only
25
- * applies to commands ran with normal execution.
26
- *
27
- * @param cwd the current working directory to run the command in. If not
28
- * provided, it will use the current working directory of the process.
29
- *
30
- * @param useProfile if set to true will use the current profile or zshrc of
31
- * the shell environment. By default this is false.
32
- *
33
- * @returns an object that holds the output and true if the command completed
34
- * successfully or false if it did not.
35
- */
36
- static execCmd(cmd: string, logError?: boolean, cwd?: string, useProfile?: boolean): Promise<ExecCmdReturnType>;
37
- /**
38
- * Executes the given command but fulfills the
39
- * promise when either the command completes, or the given number of ms have
40
- * passed. Whichever comes first.
41
- *
42
- * @param command the command to execute
43
- * @param ms the number of milliseconds to wait. This is 5 seconds by default.
44
- */
45
- static execCmdWithTimeout(command: string, ms?: number): Promise<ExecCmdReturnType>;
46
- /**
47
- * Spawns a new process where the command is ran as a stream where all
48
- * output is streamed to the console.
49
- * This is helpful for long-running commands or commands
50
- * that output a lot of data. For example `yarn` or `npm install`.
51
- * All of the output from this is logged by default because of the listeners
52
- * involved. This could be changed in the future though.
53
- *
54
- * @param cmd the command to run. This is the the first argument passed to the
55
- * `spawn` function. For example this could be `npm`.
56
- * @param args the arguments to pass to the command. For example this could be
57
- * `['install', 'react']`.
58
- */
59
- static spawnCmd(cmd: string, args?: string[], currentWorkingDirectory?: string): Promise<ExecCmdReturnType>;
60
- /**
61
- * Gets input from the user on command line.
62
- *
63
- * @param promptToUser the prompt that should be provided to the user. Include
64
- * a newline at the end if you want there to be one.
65
- */
66
- static getUserInput(promptToUser: string): Promise<string>;
67
- }
68
- export {};
69
- //# sourceMappingURL=CLIService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CLIService.d.ts","sourceRoot":"","sources":["../../src/services/CLIService.ts"],"names":[],"mappings":"AAWA,KAAK,iBAAiB,GAAG;IAAE,WAAW,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAA+B;IAE/D;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;WACU,OAAO,CAClB,GAAG,EAAE,MAAM,EACX,QAAQ,UAAQ,EAChB,GAAG,CAAC,EAAE,MAAM,EACZ,UAAU,UAAQ,GACjB,OAAO,CAAC,iBAAiB,CAAC;IA6C7B;;;;;;;OAOG;WACU,kBAAkB,CAC7B,OAAO,EAAE,MAAM,EACf,EAAE,SAAO,GACR,OAAO,CAAC,iBAAiB,CAAC;IAU7B;;;;;;;;;;;;OAYG;WACU,QAAQ,CACnB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,MAAM,EAAE,EACf,uBAAuB,CAAC,EAAE,MAAM,GAC/B,OAAO,CAAC,iBAAiB,CAAC;IAkC7B;;;;;OAKG;WACU,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAYjE"}
@@ -1,193 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const child_process_1 = require("child_process");
30
- const rl = __importStar(require("readline"));
31
- const util_1 = __importDefault(require("util"));
32
- const core_ts_lib_1 = require("@aneuhold/core-ts-lib");
33
- const CurrentEnv_1 = __importStar(require("../utils/CurrentEnv"));
34
- /**
35
- * The promisified version of the {@link normalExec} function.
36
- */
37
- const execute = util_1.default.promisify(child_process_1.exec);
38
- /**
39
- * A service which can be used to interact with the command line on the current
40
- * system.
41
- */
42
- class CLIService {
43
- static POWERSHELL_PREFIX = `pwsh -NoProfile -Command `;
44
- /**
45
- * Executes the given command in a shell environment. Spins up a separate
46
- * process to execute the command and returns a promise once it is completely
47
- * finished.
48
- *
49
- * The shell environment chosen is determined by the `CurrentEnv` class.
50
- *
51
- * @param cmd the command to run. This is ran as a normal execution where the
52
- * output is all returned at once after completion. For example this could be
53
- * `ls -a`.
54
- *
55
- * @param logError if set to false, it will not output a log if an error
56
- * occurs in `stderr` when executing the function. This can be useful if
57
- * a command regularly outputs an error even when it succeeds. This only
58
- * applies to commands ran with normal execution.
59
- *
60
- * @param cwd the current working directory to run the command in. If not
61
- * provided, it will use the current working directory of the process.
62
- *
63
- * @param useProfile if set to true will use the current profile or zshrc of
64
- * the shell environment. By default this is false.
65
- *
66
- * @returns an object that holds the output and true if the command completed
67
- * successfully or false if it did not.
68
- */
69
- static async execCmd(cmd, logError = false, cwd, useProfile = false) {
70
- const execOptions = {};
71
- if (cwd) {
72
- execOptions.cwd = cwd;
73
- }
74
- let commandToExecute = cmd;
75
- // Set the powershell prefix if the current OS is Windows so that
76
- // the profile is not ran before the command.
77
- if (CurrentEnv_1.default.os === CurrentEnv_1.OperatingSystemType.Windows && !useProfile) {
78
- commandToExecute = `${CLIService.POWERSHELL_PREFIX}${cmd}`;
79
- }
80
- else if (CurrentEnv_1.default.os === CurrentEnv_1.OperatingSystemType.Windows && useProfile) {
81
- execOptions.shell = 'pwsh';
82
- }
83
- core_ts_lib_1.Logger.verbose.info(`Executing command: ${commandToExecute}`);
84
- try {
85
- const { stdout, stderr } = await execute(commandToExecute, execOptions);
86
- if (stderr) {
87
- if (logError) {
88
- core_ts_lib_1.Logger.error(`There was an error executing ${cmd}. Details are printed below:
89
- ${stderr}`);
90
- }
91
- return {
92
- didComplete: false,
93
- output: stderr
94
- };
95
- }
96
- core_ts_lib_1.Logger.verbose.info(`Output from stdout is: ${stdout}`);
97
- return {
98
- didComplete: true,
99
- output: stdout
100
- };
101
- }
102
- catch (err) {
103
- core_ts_lib_1.Logger.verbose
104
- .error(`There was an error executing the "exec" function. Details are printed below:
105
- ${err}`);
106
- return {
107
- didComplete: false,
108
- output: err
109
- };
110
- }
111
- }
112
- /**
113
- * Executes the given command but fulfills the
114
- * promise when either the command completes, or the given number of ms have
115
- * passed. Whichever comes first.
116
- *
117
- * @param command the command to execute
118
- * @param ms the number of milliseconds to wait. This is 5 seconds by default.
119
- */
120
- static async execCmdWithTimeout(command, ms = 5000) {
121
- const sleepPromise = (0, core_ts_lib_1.sleep)(ms).then(() => {
122
- return {
123
- didComplete: false,
124
- output: `Command ended after ${ms} ms.`
125
- };
126
- });
127
- return Promise.any([sleepPromise, CLIService.execCmd(command)]);
128
- }
129
- /**
130
- * Spawns a new process where the command is ran as a stream where all
131
- * output is streamed to the console.
132
- * This is helpful for long-running commands or commands
133
- * that output a lot of data. For example `yarn` or `npm install`.
134
- * All of the output from this is logged by default because of the listeners
135
- * involved. This could be changed in the future though.
136
- *
137
- * @param cmd the command to run. This is the the first argument passed to the
138
- * `spawn` function. For example this could be `npm`.
139
- * @param args the arguments to pass to the command. For example this could be
140
- * `['install', 'react']`.
141
- */
142
- static async spawnCmd(cmd, args, currentWorkingDirectory) {
143
- return new Promise((resolve) => {
144
- let output = '';
145
- const execOptions = {
146
- cwd: currentWorkingDirectory
147
- };
148
- const spawnedCmd = (0, child_process_1.spawn)(cmd, args, execOptions);
149
- spawnedCmd.on('error', (err) => {
150
- core_ts_lib_1.Logger.error(`There was an error executing the "spawn" function. Details are printed below:
151
- ${err.message}`);
152
- resolve({
153
- didComplete: false,
154
- output: err.toString()
155
- });
156
- });
157
- spawnedCmd.stdout.on('data', (data) => {
158
- output += data;
159
- core_ts_lib_1.Logger.info(data, true);
160
- });
161
- spawnedCmd.stderr.on('data', (data) => {
162
- output += data;
163
- core_ts_lib_1.Logger.info(data, true);
164
- });
165
- spawnedCmd.on('close', (exitCode) => {
166
- core_ts_lib_1.Logger.info(`Command "${cmd}" exited with code ${exitCode}`);
167
- resolve({
168
- didComplete: true,
169
- output
170
- });
171
- });
172
- });
173
- }
174
- /**
175
- * Gets input from the user on command line.
176
- *
177
- * @param promptToUser the prompt that should be provided to the user. Include
178
- * a newline at the end if you want there to be one.
179
- */
180
- static async getUserInput(promptToUser) {
181
- const readline = rl.createInterface({
182
- input: process.stdin,
183
- output: process.stdout
184
- });
185
- return new Promise((resolve) => {
186
- readline.question(promptToUser, (input) => {
187
- readline.close();
188
- resolve(input);
189
- });
190
- });
191
- }
192
- }
193
- exports.default = CLIService;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=ConfigService.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConfigService.spec.d.ts","sourceRoot":"","sources":["../../../src/services/ConfigService/ConfigService.spec.ts"],"names":[],"mappings":""}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const ConfigService_1 = __importDefault(require("./ConfigService"));
7
- describe('ConfigService', () => {
8
- describe('useConfig', () => {
9
- /**
10
- * Depends upon a GitHub token being available in the local environment.
11
- * This will be a local `.env` file with the CONFIG_GITHUB_TOKEN variable
12
- * set.
13
- */
14
- it('should load configuration from GitHub', async () => {
15
- const env = 'local';
16
- await ConfigService_1.default.useConfig(env);
17
- expect(ConfigService_1.default.config.someKey).toEqual('SOME_VALUE');
18
- });
19
- });
20
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=TranslationService.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TranslationService.spec.d.ts","sourceRoot":"","sources":["../../../src/services/TranslationService/TranslationService.spec.ts"],"names":[],"mappings":""}
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const TranslationService_1 = __importStar(require("./TranslationService"));
27
- describe('TranslationService', () => {
28
- describe('getTranslations', () => {
29
- /**
30
- * Depends upon a GitHub token being available in the local environment.
31
- * This will be a local `.env` file with the CONFIG_GITHUB_TOKEN variable
32
- * set.
33
- */
34
- it('should load translations from GitHub', async () => {
35
- const translations = await TranslationService_1.default.getTranslations(TranslationService_1.TranslationSource.dashboard);
36
- expect(translations['test-translation'].value).toEqual('something');
37
- });
38
- });
39
- });
@@ -1,20 +0,0 @@
1
- import { OperatingSystemType } from '../../utils/CurrentEnv';
2
- /**
3
- * A service that provides functionality for interacting with the Chrome
4
- * browser.
5
- */
6
- export default class ChromeService {
7
- /**
8
- * Gets the path to the chrome application for the current system given the
9
- * operating system type.
10
- *
11
- * This does include the quotes
12
- */
13
- static getChromePath(os: OperatingSystemType): string | null;
14
- /**
15
- * Opens and sets pinned tabs in chrome. Still trying to figure out
16
- * how to get this to work.
17
- */
18
- static openAndSetPinnedTabs(): Promise<void>;
19
- }
20
- //# sourceMappingURL=ChromeService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChromeService.d.ts","sourceRoot":"","sources":["../../../src/services/applications/ChromeService.ts"],"names":[],"mappings":"AAAA,OAAmB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAGzE;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,mBAAmB,GAAG,MAAM,GAAG,IAAI;IAW5D;;;OAGG;WACU,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;CAOnD"}
@@ -1,60 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const CurrentEnv_1 = __importStar(require("../../utils/CurrentEnv"));
30
- const CLIService_1 = __importDefault(require("../CLIService"));
31
- /**
32
- * A service that provides functionality for interacting with the Chrome
33
- * browser.
34
- */
35
- class ChromeService {
36
- /**
37
- * Gets the path to the chrome application for the current system given the
38
- * operating system type.
39
- *
40
- * This does include the quotes
41
- */
42
- static getChromePath(os) {
43
- switch (os) {
44
- case CurrentEnv_1.OperatingSystemType.MacOSX:
45
- return `"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"`;
46
- case CurrentEnv_1.OperatingSystemType.Windows:
47
- return `& "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"`;
48
- default:
49
- return null;
50
- }
51
- }
52
- /**
53
- * Opens and sets pinned tabs in chrome. Still trying to figure out
54
- * how to get this to work.
55
- */
56
- static async openAndSetPinnedTabs() {
57
- await CLIService_1.default.execCmd(`${ChromeService.getChromePath(CurrentEnv_1.default.os)} --pinned-tab-count=2 https://google.com https://tonyneuhold.com`);
58
- }
59
- }
60
- exports.default = ChromeService;
@@ -1,21 +0,0 @@
1
- import { OperatingSystemType } from '../../utils/CurrentEnv';
2
- /**
3
- * A service that provides functionality for interacting with the Docker
4
- * application.
5
- */
6
- export default class DockerService {
7
- /**
8
- * Starts the Docker Desktop application. If it is already running, it doesn't
9
- * do anything.
10
- */
11
- static startDockerDesktop(): Promise<void>;
12
- static checkIfDockerDesktopIsRunning(): Promise<boolean>;
13
- /**
14
- * Gets the path to the docker application for the current system given the
15
- * operating system type.
16
- *
17
- * This does include the quotes
18
- */
19
- static getDockerPath(os: OperatingSystemType): string | null;
20
- }
21
- //# sourceMappingURL=DockerService.d.ts.map