@koober/mrm-preset
Advanced tools
Comparing version 1.3.3 to 1.3.4
@@ -32,2 +32,3 @@ const { packageJson } = require('mrm-core'); | ||
}, | ||
roots: hasWorkspaces ? ['<rootDir>/packages'] : undefined, | ||
transform: { | ||
@@ -34,0 +35,0 @@ '^.+\\.tsx?$': 'ts-jest', |
@@ -6,2 +6,3 @@ const { json, file, template } = require('mrm-core'); | ||
const { eslintIgnore } = require('../eslint'); | ||
const { useWorkspaces } = require('../workspace'); | ||
@@ -28,30 +29,46 @@ /** | ||
const packages = ['typescript', '@types/node', tsConfigPreset]; | ||
const hasWorkspaces = useWorkspaces(); | ||
const tsConfigSettingsName = 'tsconfig.settings.json'; | ||
const tsConfigSettings = json(tsConfigSettingsName); | ||
tsConfigSettings | ||
.merge({ | ||
compilerOptions: {}, | ||
extends: tsConfigPreset, | ||
}) | ||
.save(); | ||
const tsConfig = json('tsconfig.json'); | ||
tsConfig | ||
.merge({ | ||
compilerOptions: { | ||
outDir: './lib', | ||
rootDir: './src', | ||
}, | ||
extends: './' + tsConfigSettingsName, | ||
include: ['./src'], | ||
}) | ||
.save(); | ||
//Create default index | ||
const templateDir = join(__dirname, 'templates'); | ||
if (!file('src/index.ts').exists()) { | ||
template('src/index.ts', join(templateDir, 'index.ts')).apply().save(); | ||
if (hasWorkspaces) { | ||
tsConfig | ||
.unset('compilerOptions.rootDir') | ||
.unset('compilerOptions.outDir') | ||
.unset('include') | ||
.merge({ | ||
extends: './' + tsConfigSettingsName, | ||
}) | ||
.save(); | ||
file('src/index.ts').delete(); | ||
file('src/index.spec.ts').delete(); | ||
} else { | ||
tsConfigSettings | ||
.merge({ | ||
compilerOptions: {}, | ||
extends: tsConfigPreset, | ||
}) | ||
.save(); | ||
tsConfig | ||
.merge({ | ||
compilerOptions: { | ||
outDir: './lib', | ||
rootDir: './src', | ||
}, | ||
extends: './' + tsConfigSettingsName, | ||
include: ['./src'], | ||
}) | ||
.save(); | ||
//Create default index | ||
const templateDir = join(__dirname, 'templates'); | ||
if (!file('src/index.ts').exists()) { | ||
template('src/index.ts', join(templateDir, 'index.ts')).apply().save(); | ||
} | ||
if (!file('src/index.spec.ts').exists()) { | ||
template('src/index.spec.ts', join(templateDir, 'index.spec.ts')).apply().save(); | ||
} | ||
} | ||
if (!file('src/index.spec.ts').exists()) { | ||
template('src/index.spec.ts', join(templateDir, 'index.spec.ts')).apply().save(); | ||
} | ||
@@ -58,0 +75,0 @@ // Dependencies |
{ | ||
"name": "@koober/mrm-preset", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "Mrm configuration presets", | ||
@@ -48,3 +48,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "8641064f35e6f68f8cfa46236c48d593927cb45b" | ||
"gitHead": "8f3f2247a70e0c72d73616766282b4625a5245c0" | ||
} |
const { packageJson, json, makeDirs } = require('mrm-core'); | ||
const { install } = require('../pm'); | ||
const { vscodeTask } = require('../vscode'); | ||
@@ -80,2 +81,20 @@ function task() { | ||
install(packageInstall, { dev: true }); | ||
//VSCode | ||
vscodeTask({ | ||
group: { | ||
isDefault: true, | ||
kind: 'build', | ||
}, | ||
script: 'build', | ||
type: 'npm', | ||
}); | ||
vscodeTask({ | ||
group: { | ||
isDefault: true, | ||
kind: 'test', | ||
}, | ||
script: 'test', | ||
type: 'npm', | ||
}); | ||
} | ||
@@ -82,0 +101,0 @@ |
@@ -14,1 +14,32 @@ const { json } = require('mrm-core'); | ||
exports.vscodeRecommendedExtension = vscodeRecommendedExtension; | ||
/** | ||
* @param {{ | ||
* type: string, | ||
* script: string; | ||
* group: { | ||
* kind: string, | ||
* isDefault: boolean | ||
* } | ||
* }} newTask | ||
*/ | ||
function vscodeTask(newTask) { | ||
const vscodeTaskFile = json('.vscode/tasks.json', { | ||
tasks: [], | ||
version: '2.0.0', | ||
}); | ||
/** | ||
* @type {Array<any>} | ||
*/ | ||
const tasks = vscodeTaskFile.get('tasks', []); | ||
if (tasks.find((task) => task.script === newTask.script)) { | ||
vscodeTaskFile.set( | ||
'tasks', | ||
tasks.map((task) => (task.script === newTask.script ? newTask : task)) | ||
); | ||
} else { | ||
vscodeTaskFile.set('tasks', [newTask].concat(tasks)); | ||
} | ||
vscodeTaskFile.save(); | ||
} | ||
exports.vscodeTask = vscodeTask; |
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
45961
38
1504