@koober/mrm-preset
Advanced tools
Comparing version 1.3.1 to 1.3.2
/* eslint-disable sort-keys-fix/sort-keys-fix */ | ||
const { packageJson } = require('mrm-core'); | ||
const { packageJson, file } = require('mrm-core'); | ||
const { install } = require('../pm'); | ||
@@ -30,2 +30,3 @@ const path = require('path'); | ||
const scripts = createNPMScript(); | ||
const packageFile = packageJson({ | ||
@@ -38,16 +39,36 @@ name: path.basename(process.cwd()), | ||
}); | ||
/** | ||
* @param {string} configName | ||
* @param {() => any} getDefault | ||
*/ | ||
const setConfigDefault = (configName, getDefault) => { | ||
const path = 'config.' + configName; | ||
const value = packageFile.get(path); | ||
if (value == null) { | ||
packageFile.set(path, getDefault()); | ||
} | ||
}; | ||
packageFile.merge({ | ||
scripts: scripts, | ||
config: Object.assign( | ||
{ | ||
packageManager: packageManager, | ||
packageArchetype: packageArchetype, | ||
mrmPreset: mrmPreset, | ||
mrmTask: mrmTask, | ||
}, | ||
packageFile.get('config', {}) | ||
), | ||
scripts, | ||
}); | ||
setConfigDefault('packageManager', () => { | ||
if (file('yarn.lock').exists()) { | ||
return 'yarn'; | ||
} | ||
if (file('package-lock.json').exists()) { | ||
return 'npm'; | ||
} | ||
return packageManager; | ||
}); | ||
setConfigDefault('packageArchetype', () => { | ||
if (file('lerna.json').exists() || Boolean(packageFile.get('workspaces'))) { | ||
return 'workspace'; | ||
} | ||
return packageArchetype; | ||
}); | ||
setConfigDefault('mrmPreset', () => mrmPreset); | ||
setConfigDefault('mrmTask', () => mrmTask); | ||
packageFile.save(); | ||
@@ -54,0 +75,0 @@ install(['mrm', mrmPreset], { dev: true, yarn: packageManager === 'yarn' }); |
{ | ||
"name": "@koober/mrm-preset", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "Mrm configuration presets", | ||
@@ -48,3 +48,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "e8a700e1fb5a3f901d8add39c63394b1b79dbe28" | ||
"gitHead": "b0cf51f18d0761e43267e654592ba178e2aaecb4" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44247
1435