termcast 1.3.24 → 1.3.26

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 (53) hide show
  1. package/dist/apis/toast.d.ts +5 -0
  2. package/dist/apis/toast.d.ts.map +1 -1
  3. package/dist/apis/toast.js +7 -43
  4. package/dist/apis/toast.js.map +1 -1
  5. package/dist/build.d.ts.map +1 -1
  6. package/dist/build.js +1 -0
  7. package/dist/build.js.map +1 -1
  8. package/dist/cli.d.ts +1 -0
  9. package/dist/cli.d.ts.map +1 -1
  10. package/dist/cli.js +21 -10
  11. package/dist/cli.js.map +1 -1
  12. package/dist/compile.d.ts +2 -1
  13. package/dist/compile.d.ts.map +1 -1
  14. package/dist/compile.js +9 -7
  15. package/dist/compile.js.map +1 -1
  16. package/dist/components/form/index.d.ts.map +1 -1
  17. package/dist/components/form/index.js +5 -3
  18. package/dist/components/form/index.js.map +1 -1
  19. package/dist/components/list.d.ts.map +1 -1
  20. package/dist/components/list.js +16 -9
  21. package/dist/components/list.js.map +1 -1
  22. package/dist/examples/toast-variations.d.ts +2 -0
  23. package/dist/examples/toast-variations.d.ts.map +1 -0
  24. package/dist/examples/toast-variations.js +122 -0
  25. package/dist/examples/toast-variations.js.map +1 -0
  26. package/dist/release.d.ts +1 -1
  27. package/dist/release.d.ts.map +1 -1
  28. package/dist/release.js +29 -33
  29. package/dist/release.js.map +1 -1
  30. package/dist/utils/run-command.d.ts +3 -2
  31. package/dist/utils/run-command.d.ts.map +1 -1
  32. package/dist/utils/run-command.js +9 -3
  33. package/dist/utils/run-command.js.map +1 -1
  34. package/package.json +2 -3
  35. package/src/apis/toast.tsx +37 -62
  36. package/src/build.tsx +1 -0
  37. package/src/cli.tsx +23 -11
  38. package/src/compile.tsx +10 -6
  39. package/src/components/form/index.tsx +20 -11
  40. package/src/components/list.tsx +54 -31
  41. package/src/examples/form-basic.vitest.tsx +8 -8
  42. package/src/examples/list-with-detail.vitest.tsx +8 -8
  43. package/src/examples/list-with-sections.vitest.tsx +9 -9
  44. package/src/examples/list-with-toast.vitest.tsx +16 -16
  45. package/src/examples/simple-file-picker.vitest.tsx +12 -8
  46. package/src/examples/simple-grid.vitest.tsx +2 -2
  47. package/src/examples/simple-navigation.vitest.tsx +16 -16
  48. package/src/examples/swift-extension.vitest.tsx +2 -2
  49. package/src/examples/toast-variations.tsx +150 -0
  50. package/src/examples/toast-variations.vitest.tsx +370 -0
  51. package/src/extensions/dev.vitest.tsx +12 -10
  52. package/src/release.tsx +32 -38
  53. package/src/utils/run-command.tsx +10 -3
@@ -174,10 +174,10 @@ test('can fill arguments and run command', async () => {
174
174
  ▼ Category (empty)
175
175
 
176
176
 
177
-
178
- copy val┌─────────────────────────────────┐
179
- ✓ Copied to Clipboard - (empty)
180
- └─────────────────────────────────┘"
177
+ ┌───────────────────────┐
178
+ Copied to Clipboard │
179
+ (empty)
180
+ └───────────────────────┘"
181
181
  `)
182
182
  }, 30000)
183
183
 
@@ -207,12 +207,14 @@ test('can run simple view command without arguments', async () => {
207
207
 
208
208
  Items ▲
209
209
  ›▲ First Item This is the first item █
210
- ▲ Second Item This is the second item
211
- ▲ Third Item This is the third item
212
- ▲ Fourth Item This is the fourth item
213
-
214
-
215
- copy item title ↑↓ navigate ^k actions"
210
+ ▲ Second Item This is the second item
211
+ ▲ Third Item This is the third item
212
+ ▲ Fourth Item This is the fourth item
213
+ ▲ Fifth Item This is the fifth item ▼
214
+ ┌───────────────────────┐
215
+ Copied to Clipboard
216
+ │ First Item │
217
+ └───────────────────────┘"
216
218
  `)
217
219
  }, 30000)
218
220
 
package/src/release.tsx CHANGED
@@ -19,7 +19,7 @@ export interface ReleaseOptions {
19
19
 
20
20
  export interface ReleaseResult {
21
21
  success: boolean
22
- version: string
22
+ tag: string
23
23
  uploadedFiles: string[]
24
24
  }
25
25
 
@@ -33,46 +33,38 @@ export async function releaseExtension({
33
33
  throw new Error(`Extension path does not exist: ${resolvedPath}`)
34
34
  }
35
35
 
36
- const packageJsonPath = path.join(resolvedPath, 'package.json')
37
- if (!fs.existsSync(packageJsonPath)) {
38
- throw new Error(`No package.json found at: ${packageJsonPath}`)
39
- }
40
-
41
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))
42
- const name = packageJson.name
43
- const version = packageJson.version
44
-
45
- if (!name) {
46
- throw new Error('package.json must have a name field')
47
- }
48
- if (!version) {
49
- throw new Error('package.json must have a version field')
50
- }
51
-
52
- const tag = `${name}@${version}`
53
- console.log(`Preparing release ${tag}...`)
54
-
55
- // Check if release already exists
36
+ // Get repo name from git remote
37
+ let repoName: string
56
38
  try {
57
- const checkResult = execSync(`gh release view "${tag}" --json tagName`, {
39
+ const remoteUrl = execSync('git config --get remote.origin.url', {
58
40
  cwd: resolvedPath,
59
41
  encoding: 'utf-8',
60
- stdio: ['pipe', 'pipe', 'pipe'],
61
- })
62
- if (checkResult.includes(tag)) {
63
- throw new Error(`Release ${tag} already exists. Bump the version in package.json first.`)
42
+ }).trim()
43
+ // Handle both HTTPS and SSH URLs:
44
+ // https://github.com/user/repo.git -> repo
45
+ // git@github.com:user/repo.git -> repo
46
+ const match = remoteUrl.match(/\/([^/]+?)(?:\.git)?$/) || remoteUrl.match(/:([^/]+?)(?:\.git)?$/)
47
+ if (!match) {
48
+ throw new Error(`Could not parse repo name from remote URL: ${remoteUrl}`)
64
49
  }
50
+ repoName = match[1].replace(/\.git$/, '')
65
51
  } catch (error: any) {
66
- if (error.message?.includes('already exists')) {
67
- throw error
68
- }
69
- const stderr = error.stderr?.toString() || ''
70
- const isNotFound = stderr.includes('release not found') || stderr.includes('Not Found')
71
- if (!isNotFound) {
72
- throw new Error(`Failed to check release status: ${stderr || error.message}`)
73
- }
52
+ throw new Error(`Failed to get git remote: ${error.message}`)
74
53
  }
75
54
 
55
+ // Generate date-based tag with hour and minute
56
+ const now = new Date()
57
+ const dateTag = [
58
+ now.getFullYear(),
59
+ String(now.getMonth() + 1).padStart(2, '0'),
60
+ String(now.getDate()).padStart(2, '0'),
61
+ String(now.getHours()).padStart(2, '0'),
62
+ String(now.getMinutes()).padStart(2, '0'),
63
+ ].join('')
64
+
65
+ const tag = `${repoName}@${dateTag}`
66
+ console.log(`Preparing release ${tag}...`)
67
+
76
68
  // Install dependencies for all platforms
77
69
  console.log('Installing dependencies for all platforms...')
78
70
  execSync('bun install --os="*" --cpu="*"', {
@@ -92,13 +84,14 @@ export async function releaseExtension({
92
84
  if (!fs.existsSync(outputDir)) {
93
85
  fs.mkdirSync(outputDir, { recursive: true })
94
86
  }
87
+ fs.writeFileSync(path.join(outputDir, '.gitignore'), '*\n')
95
88
 
96
89
  // Compile for all targets in parallel
97
90
  console.log(`Compiling for ${targets.length} targets in parallel...`)
98
91
  const compileResults = await Promise.all(
99
92
  targets.map(async (target) => {
100
93
  const suffix = targetToFileSuffix(target)
101
- const binaryName = `${name}-${suffix}`
94
+ const binaryName = `${repoName}-${suffix}`
102
95
  const outfile = path.join(outputDir, binaryName)
103
96
 
104
97
  const result = await compileExtension({
@@ -106,12 +99,13 @@ export async function releaseExtension({
106
99
  outfile,
107
100
  minify: true,
108
101
  target,
102
+ version: tag,
109
103
  })
110
104
 
111
105
  console.log(` ✓ ${path.basename(result.outfile)}`)
112
106
 
113
107
  const archiveExt = getArchiveExtension(target)
114
- const archiveName = `${name}-${suffix}${archiveExt}`
108
+ const archiveName = `${repoName}-${suffix}${archiveExt}`
115
109
  const archivePath = path.join(outputDir, archiveName)
116
110
 
117
111
  if (archiveExt === '.tar.gz') {
@@ -130,7 +124,7 @@ export async function releaseExtension({
130
124
  // Create GitHub release
131
125
  console.log(`\nCreating GitHub release ${tag}...`)
132
126
  try {
133
- execSync(`gh release create "${tag}" --title "${tag}" --notes "Release ${version}"`, {
127
+ execSync(`gh release create "${tag}" --title "${tag}" --notes "Release ${tag}"`, {
134
128
  cwd: resolvedPath,
135
129
  stdio: 'inherit',
136
130
  })
@@ -158,7 +152,7 @@ export async function releaseExtension({
158
152
 
159
153
  return {
160
154
  success: true,
161
- version,
155
+ tag,
162
156
  uploadedFiles: compileResults,
163
157
  }
164
158
  }
@@ -18,6 +18,7 @@ export interface CommandInfo {
18
18
  export interface ParsedExtensionArgs {
19
19
  commandName?: string
20
20
  showHelp: boolean
21
+ showVersion: boolean
21
22
  }
22
23
 
23
24
  /**
@@ -35,6 +36,7 @@ export function parseExtensionArgs({ skipArgv = 0 }: { skipArgv?: number } = {})
35
36
  return {
36
37
  commandName: parsed.args[0] as string | undefined,
37
38
  showHelp: Boolean(parsed.options.help || parsed.options.h),
39
+ showVersion: Boolean(parsed.options.version || parsed.options.v),
38
40
  }
39
41
  }
40
42
 
@@ -54,12 +56,13 @@ function printExtensionHelp({
54
56
  }
55
57
  console.log('\nOptions:')
56
58
  console.log(' --help, -h Show this help message')
59
+ console.log(' --version, -v Show version')
57
60
  console.log()
58
61
  }
59
62
 
60
63
  /**
61
- * Check for --help flag and print help if found. Call before rendering.
62
- * Exits process if help is shown.
64
+ * Check for --help and --version flags. Call before rendering.
65
+ * Exits process if help or version is shown.
63
66
  */
64
67
  export function handleHelpFlag({
65
68
  extensionName,
@@ -70,7 +73,11 @@ export function handleHelpFlag({
70
73
  commands: CommandInfo[]
71
74
  skipArgv?: number
72
75
  }): void {
73
- const { showHelp } = parseExtensionArgs({ skipArgv })
76
+ const { showHelp, showVersion } = parseExtensionArgs({ skipArgv })
77
+ if (showVersion) {
78
+ console.log(process.env.VERSION || 'unknown')
79
+ process.exit(0)
80
+ }
74
81
  if (showHelp) {
75
82
  printExtensionHelp({ extensionName, commands })
76
83
  process.exit(0)