Skip to content

Commit 63c9276

Browse files
committed
fix: tiged import issue
1 parent 1d5295b commit 63c9276

File tree

6 files changed

+28
-12
lines changed

6 files changed

+28
-12
lines changed

packages/create-commandkit/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ npx create-commandkit@latest --example "https://github.com/user/repo" --example-
5252
### CLI Options
5353

5454
- `-h, --help` - Show all available options
55-
- `-v, --version` - Output the version number
55+
- `-V, --version` - Output the version number
5656
- `-e, --example <name-or-url>` - An example to bootstrap the app with
5757
- `--example-path <path>` - Specify the path to the example separately
5858
- `--use-npm` - Use npm as package manager

packages/create-commandkit/src/cli.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export function parseCLI(): CLIOptions {
1010
.version(process.env.npm_package_version || '1.0.0')
1111
.argument('[project-directory]', 'Project directory name')
1212
.option('-h, --help', 'Show all available options')
13-
.option('-v, --version', 'Output the version number')
1413
.option(
1514
'-e, --example <name-or-url>',
1615
'An example to bootstrap the app with',
@@ -42,7 +41,6 @@ export function parseCLI(): CLIOptions {
4241

4342
return {
4443
help: options.help,
45-
version: options.version,
4644
example: options.example,
4745
examplePath: options.examplePath,
4846
useNpm: options.useNpm,

packages/create-commandkit/src/functions/fetchExample.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'fs-extra';
22
import path from 'node:path';
33
// @ts-ignore
4-
import { tiged } from 'tiged';
4+
import tiged from 'tiged';
55
import { validateExampleName } from './validate.js';
66

77
export interface FetchExampleOptions {

packages/create-commandkit/src/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env node
2-
console.clear();
32

43
import { confirm, intro, outro, password, text } from '@clack/prompts';
54
import fs from 'fs-extra';
@@ -34,7 +33,7 @@ Usage: create-commandkit [options] [project-directory]
3433
3534
Options:
3635
-h, --help Show all available options
37-
-v, --version Output the version number
36+
-V, --version Output the version number
3837
-e, --example <name-or-url> An example to bootstrap the app with
3938
--example-path <path> Specify the path to the example separately
4039
--use-npm Explicitly tell the CLI to bootstrap using npm
@@ -58,11 +57,6 @@ Examples:
5857
process.exit(0);
5958
}
6059

61-
if (cliOptions.version) {
62-
console.log(process.env.npm_package_version || '1.0.0');
63-
process.exit(0);
64-
}
65-
6660
// Handle list examples flag
6761
if (cliOptions.listExamples) {
6862
console.log(colors.cyan('Fetching available examples...'));

packages/create-commandkit/src/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun' | 'deno';
22

33
export interface CLIOptions {
44
help?: boolean;
5-
version?: boolean;
65
example?: string;
76
examplePath?: string;
87
useNpm?: boolean;

packages/create-commandkit/src/utils.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,28 @@ export function getInstallCommand(
9090
}
9191

9292
export async function fetchAvailableExamples(): Promise<string[]> {
93+
let controller: AbortController | null = null;
94+
let timeoutId: NodeJS.Timeout | null = null;
95+
9396
try {
97+
controller = new AbortController();
98+
timeoutId = setTimeout(() => controller!.abort(), 10000); // 10 second timeout
99+
94100
const response = await fetch(
95101
'https://api.github.com/repos/underctrl-io/commandkit/contents/examples',
102+
{
103+
signal: controller.signal,
104+
headers: {
105+
'User-Agent': 'create-commandkit',
106+
},
107+
},
96108
);
97109

110+
if (timeoutId) {
111+
clearTimeout(timeoutId);
112+
timeoutId = null;
113+
}
114+
98115
if (!response.ok) {
99116
throw new Error(`GitHub API error: ${response.status}`);
100117
}
@@ -110,6 +127,14 @@ export async function fetchAvailableExamples(): Promise<string[]> {
110127
.map((item) => item.name)
111128
.sort();
112129
} catch (error) {
130+
// Clean up on error
131+
if (timeoutId) {
132+
clearTimeout(timeoutId);
133+
}
134+
if (controller) {
135+
controller.abort();
136+
}
137+
113138
// Fallback to few known examples if API fails
114139
return ['basic-ts', 'basic-js', 'deno-ts', 'without-cli'];
115140
}

0 commit comments

Comments
 (0)