@aneuhold/core-ts-lib 1.0.7 → 1.0.9
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.
- package/lib/helperFunctions/dateFunctions.d.ts +9 -9
- package/lib/helperFunctions/dateFunctions.js +15 -15
- package/lib/helperFunctions/sleep.d.ts +6 -6
- package/lib/helperFunctions/sleep.js +12 -12
- package/lib/helperFunctions/stringFunctions.d.ts +8 -8
- package/lib/helperFunctions/stringFunctions.js +13 -13
- package/lib/index.d.ts +12 -11
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +54 -52
- package/lib/services/CLIService.d.ts +68 -65
- package/lib/services/CLIService.d.ts.map +1 -1
- package/lib/services/CLIService.js +194 -188
- package/lib/services/StringService.d.ts +13 -13
- package/lib/services/StringService.js +18 -18
- package/lib/services/applications/ChromeService.d.ts +19 -19
- package/lib/services/applications/ChromeService.js +60 -60
- package/lib/services/applications/DockerService.d.ts +20 -20
- package/lib/services/applications/DockerService.js +88 -88
- package/lib/services/applications/FileSystemService.d.ts +17 -17
- package/lib/services/applications/FileSystemService.js +87 -87
- package/lib/services/applications/ITermService.d.ts +8 -0
- package/lib/services/applications/ITermService.d.ts.map +1 -0
- package/lib/services/applications/ITermService.js +45 -0
- package/lib/services/applications/OsaScriptService.d.ts +4 -0
- package/lib/services/applications/OsaScriptService.d.ts.map +1 -0
- package/lib/services/applications/OsaScriptService.js +31 -0
- package/lib/utils/CurrentEnv.d.ts +62 -61
- package/lib/utils/CurrentEnv.d.ts.map +1 -1
- package/lib/utils/CurrentEnv.js +137 -133
- package/lib/utils/Logger.d.ts +67 -67
- package/lib/utils/Logger.js +112 -112
- package/lib/utils/OsaScriptBuilder.d.ts +45 -0
- package/lib/utils/OsaScriptBuilder.d.ts.map +1 -0
- package/lib/utils/OsaScriptBuilder.js +53 -0
- package/package.json +1 -1
- package/lib/helperFunctions/applications/applications.d.ts +0 -21
- package/lib/helperFunctions/applications/applications.d.ts.map +0 -1
- package/lib/helperFunctions/applications/applications.js +0 -26
- package/lib/helperFunctions/applications/chromeApplication.d.ts +0 -8
- package/lib/helperFunctions/applications/chromeApplication.d.ts.map +0 -1
- package/lib/helperFunctions/applications/chromeApplication.js +0 -63
- package/lib/helperFunctions/applications/fileSystemApplication.d.ts +0 -8
- package/lib/helperFunctions/applications/fileSystemApplication.d.ts.map +0 -1
- package/lib/helperFunctions/applications/fileSystemApplication.js +0 -51
- package/lib/helperFunctions/cmd.d.ts +0 -54
- package/lib/helperFunctions/cmd.d.ts.map +0 -1
- package/lib/helperFunctions/cmd.js +0 -177
- package/lib/helperFunctions/fileFunctions.d.ts +0 -10
- package/lib/helperFunctions/fileFunctions.d.ts.map +0 -1
- package/lib/helperFunctions/fileFunctions.js +0 -43
- package/lib/helperFunctions/input.d.ts +0 -8
- package/lib/helperFunctions/input.d.ts.map +0 -1
- package/lib/helperFunctions/input.js +0 -48
- package/lib/utils/Log.d.ts +0 -69
- package/lib/utils/Log.d.ts.map +0 -1
- package/lib/utils/Log.js +0 -112
|
@@ -1,21 +1,21 @@
|
|
|
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
|
-
}
|
|
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
21
|
//# sourceMappingURL=DockerService.d.ts.map
|
|
@@ -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,18 @@
|
|
|
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
|
+
}
|
|
18
18
|
//# sourceMappingURL=FileSystemService.d.ts.map
|
|
@@ -1,87 +1,87 @@
|
|
|
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
|
+
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;
|
|
@@ -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 @@
|
|
|
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;
|