Merge branch 'experimental' into develop

This commit is contained in:
Siwoo Jeon 2024-10-09 11:49:32 +09:00
commit dceac4b653
Signed by: migan
GPG key ID: 036E9A8C5E8E48DA
49 changed files with 1735 additions and 6090 deletions

View file

@ -1,7 +0,0 @@
{
"recommendations": [
"arcanis.vscode-zipfs",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}

10
.vscode/settings.json vendored
View file

@ -1,10 +0,0 @@
{
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true
},
"eslint.nodePath": ".yarn/sdks",
"prettier.prettierPath": ".yarn/sdks/prettier/index.cjs",
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}

File diff suppressed because one or more lines are too long

View file

@ -1,32 +0,0 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require eslint/bin/eslint.js
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;
// Defer to the real eslint/bin/eslint.js your application uses
module.exports = wrapWithUserWrapper(absRequire(`eslint/bin/eslint.js`));

View file

@ -1,32 +0,0 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require eslint
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;
// Defer to the real eslint your application uses
module.exports = wrapWithUserWrapper(absRequire(`eslint`));

View file

@ -1,32 +0,0 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require eslint
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;
// Defer to the real eslint your application uses
module.exports = wrapWithUserWrapper(absRequire(`eslint`));

View file

@ -1,32 +0,0 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require eslint/rules
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;
// Defer to the real eslint/rules your application uses
module.exports = wrapWithUserWrapper(absRequire(`eslint/rules`));

View file

@ -1,32 +0,0 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require eslint/universal
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;
// Defer to the real eslint/universal your application uses
module.exports = wrapWithUserWrapper(absRequire(`eslint/universal`));

View file

@ -1,32 +0,0 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require eslint/use-at-your-own-risk
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;
// Defer to the real eslint/use-at-your-own-risk your application uses
module.exports = wrapWithUserWrapper(absRequire(`eslint/use-at-your-own-risk`));

View file

@ -1,32 +0,0 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require eslint/universal
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;
// Defer to the real eslint/universal your application uses
module.exports = wrapWithUserWrapper(absRequire(`eslint/universal`));

View file

@ -1,32 +0,0 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require eslint/use-at-your-own-risk
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;
// Defer to the real eslint/use-at-your-own-risk your application uses
module.exports = wrapWithUserWrapper(absRequire(`eslint/use-at-your-own-risk`));

View file

@ -1,27 +0,0 @@
{
"name": "eslint",
"version": "9.11.0-sdk",
"main": "./lib/api.js",
"type": "commonjs",
"bin": {
"eslint": "./bin/eslint.js"
},
"exports": {
".": {
"types": "./lib/types/index.d.ts",
"default": "./lib/api.js"
},
"./package.json": "./package.json",
"./use-at-your-own-risk": {
"types": "./lib/types/use-at-your-own-risk.d.ts",
"default": "./lib/unsupported-api.js"
},
"./rules": {
"types": "./lib/types/rules/index.d.ts"
},
"./universal": {
"types": "./lib/types/universal.d.ts",
"default": "./lib/universal.js"
}
}
}

View file

@ -1,5 +0,0 @@
# This file is automatically generated by @yarnpkg/sdks.
# Manual changes might be lost!
integrations:
- vscode

View file

@ -1,32 +0,0 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require prettier/bin/prettier.cjs
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;
// Defer to the real prettier/bin/prettier.cjs your application uses
module.exports = wrapWithUserWrapper(absRequire(`prettier/bin/prettier.cjs`));

View file

@ -1,32 +0,0 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require prettier
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;
// Defer to the real prettier your application uses
module.exports = wrapWithUserWrapper(absRequire(`prettier`));

View file

@ -1,7 +0,0 @@
{
"name": "prettier",
"version": "3.3.3-sdk",
"main": "./index.cjs",
"type": "commonjs",
"bin": "./bin/prettier.cjs"
}

View file

@ -1,32 +0,0 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/bin/tsc
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;
// Defer to the real typescript/bin/tsc your application uses
module.exports = wrapWithUserWrapper(absRequire(`typescript/bin/tsc`));

View file

@ -1,32 +0,0 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/bin/tsserver
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;
// Defer to the real typescript/bin/tsserver your application uses
module.exports = wrapWithUserWrapper(absRequire(`typescript/bin/tsserver`));

View file

@ -1,32 +0,0 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/lib/tsc.js
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;
// Defer to the real typescript/lib/tsc.js your application uses
module.exports = wrapWithUserWrapper(absRequire(`typescript/lib/tsc.js`));

View file

@ -1,248 +0,0 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/lib/tsserver.js
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;
const moduleWrapper = exports => {
return wrapWithUserWrapper(moduleWrapperFn(exports));
};
const moduleWrapperFn = tsserver => {
if (!process.versions.pnp) {
return tsserver;
}
const {isAbsolute} = require(`path`);
const pnpApi = require(`pnpapi`);
const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//);
const isPortal = str => str.startsWith("portal:/");
const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`);
const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => {
return `${locator.name}@${locator.reference}`;
}));
// VSCode sends the zip paths to TS using the "zip://" prefix, that TS
// doesn't understand. This layer makes sure to remove the protocol
// before forwarding it to TS, and to add it back on all returned paths.
function toEditorPath(str) {
// We add the `zip:` prefix to both `.zip/` paths and virtual paths
if (isAbsolute(str) && !str.match(/^\^?(zip:|\/zip\/)/) && (str.match(/\.zip\//) || isVirtual(str))) {
// We also take the opportunity to turn virtual paths into physical ones;
// this makes it much easier to work with workspaces that list peer
// dependencies, since otherwise Ctrl+Click would bring us to the virtual
// file instances instead of the real ones.
//
// We only do this to modules owned by the the dependency tree roots.
// This avoids breaking the resolution when jumping inside a vendor
// with peer dep (otherwise jumping into react-dom would show resolution
// errors on react).
//
const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str;
if (resolved) {
const locator = pnpApi.findPackageLocator(resolved);
if (locator && (dependencyTreeRoots.has(`${locator.name}@${locator.reference}`) || isPortal(locator.reference))) {
str = resolved;
}
}
str = normalize(str);
if (str.match(/\.zip\//)) {
switch (hostInfo) {
// Absolute VSCode `Uri.fsPath`s need to start with a slash.
// VSCode only adds it automatically for supported schemes,
// so we have to do it manually for the `zip` scheme.
// The path needs to start with a caret otherwise VSCode doesn't handle the protocol
//
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
//
// 2021-10-08: VSCode changed the format in 1.61.
// Before | ^zip:/c:/foo/bar.zip/package.json
// After | ^/zip//c:/foo/bar.zip/package.json
//
// 2022-04-06: VSCode changed the format in 1.66.
// Before | ^/zip//c:/foo/bar.zip/package.json
// After | ^/zip/c:/foo/bar.zip/package.json
//
// 2022-05-06: VSCode changed the format in 1.68
// Before | ^/zip/c:/foo/bar.zip/package.json
// After | ^/zip//c:/foo/bar.zip/package.json
//
case `vscode <1.61`: {
str = `^zip:${str}`;
} break;
case `vscode <1.66`: {
str = `^/zip/${str}`;
} break;
case `vscode <1.68`: {
str = `^/zip${str}`;
} break;
case `vscode`: {
str = `^/zip/${str}`;
} break;
// To make "go to definition" work,
// We have to resolve the actual file system path from virtual path
// and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
case `coc-nvim`: {
str = normalize(resolved).replace(/\.zip\//, `.zip::`);
str = resolve(`zipfile:${str}`);
} break;
// Support neovim native LSP and [typescript-language-server](https://github.com/theia-ide/typescript-language-server)
// We have to resolve the actual file system path from virtual path,
// everything else is up to neovim
case `neovim`: {
str = normalize(resolved).replace(/\.zip\//, `.zip::`);
str = `zipfile://${str}`;
} break;
default: {
str = `zip:${str}`;
} break;
}
} else {
str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`);
}
}
return str;
}
function fromEditorPath(str) {
switch (hostInfo) {
case `coc-nvim`: {
str = str.replace(/\.zip::/, `.zip/`);
// The path for coc-nvim is in format of /<pwd>/zipfile:/<pwd>/.yarn/...
// So in order to convert it back, we use .* to match all the thing
// before `zipfile:`
return process.platform === `win32`
? str.replace(/^.*zipfile:\//, ``)
: str.replace(/^.*zipfile:/, ``);
} break;
case `neovim`: {
str = str.replace(/\.zip::/, `.zip/`);
// The path for neovim is in format of zipfile:///<pwd>/.yarn/...
return str.replace(/^zipfile:\/\//, ``);
} break;
case `vscode`:
default: {
return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`)
} break;
}
}
// Force enable 'allowLocalPluginLoads'
// TypeScript tries to resolve plugins using a path relative to itself
// which doesn't work when using the global cache
// https://github.com/microsoft/TypeScript/blob/1b57a0395e0bff191581c9606aab92832001de62/src/server/project.ts#L2238
// VSCode doesn't want to enable 'allowLocalPluginLoads' due to security concerns but
// TypeScript already does local loads and if this code is running the user trusts the workspace
// https://github.com/microsoft/vscode/issues/45856
const ConfiguredProject = tsserver.server.ConfiguredProject;
const {enablePluginsWithOptions: originalEnablePluginsWithOptions} = ConfiguredProject.prototype;
ConfiguredProject.prototype.enablePluginsWithOptions = function() {
this.projectService.allowLocalPluginLoads = true;
return originalEnablePluginsWithOptions.apply(this, arguments);
};
// And here is the point where we hijack the VSCode <-> TS communications
// by adding ourselves in the middle. We locate everything that looks
// like an absolute path of ours and normalize it.
const Session = tsserver.server.Session;
const {onMessage: originalOnMessage, send: originalSend} = Session.prototype;
let hostInfo = `unknown`;
Object.assign(Session.prototype, {
onMessage(/** @type {string | object} */ message) {
const isStringMessage = typeof message === 'string';
const parsedMessage = isStringMessage ? JSON.parse(message) : message;
if (
parsedMessage != null &&
typeof parsedMessage === `object` &&
parsedMessage.arguments &&
typeof parsedMessage.arguments.hostInfo === `string`
) {
hostInfo = parsedMessage.arguments.hostInfo;
if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) {
const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match(
// The RegExp from https://semver.org/ but without the caret at the start
/(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
) ?? []).map(Number)
if (major === 1) {
if (minor < 61) {
hostInfo += ` <1.61`;
} else if (minor < 66) {
hostInfo += ` <1.66`;
} else if (minor < 68) {
hostInfo += ` <1.68`;
}
}
}
}
const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => {
return typeof value === 'string' ? fromEditorPath(value) : value;
});
return originalOnMessage.call(
this,
isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON)
);
},
send(/** @type {any} */ msg) {
return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => {
return typeof value === `string` ? toEditorPath(value) : value;
})));
}
});
return tsserver;
};
const [major, minor] = absRequire(`typescript/package.json`).version.split(`.`, 2).map(value => parseInt(value, 10));
// In TypeScript@>=5.5 the tsserver uses the public TypeScript API so that needs to be patched as well.
// Ref https://github.com/microsoft/TypeScript/pull/55326
if (major > 5 || (major === 5 && minor >= 5)) {
moduleWrapper(absRequire(`typescript`));
}
// Defer to the real typescript/lib/tsserver.js your application uses
module.exports = moduleWrapper(absRequire(`typescript/lib/tsserver.js`));

View file

@ -1,248 +0,0 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/lib/tsserverlibrary.js
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;
const moduleWrapper = exports => {
return wrapWithUserWrapper(moduleWrapperFn(exports));
};
const moduleWrapperFn = tsserver => {
if (!process.versions.pnp) {
return tsserver;
}
const {isAbsolute} = require(`path`);
const pnpApi = require(`pnpapi`);
const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//);
const isPortal = str => str.startsWith("portal:/");
const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`);
const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => {
return `${locator.name}@${locator.reference}`;
}));
// VSCode sends the zip paths to TS using the "zip://" prefix, that TS
// doesn't understand. This layer makes sure to remove the protocol
// before forwarding it to TS, and to add it back on all returned paths.
function toEditorPath(str) {
// We add the `zip:` prefix to both `.zip/` paths and virtual paths
if (isAbsolute(str) && !str.match(/^\^?(zip:|\/zip\/)/) && (str.match(/\.zip\//) || isVirtual(str))) {
// We also take the opportunity to turn virtual paths into physical ones;
// this makes it much easier to work with workspaces that list peer
// dependencies, since otherwise Ctrl+Click would bring us to the virtual
// file instances instead of the real ones.
//
// We only do this to modules owned by the the dependency tree roots.
// This avoids breaking the resolution when jumping inside a vendor
// with peer dep (otherwise jumping into react-dom would show resolution
// errors on react).
//
const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str;
if (resolved) {
const locator = pnpApi.findPackageLocator(resolved);
if (locator && (dependencyTreeRoots.has(`${locator.name}@${locator.reference}`) || isPortal(locator.reference))) {
str = resolved;
}
}
str = normalize(str);
if (str.match(/\.zip\//)) {
switch (hostInfo) {
// Absolute VSCode `Uri.fsPath`s need to start with a slash.
// VSCode only adds it automatically for supported schemes,
// so we have to do it manually for the `zip` scheme.
// The path needs to start with a caret otherwise VSCode doesn't handle the protocol
//
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
//
// 2021-10-08: VSCode changed the format in 1.61.
// Before | ^zip:/c:/foo/bar.zip/package.json
// After | ^/zip//c:/foo/bar.zip/package.json
//
// 2022-04-06: VSCode changed the format in 1.66.
// Before | ^/zip//c:/foo/bar.zip/package.json
// After | ^/zip/c:/foo/bar.zip/package.json
//
// 2022-05-06: VSCode changed the format in 1.68
// Before | ^/zip/c:/foo/bar.zip/package.json
// After | ^/zip//c:/foo/bar.zip/package.json
//
case `vscode <1.61`: {
str = `^zip:${str}`;
} break;
case `vscode <1.66`: {
str = `^/zip/${str}`;
} break;
case `vscode <1.68`: {
str = `^/zip${str}`;
} break;
case `vscode`: {
str = `^/zip/${str}`;
} break;
// To make "go to definition" work,
// We have to resolve the actual file system path from virtual path
// and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
case `coc-nvim`: {
str = normalize(resolved).replace(/\.zip\//, `.zip::`);
str = resolve(`zipfile:${str}`);
} break;
// Support neovim native LSP and [typescript-language-server](https://github.com/theia-ide/typescript-language-server)
// We have to resolve the actual file system path from virtual path,
// everything else is up to neovim
case `neovim`: {
str = normalize(resolved).replace(/\.zip\//, `.zip::`);
str = `zipfile://${str}`;
} break;
default: {
str = `zip:${str}`;
} break;
}
} else {
str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`);
}
}
return str;
}
function fromEditorPath(str) {
switch (hostInfo) {
case `coc-nvim`: {
str = str.replace(/\.zip::/, `.zip/`);
// The path for coc-nvim is in format of /<pwd>/zipfile:/<pwd>/.yarn/...
// So in order to convert it back, we use .* to match all the thing
// before `zipfile:`
return process.platform === `win32`
? str.replace(/^.*zipfile:\//, ``)
: str.replace(/^.*zipfile:/, ``);
} break;
case `neovim`: {
str = str.replace(/\.zip::/, `.zip/`);
// The path for neovim is in format of zipfile:///<pwd>/.yarn/...
return str.replace(/^zipfile:\/\//, ``);
} break;
case `vscode`:
default: {
return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`)
} break;
}
}
// Force enable 'allowLocalPluginLoads'
// TypeScript tries to resolve plugins using a path relative to itself
// which doesn't work when using the global cache
// https://github.com/microsoft/TypeScript/blob/1b57a0395e0bff191581c9606aab92832001de62/src/server/project.ts#L2238
// VSCode doesn't want to enable 'allowLocalPluginLoads' due to security concerns but
// TypeScript already does local loads and if this code is running the user trusts the workspace
// https://github.com/microsoft/vscode/issues/45856
const ConfiguredProject = tsserver.server.ConfiguredProject;
const {enablePluginsWithOptions: originalEnablePluginsWithOptions} = ConfiguredProject.prototype;
ConfiguredProject.prototype.enablePluginsWithOptions = function() {
this.projectService.allowLocalPluginLoads = true;
return originalEnablePluginsWithOptions.apply(this, arguments);
};
// And here is the point where we hijack the VSCode <-> TS communications
// by adding ourselves in the middle. We locate everything that looks
// like an absolute path of ours and normalize it.
const Session = tsserver.server.Session;
const {onMessage: originalOnMessage, send: originalSend} = Session.prototype;
let hostInfo = `unknown`;
Object.assign(Session.prototype, {
onMessage(/** @type {string | object} */ message) {
const isStringMessage = typeof message === 'string';
const parsedMessage = isStringMessage ? JSON.parse(message) : message;
if (
parsedMessage != null &&
typeof parsedMessage === `object` &&
parsedMessage.arguments &&
typeof parsedMessage.arguments.hostInfo === `string`
) {
hostInfo = parsedMessage.arguments.hostInfo;
if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) {
const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match(
// The RegExp from https://semver.org/ but without the caret at the start
/(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
) ?? []).map(Number)
if (major === 1) {
if (minor < 61) {
hostInfo += ` <1.61`;
} else if (minor < 66) {
hostInfo += ` <1.66`;
} else if (minor < 68) {
hostInfo += ` <1.68`;
}
}
}
}
const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => {
return typeof value === 'string' ? fromEditorPath(value) : value;
});
return originalOnMessage.call(
this,
isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON)
);
},
send(/** @type {any} */ msg) {
return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => {
return typeof value === `string` ? toEditorPath(value) : value;
})));
}
});
return tsserver;
};
const [major, minor] = absRequire(`typescript/package.json`).version.split(`.`, 2).map(value => parseInt(value, 10));
// In TypeScript@>=5.5 the tsserver uses the public TypeScript API so that needs to be patched as well.
// Ref https://github.com/microsoft/TypeScript/pull/55326
if (major > 5 || (major === 5 && minor >= 5)) {
moduleWrapper(absRequire(`typescript`));
}
// Defer to the real typescript/lib/tsserverlibrary.js your application uses
module.exports = moduleWrapper(absRequire(`typescript/lib/tsserverlibrary.js`));

View file

@ -1,32 +0,0 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);
const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;
// Defer to the real typescript your application uses
module.exports = wrapWithUserWrapper(absRequire(`typescript`));

View file

@ -1,10 +0,0 @@
{
"name": "typescript",
"version": "5.6.2-sdk",
"main": "./lib/typescript.js",
"type": "commonjs",
"bin": {
"tsc": "./bin/tsc",
"tsserver": "./bin/tsserver"
}
}

View file

@ -1 +0,0 @@
yarnPath: .yarn/releases/yarn-4.5.0.cjs

View file

@ -7,9 +7,9 @@ RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSI
RUN mkdir app RUN mkdir app
WORKDIR /app WORKDIR /app
COPY . . COPY . .
RUN yarn install RUN pnpm install
RUN yarn db:push RUN pnpm db:push
RUN yarn build RUN pnpm build
ENTRYPOINT ["./docker-entrypoint.sh"] ENTRYPOINT ["./docker-entrypoint.sh"]

View file

@ -6,13 +6,13 @@
### 종속성 ### 종속성
- 이 프로젝트는 Node.JS을 사용하고, 패키지 매니저를 Yarn Berry로 사용합니다. - 이 프로젝트는 Node.JS을 사용하고, 패키지 매니저를 PNPM을 사용합니다.
- 이 프로젝트는 MariaDB(또는 MySQL)와 Database ORM인 Prisma를 사용합니다. - 이 프로젝트는 MariaDB(또는 MySQL)와 Database ORM인 Prisma를 사용합니다.
#### 종속성 설치 #### 종속성 설치
```sh ```sh
yarn install pnpm install
``` ```
### 설정 파일 ### 설정 파일
@ -29,9 +29,9 @@ yarn install
1. 먼저 .env에 DATABASE_URL부분을 채워 줍니다. 1. 먼저 .env에 DATABASE_URL부분을 채워 줍니다.
- 예시: `mysql://username:user_password@hostname:port/database?schema=public` - 예시: `mysql://username:user_password@hostname:port/database`
2. 터미널 에서 `yarn db:push`를 합니다. 2. 터미널 에서 `pnpm db:push`를 합니다.
### 실행 ### 실행
@ -40,7 +40,7 @@ yarn install
#### 그냥 실행 (디버그용 로그 출력) #### 그냥 실행 (디버그용 로그 출력)
```sh ```sh
yarn dev pnpm dev
``` ```
#### 빌드 후 실행 #### 빌드 후 실행
@ -48,11 +48,11 @@ yarn dev
##### 빌드 ##### 빌드
```sh ```sh
yarn build pnpm build
``` ```
##### 실행 ##### 실행
```sh ```sh
yarn start pnpm start
``` ```

View file

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
dockerize -wait tcp://database:1502 -timeout 20s dockerize -wait tcp://database:1502 -timeout 20s
yarn start pnpm start

5
nodemon.json Normal file
View file

@ -0,0 +1,5 @@
{
"ext": "ts,json",
"exec": "pnpm build --sourcemap && node dist/src",
"ignore": ["dist/**/*.*"]
}

View file

@ -1,7 +1,7 @@
{ {
"name": "muffinbot", "name": "muffinbot",
"version": "4.0.0-pudding.d241006a", "version": "4.0.0-pudding.d241009a",
"main": "dist/index.js", "main": "dist/src/index.js",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@prisma/client": "^5.20.0", "@prisma/client": "^5.20.0",
@ -24,28 +24,26 @@
"@types/semver": "^7.5.8", "@types/semver": "^7.5.8",
"@typescript-eslint/eslint-plugin": "^8.7.0", "@typescript-eslint/eslint-plugin": "^8.7.0",
"@typescript-eslint/parser": "^8.7.0", "@typescript-eslint/parser": "^8.7.0",
"@yarnpkg/pnpify": "^4.1.2",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"eslint": "^9.11.1", "eslint": "^9.11.1",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1", "eslint-plugin-prettier": "^5.2.1",
"globals": "^15.9.0", "globals": "^15.9.0",
"nodemon": "^3.1.7",
"prettier": "^3.3.3", "prettier": "^3.3.3",
"prisma": "^5.20.0", "prisma": "^5.20.0",
"tsup": "^8.3.0",
"typescript": "^5.6.2" "typescript": "^5.6.2"
}, },
"scripts": { "scripts": {
"build": "tsup", "build": "tsc",
"dev": "cross-env NODE_ENV=development tsup --watch --onSuccess \"node --enable-source-maps dist\"", "dev": "cross-env NODE_ENV=development nodemon",
"start": "cross-env NODE_ENV=production node dist", "start": "cross-env NODE_ENV=production node dist/src",
"db:pull": "pnpify prisma db pull", "db:pull": "prisma db pull",
"db:push": "pnpify prisma db push", "db:push": "prisma db push",
"db:generate": "pnpify prisma generate" "db:generate": "prisma generate"
}, },
"resolutions": { "resolutions": {
"@types/ws": "^8.5.11", "@types/ws": "^8.5.11",
"ws": "8.18.0" "ws": "8.18.0"
}, }
"packageManager": "yarn@4.5.0"
} }

1679
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,5 @@
generator client { generator client {
provider = "prisma-client-js" provider = "prisma-client-js"
output = "./"
} }
datasource db { datasource db {

View file

@ -1,17 +1,12 @@
import { SapphireClient, container, LogLevel } from '@sapphire/framework' import { SapphireClient, container, LogLevel } from '@sapphire/framework'
import { GatewayIntentBits, Partials } from 'discord.js' import { GatewayIntentBits, Partials } from 'discord.js'
import { ChatBot, Config, NODE_ENV } from './modules' import { ChatBot, Config, NODE_ENV } from './modules'
import { PrismaClient } from '@prisma/client'
import { version } from '../package.json' import { version } from '../package.json'
import { PrismaClient } from '../prisma'
import semver from 'semver' import semver from 'semver'
const config = new Config() const config = new Config()
// Load pieces
import './interaction-handlers/_load'
import './listeners/_load'
import './commands/_load'
const release = version const release = version
.slice((semver.coerce(version)?.toString() + '-').length) .slice((semver.coerce(version)?.toString() + '-').length)
.split('.')[1] .split('.')[1]
@ -22,7 +17,7 @@ container.version = version
container.database = new PrismaClient() container.database = new PrismaClient()
container.dokdoAliases = ['dokdo', 'dok', 'Dokdo', 'Dok', '테스트'] container.dokdoAliases = ['dokdo', 'dok', 'Dokdo', 'Dok', '테스트']
container.chatBot = new ChatBot(container.database) container.chatBot = new ChatBot(container.database)
container.lastUpdated = new Date('2024-10-06') container.lastUpdated = new Date('2024-10-09')
container.embedColors = { container.embedColors = {
default: 0xaddb87, default: 0xaddb87,
fail: 0xff0000, fail: 0xff0000,
@ -58,7 +53,6 @@ export default class MuffinBot extends SapphireClient {
repliedUser: true, repliedUser: true,
}, },
partials: [Partials.Message, Partials.ThreadMember], partials: [Partials.Message, Partials.ThreadMember],
baseUserDirectory: null,
}) })
} }

View file

@ -1,6 +0,0 @@
import './deleteLearn'
import './information'
import './learnedData'
import './learn'
import './help'
import './list'

View file

@ -8,10 +8,9 @@ import {
Message, Message,
} from 'discord.js' } from 'discord.js'
import { import {
Args,
Command,
container,
DetailedDescriptionCommandObject, DetailedDescriptionCommandObject,
Command,
Args,
} from '@sapphire/framework' } from '@sapphire/framework'
@ApplyOptions<Command.Options>({ @ApplyOptions<Command.Options>({
@ -23,7 +22,7 @@ import {
examples: ['머핀아 삭제 머핀'], examples: ['머핀아 삭제 머핀'],
}, },
}) })
class DeleteLearnCommand extends Command { export default class DeleteLearnCommand extends Command {
public registerApplicationCommands(registry: Command.Registry) { public registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(builder => registry.registerChatInputCommand(builder =>
builder builder
@ -124,9 +123,3 @@ class DeleteLearnCommand extends Command {
await this._run(interaction) await this._run(interaction)
} }
} }
void container.stores.loadPiece({
piece: DeleteLearnCommand,
name: 'delete',
store: 'commands',
})

View file

@ -1,5 +1,5 @@
import { Args, Command, container } from '@sapphire/framework'
import { ApplyOptions } from '@sapphire/decorators' import { ApplyOptions } from '@sapphire/decorators'
import { Args, Command } from '@sapphire/framework'
import { import {
type ChatInputCommandInteraction, type ChatInputCommandInteraction,
codeBlock, codeBlock,
@ -15,7 +15,7 @@ import {
examples: ['머핀아 도움말', '머핀아 도움말 배워'], examples: ['머핀아 도움말', '머핀아 도움말 배워'],
}, },
}) })
class HelpCommand extends Command { export default class HelpCommand extends Command {
public registerApplicationCommands(registry: Command.Registry) { public registerApplicationCommands(registry: Command.Registry) {
const commands = this.container.stores.get('commands').map(command => { const commands = this.container.stores.get('commands').map(command => {
return { return {
@ -124,9 +124,3 @@ class HelpCommand extends Command {
await this._run(interaction) await this._run(interaction)
} }
} }
void container.stores.loadPiece({
piece: HelpCommand,
name: 'help',
store: 'commands',
})

View file

@ -1,6 +1,6 @@
import type { ChatInputCommandInteraction, Message } from 'discord.js' import type { ChatInputCommandInteraction, Message } from 'discord.js'
import { Command, container } from '@sapphire/framework'
import { ApplyOptions } from '@sapphire/decorators' import { ApplyOptions } from '@sapphire/decorators'
import { Command } from '@sapphire/framework'
import { platform, arch } from 'os' import { platform, arch } from 'os'
@ApplyOptions<Command.Options>({ @ApplyOptions<Command.Options>({
@ -10,7 +10,7 @@ import { platform, arch } from 'os'
usage: '머핀아 정보', usage: '머핀아 정보',
}, },
}) })
class InformationCommand extends Command { export default class InformationCommand extends Command {
public registerApplicationCommands(registry: Command.Registry) { public registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(builder => registry.registerChatInputCommand(builder =>
builder.setName(this.name).setDescription(this.description), builder.setName(this.name).setDescription(this.description),
@ -74,9 +74,3 @@ class InformationCommand extends Command {
await this._run(interaction) await this._run(interaction)
} }
} }
void container.stores.loadPiece({
piece: InformationCommand,
name: 'information',
store: 'commands',
})

View file

@ -1,5 +1,5 @@
import { ChatInputCommandInteraction, codeBlock, Message } from 'discord.js' import { ChatInputCommandInteraction, codeBlock, Message } from 'discord.js'
import { type Args, Command, container } from '@sapphire/framework' import { type Args, Command } from '@sapphire/framework'
import { ApplyOptions } from '@sapphire/decorators' import { ApplyOptions } from '@sapphire/decorators'
@ApplyOptions<Command.Options>({ @ApplyOptions<Command.Options>({
@ -15,7 +15,7 @@ import { ApplyOptions } from '@sapphire/decorators'
], ],
}, },
}) })
class LearnCommand extends Command { export default class LearnCommand extends Command {
public registerApplicationCommands(registry: Command.Registry) { public registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(builder => registry.registerChatInputCommand(builder =>
builder builder
@ -126,9 +126,3 @@ class LearnCommand extends Command {
await this._run(interaction) await this._run(interaction)
} }
} }
void container.stores.loadPiece({
piece: LearnCommand,
name: 'learn',
store: 'commands',
})

View file

@ -1,6 +1,6 @@
import { ChatInputCommandInteraction, Message } from 'discord.js' import { ChatInputCommandInteraction, Message } from 'discord.js'
import { Command, container } from '@sapphire/framework'
import { ApplyOptions } from '@sapphire/decorators' import { ApplyOptions } from '@sapphire/decorators'
import { Command } from '@sapphire/framework'
@ApplyOptions<Command.Options>({ @ApplyOptions<Command.Options>({
name: '데이터학습량', name: '데이터학습량',
@ -10,7 +10,7 @@ import { ApplyOptions } from '@sapphire/decorators'
usage: '머핀아 학습데이터량', usage: '머핀아 학습데이터량',
}, },
}) })
class LearnedDataCommand extends Command { export default class LearnedDataCommand extends Command {
public registerApplicationCommands(registry: Command.Registry) { public registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(builder => registry.registerChatInputCommand(builder =>
builder.setName(this.name).setDescription(this.description), builder.setName(this.name).setDescription(this.description),
@ -48,9 +48,3 @@ ${user.username}님이 가르쳐준 단어: ${userData.length}개`)
await this._run(interaction) await this._run(interaction)
} }
} }
void container.stores.loadPiece({
piece: LearnedDataCommand,
name: 'learnedData',
store: 'commands',
})

View file

@ -1,6 +1,6 @@
import { ChatInputCommandInteraction, Message, codeBlock } from 'discord.js' import { ChatInputCommandInteraction, Message, codeBlock } from 'discord.js'
import { Command, container } from '@sapphire/framework'
import { ApplyOptions } from '@sapphire/decorators' import { ApplyOptions } from '@sapphire/decorators'
import { Command } from '@sapphire/framework'
@ApplyOptions<Command.Options>({ @ApplyOptions<Command.Options>({
name: '리스트', name: '리스트',
@ -10,7 +10,7 @@ import { ApplyOptions } from '@sapphire/decorators'
usage: '머핀아 리스트', usage: '머핀아 리스트',
}, },
}) })
class ListCommand extends Command { export default class ListCommand extends Command {
public registerApplicationCommands(registry: Command.Registry) { public registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(builder => registry.registerChatInputCommand(builder =>
builder.setName(this.name).setDescription(this.description), builder.setName(this.name).setDescription(this.description),
@ -63,9 +63,3 @@ class ListCommand extends Command {
await this._run(interaction) await this._run(interaction)
} }
} }
void container.stores.loadPiece({
piece: ListCommand,
name: 'list',
store: 'commands',
})

View file

@ -1 +0,0 @@
import './deleteLearn'

View file

@ -1,15 +1,14 @@
import {
container,
InteractionHandler,
InteractionHandlerTypes,
} from '@sapphire/framework'
import { type StringSelectMenuInteraction } from 'discord.js' import { type StringSelectMenuInteraction } from 'discord.js'
import { ApplyOptions } from '@sapphire/decorators' import { ApplyOptions } from '@sapphire/decorators'
import {
InteractionHandlerTypes,
InteractionHandler,
} from '@sapphire/framework'
@ApplyOptions<InteractionHandler.Options>({ @ApplyOptions<InteractionHandler.Options>({
interactionHandlerType: InteractionHandlerTypes.SelectMenu, interactionHandlerType: InteractionHandlerTypes.SelectMenu,
}) })
class DeleteLearnHandler extends InteractionHandler { export default class DeleteLearnHandler extends InteractionHandler {
private readonly _CUSTOM_ID = 'maa$deleteLearn' private readonly _CUSTOM_ID = 'maa$deleteLearn'
public async parse(interaction: StringSelectMenuInteraction) { public async parse(interaction: StringSelectMenuInteraction) {
@ -67,9 +66,3 @@ class DeleteLearnHandler extends InteractionHandler {
}) })
} }
} }
void container.stores.loadPiece({
piece: DeleteLearnHandler,
name: 'deleteLearn',
store: 'interaction-handlers',
})

View file

@ -1,4 +0,0 @@
import './interactionCreate'
import './messageCreate'
import './debug'
import './ready'

View file

@ -1,13 +1,7 @@
import { Listener, container } from '@sapphire/framework' import { Listener } from '@sapphire/framework'
class DebugListener extends Listener { export default class DebugListener extends Listener {
public async run(debug: string) { public async run(debug: string) {
this.container.logger.debug(`[MuffinBot] ${debug}`) this.container.logger.debug(`[MuffinBot] ${debug}`)
} }
} }
void container.stores.loadPiece({
piece: DebugListener,
name: 'debug',
store: 'listeners',
})

View file

@ -1,8 +1,8 @@
import { container, Listener } from '@sapphire/framework'
import { ChatInputCommandInteraction } from 'discord.js' import { ChatInputCommandInteraction } from 'discord.js'
import { Listener } from '@sapphire/framework'
import { previewWarning } from '../modules' import { previewWarning } from '../modules'
class InteractionCreateListener extends Listener { export default class InteractionCreateListener extends Listener {
public async run(interaction: ChatInputCommandInteraction<'cached'>) { public async run(interaction: ChatInputCommandInteraction<'cached'>) {
if (interaction.isChatInputCommand()) { if (interaction.isChatInputCommand()) {
if (this.container.channel !== 'RELEASE') if (this.container.channel !== 'RELEASE')
@ -10,9 +10,3 @@ class InteractionCreateListener extends Listener {
} }
} }
} }
void container.stores.loadPiece({
piece: InteractionCreateListener,
name: 'interactionCreate',
store: 'listeners'
})

View file

@ -1,9 +1,9 @@
import { Listener, container } from '@sapphire/framework'
import { type Message } from 'discord.js'
import { noPerm, previewWarning } from '../modules' import { noPerm, previewWarning } from '../modules'
import { Listener } from '@sapphire/framework'
import { type Message } from 'discord.js'
import { Client } from 'dokdo' import { Client } from 'dokdo'
class MessageCreateListener extends Listener { export default class MessageCreateListener extends Listener {
public async run(msg: Message<true>) { public async run(msg: Message<true>) {
const prefix = this.container.prefix const prefix = this.container.prefix
const dokdo = new Client(this.container.client, { const dokdo = new Client(this.container.client, {
@ -32,9 +32,3 @@ class MessageCreateListener extends Listener {
} }
} }
} }
void container.stores.loadPiece({
piece: MessageCreateListener,
name: 'messageCreate',
store: 'listeners',
})

View file

@ -1,9 +1,9 @@
import { container, Listener } from '@sapphire/framework'
import { ApplyOptions } from '@sapphire/decorators' import { ApplyOptions } from '@sapphire/decorators'
import { ActivityType, Client } from 'discord.js' import { ActivityType, Client } from 'discord.js'
import { Listener } from '@sapphire/framework'
@ApplyOptions<Listener.Options>({ once: true }) @ApplyOptions<Listener.Options>({ once: true })
class ClientReadyListener extends Listener { export default class ClientReadyListener extends Listener {
public async run(client: Client<true>) { public async run(client: Client<true>) {
function setStatus() { function setStatus() {
client.user.setActivity({ client.user.setActivity({
@ -18,9 +18,3 @@ class ClientReadyListener extends Listener {
this.container.logger.info(`[MuffinBot] 먹힐 준ㅂ비 완료`) this.container.logger.info(`[MuffinBot] 먹힐 준ㅂ비 완료`)
} }
} }
void container.stores.loadPiece({
piece: ClientReadyListener,
name: 'ready',
store: 'listeners',
})

View file

@ -1,5 +1,5 @@
import type { Client, Message, TextChannel } from 'discord.js' import type { Client, Message, TextChannel } from 'discord.js'
import type { PrismaClient } from '../../prisma' import type { PrismaClient } from '@prisma/client'
import { container } from '@sapphire/framework' import { container } from '@sapphire/framework'
export default class ChatBot { export default class ChatBot {

View file

@ -1,11 +0,0 @@
import { defineConfig } from 'tsup'
const sourcemap = process.env.NODE_ENV === 'development' ? true : false
export default defineConfig({
clean: true,
format: ['cjs'],
entry: ['src/index.ts'],
minify: true,
sourcemap,
})

4004
yarn.lock

File diff suppressed because it is too large Load diff