juisy 2.0.1 → 2.1.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/bin/cli/index.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/index.js +61 -11
- package/dist/templater/index.js +1 -1
- package/dist/utils/misc.d.ts +43 -1
- package/dist/vite/plugins/inject-css-variables/index.js +1 -1
- package/dist/vite/plugins/inject-project-globals/index.js +1 -1
- package/package.json +2 -2
package/bin/cli/index.js
CHANGED
package/dist/cli/index.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* juisy v2.0
|
|
2
|
+
* juisy v2.1.0
|
|
3
3
|
* Copyright © 2022-Present Hervé Perchec
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import path, { dirname } from 'node:path';
|
|
6
|
+
import path$1, { dirname } from 'node:path';
|
|
7
7
|
import { readdir, readFileSync } from 'node:fs';
|
|
8
8
|
import { glob } from 'glob';
|
|
9
9
|
import yaml from 'yaml';
|
|
@@ -24,7 +24,7 @@ function getFileUrls(pattern, options) {
|
|
|
24
24
|
async function* getFiles(dir) {
|
|
25
25
|
const dirents = await readdir(dir, { withFileTypes: true });
|
|
26
26
|
for (const dirent of dirents) {
|
|
27
|
-
const res = path.resolve(dir, dirent.name);
|
|
27
|
+
const res = path$1.resolve(dir, dirent.name);
|
|
28
28
|
if (dirent.isDirectory()) {
|
|
29
29
|
yield* getFiles(res);
|
|
30
30
|
} else {
|
|
@@ -32,11 +32,61 @@ async function* getFiles(dir) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
const path = {
|
|
36
|
+
/**
|
|
37
|
+
* Convert a path to win32 format (with `\\` separator)
|
|
38
|
+
* @param val - The path to convert
|
|
39
|
+
* @example
|
|
40
|
+
* utils.path.toWin32('a/posix/path') // => 'a\posix\path'
|
|
41
|
+
* utils.path.toWin32('C:\\a\\win32\\absolute\\path') // => 'C:\a\win32\absolute\path'
|
|
42
|
+
* utils.path.toWin32('a/mixed\\path') // => 'a\mixed\path'
|
|
43
|
+
*/
|
|
44
|
+
toWin32(val) {
|
|
45
|
+
return val.split(path$1.posix.sep).join(path$1.win32.sep);
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* Convert a path to posix format (with `/` separator)
|
|
49
|
+
* @param val - The path to convert
|
|
50
|
+
* @example
|
|
51
|
+
* utils.path.toPosix('a/posix/path') // => 'a/posix/path'
|
|
52
|
+
* utils.path.toPosix('C:\\a\\win32\\absolute\\path') // => 'C:/a/win32/absolute/path'
|
|
53
|
+
* utils.path.toPosix('a/mixed\\path') // => 'a/mixed/path'
|
|
54
|
+
*/
|
|
55
|
+
toPosix(val) {
|
|
56
|
+
return val.split(path$1.win32.sep).join(path$1.posix.sep);
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* Automatically convert a path to OS specific format
|
|
60
|
+
* @param val - The path to convert
|
|
61
|
+
*/
|
|
62
|
+
toOsFormat(val) {
|
|
63
|
+
const platform = process.platform;
|
|
64
|
+
return platform === "win32" ? path.toWin32(val) : path.toPosix(val);
|
|
65
|
+
},
|
|
66
|
+
/**
|
|
67
|
+
* Util to resolve relative file path to root directory
|
|
68
|
+
* @param from - The "from" absolute file path
|
|
69
|
+
* @param to - The "to" absolute file path
|
|
70
|
+
* @param separator - (Optional) The separator type: can be `"posix"` or `"win32"`
|
|
71
|
+
* @returns The resolved relative path to root directory
|
|
72
|
+
* @example
|
|
73
|
+
* const base = 'C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject'
|
|
74
|
+
*
|
|
75
|
+
* utils.path.resolveRel(base, 'C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject\\src\\index.ts') // 'src\\index.ts'
|
|
76
|
+
* utils.path.resolveRel('C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject\\src\\index.ts', base) // '..\\..'
|
|
77
|
+
* utils.path.resolveRel(base, 'C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject\\src\\index.ts', 'posix') // 'src/index.ts'
|
|
78
|
+
*/
|
|
79
|
+
resolveRel(from, to, separator) {
|
|
80
|
+
const relativePath = path$1.relative(from, to);
|
|
81
|
+
return separator ? separator === "posix" ? path.toPosix(relativePath) : path.toWin32(relativePath) : path.toOsFormat(relativePath);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
35
84
|
|
|
36
85
|
const misc = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
37
86
|
__proto__: null,
|
|
38
87
|
getFileUrls,
|
|
39
|
-
getFiles
|
|
88
|
+
getFiles,
|
|
89
|
+
path
|
|
40
90
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
41
91
|
|
|
42
92
|
const xml = jstoxml.toXML;
|
|
@@ -121,7 +171,7 @@ async function isFile(filePath) {
|
|
|
121
171
|
}
|
|
122
172
|
}
|
|
123
173
|
async function ejectFile(from, to, identifier = null, options) {
|
|
124
|
-
identifier = identifier || path.basename(from);
|
|
174
|
+
identifier = identifier || path$1.basename(from);
|
|
125
175
|
const force = options?.force || false;
|
|
126
176
|
const templateData = options?.templateData;
|
|
127
177
|
const processor = options?.processor || (async (str, _identifier) => str);
|
|
@@ -157,10 +207,10 @@ async function eject(templateDir, identifier, options) {
|
|
|
157
207
|
throw new Error("eject: identifier is required");
|
|
158
208
|
} else {
|
|
159
209
|
try {
|
|
160
|
-
const fullPath = path.resolve(templateDir, identifier);
|
|
210
|
+
const fullPath = path$1.resolve(templateDir, identifier);
|
|
161
211
|
if (await isFile(fullPath)) {
|
|
162
212
|
if (!ignoreFiles.includes(identifier)) {
|
|
163
|
-
await ejectFile(fullPath, path.resolve(targetDir, identifier), identifier, {
|
|
213
|
+
await ejectFile(fullPath, path$1.resolve(targetDir, identifier), identifier, {
|
|
164
214
|
force: options?.force,
|
|
165
215
|
templateData: options?.templateData,
|
|
166
216
|
processor: options?.processor,
|
|
@@ -171,9 +221,9 @@ async function eject(templateDir, identifier, options) {
|
|
|
171
221
|
} else {
|
|
172
222
|
const globPattern = await isDirectory(fullPath) ? identifier + "/**/*" : identifier;
|
|
173
223
|
for (const fileRelativePath of getFileUrls(globPattern, { cwd: templateDir, nodir: true, posix: true, dot: true })) {
|
|
174
|
-
const fullTemplateFilePath = path.resolve(templateDir, fileRelativePath);
|
|
224
|
+
const fullTemplateFilePath = path$1.resolve(templateDir, fileRelativePath);
|
|
175
225
|
if (!ignoreFiles.includes(fileRelativePath)) {
|
|
176
|
-
await ejectFile(fullTemplateFilePath, path.resolve(targetDir, fileRelativePath), fileRelativePath, {
|
|
226
|
+
await ejectFile(fullTemplateFilePath, path$1.resolve(targetDir, fileRelativePath), fileRelativePath, {
|
|
177
227
|
force: options?.force,
|
|
178
228
|
templateData: options?.templateData,
|
|
179
229
|
processor: options?.processor,
|
|
@@ -191,7 +241,7 @@ async function eject(templateDir, identifier, options) {
|
|
|
191
241
|
}
|
|
192
242
|
|
|
193
243
|
function getPackageInfo() {
|
|
194
|
-
const pkgPath = path.resolve(packageDirectorySync(), "./package.json");
|
|
244
|
+
const pkgPath = path$1.resolve(packageDirectorySync(), "./package.json");
|
|
195
245
|
return JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
196
246
|
}
|
|
197
247
|
|
|
@@ -247,7 +297,7 @@ function defineGlobals(config, builder) {
|
|
|
247
297
|
return deepmerge(GLOBALS, JSON.parse(JSON.stringify(builder(ctx))));
|
|
248
298
|
}
|
|
249
299
|
async function getProjectGlobals(filePath = "./project.globals.js") {
|
|
250
|
-
return (await import(pathToFileURL(path.resolve(filePath)))).default;
|
|
300
|
+
return (await import(pathToFileURL(path$1.resolve(filePath)))).default;
|
|
251
301
|
}
|
|
252
302
|
|
|
253
303
|
export { DataExporter, defineGlobals, eject, getPackageInfo, getProjectGlobals, misc as utils };
|
package/dist/templater/index.js
CHANGED
package/dist/utils/misc.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GlobOptions } from 'glob';
|
|
2
2
|
/**
|
|
3
3
|
* @param pattern - Same as node-glob pattern argument
|
|
4
|
-
* @param options - Same as
|
|
4
|
+
* @param options - Same as glob options argument
|
|
5
5
|
* @returns {string[]} Returns an array of file path
|
|
6
6
|
* @description
|
|
7
7
|
* Get file urls that match glob (see: https://github.com/isaacs/node-glob)
|
|
@@ -19,3 +19,45 @@ 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
|
+
* Utils related to path
|
|
24
|
+
*/
|
|
25
|
+
export declare const path: {
|
|
26
|
+
/**
|
|
27
|
+
* Convert a path to win32 format (with `\\` separator)
|
|
28
|
+
* @param val - The path to convert
|
|
29
|
+
* @example
|
|
30
|
+
* utils.path.toWin32('a/posix/path') // => 'a\posix\path'
|
|
31
|
+
* utils.path.toWin32('C:\\a\\win32\\absolute\\path') // => 'C:\a\win32\absolute\path'
|
|
32
|
+
* utils.path.toWin32('a/mixed\\path') // => 'a\mixed\path'
|
|
33
|
+
*/
|
|
34
|
+
toWin32(val: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Convert a path to posix format (with `/` separator)
|
|
37
|
+
* @param val - The path to convert
|
|
38
|
+
* @example
|
|
39
|
+
* utils.path.toPosix('a/posix/path') // => 'a/posix/path'
|
|
40
|
+
* utils.path.toPosix('C:\\a\\win32\\absolute\\path') // => 'C:/a/win32/absolute/path'
|
|
41
|
+
* utils.path.toPosix('a/mixed\\path') // => 'a/mixed/path'
|
|
42
|
+
*/
|
|
43
|
+
toPosix(val: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Automatically convert a path to OS specific format
|
|
46
|
+
* @param val - The path to convert
|
|
47
|
+
*/
|
|
48
|
+
toOsFormat(val: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Util to resolve relative file path to root directory
|
|
51
|
+
* @param from - The "from" absolute file path
|
|
52
|
+
* @param to - The "to" absolute file path
|
|
53
|
+
* @param separator - (Optional) The separator type: can be `"posix"` or `"win32"`
|
|
54
|
+
* @returns The resolved relative path to root directory
|
|
55
|
+
* @example
|
|
56
|
+
* const base = 'C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject'
|
|
57
|
+
*
|
|
58
|
+
* utils.path.resolveRel(base, 'C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject\\src\\index.ts') // 'src\\index.ts'
|
|
59
|
+
* utils.path.resolveRel('C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject\\src\\index.ts', base) // '..\\..'
|
|
60
|
+
* utils.path.resolveRel(base, 'C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject\\src\\index.ts', 'posix') // 'src/index.ts'
|
|
61
|
+
*/
|
|
62
|
+
resolveRel(from: string, to: string, separator?: "posix" | "win32"): string;
|
|
63
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "juisy",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Make you JavaScript (and/or TypeScript) project juicy!",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
},
|
|
93
93
|
"homepage": "https://hperchec.gitlab.io/juisy",
|
|
94
94
|
"bin": {
|
|
95
|
-
"juisy": "
|
|
95
|
+
"juisy": "bin/cli/index.js"
|
|
96
96
|
},
|
|
97
97
|
"peerDependencies": {
|
|
98
98
|
"@commitlint/cli": "^19.6.1",
|