@sandboxsonny/ace-kit 0.5.0 → 0.6.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/astro-integration.js +1 -1
  3. package/dist/chunk-7M26C36M.js +35 -0
  4. package/dist/cli.js +14 -1179
  5. package/dist/environment-T5K5ZJ2M.js +222 -0
  6. package/dist/main-YRQQWLHX.js +1454 -0
  7. package/dist/vite.js +1 -1
  8. package/docs/command-line.md +30 -1
  9. package/docs/getting-started.md +8 -0
  10. package/package.json +5 -2
  11. package/templates/astro/.dockerignore +7 -0
  12. package/templates/astro/.github/dependabot.yml +19 -0
  13. package/templates/astro/.github/workflows/ci.yml +23 -0
  14. package/templates/astro/.prettierignore +6 -0
  15. package/templates/astro/.prettierrc.json +20 -0
  16. package/templates/astro/.vscode/extensions.json +4 -0
  17. package/templates/astro/.vscode/launch.json +11 -0
  18. package/templates/astro/AGENTS.md +22 -0
  19. package/templates/astro/Dockerfile +17 -0
  20. package/templates/astro/_gitignore +26 -0
  21. package/templates/astro/astro.config.mjs +18 -0
  22. package/templates/astro/eslint.config.js +56 -0
  23. package/templates/astro/package.json +41 -0
  24. package/templates/astro/public/favicon.ico +0 -0
  25. package/templates/astro/public/favicon.svg +9 -0
  26. package/templates/astro/src/ace-kit.generated.d.ts +24 -0
  27. package/templates/astro/src/components/PageContent.astro +113 -0
  28. package/templates/astro/src/components/SiteFooter.astro +19 -0
  29. package/templates/astro/src/components/SiteHeader.astro +121 -0
  30. package/templates/astro/src/components/sections/Faq.astro +54 -0
  31. package/templates/astro/src/components/sections/Faq.schema.ts +17 -0
  32. package/templates/astro/src/components/sections/Gallery.astro +74 -0
  33. package/templates/astro/src/components/sections/Gallery.schema.ts +20 -0
  34. package/templates/astro/src/components/sections/Hero.astro +58 -0
  35. package/templates/astro/src/components/sections/Hero.schema.ts +14 -0
  36. package/templates/astro/src/layouts/BaseLayout.astro +36 -0
  37. package/templates/astro/src/pages/[...slug].astro +31 -0
  38. package/templates/astro/src/styles/global.css +56 -0
  39. package/templates/astro/src/types/page.d.ts +4 -0
  40. package/templates/astro/tsconfig.json +11 -0
  41. package/templates/astro/vitest.config.ts +4 -0
  42. package/templates/astro.section-types.json +109 -0
  43. package/templates/react-router/.prettierignore +5 -0
  44. package/templates/react-router/.prettierrc.json +11 -0
  45. package/templates/react-router/_gitignore +7 -0
  46. package/templates/react-router/app/ace-kit.generated.d.ts +18 -0
  47. package/templates/react-router/app/app.css +172 -0
  48. package/templates/react-router/app/components/page-content.tsx +32 -0
  49. package/templates/react-router/app/components/site-footer.tsx +9 -0
  50. package/templates/react-router/app/components/site-header.tsx +49 -0
  51. package/templates/react-router/app/entry.server.tsx +1 -0
  52. package/templates/react-router/app/root.tsx +75 -0
  53. package/templates/react-router/app/routes/page.test.tsx +64 -0
  54. package/templates/react-router/app/routes/page.tsx +22 -0
  55. package/templates/react-router/app/routes.ts +4 -0
  56. package/templates/react-router/app/types/page.d.ts +4 -0
  57. package/templates/react-router/eslint.config.js +76 -0
  58. package/templates/react-router/package.json +51 -0
  59. package/templates/react-router/public/favicon.svg +9 -0
  60. package/templates/react-router/react-router.config.ts +6 -0
  61. package/templates/react-router/tsconfig.json +22 -0
  62. package/templates/react-router/vite.config.ts +10 -0
  63. package/templates/react-router/vitest.config.ts +15 -0
  64. /package/dist/{chunk-WM5NOQE3.js → chunk-G5FGBOFT.js} +0 -0
@@ -0,0 +1,222 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ normaliseApiUrl,
4
+ parseStoredLogin
5
+ } from "./chunk-7M26C36M.js";
6
+
7
+ // src/cli/environment.ts
8
+ import { spawn } from "child_process";
9
+ import { hostname } from "os";
10
+ import { fileURLToPath, pathToFileURL } from "url";
11
+
12
+ // src/auth/file-store.ts
13
+ import { mkdir, readFile, rename, writeFile } from "fs/promises";
14
+ import { homedir } from "os";
15
+ import { dirname, join } from "path";
16
+ function defaultLoginFile(variables, platform) {
17
+ if (platform === "win32" && variables.APPDATA) return join(variables.APPDATA, "ace-kit", "credentials.json");
18
+ const configFolder = variables.XDG_CONFIG_HOME || join(homedir(), ".config");
19
+ return join(configFolder, "ace-kit", "credentials.json");
20
+ }
21
+ function createFileStore(path) {
22
+ async function readAll() {
23
+ let text;
24
+ try {
25
+ text = await readFile(path, "utf8");
26
+ } catch {
27
+ return {};
28
+ }
29
+ let parsed;
30
+ try {
31
+ parsed = JSON.parse(text);
32
+ } catch {
33
+ return {};
34
+ }
35
+ const found = {};
36
+ if (typeof parsed === "object" && parsed !== null) {
37
+ for (const [address, value] of Object.entries(parsed)) {
38
+ const login = parseStoredLogin(value);
39
+ if (login) found[address] = login;
40
+ }
41
+ }
42
+ return found;
43
+ }
44
+ async function writeAll(logins) {
45
+ await mkdir(dirname(path), { recursive: true, mode: 448 });
46
+ const temporary = `${path}.${process.pid}.tmp`;
47
+ await writeFile(temporary, `${JSON.stringify(logins, null, 2)}
48
+ `, { mode: 384 });
49
+ await rename(temporary, path);
50
+ }
51
+ return {
52
+ description: path,
53
+ async read(apiUrl) {
54
+ return (await readAll())[normaliseApiUrl(apiUrl)] ?? null;
55
+ },
56
+ async write(apiUrl, login) {
57
+ const logins = await readAll();
58
+ logins[normaliseApiUrl(apiUrl)] = login;
59
+ await writeAll(logins);
60
+ },
61
+ async remove(apiUrl) {
62
+ const logins = await readAll();
63
+ delete logins[normaliseApiUrl(apiUrl)];
64
+ await writeAll(logins);
65
+ }
66
+ };
67
+ }
68
+
69
+ // src/auth/keychain-store.ts
70
+ var keychainService = "ace-kit";
71
+ function createKeychainStore(run) {
72
+ async function read(apiUrl) {
73
+ const found = await run("security", [
74
+ "find-generic-password",
75
+ "-s",
76
+ keychainService,
77
+ "-a",
78
+ normaliseApiUrl(apiUrl),
79
+ "-w"
80
+ ]);
81
+ if (found.exitCode !== 0) return null;
82
+ try {
83
+ return parseStoredLogin(JSON.parse(Buffer.from(found.stdout.trim(), "base64").toString("utf8")));
84
+ } catch {
85
+ return null;
86
+ }
87
+ }
88
+ return {
89
+ description: "the macOS Keychain",
90
+ read,
91
+ async write(apiUrl, login) {
92
+ const account = normaliseApiUrl(apiUrl);
93
+ if (/["\\\s]/.test(account)) throw new Error("That API address can't be kept in the Keychain.");
94
+ const secret = Buffer.from(JSON.stringify(login), "utf8").toString("base64");
95
+ await run(
96
+ "security",
97
+ ["-i"],
98
+ `add-generic-password -s "${keychainService}" -a "${account}" -l "Ace Kit login" -w "${secret}" -U
99
+ `
100
+ );
101
+ const kept = await read(apiUrl);
102
+ if (kept?.token !== login.token) throw new Error("The login could not be saved in the macOS Keychain.");
103
+ },
104
+ async remove(apiUrl) {
105
+ await run("security", ["delete-generic-password", "-s", keychainService, "-a", normaliseApiUrl(apiUrl)]);
106
+ }
107
+ };
108
+ }
109
+
110
+ // src/auth/choose-store.ts
111
+ async function chooseLoginStore(options) {
112
+ const file = createFileStore(defaultLoginFile(options.variables, options.platform));
113
+ if (options.platform !== "darwin" || options.variables.ACE_KIT_CREDENTIALS === "file") return file;
114
+ try {
115
+ await options.run("security", ["help"]);
116
+ return createKeychainStore(options.run);
117
+ } catch {
118
+ return file;
119
+ }
120
+ }
121
+
122
+ // src/auth/last-api-url.ts
123
+ import { mkdir as mkdir2, readFile as readFile2, rename as rename2, writeFile as writeFile2 } from "fs/promises";
124
+ import { dirname as dirname2, join as join2 } from "path";
125
+ function defaultLastApiUrlFile(variables, platform) {
126
+ return join2(dirname2(defaultLoginFile(variables, platform)), "last-api-url");
127
+ }
128
+ function createLastApiUrl(path) {
129
+ return {
130
+ async read() {
131
+ try {
132
+ return normaliseApiUrl((await readFile2(path, "utf8")).trim());
133
+ } catch {
134
+ return null;
135
+ }
136
+ },
137
+ async write(apiUrl) {
138
+ await mkdir2(dirname2(path), { recursive: true, mode: 448 });
139
+ const temporary = `${path}.${process.pid}.tmp`;
140
+ await writeFile2(temporary, `${normaliseApiUrl(apiUrl)}
141
+ `, { mode: 384 });
142
+ await rename2(temporary, path);
143
+ }
144
+ };
145
+ }
146
+
147
+ // src/cli/version.ts
148
+ var aceKitVersion = true ? "0.6.0" : "development";
149
+
150
+ // src/cli/environment.ts
151
+ var runCommand = (command, commandArguments, input) => new Promise((resolve, reject) => {
152
+ const child = spawn(command, commandArguments, { stdio: ["pipe", "pipe", "ignore"] });
153
+ let stdout = "";
154
+ child.stdout.on("data", (chunk) => {
155
+ stdout += chunk.toString("utf8");
156
+ });
157
+ child.on("error", reject);
158
+ child.on("close", (exitCode) => resolve({ exitCode: exitCode ?? 1, stdout }));
159
+ child.stdin.on("error", () => {
160
+ });
161
+ child.stdin.end(input ?? "");
162
+ });
163
+ function browserCommand(platform, address) {
164
+ if (platform === "darwin") return { command: "open", commandArguments: [address] };
165
+ if (platform === "win32") return { command: "rundll32", commandArguments: ["url.dll,FileProtocolHandler", address] };
166
+ return { command: "xdg-open", commandArguments: [address] };
167
+ }
168
+ async function openBrowser(platform, address) {
169
+ const { command, commandArguments } = browserCommand(platform, address);
170
+ await new Promise((resolve) => {
171
+ const child = spawn(command, commandArguments, { stdio: "ignore", detached: true });
172
+ child.on("error", () => resolve());
173
+ child.on("spawn", () => {
174
+ child.unref();
175
+ resolve();
176
+ });
177
+ });
178
+ }
179
+ async function importModule(path) {
180
+ try {
181
+ return await import(pathToFileURL(path).href);
182
+ } catch (error) {
183
+ if (error.code === "ERR_UNKNOWN_FILE_EXTENSION") {
184
+ throw new Error(
185
+ "this version of Node can't run TypeScript files. Use Node 22.18 or newer, or write the schema in .js.",
186
+ { cause: error }
187
+ );
188
+ }
189
+ throw error;
190
+ }
191
+ }
192
+ async function createRealEnvironment() {
193
+ try {
194
+ process.loadEnvFile(".env");
195
+ } catch {
196
+ }
197
+ const variables = { ...process.env };
198
+ const platform = process.platform;
199
+ return {
200
+ variables,
201
+ platform,
202
+ hostname: hostname(),
203
+ version: aceKitVersion,
204
+ out: (text) => process.stdout.write(`${text}
205
+ `),
206
+ error: (text) => console.error(text),
207
+ fetchImplementation: (input, init) => fetch(input, init),
208
+ sleep: (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)),
209
+ now: Date.now,
210
+ workingDirectory: process.cwd(),
211
+ templatesDirectory: fileURLToPath(new URL("../templates", import.meta.url)),
212
+ importModule,
213
+ openBrowser: (address) => openBrowser(platform, address),
214
+ store: await chooseLoginStore({ platform, variables, run: runCommand }),
215
+ lastApiUrl: createLastApiUrl(defaultLastApiUrlFile(variables, platform))
216
+ };
217
+ }
218
+ export {
219
+ browserCommand,
220
+ createRealEnvironment,
221
+ runCommand
222
+ };