-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use
get-tsconfig
instead of tsconfig-paths
refactor: replace `node:path` with `pathe` chore: add `tinyexec` instead of `execa`
- Loading branch information
1 parent
3f0ded8
commit 8a8d1ef
Showing
20 changed files
with
60 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import type { initOptionsSchema } from '@/src/commands/init' | ||
import type { z } from 'zod' | ||
import path from 'node:path' | ||
import { getPackageManager } from '@/src/utils/get-package-manager' | ||
import { highlighter } from '@/src/utils/highlighter' | ||
import { logger } from '@/src/utils/logger' | ||
import { spinner } from '@/src/utils/spinner' | ||
import { execa } from 'execa' | ||
import fs from 'fs-extra' | ||
import { detectPackageManager } from 'nypm' | ||
import path from 'pathe' | ||
import prompts from 'prompts' | ||
import { x } from 'tinyexec' | ||
|
||
export async function createProject(options: Pick<z.infer<typeof initOptionsSchema>, 'cwd' | 'force' | 'srcDir'>) { | ||
options = { | ||
|
@@ -35,9 +35,7 @@ export async function createProject(options: Pick<z.infer<typeof initOptionsSche | |
} | ||
} | ||
|
||
const packageManager = await getPackageManager(options.cwd, { | ||
withFallback: true, | ||
}) | ||
const packageManager = detectPackageManager(options.cwd) | ||
|
||
const { name } = await prompts({ | ||
type: 'text', | ||
|
@@ -93,11 +91,13 @@ export async function createProject(options: Pick<z.infer<typeof initOptionsSche | |
] | ||
|
||
try { | ||
await execa( | ||
await x( | ||
'npx', | ||
['[email protected]', projectPath, '--silent', ...args], | ||
{ | ||
cwd: options.cwd, | ||
nodeOptions: { | ||
cwd: options.cwd, | ||
}, | ||
}, | ||
) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
import { type ConfigLoaderSuccessResult, createMatchPath } from 'tsconfig-paths' | ||
import { createPathsMatcher, type TsConfigResult } from 'get-tsconfig' | ||
|
||
export function resolveImport( | ||
importPath: string, | ||
config: Pick<ConfigLoaderSuccessResult, 'absoluteBaseUrl' | 'paths'>, | ||
) { | ||
return createMatchPath(config.absoluteBaseUrl, config.paths)( | ||
importPath, | ||
undefined, | ||
() => true, | ||
['.ts', '.tsx', '.vue'], | ||
) | ||
export function resolveImport(importPath: string, config: TsConfigResult) { | ||
const matcher = createPathsMatcher(config) | ||
if (matcher === null) { | ||
return | ||
} | ||
const paths = matcher(importPath) | ||
return paths[0] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.