juisy 2.1.0 → 2.2.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/cli/index.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* juisy v2.
|
|
2
|
+
* juisy v2.2.0
|
|
3
3
|
* Copyright © 2022-Present Hervé Perchec
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import path$1, { dirname } from 'node:path';
|
|
7
7
|
import { readdir, readFileSync } from 'node:fs';
|
|
8
8
|
import { glob } from 'glob';
|
|
9
|
+
import { packageDirectorySync } from 'pkg-dir';
|
|
9
10
|
import yaml from 'yaml';
|
|
10
11
|
import { json2csv } from 'json-2-csv';
|
|
11
12
|
import jstoxml from 'jstoxml';
|
|
12
13
|
import fs from 'fs-extra';
|
|
13
14
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
14
|
-
import { packageDirectorySync } from 'pkg-dir';
|
|
15
15
|
import log from 'loglevel';
|
|
16
16
|
import { Templater } from 'juisy/templater';
|
|
17
17
|
import dotenv from '@dotenvx/dotenvx';
|
|
@@ -32,6 +32,9 @@ async function* getFiles(dir) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
function getRootDir() {
|
|
36
|
+
return packageDirectorySync();
|
|
37
|
+
}
|
|
35
38
|
const path = {
|
|
36
39
|
/**
|
|
37
40
|
* Convert a path to win32 format (with `\\` separator)
|
|
@@ -64,11 +67,11 @@ const path = {
|
|
|
64
67
|
return platform === "win32" ? path.toWin32(val) : path.toPosix(val);
|
|
65
68
|
},
|
|
66
69
|
/**
|
|
67
|
-
* Util to resolve relative file path
|
|
70
|
+
* Util to resolve a relative file path
|
|
68
71
|
* @param from - The "from" absolute file path
|
|
69
72
|
* @param to - The "to" absolute file path
|
|
70
73
|
* @param separator - (Optional) The separator type: can be `"posix"` or `"win32"`
|
|
71
|
-
* @returns The resolved relative path
|
|
74
|
+
* @returns The resolved relative path
|
|
72
75
|
* @example
|
|
73
76
|
* const base = 'C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject'
|
|
74
77
|
*
|
|
@@ -79,6 +82,25 @@ const path = {
|
|
|
79
82
|
resolveRel(from, to, separator) {
|
|
80
83
|
const relativePath = path$1.relative(from, to);
|
|
81
84
|
return separator ? separator === "posix" ? path.toPosix(relativePath) : path.toWin32(relativePath) : path.toOsFormat(relativePath);
|
|
85
|
+
},
|
|
86
|
+
/**
|
|
87
|
+
* Util to resolve relative file path from root directory
|
|
88
|
+
* @param to - The absolute file path
|
|
89
|
+
* @param separator - (Optional) The separator type: can be `"posix"` or `"win32"`
|
|
90
|
+
* @returns The resolved relative path from root directory
|
|
91
|
+
*/
|
|
92
|
+
resolveRelFromRoot(to, separator) {
|
|
93
|
+
return path.resolveRel(getRootDir(), to, separator);
|
|
94
|
+
},
|
|
95
|
+
/**
|
|
96
|
+
* Util to resolve absolute file path from root directory
|
|
97
|
+
* @param to - The relative file path
|
|
98
|
+
* @param separator - (Optional) The separator type: can be `"posix"` or `"win32"`
|
|
99
|
+
* @returns The resolved absolute path from root directory
|
|
100
|
+
*/
|
|
101
|
+
resolveAbsFromRoot(to, separator) {
|
|
102
|
+
const absolutePath = path$1.join(getRootDir(), to);
|
|
103
|
+
return separator ? separator === "posix" ? path.toPosix(absolutePath) : path.toWin32(absolutePath) : path.toOsFormat(absolutePath);
|
|
82
104
|
}
|
|
83
105
|
};
|
|
84
106
|
|
|
@@ -86,6 +108,7 @@ const misc = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
86
108
|
__proto__: null,
|
|
87
109
|
getFileUrls,
|
|
88
110
|
getFiles,
|
|
111
|
+
getRootDir,
|
|
89
112
|
path
|
|
90
113
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
91
114
|
|
package/dist/templater/index.js
CHANGED
package/dist/utils/misc.d.ts
CHANGED
|
@@ -19,6 +19,13 @@ export declare function getFileUrls(pattern: string, options?: GlobOptions): str
|
|
|
19
19
|
* utils.getFiles(path) // => [ 'path/to/file1', 'path/to/file2', ... ]
|
|
20
20
|
*/
|
|
21
21
|
export declare function getFiles(dir: string): AsyncGenerator<string[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Synchronously find the root directory of the project in which juisy is installed.
|
|
24
|
+
*
|
|
25
|
+
* It is just a wrapper around the `packageDirectorySync` function
|
|
26
|
+
* from [pkg-dir](https://www.npmjs.com/package/pkg-dir) library.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getRootDir(): string | undefined;
|
|
22
29
|
/**
|
|
23
30
|
* Utils related to path
|
|
24
31
|
*/
|
|
@@ -47,11 +54,11 @@ export declare const path: {
|
|
|
47
54
|
*/
|
|
48
55
|
toOsFormat(val: string): string;
|
|
49
56
|
/**
|
|
50
|
-
* Util to resolve relative file path
|
|
57
|
+
* Util to resolve a relative file path
|
|
51
58
|
* @param from - The "from" absolute file path
|
|
52
59
|
* @param to - The "to" absolute file path
|
|
53
60
|
* @param separator - (Optional) The separator type: can be `"posix"` or `"win32"`
|
|
54
|
-
* @returns The resolved relative path
|
|
61
|
+
* @returns The resolved relative path
|
|
55
62
|
* @example
|
|
56
63
|
* const base = 'C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject'
|
|
57
64
|
*
|
|
@@ -60,4 +67,18 @@ export declare const path: {
|
|
|
60
67
|
* utils.path.resolveRel(base, 'C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject\\src\\index.ts', 'posix') // 'src/index.ts'
|
|
61
68
|
*/
|
|
62
69
|
resolveRel(from: string, to: string, separator?: "posix" | "win32"): string;
|
|
70
|
+
/**
|
|
71
|
+
* Util to resolve relative file path from root directory
|
|
72
|
+
* @param to - The absolute file path
|
|
73
|
+
* @param separator - (Optional) The separator type: can be `"posix"` or `"win32"`
|
|
74
|
+
* @returns The resolved relative path from root directory
|
|
75
|
+
*/
|
|
76
|
+
resolveRelFromRoot(to: string, separator?: "posix" | "win32"): string;
|
|
77
|
+
/**
|
|
78
|
+
* Util to resolve absolute file path from root directory
|
|
79
|
+
* @param to - The relative file path
|
|
80
|
+
* @param separator - (Optional) The separator type: can be `"posix"` or `"win32"`
|
|
81
|
+
* @returns The resolved absolute path from root directory
|
|
82
|
+
*/
|
|
83
|
+
resolveAbsFromRoot(to: string, separator?: "posix" | "win32"): string;
|
|
63
84
|
};
|