@tanstack/cli 0.61.1 → 0.62.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.
Files changed (46) hide show
  1. package/package.json +11 -5
  2. package/skills/CHANGELOG.md +18 -0
  3. package/skills/add-addons-existing-app/SKILL.md +113 -0
  4. package/skills/choose-ecosystem-integrations/SKILL.md +140 -0
  5. package/skills/choose-ecosystem-integrations/references/authentication-providers.md +19 -0
  6. package/skills/choose-ecosystem-integrations/references/data-layer-providers.md +20 -0
  7. package/skills/choose-ecosystem-integrations/references/deployment-targets.md +19 -0
  8. package/skills/create-app-scaffold/SKILL.md +132 -0
  9. package/skills/create-app-scaffold/references/create-flag-compatibility-matrix.md +34 -0
  10. package/skills/create-app-scaffold/references/deployment-providers.md +19 -0
  11. package/skills/create-app-scaffold/references/framework-adapters.md +17 -0
  12. package/skills/create-app-scaffold/references/toolchains.md +17 -0
  13. package/skills/maintain-custom-addons-dev-watch/SKILL.md +118 -0
  14. package/skills/query-docs-library-metadata/SKILL.md +85 -0
  15. package/skills/query-docs-library-metadata/references/discovery-command-output-schemas.md +70 -0
  16. package/CHANGELOG.md +0 -815
  17. package/playwright-report/index.html +0 -85
  18. package/playwright.config.ts +0 -21
  19. package/src/bin.ts +0 -15
  20. package/src/cli.ts +0 -1099
  21. package/src/command-line.ts +0 -612
  22. package/src/dev-watch.ts +0 -564
  23. package/src/discovery.ts +0 -209
  24. package/src/file-syncer.ts +0 -263
  25. package/src/index.ts +0 -21
  26. package/src/options.ts +0 -280
  27. package/src/types.ts +0 -27
  28. package/src/ui-environment.ts +0 -74
  29. package/src/ui-prompts.ts +0 -387
  30. package/src/utils.ts +0 -30
  31. package/test-results/.last-run.json +0 -4
  32. package/tests/command-line.test.ts +0 -703
  33. package/tests/index.test.ts +0 -9
  34. package/tests/options.test.ts +0 -281
  35. package/tests/setupVitest.ts +0 -6
  36. package/tests/ui-environment.test.ts +0 -97
  37. package/tests/ui-prompts.test.ts +0 -233
  38. package/tests-e2e/addons-smoke.spec.ts +0 -31
  39. package/tests-e2e/create-smoke.spec.ts +0 -39
  40. package/tests-e2e/helpers.ts +0 -526
  41. package/tests-e2e/matrix-opportunistic.spec.ts +0 -142
  42. package/tests-e2e/router-only-smoke.spec.ts +0 -54
  43. package/tests-e2e/solid-smoke.spec.ts +0 -26
  44. package/tests-e2e/templates-smoke.spec.ts +0 -52
  45. package/tsconfig.json +0 -17
  46. package/vitest.config.js +0 -8
package/src/discovery.ts DELETED
@@ -1,209 +0,0 @@
1
- import { z } from 'zod'
2
-
3
- const TANSTACK_API_BASE = 'https://tanstack.com/api/data'
4
-
5
- const LibrarySchema = z.object({
6
- id: z.string(),
7
- name: z.string(),
8
- tagline: z.string(),
9
- description: z.string().optional(),
10
- frameworks: z.array(z.string()),
11
- latestVersion: z.string(),
12
- latestBranch: z.string().optional(),
13
- availableVersions: z.array(z.string()),
14
- repo: z.string(),
15
- docsRoot: z.string().optional(),
16
- defaultDocs: z.string().optional(),
17
- docsUrl: z.string().optional(),
18
- githubUrl: z.string().optional(),
19
- })
20
-
21
- const LibrariesResponseSchema = z.object({
22
- libraries: z.array(LibrarySchema),
23
- groups: z.record(z.array(z.string())),
24
- groupNames: z.record(z.string()),
25
- })
26
-
27
- const PartnerSchema = z.object({
28
- id: z.string(),
29
- name: z.string(),
30
- tagline: z.string().optional(),
31
- description: z.string(),
32
- category: z.string(),
33
- categoryLabel: z.string(),
34
- libraries: z.array(z.string()),
35
- url: z.string(),
36
- })
37
-
38
- const PartnersResponseSchema = z.object({
39
- partners: z.array(PartnerSchema),
40
- categories: z.array(z.string()),
41
- categoryLabels: z.record(z.string()),
42
- })
43
-
44
- export const LIBRARY_GROUPS = ['state', 'headlessUI', 'performance', 'tooling'] as const
45
-
46
- // Algolia config (public read-only keys)
47
- const ALGOLIA_APP_ID = 'FQ0DQ6MA3C'
48
- const ALGOLIA_API_KEY = '10c34d6a5c89f6048cf644d601e65172'
49
- const ALGOLIA_INDEX = 'tanstack-test'
50
-
51
- export type LibrariesResponse = z.infer<typeof LibrariesResponseSchema>
52
- export type PartnersResponse = z.infer<typeof PartnersResponseSchema>
53
-
54
- export async function fetchLibraries(): Promise<LibrariesResponse> {
55
- const response = await fetch(`${TANSTACK_API_BASE}/libraries`)
56
- if (!response.ok) {
57
- throw new Error(`Failed to fetch libraries: ${response.statusText}`)
58
- }
59
- const data = await response.json()
60
- return LibrariesResponseSchema.parse(data)
61
- }
62
-
63
- export async function fetchPartners(): Promise<PartnersResponse> {
64
- const response = await fetch(`${TANSTACK_API_BASE}/partners`)
65
- if (!response.ok) {
66
- throw new Error(`Failed to fetch partners: ${response.statusText}`)
67
- }
68
- const data = await response.json()
69
- return PartnersResponseSchema.parse(data)
70
- }
71
-
72
- export async function fetchDocContent(
73
- repo: string,
74
- branch: string,
75
- filePath: string,
76
- ): Promise<string | null> {
77
- const url = `https://raw.githubusercontent.com/${repo}/${branch}/${filePath}`
78
- const response = await fetch(url, {
79
- headers: { 'User-Agent': 'tanstack-cli' },
80
- })
81
-
82
- if (!response.ok) {
83
- if (response.status === 404) {
84
- return null
85
- }
86
- throw new Error(`Failed to fetch doc: ${response.statusText}`)
87
- }
88
-
89
- return response.text()
90
- }
91
-
92
- export async function searchTanStackDocs({
93
- query,
94
- library,
95
- framework,
96
- limit = 10,
97
- }: {
98
- query: string
99
- library?: string
100
- framework?: string
101
- limit?: number
102
- }): Promise<{
103
- query: string
104
- totalHits: number
105
- results: Array<{
106
- title: string
107
- url: string
108
- snippet: string
109
- library: string
110
- breadcrumb: Array<string>
111
- }>
112
- }> {
113
- const ALL_LIBRARIES = [
114
- 'config',
115
- 'form',
116
- 'optimistic',
117
- 'pacer',
118
- 'query',
119
- 'ranger',
120
- 'react-charts',
121
- 'router',
122
- 'start',
123
- 'store',
124
- 'table',
125
- 'virtual',
126
- 'db',
127
- 'devtools',
128
- ]
129
- const ALL_FRAMEWORKS = ['react', 'vue', 'solid', 'svelte', 'angular']
130
-
131
- const filterParts: Array<string> = ['version:latest']
132
-
133
- if (library) {
134
- const otherLibraries = ALL_LIBRARIES.filter((l) => l !== library)
135
- const exclusions = otherLibraries.map((l) => `NOT library:${l}`).join(' AND ')
136
- if (exclusions) filterParts.push(`(${exclusions})`)
137
- }
138
-
139
- if (framework) {
140
- const otherFrameworks = ALL_FRAMEWORKS.filter((f) => f !== framework)
141
- const exclusions = otherFrameworks.map((f) => `NOT framework:${f}`).join(' AND ')
142
- if (exclusions) filterParts.push(`(${exclusions})`)
143
- }
144
-
145
- const searchParams = {
146
- requests: [
147
- {
148
- indexName: ALGOLIA_INDEX,
149
- query,
150
- hitsPerPage: Math.min(limit, 50),
151
- filters: filterParts.join(' AND '),
152
- attributesToRetrieve: ['hierarchy', 'url', 'content', 'library'],
153
- attributesToSnippet: ['content:80'],
154
- },
155
- ],
156
- }
157
-
158
- const response = await fetch(
159
- `https://${ALGOLIA_APP_ID}-dsn.algolia.net/1/indexes/*/queries`,
160
- {
161
- method: 'POST',
162
- headers: {
163
- 'Content-Type': 'application/json',
164
- 'X-Algolia-Application-Id': ALGOLIA_APP_ID,
165
- 'X-Algolia-API-Key': ALGOLIA_API_KEY,
166
- },
167
- body: JSON.stringify(searchParams),
168
- },
169
- )
170
-
171
- if (!response.ok) {
172
- throw new Error(`Algolia search failed: ${response.statusText}`)
173
- }
174
-
175
- const searchResponse = (await response.json()) as {
176
- results: Array<{
177
- hits: Array<{
178
- objectID: string
179
- url: string
180
- library?: string
181
- hierarchy: Record<string, string | undefined>
182
- content?: string
183
- _snippetResult?: { content?: { value?: string } }
184
- }>
185
- nbHits?: number
186
- }>
187
- }
188
-
189
- const searchResult = searchResponse.results[0]
190
-
191
- const results = searchResult.hits.map((hit) => {
192
- const breadcrumb = Object.values(hit.hierarchy).filter(
193
- (v): v is string => Boolean(v),
194
- )
195
- return {
196
- title: hit.hierarchy.lvl1 || hit.hierarchy.lvl0 || 'Untitled',
197
- url: hit.url,
198
- snippet: hit._snippetResult?.content?.value || hit.content || '',
199
- library: hit.library || 'unknown',
200
- breadcrumb,
201
- }
202
- })
203
-
204
- return {
205
- query,
206
- totalHits: searchResult.nbHits || results.length,
207
- results,
208
- }
209
- }
@@ -1,263 +0,0 @@
1
- import fs from 'node:fs'
2
- import path from 'node:path'
3
- import crypto from 'node:crypto'
4
- import * as diff from 'diff'
5
-
6
- export interface FileUpdate {
7
- path: string
8
- diff?: string
9
- }
10
-
11
- export interface SyncResult {
12
- updated: Array<FileUpdate>
13
- skipped: Array<string>
14
- created: Array<string>
15
- deleted: Array<string>
16
- sourceFiles: Array<string>
17
- errors: Array<string>
18
- }
19
-
20
- export interface SyncOptions {
21
- deleteRemoved?: boolean
22
- previousSourceFiles?: Set<string>
23
- }
24
-
25
- export class FileSyncer {
26
- async sync(
27
- sourceDir: string,
28
- targetDir: string,
29
- options?: SyncOptions,
30
- ): Promise<SyncResult> {
31
- const result: SyncResult = {
32
- updated: [],
33
- skipped: [],
34
- created: [],
35
- deleted: [],
36
- sourceFiles: [],
37
- errors: [],
38
- }
39
-
40
- // Ensure directories exist
41
- if (!fs.existsSync(sourceDir)) {
42
- throw new Error(`Source directory does not exist: ${sourceDir}`)
43
- }
44
- if (!fs.existsSync(targetDir)) {
45
- throw new Error(`Target directory does not exist: ${targetDir}`)
46
- }
47
-
48
- // Walk through source directory and sync files
49
- await this.syncDirectory(sourceDir, targetDir, sourceDir, result)
50
-
51
- if (options?.deleteRemoved && options.previousSourceFiles) {
52
- const currentSourceFileSet = new Set(result.sourceFiles)
53
- await this.deleteRemovedFiles(
54
- targetDir,
55
- options.previousSourceFiles,
56
- currentSourceFileSet,
57
- result,
58
- )
59
- }
60
-
61
- return result
62
- }
63
-
64
- private async syncDirectory(
65
- currentPath: string,
66
- targetBase: string,
67
- sourceBase: string,
68
- result: SyncResult,
69
- ): Promise<void> {
70
- const entries = await fs.promises.readdir(currentPath, {
71
- withFileTypes: true,
72
- })
73
-
74
- for (const entry of entries) {
75
- const sourcePath = path.join(currentPath, entry.name)
76
- const relativePath = path.relative(sourceBase, sourcePath)
77
- const targetPath = path.join(targetBase, relativePath)
78
-
79
- // Skip certain directories
80
- if (entry.isDirectory()) {
81
- if (this.shouldSkipDirectory(entry.name)) {
82
- continue
83
- }
84
-
85
- // Ensure target directory exists
86
- if (!fs.existsSync(targetPath)) {
87
- await fs.promises.mkdir(targetPath, { recursive: true })
88
- }
89
-
90
- // Recursively sync subdirectory
91
- await this.syncDirectory(sourcePath, targetBase, sourceBase, result)
92
- } else if (entry.isFile()) {
93
- // Skip certain files
94
- if (this.shouldSkipFile(entry.name)) {
95
- continue
96
- }
97
-
98
- result.sourceFiles.push(relativePath)
99
-
100
- try {
101
- const shouldUpdate = await this.shouldUpdateFile(
102
- sourcePath,
103
- targetPath,
104
- )
105
-
106
- if (shouldUpdate) {
107
- // Check if file exists to generate diff
108
- let fileDiff: string | undefined
109
- const targetExists = fs.existsSync(targetPath)
110
-
111
- if (targetExists) {
112
- // Generate diff for existing files
113
- const oldContent = await fs.promises.readFile(targetPath, 'utf-8')
114
- const newContent = await fs.promises.readFile(sourcePath, 'utf-8')
115
-
116
- const changes = diff.createPatch(
117
- relativePath,
118
- oldContent,
119
- newContent,
120
- 'Previous',
121
- 'Current',
122
- )
123
-
124
- // Only include diff if there are actual changes
125
- if (changes && changes.split('\n').length > 5) {
126
- fileDiff = changes
127
- }
128
- }
129
-
130
- // Copy file
131
- await fs.promises.copyFile(sourcePath, targetPath)
132
-
133
- // Touch file to trigger dev server reload
134
- const now = new Date()
135
- await fs.promises.utimes(targetPath, now, now)
136
-
137
- if (!targetExists) {
138
- result.created.push(relativePath)
139
- } else {
140
- result.updated.push({
141
- path: relativePath,
142
- diff: fileDiff,
143
- })
144
- }
145
- } else {
146
- result.skipped.push(relativePath)
147
- }
148
- } catch (error) {
149
- result.errors.push(
150
- `${relativePath}: ${error instanceof Error ? error.message : String(error)}`,
151
- )
152
- }
153
- }
154
- }
155
- }
156
-
157
- private async shouldUpdateFile(
158
- sourcePath: string,
159
- targetPath: string,
160
- ): Promise<boolean> {
161
- // If target doesn't exist, definitely update
162
- if (!fs.existsSync(targetPath)) {
163
- return true
164
- }
165
-
166
- // Compare file sizes first (quick check)
167
- const [sourceStats, targetStats] = await Promise.all([
168
- fs.promises.stat(sourcePath),
169
- fs.promises.stat(targetPath),
170
- ])
171
-
172
- if (sourceStats.size !== targetStats.size) {
173
- return true
174
- }
175
-
176
- // Compare MD5 hashes for content
177
- const [sourceHash, targetHash] = await Promise.all([
178
- this.calculateHash(sourcePath),
179
- this.calculateHash(targetPath),
180
- ])
181
-
182
- return sourceHash !== targetHash
183
- }
184
-
185
- private async calculateHash(filePath: string): Promise<string> {
186
- return new Promise((resolve, reject) => {
187
- const hash = crypto.createHash('md5')
188
- const stream = fs.createReadStream(filePath)
189
-
190
- stream.on('data', (data) => hash.update(data))
191
- stream.on('end', () => resolve(hash.digest('hex')))
192
- stream.on('error', reject)
193
- })
194
- }
195
-
196
- private shouldSkipDirectory(name: string): boolean {
197
- const skipDirs = [
198
- 'node_modules',
199
- '.git',
200
- 'dist',
201
- 'build',
202
- '.next',
203
- '.nuxt',
204
- '.cache',
205
- '.tmp-dev',
206
- 'coverage',
207
- '.turbo',
208
- ]
209
-
210
- return skipDirs.includes(name) || name.startsWith('.')
211
- }
212
-
213
- private shouldSkipFile(name: string): boolean {
214
- const skipFiles = [
215
- '.DS_Store',
216
- 'Thumbs.db',
217
- 'desktop.ini',
218
- '.cta.json', // Skip .cta.json as it contains framework ID that changes each build
219
- ]
220
-
221
- const skipExtensions = ['.log', '.lock', '.pid', '.seed', '.sqlite']
222
-
223
- if (skipFiles.includes(name)) {
224
- return true
225
- }
226
-
227
- const ext = path.extname(name).toLowerCase()
228
- return skipExtensions.includes(ext)
229
- }
230
-
231
- private async deleteRemovedFiles(
232
- targetDir: string,
233
- previousSourceFiles: Set<string>,
234
- currentSourceFiles: Set<string>,
235
- result: SyncResult,
236
- ): Promise<void> {
237
- for (const relativePath of previousSourceFiles) {
238
- if (currentSourceFiles.has(relativePath)) {
239
- continue
240
- }
241
-
242
- const targetPath = path.join(targetDir, relativePath)
243
-
244
- try {
245
- if (!fs.existsSync(targetPath)) {
246
- continue
247
- }
248
-
249
- const stats = await fs.promises.stat(targetPath)
250
- if (!stats.isFile()) {
251
- continue
252
- }
253
-
254
- await fs.promises.unlink(targetPath)
255
- result.deleted.push(relativePath)
256
- } catch (error) {
257
- result.errors.push(
258
- `${relativePath}: ${error instanceof Error ? error.message : String(error)}`,
259
- )
260
- }
261
- }
262
- }
263
- }
package/src/index.ts DELETED
@@ -1,21 +0,0 @@
1
- import { pathToFileURL } from 'node:url'
2
- import {
3
- createReactFrameworkDefinition,
4
- createSolidFrameworkDefinition,
5
- } from '@tanstack/create'
6
-
7
- import { cli } from './cli.js'
8
-
9
- export { cli }
10
-
11
- const entryPath = process.argv[1]
12
- if (entryPath && import.meta.url === pathToFileURL(entryPath).href) {
13
- cli({
14
- name: 'tanstack',
15
- appName: 'TanStack',
16
- frameworkDefinitionInitializers: [
17
- createReactFrameworkDefinition,
18
- createSolidFrameworkDefinition,
19
- ],
20
- })
21
- }