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/bin/cli/lib/index.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
import { pathToFileURL } from 'node:url'
|
|
3
|
-
import fs from 'fs-extra'
|
|
4
|
-
import { CLIFactory } from '#juisy/cli'
|
|
5
|
-
|
|
6
|
-
export const DEFAULT_EXT_CACHE_PATH = './node_modules/.cache/juisy/extensions.json'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Get the extensions locally added to juisy
|
|
10
|
-
* @param {string} extCachePath - The path to extensions cache file
|
|
11
|
-
* @returns {string[]} The extension names
|
|
12
|
-
*/
|
|
13
|
-
export function getExtensions (extCachePath = DEFAULT_EXT_CACHE_PATH) {
|
|
14
|
-
const absolutePath = path.isAbsolute(extCachePath)
|
|
15
|
-
? extCachePath
|
|
16
|
-
: path.resolve(extCachePath)
|
|
17
|
-
|
|
18
|
-
// If default, ensure file exists
|
|
19
|
-
if (extCachePath === DEFAULT_EXT_CACHE_PATH
|
|
20
|
-
&& fs.existsSync(path.resolve('./node_modules'))
|
|
21
|
-
&& !fs.existsSync(absolutePath)
|
|
22
|
-
) {
|
|
23
|
-
fs.outputFileSync(absolutePath, '[]')
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const content = fs.readFileSync(absolutePath, 'utf-8')
|
|
27
|
-
const extensionIds = JSON.parse(content)
|
|
28
|
-
return extensionIds
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Load an extension
|
|
33
|
-
* @param {string} id - The module name or relative/absolute path
|
|
34
|
-
*/
|
|
35
|
-
export async function loadExtension (id) {
|
|
36
|
-
// Module name or full path
|
|
37
|
-
const modPath = id.startsWith('.') // is relative?
|
|
38
|
-
? path.resolve(id) // relative to process.cwd()
|
|
39
|
-
: id // can be module name or absolute path
|
|
40
|
-
|
|
41
|
-
const mod = await import(path.isAbsolute(modPath)
|
|
42
|
-
? pathToFileURL(modPath).toString()
|
|
43
|
-
: id)
|
|
44
|
-
|
|
45
|
-
return mod.extension || mod.default
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Load the extensions
|
|
50
|
-
* @param {?string} extCachePath - The path to extensions cache file
|
|
51
|
-
*/
|
|
52
|
-
export async function loadExtensions (extCachePath) {
|
|
53
|
-
// Get extension identifiers
|
|
54
|
-
const extensionIds = getExtensions(extCachePath)
|
|
55
|
-
|
|
56
|
-
const extensions = []
|
|
57
|
-
|
|
58
|
-
for (const id of extensionIds) {
|
|
59
|
-
const loaded = {
|
|
60
|
-
id,
|
|
61
|
-
extension: await loadExtension(id)
|
|
62
|
-
}
|
|
63
|
-
extensions.push(loaded)
|
|
64
|
-
//
|
|
65
|
-
if (loaded.extension.juisyBin) {
|
|
66
|
-
loaded.extension.juisyBin(CLIFactory)
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return extensions
|
|
71
|
-
}
|
package/dist/utils/misc.d.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { GlobOptions } from 'glob';
|
|
2
|
-
/**
|
|
3
|
-
* Get file urls that match glob (see: https://github.com/isaacs/node-glob)
|
|
4
|
-
* @param pattern - Same as node-glob pattern argument
|
|
5
|
-
* @param options - Same as glob options argument
|
|
6
|
-
* @returns {string[]} Returns an array of file path
|
|
7
|
-
* @example
|
|
8
|
-
* utils.getFileUrls('path/to/*.js') // => [ 'path/to/file1.js', 'path/to/file2.js', ... ]
|
|
9
|
-
*/
|
|
10
|
-
export declare function getFileUrls(pattern: string, options?: GlobOptions): string[] | import('glob').Path[];
|
|
11
|
-
/**
|
|
12
|
-
* Get all files in a directory (recursively).
|
|
13
|
-
*
|
|
14
|
-
* Prefer using this function over `getFilesSync` for directories with
|
|
15
|
-
* a large number of files, to avoid blocking the event loop.
|
|
16
|
-
*
|
|
17
|
-
* @param dir - The directory path
|
|
18
|
-
* @returns An async generator that yields file paths
|
|
19
|
-
* @yields {string} The next found files.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* const files = []
|
|
23
|
-
* for await (const file of utils.getFiles(path)) {
|
|
24
|
-
* files.push(file)
|
|
25
|
-
* }
|
|
26
|
-
* console.log(files) // => [ 'path/to/file1', 'path/to/file2', ... ]
|
|
27
|
-
*/
|
|
28
|
-
export declare function getFiles(dir: string): AsyncGenerator<string>;
|
|
29
|
-
/**
|
|
30
|
-
* Get all files in a directory (recursively and synchronously).
|
|
31
|
-
*
|
|
32
|
-
* For directories with a large number of files, prefer using `getFiles`
|
|
33
|
-
* over this function to avoid blocking the event loop.
|
|
34
|
-
*
|
|
35
|
-
* @param dir - The directory path
|
|
36
|
-
* @returns Returns an array of file paths
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* utils.getFilesSync(path) // => [ 'path/to/file1', 'path/to/file2', ... ]
|
|
40
|
-
*/
|
|
41
|
-
export declare function getFilesSync(dir: string): string[];
|
|
42
|
-
/**
|
|
43
|
-
* Synchronously find the root directory of the project in which juisy is installed.
|
|
44
|
-
*
|
|
45
|
-
* It is just a wrapper around the `packageDirectorySync` function
|
|
46
|
-
* from [pkg-dir](https://www.npmjs.com/package/pkg-dir) library.
|
|
47
|
-
*/
|
|
48
|
-
export declare function getRootDir(): string | undefined;
|
|
49
|
-
/**
|
|
50
|
-
* Utils related to path
|
|
51
|
-
*/
|
|
52
|
-
export declare const path: {
|
|
53
|
-
/**
|
|
54
|
-
* Convert a path to win32 format (with `\\` separator)
|
|
55
|
-
* @param val - The path to convert
|
|
56
|
-
* @example
|
|
57
|
-
* utils.path.toWin32('a/posix/path') // => 'a\posix\path'
|
|
58
|
-
* utils.path.toWin32('C:\\a\\win32\\absolute\\path') // => 'C:\a\win32\absolute\path'
|
|
59
|
-
* utils.path.toWin32('a/mixed\\path') // => 'a\mixed\path'
|
|
60
|
-
*/
|
|
61
|
-
toWin32(val: string): string;
|
|
62
|
-
/**
|
|
63
|
-
* Convert a path to posix format (with `/` separator)
|
|
64
|
-
* @param val - The path to convert
|
|
65
|
-
* @example
|
|
66
|
-
* utils.path.toPosix('a/posix/path') // => 'a/posix/path'
|
|
67
|
-
* utils.path.toPosix('C:\\a\\win32\\absolute\\path') // => 'C:/a/win32/absolute/path'
|
|
68
|
-
* utils.path.toPosix('a/mixed\\path') // => 'a/mixed/path'
|
|
69
|
-
*/
|
|
70
|
-
toPosix(val: string): string;
|
|
71
|
-
/**
|
|
72
|
-
* Automatically convert a path to OS specific format
|
|
73
|
-
* @param val - The path to convert
|
|
74
|
-
*/
|
|
75
|
-
toOsFormat(val: string): string;
|
|
76
|
-
/**
|
|
77
|
-
* Check if the given path is win32 format
|
|
78
|
-
* @param val - The path to check
|
|
79
|
-
* @example
|
|
80
|
-
* utils.path.isWin32('a/posix/path') // => false
|
|
81
|
-
* utils.path.isWin32('C:\\a\\win32\\absolute\\path') // => true
|
|
82
|
-
* utils.path.isWin32('a/mixed\\path') // => true
|
|
83
|
-
*/
|
|
84
|
-
isWin32(val: string): boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Check if the given path is posix format
|
|
87
|
-
* @param val - The path to check
|
|
88
|
-
* @example
|
|
89
|
-
* utils.path.isPosix('a/posix/path') // => true
|
|
90
|
-
* utils.path.isPosix('C:\\a\\win32\\absolute\\path') // => false
|
|
91
|
-
* utils.path.isPosix('a/mixed\\path') // => false
|
|
92
|
-
*/
|
|
93
|
-
isPosix(val: string): boolean;
|
|
94
|
-
/**
|
|
95
|
-
* Normalize a path depending on base format
|
|
96
|
-
* @param val - The path to normalize
|
|
97
|
-
* @example
|
|
98
|
-
* utils.path.normalize('a/Posix/path') // => 'a/Posix/path'
|
|
99
|
-
* utils.path.normalize('C:\\a\\Win32\\Absolute\\path\\') // => 'c:\a\win32\absolute\path'
|
|
100
|
-
* utils.path.normalize('a/Mixed\\Path') // => 'a\mixed\path'
|
|
101
|
-
*/
|
|
102
|
-
normalize(val: string): string;
|
|
103
|
-
/**
|
|
104
|
-
* Util to resolve a relative file path
|
|
105
|
-
* @param from - The "from" absolute file path
|
|
106
|
-
* @param to - The "to" absolute file path
|
|
107
|
-
* @param separator - (Optional) The separator type: can be `"posix"` or `"win32"`
|
|
108
|
-
* @returns The resolved relative path
|
|
109
|
-
* @example
|
|
110
|
-
* const base = 'C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject'
|
|
111
|
-
*
|
|
112
|
-
* utils.path.resolveRel(base, 'C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject\\src\\index.ts') // 'src\\index.ts'
|
|
113
|
-
* utils.path.resolveRel('C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject\\src\\index.ts', base) // '..\\..'
|
|
114
|
-
* utils.path.resolveRel(base, 'C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject\\src\\index.ts', 'posix') // 'src/index.ts'
|
|
115
|
-
*/
|
|
116
|
-
resolveRel(from: string, to: string, separator?: "posix" | "win32"): string;
|
|
117
|
-
/**
|
|
118
|
-
* Util to resolve relative file path from root directory
|
|
119
|
-
* @param to - The absolute file path
|
|
120
|
-
* @param separator - (Optional) The separator type: can be `"posix"` or `"win32"`
|
|
121
|
-
* @returns The resolved relative path from root directory
|
|
122
|
-
*/
|
|
123
|
-
resolveRelFromRoot(to: string, separator?: "posix" | "win32"): string;
|
|
124
|
-
/**
|
|
125
|
-
* Util to resolve absolute file path from root directory
|
|
126
|
-
* @param to - The relative file path
|
|
127
|
-
* @param separator - (Optional) The separator type: can be `"posix"` or `"win32"`
|
|
128
|
-
* @returns The resolved absolute path from root directory
|
|
129
|
-
*/
|
|
130
|
-
resolveAbsFromRoot(to: string, separator?: "posix" | "win32"): string;
|
|
131
|
-
/**
|
|
132
|
-
* Util function to compare two file paths
|
|
133
|
-
* @param a - The first file path to compare
|
|
134
|
-
* @param b - The second file path to compare
|
|
135
|
-
* @returns True if the two paths are the same
|
|
136
|
-
* @example
|
|
137
|
-
* utils.path.isSameAs('src/index.ts', 'src\\index.ts') // true
|
|
138
|
-
* utils.path.isSameAs('../src/index.ts', '..\\src\\index.ts') // true
|
|
139
|
-
* utils.path.isSameAs('C:\\a\\Win32\\Absolute\\path\\', 'c:/a/Win32/Absolute/path') // true
|
|
140
|
-
* utils.path.isSameAs('C:\\a\\Win32\\Absolute\\path\\', '/a/Win32/Absolute/path')// false
|
|
141
|
-
* utils.path.isSameAs('/a/posix/absolute/path', '/a/posix/absolute/path/../../absolute/path') // true
|
|
142
|
-
* utils.path.isSameAs('/a/posix/absolute/path', '/a/Posix/Absolute/path') // false
|
|
143
|
-
*/
|
|
144
|
-
isSameAs(a: string, b: string): boolean;
|
|
145
|
-
};
|