juisy 2.0.0-beta.1 → 2.0.0-beta.11
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 +661 -0
- package/bin/cli/cmds/public/print-globals.js +1 -1
- package/bin/cli/index.js +1 -1
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/index.js +131 -31
- package/dist/cli/plugins/register-bump-version-command/cmds/index.d.ts +3 -0
- package/dist/cli/plugins/register-bump-version-command/index.d.ts +3 -0
- package/dist/cli/plugins/register-lint-commands/augment.d.ts +2 -3
- package/dist/cli/plugins/register-lint-commands/settings.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/project-globals.d.ts +1 -1
- package/dist/templater/index.js +11 -11
- package/dist/vite/plugins/inject-css-variables/index.d.ts +22 -0
- package/dist/vite/plugins/inject-css-variables/index.js +60 -0
- package/package.json +21 -14
- package/bin/cli/cmds/private/docs/lint.js +0 -42
- package/dist/cli/plugins/register-test-command/augment.d.ts +0 -3
package/dist/cli/index.d.ts
CHANGED
|
@@ -26,7 +26,6 @@ export type * from './plugins/register-docs-commands/augment';
|
|
|
26
26
|
export type * from './plugins/register-git-hooks-commands/augment';
|
|
27
27
|
export type * from './plugins/register-lint-commands/augment';
|
|
28
28
|
export type * from './plugins/register-release-command/augment';
|
|
29
|
-
export type * from './plugins/register-test-command/augment';
|
|
30
29
|
export type * from './plugins/default-command-fallbacks/augment';
|
|
31
30
|
export type * from './plugins/command-handler-injections/augment';
|
|
32
31
|
export type * from './plugins/command-meta/augment';
|
package/dist/cli/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* juisy v2.0.0-beta.
|
|
2
|
+
* juisy v2.0.0-beta.11
|
|
3
3
|
* Copyright © 2022-Present Hervé Perchec
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -17,10 +17,11 @@ import chalk from 'chalk';
|
|
|
17
17
|
import indent from 'indent-string';
|
|
18
18
|
import _stripAnsi from 'strip-ansi';
|
|
19
19
|
import dotenv from '@dotenvx/dotenvx';
|
|
20
|
+
import semver from 'semver';
|
|
21
|
+
import { getPackageInfo } from 'juisy';
|
|
20
22
|
import kebabcase from 'lodash.kebabcase';
|
|
21
23
|
import { ReadmeTemplater } from 'juisy/templater';
|
|
22
24
|
import path from 'node:path';
|
|
23
|
-
import { getPackageInfo } from 'juisy';
|
|
24
25
|
import { ESLint } from 'eslint';
|
|
25
26
|
import fs$1 from 'node:fs';
|
|
26
27
|
import yargsParser from 'yargs-parser';
|
|
@@ -173,7 +174,7 @@ const proxify = (target) => {
|
|
|
173
174
|
}
|
|
174
175
|
return obj[prop];
|
|
175
176
|
}
|
|
176
|
-
return
|
|
177
|
+
return void 0;
|
|
177
178
|
}
|
|
178
179
|
});
|
|
179
180
|
for (const property in target) {
|
|
@@ -182,13 +183,7 @@ const proxify = (target) => {
|
|
|
182
183
|
return tmp;
|
|
183
184
|
};
|
|
184
185
|
const defaultGlobalSettings = {
|
|
185
|
-
|
|
186
|
-
git: {
|
|
187
|
-
commitMessage: "chore(release): v${version}",
|
|
188
|
-
requireBranch: "main",
|
|
189
|
-
tagAnnotation: "v${version}"
|
|
190
|
-
}
|
|
191
|
-
}
|
|
186
|
+
// ...
|
|
192
187
|
};
|
|
193
188
|
const defaultCommands = [];
|
|
194
189
|
const registeredPlugins = [];
|
|
@@ -417,7 +412,7 @@ class OutputUtils {
|
|
|
417
412
|
static formatOutputMessage(msg, options = {}) {
|
|
418
413
|
let formatted = `${msg}`;
|
|
419
414
|
if (options.indentChar) {
|
|
420
|
-
if (options.indent ===
|
|
415
|
+
if (options.indent === void 0) {
|
|
421
416
|
options.indent = 1;
|
|
422
417
|
}
|
|
423
418
|
} else {
|
|
@@ -472,7 +467,7 @@ class OutputUtils {
|
|
|
472
467
|
*/
|
|
473
468
|
static error(msg, err) {
|
|
474
469
|
OutputUtils.log(OutputUtils.$style.red(`⨉ ERROR: ${msg}`));
|
|
475
|
-
if (err !==
|
|
470
|
+
if (err !== void 0) {
|
|
476
471
|
OutputUtils.log();
|
|
477
472
|
throw err;
|
|
478
473
|
}
|
|
@@ -488,7 +483,7 @@ class OutputUtils {
|
|
|
488
483
|
*/
|
|
489
484
|
static step(msg, options = {}) {
|
|
490
485
|
OutputUtils.stepsCache.index++;
|
|
491
|
-
if (options.index ===
|
|
486
|
+
if (options.index === void 0) {
|
|
492
487
|
options.index = OutputUtils.stepsCache.index;
|
|
493
488
|
}
|
|
494
489
|
OutputUtils.log(`${options.index !== null ? options.index + " - " : ""}${msg}`, { indentChar: "● " });
|
|
@@ -623,6 +618,103 @@ const LoadEnvFile = new Plugin("built-in:load-env-file", {
|
|
|
623
618
|
}
|
|
624
619
|
});
|
|
625
620
|
|
|
621
|
+
const bumpVersion = new Command({
|
|
622
|
+
command: "bump-version",
|
|
623
|
+
describe: "Bump version in package.json file",
|
|
624
|
+
meta: {
|
|
625
|
+
private: true
|
|
626
|
+
},
|
|
627
|
+
builder: function(cli) {
|
|
628
|
+
cli.option("p", {
|
|
629
|
+
alias: "preid",
|
|
630
|
+
type: "string",
|
|
631
|
+
describe: "Pre-release id",
|
|
632
|
+
requiresArg: true
|
|
633
|
+
});
|
|
634
|
+
return cli;
|
|
635
|
+
},
|
|
636
|
+
async handler(argv) {
|
|
637
|
+
const { $style, step, substep, error } = OutputUtils;
|
|
638
|
+
const { run, prompts, abort } = InterfaceUtils;
|
|
639
|
+
const packageJson = getPackageInfo();
|
|
640
|
+
let targetVersion;
|
|
641
|
+
const currentVersion = packageJson.version;
|
|
642
|
+
packageJson.name;
|
|
643
|
+
const preId = argv.preid || semver.prerelease(currentVersion) && semver.prerelease(currentVersion)[0];
|
|
644
|
+
const inc = (i) => semver.inc(currentVersion, i, preId);
|
|
645
|
+
const versionIncrements = [
|
|
646
|
+
"patch",
|
|
647
|
+
"minor",
|
|
648
|
+
"major",
|
|
649
|
+
...preId ? ["prepatch", "preminor", "premajor", "prerelease"] : []
|
|
650
|
+
];
|
|
651
|
+
step("Bump version");
|
|
652
|
+
const { release } = await prompts([
|
|
653
|
+
{
|
|
654
|
+
type: "select",
|
|
655
|
+
name: "release",
|
|
656
|
+
message: "Release type:",
|
|
657
|
+
choices: versionIncrements.map((i) => ({ title: `${i} (${inc(i)})`, value: inc(i) })).concat([{ title: "custom", value: "custom" }])
|
|
658
|
+
}
|
|
659
|
+
]);
|
|
660
|
+
if (release === "custom") {
|
|
661
|
+
const { version: customVersion } = await prompts([
|
|
662
|
+
{
|
|
663
|
+
type: "text",
|
|
664
|
+
name: "version",
|
|
665
|
+
message: "New custom version:",
|
|
666
|
+
initial: currentVersion,
|
|
667
|
+
validate: (value) => Boolean(semver.valid(value))
|
|
668
|
+
}
|
|
669
|
+
]);
|
|
670
|
+
targetVersion = customVersion;
|
|
671
|
+
} else {
|
|
672
|
+
targetVersion = release;
|
|
673
|
+
}
|
|
674
|
+
const { yes } = await prompts([
|
|
675
|
+
{
|
|
676
|
+
type: "confirm",
|
|
677
|
+
name: "yes",
|
|
678
|
+
message: `Releasing v${targetVersion}. Confirm?`,
|
|
679
|
+
initial: true
|
|
680
|
+
}
|
|
681
|
+
]);
|
|
682
|
+
if (!yes) {
|
|
683
|
+
abort();
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
this.log();
|
|
687
|
+
let commandError = false;
|
|
688
|
+
try {
|
|
689
|
+
await run("npm", [
|
|
690
|
+
"--no-git-tag-version",
|
|
691
|
+
"version",
|
|
692
|
+
targetVersion
|
|
693
|
+
], { stdio: "inherit" });
|
|
694
|
+
} catch (e) {
|
|
695
|
+
commandError = e;
|
|
696
|
+
}
|
|
697
|
+
if (commandError) {
|
|
698
|
+
substep($style.red("❌ An error has occured."), { last: true });
|
|
699
|
+
error("An error has occured.", commandError);
|
|
700
|
+
abort(1);
|
|
701
|
+
} else {
|
|
702
|
+
substep($style.green("✔ Version successfuly bumped"), { last: true });
|
|
703
|
+
this.log();
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
const RegisterBumpVersionCommand = new Plugin("built-in:register-bump-version-command", {
|
|
709
|
+
beforeCreate({ defineDefaultCommand, defineSettings, builder, factoryOptions }) {
|
|
710
|
+
defineDefaultCommand({
|
|
711
|
+
fullSignature: "bump-version",
|
|
712
|
+
commandObject: bumpVersion,
|
|
713
|
+
children: []
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
|
|
626
718
|
const changelog = new Command({
|
|
627
719
|
command: "changelog",
|
|
628
720
|
describe: "Generate CHANGELOG file",
|
|
@@ -669,7 +761,8 @@ const RegisterChangelogCommand = new Plugin("built-in:register-changelog-command
|
|
|
669
761
|
defineSettings("changelog", {
|
|
670
762
|
infile: "CHANGELOG.md",
|
|
671
763
|
preset: "angular",
|
|
672
|
-
sameFile: true
|
|
764
|
+
sameFile: true,
|
|
765
|
+
onReleaseConfig: {}
|
|
673
766
|
});
|
|
674
767
|
defineDefaultCommand({
|
|
675
768
|
fullSignature: "changelog",
|
|
@@ -729,6 +822,7 @@ const docsGenerateReadme = new Command({
|
|
|
729
822
|
alias: "c",
|
|
730
823
|
describe: "Path to config file",
|
|
731
824
|
type: "string",
|
|
825
|
+
requiresArg: true,
|
|
732
826
|
default: "./docs/readme/config.js"
|
|
733
827
|
});
|
|
734
828
|
cli.config(cli.getSettings("docs.readme"));
|
|
@@ -931,7 +1025,7 @@ const lint = new Command({
|
|
|
931
1025
|
private: true
|
|
932
1026
|
},
|
|
933
1027
|
builder(cli) {
|
|
934
|
-
cli.option("fix", {
|
|
1028
|
+
cli.strict(false).option("fix", {
|
|
935
1029
|
alias: "f",
|
|
936
1030
|
describe: "Automatically fix problems",
|
|
937
1031
|
type: "boolean",
|
|
@@ -989,7 +1083,7 @@ const lintCommit = new Command({
|
|
|
989
1083
|
});
|
|
990
1084
|
const lintSettings = cli.getSettings("lint.commit");
|
|
991
1085
|
if (lintSettings?.config) {
|
|
992
|
-
cli.config(lintSettings);
|
|
1086
|
+
cli.config({ config: lintSettings.config });
|
|
993
1087
|
}
|
|
994
1088
|
return cli;
|
|
995
1089
|
},
|
|
@@ -1168,9 +1262,7 @@ const RegisterLintCommands = new Plugin("built-in:register-lint-commands", {
|
|
|
1168
1262
|
config: "eslint.config.js"
|
|
1169
1263
|
},
|
|
1170
1264
|
commit: {
|
|
1171
|
-
|
|
1172
|
-
"@commitlint/config-conventional"
|
|
1173
|
-
]
|
|
1265
|
+
// ...
|
|
1174
1266
|
},
|
|
1175
1267
|
markdown: [],
|
|
1176
1268
|
staged: {
|
|
@@ -1244,8 +1336,6 @@ const release = new Command({
|
|
|
1244
1336
|
async handler(argv) {
|
|
1245
1337
|
const { $style, step, substep, error, wait } = OutputUtils;
|
|
1246
1338
|
const { abort, run } = InterfaceUtils;
|
|
1247
|
-
console.log("argv ? ", argv);
|
|
1248
|
-
abort(1);
|
|
1249
1339
|
step("Prepare for release");
|
|
1250
1340
|
const tempConfigFilePath = "./__TEMP_RELEASE_IT_CONFIG__.json";
|
|
1251
1341
|
const releaseItCmdArgs = [];
|
|
@@ -1296,6 +1386,7 @@ const release = new Command({
|
|
|
1296
1386
|
strictSemVer: onReleaseConfig.strictSemVer
|
|
1297
1387
|
};
|
|
1298
1388
|
tempConfig = {
|
|
1389
|
+
...releaseSettings,
|
|
1299
1390
|
plugins: {
|
|
1300
1391
|
"@release-it/conventional-changelog": releaseItChangelogConfig
|
|
1301
1392
|
}
|
|
@@ -1307,9 +1398,13 @@ const release = new Command({
|
|
|
1307
1398
|
if (argv["dry-run"]) {
|
|
1308
1399
|
releaseItCmdArgs.push("--dry-run");
|
|
1309
1400
|
}
|
|
1310
|
-
if (argv.increment) {
|
|
1311
|
-
|
|
1312
|
-
|
|
1401
|
+
if (argv.increment !== void 0) {
|
|
1402
|
+
if (argv.increment === false) {
|
|
1403
|
+
releaseItCmdArgs.push("--no-increment");
|
|
1404
|
+
} else {
|
|
1405
|
+
releaseItCmdArgs.push("--increment");
|
|
1406
|
+
releaseItCmdArgs.push(argv.increment);
|
|
1407
|
+
}
|
|
1313
1408
|
}
|
|
1314
1409
|
if (argv.ci) {
|
|
1315
1410
|
releaseItCmdArgs.push("--ci");
|
|
@@ -1357,7 +1452,11 @@ const release = new Command({
|
|
|
1357
1452
|
const RegisterReleaseCommand = new Plugin("built-in:register-release-command", {
|
|
1358
1453
|
beforeCreate({ defineDefaultCommand, defineSettings, builder, factoryOptions }) {
|
|
1359
1454
|
defineSettings("release", {
|
|
1360
|
-
|
|
1455
|
+
git: {
|
|
1456
|
+
commitMessage: "chore(release): v${version}",
|
|
1457
|
+
requireBranch: "main",
|
|
1458
|
+
tagAnnotation: "v${version}"
|
|
1459
|
+
}
|
|
1361
1460
|
});
|
|
1362
1461
|
defineDefaultCommand({
|
|
1363
1462
|
fullSignature: "release",
|
|
@@ -1513,13 +1612,13 @@ async function extractUsage(factory, recursive = false, args = [""], locale = "e
|
|
|
1513
1612
|
const innerYargs = factory([""]);
|
|
1514
1613
|
innerYargs.locale(locale);
|
|
1515
1614
|
const doclet = {
|
|
1516
|
-
command:
|
|
1517
|
-
args:
|
|
1518
|
-
aliases:
|
|
1615
|
+
command: void 0,
|
|
1616
|
+
args: void 0,
|
|
1617
|
+
aliases: void 0,
|
|
1519
1618
|
deprecated: false,
|
|
1520
|
-
extractedUsage:
|
|
1521
|
-
rawUsage:
|
|
1522
|
-
children: recursive ? {} :
|
|
1619
|
+
extractedUsage: void 0,
|
|
1620
|
+
rawUsage: void 0,
|
|
1621
|
+
children: recursive ? {} : void 0
|
|
1523
1622
|
};
|
|
1524
1623
|
const parseCallback = function(err, argv, output) {
|
|
1525
1624
|
if (err)
|
|
@@ -1567,6 +1666,7 @@ globalThis.CLI = {
|
|
|
1567
1666
|
OutputUtils
|
|
1568
1667
|
};
|
|
1569
1668
|
CLIFactory.use(LoadEnvFile);
|
|
1669
|
+
CLIFactory.use(RegisterBumpVersionCommand);
|
|
1570
1670
|
CLIFactory.use(RegisterChangelogCommand);
|
|
1571
1671
|
CLIFactory.use(RegisterDocsCommands);
|
|
1572
1672
|
CLIFactory.use(RegisterGitHooksCommands);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { default as ESLint } from 'eslint';
|
|
2
2
|
import { default as LintStaged } from 'lint-staged';
|
|
3
|
+
import { UserConfig as CommitLintConfig } from '@commitlint/types';
|
|
3
4
|
import { SettingsLintMarkdown } from './types';
|
|
4
5
|
declare module '../../types' {
|
|
5
6
|
interface GlobalSettings {
|
|
@@ -14,10 +15,8 @@ declare module '../../types' {
|
|
|
14
15
|
default?: UserProvidedConfigSetting<ESLint.Linter.LegacyConfig | ESLint.Linter.Config | ESLint.Linter.Config[]>;
|
|
15
16
|
/**
|
|
16
17
|
* Configuration for commitlint
|
|
17
|
-
* See also: https://github.com/conventional-changelog/commitlint
|
|
18
|
-
* Default: `{ extends: [ '@commitlint/config-conventional' ] }`
|
|
19
18
|
*/
|
|
20
|
-
commit?: UserProvidedConfigSetting<
|
|
19
|
+
commit?: UserProvidedConfigSetting<CommitLintConfig>;
|
|
21
20
|
/**
|
|
22
21
|
* Configuration for markdownlint (markdownlint-cli2)
|
|
23
22
|
*/
|
|
@@ -5,7 +5,7 @@ import { SettingsLintMarkdown } from './types';
|
|
|
5
5
|
*/
|
|
6
6
|
export default function resolveSettings(settings?: Required<GlobalSettings>['lint']): {
|
|
7
7
|
default?: import('../..').UserProvidedConfigSetting<import("eslint").Linter.LegacyConfig | import("eslint").Linter.Config | import("eslint").Linter.Config[]>;
|
|
8
|
-
commit?: import('../..').UserProvidedConfigSetting<
|
|
8
|
+
commit?: import('../..').UserProvidedConfigSetting<import('@commitlint/types').UserConfig>;
|
|
9
9
|
markdown?: SettingsLintMarkdown;
|
|
10
10
|
staged?: import('../..').UserProvidedConfigSetting<import('lint-staged').Config>;
|
|
11
11
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* juisy v2.0.0-beta.
|
|
2
|
+
* juisy v2.0.0-beta.11
|
|
3
3
|
* Copyright © 2022-Present Hervé Perchec
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -241,7 +241,7 @@ function defineGlobals(config, builder) {
|
|
|
241
241
|
};
|
|
242
242
|
return deepmerge(GLOBALS, JSON.parse(JSON.stringify(builder(ctx))));
|
|
243
243
|
}
|
|
244
|
-
async function getProjectGlobals(filePath = "./globals.
|
|
244
|
+
async function getProjectGlobals(filePath = "./project.globals.js") {
|
|
245
245
|
return (await import(pathToFileURL(path.resolve(filePath)))).default;
|
|
246
246
|
}
|
|
247
247
|
|
|
@@ -66,7 +66,7 @@ export declare function defineGlobals(config: {
|
|
|
66
66
|
};
|
|
67
67
|
/**
|
|
68
68
|
* Get project globals
|
|
69
|
-
* @param filePath - The filePath. Default is `'./globals.
|
|
69
|
+
* @param filePath - The filePath. Default is `'./project.globals.js'`
|
|
70
70
|
* @returns The resolved project globals object
|
|
71
71
|
*/
|
|
72
72
|
export declare function getProjectGlobals(filePath?: string): Promise<ProjectGlobals>;
|
package/dist/templater/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* juisy v2.0.0-beta.
|
|
2
|
+
* juisy v2.0.0-beta.11
|
|
3
3
|
* Copyright © 2022-Present Hervé Perchec
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -28,7 +28,7 @@ class Templater {
|
|
|
28
28
|
this.methodsMap.compile = async (template) => {
|
|
29
29
|
return handlebars.compile(template, options.engineOptions);
|
|
30
30
|
};
|
|
31
|
-
this.methodsMap.render = async (template, data =
|
|
31
|
+
this.methodsMap.render = async (template, data = void 0, opts = void 0) => {
|
|
32
32
|
return this.methodsMap.compile(template).template(data);
|
|
33
33
|
};
|
|
34
34
|
break;
|
|
@@ -37,7 +37,7 @@ class Templater {
|
|
|
37
37
|
this.methodsMap.compile = async (template) => {
|
|
38
38
|
return ejs.compile(template, options.engineOptions);
|
|
39
39
|
};
|
|
40
|
-
this.methodsMap.render = async (template, data =
|
|
40
|
+
this.methodsMap.render = async (template, data = void 0, opts) => {
|
|
41
41
|
return ejs.render(template, data, {
|
|
42
42
|
...options.engineOptions,
|
|
43
43
|
...opts || {}
|
|
@@ -66,7 +66,7 @@ class Templater {
|
|
|
66
66
|
/**
|
|
67
67
|
* Renders a template with the given context.
|
|
68
68
|
*/
|
|
69
|
-
async render(template, data =
|
|
69
|
+
async render(template, data = void 0, options = void 0) {
|
|
70
70
|
const mergedData = { ...this.defaultData, ...data || {} };
|
|
71
71
|
return await this.methodsMap.render(template, mergedData, options);
|
|
72
72
|
}
|
|
@@ -99,8 +99,8 @@ class MarkdownTemplater extends Templater {
|
|
|
99
99
|
use: [
|
|
100
100
|
...options.use || []
|
|
101
101
|
],
|
|
102
|
-
toc: options.toc === true ? defaultRemarkTocOptions : options.toc !==
|
|
103
|
-
frontmatter: options.frontmatter === true ? defaultRemarkFrontmatterOptions : options.frontmatter !==
|
|
102
|
+
toc: options.toc === true ? defaultRemarkTocOptions : options.toc !== void 0 ? options.toc : defaultRemarkTocOptions,
|
|
103
|
+
frontmatter: options.frontmatter === true ? defaultRemarkFrontmatterOptions : options.frontmatter !== void 0 ? options.frontmatter : defaultRemarkFrontmatterOptions
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
initProcessor() {
|
|
@@ -116,7 +116,7 @@ class MarkdownTemplater extends Templater {
|
|
|
116
116
|
/**
|
|
117
117
|
* Renders a template with the given context.
|
|
118
118
|
*/
|
|
119
|
-
async render(template, data =
|
|
119
|
+
async render(template, data = void 0, options = void 0) {
|
|
120
120
|
const content = await super.render(template, data, options);
|
|
121
121
|
return (await this.processor.process(content)).toString();
|
|
122
122
|
}
|
|
@@ -184,7 +184,7 @@ class ReadmeTemplater {
|
|
|
184
184
|
}, data), options.data);
|
|
185
185
|
let template = await fs.readFile(processedConfig.templatePath, { encoding: "utf8" });
|
|
186
186
|
if (processedConfig.appendAutoGenMessage) {
|
|
187
|
-
template += "\n----\n
|
|
187
|
+
template += "\n----\n<!-- markdownlint-disable-next-line line-length -->\n*<%= $config.fileName %> - this file was auto generated with [juisy](https://www.npmjs.com/package/juisy) README templater. Don't edit it.*\n";
|
|
188
188
|
}
|
|
189
189
|
return await this.templater.render(template, ejsData, processedConfig.ejsOptions);
|
|
190
190
|
}
|
|
@@ -229,9 +229,9 @@ class ReadmeTemplater {
|
|
|
229
229
|
} else {
|
|
230
230
|
result.ejsOptions = ReadmeTemplater.defaultConfig.ejsOptions;
|
|
231
231
|
}
|
|
232
|
-
result.appendAutoGenMessage = customConfig.appendAutoGenMessage !==
|
|
233
|
-
result.autoToc = customConfig.autoToc !==
|
|
234
|
-
result.slugify = customConfig.slugify !==
|
|
232
|
+
result.appendAutoGenMessage = customConfig.appendAutoGenMessage !== void 0 ? customConfig.appendAutoGenMessage : ReadmeTemplater.defaultConfig.appendAutoGenMessage;
|
|
233
|
+
result.autoToc = customConfig.autoToc !== void 0 ? customConfig.autoToc : ReadmeTemplater.defaultConfig.autoToc;
|
|
234
|
+
result.slugify = customConfig.slugify !== void 0 ? customConfig.slugify : ReadmeTemplater.defaultConfig.slugify;
|
|
235
235
|
return result;
|
|
236
236
|
}
|
|
237
237
|
/**
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
export type Options = {
|
|
3
|
+
/**
|
|
4
|
+
* The virtual module ID
|
|
5
|
+
*/
|
|
6
|
+
moduleId: string;
|
|
7
|
+
/**
|
|
8
|
+
* The CSS selector. Default is `:root`
|
|
9
|
+
*/
|
|
10
|
+
selector?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The CSS variables object
|
|
13
|
+
*/
|
|
14
|
+
variables: Record<string, string>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Inject CSS variables via a virtual module
|
|
18
|
+
* @param opts - The plugin options or an array of options
|
|
19
|
+
* @returns {Plugin} The vite plugin function
|
|
20
|
+
*/
|
|
21
|
+
export declare function injectCssVariables(optsArg?: Options | Array<Options>): Plugin;
|
|
22
|
+
export default injectCssVariables;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* juisy v2.0.0-beta.11
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "juisy",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
4
|
-
"description": "Make
|
|
3
|
+
"version": "2.0.0-beta.11",
|
|
4
|
+
"description": "Make you JavaScript (and/or TypeScript) project juicy!",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"bin",
|
|
8
|
-
"dist"
|
|
9
|
-
"template"
|
|
8
|
+
"dist"
|
|
10
9
|
],
|
|
11
10
|
"engines": {
|
|
12
11
|
"node": "^18.0.0 || ^20.0.0 || >=22.0.0"
|
|
@@ -37,6 +36,10 @@
|
|
|
37
36
|
"./templater": {
|
|
38
37
|
"types": "./dist/templater/index.d.ts",
|
|
39
38
|
"import": "./dist/templater/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./vite-plugin-inject-css-variables": {
|
|
41
|
+
"types": "./dist/vite/plugins/inject-css-variables/index.d.ts",
|
|
42
|
+
"import": "./dist/vite/plugins/inject-css-variables/index.js"
|
|
40
43
|
}
|
|
41
44
|
},
|
|
42
45
|
"publishConfig": {
|
|
@@ -54,7 +57,7 @@
|
|
|
54
57
|
"example:reset": "git checkout --no-overlay -- example && cd example && git clean -fdX",
|
|
55
58
|
"example:test": "npm run example:reset && cd example && npm install -D juisy@file:../ && npx juisy squeeze && npm run docs:readme",
|
|
56
59
|
"print:globals": "node --no-warnings ./bin/cli print:globals",
|
|
57
|
-
"release": "release-it",
|
|
60
|
+
"release": "release-it --no-increment",
|
|
58
61
|
"test": "node ./bin/cli test",
|
|
59
62
|
"test:dev": "npm test -- --watch",
|
|
60
63
|
"test:ui": "npm test -- --ui"
|
|
@@ -81,14 +84,15 @@
|
|
|
81
84
|
"bugs": {
|
|
82
85
|
"url": "https://gitlab.com/hperchec/juisy/issues"
|
|
83
86
|
},
|
|
84
|
-
"homepage": "https://gitlab.
|
|
87
|
+
"homepage": "https://hperchec.gitlab.io/juisy",
|
|
85
88
|
"bin": {
|
|
86
89
|
"juisy": "./bin/cli/index.js"
|
|
87
90
|
},
|
|
88
91
|
"peerDependencies": {
|
|
89
92
|
"@commitlint/cli": "^19.6.1",
|
|
90
93
|
"@commitlint/config-conventional": "^19.6.0",
|
|
91
|
-
"@github/markdownlint-github": "^0.
|
|
94
|
+
"@github/markdownlint-github": "^0.6.3",
|
|
95
|
+
"@release-it/bumper": "6.0.1",
|
|
92
96
|
"@release-it/conventional-changelog": "^9.0.4",
|
|
93
97
|
"@stylistic/eslint-plugin": "^2",
|
|
94
98
|
"@typescript-eslint/eslint-plugin": "^8",
|
|
@@ -104,10 +108,10 @@
|
|
|
104
108
|
"yargs": "^17.7.2"
|
|
105
109
|
},
|
|
106
110
|
"peerDependenciesMeta": {
|
|
107
|
-
"@
|
|
111
|
+
"@release-it/bumper": {
|
|
108
112
|
"optional": true
|
|
109
113
|
},
|
|
110
|
-
"
|
|
114
|
+
"@release-it/conventional-changelog": {
|
|
111
115
|
"optional": true
|
|
112
116
|
}
|
|
113
117
|
},
|
|
@@ -127,6 +131,7 @@
|
|
|
127
131
|
"@types/lodash.set": "^4.3.9",
|
|
128
132
|
"@types/node": "^22.10.2",
|
|
129
133
|
"@types/prompts": "^2.4.9",
|
|
134
|
+
"@types/semver": "^7.5.8",
|
|
130
135
|
"@types/yargs": "^17.0.33",
|
|
131
136
|
"@types/yargs-parser": "^21.0.3",
|
|
132
137
|
"@typescript-eslint/eslint-plugin": "^8.18.1",
|
|
@@ -137,9 +142,12 @@
|
|
|
137
142
|
"happy-dom": "^15.11.7",
|
|
138
143
|
"json-schema-to-ts": "^3.1.1",
|
|
139
144
|
"lint-staged": "^14.0.1",
|
|
140
|
-
"markdown-table": "^3.0.4",
|
|
141
145
|
"npm-check-updates": "^17.1.12",
|
|
142
146
|
"quicktype": "^23.0.170",
|
|
147
|
+
"typedoc": "^0.28.1",
|
|
148
|
+
"typedoc-plugin-frontmatter": "^1.3.0",
|
|
149
|
+
"typedoc-plugin-markdown": "^4.5.2",
|
|
150
|
+
"typedoc-vitepress-theme": "^1.1.2",
|
|
143
151
|
"typescript": "^5.7.2",
|
|
144
152
|
"vite": "^5.4.11",
|
|
145
153
|
"vite-plugin-dts": "^4.3.0",
|
|
@@ -147,6 +155,7 @@
|
|
|
147
155
|
"vitest": "^2.1.8"
|
|
148
156
|
},
|
|
149
157
|
"dependencies": {
|
|
158
|
+
"@commitlint/types": "^19.8.0",
|
|
150
159
|
"@dotenvx/dotenvx": "^1.31.0",
|
|
151
160
|
"ascii-tree": "^0.3.0",
|
|
152
161
|
"chalk": "^4.1.2",
|
|
@@ -168,6 +177,7 @@
|
|
|
168
177
|
"lodash.merge": "^4.6.2",
|
|
169
178
|
"lodash.set": "^4.3.2",
|
|
170
179
|
"loglevel": "^1.9.2",
|
|
180
|
+
"markdown-table": "^3.0.4",
|
|
171
181
|
"markdown-toc": "^1.2.0",
|
|
172
182
|
"markdown-utils": "^1.0.0",
|
|
173
183
|
"package-json-type": "^1.0.3",
|
|
@@ -176,13 +186,10 @@
|
|
|
176
186
|
"remark": "^15.0.1",
|
|
177
187
|
"remark-frontmatter": "^5.0.0",
|
|
178
188
|
"remark-toc": "^9.0.0",
|
|
189
|
+
"semver": "^7.7.1",
|
|
179
190
|
"simple-git-hooks": "^2.9.0",
|
|
180
191
|
"strip-ansi": "^7.1.0",
|
|
181
192
|
"ts-json-schema-generator": "^2.3.0",
|
|
182
|
-
"typedoc": "^0.27.5",
|
|
183
|
-
"typedoc-plugin-frontmatter": "^1.1.2",
|
|
184
|
-
"typedoc-plugin-markdown": "^4.3.3",
|
|
185
|
-
"typedoc-vitepress-theme": "^1.1.1",
|
|
186
193
|
"yaml": "^2.6.1",
|
|
187
194
|
"yargs": "^17.7.2",
|
|
188
195
|
"yargs-parser": "^21.1.1"
|