mirror of
https://github.com/ApfelTeeSaft/Disky.git
synced 2026-08-26 19:23:34 +00:00
file push
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
DISCORD_TOKEN=token
|
||||
CLIENT_ID=discord_client_id
|
||||
BLUESKY_IDENTIFIER=bot_account_handle # for example apfelteesaft.com or apfelbot.bsky.social
|
||||
BLUESKY_PASSWORD=app_password # the application password, refer to documentation
|
||||
@@ -0,0 +1,2 @@
|
||||
npm install
|
||||
pause
|
||||
Generated
+2236
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "discord-bluesky-bot",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@atproto/api": "^0.13.16",
|
||||
"canvas": "^2.11.2",
|
||||
"cron": "^3.2.1",
|
||||
"discord.js": "^14.16.3",
|
||||
"dotenv": "^16.4.5",
|
||||
"sqlite": "^5.1.1",
|
||||
"sqlite3": "^5.1.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.9.0",
|
||||
"@types/sqlite3": "^3.1.11",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.6.3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { ChatInputCommandInteraction, EmbedBuilder } from 'discord.js';
|
||||
import { BskyAgent } from '@atproto/api';
|
||||
|
||||
export async function handleAnalyticsCommand(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
handle: string,
|
||||
agent: BskyAgent
|
||||
) {
|
||||
const startTime = Date.now();
|
||||
await interaction.deferReply();
|
||||
|
||||
try {
|
||||
const profile = await agent.getProfile({ actor: handle });
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor('Blue')
|
||||
.setTitle(`${profile.data.displayName} (${profile.data.handle})`)
|
||||
.setDescription(profile.data.description || 'No description available.')
|
||||
.addFields(
|
||||
{ name: 'Followers', value: `${profile.data.followersCount}`, inline: true },
|
||||
{ name: 'Follows', value: `${profile.data.followsCount}`, inline: true },
|
||||
{ name: 'Posts', value: `${profile.data.postsCount}`, inline: true }
|
||||
)
|
||||
.setThumbnail(profile.data.avatar || null)
|
||||
.setImage(profile.data.banner || null)
|
||||
.setFooter({
|
||||
text: `Action took ${Date.now() - startTime}ms | Made with <3 by ApfelTeeSaft`,
|
||||
});
|
||||
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
} catch (error) {
|
||||
await interaction.editReply('Failed to fetch analytics. Please check the handle and try again.');
|
||||
console.error('Error fetching analytics:', error);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
// deprecated, bluesky does not offer history of followers to certain dates
|
||||
import { ChatInputCommandInteraction } from 'discord.js';
|
||||
import { BskyAgent } from '@atproto/api';
|
||||
import { createCanvas } from 'canvas';
|
||||
import fs from 'fs/promises';
|
||||
import path from 'path';
|
||||
|
||||
export async function handleAnalyticsGraphCommand(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
handle: string,
|
||||
agent: BskyAgent
|
||||
) {
|
||||
await interaction.deferReply();
|
||||
|
||||
try {
|
||||
const profile = await agent.getProfile({ actor: handle });
|
||||
|
||||
const createdAtStr = profile.data.createdAt || new Date().toISOString();
|
||||
const createdAt = new Date(createdAtStr);
|
||||
const now = new Date();
|
||||
|
||||
const months: string[] = [];
|
||||
for (
|
||||
let date = new Date(createdAt);
|
||||
date <= now;
|
||||
date.setMonth(date.getMonth() + 1)
|
||||
) {
|
||||
months.push(date.toLocaleString('default', { month: 'short' }));
|
||||
}
|
||||
|
||||
// random ahh code
|
||||
const totalFollowers = profile.data.followersCount || 0;
|
||||
const followerCounts = Array(months.length).fill(0);
|
||||
if (totalFollowers > 0) {
|
||||
const growthStep = totalFollowers / (followerCounts.length - 1);
|
||||
for (let i = 1; i < followerCounts.length; i++) {
|
||||
followerCounts[i] = Math.round(growthStep * i);
|
||||
}
|
||||
}
|
||||
|
||||
const width = 800;
|
||||
const height = 400;
|
||||
const canvas = createCanvas(width, height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.fillStyle = '#f0f4fc';
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
|
||||
ctx.fillStyle = '#000';
|
||||
ctx.font = 'bold 20px Arial';
|
||||
ctx.fillText(
|
||||
`Follower Trend for ${profile.data.displayName || 'Unknown'} (@${profile.data.handle || 'Unknown'})`,
|
||||
20,
|
||||
30
|
||||
);
|
||||
|
||||
ctx.strokeStyle = '#ddd';
|
||||
ctx.lineWidth = 1;
|
||||
const gridPadding = 50;
|
||||
for (let i = gridPadding; i <= width - gridPadding; i += (width - 2 * gridPadding) / (months.length - 1)) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(i, gridPadding);
|
||||
ctx.lineTo(i, height - gridPadding);
|
||||
ctx.stroke();
|
||||
}
|
||||
for (let i = height - gridPadding; i >= gridPadding; i -= (height - 2 * gridPadding) / 10) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(gridPadding, i);
|
||||
ctx.lineTo(width - gridPadding, i);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
ctx.strokeStyle = '#000';
|
||||
ctx.lineWidth = 2;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(gridPadding, gridPadding);
|
||||
ctx.lineTo(gridPadding, height - gridPadding);
|
||||
ctx.lineTo(width - gridPadding, height - gridPadding);
|
||||
ctx.stroke();
|
||||
|
||||
ctx.fillStyle = '#000';
|
||||
ctx.font = '14px Arial';
|
||||
months.forEach((month, index) => {
|
||||
const x =
|
||||
gridPadding +
|
||||
index * ((width - 2 * gridPadding) / (months.length - 1));
|
||||
ctx.fillText(month, x - ctx.measureText(month).width / 2, height - 20);
|
||||
});
|
||||
|
||||
const maxFollowers = Math.max(...followerCounts);
|
||||
const yStep = Math.ceil(maxFollowers / 10);
|
||||
for (let i = 0; i <= 10; i++) {
|
||||
const y = height - gridPadding - i * ((height - 2 * gridPadding) / 10);
|
||||
ctx.fillText(`${i * yStep}`, 10, y + 5);
|
||||
}
|
||||
|
||||
ctx.strokeStyle = '#007bff';
|
||||
ctx.lineWidth = 2;
|
||||
ctx.beginPath();
|
||||
followerCounts.forEach((count, index) => {
|
||||
const x =
|
||||
gridPadding +
|
||||
index * ((width - 2 * gridPadding) / (months.length - 1));
|
||||
const y =
|
||||
height -
|
||||
gridPadding -
|
||||
(count / (10 * yStep)) * (height - 2 * gridPadding);
|
||||
|
||||
if (index === 0) {
|
||||
ctx.moveTo(x, y);
|
||||
} else {
|
||||
ctx.lineTo(x, y);
|
||||
}
|
||||
});
|
||||
ctx.stroke();
|
||||
|
||||
const buffer = canvas.toBuffer('image/png');
|
||||
const filePath = path.join(__dirname, 'analyticsgraph.png');
|
||||
await fs.writeFile(filePath, buffer);
|
||||
|
||||
await interaction.editReply({
|
||||
content: `Follower analytics for ${profile.data.displayName || 'Unknown'} (@${profile.data.handle || 'Unknown'}):`,
|
||||
files: [filePath],
|
||||
});
|
||||
|
||||
await fs.unlink(filePath);
|
||||
} catch (error) {
|
||||
console.error('Error generating analytics graph:', error);
|
||||
await interaction.editReply('Failed to generate analytics graph. Please try again.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// unused, got implemented into index.ts
|
||||
|
||||
const commands = [
|
||||
{
|
||||
name: 'analytics',
|
||||
description: 'Get analytics for a Bluesky profile',
|
||||
options: [
|
||||
{
|
||||
name: 'handle',
|
||||
type: 3,
|
||||
description: 'The Bluesky handle to analyze',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'analyticsgraph',
|
||||
description: 'Get a graph of follower history for a Bluesky profile',
|
||||
options: [
|
||||
{
|
||||
name: 'handle',
|
||||
type: 3,
|
||||
description: 'The Bluesky handle to analyze',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'watchbluesky',
|
||||
description: 'Start watching a Bluesky profile for new posts',
|
||||
options: [
|
||||
{
|
||||
name: 'handle',
|
||||
type: 3,
|
||||
description: 'The Bluesky handle to watch',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'unwatchbluesky',
|
||||
description: 'Stop watching a Bluesky profile for new posts',
|
||||
options: [
|
||||
{
|
||||
name: 'handle',
|
||||
type: 3,
|
||||
description: 'The Bluesky handle to unwatch',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,171 @@
|
||||
import { Client, EmbedBuilder, TextChannel } from 'discord.js';
|
||||
import { BskyAgent } from '@atproto/api';
|
||||
import sqlite3 from 'sqlite3';
|
||||
import { open, Database as SqliteDatabase } from 'sqlite';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const WATCHED_PROFILES_FILE = path.resolve('./watchedProfiles.json');
|
||||
const roleId = '1305987062847242280'; // role id from cutiecord
|
||||
|
||||
let db: SqliteDatabase<sqlite3.Database, sqlite3.Statement>;
|
||||
|
||||
async function initDatabase() {
|
||||
db = await open({
|
||||
filename: './posts.db',
|
||||
driver: sqlite3.Database,
|
||||
});
|
||||
|
||||
await db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS announced_posts (
|
||||
uri TEXT PRIMARY KEY,
|
||||
handle TEXT NOT NULL,
|
||||
createdAt TEXT NOT NULL
|
||||
)
|
||||
`);
|
||||
}
|
||||
|
||||
async function isPostAnnounced(uri: string): Promise<boolean> {
|
||||
const result = await db.get('SELECT 1 FROM announced_posts WHERE uri = ?', uri);
|
||||
return !!result;
|
||||
}
|
||||
|
||||
async function markPostAsAnnounced(uri: string, handle: string, createdAt: string) {
|
||||
await db.run(
|
||||
'INSERT INTO announced_posts (uri, handle, createdAt) VALUES (?, ?, ?)',
|
||||
uri,
|
||||
handle,
|
||||
createdAt
|
||||
);
|
||||
}
|
||||
|
||||
async function getWatchedProfiles(): Promise<Record<string, string[]>> {
|
||||
if (!fs.existsSync(WATCHED_PROFILES_FILE)) {
|
||||
fs.writeFileSync(WATCHED_PROFILES_FILE, JSON.stringify({}));
|
||||
}
|
||||
|
||||
const data = fs.readFileSync(WATCHED_PROFILES_FILE, 'utf-8');
|
||||
return JSON.parse(data);
|
||||
}
|
||||
|
||||
async function saveWatchedProfiles(watchedProfiles: Record<string, string[]>) {
|
||||
fs.writeFileSync(WATCHED_PROFILES_FILE, JSON.stringify(watchedProfiles, null, 2));
|
||||
}
|
||||
|
||||
async function processFeedItem(post: any, client: Client, handle: string, channels: string[]) {
|
||||
try {
|
||||
if (!post || !post.record || !post.author || !post.record.text || !post.uri) {
|
||||
console.warn(`Invalid feed item structure for handle: ${handle}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const postUri = post.uri;
|
||||
|
||||
if (await isPostAnnounced(postUri)) {
|
||||
console.log(`Skipping already announced post for handle: ${handle}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const postLink = `https://bsky.app/profile/${post.author.handle}/post/${post.uri.split('/').pop()}`;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: post.author.displayName || post.author.handle,
|
||||
iconURL: post.author.avatar || undefined,
|
||||
})
|
||||
.setDescription(post.record.text)
|
||||
.setTimestamp(new Date(post.record.createdAt))
|
||||
.setFooter({ text: `From ${handle}` })
|
||||
.setColor('#1DA1F2');
|
||||
|
||||
for (const channelId of channels) {
|
||||
const channel = client.channels.cache.get(channelId) as TextChannel;
|
||||
if (!channel) {
|
||||
console.warn(`Channel with ID ${channelId} not found.`);
|
||||
continue;
|
||||
}
|
||||
await channel.send({
|
||||
content: `<@&${roleId}> ${postLink}`,
|
||||
embeds: [embed],
|
||||
});
|
||||
}
|
||||
|
||||
await markPostAsAnnounced(postUri, handle, post.record.createdAt);
|
||||
} catch (error) {
|
||||
console.error(`Error processing feed item for handle: ${handle}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async function checkFeeds(client: Client, agent: BskyAgent) {
|
||||
console.log('Running scheduled check for watched profiles...');
|
||||
const watchedProfiles = await getWatchedProfiles();
|
||||
|
||||
for (const handle of Object.keys(watchedProfiles)) {
|
||||
const channels = watchedProfiles[handle];
|
||||
console.log(`Checking feed for handle: ${handle}`);
|
||||
|
||||
try {
|
||||
const response = await agent.getAuthorFeed({ actor: handle });
|
||||
|
||||
if (!response.data.feed || response.data.feed.length === 0) {
|
||||
console.log(`No posts found for handle: ${handle}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const feedItem of response.data.feed.reverse()) {
|
||||
await processFeedItem(feedItem.post, client, handle, channels);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error fetching feed for handle: ${handle}`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function startWatcher(client: Client, agent: BskyAgent) {
|
||||
await initDatabase();
|
||||
console.log('Database initialized.');
|
||||
|
||||
console.log('Running initial check for watched profiles...');
|
||||
await checkFeeds(client, agent);
|
||||
|
||||
setInterval(async () => {
|
||||
await checkFeeds(client, agent);
|
||||
}, 120000); // Check every 2 minutes
|
||||
}
|
||||
|
||||
export async function handleWatchCommand(interaction: any, handle: string) {
|
||||
const watchedProfiles = await getWatchedProfiles();
|
||||
|
||||
if (!watchedProfiles[handle]) {
|
||||
watchedProfiles[handle] = [];
|
||||
}
|
||||
|
||||
const channelId = interaction.channelId;
|
||||
|
||||
if (!watchedProfiles[handle].includes(channelId)) {
|
||||
watchedProfiles[handle].push(channelId);
|
||||
await saveWatchedProfiles(watchedProfiles);
|
||||
await interaction.reply(`Now watching posts from \`${handle}\` in this channel.`);
|
||||
} else {
|
||||
await interaction.reply(`Already watching posts from \`${handle}\` in this channel.`);
|
||||
}
|
||||
}
|
||||
|
||||
export async function handleUnwatchCommand(interaction: any, handle: string) {
|
||||
const watchedProfiles = await getWatchedProfiles();
|
||||
|
||||
if (watchedProfiles[handle]) {
|
||||
const channelId = interaction.channelId;
|
||||
|
||||
watchedProfiles[handle] = watchedProfiles[handle].filter((id) => id !== channelId);
|
||||
|
||||
if (watchedProfiles[handle].length === 0) {
|
||||
delete watchedProfiles[handle];
|
||||
}
|
||||
|
||||
await saveWatchedProfiles(watchedProfiles);
|
||||
await interaction.reply(`Stopped watching posts from \`${handle}\` in this channel.`);
|
||||
} else {
|
||||
await interaction.reply(`No active watch for \`${handle}\` in this channel.`);
|
||||
}
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
import { Client, GatewayIntentBits, REST, Routes } from 'discord.js';
|
||||
import dotenv from 'dotenv';
|
||||
import { BskyAgent } from '@atproto/api';
|
||||
import { handleAnalyticsCommand } from './commands/analytics';
|
||||
import { handleWatchCommand, handleUnwatchCommand, startWatcher } from './commands/watcher';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const TOKEN = process.env.DISCORD_TOKEN!;
|
||||
const CLIENT_ID = process.env.CLIENT_ID!;
|
||||
const agent = new BskyAgent({ service: 'https://bsky.social' });
|
||||
|
||||
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
|
||||
|
||||
const commands = [
|
||||
{
|
||||
name: 'analytics',
|
||||
description: 'Get analytics for a Bluesky profile',
|
||||
options: [
|
||||
{
|
||||
name: 'handle',
|
||||
type: 3,
|
||||
description: 'The Bluesky handle to analyze',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'watchbluesky',
|
||||
description: 'Start watching a Bluesky profile for new posts',
|
||||
options: [
|
||||
{
|
||||
name: 'handle',
|
||||
type: 3,
|
||||
description: 'The Bluesky handle to watch',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'unwatchbluesky',
|
||||
description: 'Stop watching a Bluesky profile for new posts',
|
||||
options: [
|
||||
{
|
||||
name: 'handle',
|
||||
type: 3,
|
||||
description: 'The Bluesky handle to unwatch',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
async function registerCommands() {
|
||||
const rest = new REST({ version: '10' }).setToken(TOKEN);
|
||||
|
||||
try {
|
||||
console.log('Registering application commands...');
|
||||
await rest.put(Routes.applicationCommands(CLIENT_ID), { body: commands });
|
||||
console.log('Application commands registered successfully.');
|
||||
} catch (error) {
|
||||
console.error('Error registering application commands:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function authenticateBluesky() {
|
||||
const identifier = process.env.BLUESKY_IDENTIFIER!;
|
||||
const password = process.env.BLUESKY_PASSWORD!;
|
||||
|
||||
if (!identifier || !password) {
|
||||
console.error('Bluesky credentials are not properly configured in the environment variables.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
await agent.login({ identifier, password });
|
||||
console.log('Successfully authenticated with Bluesky!');
|
||||
} catch (error) {
|
||||
console.error('Failed to authenticate with Bluesky:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
client.once('ready', async () => {
|
||||
console.log(`Logged in as ${client.user?.tag}!`);
|
||||
await registerCommands();
|
||||
await authenticateBluesky();
|
||||
startWatcher(client, agent);
|
||||
});
|
||||
|
||||
client.on('interactionCreate', async (interaction) => {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
const { commandName, options } = interaction;
|
||||
|
||||
if (commandName === 'analytics') {
|
||||
const handle = options.getString('handle', true);
|
||||
await handleAnalyticsCommand(interaction, handle, agent);
|
||||
}
|
||||
|
||||
if (commandName === 'watchbluesky') {
|
||||
const handle = options.getString('handle', true);
|
||||
try {
|
||||
await handleWatchCommand(interaction, handle);
|
||||
} catch (error) {
|
||||
console.error('Error handling watchbluesky command:', error);
|
||||
await interaction.reply('Failed to watch Bluesky handle. Please try again later.');
|
||||
}
|
||||
}
|
||||
|
||||
if (commandName === 'unwatchbluesky') {
|
||||
const handle = options.getString('handle', true);
|
||||
try {
|
||||
await handleUnwatchCommand(interaction, handle);
|
||||
} catch (error) {
|
||||
console.error('Error handling unwatchbluesky command:', error);
|
||||
await interaction.reply('Failed to unwatch Bluesky handle. Please try again later.');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
client.login(TOKEN);
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Visit https://aka.ms/tsconfig to read more about this file */
|
||||
|
||||
/* Projects */
|
||||
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
||||
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
||||
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
||||
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
||||
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
||||
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
||||
|
||||
/* Language and Environment */
|
||||
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
||||
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
||||
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
||||
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
||||
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
||||
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
||||
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
||||
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
||||
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
||||
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
||||
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
||||
|
||||
/* Modules */
|
||||
"module": "commonjs", /* Specify what module code is generated. */
|
||||
// "rootDir": "./", /* Specify the root folder within your source files. */
|
||||
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
||||
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
||||
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
||||
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
||||
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
||||
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
||||
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
||||
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
||||
// "noUncheckedSideEffectImports": true, /* Check side effect imports. */
|
||||
// "resolveJsonModule": true, /* Enable importing .json files. */
|
||||
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
||||
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
||||
|
||||
/* JavaScript Support */
|
||||
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
||||
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
||||
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
||||
|
||||
/* Emit */
|
||||
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
||||
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
||||
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
||||
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
||||
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
||||
// "noEmit": true, /* Disable emitting files from a compilation. */
|
||||
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
||||
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
||||
// "removeComments": true, /* Disable emitting comments. */
|
||||
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
||||
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
||||
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
||||
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
||||
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
||||
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
||||
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
||||
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
||||
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
||||
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
||||
|
||||
/* Interop Constraints */
|
||||
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
||||
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
||||
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
||||
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
||||
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
||||
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
||||
|
||||
/* Type Checking */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
||||
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
||||
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
||||
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
||||
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
|
||||
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
||||
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
||||
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
||||
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
||||
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
||||
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
||||
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
||||
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
||||
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
||||
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
||||
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
||||
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
||||
|
||||
/* Completeness */
|
||||
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user