kaddidlehopper 0.6.0 → 0.7.0

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.
Files changed (3) hide show
  1. package/dist/cli.js +24 -3
  2. package/package.json +1 -1
  3. package/src/cli.ts +28 -3
package/dist/cli.js CHANGED
@@ -7,8 +7,8 @@ import { execSync } from 'node:child_process';
7
7
  import { Command } from 'commander';
8
8
  import chalk from 'chalk';
9
9
  import validatePackageName from 'validate-npm-package-name';
10
- const GITHUB_REPO = 'https://github.com/jherr/kdh-templates.git';
11
- const MANIFEST_URL = 'https://raw.githubusercontent.com/jherr/kdh-templates/main/manifest.json';
10
+ const GITHUB_REPO = 'https://github.com/netlify/swar-templates.git';
11
+ const MANIFEST_URL = 'https://raw.githubusercontent.com/netlify/swar-templates/main/manifest.json';
12
12
  function sanitizePackageName(name) {
13
13
  return name
14
14
  .toLowerCase()
@@ -85,14 +85,23 @@ export function cli() {
85
85
  process.exit(1);
86
86
  }
87
87
  }
88
+ // Delete index.html if it exists in the target directory
89
+ const indexHtmlPath = join(targetDir, 'index.html');
90
+ if (existsSync(indexHtmlPath)) {
91
+ await rm(indexHtmlPath);
92
+ }
88
93
  console.log(chalk.bold.cyan(`Creating a new Netlify TanStack Start app in ${chalk.white(targetDir)}...`));
89
94
  console.log(chalk.gray(`Using starter: ${starterId}`));
95
+ const manifest = await fetch(MANIFEST_URL).then((r) => r.json());
96
+ const starterEntry = manifest.starters.find((s) => s.id === starterId);
97
+ const frameworkId = starterEntry?.framework;
90
98
  // Sparse clone the template repo into a temp directory
91
99
  const tmpDir = await mkdtemp(join(tmpdir(), 'netlify-cta-'));
92
100
  try {
93
101
  console.log(chalk.gray('⟳ Fetching template...'));
102
+ const sparsePaths = [`starters/${starterId}`, ...(frameworkId ? [`frameworks/${frameworkId}`] : [])];
94
103
  execSync(`git clone --depth=1 --filter=blob:none --sparse ${GITHUB_REPO} ${tmpDir}`, { stdio: 'pipe' });
95
- execSync(`git -C ${tmpDir} sparse-checkout set starters/${starterId}`, { stdio: 'pipe' });
104
+ execSync(`git -C ${tmpDir} sparse-checkout set ${sparsePaths.join(' ')}`, { stdio: 'pipe' });
96
105
  const starterPath = join(tmpDir, 'starters', starterId);
97
106
  if (!existsSync(starterPath)) {
98
107
  console.error(chalk.red(`Starter "${starterId}" not found in the template repo. Run --list-addons-json to see available starters.`));
@@ -100,6 +109,18 @@ export function cli() {
100
109
  }
101
110
  // Copy starter files to target directory
102
111
  await cp(starterPath, targetDir, { recursive: true });
112
+ // Copy framework overlay files if they exist
113
+ if (frameworkId) {
114
+ const frameworkPath = join(tmpDir, 'frameworks', frameworkId);
115
+ if (existsSync(frameworkPath)) {
116
+ console.log(chalk.gray(`⟳ Applying framework overlay (${frameworkId})...`));
117
+ await cp(frameworkPath, targetDir, { recursive: true });
118
+ console.log(chalk.green(`✓ Framework overlay applied (${frameworkId})`));
119
+ }
120
+ else {
121
+ console.log(chalk.yellow(`⚠ Framework overlay "${frameworkId}" not found in repo, skipping`));
122
+ }
123
+ }
103
124
  // Update package.json name if a project name was provided
104
125
  if (projectName && projectName !== '.') {
105
126
  const pkgPath = join(targetDir, 'package.json');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kaddidlehopper",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Create TanStack Start applications for Netlify",
5
5
  "bin": "./dist/index.js",
6
6
  "type": "module",
package/src/cli.ts CHANGED
@@ -10,9 +10,9 @@ import validatePackageName from 'validate-npm-package-name'
10
10
 
11
11
  import type { CliOptions } from './types.js'
12
12
 
13
- const GITHUB_REPO = 'https://github.com/jherr/kdh-templates.git'
13
+ const GITHUB_REPO = 'https://github.com/netlify/swar-templates.git'
14
14
  const MANIFEST_URL =
15
- 'https://raw.githubusercontent.com/jherr/kdh-templates/main/manifest.json'
15
+ 'https://raw.githubusercontent.com/netlify/swar-templates/main/manifest.json'
16
16
 
17
17
  function sanitizePackageName(name: string): string {
18
18
  return name
@@ -119,6 +119,12 @@ export function cli() {
119
119
  }
120
120
  }
121
121
 
122
+ // Delete index.html if it exists in the target directory
123
+ const indexHtmlPath = join(targetDir, 'index.html')
124
+ if (existsSync(indexHtmlPath)) {
125
+ await rm(indexHtmlPath)
126
+ }
127
+
122
128
  console.log(
123
129
  chalk.bold.cyan(
124
130
  `Creating a new Netlify TanStack Start app in ${chalk.white(targetDir)}...`,
@@ -126,16 +132,23 @@ export function cli() {
126
132
  )
127
133
  console.log(chalk.gray(`Using starter: ${starterId}`))
128
134
 
135
+ // Fetch manifest to resolve frameworkId for this starter
136
+ type StarterEntry = { id: string; framework?: string }
137
+ const manifest = await fetch(MANIFEST_URL).then((r) => r.json()) as { starters: StarterEntry[] }
138
+ const starterEntry = manifest.starters.find((s) => s.id === starterId)
139
+ const frameworkId = starterEntry?.framework
140
+
129
141
  // Sparse clone the template repo into a temp directory
130
142
  const tmpDir = await mkdtemp(join(tmpdir(), 'netlify-cta-'))
131
143
  try {
132
144
  console.log(chalk.gray('⟳ Fetching template...'))
145
+ const sparsePaths = [`starters/${starterId}`, ...(frameworkId ? [`frameworks/${frameworkId}`] : [])]
133
146
  execSync(
134
147
  `git clone --depth=1 --filter=blob:none --sparse ${GITHUB_REPO} ${tmpDir}`,
135
148
  { stdio: 'pipe' },
136
149
  )
137
150
  execSync(
138
- `git -C ${tmpDir} sparse-checkout set starters/${starterId}`,
151
+ `git -C ${tmpDir} sparse-checkout set ${sparsePaths.join(' ')}`,
139
152
  { stdio: 'pipe' },
140
153
  )
141
154
 
@@ -152,6 +165,18 @@ export function cli() {
152
165
  // Copy starter files to target directory
153
166
  await cp(starterPath, targetDir, { recursive: true })
154
167
 
168
+ // Copy framework overlay files if they exist
169
+ if (frameworkId) {
170
+ const frameworkPath = join(tmpDir, 'frameworks', frameworkId)
171
+ if (existsSync(frameworkPath)) {
172
+ console.log(chalk.gray(`⟳ Applying framework overlay (${frameworkId})...`))
173
+ await cp(frameworkPath, targetDir, { recursive: true })
174
+ console.log(chalk.green(`✓ Framework overlay applied (${frameworkId})`))
175
+ } else {
176
+ console.log(chalk.yellow(`⚠ Framework overlay "${frameworkId}" not found in repo, skipping`))
177
+ }
178
+ }
179
+
155
180
  // Update package.json name if a project name was provided
156
181
  if (projectName && projectName !== '.') {
157
182
  const pkgPath = join(targetDir, 'package.json')