@lytjs/cli 6.5.0 → 6.7.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/dist/create.cjs +1 -1
- package/dist/create.cjs.map +1 -1
- package/dist/create.mjs +1 -1
- package/dist/create.mjs.map +1 -1
- package/dist/index.cjs +128 -85
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +130 -87
- package/dist/index.mjs.map +1 -1
- package/dist/lyt.cjs +128 -85
- package/dist/lyt.cjs.map +1 -1
- package/dist/lyt.mjs +130 -87
- package/dist/lyt.mjs.map +1 -1
- package/lyt-cli.js +4 -3
- package/package.json +3 -3
- package/dist/create.d.mts +0 -2
- package/dist/create.d.ts +0 -2
- package/dist/index.d.mts +0 -208
- package/dist/index.d.ts +0 -208
- package/dist/lyt.d.mts +0 -1
- package/dist/lyt.d.ts +0 -1
package/dist/index.cjs
CHANGED
|
@@ -190,7 +190,7 @@ function generateProjectFiles(targetDir, projectName, template) {
|
|
|
190
190
|
},
|
|
191
191
|
devDependencies: {
|
|
192
192
|
"@lytjs/plugin-vite": "^6.0.0",
|
|
193
|
-
|
|
193
|
+
vite: "^5.0.0"
|
|
194
194
|
}
|
|
195
195
|
};
|
|
196
196
|
if (!isMinimal) {
|
|
@@ -746,9 +746,10 @@ async function test(options = {}) {
|
|
|
746
746
|
var TEMPLATES2 = {
|
|
747
747
|
component(name, basePath) {
|
|
748
748
|
const filePath = path.join(basePath, `${name}.lyt`);
|
|
749
|
-
return [
|
|
750
|
-
|
|
751
|
-
|
|
749
|
+
return [
|
|
750
|
+
{
|
|
751
|
+
filePath,
|
|
752
|
+
content: `<template>
|
|
752
753
|
<div class="${name}">
|
|
753
754
|
<slot />
|
|
754
755
|
</div>
|
|
@@ -770,14 +771,16 @@ defineEmits<{
|
|
|
770
771
|
}
|
|
771
772
|
</style>
|
|
772
773
|
`
|
|
773
|
-
|
|
774
|
+
}
|
|
775
|
+
];
|
|
774
776
|
},
|
|
775
777
|
page(name, basePath) {
|
|
776
778
|
const pascalName = toPascalCase(name);
|
|
777
779
|
const filePath = path.join(basePath, `${name}.lyt`);
|
|
778
|
-
return [
|
|
779
|
-
|
|
780
|
-
|
|
780
|
+
return [
|
|
781
|
+
{
|
|
782
|
+
filePath,
|
|
783
|
+
content: `<template>
|
|
781
784
|
<div class="page-${name}">
|
|
782
785
|
<h1>${pascalName}</h1>
|
|
783
786
|
</div>
|
|
@@ -793,13 +796,15 @@ defineEmits<{
|
|
|
793
796
|
}
|
|
794
797
|
</style>
|
|
795
798
|
`
|
|
796
|
-
|
|
799
|
+
}
|
|
800
|
+
];
|
|
797
801
|
},
|
|
798
802
|
store(name, basePath) {
|
|
799
803
|
const filePath = path.join(basePath, `${name}.ts`);
|
|
800
|
-
return [
|
|
801
|
-
|
|
802
|
-
|
|
804
|
+
return [
|
|
805
|
+
{
|
|
806
|
+
filePath,
|
|
807
|
+
content: `import { defineStore } from '@lytjs/store';
|
|
803
808
|
import { signal, computed } from '@lytjs/reactivity';
|
|
804
809
|
|
|
805
810
|
export const use${toPascalCase(name)}Store = defineStore('${name}', () => {
|
|
@@ -831,14 +836,16 @@ export const use${toPascalCase(name)}Store = defineStore('${name}', () => {
|
|
|
831
836
|
};
|
|
832
837
|
});
|
|
833
838
|
`
|
|
834
|
-
|
|
839
|
+
}
|
|
840
|
+
];
|
|
835
841
|
},
|
|
836
842
|
directive(name, basePath) {
|
|
837
843
|
const filePath = path.join(basePath, `${name}.ts`);
|
|
838
844
|
const camelCaseName = toCamelCase(name);
|
|
839
|
-
return [
|
|
840
|
-
|
|
841
|
-
|
|
845
|
+
return [
|
|
846
|
+
{
|
|
847
|
+
filePath,
|
|
848
|
+
content: `import type { Directive } from '@lytjs/core';
|
|
842
849
|
|
|
843
850
|
/**
|
|
844
851
|
* ${toPascalCase(name)} Directive
|
|
@@ -862,13 +869,15 @@ export const v${toPascalCase(name)}: Directive = {
|
|
|
862
869
|
},
|
|
863
870
|
};
|
|
864
871
|
`
|
|
865
|
-
|
|
872
|
+
}
|
|
873
|
+
];
|
|
866
874
|
},
|
|
867
875
|
composable(name, basePath) {
|
|
868
876
|
const filePath = path.join(basePath, `use${toPascalCase(name)}.ts`);
|
|
869
|
-
return [
|
|
870
|
-
|
|
871
|
-
|
|
877
|
+
return [
|
|
878
|
+
{
|
|
879
|
+
filePath,
|
|
880
|
+
content: `import { signal, computed } from '@lytjs/reactivity';
|
|
872
881
|
|
|
873
882
|
/**
|
|
874
883
|
* ${toPascalCase(name)} Composable
|
|
@@ -917,13 +926,15 @@ export function use${toPascalCase(name)}() {
|
|
|
917
926
|
};
|
|
918
927
|
}
|
|
919
928
|
`
|
|
920
|
-
|
|
929
|
+
}
|
|
930
|
+
];
|
|
921
931
|
},
|
|
922
932
|
hook(name, basePath) {
|
|
923
933
|
const filePath = path.join(basePath, `use${toPascalCase(name)}.ts`);
|
|
924
|
-
return [
|
|
925
|
-
|
|
926
|
-
|
|
934
|
+
return [
|
|
935
|
+
{
|
|
936
|
+
filePath,
|
|
937
|
+
content: `import { signal, onMounted, onUnmounted } from '@lytjs/core';
|
|
927
938
|
|
|
928
939
|
/**
|
|
929
940
|
* ${toPascalCase(name)} Hook
|
|
@@ -944,13 +955,15 @@ export function use${toPascalCase(name)}() {
|
|
|
944
955
|
};
|
|
945
956
|
}
|
|
946
957
|
`
|
|
947
|
-
|
|
958
|
+
}
|
|
959
|
+
];
|
|
948
960
|
},
|
|
949
961
|
util(name, basePath) {
|
|
950
962
|
const filePath = path.join(basePath, `${name}.ts`);
|
|
951
|
-
return [
|
|
952
|
-
|
|
953
|
-
|
|
963
|
+
return [
|
|
964
|
+
{
|
|
965
|
+
filePath,
|
|
966
|
+
content: `/**
|
|
954
967
|
* ${toPascalCase(name)} Utility Functions
|
|
955
968
|
*/
|
|
956
969
|
|
|
@@ -965,13 +978,15 @@ export function ${toCamelCase(name)}(input: any) {
|
|
|
965
978
|
return input;
|
|
966
979
|
}
|
|
967
980
|
`
|
|
968
|
-
|
|
981
|
+
}
|
|
982
|
+
];
|
|
969
983
|
},
|
|
970
984
|
middleware(name, basePath) {
|
|
971
985
|
const filePath = path.join(basePath, `${name}.ts`);
|
|
972
|
-
return [
|
|
973
|
-
|
|
974
|
-
|
|
986
|
+
return [
|
|
987
|
+
{
|
|
988
|
+
filePath,
|
|
989
|
+
content: `import type { NavigationGuard } from '@lytjs/router';
|
|
975
990
|
|
|
976
991
|
/**
|
|
977
992
|
* ${toPascalCase(name)} Middleware
|
|
@@ -982,7 +997,8 @@ export const ${toCamelCase(name)}Middleware: NavigationGuard = (to, from, next)
|
|
|
982
997
|
next();
|
|
983
998
|
};
|
|
984
999
|
`
|
|
985
|
-
|
|
1000
|
+
}
|
|
1001
|
+
];
|
|
986
1002
|
}
|
|
987
1003
|
};
|
|
988
1004
|
function toPascalCase(str) {
|
|
@@ -1537,11 +1553,7 @@ async function generate(options) {
|
|
|
1537
1553
|
layout: "layouts",
|
|
1538
1554
|
middleware: "middleware"
|
|
1539
1555
|
};
|
|
1540
|
-
const targetDir = path__namespace.join(
|
|
1541
|
-
process.cwd(),
|
|
1542
|
-
basePath,
|
|
1543
|
-
typeDirs[type] || "components"
|
|
1544
|
-
);
|
|
1556
|
+
const targetDir = path__namespace.join(process.cwd(), basePath, typeDirs[type] || "components");
|
|
1545
1557
|
await ensureDir(targetDir);
|
|
1546
1558
|
const templateFn = TEMPLATES3[type];
|
|
1547
1559
|
if (!templateFn) {
|
|
@@ -1573,7 +1585,9 @@ async function generate(options) {
|
|
|
1573
1585
|
}
|
|
1574
1586
|
logger.info("\nNext steps:");
|
|
1575
1587
|
logger.info(` cd ${targetDir}`);
|
|
1576
|
-
logger.info(
|
|
1588
|
+
logger.info(
|
|
1589
|
+
` Import your ${type}: import { ${template === "sfc" ? "default" : templateData.pascalName} } from './${templateData.kebabName}'`
|
|
1590
|
+
);
|
|
1577
1591
|
logger.info("\nAvailable options:");
|
|
1578
1592
|
logger.info(" --template=sfc : Single File Component (.lyt)");
|
|
1579
1593
|
logger.info(" --template=functional : Functional component");
|
|
@@ -1587,45 +1601,53 @@ var PLUGIN_TEMPLATES = {
|
|
|
1587
1601
|
function getTemplateContent(template, pluginName) {
|
|
1588
1602
|
const packageName = `@lytjs/plugin-${pluginName}`;
|
|
1589
1603
|
const files = {};
|
|
1590
|
-
files["package.json"] = JSON.stringify(
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1604
|
+
files["package.json"] = JSON.stringify(
|
|
1605
|
+
{
|
|
1606
|
+
name: packageName,
|
|
1607
|
+
version: "0.1.0",
|
|
1608
|
+
description: `LytJS plugin: ${pluginName}`,
|
|
1609
|
+
main: "dist/index.cjs",
|
|
1610
|
+
module: "dist/index.mjs",
|
|
1611
|
+
types: "dist/index.d.ts",
|
|
1612
|
+
exports: {
|
|
1613
|
+
".": {
|
|
1614
|
+
import: "./dist/index.mjs",
|
|
1615
|
+
require: "./dist/index.cjs",
|
|
1616
|
+
types: "./dist/index.d.ts"
|
|
1617
|
+
}
|
|
1618
|
+
},
|
|
1619
|
+
files: ["dist"],
|
|
1620
|
+
scripts: {
|
|
1621
|
+
build: "tsup",
|
|
1622
|
+
dev: "tsup --watch",
|
|
1623
|
+
test: "vitest",
|
|
1624
|
+
lint: "eslint src",
|
|
1625
|
+
prepublishOnly: "npm run build"
|
|
1626
|
+
},
|
|
1627
|
+
keywords: ["lytjs", "plugin"],
|
|
1628
|
+
license: "MIT",
|
|
1629
|
+
peerDependencies: {
|
|
1630
|
+
"@lytjs/core": ">=6.0.0"
|
|
1602
1631
|
}
|
|
1603
1632
|
},
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
files["tsconfig.json"] = JSON.stringify({
|
|
1619
|
-
extends: "@lytjs/core/tsconfig.json",
|
|
1620
|
-
compilerOptions: {
|
|
1621
|
-
outDir: "./dist",
|
|
1622
|
-
rootDir: "./src",
|
|
1623
|
-
declaration: true,
|
|
1624
|
-
declarationMap: true
|
|
1633
|
+
null,
|
|
1634
|
+
2
|
|
1635
|
+
);
|
|
1636
|
+
files["tsconfig.json"] = JSON.stringify(
|
|
1637
|
+
{
|
|
1638
|
+
extends: "@lytjs/core/tsconfig.json",
|
|
1639
|
+
compilerOptions: {
|
|
1640
|
+
outDir: "./dist",
|
|
1641
|
+
rootDir: "./src",
|
|
1642
|
+
declaration: true,
|
|
1643
|
+
declarationMap: true
|
|
1644
|
+
},
|
|
1645
|
+
include: ["src"],
|
|
1646
|
+
exclude: ["node_modules", "dist", "tests"]
|
|
1625
1647
|
},
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1648
|
+
null,
|
|
1649
|
+
2
|
|
1650
|
+
);
|
|
1629
1651
|
files["tsup.config.ts"] = `import { defineConfig } from 'tsup';
|
|
1630
1652
|
|
|
1631
1653
|
export default defineConfig({
|
|
@@ -1837,7 +1859,16 @@ async function buildPlugin(options = {}) {
|
|
|
1837
1859
|
logger.info("Building plugin...");
|
|
1838
1860
|
try {
|
|
1839
1861
|
const buildCmd = "tsup";
|
|
1840
|
-
const args = [
|
|
1862
|
+
const args = [
|
|
1863
|
+
"--entry",
|
|
1864
|
+
"src/index.ts",
|
|
1865
|
+
"--outDir",
|
|
1866
|
+
outDir,
|
|
1867
|
+
"--format",
|
|
1868
|
+
"esm,cjs",
|
|
1869
|
+
"--dts",
|
|
1870
|
+
"--sourcemap"
|
|
1871
|
+
];
|
|
1841
1872
|
if (options.minify) {
|
|
1842
1873
|
args.push("--minify");
|
|
1843
1874
|
}
|
|
@@ -1903,8 +1934,8 @@ async function validatePlugin(options = {}) {
|
|
|
1903
1934
|
if (!fs.existsSync(tsupConfigPath)) {
|
|
1904
1935
|
warnings.push("tsup.config.ts not found (recommended for builds)");
|
|
1905
1936
|
}
|
|
1906
|
-
|
|
1907
|
-
|
|
1937
|
+
const hasErrors = errors.length > 0;
|
|
1938
|
+
const hasWarnings = warnings.length > 0;
|
|
1908
1939
|
if (hasErrors) {
|
|
1909
1940
|
logger.error("Validation failed with errors:");
|
|
1910
1941
|
for (const err of errors) {
|
|
@@ -1933,7 +1964,7 @@ async function validatePlugin(options = {}) {
|
|
|
1933
1964
|
}
|
|
1934
1965
|
function isEmptyDir2(dir) {
|
|
1935
1966
|
if (!fs.existsSync(dir)) return true;
|
|
1936
|
-
const files =
|
|
1967
|
+
const files = readdirSync(dir);
|
|
1937
1968
|
return files.length === 0;
|
|
1938
1969
|
}
|
|
1939
1970
|
function listPluginTemplates() {
|
|
@@ -1952,7 +1983,7 @@ async function runCli(rawArgs = process.argv.slice(2)) {
|
|
|
1952
1983
|
return;
|
|
1953
1984
|
}
|
|
1954
1985
|
if (options.version || command === "version" || command === "-v" || command === "--version") {
|
|
1955
|
-
console.
|
|
1986
|
+
console.warn(`LytJS CLI v${VERSION}`);
|
|
1956
1987
|
return;
|
|
1957
1988
|
}
|
|
1958
1989
|
switch (command) {
|
|
@@ -1986,8 +2017,17 @@ async function runCli(rawArgs = process.argv.slice(2)) {
|
|
|
1986
2017
|
grep: options.grep
|
|
1987
2018
|
});
|
|
1988
2019
|
break;
|
|
1989
|
-
case "add":
|
|
1990
|
-
const addTypes = [
|
|
2020
|
+
case "add": {
|
|
2021
|
+
const addTypes = [
|
|
2022
|
+
"component",
|
|
2023
|
+
"page",
|
|
2024
|
+
"store",
|
|
2025
|
+
"directive",
|
|
2026
|
+
"composable",
|
|
2027
|
+
"util",
|
|
2028
|
+
"middleware",
|
|
2029
|
+
"hook"
|
|
2030
|
+
];
|
|
1991
2031
|
if (!args[0] || !addTypes.includes(args[0])) {
|
|
1992
2032
|
logger.error("Usage: lyt add <type> <name>");
|
|
1993
2033
|
logger.info("Types: component, page, store, directive, composable, util, middleware, hook");
|
|
@@ -1998,8 +2038,9 @@ async function runCli(rawArgs = process.argv.slice(2)) {
|
|
|
1998
2038
|
force: options.force
|
|
1999
2039
|
});
|
|
2000
2040
|
break;
|
|
2041
|
+
}
|
|
2001
2042
|
case "generate":
|
|
2002
|
-
case "g":
|
|
2043
|
+
case "g": {
|
|
2003
2044
|
const genTypes = ["component", "page", "service", "hook", "store"];
|
|
2004
2045
|
if (!args[0] || !genTypes.includes(args[0])) {
|
|
2005
2046
|
logger.error("Usage: lyt generate <type> <name>");
|
|
@@ -2016,7 +2057,8 @@ async function runCli(rawArgs = process.argv.slice(2)) {
|
|
|
2016
2057
|
withStorybook: options.storybook
|
|
2017
2058
|
});
|
|
2018
2059
|
break;
|
|
2019
|
-
|
|
2060
|
+
}
|
|
2061
|
+
case "plugin": {
|
|
2020
2062
|
if (!args[0]) {
|
|
2021
2063
|
logger.error("Usage: lyt plugin <create|build|validate|templates>");
|
|
2022
2064
|
logger.info("Example: lyt plugin create my-plugin");
|
|
@@ -2053,6 +2095,7 @@ async function runCli(rawArgs = process.argv.slice(2)) {
|
|
|
2053
2095
|
process.exit(1);
|
|
2054
2096
|
}
|
|
2055
2097
|
break;
|
|
2098
|
+
}
|
|
2056
2099
|
default:
|
|
2057
2100
|
if (command) {
|
|
2058
2101
|
logger.error(`Unknown command: ${command}`);
|
|
@@ -2099,7 +2142,7 @@ function parseArgs(args) {
|
|
|
2099
2142
|
return { command, args: positional, options };
|
|
2100
2143
|
}
|
|
2101
2144
|
function showHelp() {
|
|
2102
|
-
console.
|
|
2145
|
+
console.warn(`
|
|
2103
2146
|
${logger.bold("LytJS CLI")} v${VERSION}
|
|
2104
2147
|
|
|
2105
2148
|
${logger.bold("Usage:")}
|