aicp-tracker 1.2.4 → 1.2.5
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/bin/setup.js +20 -7
- package/package.json +1 -1
package/bin/setup.js
CHANGED
|
@@ -139,16 +139,27 @@ async function main() {
|
|
|
139
139
|
name: 'vcsUrl',
|
|
140
140
|
message: 'VCS organisation URL (e.g. https://bitbucket.org/my-workspace or https://github.com/my-org)',
|
|
141
141
|
initial: existing?.vcsUrl || '',
|
|
142
|
-
validate: v =>
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
validate: v => {
|
|
143
|
+
try {
|
|
144
|
+
const url = new URL(v.trim());
|
|
145
|
+
if (!['bitbucket.org', 'github.com'].includes(url.hostname))
|
|
146
|
+
return 'Must be a bitbucket.org or github.com URL';
|
|
147
|
+
if (url.pathname.replace(/^\/+|\/+$/g, '').length === 0)
|
|
148
|
+
return 'Must include workspace/org slug (e.g. https://bitbucket.org/my-workspace)';
|
|
149
|
+
return true;
|
|
150
|
+
} catch {
|
|
151
|
+
return 'Enter a valid URL (e.g. https://bitbucket.org/my-workspace)';
|
|
152
|
+
}
|
|
153
|
+
},
|
|
145
154
|
},
|
|
146
155
|
{
|
|
147
156
|
type: 'input',
|
|
148
157
|
name: 'email',
|
|
149
158
|
message: 'Your email used in Bitbucket / GitHub',
|
|
150
159
|
initial: existing?.email || '',
|
|
151
|
-
validate: v => v.
|
|
160
|
+
validate: v => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v.trim().replace(/^[/\\]+|[/\\]+$/g, ''))
|
|
161
|
+
? true
|
|
162
|
+
: 'Enter a valid email address (e.g. you@example.com)',
|
|
152
163
|
},
|
|
153
164
|
{
|
|
154
165
|
type: 'select',
|
|
@@ -159,12 +170,14 @@ async function main() {
|
|
|
159
170
|
},
|
|
160
171
|
]);
|
|
161
172
|
|
|
173
|
+
const normalizedEmail = answers.email.trim().replace(/^[/\\]+|[/\\]+$/g, '').toLowerCase();
|
|
174
|
+
const normalizedVcsUrl = answers.vcsUrl.trim().replace(/\/+$/, '');
|
|
162
175
|
console.log('\n Registering with AI Code Pulse server…');
|
|
163
|
-
const apiKey = await register(
|
|
176
|
+
const apiKey = await register(normalizedEmail);
|
|
164
177
|
|
|
165
178
|
config.save({
|
|
166
|
-
vcsUrl:
|
|
167
|
-
email:
|
|
179
|
+
vcsUrl: normalizedVcsUrl,
|
|
180
|
+
email: normalizedEmail,
|
|
168
181
|
plan: answers.plan,
|
|
169
182
|
apiUrl: API_URL,
|
|
170
183
|
apiKey,
|