create-snappy 1.1.0 ā 1.1.1
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/package.json +1 -1
- package/scripts/create-snappy/cli.js +71 -5
package/package.json
CHANGED
|
@@ -155,11 +155,7 @@ async function githubLogin() {
|
|
|
155
155
|
// --- Main CLI ---
|
|
156
156
|
|
|
157
157
|
function getPackageManager() {
|
|
158
|
-
|
|
159
|
-
if (userAgent.startsWith('yarn')) return 'yarn'
|
|
160
|
-
if (userAgent.startsWith('pnpm')) return 'pnpm'
|
|
161
|
-
if (userAgent.startsWith('bun')) return 'bun'
|
|
162
|
-
return 'npm'
|
|
158
|
+
return 'pnpm'
|
|
163
159
|
}
|
|
164
160
|
|
|
165
161
|
async function main() {
|
|
@@ -235,6 +231,13 @@ async function main() {
|
|
|
235
231
|
})
|
|
236
232
|
}
|
|
237
233
|
|
|
234
|
+
questions.push({
|
|
235
|
+
type: 'password',
|
|
236
|
+
name: 'snappyLicenseKey',
|
|
237
|
+
message: 'SNAPPY License Key (leave blank to skip)?',
|
|
238
|
+
initial: savedConfig.snappyLicenseKey || '',
|
|
239
|
+
})
|
|
240
|
+
|
|
238
241
|
// Guided Setup Questions
|
|
239
242
|
const needsGuided = options.guided || !hasSavedConfig
|
|
240
243
|
|
|
@@ -305,6 +308,7 @@ async function main() {
|
|
|
305
308
|
const config = {
|
|
306
309
|
...savedConfig,
|
|
307
310
|
authorName: response.authorName || savedConfig.authorName,
|
|
311
|
+
snappyLicenseKey: response.snappyLicenseKey || savedConfig.snappyLicenseKey,
|
|
308
312
|
supabaseUrl: response.supabaseUrl || savedConfig.supabaseUrl,
|
|
309
313
|
supabaseAnonKey: response.supabaseAnonKey || savedConfig.supabaseAnonKey,
|
|
310
314
|
supabaseServiceRole: response.supabaseServiceRole || savedConfig.supabaseServiceRole,
|
|
@@ -345,6 +349,53 @@ async function main() {
|
|
|
345
349
|
// Create target dir
|
|
346
350
|
fs.mkdirSync(targetDir, { recursive: true })
|
|
347
351
|
|
|
352
|
+
let finalLicenseToken = config.snappyLicenseKey;
|
|
353
|
+
let isTrial = false;
|
|
354
|
+
let machineIdToSave = null;
|
|
355
|
+
let skippedLicense = false;
|
|
356
|
+
|
|
357
|
+
if (!finalLicenseToken || finalLicenseToken.trim() === '') {
|
|
358
|
+
const trialResponse = await prompts({
|
|
359
|
+
type: 'confirm',
|
|
360
|
+
name: 'startTrial',
|
|
361
|
+
message: 'šÆ Start 2-hour free trial?',
|
|
362
|
+
initial: true
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
if (trialResponse.startTrial) {
|
|
366
|
+
console.log(pc.cyan('\nā³ Setting up 2-hour free trial...'));
|
|
367
|
+
const machineId = Math.random().toString(36).substring(2) + Date.now().toString(36);
|
|
368
|
+
|
|
369
|
+
try {
|
|
370
|
+
const res = await fetch('https://snappycore.wicky.id/api/trial', {
|
|
371
|
+
method: 'POST',
|
|
372
|
+
headers: { 'Content-Type': 'application/json' },
|
|
373
|
+
body: JSON.stringify({ machineId })
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
const data = await res.json();
|
|
377
|
+
if (res.ok && data.token) {
|
|
378
|
+
finalLicenseToken = data.token;
|
|
379
|
+
isTrial = true;
|
|
380
|
+
machineIdToSave = machineId;
|
|
381
|
+
} else {
|
|
382
|
+
console.warn(pc.yellow(`ā ļø Trial generation failed: ${data.error || 'Unknown error'}. Continuing without license.`));
|
|
383
|
+
skippedLicense = true;
|
|
384
|
+
}
|
|
385
|
+
} catch (err) {
|
|
386
|
+
console.warn(pc.yellow(`ā ļø Could not reach licensing server: ${err.message}`));
|
|
387
|
+
skippedLicense = true;
|
|
388
|
+
}
|
|
389
|
+
} else {
|
|
390
|
+
skippedLicense = true;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Save machine ID if it's a trial
|
|
395
|
+
if (machineIdToSave) {
|
|
396
|
+
fs.writeFileSync(path.join(targetDir, '.snappy-machine-id'), machineIdToSave);
|
|
397
|
+
}
|
|
398
|
+
|
|
348
399
|
try {
|
|
349
400
|
// 1. Initialize from repository
|
|
350
401
|
const token = getSavedToken() || (await githubLogin())
|
|
@@ -412,6 +463,7 @@ async function main() {
|
|
|
412
463
|
NEXT_PUBLIC_SUPABASE_ANON_KEY="${config.supabaseAnonKey}"
|
|
413
464
|
SUPABASE_SERVICE_ROLE_KEY="${config.supabaseServiceRole}"
|
|
414
465
|
SUPABASE_URL="${config.supabaseUrl}"
|
|
466
|
+
SNAPPY_LICENSE_TOKEN="${finalLicenseToken || ''}"
|
|
415
467
|
|
|
416
468
|
# Database Configuration
|
|
417
469
|
POSTGRES_URL="postgres://postgres:${config.supabaseServiceRole}@${config.supabaseUrl.replace('https://', '').split('.')[0]}.supabase.co:5432/postgres"
|
|
@@ -447,6 +499,20 @@ REQUIRE_LOGIN="yes"
|
|
|
447
499
|
|
|
448
500
|
console.log(pc.green('\nā
SNAPPY Stack is perfectly prepared and ready to launch!'))
|
|
449
501
|
console.log(`\nNext steps:\n cd ${pc.bold(projectName)}\n ${pmRun}\n`)
|
|
502
|
+
|
|
503
|
+
if (skippedLicense) {
|
|
504
|
+
console.log(pc.red('\n āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
505
|
+
console.log(` š ${pc.bold(pc.white('Add your license key to .env'))}`);
|
|
506
|
+
console.log(pc.gray(' SNAPPY_LICENSE_TOKEN=sk_snappy_...'));
|
|
507
|
+
console.log('');
|
|
508
|
+
console.log(` š” ${pc.cyan('Get your key: wicky.id')}`);
|
|
509
|
+
console.log(` š ${pc.cyan('Docs: snappycore.wicky.id')}`);
|
|
510
|
+
console.log(pc.red(' āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
511
|
+
console.log(pc.bold(pc.red('\n THERE IS NO MERCY IN PRODUCTION š¹ \n')));
|
|
512
|
+
} else if (isTrial) {
|
|
513
|
+
console.log(pc.green('\nā
2-hour free trial active! Your trial license has been added to .env.'));
|
|
514
|
+
}
|
|
515
|
+
|
|
450
516
|
} catch (err) {
|
|
451
517
|
console.error(pc.red(`Installation failed: ${err.message || err}`))
|
|
452
518
|
} finally {
|