Skip to content

Commit

Permalink
feat(patreon): accepts patreon username as part of config
Browse files Browse the repository at this point in the history
  • Loading branch information
wessberg committed Oct 31, 2019
1 parent 3ce4ec2 commit d108ed2
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 31 deletions.
40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,32 @@
"backers"
],
"dependencies": {
"@types/eslint": "4.16.6",
"@types/inquirer": "6.0.3",
"@types/eslint": "6.1.3",
"@types/inquirer": "6.5.0",
"@types/json5": "0.0.30",
"@types/prettier": "1.16.4",
"@types/yaml": "1.0.2",
"@types/prettier": "1.18.3",
"@types/yaml": "1.2.0",
"chalk": "2.4.2",
"commander": "2.20.0",
"eslint": "5.16.0",
"inquirer": "6.4.1",
"json5": "2.1.0",
"yaml": "1.6.0",
"commander": "3.0.2",
"eslint": "6.6.0",
"inquirer": "7.0.0",
"json5": "2.1.1",
"yaml": "1.7.2",
"markdown-toc": "1.2.0",
"prettier": "1.18.2",
"tslint": "5.18.0"
"tslint": "5.20.0"
},
"devDependencies": {
"@wessberg/rollup-plugin-ts": "1.1.59",
"@wessberg/ts-config": "0.0.41",
"ava": "2.1.0",
"husky": "2.4.1",
"magic-string": "^0.25.2",
"np": "5.0.3",
"pretty-quick": "1.11.1",
"rollup": "1.16.1",
"standard-changelog": "2.0.11",
"typescript": "3.5.2"
"@wessberg/rollup-plugin-ts": "1.1.73",
"@wessberg/ts-config": "0.0.42",
"ava": "2.4.0",
"husky": "3.0.9",
"magic-string": "^0.25.4",
"np": "5.1.2",
"pretty-quick": "2.0.0",
"rollup": "1.26.0",
"standard-changelog": "2.0.15",
"typescript": "3.6.4"
},
"main": "./dist/index.js",
"module": "./dist/index.js",
Expand Down
3 changes: 2 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export default {
treeshake: true,
plugins: [
ts({
tsconfig: process.env.NODE_ENV === "production" ? "tsconfig.dist.json" : "tsconfig.json"
tsconfig: process.env.NODE_ENV === "production" ? "tsconfig.dist.json" : "tsconfig.json",
debug: true
})
],
external: [...Object.keys(packageJSON.dependencies), ...Object.keys(packageJSON.devDependencies), ...builtinModules]
Expand Down
17 changes: 9 additions & 8 deletions src/code-style/find-code-style/find-code-styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,51 +96,52 @@ export async function findCodeStyles({
* @param {Linter.Config} config
* @returns {CodeStyleKind[]}
*/
function getCodeStylesFromEslintConfig(config: Linter.Config & {extends?: string[]}): CodeStyleKind[] {
function getCodeStylesFromEslintConfig(config: Linter.Config): CodeStyleKind[] {
const ruleKeys = config.rules == null ? [] : Object.keys(config.rules);
const codeStyles: CodeStyleKind[] = [];
const extendsValue = config.extends == null ? undefined : Array.isArray(config.extends) ? config.extends : [config.extends];

// Check if it contains the Airbnb Style Guide
const containsAirbnb =
config.extends != null &&
config.extends.some(element => element === CONSTANT.ESLINT_AIRBNB_CODE_STYLE_NAME || element.includes(CONSTANT.ESLINT_AIRBNB_CODE_STYLE_HINT));
extendsValue != null &&
extendsValue.some(element => element === CONSTANT.ESLINT_AIRBNB_CODE_STYLE_NAME || element.includes(CONSTANT.ESLINT_AIRBNB_CODE_STYLE_HINT));

if (containsAirbnb) {
codeStyles.push(CodeStyleKind.AIRBNB);
}

// Check if it contains the Google Javascript Style Guide
const containsGoogle = config.extends != null && config.extends.some(element => element === CONSTANT.ESLINT_GOOGLE_CODE_STYLE_NAME);
const containsGoogle = extendsValue != null && extendsValue.some(element => element === CONSTANT.ESLINT_GOOGLE_CODE_STYLE_NAME);

if (containsGoogle) {
codeStyles.push(CodeStyleKind.GOOGLE);
}

// Check if it contains Prettier
const containsPrettier = config.extends != null && config.extends.some(element => element === CONSTANT.ESLINT_PRETTIER_CODE_STYLE_NAME);
const containsPrettier = extendsValue != null && extendsValue.some(element => element === CONSTANT.ESLINT_PRETTIER_CODE_STYLE_NAME);

if (containsPrettier) {
codeStyles.push(CodeStyleKind.PRETTIER);
}

// Check if it contains Idiomatic
const containsIdiomatic = config.extends != null && config.extends.some(element => element === CONSTANT.ESLINT_IDIOMATIC_CODE_STYLE_NAME);
const containsIdiomatic = extendsValue != null && extendsValue.some(element => element === CONSTANT.ESLINT_IDIOMATIC_CODE_STYLE_NAME);

if (containsIdiomatic) {
codeStyles.push(CodeStyleKind.IDIOMATIC);
}

// Check if it contains Standard
const containsStandard =
(config.extends != null && config.extends.some(element => element === CONSTANT.ESLINT_STANDARD_CODE_STYLE_NAME)) ||
(extendsValue != null && extendsValue.some(element => element === CONSTANT.ESLINT_STANDARD_CODE_STYLE_NAME)) ||
ruleKeys.some(key => CONSTANT.ESLINT_STANDARD_CODE_STYLE_HINTS.some(hint => key === hint));

if (containsStandard) {
codeStyles.push(CodeStyleKind.STANDARD);
}

// Check if it contains XO
const containsXo = config.extends != null && config.extends.some(element => element === CONSTANT.ESLINT_XO_CODE_STYLE_NAME);
const containsXo = extendsValue != null && extendsValue.some(element => element === CONSTANT.ESLINT_XO_CODE_STYLE_NAME);

if (containsXo) {
codeStyles.push(CodeStyleKind.XO);
Expand Down
4 changes: 4 additions & 0 deletions src/config/get-config/get-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export async function getConfig(options: FindConfigOptions): Promise<ScaffoldCon
prettier: config.prettier == null ? defaultConfig.prettier : (config.prettier as Options),
donate: {
patreon: {
username:
config.donate == null || config.donate.patreon == null || config.donate.patreon.username == null
? defaultConfig.donate.patreon.username
: config.donate.patreon.username,
userId:
config.donate == null || config.donate.patreon == null || config.donate.patreon.userId == null
? defaultConfig.donate.patreon.userId
Expand Down
1 change: 1 addition & 0 deletions src/config/scaffold-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Options} from "prettier";

export interface PatreonConfig {
userId?: string;
username?: string;
}

export interface OpenCollectiveConfig {
Expand Down
4 changes: 2 additions & 2 deletions src/funding/generate-funding/generate-funding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export function generateFunding({contributors, prettier, config}: GenerateFundin
yaml += `github: [${githubUserNames.join(", ")}]\n`;
}

if (config.donate.patreon.userId != null) {
yaml += `patreon: ${config.donate.patreon.userId}`;
if (config.donate.patreon.username != null) {
yaml += `patreon: ${config.donate.patreon.username}`;
}

if (config.donate.openCollective.project != null) {
Expand Down

0 comments on commit d108ed2

Please sign in to comment.