@aneuhold/core-ts-lib 1.0.14 → 1.0.15
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/index.d.ts
CHANGED
|
@@ -6,9 +6,10 @@ import FileSystemService from './services/applications/FileSystemService/FileSys
|
|
|
6
6
|
import ITermService from './services/applications/ITermService';
|
|
7
7
|
import CLIService from './services/CLIService';
|
|
8
8
|
import ConfigService from './services/ConfigService/ConfigService';
|
|
9
|
+
import DependencyService from './services/DependencyService';
|
|
9
10
|
import DOFunctionService from './services/DOFunctionService';
|
|
10
11
|
import StringService from './services/StringService';
|
|
11
12
|
import CurrentEnv, { OperatingSystemType, ShellType, TerminalType } from './utils/CurrentEnv';
|
|
12
13
|
import Logger from './utils/Logger';
|
|
13
|
-
export { CLIService, StringService, CurrentEnv, ChromeService, DockerService, FileSystemService, sleep, OperatingSystemType, ShellType, Logger, TerminalType, datesAreOnSameDay, ITermService, ConfigService, DOFunctionService };
|
|
14
|
+
export { CLIService, StringService, CurrentEnv, ChromeService, DockerService, FileSystemService, sleep, OperatingSystemType, ShellType, Logger, TerminalType, datesAreOnSameDay, ITermService, ConfigService, DOFunctionService, DependencyService };
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -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,aAAa,MAAM,uCAAuC,CAAC;AAClE,OAAO,aAAa,MAAM,uCAAuC,CAAC;AAClE,OAAO,iBAAiB,MAAM,6DAA6D,CAAC;AAC5F,OAAO,YAAY,MAAM,sCAAsC,CAAC;AAChE,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,OAAO,aAAa,MAAM,wCAAwC,CAAC;AACnE,OAA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EACjB,iBAAiB,EAClB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.DOFunctionService = exports.ConfigService = exports.ITermService = exports.datesAreOnSameDay = exports.TerminalType = exports.Logger = exports.ShellType = exports.OperatingSystemType = exports.sleep = exports.FileSystemService = exports.DockerService = exports.ChromeService = exports.CurrentEnv = exports.StringService = exports.CLIService = void 0;
|
|
29
|
+
exports.DependencyService = exports.DOFunctionService = exports.ConfigService = exports.ITermService = exports.datesAreOnSameDay = exports.TerminalType = exports.Logger = exports.ShellType = exports.OperatingSystemType = exports.sleep = exports.FileSystemService = exports.DockerService = exports.ChromeService = exports.CurrentEnv = exports.StringService = exports.CLIService = void 0;
|
|
30
30
|
const dateFunctions_1 = __importDefault(require("./helperFunctions/dateFunctions"));
|
|
31
31
|
exports.datesAreOnSameDay = dateFunctions_1.default;
|
|
32
32
|
const sleep_1 = __importDefault(require("./helperFunctions/sleep"));
|
|
@@ -43,6 +43,8 @@ const CLIService_1 = __importDefault(require("./services/CLIService"));
|
|
|
43
43
|
exports.CLIService = CLIService_1.default;
|
|
44
44
|
const ConfigService_1 = __importDefault(require("./services/ConfigService/ConfigService"));
|
|
45
45
|
exports.ConfigService = ConfigService_1.default;
|
|
46
|
+
const DependencyService_1 = __importDefault(require("./services/DependencyService"));
|
|
47
|
+
exports.DependencyService = DependencyService_1.default;
|
|
46
48
|
const DOFunctionService_1 = __importDefault(require("./services/DOFunctionService"));
|
|
47
49
|
exports.DOFunctionService = DOFunctionService_1.default;
|
|
48
50
|
const StringService_1 = __importDefault(require("./services/StringService"));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A service which can be used to manage dependencies in the current project
|
|
3
|
+
* in various ways.
|
|
4
|
+
*/
|
|
5
|
+
export default class DependencyService {
|
|
6
|
+
/**
|
|
7
|
+
* Updates the package.json files of all sub-directories based on the root
|
|
8
|
+
* package.json file. This will match any versions of dependencies in the
|
|
9
|
+
* sub-directories to the version in the root package.json file.
|
|
10
|
+
*/
|
|
11
|
+
static updateChildPackageJsons(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=DependencyService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DependencyService.d.ts","sourceRoot":"","sources":["../../src/services/DependencyService.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC;;;;OAIG;WACU,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;CA+DtD"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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 promises_1 = require("fs/promises");
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const FileSystemService_1 = __importDefault(require("./applications/FileSystemService/FileSystemService"));
|
|
9
|
+
/**
|
|
10
|
+
* A service which can be used to manage dependencies in the current project
|
|
11
|
+
* in various ways.
|
|
12
|
+
*/
|
|
13
|
+
class DependencyService {
|
|
14
|
+
/**
|
|
15
|
+
* Updates the package.json files of all sub-directories based on the root
|
|
16
|
+
* package.json file. This will match any versions of dependencies in the
|
|
17
|
+
* sub-directories to the version in the root package.json file.
|
|
18
|
+
*/
|
|
19
|
+
static async updateChildPackageJsons() {
|
|
20
|
+
// Read the root package.json file
|
|
21
|
+
const rootPackageJsonPath = path_1.default.join(process.cwd(), 'package.json');
|
|
22
|
+
try {
|
|
23
|
+
await (0, promises_1.access)(rootPackageJsonPath);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
throw new Error('No package.json file found in the current directory.');
|
|
27
|
+
}
|
|
28
|
+
const rootPackageJsonData = JSON.parse(await (0, promises_1.readFile)(rootPackageJsonPath, 'utf-8'));
|
|
29
|
+
// Get all files and in the current directory
|
|
30
|
+
const filePaths = await FileSystemService_1.default.getAllFilePathsRelative(process.cwd());
|
|
31
|
+
const packageJsonPaths = filePaths.filter((filePath) => !filePath.includes('node_modules') &&
|
|
32
|
+
!filePath.includes('dist') &&
|
|
33
|
+
!filePath.includes('build') &&
|
|
34
|
+
filePath !== '/package.json' &&
|
|
35
|
+
filePath.endsWith('package.json'));
|
|
36
|
+
const rootDependencies = {
|
|
37
|
+
...rootPackageJsonData.dependencies,
|
|
38
|
+
...rootPackageJsonData.devDependencies
|
|
39
|
+
};
|
|
40
|
+
// Iterate over all package.json files
|
|
41
|
+
await Promise.all(packageJsonPaths.map(async (packageJsonPath) => {
|
|
42
|
+
const fullPackageJsonPath = path_1.default.join(process.cwd(), packageJsonPath);
|
|
43
|
+
const packageJsonData = JSON.parse(await (0, promises_1.readFile)(fullPackageJsonPath, 'utf-8'));
|
|
44
|
+
if (packageJsonData.dependencies) {
|
|
45
|
+
Object.keys(packageJsonData.dependencies).forEach((dependency) => {
|
|
46
|
+
if (rootDependencies[dependency]) {
|
|
47
|
+
packageJsonData.dependencies[dependency] =
|
|
48
|
+
rootDependencies[dependency];
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (packageJsonData.devDependencies) {
|
|
53
|
+
Object.keys(packageJsonData.devDependencies).forEach((dependency) => {
|
|
54
|
+
if (rootDependencies[dependency]) {
|
|
55
|
+
packageJsonData.dependencies[dependency] =
|
|
56
|
+
rootDependencies[dependency];
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// Write the updated package.json file
|
|
61
|
+
await (0, promises_1.writeFile)(fullPackageJsonPath, JSON.stringify(packageJsonData, null, 2));
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.default = DependencyService;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aneuhold/core-ts-lib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
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",
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
"pushpub": "npm run build && npm version patch && git push && npm publish --access public",
|
|
9
9
|
"build": "tsc",
|
|
10
10
|
"watch": "tsc -w",
|
|
11
|
+
"link:local": "cd lib && yarn link",
|
|
12
|
+
"unlink:local": "cd lib && yarn unlink",
|
|
11
13
|
"upgrade:all": "yarn upgrade --latest",
|
|
12
14
|
"test": "jest"
|
|
13
15
|
},
|