@tanstack/cta-engine 0.17.5 → 0.20.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/dist/file-helpers.js
CHANGED
|
@@ -28,7 +28,7 @@ export function getBinaryFile(content) {
|
|
|
28
28
|
}
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
31
|
-
export function relativePath(from, to) {
|
|
31
|
+
export function relativePath(from, to, stripExtension = false) {
|
|
32
32
|
const fixedOnWindows = from.startsWith('.\\')
|
|
33
33
|
? from.replace(/\\/g, '/')
|
|
34
34
|
: from;
|
|
@@ -48,6 +48,9 @@ export function relativePath(from, to) {
|
|
|
48
48
|
}
|
|
49
49
|
const upLevels = fromSegments.length - commonIndex;
|
|
50
50
|
const downLevels = toSegments.slice(commonIndex);
|
|
51
|
+
if (stripExtension) {
|
|
52
|
+
to = to.replace(extname(to), '');
|
|
53
|
+
}
|
|
51
54
|
if (upLevels === 0 && downLevels.length === 0) {
|
|
52
55
|
return `./${basename(to)}`;
|
|
53
56
|
}
|
package/dist/template-file.js
CHANGED
|
@@ -60,7 +60,7 @@ export function createTemplateFile(environment, options) {
|
|
|
60
60
|
routes,
|
|
61
61
|
getPackageManagerAddScript,
|
|
62
62
|
getPackageManagerRunScript,
|
|
63
|
-
relativePath: (path) => relativePath(file, path),
|
|
63
|
+
relativePath: (path, stripExtension = false) => relativePath(file, path, stripExtension),
|
|
64
64
|
ignoreFile: () => {
|
|
65
65
|
throw new IgnoreFileError();
|
|
66
66
|
},
|
|
@@ -4,7 +4,7 @@ export declare function isBinaryFile(path: string): boolean;
|
|
|
4
4
|
export declare function convertBinaryContentsToBase64(contents: any): string;
|
|
5
5
|
export declare function isBase64(content: string): boolean;
|
|
6
6
|
export declare function getBinaryFile(content: string): string | null;
|
|
7
|
-
export declare function relativePath(from: string, to: string): string;
|
|
7
|
+
export declare function relativePath(from: string, to: string, stripExtension?: boolean): string;
|
|
8
8
|
export declare function isDirectory(path: string): boolean;
|
|
9
9
|
export declare function findFilesRecursively(path: string, files: Record<string, string>): void;
|
|
10
10
|
export declare function recursivelyGatherFiles(path: string, includeProjectFiles?: boolean): Promise<Record<string, string>>;
|
package/package.json
CHANGED
package/src/file-helpers.ts
CHANGED
|
@@ -36,7 +36,11 @@ export function getBinaryFile(content: string): string | null {
|
|
|
36
36
|
return null
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export function relativePath(
|
|
39
|
+
export function relativePath(
|
|
40
|
+
from: string,
|
|
41
|
+
to: string,
|
|
42
|
+
stripExtension: boolean = false,
|
|
43
|
+
) {
|
|
40
44
|
const fixedOnWindows = from.startsWith('.\\')
|
|
41
45
|
? from.replace(/\\/g, '/')
|
|
42
46
|
: from
|
|
@@ -63,6 +67,10 @@ export function relativePath(from: string, to: string) {
|
|
|
63
67
|
const upLevels = fromSegments.length - commonIndex
|
|
64
68
|
const downLevels = toSegments.slice(commonIndex)
|
|
65
69
|
|
|
70
|
+
if (stripExtension) {
|
|
71
|
+
to = to.replace(extname(to), '')
|
|
72
|
+
}
|
|
73
|
+
|
|
66
74
|
if (upLevels === 0 && downLevels.length === 0) {
|
|
67
75
|
return `./${basename(to)}`
|
|
68
76
|
} else if (upLevels === 0 && downLevels.length > 0) {
|
package/src/template-file.ts
CHANGED
|
@@ -92,7 +92,8 @@ export function createTemplateFile(environment: Environment, options: Options) {
|
|
|
92
92
|
getPackageManagerAddScript,
|
|
93
93
|
getPackageManagerRunScript,
|
|
94
94
|
|
|
95
|
-
relativePath: (path: string
|
|
95
|
+
relativePath: (path: string, stripExtension: boolean = false) =>
|
|
96
|
+
relativePath(file, path, stripExtension),
|
|
96
97
|
|
|
97
98
|
ignoreFile: () => {
|
|
98
99
|
throw new IgnoreFileError()
|
|
@@ -16,6 +16,9 @@ beforeEach(() => {
|
|
|
16
16
|
})
|
|
17
17
|
|
|
18
18
|
describe('relativePath', () => {
|
|
19
|
+
it('relative path with the same directory and strip extension', () => {
|
|
20
|
+
expect(relativePath('src/utils.ts', 'src/index.ts', true)).toBe('./index')
|
|
21
|
+
})
|
|
19
22
|
it('relative path with the same directory', () => {
|
|
20
23
|
expect(relativePath('src/utils.ts', 'src/index.ts')).toBe('./index.ts')
|
|
21
24
|
})
|