@alessiofrittoli/package-configs 1.8.0-alpha.8 → 1.8.0
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
|
@@ -56,7 +56,7 @@ const lastChainLink = () => () => {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
* @type import('@alessiofrittoli/chain-functions/types').ChainFactory<( { cwd
|
|
59
|
+
* @type import('@alessiofrittoli/chain-functions/types').ChainFactory<( params: { cwd: string; scriptsDir: string } ) => void | Promise<void>>
|
|
60
60
|
*/
|
|
61
61
|
const postInstallChain = [installDependencies, lastChainLink]
|
|
62
62
|
|
|
@@ -67,7 +67,7 @@ const runChain = async () => {
|
|
|
67
67
|
return process.exit(0)
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
await Chain.functions(postInstallChain)({ cwd })
|
|
70
|
+
await Chain.functions(postInstallChain)({ cwd, scriptsDir: path.resolve(__dirname, '../') })
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
// oxlint-disable-next-line typescript/no-floating-promises
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
const { openSync, existsSync, readFileSync, writeFileSync } = require('fs')
|
|
1
2
|
const { ReadStream, WriteStream } = require('tty')
|
|
2
3
|
const { execSync } = require('child_process')
|
|
3
4
|
const prompts = require('prompts')
|
|
4
|
-
const
|
|
5
|
+
const path = require('path')
|
|
5
6
|
|
|
6
7
|
// // example writing user input data to stdout
|
|
7
8
|
|
|
@@ -48,16 +49,31 @@ const isCIEnv = () =>
|
|
|
48
49
|
const arrayUnique = array => (array.length <= 0 ? array : [...new Set(array)])
|
|
49
50
|
|
|
50
51
|
/**
|
|
51
|
-
* @type import('@alessiofrittoli/chain-functions/types').ChainLink<( { cwd
|
|
52
|
+
* @type import('@alessiofrittoli/chain-functions/types').ChainLink<( params: { cwd: string; scriptsDir: string } ) => void | Promise<void>>
|
|
52
53
|
*/
|
|
53
54
|
const installDependencies = next => async params => {
|
|
54
55
|
if (isCIEnv()) {
|
|
55
56
|
return next(params)
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
const { cwd } = params
|
|
59
|
+
const { cwd, scriptsDir } = params
|
|
59
60
|
|
|
60
61
|
try {
|
|
62
|
+
const stateFilePath = path.resolve(scriptsDir, 'post-install-data.json')
|
|
63
|
+
|
|
64
|
+
if (existsSync(stateFilePath)) {
|
|
65
|
+
try {
|
|
66
|
+
const file = JSON.parse(
|
|
67
|
+
readFileSync(path.resolve(scriptsDir, 'post-install-data.json'), 'utf-8'),
|
|
68
|
+
)
|
|
69
|
+
if (file.installDependencies.done) {
|
|
70
|
+
return next(params)
|
|
71
|
+
}
|
|
72
|
+
} catch {
|
|
73
|
+
return next(params)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
61
77
|
const inputPath = process.platform === 'win32' ? 'CONIN$' : '/dev/tty'
|
|
62
78
|
const outputPath = process.platform === 'win32' ? 'CONOUT$' : '/dev/tty'
|
|
63
79
|
const stdin = !process.stdin.isTTY ? new ReadStream(openSync(inputPath, 'r')) : undefined
|
|
@@ -169,6 +185,8 @@ const installDependencies = next => async params => {
|
|
|
169
185
|
|
|
170
186
|
execSync(`${installCommand} ${dependenciesChoice.join(' ')}`, { cwd, stdio: 'ignore' })
|
|
171
187
|
|
|
188
|
+
writeFileSync(stateFilePath, JSON.stringify({ installDependencies: { done: true } }))
|
|
189
|
+
|
|
172
190
|
return next(params)
|
|
173
191
|
} catch {
|
|
174
192
|
return next(params)
|