create-kide-app 0.0.24 → 0.0.26
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 +93 -1
- package/package.json +1 -1
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");
|
|
@@ -199,8 +289,10 @@ async function main() {
|
|
|
199
289
|
try {
|
|
200
290
|
execSync(`${pm.run} cms:seed`, { cwd: projectDir, stdio: "pipe" });
|
|
201
291
|
s.stop("Demo content seeded");
|
|
202
|
-
} catch {
|
|
292
|
+
} catch (err) {
|
|
203
293
|
s.stop("Seeding failed — run `pnpm cms:seed` manually");
|
|
294
|
+
if (err.stderr) console.error(err.stderr.toString().slice(-1500));
|
|
295
|
+
if (err.stdout) console.error(err.stdout.toString().slice(-1500));
|
|
204
296
|
}
|
|
205
297
|
} else if (seedDemo && target === "cloudflare") {
|
|
206
298
|
p.note(
|