Merge changes to dev branch. (#100)

pull/101/head
Skyler 3 years ago committed by GitHub
commit 5ff6224c49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1 +1,3 @@
use flake
nix_direnv_watch_file flake.nix
use flake --impure
dotenv .env

@ -21,10 +21,10 @@ jobs:
- uses: cachix/install-nix-action@v19
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- run: nix develop --command pnpm install --frozen-lockfile
- run: nix develop .#pure --command pnpm install --frozen-lockfile
- name: Show versions
run: nix develop --command pnpm run versions
run: nix develop .#pure --command pnpm run versions
- name: Compile
run: nix develop --command pnpm run build build
run: nix develop .#pure --command pnpm run build build
- name: Run prettier and eslint
run: nix develop --command pnpm run lint-ci
run: nix develop .#pure --command pnpm run lint-ci

138
.gitignore vendored

@ -1,14 +1,8 @@
dist/
.history/
node_modules/
src/config/*
!src/config/*.d.ts
!src/config/format.ts
!src/config/default.ts
!src/config/emojis.ts
src/utils/migration/data
src/config/main.ts
.vscode/
.vim/
yarn-error.log
@ -21,3 +15,135 @@ ClicksMigratingProblems/oldData/
ClicksMigratingProblems/oldData copy/
.direnv/
.devenv/
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
.cache
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

2
.gitmodules vendored

@ -1,4 +1,4 @@
[submodule "src/reflex/nsfwjs"]
path = src/reflex/nsfwjs
url = https://github.com/infinitered/nsfwjs
url = https://github.com/clicksminuteper/nsfwjs
shallow = true

@ -21,4 +21,5 @@ ClicksMigratingProblems/oldData/
ClicksMigratingProblems/oldData copy/
.direnv/
.devenv/
src/reflex/nsfwjs/**/*

@ -29,7 +29,6 @@ Alternatively, you can run `Installer.js` to generate it for you.
```json
{
"token": "your-token-here",
"developmentToken": "dev-token-here",
"managementGuildID": "your-management-guild-id-here",
"developmentGuildID": "your-development-guild-id-here",
"enableDevelopment": true,

@ -0,0 +1 @@
allowUnfree: true

@ -12,15 +12,15 @@
"locked": {
"lastModified": 1686252801,
"narHash": "sha256-ASguQr5onfE7HzawjAvhck2y7NDZ3bdhqFC8O3/XrXU=",
"owner": "clicksminuteper",
"repo": "nixfiles",
"ref": "refs/heads/production",
"rev": "7f3559f9a56d28b8f5352040f18305082a6dacc0",
"type": "github"
"revCount": 53,
"type": "git",
"url": "ssh://git@github.com/clicksminuteper/nixfiles"
},
"original": {
"owner": "clicksminuteper",
"repo": "nixfiles",
"type": "github"
"type": "git",
"url": "ssh://git@github.com/clicksminuteper/nixfiles"
}
},
"deploy-rs": {
@ -43,6 +43,27 @@
"type": "github"
}
},
"devenv": {
"inputs": {
"flake-compat": "flake-compat_2",
"nix": "nix",
"nixpkgs": "nixpkgs_3",
"pre-commit-hooks": "pre-commit-hooks"
},
"locked": {
"lastModified": 1686642933,
"narHash": "sha256-5Z4uitx27QtZIrG9sOSJlZRNcVQn/TI36nj7o70n5Dw=",
"owner": "cachix",
"repo": "devenv",
"rev": "f5278b5d56e39f86a299a2e1889906933a26f762",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
@ -59,6 +80,22 @@
"type": "github"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
@ -78,6 +115,21 @@
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"inputs": {
"systems": "systems_2"
},
@ -95,7 +147,7 @@
"type": "github"
}
},
"flake-utils_3": {
"flake-utils_4": {
"inputs": {
"systems": "systems_3"
},
@ -113,6 +165,28 @@
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"devenv",
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@ -135,6 +209,46 @@
"type": "github"
}
},
"lowdown-src": {
"flake": false,
"locked": {
"lastModified": 1633514407,
"narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=",
"owner": "kristapsdz",
"repo": "lowdown",
"rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8",
"type": "github"
},
"original": {
"owner": "kristapsdz",
"repo": "lowdown",
"type": "github"
}
},
"nix": {
"inputs": {
"lowdown-src": "lowdown-src",
"nixpkgs": [
"devenv",
"nixpkgs"
],
"nixpkgs-regression": "nixpkgs-regression"
},
"locked": {
"lastModified": 1676545802,
"narHash": "sha256-EK4rZ+Hd5hsvXnzSzk2ikhStJnD63odF7SzsQ8CuSPU=",
"owner": "domenkozar",
"repo": "nix",
"rev": "7c91803598ffbcfe4a55c44ac6d49b2cf07a527f",
"type": "github"
},
"original": {
"owner": "domenkozar",
"ref": "relaxed-flakes",
"repo": "nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1671417167,
@ -151,6 +265,22 @@
"type": "github"
}
},
"nixpkgs-regression": {
"locked": {
"lastModified": 1643052045,
"narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1685758009,
@ -167,6 +297,22 @@
"type": "github"
}
},
"nixpkgs-stable_2": {
"locked": {
"lastModified": 1678872516,
"narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-22.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1686059680,
@ -183,31 +329,76 @@
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1678875422,
"narHash": "sha256-T3o6NcQPwXjxJMn2shz86Chch4ljXgZn746c2caGxd8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "126f49a01de5b7e35a43fd43f891ecf6d3a51459",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"pnpm2nix": {
"inputs": {
"flake-utils": "flake-utils_3",
"flake-utils": "flake-utils_4",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1686173255,
"narHash": "sha256-G9HiMDCnK+YeIb+lpLxsRg+/Kk2pz/PSlEtFe8Yi138=",
"owner": "clicksminuteper",
"repo": "pnpm2nix",
"rev": "f91bc86c6d2b1c2c3c4f476835b5ec01b750e898",
"lastModified": 1686323589,
"narHash": "sha256-XADn6eWl3670Oj38p0GiN1PaPKvTmDQRQErGLXYjZQU=",
"ref": "refs/heads/master",
"rev": "aa1dc4ff5759f04cc383a5b38a163b3a7b6ac601",
"revCount": 102,
"type": "git",
"url": "ssh://git@github.com/clicksminuteper/pnpm2nix"
},
"original": {
"type": "git",
"url": "ssh://git@github.com/clicksminuteper/pnpm2nix"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": [
"devenv",
"flake-compat"
],
"flake-utils": "flake-utils_2",
"gitignore": "gitignore",
"nixpkgs": [
"devenv",
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable_2"
},
"locked": {
"lastModified": 1686050334,
"narHash": "sha256-R0mczWjDzBpIvM3XXhO908X5e2CQqjyh/gFbwZk/7/Q=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "6881eb2ae5d8a3516e34714e7a90d9d95914c4dc",
"type": "github"
},
"original": {
"owner": "clicksminuteper",
"repo": "pnpm2nix",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"clicks-server": "clicks-server",
"flake-utils": "flake-utils_2",
"devenv": "devenv",
"flake-utils": "flake-utils_3",
"nixpkgs": [
"clicks-server",
"nixpkgs"

@ -2,70 +2,169 @@
description = "A basic flake with a shell";
inputs.nixpkgs.follows = "clicks-server/nixpkgs";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.clicks-server.url = "github:clicksminuteper/nixfiles";
inputs.pnpm2nix.url = "github:clicksminuteper/pnpm2nix";
inputs.clicks-server.url = "git+ssh://git@github.com/clicksminuteper/nixfiles";
inputs.pnpm2nix.url = "git+ssh://git@github.com/clicksminuteper/pnpm2nix";
inputs.devenv.url = "github:cachix/devenv";
inputs.pnpm2nix.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, flake-utils, clicks-server, pnpm2nix }:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
nodejs = pkgs.nodejs_20;
nodePackages = pkgs.nodePackages_latest;
lib = pkgs.lib;
in rec {
devShells.default = pkgs.mkShell {
packages = [ nodejs nodePackages.pnpm pkgs.pkg-config pkgs.fontconfig.dev ];
shellHook = ''
unset name
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${lib.makeSearchPath "/lib/pkgconfig" [
pkgs.pixman
pkgs.cairo.dev
pkgs.libpng.dev
pkgs.gnome2.pango.dev
pkgs.glib.dev
pkgs.harfbuzz.dev
pkgs.freetype.dev
]}
'';
};
packages.env = lib.pipe {
src = ./.;
} [
(pnpm2nix.mkPnpmPackage.${system})
(pnpm2nix.mkPnpmEnv.${system})
];
packages.default = let
packageJSON = (builtins.fromJSON (builtins.readFile ./package.json));
in pkgs.stdenv.mkDerivation {
pname = "nucleus";
version = packageJSON.version;
src = ./.;
buildInputs = [ packages.env nodejs nodePackages.pnpm ];
nativeBuildInputs = [ packages.env nodePackages.pnpm ];
buildPhase = ''
pnpm run build
'';
installPhase = ''
cp dist $out
mkdir -p $out/bin
echo "#!/usr/bin/env bash\ncd $out\n${packageJSON.scripts.start}" > $out/bin/nucleus
'';
};
dockerImage = let
nucleus = packages.default;
in pkgs.dockerTools.streamLayeredImage {
name = "nucleus";
tag = "latest";
contents = [ nucleus ];
config.Cmd = [ "${nucleus}/bin/nucleus" ];
};
});
}
outputs = { self, devenv, nixpkgs, flake-utils, clicks-server, pnpm2nix, ... }@inputs:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
nodejs = pkgs.nodejs_20;
nodePackages = pkgs.nodePackages_latest;
lib = pkgs.lib;
shellPackages = [ nodejs nodePackages.pnpm pkgs.pkg-config pkgs.fontconfig.dev pkgs.clamav ];
enterShellHook = ''
unset name
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${lib.makeSearchPath "/lib/pkgconfig" [
pkgs.pixman
pkgs.cairo.dev
pkgs.libpng.dev
pkgs.gnome2.pango.dev
pkgs.glib.dev
pkgs.harfbuzz.dev
pkgs.freetype.dev
]}
'';
in
rec {
devShells.pure = pkgs.mkShell {
packages = shellPackages;
shellHook = enterShellHook;
};
devShells.default = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
({ pkgs, config, ... }: {
# This is your devenv configuration
packages = shellPackages;
enterShell = enterShellHook;
services.mongodb = {
enable = true;
package = pkgs.mongodb-6_0;
additionalArgs = [
"--port"
"27017"
"--noauth"
];
};
processes.clamav.exec =
let
clamd_config = pkgs.writeText "clamd.conf" ''
TCPSocket 3310
PidFile /tmp/clamav-nucleus.pid
DatabaseDirectory ${config.env.DEVENV_STATE}/clamav/db
TemporaryDirectory /tmp
Foreground true
'';
freshclam_config = pkgs.writeText "freshclam.conf" ''
DatabaseDirectory ${config.env.DEVENV_STATE}/clamav/db
DatabaseMirror database.clamav.net
'';
in
"mkdir -p $DEVENV_STATE/clamav/db && ${pkgs.clamav}/bin/freshclam --config ${freshclam_config} || true; ${pkgs.clamav}/bin/clamd -c ${clamd_config}";
})
];
};
}) // {
packages.x86_64-linux =
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
nodejs = pkgs.nodejs_20;
nodePackages = pkgs.nodePackages_latest;
lib = pkgs.lib;
in
rec {
nucleus =
let
packageJSON = (builtins.fromJSON (builtins.readFile ./package.json));
node_modules = lib.pipe
{
src = ./.;
linkDevDependencies = true;
overrides = pnpm2nix.defaultPnpmOverrides.x86_64-linux // {
canvas = (drv: drv.overrideAttrs (oldAttrs: {
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ pkgs.pkg-config ];
buildInputs = oldAttrs.buildInputs ++ [
pkgs.pixman
pkgs.cairo.dev
pkgs.libpng.dev
pkgs.gnome2.pango.dev
pkgs.glib.dev
pkgs.harfbuzz.dev
pkgs.freetype.dev
];
}));
"@tensorflow/tfjs-node" = (drv: drv.overrideAttrs (oldAttrs: {
buildInputs = oldAttrs.buildInputs ++ [
pkgs.libtensorflow
];
preBuild = ''
mkdir -p node_modules/@tensorflow/tfjs-node/deps/lib
ln -s ${pkgs.libtensorflow}/lib/libtensorflow.so.2 node_modules/@tensorflow/tfjs-node/deps/lib/libtensorflow.so.2.9.1
'';
}));
};
} [
(pnpm2nix.mkPnpmPackage.x86_64-linux)
(drv: builtins.readFile "${drv}/nix-support/propagated-build-inputs")
(path: "${path}/node_modules")
];
in
pkgs.stdenv.mkDerivation {
pname = "nucleus";
version = packageJSON.version;
src = ./.;
buildInputs = [ nodejs nodePackages.pnpm ];
nativeBuildInputs = [ nodePackages.pnpm nodePackages.typescript pkgs.python3 ];
buildPhase = ''
${pkgs.python3}/bin/python3 ${./scripts/fix-pnpm-bin.py} ${node_modules} ./bin
export PATH=$PATH:./bin
ln -s ${node_modules} node_modules
pnpm run build
'';
installPhase = ''
mkdir -p $out
cp dist $out -r
cp node_modules $out -r
cp bin $out/.bin -r
cp package.json $out
cp LICENSE $out
mkdir -p $out/bin
echo "#!/usr/bin/env bash" > $out/bin/nucleus
echo "cd $out" >> $out/bin/nucleus
echo "export PATH=$PATH:$out/node_modules/.bin" >> $out/bin/nucleus
echo "${packageJSON.scripts.start}" >> $out/bin/nucleus
chmod +x $out/bin/nucleus
'';
};
dockerImage = pkgs.dockerTools.streamLayeredImage {
name = "nucleus";
tag = "latest";
contents = [ nucleus ];
config.Cmd = [ "${nucleus}/bin/nucleus" ];
};
default = nucleus;
};
};
}

@ -0,0 +1,3 @@
builds:
exclude:
- devShells.x86_64-linux.default

@ -1,5 +1,6 @@
{
"dependencies": {
"@clicks/nsfwjs": "^3.0.3",
"@hokify/agenda": "^6.3.0",
"@octokit/graphql": "^5.0.6",
"@tensorflow/tfjs": "^4.7.0",
@ -12,6 +13,7 @@
"clamscan": "^2.1.2",
"diff": "^5.1.0",
"discord.js": "^14.11.0",
"dotenv": "^16.1.4",
"eslint": "^8.42.0",
"express": "^4.18.2",
"fuse.js": "^6.6.2",
@ -22,12 +24,16 @@
"mongodb": "^5.6.0",
"node-fetch": "^3.3.1",
"node-tesseract-ocr": "^2.2.1",
"@clicks/nsfwjs": "^3.0.2",
"octokit": "^2.0.19",
"seedrandom": "^3.0.5",
"structured-clone": "^0.2.2",
"systeminformation": "^5.18.2"
},
"pnpm": {
"overrides": {
"@hokify/agenda>mongodb": "$mongodb"
}
},
"name": "nucleus",
"version": "1.1.0",
"description": "Nucleus: The core of your server",
@ -35,7 +41,7 @@
"scripts": {
"build": "tsc && pnpm copy-files",
"copy-files": "copyfiles -u 1 src/reflex/nsfwjs/example/nsfw_demo/public/model/**/* dist/",
"start": "node --experimental-json-modules --enable-source-maps dist/index.js",
"start": "node --experimental-json-modules --enable-source-maps -r dotenv/config dist/index.js",
"dev": "rm -rf dist && eslint src --fix && pnpm build && node --experimental-json-modules --enable-source-maps dist/index.js",
"force-dev": "clear; rm -rf dist; tsc-suppress && pnpm copy-files && node --experimental-json-modules --enable-source-maps dist/index.js",
"lint": "echo 'Style checking...'; prettier --check .; echo 'Linting...'; eslint src; echo 'To auto-fix everything possible, please run `pnpm lint-fix`'; true",
@ -46,7 +52,7 @@
"setup": "npm i -g pnpm | pnpm | pnpm build | node Installer.js",
"win-force-build": "clear | rm -r dist | tsc-suppress | pnpm copy-files",
"audit-fix": "pnpm audit --fix",
"versions": "pnpm versions && pnpm list && node --version",
"versions": "pnpm --version && pnpm list && node --version",
"win-lint-fix": "echo 'Fixing eslint issues...' | eslint src --fix | echo 'Reformatting...' | prettier --write --loglevel warn --cache . | true"
},
"repository": {
@ -79,7 +85,6 @@
"prettier": "^2.8.8",
"prettier-eslint": "^15.0.1",
"tsc-suppress": "^1.0.7",
"typescript": "^5.1.3",
"yarn-audit-fix": "^9.3.10"
"typescript": "^5.1.3"
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1 @@
/nix/store/fmvzckvxnqrfbgv0mvzghgi87602pgcm-nucleus-1.1.0

@ -0,0 +1,50 @@
import sys
import os
import json
node_modules = sys.argv[1]
bin_dir = sys.argv[2]
def collect_packages_in(_node_modules, packages: set[str] | None = None):
_packages: set[str] = packages or set()
for path in os.listdir(_node_modules):
if not os.path.isdir(os.path.join(_node_modules, path)) or os.path.join(_node_modules, path) in _packages:
continue
_packages.add(os.path.join(_node_modules, path))
if os.path.exists(os.path.join(_node_modules, path, "node_modules")):
collect_packages_in(os.path.join(_node_modules, path, "node_modules"), _packages)
return _packages
def get_binaries_in(package):
package_json = os.path.join(package, "package.json")
if not os.path.exists(package_json):
return []
with open(package_json) as f:
package_json_contents = json.load(f)
if "bin" not in package_json_contents:
return []
if type(package_json_contents["bin"]) == str:
return [[os.path.basename(package_json_contents["name"]), os.path.join(package, package_json_contents["bin"])]]
return [[name, os.path.join(package, bin)] for name, bin in package_json_contents["bin"].items()]
def main():
packages = collect_packages_in(node_modules)
binaries = []
for package in packages:
binaries += get_binaries_in(package)
os.makedirs(bin_dir, exist_ok=True)
for binary in binaries:
if os.path.exists(os.path.join(bin_dir, binary[0])):
os.remove(os.path.join(bin_dir, binary[0]))
os.symlink(os.path.realpath(binary[1]), os.path.join(bin_dir, binary[0]))
if __name__ == "__main__":
main()

@ -2,7 +2,6 @@ import fs from "fs";
import * as readLine from "node:readline/promises";
const defaultDict: Record<string, string | string[] | boolean | Record<string, string | number | undefined>> = {
developmentToken: "Your development bot token (Used for testing in one server, rather than production)",
developmentGuildID: "Your development guild ID",
enableDevelopment: true,
token: "Your bot token",
@ -78,7 +77,7 @@ export default async function (walkthrough = false) {
}
if (Object.keys(json).length) {
if (json["token"] === defaultDict["token"] || json["developmentToken"] === defaultDict["developmentToken"]) {
if (json["token"] === defaultDict["token"]) {
console.log("\x1b[31m⚠ No main.ts found, creating one.");
console.log(
" \x1b[2mYou can edit src/config/main.ts directly using template written to the file.\x1b[0m\n"

@ -1,30 +0,0 @@
declare const config: {
developmentToken: string;
developmentGuildID: string;
enableDevelopment: boolean;
token: string;
managementGuildID: string;
owners: string[];
commandsFolder: string;
eventsFolder: string;
messageContextFolder: string;
userContextFolder: string;
verifySecret: string;
mongoOptions: {
username: string;
password: string;
database: string;
host: string;
authSource: string;
};
baseUrl: string;
clamav: {
socket?: string;
host?: string;
port?: number;
};
githubPAT: string;
suggestionChannel: string;
};
export default config;

@ -0,0 +1,56 @@
interface config {
developmentGuildID: string;
enableDevelopment: boolean;
token: string;
managementGuildID: string;
owners: string[];
commandsFolder: string;
eventsFolder: string;
messageContextFolder: string;
userContextFolder: string;
verifySecret: string;
mongoOptions: {
username: string;
password: string;
database: string;
host: string;
authSource: string;
};
baseUrl: string;
clamav: {
socket?: string;
host?: string;
port?: number;
};
githubPAT: string;
suggestionChannel: string;
};
export default {
"token": process.env["TOKEN"]!,
"managementGuildID": process.env["MANAGEMENT_GUILD_ID"]!,
"developmentGuildID": process.env["DEV_GUILD_ID"]!,
"enableDevelopment": process.env["ENABLE_DEV"] === "true",
"owners": process.env["OWNERS"]?.split(","),
"commandsFolder": process.env["COMMANDS_FOLDER"] ?? "dist/commands",
"eventsFolder": process.env["EVENTS_FOLDER"] ?? "dist/events",
"messageContextFolder": process.env["MESSAGE_CONTEXT_FOLDER"] ?? "dist/context/messages",
"userContextFolder": process.env["USER_CONTEXT_FOLDER"] ?? "dist/context/users",
"verifySecret": process.env["VERIFY_SECRET"]!,
"mongoOptions": {
"username": process.env["MONGO_USERNAME"]!,
"password": process.env["MONGO_PASSWORD"]!,
"host": process.env["MONGO_HOST"]!,
"database": process.env["MONGO_DATABASE"]!,
"authSource": process.env["MONGO_AUTH_SOURCE"]!,
},
"baseUrl": process.env["BASE_URL"]!,
"clamav": {
"host": process.env["CLAMAV_HOST"]!,
"port": parseInt(process.env["CLAMAV_PORT"] ?? "3310")
},
"githubPAT": process.env["GITHUB_PAT"]!,
"suggestionChannel": process.env["SUGGESTION_CHANNEL"]!,
} as config;

@ -18,6 +18,9 @@ const channelTypeEmoji: Record<number, string> = {
99: "Rules" // Rules channel
};
// this eslint rule is invalid here, as the type definition is actually incorrect
// if you make it an interface due to the [key: string]: unknown line. Try it if you like :)
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type channelChanges = {
channelId: ReturnType<typeof entry>;
channel: ReturnType<typeof entry>;
@ -38,7 +41,7 @@ type channelChanges = {
maxUsers?: ReturnType<typeof entry>;
autoArchiveDuration?: ReturnType<typeof entry>;
[key: string]: unknown;
}
};
export const event = "channelUpdate";

@ -26,6 +26,6 @@ process.on("uncaughtException", (err) => {
console.error(err);
});
await client.login(config.enableDevelopment ? config.developmentToken : config.token);
await client.login(config.token);
await recordPerformance();

@ -0,0 +1 @@
Subproject commit 9b0e45c13996b1b6bc96a3af3d3c4b67ad4e971f

@ -5,7 +5,7 @@ import Tesseract from "node-tesseract-ocr";
import type Discord from "discord.js";
import client from "../utils/client.js";
import { createHash } from "crypto";
import * as nsfwjs from "nsfwjs";
import * as nsfwjs from "@clicks/nsfwjs";
import ClamScan from "clamscan";
import * as tf from "@tensorflow/tfjs-node";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";

@ -471,6 +471,7 @@ export class Transcript {
obj.style = child.style;
obj.label = child.label ?? "";
} else if (child.type > 2) {
// FIXME: Can we write this more clearly to make it obvious what we mean by 2 here?
obj.placeholder = child.placeholder ?? "";
}
return obj;

@ -18,7 +18,7 @@ function getEmojiPaths(obj: EmojisIndex, path: string[] = []) {
}
getEmojiPaths(emojis);
function getEmojiByName(name: typeof EMOJIPATHS[number], format?: string): string {
function getEmojiByName(name: (typeof EMOJIPATHS)[number], format?: string): string {
const parts = name.split(".");
let id: string | EmojisIndex | EmojisIndex[] | undefined = emojis;
for (const part of parts) {

Loading…
Cancel
Save