@aneuhold/core-ts-lib 1.1.4 → 1.1.5

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 (55) hide show
  1. package/lib/index.d.ts +2 -1
  2. package/lib/index.d.ts.map +1 -1
  3. package/lib/index.js +3 -1
  4. package/package.json +1 -1
  5. package/lib/helperFunctions/stringFunctions.d.ts +0 -9
  6. package/lib/helperFunctions/stringFunctions.d.ts.map +0 -1
  7. package/lib/helperFunctions/stringFunctions.js +0 -13
  8. package/lib/services/CLIService.d.ts +0 -69
  9. package/lib/services/CLIService.d.ts.map +0 -1
  10. package/lib/services/CLIService.js +0 -194
  11. package/lib/services/ConfigService/ConfigService.d.ts +0 -25
  12. package/lib/services/ConfigService/ConfigService.d.ts.map +0 -1
  13. package/lib/services/ConfigService/ConfigService.js +0 -72
  14. package/lib/services/ConfigService/ConfigService.spec.d.ts +0 -2
  15. package/lib/services/ConfigService/ConfigService.spec.d.ts.map +0 -1
  16. package/lib/services/ConfigService/ConfigService.spec.js +0 -28
  17. package/lib/services/DOFunctionService/DOAuthCheckPassword.d.ts +0 -1
  18. package/lib/services/DOFunctionService/DOAuthCheckPassword.d.ts.map +0 -1
  19. package/lib/services/DOFunctionService/DOAuthCheckPassword.js +0 -1
  20. package/lib/services/DOFunctionService/functions/DOAuthCheckPassword.d.ts +0 -1
  21. package/lib/services/DOFunctionService/functions/DOAuthCheckPassword.d.ts.map +0 -1
  22. package/lib/services/DOFunctionService/functions/DOAuthCheckPassword.js +0 -1
  23. package/lib/services/DOFunctionService/functions/authCheckPassword.d.ts +0 -1
  24. package/lib/services/DOFunctionService/functions/authCheckPassword.d.ts.map +0 -1
  25. package/lib/services/DOFunctionService/functions/authCheckPassword.js +0 -1
  26. package/lib/services/DOFunctionService.d.ts +0 -32
  27. package/lib/services/DOFunctionService.d.ts.map +0 -1
  28. package/lib/services/DOFunctionService.js +0 -30
  29. package/lib/services/applications/ChromeService.d.ts +0 -20
  30. package/lib/services/applications/ChromeService.d.ts.map +0 -1
  31. package/lib/services/applications/ChromeService.js +0 -60
  32. package/lib/services/applications/DockerService.d.ts +0 -21
  33. package/lib/services/applications/DockerService.d.ts.map +0 -1
  34. package/lib/services/applications/DockerService.js +0 -88
  35. package/lib/services/applications/FileSystemService/FileSystemService.d.ts +0 -45
  36. package/lib/services/applications/FileSystemService/FileSystemService.d.ts.map +0 -1
  37. package/lib/services/applications/FileSystemService/FileSystemService.js +0 -176
  38. package/lib/services/applications/FileSystemService/FileSystemService.spec.d.ts +0 -2
  39. package/lib/services/applications/FileSystemService/FileSystemService.spec.d.ts.map +0 -1
  40. package/lib/services/applications/FileSystemService/FileSystemService.spec.js +0 -85
  41. package/lib/services/applications/FileSystemService.d.ts +0 -19
  42. package/lib/services/applications/FileSystemService.d.ts.map +0 -1
  43. package/lib/services/applications/FileSystemService.js +0 -97
  44. package/lib/services/applications/ITermService.d.ts +0 -8
  45. package/lib/services/applications/ITermService.d.ts.map +0 -1
  46. package/lib/services/applications/ITermService.js +0 -45
  47. package/lib/services/applications/OsaScriptService.d.ts +0 -4
  48. package/lib/services/applications/OsaScriptService.d.ts.map +0 -1
  49. package/lib/services/applications/OsaScriptService.js +0 -31
  50. package/lib/utils/CurrentEnv.d.ts +0 -63
  51. package/lib/utils/CurrentEnv.d.ts.map +0 -1
  52. package/lib/utils/CurrentEnv.js +0 -137
  53. package/lib/utils/OsaScriptBuilder.d.ts +0 -45
  54. package/lib/utils/OsaScriptBuilder.d.ts.map +0 -1
  55. package/lib/utils/OsaScriptBuilder.js +0 -53
package/lib/index.d.ts CHANGED
@@ -6,6 +6,7 @@ import { DOAuthCheckPasswordInput, DOAuthCheckPasswordOutput, DOAuthCheckPasswor
6
6
  import FileSystemService from './services/FileSystemService/FileSystemService';
7
7
  import StringService from './services/StringService';
8
8
  import Logger from './utils/Logger';
9
- export { datesAreOnSameDay, DependencyService, DOFunctionService, FileSystemService, Logger, sleep, StringService };
9
+ import TestUtils from './utils/TestUtils';
10
+ export { datesAreOnSameDay, DependencyService, DOFunctionService, FileSystemService, Logger, sleep, StringService, TestUtils };
10
11
  export type { DOAuthCheckPasswordInput, DOAuthCheckPasswordOutput, DOAuthCheckPasswordRawOutput, DOFunction };
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,iCAAiC,CAAC;AAChE,OAAO,KAAK,MAAM,yBAAyB,CAAC;AAC5C,OAAO,iBAAiB,MAAM,8BAA8B,CAAC;AAC7D,OAAO,iBAAiB,EAAE,EACxB,UAAU,EACX,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,4BAA4B,EAC7B,MAAM,8DAA8D,CAAC;AACtE,OAAO,iBAAiB,MAAM,gDAAgD,CAAC;AAC/E,OAAO,aAAa,MAAM,0BAA0B,CAAC;AACrD,OAAO,MAAM,MAAM,gBAAgB,CAAC;AAGpC,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,MAAM,EACN,KAAK,EACL,aAAa,EACd,CAAC;AAGF,YAAY,EACV,wBAAwB,EACxB,yBAAyB,EACzB,4BAA4B,EAC5B,UAAU,EACX,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,iCAAiC,CAAC;AAChE,OAAO,KAAK,MAAM,yBAAyB,CAAC;AAC5C,OAAO,iBAAiB,MAAM,8BAA8B,CAAC;AAC7D,OAAO,iBAAiB,EAAE,EACxB,UAAU,EACX,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,4BAA4B,EAC7B,MAAM,8DAA8D,CAAC;AACtE,OAAO,iBAAiB,MAAM,gDAAgD,CAAC;AAC/E,OAAO,aAAa,MAAM,0BAA0B,CAAC;AACrD,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAG1C,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,MAAM,EACN,KAAK,EACL,aAAa,EACb,SAAS,EACV,CAAC;AAGF,YAAY,EACV,wBAAwB,EACxB,yBAAyB,EACzB,4BAA4B,EAC5B,UAAU,EACX,CAAC"}
package/lib/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.StringService = exports.sleep = exports.Logger = exports.FileSystemService = exports.DOFunctionService = exports.DependencyService = exports.datesAreOnSameDay = void 0;
6
+ exports.TestUtils = exports.StringService = exports.sleep = exports.Logger = exports.FileSystemService = exports.DOFunctionService = exports.DependencyService = exports.datesAreOnSameDay = void 0;
7
7
  const dateFunctions_1 = __importDefault(require("./helperFunctions/dateFunctions"));
8
8
  exports.datesAreOnSameDay = dateFunctions_1.default;
9
9
  const sleep_1 = __importDefault(require("./helperFunctions/sleep"));
@@ -18,3 +18,5 @@ const StringService_1 = __importDefault(require("./services/StringService"));
18
18
  exports.StringService = StringService_1.default;
19
19
  const Logger_1 = __importDefault(require("./utils/Logger"));
20
20
  exports.Logger = Logger_1.default;
21
+ const TestUtils_1 = __importDefault(require("./utils/TestUtils"));
22
+ exports.TestUtils = TestUtils_1.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aneuhold/core-ts-lib",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "A core library for all of my TypeScript projects",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1,9 +0,0 @@
1
- /**
2
- * Gets the file extension of the provided file name.
3
- *
4
- * @param fileName the full name of the file or the entire file path
5
- * @returns a string containing the extension of the file name or undefined
6
- * if there is no extension
7
- */
8
- export default function getFileNameExtension(fileName: string): string | undefined;
9
- //# sourceMappingURL=stringFunctions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stringFunctions.d.ts","sourceRoot":"","sources":["../../src/helperFunctions/stringFunctions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,SAAS,CAEpB"}
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Gets the file extension of the provided file name.
5
- *
6
- * @param fileName the full name of the file or the entire file path
7
- * @returns a string containing the extension of the file name or undefined
8
- * if there is no extension
9
- */
10
- function getFileNameExtension(fileName) {
11
- return fileName.split('.').pop();
12
- }
13
- exports.default = getFileNameExtension;
@@ -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":"AAYA,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,194 +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 sleep_1 = __importDefault(require("../helperFunctions/sleep"));
33
- const CurrentEnv_1 = __importStar(require("../utils/CurrentEnv"));
34
- const Logger_1 = __importDefault(require("../utils/Logger"));
35
- /**
36
- * The promisified version of the {@link normalExec} function.
37
- */
38
- const execute = util_1.default.promisify(child_process_1.exec);
39
- /**
40
- * A service which can be used to interact with the command line on the current
41
- * system.
42
- */
43
- class CLIService {
44
- static POWERSHELL_PREFIX = `pwsh -NoProfile -Command `;
45
- /**
46
- * Executes the given command in a shell environment. Spins up a separate
47
- * process to execute the command and returns a promise once it is completely
48
- * finished.
49
- *
50
- * The shell environment chosen is determined by the `CurrentEnv` class.
51
- *
52
- * @param cmd the command to run. This is ran as a normal execution where the
53
- * output is all returned at once after completion. For example this could be
54
- * `ls -a`.
55
- *
56
- * @param logError if set to false, it will not output a log if an error
57
- * occurs in `stderr` when executing the function. This can be useful if
58
- * a command regularly outputs an error even when it succeeds. This only
59
- * applies to commands ran with normal execution.
60
- *
61
- * @param cwd the current working directory to run the command in. If not
62
- * provided, it will use the current working directory of the process.
63
- *
64
- * @param useProfile if set to true will use the current profile or zshrc of
65
- * the shell environment. By default this is false.
66
- *
67
- * @returns an object that holds the output and true if the command completed
68
- * successfully or false if it did not.
69
- */
70
- static async execCmd(cmd, logError = false, cwd, useProfile = false) {
71
- const execOptions = {};
72
- if (cwd) {
73
- execOptions.cwd = cwd;
74
- }
75
- let commandToExecute = cmd;
76
- // Set the powershell prefix if the current OS is Windows so that
77
- // the profile is not ran before the command.
78
- if (CurrentEnv_1.default.os === CurrentEnv_1.OperatingSystemType.Windows && !useProfile) {
79
- commandToExecute = `${CLIService.POWERSHELL_PREFIX}${cmd}`;
80
- }
81
- else if (CurrentEnv_1.default.os === CurrentEnv_1.OperatingSystemType.Windows && useProfile) {
82
- execOptions.shell = 'pwsh';
83
- }
84
- Logger_1.default.verbose.info(`Executing command: ${commandToExecute}`);
85
- try {
86
- const { stdout, stderr } = await execute(commandToExecute, execOptions);
87
- if (stderr) {
88
- if (logError) {
89
- Logger_1.default.error(`There was an error executing ${cmd}. Details are printed below:
90
- ${stderr}`);
91
- }
92
- return {
93
- didComplete: false,
94
- output: stderr
95
- };
96
- }
97
- Logger_1.default.verbose.info(`Output from stdout is: ${stdout}`);
98
- return {
99
- didComplete: true,
100
- output: stdout
101
- };
102
- }
103
- catch (err) {
104
- Logger_1.default.verbose
105
- .error(`There was an error executing the "exec" function. Details are printed below:
106
- ${err}`);
107
- return {
108
- didComplete: false,
109
- output: err
110
- };
111
- }
112
- }
113
- /**
114
- * Executes the given command but fulfills the
115
- * promise when either the command completes, or the given number of ms have
116
- * passed. Whichever comes first.
117
- *
118
- * @param command the command to execute
119
- * @param ms the number of milliseconds to wait. This is 5 seconds by default.
120
- */
121
- static async execCmdWithTimeout(command, ms = 5000) {
122
- const sleepPromise = (0, sleep_1.default)(ms).then(() => {
123
- return {
124
- didComplete: false,
125
- output: `Command ended after ${ms} ms.`
126
- };
127
- });
128
- return Promise.any([sleepPromise, CLIService.execCmd(command)]);
129
- }
130
- /**
131
- * Spawns a new process where the command is ran as a stream where all
132
- * output is streamed to the console.
133
- * This is helpful for long-running commands or commands
134
- * that output a lot of data. For example `yarn` or `npm install`.
135
- * All of the output from this is logged by default because of the listeners
136
- * involved. This could be changed in the future though.
137
- *
138
- * @param cmd the command to run. This is the the first argument passed to the
139
- * `spawn` function. For example this could be `npm`.
140
- * @param args the arguments to pass to the command. For example this could be
141
- * `['install', 'react']`.
142
- */
143
- static async spawnCmd(cmd, args, currentWorkingDirectory) {
144
- return new Promise((resolve) => {
145
- let output = '';
146
- const execOptions = {
147
- cwd: currentWorkingDirectory
148
- };
149
- const spawnedCmd = (0, child_process_1.spawn)(cmd, args, execOptions);
150
- spawnedCmd.on('error', (err) => {
151
- Logger_1.default.error(`There was an error executing the "spawn" function. Details are printed below:
152
- ${err}`);
153
- resolve({
154
- didComplete: false,
155
- output: err.toString()
156
- });
157
- });
158
- spawnedCmd.stdout.on('data', (data) => {
159
- output += data;
160
- Logger_1.default.info(data, true);
161
- });
162
- spawnedCmd.stderr.on('data', (data) => {
163
- output += data;
164
- Logger_1.default.info(data, true);
165
- });
166
- spawnedCmd.on('close', (exitCode) => {
167
- Logger_1.default.info(`Command "${cmd}" exited with code ${exitCode}`);
168
- resolve({
169
- didComplete: true,
170
- output
171
- });
172
- });
173
- });
174
- }
175
- /**
176
- * Gets input from the user on command line.
177
- *
178
- * @param promptToUser the prompt that should be provided to the user. Include
179
- * a newline at the end if you want there to be one.
180
- */
181
- static async getUserInput(promptToUser) {
182
- const readline = rl.createInterface({
183
- input: process.stdin,
184
- output: process.stdout
185
- });
186
- return new Promise((resolve) => {
187
- readline.question(promptToUser, (input) => {
188
- readline.close();
189
- resolve(input);
190
- });
191
- });
192
- }
193
- }
194
- exports.default = CLIService;
@@ -1,25 +0,0 @@
1
- import 'dotenv/config';
2
- export type ConfigEnv = 'local' | 'dev' | 'prod';
3
- /**
4
- * A class which can be used to load configuration into the local environment
5
- * from a pre-defined location.
6
- */
7
- export default class ConfigService {
8
- private static gitHub;
9
- static useConfig(env: string): Promise<void>;
10
- /**
11
- * Creates a new GitHub client using `CONFIG_GITHUB_TOKEN` from the
12
- * local environment or .env file.
13
- */
14
- private static getGitHubClient;
15
- /**
16
- * Inserts the provided configuration into the local environment.
17
- */
18
- private static insertPropertiesIntoEnv;
19
- /**
20
- * Strips JSON comments from the provided JSON string. Only `//` comments
21
- * are supported at the moment.
22
- */
23
- private static stripJsonComments;
24
- }
25
- //# sourceMappingURL=ConfigService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConfigService.d.ts","sourceRoot":"","sources":["../../../src/services/ConfigService/ConfigService.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,CAAC;AAGvB,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAEjD;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAwB;WAEhC,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBlD;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAY9B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAUtC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAG9B;CACH"}
@@ -1,72 +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 octokit_1 = require("octokit");
7
- require("dotenv/config");
8
- const Logger_1 = __importDefault(require("../../utils/Logger"));
9
- /**
10
- * A class which can be used to load configuration into the local environment
11
- * from a pre-defined location.
12
- */
13
- class ConfigService {
14
- static gitHub = null;
15
- static async useConfig(env) {
16
- if (!ConfigService.gitHub) {
17
- ConfigService.gitHub = ConfigService.getGitHubClient();
18
- }
19
- try {
20
- const result = await ConfigService.gitHub.rest.repos.getContent({
21
- mediaType: {
22
- format: 'raw'
23
- },
24
- owner: 'aneuhold',
25
- repo: 'config',
26
- path: `${env}.jsonc`
27
- });
28
- const strippedJson = ConfigService.stripJsonComments(result.data);
29
- const config = JSON.parse(strippedJson);
30
- ConfigService.insertPropertiesIntoEnv(config);
31
- }
32
- catch (error) {
33
- Logger_1.default.error(`Failed to load ${env}.json, error: ${error}`);
34
- throw error;
35
- }
36
- }
37
- /**
38
- * Creates a new GitHub client using `CONFIG_GITHUB_TOKEN` from the
39
- * local environment or .env file.
40
- */
41
- static getGitHubClient() {
42
- const authToken = process.env.CONFIG_GITHUB_TOKEN;
43
- if (!authToken) {
44
- throw new Error('No CONFIG_GITHUB_TOKEN key found in environment variables.');
45
- }
46
- return new octokit_1.Octokit({
47
- auth: authToken
48
- });
49
- }
50
- /**
51
- * Inserts the provided configuration into the local environment.
52
- */
53
- static insertPropertiesIntoEnv(config) {
54
- Object.entries(config).forEach(([key, value]) => {
55
- if (typeof value === 'object') {
56
- ConfigService.insertPropertiesIntoEnv(value);
57
- }
58
- else {
59
- process.env[key] = value;
60
- }
61
- });
62
- }
63
- /**
64
- * Strips JSON comments from the provided JSON string. Only `//` comments
65
- * are supported at the moment.
66
- */
67
- static stripJsonComments = (jsonString) => {
68
- const commentRegex = /\/\/(.*)/g;
69
- return jsonString.replace(commentRegex, '');
70
- };
71
- }
72
- exports.default = ConfigService;
@@ -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,28 +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 console_1 = require("console");
7
- const ConfigService_1 = __importDefault(require("./ConfigService"));
8
- const TestUtils_1 = __importDefault(require("../../utils/TestUtils"));
9
- describe('ConfigService', () => {
10
- describe('useConfig', () => {
11
- /**
12
- * Depends upon a GitHub token being available in the local environment.
13
- * This will be a local `.env` file with the CONFIG_GITHUB_TOKEN variable
14
- * set.
15
- */
16
- it('should load configuration from GitHub', async () => {
17
- const env = 'local';
18
- await ConfigService_1.default.useConfig(env);
19
- (0, console_1.assert)(process.env.SOME_KEY === 'SOME_VALUE');
20
- });
21
- it('should throw an error when loading configuration fails', async () => {
22
- const env = 'invalid_env';
23
- TestUtils_1.default.suppressConsole();
24
- await expect(ConfigService_1.default.useConfig(env)).rejects.toThrow();
25
- TestUtils_1.default.restoreConsole();
26
- });
27
- });
28
- });
@@ -1 +0,0 @@
1
- //# sourceMappingURL=DOAuthCheckPassword.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DOAuthCheckPassword.d.ts","sourceRoot":"","sources":["../../../src/services/DOFunctionService/DOAuthCheckPassword.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- //# sourceMappingURL=DOAuthCheckPassword.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DOAuthCheckPassword.d.ts","sourceRoot":"","sources":["../../../../src/services/DOFunctionService/functions/DOAuthCheckPassword.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=authCheckPassword.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authCheckPassword.d.ts","sourceRoot":"","sources":["../../../../src/services/DOFunctionService/functions/authCheckPassword.ts"],"names":[],"mappings":""}
@@ -1,32 +0,0 @@
1
- /**
2
- * Output from a Digital Ocean function must always be an object.
3
- */
4
- export type DOFunctionOutput<TOutput extends object> = {
5
- /**
6
- * The body is an object, which means it will automatically be serialized to
7
- * JSON and the Content-Type header will be set to application/json.
8
- */
9
- body: TOutput;
10
- };
11
- export declare const DOFunctionsInfo: {
12
- authCheckPassword: {
13
- url: string;
14
- method: string;
15
- };
16
- };
17
- declare abstract class DOFunction<TInput extends object, TOutput extends object> {
18
- abstract url: string;
19
- abstract method: 'GET' | 'POST';
20
- abstract call: (args: TInput) => Promise<DOFunctionOutput<TOutput>>;
21
- }
22
- interface DOFunction<TInput extends object, TOutput> implements DOFunctionOutput {
23
- }
24
- export type DOFunctions = keyof typeof DOFunctionsInfo;
25
- /**
26
- * A service to provide some utility realted to Digital Ocean functions.
27
- */
28
- export default class DOFunctionService {
29
- static call(functionName: DOFunction): any;
30
- }
31
- export {};
32
- //# sourceMappingURL=DOFunctionService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DOFunctionService.d.ts","sourceRoot":"","sources":["../../src/services/DOFunctionService.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,OAAO,SAAS,MAAM,IAAI;IACrD;;;OAGG;IACH,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;CAK3B,CAAA;AAED,uBAAe,UAAU,CAAC,MAAM,SAAS,MAAM,EAAE,OAAO,SAAS,MAAM;IACrE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;CACrE;AAYD,UAAU,UAAU,CAAC,MAAM,SAAS,MAAM,EAAE,OAAO,CAAC,YAAW,gBAAgB;CAAA;AAM/E,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,eAAe,CAAC;AAEvD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;WACvB,IAAI,CAAC,YAAY,EAAE,UAAU;CAC3C"}
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DOFunctionsInfo = void 0;
4
- exports.DOFunctionsInfo = {
5
- authCheckPassword: {
6
- url: 'https://faas-sfo3-7872a1dd.doserverless.co/api/v1/web/fn-66dd3ef6-c21d-46dc-b7ae-caf2ac8041ec/auth/checkPassword',
7
- method: 'POST'
8
- }
9
- };
10
- class DOFunction {
11
- }
12
- class DOAuthCheckPassword extends DOFunction {
13
- url = 'https://faas-sfo3-7872a1dd.doserverless.co/api/v1/web/fn-66dd3ef6-c21d-46dc-b7ae-caf2ac8041ec/auth/checkPassword';
14
- method = 'POST';
15
- call(args) {
16
- }
17
- }
18
- (args);
19
- then((response) => response.json());
20
- > {
21
- url: string,
22
- method: 'GET' | 'POST',
23
- call: (args) => Promise
24
- };
25
- /**
26
- * A service to provide some utility realted to Digital Ocean functions.
27
- */
28
- class DOFunctionService {
29
- }
30
- exports.default = DOFunctionService;
@@ -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"}