reciple 10.0.2 → 10.0.4

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.
@@ -87,7 +87,7 @@ var CLI = class {
87
87
  (function(_CLI) {
88
88
  _CLI.root = path.join(path.dirname(fileURLToPath(import.meta.url)), "../../../");
89
89
  _CLI.bin = path.join(CLI.root, "dist/bin/reciple.mjs");
90
- _CLI.version = "10.0.2";
90
+ _CLI.version = "10.0.4";
91
91
  function stringifyFlags(flags, command, ignored = []) {
92
92
  let arr = [];
93
93
  for (const [key, value] of Object.entries(flags)) {
@@ -1,5 +1,6 @@
1
1
  import { CLI } from "./CLI.mjs";
2
2
  import path from "node:path";
3
+ import { isDebugging } from "@reciple/utils";
3
4
  import { mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
4
5
  import { colors } from "@prtty/prtty";
5
6
  import { Client, RecipleError } from "@reciple/core";
@@ -29,11 +30,15 @@ var ConfigReader = class ConfigReader {
29
30
  this.filepath = filepath;
30
31
  }
31
32
  async read(options) {
33
+ const originalPath = process.cwd();
34
+ process.chdir(path.dirname(this.filepath));
32
35
  const { module } = await unrun({
33
36
  ...options,
34
- inputOptions: { cwd: path.dirname(this.filepath) },
37
+ debug: isDebugging(),
38
+ preset: "bundle-require",
35
39
  path: this.filepath
36
40
  });
41
+ process.chdir(originalPath);
37
42
  if (!module || !module.client || !(module.client instanceof Client)) throw new RecipleError(`exported client is not an instance of ${colors.cyan("Client")} from ${colors.green("\"@reciple/core\"")}.`);
38
43
  this._client = module.client;
39
44
  this._config = module.config;
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigReader.mjs","names":[],"sources":["../../../src/classes/cli/ConfigReader.ts"],"sourcesContent":["import type { ModuleLoader } from '../client/ModuleLoader.js';\nimport type { ModuleManager } from '../managers/ModuleManager.js';\nimport type { EventListeners } from '../client/EventListeners.js';\nimport type { Logger } from '@prtty/print';\nimport { CLI } from './CLI.js';\nimport { Client, RecipleError, type Config } from '@reciple/core';\nimport type { BuildConfig } from '../../helpers/types.js';\nimport type { UserConfig as TsdownConfig } from 'tsdown';\nimport path from 'node:path';\nimport { mkdir, readdir, readFile, stat, writeFile } from 'node:fs/promises';\nimport { resolveTSConfig } from 'pkg-types';\nimport { unrun, type Options as UnrunOptions } from 'unrun';\nimport { colors } from '@prtty/prtty';\nimport type { ShardingManagerOptions } from 'discord.js';\n\ndeclare module \"@reciple/core\" {\n interface Config {\n token?: string;\n modules?: ModuleLoader.Config;\n logger?: Logger|Logger.Options;\n }\n\n interface Client {\n readonly modules: ModuleManager;\n readonly moduleLoader: ModuleLoader;\n readonly eventListeners: EventListeners;\n readonly cli: CLI;\n logger: Logger;\n }\n}\n\nexport class ConfigReader {\n private _client: Client|null = null;\n private _config: Config|null = null;\n private _build: BuildConfig|null = null;\n private _sharding: ShardingManagerOptions|null = null;\n\n get client() {\n if (!this._client) throw new RecipleError('client is not yet loaded from config.');\n return this._client;\n }\n\n get config() {\n return this._config ?? {};\n }\n\n get build() {\n return ConfigReader.normalizeTsdownConfig({\n overrides: this._build ?? {}\n });\n }\n\n get sharding() {\n return this._sharding;\n }\n\n constructor(public readonly filepath: string) {}\n\n public async read(options?: Omit<UnrunOptions, 'path'>): Promise<ConfigReader> {\n const { module } = await unrun<Config>({\n ...options,\n inputOptions: {\n cwd: path.dirname(this.filepath)\n },\n path: this.filepath\n });\n\n if (!module || !module.client || !(module.client instanceof Client)) {\n throw new RecipleError(`exported client is not an instance of ${colors.cyan('Client')} from ${colors.green('\"@reciple/core\"')}.`);\n }\n\n this._client = module.client;\n this._config = module.config;\n this._build = module.build;\n this._sharding = module.sharding ?? null;\n\n return this;\n }\n\n public async create(options: Omit<ConfigReader.CreateOptions, 'path'>): Promise<ConfigReader> {\n const exists = await ConfigReader.exists(this.filepath);\n\n if (exists && options.throwIfExists === true) {\n throw new RecipleError(`Config file already exists at ${colors.green(path.relative(process.cwd(), this.filepath))}.`);\n }\n\n if (!exists || exists && options.overwrite !== false) {\n await mkdir(path.dirname(this.filepath), { recursive: true });\n await writeFile(this.filepath, await ConfigReader.getDefaultContent(options.type));\n }\n\n return options.readOptions !== false ? this.read(options.readOptions) : this;\n }\n\n public static async exists(file: string): Promise<boolean> {\n return await stat(file).then(s => s.isFile()).catch(() => false);\n }\n\n public static async create(options: ConfigReader.CreateOptions): Promise<ConfigReader> {\n return new ConfigReader(options.path).create(options);\n }\n\n public static async find(options?: ConfigReader.FindOptions): Promise<string|null> {\n const filenames = ConfigReader.configFilenames.filter(f => !options?.lang || f.endsWith(options.lang));\n const cwd = options?.cwd ?? process.cwd();\n const directories = [cwd];\n\n directories.push(...(options?.directories ?? [path.join(cwd, '.config')]));\n\n for (const directory of directories) {\n const stats = await stat(directory).catch(() => undefined);\n\n if (!stats?.isDirectory()) continue;\n\n const file = (await readdir(directory)).find(f => filenames.includes(f));\n if (file) return path.join(directory, file);\n }\n\n return null;\n }\n}\n\nexport namespace ConfigReader {\n export interface CreateOptions {\n path: string;\n overwrite?: boolean;\n throwIfExists?: boolean;\n type: LangType;\n readOptions?: Omit<UnrunOptions, 'path'>|false;\n }\n\n export interface FindOptions {\n cwd?: string;\n lang?: LangType;\n directories?: string[];\n }\n\n export async function getProjectLang(cwd: string): Promise<LangType> {\n const hasTsConfig = !!await resolveTSConfig(cwd, { try: true });\n const configLangIsTypescript = !!(await ConfigReader.find({ cwd, lang: 'ts' }));\n\n return hasTsConfig || configLangIsTypescript ? 'ts' : 'js';\n }\n\n export type LangType = 'ts'|'js';\n\n export const defaultConfigPath = {\n ts: path.join(CLI.root, 'assets/config', `reciple.config.ts`),\n js: path.join(CLI.root, 'assets/config', `reciple.config.js`)\n };\n\n export async function getDefaultContent(type: LangType): Promise<string> {\n const filepath = ConfigReader.defaultConfigPath[type];\n const content = await readFile(filepath, 'utf-8');\n return content;\n }\n\n export const configFilenames = [\n 'reciple.config.ts',\n 'reciple.config.mts',\n 'reciple.config.js',\n 'reciple.config.mjs'\n ];\n\n export function createConfigFilename(type: LangType, esm: boolean = false): string {\n return `reciple.config.${esm ? 'm' : ''}${type}`;\n }\n\n export function normalizeTsdownConfig({ type, overrides }: { type?: LangType; overrides?: BuildConfig; } = {}): TsdownConfig {\n return {\n entry: [`./src/**/*.{ts,tsx,js,jsx}`],\n outDir: './modules',\n tsconfig: `./${type ?? 'ts'}config.json`,\n external: [],\n noExternal: [],\n sourcemap: true,\n treeshake: true,\n clean: true,\n ...overrides,\n watch: false,\n platform: 'node',\n format: 'esm',\n unbundle: true,\n skipNodeModulesBundle: true\n };\n }\n}\n"],"mappings":";;;;;;;;;AA+BA,IAAa,eAAb,MAAa,aAAa;CACtB,AAAQ,UAAuB;CAC/B,AAAQ,UAAuB;CAC/B,AAAQ,SAA2B;CACnC,AAAQ,YAAyC;CAEjD,IAAI,SAAS;AACT,MAAI,CAAC,KAAK,QAAS,OAAM,IAAI,aAAa,wCAAwC;AAClF,SAAO,KAAK;;CAGhB,IAAI,SAAS;AACT,SAAO,KAAK,WAAW,EAAE;;CAG7B,IAAI,QAAQ;AACR,SAAO,aAAa,sBAAsB,EACtC,WAAW,KAAK,UAAU,EAAE,EAC/B,CAAC;;CAGN,IAAI,WAAW;AACX,SAAO,KAAK;;CAGhB,YAAY,AAAgB,UAAkB;EAAlB;;CAE5B,MAAa,KAAK,SAA6D;EAC3E,MAAM,EAAE,WAAW,MAAM,MAAc;GACnC,GAAG;GACH,cAAc,EACV,KAAK,KAAK,QAAQ,KAAK,SAAS,EACnC;GACD,MAAM,KAAK;GACd,CAAC;AAEF,MAAI,CAAC,UAAU,CAAC,OAAO,UAAU,EAAE,OAAO,kBAAkB,QACxD,OAAM,IAAI,aAAa,yCAAyC,OAAO,KAAK,SAAS,CAAC,QAAQ,OAAO,MAAM,oBAAkB,CAAC,GAAG;AAGrI,OAAK,UAAU,OAAO;AACtB,OAAK,UAAU,OAAO;AACtB,OAAK,SAAS,OAAO;AACrB,OAAK,YAAY,OAAO,YAAY;AAEpC,SAAO;;CAGX,MAAa,OAAO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,cAAc,CAAC,CAAC,MAAM,gBAAgB,KAAK,EAAE,KAAK,MAAM,CAAC;EAC/D,MAAM,yBAAyB,CAAC,CAAE,MAAM,aAAa,KAAK;GAAE;GAAK,MAAM;GAAM,CAAC;AAE9E,SAAO,eAAe,yBAAyB,OAAO;;;mCAKzB;EAC7B,IAAI,KAAK,KAAK,IAAI,MAAM,iBAAiB,oBAAoB;EAC7D,IAAI,KAAK,KAAK,IAAI,MAAM,iBAAiB,oBAAoB;EAChE;CAEM,eAAe,kBAAkB,MAAiC;EACrE,MAAM,WAAW,aAAa,kBAAkB;AAEhD,SADgB,MAAM,SAAS,UAAU,QAAQ;;;iCAItB;EAC3B;EACA;EACA;EACA;EACH;CAEM,SAAS,qBAAqB,MAAgB,MAAe,OAAe;AAC/E,SAAO,kBAAkB,MAAM,MAAM,KAAK;;;CAGvC,SAAS,sBAAsB,EAAE,MAAM,cAA6D,EAAE,EAAgB;AACzH,SAAO;GACH,OAAO,CAAC,6BAA6B;GACrC,QAAQ;GACR,UAAU,KAAK,QAAQ,KAAK;GAC5B,UAAU,EAAE;GACZ,YAAY,EAAE;GACd,WAAW;GACX,WAAW;GACX,OAAO;GACP,GAAG;GACH,OAAO;GACP,UAAU;GACV,QAAQ;GACR,UAAU;GACV,uBAAuB;GAC1B"}
1
+ {"version":3,"file":"ConfigReader.mjs","names":[],"sources":["../../../src/classes/cli/ConfigReader.ts"],"sourcesContent":["import type { ModuleLoader } from '../client/ModuleLoader.js';\nimport type { ModuleManager } from '../managers/ModuleManager.js';\nimport type { EventListeners } from '../client/EventListeners.js';\nimport type { Logger } from '@prtty/print';\nimport { CLI } from './CLI.js';\nimport { Client, RecipleError, type Config } from '@reciple/core';\nimport type { BuildConfig } from '../../helpers/types.js';\nimport type { UserConfig as TsdownConfig } from 'tsdown';\nimport path from 'node:path';\nimport { mkdir, readdir, readFile, stat, writeFile } from 'node:fs/promises';\nimport { resolveTSConfig } from 'pkg-types';\nimport { unrun, type Options as UnrunOptions } from 'unrun';\nimport { colors } from '@prtty/prtty';\nimport type { ShardingManagerOptions } from 'discord.js';\nimport { isDebugging } from '@reciple/utils';\n\ndeclare module \"@reciple/core\" {\n interface Config {\n token?: string;\n modules?: ModuleLoader.Config;\n logger?: Logger|Logger.Options;\n }\n\n interface Client {\n readonly modules: ModuleManager;\n readonly moduleLoader: ModuleLoader;\n readonly eventListeners: EventListeners;\n readonly cli: CLI;\n logger: Logger;\n }\n}\n\nexport class ConfigReader {\n private _client: Client|null = null;\n private _config: Config|null = null;\n private _build: BuildConfig|null = null;\n private _sharding: ShardingManagerOptions|null = null;\n\n get client() {\n if (!this._client) throw new RecipleError('client is not yet loaded from config.');\n return this._client;\n }\n\n get config() {\n return this._config ?? {};\n }\n\n get build() {\n return ConfigReader.normalizeTsdownConfig({\n overrides: this._build ?? {}\n });\n }\n\n get sharding() {\n return this._sharding;\n }\n\n constructor(public readonly filepath: string) {}\n\n public async read(options?: Omit<UnrunOptions, 'path'>): Promise<ConfigReader> {\n const originalPath = process.cwd();\n\n process.chdir(path.dirname(this.filepath));\n\n const { module } = await unrun<Config>({\n ...options,\n debug: isDebugging(),\n preset: 'bundle-require',\n path: this.filepath\n });\n\n process.chdir(originalPath);\n\n if (!module || !module.client || !(module.client instanceof Client)) {\n throw new RecipleError(`exported client is not an instance of ${colors.cyan('Client')} from ${colors.green('\"@reciple/core\"')}.`);\n }\n\n this._client = module.client;\n this._config = module.config;\n this._build = module.build;\n this._sharding = module.sharding ?? null;\n\n return this;\n }\n\n public async create(options: Omit<ConfigReader.CreateOptions, 'path'>): Promise<ConfigReader> {\n const exists = await ConfigReader.exists(this.filepath);\n\n if (exists && options.throwIfExists === true) {\n throw new RecipleError(`Config file already exists at ${colors.green(path.relative(process.cwd(), this.filepath))}.`);\n }\n\n if (!exists || exists && options.overwrite !== false) {\n await mkdir(path.dirname(this.filepath), { recursive: true });\n await writeFile(this.filepath, await ConfigReader.getDefaultContent(options.type));\n }\n\n return options.readOptions !== false ? this.read(options.readOptions) : this;\n }\n\n public static async exists(file: string): Promise<boolean> {\n return await stat(file).then(s => s.isFile()).catch(() => false);\n }\n\n public static async create(options: ConfigReader.CreateOptions): Promise<ConfigReader> {\n return new ConfigReader(options.path).create(options);\n }\n\n public static async find(options?: ConfigReader.FindOptions): Promise<string|null> {\n const filenames = ConfigReader.configFilenames.filter(f => !options?.lang || f.endsWith(options.lang));\n const cwd = options?.cwd ?? process.cwd();\n const directories = [cwd];\n\n directories.push(...(options?.directories ?? [path.join(cwd, '.config')]));\n\n for (const directory of directories) {\n const stats = await stat(directory).catch(() => undefined);\n\n if (!stats?.isDirectory()) continue;\n\n const file = (await readdir(directory)).find(f => filenames.includes(f));\n if (file) return path.join(directory, file);\n }\n\n return null;\n }\n}\n\nexport namespace ConfigReader {\n export interface CreateOptions {\n path: string;\n overwrite?: boolean;\n throwIfExists?: boolean;\n type: LangType;\n readOptions?: Omit<UnrunOptions, 'path'>|false;\n }\n\n export interface FindOptions {\n cwd?: string;\n lang?: LangType;\n directories?: string[];\n }\n\n export async function getProjectLang(cwd: string): Promise<LangType> {\n const hasTsConfig = !!await resolveTSConfig(cwd, { try: true });\n const configLangIsTypescript = !!(await ConfigReader.find({ cwd, lang: 'ts' }));\n\n return hasTsConfig || configLangIsTypescript ? 'ts' : 'js';\n }\n\n export type LangType = 'ts'|'js';\n\n export const defaultConfigPath = {\n ts: path.join(CLI.root, 'assets/config', `reciple.config.ts`),\n js: path.join(CLI.root, 'assets/config', `reciple.config.js`)\n };\n\n export async function getDefaultContent(type: LangType): Promise<string> {\n const filepath = ConfigReader.defaultConfigPath[type];\n const content = await readFile(filepath, 'utf-8');\n return content;\n }\n\n export const configFilenames = [\n 'reciple.config.ts',\n 'reciple.config.mts',\n 'reciple.config.js',\n 'reciple.config.mjs'\n ];\n\n export function createConfigFilename(type: LangType, esm: boolean = false): string {\n return `reciple.config.${esm ? 'm' : ''}${type}`;\n }\n\n export function normalizeTsdownConfig({ type, overrides }: { type?: LangType; overrides?: BuildConfig; } = {}): TsdownConfig {\n return {\n entry: [`./src/**/*.{ts,tsx,js,jsx}`],\n outDir: './modules',\n tsconfig: `./${type ?? 'ts'}config.json`,\n external: [],\n noExternal: [],\n sourcemap: true,\n treeshake: true,\n clean: true,\n ...overrides,\n watch: false,\n platform: 'node',\n format: 'esm',\n unbundle: true,\n skipNodeModulesBundle: true\n };\n }\n}\n"],"mappings":";;;;;;;;;;AAgCA,IAAa,eAAb,MAAa,aAAa;CACtB,AAAQ,UAAuB;CAC/B,AAAQ,UAAuB;CAC/B,AAAQ,SAA2B;CACnC,AAAQ,YAAyC;CAEjD,IAAI,SAAS;AACT,MAAI,CAAC,KAAK,QAAS,OAAM,IAAI,aAAa,wCAAwC;AAClF,SAAO,KAAK;;CAGhB,IAAI,SAAS;AACT,SAAO,KAAK,WAAW,EAAE;;CAG7B,IAAI,QAAQ;AACR,SAAO,aAAa,sBAAsB,EACtC,WAAW,KAAK,UAAU,EAAE,EAC/B,CAAC;;CAGN,IAAI,WAAW;AACX,SAAO,KAAK;;CAGhB,YAAY,AAAgB,UAAkB;EAAlB;;CAE5B,MAAa,KAAK,SAA6D;EAC3E,MAAM,eAAe,QAAQ,KAAK;AAElC,UAAQ,MAAM,KAAK,QAAQ,KAAK,SAAS,CAAC;EAE1C,MAAM,EAAE,WAAW,MAAM,MAAc;GACnC,GAAG;GACH,OAAO,aAAa;GACpB,QAAQ;GACR,MAAM,KAAK;GACd,CAAC;AAEF,UAAQ,MAAM,aAAa;AAE3B,MAAI,CAAC,UAAU,CAAC,OAAO,UAAU,EAAE,OAAO,kBAAkB,QACxD,OAAM,IAAI,aAAa,yCAAyC,OAAO,KAAK,SAAS,CAAC,QAAQ,OAAO,MAAM,oBAAkB,CAAC,GAAG;AAGrI,OAAK,UAAU,OAAO;AACtB,OAAK,UAAU,OAAO;AACtB,OAAK,SAAS,OAAO;AACrB,OAAK,YAAY,OAAO,YAAY;AAEpC,SAAO;;CAGX,MAAa,OAAO,SAA0E;EAC1F,MA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,MAAM,gBAAgB,KAAK,EAAE,KAAK,MAAM,CAAC;EAC/D,MAAM,yBAAyB,CAAC,CAAE,MAAM,aAAa,KAAK;GAAE;GAAK,MAAM;GAAM,CAAC;AAE9E,SAAO,eAAe,yBAAyB,OAAO;;;mCAKzB;EAC7B,IAAI,KAAK,KAAK,IAAI,MAAM,iBAAiB,oBAAoB;EAC7D,IAAI,KAAK,KAAK,IAAI,MAAM,iBAAiB,oBAAoB;EAChE;CAEM,eAAe,kBAAkB,MAAiC;EACrE,MAAM,WAAW,aAAa,kBAAkB;AAEhD,SADgB,MAAM,SAAS,UAAU,QAAQ;;;iCAItB;EAC3B;EACA;EACA;EACA;EACH;CAEM,SAAS,qBAAqB,MAAgB,MAAe,OAAe;AAC/E,SAAO,kBAAkB,MAAM,MAAM,KAAK;;;CAGvC,SAAS,sBAAsB,EAAE,MAAM,cAA6D,EAAE,EAAgB;AACzH,SAAO;GACH,OAAO,CAAC,6BAA6B;GACrC,QAAQ;GACR,UAAU,KAAK,QAAQ,KAAK;GAC5B,UAAU,EAAE;GACZ,YAAY,EAAE;GACd,WAAW;GACX,WAAW;GACX,OAAO;GACP,GAAG;GACH,OAAO;GACP,UAAU;GACV,QAAQ;GACR,UAAU;GACV,uBAAuB;GAC1B"}
@@ -4,7 +4,7 @@ import { ConfigReader } from "../cli/ConfigReader.mjs";
4
4
  import { packageJSON } from "../../helpers/constants.mjs";
5
5
  import { ModuleTemplateBuilder } from "./ModuleTemplateBuilder.mjs";
6
6
  import path from "node:path";
7
- import { PackageJsonBuilder } from "@reciple/utils";
7
+ import { PackageJsonBuilder, isDebugging } from "@reciple/utils";
8
8
  import { parse } from "@dotenvx/dotenvx";
9
9
  import { copyFile, mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
10
10
  import { confirm, intro, isCancel, log, outro, select, text } from "@clack/prompts";
@@ -236,6 +236,7 @@ var TemplateBuilder = class TemplateBuilder {
236
236
  },
237
237
  ...TemplateBuilder.createDependencyRecord(this.typescript ? "ts" : "js")
238
238
  });
239
+ await this.packageJson?.write(this.packageJsonPath, true);
239
240
  return this;
240
241
  }
241
242
  async installDependencies(options) {
@@ -254,7 +255,7 @@ var TemplateBuilder = class TemplateBuilder {
254
255
  promise: installDependencies({
255
256
  cwd: this.directory,
256
257
  packageManager: this.packageManager,
257
- silent: true
258
+ silent: !isDebugging()
258
259
  }),
259
260
  indicator: "timer",
260
261
  errorMessage: `${colors.bold().red("✗")} Failed to install dependencies`,
@@ -299,12 +300,11 @@ var TemplateBuilder = class TemplateBuilder {
299
300
  return this;
300
301
  }
301
302
  async build(options) {
302
- await this.packageJson?.write(this.packageJsonPath, true);
303
303
  if (!options?.skipBuild && this.dependenciesInstalled) await CLI.createSpinnerPromise({
304
304
  promise: runScript("build", {
305
305
  cwd: this.directory,
306
306
  packageManager: this.packageManager,
307
- silent: true
307
+ silent: !isDebugging()
308
308
  }),
309
309
  indicator: "timer",
310
310
  errorMessage: `${colors.bold().red("✗")} Failed to build project`,
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateBuilder.mjs","names":["parseDotenv"],"sources":["../../../src/classes/templates/TemplateBuilder.ts"],"sourcesContent":["import { PackageJsonBuilder } from '@reciple/utils';\nimport { ConfigReader } from '../cli/ConfigReader.js';\nimport { copyFile, mkdir, readdir, readFile, stat, writeFile } from 'node:fs/promises';\nimport { confirm, intro, isCancel, outro, select, text, log } from '@clack/prompts';\nimport micromatch from 'micromatch';\nimport { CLI } from '../cli/CLI.js';\nimport path from 'node:path';\nimport { existsSync, statSync } from 'node:fs';\nimport { NotAnError } from '../NotAnError.js';\nimport { slug } from 'github-slugger';\nimport { packageJSON } from '../../helpers/constants.js';\nimport { parse as parseDotenv } from '@dotenvx/dotenvx';\nimport { ModuleTemplateBuilder } from './ModuleTemplateBuilder.js';\nimport { detectPackageManager, installDependencies, installDependenciesCommand, runScript, runScriptCommand, type PackageManagerName } from 'nypm';\nimport { colors } from '@prtty/prtty';\n\nexport class TemplateBuilder {\n private _directory?: string;\n\n public cli: CLI;\n public typescript?: boolean;\n public token?: string;\n public defaultAll: boolean;\n\n public config?: ConfigReader;\n public packageJson?: PackageJsonBuilder;\n\n public packageManager?: PackageManagerName;\n public dependenciesInstalled: boolean = false;\n\n get directory() {\n return this._directory ?? process.cwd();\n }\n\n get relativeDirectory() {\n return path.relative(process.cwd(), this.directory) || './';\n }\n\n get packageJsonPath() {\n return path.join(this.directory, 'package.json');\n }\n\n get name() {\n return slug(path.basename(this.directory));\n }\n\n constructor(options: TemplateBuilder.Options) {\n this.cli = options.cli;\n this._directory = options.directory;\n this.typescript = options.typescript;\n this.defaultAll = options.defaultAll ?? false;\n this.packageManager = options.packageManager;\n this.token = options.token;\n }\n\n public async init(): Promise<this> {\n intro(colors.bold().black().bgCyan(` ${this.cli.command.name()} create - v${this.cli.build} `));\n return this;\n }\n\n public async createDirectory(options?: TemplateBuilder.CreateDirectoryOptions): Promise<this> {\n this._directory = options?.directory ?? this._directory;\n\n if (!this._directory) {\n const dir = this.defaultAll\n ? process.cwd()\n : await text({\n message: `Enter project directory`,\n placeholder: `Leave empty to use current directory`,\n defaultValue: process.cwd(),\n validate: value => {\n const dir = path.resolve(value);\n if (existsSync(dir) && !statSync(dir).isDirectory()) return 'Invalid folder directory';\n }\n });\n\n if (isCancel(dir)) throw new NotAnError('Operation cancelled');\n this._directory = dir;\n }\n\n this._directory = path.resolve(this._directory);\n\n const stats = await stat(this.directory).catch(() => undefined);\n\n if (stats) {\n let files = await readdir(this.directory);\n files = micromatch.not(files, options?.ignoredFiles ?? TemplateBuilder.ignoredDirectoryFiles, { dot: true });\n\n if (files.length) {\n switch (options?.onNotEmpty) {\n case 'throw':\n throw new NotAnError(`Directory ${colors.cyan(this.relativeDirectory)} is not empty`);\n case 'ignore':\n return this;\n default:\n const overwrite = this.defaultAll\n ? false\n : await confirm({\n message: `Directory ${colors.cyan(this.relativeDirectory)} is not empty. Would you like to continue?`,\n active: 'Yes',\n inactive: 'No',\n initialValue: false\n });\n\n if (!overwrite) throw new NotAnError(`Directory ${colors.cyan(this.relativeDirectory)} is not empty`);\n if (isCancel(overwrite)) throw new NotAnError('Operation cancelled');\n break;\n }\n }\n }\n\n await mkdir(this.directory, { recursive: true });\n return this;\n }\n\n public async setupLanguage(options?: TemplateBuilder.SetupLanguageOptions): Promise<this> {\n this.typescript = options?.typescript ?? this.typescript;\n\n if (!this.typescript) {\n const isTypeScript = this.defaultAll\n ? false\n : await confirm({\n message: 'Would you like to use TypeScript?',\n active: 'Yes',\n inactive: 'No',\n initialValue: false\n });\n\n if (isCancel(isTypeScript)) throw new NotAnError('Operation cancelled');\n this.typescript = isTypeScript;\n }\n\n return this;\n }\n\n public async createEnvFile(options?: TemplateBuilder.CreateEnvFileOptions): Promise<this> {\n const tokenKey = options?.tokenKey ?? 'DISCORD_TOKEN';\n const envFile = options?.envFile ? path.resolve(options.envFile) : path.join(this.directory, '.env');\n const stats = await stat(envFile).catch(() => undefined);\n\n let env = options?.env ?? {};\n env = stats\n ? parseDotenv(await readFile(envFile, 'utf-8'), {\n processEnv: env\n })\n : env;\n\n if (env[tokenKey]) {\n const skip = this.defaultAll || await confirm({\n message: 'Discord bot token already exists in .env file, do you want to skip?',\n initialValue: true,\n active: 'Yes',\n inactive: 'No'\n });\n\n if (isCancel(skip)) throw new NotAnError('Operation cancelled');\n if (skip) return this;\n }\n\n const token = await text({\n message: 'Enter Discord Bot Token',\n placeholder: 'Bot Token from Discord Developer Portal',\n defaultValue: env[tokenKey]\n });\n\n if (isCancel(token)) throw new NotAnError('Operation cancelled');\n env[tokenKey] = token;\n\n await writeFile(envFile, `\\n${tokenKey}=\"${token}\"\\n`, {\n encoding: 'utf-8',\n flag: 'a'\n });\n\n return this;\n }\n\n public async createConfig(options?: TemplateBuilder.CreateConfigOptions): Promise<this> {\n let filepath = options?.path;\n\n if (!filepath) {\n filepath = await ConfigReader.find({\n cwd: this.directory,\n lang: this.typescript\n ? 'ts'\n : this.typescript === false\n ? 'js'\n : undefined\n }) ?? path.join(\n this.directory,\n ConfigReader.createConfigFilename(this.typescript ? 'ts' : 'js')\n );\n }\n\n const exists = await ConfigReader.exists(filepath);\n\n if (exists) {\n const overwrite = this.defaultAll\n ? false\n : await confirm({\n message: `Config file already exists at ${colors.green(path.relative(process.cwd(), filepath))}. Would you like to overwrite it?`,\n active: 'Yes',\n inactive: 'No',\n initialValue: false\n });\n\n if (!overwrite) return this;\n if (isCancel(overwrite)) throw new NotAnError('Operation cancelled');\n }\n\n this.config = await ConfigReader.create({\n ...options,\n path: filepath,\n type: this.typescript ? 'ts' : 'js',\n overwrite: true,\n readOptions: false\n });\n\n return this;\n }\n\n public async createTemplate(options?: TemplateBuilder.CreateModulesOptions): Promise<this> {\n const source = path.join(CLI.root, './assets/templates/', this.typescript ? 'typescript' : 'javascript');\n const globals = path.join(CLI.root, './assets/global/');\n\n function rename(data: TemplateBuilder.CopyMetadata) {\n switch (data.basename) {\n case 'gitignore':\n return '.gitignore';\n default:\n return options?.rename?.(data) ?? data.basename;\n }\n }\n\n function overwrite(data: TemplateBuilder.CopyMetadata) {\n switch (data.basename) {\n case 'gitignore':\n return false;\n case 'tsconfig.json':\n case 'jsconfig.json':\n return true;\n default:\n return (typeof options?.overwrite === 'boolean' ? options.overwrite : options?.overwrite?.(data)) ?? true;\n }\n }\n\n const [template, loader] = CLI.createSpinnerPromise({\n promise: Promise.all([\n TemplateBuilder.copy(source, this.directory, { ...options, rename, overwrite }),\n TemplateBuilder.copy(globals, this.directory, { ...options, rename, overwrite })\n ]),\n message: 'Copying template files',\n successMessage: 'Files copied successfully',\n errorMessage: 'Failed to copy files'\n });\n\n await template;\n return this;\n }\n\n public async setPackageManager(options?: TemplateBuilder.SetPackageManagerOptions) {\n this.packageManager = options?.packageManager ?? this.packageManager;\n\n if (!this.packageManager) {\n const defaultPackageManager = await detectPackageManager(this.directory).then(pm => pm?.name ?? 'npm');\n const packageManager: PackageManagerName|symbol = this.defaultAll\n ? defaultPackageManager\n : await select({\n message: 'Select package manager',\n options: [\n { value: defaultPackageManager, label: defaultPackageManager },\n ...[\n { value: 'npm', label: 'npm' },\n { value: 'yarn', label: 'yarn' },\n { value: 'pnpm', label: 'pnpm' },\n { value: 'bun', label: 'bun' },\n { value: 'deno', label: 'deno' }\n ].filter(o => o.value !== defaultPackageManager) as { value: PackageManagerName; label: string; }[]\n ],\n initialValue: defaultPackageManager\n });\n\n if (isCancel(packageManager)) throw new NotAnError('Operation cancelled');\n this.packageManager = packageManager;\n }\n\n this.packageJson = await PackageJsonBuilder.read(this.packageJsonPath, true);\n this.packageJson.merge({\n name: this.name,\n private: true,\n type: 'module',\n scripts: {\n build: `reciple build`,\n start: 'reciple start',\n dev: 'nodemon',\n },\n ...TemplateBuilder.createDependencyRecord(this.typescript ? 'ts' : 'js'),\n });\n\n return this;\n }\n\n public async installDependencies(options?: TemplateBuilder.InstallDependenciesOptions): Promise<this> {\n if (options?.value !== false) {\n if (options?.value === undefined) {\n const install = this.defaultAll\n ? true\n : await confirm({\n message: `Would you like to install dependencies?`,\n active: 'Yes',\n inactive: 'No',\n initialValue: true\n });\n\n if (isCancel(install)) throw new NotAnError('Operation cancelled');\n if (!install) return this;\n }\n\n await CLI.createSpinnerPromise({\n promise: installDependencies({\n cwd: this.directory,\n packageManager: this.packageManager,\n silent: true\n }),\n indicator: 'timer',\n errorMessage: `${colors.bold().red('✗')} Failed to install dependencies`,\n successMessage: `${colors.bold().green('✔')} Dependencies installed successfully`,\n message: `${colors.bold().dim('$')} Installing dependencies`\n })[0];\n\n this.dependenciesInstalled = true;\n }\n\n return this;\n }\n\n public async createModules(): Promise<this> {\n const modulesDirectory = path.join(this.directory, 'src');\n const moduleTemplates = await ModuleTemplateBuilder.resolveModuleTemplates(this.typescript ? 'ts' : 'js');\n\n await mkdir(modulesDirectory, { recursive: true });\n\n if (!this.dependenciesInstalled) {\n log.warn('Dependencies not installed. Skipping module creation.');\n return this;\n }\n\n const moduleOptions: ModuleTemplateBuilder.Options = {\n cli: this.cli,\n config: await this.config?.read()!,\n defaultAll: true,\n typescript: this.typescript,\n };\n\n const [template, loader] = CLI.createSpinnerPromise({\n promise: Promise.all([\n new ModuleTemplateBuilder({\n ...moduleOptions,\n directory: path.join(modulesDirectory, 'commands'),\n filename: `SlashCommand.${this.typescript ? 'ts' : 'js'}`,\n template: moduleTemplates.find(t => t.name === 'SlashCommand')\n })\n .setupPlaceholders()\n .then(m => m.build({ silent: true })),\n new ModuleTemplateBuilder({\n ...moduleOptions,\n directory: path.join(modulesDirectory, 'events'),\n filename: `ClientEvent.${this.typescript ? 'ts' : 'js'}`,\n template: moduleTemplates.find(t => t.name === 'ClientEvent')\n })\n .setupPlaceholders()\n .then(m => m.build({ silent: true }))\n ]),\n message: 'Creating module templates',\n successMessage: 'Module templates created successfully',\n errorMessage: 'Failed to create module templates'\n });\n\n await template;\n return this;\n }\n\n public async build(options?: TemplateBuilder.BuildOptions): Promise<this> {\n await this.packageJson?.write(this.packageJsonPath, true);\n\n if (!options?.skipBuild && this.dependenciesInstalled) await CLI.createSpinnerPromise({\n promise: runScript('build', {\n cwd: this.directory,\n packageManager: this.packageManager,\n silent: true\n }),\n indicator: 'timer',\n errorMessage: `${colors.bold().red('✗')} Failed to build project`,\n successMessage: `${colors.bold().green('✔')} Project built successfully`,\n message: `${colors.bold().dim('$')} Building project`\n })[0];\n\n outro(`Project created in ${colors.cyan(this.relativeDirectory)}`);\n\n console.log(`\\n${colors.bold().green('✔')} Start developing:`);\n\n if (this.relativeDirectory !== './') {\n console.log(` • ${colors.cyan().bold(`cd ${this.relativeDirectory}`)}`);\n }\n\n console.log(` • ${colors.cyan().bold(installDependenciesCommand(this.packageManager ?? 'npm'))} ${colors.dim('(Install dependencies)')}`);\n console.log(` • ${colors.cyan().bold(runScriptCommand(this.packageManager ?? 'npm', 'build'))} ${colors.dim('(Build)')}`);\n console.log(` • ${colors.cyan().bold(runScriptCommand(this.packageManager ?? 'npm', 'dev'))} ${colors.dim('(Development)')}`);\n console.log(` • ${colors.cyan().bold(runScriptCommand(this.packageManager ?? 'npm', 'start'))} ${colors.dim('(Production)')}`);\n\n\n return this;\n }\n}\n\nexport namespace TemplateBuilder {\n export interface Options {\n cli: CLI;\n directory?: string;\n typescript?: boolean;\n packageManager?: PackageManagerName;\n defaultAll?: boolean;\n token?: string;\n }\n\n export const ignoredDirectoryFiles = ['.*', 'LICENSE'];\n\n export const dependencies: Record<'ts'|'js'|'both', Partial<Record<'dependencies'|'devDependencies', Record<string, string>>>> = {\n both: {\n dependencies: {\n '@reciple/core': packageJSON.dependencies?.['@reciple/core']!,\n '@reciple/jsx': packageJSON.dependencies?.['@reciple/jsx']!,\n 'reciple': `^${packageJSON.version}`,\n },\n devDependencies: {\n '@types/node': packageJSON.devDependencies?.['@types/node']!,\n nodemon: packageJSON.devDependencies?.nodemon!,\n typescript: packageJSON.devDependencies?.['typescript']!,\n }\n },\n ts: {},\n js: {}\n };\n\n export function createDependencyRecord(type: 'ts'|'js'): Partial<Record<'dependencies'|'devDependencies', Record<string, string>>> {\n const record = type === 'ts'\n ? dependencies.ts\n : type === 'js'\n ? dependencies.js\n : {};\n\n record.dependencies = { ...record.dependencies, ...dependencies.both.dependencies };\n record.devDependencies = { ...record.devDependencies, ...dependencies.both.devDependencies };\n\n return record;\n }\n\n export interface CreateDirectoryOptions {\n directory?: string;\n ignoredFiles?: string[];\n onNotEmpty?: 'prompt'|'throw'|'ignore';\n }\n\n export interface SetupLanguageOptions {\n typescript?: boolean;\n }\n\n export interface CreateConfigOptions extends Partial<ConfigReader.CreateOptions> {}\n\n export interface CreateModulesOptions extends Partial<CopyOptions> {}\n\n export interface SetPackageManagerOptions {\n packageManager?: PackageManagerName;\n }\n\n export interface InstallDependenciesOptions {\n value?: boolean;\n }\n\n export interface CreateEnvFileOptions {\n envFile?: string;\n tokenKey?: string;\n env?: Record<string, string>;\n }\n\n export interface BuildOptions {\n skipBuild?: boolean;\n }\n\n export interface CopyOptions {\n overwrite?: boolean|((data: CopyMetadata) => boolean);\n filter?: (data: CopyMetadata) => boolean;\n rename?: (data: CopyMetadata) => string;\n }\n\n export interface CopyMetadata {\n basename: string;\n src: string;\n dest: string;\n }\n\n export async function copy(from: string, to: string, options?: CopyOptions): Promise<void> {\n const fromStats = await stat(from).catch(() => undefined);\n if (!fromStats) return;\n\n if (fromStats.isDirectory()) {\n const files = await readdir(from);\n\n for (const file of files) {\n const data: CopyMetadata = {\n basename: file,\n src: path.join(from, file),\n dest: to\n };\n\n await copy(\n data.src,\n path.join(to,\n options?.rename\n ? options.rename(data)\n : file\n ),\n options\n );\n }\n return;\n }\n\n const data: CopyMetadata = {\n basename: path.basename(from),\n src: from,\n dest: to\n };\n\n if (options?.filter && !options.filter(data)) return;\n\n const toStats = await stat(to).catch(() => undefined);\n const overwrite = typeof options?.overwrite === 'function'\n ? options.overwrite(data)\n : options?.overwrite ?? true;\n\n if (toStats && overwrite) return;\n\n await mkdir(path.dirname(to), { recursive: true });\n await copyFile(from, to);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,IAAa,kBAAb,MAAa,gBAAgB;CACzB,AAAQ;CAER,AAAO;CACP,AAAO;CACP,AAAO;CACP,AAAO;CAEP,AAAO;CACP,AAAO;CAEP,AAAO;CACP,AAAO,wBAAiC;CAExC,IAAI,YAAY;AACZ,SAAO,KAAK,cAAc,QAAQ,KAAK;;CAG3C,IAAI,oBAAoB;AACpB,SAAO,KAAK,SAAS,QAAQ,KAAK,EAAE,KAAK,UAAU,IAAI;;CAG3D,IAAI,kBAAkB;AAClB,SAAO,KAAK,KAAK,KAAK,WAAW,eAAe;;CAGpD,IAAI,OAAO;AACP,SAAO,KAAK,KAAK,SAAS,KAAK,UAAU,CAAC;;CAG9C,YAAY,SAAkC;AAC1C,OAAK,MAAM,QAAQ;AACnB,OAAK,aAAa,QAAQ;AAC1B,OAAK,aAAa,QAAQ;AAC1B,OAAK,aAAa,QAAQ,cAAc;AACxC,OAAK,iBAAiB,QAAQ;AAC9B,OAAK,QAAQ,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KAAK;GACL,MAAM;GACT;AAED,MAAI,SAAS,UAAU,CAAC,QAAQ,OAAO,KAAK,CAAE;EAE9C,MAAM,UAAU,MAAM,KAAK,GAAG,CAAC,YAAY,OAAU;EACrD,MAAM,YAAY,OAAO,SAAS,cAAc,aAC1C,QAAQ,UAAU,KAAK,GACvB,SAAS,aAAa;AAE5B,MAAI,WAAW,UAAW;AAE1B,QAAM,MAAM,KAAK,QAAQ,GAAG,EAAE,EAAE,WAAW,MAAM,CAAC;AAClD,QAAM,SAAS,MAAM,GAAG"}
1
+ {"version":3,"file":"TemplateBuilder.mjs","names":["parseDotenv"],"sources":["../../../src/classes/templates/TemplateBuilder.ts"],"sourcesContent":["import { isDebugging, PackageJsonBuilder } from '@reciple/utils';\nimport { ConfigReader } from '../cli/ConfigReader.js';\nimport { copyFile, mkdir, readdir, readFile, stat, writeFile } from 'node:fs/promises';\nimport { confirm, intro, isCancel, outro, select, text, log } from '@clack/prompts';\nimport micromatch from 'micromatch';\nimport { CLI } from '../cli/CLI.js';\nimport path from 'node:path';\nimport { existsSync, statSync } from 'node:fs';\nimport { NotAnError } from '../NotAnError.js';\nimport { slug } from 'github-slugger';\nimport { packageJSON } from '../../helpers/constants.js';\nimport { parse as parseDotenv } from '@dotenvx/dotenvx';\nimport { ModuleTemplateBuilder } from './ModuleTemplateBuilder.js';\nimport { detectPackageManager, installDependencies, installDependenciesCommand, runScript, runScriptCommand, type PackageManagerName } from 'nypm';\nimport { colors } from '@prtty/prtty';\n\nexport class TemplateBuilder {\n private _directory?: string;\n\n public cli: CLI;\n public typescript?: boolean;\n public token?: string;\n public defaultAll: boolean;\n\n public config?: ConfigReader;\n public packageJson?: PackageJsonBuilder;\n\n public packageManager?: PackageManagerName;\n public dependenciesInstalled: boolean = false;\n\n get directory() {\n return this._directory ?? process.cwd();\n }\n\n get relativeDirectory() {\n return path.relative(process.cwd(), this.directory) || './';\n }\n\n get packageJsonPath() {\n return path.join(this.directory, 'package.json');\n }\n\n get name() {\n return slug(path.basename(this.directory));\n }\n\n constructor(options: TemplateBuilder.Options) {\n this.cli = options.cli;\n this._directory = options.directory;\n this.typescript = options.typescript;\n this.defaultAll = options.defaultAll ?? false;\n this.packageManager = options.packageManager;\n this.token = options.token;\n }\n\n public async init(): Promise<this> {\n intro(colors.bold().black().bgCyan(` ${this.cli.command.name()} create - v${this.cli.build} `));\n return this;\n }\n\n public async createDirectory(options?: TemplateBuilder.CreateDirectoryOptions): Promise<this> {\n this._directory = options?.directory ?? this._directory;\n\n if (!this._directory) {\n const dir = this.defaultAll\n ? process.cwd()\n : await text({\n message: `Enter project directory`,\n placeholder: `Leave empty to use current directory`,\n defaultValue: process.cwd(),\n validate: value => {\n const dir = path.resolve(value);\n if (existsSync(dir) && !statSync(dir).isDirectory()) return 'Invalid folder directory';\n }\n });\n\n if (isCancel(dir)) throw new NotAnError('Operation cancelled');\n this._directory = dir;\n }\n\n this._directory = path.resolve(this._directory);\n\n const stats = await stat(this.directory).catch(() => undefined);\n\n if (stats) {\n let files = await readdir(this.directory);\n files = micromatch.not(files, options?.ignoredFiles ?? TemplateBuilder.ignoredDirectoryFiles, { dot: true });\n\n if (files.length) {\n switch (options?.onNotEmpty) {\n case 'throw':\n throw new NotAnError(`Directory ${colors.cyan(this.relativeDirectory)} is not empty`);\n case 'ignore':\n return this;\n default:\n const overwrite = this.defaultAll\n ? false\n : await confirm({\n message: `Directory ${colors.cyan(this.relativeDirectory)} is not empty. Would you like to continue?`,\n active: 'Yes',\n inactive: 'No',\n initialValue: false\n });\n\n if (!overwrite) throw new NotAnError(`Directory ${colors.cyan(this.relativeDirectory)} is not empty`);\n if (isCancel(overwrite)) throw new NotAnError('Operation cancelled');\n break;\n }\n }\n }\n\n await mkdir(this.directory, { recursive: true });\n return this;\n }\n\n public async setupLanguage(options?: TemplateBuilder.SetupLanguageOptions): Promise<this> {\n this.typescript = options?.typescript ?? this.typescript;\n\n if (!this.typescript) {\n const isTypeScript = this.defaultAll\n ? false\n : await confirm({\n message: 'Would you like to use TypeScript?',\n active: 'Yes',\n inactive: 'No',\n initialValue: false\n });\n\n if (isCancel(isTypeScript)) throw new NotAnError('Operation cancelled');\n this.typescript = isTypeScript;\n }\n\n return this;\n }\n\n public async createEnvFile(options?: TemplateBuilder.CreateEnvFileOptions): Promise<this> {\n const tokenKey = options?.tokenKey ?? 'DISCORD_TOKEN';\n const envFile = options?.envFile ? path.resolve(options.envFile) : path.join(this.directory, '.env');\n const stats = await stat(envFile).catch(() => undefined);\n\n let env = options?.env ?? {};\n env = stats\n ? parseDotenv(await readFile(envFile, 'utf-8'), {\n processEnv: env\n })\n : env;\n\n if (env[tokenKey]) {\n const skip = this.defaultAll || await confirm({\n message: 'Discord bot token already exists in .env file, do you want to skip?',\n initialValue: true,\n active: 'Yes',\n inactive: 'No'\n });\n\n if (isCancel(skip)) throw new NotAnError('Operation cancelled');\n if (skip) return this;\n }\n\n const token = await text({\n message: 'Enter Discord Bot Token',\n placeholder: 'Bot Token from Discord Developer Portal',\n defaultValue: env[tokenKey]\n });\n\n if (isCancel(token)) throw new NotAnError('Operation cancelled');\n env[tokenKey] = token;\n\n await writeFile(envFile, `\\n${tokenKey}=\"${token}\"\\n`, {\n encoding: 'utf-8',\n flag: 'a'\n });\n\n return this;\n }\n\n public async createConfig(options?: TemplateBuilder.CreateConfigOptions): Promise<this> {\n let filepath = options?.path;\n\n if (!filepath) {\n filepath = await ConfigReader.find({\n cwd: this.directory,\n lang: this.typescript\n ? 'ts'\n : this.typescript === false\n ? 'js'\n : undefined\n }) ?? path.join(\n this.directory,\n ConfigReader.createConfigFilename(this.typescript ? 'ts' : 'js')\n );\n }\n\n const exists = await ConfigReader.exists(filepath);\n\n if (exists) {\n const overwrite = this.defaultAll\n ? false\n : await confirm({\n message: `Config file already exists at ${colors.green(path.relative(process.cwd(), filepath))}. Would you like to overwrite it?`,\n active: 'Yes',\n inactive: 'No',\n initialValue: false\n });\n\n if (!overwrite) return this;\n if (isCancel(overwrite)) throw new NotAnError('Operation cancelled');\n }\n\n this.config = await ConfigReader.create({\n ...options,\n path: filepath,\n type: this.typescript ? 'ts' : 'js',\n overwrite: true,\n readOptions: false\n });\n\n return this;\n }\n\n public async createTemplate(options?: TemplateBuilder.CreateModulesOptions): Promise<this> {\n const source = path.join(CLI.root, './assets/templates/', this.typescript ? 'typescript' : 'javascript');\n const globals = path.join(CLI.root, './assets/global/');\n\n function rename(data: TemplateBuilder.CopyMetadata) {\n switch (data.basename) {\n case 'gitignore':\n return '.gitignore';\n default:\n return options?.rename?.(data) ?? data.basename;\n }\n }\n\n function overwrite(data: TemplateBuilder.CopyMetadata) {\n switch (data.basename) {\n case 'gitignore':\n return false;\n case 'tsconfig.json':\n case 'jsconfig.json':\n return true;\n default:\n return (typeof options?.overwrite === 'boolean' ? options.overwrite : options?.overwrite?.(data)) ?? true;\n }\n }\n\n const [template, loader] = CLI.createSpinnerPromise({\n promise: Promise.all([\n TemplateBuilder.copy(source, this.directory, { ...options, rename, overwrite }),\n TemplateBuilder.copy(globals, this.directory, { ...options, rename, overwrite })\n ]),\n message: 'Copying template files',\n successMessage: 'Files copied successfully',\n errorMessage: 'Failed to copy files'\n });\n\n await template;\n return this;\n }\n\n public async setPackageManager(options?: TemplateBuilder.SetPackageManagerOptions) {\n this.packageManager = options?.packageManager ?? this.packageManager;\n\n if (!this.packageManager) {\n const defaultPackageManager = await detectPackageManager(this.directory).then(pm => pm?.name ?? 'npm');\n const packageManager: PackageManagerName|symbol = this.defaultAll\n ? defaultPackageManager\n : await select({\n message: 'Select package manager',\n options: [\n { value: defaultPackageManager, label: defaultPackageManager },\n ...[\n { value: 'npm', label: 'npm' },\n { value: 'yarn', label: 'yarn' },\n { value: 'pnpm', label: 'pnpm' },\n { value: 'bun', label: 'bun' },\n { value: 'deno', label: 'deno' }\n ].filter(o => o.value !== defaultPackageManager) as { value: PackageManagerName; label: string; }[]\n ],\n initialValue: defaultPackageManager\n });\n\n if (isCancel(packageManager)) throw new NotAnError('Operation cancelled');\n this.packageManager = packageManager;\n }\n\n this.packageJson = await PackageJsonBuilder.read(this.packageJsonPath, true);\n this.packageJson.merge({\n name: this.name,\n private: true,\n type: 'module',\n scripts: {\n build: `reciple build`,\n start: 'reciple start',\n dev: 'nodemon',\n },\n ...TemplateBuilder.createDependencyRecord(this.typescript ? 'ts' : 'js'),\n });\n\n await this.packageJson?.write(this.packageJsonPath, true);\n\n return this;\n }\n\n public async installDependencies(options?: TemplateBuilder.InstallDependenciesOptions): Promise<this> {\n if (options?.value !== false) {\n if (options?.value === undefined) {\n const install = this.defaultAll\n ? true\n : await confirm({\n message: `Would you like to install dependencies?`,\n active: 'Yes',\n inactive: 'No',\n initialValue: true\n });\n\n if (isCancel(install)) throw new NotAnError('Operation cancelled');\n if (!install) return this;\n }\n\n await CLI.createSpinnerPromise({\n promise: installDependencies({\n cwd: this.directory,\n packageManager: this.packageManager,\n silent: !isDebugging()\n }),\n indicator: 'timer',\n errorMessage: `${colors.bold().red('✗')} Failed to install dependencies`,\n successMessage: `${colors.bold().green('✔')} Dependencies installed successfully`,\n message: `${colors.bold().dim('$')} Installing dependencies`\n })[0];\n\n this.dependenciesInstalled = true;\n }\n\n return this;\n }\n\n public async createModules(): Promise<this> {\n const modulesDirectory = path.join(this.directory, 'src');\n const moduleTemplates = await ModuleTemplateBuilder.resolveModuleTemplates(this.typescript ? 'ts' : 'js');\n\n await mkdir(modulesDirectory, { recursive: true });\n\n if (!this.dependenciesInstalled) {\n log.warn('Dependencies not installed. Skipping module creation.');\n return this;\n }\n\n const moduleOptions: ModuleTemplateBuilder.Options = {\n cli: this.cli,\n config: await this.config?.read()!,\n defaultAll: true,\n typescript: this.typescript,\n };\n\n const [template, loader] = CLI.createSpinnerPromise({\n promise: Promise.all([\n new ModuleTemplateBuilder({\n ...moduleOptions,\n directory: path.join(modulesDirectory, 'commands'),\n filename: `SlashCommand.${this.typescript ? 'ts' : 'js'}`,\n template: moduleTemplates.find(t => t.name === 'SlashCommand')\n })\n .setupPlaceholders()\n .then(m => m.build({ silent: true })),\n new ModuleTemplateBuilder({\n ...moduleOptions,\n directory: path.join(modulesDirectory, 'events'),\n filename: `ClientEvent.${this.typescript ? 'ts' : 'js'}`,\n template: moduleTemplates.find(t => t.name === 'ClientEvent')\n })\n .setupPlaceholders()\n .then(m => m.build({ silent: true }))\n ]),\n message: 'Creating module templates',\n successMessage: 'Module templates created successfully',\n errorMessage: 'Failed to create module templates'\n });\n\n await template;\n return this;\n }\n\n public async build(options?: TemplateBuilder.BuildOptions): Promise<this> {\n if (!options?.skipBuild && this.dependenciesInstalled) await CLI.createSpinnerPromise({\n promise: runScript('build', {\n cwd: this.directory,\n packageManager: this.packageManager,\n silent: !isDebugging()\n }),\n indicator: 'timer',\n errorMessage: `${colors.bold().red('✗')} Failed to build project`,\n successMessage: `${colors.bold().green('✔')} Project built successfully`,\n message: `${colors.bold().dim('$')} Building project`\n })[0];\n\n outro(`Project created in ${colors.cyan(this.relativeDirectory)}`);\n\n console.log(`\\n${colors.bold().green('✔')} Start developing:`);\n\n if (this.relativeDirectory !== './') {\n console.log(` • ${colors.cyan().bold(`cd ${this.relativeDirectory}`)}`);\n }\n\n console.log(` • ${colors.cyan().bold(installDependenciesCommand(this.packageManager ?? 'npm'))} ${colors.dim('(Install dependencies)')}`);\n console.log(` • ${colors.cyan().bold(runScriptCommand(this.packageManager ?? 'npm', 'build'))} ${colors.dim('(Build)')}`);\n console.log(` • ${colors.cyan().bold(runScriptCommand(this.packageManager ?? 'npm', 'dev'))} ${colors.dim('(Development)')}`);\n console.log(` • ${colors.cyan().bold(runScriptCommand(this.packageManager ?? 'npm', 'start'))} ${colors.dim('(Production)')}`);\n\n\n return this;\n }\n}\n\nexport namespace TemplateBuilder {\n export interface Options {\n cli: CLI;\n directory?: string;\n typescript?: boolean;\n packageManager?: PackageManagerName;\n defaultAll?: boolean;\n token?: string;\n }\n\n export const ignoredDirectoryFiles = ['.*', 'LICENSE'];\n\n export const dependencies: Record<'ts'|'js'|'both', Partial<Record<'dependencies'|'devDependencies', Record<string, string>>>> = {\n both: {\n dependencies: {\n '@reciple/core': packageJSON.dependencies?.['@reciple/core']!,\n '@reciple/jsx': packageJSON.dependencies?.['@reciple/jsx']!,\n 'reciple': `^${packageJSON.version}`,\n },\n devDependencies: {\n '@types/node': packageJSON.devDependencies?.['@types/node']!,\n nodemon: packageJSON.devDependencies?.nodemon!,\n typescript: packageJSON.devDependencies?.['typescript']!,\n }\n },\n ts: {},\n js: {}\n };\n\n export function createDependencyRecord(type: 'ts'|'js'): Partial<Record<'dependencies'|'devDependencies', Record<string, string>>> {\n const record = type === 'ts'\n ? dependencies.ts\n : type === 'js'\n ? dependencies.js\n : {};\n\n record.dependencies = { ...record.dependencies, ...dependencies.both.dependencies };\n record.devDependencies = { ...record.devDependencies, ...dependencies.both.devDependencies };\n\n return record;\n }\n\n export interface CreateDirectoryOptions {\n directory?: string;\n ignoredFiles?: string[];\n onNotEmpty?: 'prompt'|'throw'|'ignore';\n }\n\n export interface SetupLanguageOptions {\n typescript?: boolean;\n }\n\n export interface CreateConfigOptions extends Partial<ConfigReader.CreateOptions> {}\n\n export interface CreateModulesOptions extends Partial<CopyOptions> {}\n\n export interface SetPackageManagerOptions {\n packageManager?: PackageManagerName;\n }\n\n export interface InstallDependenciesOptions {\n value?: boolean;\n }\n\n export interface CreateEnvFileOptions {\n envFile?: string;\n tokenKey?: string;\n env?: Record<string, string>;\n }\n\n export interface BuildOptions {\n skipBuild?: boolean;\n }\n\n export interface CopyOptions {\n overwrite?: boolean|((data: CopyMetadata) => boolean);\n filter?: (data: CopyMetadata) => boolean;\n rename?: (data: CopyMetadata) => string;\n }\n\n export interface CopyMetadata {\n basename: string;\n src: string;\n dest: string;\n }\n\n export async function copy(from: string, to: string, options?: CopyOptions): Promise<void> {\n const fromStats = await stat(from).catch(() => undefined);\n if (!fromStats) return;\n\n if (fromStats.isDirectory()) {\n const files = await readdir(from);\n\n for (const file of files) {\n const data: CopyMetadata = {\n basename: file,\n src: path.join(from, file),\n dest: to\n };\n\n await copy(\n data.src,\n path.join(to,\n options?.rename\n ? options.rename(data)\n : file\n ),\n options\n );\n }\n return;\n }\n\n const data: CopyMetadata = {\n basename: path.basename(from),\n src: from,\n dest: to\n };\n\n if (options?.filter && !options.filter(data)) return;\n\n const toStats = await stat(to).catch(() => undefined);\n const overwrite = typeof options?.overwrite === 'function'\n ? options.overwrite(data)\n : options?.overwrite ?? true;\n\n if (toStats && overwrite) return;\n\n await mkdir(path.dirname(to), { recursive: true });\n await copyFile(from, to);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,IAAa,kBAAb,MAAa,gBAAgB;CACzB,AAAQ;CAER,AAAO;CACP,AAAO;CACP,AAAO;CACP,AAAO;CAEP,AAAO;CACP,AAAO;CAEP,AAAO;CACP,AAAO,wBAAiC;CAExC,IAAI,YAAY;AACZ,SAAO,KAAK,cAAc,QAAQ,KAAK;;CAG3C,IAAI,oBAAoB;AACpB,SAAO,KAAK,SAAS,QAAQ,KAAK,EAAE,KAAK,UAAU,IAAI;;CAG3D,IAAI,kBAAkB;AAClB,SAAO,KAAK,KAAK,KAAK,WAAW,eAAe;;CAGpD,IAAI,OAAO;AACP,SAAO,KAAK,KAAK,SAAS,KAAK,UAAU,CAAC;;CAG9C,YAAY,SAAkC;AAC1C,OAAK,MAAM,QAAQ;AACnB,OAAK,aAAa,QAAQ;AAC1B,OAAK,aAAa,QAAQ;AAC1B,OAAK,aAAa,QAAQ,cAAc;AACxC,OAAK,iBAAiB,QAAQ;AAC9B,OAAK,QAAQ,QAAQ;;CAGzB,MAAa,OAAsB;AAC/B,QAAM,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,IAAI,KAAK,IAAI,QAAQ,MAAM,CAAC,aAAa,KAAK,IAAI,MAAM,GAAG,CAAC;AAC/F,SAAO;;CAGX,MAAa,gBAAgB,SAAiE;AAC1F,OAAK,aAAa,SAAS,aAAa,KAAK;AAE7C,MAAI,CAAC,KAAK,YAAY;GAClB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1B,QAAM,MAAM,KAAK,QAAQ,GAAG,EAAE,EAAE,WAAW,MAAM,CAAC;AAClD,QAAM,SAAS,MAAM,GAAG"}
@@ -3,11 +3,11 @@ import { AnyCommandModuleData } from "../../helpers/types.mjs";
3
3
  import "../../index.mjs";
4
4
  import * as _reciple_core0 from "@reciple/core";
5
5
  import { Validator } from "@reciple/core";
6
- import * as _sapphire_shapeshift9 from "@sapphire/shapeshift";
6
+ import * as _sapphire_shapeshift33 from "@sapphire/shapeshift";
7
7
 
8
8
  //#region src/classes/validation/CommandModuleValidator.d.ts
9
9
  declare class CommandModuleValidator extends Validator {
10
- static object: _sapphire_shapeshift9.ObjectValidator<{
10
+ static object: _sapphire_shapeshift33.ObjectValidator<{
11
11
  id: string | undefined;
12
12
  moduleType: ModuleType | undefined;
13
13
  onEnable: Function | undefined;
@@ -16,23 +16,23 @@ declare class CommandModuleValidator extends Validator {
16
16
  } & {
17
17
  id: string;
18
18
  type: _reciple_core0.CommandType;
19
- data: _sapphire_shapeshift9.UndefinedToOptional<{
19
+ data: _sapphire_shapeshift33.UndefinedToOptional<{
20
20
  name: any;
21
21
  description: any;
22
22
  aliases: any;
23
23
  options: any;
24
24
  flags: any;
25
- }> | _sapphire_shapeshift9.UndefinedToOptional<{
25
+ }> | _sapphire_shapeshift33.UndefinedToOptional<{
26
26
  type: any;
27
27
  name: any;
28
28
  }>;
29
29
  cooldown: number | undefined;
30
- preconditions: _sapphire_shapeshift9.UndefinedToOptional<{
30
+ preconditions: _sapphire_shapeshift33.UndefinedToOptional<{
31
31
  id: any;
32
32
  scope: any;
33
33
  execute: any;
34
34
  }>[] | undefined;
35
- postconditions: _sapphire_shapeshift9.UndefinedToOptional<{
35
+ postconditions: _sapphire_shapeshift33.UndefinedToOptional<{
36
36
  id: any;
37
37
  scope: any;
38
38
  execute: any;
@@ -40,7 +40,7 @@ declare class CommandModuleValidator extends Validator {
40
40
  disabledPreconditions: string[] | undefined;
41
41
  disabledPostconditions: string[] | undefined;
42
42
  execute: Function;
43
- }, _sapphire_shapeshift9.UndefinedToOptional<{
43
+ }, _sapphire_shapeshift33.UndefinedToOptional<{
44
44
  id: string | undefined;
45
45
  moduleType: ModuleType | undefined;
46
46
  onEnable: Function | undefined;
@@ -49,23 +49,23 @@ declare class CommandModuleValidator extends Validator {
49
49
  } & {
50
50
  id: string;
51
51
  type: _reciple_core0.CommandType;
52
- data: _sapphire_shapeshift9.UndefinedToOptional<{
52
+ data: _sapphire_shapeshift33.UndefinedToOptional<{
53
53
  name: any;
54
54
  description: any;
55
55
  aliases: any;
56
56
  options: any;
57
57
  flags: any;
58
- }> | _sapphire_shapeshift9.UndefinedToOptional<{
58
+ }> | _sapphire_shapeshift33.UndefinedToOptional<{
59
59
  type: any;
60
60
  name: any;
61
61
  }>;
62
62
  cooldown: number | undefined;
63
- preconditions: _sapphire_shapeshift9.UndefinedToOptional<{
63
+ preconditions: _sapphire_shapeshift33.UndefinedToOptional<{
64
64
  id: any;
65
65
  scope: any;
66
66
  execute: any;
67
67
  }>[] | undefined;
68
- postconditions: _sapphire_shapeshift9.UndefinedToOptional<{
68
+ postconditions: _sapphire_shapeshift33.UndefinedToOptional<{
69
69
  id: any;
70
70
  scope: any;
71
71
  execute: any;
@@ -74,9 +74,9 @@ declare class CommandModuleValidator extends Validator {
74
74
  disabledPostconditions: string[] | undefined;
75
75
  execute: Function;
76
76
  }>>;
77
- static resolvable: _sapphire_shapeshift9.UnionValidator<_sapphire_shapeshift9.UndefinedToOptional<{
77
+ static resolvable: _sapphire_shapeshift33.UnionValidator<_sapphire_shapeshift33.UndefinedToOptional<{
78
78
  toJSON: Function;
79
- }> | _sapphire_shapeshift9.UndefinedToOptional<{
79
+ }> | _sapphire_shapeshift33.UndefinedToOptional<{
80
80
  id: string | undefined;
81
81
  moduleType: ModuleType | undefined;
82
82
  onEnable: Function | undefined;
@@ -85,23 +85,23 @@ declare class CommandModuleValidator extends Validator {
85
85
  } & {
86
86
  id: string;
87
87
  type: _reciple_core0.CommandType;
88
- data: _sapphire_shapeshift9.UndefinedToOptional<{
88
+ data: _sapphire_shapeshift33.UndefinedToOptional<{
89
89
  name: any;
90
90
  description: any;
91
91
  aliases: any;
92
92
  options: any;
93
93
  flags: any;
94
- }> | _sapphire_shapeshift9.UndefinedToOptional<{
94
+ }> | _sapphire_shapeshift33.UndefinedToOptional<{
95
95
  type: any;
96
96
  name: any;
97
97
  }>;
98
98
  cooldown: number | undefined;
99
- preconditions: _sapphire_shapeshift9.UndefinedToOptional<{
99
+ preconditions: _sapphire_shapeshift33.UndefinedToOptional<{
100
100
  id: any;
101
101
  scope: any;
102
102
  execute: any;
103
103
  }>[] | undefined;
104
- postconditions: _sapphire_shapeshift9.UndefinedToOptional<{
104
+ postconditions: _sapphire_shapeshift33.UndefinedToOptional<{
105
105
  id: any;
106
106
  scope: any;
107
107
  execute: any;
@@ -3,19 +3,19 @@ import { EventModule } from "../modules/events/EventModule.mjs";
3
3
  import "../../index.mjs";
4
4
  import { Validator } from "@reciple/core";
5
5
  import { EventEmitter } from "node:events";
6
- import * as _sapphire_shapeshift26 from "@sapphire/shapeshift";
6
+ import * as _sapphire_shapeshift9 from "@sapphire/shapeshift";
7
7
 
8
8
  //#region src/classes/validation/EventModuleValidator.d.ts
9
9
  declare class EventModuleValidator extends Validator {
10
- static emitter: _sapphire_shapeshift26.InstanceValidator<EventEmitter<{
10
+ static emitter: _sapphire_shapeshift9.InstanceValidator<EventEmitter<{
11
11
  [x: string]: any[];
12
12
  [x: number]: any[];
13
13
  [x: symbol]: any[];
14
14
  }>>;
15
- static event: _sapphire_shapeshift26.StringValidator<string>;
16
- static once: _sapphire_shapeshift26.UnionValidator<boolean | undefined>;
17
- static onEvent: _sapphire_shapeshift26.InstanceValidator<Function>;
18
- static object: _sapphire_shapeshift26.ObjectValidator<{
15
+ static event: _sapphire_shapeshift9.StringValidator<string>;
16
+ static once: _sapphire_shapeshift9.UnionValidator<boolean | undefined>;
17
+ static onEvent: _sapphire_shapeshift9.InstanceValidator<Function>;
18
+ static object: _sapphire_shapeshift9.ObjectValidator<{
19
19
  id: string | undefined;
20
20
  moduleType: ModuleType | undefined;
21
21
  onEnable: Function | undefined;
@@ -30,7 +30,7 @@ declare class EventModuleValidator extends Validator {
30
30
  event: string;
31
31
  once: boolean | undefined;
32
32
  onEvent: Function;
33
- }, _sapphire_shapeshift26.UndefinedToOptional<{
33
+ }, _sapphire_shapeshift9.UndefinedToOptional<{
34
34
  id: string | undefined;
35
35
  moduleType: ModuleType | undefined;
36
36
  onEnable: Function | undefined;
@@ -46,9 +46,9 @@ declare class EventModuleValidator extends Validator {
46
46
  once: boolean | undefined;
47
47
  onEvent: Function;
48
48
  }>>;
49
- static resolvable: _sapphire_shapeshift26.UnionValidator<_sapphire_shapeshift26.UndefinedToOptional<{
49
+ static resolvable: _sapphire_shapeshift9.UnionValidator<_sapphire_shapeshift9.UndefinedToOptional<{
50
50
  toJSON: Function;
51
- }> | _sapphire_shapeshift26.UndefinedToOptional<{
51
+ }> | _sapphire_shapeshift9.UndefinedToOptional<{
52
52
  id: string | undefined;
53
53
  moduleType: ModuleType | undefined;
54
54
  onEnable: Function | undefined;
@@ -1,22 +1,22 @@
1
1
  import { PostconditionModule } from "../modules/PostconditionModule.mjs";
2
2
  import { CommandPostconditionReason, CommandType, Validator } from "@reciple/core";
3
- import * as _sapphire_shapeshift35 from "@sapphire/shapeshift";
3
+ import * as _sapphire_shapeshift18 from "@sapphire/shapeshift";
4
4
 
5
5
  //#region src/classes/validation/PostconditionModule.d.ts
6
6
  declare class PostconditionModuleValidator extends Validator {
7
- static scope: _sapphire_shapeshift35.UnionValidator<CommandType[] | undefined>;
8
- static accepts: _sapphire_shapeshift35.UnionValidator<CommandPostconditionReason[] | undefined>;
9
- static execute: _sapphire_shapeshift35.InstanceValidator<Function>;
10
- static object: _sapphire_shapeshift35.ObjectValidator<{
7
+ static scope: _sapphire_shapeshift18.UnionValidator<CommandType[] | undefined>;
8
+ static accepts: _sapphire_shapeshift18.UnionValidator<CommandPostconditionReason[] | undefined>;
9
+ static execute: _sapphire_shapeshift18.InstanceValidator<Function>;
10
+ static object: _sapphire_shapeshift18.ObjectValidator<{
11
11
  scope: CommandType[] | undefined;
12
12
  execute: Function;
13
- }, _sapphire_shapeshift35.UndefinedToOptional<{
13
+ }, _sapphire_shapeshift18.UndefinedToOptional<{
14
14
  scope: CommandType[] | undefined;
15
15
  execute: Function;
16
16
  }>>;
17
- static resolvable: _sapphire_shapeshift35.UnionValidator<_sapphire_shapeshift35.UndefinedToOptional<{
17
+ static resolvable: _sapphire_shapeshift18.UnionValidator<_sapphire_shapeshift18.UndefinedToOptional<{
18
18
  toJSON: Function;
19
- }> | _sapphire_shapeshift35.UndefinedToOptional<{
19
+ }> | _sapphire_shapeshift18.UndefinedToOptional<{
20
20
  scope: CommandType[] | undefined;
21
21
  execute: Function;
22
22
  }>>;
@@ -1,21 +1,21 @@
1
1
  import { PreconditionModule } from "../modules/PreconditionModule.mjs";
2
2
  import { CommandType, Validator } from "@reciple/core";
3
- import * as _sapphire_shapeshift43 from "@sapphire/shapeshift";
3
+ import * as _sapphire_shapeshift26 from "@sapphire/shapeshift";
4
4
 
5
5
  //#region src/classes/validation/PreconditionModule.d.ts
6
6
  declare class PreconditionModuleValidator extends Validator {
7
- static scope: _sapphire_shapeshift43.UnionValidator<CommandType[] | undefined>;
8
- static execute: _sapphire_shapeshift43.InstanceValidator<Function>;
9
- static object: _sapphire_shapeshift43.ObjectValidator<{
7
+ static scope: _sapphire_shapeshift26.UnionValidator<CommandType[] | undefined>;
8
+ static execute: _sapphire_shapeshift26.InstanceValidator<Function>;
9
+ static object: _sapphire_shapeshift26.ObjectValidator<{
10
10
  scope: CommandType[] | undefined;
11
11
  execute: Function;
12
- }, _sapphire_shapeshift43.UndefinedToOptional<{
12
+ }, _sapphire_shapeshift26.UndefinedToOptional<{
13
13
  scope: CommandType[] | undefined;
14
14
  execute: Function;
15
15
  }>>;
16
- static resolvable: _sapphire_shapeshift43.UnionValidator<_sapphire_shapeshift43.UndefinedToOptional<{
16
+ static resolvable: _sapphire_shapeshift26.UnionValidator<_sapphire_shapeshift26.UndefinedToOptional<{
17
17
  toJSON: Function;
18
- }> | _sapphire_shapeshift43.UndefinedToOptional<{
18
+ }> | _sapphire_shapeshift26.UndefinedToOptional<{
19
19
  scope: CommandType[] | undefined;
20
20
  execute: Function;
21
21
  }>>;
@@ -1,10 +1,11 @@
1
1
  import { CLI } from "../classes/cli/CLI.mjs";
2
+ import { PackageJson } from "@reciple/utils";
2
3
 
3
4
  //#region src/helpers/constants.d.ts
4
5
  /**
5
6
  * @private
6
7
  */
7
- declare const packageJSON: any;
8
+ declare const packageJSON: PackageJson;
8
9
  declare const cli: CLI;
9
10
  declare enum ModuleType {
10
11
  Base = 1,
package/dist/package.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  //#region package.json
2
2
  var package_default = {
3
3
  name: "reciple",
4
- version: "10.0.2",
4
+ version: "10.0.4",
5
5
  license: "LGPL-3.0-only",
6
6
  description: "The CLI for reciple",
7
7
  module: "./dist/index.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reciple",
3
- "version": "10.0.2",
3
+ "version": "10.0.4",
4
4
  "license": "LGPL-3.0-only",
5
5
  "description": "The CLI for reciple",
6
6
  "module": "./dist/index.mjs",