* fix(cli): incorrect `yarn` project creation process, close #254 * chore: tweak
This commit is contained in:
parent
6d918ca7b8
commit
08eeac7cb8
@ -41,6 +41,8 @@
|
||||
"vuepress": "2.0.0-rc.17",
|
||||
"vue": "^3.5.10",
|
||||
"sass-embedded": "^1.79.4",
|
||||
"sass-loader": "^16.0.2"
|
||||
"sass-loader": "^16.0.2",
|
||||
"http-server": "^14.1.1",
|
||||
"typescript": "^5.6.2"
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,6 +72,13 @@ export async function generate(mode: Mode, data: ResolvedData): Promise<void> {
|
||||
}
|
||||
// rewrite git files end ====================================
|
||||
|
||||
if (data.packageManager === 'yarn') {
|
||||
fileList.push({
|
||||
filepath: '.yarnrc.yml',
|
||||
content: 'nodeLinker: \'node-modules\'\n',
|
||||
})
|
||||
}
|
||||
|
||||
if (data.deploy !== DeployType.custom) {
|
||||
fileList.push(...await readFiles(getTemplate(`deploy/${data.deploy}`)))
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ export async function createPackageJson(
|
||||
siteDescription,
|
||||
bundler,
|
||||
injectNpmScripts,
|
||||
useTs,
|
||||
}: ResolvedData,
|
||||
): Promise<File> {
|
||||
if (mode === Mode.create) {
|
||||
@ -23,8 +24,10 @@ export async function createPackageJson(
|
||||
pkg.description = siteDescription
|
||||
|
||||
if (packageManager !== 'npm') {
|
||||
const version = await getPackageManagerVersion(packageManager)
|
||||
let version = await getPackageManagerVersion(packageManager)
|
||||
if (version) {
|
||||
if (packageManager === 'yarn' && version.startsWith('1'))
|
||||
version = '4.5.0'
|
||||
pkg.packageManager = `${packageManager}@${version}`
|
||||
}
|
||||
}
|
||||
@ -61,9 +64,8 @@ export async function createPackageJson(
|
||||
pkg.devDependencies[`@vuepress/bundler-${bundler}`] = `${meta.vuepress}`
|
||||
pkg.devDependencies.vuepress = `${meta.vuepress}`
|
||||
pkg.devDependencies['vuepress-theme-plume'] = `${context.version}`
|
||||
pkg.devDependencies['http-server'] = '^14.1.1'
|
||||
|
||||
const deps: string[] = []
|
||||
const deps: string[] = ['http-server']
|
||||
if (!hasDep('vue'))
|
||||
deps.push('vue')
|
||||
|
||||
@ -73,6 +75,9 @@ export async function createPackageJson(
|
||||
if (!hasDep('sass-embedded'))
|
||||
deps.push('sass-embedded')
|
||||
|
||||
if (useTs)
|
||||
deps.push('typescript')
|
||||
|
||||
for (const dep of deps)
|
||||
pkg.devDependencies[dep] = meta[dep]
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ export async function run(mode: Mode, root?: string) {
|
||||
if (data.install) {
|
||||
progress.message(t('spinner.install'))
|
||||
try {
|
||||
await execaCommand(pm === 'yarn' ? 'yarn' : `${pm} install`, { cwd })
|
||||
await execaCommand(`${pm} install`, { cwd })
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`${colors.red('install dependencies error: ')}\n`, e)
|
||||
@ -58,8 +58,8 @@ export async function run(mode: Mode, root?: string) {
|
||||
}
|
||||
|
||||
const cdCommand = mode === Mode.create ? colors.green(`cd ${data.root}`) : ''
|
||||
const runCommand = colors.green(pm === 'yarn' ? 'yarn docs:dev' : `${pm} run docs:dev`)
|
||||
const installCommand = colors.green(pm === 'yarn' ? 'yarn' : `${pm} install`)
|
||||
const runCommand = colors.green(`${pm} run docs:dev`)
|
||||
const installCommand = colors.green(`${pm} install`)
|
||||
|
||||
progress.stop(t('spinner.stop'))
|
||||
|
||||
|
||||
@ -37,8 +37,14 @@
|
||||
"tsup": "tsup --config tsup.config.ts"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"markdown-it": "^14.0.0",
|
||||
"vuepress": "2.0.0-rc.17"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"markdown-it": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@mdit/plugin-attrs": "^0.13.1",
|
||||
"@mdit/plugin-footnote": "^0.13.1",
|
||||
|
||||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@ -189,6 +189,9 @@ importers:
|
||||
image-size:
|
||||
specifier: ^1.1.1
|
||||
version: 1.1.1
|
||||
markdown-it:
|
||||
specifier: ^14.0.0
|
||||
version: 14.1.0
|
||||
markdown-it-container:
|
||||
specifier: ^4.0.0
|
||||
version: 4.0.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user