feat: start doing discord git feed
This commit is contained in:
parent
5edd2aba47
commit
e0b87a1298
10 changed files with 301 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,5 +2,6 @@
|
|||
*.temp
|
||||
*node_modules/
|
||||
*types/
|
||||
*build/
|
||||
**/ags/style.css
|
||||
result*
|
||||
|
|
|
@ -11,6 +11,7 @@ autocmd Filetype ruby setlocal ts=2 sw=2 expandtab
|
|||
|
||||
" for js/coffee/jade files, 4 spaces
|
||||
autocmd Filetype javascript setlocal ts=4 sw=4 sts=0 expandtab
|
||||
autocmd Filetype typescript setlocal ts=4 sw=4 sts=0 expandtab
|
||||
autocmd Filetype java setlocal ts=4 sw=4 sts=0 expandtab
|
||||
autocmd Filetype sh setlocal ts=4 sw=4 sts=0 expandtab
|
||||
|
||||
|
|
145
common/pkgs/discord-commits/.eslintrc.json
Normal file
145
common/pkgs/discord-commits/.eslintrc.json
Normal file
|
@ -0,0 +1,145 @@
|
|||
{
|
||||
"env": {
|
||||
"es2021": true
|
||||
},
|
||||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"overrides": [],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "latest",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": ["@stylistic", "@typescript-eslint"],
|
||||
"rules": {
|
||||
"array-callback-return": ["error", {
|
||||
"allowImplicit": true,
|
||||
"checkForEach": true
|
||||
}],
|
||||
"no-constructor-return": ["error"],
|
||||
"no-unreachable-loop": ["error", { "ignore": [
|
||||
"ForInStatement", "ForOfStatement"
|
||||
]}],
|
||||
"no-use-before-define": ["error", {
|
||||
"functions": false
|
||||
}],
|
||||
|
||||
|
||||
"block-scoped-var": ["error"],
|
||||
"capitalized-comments": ["warn", "always", {
|
||||
"ignoreConsecutiveComments": true
|
||||
}],
|
||||
"class-methods-use-this": ["error"],
|
||||
"curly": ["warn"],
|
||||
"default-case-last": ["warn"],
|
||||
"default-param-last": ["error"],
|
||||
"eqeqeq": ["error", "smart"],
|
||||
"func-names": ["warn", "never"],
|
||||
"func-style": ["warn", "expression"],
|
||||
"logical-assignment-operators": ["warn", "always"],
|
||||
"no-array-constructor": ["error"],
|
||||
"no-else-return": ["error"],
|
||||
"no-empty-function": ["warn"],
|
||||
"no-empty-static-block": ["warn"],
|
||||
"no-extend-native": ["error"],
|
||||
"no-extra-bind": ["warn"],
|
||||
"no-implicit-coercion": ["warn"],
|
||||
"no-iterator": ["error"],
|
||||
"no-labels": ["error"],
|
||||
"no-lone-blocks": ["error"],
|
||||
"no-lonely-if": ["error"],
|
||||
"no-loop-func": ["error"],
|
||||
"no-magic-numbers": ["error", {
|
||||
"ignore": [-1, 0.1, 0, 1, 2, 3, 10, 33, 66, 100, 255, 360, 450, 1000],
|
||||
"ignoreDefaultValues": true
|
||||
}],
|
||||
"no-multi-assign": ["error"],
|
||||
"no-new": ["error"],
|
||||
"no-new-func": ["error"],
|
||||
"no-new-wrappers": ["error"],
|
||||
"no-object-constructor": ["error"],
|
||||
"no-proto": ["error"],
|
||||
"no-return-assign": ["error"],
|
||||
"no-sequences": ["error"],
|
||||
"no-shadow": ["error", { "builtinGlobals": true }],
|
||||
"no-undef-init": ["warn"],
|
||||
"no-undefined": ["error"],
|
||||
"no-useless-constructor": ["warn"],
|
||||
"no-useless-escape": ["off"],
|
||||
"no-useless-return": ["error"],
|
||||
"no-var": ["error"],
|
||||
"no-void": ["error"],
|
||||
"no-with": ["error"],
|
||||
"object-shorthand": ["error", "always"],
|
||||
"one-var": ["error", "never"],
|
||||
"operator-assignment": ["warn", "always"],
|
||||
"prefer-arrow-callback": ["error"],
|
||||
"prefer-const": ["error"],
|
||||
"prefer-object-has-own": ["error"],
|
||||
"prefer-regex-literals": ["error"],
|
||||
"prefer-template": ["warn"],
|
||||
|
||||
|
||||
"@stylistic/array-bracket-newline": ["warn", "consistent"],
|
||||
"@stylistic/array-bracket-spacing": ["warn", "never"],
|
||||
"@stylistic/arrow-parens": ["warn", "always"],
|
||||
"@stylistic/brace-style": ["warn", "stroustrup"],
|
||||
"@stylistic/comma-dangle": ["warn", "always-multiline"],
|
||||
"@stylistic/comma-spacing": ["warn", { "before": false, "after": true }],
|
||||
"@stylistic/comma-style": ["error", "last"],
|
||||
"@stylistic/dot-location": ["error", "property"],
|
||||
"@stylistic/function-call-argument-newline": ["warn", "consistent"],
|
||||
"@stylistic/function-paren-newline": ["warn", "consistent"],
|
||||
"@stylistic/indent": ["warn", 4, {
|
||||
"SwitchCase": 1,
|
||||
"ignoreComments": true
|
||||
}],
|
||||
"@stylistic/key-spacing": ["warn", { "beforeColon": false, "afterColon": true }],
|
||||
"@stylistic/keyword-spacing": ["warn", { "before": true }],
|
||||
"@stylistic/linebreak-style": ["error", "unix"],
|
||||
"@stylistic/lines-between-class-members": ["warn", "always", { "exceptAfterSingleLine": true }],
|
||||
"@stylistic/max-len": ["warn", {
|
||||
"code": 80,
|
||||
"ignoreComments": true,
|
||||
"ignoreTrailingComments": true,
|
||||
"ignoreUrls": true
|
||||
}],
|
||||
"@stylistic/multiline-ternary": ["warn", "always-multiline"],
|
||||
"@stylistic/new-parens": ["error"],
|
||||
"@stylistic/no-mixed-operators": ["warn"],
|
||||
"@stylistic/no-mixed-spaces-and-tabs": ["error"],
|
||||
"@stylistic/no-multi-spaces": ["error"],
|
||||
"@stylistic/no-tabs": ["error"],
|
||||
"@stylistic/no-trailing-spaces": ["error"],
|
||||
"@stylistic/no-whitespace-before-property": ["warn"],
|
||||
"@stylistic/nonblock-statement-body-position": ["error", "below"],
|
||||
"@stylistic/object-curly-newline": ["warn", { "consistent": true }],
|
||||
"@stylistic/object-curly-spacing": ["warn", "always"],
|
||||
"@stylistic/operator-linebreak": ["warn", "after"],
|
||||
"@stylistic/padded-blocks": ["error", "never"],
|
||||
"@stylistic/padding-line-between-statements": ["warn",
|
||||
{ "blankLine": "always", "prev": "*", "next": "return" },
|
||||
{ "blankLine": "always", "prev": ["const", "let", "var"], "next": "*"},
|
||||
{ "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"]},
|
||||
{ "blankLine": "always", "prev": ["case", "default"], "next": "*" }
|
||||
],
|
||||
"@stylistic/quote-props": ["error", "consistent-as-needed"],
|
||||
"@stylistic/quotes": ["error", "single", { "avoidEscape": true }],
|
||||
"@stylistic/semi": ["error", "always"],
|
||||
"@stylistic/semi-spacing": ["warn"],
|
||||
"@stylistic/space-before-blocks": ["warn"],
|
||||
"@stylistic/space-before-function-paren": ["warn", "never"],
|
||||
"@stylistic/space-infix-ops": ["warn"],
|
||||
"@stylistic/spaced-comment": ["warn", "always"],
|
||||
"@stylistic/switch-colon-spacing": ["warn"],
|
||||
"@stylistic/wrap-regex": ["warn"]
|
||||
},
|
||||
"globals": {
|
||||
"ARGV": "readonly",
|
||||
"imports": "readonly",
|
||||
"print": "readonly",
|
||||
"console": "readonly",
|
||||
"logError": "readonly",
|
||||
"setTimeout": "readonly",
|
||||
"setInterval": "readonly"
|
||||
}
|
||||
}
|
88
common/pkgs/discord-commits/commit.d.ts
vendored
Normal file
88
common/pkgs/discord-commits/commit.d.ts
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
export type Commit = {
|
||||
url: string,
|
||||
sha: string,
|
||||
created: string,
|
||||
html_url: string,
|
||||
commit: {
|
||||
url: string,
|
||||
author: {
|
||||
name: string,
|
||||
email: string,
|
||||
date: string
|
||||
},
|
||||
committer: {
|
||||
name: string,
|
||||
email: string,
|
||||
date: string
|
||||
},
|
||||
message: string,
|
||||
tree: {
|
||||
url: string,
|
||||
sha: string,
|
||||
created: string
|
||||
},
|
||||
verification: {
|
||||
verified: boolean,
|
||||
reason: string,
|
||||
signature: string,
|
||||
signer: string | null,
|
||||
payload: string
|
||||
}
|
||||
},
|
||||
author: {
|
||||
id: number,
|
||||
login: string,
|
||||
login_name: string,
|
||||
full_name: string,
|
||||
email: string,
|
||||
avatar_url: string,
|
||||
language: string,
|
||||
is_admin: boolean,
|
||||
last_login: string,
|
||||
created: string,
|
||||
restricted: boolean,
|
||||
active: boolean,
|
||||
prohibit_login: boolean,
|
||||
location: string,
|
||||
website: string,
|
||||
description: string,
|
||||
visibility: string,
|
||||
followers_count: number,
|
||||
following_count: number,
|
||||
starred_repos_count: number,
|
||||
username: string
|
||||
},
|
||||
committer: {
|
||||
id: number,
|
||||
login: string,
|
||||
login_name: string,
|
||||
full_name: string,
|
||||
email: string,
|
||||
avatar_url: string,
|
||||
language: string,
|
||||
is_admin: boolean,
|
||||
last_login: string,
|
||||
created: string,
|
||||
restricted: boolean,
|
||||
active: boolean,
|
||||
prohibit_login: boolean,
|
||||
location: string,
|
||||
website: string,
|
||||
description: string,
|
||||
visibility: string,
|
||||
followers_count: number,
|
||||
following_count: number,
|
||||
starred_repos_count: number,
|
||||
username: string
|
||||
},
|
||||
parents: Array<{
|
||||
url: string,
|
||||
sha: string,
|
||||
created: string
|
||||
}>,
|
||||
files: Array<{
|
||||
filename: string,
|
||||
status: string
|
||||
}>,
|
||||
stats: { total: number, additions: number, deletions: number }
|
||||
};
|
BIN
common/pkgs/discord-commits/flake.lock
Normal file
BIN
common/pkgs/discord-commits/flake.lock
Normal file
Binary file not shown.
BIN
common/pkgs/discord-commits/flake.nix
Normal file
BIN
common/pkgs/discord-commits/flake.nix
Normal file
Binary file not shown.
33
common/pkgs/discord-commits/index.ts
Normal file
33
common/pkgs/discord-commits/index.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
import { Commit } from 'commit'; // Custom type
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
const DATA = {
|
||||
env: {...process.env},
|
||||
webhook: process.argv[2], // get it from env?
|
||||
};
|
||||
|
||||
const allCommits = await (await fetch('https://git.nelim.org/api/v1/repos/matt1432/nixos-configs/commits')).json() as Array<Commit>;
|
||||
|
||||
const last = allCommits[0];
|
||||
|
||||
const commit = JSON.stringify({
|
||||
content: null,
|
||||
embeds: [{
|
||||
title: 'New commit containing changes to server configs:',
|
||||
description: last.commit.message,
|
||||
url: last.url,
|
||||
author: {
|
||||
name: last.author.username,
|
||||
icon_url: last.author.avatar_url,
|
||||
},
|
||||
}],
|
||||
// Diff: await (await fetch(`${last['url']}.diff`)).text()
|
||||
});
|
||||
|
||||
const post = await fetch(`${DATA.webhook}?wait=true`, {
|
||||
method: 'post',
|
||||
body: commit,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
|
||||
console.log(await post.text());
|
BIN
common/pkgs/discord-commits/package-lock.json
generated
Normal file
BIN
common/pkgs/discord-commits/package-lock.json
generated
Normal file
Binary file not shown.
15
common/pkgs/discord-commits/package.json
Normal file
15
common/pkgs/discord-commits/package.json
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@stylistic/eslint-plugin": "^1.4.0",
|
||||
"@types/node": "^20.10.5",
|
||||
"@types/node-fetch": "^2.6.9",
|
||||
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
||||
"@typescript-eslint/parser": "^6.9.1",
|
||||
"eslint": "^8.52.0",
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"node-fetch": "^3.3.2"
|
||||
}
|
||||
}
|
18
common/pkgs/discord-commits/tsconfig.json
Normal file
18
common/pkgs/discord-commits/tsconfig.json
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"lib": [
|
||||
"ES2022"
|
||||
],
|
||||
"outDir": "build",
|
||||
"strict": true,
|
||||
"moduleResolution": "node",
|
||||
"baseUrl": ".",
|
||||
"typeRoots": [
|
||||
"./node_modules/@types",
|
||||
],
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
}
|
Loading…
Reference in a new issue