Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/create-commandkit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ Examples:
process.exit(1);
}

// Determine package manager
const manager = resolvePackageManager(cliOptions);

// Get Discord token
let token: string;
if (cliOptions.yes) {
Expand All @@ -158,9 +155,13 @@ Examples:

outro(colors.cyan('Setup complete.'));

const example = cliOptions.example || getDefaultExample(cliOptions);

// Determine package manager
const manager = resolvePackageManager(cliOptions, example);

// Fetch example from GitHub
try {
const example = cliOptions.example || getDefaultExample(cliOptions);
await fetchExample({
example,
examplePath: cliOptions.examplePath,
Expand Down
28 changes: 20 additions & 8 deletions packages/create-commandkit/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,18 @@ export function getPackageManagerFromCLI(options: {
return null;
}

export function resolvePackageManager(cliOptions: {
useNpm?: boolean;
usePnpm?: boolean;
useYarn?: boolean;
useBun?: boolean;
useDeno?: boolean;
}): PackageManager {
export function resolvePackageManager(
cliOptions: {
useNpm?: boolean;
usePnpm?: boolean;
useYarn?: boolean;
useBun?: boolean;
useDeno?: boolean;
},
name: string,
): PackageManager {
const cliManager = getPackageManagerFromCLI(cliOptions);
return cliManager || detectPackageManager();
return cliManager || (isDenoProject(name) ? 'deno' : detectPackageManager());
}

export function getDefaultExample(cliOptions: CLIOptions): string {
Expand Down Expand Up @@ -139,3 +142,12 @@ export async function fetchAvailableExamples(): Promise<string[]> {
return ['basic-ts', 'basic-js', 'deno-ts', 'without-cli'];
}
}

export function isDenoProject(example: string): boolean {
const isOfficial = isOfficialExample(example);
// if it's not an official example, we can assume it's not a Deno project
// the user may use --use-deno to force a Deno project
if (!isOfficial) return false;

return example.startsWith('deno-') || example.startsWith('with-deno-');
}