juisy 2.2.0 → 3.0.0-beta.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/README.md +85 -0
- package/bin/cli/cli.js +3 -0
- package/bin/cli/cmds/index.js +2 -4
- package/bin/scripts/prepare.js +22 -22
- package/dist/DataExporter.d.ts +9 -4
- package/dist/bootstrap.d.ts +6 -0
- package/dist/bootstrap.js +21 -0
- package/dist/cli/CLIFactory.d.ts +1 -0
- package/dist/cli/Command.d.ts +23 -2
- package/dist/cli/GlobalSettings.schema.json +1 -1
- package/dist/cli/InterfaceUtils.d.ts +14 -12
- 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 +210 -122
- package/dist/cli/plugins/command-meta/augment.d.ts +1 -4
- package/dist/cli/plugins/command-meta/index.d.ts +4 -0
- package/dist/cli/plugins/default-command-fallbacks/augment.d.ts +1 -1
- 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/augment.d.ts +1 -1
- 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 +9 -1
- package/dist/cli/utils.d.ts +3 -4
- package/dist/eject.d.ts +1 -0
- package/dist/extensions.d.ts +26 -0
- package/dist/extensions.js +44 -0
- package/dist/get-package-info.d.ts +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +23 -128
- package/dist/project-globals.d.ts +6 -2
- package/dist/shims/shims.d.ts +1440 -0
- package/dist/templater/index.d.ts +4 -1
- package/dist/templater/index.js +43 -24
- package/dist/templater/markdown-templater/ReadmeTemplater.d.ts +12 -12
- package/dist/templater/markdown-templater/index.d.ts +10 -1
- package/package.json +43 -49
- 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/utils/misc.d.ts +0 -84
- 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
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* juisy v2.2.0
|
|
3
|
-
* Copyright © 2022-Present Hervé Perchec
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
function injectCssVariables(optsArg = []) {
|
|
7
|
-
const optionsArray = optsArg instanceof Array ? optsArg : [optsArg];
|
|
8
|
-
const virtualModules = /* @__PURE__ */ new Map();
|
|
9
|
-
for (let i = 0; i < optionsArray.length; i++) {
|
|
10
|
-
const options = optionsArray[i];
|
|
11
|
-
if (!options.moduleId || options.moduleId.trim().length === 0) {
|
|
12
|
-
throw new Error(`Please provide a non-empty module ID in plugin options at index ${i}`);
|
|
13
|
-
}
|
|
14
|
-
if (virtualModules.has(options.moduleId)) {
|
|
15
|
-
throw new Error(`The module ID "${options.moduleId}" is already used. Please provide another ID`);
|
|
16
|
-
}
|
|
17
|
-
virtualModules.set(options.moduleId, options);
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
name: "vite-plugin-inject-css-variables",
|
|
21
|
-
enforce: "pre",
|
|
22
|
-
resolveId(id) {
|
|
23
|
-
const options = virtualModules.get(id);
|
|
24
|
-
if (!options) {
|
|
25
|
-
return;
|
|
26
|
-
} else {
|
|
27
|
-
return "\0" + options.moduleId;
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
async load(id) {
|
|
31
|
-
const options = virtualModules.get(id.slice(1));
|
|
32
|
-
if (!id.startsWith("\0") || !options) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const { selector = ":root", variables } = options;
|
|
36
|
-
try {
|
|
37
|
-
if (Object.keys(variables).length === 0) {
|
|
38
|
-
return "";
|
|
39
|
-
}
|
|
40
|
-
for (const key in variables) {
|
|
41
|
-
if (typeof variables[key] === "string") {
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
} catch (e) {
|
|
46
|
-
this.error(`The variables object for module "${options.moduleId}" is malformed`);
|
|
47
|
-
}
|
|
48
|
-
let css = `${selector} {
|
|
49
|
-
`;
|
|
50
|
-
for (const key in variables) {
|
|
51
|
-
css += ` --${key}: ${variables[key]};
|
|
52
|
-
`;
|
|
53
|
-
}
|
|
54
|
-
css += "}\n";
|
|
55
|
-
return css;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export { injectCssVariables as default, injectCssVariables };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Plugin } from 'vite';
|
|
2
|
-
export type Options = {
|
|
3
|
-
/**
|
|
4
|
-
* The virtual module ID
|
|
5
|
-
* @default 'virtual:project.globals.js'
|
|
6
|
-
*/
|
|
7
|
-
moduleId?: string;
|
|
8
|
-
/**
|
|
9
|
-
* The project globals path (relative from root folder)
|
|
10
|
-
*/
|
|
11
|
-
filePath?: string;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Inject project globals via a virtual module
|
|
15
|
-
* @param opts - The plugin options or an array of options
|
|
16
|
-
* @returns {Plugin} The vite plugin function
|
|
17
|
-
*/
|
|
18
|
-
export declare function injectProjectGlobals(options?: Options): Plugin;
|
|
19
|
-
export default injectProjectGlobals;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* juisy v2.2.0
|
|
3
|
-
* Copyright © 2022-Present Hervé Perchec
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { getProjectGlobals } from 'juisy';
|
|
7
|
-
import { OutputUtils } from 'juisy/cli';
|
|
8
|
-
|
|
9
|
-
function injectProjectGlobals(options = {}) {
|
|
10
|
-
const { $style } = OutputUtils;
|
|
11
|
-
let config;
|
|
12
|
-
let moduleId = "virtual:project.globals.js";
|
|
13
|
-
if (options.moduleId) {
|
|
14
|
-
if (options.moduleId.trim().length === 0) {
|
|
15
|
-
throw new Error("Please provide a non-empty module ID for juisy/vite-plugin-inject-project-globals");
|
|
16
|
-
}
|
|
17
|
-
moduleId = options.moduleId;
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
name: "vite-plugin-inject-project-globals",
|
|
21
|
-
enforce: "pre",
|
|
22
|
-
configResolved(resolvedConfig) {
|
|
23
|
-
config = resolvedConfig;
|
|
24
|
-
},
|
|
25
|
-
resolveId(id) {
|
|
26
|
-
if (id !== moduleId) {
|
|
27
|
-
return;
|
|
28
|
-
} else {
|
|
29
|
-
return "\0" + moduleId;
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
/**
|
|
33
|
-
* Vite plugin `load` hook
|
|
34
|
-
* @param id - The requested module ID
|
|
35
|
-
* @returns The module content as a string
|
|
36
|
-
* @description
|
|
37
|
-
* Load the virtual module and return its content.
|
|
38
|
-
* If the module ID is not the one defined by the plugin, simply return null.
|
|
39
|
-
* Otherwise, call `getProjectGlobals` and build a js string.
|
|
40
|
-
*/
|
|
41
|
-
async load(id) {
|
|
42
|
-
if (!id.startsWith("\0") || id.slice(1) !== moduleId) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const PROJECT_GLOBALS = {
|
|
46
|
-
...await getProjectGlobals(options.filePath)
|
|
47
|
-
};
|
|
48
|
-
if (PROJECT_GLOBALS.ENV) {
|
|
49
|
-
config.logger.warn("\n[vite-plugin-inject-project-globals] " + $style.yellow("The following ENV variables are exposed:"));
|
|
50
|
-
config.logger.warn(JSON.stringify(PROJECT_GLOBALS.ENV));
|
|
51
|
-
config.logger.warn("\n");
|
|
52
|
-
}
|
|
53
|
-
return "const PROJECT_GLOBALS = " + JSON.stringify(PROJECT_GLOBALS) + "\nconst isBrowser = import.meta.env.SSR === false\nif (isBrowser) {\n if (PROJECT_GLOBALS.ENV) {\n console.warn('[vite-plugin-inject-project-globals] WARNING: some ENV variables are exposed! Be careful, do not expose sensitive data!')\n }\n}\nexport default PROJECT_GLOBALS\n";
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export { injectProjectGlobals as default, injectProjectGlobals };
|