Comparing version 0.1.8 to 0.2.0
@@ -8,3 +8,2 @@ const path = require('path'); | ||
const templatePath = path.resolve(__dirname, '../templates'); | ||
const repoName = name => name.replace(/^@4c\//, ''); | ||
@@ -14,3 +13,2 @@ async function setupNpm(dest, a) { | ||
eslint: '^4.16.0', | ||
'eslint-config-import': '^0.13.0', | ||
'eslint-config-prettier': '^2.9.0', | ||
@@ -23,7 +21,7 @@ 'eslint-plugin-import': '^2.8.0', | ||
if (a.type === 'web') { | ||
eslint['eslint-config-4catalyzer-react'] = '^0.3.3'; | ||
eslint['eslint-config-4catalyzer-react'] = '^0.4.1'; | ||
eslint['eslint-plugin-react'] = '^7.5.1'; | ||
eslint['eslint-plugin-jsx-a11y'] = '^5.1.1'; | ||
eslint['eslint-plugin-jsx-a11y'] = '^6.0.3'; | ||
} else { | ||
eslint['eslint-config-4catalyzer'] = '^0.3.3'; | ||
eslint['eslint-config-4catalyzer'] = '^0.4.1'; | ||
} | ||
@@ -42,14 +40,23 @@ | ||
repository: `https://github.com/4Catalyzer/${repoName(a.name)}.git`, | ||
repository: { | ||
type: 'git', | ||
url: GitUtilities.remoteUrl(a.name), | ||
}, | ||
author: '4Catalyzer', | ||
license: 'MIT', | ||
scripts: { | ||
tdd: 'jest --watch', | ||
test: 'npm run lint && jest', | ||
testonly: 'jest', | ||
...(a.babel && { | ||
'build:es': 'BABEL_ENV=esm babel src -d es --ignore __tests__', | ||
'build:lib': 'babel src -d lib --ignore __tests__', | ||
'build:es': | ||
'babel src -d es --env-name esm --ignore **/__tests__ --delete-dir-on-start', | ||
'build:lib': | ||
'babel src -d lib --ignore **/__tests__ --delete-dir-on-start', | ||
build: 'npm run build:lib && npm run build:es', | ||
prepublishOnly: 'yarn run build', | ||
}), | ||
lint: [ | ||
'eslint .', | ||
"prettier --list-different --ignore-path .ignore '**/*.{json,css,md}'", | ||
"prettier --list-different --ignore-path .eslintignore '**/*.{json,css,md}'", | ||
].join(' && '), | ||
@@ -62,2 +69,5 @@ format: [ | ||
}, | ||
publishConfig: { | ||
access: a.isPrivate ? 'restricted' : 'public', | ||
}, | ||
prettier: { | ||
@@ -75,2 +85,11 @@ printWidth: 79, | ||
}, | ||
jest: { | ||
roots: ['<rootDir>/test'], | ||
testEnvironment: a.type === 'node' ? 'node' : 'jsdom', | ||
}, | ||
...(a.semanticRelease && { | ||
release: { | ||
extends: ['@4c/semantic-release-config'], | ||
}, | ||
}), | ||
devDependencies: { | ||
@@ -81,6 +100,11 @@ ...(a.babel && { | ||
'@4c/babel-preset-4catalyzer': '^1.0.0', | ||
'babel-jest': '^22.4.3', | ||
'babel-core': 'bridge', | ||
}), | ||
...(a.semanticRelease && { | ||
'@4c/semantic-release-config': '^1.0.2', | ||
}), | ||
'babel-eslint': '^8.2.1', | ||
husky: '^0.14.3', | ||
'lint-staged': '^6.1.0', | ||
'lint-staged': '^7.1.0', | ||
prettier: '^1.10.2', | ||
@@ -124,2 +148,8 @@ ...eslint, | ||
{ | ||
name: 'scopePackage', | ||
type: 'confirm', | ||
message: 'Create a scoped package?', | ||
default: true, | ||
}, | ||
{ | ||
name: 'scope', | ||
@@ -129,4 +159,12 @@ type: 'input', | ||
default: '@4c', | ||
when: _ => !!_.scopePackage, | ||
}, | ||
{ | ||
name: 'isPrivate', | ||
type: 'confirm', | ||
default: false, | ||
message: 'Is this a private package?', | ||
when: _ => !!_.scope, | ||
}, | ||
{ | ||
name: 'name', | ||
@@ -151,2 +189,8 @@ type: 'input', | ||
}, | ||
{ | ||
name: 'semanticRelease', | ||
type: 'confirm', | ||
default: true, | ||
message: 'Do you want to use semantic-release to handle releases?', | ||
}, | ||
]); | ||
@@ -162,7 +206,7 @@ | ||
await copyTemplate('.travis.yml'); | ||
await copyTemplate('.eslintrc'); | ||
await copyTemplate(`${answers.type}.eslintrc`, '.eslintrc'); | ||
await copyTemplate('.eslintignore'); | ||
await GitUtilities.init(dest); | ||
await GitUtilities.addRemote(answers.name); | ||
await GitUtilities.addRemote(dest, answers.name); | ||
@@ -176,3 +220,3 @@ await setupNpm(dest, answers); | ||
` | ||
module.exports = { | ||
module.exports = api => ({ | ||
presets: [ | ||
@@ -183,7 +227,7 @@ [ | ||
target: '${answers.type}', | ||
modules: process.env.BABEL_ENV === 'esm' ? false : 'commonjs' | ||
modules: api.env() === 'esm' ? false : 'commonjs' | ||
}, | ||
], | ||
] | ||
}; | ||
}); | ||
`, | ||
@@ -196,7 +240,15 @@ ); | ||
await execa('yarn', ['install'], { cwd: dest, stdio: 'inherit' }); | ||
await execa('yarn', ['upgrade-interactive', '--latest'], { | ||
cwd: dest, | ||
stdio: 'inherit', | ||
}); | ||
await execa('npm', ['run', 'format'], { cwd: dest, stdio: 'inherit' }); | ||
console.log('Done!'); | ||
if (answers.semanticRelease) { | ||
console.log( | ||
'\nRun `npx semantic-release-cli setup` after pushing to github for the first time to setup semantic release\n', | ||
); | ||
} else { | ||
console.log('Done!'); | ||
} | ||
}, | ||
}; |
@@ -10,3 +10,9 @@ const execa = require('execa'); | ||
} | ||
const repoName = name => name.replace(/^@.+\//, ''); | ||
exports.repoName = repoName; | ||
exports.remoteUrl = (name, org = '4Catalyzer') => | ||
`https://github.com/${org}/${repoName(name)}.git`; | ||
exports.isGitRepo = dest => | ||
@@ -53,14 +59,8 @@ execa('git', ['rev-parse'], { cwd: dest, stdio: 'inherit' }) | ||
exports.addRemote = (name, org = '4catalyzer') => { | ||
exports.addRemote = (dest, name, org) => { | ||
try { | ||
execa( | ||
'git', | ||
[ | ||
'remote', | ||
'add', | ||
'origin', | ||
`git@github.com:${org}/${name.replace(/^@4c\//, '')}.git`, | ||
], | ||
{ cwd: name, stdio: [0, 1, 'pipe'] }, | ||
); | ||
execa('git', ['remote', 'add', 'origin', exports.remoteUrl(name, org)], { | ||
cwd: dest, | ||
stdio: 'inherit', | ||
}); | ||
} catch (err) { | ||
@@ -67,0 +67,0 @@ if ((err.stderr || '').match(/remote origin already exists/)) return; |
{ | ||
"name": "@4c/cli", | ||
"version": "0.1.8", | ||
"version": "0.2.0", | ||
"main": "index.js", | ||
@@ -12,2 +12,3 @@ "repository": "https://github.com/4Catalyzer/init.git", | ||
"scripts": { | ||
"test": "npm run lint", | ||
"lint": "eslint . && prettier --list-different --ignore-path .ignore '**/*.{json,css,md}'", | ||
@@ -14,0 +15,0 @@ "precommit": "lint-staged" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
115115
16
607