add conf to remember preferred config
This commit is contained in:
parent
e180e34ee5
commit
288d18f616
6 changed files with 59 additions and 13 deletions
5
packages/create-freesewing-pattern/lib/config.js
Normal file
5
packages/create-freesewing-pattern/lib/config.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const Conf = require('conf')
|
||||||
|
|
||||||
|
module.exports = new Conf()
|
|
@ -5,13 +5,17 @@ const githubUsername = require('github-username')
|
||||||
const parseGitConfig = require('parse-git-config')
|
const parseGitConfig = require('parse-git-config')
|
||||||
const which = require('which')
|
const which = require('which')
|
||||||
|
|
||||||
|
const config = require('./config')
|
||||||
|
|
||||||
module.exports = async () => {
|
module.exports = async () => {
|
||||||
const defaults = {
|
const defaults = {
|
||||||
author: undefined,
|
author: config.get('author'),
|
||||||
manager: 'npm'
|
manager: config.get('manager', 'npm'),
|
||||||
|
license: config.get('license', 'MIT')
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (!config.get('author')) {
|
||||||
const gitConfigPath = getGitConfigPath('global')
|
const gitConfigPath = getGitConfigPath('global')
|
||||||
|
|
||||||
if (gitConfigPath) {
|
if (gitConfigPath) {
|
||||||
|
@ -24,9 +28,18 @@ module.exports = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defaults.author) {
|
||||||
|
config.set('author', defaults.author)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!config.get('manager')) {
|
||||||
if (which.sync('yarn', { nothrow: true })) {
|
if (which.sync('yarn', { nothrow: true })) {
|
||||||
defaults.manager = 'yarn'
|
defaults.manager = 'yarn'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.set('manager', defaults.manager)
|
||||||
|
}
|
||||||
} catch (err) { }
|
} catch (err) { }
|
||||||
|
|
||||||
return defaults
|
return defaults
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
const inquirer = require('inquirer')
|
const inquirer = require('inquirer')
|
||||||
const isValidNpmName = require('is-valid-npm-name')
|
const isValidNpmName = require('is-valid-npm-name')
|
||||||
|
|
||||||
|
const config = require('./config')
|
||||||
|
|
||||||
module.exports = async (defaults) => {
|
module.exports = async (defaults) => {
|
||||||
const info = await inquirer.prompt([
|
const info = await inquirer.prompt([
|
||||||
{
|
{
|
||||||
|
@ -35,7 +37,7 @@ module.exports = async (defaults) => {
|
||||||
type: 'input',
|
type: 'input',
|
||||||
name: 'license',
|
name: 'license',
|
||||||
message: 'License',
|
message: 'License',
|
||||||
default: 'MIT'
|
default: defaults.license
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'list',
|
type: 'list',
|
||||||
|
@ -46,5 +48,9 @@ module.exports = async (defaults) => {
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
config.set('author', info.author)
|
||||||
|
config.set('manager', info.manager)
|
||||||
|
config.set('license', info.license)
|
||||||
|
|
||||||
return info
|
return info
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
"publish"
|
"publish"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"conf": "^1.4.0",
|
||||||
"consolidate": "^0.15.0",
|
"consolidate": "^0.15.0",
|
||||||
"cp-file": "^5.0.0",
|
"cp-file": "^5.0.0",
|
||||||
"execa": "^0.9.0",
|
"execa": "^0.9.0",
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
"jsnext:main": "dist/index.es.js",
|
"jsnext:main": "dist/index.es.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "CI=1 react-scripts test --env=jsdom",
|
"test": "CI=1 react-scripts test --env=jsdom",
|
||||||
|
"test:watch": "react-scripts test --env=jsdom",
|
||||||
"build": "rollup -c",
|
"build": "rollup -c",
|
||||||
"start": "rollup -c -w",
|
"start": "rollup -c -w",
|
||||||
"prepare": "{{manager}} run build",
|
"prepare": "{{manager}} run build",
|
||||||
|
|
|
@ -1051,6 +1051,16 @@ concordance@^3.0.0:
|
||||||
semver "^5.3.0"
|
semver "^5.3.0"
|
||||||
well-known-symbols "^1.0.0"
|
well-known-symbols "^1.0.0"
|
||||||
|
|
||||||
|
conf@^1.4.0:
|
||||||
|
version "1.4.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/conf/-/conf-1.4.0.tgz#1ea66c9d7a9b601674a5bb9d2b8dc3c726625e67"
|
||||||
|
dependencies:
|
||||||
|
dot-prop "^4.1.0"
|
||||||
|
env-paths "^1.0.0"
|
||||||
|
make-dir "^1.0.0"
|
||||||
|
pkg-up "^2.0.0"
|
||||||
|
write-file-atomic "^2.3.0"
|
||||||
|
|
||||||
configstore@^3.0.0:
|
configstore@^3.0.0:
|
||||||
version "3.1.1"
|
version "3.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/configstore/-/configstore-3.1.1.tgz#094ee662ab83fad9917678de114faaea8fcdca90"
|
resolved "https://registry.yarnpkg.com/configstore/-/configstore-3.1.1.tgz#094ee662ab83fad9917678de114faaea8fcdca90"
|
||||||
|
@ -1338,6 +1348,10 @@ encoding@^0.1.11:
|
||||||
dependencies:
|
dependencies:
|
||||||
iconv-lite "~0.4.13"
|
iconv-lite "~0.4.13"
|
||||||
|
|
||||||
|
env-paths@^1.0.0:
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-1.0.0.tgz#4168133b42bb05c38a35b1ae4397c8298ab369e0"
|
||||||
|
|
||||||
equal-length@^1.0.0:
|
equal-length@^1.0.0:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/equal-length/-/equal-length-1.0.1.tgz#21ca112d48ab24b4e1e7ffc0e5339d31fdfc274c"
|
resolved "https://registry.yarnpkg.com/equal-length/-/equal-length-1.0.1.tgz#21ca112d48ab24b4e1e7ffc0e5339d31fdfc274c"
|
||||||
|
@ -3436,6 +3450,12 @@ pkg-dir@^2.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
find-up "^2.1.0"
|
find-up "^2.1.0"
|
||||||
|
|
||||||
|
pkg-up@^2.0.0:
|
||||||
|
version "2.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-2.0.0.tgz#c819ac728059a461cab1c3889a2be3c49a004d7f"
|
||||||
|
dependencies:
|
||||||
|
find-up "^2.1.0"
|
||||||
|
|
||||||
plur@^2.0.0, plur@^2.1.2:
|
plur@^2.0.0, plur@^2.1.2:
|
||||||
version "2.1.2"
|
version "2.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/plur/-/plur-2.1.2.tgz#7482452c1a0f508e3e344eaec312c91c29dc655a"
|
resolved "https://registry.yarnpkg.com/plur/-/plur-2.1.2.tgz#7482452c1a0f508e3e344eaec312c91c29dc655a"
|
||||||
|
@ -4494,7 +4514,7 @@ write-file-atomic@^1.1.4:
|
||||||
imurmurhash "^0.1.4"
|
imurmurhash "^0.1.4"
|
||||||
slide "^1.1.5"
|
slide "^1.1.5"
|
||||||
|
|
||||||
write-file-atomic@^2.0.0:
|
write-file-atomic@^2.0.0, write-file-atomic@^2.3.0:
|
||||||
version "2.3.0"
|
version "2.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.3.0.tgz#1ff61575c2e2a4e8e510d6fa4e243cce183999ab"
|
resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.3.0.tgz#1ff61575c2e2a4e8e510d6fa4e243cce183999ab"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue