Skip to content

Commit

Permalink
ran prettier on project
Browse files Browse the repository at this point in the history
  • Loading branch information
pkscout committed Mar 13, 2021
1 parent 030636f commit ce6fbb8
Show file tree
Hide file tree
Showing 20 changed files with 692 additions and 568 deletions.
14 changes: 14 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"env": {
"commonjs": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2020
},
"rules": {
"import/first": "error"
}
}
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ module.exports = {
},
},
],
}
};
4 changes: 3 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"printWidth": 85,
"arrowParens": "avoid",
"semi": false
"semi": true,
"tabWidth": 2
}
2 changes: 1 addition & 1 deletion gatsby-browser.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import './src/styles/global.css';
import "./src/styles/global.css";
30 changes: 15 additions & 15 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const path = require(`path`)
const path = require(`path`);
require(`dotenv`).config({
path: `.env.${process.env.NODE_ENV}`,
})
const config = require(`./gatsby-site-config`)
});
const config = require(`./gatsby-site-config`);

module.exports = {
siteMetadata: config.siteMetadata,
Expand Down Expand Up @@ -59,23 +59,23 @@ module.exports = {
`gatsby-transformer-yaml`,
`gatsby-transformer-sharp`,
{
resolve: 'gatsby-source-kodidonorwall',
resolve: "gatsby-source-kodidonorwall",
options: {
typeName: 'Donor',
accessKeyId: process.env.AWS_ID,
typeName: "Donor",
accessKeyId: process.env.AWS_ID,
secretAccessKey: process.env.AWS_KEY,
region: 'us-east-1',
region: "us-east-1",
params: {
TableName : process.env.AWS_DBNAME,
IndexName: 'all',
TableName: process.env.AWS_DBNAME,
IndexName: "all",
Limit: 30,
ProjectionExpression: 'id,createdAt,amount,currency,provider,publicName',
ProjectionExpression: "id,createdAt,amount,currency,provider,publicName",
ScanIndexForward: false,
KeyConditionExpression: 'dummy=:dummyval',
ExpressionAttributeValues: {":dummyval":"1"},
KeyConditionExpression: "dummy=:dummyval",
ExpressionAttributeValues: { ":dummyval": "1" },
// OTHER PARAMS HERE
}
}
},
},
},
{
resolve: "gatsby-source-kodiaddon",
Expand All @@ -88,4 +88,4 @@ module.exports = {
// To learn more, visit: https://gatsby.app/offline
// `gatsby-plugin-offline`,
],
}
};
13 changes: 7 additions & 6 deletions gatsby-site-config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// gatsby-site-config.js
let url = ''
let url = "";
if (process.env.GATSBY_SITEURL === undefined) {
url = 'https://dont.care'
url = "https://dont.care";
} else {
url = process.env.GATSBY_SITEURL
url = process.env.GATSBY_SITEURL;
}

module.exports = {
siteMetadata: {
title: "Kodi | Open Source Home Theater Software",
description: "Kodi is a free media player that is designed to look great on your big screen TV but is just as home on a small screen.",
description:
"Kodi is a free media player that is designed to look great on your big screen TV but is just as home on a small screen.",
siteUrl: url,
author: "Team Kodi",
}
}
},
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"build": "gatsby build",
"develop": "gatsby develop",
"start": "npm run develop",
"format": "prettier --write \"src/**/*.js\"",
"format": "prettier --write \"**/*.+(js|jsx|tsx)\"",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {}
Expand Down
66 changes: 33 additions & 33 deletions plugins/gatsby-source-kodiaddon/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@
// console.log(inspect(authors, { colors: true, depth: Infinity }));
// const inspect = require("util").inspect // this is only here to inspect the json during debugging

const fs = require("fs")
const yaml = require("js-yaml")
const fs = require("fs");
const yaml = require("js-yaml");

let kodiversion = ""
let kodiversions = ""
let kodiversion = "";
let kodiversions = "";
/** @type {import("../../src/addon").IAddon[]} */
let addons = []
let featured = { addons: [] }
let addons = [];
let featured = { addons: [] };
/** @type {any[]} */
let authors = []
let authors = [];
/** @type {any[]} */
let categories = []
let pixiememory = ""
let addonsfeatured = ""
let addonnodetype = ""
let authornodetype = ""
let categorynodetype = ""
let categories = [];
let pixiememory = "";
let addonsfeatured = "";
let addonnodetype = "";
let authornodetype = "";
let categorynodetype = "";

exports.onPreBootstrap =
/**
* @param {any} _ref
* @param {{ kodiversion: string }} pluginOptions
*/
function (_ref, pluginOptions) {
kodiversions = pluginOptions.kodiversions
}
kodiversions = pluginOptions.kodiversions;
};

function setFeatured(addon) {
if (featured.addons.find(o => o.addonid === addon.id) !== undefined) {
addon.featured = "true"
addon.featured = "true";
} else {
addon.featured = ""
addon.featured = "";
}
return addon
return addon;
}

exports.sourceNodes = async ({
Expand All @@ -46,20 +46,20 @@ exports.sourceNodes = async ({
createNodeId,
getNodesByType,
}) => {
const { createNode, touchNode, deleteNode } = actions
const { createNode, touchNode, deleteNode } = actions;
for (let i = 0; i < kodiversions.length; i++) {
kodiversion = kodiversions[i]
console.log("loading addon information for " + kodiversion)
pixiememory = "src/data/addons/" + kodiversion + "/"
addonnodetype = kodiversion + "Addon"
authornodetype = kodiversion + "Author"
categorynodetype = kodiversion + "Category"
addons = JSON.parse(fs.readFileSync(pixiememory + "addons.json", "utf8"))
authors = JSON.parse(fs.readFileSync(pixiememory + "authors.json", "utf8"))
kodiversion = kodiversions[i];
console.log("loading addon information for " + kodiversion);
pixiememory = "src/data/addons/" + kodiversion + "/";
addonnodetype = kodiversion + "Addon";
authornodetype = kodiversion + "Author";
categorynodetype = kodiversion + "Category";
addons = JSON.parse(fs.readFileSync(pixiememory + "addons.json", "utf8"));
authors = JSON.parse(fs.readFileSync(pixiememory + "authors.json", "utf8"));
categories = JSON.parse(
fs.readFileSync(pixiememory + "categories.json", "utf8")
)
featured = yaml.load(fs.readFileSync(pixiememory + "featured.yaml", "utf8"))
);
featured = yaml.load(fs.readFileSync(pixiememory + "featured.yaml", "utf8"));
addons.forEach(addon =>
createNode({
...setFeatured(addon),
Expand All @@ -72,7 +72,7 @@ exports.sourceNodes = async ({
contentDigest: createContentDigest(addon),
},
})
)
);
authors.forEach(author =>
createNode({
...author,
Expand All @@ -85,7 +85,7 @@ exports.sourceNodes = async ({
contentDigest: createContentDigest(author),
},
})
)
);
categories.forEach(category =>
createNode({
...category,
Expand All @@ -98,6 +98,6 @@ exports.sourceNodes = async ({
contentDigest: createContentDigest(category),
},
})
)
);
}
}
};
2 changes: 1 addition & 1 deletion plugins/gatsby-source-kodiaddon/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// noop

export {}
export {};
94 changes: 49 additions & 45 deletions plugins/gatsby-source-kodidonorwall/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
var AWS = require('aws-sdk');
let DUMMYITEM = item = {
amount: 0,
currency: 'usd',
createdAt: 1613609727,
id: 'blank-record',
provider: 'none',
publicName: 'Dummy Record'
}
var AWS = require("aws-sdk");
let DUMMYITEM = (item = {
amount: 0,
currency: "usd",
createdAt: 1613609727,
id: "blank-record",
provider: "none",
publicName: "Dummy Record",
});

exports.sourceNodes = ( { actions, createNodeId, createContentDigest },
options,
) => {
exports.sourceNodes = ({ actions, createNodeId, createContentDigest }, options) => {
return new Promise((resolve, reject) => {
const { createNode } = actions
delete options.plugins
const { createNode } = actions;
delete options.plugins;

const processData = item => {
const nodeId = createNodeId(`dynamodb-${item.id}`)
const nodeContentDigest = createContentDigest(item)
const nodeId = createNodeId(`dynamodb-${item.id}`);
const nodeContentDigest = createContentDigest(item);

const nodeData = Object.assign({}, item, {
id: nodeId,
parent: null,
Expand All @@ -29,55 +27,61 @@ exports.sourceNodes = ( { actions, createNodeId, createContentDigest },
type: options.typeName,
content: JSON.stringify(item),
},
})
return nodeData
}
});
return nodeData;
};

const onQuery = (err, data) => {
if (err || data.Items.length == 0) {
if (err) {
console.error("Unable to query donors. Error:", JSON.stringify(err, null, 2));
console.error(
"Unable to query donors. Error:",
JSON.stringify(err, null, 2)
);
} else {
console.log("No donor records found.")
console.log("No donor records found.");
}
console.log("Creating single empty donor record.")
const nodeData = processData(DUMMYITEM)
createNode(nodeData)
if (err){
reject(err)
console.log("Creating single empty donor record.");
const nodeData = processData(DUMMYITEM);
createNode(nodeData);
if (err) {
reject(err);
} else {
resolve()
resolve();
}
} else {
console.log("Query for donors succeeded.");
data.Items.forEach((item) => {
const nodeData = processData(item)
createNode(nodeData)
data.Items.forEach(item => {
const nodeData = processData(item);
createNode(nodeData);
});

if (typeof data.LastEvaluatedKey != "undefined") {
console.log("Querying for more...");
params.ExclusiveStartKey = data.LastEvaluatedKey;
docClient.query(params, onQuery);
} else {
resolve()
resolve();
}
}
}

if (options.params.TableName == undefined || options.accessKeyId == undefined || options.secretAccessKey == undefined) {
console.log("Unable to query donor database.")
console.log("Creating single empty donor record.")
createNode(processData(DUMMYITEM))
resolve()
};

if (
options.params.TableName == undefined ||
options.accessKeyId == undefined ||
options.secretAccessKey == undefined
) {
console.log("Unable to query donor database.");
console.log("Creating single empty donor record.");
createNode(processData(DUMMYITEM));
resolve();
} else {
var docClient = new AWS.DynamoDB.DocumentClient({
region: options.region,
accessKeyId: options.accessKeyId,
secretAccessKey: options.secretAccessKey
accessKeyId: options.accessKeyId,
secretAccessKey: options.secretAccessKey,
});
docClient.query(options.params, onQuery);
}

})
}
});
};
2 changes: 1 addition & 1 deletion postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ module.exports = {
tailwindcss: {},
autoprefixer: {},
},
}
};
Loading

0 comments on commit ce6fbb8

Please sign in to comment.