lenix 1.6.2 → 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/format/index.ts +64 -0
- package/format/preset.json +10 -0
- package/package.json +2 -1
package/format/index.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { intro, outro, confirm, log, spinner } from '@clack/prompts'
|
|
2
|
+
import { execSync } from 'child_process'
|
|
3
|
+
import fs from 'fs'
|
|
4
|
+
|
|
5
|
+
intro('Prettier Setup')
|
|
6
|
+
|
|
7
|
+
const install = await confirm({
|
|
8
|
+
message:
|
|
9
|
+
'Install prettier + eslint-config-prettier(to prevent conflicts)? (see https://prettier.io/docs/install)',
|
|
10
|
+
})
|
|
11
|
+
if (install === true) {
|
|
12
|
+
const span = spinner()
|
|
13
|
+
span.start('Installing...')
|
|
14
|
+
execSync('pnpm add --save-dev --save-exact prettier eslint-config-prettier', {
|
|
15
|
+
stdio: 'pipe',
|
|
16
|
+
})
|
|
17
|
+
span.stop('Installed')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const prompt = await confirm({ message: 'Create .prettierrc with a preset?' })
|
|
21
|
+
if (prompt === true) {
|
|
22
|
+
const preset = await import('./preset.json').then(file =>
|
|
23
|
+
JSON.stringify(file.default, null, 2),
|
|
24
|
+
)
|
|
25
|
+
fs.writeFileSync('.prettierrc', `${preset}\n`)
|
|
26
|
+
log.success('Created .prettierrc with a preset')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const ignore = await confirm({
|
|
30
|
+
message: 'Create .prettierignore? (see https://prettier.io/docs/ignore)',
|
|
31
|
+
})
|
|
32
|
+
if (ignore === true) {
|
|
33
|
+
fs.writeFileSync('.prettierignore', '# Ignore artifacts:\nbuild\ncoverage\n')
|
|
34
|
+
log.success('Created .prettierignore')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
log.warn(
|
|
38
|
+
'Manual (optional) — copy paste the import below and add "prettier" to the `end` of your ESLint extends',
|
|
39
|
+
)
|
|
40
|
+
log.info("---> import prettier from 'eslint-config-prettier' <---")
|
|
41
|
+
await confirm({ message: 'Done?' })
|
|
42
|
+
|
|
43
|
+
log.warn(
|
|
44
|
+
'Manual — add to .vscode/settings.json:\n "editor.formatOnSave": true,\n "editor.defaultFormatter": "esbenp.prettier-vscode"',
|
|
45
|
+
)
|
|
46
|
+
await confirm({ message: 'Done?' })
|
|
47
|
+
|
|
48
|
+
log.warn(
|
|
49
|
+
'Manual (optional) — add to .vscode/extensions.json (inside "recommendations" array):\n "esbenp.prettier-vscode"',
|
|
50
|
+
)
|
|
51
|
+
log.info('like: "recommendations": ["esbenp.prettier-vscode"]')
|
|
52
|
+
await confirm({ message: 'Done?' })
|
|
53
|
+
|
|
54
|
+
const format = await confirm({
|
|
55
|
+
message: 'Run prettier on existing files now to test it out?',
|
|
56
|
+
})
|
|
57
|
+
if (format === true) {
|
|
58
|
+
const span = spinner()
|
|
59
|
+
span.start('Formatting...')
|
|
60
|
+
execSync('pnpm exec prettier . --write', { stdio: 'pipe' })
|
|
61
|
+
span.stop('Formatted')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
outro('Prettier setup complete!')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lenix",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"description": "The All-in-one Package",
|
|
5
5
|
"author": "Lenix",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
34
34
|
"modules/src",
|
|
35
|
+
"format",
|
|
35
36
|
"oop",
|
|
36
37
|
"lint/dist"
|
|
37
38
|
],
|