reciple 10.0.5 → 10.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/_virtual/{_@oxc-project_runtime@0.110.0 → _@oxc-project_runtime@0.108.0}/helpers/decorate.mjs +1 -1
  2. package/dist/bin/commands/build.d.mts +1 -6
  3. package/dist/bin/commands/build.mjs +3 -2
  4. package/dist/bin/commands/build.mjs.map +1 -1
  5. package/dist/bin/commands/create.mjs +2 -3
  6. package/dist/bin/commands/create.mjs.map +1 -1
  7. package/dist/bin/commands/createModule.d.mts +0 -1
  8. package/dist/bin/commands/createModule.mjs +3 -2
  9. package/dist/bin/commands/createModule.mjs.map +1 -1
  10. package/dist/bin/commands/start.d.mts +0 -1
  11. package/dist/bin/commands/start.mjs +26 -25
  12. package/dist/bin/commands/start.mjs.map +1 -1
  13. package/dist/bin/commands/startSharding.mjs +21 -20
  14. package/dist/bin/commands/startSharding.mjs.map +1 -1
  15. package/dist/classes/cli/CLI.d.mts +1 -0
  16. package/dist/classes/cli/CLI.mjs +9 -1
  17. package/dist/classes/cli/CLI.mjs.map +1 -1
  18. package/dist/classes/cli/ConfigReader.d.mts +1 -4
  19. package/dist/classes/cli/ConfigReader.mjs +3 -8
  20. package/dist/classes/cli/ConfigReader.mjs.map +1 -1
  21. package/dist/classes/client/ModuleLoader.mjs +18 -18
  22. package/dist/classes/client/ModuleLoader.mjs.map +1 -1
  23. package/dist/classes/managers/ModuleManager.mjs +1 -1
  24. package/dist/classes/modules/PostconditionModule.mjs +1 -1
  25. package/dist/classes/modules/PreconditionModule.mjs +1 -1
  26. package/dist/classes/modules/commands/ContextMenuCommandModule.mjs +1 -1
  27. package/dist/classes/modules/commands/MessageCommandModule.mjs +1 -1
  28. package/dist/classes/modules/commands/SlashCommandModule.mjs +1 -1
  29. package/dist/classes/templates/ModuleTemplateBuilder.mjs +19 -19
  30. package/dist/classes/templates/ModuleTemplateBuilder.mjs.map +1 -1
  31. package/dist/classes/templates/TemplateBuilder.d.mts +1 -3
  32. package/dist/classes/templates/TemplateBuilder.mjs +30 -38
  33. package/dist/classes/templates/TemplateBuilder.mjs.map +1 -1
  34. package/dist/classes/validation/BaseModuleValidator.d.mts +10 -10
  35. package/dist/classes/validation/CommandModuleValidator.d.mts +17 -17
  36. package/dist/classes/validation/EventModuleValidator.d.mts +10 -10
  37. package/dist/classes/validation/PreconditionModule.d.mts +7 -7
  38. package/dist/package.mjs +1 -1
  39. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- //#region \0@oxc-project+runtime@0.110.0/helpers/decorate.js
1
+ //#region \0@oxc-project+runtime@0.108.0/helpers/decorate.js
2
2
  function __decorate(decorators, target, key, desc) {
3
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -6,11 +6,6 @@ declare class BuildSubcommand extends CLISubcommand {
6
6
  subcommand: Command;
7
7
  execute(): Promise<void>;
8
8
  }
9
- declare namespace BuildSubcommand {
10
- interface Flags {
11
- config?: string;
12
- }
13
- }
14
9
  //#endregion
15
- export { BuildSubcommand, BuildSubcommand as default };
10
+ export { BuildSubcommand as default };
16
11
  //# sourceMappingURL=build.d.mts.map
@@ -6,9 +6,10 @@ import { build } from "tsdown";
6
6
 
7
7
  //#region src/bin/commands/build.ts
8
8
  var BuildSubcommand = class extends CLISubcommand {
9
- subcommand = new Command("build").description("Build the reciple modules defined in config file").option("-c, --config <path>", "Path to the configuration file");
9
+ subcommand = new Command("build").description("Build the reciple modules defined in config file").argument("[project]", "The root directory of your project");
10
10
  async execute() {
11
- const { build: buildConfig } = await new ConfigReader(this.subcommand.opts().config ?? await ConfigReader.find() ?? ConfigReader.createConfigFilename("js")).read({ ignoreInstanceCheck: true });
11
+ await this.cli.setCurrentDirectory(this.subcommand.args[0]);
12
+ const { build: buildConfig } = await new ConfigReader(await ConfigReader.find() ?? ConfigReader.createConfigFilename("js")).read();
12
13
  let plugins = buildConfig.plugins ? Array.isArray(buildConfig.plugins) ? buildConfig.plugins : [buildConfig.plugins] : [];
13
14
  plugins.push(CLI.createTsdownLogger(this.cli.logger));
14
15
  await build({
@@ -1 +1 @@
1
- {"version":3,"file":"build.mjs","names":[],"sources":["../../../src/bin/commands/build.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { CLISubcommand } from '../../classes/cli/CLISubcommand.js';\nimport { ConfigReader } from '../../classes/cli/ConfigReader.js';\nimport { build } from 'tsdown';\nimport { CLI } from '../../classes/cli/CLI.js';\n\nexport default class BuildSubcommand extends CLISubcommand {\n public subcommand: Command = new Command('build')\n .description('Build the reciple modules defined in config file')\n .option('-c, --config <path>', 'Path to the configuration file');\n\n public async execute(): Promise<void> {\n const flags = this.subcommand.opts<BuildSubcommand.Flags>();\n\n const configReader = new ConfigReader(\n flags.config\n ?? await ConfigReader.find()\n ?? ConfigReader.createConfigFilename('js')\n );\n\n const { build: buildConfig } = await configReader.read({ ignoreInstanceCheck: true });\n\n let plugins = buildConfig.plugins\n ? Array.isArray(buildConfig.plugins)\n ? buildConfig.plugins\n : [buildConfig.plugins]\n : [];\n\n plugins.push(CLI.createTsdownLogger(this.cli.logger));\n\n await build({\n ...buildConfig,\n logLevel: 'silent',\n plugins,\n });\n }\n}\n\nexport namespace BuildSubcommand {\n export interface Flags {\n config?: string;\n }\n}\n"],"mappings":";;;;;;;AAMA,IAAqB,kBAArB,cAA6C,cAAc;CACvD,AAAO,aAAsB,IAAI,QAAQ,QAAQ,CAC5C,YAAY,mDAAmD,CAC/D,OAAO,uBAAuB,iCAAiC;CAEpE,MAAa,UAAyB;EASlC,MAAM,EAAE,OAAO,gBAAgB,MANV,IAAI,aAFX,KAAK,WAAW,MAA6B,CAGjD,UACH,MAAM,aAAa,MAAM,IACzB,aAAa,qBAAqB,KAAK,CAC7C,CAEiD,KAAK,EAAE,qBAAqB,MAAM,CAAC;EAErF,IAAI,UAAU,YAAY,UACpB,MAAM,QAAQ,YAAY,QAAQ,GAC9B,YAAY,UACZ,CAAC,YAAY,QAAQ,GACzB,EAAE;AAER,UAAQ,KAAK,IAAI,mBAAmB,KAAK,IAAI,OAAO,CAAC;AAErD,QAAM,MAAM;GACR,GAAG;GACH,UAAU;GACV;GACH,CAAC"}
1
+ {"version":3,"file":"build.mjs","names":[],"sources":["../../../src/bin/commands/build.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { CLISubcommand } from '../../classes/cli/CLISubcommand.js';\nimport { ConfigReader } from '../../classes/cli/ConfigReader.js';\nimport { build } from 'tsdown';\nimport { CLI } from '../../classes/cli/CLI.js';\n\nexport default class BuildSubcommand extends CLISubcommand {\n public subcommand: Command = new Command('build')\n .description('Build the reciple modules defined in config file')\n .argument('[project]', 'The root directory of your project');\n\n public async execute(): Promise<void> {\n await this.cli.setCurrentDirectory(this.subcommand.args[0]);\n\n const configReader = new ConfigReader(\n await ConfigReader.find()\n ?? ConfigReader.createConfigFilename('js')\n );\n\n const { build: buildConfig } = await configReader.read();\n\n let plugins = buildConfig.plugins\n ? Array.isArray(buildConfig.plugins)\n ? buildConfig.plugins\n : [buildConfig.plugins]\n : [];\n\n plugins.push(CLI.createTsdownLogger(this.cli.logger));\n\n await build({\n ...buildConfig,\n logLevel: 'silent',\n plugins,\n });\n }\n}\n"],"mappings":";;;;;;;AAMA,IAAqB,kBAArB,cAA6C,cAAc;CACvD,AAAO,aAAsB,IAAI,QAAQ,QAAQ,CAC5C,YAAY,mDAAmD,CAC/D,SAAS,aAAa,qCAAqC;CAEhE,MAAa,UAAyB;AAClC,QAAM,KAAK,IAAI,oBAAoB,KAAK,WAAW,KAAK,GAAG;EAO3D,MAAM,EAAE,OAAO,gBAAgB,MALV,IAAI,aACrB,MAAM,aAAa,MAAM,IACtB,aAAa,qBAAqB,KAAK,CAC7C,CAEiD,MAAM;EAExD,IAAI,UAAU,YAAY,UACpB,MAAM,QAAQ,YAAY,QAAQ,GAC9B,YAAY,UACZ,CAAC,YAAY,QAAQ,GACzB,EAAE;AAER,UAAQ,KAAK,IAAI,mBAAmB,KAAK,IAAI,OAAO,CAAC;AAErD,QAAM,MAAM;GACR,GAAG;GACH,UAAU;GACV;GACH,CAAC"}
@@ -8,7 +8,7 @@ import { inspect } from "node:util";
8
8
 
9
9
  //#region src/bin/commands/create.ts
10
10
  var CreateSubcommand = class extends CLISubcommand {
11
- subcommand = new Command("create").description("Create a new reciple project").argument("[output]", "The directory to create the project in").option("-c, --config <path>", "Path to the configuration file").option("-t, --token <DiscordToken>", "Set your Discord Bot token").option("-T, --typescript", "Use TypeScript").addOption(new Option("-p, --package-manager <name>", "The name of the package manager to use").choices([
11
+ subcommand = new Command("create").description("Create a new reciple project").argument("[project]", "The root directory of your project").option("-c, --config <path>", "Path to the configuration file").option("-t, --token <DiscordToken>", "Set your Discord Bot token").option("-T, --typescript", "Use TypeScript").addOption(new Option("-p, --package-manager <name>", "The name of the package manager to use").choices([
12
12
  "npm",
13
13
  "yarn",
14
14
  "pnpm",
@@ -19,7 +19,6 @@ var CreateSubcommand = class extends CLISubcommand {
19
19
  const flags = this.cli.getFlags("create");
20
20
  const template = new TemplateBuilder({
21
21
  cli: this.cli,
22
- directory: this.subcommand.args[0],
23
22
  typescript: flags?.typescript,
24
23
  packageManager: flags?.packageManager,
25
24
  defaultAll: flags?.default,
@@ -27,7 +26,7 @@ var CreateSubcommand = class extends CLISubcommand {
27
26
  });
28
27
  try {
29
28
  await template.init();
30
- await template.createDirectory();
29
+ await template.createDirectory({ directory: this.subcommand.args[0] });
31
30
  await template.setupLanguage();
32
31
  await template.createConfig();
33
32
  await template.createEnvFile({ envFile: this.cli.flags.env[0] });
@@ -1 +1 @@
1
- {"version":3,"file":"create.mjs","names":[],"sources":["../../../src/bin/commands/create.ts"],"sourcesContent":["import { Command, Option } from 'commander';\nimport { CLISubcommand } from '../../classes/cli/CLISubcommand.js';\nimport { TemplateBuilder } from '../../classes/templates/TemplateBuilder.js';\nimport { cancel } from '@clack/prompts';\nimport { inspect } from 'node:util';\nimport { NotAnError } from '../../classes/NotAnError.js';\nimport type { PackageManagerName } from 'nypm';\nimport { colors } from '@prtty/prtty';\n\nexport default class CreateSubcommand extends CLISubcommand {\n public subcommand: Command = new Command('create')\n .description('Create a new reciple project')\n .argument('[output]', 'The directory to create the project in')\n .option('-c, --config <path>', 'Path to the configuration file')\n .option('-t, --token <DiscordToken>', 'Set your Discord Bot token')\n .option('-T, --typescript', 'Use TypeScript')\n .addOption(new Option('-p, --package-manager <name>', 'The name of the package manager to use')\n .choices(['npm', 'yarn', 'pnpm', 'bun', 'deno'])\n )\n .option('-D, --default', 'Use defaults for prompts')\n .option('--install', 'Install dependencies during setup', true)\n .option('--no-install', 'Do not install dependencies during setup')\n .option('--build', 'Build the project after creation', true)\n .option('--no-build', 'Do not build the project after creation')\n .allowUnknownOption(true);\n\n public async execute(): Promise<void> {\n const flags = this.cli.getFlags<CreateSubcommand.Flags>('create');\n const template = new TemplateBuilder({\n cli: this.cli,\n directory: this.subcommand.args[0],\n typescript: flags?.typescript,\n packageManager: flags?.packageManager,\n defaultAll: flags?.default,\n token: flags?.token,\n });\n\n try {\n await template.init();\n await template.createDirectory();\n await template.setupLanguage();\n await template.createConfig();\n await template.createEnvFile({ envFile: this.cli.flags.env[0] });\n await template.createTemplate();\n await template.setPackageManager();\n await template.installDependencies({ value: flags?.install });\n await template.createModules();\n await template.build({ skipBuild: !flags?.build });\n } catch (error) {\n cancel(colors.red(error instanceof NotAnError ? error.message : inspect(error)));\n }\n }\n}\n\nexport namespace CreateSubcommand {\n export interface Flags {\n config?: string;\n token?: string;\n default?: boolean;\n typescript?: boolean;\n packageManager?: PackageManagerName;\n install: boolean;\n build: boolean;\n }\n}\n"],"mappings":";;;;;;;;;AASA,IAAqB,mBAArB,cAA8C,cAAc;CACxD,AAAO,aAAsB,IAAI,QAAQ,SAAS,CAC7C,YAAY,+BAA+B,CAC3C,SAAS,YAAY,yCAAyC,CAC9D,OAAO,uBAAuB,iCAAiC,CAC/D,OAAO,8BAA8B,6BAA6B,CAClE,OAAO,oBAAoB,iBAAiB,CAC5C,UAAU,IAAI,OAAO,gCAAgC,yCAAyC,CAC1F,QAAQ;EAAC;EAAO;EAAQ;EAAQ;EAAO;EAAO,CAAC,CACnD,CACA,OAAO,iBAAiB,2BAA2B,CACnD,OAAO,aAAa,qCAAqC,KAAK,CAC9D,OAAO,gBAAgB,2CAA2C,CAClE,OAAO,WAAW,oCAAoC,KAAK,CAC3D,OAAO,cAAc,0CAA0C,CAC/D,mBAAmB,KAAK;CAE7B,MAAa,UAAyB;EAClC,MAAM,QAAQ,KAAK,IAAI,SAAiC,SAAS;EACjE,MAAM,WAAW,IAAI,gBAAgB;GACjC,KAAK,KAAK;GACV,WAAW,KAAK,WAAW,KAAK;GAChC,YAAY,OAAO;GACnB,gBAAgB,OAAO;GACvB,YAAY,OAAO;GACnB,OAAO,OAAO;GACjB,CAAC;AAEF,MAAI;AACA,SAAM,SAAS,MAAM;AACrB,SAAM,SAAS,iBAAiB;AAChC,SAAM,SAAS,eAAe;AAC9B,SAAM,SAAS,cAAc;AAC7B,SAAM,SAAS,cAAc,EAAE,SAAS,KAAK,IAAI,MAAM,IAAI,IAAI,CAAC;AAChE,SAAM,SAAS,gBAAgB;AAC/B,SAAM,SAAS,mBAAmB;AAClC,SAAM,SAAS,oBAAoB,EAAE,OAAO,OAAO,SAAS,CAAC;AAC7D,SAAM,SAAS,eAAe;AAC9B,SAAM,SAAS,MAAM,EAAE,WAAW,CAAC,OAAO,OAAO,CAAC;WAC7C,OAAO;AACZ,UAAO,OAAO,IAAI,iBAAiB,aAAa,MAAM,UAAU,QAAQ,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"create.mjs","names":[],"sources":["../../../src/bin/commands/create.ts"],"sourcesContent":["import { Command, Option } from 'commander';\nimport { CLISubcommand } from '../../classes/cli/CLISubcommand.js';\nimport { TemplateBuilder } from '../../classes/templates/TemplateBuilder.js';\nimport { cancel } from '@clack/prompts';\nimport { inspect } from 'node:util';\nimport { NotAnError } from '../../classes/NotAnError.js';\nimport type { PackageManagerName } from 'nypm';\nimport { colors } from '@prtty/prtty';\n\nexport default class CreateSubcommand extends CLISubcommand {\n public subcommand: Command = new Command('create')\n .description('Create a new reciple project')\n .argument('[project]', 'The root directory of your project')\n .option('-c, --config <path>', 'Path to the configuration file')\n .option('-t, --token <DiscordToken>', 'Set your Discord Bot token')\n .option('-T, --typescript', 'Use TypeScript')\n .addOption(new Option('-p, --package-manager <name>', 'The name of the package manager to use')\n .choices(['npm', 'yarn', 'pnpm', 'bun', 'deno'])\n )\n .option('-D, --default', 'Use defaults for prompts')\n .option('--install', 'Install dependencies during setup', true)\n .option('--no-install', 'Do not install dependencies during setup')\n .option('--build', 'Build the project after creation', true)\n .option('--no-build', 'Do not build the project after creation')\n .allowUnknownOption(true);\n\n public async execute(): Promise<void> {\n const flags = this.cli.getFlags<CreateSubcommand.Flags>('create');\n const template = new TemplateBuilder({\n cli: this.cli,\n typescript: flags?.typescript,\n packageManager: flags?.packageManager,\n defaultAll: flags?.default,\n token: flags?.token,\n });\n\n try {\n await template.init();\n await template.createDirectory({ directory: this.subcommand.args[0] });\n await template.setupLanguage();\n await template.createConfig();\n await template.createEnvFile({ envFile: this.cli.flags.env[0] });\n await template.createTemplate();\n await template.setPackageManager();\n await template.installDependencies({ value: flags?.install });\n await template.createModules();\n await template.build({ skipBuild: !flags?.build });\n } catch (error) {\n cancel(colors.red(error instanceof NotAnError ? error.message : inspect(error)));\n }\n }\n}\n\nexport namespace CreateSubcommand {\n export interface Flags {\n config?: string;\n token?: string;\n default?: boolean;\n typescript?: boolean;\n packageManager?: PackageManagerName;\n install: boolean;\n build: boolean;\n }\n}\n"],"mappings":";;;;;;;;;AASA,IAAqB,mBAArB,cAA8C,cAAc;CACxD,AAAO,aAAsB,IAAI,QAAQ,SAAS,CAC7C,YAAY,+BAA+B,CAC3C,SAAS,aAAa,qCAAqC,CAC3D,OAAO,uBAAuB,iCAAiC,CAC/D,OAAO,8BAA8B,6BAA6B,CAClE,OAAO,oBAAoB,iBAAiB,CAC5C,UAAU,IAAI,OAAO,gCAAgC,yCAAyC,CAC1F,QAAQ;EAAC;EAAO;EAAQ;EAAQ;EAAO;EAAO,CAAC,CACnD,CACA,OAAO,iBAAiB,2BAA2B,CACnD,OAAO,aAAa,qCAAqC,KAAK,CAC9D,OAAO,gBAAgB,2CAA2C,CAClE,OAAO,WAAW,oCAAoC,KAAK,CAC3D,OAAO,cAAc,0CAA0C,CAC/D,mBAAmB,KAAK;CAE7B,MAAa,UAAyB;EAClC,MAAM,QAAQ,KAAK,IAAI,SAAiC,SAAS;EACjE,MAAM,WAAW,IAAI,gBAAgB;GACjC,KAAK,KAAK;GACV,YAAY,OAAO;GACnB,gBAAgB,OAAO;GACvB,YAAY,OAAO;GACnB,OAAO,OAAO;GACjB,CAAC;AAEF,MAAI;AACA,SAAM,SAAS,MAAM;AACrB,SAAM,SAAS,gBAAgB,EAAE,WAAW,KAAK,WAAW,KAAK,IAAI,CAAC;AACtE,SAAM,SAAS,eAAe;AAC9B,SAAM,SAAS,cAAc;AAC7B,SAAM,SAAS,cAAc,EAAE,SAAS,KAAK,IAAI,MAAM,IAAI,IAAI,CAAC;AAChE,SAAM,SAAS,gBAAgB;AAC/B,SAAM,SAAS,mBAAmB;AAClC,SAAM,SAAS,oBAAoB,EAAE,OAAO,OAAO,SAAS,CAAC;AAC7D,SAAM,SAAS,eAAe;AAC9B,SAAM,SAAS,MAAM,EAAE,WAAW,CAAC,OAAO,OAAO,CAAC;WAC7C,OAAO;AACZ,UAAO,OAAO,IAAI,iBAAiB,aAAa,MAAM,UAAU,QAAQ,MAAM,CAAC,CAAC"}
@@ -11,7 +11,6 @@ declare namespace CreateModuleSubcommand {
11
11
  interface Flags {
12
12
  template?: string;
13
13
  filename?: string;
14
- config?: string;
15
14
  typescript?: boolean;
16
15
  default?: boolean;
17
16
  }
@@ -9,11 +9,12 @@ import { inspect } from "node:util";
9
9
 
10
10
  //#region src/bin/commands/createModule.ts
11
11
  var CreateModuleSubcommand = class extends CLISubcommand {
12
- subcommand = new Command("module").description("Creates new module").argument("[output]", "The directory to create the module in").option("--template, -t <template>", "Template source name").option("--filename", "The filename of the module").option("-c, --config <path>", "Path to the configuration file").option("-T, --typescript", "Use TypeScript").option("-D, --default", "Use defaults for prompts").enablePositionalOptions(true);
12
+ subcommand = new Command("module").description("Creates new reciple module").argument("[project]", "The root directory of your project").option("--template, -t <template>", "Template source name").option("--filename", "The filename of the module").option("-T, --typescript", "Use TypeScript").option("-D, --default", "Use defaults for prompts").enablePositionalOptions(true);
13
13
  parent = "create";
14
14
  async execute() {
15
15
  const flags = this.subcommand.opts();
16
- const configReader = await new ConfigReader(flags.config ?? await ConfigReader.find() ?? ConfigReader.createConfigFilename("js")).read({ ignoreInstanceCheck: true });
16
+ await this.cli.setCurrentDirectory(this.subcommand.args[0]);
17
+ const configReader = await new ConfigReader(await ConfigReader.find() ?? ConfigReader.createConfigFilename("js")).read();
17
18
  const template = new ModuleTemplateBuilder({
18
19
  cli: this.cli,
19
20
  config: configReader,
@@ -1 +1 @@
1
- {"version":3,"file":"createModule.mjs","names":[],"sources":["../../../src/bin/commands/createModule.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { CLISubcommand } from '../../classes/cli/CLISubcommand.js';\nimport { ConfigReader } from '../../classes/cli/ConfigReader.js';\nimport { ModuleTemplateBuilder } from '../../classes/templates/ModuleTemplateBuilder.js';\nimport { cancel } from '@clack/prompts';\nimport { colors } from '@prtty/prtty';\nimport { NotAnError } from '../../classes/NotAnError.js';\nimport { inspect } from 'node:util';\n\nexport default class CreateModuleSubcommand extends CLISubcommand {\n public subcommand: Command = new Command('module')\n .description('Creates new module')\n .argument('[output]', 'The directory to create the module in')\n .option('--template, -t <template>', 'Template source name')\n .option('--filename', 'The filename of the module')\n .option('-c, --config <path>', 'Path to the configuration file')\n .option('-T, --typescript', 'Use TypeScript')\n .option('-D, --default', 'Use defaults for prompts')\n .enablePositionalOptions(true);\n\n public parent: string = 'create';\n\n public async execute(): Promise<void> {\n const flags = this.subcommand.opts<CreateModuleSubcommand.Flags>();\n\n const configReader = await new ConfigReader(\n flags.config\n ?? await ConfigReader.find()\n ?? ConfigReader.createConfigFilename('js')\n ).read({ ignoreInstanceCheck: true });\n\n const template = new ModuleTemplateBuilder({\n cli: this.cli,\n config: configReader,\n typescript: flags.typescript,\n filename: flags.filename,\n defaultAll: flags?.default\n });\n\n try {\n await template.init();\n await template.setupLanguage();\n await template.setupTemplate();\n await template.setupPlaceholders();\n await template.setupDirectory();\n await template.setupFilename();\n await template.build();\n } catch (error) {\n cancel(colors.red(error instanceof NotAnError ? error.message : inspect(error)));\n }\n }\n}\n\nexport namespace CreateModuleSubcommand {\n export interface Flags {\n template?: string;\n filename?: string;\n config?: string;\n typescript?: boolean;\n default?: boolean;\n }\n}\n"],"mappings":";;;;;;;;;;AASA,IAAqB,yBAArB,cAAoD,cAAc;CAC9D,AAAO,aAAsB,IAAI,QAAQ,SAAS,CAC7C,YAAY,qBAAqB,CACjC,SAAS,YAAY,wCAAwC,CAC7D,OAAO,6BAA6B,uBAAuB,CAC3D,OAAO,cAAc,6BAA6B,CAClD,OAAO,uBAAuB,iCAAiC,CAC/D,OAAO,oBAAoB,iBAAiB,CAC5C,OAAO,iBAAiB,2BAA2B,CACnD,wBAAwB,KAAK;CAElC,AAAO,SAAiB;CAExB,MAAa,UAAyB;EAClC,MAAM,QAAQ,KAAK,WAAW,MAAoC;EAElE,MAAM,eAAe,MAAM,IAAI,aAC3B,MAAM,UACH,MAAM,aAAa,MAAM,IACzB,aAAa,qBAAqB,KAAK,CAC7C,CAAC,KAAK,EAAE,qBAAqB,MAAM,CAAC;EAErC,MAAM,WAAW,IAAI,sBAAsB;GACvC,KAAK,KAAK;GACV,QAAQ;GACR,YAAY,MAAM;GAClB,UAAU,MAAM;GAChB,YAAY,OAAO;GACtB,CAAC;AAEF,MAAI;AACA,SAAM,SAAS,MAAM;AACrB,SAAM,SAAS,eAAe;AAC9B,SAAM,SAAS,eAAe;AAC9B,SAAM,SAAS,mBAAmB;AAClC,SAAM,SAAS,gBAAgB;AAC/B,SAAM,SAAS,eAAe;AAC9B,SAAM,SAAS,OAAO;WACjB,OAAO;AACZ,UAAO,OAAO,IAAI,iBAAiB,aAAa,MAAM,UAAU,QAAQ,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"createModule.mjs","names":[],"sources":["../../../src/bin/commands/createModule.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { CLISubcommand } from '../../classes/cli/CLISubcommand.js';\nimport { ConfigReader } from '../../classes/cli/ConfigReader.js';\nimport { ModuleTemplateBuilder } from '../../classes/templates/ModuleTemplateBuilder.js';\nimport { cancel } from '@clack/prompts';\nimport { colors } from '@prtty/prtty';\nimport { NotAnError } from '../../classes/NotAnError.js';\nimport { inspect } from 'node:util';\n\nexport default class CreateModuleSubcommand extends CLISubcommand {\n public subcommand: Command = new Command('module')\n .description('Creates new reciple module')\n .argument('[project]', 'The root directory of your project')\n .option('--template, -t <template>', 'Template source name')\n .option('--filename', 'The filename of the module')\n .option('-T, --typescript', 'Use TypeScript')\n .option('-D, --default', 'Use defaults for prompts')\n .enablePositionalOptions(true);\n\n public parent: string = 'create';\n\n public async execute(): Promise<void> {\n const flags = this.subcommand.opts<CreateModuleSubcommand.Flags>();\n\n await this.cli.setCurrentDirectory(this.subcommand.args[0]);\n\n const configReader = await new ConfigReader(\n await ConfigReader.find()\n ?? ConfigReader.createConfigFilename('js')\n ).read();\n\n const template = new ModuleTemplateBuilder({\n cli: this.cli,\n config: configReader,\n typescript: flags.typescript,\n filename: flags.filename,\n defaultAll: flags?.default\n });\n\n try {\n await template.init();\n await template.setupLanguage();\n await template.setupTemplate();\n await template.setupPlaceholders();\n await template.setupDirectory();\n await template.setupFilename();\n await template.build();\n } catch (error) {\n cancel(colors.red(error instanceof NotAnError ? error.message : inspect(error)));\n }\n }\n}\n\nexport namespace CreateModuleSubcommand {\n export interface Flags {\n template?: string;\n filename?: string;\n typescript?: boolean;\n default?: boolean;\n }\n}\n"],"mappings":";;;;;;;;;;AASA,IAAqB,yBAArB,cAAoD,cAAc;CAC9D,AAAO,aAAsB,IAAI,QAAQ,SAAS,CAC7C,YAAY,6BAA6B,CACzC,SAAS,aAAa,qCAAqC,CAC3D,OAAO,6BAA6B,uBAAuB,CAC3D,OAAO,cAAc,6BAA6B,CAClD,OAAO,oBAAoB,iBAAiB,CAC5C,OAAO,iBAAiB,2BAA2B,CACnD,wBAAwB,KAAK;CAElC,AAAO,SAAiB;CAExB,MAAa,UAAyB;EAClC,MAAM,QAAQ,KAAK,WAAW,MAAoC;AAElE,QAAM,KAAK,IAAI,oBAAoB,KAAK,WAAW,KAAK,GAAG;EAE3D,MAAM,eAAe,MAAM,IAAI,aAC3B,MAAM,aAAa,MAAM,IACtB,aAAa,qBAAqB,KAAK,CAC7C,CAAC,MAAM;EAER,MAAM,WAAW,IAAI,sBAAsB;GACvC,KAAK,KAAK;GACV,QAAQ;GACR,YAAY,MAAM;GAClB,UAAU,MAAM;GAChB,YAAY,OAAO;GACtB,CAAC;AAEF,MAAI;AACA,SAAM,SAAS,MAAM;AACrB,SAAM,SAAS,eAAe;AAC9B,SAAM,SAAS,eAAe;AAC9B,SAAM,SAAS,mBAAmB;AAClC,SAAM,SAAS,gBAAgB;AAC/B,SAAM,SAAS,eAAe;AAC9B,SAAM,SAAS,OAAO;WACjB,OAAO;AACZ,UAAO,OAAO,IAAI,iBAAiB,aAAa,MAAM,UAAU,QAAQ,MAAM,CAAC,CAAC"}
@@ -8,7 +8,6 @@ declare class StartSubcommand extends CLISubcommand {
8
8
  }
9
9
  declare namespace StartSubcommand {
10
10
  interface Flags {
11
- config?: string;
12
11
  token?: string;
13
12
  build?: boolean;
14
13
  }
@@ -15,21 +15,22 @@ import { build } from "tsdown";
15
15
 
16
16
  //#region src/bin/commands/start.ts
17
17
  var StartSubcommand = class extends CLISubcommand {
18
- subcommand = new Command("start").description("Start the reciple client").option("-c, --config <path>", "Path to the configuration file").option("-t, --token <DiscordToken>", "Set your Discord Bot token").option("-b, --build", "Build the modules before starting the client").allowUnknownOption(true);
18
+ subcommand = new Command("start").description("Start the reciple client").argument("[project]", "The root directory of your project").option("-t, --token <DiscordToken>", "Set your Discord Bot token").option("-b, --build", "Build the modules before starting the client").allowUnknownOption(true);
19
19
  async execute() {
20
20
  const flags = this.subcommand.opts();
21
- const { client, config, build: buildConfig } = await new ConfigReader(flags.config ?? await ConfigReader.find() ?? ConfigReader.createConfigFilename("js")).read();
22
- const logger = config.logger instanceof Logger ? this.cli.logger = config.logger : this.cli.logger.clone(config.logger);
21
+ await this.cli.setCurrentDirectory(this.subcommand.args[0]);
22
+ const { client, config, build: buildConfig } = await new ConfigReader(await ConfigReader.find() ?? ConfigReader.createConfigFilename("js")).read();
23
+ const logger$1 = config.logger instanceof Logger ? this.cli.logger = config.logger : this.cli.logger.clone(config.logger);
23
24
  let token = flags.token || config.token || "";
24
25
  token = resolveEnvProtocol(token) || token;
25
26
  function handleProcessError(err) {
26
- logger.error(err);
27
+ logger$1.error(err);
27
28
  process.exit(1);
28
29
  }
29
30
  process.once("uncaughtException", handleProcessError);
30
31
  process.once("unhandledRejection", handleProcessError);
31
- process.on("warning", (warn) => logger.warn(warn));
32
- logger.log(colors.magenta(`⚡ Initializing reciple!`));
32
+ process.on("warning", (warn) => logger$1.warn(warn));
33
+ logger$1.log(colors.magenta(`⚡ Initializing reciple!`));
33
34
  if (flags.build) {
34
35
  let plugins = buildConfig.plugins ? Array.isArray(buildConfig.plugins) ? buildConfig.plugins : [buildConfig.plugins] : [];
35
36
  plugins.push(CLI.createTsdownLogger());
@@ -40,7 +41,7 @@ var StartSubcommand = class extends CLISubcommand {
40
41
  });
41
42
  }
42
43
  Object.assign(client, {
43
- logger,
44
+ logger: logger$1,
44
45
  cli: this.cli,
45
46
  config
46
47
  });
@@ -50,12 +51,12 @@ var StartSubcommand = class extends CLISubcommand {
50
51
  eventListeners: new EventListeners()
51
52
  });
52
53
  Reflect.set(global, "useClient", () => client);
53
- Reflect.set(global, "useLogger", () => logger);
54
+ Reflect.set(global, "useLogger", () => logger$1);
54
55
  EventListeners.registerLoggerEventListeners(client);
55
- logger.log(colors.green(`📦 Version Info:`));
56
- logger.log(` ├─ ${colors.cyan(`reciple`)}\t\t${colors.yellow(`${this.cli.version}`)}`);
57
- logger.log(` ├─ ${colors.cyan(`@reciple/client`)}\t${colors.yellow(`${Client.version}`)}`);
58
- logger.log(` └─ ${colors.cyan(`discord.js`)}\t${colors.yellow(`${version}`)}`);
56
+ logger$1.log(colors.green(`📦 Version Info:`));
57
+ logger$1.log(` ├─ ${colors.cyan(`reciple`)}\t\t${colors.yellow(`${this.cli.version}`)}`);
58
+ logger$1.log(` ├─ ${colors.cyan(`@reciple/client`)}\t${colors.yellow(`${Client.version}`)}`);
59
+ logger$1.log(` └─ ${colors.cyan(`discord.js`)}\t${colors.yellow(`${version}`)}`);
59
60
  const modules = await client.moduleLoader.findModules();
60
61
  Object.assign(client, {
61
62
  _onBeforeLogin: async () => {
@@ -63,14 +64,14 @@ var StartSubcommand = class extends CLISubcommand {
63
64
  client.once("clientReady", async () => {
64
65
  if (!client.isReady()) return;
65
66
  EventListeners.registerCommandsEventListeners(client);
66
- logger.debug(`Client is ready!`);
67
+ logger$1.debug(`Client is ready!`);
67
68
  process.removeListener("uncaughtException", handleProcessError);
68
69
  process.removeListener("unhandledRejection", handleProcessError);
69
70
  const notEnabledModules = modules.length - enabledModules.length;
70
- logger.log(colors.green(`✅ ${enabledModules.length} ${Format.plural(enabledModules.length, "module")} ${Format.plural(enabledModules.length, "is", "are")} enabled.${notEnabledModules > 0 ? colors.red(` (${notEnabledModules} not enabled)`) : ""}`));
71
+ logger$1.log(colors.green(`✅ ${enabledModules.length} ${Format.plural(enabledModules.length, "module")} ${Format.plural(enabledModules.length, "is", "are")} enabled.${notEnabledModules > 0 ? colors.red(` (${notEnabledModules} not enabled)`) : ""}`));
71
72
  const readyModules = await client.modules.readyModules();
72
73
  const notReadyModules = readyModules.length - enabledModules.length;
73
- logger.log(colors.green(`✅ ${readyModules.length} ${Format.plural(readyModules.length, "module")} ${Format.plural(readyModules.length, "is", "are")} ready.${notReadyModules > 0 ? colors.red(` (${notReadyModules} not ready)`) : ""}`));
74
+ logger$1.log(colors.green(`✅ ${readyModules.length} ${Format.plural(readyModules.length, "module")} ${Format.plural(readyModules.length, "is", "are")} ready.${notReadyModules > 0 ? colors.red(` (${notReadyModules} not ready)`) : ""}`));
74
75
  await client.commands.registerApplicationCommands({
75
76
  ...config.applicationCommandsRegister,
76
77
  commands: client.commands.applicationCommands
@@ -81,21 +82,21 @@ var StartSubcommand = class extends CLISubcommand {
81
82
  message: client.commands.cache.filter((c) => c.type === CommandType.Message).size,
82
83
  slash: client.commands.cache.filter((c) => c.type === CommandType.Slash).size
83
84
  };
84
- logger.log(`🔑 Logged in as ${colors.bold(colors.cyan(client.user.displayName))} ${colors.magenta(`(${client.user.id})`)}`);
85
- logger.log(` ├─ Loaded ${colors.green(modules.length.toLocaleString())} ${Format.plural(modules.length, "module")}.`);
86
- logger.log(` ├─ Loaded ${colors.green(commands.contextMenus.toLocaleString())} context menu ${Format.plural(commands.contextMenus, "command")}.`);
87
- logger.log(` ├─ Loaded ${colors.green(commands.message.toLocaleString())} message ${Format.plural(commands.message, "command")}.`);
88
- logger.log(` ├─ Loaded ${colors.green(commands.slash.toLocaleString())} slash ${Format.plural(commands.slash, "command")}.`);
89
- logger.log(` ├─ Loaded ${colors.green(client.preconditions.cache.size.toLocaleString())} global ${Format.plural(client.preconditions.cache.size, "precondition")}.`);
90
- logger.log(` └─ Loaded ${colors.green(client.postconditions.cache.size.toLocaleString())} global ${Format.plural(client.postconditions.cache.size, "postcondition")}.`);
85
+ logger$1.log(`🔑 Logged in as ${colors.bold(colors.cyan(client.user.displayName))} ${colors.magenta(`(${client.user.id})`)}`);
86
+ logger$1.log(` ├─ Loaded ${colors.green(modules.length.toLocaleString())} ${Format.plural(modules.length, "module")}.`);
87
+ logger$1.log(` ├─ Loaded ${colors.green(commands.contextMenus.toLocaleString())} context menu ${Format.plural(commands.contextMenus, "command")}.`);
88
+ logger$1.log(` ├─ Loaded ${colors.green(commands.message.toLocaleString())} message ${Format.plural(commands.message, "command")}.`);
89
+ logger$1.log(` ├─ Loaded ${colors.green(commands.slash.toLocaleString())} slash ${Format.plural(commands.slash, "command")}.`);
90
+ logger$1.log(` ├─ Loaded ${colors.green(client.preconditions.cache.size.toLocaleString())} global ${Format.plural(client.preconditions.cache.size, "precondition")}.`);
91
+ logger$1.log(` └─ Loaded ${colors.green(client.postconditions.cache.size.toLocaleString())} global ${Format.plural(client.postconditions.cache.size, "postcondition")}.`);
91
92
  });
92
93
  client.eventListeners.registerProcessExitEvents(async (signal) => RuntimeEnvironment.handleExitSignal(client, signal));
93
94
  },
94
- _onBeforeDestroy: async (client) => {
95
- await client.modules.disableModules();
95
+ _onBeforeDestroy: async (client$1) => {
96
+ await client$1.modules.disableModules();
96
97
  }
97
98
  });
98
- logger.debug(`Logging in...`);
99
+ logger$1.debug(`Logging in...`);
99
100
  await client.login(token);
100
101
  }
101
102
  };
@@ -1 +1 @@
1
- {"version":3,"file":"start.mjs","names":["DiscordJsVersion"],"sources":["../../../src/bin/commands/start.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { CLISubcommand } from '../../classes/cli/CLISubcommand.js';\nimport { ConfigReader } from '../../classes/cli/ConfigReader.js';\nimport { Logger } from '@prtty/print';\nimport { Format, resolveEnvProtocol } from '@reciple/utils';\nimport { Client, CommandType } from '@reciple/core';\nimport { ModuleLoader } from '../../classes/client/ModuleLoader.js';\nimport { ModuleManager } from '../../classes/managers/ModuleManager.js';\nimport { version as DiscordJsVersion } from 'discord.js';\nimport { EventListeners } from '../../classes/client/EventListeners.js';\nimport { RuntimeEnvironment } from '../../classes/cli/RuntimeEnvironment.js';\nimport { build } from 'tsdown';\nimport { CLI } from '../../classes/cli/CLI.js';\nimport { colors } from '@prtty/prtty';\n\nexport default class StartSubcommand extends CLISubcommand {\n public subcommand: Command = new Command('start')\n .description('Start the reciple client')\n .option('-c, --config <path>', 'Path to the configuration file')\n .option('-t, --token <DiscordToken>', 'Set your Discord Bot token')\n .option('-b, --build', 'Build the modules before starting the client')\n .allowUnknownOption(true);\n\n public async execute(): Promise<void> {\n const flags = this.subcommand.opts<StartSubcommand.Flags>();\n const configReader = new ConfigReader(\n flags.config\n ?? await ConfigReader.find()\n ?? ConfigReader.createConfigFilename('js')\n );\n\n const { client, config, build: buildConfig } = await configReader.read();\n\n const logger = config.logger instanceof Logger ? this.cli.logger = config.logger : this.cli.logger.clone(config.logger);\n\n let token = flags.token || config.token || '';\n token = resolveEnvProtocol(token) || token;\n\n function handleProcessError(err: unknown) {\n logger.error(err);\n process.exit(1);\n }\n\n process.once('uncaughtException', handleProcessError);\n process.once('unhandledRejection', handleProcessError);\n process.on('warning', warn => logger.warn(warn));\n\n logger.log(colors.magenta(`⚡ Initializing reciple!`));\n\n if (flags.build) {\n let plugins = buildConfig.plugins\n ? Array.isArray(buildConfig.plugins)\n ? buildConfig.plugins\n : [buildConfig.plugins]\n : [];\n\n plugins.push(CLI.createTsdownLogger());\n\n await build({\n ...buildConfig,\n logLevel: 'silent',\n plugins,\n });\n }\n\n Object.assign(client, {\n logger,\n cli: this.cli,\n config\n });\n\n Object.assign(client, {\n modules: new ModuleManager(client),\n moduleLoader: new ModuleLoader(client),\n eventListeners: new EventListeners()\n });\n\n Reflect.set(global, 'useClient', () => client);\n Reflect.set(global, 'useLogger', () => logger);\n\n EventListeners.registerLoggerEventListeners(client);\n\n logger.log(colors.green(`📦 Version Info:`));\n logger.log(` ├─ ${colors.cyan(`reciple`)}\\t\\t${colors.yellow(`${this.cli.version}`)}`);\n logger.log(` ├─ ${colors.cyan(`@reciple/client`)}\\t${colors.yellow(`${Client.version}`)}`);\n logger.log(` └─ ${colors.cyan(`discord.js`)}\\t${colors.yellow(`${DiscordJsVersion}`)}`);\n\n const modules = await client.moduleLoader.findModules();\n\n Object.assign(client, {\n _onBeforeLogin: async() => {\n const enabledModules = await client.modules.enableModules({ modules });\n\n client.once('clientReady', async() => {\n if (!client.isReady()) return;\n\n EventListeners.registerCommandsEventListeners(client);\n\n logger.debug(`Client is ready!`);\n process.removeListener('uncaughtException', handleProcessError);\n process.removeListener('unhandledRejection', handleProcessError);\n\n const notEnabledModules = modules.length - enabledModules.length;\n logger.log(colors.green(`✅ ${enabledModules.length} ${Format.plural(enabledModules.length, 'module')} ${Format.plural(enabledModules.length, 'is', 'are')} enabled.${notEnabledModules > 0 ? colors.red(` (${notEnabledModules} not enabled)`) : ''}`));\n\n const readyModules = await client.modules.readyModules();\n const notReadyModules = readyModules.length - enabledModules.length;\n\n logger.log(colors.green(`✅ ${readyModules.length} ${Format.plural(readyModules.length, 'module')} ${Format.plural(readyModules.length, 'is', 'are')} ready.${notReadyModules > 0 ? colors.red(` (${notReadyModules} not ready)`) : ''}`));\n\n await client.commands.registerApplicationCommands({\n ...config.applicationCommandsRegister,\n commands: client.commands.applicationCommands,\n });\n\n process.stdin.resume();\n\n const commands = {\n contextMenus: client.commands.cache.filter(c => c.type === CommandType.ContextMenu).size,\n message: client.commands.cache.filter(c => c.type === CommandType.Message).size,\n slash: client.commands.cache.filter(c => c.type === CommandType.Slash).size\n };\n\n logger.log(`🔑 Logged in as ${colors.bold(colors.cyan(client.user.displayName))} ${colors.magenta(`(${client.user.id})`)}`);\n logger.log(` ├─ Loaded ${colors.green(modules.length.toLocaleString())} ${Format.plural(modules.length, 'module')}.`);\n logger.log(` ├─ Loaded ${colors.green(commands.contextMenus.toLocaleString())} context menu ${Format.plural(commands.contextMenus, 'command')}.`);\n logger.log(` ├─ Loaded ${colors.green(commands.message.toLocaleString())} message ${Format.plural(commands.message, 'command')}.`);\n logger.log(` ├─ Loaded ${colors.green(commands.slash.toLocaleString())} slash ${Format.plural(commands.slash, 'command')}.`);\n logger.log(` ├─ Loaded ${colors.green(client.preconditions.cache.size.toLocaleString())} global ${Format.plural(client.preconditions.cache.size, 'precondition')}.`);\n logger.log(` └─ Loaded ${colors.green(client.postconditions.cache.size.toLocaleString())} global ${Format.plural(client.postconditions.cache.size, 'postcondition')}.`);\n });\n\n client.eventListeners.registerProcessExitEvents(async signal => RuntimeEnvironment.handleExitSignal(client, signal));\n },\n _onBeforeDestroy: async (client: Client) => {\n await client.modules.disableModules();\n }\n })\n\n logger.debug(`Logging in...`);\n await client.login(token);\n }\n}\n\nexport namespace StartSubcommand {\n export interface Flags {\n config?: string;\n token?: string;\n build?: boolean;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,IAAqB,kBAArB,cAA6C,cAAc;CACvD,AAAO,aAAsB,IAAI,QAAQ,QAAQ,CAC5C,YAAY,2BAA2B,CACvC,OAAO,uBAAuB,iCAAiC,CAC/D,OAAO,8BAA8B,6BAA6B,CAClE,OAAO,eAAe,+CAA+C,CACrE,mBAAmB,KAAK;CAE7B,MAAa,UAAyB;EAClC,MAAM,QAAQ,KAAK,WAAW,MAA6B;EAO3D,MAAM,EAAE,QAAQ,QAAQ,OAAO,gBAAgB,MAN1B,IAAI,aACrB,MAAM,UACH,MAAM,aAAa,MAAM,IACzB,aAAa,qBAAqB,KAAK,CAC7C,CAEiE,MAAM;EAExE,MAAM,SAAS,OAAO,kBAAkB,SAAS,KAAK,IAAI,SAAS,OAAO,SAAS,KAAK,IAAI,OAAO,MAAM,OAAO,OAAO;EAEvH,IAAI,QAAQ,MAAM,SAAS,OAAO,SAAS;AACvC,UAAQ,mBAAmB,MAAM,IAAI;EAEzC,SAAS,mBAAmB,KAAc;AACtC,UAAO,MAAM,IAAI;AACjB,WAAQ,KAAK,EAAE;;AAGnB,UAAQ,KAAK,qBAAqB,mBAAmB;AACrD,UAAQ,KAAK,sBAAsB,mBAAmB;AACtD,UAAQ,GAAG,YAAW,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cAAc,OAAO,MAAM,SAAS,aAAa,gBAAgB,CAAC,CAAC,gBAAgB,OAAO,OAAO,SAAS,cAAc,UAAU,CAAC,GAAG;AACjJ,YAAO,IAAI,cAAc,OAAO,MAAM,SAAS,QAAQ,gBAAgB,CAAC,CAAC,WAAW,OAAO,OAAO,SAAS,SAAS,UAAU,CAAC,GAAG;AAClI,YAAO,IAAI,cAAc,OAAO,MAAM,SAAS,MAAM,gBAAgB,CAAC,CAAC,SAAS,OAAO,OAAO,SAAS,OAAO,UAAU,CAAC,GAAG;AAC5H,YAAO,IAAI,cAAc,OAAO,MAAM,OAAO,cAAc,MAAM,KAAK,gBAAgB,CAAC,CAAC,UAAU,OAAO,OAAO,OAAO,cAAc,MAAM,MAAM,eAAe,CAAC,GAAG;AACpK,YAAO,IAAI,cAAc,OAAO,MAAM,OAAO,eAAe,MAAM,KAAK,gBAAgB,CAAC,CAAC,UAAU,OAAO,OAAO,OAAO,eAAe,MAAM,MAAM,gBAAgB,CAAC,GAAG;MACzK;AAEF,WAAO,eAAe,0BAA0B,OAAM,WAAU,mBAAmB,iBAAiB,QAAQ,OAAO,CAAC;;GAExH,kBAAkB,OAAO,WAAmB;AACxC,UAAM,OAAO,QAAQ,gBAAgB;;GAE5C,CAAC;AAEF,SAAO,MAAM,gBAAgB;AAC7B,QAAM,OAAO,MAAM,MAAM"}
1
+ {"version":3,"file":"start.mjs","names":["logger","DiscordJsVersion","client"],"sources":["../../../src/bin/commands/start.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { CLISubcommand } from '../../classes/cli/CLISubcommand.js';\nimport { ConfigReader } from '../../classes/cli/ConfigReader.js';\nimport { Logger } from '@prtty/print';\nimport { Format, resolveEnvProtocol } from '@reciple/utils';\nimport { Client, CommandType } from '@reciple/core';\nimport { ModuleLoader } from '../../classes/client/ModuleLoader.js';\nimport { ModuleManager } from '../../classes/managers/ModuleManager.js';\nimport { version as DiscordJsVersion } from 'discord.js';\nimport { EventListeners } from '../../classes/client/EventListeners.js';\nimport { RuntimeEnvironment } from '../../classes/cli/RuntimeEnvironment.js';\nimport { build } from 'tsdown';\nimport { CLI } from '../../classes/cli/CLI.js';\nimport { colors } from '@prtty/prtty';\n\nexport default class StartSubcommand extends CLISubcommand {\n public subcommand: Command = new Command('start')\n .description('Start the reciple client')\n .argument('[project]', 'The root directory of your project')\n .option('-t, --token <DiscordToken>', 'Set your Discord Bot token')\n .option('-b, --build', 'Build the modules before starting the client')\n .allowUnknownOption(true);\n\n public async execute(): Promise<void> {\n const flags = this.subcommand.opts<StartSubcommand.Flags>();\n\n await this.cli.setCurrentDirectory(this.subcommand.args[0]);\n\n const configReader = new ConfigReader(\n await ConfigReader.find()\n ?? ConfigReader.createConfigFilename('js')\n );\n\n const { client, config, build: buildConfig } = await configReader.read();\n\n const logger = config.logger instanceof Logger ? this.cli.logger = config.logger : this.cli.logger.clone(config.logger);\n\n let token = flags.token || config.token || '';\n token = resolveEnvProtocol(token) || token;\n\n function handleProcessError(err: unknown) {\n logger.error(err);\n process.exit(1);\n }\n\n process.once('uncaughtException', handleProcessError);\n process.once('unhandledRejection', handleProcessError);\n process.on('warning', warn => logger.warn(warn));\n\n logger.log(colors.magenta(`⚡ Initializing reciple!`));\n\n if (flags.build) {\n let plugins = buildConfig.plugins\n ? Array.isArray(buildConfig.plugins)\n ? buildConfig.plugins\n : [buildConfig.plugins]\n : [];\n\n plugins.push(CLI.createTsdownLogger());\n\n await build({\n ...buildConfig,\n logLevel: 'silent',\n plugins,\n });\n }\n\n Object.assign(client, {\n logger,\n cli: this.cli,\n config\n });\n\n Object.assign(client, {\n modules: new ModuleManager(client),\n moduleLoader: new ModuleLoader(client),\n eventListeners: new EventListeners()\n });\n\n Reflect.set(global, 'useClient', () => client);\n Reflect.set(global, 'useLogger', () => logger);\n\n EventListeners.registerLoggerEventListeners(client);\n\n logger.log(colors.green(`📦 Version Info:`));\n logger.log(` ├─ ${colors.cyan(`reciple`)}\\t\\t${colors.yellow(`${this.cli.version}`)}`);\n logger.log(` ├─ ${colors.cyan(`@reciple/client`)}\\t${colors.yellow(`${Client.version}`)}`);\n logger.log(` └─ ${colors.cyan(`discord.js`)}\\t${colors.yellow(`${DiscordJsVersion}`)}`);\n\n const modules = await client.moduleLoader.findModules();\n\n Object.assign(client, {\n _onBeforeLogin: async() => {\n const enabledModules = await client.modules.enableModules({ modules });\n\n client.once('clientReady', async() => {\n if (!client.isReady()) return;\n\n EventListeners.registerCommandsEventListeners(client);\n\n logger.debug(`Client is ready!`);\n process.removeListener('uncaughtException', handleProcessError);\n process.removeListener('unhandledRejection', handleProcessError);\n\n const notEnabledModules = modules.length - enabledModules.length;\n logger.log(colors.green(`✅ ${enabledModules.length} ${Format.plural(enabledModules.length, 'module')} ${Format.plural(enabledModules.length, 'is', 'are')} enabled.${notEnabledModules > 0 ? colors.red(` (${notEnabledModules} not enabled)`) : ''}`));\n\n const readyModules = await client.modules.readyModules();\n const notReadyModules = readyModules.length - enabledModules.length;\n\n logger.log(colors.green(`✅ ${readyModules.length} ${Format.plural(readyModules.length, 'module')} ${Format.plural(readyModules.length, 'is', 'are')} ready.${notReadyModules > 0 ? colors.red(` (${notReadyModules} not ready)`) : ''}`));\n\n await client.commands.registerApplicationCommands({\n ...config.applicationCommandsRegister,\n commands: client.commands.applicationCommands,\n });\n\n process.stdin.resume();\n\n const commands = {\n contextMenus: client.commands.cache.filter(c => c.type === CommandType.ContextMenu).size,\n message: client.commands.cache.filter(c => c.type === CommandType.Message).size,\n slash: client.commands.cache.filter(c => c.type === CommandType.Slash).size\n };\n\n logger.log(`🔑 Logged in as ${colors.bold(colors.cyan(client.user.displayName))} ${colors.magenta(`(${client.user.id})`)}`);\n logger.log(` ├─ Loaded ${colors.green(modules.length.toLocaleString())} ${Format.plural(modules.length, 'module')}.`);\n logger.log(` ├─ Loaded ${colors.green(commands.contextMenus.toLocaleString())} context menu ${Format.plural(commands.contextMenus, 'command')}.`);\n logger.log(` ├─ Loaded ${colors.green(commands.message.toLocaleString())} message ${Format.plural(commands.message, 'command')}.`);\n logger.log(` ├─ Loaded ${colors.green(commands.slash.toLocaleString())} slash ${Format.plural(commands.slash, 'command')}.`);\n logger.log(` ├─ Loaded ${colors.green(client.preconditions.cache.size.toLocaleString())} global ${Format.plural(client.preconditions.cache.size, 'precondition')}.`);\n logger.log(` └─ Loaded ${colors.green(client.postconditions.cache.size.toLocaleString())} global ${Format.plural(client.postconditions.cache.size, 'postcondition')}.`);\n });\n\n client.eventListeners.registerProcessExitEvents(async signal => RuntimeEnvironment.handleExitSignal(client, signal));\n },\n _onBeforeDestroy: async (client: Client) => {\n await client.modules.disableModules();\n }\n })\n\n logger.debug(`Logging in...`);\n await client.login(token);\n }\n}\n\nexport namespace StartSubcommand {\n export interface Flags {\n token?: string;\n build?: boolean;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,IAAqB,kBAArB,cAA6C,cAAc;CACvD,AAAO,aAAsB,IAAI,QAAQ,QAAQ,CAC5C,YAAY,2BAA2B,CACvC,SAAS,aAAa,qCAAqC,CAC3D,OAAO,8BAA8B,6BAA6B,CAClE,OAAO,eAAe,+CAA+C,CACrE,mBAAmB,KAAK;CAE7B,MAAa,UAAyB;EAClC,MAAM,QAAQ,KAAK,WAAW,MAA6B;AAE3D,QAAM,KAAK,IAAI,oBAAoB,KAAK,WAAW,KAAK,GAAG;EAO3D,MAAM,EAAE,QAAQ,QAAQ,OAAO,gBAAgB,MAL1B,IAAI,aACrB,MAAM,aAAa,MAAM,IACtB,aAAa,qBAAqB,KAAK,CAC7C,CAEiE,MAAM;EAExE,MAAMA,WAAS,OAAO,kBAAkB,SAAS,KAAK,IAAI,SAAS,OAAO,SAAS,KAAK,IAAI,OAAO,MAAM,OAAO,OAAO;EAEvH,IAAI,QAAQ,MAAM,SAAS,OAAO,SAAS;AACvC,UAAQ,mBAAmB,MAAM,IAAI;EAEzC,SAAS,mBAAmB,KAAc;AACtC,YAAO,MAAM,IAAI;AACjB,WAAQ,KAAK,EAAE;;A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Q,OAAO,gBAAgB,CAAC,CAAC,GAAG,OAAO,OAAO,QAAQ,QAAQ,SAAS,CAAC,GAAG;AACrH,cAAO,IAAI,cAAc,OAAO,MAAM,SAAS,aAAa,gBAAgB,CAAC,CAAC,gBAAgB,OAAO,OAAO,SAAS,cAAc,UAAU,CAAC,GAAG;AACjJ,cAAO,IAAI,cAAc,OAAO,MAAM,SAAS,QAAQ,gBAAgB,CAAC,CAAC,WAAW,OAAO,OAAO,SAAS,SAAS,UAAU,CAAC,GAAG;AAClI,cAAO,IAAI,cAAc,OAAO,MAAM,SAAS,MAAM,gBAAgB,CAAC,CAAC,SAAS,OAAO,OAAO,SAAS,OAAO,UAAU,CAAC,GAAG;AAC5H,cAAO,IAAI,cAAc,OAAO,MAAM,OAAO,cAAc,MAAM,KAAK,gBAAgB,CAAC,CAAC,UAAU,OAAO,OAAO,OAAO,cAAc,MAAM,MAAM,eAAe,CAAC,GAAG;AACpK,cAAO,IAAI,cAAc,OAAO,MAAM,OAAO,eAAe,MAAM,KAAK,gBAAgB,CAAC,CAAC,UAAU,OAAO,OAAO,OAAO,eAAe,MAAM,MAAM,gBAAgB,CAAC,GAAG;MACzK;AAEF,WAAO,eAAe,0BAA0B,OAAM,WAAU,mBAAmB,iBAAiB,QAAQ,OAAO,CAAC;;GAExH,kBAAkB,OAAO,aAAmB;AACxC,UAAMC,SAAO,QAAQ,gBAAgB;;GAE5C,CAAC;AAEF,WAAO,MAAM,gBAAgB;AAC7B,QAAM,OAAO,MAAM,MAAM"}
@@ -12,30 +12,31 @@ import { build } from "tsdown";
12
12
  //#region src/bin/commands/startSharding.ts
13
13
  var StartShardingSubcommand = class extends CLISubcommand {
14
14
  parent = "start";
15
- subcommand = new Command("sharding").description("Start the reciple client in sharding mode").option("-c, --config <path>", "Path to the configuration file").option("-t, --token <DiscordToken>", "Set your Discord Bot token").option("-b, --build", "Build the modules before starting the client").allowUnknownOption(true);
15
+ subcommand = new Command("sharding").description("Start the reciple client in sharding mode").argument("[project]", "The root directory of your project").option("-t, --token <DiscordToken>", "Set your Discord Bot token").option("-b, --build", "Build the modules before starting the client").allowUnknownOption(true);
16
16
  async execute() {
17
17
  process.env.RECIPLE_SHARDING = "true";
18
18
  process.env.RECIPLE_FIRST_SHARD = "true";
19
19
  const recipleFlags = this.cli.getFlags();
20
20
  const flags = this.subcommand.opts();
21
+ await this.cli.setCurrentDirectory(this.subcommand.args[0]);
21
22
  const shardArgs = [
22
23
  ...CLI.stringifyFlags(recipleFlags, this.cli.command),
23
24
  "start",
24
25
  ...CLI.stringifyFlags(flags, this.command)
25
26
  ];
26
- const { config, build: buildConfig, sharding } = await new ConfigReader(flags.config ?? await ConfigReader.find() ?? ConfigReader.createConfigFilename("js")).read({ ignoreInstanceCheck: true });
27
- const logger = config.logger instanceof Logger ? this.cli.logger = config.logger : this.cli.logger.clone(config.logger);
28
- logger.label = "ShardingManager";
27
+ const { config, build: buildConfig, sharding } = await new ConfigReader(await ConfigReader.find() ?? ConfigReader.createConfigFilename("js")).read();
28
+ const logger$1 = config.logger instanceof Logger ? this.cli.logger = config.logger : this.cli.logger.clone(config.logger);
29
+ logger$1.label = "ShardingManager";
29
30
  let token = flags.token || config.token || "";
30
31
  token = resolveEnvProtocol(token) || token;
31
- logger.log(colors.magenta(`⚡ Initializing reciple sharding manager!`));
32
+ logger$1.log(colors.magenta(`⚡ Initializing reciple sharding manager!`));
32
33
  const processErrorLogger = (err) => {
33
- logger?.error(err);
34
+ logger$1?.error(err);
34
35
  process.exit(1);
35
36
  };
36
37
  process.once("uncaughtException", processErrorLogger);
37
38
  process.once("unhandledRejection", processErrorLogger);
38
- process.on("warning", (warn) => logger.warn(warn));
39
+ process.on("warning", (warn) => logger$1.warn(warn));
39
40
  if (flags.build) {
40
41
  let plugins = buildConfig.plugins ? Array.isArray(buildConfig.plugins) ? buildConfig.plugins : [buildConfig.plugins] : [];
41
42
  plugins.push(CLI.createTsdownLogger());
@@ -46,10 +47,10 @@ var StartShardingSubcommand = class extends CLISubcommand {
46
47
  });
47
48
  }
48
49
  if (!sharding) {
49
- logger.error("Sharding is not enabled in the config file");
50
+ logger$1.error("Sharding is not enabled in the config file");
50
51
  process.exit(1);
51
52
  }
52
- Reflect.set(global, "useLogger", () => logger);
53
+ Reflect.set(global, "useLogger", () => logger$1);
53
54
  const eventListeners = new EventListeners();
54
55
  const manager = new ShardingManager(CLI.bin, {
55
56
  ...sharding,
@@ -57,25 +58,25 @@ var StartShardingSubcommand = class extends CLISubcommand {
57
58
  shardArgs
58
59
  });
59
60
  manager.on("shardCreate", (shard) => {
60
- logger.log(colors.magenta(`🚀 Launched shard ${colors.green(String(shard.id))}`));
61
+ logger$1.log(colors.magenta(`🚀 Launched shard ${colors.green(String(shard.id))}`));
61
62
  shard.on("ready", () => {
62
- logger.log(colors.magenta(`✅ Shard ${colors.green(String(shard.id))} is ready!`));
63
+ logger$1.log(colors.magenta(`✅ Shard ${colors.green(String(shard.id))} is ready!`));
63
64
  if (process.env.RECIPLE_FIRST_SHARD === "true") process.env.RECIPLE_FIRST_SHARD = "false";
64
65
  });
65
66
  shard.on("reconnecting", () => {
66
- logger.log(colors.magenta(`🔄 Shard ${colors.green(String(shard.id))} is reconnecting...`));
67
+ logger$1.log(colors.magenta(`🔄 Shard ${colors.green(String(shard.id))} is reconnecting...`));
67
68
  });
68
69
  shard.on("resume", () => {
69
- logger.log(colors.magenta(`✅ Shard ${colors.green(String(shard.id))} has resumed!`));
70
+ logger$1.log(colors.magenta(`✅ Shard ${colors.green(String(shard.id))} has resumed!`));
70
71
  });
71
72
  shard.on("disconnect", () => {
72
- logger.log(colors.magenta(`🛑 Shard ${colors.green(String(shard.id))} is disconnected!`));
73
+ logger$1.log(colors.magenta(`🛑 Shard ${colors.green(String(shard.id))} is disconnected!`));
73
74
  });
74
75
  shard.on("death", () => {
75
- logger.error(`🛑 Shard ${colors.green(String(shard.id))} has died!`);
76
+ logger$1.error(`🛑 Shard ${colors.green(String(shard.id))} has died!`);
76
77
  });
77
78
  shard.on("error", (error) => {
78
- logger.error(`❌ Shard ${colors.green(String(shard.id))} encountered an error:`, error);
79
+ logger$1.error(`❌ Shard ${colors.green(String(shard.id))} encountered an error:`, error);
79
80
  });
80
81
  shard.on("message", (message) => {});
81
82
  });
@@ -84,14 +85,14 @@ var StartShardingSubcommand = class extends CLISubcommand {
84
85
  await manager.spawn();
85
86
  }
86
87
  destroyShardingManager(manager) {
87
- const logger = useLogger();
88
+ const logger$1 = useLogger();
88
89
  manager.shards.map((s) => {
89
- logger.log(colors.magenta(`🚧 Destroying shard ${s.id}`));
90
+ logger$1.log(colors.magenta(`🚧 Destroying shard ${s.id}`));
90
91
  if (s.process) s.process.kill();
91
92
  else s.kill();
92
- logger.log(colors.magenta(`🛑 Destroyed shard ${s.id}`));
93
+ logger$1.log(colors.magenta(`🛑 Destroyed shard ${s.id}`));
93
94
  });
94
- logger.log(colors.magenta(`🚨 Destroyed all shards`));
95
+ logger$1.log(colors.magenta(`🚨 Destroyed all shards`));
95
96
  setTimeout(() => process.exit(0), 500);
96
97
  }
97
98
  };
@@ -1 +1 @@
1
- {"version":3,"file":"startSharding.mjs","names":[],"sources":["../../../src/bin/commands/startSharding.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { CLISubcommand } from '../../classes/cli/CLISubcommand.js';\nimport { ConfigReader } from '../../classes/cli/ConfigReader.js';\nimport type { StartSubcommand } from './start.js';\nimport { Logger } from '@prtty/print';\nimport { resolveEnvProtocol } from '@reciple/utils';\nimport { colors } from '@prtty/prtty';\nimport { CLI } from '../../classes/cli/CLI.js';\nimport { build } from 'tsdown';\nimport { ShardingManager } from 'discord.js';\nimport { EventListeners } from '../../classes/client/EventListeners.js';\n\nexport default class StartShardingSubcommand extends CLISubcommand {\n public parent?: string = 'start';\n\n public subcommand: Command = new Command('sharding')\n .description('Start the reciple client in sharding mode')\n .option('-c, --config <path>', 'Path to the configuration file')\n .option('-t, --token <DiscordToken>', 'Set your Discord Bot token')\n .option('-b, --build', 'Build the modules before starting the client')\n .allowUnknownOption(true);\n\n public async execute(): Promise<void> {\n process.env.RECIPLE_SHARDING = 'true';\n process.env.RECIPLE_FIRST_SHARD = 'true';\n\n const recipleFlags = this.cli.getFlags();\n const flags = this.subcommand.opts<ShardingSubcommand.Flags>();\n\n const shardArgs: string[] = [\n ...CLI.stringifyFlags(recipleFlags, this.cli.command),\n 'start',\n ...CLI.stringifyFlags(flags, this.command)\n ];\n\n const configReader = new ConfigReader(\n flags.config\n ?? await ConfigReader.find()\n ?? ConfigReader.createConfigFilename('js')\n );\n\n const { config, build: buildConfig, sharding } = await configReader.read({ ignoreInstanceCheck: true });\n\n const logger = config.logger instanceof Logger ? this.cli.logger = config.logger : this.cli.logger.clone(config.logger);\n\n logger.label = 'ShardingManager';\n\n let token = flags.token || config.token || '';\n token = resolveEnvProtocol(token) || token;\n\n logger.log(colors.magenta(`⚡ Initializing reciple sharding manager!`));\n\n const processErrorLogger = (err: any) => {\n logger?.error(err);\n process.exit(1);\n };\n\n process.once('uncaughtException', processErrorLogger);\n process.once('unhandledRejection', processErrorLogger);\n process.on('warning', warn => logger.warn(warn));\n\n if (flags.build) {\n let plugins = buildConfig.plugins\n ? Array.isArray(buildConfig.plugins)\n ? buildConfig.plugins\n : [buildConfig.plugins]\n : [];\n\n plugins.push(CLI.createTsdownLogger());\n\n await build({\n ...buildConfig,\n logLevel: 'silent',\n plugins,\n });\n }\n\n if (!sharding) {\n logger.error('Sharding is not enabled in the config file');\n process.exit(1);\n }\n\n Reflect.set(global, 'useLogger', () => logger);\n\n const eventListeners = new EventListeners();\n const manager = new ShardingManager(CLI.bin, {\n ...sharding,\n token: token,\n shardArgs\n });\n\n manager.on('shardCreate', shard => {\n logger.log(colors.magenta(`🚀 Launched shard ${colors.green(String(shard.id))}`));\n\n shard.on('ready', () => {\n logger.log(colors.magenta(`✅ Shard ${colors.green(String(shard.id))} is ready!`));\n\n if (process.env.RECIPLE_FIRST_SHARD === 'true') {\n process.env.RECIPLE_FIRST_SHARD = 'false';\n }\n });\n\n shard.on('reconnecting', () => {\n logger.log(colors.magenta(`🔄 Shard ${colors.green(String(shard.id))} is reconnecting...`));\n });\n\n shard.on('resume', () => {\n logger.log(colors.magenta(`✅ Shard ${colors.green(String(shard.id))} has resumed!`));\n });\n\n shard.on('disconnect', () => {\n logger.log(colors.magenta(`🛑 Shard ${colors.green(String(shard.id))} is disconnected!`));\n });\n\n shard.on('death', () => {\n logger.error(`🛑 Shard ${colors.green(String(shard.id))} has died!`);\n });\n\n shard.on('error', error => {\n logger.error(`❌ Shard ${colors.green(String(shard.id))} encountered an error:`, error);\n });\n\n shard.on('message', message => {\n // TODO: Handle shard messages\n });\n });\n\n eventListeners.registerProcessExitEvents(signal => this.destroyShardingManager(manager));\n process.stdin.resume();\n\n await manager.spawn();\n }\n\n public destroyShardingManager(manager: ShardingManager): void {\n const logger = useLogger();\n\n manager.shards.map(s => {\n logger.log(colors.magenta(`🚧 Destroying shard ${s.id}`));\n\n if (s.process) {\n s.process.kill();\n } else {\n s.kill();\n }\n\n logger.log(colors.magenta(`🛑 Destroyed shard ${s.id}`));\n });\n\n logger.log(colors.magenta(`🚨 Destroyed all shards`));\n setTimeout(() => process.exit(0), 500);\n }\n}\n\nexport namespace ShardingSubcommand {\n export interface Flags extends StartSubcommand.Flags {}\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAqB,0BAArB,cAAqD,cAAc;CAC/D,AAAO,SAAkB;CAEzB,AAAO,aAAsB,IAAI,QAAQ,WAAW,CAC/C,YAAY,4CAA4C,CACxD,OAAO,uBAAuB,iCAAiC,CAC/D,OAAO,8BAA8B,6BAA6B,CAClE,OAAO,eAAe,+CAA+C,CACrE,mBAAmB,KAAK;CAE7B,MAAa,UAAyB;AAClC,UAAQ,IAAI,mBAAmB;AAC/B,UAAQ,IAAI,sBAAsB;EAElC,MAAM,eAAe,KAAK,IAAI,UAAU;EACxC,MAAM,QAAQ,KAAK,WAAW,MAAgC;EAE9D,MAAM,YAAsB;GACxB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IAAI,OAAO,QAAQ,sBAAsB,EAAE,KAAK,CAAC;IAC1D;AAEF,SAAO,IAAI,OAAO,QAAQ,0BAA0B,CAAC;AACrD,mBAAiB,QAAQ,KAAK,EAAE,EAAE,IAAI"}
1
+ {"version":3,"file":"startSharding.mjs","names":["logger"],"sources":["../../../src/bin/commands/startSharding.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { CLISubcommand } from '../../classes/cli/CLISubcommand.js';\nimport { ConfigReader } from '../../classes/cli/ConfigReader.js';\nimport type { StartSubcommand } from './start.js';\nimport { Logger } from '@prtty/print';\nimport { resolveEnvProtocol } from '@reciple/utils';\nimport { colors } from '@prtty/prtty';\nimport { CLI } from '../../classes/cli/CLI.js';\nimport { build } from 'tsdown';\nimport { ShardingManager } from 'discord.js';\nimport { EventListeners } from '../../classes/client/EventListeners.js';\n\nexport default class StartShardingSubcommand extends CLISubcommand {\n public parent?: string = 'start';\n\n public subcommand: Command = new Command('sharding')\n .description('Start the reciple client in sharding mode')\n .argument('[project]', 'The root directory of your project')\n .option('-t, --token <DiscordToken>', 'Set your Discord Bot token')\n .option('-b, --build', 'Build the modules before starting the client')\n .allowUnknownOption(true);\n\n public async execute(): Promise<void> {\n process.env.RECIPLE_SHARDING = 'true';\n process.env.RECIPLE_FIRST_SHARD = 'true';\n\n const recipleFlags = this.cli.getFlags();\n const flags = this.subcommand.opts<ShardingSubcommand.Flags>();\n\n await this.cli.setCurrentDirectory(this.subcommand.args[0]);\n\n const shardArgs: string[] = [\n ...CLI.stringifyFlags(recipleFlags, this.cli.command),\n 'start',\n ...CLI.stringifyFlags(flags, this.command)\n ];\n\n const configReader = new ConfigReader(\n await ConfigReader.find()\n ?? ConfigReader.createConfigFilename('js')\n );\n\n const { config, build: buildConfig, sharding } = await configReader.read();\n const logger = config.logger instanceof Logger ? this.cli.logger = config.logger : this.cli.logger.clone(config.logger);\n\n logger.label = 'ShardingManager';\n\n let token = flags.token || config.token || '';\n token = resolveEnvProtocol(token) || token;\n\n logger.log(colors.magenta(`⚡ Initializing reciple sharding manager!`));\n\n const processErrorLogger = (err: any) => {\n logger?.error(err);\n process.exit(1);\n };\n\n process.once('uncaughtException', processErrorLogger);\n process.once('unhandledRejection', processErrorLogger);\n process.on('warning', warn => logger.warn(warn));\n\n if (flags.build) {\n let plugins = buildConfig.plugins\n ? Array.isArray(buildConfig.plugins)\n ? buildConfig.plugins\n : [buildConfig.plugins]\n : [];\n\n plugins.push(CLI.createTsdownLogger());\n\n await build({\n ...buildConfig,\n logLevel: 'silent',\n plugins,\n });\n }\n\n if (!sharding) {\n logger.error('Sharding is not enabled in the config file');\n process.exit(1);\n }\n\n Reflect.set(global, 'useLogger', () => logger);\n\n const eventListeners = new EventListeners();\n const manager = new ShardingManager(CLI.bin, {\n ...sharding,\n token: token,\n shardArgs\n });\n\n manager.on('shardCreate', shard => {\n logger.log(colors.magenta(`🚀 Launched shard ${colors.green(String(shard.id))}`));\n\n shard.on('ready', () => {\n logger.log(colors.magenta(`✅ Shard ${colors.green(String(shard.id))} is ready!`));\n\n if (process.env.RECIPLE_FIRST_SHARD === 'true') {\n process.env.RECIPLE_FIRST_SHARD = 'false';\n }\n });\n\n shard.on('reconnecting', () => {\n logger.log(colors.magenta(`🔄 Shard ${colors.green(String(shard.id))} is reconnecting...`));\n });\n\n shard.on('resume', () => {\n logger.log(colors.magenta(`✅ Shard ${colors.green(String(shard.id))} has resumed!`));\n });\n\n shard.on('disconnect', () => {\n logger.log(colors.magenta(`🛑 Shard ${colors.green(String(shard.id))} is disconnected!`));\n });\n\n shard.on('death', () => {\n logger.error(`🛑 Shard ${colors.green(String(shard.id))} has died!`);\n });\n\n shard.on('error', error => {\n logger.error(`❌ Shard ${colors.green(String(shard.id))} encountered an error:`, error);\n });\n\n shard.on('message', message => {\n // TODO: Handle shard messages\n });\n });\n\n eventListeners.registerProcessExitEvents(signal => this.destroyShardingManager(manager));\n process.stdin.resume();\n\n await manager.spawn();\n }\n\n public destroyShardingManager(manager: ShardingManager): void {\n const logger = useLogger();\n\n manager.shards.map(s => {\n logger.log(colors.magenta(`🚧 Destroying shard ${s.id}`));\n\n if (s.process) {\n s.process.kill();\n } else {\n s.kill();\n }\n\n logger.log(colors.magenta(`🛑 Destroyed shard ${s.id}`));\n });\n\n logger.log(colors.magenta(`🚨 Destroyed all shards`));\n setTimeout(() => process.exit(0), 500);\n }\n}\n\nexport namespace ShardingSubcommand {\n export interface Flags extends StartSubcommand.Flags {}\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAqB,0BAArB,cAAqD,cAAc;CAC/D,AAAO,SAAkB;CAEzB,AAAO,aAAsB,IAAI,QAAQ,WAAW,CAC/C,YAAY,4CAA4C,CACxD,SAAS,aAAa,qCAAqC,CAC3D,OAAO,8BAA8B,6BAA6B,CAClE,OAAO,eAAe,+CAA+C,CACrE,mBAAmB,KAAK;CAE7B,MAAa,UAAyB;AAClC,UAAQ,IAAI,mBAAmB;AAC/B,UAAQ,IAAI,sBAAsB;EAElC,MAAM,eAAe,KAAK,IAAI,UAAU;EACxC,MAAM,QAAQ,KAAK,WAAW,MAAgC;AAE9D,QAAM,KAAK,IAAI,oBAAoB,KAAK,WAAW,KAAK,GAAG;EAE3D,MAAM,YAAsB;GACxB,GAAG,IAAI,eAAe,cAAc,KAAK,IAAI,QAAQ;GACrD;GACA,GAAG,IAAI,eAAe,OAAO,KAAK,QAAQ;GAC7C;EAOD,MAAM,EAAE,QAAQ,OAAO,aAAa,aAAa,MAL5B,IAAI,aACrB,MAAM,aAAa,MAAM,IACtB,aAAa,qBAAqB,KAAK,CAC7C,CAEmE,MAAM;EAC1E,MAAMA,WAAS,OAAO,kBAAkB,SAAS,KAAK,IAAI,SAAS,OAAO,SAAS,KAAK,IAAI,OAAO,MAAM,OAAO,OAAO;AAEvH,WAAO,QAAQ;EAEf,IAAI,QAAQ,MAAM,SAAS,OAAO,SAAS;AACvC,UAAQ,mBAAmB,MAAM,IAAI;AAEzC,WAAO,IAAI,OAAO,QAAQ,2CA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AC;KACtF;AAEF,SAAM,GAAG,oBAAoB;AACzB,aAAO,IAAI,OAAO,QAAQ,YAAY,OAAO,MAAM,OAAO,MAAM,GAAG,CAAC,CAAC,mBAAmB,CAAC;KAC3F;AAEF,SAAM,GAAG,eAAe;AACpB,aAAO,MAAM,YAAY,OAAO,MAAM,OAAO,MAAM,GAAG,CAAC,CAAC,YAAY;KACtE;AAEF,SAAM,GAAG,UAAS,UAAS;AACvB,aAAO,MAAM,WAAW,OAAO,MAAM,OAAO,MAAM,GAAG,CAAC,CAAC,yBAAyB,MAAM;KACxF;AAEF,SAAM,GAAG,YAAW,YAAW,GAE7B;IACJ;AAEF,iBAAe,2BAA0B,WAAU,KAAK,uBAAuB,QAAQ,CAAC;AACxF,UAAQ,MAAM,QAAQ;AAEtB,QAAM,QAAQ,OAAO;;CAGzB,AAAO,uBAAuB,SAAgC;EAC1D,MAAMA,WAAS,WAAW;AAE1B,UAAQ,OAAO,KAAI,MAAK;AACpB,YAAO,IAAI,OAAO,QAAQ,uBAAuB,EAAE,KAAK,CAAC;AAEzD,OAAI,EAAE,QACF,GAAE,QAAQ,MAAM;OAEhB,GAAE,MAAM;AAGZ,YAAO,IAAI,OAAO,QAAQ,sBAAsB,EAAE,KAAK,CAAC;IAC1D;AAEF,WAAO,IAAI,OAAO,QAAQ,0BAA0B,CAAC;AACrD,mBAAiB,QAAQ,KAAK,EAAE,EAAE,IAAI"}
@@ -16,6 +16,7 @@ declare class CLI {
16
16
  parse(argv?: string[]): Promise<this>;
17
17
  loadCommands(): Promise<void>;
18
18
  handlePreAction(cmd: Command, action: Command): Promise<void>;
19
+ setCurrentDirectory(cwd?: string): Promise<void>;
19
20
  getFlags<Flags extends Record<string, any> = Record<string, any>>(command: Command | string, mergeDefault?: false): Flags | undefined;
20
21
  getFlags<Flags extends Record<string, any> = Record<string, any>>(command: Command | string, mergeDefault: true): Flags & CLI.Flags | undefined;
21
22
  getFlags(command?: undefined): CLI.Flags;
@@ -70,6 +70,14 @@ var CLI = class {
70
70
  });
71
71
  this.logger.debug(`Loaded environment variables from ${this.flags.env.join(", ")}`);
72
72
  }
73
+ async setCurrentDirectory(cwd) {
74
+ cwd ??= process.cwd();
75
+ if (!await stat(cwd).then((s) => s.isDirectory()).catch(() => false)) {
76
+ console.log(colors.red("Please specify a valid project directory"));
77
+ process.exit(1);
78
+ }
79
+ process.chdir(cwd);
80
+ }
73
81
  getFlags(command, mergeDefault = false) {
74
82
  if (!command) return this.flags;
75
83
  command = typeof command === "string" ? this.command.commands.find((c) => c.name() === command) : command;
@@ -87,7 +95,7 @@ var CLI = class {
87
95
  (function(_CLI) {
88
96
  _CLI.root = path.join(path.dirname(fileURLToPath(import.meta.url)), "../../../");
89
97
  _CLI.bin = path.join(CLI.root, "dist/bin/reciple.mjs");
90
- _CLI.version = "10.0.5";
98
+ _CLI.version = "10.0.7";
91
99
  function stringifyFlags(flags, command, ignored = []) {
92
100
  let arr = [];
93
101
  for (const [key, value] of Object.entries(flags)) {
@@ -1 +1 @@
1
- {"version":3,"file":"CLI.mjs","names":[],"sources":["../../../src/classes/cli/CLI.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { fileURLToPath } from 'node:url';\nimport path from 'node:path';\nimport { coerce } from 'semver';\nimport { Format, isDebugging, recursiveDefaults } from '@reciple/utils';\nimport { logger, Logger, LogLevel } from '@prtty/print';\nimport { config as loadEnv } from '@dotenvx/dotenvx';\nimport { readdir, stat } from 'node:fs/promises';\nimport { CLISubcommand } from './CLISubcommand.js';\nimport { spinner, type SpinnerOptions } from '@clack/prompts';\nimport type { RolldownPlugin } from 'rolldown';\nimport { colors } from '@prtty/prtty';\n\nexport class CLI {\n public build: string;\n public version: string;\n public command: Command;\n public logger: Logger;\n\n get isDebugging(): boolean {\n return this.flags.debug;\n }\n\n get flags(): CLI.Flags {\n return this.command.opts();\n }\n\n constructor(public readonly options: CLI.Options) {\n this.build = options.build;\n this.version = String(coerce(this.build) ?? this.build);\n\n this.command = new Command()\n .name(options.name)\n .description(options.description)\n .version(options.build, '-v, --version', 'Output the CLI version number')\n .option('-D, --debug', 'Enable debug mode', isDebugging())\n .option('--no-debug', 'Disabled debug mode')\n .option('--env <file>', 'Load environment variables from .env file', (v, p) => p.concat(v), [] as string[])\n .enablePositionalOptions(true)\n .hook('preAction', this.handlePreAction.bind(this))\n .showHelpAfterError();\n\n this.logger = options.logger instanceof Logger ? options.logger : new Logger(options.logger);\n\n if (this.flags.debug) {\n this.logger.logLevel = LogLevel.Debug;\n this.logger.writeLevel = LogLevel.Debug;\n }\n }\n\n public async parse(argv?: string[]): Promise<this> {\n await this.loadCommands();\n await this.command.parseAsync(argv);\n return this;\n }\n\n public async loadCommands(): Promise<void> {\n this.logger.debug(`Loading cli commands from ${this.options.subcommandsDir}`);\n\n const dirStat = await stat(this.options.subcommandsDir).catch(() => undefined);\n if (!dirStat?.isDirectory()) return;\n\n const files = (await readdir(this.options.subcommandsDir))\n .map(f => path.join(this.options.subcommandsDir, f))\n .filter(f => f.endsWith('.mjs'));\n\n const hasParent: CLISubcommand[] = [];\n\n for (const file of files) {\n const Subommand = recursiveDefaults<CLISubcommand.Constructor>(await import(path.isAbsolute(file) ? `file://${file}` : file));\n if (!Subommand || typeof Subommand !== 'function') continue;\n\n const instance = new Subommand({ cli: this, command: this.command });\n\n if (instance.parent) {\n hasParent.push(instance);\n continue;\n }\n\n CLISubcommand.registerSubcommand(instance);\n }\n\n for (const instance of hasParent) {\n CLISubcommand.registerSubcommand(instance);\n }\n }\n\n public async handlePreAction(cmd: Command, action: Command): Promise<void> {\n this.logger.debug(`Executing ${action.name()}`);\n this.logger.debug(`Debug mode is ${this.flags.debug ? 'enabled' : 'disabled'}`);\n process.env.NODE_ENV = this.flags.debug ? 'development' : process.env.NODE_ENV;\n\n loadEnv({\n path: this.flags.env.length ? this.flags.env : [path.join(process.cwd(), '.env')],\n debug: this.flags.debug,\n quiet: !this.flags.debug,\n ignore: ['MISSING_ENV_FILE']\n });\n\n this.logger.debug(`Loaded environment variables from ${this.flags.env.join(', ')}`);\n }\n\n public getFlags<Flags extends Record<string, any> = Record<string, any>>(command: Command|string, mergeDefault?: false): Flags|undefined;\n public getFlags<Flags extends Record<string, any> = Record<string, any>>(command: Command|string, mergeDefault: true): Flags & CLI.Flags|undefined;\n public getFlags(command?: undefined): CLI.Flags;\n public getFlags(command?: Command|string, mergeDefault: boolean = false): Record<string, any>|undefined {\n if (!command) return this.flags;\n\n command = typeof command === 'string' ? this.command.commands.find(c => c.name() === command) : command;\n const flags = command?.opts();\n\n return mergeDefault ? { ...this.flags, ...flags } : flags;\n }\n\n public getCommand(name: string): Command|undefined;\n public getCommand(name?: undefined): Command;\n public getCommand(name?: string): Command|undefined {\n if (!name) return this.command;\n\n return this.command.commands.find(c => c.name() === name);\n }\n}\n\nexport namespace CLI {\n export interface Options {\n name: string;\n description: string;\n build: string;\n subcommandsDir: string;\n logger?: Logger|Logger.Options;\n }\n\n export interface Flags {\n debug: boolean;\n env: string[];\n }\n\n export const root: string = path.join(path.dirname(fileURLToPath(import.meta.url)), '../../../');\n export const bin: string = path.join(CLI.root, 'dist/bin/reciple.mjs');\n export const version = process.env.__VERSION__;\n\n export function stringifyFlags(flags: Record<string, any>, command: Command, ignored: string[] = []): string[] {\n let arr: string[] = [];\n\n for (const [key, value] of Object.entries(flags)) {\n const option = command.options.find(o => o.name() === key || o.attributeName() === key);\n if (!option || ignored.includes(key)) continue;\n\n const flag = option.long ?? option.short ?? `--${option.name()}`;\n\n if (!option.flags.endsWith('>') && !option.flags.endsWith(']') && typeof value === 'boolean') {\n if (value) arr.push(flag);\n continue;\n }\n\n arr.push(flag, String(value));\n }\n\n return arr;\n }\n\n export interface SpinnerPromiseOptions<T> {\n indicator?: SpinnerOptions['indicator'];\n promise: Promise<T>;\n message?: string;\n successMessage?: string;\n errorMessage?: string;\n }\n\n export function createSpinnerPromise<T>(options: SpinnerPromiseOptions<T>): [Promise<T>, ReturnType<typeof spinner>] {\n const loader = spinner({ indicator: options.indicator });\n\n return [\n new Promise<T>((resolve, reject) => {\n loader.start(options.message);\n\n options.promise\n .then((value) => {\n loader.stop(options.successMessage);\n resolve(value);\n })\n .catch((error) => {\n loader.stop(options.errorMessage);\n reject(error);\n });\n }),\n loader\n ];\n }\n\n export function createTsdownLogger(_logger: Logger = logger): RolldownPlugin {\n let startedAt: number;\n\n return {\n name: 'reciple:log-build-completion',\n buildStart: () => {\n _logger.log(colors.green('🚀 Building reciple modules...'));\n startedAt = Date.now();\n },\n renderChunk: (code, info) => {\n const size = Format.bytes(Buffer.byteLength(code, 'utf8'));\n _logger.log(` ├─ ${colors.cyan(size)}\\t${colors.bold(info.fileName)}`);\n\n return { code };\n },\n buildEnd: error => {\n if (error) _logger.error(error)\n },\n closeBundle: () => {\n const time = Format.duration(Date.now() - startedAt);\n _logger.log(colors.green(`✅ Build success in `) + colors.yellow(`${time}`));\n }\n };\n }\n\n export const ignoredDefault = [\n '.git',\n '.log',\n '.nyc_output',\n '.sass-cache',\n '.yarn',\n 'bower_components',\n 'coverage',\n 'node_modules'\n ]\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,IAAa,MAAb,MAAiB;CACb,AAAO;CACP,AAAO;CACP,AAAO;CACP,AAAO;CAEP,IAAI,cAAuB;AACvB,SAAO,KAAK,MAAM;;CAGtB,IAAI,QAAmB;AACnB,SAAO,KAAK,QAAQ,MAAM;;CAG9B,YAAY,AAAgB,SAAsB;EAAtB;AACxB,OAAK,QAAQ,QAAQ;AACrB,OAAK,UAAU,OAAO,OAAO,KAAK,MAAM,IAAI,KAAK,MAAM;AAEvD,OAAK,UAAU,IAAI,SAAQ,CACtB,KAAK,QAAQ,KAAI,CACjB,YAAY,QAAQ,YAAW,CAC/B,QAAQ,QAAQ,OAAO,iBAAiB,gCAA+B,CACvE,OAAO,eAAe,qBAAqB,aAAa,CAAA,CACxD,OAAO,cAAc,sBAAqB,CAC1C,OAAO,gBAAgB,8CAA+C,GAAG,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE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port { fileURLToPath } from 'node:url';\nimport path from 'node:path';\nimport { coerce } from 'semver';\nimport { Format, isDebugging, recursiveDefaults } from '@reciple/utils';\nimport { logger, Logger, LogLevel } from '@prtty/print';\nimport { config as loadEnv } from '@dotenvx/dotenvx';\nimport { readdir, stat } from 'node:fs/promises';\nimport { CLISubcommand } from './CLISubcommand.js';\nimport { spinner, type SpinnerOptions } from '@clack/prompts';\nimport type { RolldownPlugin } from 'rolldown';\nimport { colors } from '@prtty/prtty';\n\nexport class CLI {\n public build: string;\n public version: string;\n public command: Command;\n public logger: Logger;\n\n get isDebugging(): boolean {\n return this.flags.debug;\n }\n\n get flags(): CLI.Flags {\n return this.command.opts();\n }\n\n constructor(public readonly options: CLI.Options) {\n this.build = options.build;\n this.version = String(coerce(this.build) ?? this.build);\n\n this.command = new Command()\n .name(options.name)\n .description(options.description)\n .version(options.build, '-v, --version', 'Output the CLI version number')\n .option('-D, --debug', 'Enable debug mode', isDebugging())\n .option('--no-debug', 'Disabled debug mode')\n .option('--env <file>', 'Load environment variables from .env file', (v, p) => p.concat(v), [] as string[])\n .enablePositionalOptions(true)\n .hook('preAction', this.handlePreAction.bind(this))\n .showHelpAfterError();\n\n this.logger = options.logger instanceof Logger ? options.logger : new Logger(options.logger);\n\n if (this.flags.debug) {\n this.logger.logLevel = LogLevel.Debug;\n this.logger.writeLevel = LogLevel.Debug;\n }\n }\n\n public async parse(argv?: string[]): Promise<this> {\n await this.loadCommands();\n await this.command.parseAsync(argv);\n return this;\n }\n\n public async loadCommands(): Promise<void> {\n this.logger.debug(`Loading cli commands from ${this.options.subcommandsDir}`);\n\n const dirStat = await stat(this.options.subcommandsDir).catch(() => undefined);\n if (!dirStat?.isDirectory()) return;\n\n const files = (await readdir(this.options.subcommandsDir))\n .map(f => path.join(this.options.subcommandsDir, f))\n .filter(f => f.endsWith('.mjs'));\n\n const hasParent: CLISubcommand[] = [];\n\n for (const file of files) {\n const Subommand = recursiveDefaults<CLISubcommand.Constructor>(await import(path.isAbsolute(file) ? `file://${file}` : file));\n if (!Subommand || typeof Subommand !== 'function') continue;\n\n const instance = new Subommand({ cli: this, command: this.command });\n\n if (instance.parent) {\n hasParent.push(instance);\n continue;\n }\n\n CLISubcommand.registerSubcommand(instance);\n }\n\n for (const instance of hasParent) {\n CLISubcommand.registerSubcommand(instance);\n }\n }\n\n public async handlePreAction(cmd: Command, action: Command): Promise<void> {\n this.logger.debug(`Executing ${action.name()}`);\n this.logger.debug(`Debug mode is ${this.flags.debug ? 'enabled' : 'disabled'}`);\n process.env.NODE_ENV = this.flags.debug ? 'development' : process.env.NODE_ENV;\n\n loadEnv({\n path: this.flags.env.length ? this.flags.env : [path.join(process.cwd(), '.env')],\n debug: this.flags.debug,\n quiet: !this.flags.debug,\n ignore: ['MISSING_ENV_FILE']\n });\n\n this.logger.debug(`Loaded environment variables from ${this.flags.env.join(', ')}`);\n }\n\n public async setCurrentDirectory(cwd?: string): Promise<void> {\n cwd ??= process.cwd();\n\n if (!(await stat(cwd).then(s => s.isDirectory()).catch(() => false))) {\n console.log(colors.red('Please specify a valid project directory'));\n process.exit(1);\n }\n\n process.chdir(cwd);\n }\n\n public getFlags<Flags extends Record<string, any> = Record<string, any>>(command: Command|string, mergeDefault?: false): Flags|undefined;\n public getFlags<Flags extends Record<string, any> = Record<string, any>>(command: Command|string, mergeDefault: true): Flags & CLI.Flags|undefined;\n public getFlags(command?: undefined): CLI.Flags;\n public getFlags(command?: Command|string, mergeDefault: boolean = false): Record<string, any>|undefined {\n if (!command) return this.flags;\n\n command = typeof command === 'string' ? this.command.commands.find(c => c.name() === command) : command;\n const flags = command?.opts();\n\n return mergeDefault ? { ...this.flags, ...flags } : flags;\n }\n\n public getCommand(name: string): Command|undefined;\n public getCommand(name?: undefined): Command;\n public getCommand(name?: string): Command|undefined {\n if (!name) return this.command;\n\n return this.command.commands.find(c => c.name() === name);\n }\n}\n\nexport namespace CLI {\n export interface Options {\n name: string;\n description: string;\n build: string;\n subcommandsDir: string;\n logger?: Logger|Logger.Options;\n }\n\n export interface Flags {\n debug: boolean;\n env: string[];\n }\n\n export const root: string = path.join(path.dirname(fileURLToPath(import.meta.url)), '../../../');\n export const bin: string = path.join(CLI.root, 'dist/bin/reciple.mjs');\n export const version = process.env.__VERSION__;\n\n export function stringifyFlags(flags: Record<string, any>, command: Command, ignored: string[] = []): string[] {\n let arr: string[] = [];\n\n for (const [key, value] of Object.entries(flags)) {\n const option = command.options.find(o => o.name() === key || o.attributeName() === key);\n if (!option || ignored.includes(key)) continue;\n\n const flag = option.long ?? option.short ?? `--${option.name()}`;\n\n if (!option.flags.endsWith('>') && !option.flags.endsWith(']') && typeof value === 'boolean') {\n if (value) arr.push(flag);\n continue;\n }\n\n arr.push(flag, String(value));\n }\n\n return arr;\n }\n\n export interface SpinnerPromiseOptions<T> {\n indicator?: SpinnerOptions['indicator'];\n promise: Promise<T>;\n message?: string;\n successMessage?: string;\n errorMessage?: string;\n }\n\n export function createSpinnerPromise<T>(options: SpinnerPromiseOptions<T>): [Promise<T>, ReturnType<typeof spinner>] {\n const loader = spinner({ indicator: options.indicator });\n\n return [\n new Promise<T>((resolve, reject) => {\n loader.start(options.message);\n\n options.promise\n .then((value) => {\n loader.stop(options.successMessage);\n resolve(value);\n })\n .catch((error) => {\n loader.stop(options.errorMessage);\n reject(error);\n });\n }),\n loader\n ];\n }\n\n export function createTsdownLogger(_logger: Logger = logger): RolldownPlugin {\n let startedAt: number;\n\n return {\n name: 'reciple:log-build-completion',\n buildStart: () => {\n _logger.log(colors.green('🚀 Building reciple modules...'));\n startedAt = Date.now();\n },\n renderChunk: (code, info) => {\n const size = Format.bytes(Buffer.byteLength(code, 'utf8'));\n _logger.log(` ├─ ${colors.cyan(size)}\\t${colors.bold(info.fileName)}`);\n\n return { code };\n },\n buildEnd: error => {\n if (error) _logger.error(error)\n },\n closeBundle: () => {\n const time = Format.duration(Date.now() - startedAt);\n _logger.log(colors.green(`✅ Build success in `) + colors.yellow(`${time}`));\n }\n };\n }\n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SAAY,SAAS,WAAW;AAChC,UAAO,MAAM,QAAQ,QAAQ;AAE7B,WAAQ,QACH,MAAM,UAAU;AACb,WAAO,KAAK,QAAQ,eAAe;AACnC,YAAQ,MAAM;KACjB,CACA,OAAO,UAAU;AACd,WAAO,KAAK,QAAQ,aAAa;AACjC,WAAO,MAAM;KACf;IACR,EACF,OACH;;;CAGE,SAAS,mBAAmB,UAAkB,QAAwB;EACzE,IAAI;AAEJ,SAAO;GACH,MAAM;GACN,kBAAkB;AACd,YAAQ,IAAI,OAAO,MAAM,iCAAiC,CAAC;AAC3D,gBAAY,KAAK,KAAK;;GAE1B,cAAc,MAAM,SAAS;IACzB,MAAM,OAAO,OAAO,MAAM,OAAO,WAAW,MAAM,OAAO,CAAC;AAC1D,YAAQ,IAAI,OAAO,OAAO,KAAK,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,SAAS,GAAG;AAEtE,WAAO,EAAE,MAAM;;GAEnB,WAAU,UAAS;AACf,QAAI,MAAO,SAAQ,MAAM,MAAK;;GAElC,mBAAmB;IACf,MAAM,OAAO,OAAO,SAAS,KAAK,KAAK,GAAG,UAAU;AACpD,YAAQ,IAAI,OAAO,MAAM,sBAAsB,GAAG,OAAO,OAAO,GAAG,OAAO,CAAC;;GAElF;;;uBAGyB;EAC1B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACJ"}
@@ -35,9 +35,7 @@ declare class ConfigReader {
35
35
  get build(): UserConfig;
36
36
  get sharding(): ShardingManagerOptions | null;
37
37
  constructor(filepath: string);
38
- read(options?: Omit<Options, 'path'> & {
39
- ignoreInstanceCheck?: boolean;
40
- }): Promise<ConfigReader>;
38
+ read(options?: Omit<Options, 'path'>): Promise<ConfigReader>;
41
39
  create(options: Omit<ConfigReader.CreateOptions, 'path'>): Promise<ConfigReader>;
42
40
  static exists(file: string): Promise<boolean>;
43
41
  static create(options: ConfigReader.CreateOptions): Promise<ConfigReader>;
@@ -52,7 +50,6 @@ declare namespace ConfigReader {
52
50
  readOptions?: Omit<Options, 'path'> | false;
53
51
  }
54
52
  interface FindOptions {
55
- cwd?: string;
56
53
  lang?: LangType;
57
54
  directories?: string[];
58
55
  }