@augment-vir/node 31.43.3 → 31.45.0
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/README.md +0 -2
- package/dist/augments/npm/npm-deps.d.ts +38 -0
- package/dist/augments/npm/npm-deps.js +47 -0
- package/dist/augments/npm/package-json.d.ts +21 -0
- package/dist/augments/npm/package-json.js +48 -0
- package/dist/file-paths.mock.d.ts +0 -6
- package/dist/file-paths.mock.js +0 -6
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +4 -6
- package/src/augments/npm/npm-deps.ts +85 -0
- package/src/augments/npm/package-json.ts +75 -0
- package/src/file-paths.mock.ts +0 -7
- package/src/index.ts +2 -1
- package/dist/augments/docker.d.ts +0 -92
- package/dist/augments/docker.js +0 -87
- package/dist/docker/containers/container-info.d.ts +0 -57
- package/dist/docker/containers/container-info.js +0 -18
- package/dist/docker/containers/container-status.d.ts +0 -32
- package/dist/docker/containers/container-status.js +0 -68
- package/dist/docker/containers/copy-to-container.d.ts +0 -14
- package/dist/docker/containers/copy-to-container.js +0 -10
- package/dist/docker/containers/docker-command-inputs.d.ts +0 -74
- package/dist/docker/containers/docker-command-inputs.js +0 -45
- package/dist/docker/containers/kill-container.d.ts +0 -10
- package/dist/docker/containers/kill-container.js +0 -12
- package/dist/docker/containers/run-command.d.ts +0 -18
- package/dist/docker/containers/run-command.js +0 -24
- package/dist/docker/containers/run-container.d.ts +0 -23
- package/dist/docker/containers/run-container.js +0 -47
- package/dist/docker/containers/run-container.mock.d.ts +0 -2
- package/dist/docker/containers/run-container.mock.js +0 -16
- package/dist/docker/containers/try-or-kill-container.d.ts +0 -6
- package/dist/docker/containers/try-or-kill-container.js +0 -14
- package/dist/docker/docker-image.d.ts +0 -9
- package/dist/docker/docker-image.js +0 -50
- package/dist/docker/docker-startup.d.ts +0 -2
- package/dist/docker/docker-startup.js +0 -39
- package/dist/docker/run-docker-test.mock.d.ts +0 -2
- package/dist/docker/run-docker-test.mock.js +0 -23
- package/src/augments/docker.ts +0 -119
- package/src/docker/containers/container-info.ts +0 -83
- package/src/docker/containers/container-status.ts +0 -110
- package/src/docker/containers/copy-to-container.ts +0 -34
- package/src/docker/containers/docker-command-inputs.ts +0 -122
- package/src/docker/containers/kill-container.ts +0 -25
- package/src/docker/containers/run-command.ts +0 -51
- package/src/docker/containers/run-container.mock.ts +0 -22
- package/src/docker/containers/run-container.ts +0 -92
- package/src/docker/containers/try-or-kill-container.ts +0 -18
- package/src/docker/docker-image.ts +0 -61
- package/src/docker/docker-startup.ts +0 -49
- package/src/docker/run-docker-test.mock.ts +0 -26
package/README.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
A collection of augments, helpers types, functions, and classes only for Node.js (backend) JavaScript environments.
|
|
4
4
|
|
|
5
|
-
- Includes a custom Prisma API built on its CLI: [`prisma`](https://electrovir.github.io/augment-vir/variables/prisma.html).
|
|
6
|
-
- Includes a custom Docker API built on its CLI: [`docker`](https://electrovir.github.io/augment-vir/variables/docker.html).
|
|
7
5
|
- Includes an easy to use shell script runner: [`runShellCommand`](https://electrovir.github.io/augment-vir/functions/runShellCommand.html).
|
|
8
6
|
- and much more!
|
|
9
7
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* All `package.json` keys that are parsed as direct dependencies.
|
|
3
|
+
*
|
|
4
|
+
* @category Internal
|
|
5
|
+
*/
|
|
6
|
+
export declare enum PackageJsonDependencyKey {
|
|
7
|
+
DevDependencies = "devDependencies",
|
|
8
|
+
Dependencies = "dependencies",
|
|
9
|
+
PeerDependencies = "peerDependencies"
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A record of package names to package versions included in the direct dependencies. This is the
|
|
13
|
+
* output from {@link listAllDirectNpmDeps}.
|
|
14
|
+
*
|
|
15
|
+
* @category Internal
|
|
16
|
+
*/
|
|
17
|
+
export type NpmDeps = Record<string, NpmDep[]>;
|
|
18
|
+
export type NpmDep = {
|
|
19
|
+
/** Path to the `package.json` file that depends on this. */
|
|
20
|
+
requiredBy: string;
|
|
21
|
+
dependencyKey: PackageJsonDependencyKey;
|
|
22
|
+
/**
|
|
23
|
+
* The version as it is directly noted in the `package.json` file. This might not necessarily
|
|
24
|
+
* correlate to any actually published versions.
|
|
25
|
+
*/
|
|
26
|
+
versionValue: string;
|
|
27
|
+
/** If true, this dependency is part of the workspace's own packages. */
|
|
28
|
+
isWorkspace: boolean;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Finds all direct deps for the workspace at, or that contains, the given dir path.
|
|
32
|
+
*
|
|
33
|
+
* @category Node : Npm
|
|
34
|
+
* @category Package : @augment-vir/node
|
|
35
|
+
* @throws If no directory with a `package-lock.json` file is found.
|
|
36
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
37
|
+
*/
|
|
38
|
+
export declare function listAllDirectNpmDeps(startDirPath: string): Promise<NpmDeps>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { check } from '@augment-vir/assert';
|
|
2
|
+
import { filterMap, getEnumValues, getObjectTypedEntries, getOrSet } from '@augment-vir/common';
|
|
3
|
+
import { readJsonFile } from '../fs/json.js';
|
|
4
|
+
import { findAllPackageJsonFilePaths } from './package-json.js';
|
|
5
|
+
/**
|
|
6
|
+
* All `package.json` keys that are parsed as direct dependencies.
|
|
7
|
+
*
|
|
8
|
+
* @category Internal
|
|
9
|
+
*/
|
|
10
|
+
export var PackageJsonDependencyKey;
|
|
11
|
+
(function (PackageJsonDependencyKey) {
|
|
12
|
+
PackageJsonDependencyKey["DevDependencies"] = "devDependencies";
|
|
13
|
+
PackageJsonDependencyKey["Dependencies"] = "dependencies";
|
|
14
|
+
PackageJsonDependencyKey["PeerDependencies"] = "peerDependencies";
|
|
15
|
+
})(PackageJsonDependencyKey || (PackageJsonDependencyKey = {}));
|
|
16
|
+
/**
|
|
17
|
+
* Finds all direct deps for the workspace at, or that contains, the given dir path.
|
|
18
|
+
*
|
|
19
|
+
* @category Node : Npm
|
|
20
|
+
* @category Package : @augment-vir/node
|
|
21
|
+
* @throws If no directory with a `package-lock.json` file is found.
|
|
22
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
23
|
+
*/
|
|
24
|
+
export async function listAllDirectNpmDeps(startDirPath) {
|
|
25
|
+
const packageJsonFilePaths = await findAllPackageJsonFilePaths(startDirPath);
|
|
26
|
+
const deps = {};
|
|
27
|
+
const packageJsonFiles = await Promise.all(packageJsonFilePaths.map(async (packageJsonFilePath) => {
|
|
28
|
+
return {
|
|
29
|
+
packageJsonFilePath,
|
|
30
|
+
packageJson: (await readJsonFile(packageJsonFilePath)),
|
|
31
|
+
};
|
|
32
|
+
}));
|
|
33
|
+
const allWorkspacePackageNames = filterMap(packageJsonFiles, (packageJsonFile) => packageJsonFile.packageJson.name, check.isTruthy);
|
|
34
|
+
packageJsonFiles.forEach(({ packageJson, packageJsonFilePath }) => {
|
|
35
|
+
getEnumValues(PackageJsonDependencyKey).forEach((dependencyKey) => {
|
|
36
|
+
getObjectTypedEntries(packageJson[dependencyKey] || {}).forEach(([dependencyName, versionValue,]) => {
|
|
37
|
+
getOrSet(deps, dependencyName, () => []).push({
|
|
38
|
+
dependencyKey,
|
|
39
|
+
requiredBy: packageJsonFilePath,
|
|
40
|
+
versionValue,
|
|
41
|
+
isWorkspace: allWorkspacePackageNames.includes(dependencyName),
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
return deps;
|
|
47
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds all `package.json` files contained within the workspaces present in the current
|
|
3
|
+
* `startDirPath`. A workspace root dir is found by recursively looking for a parent
|
|
4
|
+
* `package-lock.json` file.
|
|
5
|
+
*
|
|
6
|
+
* @category Node : Npm
|
|
7
|
+
* @category Package : @augment-vir/node
|
|
8
|
+
* @throws If no directory with a `package-lock.json` file is found.
|
|
9
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
10
|
+
*/
|
|
11
|
+
export declare function findAllPackageJsonFilePaths(startDirPath: string): Promise<string[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Get all workspace package.json paths starting at the given directory path. The output is string
|
|
14
|
+
* sorted to keep it stable.
|
|
15
|
+
*
|
|
16
|
+
* @category Node : Npm
|
|
17
|
+
* @category Package : @augment-vir/node
|
|
18
|
+
* @throws Error if there is no `package.json` file at the given `rootDirPath`.
|
|
19
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
20
|
+
*/
|
|
21
|
+
export declare function getWorkspacePackageJsonFilePaths(rootDirPath: string): Promise<string[]>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { check } from '@augment-vir/assert';
|
|
2
|
+
import { filterMap, fromAsyncIterable } from '@augment-vir/common';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { glob, readFile } from 'node:fs/promises';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { findAncestor, joinFilesToDir } from '../path/ancestor.js';
|
|
7
|
+
/**
|
|
8
|
+
* Finds all `package.json` files contained within the workspaces present in the current
|
|
9
|
+
* `startDirPath`. A workspace root dir is found by recursively looking for a parent
|
|
10
|
+
* `package-lock.json` file.
|
|
11
|
+
*
|
|
12
|
+
* @category Node : Npm
|
|
13
|
+
* @category Package : @augment-vir/node
|
|
14
|
+
* @throws If no directory with a `package-lock.json` file is found.
|
|
15
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
16
|
+
*/
|
|
17
|
+
export async function findAllPackageJsonFilePaths(startDirPath) {
|
|
18
|
+
const packageRootDir = findAncestor(startDirPath, (dir) => existsSync(join(dir, 'package-lock.json')));
|
|
19
|
+
if (!packageRootDir) {
|
|
20
|
+
throw new Error(`Cannot find all package.json files: failed to find any directory with a package-lock.json file. Started at '${startDirPath}'.`);
|
|
21
|
+
}
|
|
22
|
+
const rootPackageJsonPath = join(packageRootDir, 'package.json');
|
|
23
|
+
return [
|
|
24
|
+
rootPackageJsonPath,
|
|
25
|
+
...(await getWorkspacePackageJsonFilePaths(packageRootDir)),
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get all workspace package.json paths starting at the given directory path. The output is string
|
|
30
|
+
* sorted to keep it stable.
|
|
31
|
+
*
|
|
32
|
+
* @category Node : Npm
|
|
33
|
+
* @category Package : @augment-vir/node
|
|
34
|
+
* @throws Error if there is no `package.json` file at the given `rootDirPath`.
|
|
35
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
36
|
+
*/
|
|
37
|
+
export async function getWorkspacePackageJsonFilePaths(rootDirPath) {
|
|
38
|
+
const packageJson = JSON.parse(await readFile(join(rootDirPath, 'package.json'), 'utf8'));
|
|
39
|
+
/* node:coverage ignore next 3: this package only uses one type of workspace */
|
|
40
|
+
const patterns = check.isArray(packageJson.workspaces)
|
|
41
|
+
? packageJson.workspaces
|
|
42
|
+
: packageJson.workspaces?.packages || [];
|
|
43
|
+
const matchedPaths = joinFilesToDir(rootDirPath, (await Promise.all(patterns.map(async (pattern) => {
|
|
44
|
+
return await fromAsyncIterable(glob(pattern, { cwd: rootDirPath }));
|
|
45
|
+
}))).flat());
|
|
46
|
+
const workspacePackageJsonPaths = filterMap(matchedPaths, (matchedPath) => join(matchedPath, 'package.json'), (packageJsonPath) => existsSync(packageJsonPath));
|
|
47
|
+
return workspacePackageJsonPaths.sort();
|
|
48
|
+
}
|
|
@@ -10,9 +10,3 @@ export declare const workspaceQueryPackageJsonPath: string;
|
|
|
10
10
|
export declare const tempWorkspaceQueryFile: string;
|
|
11
11
|
export declare const recursiveFileReadDir: string;
|
|
12
12
|
export declare const invalidPackageDirPath: string;
|
|
13
|
-
export declare const testPrismaSchemaPath: string;
|
|
14
|
-
export declare const testPrismaSchema2Path: string;
|
|
15
|
-
export declare const testInvalidPrismaSchemaPath: string;
|
|
16
|
-
export declare const testSqliteDbPath: string;
|
|
17
|
-
export declare const generatedPrismaClientDirPath: string;
|
|
18
|
-
export declare const testPrismaMigrationsDirPath: string;
|
package/dist/file-paths.mock.js
CHANGED
|
@@ -12,9 +12,3 @@ export const workspaceQueryPackageJsonPath = join(workspaceQueryDir, 'package.js
|
|
|
12
12
|
export const tempWorkspaceQueryFile = join(workspaceQueryDir, 'temp-workspace-query-output.ts');
|
|
13
13
|
export const recursiveFileReadDir = join(testFilesDir, 'recursive-reading');
|
|
14
14
|
export const invalidPackageDirPath = join(testFilesDir, 'invalid-package');
|
|
15
|
-
export const testPrismaSchemaPath = join(testFilesDir, 'schema.prisma');
|
|
16
|
-
export const testPrismaSchema2Path = join(testFilesDir, 'schema2.prisma');
|
|
17
|
-
export const testInvalidPrismaSchemaPath = join(testFilesDir, 'invalid-schema.prisma');
|
|
18
|
-
export const testSqliteDbPath = join(notCommittedDirPath, 'dev.db');
|
|
19
|
-
export const generatedPrismaClientDirPath = join(nodePackageDir, 'node_modules', '.prisma');
|
|
20
|
-
export const testPrismaMigrationsDirPath = join(testFilesDir, 'migrations');
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export * from './augments/docker.js';
|
|
2
1
|
export * from './augments/fs/dir-contents.js';
|
|
3
2
|
export * from './augments/fs/download.js';
|
|
4
3
|
export * from './augments/fs/json.js';
|
|
@@ -7,6 +6,8 @@ export * from './augments/fs/read-file.js';
|
|
|
7
6
|
export * from './augments/fs/symlink.js';
|
|
8
7
|
export * from './augments/fs/write.js';
|
|
9
8
|
export * from './augments/npm/find-bin-path.js';
|
|
9
|
+
export * from './augments/npm/npm-deps.js';
|
|
10
|
+
export * from './augments/npm/package-json.js';
|
|
10
11
|
export * from './augments/npm/query-workspace.js';
|
|
11
12
|
export * from './augments/npm/read-package-json.js';
|
|
12
13
|
export * from './augments/os/operating-system.js';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export * from './augments/docker.js';
|
|
2
1
|
export * from './augments/fs/dir-contents.js';
|
|
3
2
|
export * from './augments/fs/download.js';
|
|
4
3
|
export * from './augments/fs/json.js';
|
|
@@ -7,6 +6,8 @@ export * from './augments/fs/read-file.js';
|
|
|
7
6
|
export * from './augments/fs/symlink.js';
|
|
8
7
|
export * from './augments/fs/write.js';
|
|
9
8
|
export * from './augments/npm/find-bin-path.js';
|
|
9
|
+
export * from './augments/npm/npm-deps.js';
|
|
10
|
+
export * from './augments/npm/package-json.js';
|
|
10
11
|
export * from './augments/npm/query-workspace.js';
|
|
11
12
|
export * from './augments/npm/read-package-json.js';
|
|
12
13
|
export * from './augments/os/operating-system.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@augment-vir/node",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.45.0",
|
|
4
4
|
"description": "A collection of augments, helpers types, functions, and classes only for Node.js (backend) JavaScript environments.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"augment",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"test:update": "npm test"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@augment-vir/assert": "^31.
|
|
42
|
-
"@augment-vir/common": "^31.
|
|
41
|
+
"@augment-vir/assert": "^31.45.0",
|
|
42
|
+
"@augment-vir/common": "^31.45.0",
|
|
43
43
|
"@date-vir/duration": "^8.0.0",
|
|
44
44
|
"ansi-styles": "^6.2.3",
|
|
45
45
|
"sanitize-filename": "^1.6.3",
|
|
@@ -49,8 +49,7 @@
|
|
|
49
49
|
"typed-event-target": "^4.1.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@augment-vir/test": "^31.
|
|
53
|
-
"@prisma/client": "^6.17.1",
|
|
52
|
+
"@augment-vir/test": "^31.45.0",
|
|
54
53
|
"@types/node": "^24.9.1",
|
|
55
54
|
"@web/dev-server-esbuild": "^1.0.4",
|
|
56
55
|
"@web/test-runner": "^0.20.2",
|
|
@@ -59,7 +58,6 @@
|
|
|
59
58
|
"@web/test-runner-visual-regression": "^0.10.0",
|
|
60
59
|
"c8": "^10.1.3",
|
|
61
60
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
62
|
-
"prisma": "^6.17.1",
|
|
63
61
|
"typescript": "^5.9.3"
|
|
64
62
|
},
|
|
65
63
|
"peerDependencies": {
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {check} from '@augment-vir/assert';
|
|
2
|
+
import {filterMap, getEnumValues, getObjectTypedEntries, getOrSet} from '@augment-vir/common';
|
|
3
|
+
import {type PackageJson} from 'type-fest';
|
|
4
|
+
import {readJsonFile} from '../fs/json.js';
|
|
5
|
+
import {findAllPackageJsonFilePaths} from './package-json.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* All `package.json` keys that are parsed as direct dependencies.
|
|
9
|
+
*
|
|
10
|
+
* @category Internal
|
|
11
|
+
*/
|
|
12
|
+
export enum PackageJsonDependencyKey {
|
|
13
|
+
DevDependencies = 'devDependencies',
|
|
14
|
+
Dependencies = 'dependencies',
|
|
15
|
+
PeerDependencies = 'peerDependencies',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A record of package names to package versions included in the direct dependencies. This is the
|
|
20
|
+
* output from {@link listAllDirectNpmDeps}.
|
|
21
|
+
*
|
|
22
|
+
* @category Internal
|
|
23
|
+
*/
|
|
24
|
+
export type NpmDeps = Record<string, NpmDep[]>;
|
|
25
|
+
export type NpmDep = {
|
|
26
|
+
/** Path to the `package.json` file that depends on this. */
|
|
27
|
+
requiredBy: string;
|
|
28
|
+
dependencyKey: PackageJsonDependencyKey;
|
|
29
|
+
/**
|
|
30
|
+
* The version as it is directly noted in the `package.json` file. This might not necessarily
|
|
31
|
+
* correlate to any actually published versions.
|
|
32
|
+
*/
|
|
33
|
+
versionValue: string;
|
|
34
|
+
/** If true, this dependency is part of the workspace's own packages. */
|
|
35
|
+
isWorkspace: boolean;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Finds all direct deps for the workspace at, or that contains, the given dir path.
|
|
40
|
+
*
|
|
41
|
+
* @category Node : Npm
|
|
42
|
+
* @category Package : @augment-vir/node
|
|
43
|
+
* @throws If no directory with a `package-lock.json` file is found.
|
|
44
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
45
|
+
*/
|
|
46
|
+
export async function listAllDirectNpmDeps(startDirPath: string): Promise<NpmDeps> {
|
|
47
|
+
const packageJsonFilePaths = await findAllPackageJsonFilePaths(startDirPath);
|
|
48
|
+
|
|
49
|
+
const deps: NpmDeps = {};
|
|
50
|
+
|
|
51
|
+
const packageJsonFiles = await Promise.all(
|
|
52
|
+
packageJsonFilePaths.map(async (packageJsonFilePath) => {
|
|
53
|
+
return {
|
|
54
|
+
packageJsonFilePath,
|
|
55
|
+
packageJson: (await readJsonFile(packageJsonFilePath)) as PackageJson,
|
|
56
|
+
};
|
|
57
|
+
}),
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const allWorkspacePackageNames = filterMap(
|
|
61
|
+
packageJsonFiles,
|
|
62
|
+
(packageJsonFile) => packageJsonFile.packageJson.name,
|
|
63
|
+
check.isTruthy,
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
packageJsonFiles.forEach(({packageJson, packageJsonFilePath}) => {
|
|
67
|
+
getEnumValues(PackageJsonDependencyKey).forEach((dependencyKey) => {
|
|
68
|
+
getObjectTypedEntries(packageJson[dependencyKey] || {}).forEach(
|
|
69
|
+
([
|
|
70
|
+
dependencyName,
|
|
71
|
+
versionValue,
|
|
72
|
+
]) => {
|
|
73
|
+
getOrSet(deps, dependencyName, () => []).push({
|
|
74
|
+
dependencyKey,
|
|
75
|
+
requiredBy: packageJsonFilePath,
|
|
76
|
+
versionValue,
|
|
77
|
+
isWorkspace: allWorkspacePackageNames.includes(dependencyName),
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return deps;
|
|
85
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {check} from '@augment-vir/assert';
|
|
2
|
+
import {filterMap, fromAsyncIterable} from '@augment-vir/common';
|
|
3
|
+
import {existsSync} from 'node:fs';
|
|
4
|
+
import {glob, readFile} from 'node:fs/promises';
|
|
5
|
+
import {join} from 'node:path';
|
|
6
|
+
import {type PackageJson} from 'type-fest';
|
|
7
|
+
import {findAncestor, joinFilesToDir} from '../path/ancestor.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Finds all `package.json` files contained within the workspaces present in the current
|
|
11
|
+
* `startDirPath`. A workspace root dir is found by recursively looking for a parent
|
|
12
|
+
* `package-lock.json` file.
|
|
13
|
+
*
|
|
14
|
+
* @category Node : Npm
|
|
15
|
+
* @category Package : @augment-vir/node
|
|
16
|
+
* @throws If no directory with a `package-lock.json` file is found.
|
|
17
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
18
|
+
*/
|
|
19
|
+
export async function findAllPackageJsonFilePaths(startDirPath: string) {
|
|
20
|
+
const packageRootDir = findAncestor(startDirPath, (dir) =>
|
|
21
|
+
existsSync(join(dir, 'package-lock.json')),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
if (!packageRootDir) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`Cannot find all package.json files: failed to find any directory with a package-lock.json file. Started at '${startDirPath}'.`,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const rootPackageJsonPath = join(packageRootDir, 'package.json');
|
|
31
|
+
|
|
32
|
+
return [
|
|
33
|
+
rootPackageJsonPath,
|
|
34
|
+
...(await getWorkspacePackageJsonFilePaths(packageRootDir)),
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Get all workspace package.json paths starting at the given directory path. The output is string
|
|
40
|
+
* sorted to keep it stable.
|
|
41
|
+
*
|
|
42
|
+
* @category Node : Npm
|
|
43
|
+
* @category Package : @augment-vir/node
|
|
44
|
+
* @throws Error if there is no `package.json` file at the given `rootDirPath`.
|
|
45
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
46
|
+
*/
|
|
47
|
+
export async function getWorkspacePackageJsonFilePaths(rootDirPath: string): Promise<string[]> {
|
|
48
|
+
const packageJson: PackageJson = JSON.parse(
|
|
49
|
+
await readFile(join(rootDirPath, 'package.json'), 'utf8'),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
/* node:coverage ignore next 3: this package only uses one type of workspace */
|
|
53
|
+
const patterns = check.isArray(packageJson.workspaces)
|
|
54
|
+
? packageJson.workspaces
|
|
55
|
+
: packageJson.workspaces?.packages || [];
|
|
56
|
+
|
|
57
|
+
const matchedPaths: string[] = joinFilesToDir(
|
|
58
|
+
rootDirPath,
|
|
59
|
+
(
|
|
60
|
+
await Promise.all(
|
|
61
|
+
patterns.map(async (pattern) => {
|
|
62
|
+
return await fromAsyncIterable(glob(pattern, {cwd: rootDirPath}));
|
|
63
|
+
}),
|
|
64
|
+
)
|
|
65
|
+
).flat(),
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const workspacePackageJsonPaths = filterMap(
|
|
69
|
+
matchedPaths,
|
|
70
|
+
(matchedPath) => join(matchedPath, 'package.json'),
|
|
71
|
+
(packageJsonPath) => existsSync(packageJsonPath),
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
return workspacePackageJsonPaths.sort();
|
|
75
|
+
}
|
package/src/file-paths.mock.ts
CHANGED
|
@@ -20,10 +20,3 @@ export const tempWorkspaceQueryFile = join(workspaceQueryDir, 'temp-workspace-qu
|
|
|
20
20
|
export const recursiveFileReadDir = join(testFilesDir, 'recursive-reading');
|
|
21
21
|
|
|
22
22
|
export const invalidPackageDirPath = join(testFilesDir, 'invalid-package');
|
|
23
|
-
|
|
24
|
-
export const testPrismaSchemaPath = join(testFilesDir, 'schema.prisma');
|
|
25
|
-
export const testPrismaSchema2Path = join(testFilesDir, 'schema2.prisma');
|
|
26
|
-
export const testInvalidPrismaSchemaPath = join(testFilesDir, 'invalid-schema.prisma');
|
|
27
|
-
export const testSqliteDbPath = join(notCommittedDirPath, 'dev.db');
|
|
28
|
-
export const generatedPrismaClientDirPath = join(nodePackageDir, 'node_modules', '.prisma');
|
|
29
|
-
export const testPrismaMigrationsDirPath = join(testFilesDir, 'migrations');
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export * from './augments/docker.js';
|
|
2
1
|
export * from './augments/fs/dir-contents.js';
|
|
3
2
|
export * from './augments/fs/download.js';
|
|
4
3
|
export * from './augments/fs/json.js';
|
|
@@ -7,6 +6,8 @@ export * from './augments/fs/read-file.js';
|
|
|
7
6
|
export * from './augments/fs/symlink.js';
|
|
8
7
|
export * from './augments/fs/write.js';
|
|
9
8
|
export * from './augments/npm/find-bin-path.js';
|
|
9
|
+
export * from './augments/npm/npm-deps.js';
|
|
10
|
+
export * from './augments/npm/package-json.js';
|
|
10
11
|
export * from './augments/npm/query-workspace.js';
|
|
11
12
|
export * from './augments/npm/read-package-json.js';
|
|
12
13
|
export * from './augments/os/operating-system.js';
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { getContainerInfo } from '../docker/containers/container-info.js';
|
|
2
|
-
import { getContainerLogs, getContainerStatus, waitUntilContainerExited, waitUntilContainerRemoved, waitUntilContainerRunning } from '../docker/containers/container-status.js';
|
|
3
|
-
import { copyToContainer } from '../docker/containers/copy-to-container.js';
|
|
4
|
-
import { makeEnvFlags, makePortMapFlags, makeVolumeFlags } from '../docker/containers/docker-command-inputs.js';
|
|
5
|
-
import { killContainer } from '../docker/containers/kill-container.js';
|
|
6
|
-
import { runContainerCommand } from '../docker/containers/run-command.js';
|
|
7
|
-
import { runContainer } from '../docker/containers/run-container.js';
|
|
8
|
-
import { tryOrKillContainer } from '../docker/containers/try-or-kill-container.js';
|
|
9
|
-
import { isImageInLocalRegistry, removeImageFromLocalRegistry, updateImage } from '../docker/docker-image.js';
|
|
10
|
-
import { isDockerRunning, startDocker } from '../docker/docker-startup.js';
|
|
11
|
-
export { type DockerContainerInfo, type DockerContainerInfoState, } from '../docker/containers/container-info.js';
|
|
12
|
-
export { DockerContainerStatus, exitedDockerContainerStatuses, } from '../docker/containers/container-status.js';
|
|
13
|
-
export { type CopyToDockerContainerParams } from '../docker/containers/copy-to-container.js';
|
|
14
|
-
export { type DockerEnvMap, type DockerPortMap, type DockerVolumeMap, type DockerVolumeMappingType, } from '../docker/containers/docker-command-inputs.js';
|
|
15
|
-
export { type RunDockerContainerCommandParams } from '../docker/containers/run-command.js';
|
|
16
|
-
export { type RunDockerContainerParams } from '../docker/containers/run-container.js';
|
|
17
|
-
/**
|
|
18
|
-
* Centralized Docker API.
|
|
19
|
-
*
|
|
20
|
-
* @deprecated Use the [docker-vir](https://www.npmjs.com/package/docker-vir) package instead.
|
|
21
|
-
* @category Node : Docker
|
|
22
|
-
* @category Package : @augment-vir/node
|
|
23
|
-
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
24
|
-
*/
|
|
25
|
-
export declare const docker: {
|
|
26
|
-
/** Detects if the Docker service is running. */
|
|
27
|
-
isRunning: typeof isDockerRunning;
|
|
28
|
-
/**
|
|
29
|
-
* Tries to start Docker based ont he current operating system's supported commands. The success
|
|
30
|
-
* of this operation is heavily dependent on how you have Docker setup on your system.
|
|
31
|
-
*/
|
|
32
|
-
start: typeof startDocker;
|
|
33
|
-
image: {
|
|
34
|
-
/** Downloads an image if it is missing from the local registry. */
|
|
35
|
-
update: typeof updateImage;
|
|
36
|
-
/** Removes an image from the local registry. */
|
|
37
|
-
remove: typeof removeImageFromLocalRegistry;
|
|
38
|
-
/** Detects if an image exists in the local registry. */
|
|
39
|
-
exists: typeof isImageInLocalRegistry;
|
|
40
|
-
};
|
|
41
|
-
container: {
|
|
42
|
-
/**
|
|
43
|
-
* Get the current status of a container. If the container does not exist at all, the status
|
|
44
|
-
* will be {@link DockerContainerStatus.Removed}.
|
|
45
|
-
*/
|
|
46
|
-
getStatus: typeof getContainerStatus;
|
|
47
|
-
/** Wait until a container is running and responsive. */
|
|
48
|
-
waitUntilRunning: typeof waitUntilContainerRunning;
|
|
49
|
-
/**
|
|
50
|
-
* Wait until a container has a status that can be classified as "exited".
|
|
51
|
-
*
|
|
52
|
-
* @see {@link exitedDockerContainerStatuses}
|
|
53
|
-
*/
|
|
54
|
-
waitUntilExited: typeof waitUntilContainerExited;
|
|
55
|
-
/** Wait until a container is completely removed. */
|
|
56
|
-
waitUntilRemoved: typeof waitUntilContainerRemoved;
|
|
57
|
-
/**
|
|
58
|
-
* Runs a callback (which presumably will run a command within the given `containerName`)
|
|
59
|
-
* and kills the container if the callback fails.
|
|
60
|
-
*/
|
|
61
|
-
tryOrKill: typeof tryOrKillContainer;
|
|
62
|
-
/** Run a container that isn't already running. */
|
|
63
|
-
run: typeof runContainer;
|
|
64
|
-
/** Kill a container. */
|
|
65
|
-
kill: typeof killContainer;
|
|
66
|
-
/** Copy a file or directory to a container. */
|
|
67
|
-
copyTo: typeof copyToContainer;
|
|
68
|
-
/** Run a command on a container that is already running. */
|
|
69
|
-
runCommand: typeof runContainerCommand;
|
|
70
|
-
/** Run `docker inspect` on a container and return its output. */
|
|
71
|
-
getInfo: typeof getContainerInfo;
|
|
72
|
-
/** Get a container's logs. */
|
|
73
|
-
getLogs: typeof getContainerLogs;
|
|
74
|
-
};
|
|
75
|
-
util: {
|
|
76
|
-
/**
|
|
77
|
-
* Manually create a string of volume mapping flags. This is automatically done already
|
|
78
|
-
* inside the run container methods.
|
|
79
|
-
*/
|
|
80
|
-
makeVolumeFlags: typeof makeVolumeFlags;
|
|
81
|
-
/**
|
|
82
|
-
* Manually create a string of port mapping flags. This is automatically done already inside
|
|
83
|
-
* the run container methods.
|
|
84
|
-
*/
|
|
85
|
-
makePortMapFlags: typeof makePortMapFlags;
|
|
86
|
-
/**
|
|
87
|
-
* Manually create a string of env mapping flags. This is automatically done already inside
|
|
88
|
-
* the run container methods.
|
|
89
|
-
*/
|
|
90
|
-
makeEnvFlags: typeof makeEnvFlags;
|
|
91
|
-
};
|
|
92
|
-
};
|
package/dist/augments/docker.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { getContainerInfo } from '../docker/containers/container-info.js';
|
|
2
|
-
import { getContainerLogs, getContainerStatus, waitUntilContainerExited, waitUntilContainerRemoved, waitUntilContainerRunning, } from '../docker/containers/container-status.js';
|
|
3
|
-
import { copyToContainer } from '../docker/containers/copy-to-container.js';
|
|
4
|
-
import { makeEnvFlags, makePortMapFlags, makeVolumeFlags, } from '../docker/containers/docker-command-inputs.js';
|
|
5
|
-
import { killContainer } from '../docker/containers/kill-container.js';
|
|
6
|
-
import { runContainerCommand } from '../docker/containers/run-command.js';
|
|
7
|
-
import { runContainer } from '../docker/containers/run-container.js';
|
|
8
|
-
import { tryOrKillContainer } from '../docker/containers/try-or-kill-container.js';
|
|
9
|
-
import { isImageInLocalRegistry, removeImageFromLocalRegistry, updateImage, } from '../docker/docker-image.js';
|
|
10
|
-
import { isDockerRunning, startDocker } from '../docker/docker-startup.js';
|
|
11
|
-
export { DockerContainerStatus, exitedDockerContainerStatuses, } from '../docker/containers/container-status.js';
|
|
12
|
-
/**
|
|
13
|
-
* Centralized Docker API.
|
|
14
|
-
*
|
|
15
|
-
* @deprecated Use the [docker-vir](https://www.npmjs.com/package/docker-vir) package instead.
|
|
16
|
-
* @category Node : Docker
|
|
17
|
-
* @category Package : @augment-vir/node
|
|
18
|
-
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
19
|
-
*/
|
|
20
|
-
export const docker = {
|
|
21
|
-
/** Detects if the Docker service is running. */
|
|
22
|
-
isRunning: isDockerRunning,
|
|
23
|
-
/**
|
|
24
|
-
* Tries to start Docker based ont he current operating system's supported commands. The success
|
|
25
|
-
* of this operation is heavily dependent on how you have Docker setup on your system.
|
|
26
|
-
*/
|
|
27
|
-
start: startDocker,
|
|
28
|
-
image: {
|
|
29
|
-
/** Downloads an image if it is missing from the local registry. */
|
|
30
|
-
update: updateImage,
|
|
31
|
-
/** Removes an image from the local registry. */
|
|
32
|
-
remove: removeImageFromLocalRegistry,
|
|
33
|
-
/** Detects if an image exists in the local registry. */
|
|
34
|
-
exists: isImageInLocalRegistry,
|
|
35
|
-
},
|
|
36
|
-
container: {
|
|
37
|
-
/**
|
|
38
|
-
* Get the current status of a container. If the container does not exist at all, the status
|
|
39
|
-
* will be {@link DockerContainerStatus.Removed}.
|
|
40
|
-
*/
|
|
41
|
-
getStatus: getContainerStatus,
|
|
42
|
-
/** Wait until a container is running and responsive. */
|
|
43
|
-
waitUntilRunning: waitUntilContainerRunning,
|
|
44
|
-
/**
|
|
45
|
-
* Wait until a container has a status that can be classified as "exited".
|
|
46
|
-
*
|
|
47
|
-
* @see {@link exitedDockerContainerStatuses}
|
|
48
|
-
*/
|
|
49
|
-
waitUntilExited: waitUntilContainerExited,
|
|
50
|
-
/** Wait until a container is completely removed. */
|
|
51
|
-
waitUntilRemoved: waitUntilContainerRemoved,
|
|
52
|
-
/**
|
|
53
|
-
* Runs a callback (which presumably will run a command within the given `containerName`)
|
|
54
|
-
* and kills the container if the callback fails.
|
|
55
|
-
*/
|
|
56
|
-
tryOrKill: tryOrKillContainer,
|
|
57
|
-
/** Run a container that isn't already running. */
|
|
58
|
-
run: runContainer,
|
|
59
|
-
/** Kill a container. */
|
|
60
|
-
kill: killContainer,
|
|
61
|
-
/** Copy a file or directory to a container. */
|
|
62
|
-
copyTo: copyToContainer,
|
|
63
|
-
/** Run a command on a container that is already running. */
|
|
64
|
-
runCommand: runContainerCommand,
|
|
65
|
-
/** Run `docker inspect` on a container and return its output. */
|
|
66
|
-
getInfo: getContainerInfo,
|
|
67
|
-
/** Get a container's logs. */
|
|
68
|
-
getLogs: getContainerLogs,
|
|
69
|
-
},
|
|
70
|
-
util: {
|
|
71
|
-
/**
|
|
72
|
-
* Manually create a string of volume mapping flags. This is automatically done already
|
|
73
|
-
* inside the run container methods.
|
|
74
|
-
*/
|
|
75
|
-
makeVolumeFlags,
|
|
76
|
-
/**
|
|
77
|
-
* Manually create a string of port mapping flags. This is automatically done already inside
|
|
78
|
-
* the run container methods.
|
|
79
|
-
*/
|
|
80
|
-
makePortMapFlags,
|
|
81
|
-
/**
|
|
82
|
-
* Manually create a string of env mapping flags. This is automatically done already inside
|
|
83
|
-
* the run container methods.
|
|
84
|
-
*/
|
|
85
|
-
makeEnvFlags,
|
|
86
|
-
},
|
|
87
|
-
};
|