get rid of semicolons
continuous-integration/drone/push Build is passing Details

Signed-off-by: Sam Therapy <sam@samtherapy.net>
This commit is contained in:
Sam Therapy 2022-10-28 16:21:31 +02:00
parent d240cd4e50
commit 6ef64eeea6
Signed by: sam
GPG Key ID: 4D8B07C18F31ACBD
4 changed files with 80 additions and 82 deletions

View File

@ -1,24 +1,24 @@
{
"env": {
"browser": true,
"es2021": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "prettier"],
"rules": {
"linebreak-style": ["error", "unix"],
"quotes": ["error", "double"],
"semi": ["error", "always"],
"prettier/prettier": ["error", { "singleQuote": false }]
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
]
"env": {
"browser": true,
"es2021": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "prettier"],
"rules": {
"linebreak-style": ["error", "unix"],
"quotes": ["error", "double"],
"semi": ["error", "never"],
"prettier/prettier": ["error", { "singleQuote": false, "semi": false }]
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
]
}

View File

@ -24,8 +24,8 @@
"scripts": {
"build": "tsc -b",
"clean": "tsc -b --clean",
"lint": "eslint --ext .ts ./src --fix && prettier --write ./src",
"lint:ci": "eslint --ext .ts,.js ./src && prettier ./src --check",
"lint": "eslint --ext .ts ./src --fix && prettier --no-semi --write ./src",
"lint:ci": "eslint --ext .ts,.js ./src && prettier --no-semi --check ./src",
"package": "pkg . -C Gzip",
"test": "echo \"No tests yet!\" && exit 0",
"token": "node ./dist/token.js",

View File

@ -1,6 +1,6 @@
import commandLineArgs from "command-line-args";
import commandLineUsage from "command-line-usage";
import { exit } from "node:process";
import commandLineArgs from "command-line-args"
import commandLineUsage from "command-line-usage"
import { exit } from "node:process"
const optionDefinitions = [
{
@ -15,8 +15,8 @@ const optionDefinitions = [
alias: "v",
description: "Print debugging output.",
},
];
const args = commandLineArgs(optionDefinitions);
]
const args = commandLineArgs(optionDefinitions)
if (args.help) {
const usage = commandLineUsage([
{
@ -32,13 +32,13 @@ if (args.help) {
content:
"Project home: {underline https://git.froth.zone/sam/js-feditoken}",
},
]);
console.log(usage);
exit(0);
])
console.log(usage)
exit(0)
}
if (args.verbose) {
console.log("Running in verbose mode.\n");
console.log("Running in verbose mode.\n")
}
export default args;
export default args

View File

@ -1,80 +1,78 @@
#!/usr/bin/env node
// Takes a user inputted fediverse instance and generates a token for the bot, and adds it to the configuration file
import generator, { detector } from "megalodon";
import generator, { detector } from "megalodon"
import readline from "node:readline";
import { writeFile } from "node:fs/promises";
import { exit, stdin, stdout } from "node:process";
import readline from "node:readline"
import { writeFile } from "node:fs/promises"
import { exit, stdin, stdout } from "node:process"
import args from "./args.js";
import args from "./args.js"
const rl = readline.createInterface({ input: stdin, output: stdout });
const rl = readline.createInterface({ input: stdin, output: stdout })
async function main() {
const instance = `https://${await question("Instance URL: https://")}`;
const instance = `https://${await question("Instance URL: https://")}`
const type = await detector(instance).catch((err) => {
console.error("This does not seem to be a valid instance!");
console.error("Supported instance types: Mastodon, Misskey, Pleroma");
if (args.verbose) console.error(err);
else console.error("Run with -v to see the full error.");
exit(1);
});
console.error("This does not seem to be a valid instance!")
console.error("Supported instance types: Mastodon, Misskey, Pleroma")
if (args.verbose) console.error(err)
else console.error("Run with -v to see the full error.")
exit(1)
})
if (args.verbose) {
console.log(`Detected ${instance} as a ${type} instance.`);
console.log(`Detected ${instance} as a ${type} instance.`)
}
const client = generator(type, instance);
const client = generator(type, instance)
console.log(
"What would you like the app name to be? (default: JS-FediToken)"
);
const appName = (await question("App Name: ")) || "JS-FediToken";
console.log("What would you like the app name to be? (default: JS-FediToken)")
const appName = (await question("App Name: ")) || "JS-FediToken"
console.log(
"What would you like the app's website to be? (default: https://git.froth.zone/Sam/js-feditoken)"
);
)
const appWebsite =
(await question("App Website: ")) ||
"https://git.froth.zone/Sam/js-feditoken";
"https://git.froth.zone/Sam/js-feditoken"
const appData = await client
.registerApp(appName, { website: appWebsite })
.catch((err: Error) => {
console.error("App registration failure!");
if (args.verbose) console.error(err);
else console.error("Run with -v to see the full error.");
exit(1);
});
console.error("App registration failure!")
if (args.verbose) console.error(err)
else console.error("Run with -v to see the full error.")
exit(1)
})
const clientId = appData.clientId;
const clientSecret = appData.clientSecret;
const clientId = appData.clientId
const clientSecret = appData.clientSecret
console.log(
"Please open this URL in your browser for the authorization code."
);
console.log(appData.url);
)
console.log(appData.url)
let code: string;
let code: string
if (type === "misskey") {
code = appData.session_token || "";
await question("Authenticate with Misskey, then hit return.");
code = appData.session_token || ""
await question("Authenticate with Misskey, then hit return.")
} else {
code = await question("Authorization Code: ");
code = await question("Authorization Code: ")
}
const tokenData = await client
.fetchAccessToken(clientId, clientSecret, code)
.catch((err: Error) => {
console.error("Access Token fetch failed.");
if (args.verbose) console.error(err);
else console.error("Run with -v to see the full error.");
exit(1);
});
console.error("Access Token fetch failed.")
if (args.verbose) console.error(err)
else console.error("Run with -v to see the full error.")
exit(1)
})
if (args.verbose) {
console.log(`Access Token: ${tokenData.accessToken}`);
console.log(`Refresh Token: ${tokenData.refreshToken}`);
console.log(`Access Token: ${tokenData.accessToken}`)
console.log(`Refresh Token: ${tokenData.refreshToken}`)
}
const config = {
@ -82,11 +80,11 @@ async function main() {
type: type,
accessToken: tokenData.accessToken,
refreshToken: tokenData.refreshToken,
};
await writeFile("./config.json", JSON.stringify(config, null, 2));
}
await writeFile("./config.json", JSON.stringify(config, null, 2))
console.log("Saved config to ./config.json");
exit(0);
console.log("Saved config to ./config.json")
exit(0)
}
/**
@ -96,8 +94,8 @@ async function main() {
*/
async function question(text: string): Promise<string> {
return new Promise((resolve) => {
rl.question(text, resolve);
});
rl.question(text, resolve)
})
}
main();
main()