@alessiofrittoli/package-configs 1.8.0-alpha.1 → 1.8.0-alpha.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alessiofrittoli/package-configs",
|
|
3
|
-
"version": "1.8.0-alpha.
|
|
3
|
+
"version": "1.8.0-alpha.2",
|
|
4
4
|
"description": "Utility library that offers base configurations for your packages.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
@@ -189,10 +189,6 @@
|
|
|
189
189
|
"test:coverage": "pnpm test:watch --coverage",
|
|
190
190
|
"test:coverage:ci": "pnpm test:ci --coverage",
|
|
191
191
|
"test:serve-coverage": "http-server ./coverage --gzip true -p 0 -o /index.html --silent",
|
|
192
|
-
"test:coverage:serve": "concurrently --prefix none --kill-others \"pnpm test:coverage\" \"pnpm test:serve-coverage\""
|
|
193
|
-
"//4a": "*********************************************************************",
|
|
194
|
-
"//4b": "******************************* OTHER *******************************",
|
|
195
|
-
"//4c": "*********************************************************************",
|
|
196
|
-
"postinstall": "node scripts/postinstall/index.ts"
|
|
192
|
+
"test:coverage:serve": "concurrently --prefix none --kill-others \"pnpm test:coverage\" \"pnpm test:serve-coverage\""
|
|
197
193
|
}
|
|
198
194
|
}
|
|
@@ -62,7 +62,11 @@ const isExternalPackage = ({ root, name }: Package): boolean => {
|
|
|
62
62
|
*/
|
|
63
63
|
const getProcessRoot = (): string => process.env.INIT_CWD || process.cwd()
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
interface PostInstallChainFnParams {
|
|
66
|
+
cwd: string
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type PostInstallChainFn = (params: PostInstallChainFnParams) => void | Promise<void>
|
|
66
70
|
|
|
67
71
|
const lastChainLink: LastChainLink<PostInstallChainFn> = () => () => {
|
|
68
72
|
console.log({
|
|
@@ -74,11 +78,13 @@ const lastChainLink: LastChainLink<PostInstallChainFn> = () => () => {
|
|
|
74
78
|
const postInstallChain: ChainFactory<PostInstallChainFn> = [installDependencies, lastChainLink]
|
|
75
79
|
|
|
76
80
|
const runChain = async (): Promise<void> => {
|
|
77
|
-
|
|
81
|
+
const cwd = getProcessRoot()
|
|
82
|
+
|
|
83
|
+
if (!isExternalPackage({ name: project.name, root: cwd })) {
|
|
78
84
|
return
|
|
79
85
|
}
|
|
80
86
|
|
|
81
|
-
await Chain.functions(postInstallChain)()
|
|
87
|
+
await Chain.functions(postInstallChain)({ cwd })
|
|
82
88
|
}
|
|
83
89
|
|
|
84
90
|
runChain().catch(console.error)
|
|
@@ -23,110 +23,114 @@ const isCIEnv = (): boolean =>
|
|
|
23
23
|
*/
|
|
24
24
|
export const arrayUnique = <T>(array: T[]): T[] => (array.length <= 0 ? array : [...new Set(array)])
|
|
25
25
|
|
|
26
|
-
export const installDependencies: ChainLink<PostInstallChainFn> =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
export const installDependencies: ChainLink<PostInstallChainFn> =
|
|
27
|
+
next =>
|
|
28
|
+
async (params): Promise<void> => {
|
|
29
|
+
if (isCIEnv()) {
|
|
30
|
+
return next(params)
|
|
31
|
+
}
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
const { installDeps } = await prompts([
|
|
33
|
-
{
|
|
34
|
-
type: 'confirm',
|
|
35
|
-
name: 'installDeps',
|
|
36
|
-
message: 'Would you like to install optional dependencies?',
|
|
37
|
-
initial: true,
|
|
38
|
-
},
|
|
39
|
-
])
|
|
33
|
+
const { cwd } = params
|
|
40
34
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
try {
|
|
36
|
+
const { installDeps } = await prompts([
|
|
37
|
+
{
|
|
38
|
+
type: 'confirm',
|
|
39
|
+
name: 'installDeps',
|
|
40
|
+
message: 'Would you like to install optional dependencies?',
|
|
41
|
+
initial: true,
|
|
42
|
+
},
|
|
43
|
+
])
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
name: '_dependenciesChoice',
|
|
49
|
-
message: "Please, select which tool you're going to use",
|
|
50
|
-
choices: [
|
|
51
|
-
{
|
|
52
|
-
title: 'Vite',
|
|
53
|
-
selected: true,
|
|
54
|
-
description: 'Will install Vite',
|
|
55
|
-
value: ['vite'],
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
title: 'Vitest',
|
|
59
|
-
selected: true,
|
|
60
|
-
description: 'Will install Vitest',
|
|
61
|
-
value: ['vitest', '@vitest/coverage-v8'],
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
title: 'Oxlint',
|
|
65
|
-
selected: true,
|
|
66
|
-
description: 'Will install Oxlint',
|
|
67
|
-
value: ['oxlint', 'oxlint-tsgolint'],
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
title: 'Prettier',
|
|
71
|
-
selected: true,
|
|
72
|
-
description: 'Will install Prettier',
|
|
73
|
-
value: ['prettier', 'prettier-plugin-sort-imports'],
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
title: 'tsdown',
|
|
77
|
-
selected: true,
|
|
78
|
-
description: 'Will install tsdown',
|
|
79
|
-
value: ['tsdown'],
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
title: 'ESLint',
|
|
83
|
-
selected: false,
|
|
84
|
-
description: 'Will install ESLint dev dependencies',
|
|
85
|
-
value: [
|
|
86
|
-
'eslint',
|
|
87
|
-
'@eslint/compat',
|
|
88
|
-
'@eslint/eslintrc',
|
|
89
|
-
'@eslint/js',
|
|
90
|
-
'globals',
|
|
91
|
-
'typescript-eslint',
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
title: 'Next.js',
|
|
96
|
-
description: 'Will install Next.js related ESLint dev dependencies',
|
|
97
|
-
selected: false,
|
|
98
|
-
value: [
|
|
99
|
-
'eslint',
|
|
100
|
-
'@eslint/compat',
|
|
101
|
-
'@eslint/eslintrc',
|
|
102
|
-
'@eslint/js',
|
|
103
|
-
'globals',
|
|
104
|
-
'typescript-eslint',
|
|
105
|
-
],
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
},
|
|
109
|
-
])
|
|
45
|
+
if (!installDeps) {
|
|
46
|
+
return next(params)
|
|
47
|
+
}
|
|
110
48
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
49
|
+
const { _dependenciesChoice } = await prompts([
|
|
50
|
+
{
|
|
51
|
+
type: 'multiselect',
|
|
52
|
+
name: '_dependenciesChoice',
|
|
53
|
+
message: "Please, select which tool you're going to use",
|
|
54
|
+
choices: [
|
|
55
|
+
{
|
|
56
|
+
title: 'Vite',
|
|
57
|
+
selected: true,
|
|
58
|
+
description: 'Will install Vite',
|
|
59
|
+
value: ['vite'],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
title: 'Vitest',
|
|
63
|
+
selected: true,
|
|
64
|
+
description: 'Will install Vitest',
|
|
65
|
+
value: ['vitest', '@vitest/coverage-v8'],
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
title: 'Oxlint',
|
|
69
|
+
selected: true,
|
|
70
|
+
description: 'Will install Oxlint',
|
|
71
|
+
value: ['oxlint', 'oxlint-tsgolint'],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
title: 'Prettier',
|
|
75
|
+
selected: true,
|
|
76
|
+
description: 'Will install Prettier',
|
|
77
|
+
value: ['prettier', 'prettier-plugin-sort-imports'],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
title: 'tsdown',
|
|
81
|
+
selected: true,
|
|
82
|
+
description: 'Will install tsdown',
|
|
83
|
+
value: ['tsdown'],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
title: 'ESLint',
|
|
87
|
+
selected: false,
|
|
88
|
+
description: 'Will install ESLint dev dependencies',
|
|
89
|
+
value: [
|
|
90
|
+
'eslint',
|
|
91
|
+
'@eslint/compat',
|
|
92
|
+
'@eslint/eslintrc',
|
|
93
|
+
'@eslint/js',
|
|
94
|
+
'globals',
|
|
95
|
+
'typescript-eslint',
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
title: 'Next.js',
|
|
100
|
+
description: 'Will install Next.js related ESLint dev dependencies',
|
|
101
|
+
selected: false,
|
|
102
|
+
value: [
|
|
103
|
+
'eslint',
|
|
104
|
+
'@eslint/compat',
|
|
105
|
+
'@eslint/eslintrc',
|
|
106
|
+
'@eslint/js',
|
|
107
|
+
'globals',
|
|
108
|
+
'typescript-eslint',
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
])
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
if (!_dependenciesChoice) {
|
|
116
|
+
return next(params)
|
|
117
|
+
}
|
|
116
118
|
|
|
117
|
-
|
|
119
|
+
const dependenciesChoice = arrayUnique((_dependenciesChoice as string[][]).flatMap(c => c))
|
|
118
120
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
let engine: 'npm' | 'pnpm' = 'npm'
|
|
122
|
+
|
|
123
|
+
try {
|
|
124
|
+
execSync('pnpm -v', { cwd, stdio: 'ignore' })
|
|
125
|
+
engine = 'pnpm'
|
|
126
|
+
} catch {
|
|
127
|
+
engine = 'npm'
|
|
128
|
+
}
|
|
125
129
|
|
|
126
|
-
|
|
130
|
+
const installCommand = engine === 'npm' ? 'npm install --save-dev' : 'pnpm add --save-dev'
|
|
127
131
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
132
|
+
execSync(`${installCommand} ${dependenciesChoice.join(' ')}`, { cwd, stdio: 'inherit' })
|
|
133
|
+
} catch {
|
|
134
|
+
return next(params)
|
|
135
|
+
}
|
|
131
136
|
}
|
|
132
|
-
}
|