Skip to content

Commit

Permalink
fix: dotfiles v2 the reckoning of the package.json (#81)
Browse files Browse the repository at this point in the history
* fix: on template generation package should be renamed to package.json

* fix: issue with keywords, and template/package.json affecting main package.json

* removed npx for editor-config
  • Loading branch information
Mauricio Mercado authored Apr 7, 2020
1 parent b8f23d3 commit 46d9d8c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
11 changes: 9 additions & 2 deletions lib/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = async function main(argv) {
answers.license = answers.license.key
answers.private = !answers.oss
answers.access = answers.oss ? 'public' : 'restricted'
answers.keywords = ['telus'].concat(answers.topics)
answers.keywords = JSON.stringify(['telus'].concat(answers.topics))

// write license file
await write(join(argv.path, 'LICENSE'), `${license}\n`)
Expand All @@ -45,6 +45,13 @@ module.exports = async function main(argv) {
const stream = glob.stream('**/*', { cwd: template, dot: true })

stream.on('data', async (file) => {
// Needed to add package to be renamed to package.json because
// whenever we were about to publish this package, the package.json
// of the template will affect what the main package.json will be able
// to add to the published package.
// and also while trying not to set developers to fail by publishing everything
// themselves.
const rename = { gitignore: '.gitignore', package: 'package.json' }
const dir = dirname(file)

// create directory if none-exists
Expand All @@ -59,6 +66,6 @@ module.exports = async function main(argv) {
})

// write file to destination
write(join(argv.path, file === 'gitignore' ? '.gitignore' : file), content)
write(join(argv.path, Object.keys(rename).includes(file) ? rename[file] : file), content)
})
}
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
},
"license": "MIT",
"bin": "index.js",
"files": [
"template",
"lib"
],
"keywords": [
"telus",
"init",
Expand All @@ -24,12 +28,6 @@
"engines": {
"node": ">=12"
},
"files": [
"lib",
"template",
"template/*",
"index.js"
],
"bugs": {
"url": "https://github.com/telus/create-library/issues"
},
Expand Down
2 changes: 1 addition & 1 deletion template/package.json → template/package
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"license": "[license]",
"main": "index.js",
"keywords": "[keywords]",
"keywords": [keywords],
"engines": {
"node": ">=12"
},
Expand Down

0 comments on commit 46d9d8c

Please sign in to comment.