@tryarcanist/cli 0.1.1 → 0.1.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/dist/index.js +14 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -73,8 +73,22 @@ function validateApiUrl(url) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// src/commands/create.ts
|
|
76
|
+
function validateRepoUrl(url) {
|
|
77
|
+
const shorthand = /^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/.test(url);
|
|
78
|
+
if (shorthand) return null;
|
|
79
|
+
const ssh = /^git@[^:]+:[^/]+\/[^/]+?(?:\.git)?$/.test(url);
|
|
80
|
+
if (ssh) return null;
|
|
81
|
+
const https = /^https?:\/\/github\.com\/[^/]+\/[^/]+?(?:\.git)?\/?$/.test(url);
|
|
82
|
+
if (https) return null;
|
|
83
|
+
return `Invalid repo URL: "${url}". Expected a GitHub URL (https://github.com/owner/repo) or owner/repo shorthand.`;
|
|
84
|
+
}
|
|
76
85
|
async function createCommand(repoUrl, prompt, options) {
|
|
77
86
|
const config = requireConfig();
|
|
87
|
+
const repoError = validateRepoUrl(repoUrl);
|
|
88
|
+
if (repoError) {
|
|
89
|
+
console.error(`Error: ${repoError}`);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
78
92
|
let sessionId;
|
|
79
93
|
try {
|
|
80
94
|
const sessionData = await apiFetch(config, "/api/sessions", {
|