zone5 1.3.1 → 1.3.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zone5",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "repository": {
5
5
  "url": "https://github.com/cwygoda/zone5"
6
6
  },
@@ -1,238 +0,0 @@
1
- import f from "fs-extra";
2
- import { execSync as C } from "node:child_process";
3
- import { mkdir as h, writeFile as p, copyFile as j, symlink as x, rename as S } from "node:fs/promises";
4
- import { dirname as $, join as n, resolve as w, basename as u } from "node:path";
5
- import { fileURLToPath as z } from "node:url";
6
- import D from "ora";
7
- import l from "picocolors";
8
- import I from "prompts";
9
- import { pathExists as k, isDirectory as b, findImagesRecursive as J } from "./index3.js";
10
- const T = $(z(import.meta.url)), g = n(T, "templates");
11
- async function X(e) {
12
- const { inputFolder: i, outputFolder: o, mode: s, packageManager: a, interactive: d } = e, c = w(i), r = w(o);
13
- console.log(l.bold(`
14
- 🖼️ zone5
15
- `));
16
- const t = D("Validating input folder...").start();
17
- if (!await k(c))
18
- throw t.fail(`Input folder does not exist: ${c}`), new Error("Input folder not found");
19
- if (!await b(c))
20
- throw t.fail(`Input path is not a directory: ${c}`), new Error("Input path must be a directory");
21
- t.text = "Scanning for images...";
22
- const m = await J(c);
23
- if (m.length === 0)
24
- throw t.fail("No images found in input folder"), new Error("No images found");
25
- if (t.succeed(`Found ${l.cyan(m.length.toString())} images`), await k(r))
26
- throw t.fail(`Output folder already exists: ${r}`), new Error("Output folder must not exist");
27
- if (d) {
28
- const { confirmed: y } = await I({
29
- type: "confirm",
30
- name: "confirmed",
31
- message: `Create project at ${l.cyan(r)} with ${l.cyan(m.length.toString())} images (mode: ${l.yellow(s)})?`,
32
- initial: !0
33
- });
34
- y || (console.log(l.dim("Cancelled")), process.exit(0));
35
- }
36
- t.start("Creating SvelteKit project..."), await P(r), t.succeed("Created SvelteKit project"), t.start("Adding dependencies to package.json..."), await L(r), t.succeed("Added dependencies to package.json"), a === "skip" ? t.info("Skipped dependency installation") : (t.start("Installing dependencies..."), await N(r, a), t.succeed("Installed dependencies")), t.start(
37
- `${s === "copy" ? "Copying" : s === "link" ? "Linking" : "Moving"} images...`
38
- );
39
- const v = n(r, "src", "routes");
40
- if (await f.ensureDir(v), await E(m, c, v, s), t.succeed(
41
- `${s === "copy" ? "Copied" : s === "link" ? "Linked" : "Moved"} ${m.length} images`
42
- ), t.start("Generating gallery page..."), await F(v, m), t.succeed("Generated gallery page"), t.start("Adding template files..."), await A(r), t.succeed("Added template files"), t.start("Configuring Vite..."), await M(r), t.succeed("Configured Vite"), t.start("Configuring Svelte..."), await R(r), t.succeed("Configured Svelte"), t.start("Configuring Tailwind..."), await Z(r), t.succeed("Configured Tailwind"), t.start("Creating zone5 config..."), await _(r), t.succeed("Created zone5 config"), a !== "skip" && (t.start("Running svelte-kit sync..."), await O(r, a), t.succeed("Ran svelte-kit sync")), console.log(l.green(`
43
- ✓ Project created successfully!
44
- `)), console.log("Next steps:"), console.log(l.cyan(` cd ${u(r)}`)), a === "skip")
45
- console.log(l.cyan(" npm install # or your preferred package manager")), console.log(l.cyan(" npm run dev"));
46
- else {
47
- const y = a === "npm" ? "npm run dev" : `${a} dev`;
48
- console.log(l.cyan(` ${y}`));
49
- }
50
- console.log();
51
- }
52
- async function P(e) {
53
- await h(e, { recursive: !0 });
54
- const i = {
55
- name: u(e),
56
- version: "0.0.1",
57
- private: !0,
58
- type: "module",
59
- scripts: {
60
- dev: "vite dev",
61
- build: "vite build",
62
- preview: "vite preview"
63
- },
64
- devDependencies: {},
65
- dependencies: {}
66
- };
67
- await p(n(e, "package.json"), JSON.stringify(i, null, " ")), await f.ensureDir(n(e, "src", "routes")), await f.ensureDir(n(e, "static")), await p(n(e, "src", "app.html"), `<!doctype html>
68
- <html lang="en">
69
- <head>
70
- <meta charset="utf-8" />
71
- <meta name="viewport" content="width=device-width, initial-scale=1" />
72
- %sveltekit.head%
73
- </head>
74
- <body data-sveltekit-preload-data="hover">
75
- <div style="display: contents">%sveltekit.body%</div>
76
- </body>
77
- </html>
78
- `);
79
- }
80
- async function L(e) {
81
- const i = n(e, "package.json"), o = JSON.parse(await f.readFile(i, "utf-8"));
82
- o.devDependencies = {
83
- "@lucide/svelte": "^0.553.0",
84
- "@sveltejs/adapter-static": "^3.0.0",
85
- "@sveltejs/kit": "^2.0.0",
86
- "@sveltejs/vite-plugin-svelte": "^6.0.0",
87
- "@tailwindcss/vite": "^4.0.0",
88
- zone5: "latest",
89
- mdsvex: "^0.12.0",
90
- svelte: "^5.0.0",
91
- tailwindcss: "^4.0.0",
92
- typescript: "^5.0.0",
93
- vite: "^7.0.0"
94
- };
95
- const s = process.env.ZONE5_LOCAL_PATH;
96
- if (s) {
97
- const a = w(s);
98
- o.devDependencies.zone5 = `file:${a}`;
99
- }
100
- await p(i, JSON.stringify(o, null, " "));
101
- }
102
- async function N(e, i) {
103
- C((() => {
104
- switch (i) {
105
- case "npm":
106
- return "npm install";
107
- case "pnpm":
108
- return "pnpm install";
109
- case "yarn":
110
- return "yarn install";
111
- case "bun":
112
- return "bun install";
113
- }
114
- })(), {
115
- cwd: e,
116
- stdio: "pipe"
117
- }), await p(n(e, "svelte.config.js"), `import adapter from '@sveltejs/adapter-static';
118
-
119
- /** @type {import('@sveltejs/kit').Config} */
120
- const config = {
121
- kit: {
122
- adapter: adapter()
123
- }
124
- };
125
-
126
- export default config;
127
- `), await p(n(e, "vite.config.ts"), `import { sveltekit } from '@sveltejs/vite-plugin-svelte';
128
- import { defineConfig } from 'vite';
129
-
130
- export default defineConfig({
131
- plugins: [sveltekit()]
132
- });
133
- `);
134
- const d = {
135
- extends: "./.svelte-kit/tsconfig.json",
136
- compilerOptions: {
137
- allowJs: !0,
138
- checkJs: !0,
139
- esModuleInterop: !0,
140
- forceConsistentCasingInFileNames: !0,
141
- resolveJsonModule: !0,
142
- skipLibCheck: !0,
143
- sourceMap: !0,
144
- strict: !0,
145
- moduleResolution: "bundler"
146
- }
147
- };
148
- await p(n(e, "tsconfig.json"), JSON.stringify(d, null, " "));
149
- }
150
- async function O(e, i) {
151
- C((() => {
152
- switch (i) {
153
- case "npm":
154
- return "npx svelte-kit sync";
155
- case "pnpm":
156
- return "pnpm exec svelte-kit sync";
157
- case "yarn":
158
- return "yarn svelte-kit sync";
159
- case "bun":
160
- return "bunx svelte-kit sync";
161
- }
162
- })(), {
163
- cwd: e,
164
- stdio: "pipe"
165
- });
166
- }
167
- async function E(e, i, o, s) {
168
- for (const { path: a, relativePath: d } of e) {
169
- const c = n(o, u(d));
170
- s === "copy" ? await j(a, c) : s === "link" ? await x(a, c) : s === "move" && await S(a, c);
171
- }
172
- }
173
- async function F(e, i) {
174
- const s = `# Photo Gallery
175
-
176
- ${i.map(({ relativePath: a }) => {
177
- const d = u(a);
178
- return `![${d.replace(/\.[^.]+$/, "")}](./${d}?z5)`;
179
- }).join(`
180
- `)}
181
- `;
182
- await p(n(e, "+page.md"), s);
183
- }
184
- async function A(e) {
185
- const i = n(g, "layout.svelte"), o = n(e, "src", "routes", "+layout.svelte");
186
- await f.copy(i, o);
187
- const s = n(g, "app.css"), a = n(e, "src", "app.css");
188
- await f.copy(s, a);
189
- const d = n(g, "layout.ts"), c = n(e, "src", "routes", "+layout.ts");
190
- await f.copy(d, c);
191
- }
192
- async function M(e) {
193
- const i = n(e, "vite.config.ts");
194
- await p(i, `import { sveltekit } from '@sveltejs/kit/vite';
195
- import tailwindcss from '@tailwindcss/vite';
196
- import { zone5 } from 'zone5/vite';
197
- import { defineConfig } from 'vite';
198
-
199
- export default defineConfig({
200
- plugins: [tailwindcss(), zone5(), sveltekit()]
201
- });
202
- `);
203
- }
204
- async function R(e) {
205
- const i = n(e, "svelte.config.js");
206
- await p(i, `import adapter from '@sveltejs/adapter-static';
207
- import { mdsvex } from 'mdsvex';
208
- import { remarkZ5Images } from 'zone5/remark';
209
-
210
- /** @type {import('@sveltejs/kit').Config} */
211
- const config = {
212
- extensions: ['.svelte', '.md'],
213
- preprocess: [
214
- mdsvex({
215
- extensions: ['.md'],
216
- remarkPlugins: [remarkZ5Images]
217
- })
218
- ],
219
- kit: {
220
- adapter: adapter()
221
- }
222
- };
223
-
224
- export default config;
225
- `);
226
- }
227
- async function Z(e) {
228
- await p(n(e, "tailwind.config.ts"), `/** @type {import('tailwindcss').Config} */
229
- export default {};
230
- `);
231
- }
232
- async function _(e) {
233
- const i = n(g, ".zone5.toml"), o = n(e, ".zone5.toml");
234
- await f.copy(i, o);
235
- }
236
- export {
237
- X as createProject
238
- };
@@ -1,53 +0,0 @@
1
- import { constants as o } from "node:fs";
2
- import { access as c, stat as f, readdir as u } from "node:fs/promises";
3
- import { join as p, extname as h } from "node:path";
4
- const m = /* @__PURE__ */ new Set([
5
- ".jpg",
6
- ".jpeg",
7
- ".png",
8
- ".webp",
9
- ".avif",
10
- ".gif",
11
- ".tiff",
12
- ".tif",
13
- ".heic",
14
- ".heif"
15
- ]);
16
- async function I(t) {
17
- try {
18
- return await c(t, o.F_OK), !0;
19
- } catch {
20
- return !1;
21
- }
22
- }
23
- async function x(t) {
24
- try {
25
- return (await f(t)).isDirectory();
26
- } catch {
27
- return !1;
28
- }
29
- }
30
- function l(t) {
31
- const a = h(t).toLowerCase();
32
- return m.has(a);
33
- }
34
- async function g(t, a = t) {
35
- const r = await u(t, { withFileTypes: !0 }), i = [];
36
- for (const e of r) {
37
- const s = p(t, e.name);
38
- if (e.isFile() && l(e.name)) {
39
- const n = s.replace(a + "/", "");
40
- i.push({ path: s, relativePath: n });
41
- } else if (e.isDirectory()) {
42
- const n = await g(s, a);
43
- i.push(...n);
44
- }
45
- }
46
- return i.sort((e, s) => e.relativePath.localeCompare(s.relativePath));
47
- }
48
- export {
49
- g as findImagesRecursive,
50
- x as isDirectory,
51
- l as isImage,
52
- I as pathExists
53
- };