@apex-stack/core 0.4.1 → 0.5.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/add-M3YLIFF5.js +113 -0
- package/dist/cli.js +1 -1
- package/package.json +3 -3
- package/dist/add-Z7JSLBOT.js +0 -85
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {
|
|
2
|
+
banner,
|
|
3
|
+
color
|
|
4
|
+
} from "./chunk-QIXJSQLW.js";
|
|
5
|
+
|
|
6
|
+
// src/commands/add.ts
|
|
7
|
+
import { cpSync, existsSync, mkdirSync, readFileSync } from "fs";
|
|
8
|
+
import { dirname, join, resolve } from "path";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
|
+
import { defineCommand } from "citty";
|
|
11
|
+
var REGISTRY_DIR = fileURLToPath(new URL("../components", import.meta.url));
|
|
12
|
+
function loadRegistry() {
|
|
13
|
+
const p = join(REGISTRY_DIR, "registry.json");
|
|
14
|
+
if (!existsSync(p)) return {};
|
|
15
|
+
try {
|
|
16
|
+
return JSON.parse(readFileSync(p, "utf8"));
|
|
17
|
+
} catch {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
var addCommand = defineCommand({
|
|
22
|
+
meta: {
|
|
23
|
+
name: "add",
|
|
24
|
+
description: "Add a themeable component into your project (copies the .alpine source)"
|
|
25
|
+
},
|
|
26
|
+
args: {
|
|
27
|
+
name: {
|
|
28
|
+
type: "positional",
|
|
29
|
+
required: false,
|
|
30
|
+
description: "Component(s) to add, space-separated (e.g. button card modal)"
|
|
31
|
+
},
|
|
32
|
+
all: { type: "boolean", default: false, description: "Add every component in the registry" },
|
|
33
|
+
root: { type: "string", description: "Project root", default: "." },
|
|
34
|
+
force: { type: "boolean", default: false, description: "Overwrite existing component files" }
|
|
35
|
+
},
|
|
36
|
+
run({ args }) {
|
|
37
|
+
const registry = loadRegistry();
|
|
38
|
+
const log = console.log;
|
|
39
|
+
process.stdout.write(banner());
|
|
40
|
+
const keys = Object.keys(registry);
|
|
41
|
+
if (!keys.length) {
|
|
42
|
+
console.error(` ${color.red("\u2717")} No component registry bundled in this build.
|
|
43
|
+
`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
const rest = args._ ?? [];
|
|
47
|
+
const requested = args.all ? keys : [
|
|
48
|
+
...new Set(
|
|
49
|
+
[...rest, ...args.name ? [String(args.name)] : []].map((s) => s.toLowerCase())
|
|
50
|
+
)
|
|
51
|
+
];
|
|
52
|
+
if (!requested.length) {
|
|
53
|
+
log(
|
|
54
|
+
` ${color.bold("Available components")} ${color.gray("\u2014 apex add <name...> | --all")}
|
|
55
|
+
`
|
|
56
|
+
);
|
|
57
|
+
for (const k of keys) {
|
|
58
|
+
log(` ${color.cyan(k.padEnd(14))} ${color.gray(registry[k]?.description ?? "")}`);
|
|
59
|
+
}
|
|
60
|
+
log(
|
|
61
|
+
`
|
|
62
|
+
${color.gray("Pick several at once, e.g.")} ${color.cyan("apex add button card modal")}
|
|
63
|
+
`
|
|
64
|
+
);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const unknown = requested.filter((k) => !registry[k]);
|
|
68
|
+
if (unknown.length) {
|
|
69
|
+
console.error(
|
|
70
|
+
` ${color.red("\u2717")} Unknown component(s): ${unknown.join(", ")}. Run ${color.cyan("apex add")} to list.
|
|
71
|
+
`
|
|
72
|
+
);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
const root = resolve(process.cwd(), String(args.root));
|
|
76
|
+
const added = [];
|
|
77
|
+
const skipped = [];
|
|
78
|
+
for (const key of requested) {
|
|
79
|
+
const entry = registry[key];
|
|
80
|
+
const dest = join(root, "components", `${entry.name}.alpine`);
|
|
81
|
+
if (existsSync(dest) && !args.force) {
|
|
82
|
+
skipped.push(entry.name);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
86
|
+
cpSync(join(REGISTRY_DIR, entry.file), dest);
|
|
87
|
+
added.push(entry.name);
|
|
88
|
+
}
|
|
89
|
+
if (added.length) {
|
|
90
|
+
log(
|
|
91
|
+
` ${color.green("+")} Added ${added.length} component(s) to ${color.bold("components/")}:`
|
|
92
|
+
);
|
|
93
|
+
for (const n of added) log(` ${color.green(`${n}.alpine`)} ${color.gray(`<${n} />`)}`);
|
|
94
|
+
}
|
|
95
|
+
if (skipped.length) {
|
|
96
|
+
log(
|
|
97
|
+
` ${color.gray(`\u2022 Skipped ${skipped.length} existing: ${skipped.join(", ")} (use --force)`)}`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
const appCss = ["app.css", "styles/app.css", "src/app.css"].map((p) => join(root, p)).find(existsSync);
|
|
101
|
+
const themed = appCss ? readFileSync(appCss, "utf8").includes("@theme") : false;
|
|
102
|
+
if (!themed && added.length) {
|
|
103
|
+
log(
|
|
104
|
+
`
|
|
105
|
+
${color.gray("Tip: run")} ${color.cyan("apex theme")} ${color.gray("to set up Tailwind + the theme (apps from")} ${color.cyan("apex new")} ${color.gray("already have it).")}`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
log("");
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
export {
|
|
112
|
+
addCommand
|
|
113
|
+
};
|
package/dist/cli.js
CHANGED
|
@@ -151,7 +151,7 @@ var main = defineCommand2({
|
|
|
151
151
|
build: () => import("./build-VHS6KZBK.js").then((m) => m.buildCommand),
|
|
152
152
|
start: () => import("./start-3O3E43PT.js").then((m) => m.startCommand),
|
|
153
153
|
make: () => import("./make-VAYO5GWA.js").then((m) => m.makeCommand),
|
|
154
|
-
add: () => import("./add-
|
|
154
|
+
add: () => import("./add-M3YLIFF5.js").then((m) => m.addCommand),
|
|
155
155
|
theme: () => import("./theme-UUOIV44V.js").then((m) => m.themeCommand),
|
|
156
156
|
upgrade: () => import("./upgrade-WC5F5FKY.js").then((m) => m.upgradeCommand),
|
|
157
157
|
migrate: () => import("./migrate-X6LIHMIE.js").then((m) => m.migrateCommand),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apex-stack/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "The full-stack meta-framework for Alpine.js — CLI and runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"vite": "^6.0.7",
|
|
49
49
|
"zod": "^4.4.3",
|
|
50
50
|
"@apex-stack/kit": "0.2.0",
|
|
51
|
-
"@apex-stack/
|
|
52
|
-
"@apex-stack/
|
|
51
|
+
"@apex-stack/vite": "0.1.6",
|
|
52
|
+
"@apex-stack/theme": "0.3.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"alpinejs": "^3.14.0"
|
package/dist/add-Z7JSLBOT.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
banner,
|
|
3
|
-
color
|
|
4
|
-
} from "./chunk-QIXJSQLW.js";
|
|
5
|
-
|
|
6
|
-
// src/commands/add.ts
|
|
7
|
-
import { cpSync, existsSync, mkdirSync, readFileSync } from "fs";
|
|
8
|
-
import { dirname, join, resolve } from "path";
|
|
9
|
-
import { fileURLToPath } from "url";
|
|
10
|
-
import { defineCommand } from "citty";
|
|
11
|
-
var REGISTRY_DIR = fileURLToPath(new URL("../components", import.meta.url));
|
|
12
|
-
function loadRegistry() {
|
|
13
|
-
const p = join(REGISTRY_DIR, "registry.json");
|
|
14
|
-
if (!existsSync(p)) return {};
|
|
15
|
-
try {
|
|
16
|
-
return JSON.parse(readFileSync(p, "utf8"));
|
|
17
|
-
} catch {
|
|
18
|
-
return {};
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
var addCommand = defineCommand({
|
|
22
|
-
meta: {
|
|
23
|
-
name: "add",
|
|
24
|
-
description: "Add a themeable component into your project (copies the .alpine source)"
|
|
25
|
-
},
|
|
26
|
-
args: {
|
|
27
|
-
name: { type: "positional", required: false, description: "Component to add (e.g. button)" },
|
|
28
|
-
root: { type: "string", description: "Project root", default: "." },
|
|
29
|
-
force: { type: "boolean", default: false, description: "Overwrite an existing component file" }
|
|
30
|
-
},
|
|
31
|
-
run({ args }) {
|
|
32
|
-
const registry = loadRegistry();
|
|
33
|
-
const log = console.log;
|
|
34
|
-
process.stdout.write(banner());
|
|
35
|
-
const keys = Object.keys(registry);
|
|
36
|
-
if (!keys.length) {
|
|
37
|
-
console.error(` ${color.red("\u2717")} No component registry bundled in this build.
|
|
38
|
-
`);
|
|
39
|
-
process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
const name = args.name ? String(args.name).toLowerCase() : "";
|
|
42
|
-
if (!name) {
|
|
43
|
-
log(` ${color.bold("Available components")} ${color.gray("\u2014 apex add <name>")}
|
|
44
|
-
`);
|
|
45
|
-
for (const k of keys) {
|
|
46
|
-
log(` ${color.cyan(k.padEnd(12))} ${color.gray(registry[k]?.description ?? "")}`);
|
|
47
|
-
}
|
|
48
|
-
log("");
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const entry = registry[name];
|
|
52
|
-
if (!entry) {
|
|
53
|
-
console.error(
|
|
54
|
-
` ${color.red("\u2717")} Unknown component "${name}". Available: ${keys.join(", ")}
|
|
55
|
-
`
|
|
56
|
-
);
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
|
-
const root = resolve(process.cwd(), String(args.root));
|
|
60
|
-
const dest = join(root, "components", `${entry.name}.alpine`);
|
|
61
|
-
if (existsSync(dest) && !args.force) {
|
|
62
|
-
log(
|
|
63
|
-
` ${color.gray("\u2022")} ${entry.name} already exists at components/${entry.name}.alpine ${color.gray("(use --force to overwrite)")}
|
|
64
|
-
`
|
|
65
|
-
);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
mkdirSync(dirname(dest), { recursive: true });
|
|
69
|
-
cpSync(join(REGISTRY_DIR, entry.file), dest);
|
|
70
|
-
log(` ${color.green("+")} Added ${color.bold(`components/${entry.name}.alpine`)}`);
|
|
71
|
-
log(`
|
|
72
|
-
Use it: ${color.cyan(`<${entry.name} />`)} ${color.gray("in any page/component.")}`);
|
|
73
|
-
const appCss = ["app.css", "styles/app.css", "src/app.css"].map((p) => join(root, p)).find(existsSync);
|
|
74
|
-
const themed = appCss ? readFileSync(appCss, "utf8").includes("@theme") : false;
|
|
75
|
-
if (!themed) {
|
|
76
|
-
log(
|
|
77
|
-
` ${color.gray("Tip: run")} ${color.cyan("apex theme")} ${color.gray("to set up Tailwind + the theme so it styles up (apps from")} ${color.cyan("apex new")} ${color.gray("already have it).")}`
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
log("");
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
export {
|
|
84
|
-
addCommand
|
|
85
|
-
};
|