juisy 2.2.0 → 2.3.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/LICENSE +1 -1
- package/bin/cli/cli.js +14 -0
- package/bin/cli/cmds/index.js +6 -4
- package/bin/cli/cmds/public/AddExt.js +49 -0
- package/bin/cli/cmds/public/RemoveExt.js +49 -0
- package/bin/cli/index.js +1 -0
- package/bin/cli/init.js +1 -0
- package/bin/cli/lib/index.js +71 -0
- package/dist/DataExporter.d.ts +1 -0
- package/dist/bootstrap.d.ts +1 -0
- package/dist/cli/CLIFactory.d.ts +1 -0
- package/dist/cli/Command.d.ts +23 -2
- package/dist/cli/InterfaceUtils.d.ts +11 -9
- package/dist/cli/OutputUtils.d.ts +30 -16
- package/dist/cli/Plugin.d.ts +9 -0
- package/dist/cli/extract-usage.d.ts +8 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +193 -113
- package/dist/cli/plugins/command-meta/augment.d.ts +0 -3
- package/dist/cli/plugins/command-meta/index.d.ts +4 -0
- package/dist/cli/plugins/default-command-fallbacks/command-visitors/default-command-fallbacks.d.ts +1 -1
- package/dist/cli/plugins/default-command-fallbacks/index.d.ts +4 -0
- package/dist/cli/plugins/load-env-file/index.d.ts +4 -0
- package/dist/cli/plugins/private-commands/augment.d.ts +8 -0
- package/dist/cli/plugins/private-commands/command-visitors/private-command.d.ts +7 -3
- package/dist/cli/plugins/private-commands/index.d.ts +4 -0
- package/dist/cli/plugins/register-bump-version-command/index.d.ts +4 -0
- package/dist/cli/plugins/register-changelog-command/index.d.ts +4 -0
- package/dist/cli/plugins/register-docs-commands/index.d.ts +4 -0
- package/dist/cli/plugins/register-git-hooks-commands/index.d.ts +4 -0
- package/dist/cli/plugins/register-lint-commands/index.d.ts +4 -0
- package/dist/cli/plugins/register-lint-commands/settings.d.ts +2 -0
- package/dist/cli/plugins/register-lint-commands/types.d.ts +5 -9
- package/dist/cli/plugins/register-release-command/index.d.ts +4 -0
- package/dist/cli/plugins/register-test-command/index.d.ts +4 -0
- package/dist/cli/types.d.ts +7 -0
- package/dist/cli/utils.d.ts +3 -4
- package/dist/eject.d.ts +1 -0
- package/dist/get-package-info.d.ts +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +167 -11
- package/dist/project-globals.d.ts +2 -0
- package/dist/shims/shims.d.ts +1440 -0
- package/dist/templater/index.d.ts +4 -1
- package/dist/templater/index.js +42 -23
- package/dist/templater/markdown-templater/ReadmeTemplater.d.ts +8 -10
- package/dist/templater/markdown-templater/index.d.ts +10 -1
- package/dist/utils/misc.d.ts +69 -8
- package/package.json +38 -44
- package/bin/cli/cmds/private/docs/generate-api.js +0 -31
- package/bin/cli/cmds/private/docs/index.js +0 -20
- package/bin/cli/cmds/private/test.js +0 -33
- package/dist/vite/plugins/inject-css-variables/index.d.ts +0 -23
- package/dist/vite/plugins/inject-css-variables/index.js +0 -60
- package/dist/vite/plugins/inject-project-globals/index.d.ts +0 -19
- package/dist/vite/plugins/inject-project-globals/index.js +0 -58
|
@@ -2,6 +2,8 @@ import { GlobalSettings } from '../../types';
|
|
|
2
2
|
import { SettingsLintMarkdown } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Resolve settings for 'lint' namespace
|
|
5
|
+
* @param settings - The lint settings object
|
|
6
|
+
* @group None
|
|
5
7
|
*/
|
|
6
8
|
export default function resolveSettings(settings?: Required<GlobalSettings>['lint']): {
|
|
7
9
|
default?: import('../..').UserProvidedConfigSetting<import("eslint").Linter.LegacyConfig | import("eslint").Linter.Config | import("eslint").Linter.Config[]>;
|
|
@@ -4,23 +4,19 @@
|
|
|
4
4
|
*/
|
|
5
5
|
type MarkdownlintCLI2Config = {
|
|
6
6
|
[key: string]: any;
|
|
7
|
-
globs?: never;
|
|
8
7
|
fix?: never;
|
|
9
8
|
};
|
|
10
9
|
/**
|
|
11
10
|
* Object for root config in lint.markdown settings
|
|
11
|
+
* @group Types
|
|
12
12
|
*/
|
|
13
|
-
export type SettingsLintMarkdown = Array<
|
|
13
|
+
export type SettingsLintMarkdown = Array<SettingsLintMarkdownConfig>;
|
|
14
14
|
/**
|
|
15
|
-
* Object for
|
|
15
|
+
* Object for config in lint.markdown settings
|
|
16
|
+
* @group Types
|
|
16
17
|
*/
|
|
17
|
-
export type
|
|
18
|
+
export type SettingsLintMarkdownConfig = {
|
|
18
19
|
config: string | MarkdownlintCLI2Config;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Object for glob scoped config in lint.markdown settings
|
|
22
|
-
*/
|
|
23
|
-
export type SettingsLintMarkdownConfig = SettingsLintMarkdownRootConfig & {
|
|
24
20
|
globs?: string[];
|
|
25
21
|
};
|
|
26
22
|
export {};
|
package/dist/cli/types.d.ts
CHANGED
|
@@ -142,4 +142,11 @@ engine: CLIEngine,
|
|
|
142
142
|
* The default options to set
|
|
143
143
|
*/
|
|
144
144
|
options: any) => false | CommandObject);
|
|
145
|
+
/**
|
|
146
|
+
* CLI engine logger instance interface
|
|
147
|
+
* @group Types
|
|
148
|
+
*/
|
|
149
|
+
export interface LoggerInstance {
|
|
150
|
+
log: Function;
|
|
151
|
+
}
|
|
145
152
|
export {};
|
package/dist/cli/utils.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { CommandObject, CLIEngine } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* @ignore
|
|
4
|
-
* @param target - The target builder
|
|
5
|
-
* @param builder - The wrap
|
|
6
|
-
* @description
|
|
7
3
|
* Wrap command builder (target) with builder passed as second parameter
|
|
8
4
|
* that will be called before target. Target can be undefined
|
|
5
|
+
* @param target - The target builder
|
|
6
|
+
* @param builder - The wrap
|
|
7
|
+
* @ignore
|
|
9
8
|
*/
|
|
10
9
|
export declare function wrapCommandBuilder(target: CommandObject['builder'], builder: (cli: CLIEngine) => CLIEngine): (cli: CLIEngine) => CLIEngine | PromiseLike<CLIEngine>;
|
package/dist/eject.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export type EjectOptions = {
|
|
|
23
23
|
* Takes content as unique argument and must return string or a Promise that resolves a string
|
|
24
24
|
* @param options.onError - The callback if an error occurs
|
|
25
25
|
* @param options.onSuccess - The callback in of success
|
|
26
|
+
* @group None
|
|
26
27
|
*/
|
|
27
28
|
export default function eject(
|
|
28
29
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Public API of juisy library
|
|
3
3
|
* @module juisy
|
|
4
|
+
* @importTarget .
|
|
4
5
|
* @author Hervé Perchec
|
|
5
6
|
*/
|
|
6
7
|
import * as utils from './utils/misc';
|
|
@@ -10,8 +11,11 @@ export { default as getPackageInfo } from './get-package-info';
|
|
|
10
11
|
export { defineGlobals, getProjectGlobals } from './project-globals';
|
|
11
12
|
/**
|
|
12
13
|
* @ignore
|
|
13
|
-
|
|
14
|
+
*/
|
|
14
15
|
export { utils };
|
|
15
16
|
export type * from './DataExporter';
|
|
16
17
|
export type * from './eject';
|
|
17
18
|
export type * from './project-globals';
|
|
19
|
+
export type * from './shims/shims';
|
|
20
|
+
declare const _default: {};
|
|
21
|
+
export default _default;
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,100 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* juisy v2.
|
|
2
|
+
* juisy v2.3.0
|
|
3
3
|
* Copyright © 2022-Present Hervé Perchec
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import path$1, { dirname } from 'node:path';
|
|
7
|
-
import {
|
|
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';
|
|
8
12
|
import { glob } from 'glob';
|
|
9
13
|
import { packageDirectorySync } from 'pkg-dir';
|
|
10
14
|
import yaml from 'yaml';
|
|
11
15
|
import { json2csv } from 'json-2-csv';
|
|
12
16
|
import jstoxml from 'jstoxml';
|
|
13
|
-
import fs from 'fs-extra';
|
|
14
|
-
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
15
17
|
import log from 'loglevel';
|
|
16
18
|
import { Templater } from 'juisy/templater';
|
|
17
19
|
import dotenv from '@dotenvx/dotenvx';
|
|
18
20
|
import deepmerge from 'deepmerge';
|
|
19
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
|
+
|
|
20
98
|
function getFileUrls(pattern, options) {
|
|
21
99
|
const files = glob.sync(pattern, options || {});
|
|
22
100
|
return files;
|
|
@@ -32,6 +110,19 @@ async function* getFiles(dir) {
|
|
|
32
110
|
}
|
|
33
111
|
}
|
|
34
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
|
+
}
|
|
35
126
|
function getRootDir() {
|
|
36
127
|
return packageDirectorySync();
|
|
37
128
|
}
|
|
@@ -66,6 +157,48 @@ const path = {
|
|
|
66
157
|
const platform = process.platform;
|
|
67
158
|
return platform === "win32" ? path.toWin32(val) : path.toPosix(val);
|
|
68
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
|
+
},
|
|
69
202
|
/**
|
|
70
203
|
* Util to resolve a relative file path
|
|
71
204
|
* @param from - The "from" absolute file path
|
|
@@ -101,15 +234,32 @@ const path = {
|
|
|
101
234
|
resolveAbsFromRoot(to, separator) {
|
|
102
235
|
const absolutePath = path$1.join(getRootDir(), to);
|
|
103
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));
|
|
104
253
|
}
|
|
105
254
|
};
|
|
106
255
|
|
|
107
256
|
const misc = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
257
|
+
__proto__: null,
|
|
258
|
+
getFileUrls,
|
|
259
|
+
getFiles,
|
|
260
|
+
getFilesSync,
|
|
261
|
+
getRootDir,
|
|
262
|
+
path
|
|
113
263
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
114
264
|
|
|
115
265
|
const xml = jstoxml.toXML;
|
|
@@ -208,7 +358,10 @@ async function ejectFile(from, to, identifier = null, options) {
|
|
|
208
358
|
const write = await fs.exists(to) ? force : true;
|
|
209
359
|
if (write) {
|
|
210
360
|
const template = await fs.readFile(from, { encoding: "utf8" });
|
|
211
|
-
const content = await templater.render(
|
|
361
|
+
const content = await templater.render(
|
|
362
|
+
template,
|
|
363
|
+
typeof templateData === "function" ? await templateData(identifier) : templateData
|
|
364
|
+
);
|
|
212
365
|
const processedContent = await processor(content, identifier);
|
|
213
366
|
await fs.ensureFile(to);
|
|
214
367
|
await fs.writeFile(to, processedContent);
|
|
@@ -323,4 +476,7 @@ async function getProjectGlobals(filePath = "./project.globals.js") {
|
|
|
323
476
|
return (await import(pathToFileURL(path$1.resolve(filePath)))).default;
|
|
324
477
|
}
|
|
325
478
|
|
|
326
|
-
|
|
479
|
+
bootstrap(import.meta);
|
|
480
|
+
const index = {};
|
|
481
|
+
|
|
482
|
+
export { DataExporter, index as default, defineGlobals, eject, getPackageInfo, getProjectGlobals, misc as utils };
|
|
@@ -38,6 +38,7 @@ export type DefineGlobalsBuilder<T extends Record<string, any>> = (ctx: {
|
|
|
38
38
|
* @param config - The config object
|
|
39
39
|
* @param builder - The builder function
|
|
40
40
|
* @returns The computed globals object
|
|
41
|
+
* @group None
|
|
41
42
|
*/
|
|
42
43
|
export declare function defineGlobals<CustomGlobals extends Record<string, any>>(config: {
|
|
43
44
|
env?: {
|
|
@@ -49,5 +50,6 @@ export declare function defineGlobals<CustomGlobals extends Record<string, any>>
|
|
|
49
50
|
* Get project globals
|
|
50
51
|
* @param filePath - The filePath. Default is `'./project.globals.js'`
|
|
51
52
|
* @returns The resolved project globals object
|
|
53
|
+
* @group None
|
|
52
54
|
*/
|
|
53
55
|
export declare function getProjectGlobals(filePath?: string): Promise<DefaultProjectGlobals & Record<string, string | Record<string, unknown> | undefined>>;
|