@lumerahq/cli 0.19.3-dev.0 → 0.19.3

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.
Files changed (42) hide show
  1. package/README.md +5 -3
  2. package/dist/chunk-H357NP7T.js +77 -0
  3. package/dist/{chunk-GKI2HQJC.js → chunk-JKXLKK5I.js} +14 -1
  4. package/dist/chunk-P5HFNAVN.js +280 -0
  5. package/dist/{chunk-53NOF33P.js → chunk-SU26C4GL.js} +9 -49
  6. package/dist/{deps-ULTIIDYK.js → deps-EC3VRNN7.js} +4 -2
  7. package/dist/{dev-5JMHMS4U.js → dev-R43VQCZD.js} +9 -2
  8. package/dist/index.js +13 -13
  9. package/dist/{init-37XOMJLU.js → init-TDIQAOG4.js} +29 -9
  10. package/dist/{register-JJUMS4FI.js → register-JFJADKAJ.js} +1 -1
  11. package/dist/{resources-4IUZYKGX.js → resources-OP7EECKZ.js} +20 -92
  12. package/dist/{run-5ZOSPBGO.js → run-EJP5WCQU.js} +1 -1
  13. package/dist/{templates-M3RDNDDY.js → templates-LNUOTNLN.js} +2 -3
  14. package/package.json +1 -1
  15. package/templates/default/.agents/skills/.gitkeep +0 -0
  16. package/templates/default/AGENTS.md +151 -0
  17. package/templates/default/README.md +18 -0
  18. package/templates/default/_gitignore +14 -0
  19. package/templates/default/architecture.md +29 -0
  20. package/templates/default/biome.json +38 -0
  21. package/templates/default/components.json +21 -0
  22. package/templates/default/icon.svg +29 -0
  23. package/templates/default/index.html +16 -0
  24. package/templates/default/package.json +53 -0
  25. package/templates/default/platform/automations/.gitkeep +0 -0
  26. package/templates/default/platform/collections/.gitkeep +0 -0
  27. package/templates/default/platform/hooks/.gitkeep +0 -0
  28. package/templates/default/pyproject.toml +14 -0
  29. package/templates/default/scripts/.gitkeep +0 -0
  30. package/templates/default/src/components/layout.tsx +11 -0
  31. package/templates/default/src/lib/auth.ts +9 -0
  32. package/templates/default/src/lib/queries.ts +17 -0
  33. package/templates/default/src/lib/utils.ts +6 -0
  34. package/templates/default/src/main.tsx +130 -0
  35. package/templates/default/src/routes/__root.tsx +10 -0
  36. package/templates/default/src/routes/index.tsx +87 -0
  37. package/templates/default/src/styles.css +128 -0
  38. package/templates/default/template.json +7 -0
  39. package/templates/default/tsconfig.json +22 -0
  40. package/templates/default/vite.config.ts +28 -0
  41. package/dist/chunk-OQW5E7UT.js +0 -159
  42. package/dist/chunk-XDTWVFPE.js +0 -120
@@ -1,159 +0,0 @@
1
- import {
2
- fetchWithRetry
3
- } from "./chunk-FJFIWC7G.js";
4
-
5
- // src/lib/templates.ts
6
- import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, unlinkSync, writeFileSync } from "fs";
7
- import { homedir, tmpdir } from "os";
8
- import { join } from "path";
9
- import { spawnSync } from "child_process";
10
- var GITHUB_OWNER = "lumerahq";
11
- var GITHUB_REPO = "app-templates";
12
- var GITHUB_REF = "main";
13
- function getCacheDir() {
14
- return join(homedir(), ".lumera", "templates");
15
- }
16
- function readCacheMeta() {
17
- const metaPath = join(getCacheDir(), ".cache-meta.json");
18
- if (!existsSync(metaPath)) return null;
19
- try {
20
- return JSON.parse(readFileSync(metaPath, "utf-8"));
21
- } catch {
22
- return null;
23
- }
24
- }
25
- async function fetchLatestSha() {
26
- const url = `https://api.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPO}/commits/${GITHUB_REF}`;
27
- const res = await fetchWithRetry(url, {
28
- headers: { Accept: "application/vnd.github.sha" }
29
- });
30
- if (!res.ok) throw new Error(`GitHub API error: ${res.status}`);
31
- return (await res.text()).trim();
32
- }
33
- async function downloadAndExtract(commitSha) {
34
- const cacheDir = getCacheDir();
35
- const tarballUrl = `https://github.com/${GITHUB_OWNER}/${GITHUB_REPO}/archive/refs/heads/${GITHUB_REF}.tar.gz`;
36
- const res = await fetchWithRetry(tarballUrl);
37
- if (!res.ok) throw new Error(`Failed to download templates: ${res.status}`);
38
- const tmpFile = join(tmpdir(), `lumera-templates-${Date.now()}.tar.gz`);
39
- const buffer = Buffer.from(await res.arrayBuffer());
40
- writeFileSync(tmpFile, buffer);
41
- mkdirSync(cacheDir, { recursive: true });
42
- for (const entry of readdirSync(cacheDir)) {
43
- if (entry === ".cache-meta.json" || entry === ".refs") continue;
44
- rmSync(join(cacheDir, entry), { recursive: true, force: true });
45
- }
46
- const result = spawnSync("tar", ["xzf", tmpFile, "-C", cacheDir, "--strip-components=1"], { stdio: "ignore" });
47
- if (result.status !== 0) throw new Error("Failed to extract template archive");
48
- unlinkSync(tmpFile);
49
- const meta = { commitSha, fetchedAt: (/* @__PURE__ */ new Date()).toISOString() };
50
- writeFileSync(join(cacheDir, ".cache-meta.json"), JSON.stringify(meta));
51
- return cacheDir;
52
- }
53
- async function ensureRemoteCache() {
54
- const cacheDir = getCacheDir();
55
- const cached = readCacheMeta();
56
- const latestSha = await fetchLatestSha();
57
- if (cached?.commitSha === latestSha && existsSync(cacheDir)) {
58
- return cacheDir;
59
- }
60
- console.log(" Fetching latest templates...");
61
- return downloadAndExtract(latestSha);
62
- }
63
- function parseTemplateRef(input) {
64
- const atIndex = input.lastIndexOf("@");
65
- if (atIndex > 0) {
66
- return {
67
- name: input.slice(0, atIndex),
68
- ref: input.slice(atIndex + 1)
69
- };
70
- }
71
- return { name: input, ref: null };
72
- }
73
- async function ensureRemoteCacheForRef(ref) {
74
- const refCacheDir = join(getCacheDir(), ".refs", ref);
75
- if (existsSync(refCacheDir) && existsSync(join(refCacheDir, ".cache-meta.json"))) {
76
- return refCacheDir;
77
- }
78
- console.log(` Fetching templates at ref "${ref}"...`);
79
- const urls = [
80
- `https://github.com/${GITHUB_OWNER}/${GITHUB_REPO}/archive/refs/tags/${ref}.tar.gz`,
81
- `https://github.com/${GITHUB_OWNER}/${GITHUB_REPO}/archive/refs/heads/${ref}.tar.gz`,
82
- `https://github.com/${GITHUB_OWNER}/${GITHUB_REPO}/archive/${ref}.tar.gz`
83
- ];
84
- let res = null;
85
- for (const url of urls) {
86
- const attempt = await fetchWithRetry(url);
87
- if (attempt.ok) {
88
- res = attempt;
89
- break;
90
- }
91
- }
92
- if (!res) {
93
- throw new Error(
94
- `Failed to fetch templates at ref "${ref}". Ensure the tag, branch, or SHA exists in ${GITHUB_OWNER}/${GITHUB_REPO}.`
95
- );
96
- }
97
- const tmpFile = join(tmpdir(), `lumera-templates-${ref}-${Date.now()}.tar.gz`);
98
- const buffer = Buffer.from(await res.arrayBuffer());
99
- writeFileSync(tmpFile, buffer);
100
- mkdirSync(refCacheDir, { recursive: true });
101
- const result = spawnSync("tar", ["xzf", tmpFile, "-C", refCacheDir, "--strip-components=1"], { stdio: "ignore" });
102
- if (result.status !== 0) throw new Error("Failed to extract template archive");
103
- unlinkSync(tmpFile);
104
- const meta = { commitSha: ref, fetchedAt: (/* @__PURE__ */ new Date()).toISOString() };
105
- writeFileSync(join(refCacheDir, ".cache-meta.json"), JSON.stringify(meta));
106
- return refCacheDir;
107
- }
108
- function listTemplates(baseDir) {
109
- if (!existsSync(baseDir)) return [];
110
- const templates = [];
111
- for (const entry of readdirSync(baseDir, { withFileTypes: true })) {
112
- if (!entry.isDirectory()) continue;
113
- const metaPath = join(baseDir, entry.name, "template.json");
114
- if (!existsSync(metaPath)) continue;
115
- try {
116
- const raw = JSON.parse(readFileSync(metaPath, "utf-8"));
117
- if (!raw.name || !raw.title || !raw.description || !raw.category) {
118
- console.warn(`Warning: Skipping template "${entry.name}" \u2014 template.json is missing required fields (name, title, description, category)`);
119
- continue;
120
- }
121
- templates.push(raw);
122
- } catch {
123
- console.warn(`Warning: Skipping template "${entry.name}" \u2014 invalid template.json`);
124
- }
125
- }
126
- return templates.sort((a, b) => {
127
- if (a.name === "default") return -1;
128
- if (b.name === "default") return 1;
129
- return a.title.localeCompare(b.title);
130
- });
131
- }
132
- async function resolveTemplate(nameWithRef) {
133
- const { name, ref } = parseTemplateRef(nameWithRef);
134
- const cacheDir = ref ? await ensureRemoteCacheForRef(ref) : await ensureRemoteCache();
135
- const dir = join(cacheDir, name);
136
- if (!existsSync(dir) || !existsSync(join(dir, "template.json"))) {
137
- const available = listTemplates(cacheDir).map((t) => t.name).join(", ");
138
- if (ref) {
139
- throw new Error(
140
- `Template "${name}" not found at ref "${ref}". Available: ${available || "none"}`
141
- );
142
- }
143
- throw new Error(
144
- `Template "${name}" not found. Available: ${available || "none"}
145
- Cache location: ${cacheDir}
146
- Try deleting the cache and retrying: rm -rf ${cacheDir}`
147
- );
148
- }
149
- return dir;
150
- }
151
- async function listAllTemplates() {
152
- const cacheDir = await ensureRemoteCache();
153
- return listTemplates(cacheDir);
154
- }
155
-
156
- export {
157
- resolveTemplate,
158
- listAllTemplates
159
- };
@@ -1,120 +0,0 @@
1
- import {
2
- loadEnv
3
- } from "./chunk-2CR762KB.js";
4
- import {
5
- createApiClient
6
- } from "./chunk-GKI2HQJC.js";
7
- import {
8
- findProjectRoot,
9
- getAppName
10
- } from "./chunk-ZH3NVYEQ.js";
11
-
12
- // src/commands/deps.ts
13
- import pc from "picocolors";
14
- import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
15
- import { join } from "path";
16
- var DEPS_FILE = "platform/project_deps.json";
17
- function loadDeps(projectRoot) {
18
- const depsPath = join(projectRoot, DEPS_FILE);
19
- if (!existsSync(depsPath)) return null;
20
- try {
21
- return JSON.parse(readFileSync(depsPath, "utf-8"));
22
- } catch {
23
- return null;
24
- }
25
- }
26
- async function syncDeps(projectRoot) {
27
- const root = projectRoot ?? findProjectRoot();
28
- loadEnv(root);
29
- const deps2 = loadDeps(root);
30
- if (!deps2 || !deps2.dependencies || Object.keys(deps2.dependencies).length === 0) {
31
- return true;
32
- }
33
- const appName = getAppName(root);
34
- const api = createApiClient(void 0, void 0, appName);
35
- let allOk = true;
36
- for (const [depProject, config] of Object.entries(deps2.dependencies)) {
37
- try {
38
- const manifest = await api.getProjectManifest(depProject);
39
- const remoteNames = new Set(manifest.collections.map((c) => c.name));
40
- for (const col of config.collections) {
41
- if (remoteNames.has(col)) {
42
- console.log(pc.green(" \u2713"), `${depProject}/${col}`);
43
- } else {
44
- console.log(pc.red(" \u2717"), `${depProject}/${col} \u2014 not found in project manifest`);
45
- allOk = false;
46
- }
47
- }
48
- } catch (e) {
49
- console.log(pc.red(" \u2717"), `${depProject}: failed to fetch manifest \u2014 ${e}`);
50
- allOk = false;
51
- }
52
- }
53
- return allOk;
54
- }
55
- async function deps(args) {
56
- const sub = args[0];
57
- const projectRoot = findProjectRoot();
58
- loadEnv(projectRoot);
59
- if (sub === "sync") {
60
- console.log();
61
- console.log(pc.cyan(pc.bold(" Deps Sync")));
62
- console.log(pc.dim(" Verifying cross-project dependencies..."));
63
- console.log();
64
- const ok = await syncDeps(projectRoot);
65
- if (!ok) {
66
- console.log();
67
- console.log(pc.red(" Some dependencies could not be resolved."));
68
- process.exit(1);
69
- }
70
- console.log();
71
- console.log(pc.green(" All dependencies verified."));
72
- return;
73
- }
74
- if (sub === "list") {
75
- const depsData = loadDeps(projectRoot);
76
- if (!depsData || Object.keys(depsData.dependencies).length === 0) {
77
- console.log(pc.dim(" No dependencies declared in platform/project_deps.json"));
78
- return;
79
- }
80
- console.log();
81
- console.log(pc.cyan(pc.bold(" Project Dependencies")));
82
- console.log();
83
- for (const [depProject, config] of Object.entries(depsData.dependencies)) {
84
- console.log(` ${pc.bold(depProject)}`);
85
- for (const col of config.collections) {
86
- console.log(` \u2022 ${col}`);
87
- }
88
- }
89
- console.log();
90
- return;
91
- }
92
- if (sub === "init") {
93
- const depsPath = join(projectRoot, DEPS_FILE);
94
- if (existsSync(depsPath)) {
95
- console.log(pc.yellow(" platform/project_deps.json already exists."));
96
- return;
97
- }
98
- const platformDir = join(projectRoot, "platform");
99
- mkdirSync(platformDir, { recursive: true });
100
- const initial = { dependencies: {} };
101
- writeFileSync(depsPath, JSON.stringify(initial, null, 2) + "\n");
102
- console.log(pc.green(" \u2713"), "Created platform/project_deps.json");
103
- return;
104
- }
105
- console.log(`
106
- ${pc.bold("lumera deps")} \u2014 manage cross-project dependencies
107
-
108
- ${pc.bold("Commands:")}
109
- sync Fetch manifests and verify declared dependencies exist
110
- list Show declared dependencies
111
- init Create an empty platform/project_deps.json
112
-
113
- ${pc.bold("Dependency file:")} platform/project_deps.json
114
- `);
115
- }
116
-
117
- export {
118
- syncDeps,
119
- deps
120
- };