@augment-vir/node 31.32.3 → 31.33.1
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/dist/augments/path/contains.d.ts +16 -0
- package/dist/augments/path/contains.js +33 -0
- package/dist/augments/prisma.js +1 -1
- package/dist/docker/containers/run-container.mock.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/scripts/fix-ts-bin.script.js +21 -1
- package/package.json +11 -12
- package/src/augments/path/contains.ts +51 -0
- package/src/augments/prisma.ts +1 -1
- package/src/docker/containers/run-container.mock.ts +1 -1
- package/src/index.ts +1 -0
- package/src/scripts/fix-ts-bin.script.ts +32 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
/**
|
|
3
|
+
* Checks to see if a potential child path is inside of a potential parent path.
|
|
4
|
+
*
|
|
5
|
+
* @category Path : Node
|
|
6
|
+
* @category Package : @augment-vir/node
|
|
7
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
8
|
+
*/
|
|
9
|
+
export declare function doesPathContain(potentialParentPath: string, potentialChildPath: string, options?: PartialWithUndefined<{
|
|
10
|
+
/**
|
|
11
|
+
* Set this to `true` to return `true` if the paths are exactly equal.
|
|
12
|
+
*
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
allowSelf: boolean;
|
|
16
|
+
}>): boolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isAbsolute, normalize, relative, resolve, sep } from 'node:path';
|
|
2
|
+
import { isOperatingSystem, OperatingSystem } from '../os/operating-system.js';
|
|
3
|
+
/**
|
|
4
|
+
* Checks to see if a potential child path is inside of a potential parent path.
|
|
5
|
+
*
|
|
6
|
+
* @category Path : Node
|
|
7
|
+
* @category Package : @augment-vir/node
|
|
8
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
9
|
+
*/
|
|
10
|
+
export function doesPathContain(potentialParentPath, potentialChildPath, options = {}) {
|
|
11
|
+
if (!potentialParentPath || !potentialChildPath) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const parent = normalizePath(potentialParentPath);
|
|
15
|
+
const child = normalizePath(potentialChildPath);
|
|
16
|
+
const relativePath = relative(parent, child);
|
|
17
|
+
if (!relativePath) {
|
|
18
|
+
/** Paths are identical. */
|
|
19
|
+
return !!options.allowSelf;
|
|
20
|
+
/* node:coverage ignore next 4: cannot test Windows specific behavior on all systems. */
|
|
21
|
+
}
|
|
22
|
+
else if (isAbsolute(relativePath)) {
|
|
23
|
+
/** On Windows, paths on different drives yield an absolute relative path. */
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
/** Contained if it does not traverse up out of parent. */
|
|
27
|
+
return relativePath !== '..' && !relativePath.startsWith('..' + sep);
|
|
28
|
+
}
|
|
29
|
+
function normalizePath(inputPath) {
|
|
30
|
+
const absolutePath = normalize(resolve(inputPath));
|
|
31
|
+
/* node:coverage ignore next 1: cannot test Windows specific behavior on all systems. */
|
|
32
|
+
return isOperatingSystem(OperatingSystem.Windows) ? absolutePath.toLowerCase() : absolutePath;
|
|
33
|
+
}
|
package/dist/augments/prisma.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { docker } from '../../augments/docker.js';
|
|
2
2
|
export async function runMockLongLivingContainer(containerName, args = {}) {
|
|
3
3
|
await docker.container.run({
|
|
4
|
-
containerName
|
|
4
|
+
containerName,
|
|
5
5
|
detach: true,
|
|
6
6
|
imageName: 'alpine:3.20.2',
|
|
7
7
|
dockerFlags: [
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from './augments/npm/query-workspace.js';
|
|
|
11
11
|
export * from './augments/npm/read-package-json.js';
|
|
12
12
|
export * from './augments/os/operating-system.js';
|
|
13
13
|
export * from './augments/path/ancestor.js';
|
|
14
|
+
export * from './augments/path/contains.js';
|
|
14
15
|
export * from './augments/path/os-path.js';
|
|
15
16
|
export * from './augments/path/resolve-import.js';
|
|
16
17
|
export * from './augments/path/root.js';
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export * from './augments/npm/query-workspace.js';
|
|
|
11
11
|
export * from './augments/npm/read-package-json.js';
|
|
12
12
|
export * from './augments/os/operating-system.js';
|
|
13
13
|
export * from './augments/path/ancestor.js';
|
|
14
|
+
export * from './augments/path/contains.js';
|
|
14
15
|
export * from './augments/path/os-path.js';
|
|
15
16
|
export * from './augments/path/resolve-import.js';
|
|
16
17
|
export * from './augments/path/root.js';
|
|
@@ -16,23 +16,32 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { log } from '@augment-vir/common';
|
|
18
18
|
import { interpolationSafeWindowsPath, runShellCommand } from '@augment-vir/node';
|
|
19
|
-
import { rm, writeFile } from 'node:fs/promises';
|
|
19
|
+
import { readFile, rm, writeFile } from 'node:fs/promises';
|
|
20
20
|
import { join, sep } from 'node:path/posix';
|
|
21
21
|
const packagesToFix = [
|
|
22
|
+
{
|
|
23
|
+
packageName: 'runstorm',
|
|
24
|
+
binName: 'runstorm',
|
|
25
|
+
scriptPath: join('runstorm', 'src', 'cli', 'cli.script.ts'),
|
|
26
|
+
fixImport: true,
|
|
27
|
+
},
|
|
22
28
|
{
|
|
23
29
|
packageName: 'mono-vir',
|
|
24
30
|
binName: 'mono-vir',
|
|
25
31
|
scriptPath: join('mono-vir', 'src', 'cli', 'cli.script.ts'),
|
|
32
|
+
fixImport: true,
|
|
26
33
|
},
|
|
27
34
|
{
|
|
28
35
|
packageName: 'virmator',
|
|
29
36
|
binName: 'virmator',
|
|
30
37
|
scriptPath: join('virmator', 'src', 'cli.script.ts'),
|
|
38
|
+
fixImport: true,
|
|
31
39
|
},
|
|
32
40
|
{
|
|
33
41
|
packageName: 'prettier',
|
|
34
42
|
binName: 'prettier',
|
|
35
43
|
scriptPath: join('prettier', 'bin', 'prettier.cjs'),
|
|
44
|
+
fixImport: false,
|
|
36
45
|
},
|
|
37
46
|
];
|
|
38
47
|
function createBinFileContents({ scriptPath }) {
|
|
@@ -47,6 +56,17 @@ async function fixTsBin(packageToFix) {
|
|
|
47
56
|
await rm(binFilePath, { force: true });
|
|
48
57
|
await writeFile(binFilePath, createBinFileContents(packageToFix));
|
|
49
58
|
await runShellCommand(`chmod +x ${interpolationSafeWindowsPath(binFilePath)}`);
|
|
59
|
+
await fixPackageJson(packageToFix);
|
|
50
60
|
log.success(`Fixed ${packageToFix.packageName} bin.`);
|
|
51
61
|
}
|
|
62
|
+
async function fixPackageJson(packageToFix) {
|
|
63
|
+
if (!packageToFix.fixImport) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const packageJsonPath = join(process.cwd(), 'node_modules', packageToFix.packageName, 'package.json');
|
|
67
|
+
const original = String(await readFile(packageJsonPath));
|
|
68
|
+
await writeFile(packageJsonPath, original
|
|
69
|
+
.replace('"main": "dist/index.js"', '"main": "src/index.ts"')
|
|
70
|
+
.replace('"module": "dist/index.js"', '"module": "src/index.ts"'));
|
|
71
|
+
}
|
|
52
72
|
await Promise.all(packagesToFix.map(async (packageToFix) => await fixTsBin(packageToFix)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@augment-vir/node",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.33.1",
|
|
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",
|
|
@@ -33,33 +33,32 @@
|
|
|
33
33
|
"types": "dist/index.d.ts",
|
|
34
34
|
"scripts": {
|
|
35
35
|
"compile": "virmator compile",
|
|
36
|
-
"test": "virmator --no-deps test node --test-concurrency
|
|
37
|
-
"test:coverage": "virmator test node coverage --test-concurrency
|
|
36
|
+
"test": "virmator --no-deps test node --test-concurrency=1",
|
|
37
|
+
"test:coverage": "virmator test node coverage --test-concurrency=1",
|
|
38
38
|
"test:update": "npm test"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@augment-vir/assert": "^31.
|
|
42
|
-
"@augment-vir/common": "^31.
|
|
43
|
-
"@date-vir/duration": "^7.4.
|
|
41
|
+
"@augment-vir/assert": "^31.33.1",
|
|
42
|
+
"@augment-vir/common": "^31.33.1",
|
|
43
|
+
"@date-vir/duration": "^7.4.2",
|
|
44
44
|
"ansi-styles": "^6.2.1",
|
|
45
45
|
"terminate": "^2.8.0",
|
|
46
|
-
"tsx": "^4.20.
|
|
46
|
+
"tsx": "^4.20.5",
|
|
47
47
|
"type-fest": "^4.41.0",
|
|
48
48
|
"typed-event-target": "^4.1.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@augment-vir/test": "^31.
|
|
52
|
-
"@prisma/client": "^6.
|
|
53
|
-
"@types/node": "^24.
|
|
51
|
+
"@augment-vir/test": "^31.33.1",
|
|
52
|
+
"@prisma/client": "^6.15.0",
|
|
53
|
+
"@types/node": "^24.3.0",
|
|
54
54
|
"@web/dev-server-esbuild": "^1.0.4",
|
|
55
55
|
"@web/test-runner": "^0.20.2",
|
|
56
56
|
"@web/test-runner-commands": "^0.9.0",
|
|
57
57
|
"@web/test-runner-playwright": "^0.11.1",
|
|
58
58
|
"@web/test-runner-visual-regression": "^0.10.0",
|
|
59
59
|
"c8": "^10.1.3",
|
|
60
|
-
"concurrently": "^9.2.0",
|
|
61
60
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
62
|
-
"prisma": "^6.
|
|
61
|
+
"prisma": "^6.15.0",
|
|
63
62
|
"typescript": "^5.9.2"
|
|
64
63
|
},
|
|
65
64
|
"peerDependencies": {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {type PartialWithUndefined} from '@augment-vir/common';
|
|
2
|
+
import {isAbsolute, normalize, relative, resolve, sep} from 'node:path';
|
|
3
|
+
import {isOperatingSystem, OperatingSystem} from '../os/operating-system.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Checks to see if a potential child path is inside of a potential parent path.
|
|
7
|
+
*
|
|
8
|
+
* @category Path : Node
|
|
9
|
+
* @category Package : @augment-vir/node
|
|
10
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
11
|
+
*/
|
|
12
|
+
export function doesPathContain(
|
|
13
|
+
potentialParentPath: string,
|
|
14
|
+
potentialChildPath: string,
|
|
15
|
+
options: PartialWithUndefined<{
|
|
16
|
+
/**
|
|
17
|
+
* Set this to `true` to return `true` if the paths are exactly equal.
|
|
18
|
+
*
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
allowSelf: boolean;
|
|
22
|
+
}> = {},
|
|
23
|
+
): boolean {
|
|
24
|
+
if (!potentialParentPath || !potentialChildPath) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const parent = normalizePath(potentialParentPath);
|
|
29
|
+
const child = normalizePath(potentialChildPath);
|
|
30
|
+
|
|
31
|
+
const relativePath = relative(parent, child);
|
|
32
|
+
|
|
33
|
+
if (!relativePath) {
|
|
34
|
+
/** Paths are identical. */
|
|
35
|
+
return !!options.allowSelf;
|
|
36
|
+
/* node:coverage ignore next 4: cannot test Windows specific behavior on all systems. */
|
|
37
|
+
} else if (isAbsolute(relativePath)) {
|
|
38
|
+
/** On Windows, paths on different drives yield an absolute relative path. */
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Contained if it does not traverse up out of parent. */
|
|
43
|
+
return relativePath !== '..' && !relativePath.startsWith('..' + sep);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function normalizePath(inputPath: string): string {
|
|
47
|
+
const absolutePath = normalize(resolve(inputPath));
|
|
48
|
+
|
|
49
|
+
/* node:coverage ignore next 1: cannot test Windows specific behavior on all systems. */
|
|
50
|
+
return isOperatingSystem(OperatingSystem.Windows) ? absolutePath.toLowerCase() : absolutePath;
|
|
51
|
+
}
|
package/src/augments/prisma.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from './augments/npm/query-workspace.js';
|
|
|
11
11
|
export * from './augments/npm/read-package-json.js';
|
|
12
12
|
export * from './augments/os/operating-system.js';
|
|
13
13
|
export * from './augments/path/ancestor.js';
|
|
14
|
+
export * from './augments/path/contains.js';
|
|
14
15
|
export * from './augments/path/os-path.js';
|
|
15
16
|
export * from './augments/path/resolve-import.js';
|
|
16
17
|
export * from './augments/path/root.js';
|
|
@@ -18,30 +18,40 @@
|
|
|
18
18
|
|
|
19
19
|
import {log} from '@augment-vir/common';
|
|
20
20
|
import {interpolationSafeWindowsPath, runShellCommand} from '@augment-vir/node';
|
|
21
|
-
import {rm, writeFile} from 'node:fs/promises';
|
|
21
|
+
import {readFile, rm, writeFile} from 'node:fs/promises';
|
|
22
22
|
import {join, sep} from 'node:path/posix';
|
|
23
23
|
|
|
24
24
|
type PackageToFix = {
|
|
25
25
|
packageName: string;
|
|
26
26
|
binName: string;
|
|
27
27
|
scriptPath: string;
|
|
28
|
+
fixImport: boolean;
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
const packagesToFix: ReadonlyArray<Readonly<PackageToFix>> = [
|
|
32
|
+
{
|
|
33
|
+
packageName: 'runstorm',
|
|
34
|
+
binName: 'runstorm',
|
|
35
|
+
scriptPath: join('runstorm', 'src', 'cli', 'cli.script.ts'),
|
|
36
|
+
fixImport: true,
|
|
37
|
+
},
|
|
31
38
|
{
|
|
32
39
|
packageName: 'mono-vir',
|
|
33
40
|
binName: 'mono-vir',
|
|
34
41
|
scriptPath: join('mono-vir', 'src', 'cli', 'cli.script.ts'),
|
|
42
|
+
fixImport: true,
|
|
35
43
|
},
|
|
36
44
|
{
|
|
37
45
|
packageName: 'virmator',
|
|
38
46
|
binName: 'virmator',
|
|
39
47
|
scriptPath: join('virmator', 'src', 'cli.script.ts'),
|
|
48
|
+
fixImport: true,
|
|
40
49
|
},
|
|
41
50
|
{
|
|
42
51
|
packageName: 'prettier',
|
|
43
52
|
binName: 'prettier',
|
|
44
53
|
scriptPath: join('prettier', 'bin', 'prettier.cjs'),
|
|
54
|
+
fixImport: false,
|
|
45
55
|
},
|
|
46
56
|
];
|
|
47
57
|
|
|
@@ -58,7 +68,28 @@ async function fixTsBin(packageToFix: Readonly<PackageToFix>) {
|
|
|
58
68
|
await rm(binFilePath, {force: true});
|
|
59
69
|
await writeFile(binFilePath, createBinFileContents(packageToFix));
|
|
60
70
|
await runShellCommand(`chmod +x ${interpolationSafeWindowsPath(binFilePath)}`);
|
|
71
|
+
await fixPackageJson(packageToFix);
|
|
61
72
|
log.success(`Fixed ${packageToFix.packageName} bin.`);
|
|
62
73
|
}
|
|
63
74
|
|
|
75
|
+
async function fixPackageJson(packageToFix: Readonly<PackageToFix>) {
|
|
76
|
+
if (!packageToFix.fixImport) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const packageJsonPath = join(
|
|
81
|
+
process.cwd(),
|
|
82
|
+
'node_modules',
|
|
83
|
+
packageToFix.packageName,
|
|
84
|
+
'package.json',
|
|
85
|
+
);
|
|
86
|
+
const original = String(await readFile(packageJsonPath));
|
|
87
|
+
await writeFile(
|
|
88
|
+
packageJsonPath,
|
|
89
|
+
original
|
|
90
|
+
.replace('"main": "dist/index.js"', '"main": "src/index.ts"')
|
|
91
|
+
.replace('"module": "dist/index.js"', '"module": "src/index.ts"'),
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
64
95
|
await Promise.all(packagesToFix.map(async (packageToFix) => await fixTsBin(packageToFix)));
|