@nebula.js/cli-create
Advanced tools
Comparing version 0.2.0 to 0.2.1
const create = require('./lib/create'); | ||
const mashup = { | ||
command: 'mashup <name>', | ||
desc: 'Create a mashup', | ||
builder(yargs) { | ||
yargs.positional('name', { | ||
type: 'string', | ||
description: 'name of the project', | ||
}); | ||
}, | ||
handler(argv) { | ||
create(argv); | ||
}, | ||
}; | ||
module.exports = { | ||
@@ -7,2 +21,4 @@ command: 'create <name>', | ||
builder(yargs) { | ||
yargs.command(mashup); | ||
yargs.positional('name', { | ||
@@ -9,0 +25,0 @@ type: 'string', |
@@ -49,3 +49,3 @@ const chalk = require('chalk'); | ||
function cpy(root, destination) { | ||
function copyFactory(root, destination) { | ||
return (source, target, data) => { | ||
@@ -65,2 +65,4 @@ if (data) { | ||
const isMashup = argv._.includes('mashup'); | ||
const projectFolder = name; | ||
@@ -95,3 +97,3 @@ const packageName = name.split('/').slice(-1)[0]; | ||
choices: ['none', 'minimal', 'barchart'], | ||
when: !argv.picasso, | ||
when: !isMashup && !argv.picasso, | ||
}, | ||
@@ -109,24 +111,26 @@ ]); | ||
// ==== common files ==== | ||
// copy raw files | ||
['editorconfig', 'eslintignore', 'gitignore', 'eslintrc.json'].forEach(filename => | ||
fs.copyFileSync( | ||
path.resolve(templatesRoot, 'common', `_${filename}`), // copying dotfiles may not always work, so they are prefixed with an underline | ||
path.resolve(destination, `.${filename}`) | ||
) | ||
); | ||
const copy = copyFactory(templatesRoot, destination); | ||
const copy = cpy(templatesRoot, destination); | ||
copy('common/README.md', 'README.md', { name: packageName }); | ||
// ==== template files ==== | ||
const folders = []; | ||
if (picasso !== 'none') { | ||
folders.push('picasso/common'); | ||
folders.push(`picasso/${picasso}`); | ||
const folders = ['common']; | ||
if (isMashup) { | ||
folders.push('mashup'); | ||
} else { | ||
folders.push('none'); | ||
folders.push('sn/common'); | ||
if (picasso !== 'none') { | ||
folders.push('sn/picasso/common'); | ||
folders.push(`sn/picasso/${picasso}`); | ||
} else { | ||
folders.push('sn/none'); | ||
} | ||
} | ||
const data = { | ||
name: packageName, | ||
description: '', | ||
user: options.author.name, | ||
email: options.author.email, | ||
nebulaVersion: pkg.version, | ||
}; | ||
const traverse = (sourceFolder, targetFolder = '') => { | ||
@@ -142,12 +146,7 @@ const files = fs.readdirSync(path.resolve(templatesRoot, sourceFolder)); | ||
traverse(p, next); | ||
} else if (file === '_package.json') { | ||
copy(`${sourceFolder}/_package.json`, 'package.json', { | ||
name: packageName, | ||
description: '', | ||
user: options.author.name, | ||
email: options.author.email, | ||
nebulaVersion: pkg.version, | ||
}); | ||
} else if (file[0] === '_') { | ||
const newFileName = file === '_package.json' ? 'package.json' : `.${file.substr(1)}`; | ||
copy(`${sourceFolder}/${file}`, `${targetFolder}/${newFileName}`.replace(/^\//, ''), data); | ||
} else { | ||
copy(`${sourceFolder}/${file}`, next); | ||
copy(`${sourceFolder}/${file}`, next, data); | ||
} | ||
@@ -154,0 +153,0 @@ }); |
{ | ||
"name": "@nebula.js/cli-create", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "", | ||
@@ -30,3 +30,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "f831ff585b2cf3adfa0eda2bf8629b2697527550" | ||
"gitHead": "5d7768efdb31e06bf21278713cda61ffe86435ee" | ||
} |
@@ -6,3 +6,3 @@ # @nebula.js/cli-create | ||
```sh | ||
npm install -g @nebula.js/cli@next | ||
npm install -g @nebula.js/cli | ||
``` | ||
@@ -9,0 +9,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
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
25633
32
735
3