create-kide-app 0.0.23 → 0.0.25

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/index.js CHANGED
@@ -175,6 +175,96 @@ async function main() {
175
175
  s.stop(`${pm.install} failed — run it manually`);
176
176
  }
177
177
 
178
+ // --- Initialize git repository ---
179
+
180
+ let gitInitialized = false;
181
+ try {
182
+ execSync("git init -q && git add . && git commit -q -m 'Initial commit from create-kide-app'", {
183
+ cwd: projectDir,
184
+ stdio: "pipe",
185
+ });
186
+ gitInitialized = true;
187
+ } catch {
188
+ // git not available — silently skip
189
+ }
190
+
191
+ // --- Optional: create GitHub repository ---
192
+
193
+ if (gitInitialized) {
194
+ let ghAvailable = false;
195
+ try {
196
+ execSync("gh --version", { stdio: "pipe" });
197
+ execSync("gh auth status", { stdio: "pipe" });
198
+ ghAvailable = true;
199
+ } catch {
200
+ // gh not installed or not authenticated — skip the prompt
201
+ }
202
+
203
+ if (ghAvailable) {
204
+ const createRepo = await p.confirm({
205
+ message: "Create a GitHub repository for this project?",
206
+ initialValue: false,
207
+ });
208
+ if (!p.isCancel(createRepo) && createRepo) {
209
+ // Get the GitHub username so we can check repo availability
210
+ let ghUser = "";
211
+ try {
212
+ ghUser = execSync("gh api user --jq .login", { stdio: "pipe" }).toString().trim();
213
+ } catch {}
214
+
215
+ // Prompt for repo name, validate it doesn't already exist
216
+ let repoName = null;
217
+ while (true) {
218
+ const input = await p.text({
219
+ message: "Repository name",
220
+ initialValue: projectName,
221
+ validate: (value) => {
222
+ if (!value) return "Repository name is required";
223
+ if (!/^[a-zA-Z0-9._-]+$/.test(value)) return "Only letters, numbers, dots, hyphens, and underscores";
224
+ },
225
+ });
226
+ if (p.isCancel(input)) break;
227
+
228
+ // Check if repo already exists under the user's account
229
+ if (ghUser) {
230
+ try {
231
+ execSync(`gh repo view ${ghUser}/${input}`, { stdio: "pipe" });
232
+ p.note(`A repository named "${input}" already exists. Pick a different name.`, "Name taken");
233
+ continue;
234
+ } catch {
235
+ // Repo doesn't exist — name is free
236
+ }
237
+ }
238
+ repoName = input;
239
+ break;
240
+ }
241
+
242
+ if (repoName) {
243
+ const visibility = await p.select({
244
+ message: "Repository visibility",
245
+ options: [
246
+ { label: "Private", value: "--private" },
247
+ { label: "Public", value: "--public" },
248
+ ],
249
+ });
250
+ if (!p.isCancel(visibility)) {
251
+ s.start("Creating GitHub repository");
252
+ try {
253
+ execSync(`gh repo create ${repoName} ${visibility} --source=. --push`, {
254
+ cwd: projectDir,
255
+ stdio: "pipe",
256
+ });
257
+ s.stop("GitHub repository created and pushed");
258
+ } catch (err) {
259
+ s.stop("GitHub repository creation failed");
260
+ if (err.stderr) console.error(err.stderr.toString().slice(-500));
261
+ }
262
+ }
263
+ }
264
+ }
265
+ }
266
+ }
267
+
178
268
  // --- Generate schema ---
179
269
 
180
270
  s.start("Generating CMS schema");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-kide-app",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "description": "Scaffold a new Kide CMS project",
5
5
  "author": "Matti Hernesniemi",
6
6
  "license": "MIT",
@@ -20,10 +20,12 @@ if (new URLSearchParams(location.search).has("preview")) {
20
20
  headers: { "Content-Type": "application/json" },
21
21
  body: JSON.stringify({ type: d.render, data: d.value }),
22
22
  })
23
- .then((r) => r.text())
23
+ .then((r) => (r.ok ? r.text() : null))
24
24
  .then((html) => {
25
- if (id === pending) els.forEach((el) => (el.innerHTML = html));
26
- });
25
+ // Endpoint may not exist in production builds (only dev) silently skip
26
+ if (html != null && id === pending) els.forEach((el) => (el.innerHTML = html));
27
+ })
28
+ .catch(() => {});
27
29
  } else if (d.html != null) {
28
30
  els.forEach((el) => (el.innerHTML = d.html));
29
31
  } else {