@aneuhold/core-ts-lib 1.0.8 → 1.0.10

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/lib/helperFunctions/dateFunctions.d.ts +9 -9
  2. package/lib/helperFunctions/dateFunctions.js +15 -15
  3. package/lib/helperFunctions/sleep.d.ts +6 -6
  4. package/lib/helperFunctions/sleep.js +12 -12
  5. package/lib/helperFunctions/stringFunctions.d.ts +8 -8
  6. package/lib/helperFunctions/stringFunctions.js +13 -13
  7. package/lib/index.d.ts +12 -11
  8. package/lib/index.d.ts.map +1 -1
  9. package/lib/index.js +54 -52
  10. package/lib/services/CLIService.d.ts +68 -68
  11. package/lib/services/CLIService.js +194 -194
  12. package/lib/services/StringService.d.ts +13 -13
  13. package/lib/services/StringService.js +18 -18
  14. package/lib/services/applications/ChromeService.d.ts +19 -19
  15. package/lib/services/applications/ChromeService.js +60 -60
  16. package/lib/services/applications/DockerService.d.ts +20 -20
  17. package/lib/services/applications/DockerService.js +88 -88
  18. package/lib/services/applications/FileSystemService.d.ts +18 -17
  19. package/lib/services/applications/FileSystemService.d.ts.map +1 -1
  20. package/lib/services/applications/FileSystemService.js +97 -87
  21. package/lib/services/applications/ITermService.d.ts +8 -0
  22. package/lib/services/applications/ITermService.d.ts.map +1 -0
  23. package/lib/services/applications/ITermService.js +45 -0
  24. package/lib/services/applications/OsaScriptService.d.ts +4 -0
  25. package/lib/services/applications/OsaScriptService.d.ts.map +1 -0
  26. package/lib/services/applications/OsaScriptService.js +31 -0
  27. package/lib/utils/CurrentEnv.d.ts +62 -61
  28. package/lib/utils/CurrentEnv.d.ts.map +1 -1
  29. package/lib/utils/CurrentEnv.js +137 -133
  30. package/lib/utils/Logger.d.ts +67 -67
  31. package/lib/utils/Logger.js +112 -112
  32. package/lib/utils/OsaScriptBuilder.d.ts +45 -0
  33. package/lib/utils/OsaScriptBuilder.d.ts.map +1 -0
  34. package/lib/utils/OsaScriptBuilder.js +53 -0
  35. package/package.json +1 -1
  36. package/lib/helperFunctions/applications/applications.d.ts +0 -21
  37. package/lib/helperFunctions/applications/applications.d.ts.map +0 -1
  38. package/lib/helperFunctions/applications/applications.js +0 -26
  39. package/lib/helperFunctions/applications/chromeApplication.d.ts +0 -8
  40. package/lib/helperFunctions/applications/chromeApplication.d.ts.map +0 -1
  41. package/lib/helperFunctions/applications/chromeApplication.js +0 -63
  42. package/lib/helperFunctions/applications/fileSystemApplication.d.ts +0 -8
  43. package/lib/helperFunctions/applications/fileSystemApplication.d.ts.map +0 -1
  44. package/lib/helperFunctions/applications/fileSystemApplication.js +0 -51
  45. package/lib/helperFunctions/cmd.d.ts +0 -54
  46. package/lib/helperFunctions/cmd.d.ts.map +0 -1
  47. package/lib/helperFunctions/cmd.js +0 -177
  48. package/lib/helperFunctions/fileFunctions.d.ts +0 -10
  49. package/lib/helperFunctions/fileFunctions.d.ts.map +0 -1
  50. package/lib/helperFunctions/fileFunctions.js +0 -43
  51. package/lib/helperFunctions/input.d.ts +0 -8
  52. package/lib/helperFunctions/input.d.ts.map +0 -1
  53. package/lib/helperFunctions/input.js +0 -48
  54. package/lib/utils/Log.d.ts +0 -69
  55. package/lib/utils/Log.d.ts.map +0 -1
  56. package/lib/utils/Log.js +0 -112
@@ -1,88 +1,88 @@
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
+ "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,18 +1,19 @@
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
- }
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
+ }
18
19
  //# sourceMappingURL=FileSystemService.d.ts.map
@@ -1 +1 @@
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;IAQ5C;;;;;;;OAOG;WACU,iBAAiB,CAC5B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC;mBA8BK,qBAAqB;CAM3C"}
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,87 +1,97 @@
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
- Logger_1.default.error('Not implemented for this OS yet.');
45
- }
46
- /**
47
- * Tries to add the provided snippet of text to the path provided. If the file
48
- * doesn't exist, it creates it. If the folders to the file don't exist, it
49
- * creates those. If the text already exists in the file, it does nothing.
50
- *
51
- * @param folderPath the path to the folder which contains the file that should
52
- * be updated
53
- */
54
- static async findAndInsertText(folderPath, fileName, textToInsert) {
55
- const filePath = path_1.default.join(folderPath, fileName);
56
- try {
57
- await (0, promises_1.access)(folderPath);
58
- }
59
- catch (e) {
60
- console.log(e);
61
- Logger_1.default.info(`Directory "${folderPath}" does not exist. Creating it now...`);
62
- await (0, promises_1.mkdir)(folderPath, { recursive: true });
63
- }
64
- try {
65
- await (0, promises_1.access)(filePath);
66
- const fileContents = await (0, promises_1.readFile)(filePath);
67
- if (!fileContents.includes(textToInsert)) {
68
- await (0, promises_1.appendFile)(filePath, `\n${textToInsert}`);
69
- Logger_1.default.info(`Added "${textToInsert}" to "${filePath}"`);
70
- }
71
- else {
72
- Logger_1.default.info(`"${textToInsert}" already exists in "${filePath}"`);
73
- }
74
- }
75
- catch {
76
- Logger_1.default.info(`File at "${filePath}" didn't exist. Creating it now and adding "${textToInsert}" to it.`);
77
- await (0, promises_1.writeFile)(filePath, textToInsert);
78
- }
79
- }
80
- static async openWindowsNugetCache() {
81
- await Promise.all([
82
- CLIService_1.default.execCmd(`ii $HOME/localNuget`),
83
- CLIService_1.default.execCmd(`ii $HOME/.nuget/packages`)
84
- ]);
85
- }
86
- }
87
- exports.default = FileSystemService;
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;
@@ -0,0 +1,8 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,45 @@
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 Logger_1 = __importDefault(require("../../utils/Logger"));
7
+ const OsaScriptBuilder_1 = __importDefault(require("../../utils/OsaScriptBuilder"));
8
+ const CLIService_1 = __importDefault(require("../CLIService"));
9
+ class ITermService {
10
+ /**
11
+ * Splits the iTerm terminal horzontally and runs each command in a separate
12
+ * pane.
13
+ */
14
+ static async splitHorizontallyAndRunCommands(commands, cwd = '') {
15
+ const terminalWindowTellBlock = {
16
+ tellCommand: `W's current session`,
17
+ sections: []
18
+ };
19
+ // Do the number of splits needed
20
+ commands.forEach(() => {
21
+ terminalWindowTellBlock.sections.push(`split horizontally with default profile`);
22
+ });
23
+ const iTermApplicationTellBlock = {
24
+ tellCommand: 'application "iTerm"',
25
+ sections: [
26
+ 'activate',
27
+ 'set W to current window',
28
+ 'if W = missing value then set W to create window with default profile',
29
+ terminalWindowTellBlock,
30
+ `set T to W's current tab`
31
+ ]
32
+ };
33
+ // Add in the commands, adding 2 to the session number because the first
34
+ // session is 1, and the second is 2.
35
+ commands.forEach((command, i) => {
36
+ iTermApplicationTellBlock.sections.push(`write T's session ${i + 2} text "cd ${cwd} && ${command}"`);
37
+ });
38
+ const osaScriptBuilder = new OsaScriptBuilder_1.default();
39
+ osaScriptBuilder.addTellBlock(iTermApplicationTellBlock);
40
+ const osaScript = osaScriptBuilder.getFullCommand();
41
+ Logger_1.default.verbose.info(`OsaScript: ${osaScript}`);
42
+ await CLIService_1.default.execCmd(osaScript);
43
+ }
44
+ }
45
+ exports.default = ITermService;
@@ -0,0 +1,4 @@
1
+ export default class OsaScriptService {
2
+ static runOsaScript(): Promise<void>;
3
+ }
4
+ //# sourceMappingURL=OsaScriptService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OsaScriptService.d.ts","sourceRoot":"","sources":["../../../src/services/applications/OsaScriptService.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,OAAO,OAAO,gBAAgB;WACtB,YAAY;CAqB1B"}
@@ -0,0 +1,31 @@
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 Logger_1 = __importDefault(require("../../utils/Logger"));
7
+ const OsaScriptBuilder_1 = __importDefault(require("../../utils/OsaScriptBuilder"));
8
+ const CLIService_1 = __importDefault(require("../CLIService"));
9
+ class OsaScriptService {
10
+ static async runOsaScript() {
11
+ Logger_1.default.info('Running OSA Script...');
12
+ const osaScriptBuilder = new OsaScriptBuilder_1.default();
13
+ osaScriptBuilder.addTellBlock({
14
+ tellCommand: 'application "iTerm"',
15
+ sections: [
16
+ 'activate',
17
+ 'set W to current window',
18
+ 'if W = missing value then set W to create window with default profile',
19
+ {
20
+ tellCommand: `W's current session`,
21
+ sections: [`write text "cddev"`]
22
+ }
23
+ ]
24
+ });
25
+ const osaScript = osaScriptBuilder.getFullCommand();
26
+ Logger_1.default.verbose.info(`OsaScript: ${osaScript}`);
27
+ await CLIService_1.default.execCmd(osaScript);
28
+ Logger_1.default.info('OsaScript completed.');
29
+ }
30
+ }
31
+ exports.default = OsaScriptService;
@@ -1,62 +1,63 @@
1
- /**
2
- * The type of shell that the current environment is running.
3
- */
4
- export declare enum ShellType {
5
- PowerShellCore = 0,
6
- PowerShellDesktop = 1,
7
- Bash = 2,
8
- Zsh = 3,
9
- CommandPrompt = 4,
10
- Unknown = 5
11
- }
12
- export declare enum OperatingSystemType {
13
- Windows = 0,
14
- MacOSX = 1,
15
- Linux = 2,
16
- Unknown = 3
17
- }
18
- /**
19
- * The type of terminal that the current enviornment is running.
20
- */
21
- export declare enum TerminalType {
22
- WindowsTerminal = 0,
23
- Unknown = 1
24
- }
25
- /**
26
- * Provides information relevant to the current environment this script is
27
- * running in.
28
- */
29
- export default class CurrentEnv {
30
- /**
31
- * Returns the type of terminal the current environment is using.
32
- */
33
- static terminal(): TerminalType;
34
- /**
35
- * Returns the type of shell the current environment is using.
36
- *
37
- * This might be arbitrary because it seems that the exec command will use
38
- * whatever the default shell is or whatever is specified as the shell
39
- * option.
40
- */
41
- static shell(): Promise<ShellType>;
42
- /**
43
- * Gets all file names in the current directory.
44
- */
45
- static fileNamesInDir(): Promise<string[]>;
46
- /**
47
- * Runs the startup script for the current system. This command exits the
48
- * package.
49
- *
50
- * The startup scripts are defined in the
51
- * [dotfiles repo](https://github.com/aneuhold/dotfiles).
52
- */
53
- static runStartupScript(): Promise<void>;
54
- /**
55
- * Determines the type of operating system in the current environment.
56
- *
57
- * This looks to be O(1) complexity.
58
- */
59
- static get os(): OperatingSystemType;
60
- static folderName(): string;
61
- }
1
+ /**
2
+ * The type of shell that the current environment is running.
3
+ */
4
+ export declare enum ShellType {
5
+ PowerShellCore = 0,
6
+ PowerShellDesktop = 1,
7
+ Bash = 2,
8
+ Zsh = 3,
9
+ CommandPrompt = 4,
10
+ Unknown = 5
11
+ }
12
+ export declare enum OperatingSystemType {
13
+ Windows = 0,
14
+ MacOSX = 1,
15
+ Linux = 2,
16
+ Unknown = 3
17
+ }
18
+ /**
19
+ * The type of terminal that the current enviornment is running.
20
+ */
21
+ export declare enum TerminalType {
22
+ WindowsTerminal = 0,
23
+ ITerm2 = 1,
24
+ Unknown = 2
25
+ }
26
+ /**
27
+ * Provides information relevant to the current environment this script is
28
+ * running in.
29
+ */
30
+ export default class CurrentEnv {
31
+ /**
32
+ * Returns the type of terminal the current environment is using.
33
+ */
34
+ static terminal(): TerminalType;
35
+ /**
36
+ * Returns the type of shell the current environment is using.
37
+ *
38
+ * This might be arbitrary because it seems that the exec command will use
39
+ * whatever the default shell is or whatever is specified as the shell
40
+ * option.
41
+ */
42
+ static shell(): Promise<ShellType>;
43
+ /**
44
+ * Gets all file names in the current directory.
45
+ */
46
+ static fileNamesInDir(): Promise<string[]>;
47
+ /**
48
+ * Runs the startup script for the current system. This command exits the
49
+ * package.
50
+ *
51
+ * The startup scripts are defined in the
52
+ * [dotfiles repo](https://github.com/aneuhold/dotfiles).
53
+ */
54
+ static runStartupScript(): Promise<void>;
55
+ /**
56
+ * Determines the type of operating system in the current environment.
57
+ *
58
+ * This looks to be O(1) complexity.
59
+ */
60
+ static get os(): OperatingSystemType;
61
+ static folderName(): string;
62
+ }
62
63
  //# sourceMappingURL=CurrentEnv.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CurrentEnv.d.ts","sourceRoot":"","sources":["../../src/utils/CurrentEnv.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,oBAAY,SAAS;IACnB,cAAc,IAAA;IACd,iBAAiB,IAAA;IACjB,IAAI,IAAA;IACJ,GAAG,IAAA;IACH,aAAa,IAAA;IACb,OAAO,IAAA;CACR;AAED,oBAAY,mBAAmB;IAC7B,OAAO,IAAA;IACP,MAAM,IAAA;IACN,KAAK,IAAA;IACL,OAAO,IAAA;CACR;AAED;;GAEG;AACH,oBAAY,YAAY;IACtB,eAAe,IAAA;IACf,OAAO,IAAA;CACR;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B;;OAEG;WACW,QAAQ,IAAI,YAAY;IAStC;;;;;;OAMG;WACiB,KAAK,IAAI,OAAO,CAAC,SAAS,CAAC;IAyB/C;;OAEG;WACiB,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIvD;;;;;;OAMG;WACiB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBrD;;;;OAIG;IACH,WAAkB,EAAE,IAAI,mBAAmB,CAQ1C;WAEa,UAAU,IAAI,MAAM;CAGnC"}
1
+ {"version":3,"file":"CurrentEnv.d.ts","sourceRoot":"","sources":["../../src/utils/CurrentEnv.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,oBAAY,SAAS;IACnB,cAAc,IAAA;IACd,iBAAiB,IAAA;IACjB,IAAI,IAAA;IACJ,GAAG,IAAA;IACH,aAAa,IAAA;IACb,OAAO,IAAA;CACR;AAED,oBAAY,mBAAmB;IAC7B,OAAO,IAAA;IACP,MAAM,IAAA;IACN,KAAK,IAAA;IACL,OAAO,IAAA;CACR;AAED;;GAEG;AACH,oBAAY,YAAY;IACtB,eAAe,IAAA;IACf,MAAM,IAAA;IACN,OAAO,IAAA;CACR;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B;;OAEG;WACW,QAAQ,IAAI,YAAY;IAYtC;;;;;;OAMG;WACiB,KAAK,IAAI,OAAO,CAAC,SAAS,CAAC;IAyB/C;;OAEG;WACiB,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIvD;;;;;;OAMG;WACiB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBrD;;;;OAIG;IACH,WAAkB,EAAE,IAAI,mBAAmB,CAQ1C;WAEa,UAAU,IAAI,MAAM;CAGnC"}