bevry-base
Advanced tools
Comparing version 1.12.0 to 1.13.0
# History | ||
## v1.13.0 2018 February 15 | ||
- You can now scaffold new projects by running inside an empty directory | ||
- Closes [#1](https://github.com/bevry/based/issues/1) | ||
## v1.12.0 2018 February 15 | ||
@@ -10,2 +14,3 @@ - Remove Gratipay badge as it no longer exists | ||
- Now asks about the test entry location | ||
- Closes [#2](https://github.com/bevry/based/issues/2) | ||
@@ -12,0 +17,0 @@ ## v1.10.0 2018 February 7 |
{ | ||
"name": "bevry-base", | ||
"version": "1.12.0", | ||
"version": "1.13.0", | ||
"description": "Automatic application of the Bevry base files /bevry/base", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/bevry/based", |
@@ -57,5 +57,5 @@ <!-- TITLE/ --> | ||
Install the package globally, then run it via: | ||
Install the package globally. Then run on your project or in a new directory with: | ||
``` bash | ||
``` | ||
bevry-base | ||
@@ -62,0 +62,0 @@ ``` |
@@ -170,6 +170,6 @@ /* eslint no-sync:0, camelcase:0, no-console:0 */ | ||
const exists = await util.exists(file) | ||
if (opts.overwrite === false) { | ||
return Promise.resolve() | ||
} | ||
if (exists) { | ||
if (opts.overwrite === false) { | ||
return Promise.resolve() | ||
} | ||
const localData = await util.read(file).toString() | ||
@@ -185,3 +185,5 @@ const lines = localData.split('\n') | ||
catch (err) { | ||
throw new Error(`Download of ${opts.url} FAILED due to: ${stackOrMessage(err)}`) | ||
return Promise.reject( | ||
new Error(`Download of ${opts.url} FAILED due to: ${stackOrMessage(err)}`) | ||
) | ||
} | ||
@@ -206,3 +208,3 @@ } | ||
const stdout = await util.exec('git config --global user.name', { stdio: ['ignore', 'pipe', 'ignore'] }) | ||
state.gitUserName = (stdout && stdout.toString()) || null | ||
state.gitUserName = (stdout && stdout.toString().trim()) || null | ||
return state.gitUserName | ||
@@ -219,3 +221,3 @@ } | ||
const stdout = await util.exec('git config --global user.email', { stdio: ['ignore', 'pipe', 'ignore'] }) | ||
state.gitUserEmail = (stdout && stdout.toString()) || null | ||
state.gitUserEmail = (stdout && stdout.toString().trim()) || null | ||
return state.gitUserEmail | ||
@@ -317,3 +319,6 @@ } | ||
function hasMultipleEditions (packageData = getPackage()) { | ||
return (packageData.editions && packageData.editions.length > 1) || false | ||
if (packageData && packageData.editions) { | ||
return packageData.editions.length > 1 | ||
} | ||
return null | ||
} | ||
@@ -343,3 +348,3 @@ | ||
function isPackageDocPadPlugin (packageData = getPackage()) { | ||
return packageData.name.indexOf('docpad-plugin-') === 0 | ||
return packageData && packageData.name.indexOf('docpad-plugin-') === 0 | ||
} | ||
@@ -353,3 +358,6 @@ | ||
else { | ||
return (packageData.main && packageData.main.replace(/^.+\//, '').replace(/\.[^.]+?$/, '')) || null | ||
return (packageData.main && packageData.main | ||
.replace(/^.+\//, '') /* remove dirname */ | ||
.replace(/\.[^.]+$/, '') /* remove extension */ | ||
) || null | ||
} | ||
@@ -369,3 +377,3 @@ } | ||
&& packageData.scripts.test | ||
&& packageData.scripts.test.match(/^node(?: --[a-zA-Z0-9_]+)* (?:[^/]+\/)*([^.]+)\.(js|coffee)/) | ||
&& packageData.scripts.test.match(/^node(?: --[a-zA-Z0-9_]+)* (?:[^/]+\/)*([^.]+)\.js/) /* fetches filename without ext */ | ||
return (result && result[1]) || null | ||
@@ -501,3 +509,6 @@ } | ||
message: 'Will you use babel to support older environments?', | ||
default: hasMultipleEditions(), | ||
default () { | ||
const result = hasMultipleEditions() | ||
return result == null ? true : result | ||
}, | ||
when ({ language }) { | ||
@@ -534,3 +545,3 @@ return language === 'esnext' | ||
message: 'Who will the package author be?', | ||
default: getPackageAuthor() || `${new Date().getFullYear()}+ ${getGitUserName() || 'name'} <${getGitUserEmail() || 'email'}>`, | ||
default: getPackageAuthor() || `${new Date().getFullYear()}+ ${await getGitUserName() || 'name'} <${await getGitUserEmail() || 'email'}>`, | ||
validate: isSpecified, | ||
@@ -627,3 +638,5 @@ filter: trim | ||
catch (err) { | ||
throw new Error(`Failed to fetch the answers from the user: ${stackOrMessage(err)}`) | ||
return Promise.reject( | ||
new Error(`Failed to fetch the answers from the user: ${stackOrMessage(err)}`) | ||
) | ||
} | ||
@@ -650,8 +663,10 @@ } | ||
const customPackageScripts = {} | ||
Object.keys(packageDataLocal.scripts).forEach(function (key) { | ||
if (key.indexOf('my:') === 0) { | ||
const value = packageDataLocal.scripts[key] | ||
customPackageScripts[key] = value | ||
} | ||
}) | ||
if (packageDataLocal) { | ||
Object.keys(packageDataLocal.scripts).forEach(function (key) { | ||
if (key.indexOf('my:') === 0) { | ||
const value = packageDataLocal.scripts[key] | ||
customPackageScripts[key] = value | ||
} | ||
}) | ||
} | ||
const packageData = Object.assign( | ||
@@ -847,3 +862,10 @@ { | ||
const useEditionAutoloader = packageData.editions.length > 1 | ||
const lastEdition = packageData.editions[packageData.editions.length - 1] | ||
const sourceEdition = packageData.editions[0] | ||
const compiledEdition = packageData.editions[packageData.editions.length - 1] | ||
const sourceExtension = sourceEdition.entry.replace(/^.+\./, '') | ||
const compiledExtension = compiledEdition.entry.replace(/^.+\./, '') | ||
const sourceMainPath = pathUtil.join(sourceEdition.directory || '.', answers.mainEntry + '.' + sourceExtension) | ||
const sourceTestPath = pathUtil.join(sourceEdition.directory || '.', answers.testEntry + '.' + sourceExtension) | ||
const compiledMainPath = pathUtil.join(compiledEdition.directory || '.', answers.mainEntry + '.' + compiledExtension) | ||
const compiledTestPath = pathUtil.join(compiledEdition.directory || '.', answers.testEntry + '.' + compiledExtension) | ||
@@ -870,4 +892,4 @@ console.log('customising package data') | ||
else { | ||
mainPath = pathUtil.join(lastEdition.directory || '.', lastEdition.entry) | ||
testPath = pathUtil.join(lastEdition.directory || '.', answers.testEntry) | ||
mainPath = compiledMainPath | ||
testPath = compiledTestPath | ||
} | ||
@@ -891,3 +913,3 @@ packageData.main = mainPath | ||
if (answers.publish) { | ||
packageData.browser = pathUtil.join(lastEdition.directory || '.', lastEdition.entry) | ||
packageData.browser = compiledMainPath | ||
} | ||
@@ -1199,3 +1221,3 @@ else { | ||
console.log('adding the dependencies...\n') | ||
await util.spawn(['yarn', 'add'].concat(addDependencies)) | ||
await util.spawn(['npm', 'install', '--save'].concat(addDependencies)) | ||
console.log('\n...added the dependencies') | ||
@@ -1205,3 +1227,3 @@ } | ||
console.log('adding the development dependencies...\n') | ||
await util.spawn(['yarn', 'add', '--dev'].concat(addDevDependencies)) | ||
await util.spawn(['npm', 'install', '--save-dev'].concat(addDevDependencies)) | ||
console.log('\n...added the development dependencies') | ||
@@ -1211,13 +1233,15 @@ } | ||
console.log('remove old dependencies...\n') | ||
await util.spawn(['yarn', 'remove'].concat(removeDependencies)) | ||
await util.spawn(['npm', 'uninstall', '--save', '--save-dev'].concat(removeDependencies)) | ||
console.log('\n...removed old dependencies') | ||
} | ||
console.log('installing the dependencies...\n') | ||
await util.spawn('yarn') | ||
console.log('\n...installed all the dependencies') | ||
console.log('upgrading the installed dependencies...\n') | ||
await util.spawn('yarn upgrade') | ||
await util.spawn(['npm', 'install', '-g', 'npm-check-updates']) | ||
await util.spawn(['ncu', '-u']) | ||
console.log('\n...upgrading all the installed dependencies') | ||
console.log('installing the dependencies...\n') | ||
await util.spawn(['npm', 'install']) | ||
console.log('\n...installed all the dependencies') | ||
// remove old files | ||
@@ -1248,10 +1272,3 @@ console.log('removing old files...') | ||
)) | ||
await util.spawn( | ||
['touch'].concat( | ||
packageData.editions.map( | ||
(edition) => pathUtil.join(edition.directory || '.', edition.entry) | ||
) | ||
) | ||
// add test entry as well | ||
) | ||
await util.spawn(['touch', sourceMainPath, sourceTestPath]) | ||
@@ -1268,3 +1285,2 @@ console.log('running setup...\n') | ||
init() |
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
54632
1210