@alessiofrittoli/package-configs 1.8.0-alpha.4 → 1.8.0-alpha.6

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.4",
3
+ "version": "1.8.0-alpha.6",
4
4
  "description": "Utility library that offers base configurations for your packages.",
5
5
  "type": "module",
6
6
  "author": {
@@ -165,6 +165,7 @@
165
165
  "vitest": "^5.0.5"
166
166
  },
167
167
  "dependencies": {
168
+ "@alessiofrittoli/chain-functions": "^2.7.0",
168
169
  "prompts": "^2.4.2"
169
170
  },
170
171
  "scripts": {
@@ -188,6 +189,10 @@
188
189
  "test:coverage": "pnpm test:watch --coverage",
189
190
  "test:coverage:ci": "pnpm test:ci --coverage",
190
191
  "test:serve-coverage": "http-server ./coverage --gzip true -p 0 -o /index.html --silent",
191
- "test:coverage:serve": "concurrently --prefix none --kill-others \"pnpm test:coverage\" \"pnpm test:serve-coverage\""
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.cjs"
192
197
  }
193
198
  }
@@ -1,6 +1,30 @@
1
1
  const { execSync } = require('child_process')
2
2
  const prompts = require('prompts')
3
3
 
4
+ // // example writing user input data to stdout
5
+
6
+ // // const { openSync } = require('fs')
7
+ // // const { ReadStream, WriteStream } = require('tty')
8
+ // // const inputPath = process.platform === 'win32' ? 'CONIN$' : '/dev/tty'
9
+ // // const outputPath = process.platform === 'win32' ? 'CONOUT$' : '/dev/tty'
10
+
11
+ // // const stdin = new ReadStream(openSync(inputPath, 'r'))
12
+ // // const stdout = new WriteStream(openSync(outputPath, 'w'))
13
+ // const stdin = process.stdin
14
+ // const stdout = process.stdout
15
+
16
+ // stdin.setRawMode(true)
17
+ // stdin.resume()
18
+
19
+ // stdin.on( 'data', (data) => {
20
+ // stdout.write( data.toString() )
21
+
22
+ // if (data.includes('\x03')) {
23
+ // stdin.setRawMode(false)
24
+ // process.exit(0)
25
+ // }
26
+ // } )
27
+
4
28
  /**
5
29
  * Check whether script is running in a CI environment.
6
30
  *
@@ -31,96 +55,114 @@ const getProcessRoot = () => process.env.INIT_CWD || process.cwd()
31
55
 
32
56
  const installDependencies = async () => {
33
57
  if (isCIEnv()) {
34
- return
58
+ return process.exit(0)
35
59
  }
36
60
 
37
61
  const cwd = getProcessRoot()
38
62
 
39
63
  try {
40
- const { installDeps } = await prompts([
64
+ const { installDeps } = await prompts(
65
+ [
66
+ {
67
+ type: 'confirm',
68
+ name: 'installDeps',
69
+ message: 'Would you like to install optional dependencies?',
70
+ initial: true,
71
+ },
72
+ ],
41
73
  {
42
- type: 'confirm',
43
- name: 'installDeps',
44
- message: 'Would you like to install optional dependencies?',
45
- initial: true,
74
+ onCancel() {
75
+ process.exit(0)
76
+ },
46
77
  },
47
- ])
78
+ )
48
79
 
49
80
  if (!installDeps) {
50
- return
81
+ return process.exit(0)
51
82
  }
52
83
 
53
- const { _dependenciesChoice } = await prompts([
84
+ const { _dependenciesChoice } = await prompts(
85
+ [
86
+ {
87
+ type: 'multiselect',
88
+ name: '_dependenciesChoice',
89
+ message: "Please, select which tool you're going to use",
90
+ choices: [
91
+ {
92
+ title: 'Vite',
93
+ selected: true,
94
+ description: 'Will install Vite',
95
+ value: ['vite'],
96
+ },
97
+ {
98
+ title: 'Vitest',
99
+ selected: true,
100
+ description: 'Will install Vitest',
101
+ value: ['vitest', '@vitest/coverage-v8'],
102
+ },
103
+ {
104
+ title: 'Oxlint',
105
+ selected: true,
106
+ description: 'Will install Oxlint',
107
+ value: ['oxlint', 'oxlint-tsgolint'],
108
+ },
109
+ {
110
+ title: 'Prettier',
111
+ selected: true,
112
+ description: 'Will install Prettier',
113
+ value: ['prettier', 'prettier-plugin-sort-imports'],
114
+ },
115
+ {
116
+ title: 'tsdown',
117
+ selected: true,
118
+ description: 'Will install tsdown',
119
+ value: ['tsdown'],
120
+ },
121
+ {
122
+ title: 'ESLint',
123
+ selected: false,
124
+ description: 'Will install ESLint dev dependencies',
125
+ value: [
126
+ 'eslint',
127
+ '@eslint/compat',
128
+ '@eslint/eslintrc',
129
+ '@eslint/js',
130
+ 'globals',
131
+ 'typescript-eslint',
132
+ ],
133
+ },
134
+ {
135
+ title: 'Next.js',
136
+ description: 'Will install Next.js related ESLint dev dependencies',
137
+ selected: false,
138
+ value: [
139
+ 'eslint',
140
+ '@eslint/compat',
141
+ '@eslint/eslintrc',
142
+ '@eslint/js',
143
+ 'globals',
144
+ 'typescript-eslint',
145
+ ],
146
+ },
147
+ ],
148
+ },
149
+ ],
54
150
  {
55
- type: 'multiselect',
56
- name: '_dependenciesChoice',
57
- message: "Please, select which tool you're going to use",
58
- choices: [
59
- {
60
- title: 'Vite',
61
- selected: true,
62
- description: 'Will install Vite',
63
- value: ['vite'],
64
- },
65
- {
66
- title: 'Vitest',
67
- selected: true,
68
- description: 'Will install Vitest',
69
- value: ['vitest', '@vitest/coverage-v8'],
70
- },
71
- {
72
- title: 'Oxlint',
73
- selected: true,
74
- description: 'Will install Oxlint',
75
- value: ['oxlint', 'oxlint-tsgolint'],
76
- },
77
- {
78
- title: 'Prettier',
79
- selected: true,
80
- description: 'Will install Prettier',
81
- value: ['prettier', 'prettier-plugin-sort-imports'],
82
- },
83
- {
84
- title: 'tsdown',
85
- selected: true,
86
- description: 'Will install tsdown',
87
- value: ['tsdown'],
88
- },
89
- {
90
- title: 'ESLint',
91
- selected: false,
92
- description: 'Will install ESLint dev dependencies',
93
- value: [
94
- 'eslint',
95
- '@eslint/compat',
96
- '@eslint/eslintrc',
97
- '@eslint/js',
98
- 'globals',
99
- 'typescript-eslint',
100
- ],
101
- },
102
- {
103
- title: 'Next.js',
104
- description: 'Will install Next.js related ESLint dev dependencies',
105
- selected: false,
106
- value: [
107
- 'eslint',
108
- '@eslint/compat',
109
- '@eslint/eslintrc',
110
- '@eslint/js',
111
- 'globals',
112
- 'typescript-eslint',
113
- ],
114
- },
115
- ],
151
+ onCancel() {
152
+ process.exit(0)
153
+ },
116
154
  },
117
- ])
155
+ )
118
156
 
119
157
  if (!_dependenciesChoice) {
120
- return
158
+ return process.exit(0)
121
159
  }
122
160
 
123
- const dependenciesChoice = arrayUnique(_dependenciesChoice.flatMap(c => c))
161
+ const dependenciesChoice = arrayUnique(_dependenciesChoice.flatMap(choice => choice))
162
+
163
+ if (dependenciesChoice.length <= 0) {
164
+ return process.exit(0)
165
+ }
124
166
 
125
167
  let engine = 'npm'
126
168
 
@@ -134,8 +176,10 @@ const installDependencies = async () => {
134
176
  const installCommand = engine === 'npm' ? 'npm install --save-dev' : 'pnpm add --save-dev'
135
177
 
136
178
  execSync(`${installCommand} ${dependenciesChoice.join(' ')}`, { cwd, stdio: 'inherit' })
179
+
180
+ process.exit(0)
137
181
  } catch {
138
- return
182
+ return process.exit(0)
139
183
  }
140
184
  }
141
185