@@ -2,7 +2,8 @@ import path from 'path'
2
2
import inquirer from 'inquirer'
3
3
import fsExtra from 'fs-extra'
4
4
import InquirerSearchList from 'inquirer-search-list'
5
- import Listr , { ListrTask } from 'listr'
5
+ import type { ListrTask } from 'listr'
6
+ import Listr from 'listr'
6
7
import type { PackageResponse } from '@pnpm/package-store'
7
8
import isOffline from 'is-offline-node'
8
9
import pc from 'picocolors'
@@ -11,7 +12,7 @@ import { merge } from 'lodash-es'
11
12
12
13
import { isMonorepo , isYaml } from '../utils'
13
14
import logger , { debug } from '../utils/logger'
14
- import { CommonOptions , AsyncReturnType , Package } from '../interface'
15
+ import type { AsyncReturnType , CommonOptions , Package } from '../interface'
15
16
import createStore from '../store'
16
17
import { usage } from '../utils/show-usage'
17
18
import { findPrefPackageByPk } from '../utils/find-pref-package'
@@ -61,7 +62,7 @@ const postgenerate = async ({
61
62
if ( fsExtra . existsSync ( path . join ( process . cwd ( ) , project , 'package.json' ) ) ) {
62
63
const pkg = fsExtra . readJSONSync ( path . join ( process . cwd ( ) , project , 'package.json' ) )
63
64
pkg . readme = undefined
64
- fsExtra . outputJSONSync ( path . join ( process . cwd ( ) , project , 'package.json' ) , pkg )
65
+ fsExtra . outputJSONSync ( path . join ( process . cwd ( ) , project , 'package.json' ) , pkg , { spaces : 2 } )
65
66
}
66
67
// clear up
67
68
common . forEach ( ( filename ) => {
@@ -122,7 +123,7 @@ const createTask = ({
122
123
title : 'Validate template' ,
123
124
task : ( ) => {
124
125
if ( ! project ) {
125
- throw new Error ( ` <project> is required` )
126
+ throw new Error ( ' <project> is required' )
126
127
}
127
128
} ,
128
129
} ,
@@ -156,6 +157,7 @@ const createTask = ({
156
157
if ( ! ctx . templateResponse ) {
157
158
throw new Error ( 'template not found' )
158
159
}
160
+
159
161
return generate ( { project, store, templateResponse : ctx . templateResponse } )
160
162
} ,
161
163
} ,
@@ -179,10 +181,10 @@ export const create = async (
179
181
template : string ,
180
182
project : string ,
181
183
options : CommonOptions &
182
- Pick < CreateOptions , 'latest' > & {
183
- preset : string [ ]
184
- mono ?: boolean
185
- } ,
184
+ Pick < CreateOptions , 'latest' > & {
185
+ preset : string [ ]
186
+ mono ?: boolean
187
+ } ,
186
188
) => {
187
189
const store = await createStore ( options )
188
190
const choices = await store . lockFile . readTemplates ( { presetNames : options . preset } )
@@ -216,7 +218,9 @@ export const create = async (
216
218
message : 'Please select template' ,
217
219
choices,
218
220
validate ( answer : { template : string ; project : string } ) {
219
- if ( ! answer ) return 'You must choose template.'
221
+ if ( ! answer ) {
222
+ return 'You must choose template.'
223
+ }
220
224
221
225
return true
222
226
} ,
@@ -226,7 +230,9 @@ export const create = async (
226
230
name : 'project' ,
227
231
message : 'Please enter project name' ,
228
232
validate ( answer : { template : string ; project : string } ) {
229
- if ( ! answer ) return 'You must enter project name.'
233
+ if ( ! answer ) {
234
+ return 'You must enter project name.'
235
+ }
230
236
231
237
return true
232
238
} ,
0 commit comments