demplate-addons
Advanced tools
Comparing version 0.0.7 to 0.0.8
{ | ||
"name": "demplate-addons", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "email": "efim@dezh.in", |
@@ -5,4 +5,33 @@ #!/usr/bin/env node | ||
const fsExtra = require('fs-extra'); | ||
const fs = require('fs'); | ||
const fs = require('node:fs'); | ||
const { exec } = require('node:child_process'); | ||
const dirPath = './node_modules/demplate-addons/addons/'; | ||
const ifYarn = () => fs.existsSync('./yarn.lock'); | ||
const mergeJson = (from, to) => { | ||
const rawDataAddon = fs.readFileSync(from); | ||
const rawDataPackage = fs.readFileSync(to); | ||
const { | ||
package: { | ||
dependencies = {}, | ||
devDependencies = {} | ||
} | ||
} = JSON.parse(rawDataAddon); | ||
const packageJson = JSON.parse(rawDataPackage); | ||
fs.writeFileSync(to, JSON.stringify({ | ||
...packageJson, | ||
dependencies: { | ||
...(packageJson.dependencies || {}), | ||
...dependencies | ||
}, | ||
devDependencies: { | ||
...(packageJson.devDependencies || {}), | ||
...devDependencies | ||
} | ||
}, null, 2)); | ||
} | ||
inquirer | ||
@@ -15,3 +44,3 @@ .prompt([ | ||
choices: [ | ||
...fs.readdirSync('./node_modules/demplate-addons/addons/', {withFileTypes: true}) | ||
...fs.readdirSync(dirPath, {withFileTypes: true}) | ||
.filter(dirent => dirent.isDirectory()) | ||
@@ -30,26 +59,12 @@ .map(dirent => dirent.name), | ||
default: | ||
fsExtra.copySync(`./node_modules/demplate-addons/addons/${addon}/template`, '.', { | ||
fsExtra.copySync(`${dirPath}${addon}/template`, '.', { | ||
overwrite: true | ||
}); | ||
const rawDataAddon = fs.readFileSync(`node_modules/demplate-addons/addons/${addon}/template.json`); | ||
const rawDataPackage = fs.readFileSync(`./package.json`); | ||
const { | ||
package: { | ||
dependencies = {}, | ||
devDependencies = {} | ||
} | ||
} = JSON.parse(rawDataAddon); | ||
const packageJson = JSON.parse(rawDataPackage); | ||
fs.writeFileSync('./package.json', JSON.stringify({ | ||
...packageJson, | ||
dependencies: { | ||
...(packageJson.dependencies || {}), | ||
...dependencies | ||
}, | ||
devDependencies: { | ||
...(packageJson.devDependencies || {}), | ||
...devDependencies | ||
} | ||
}, null, 2)); | ||
mergeJson(`${dirPath}${addon}/template.json`, `./package.json`); | ||
if (ifYarn()) { | ||
exec('yarn') | ||
} else { | ||
exec('npm install') | ||
} | ||
} | ||
}); |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
12034
430
1