Skip to content
This repository has been archived by the owner on Apr 1, 2023. It is now read-only.

WIP CRL v2 #136

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
982d4e9
initial v2 skeleton
transitive-bullshit Mar 5, 2019
b964c40
.
transitive-bullshit Mar 5, 2019
fa92dff
v0.0.1
transitive-bullshit Mar 5, 2019
c7591ab
.
transitive-bullshit Mar 5, 2019
d32b960
chore(crl-scripts): update deps
transitive-bullshit Apr 11, 2019
56e1fda
👝
transitive-bullshit Apr 11, 2019
79618bc
😅
transitive-bullshit Apr 11, 2019
073dd57
😪
transitive-bullshit Apr 11, 2019
c373727
🦏
transitive-bullshit Apr 12, 2019
0a77d84
🚮
transitive-bullshit Apr 12, 2019
df19928
.
transitive-bullshit Apr 12, 2019
3e12c8f
consolidate one template
transitive-bullshit Apr 14, 2019
1ec4659
🐿
transitive-bullshit Apr 14, 2019
83e3a55
🚶
transitive-bullshit Apr 14, 2019
d73cd27
🌭
transitive-bullshit Apr 17, 2019
eb30c88
v0.0.2
transitive-bullshit Apr 17, 2019
93581b3
transitive-bullshit Apr 17, 2019
49f14fd
v0.0.3
transitive-bullshit Apr 17, 2019
0ad39b9
🏁
transitive-bullshit Apr 17, 2019
39db65b
add open open source notice
transitive-bullshit Aug 29, 2019
a157324
Implement eject script
Jan 14, 2020
3ad01c0
Merge pull request #193 from CarterMcAlister/v2-eject
transitive-bullshit Jan 14, 2020
0d3c72a
Update dependencies
Jan 15, 2020
bf6f5eb
Update target version to node >= 10
Jan 15, 2020
8196c2c
Bump react peerDependency to >=16.8 for hooks compatibility
Jan 15, 2020
5a960ed
Merge pull request #194 from transitive-bullshit/v2-dependencies
transitive-bullshit Jan 16, 2020
8333876
Change templates to use hooks
Jan 17, 2020
8d80a14
Remove comment
Jan 17, 2020
977bd4c
Merge pull request #196 from transitive-bullshit/v2-hooks
CarterMcAlister Jan 17, 2020
5ce1cc5
Add command to get version
Jan 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ dist

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
Expand Down
8 changes: 8 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"lerna": "2.11.0",
"version": "independent",
"npmClient": "yarn",
"packages": [
"packages/*"
]
}
116 changes: 0 additions & 116 deletions lib/create-library.test.js

This file was deleted.

60 changes: 15 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,55 +1,25 @@
{
"name": "create-react-library",
"version": "2.6.7",
"name": "create-react-library-monorepo",
"private": true,
"version": "0.0.0",
"description": "CLI for easily bootstrapping modern react libraries",
"repository": "transitive-bullshit/create-react-library",
"author": "Travis Fischer <[email protected]>",
"main": "index.js",
"author": "Travis Fischer <[email protected]>",
"license": "MIT",
"reveal": true,
"bin": {
"create-react-library": "index.js"
},
"scripts": {
"test": "ava -v && standard *.js lib/*.js"
},
"engines": {
"node": ">=8",
"npm": ">=5"
"node": ">=8"
},
"keywords": [
"react",
"preact",
"library",
"module",
"create-react-app",
"cli",
"component",
"rollup",
"babel",
"publish"
],
"dependencies": {
"chalk": "^2.4.2",
"commander": "^2.19.0",
"conf": "^2.2.0",
"cp-file": "^6.0.0",
"execa": "^1.0.0",
"git-config-path": "^2.0.0",
"github-username": "^4.1.0",
"globby": "^9.0.0",
"handlebars": "^4.1.0",
"inquirer": "^6.2.2",
"make-dir": "^2.0.0",
"ora": "^3.1.0",
"p-each-series": "^1.0.0",
"parse-git-config": "^3.0.0",
"validate-npm-package-name": "^3.0.0",
"which": "^1.3.1"
"scripts": {
"test": "run-s test:*",
"test:unit": "lerna run test",
"clean": "git clean -dfqX -- ./node_modules **/{build,node_modules}/",
"bootstrap": "lerna bootstrap",
"publish": "lerna publish",
"preinstall": "node -e \"if (process.env.npm_execpath.indexOf('yarn') < 0) throw new Error('yarn is required for development')\"",
"postinstall": "run-s bootstrap"
},
"devDependencies": {
"ava": "^1.2.1",
"rmfr": "^2.0.0",
"standard": "^12.0.1"
"lerna": "^3.10.6",
"npm-run-all": "^4.1.5"
}
}
File renamed without changes.
20 changes: 9 additions & 11 deletions lib/cli.js → packages/create-react-library/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ module.exports = async () => {
.name('create-react-library')
.version(version)
.usage('[options] [package-name]')
.option('-d, --desc <string>', 'package description')
.option('-a, --author <string>', 'author\'s github handle', defaults.author)
.option('-l, --license <string>', 'package license', defaults.license)
.option('-r, --repo <string>', 'package repo path')
.option('-g, --no-git', 'generate without git init')
.option('-m, --manager <npm|yarn>', 'package manager to use', /^(npm|yarn)$/, defaults.manager)
.option('-t, --template <default|typescript>', 'package template to use', /^(default|typescript|custom)$/, defaults.template)
.option('-p, --template-path <string>', 'custom package template path')
.option('-s, --skip-prompts', 'skip all prompts (must provide package-name via cli)')
.option('-d, --desc <string>', 'Package description')
.option('-a, --author <string>', 'Author\'s github handle', defaults.author)
.option('-l, --license <string>', 'Package license', defaults.license)
.option('-r, --repo <string>', 'Package repo path')
.option('-g, --no-git', 'Generate without git init')
.option('-m, --manager <npm|yarn>', 'Package manager to use', /^(npm|yarn)$/, defaults.manager)
.option('-t, --typescript', 'Add TypeScript support to the generated template')
.option('-s, --skip-prompts', 'Skip all prompts (must provide package-name via cli)')
.parse(process.argv)

const opts = {
Expand All @@ -34,9 +33,8 @@ module.exports = async () => {
license: program.license,
repo: program.repo,
manager: program.manager,
template: program.template,
templatePath: program.templatePath,
skipPrompts: program.skipPrompts,
typescript: program.typescript,
git: program.git
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,40 @@ const templateBlacklist = new Set([
'example/public/favicon.ico'
])

const templateTSBlacklist = new Set([
'src/index.js'
])

const templateTSWhitelist = new Set([
'tsconfig.json',
'src/index.tsx',
'src/typings.d.ts',
'example/tsconfig.json'
])

module.exports = async (info) => {
const {
manager,
template,
name,
templatePath,
git
} = info

// handle scoped package names
const parts = name.split('/')
info.shortName = parts[parts.length - 1]
if (!info.shortName) {
const parts = name.split('/')
info.shortName = parts[parts.length - 1]
}

if (!info.dest) {
info.dest = path.join(process.cwd(), info.shortName)
}

const dest = info.dest

const dest = path.join(process.cwd(), info.shortName)
info.dest = dest
await mkdirp(dest)

const source = template === 'custom'
? path.join(process.cwd(), templatePath)
: path.join(__dirname, '..', 'template', template)
const files = await globby(source, {
dot: true
})
const source = path.join(__dirname, '..', 'template')
const files = await globby(source, { dot: true })

{
const promise = pEachSeries(files, async (file) => {
Expand All @@ -48,7 +59,7 @@ module.exports = async (info) => {
info
})
})
ora.promise(promise, `Copying ${template} template to ${dest}`)
ora.promise(promise, `Copying template to ${dest}`)
await promise
}

Expand Down Expand Up @@ -79,6 +90,12 @@ module.exports.copyTemplateFile = async (opts) => {
const destFilePath = path.join(dest, fileRelativePath)
const destFileDir = path.parse(destFilePath).dir

if (info.typescript && templateTSBlacklist.has(fileRelativePath)) {
return
} else if (!info.typescript && templateTSWhitelist.has(fileRelativePath)) {
return
}

await mkdirp(destFileDir)

if (templateBlacklist.has(fileRelativePath)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = async () => {
repo: (info) => `${info.author}/${info.name}`,
license: config.get('license', 'MIT'),
manager: config.get('manager', 'npm'),
template: config.get('template', 'default')
typescript: config.get('typescript', false)
}

try {
Expand Down Expand Up @@ -44,10 +44,6 @@ module.exports = async () => {

config.set('manager', defaults.manager)
}

if (!config.get('template')) {
config.set('template', defaults.template)
}
} catch (err) { }

return defaults
Expand Down
Loading