juisy 2.3.0 → 3.0.0-beta.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/README.md +85 -0
- package/bin/cli/cli.js +3 -14
- package/bin/cli/cmds/index.js +0 -4
- package/bin/cli/index.js +0 -1
- package/bin/scripts/prepare.js +1 -1
- package/dist/DataExporter.d.ts +8 -4
- package/dist/bootstrap.d.ts +6 -1
- package/dist/bootstrap.js +21 -0
- package/dist/cli/GlobalSettings.schema.json +1 -1
- package/dist/cli/InterfaceUtils.d.ts +4 -4
- package/dist/cli/index.js +27 -19
- package/dist/cli/plugins/command-meta/augment.d.ts +1 -1
- package/dist/cli/plugins/default-command-fallbacks/augment.d.ts +1 -1
- package/dist/cli/plugins/load-env-file/augment.d.ts +1 -1
- package/dist/cli/types.d.ts +2 -1
- package/dist/extensions.d.ts +26 -0
- package/dist/extensions.js +44 -0
- package/dist/index.d.ts +1 -5
- package/dist/index.js +20 -281
- package/dist/project-globals.d.ts +4 -2
- package/dist/templater/index.js +5 -2
- package/dist/templater/markdown-templater/ReadmeTemplater.d.ts +4 -2
- package/package.json +20 -36
- package/bin/cli/cmds/public/AddExt.js +0 -49
- package/bin/cli/cmds/public/RemoveExt.js +0 -49
- package/bin/cli/init.js +0 -1
- package/bin/cli/lib/index.js +0 -71
- package/dist/utils/misc.d.ts +0 -145
package/dist/index.js
CHANGED
|
@@ -1,266 +1,23 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* juisy
|
|
2
|
+
* juisy v3.0.0-beta.1
|
|
3
3
|
* Copyright © 2022-Present Hervé Perchec
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import path$1, { dirname } from 'node:path';
|
|
7
|
-
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
8
|
-
import fs from 'fs-extra';
|
|
9
|
-
import { CLIFactory } from 'juisy/cli';
|
|
10
|
-
import { readdir } from 'node:fs/promises';
|
|
11
|
-
import { readdirSync, readFileSync } from 'node:fs';
|
|
12
|
-
import { glob } from 'glob';
|
|
13
|
-
import { packageDirectorySync } from 'pkg-dir';
|
|
14
6
|
import yaml from 'yaml';
|
|
15
7
|
import { json2csv } from 'json-2-csv';
|
|
16
8
|
import jstoxml from 'jstoxml';
|
|
9
|
+
import fs from 'fs-extra';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { packageDirectorySync } from 'pkg-dir';
|
|
17
12
|
import log from 'loglevel';
|
|
18
13
|
import { Templater } from 'juisy/templater';
|
|
14
|
+
import getFileUrls from '@juisy/utils/fs/get-file-urls';
|
|
15
|
+
import isFile from '@juisy/utils/fs/is-file';
|
|
16
|
+
import isDirectory from '@juisy/utils/fs/is-directory';
|
|
17
|
+
import { readFileSync } from 'node:fs';
|
|
18
|
+
import { pathToFileURL } from 'node:url';
|
|
19
19
|
import dotenv from '@dotenvx/dotenvx';
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
-
// export const DEFAULT_EXT_CACHE_PATH = './node_modules/.cache/juisy/extensions.json'
|
|
23
|
-
const DEFAULT_EXT_CACHE_PATH = './package.json';
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Get the extensions locally added to juisy
|
|
27
|
-
* @param {string} extCachePath - The path to extensions cache file
|
|
28
|
-
* @returns {string[]} The extension names
|
|
29
|
-
*/
|
|
30
|
-
function getExtensions (extCachePath = DEFAULT_EXT_CACHE_PATH) {
|
|
31
|
-
const absolutePath = path$1.isAbsolute(extCachePath)
|
|
32
|
-
? extCachePath
|
|
33
|
-
: path$1.resolve(extCachePath);
|
|
34
|
-
|
|
35
|
-
// // If default, ensure file exists
|
|
36
|
-
// if (extCachePath === DEFAULT_EXT_CACHE_PATH
|
|
37
|
-
// && fs.existsSync(path.resolve('./node_modules'))
|
|
38
|
-
// && !fs.existsSync(absolutePath)
|
|
39
|
-
// ) {
|
|
40
|
-
// fs.outputFileSync(absolutePath, '[]')
|
|
41
|
-
// }
|
|
42
|
-
|
|
43
|
-
const content = fs.readFileSync(absolutePath, 'utf-8');
|
|
44
|
-
const extensionIds = JSON.parse(content).juisy?.extensions || [];
|
|
45
|
-
return extensionIds
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Load an extension
|
|
50
|
-
* @param {string} id - The module name or relative/absolute path
|
|
51
|
-
*/
|
|
52
|
-
async function loadExtension (id) {
|
|
53
|
-
// Module name or full path
|
|
54
|
-
const modPath = id.startsWith('.') // is relative?
|
|
55
|
-
? path$1.resolve(id) // relative to process.cwd()
|
|
56
|
-
: id; // can be module name or absolute path
|
|
57
|
-
|
|
58
|
-
const mod = await import(path$1.isAbsolute(modPath)
|
|
59
|
-
? pathToFileURL(modPath).toString()
|
|
60
|
-
: id);
|
|
61
|
-
|
|
62
|
-
return mod.extension || mod.default
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Load the extensions
|
|
67
|
-
* @param {?string} extCachePath - The path to extensions cache file
|
|
68
|
-
*/
|
|
69
|
-
async function loadExtensions (extCachePath) {
|
|
70
|
-
// Get extension identifiers
|
|
71
|
-
const extensionIds = getExtensions(extCachePath);
|
|
72
|
-
|
|
73
|
-
const extensions = [];
|
|
74
|
-
|
|
75
|
-
for (const id of extensionIds) {
|
|
76
|
-
const loaded = {
|
|
77
|
-
id,
|
|
78
|
-
extension: await loadExtension(id)
|
|
79
|
-
};
|
|
80
|
-
extensions.push(loaded);
|
|
81
|
-
//
|
|
82
|
-
if (loaded.extension.juisyBin) {
|
|
83
|
-
loaded.extension.juisyBin(CLIFactory);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return extensions
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
let isAlreadyBootstraped = false;
|
|
91
|
-
async function bootstrap(importMeta) {
|
|
92
|
-
await loadExtensions();
|
|
93
|
-
console.log("importMeta.url:", importMeta.url);
|
|
94
|
-
console.log("isAlreadyBootstraped ? ", isAlreadyBootstraped);
|
|
95
|
-
isAlreadyBootstraped = true;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function getFileUrls(pattern, options) {
|
|
99
|
-
const files = glob.sync(pattern, options || {});
|
|
100
|
-
return files;
|
|
101
|
-
}
|
|
102
|
-
async function* getFiles(dir) {
|
|
103
|
-
const dirents = await readdir(dir, { withFileTypes: true });
|
|
104
|
-
for (const dirent of dirents) {
|
|
105
|
-
const res = path$1.resolve(dir, dirent.name);
|
|
106
|
-
if (dirent.isDirectory()) {
|
|
107
|
-
yield* getFiles(res);
|
|
108
|
-
} else {
|
|
109
|
-
yield res;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
function getFilesSync(dir) {
|
|
114
|
-
const files = [];
|
|
115
|
-
const dirents = readdirSync(dir, { withFileTypes: true });
|
|
116
|
-
for (const dirent of dirents) {
|
|
117
|
-
const res = path$1.resolve(dir, dirent.name);
|
|
118
|
-
if (dirent.isDirectory()) {
|
|
119
|
-
files.push(...getFilesSync(res));
|
|
120
|
-
} else {
|
|
121
|
-
files.push(res);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return files;
|
|
125
|
-
}
|
|
126
|
-
function getRootDir() {
|
|
127
|
-
return packageDirectorySync();
|
|
128
|
-
}
|
|
129
|
-
const path = {
|
|
130
|
-
/**
|
|
131
|
-
* Convert a path to win32 format (with `\\` separator)
|
|
132
|
-
* @param val - The path to convert
|
|
133
|
-
* @example
|
|
134
|
-
* utils.path.toWin32('a/posix/path') // => 'a\posix\path'
|
|
135
|
-
* utils.path.toWin32('C:\\a\\win32\\absolute\\path') // => 'C:\a\win32\absolute\path'
|
|
136
|
-
* utils.path.toWin32('a/mixed\\path') // => 'a\mixed\path'
|
|
137
|
-
*/
|
|
138
|
-
toWin32(val) {
|
|
139
|
-
return val.split(path$1.posix.sep).join(path$1.win32.sep);
|
|
140
|
-
},
|
|
141
|
-
/**
|
|
142
|
-
* Convert a path to posix format (with `/` separator)
|
|
143
|
-
* @param val - The path to convert
|
|
144
|
-
* @example
|
|
145
|
-
* utils.path.toPosix('a/posix/path') // => 'a/posix/path'
|
|
146
|
-
* utils.path.toPosix('C:\\a\\win32\\absolute\\path') // => 'C:/a/win32/absolute/path'
|
|
147
|
-
* utils.path.toPosix('a/mixed\\path') // => 'a/mixed/path'
|
|
148
|
-
*/
|
|
149
|
-
toPosix(val) {
|
|
150
|
-
return val.split(path$1.win32.sep).join(path$1.posix.sep);
|
|
151
|
-
},
|
|
152
|
-
/**
|
|
153
|
-
* Automatically convert a path to OS specific format
|
|
154
|
-
* @param val - The path to convert
|
|
155
|
-
*/
|
|
156
|
-
toOsFormat(val) {
|
|
157
|
-
const platform = process.platform;
|
|
158
|
-
return platform === "win32" ? path.toWin32(val) : path.toPosix(val);
|
|
159
|
-
},
|
|
160
|
-
/**
|
|
161
|
-
* Check if the given path is win32 format
|
|
162
|
-
* @param val - The path to check
|
|
163
|
-
* @example
|
|
164
|
-
* utils.path.isWin32('a/posix/path') // => false
|
|
165
|
-
* utils.path.isWin32('C:\\a\\win32\\absolute\\path') // => true
|
|
166
|
-
* utils.path.isWin32('a/mixed\\path') // => true
|
|
167
|
-
*/
|
|
168
|
-
isWin32(val) {
|
|
169
|
-
return /^[a-zA-Z]:/.test(val) || val.includes("\\");
|
|
170
|
-
},
|
|
171
|
-
/**
|
|
172
|
-
* Check if the given path is posix format
|
|
173
|
-
* @param val - The path to check
|
|
174
|
-
* @example
|
|
175
|
-
* utils.path.isPosix('a/posix/path') // => true
|
|
176
|
-
* utils.path.isPosix('C:\\a\\win32\\absolute\\path') // => false
|
|
177
|
-
* utils.path.isPosix('a/mixed\\path') // => false
|
|
178
|
-
*/
|
|
179
|
-
isPosix(val) {
|
|
180
|
-
return !path.isWin32(val);
|
|
181
|
-
},
|
|
182
|
-
/**
|
|
183
|
-
* Normalize a path depending on base format
|
|
184
|
-
* @param val - The path to normalize
|
|
185
|
-
* @example
|
|
186
|
-
* utils.path.normalize('a/Posix/path') // => 'a/Posix/path'
|
|
187
|
-
* utils.path.normalize('C:\\a\\Win32\\Absolute\\path\\') // => 'c:\a\win32\absolute\path'
|
|
188
|
-
* utils.path.normalize('a/Mixed\\Path') // => 'a\mixed\path'
|
|
189
|
-
*/
|
|
190
|
-
normalize(val) {
|
|
191
|
-
let normalized;
|
|
192
|
-
if (path.isWin32(val)) {
|
|
193
|
-
normalized = path$1.win32.normalize(val).toLowerCase();
|
|
194
|
-
} else {
|
|
195
|
-
normalized = path$1.posix.normalize(val);
|
|
196
|
-
}
|
|
197
|
-
if ((normalized.endsWith("/") || normalized.endsWith("\\")) && normalized.length > 1) {
|
|
198
|
-
normalized = normalized.slice(0, -1);
|
|
199
|
-
}
|
|
200
|
-
return normalized;
|
|
201
|
-
},
|
|
202
|
-
/**
|
|
203
|
-
* Util to resolve a relative file path
|
|
204
|
-
* @param from - The "from" absolute file path
|
|
205
|
-
* @param to - The "to" absolute file path
|
|
206
|
-
* @param separator - (Optional) The separator type: can be `"posix"` or `"win32"`
|
|
207
|
-
* @returns The resolved relative path
|
|
208
|
-
* @example
|
|
209
|
-
* const base = 'C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject'
|
|
210
|
-
*
|
|
211
|
-
* utils.path.resolveRel(base, 'C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject\\src\\index.ts') // 'src\\index.ts'
|
|
212
|
-
* utils.path.resolveRel('C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject\\src\\index.ts', base) // '..\\..'
|
|
213
|
-
* utils.path.resolveRel(base, 'C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject\\src\\index.ts', 'posix') // 'src/index.ts'
|
|
214
|
-
*/
|
|
215
|
-
resolveRel(from, to, separator) {
|
|
216
|
-
const relativePath = path$1.relative(from, to);
|
|
217
|
-
return separator ? separator === "posix" ? path.toPosix(relativePath) : path.toWin32(relativePath) : path.toOsFormat(relativePath);
|
|
218
|
-
},
|
|
219
|
-
/**
|
|
220
|
-
* Util to resolve relative file path from root directory
|
|
221
|
-
* @param to - The absolute file path
|
|
222
|
-
* @param separator - (Optional) The separator type: can be `"posix"` or `"win32"`
|
|
223
|
-
* @returns The resolved relative path from root directory
|
|
224
|
-
*/
|
|
225
|
-
resolveRelFromRoot(to, separator) {
|
|
226
|
-
return path.resolveRel(getRootDir(), to, separator);
|
|
227
|
-
},
|
|
228
|
-
/**
|
|
229
|
-
* Util to resolve absolute file path from root directory
|
|
230
|
-
* @param to - The relative file path
|
|
231
|
-
* @param separator - (Optional) The separator type: can be `"posix"` or `"win32"`
|
|
232
|
-
* @returns The resolved absolute path from root directory
|
|
233
|
-
*/
|
|
234
|
-
resolveAbsFromRoot(to, separator) {
|
|
235
|
-
const absolutePath = path$1.join(getRootDir(), to);
|
|
236
|
-
return separator ? separator === "posix" ? path.toPosix(absolutePath) : path.toWin32(absolutePath) : path.toOsFormat(absolutePath);
|
|
237
|
-
},
|
|
238
|
-
/**
|
|
239
|
-
* Util function to compare two file paths
|
|
240
|
-
* @param a - The first file path to compare
|
|
241
|
-
* @param b - The second file path to compare
|
|
242
|
-
* @returns True if the two paths are the same
|
|
243
|
-
* @example
|
|
244
|
-
* utils.path.isSameAs('src/index.ts', 'src\\index.ts') // true
|
|
245
|
-
* utils.path.isSameAs('../src/index.ts', '..\\src\\index.ts') // true
|
|
246
|
-
* utils.path.isSameAs('C:\\a\\Win32\\Absolute\\path\\', 'c:/a/Win32/Absolute/path') // true
|
|
247
|
-
* utils.path.isSameAs('C:\\a\\Win32\\Absolute\\path\\', '/a/Win32/Absolute/path')// false
|
|
248
|
-
* utils.path.isSameAs('/a/posix/absolute/path', '/a/posix/absolute/path/../../absolute/path') // true
|
|
249
|
-
* utils.path.isSameAs('/a/posix/absolute/path', '/a/Posix/Absolute/path') // false
|
|
250
|
-
*/
|
|
251
|
-
isSameAs(a, b) {
|
|
252
|
-
return path.normalize(path.toPosix(a)) === path.normalize(path.toPosix(b));
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
const misc = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
257
|
-
__proto__: null,
|
|
258
|
-
getFileUrls,
|
|
259
|
-
getFiles,
|
|
260
|
-
getFilesSync,
|
|
261
|
-
getRootDir,
|
|
262
|
-
path
|
|
263
|
-
}, Symbol.toStringTag, { value: 'Module' }));
|
|
20
|
+
import deepMerge from '@juisy/utils/object/deep-merge';
|
|
264
21
|
|
|
265
22
|
const xml = jstoxml.toXML;
|
|
266
23
|
const SUPPORTED_FORMATS = [
|
|
@@ -301,6 +58,7 @@ class DataExporter {
|
|
|
301
58
|
throw new Error(`DataConverter: Unsupported "${format}" format`);
|
|
302
59
|
}
|
|
303
60
|
}
|
|
61
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
304
62
|
exportSync(data, options) {
|
|
305
63
|
switch (this.format) {
|
|
306
64
|
case "json":
|
|
@@ -320,31 +78,13 @@ class DataExporter {
|
|
|
320
78
|
}
|
|
321
79
|
}
|
|
322
80
|
|
|
323
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
324
|
-
dirname(__filename);
|
|
325
81
|
const templater = new Templater("ejs", {
|
|
326
82
|
engineOptions: {
|
|
327
83
|
// ...
|
|
328
84
|
}
|
|
329
85
|
});
|
|
330
|
-
async function isDirectory(filePath) {
|
|
331
|
-
try {
|
|
332
|
-
const stats = await fs.stat(filePath);
|
|
333
|
-
return stats.isDirectory();
|
|
334
|
-
} catch (err) {
|
|
335
|
-
return false;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
async function isFile(filePath) {
|
|
339
|
-
try {
|
|
340
|
-
const stats = await fs.stat(filePath);
|
|
341
|
-
return stats.isFile();
|
|
342
|
-
} catch (err) {
|
|
343
|
-
return false;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
86
|
async function ejectFile(from, to, identifier = null, options) {
|
|
347
|
-
identifier = identifier || path
|
|
87
|
+
identifier = identifier || path.basename(from);
|
|
348
88
|
const force = options?.force || false;
|
|
349
89
|
const templateData = options?.templateData;
|
|
350
90
|
const processor = options?.processor || (async (str, _identifier) => str);
|
|
@@ -383,10 +123,10 @@ async function eject(templateDir, identifier, options) {
|
|
|
383
123
|
throw new Error("eject: identifier is required");
|
|
384
124
|
} else {
|
|
385
125
|
try {
|
|
386
|
-
const fullPath = path
|
|
126
|
+
const fullPath = path.resolve(templateDir, identifier);
|
|
387
127
|
if (await isFile(fullPath)) {
|
|
388
128
|
if (!ignoreFiles.includes(identifier)) {
|
|
389
|
-
await ejectFile(fullPath, path
|
|
129
|
+
await ejectFile(fullPath, path.resolve(targetDir, identifier), identifier, {
|
|
390
130
|
force: options?.force,
|
|
391
131
|
templateData: options?.templateData,
|
|
392
132
|
processor: options?.processor,
|
|
@@ -397,9 +137,9 @@ async function eject(templateDir, identifier, options) {
|
|
|
397
137
|
} else {
|
|
398
138
|
const globPattern = await isDirectory(fullPath) ? identifier + "/**/*" : identifier;
|
|
399
139
|
for (const fileRelativePath of getFileUrls(globPattern, { cwd: templateDir, nodir: true, posix: true, dot: true })) {
|
|
400
|
-
const fullTemplateFilePath = path
|
|
140
|
+
const fullTemplateFilePath = path.resolve(templateDir, fileRelativePath);
|
|
401
141
|
if (!ignoreFiles.includes(fileRelativePath)) {
|
|
402
|
-
await ejectFile(fullTemplateFilePath, path
|
|
142
|
+
await ejectFile(fullTemplateFilePath, path.resolve(targetDir, fileRelativePath), fileRelativePath, {
|
|
403
143
|
force: options?.force,
|
|
404
144
|
templateData: options?.templateData,
|
|
405
145
|
processor: options?.processor,
|
|
@@ -417,7 +157,7 @@ async function eject(templateDir, identifier, options) {
|
|
|
417
157
|
}
|
|
418
158
|
|
|
419
159
|
function getPackageInfo() {
|
|
420
|
-
const pkgPath = path
|
|
160
|
+
const pkgPath = path.resolve(packageDirectorySync(), "./package.json");
|
|
421
161
|
return JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
422
162
|
}
|
|
423
163
|
|
|
@@ -470,13 +210,12 @@ function defineGlobals(config, builder) {
|
|
|
470
210
|
env,
|
|
471
211
|
pkg
|
|
472
212
|
};
|
|
473
|
-
return
|
|
213
|
+
return deepMerge(GLOBALS, JSON.parse(JSON.stringify(builder(ctx))));
|
|
474
214
|
}
|
|
475
215
|
async function getProjectGlobals(filePath = "./project.globals.js") {
|
|
476
|
-
return (await import(pathToFileURL(path
|
|
216
|
+
return (await import(pathToFileURL(path.resolve(filePath)))).default;
|
|
477
217
|
}
|
|
478
218
|
|
|
479
|
-
bootstrap(import.meta);
|
|
480
219
|
const index = {};
|
|
481
220
|
|
|
482
|
-
export { DataExporter, index as default, defineGlobals, eject, getPackageInfo, getProjectGlobals
|
|
221
|
+
export { DataExporter, index as default, defineGlobals, eject, getPackageInfo, getProjectGlobals };
|
|
@@ -29,7 +29,8 @@ export type DotenvOptions = Omit<DotenvConfigOptions, 'processEnv'>;
|
|
|
29
29
|
/**
|
|
30
30
|
* @group Types
|
|
31
31
|
*/
|
|
32
|
-
export type DefineGlobalsBuilder<T extends Record<string, any>> = (
|
|
32
|
+
export type DefineGlobalsBuilder<T extends Record<string, any>> = (// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
33
|
+
ctx: {
|
|
33
34
|
env: NodeJS.ProcessEnv;
|
|
34
35
|
pkg: PackageJson;
|
|
35
36
|
}) => T;
|
|
@@ -40,7 +41,8 @@ export type DefineGlobalsBuilder<T extends Record<string, any>> = (ctx: {
|
|
|
40
41
|
* @returns The computed globals object
|
|
41
42
|
* @group None
|
|
42
43
|
*/
|
|
43
|
-
export declare function defineGlobals<CustomGlobals extends Record<string, any>>(
|
|
44
|
+
export declare function defineGlobals<CustomGlobals extends Record<string, any>>(// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
45
|
+
config: {
|
|
44
46
|
env?: {
|
|
45
47
|
map?: string[];
|
|
46
48
|
dotenvOptions?: DotenvOptions;
|
package/dist/templater/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* juisy
|
|
2
|
+
* juisy v3.0.0-beta.1
|
|
3
3
|
* Copyright © 2022-Present Hervé Perchec
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -48,6 +48,9 @@ class Templater {
|
|
|
48
48
|
);
|
|
49
49
|
};
|
|
50
50
|
break;
|
|
51
|
+
/**
|
|
52
|
+
* @todo ? pug not yet supported
|
|
53
|
+
*/
|
|
51
54
|
case "pug":
|
|
52
55
|
this.engine = (template, options2) => () => "";
|
|
53
56
|
break;
|
|
@@ -61,6 +64,7 @@ class Templater {
|
|
|
61
64
|
engine;
|
|
62
65
|
defaultData;
|
|
63
66
|
methodsMap = {};
|
|
67
|
+
// eslint-disable-line @typescript-eslint/no-unsafe-function-type
|
|
64
68
|
/**
|
|
65
69
|
* @returns Get the engine
|
|
66
70
|
*/
|
|
@@ -188,7 +192,6 @@ class ReadmeTemplater {
|
|
|
188
192
|
/**
|
|
189
193
|
* Render README markdown
|
|
190
194
|
* @param options - Options object
|
|
191
|
-
* @param options.data - Additionnal data object to merge with default EJS data
|
|
192
195
|
* @returns Returns the rendered markdown as string. Promise is immediately resolved except if a module is async.
|
|
193
196
|
* @example
|
|
194
197
|
* await templater.render()
|
|
@@ -23,7 +23,7 @@ export type Configuration = {
|
|
|
23
23
|
*/
|
|
24
24
|
ejsDataPath: string;
|
|
25
25
|
/**
|
|
26
|
-
* EJS options: see also {@link https://www.npmjs.com/package/ejs#options EJS documentation}.
|
|
26
|
+
* EJS options: see also {@link https://www.npmjs.com/package/ejs#options "EJS documentation"}.
|
|
27
27
|
* @property {string[]} [ejsOptions.root] - The path of template folder is automatically included.
|
|
28
28
|
* @property {string[]} [ejsOptions.views] - The path of template folder and the path of internal partials are automatically included.
|
|
29
29
|
*/
|
|
@@ -81,13 +81,15 @@ export declare class ReadmeTemplater {
|
|
|
81
81
|
/**
|
|
82
82
|
* Render README markdown
|
|
83
83
|
* @param options - Options object
|
|
84
|
-
* @param options.data - Additionnal data object to merge with default EJS data
|
|
85
84
|
* @returns Returns the rendered markdown as string. Promise is immediately resolved except if a module is async.
|
|
86
85
|
* @example
|
|
87
86
|
* await templater.render()
|
|
88
87
|
* await templater.render({ data: { foo: 'bar' } })
|
|
89
88
|
*/
|
|
90
89
|
render(options?: {
|
|
90
|
+
/**
|
|
91
|
+
* Additionnal data object to merge with default EJS data
|
|
92
|
+
*/
|
|
91
93
|
data?: Record<any, any>;
|
|
92
94
|
}): Promise<string>;
|
|
93
95
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "juisy",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.1",
|
|
4
4
|
"description": "Make your JavaScript (and/or TypeScript) project juicy!",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -90,14 +90,13 @@
|
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"@github/markdownlint-github": "^0.6.3",
|
|
93
|
-
"@
|
|
94
|
-
"@types/yargs-parser": "^21.0.3",
|
|
93
|
+
"@juisy/utils": "3.0.0-beta.1",
|
|
95
94
|
"conventional-changelog-cli": "^5.0.0",
|
|
96
95
|
"eslint": "^9",
|
|
97
96
|
"lint-staged": "^14.0.1",
|
|
98
97
|
"markdownlint-cli2": "^0.12.0",
|
|
99
98
|
"markdownlint-cli2-formatter-pretty": "^0.0.7",
|
|
100
|
-
"release-it": "^
|
|
99
|
+
"release-it": "^20",
|
|
101
100
|
"simple-git-hooks": "^2.9.0",
|
|
102
101
|
"yargs": "^17.7.2"
|
|
103
102
|
},
|
|
@@ -113,66 +112,49 @@
|
|
|
113
112
|
}
|
|
114
113
|
},
|
|
115
114
|
"devDependencies": {
|
|
116
|
-
"@babel/eslint-parser": "^7.25.9",
|
|
117
115
|
"@conventional-changelog/git-client": "^1.0.1",
|
|
118
116
|
"@types/conventional-changelog": "^3.1.5",
|
|
119
117
|
"@types/conventional-changelog-config-spec": "^2.1.5",
|
|
120
118
|
"@types/ejs": "^3.1.5",
|
|
121
119
|
"@types/fs-extra": "^11.0.4",
|
|
122
120
|
"@types/lint-staged": "^13.3.0",
|
|
123
|
-
"@types/lodash.get": "^4.4.9",
|
|
124
|
-
"@types/lodash.kebabcase": "^4.1.9",
|
|
125
121
|
"@types/lodash.merge": "^4.6.9",
|
|
126
|
-
"@types/lodash.set": "^4.3.9",
|
|
127
122
|
"@types/node": "^22.10.2",
|
|
128
123
|
"@types/prompts": "^2.4.9",
|
|
129
124
|
"@types/semver": "^7.5.8",
|
|
130
125
|
"@types/yargs": "^17.0.33",
|
|
131
126
|
"@types/yargs-parser": "^21.0.3",
|
|
132
|
-
"@typescript-eslint/eslint-plugin": "^8.18.1",
|
|
133
|
-
"cpy-cli": "^5.0.0",
|
|
134
|
-
"eslint": "^9.17.0",
|
|
135
127
|
"json-schema-to-ts": "^3.1.1",
|
|
136
128
|
"lint-staged": "^14.0.1",
|
|
137
129
|
"npm-check-updates": "^17.1.12",
|
|
138
|
-
"quicktype": "^23.0.170"
|
|
139
|
-
"typescript": "^5.7.2",
|
|
140
|
-
"vite": "^5.4.11",
|
|
141
|
-
"vite-plugin-dts": "^4.3.0"
|
|
130
|
+
"quicktype": "^23.0.170"
|
|
142
131
|
},
|
|
143
132
|
"dependencies": {
|
|
144
133
|
"@commitlint/cli": "^19.6.1",
|
|
145
134
|
"@commitlint/config-conventional": "^19.6.0",
|
|
146
135
|
"@commitlint/types": "^19.8.0",
|
|
147
|
-
"@dotenvx/dotenvx": "
|
|
148
|
-
"@
|
|
149
|
-
"@release-it/conventional-changelog": "^9.0.4",
|
|
150
|
-
"@stylistic/eslint-plugin": "^5",
|
|
136
|
+
"@dotenvx/dotenvx": "1.32.0",
|
|
137
|
+
"@juisy/utils": "3.0.0-beta.1",
|
|
151
138
|
"ascii-tree": "^0.3.0",
|
|
152
139
|
"chalk": "^5.4.1",
|
|
153
140
|
"conventional-recommended-bump": "^10.0.0",
|
|
154
|
-
"deepmerge": "^4.3.1",
|
|
155
141
|
"ejs": "^3.1.10",
|
|
142
|
+
"eslint": "^9.17.0",
|
|
156
143
|
"execa": "^9.5.2",
|
|
157
144
|
"find-up": "^7.0.0",
|
|
158
145
|
"fs-extra": "^11.2.0",
|
|
159
146
|
"github-slugger": "^2.0.0",
|
|
160
|
-
"glob": "^11.0.0",
|
|
161
147
|
"globals": "^16",
|
|
162
148
|
"handlebars": "^4.7.8",
|
|
163
149
|
"import-single-ts": "^1.2.0",
|
|
164
150
|
"indent-string": "^5.0.0",
|
|
165
151
|
"json-2-csv": "^5.5.7",
|
|
166
152
|
"jstoxml": "^5.0.2",
|
|
167
|
-
"lodash.get": "^4.4.2",
|
|
168
|
-
"lodash.kebabcase": "^4.1.1",
|
|
169
153
|
"lodash.merge": "^4.6.2",
|
|
170
|
-
"lodash.set": "^4.3.2",
|
|
171
154
|
"loglevel": "^1.9.2",
|
|
172
155
|
"markdown-table": "^3.0.4",
|
|
173
156
|
"markdown-toc": "^1.2.0",
|
|
174
157
|
"markdown-utils": "^1.0.0",
|
|
175
|
-
"mri": "^1.2.0",
|
|
176
158
|
"package-json-type": "^1.0.3",
|
|
177
159
|
"pkg-dir": "^8.0.0",
|
|
178
160
|
"prompts": "^2.4.2",
|
|
@@ -183,21 +165,23 @@
|
|
|
183
165
|
"semver": "^7.7.1",
|
|
184
166
|
"strip-ansi": "^7.1.0",
|
|
185
167
|
"strip-indent": "^4.1.1",
|
|
186
|
-
"
|
|
187
|
-
"typescript-eslint": "^8",
|
|
188
|
-
"unist-util-is": "^6.0.1",
|
|
189
|
-
"unist-util-source": "^5.0.0",
|
|
190
|
-
"unist-util-visit": "^5.0.0",
|
|
168
|
+
"typescript": "^5.7.2",
|
|
191
169
|
"yaml": "^2.6.1",
|
|
192
170
|
"yargs": "^17.7.2",
|
|
193
171
|
"yargs-parser": "^21.1.1"
|
|
194
172
|
},
|
|
195
173
|
"release-it": {
|
|
196
|
-
"git": false
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
174
|
+
"git": false,
|
|
175
|
+
"plugins": {
|
|
176
|
+
"@release-it/bumper": {
|
|
177
|
+
"out": {
|
|
178
|
+
"file": "package.json",
|
|
179
|
+
"path": [
|
|
180
|
+
"dependencies.@juisy/utils",
|
|
181
|
+
"peerDependencies.@juisy/utils"
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
202
186
|
}
|
|
203
187
|
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @import { Command } from '#juisy/cli'
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @extends {Command}
|
|
7
|
-
*/
|
|
8
|
-
export default class AddExtCommand extends CLI.Command {
|
|
9
|
-
/**
|
|
10
|
-
* The command signature
|
|
11
|
-
*/
|
|
12
|
-
command = 'ext:add <ext>'
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The command description
|
|
16
|
-
*/
|
|
17
|
-
describe = 'Add a Juisy extension'
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The command meta
|
|
21
|
-
*/
|
|
22
|
-
meta = {}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Command builder
|
|
26
|
-
*/
|
|
27
|
-
builder (cli) {
|
|
28
|
-
return cli
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Command handler
|
|
33
|
-
*/
|
|
34
|
-
async handler (args) {
|
|
35
|
-
// Utils
|
|
36
|
-
const { $style, step, substep } = CLI.OutputUtils
|
|
37
|
-
// const { run } = CLI.InterfaceUtils
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Add extension
|
|
41
|
-
*/
|
|
42
|
-
step('Adding extension')
|
|
43
|
-
|
|
44
|
-
this.log('Wants to add: ', args.ext)
|
|
45
|
-
|
|
46
|
-
substep($style.green('✔ Successfuly generated'), { last: true })
|
|
47
|
-
this.log() // blank line
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @import { Command } from '#juisy/cli'
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @extends {Command}
|
|
7
|
-
*/
|
|
8
|
-
export default class RemoveExtCommand extends CLI.Command {
|
|
9
|
-
/**
|
|
10
|
-
* The command signature
|
|
11
|
-
*/
|
|
12
|
-
command = 'ext:remove <ext>'
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The command description
|
|
16
|
-
*/
|
|
17
|
-
describe = 'Remove a Juisy extension'
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The command meta
|
|
21
|
-
*/
|
|
22
|
-
meta = {}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Command builder
|
|
26
|
-
*/
|
|
27
|
-
builder (cli) {
|
|
28
|
-
return cli
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Command handler
|
|
33
|
-
*/
|
|
34
|
-
async handler (args) {
|
|
35
|
-
// Utils
|
|
36
|
-
const { $style, step, substep } = CLI.OutputUtils
|
|
37
|
-
// const { run } = CLI.InterfaceUtils
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Remove extension
|
|
41
|
-
*/
|
|
42
|
-
step('Removing extension')
|
|
43
|
-
|
|
44
|
-
this.log('Wants to remove: ', args.ext)
|
|
45
|
-
|
|
46
|
-
substep($style.green('✔ Successfuly generated'), { last: true })
|
|
47
|
-
this.log() // blank line
|
|
48
|
-
}
|
|
49
|
-
}
|
package/bin/cli/init.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
process.env.JUISY_ENABLE_EXTENSIONS = 'true'
|