Skip to content

Commit 3f78be2

Browse files
committed
style: format files
1 parent 4114cc4 commit 3f78be2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+203
-282
lines changed

.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pnpm-lock.yaml
2+
3+
# prettier doesn't respect newlines between chained methods
4+
# https://github.com/prettier/prettier/issues/7884
5+
**/*.spec.js
6+
**/*.spec.ts

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": false,
3+
"tabWidth": 2,
4+
"singleQuote": true,
5+
"printWidth": 80,
6+
"trailingComma": "none"
7+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# create-vue
2+
23
An easy way to start a Vue project

index.js

Lines changed: 77 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function canSafelyOverwrite(dir) {
3434
return !fs.existsSync(dir) || fs.readdirSync(dir).length === 0
3535
}
3636

37-
function emptyDir (dir) {
37+
function emptyDir(dir) {
3838
postOrderDirectoryTraverse(
3939
dir,
4040
(dir) => fs.rmdirSync(dir),
@@ -45,7 +45,7 @@ function emptyDir (dir) {
4545
async function init() {
4646
const cwd = process.cwd()
4747
const argv = minimist(process.argv.slice(2))
48-
48+
4949
let targetDir = argv._[0]
5050
const defaultProjectName = !targetDir ? 'vue-project' : targetDir
5151

@@ -62,71 +62,77 @@ async function init() {
6262
// - Project language: JavaScript / TypeScript
6363
// - Install Vue Router & Vuex for SPA development?
6464
// - Add Cypress for testing?
65-
result = await prompts([
66-
{
67-
name: 'projectName',
68-
type: targetDir ? null : 'text',
69-
message: 'Project name:',
70-
initial: defaultProjectName,
71-
onState: (state) =>
72-
(targetDir = String(state.value).trim() || defaultProjectName)
73-
},
74-
{
75-
name: 'shouldOverwrite',
76-
type: () => canSafelyOverwrite(targetDir) ? null : 'confirm',
77-
message: () => {
78-
const dirForPrompt = targetDir === '.'
79-
? 'Current directory'
80-
: `Target directory "${targetDir}"`
81-
82-
return `${dirForPrompt} is not empty. Remove existing files and continue?`
83-
}
84-
},
85-
{
86-
name: 'overwriteChecker',
87-
type: (prev, values = {}) => {
88-
if (values.shouldOverwrite === false) {
89-
throw new Error(red('✖') + ' Operation cancelled')
65+
result = await prompts(
66+
[
67+
{
68+
name: 'projectName',
69+
type: targetDir ? null : 'text',
70+
message: 'Project name:',
71+
initial: defaultProjectName,
72+
onState: (state) =>
73+
(targetDir = String(state.value).trim() || defaultProjectName)
74+
},
75+
{
76+
name: 'shouldOverwrite',
77+
type: () => (canSafelyOverwrite(targetDir) ? null : 'confirm'),
78+
message: () => {
79+
const dirForPrompt =
80+
targetDir === '.'
81+
? 'Current directory'
82+
: `Target directory "${targetDir}"`
83+
84+
return `${dirForPrompt} is not empty. Remove existing files and continue?`
9085
}
91-
return null
86+
},
87+
{
88+
name: 'overwriteChecker',
89+
type: (prev, values = {}) => {
90+
if (values.shouldOverwrite === false) {
91+
throw new Error(red('✖') + ' Operation cancelled')
92+
}
93+
return null
94+
}
95+
},
96+
{
97+
name: 'packageName',
98+
type: () => (isValidPackageName(targetDir) ? null : 'text'),
99+
message: 'Package name:',
100+
initial: () => toValidPackageName(targetDir),
101+
validate: (dir) =>
102+
isValidPackageName(dir) || 'Invalid package.json name'
103+
},
104+
{
105+
name: 'shouldUseTypeScript',
106+
type: () => (isValidTemplate ? null : 'toggle'),
107+
message: 'Add TypeScript?',
108+
initial: false,
109+
active: 'Yes',
110+
inactive: 'No'
111+
},
112+
{
113+
name: 'isSPA',
114+
type: () => (isValidTemplate ? null : 'toggle'),
115+
message:
116+
'Add Vue Router & Vuex for Single Page Application development?',
117+
initial: false,
118+
active: 'Yes',
119+
inactive: 'No'
120+
},
121+
{
122+
name: 'shouldAddCypress',
123+
type: () => (isValidTemplate ? null : 'toggle'),
124+
message: 'Add Cypress for testing?',
125+
initial: false,
126+
active: 'Yes',
127+
inactive: 'No'
92128
}
93-
},
129+
],
94130
{
95-
name: 'packageName',
96-
type: () => (isValidPackageName(targetDir) ? null : 'text'),
97-
message: 'Package name:',
98-
initial: () => toValidPackageName(targetDir),
99-
validate: (dir) => isValidPackageName(dir) || 'Invalid package.json name'
100-
},
101-
{
102-
name: 'shouldUseTypeScript',
103-
type: () => isValidTemplate ? null : 'toggle',
104-
message: 'Add TypeScript?',
105-
initial: false,
106-
active: 'Yes',
107-
inactive: 'No'
108-
},
109-
{
110-
name: 'isSPA',
111-
type: () => isValidTemplate ? null : 'toggle',
112-
message: 'Add Vue Router & Vuex for Single Page Application development?',
113-
initial: false,
114-
active: 'Yes',
115-
inactive: 'No'
116-
},
117-
{
118-
name: 'shouldAddCypress',
119-
type: () => isValidTemplate ? null : 'toggle',
120-
message: 'Add Cypress for testing?',
121-
initial: false,
122-
active: 'Yes',
123-
inactive: 'No'
124-
}
125-
], {
126-
onCancel: () => {
127-
throw new Error(red('✖') + ' Operation cancelled')
131+
onCancel: () => {
132+
throw new Error(red('✖') + ' Operation cancelled')
133+
}
128134
}
129-
})
135+
)
130136
} catch (cancelled) {
131137
console.log(cancelled.message)
132138
process.exit(1)
@@ -180,13 +186,17 @@ async function init() {
180186
if (filepath.endsWith('.js')) {
181187
fs.renameSync(filepath, filepath.replace(/\.js$/, '.ts'))
182188
} else if (path.basename(filepath) === 'jsconfig.json') {
183-
fs.renameSync(filepath, filepath.replace(/jsconfig\.json$/, 'tsconfig.json'))
189+
fs.renameSync(
190+
filepath,
191+
filepath.replace(/jsconfig\.json$/, 'tsconfig.json')
192+
)
184193
}
185194
}
186195
)
187196
}
188197

189198
// Render code template.
199+
// prettier-ignore
190200
const codeTemplate =
191201
(shouldUseTypeScript ? 'typescript-' : '') +
192202
(isSPA ? 'spa' : 'default')
@@ -219,9 +229,9 @@ async function init() {
219229
const packageManager = /pnpm/.test(process.env.npm_execpath)
220230
? 'pnpm'
221231
: /yarn/.test(process.env.npm_execpath)
222-
?'yarn'
223-
: 'npm'
224-
232+
? 'yarn'
233+
: 'npm'
234+
225235
const commandsMap = {
226236
install: {
227237
pnpm: 'pnpm install',

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"node": "^12.13.0 || ^14.0.0 || >= 16.0.0"
1717
},
1818
"scripts": {
19+
"format": "prettier --write .",
1920
"test": "echo \"Error: no test specified\" && exit 1",
2021
"prepublishOnly": "node snapshot.js"
2122
},

playground/default-ts-with-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@
2727
"typescript": "~4.3.5",
2828
"vue-tsc": "^0.2.2"
2929
}
30-
}
30+
}

playground/default-ts-with-tests/src/components/HelloWorld.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import { ref } from 'vue'
3030
3131
defineProps<{
32-
msg: String,
32+
msg: String
3333
}>()
3434
3535
const count = ref(0)

playground/default-ts-with-tests/tsconfig.json

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,11 @@
1111
"resolveJsonModule": true,
1212
"esModuleInterop": true,
1313
"paths": {
14-
"@/*": [
15-
"src/*"
16-
]
14+
"@/*": ["src/*"]
1715
},
1816
"lib": ["esnext", "dom", "dom.iterable", "scripthost"],
1917
"skipLibCheck": true
2018
},
21-
"include": [
22-
"vite.config.*",
23-
24-
"src/**/*",
25-
"src/**/*.vue"
26-
],
27-
"exclude": [
28-
"src/**/__tests__/**"
29-
]
19+
"include": ["vite.config.*", "src/**/*", "src/**/*.vue"],
20+
"exclude": ["src/**/__tests__/**"]
3021
}

playground/default-ts-with-tests/vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default defineConfig({
77
plugins: [vue(), vueJsx()],
88
resolve: {
99
alias: {
10-
'@/': new URL('./src/', import.meta.url).pathname,
11-
},
10+
'@/': new URL('./src/', import.meta.url).pathname
11+
}
1212
}
1313
})

playground/default-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
"typescript": "~4.3.5",
2020
"vue-tsc": "^0.2.2"
2121
}
22-
}
22+
}

0 commit comments

Comments
 (0)