@aneuhold/core-ts-lib 1.1.3 → 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 +3 -1
  2. package/lib/index.d.ts.map +1 -1
  3. package/lib/index.js +5 -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
@@ -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
@@ -1 +0,0 @@
1
- {"version":3,"file":"DockerService.d.ts","sourceRoot":"","sources":["../../../src/services/applications/DockerService.ts"],"names":[],"mappings":"AAEA,OAAmB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAIzE;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC;;;OAGG;WACU,kBAAkB;WAgBlB,6BAA6B,IAAI,OAAO,CAAC,OAAO,CAAC;IAe9D;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,mBAAmB,GAAG,MAAM,GAAG,IAAI;CAS7D"}
@@ -1,88 +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
- /* eslint-disable no-await-in-loop */
30
- const sleep_1 = __importDefault(require("../../helperFunctions/sleep"));
31
- const CurrentEnv_1 = __importStar(require("../../utils/CurrentEnv"));
32
- const Logger_1 = __importDefault(require("../../utils/Logger"));
33
- const CLIService_1 = __importDefault(require("../CLIService"));
34
- /**
35
- * A service that provides functionality for interacting with the Docker
36
- * application.
37
- */
38
- class DockerService {
39
- /**
40
- * Starts the Docker Desktop application. If it is already running, it doesn't
41
- * do anything.
42
- */
43
- static async startDockerDesktop() {
44
- const currentOS = CurrentEnv_1.default.os;
45
- const dockerPath = DockerService.getDockerPath(currentOS);
46
- let dockerRunning = await DockerService.checkIfDockerDesktopIsRunning();
47
- if (!dockerRunning && dockerPath) {
48
- Logger_1.default.info('Docker desktop is not running. Starting it now...');
49
- await CLIService_1.default.execCmdWithTimeout(dockerPath, 4000);
50
- while (!dockerRunning) {
51
- Logger_1.default.info('Waiting for Docker to start...');
52
- await (0, sleep_1.default)(2000);
53
- dockerRunning = await DockerService.checkIfDockerDesktopIsRunning();
54
- }
55
- }
56
- Logger_1.default.info('Docker desktop is running.');
57
- }
58
- static async checkIfDockerDesktopIsRunning() {
59
- const currentOS = CurrentEnv_1.default.os;
60
- if (currentOS === CurrentEnv_1.OperatingSystemType.Windows) {
61
- const { didComplete } = await CLIService_1.default.execCmd('Get-Process docker');
62
- if (didComplete) {
63
- Logger_1.default.verbose.info('Docker is running.');
64
- return true;
65
- }
66
- Logger_1.default.verbose.info('Docker is not running.');
67
- return false;
68
- }
69
- Logger_1.default.error('Docker command not defined for this OS yet.');
70
- return false;
71
- }
72
- /**
73
- * Gets the path to the docker application for the current system given the
74
- * operating system type.
75
- *
76
- * This does include the quotes
77
- */
78
- static getDockerPath(os) {
79
- switch (os) {
80
- case CurrentEnv_1.OperatingSystemType.Windows:
81
- return `& "C:\\Program Files\\Docker\\Docker\\Docker Desktop.exe"`;
82
- default:
83
- Logger_1.default.error('Docker path not defined for this OS yet.');
84
- return null;
85
- }
86
- }
87
- }
88
- exports.default = DockerService;
@@ -1,45 +0,0 @@
1
- /**
2
- * A service which can be used to interact with the file system application on
3
- * the current system.
4
- */
5
- export default class FileSystemService {
6
- static openNugetCache(): Promise<void>;
7
- /**
8
- * Tries to add the provided snippet of text to the path provided. If the file
9
- * doesn't exist, it creates it. If the folders to the file don't exist, it
10
- * creates those. If the text already exists in the file, it does nothing.
11
- *
12
- * @param folderPath the path to the folder which contains the file that should
13
- * be updated
14
- */
15
- static findAndInsertText(folderPath: string, fileName: string, textToInsert: string): Promise<void>;
16
- /**
17
- * Copies the contents of one folder to another folder.
18
- *
19
- * @param ignoreExtensions is an array with extensions that should be
20
- * ignored. For example, if you want to ignore all .ts files, you would pass
21
- * in ['ts'].
22
- */
23
- static copyFolderContents(sourceFolderPath: string, targetFolderPath: string, ignoreExtensions?: string[]): Promise<void>;
24
- static checkOrCreateFolder(folderPath: string): Promise<void>;
25
- static deleteFolder(folderPath: string): Promise<void>;
26
- /**
27
- * Gets all the file paths in the directory provided, including all
28
- * subdirectories, as an array of strings. The returned result will include
29
- * the directory path provided.
30
- *
31
- * If only relative file paths are needed, use {@link getAllFilePathsRelative}.
32
- */
33
- static getAllFilePaths(dirPath: string): Promise<string[]>;
34
- /**
35
- * Gets all the file paths in the directory provided, including all
36
- * subdirectories, as an array of strings. The returned result will not
37
- * include the directory path provided.
38
- *
39
- * If absolute file paths are needed, use {@link getAllFilePaths}.
40
- */
41
- static getAllFilePathsRelative(dirPath: string): Promise<string[]>;
42
- private static openWindowsNugetCache;
43
- private static openMacNugetCache;
44
- }
45
- //# sourceMappingURL=FileSystemService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileSystemService.d.ts","sourceRoot":"","sources":["../../../../src/services/applications/FileSystemService/FileSystemService.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;WACvB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAY5C;;;;;;;OAOG;WACU,iBAAiB,CAC5B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC;IAsBhB;;;;;;OAMG;WACU,kBAAkB,CAC7B,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAC1B,OAAO,CAAC,IAAI,CAAC;WAoCH,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAWtD,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU5D;;;;;;OAMG;WACU,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAoBhE;;;;;;OAMG;WACU,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;mBAOnD,qBAAqB;mBAOrB,iBAAiB;CAMvC"}
@@ -1,176 +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 promises_1 = require("fs/promises");
30
- const path_1 = __importDefault(require("path"));
31
- const CurrentEnv_1 = __importStar(require("../../../utils/CurrentEnv"));
32
- const Logger_1 = __importDefault(require("../../../utils/Logger"));
33
- const CLIService_1 = __importDefault(require("../../CLIService"));
34
- const StringService_1 = __importDefault(require("../../StringService"));
35
- /**
36
- * A service which can be used to interact with the file system application on
37
- * the current system.
38
- */
39
- class FileSystemService {
40
- static async openNugetCache() {
41
- if (CurrentEnv_1.default.os === CurrentEnv_1.OperatingSystemType.Windows) {
42
- await FileSystemService.openWindowsNugetCache();
43
- return;
44
- }
45
- if (CurrentEnv_1.default.os === CurrentEnv_1.OperatingSystemType.MacOSX) {
46
- await FileSystemService.openMacNugetCache();
47
- return;
48
- }
49
- Logger_1.default.error('Not implemented for this OS yet.');
50
- }
51
- /**
52
- * Tries to add the provided snippet of text to the path provided. If the file
53
- * doesn't exist, it creates it. If the folders to the file don't exist, it
54
- * creates those. If the text already exists in the file, it does nothing.
55
- *
56
- * @param folderPath the path to the folder which contains the file that should
57
- * be updated
58
- */
59
- static async findAndInsertText(folderPath, fileName, textToInsert) {
60
- const filePath = path_1.default.join(folderPath, fileName);
61
- await FileSystemService.checkOrCreateFolder(folderPath);
62
- try {
63
- await (0, promises_1.access)(filePath);
64
- const fileContents = await (0, promises_1.readFile)(filePath);
65
- if (!fileContents.includes(textToInsert)) {
66
- await (0, promises_1.appendFile)(filePath, `\n${textToInsert}`);
67
- Logger_1.default.info(`Added "${textToInsert}" to "${filePath}"`);
68
- }
69
- else {
70
- Logger_1.default.info(`"${textToInsert}" already exists in "${filePath}"`);
71
- }
72
- }
73
- catch {
74
- Logger_1.default.info(`File at "${filePath}" didn't exist. Creating it now and adding "${textToInsert}" to it.`);
75
- await (0, promises_1.writeFile)(filePath, textToInsert);
76
- }
77
- }
78
- /**
79
- * Copies the contents of one folder to another folder.
80
- *
81
- * @param ignoreExtensions is an array with extensions that should be
82
- * ignored. For example, if you want to ignore all .ts files, you would pass
83
- * in ['ts'].
84
- */
85
- static async copyFolderContents(sourceFolderPath, targetFolderPath, ignoreExtensions) {
86
- // Check if the source directory exists first
87
- try {
88
- await (0, promises_1.access)(sourceFolderPath);
89
- }
90
- catch {
91
- Logger_1.default.error(`Source directory "${sourceFolderPath}" does not exist.`);
92
- return;
93
- }
94
- await FileSystemService.checkOrCreateFolder(targetFolderPath);
95
- // Get the files in the source directory
96
- const sourceFilePaths = await FileSystemService.getAllFilePathsRelative(sourceFolderPath);
97
- // console.log(sourceFilePaths);
98
- await Promise.all(sourceFilePaths.map(async (sourceFilePath) => {
99
- const sourceFile = path_1.default.join(sourceFolderPath, sourceFilePath);
100
- const targetFile = path_1.default.join(targetFolderPath, sourceFilePath);
101
- const sourceFileExtension = StringService_1.default.getFileNameExtension(sourceFile);
102
- if (sourceFileExtension &&
103
- ignoreExtensions?.includes(sourceFileExtension)) {
104
- return;
105
- }
106
- await (0, promises_1.cp)(sourceFile, targetFile, { recursive: true });
107
- }));
108
- }
109
- static async checkOrCreateFolder(folderPath) {
110
- try {
111
- await (0, promises_1.access)(folderPath);
112
- }
113
- catch {
114
- Logger_1.default.verbose.info(`Directory "${folderPath}" does not exist. Creating it now...`);
115
- await (0, promises_1.mkdir)(folderPath, { recursive: true });
116
- }
117
- }
118
- static async deleteFolder(folderPath) {
119
- try {
120
- await (0, promises_1.access)(folderPath);
121
- }
122
- catch {
123
- Logger_1.default.error(`Directory "${folderPath}" does not exist.`);
124
- return;
125
- }
126
- await (0, promises_1.rm)(folderPath, { recursive: true });
127
- }
128
- /**
129
- * Gets all the file paths in the directory provided, including all
130
- * subdirectories, as an array of strings. The returned result will include
131
- * the directory path provided.
132
- *
133
- * If only relative file paths are needed, use {@link getAllFilePathsRelative}.
134
- */
135
- static async getAllFilePaths(dirPath) {
136
- const filePaths = [];
137
- const fileOrFolderNames = await (0, promises_1.readdir)(dirPath);
138
- await Promise.all(fileOrFolderNames.map(async (fileOrFolder) => {
139
- const absolutePath = path_1.default.join(dirPath, fileOrFolder);
140
- const fileStat = await (0, promises_1.stat)(absolutePath);
141
- if (fileStat.isDirectory()) {
142
- filePaths.push(...(await this.getAllFilePaths(absolutePath)));
143
- }
144
- else {
145
- filePaths.push(absolutePath);
146
- }
147
- }));
148
- return filePaths;
149
- }
150
- /**
151
- * Gets all the file paths in the directory provided, including all
152
- * subdirectories, as an array of strings. The returned result will not
153
- * include the directory path provided.
154
- *
155
- * If absolute file paths are needed, use {@link getAllFilePaths}.
156
- */
157
- static async getAllFilePathsRelative(dirPath) {
158
- const filePaths = await this.getAllFilePaths(dirPath);
159
- return filePaths.map((filePath) => {
160
- return filePath.replace(dirPath, '');
161
- });
162
- }
163
- static async openWindowsNugetCache() {
164
- await Promise.all([
165
- CLIService_1.default.execCmd(`ii $HOME/localNuget`),
166
- CLIService_1.default.execCmd(`ii $HOME/.nuget/packages`)
167
- ]);
168
- }
169
- static async openMacNugetCache() {
170
- await Promise.all([
171
- CLIService_1.default.execCmd(`open $HOME/localNuget`),
172
- CLIService_1.default.execCmd(`open $HOME/.nuget/packages`)
173
- ]);
174
- }
175
- }
176
- exports.default = FileSystemService;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=FileSystemService.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileSystemService.spec.d.ts","sourceRoot":"","sources":["../../../../src/services/applications/FileSystemService/FileSystemService.spec.ts"],"names":[],"mappings":""}
@@ -1,85 +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 path_1 = __importDefault(require("path"));
7
- const promises_1 = require("fs/promises");
8
- const FileSystemService_1 = __importDefault(require("./FileSystemService"));
9
- const TEST_FOLDER_NAME = '__fileSystemService-tests__';
10
- describe('FileSystemService', () => {
11
- afterAll(async () => {
12
- await deleteTestFolder();
13
- });
14
- describe('copyFolderContents', () => {
15
- it('should successfully copy all contents when target folder doesnt exist', async () => {
16
- // Make a test folder with a folder and a couple files in it
17
- const testName = 'copyFolderContents-1';
18
- const sourceFolderName = `${testName}-source`;
19
- const sourceFolderPath = await createTestFolder(sourceFolderName);
20
- await createTestFiles(sourceFolderPath, {
21
- 'file1.txt': 'test text',
22
- 'file2.txt': 'test text',
23
- subFolder: {
24
- 'subFile1.txt': 'sub test text',
25
- 'subFile2.txt': 'sub test text'
26
- }
27
- });
28
- const targetFolderPath = path_1.default.join(TEST_FOLDER_NAME, `${testName}-target`);
29
- // Execute
30
- await FileSystemService_1.default.copyFolderContents(sourceFolderPath, targetFolderPath);
31
- // Assert
32
- const expectedContents = await FileSystemService_1.default.getAllFilePathsRelative(sourceFolderPath);
33
- const actualContents = await FileSystemService_1.default.getAllFilePathsRelative(targetFolderPath);
34
- expect(actualContents).toEqual(expectedContents);
35
- });
36
- it('should successfully copy only files that arent ignored', async () => {
37
- // Make a test folder with a folder and a couple files in it
38
- const testName = 'copyFolderContents-2';
39
- const sourceFolderName = `${testName}-source`;
40
- const sourceFolderPath = await createTestFolder(sourceFolderName);
41
- await createTestFiles(sourceFolderPath, {
42
- 'file1.txt': 'test text',
43
- 'file2.txt': 'test text',
44
- subFolder: {
45
- 'subFile1.txt': 'sub test text',
46
- 'subFile2.txt': 'sub test text'
47
- },
48
- javascript: {
49
- 'file1.js': 'test text',
50
- 'file2.js': 'test text'
51
- },
52
- typescript: {
53
- 'file1.ts': 'test text',
54
- 'file2.ts': 'test text'
55
- }
56
- });
57
- const targetFolderPath = path_1.default.join(TEST_FOLDER_NAME, `${testName}-target`);
58
- // Execute
59
- await FileSystemService_1.default.copyFolderContents(sourceFolderPath, targetFolderPath, ['ts']);
60
- // Assert
61
- const expectedContents = (await FileSystemService_1.default.getAllFilePathsRelative(sourceFolderPath)).filter((sourceFilePath) => !sourceFilePath.endsWith('.ts'));
62
- const actualContents = await FileSystemService_1.default.getAllFilePathsRelative(targetFolderPath);
63
- expect(actualContents).toEqual(expectedContents);
64
- });
65
- });
66
- });
67
- async function createTestFiles(folderPath, fileStructure) {
68
- await FileSystemService_1.default.checkOrCreateFolder(folderPath);
69
- await Promise.all(Object.entries(fileStructure).map(async ([key, value]) => {
70
- if (typeof value === 'string') {
71
- await (0, promises_1.writeFile)(path_1.default.join(folderPath, key), value);
72
- }
73
- else if (typeof value === 'object') {
74
- await createTestFiles(path_1.default.join(folderPath, key), value);
75
- }
76
- }));
77
- }
78
- async function createTestFolder(folderName) {
79
- const testFolderPath = path_1.default.join(TEST_FOLDER_NAME, folderName);
80
- await FileSystemService_1.default.checkOrCreateFolder(testFolderPath);
81
- return testFolderPath;
82
- }
83
- async function deleteTestFolder() {
84
- await FileSystemService_1.default.deleteFolder(TEST_FOLDER_NAME);
85
- }
@@ -1,19 +0,0 @@
1
- /**
2
- * A service which can be used to interact with the file system on the current
3
- * system.
4
- */
5
- export default class FileSystemService {
6
- static openNugetCache(): Promise<void>;
7
- /**
8
- * Tries to add the provided snippet of text to the path provided. If the file
9
- * doesn't exist, it creates it. If the folders to the file don't exist, it
10
- * creates those. If the text already exists in the file, it does nothing.
11
- *
12
- * @param folderPath the path to the folder which contains the file that should
13
- * be updated
14
- */
15
- static findAndInsertText(folderPath: string, fileName: string, textToInsert: string): Promise<void>;
16
- private static openWindowsNugetCache;
17
- private static openMacNugetCache;
18
- }
19
- //# sourceMappingURL=FileSystemService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileSystemService.d.ts","sourceRoot":"","sources":["../../../src/services/applications/FileSystemService.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;WACvB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAY5C;;;;;;;OAOG;WACU,iBAAiB,CAC5B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC;mBA8BK,qBAAqB;mBAOrB,iBAAiB;CAMvC"}
@@ -1,97 +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 promises_1 = require("fs/promises");
30
- const path_1 = __importDefault(require("path"));
31
- const CurrentEnv_1 = __importStar(require("../../utils/CurrentEnv"));
32
- const Logger_1 = __importDefault(require("../../utils/Logger"));
33
- const CLIService_1 = __importDefault(require("../CLIService"));
34
- /**
35
- * A service which can be used to interact with the file system on the current
36
- * system.
37
- */
38
- class FileSystemService {
39
- static async openNugetCache() {
40
- if (CurrentEnv_1.default.os === CurrentEnv_1.OperatingSystemType.Windows) {
41
- await FileSystemService.openWindowsNugetCache();
42
- return;
43
- }
44
- if (CurrentEnv_1.default.os === CurrentEnv_1.OperatingSystemType.MacOSX) {
45
- await FileSystemService.openMacNugetCache();
46
- return;
47
- }
48
- Logger_1.default.error('Not implemented for this OS yet.');
49
- }
50
- /**
51
- * Tries to add the provided snippet of text to the path provided. If the file
52
- * doesn't exist, it creates it. If the folders to the file don't exist, it
53
- * creates those. If the text already exists in the file, it does nothing.
54
- *
55
- * @param folderPath the path to the folder which contains the file that should
56
- * be updated
57
- */
58
- static async findAndInsertText(folderPath, fileName, textToInsert) {
59
- const filePath = path_1.default.join(folderPath, fileName);
60
- try {
61
- await (0, promises_1.access)(folderPath);
62
- }
63
- catch (e) {
64
- console.log(e);
65
- Logger_1.default.info(`Directory "${folderPath}" does not exist. Creating it now...`);
66
- await (0, promises_1.mkdir)(folderPath, { recursive: true });
67
- }
68
- try {
69
- await (0, promises_1.access)(filePath);
70
- const fileContents = await (0, promises_1.readFile)(filePath);
71
- if (!fileContents.includes(textToInsert)) {
72
- await (0, promises_1.appendFile)(filePath, `\n${textToInsert}`);
73
- Logger_1.default.info(`Added "${textToInsert}" to "${filePath}"`);
74
- }
75
- else {
76
- Logger_1.default.info(`"${textToInsert}" already exists in "${filePath}"`);
77
- }
78
- }
79
- catch {
80
- Logger_1.default.info(`File at "${filePath}" didn't exist. Creating it now and adding "${textToInsert}" to it.`);
81
- await (0, promises_1.writeFile)(filePath, textToInsert);
82
- }
83
- }
84
- static async openWindowsNugetCache() {
85
- await Promise.all([
86
- CLIService_1.default.execCmd(`ii $HOME/localNuget`),
87
- CLIService_1.default.execCmd(`ii $HOME/.nuget/packages`)
88
- ]);
89
- }
90
- static async openMacNugetCache() {
91
- await Promise.all([
92
- CLIService_1.default.execCmd(`open $HOME/localNuget`),
93
- CLIService_1.default.execCmd(`open $HOME/.nuget/packages`)
94
- ]);
95
- }
96
- }
97
- exports.default = FileSystemService;
@@ -1,8 +0,0 @@
1
- export default class ITermService {
2
- /**
3
- * Splits the iTerm terminal horzontally and runs each command in a separate
4
- * pane.
5
- */
6
- static splitHorizontallyAndRunCommands(commands: string[], cwd?: string): Promise<void>;
7
- }
8
- //# sourceMappingURL=ITermService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ITermService.d.ts","sourceRoot":"","sources":["../../../src/services/applications/ITermService.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B;;;OAGG;WACU,+BAA+B,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,GAAG,SAAK;CAmC1E"}