@mateoserrano/simple-config 1.1.3 → 1.1.5
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 +1 -1
- package/src/constants.js +3 -7
- package/src/core/deps.js +2 -1
- package/src/core/urls.js +20 -0
- package/src/core/utils/index.js +0 -1
- package/src/functions.js +4 -3
- package/src/core/utils/urls.js +0 -7
package/package.json
CHANGED
package/src/constants.js
CHANGED
|
@@ -62,11 +62,7 @@ export const devDepFiles = {
|
|
|
62
62
|
},
|
|
63
63
|
],
|
|
64
64
|
}
|
|
65
|
-
export const addHuskyPrepare = 'npm pkg set scripts.prepare="husky"'
|
|
65
|
+
export const addHuskyPrepare = 'npm pkg set scripts.prepare="husky init"'
|
|
66
66
|
export const installCmd = (installNames) => `npm install -D ${installNames.join(' ')} --save-exact`
|
|
67
|
-
export const
|
|
68
|
-
|
|
69
|
-
'. "$(dirname -- "$0")/_/husky.sh"\n\n' +
|
|
70
|
-
'npx lint-staged"' +
|
|
71
|
-
'> .husky/pre-commit'
|
|
72
|
-
export const authorizeHuskyCommand = 'chmod +x .husky/pre-commit'
|
|
67
|
+
export const prepareHuskyCommand = 'npx prepare'
|
|
68
|
+
export const setupHuskyCommand = 'npx husky add .husky/pre-commit "npx lint-staged"'
|
package/src/core/deps.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { moveFromPath } from './utils/index.js'
|
|
2
|
+
import { getPackageRoot } from './urls.js'
|
|
2
3
|
import { copyFileToFolderOrSkip } from './files.js'
|
|
3
4
|
|
|
4
5
|
export const getTemplatesFolder = (templatesRelativePath) => {
|
package/src/core/urls.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
2
|
+
import { moveFromPath, verifyValidFile } from './utils/files.js'
|
|
3
|
+
|
|
4
|
+
export function getPackageRoot() {
|
|
5
|
+
let current = fileURLToPath(new URL('.', import.meta.url))
|
|
6
|
+
|
|
7
|
+
while (true) {
|
|
8
|
+
if (verifyValidFile(moveFromPath(current, 'package.json'))) {
|
|
9
|
+
return current
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const parent = moveFromPath(current, '..')
|
|
13
|
+
|
|
14
|
+
if (parent === current) {
|
|
15
|
+
throw new Error('package.json not found')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
current = parent
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/core/utils/index.js
CHANGED
package/src/functions.js
CHANGED
|
@@ -6,18 +6,19 @@ import {
|
|
|
6
6
|
verifyNodePackage,
|
|
7
7
|
} from './core/index.js'
|
|
8
8
|
import {
|
|
9
|
-
addHuskyPrepare,
|
|
9
|
+
addHuskyPrepare,
|
|
10
10
|
devDepFiles,
|
|
11
11
|
devDeps,
|
|
12
12
|
installCmd,
|
|
13
|
+
prepareHuskyCommand,
|
|
13
14
|
setupHuskyCommand,
|
|
14
15
|
} from './constants.js'
|
|
15
16
|
|
|
16
17
|
const runAddPrepareCommand = () => runCommandSilent(addHuskyPrepare)
|
|
17
18
|
const runInstallCommand = (installNames) => runCommandSilent(installCmd(installNames))
|
|
18
19
|
const runHuskyCommand = () => {
|
|
20
|
+
runCommandSilent(prepareHuskyCommand)
|
|
19
21
|
runCommandSilent(setupHuskyCommand)
|
|
20
|
-
runCommandSilent(authorizeHuskyCommand)
|
|
21
22
|
}
|
|
22
23
|
const getInstallationArguments = () => getInstallNames(devDeps)
|
|
23
24
|
|
|
@@ -38,6 +39,6 @@ export const configureHusky = () => {
|
|
|
38
39
|
}
|
|
39
40
|
export const copyConfigurationFiles = () => {
|
|
40
41
|
console.log('Copying configuration files...')
|
|
41
|
-
const templatesDirectory = getTemplatesFolder('
|
|
42
|
+
const templatesDirectory = getTemplatesFolder('templates')
|
|
42
43
|
copyFilesToTargetOrSkip(devDepFiles, templatesDirectory)
|
|
43
44
|
}
|
package/src/core/utils/urls.js
DELETED