create-snappy 1.1.1 → 1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-snappy",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "The official installer for the SNAPPY stack.",
5
5
  "main": "scripts/create-snappy/cli.js",
6
6
  "bin": {
@@ -225,7 +225,7 @@ async function main() {
225
225
  name: 'template',
226
226
  message: 'Which template would you like to use?',
227
227
  choices: [
228
- { title: 'Portfolio', description: 'A sleek portfolio template', value: 'portofolio' },
228
+ { title: 'Portfolio', description: 'A sleek portfolio template', value: 'portfolio' },
229
229
  ],
230
230
  initial: 0,
231
231
  })
@@ -234,7 +234,7 @@ async function main() {
234
234
  questions.push({
235
235
  type: 'password',
236
236
  name: 'snappyLicenseKey',
237
- message: 'SNAPPY License Key (leave blank to skip)?',
237
+ message: 'SNAPPY License Key (leave blank for trial)?',
238
238
  initial: savedConfig.snappyLicenseKey || '',
239
239
  })
240
240
 
@@ -327,7 +327,7 @@ async function main() {
327
327
  const projectName = providedName || response.projectName
328
328
  const projectDescription = response.projectDescription
329
329
  const authorName = config.authorName
330
- const selectedTemplate = options.template || response.template || 'portofolio'
330
+ const selectedTemplate = options.template || response.template || 'portfolio'
331
331
 
332
332
  const targetDir = path.resolve(process.cwd(), projectName)
333
333
 
@@ -398,39 +398,43 @@ async function main() {
398
398
 
399
399
  try {
400
400
  // 1. Initialize from repository
401
- const token = getSavedToken() || (await githubLogin())
402
-
403
401
  const repoUrl = process.env.SNAPPY_REPO_URL || 'https://github.com/snappy-stack/snappy'
404
- let authenticatedUrl = repoUrl
405
-
406
- if (token) {
407
- authenticatedUrl = repoUrl.replace('https://', `https://x-access-token:${token}@`)
408
- }
409
-
410
402
  const cloneSpinner = ora(`Cloning secure template (${selectedTemplate})...`).start()
403
+
411
404
  try {
412
- // Use branch as the template name
413
- execSync(`git clone --depth 1 -b ${selectedTemplate} ${authenticatedUrl} "${targetDir}"`, {
414
- stdio: 'ignore',
415
- })
416
- cloneSpinner.succeed('Project cloned successfully.')
417
- } catch (cloneErr) {
418
- cloneSpinner.stop()
419
- if (!token) {
420
- console.log(pc.yellow('\nšŸ” This template might be private. Attempting login...'))
421
- token = await githubLogin()
422
- authenticatedUrl = repoUrl.replace('https://', `https://x-access-token:${token}@`)
423
- const retrySpinner = ora(`Cloning secure template (${selectedTemplate})...`).start()
424
- execSync(`git clone --depth 1 -b ${selectedTemplate} ${authenticatedUrl} "${targetDir}"`, {
405
+ // Try public clone first for public repo
406
+ try {
407
+ execSync(`git clone --depth 1 -b ${selectedTemplate} ${repoUrl} "${targetDir}"`, {
425
408
  stdio: 'ignore',
426
409
  })
427
- retrySpinner.succeed('Project cloned successfully.')
428
- } else {
429
- console.error(
430
- pc.red("Clone failed. The branch might not exist, or you don't have access."),
431
- )
432
- throw cloneErr
410
+ cloneSpinner.succeed('Project cloned successfully (public).')
411
+ } catch (publicErr) {
412
+ // If public fails, try with token
413
+ const token = getSavedToken()
414
+ if (token) {
415
+ const authenticatedUrl = repoUrl.replace('https://', `https://x-access-token:${token}@`)
416
+ execSync(`git clone --depth 1 -b ${selectedTemplate} ${authenticatedUrl} "${targetDir}"`, {
417
+ stdio: 'ignore',
418
+ })
419
+ cloneSpinner.succeed('Project cloned successfully (authenticated).')
420
+ } else {
421
+ // No token, ask for one
422
+ cloneSpinner.stop()
423
+ console.log(pc.yellow('\nšŸ” This template might be private. Please authenticate...'))
424
+ const newToken = await githubLogin()
425
+ const authenticatedUrl = repoUrl.replace('https://', `https://x-access-token:${newToken}@`)
426
+ const retrySpinner = ora(`Cloning secure template (${selectedTemplate})...`).start()
427
+ execSync(`git clone --depth 1 -b ${selectedTemplate} ${authenticatedUrl} "${targetDir}"`, {
428
+ stdio: 'ignore',
429
+ })
430
+ retrySpinner.succeed('Project cloned successfully.')
431
+ }
433
432
  }
433
+ } catch (err) {
434
+ cloneSpinner.stop()
435
+ console.error(pc.red("\nāŒ Clone failed. The branch might not exist, or you don't have access."))
436
+ console.error(pc.gray(`Command: git clone -b ${selectedTemplate} ${repoUrl}`))
437
+ throw err
434
438
  }
435
439
 
436
440
  if (fs.existsSync(path.join(targetDir, '.git'))) {