reciple 10.0.1 → 10.0.3
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.
- package/dist/_virtual/{_@oxc-project_runtime@0.108.0 → _@oxc-project_runtime@0.110.0}/helpers/decorate.mjs +1 -1
- package/dist/bin/commands/start.mjs +23 -23
- package/dist/bin/commands/start.mjs.map +1 -1
- package/dist/bin/commands/startSharding.mjs +18 -18
- package/dist/bin/commands/startSharding.mjs.map +1 -1
- package/dist/classes/cli/CLI.mjs +1 -1
- package/dist/classes/cli/ConfigReader.mjs +1 -0
- package/dist/classes/cli/ConfigReader.mjs.map +1 -1
- package/dist/classes/client/ModuleLoader.mjs +18 -18
- package/dist/classes/client/ModuleLoader.mjs.map +1 -1
- package/dist/classes/managers/ModuleManager.mjs +1 -1
- package/dist/classes/modules/PostconditionModule.mjs +1 -1
- package/dist/classes/modules/PreconditionModule.mjs +1 -1
- package/dist/classes/modules/commands/ContextMenuCommandModule.mjs +1 -1
- package/dist/classes/modules/commands/MessageCommandModule.mjs +1 -1
- package/dist/classes/modules/commands/SlashCommandModule.mjs +1 -1
- package/dist/classes/templates/ModuleTemplateBuilder.mjs +19 -19
- package/dist/classes/templates/ModuleTemplateBuilder.mjs.map +1 -1
- package/dist/classes/templates/TemplateBuilder.mjs +8 -8
- package/dist/classes/templates/TemplateBuilder.mjs.map +1 -1
- package/dist/classes/validation/BaseModuleValidator.d.mts +11 -11
- package/dist/classes/validation/CommandModuleValidator.d.mts +17 -17
- package/dist/classes/validation/EventModuleValidator.d.mts +10 -11
- package/dist/classes/validation/PostconditionModule.d.mts +9 -9
- package/dist/classes/validation/PreconditionModule.d.mts +7 -7
- package/dist/package.mjs +1 -1
- package/package.json +1 -1
|
@@ -71,11 +71,11 @@ var ModuleTemplateBuilder = class ModuleTemplateBuilder {
|
|
|
71
71
|
if (!template) {
|
|
72
72
|
const templateName = typeof options?.template === "string" ? options.template : void 0;
|
|
73
73
|
const templates = await ModuleTemplateBuilder.resolveModuleTemplates(this.typescript ? "ts" : "js");
|
|
74
|
-
const selectedTemplate = this.defaultAll ? templateName ? templates.find((template
|
|
74
|
+
const selectedTemplate = this.defaultAll ? templateName ? templates.find((template) => template.name === templateName) : templates.at(0) : await select({
|
|
75
75
|
message: "Select a module template",
|
|
76
|
-
options: templates.map((template
|
|
77
|
-
label: template
|
|
78
|
-
value: template
|
|
76
|
+
options: templates.map((template) => ({
|
|
77
|
+
label: template.name,
|
|
78
|
+
value: template
|
|
79
79
|
}))
|
|
80
80
|
});
|
|
81
81
|
if (isCancel(selectedTemplate)) throw new NotAnError("Operation cancelled");
|
|
@@ -102,9 +102,9 @@ var ModuleTemplateBuilder = class ModuleTemplateBuilder {
|
|
|
102
102
|
initialValue: defaultValue,
|
|
103
103
|
placeholder: defaultValue,
|
|
104
104
|
defaultValue,
|
|
105
|
-
validate: (value
|
|
106
|
-
if (!value
|
|
107
|
-
if (value
|
|
105
|
+
validate: (value) => {
|
|
106
|
+
if (!value) return "Please enter a value";
|
|
107
|
+
if (value.includes(" ")) return "Please enter a value without spaces";
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
break;
|
|
@@ -162,9 +162,9 @@ var ModuleTemplateBuilder = class ModuleTemplateBuilder {
|
|
|
162
162
|
});
|
|
163
163
|
const selectedDirectory = this.defaultAll ? directories.at(0) : await select({
|
|
164
164
|
message: "Select a directory",
|
|
165
|
-
options: directories.map((directory
|
|
166
|
-
label: path.relative(cwd, directory
|
|
167
|
-
value: directory
|
|
165
|
+
options: directories.map((directory) => ({
|
|
166
|
+
label: path.relative(cwd, directory),
|
|
167
|
+
value: directory
|
|
168
168
|
}))
|
|
169
169
|
});
|
|
170
170
|
if (isCancel(selectedDirectory)) throw new NotAnError("Operation cancelled");
|
|
@@ -203,15 +203,15 @@ var ModuleTemplateBuilder = class ModuleTemplateBuilder {
|
|
|
203
203
|
}
|
|
204
204
|
};
|
|
205
205
|
(function(_ModuleTemplateBuilder) {
|
|
206
|
-
let Placeholder = /* @__PURE__ */ function(Placeholder
|
|
207
|
-
Placeholder
|
|
208
|
-
Placeholder
|
|
209
|
-
Placeholder
|
|
210
|
-
Placeholder
|
|
211
|
-
Placeholder
|
|
212
|
-
Placeholder
|
|
213
|
-
Placeholder
|
|
214
|
-
return Placeholder
|
|
206
|
+
let Placeholder = /* @__PURE__ */ function(Placeholder) {
|
|
207
|
+
Placeholder["ModuleName"] = "$MODULE_NAME$";
|
|
208
|
+
Placeholder["CommandName"] = "$COMMAND_NAME$";
|
|
209
|
+
Placeholder["CommandDescription"] = "$COMMAND_DESCRIPTION$";
|
|
210
|
+
Placeholder["CommandContextMenuType"] = "$COMMAND_CONTEXT_MENU_TYPE$";
|
|
211
|
+
Placeholder["EventEmitter"] = "$EVENT_EMITTER$";
|
|
212
|
+
Placeholder["EventName"] = "$EVENT_NAME$";
|
|
213
|
+
Placeholder["EventOnce"] = "$EVENT_ONCE$";
|
|
214
|
+
return Placeholder;
|
|
215
215
|
}({});
|
|
216
216
|
_ModuleTemplateBuilder.Placeholder = Placeholder;
|
|
217
217
|
_ModuleTemplateBuilder.PlaceholderDefaultValues = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModuleTemplateBuilder.mjs","names":["template","value","directory"],"sources":["../../../src/classes/templates/ModuleTemplateBuilder.ts"],"sourcesContent":["import path from 'node:path';\nimport { CLI } from '../cli/CLI.js';\nimport { ModuleType } from '../../helpers/constants.js';\nimport { BaseModule } from '../modules/BaseModule.js';\nimport { MessageCommandModule } from '../modules/commands/MessageCommandModule.js';\nimport { SlashCommandModule } from '../modules/commands/SlashCommandModule.js';\nimport { ContextMenuCommandModule } from '../modules/commands/ContextMenuCommandModule.js';\nimport { ClientEventModule } from '../modules/events/ClientEventModule.js';\nimport { EventModule } from '../modules/events/EventModule.js';\nimport { RESTEventModule } from '../modules/events/RESTEventModule.js';\nimport { PostconditionModule } from '../modules/PostconditionModule.js';\nimport { PreconditionModule } from '../modules/PreconditionModule.js';\nimport { mkdir, readdir, readFile, writeFile } from 'node:fs/promises';\nimport { ConfigReader } from '../cli/ConfigReader.js';\nimport { confirm, intro, isCancel, outro, select, text } from '@clack/prompts';\nimport { NotAnError } from '../NotAnError.js';\nimport { ApplicationCommandType } from 'discord.js';\nimport { ModuleLoader } from '../client/ModuleLoader.js';\nimport { existsSync } from 'node:fs';\nimport { readTSConfig } from 'pkg-types';\nimport { colors } from '@prtty/prtty';\n\nexport class ModuleTemplateBuilder {\n public _directory?: string;\n\n public readonly cli: CLI;\n public readonly config: ConfigReader;\n\n public template?: ModuleTemplateBuilder.Data;\n public typescript?: boolean;\n public filename?: string;\n public defaultAll: boolean;\n\n get content() {\n return this.template?.content ?? '';\n }\n\n get directory() {\n return this._directory ?? process.cwd();\n }\n\n get filepath() {\n return path.join(this.directory, this.filename ?? '');\n }\n\n constructor(options: ModuleTemplateBuilder.Options) {\n this.cli = options.cli;\n this.config = options.config;\n this.template = options?.template;\n this.typescript = options?.typescript;\n this._directory = options?.directory;\n this.filename = options?.filename;\n this.defaultAll = options?.defaultAll ?? false;\n }\n\n public async init(): Promise<this> {\n intro(colors.bold().black().bgCyan(` ${this.cli.command.name()} create module - v${this.cli.build} `));\n return this;\n }\n\n public async setupLanguage(options?: ModuleTemplateBuilder.SetupLanguageOptions): Promise<this> {\n this.typescript = options?.typescript ?? this.typescript;\n\n if (!this.typescript) {\n const isTypeScriptDefault = (await ConfigReader.getProjectLang(this.directory)) === 'ts';\n const isTypeScript = this.defaultAll\n ? isTypeScriptDefault\n : await confirm({\n message: 'Would you like to use TypeScript?',\n active: 'Yes',\n inactive: 'No',\n initialValue: isTypeScriptDefault\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 setupTemplate(options?: ModuleTemplateBuilder.SetupTemplateOptions): Promise<this> {\n let template = typeof options?.template === 'object' ? options.template : undefined;\n\n if (!template) {\n const templateName = typeof options?.template === 'string' ? options.template : undefined;\n const templates = await ModuleTemplateBuilder.resolveModuleTemplates(this.typescript ? 'ts' : 'js');\n\n const selectedTemplate = this.defaultAll\n ? templateName ? templates.find(template => template.name === templateName) : templates.at(0)\n : await select({\n message: 'Select a module template',\n options: templates.map(template => ({\n label: template.name,\n value: template\n }))\n });\n\n if (isCancel(selectedTemplate)) throw new NotAnError('Operation cancelled');\n template = selectedTemplate;\n }\n\n this.template = template;\n if (!this.template) throw new NotAnError('No template selected');\n\n return this;\n }\n\n public async setupPlaceholders(): Promise<this> {\n const placeholders = Object.keys(ModuleTemplateBuilder.Placeholder).filter(k => !k.startsWith('$')) as (keyof typeof ModuleTemplateBuilder.Placeholder)[];\n\n for (const placeholderKey of placeholders) {\n if (!ModuleTemplateBuilder.hasPlaceholder(ModuleTemplateBuilder.Placeholder[placeholderKey], this.content)) continue;\n const placeholder = ModuleTemplateBuilder.Placeholder[placeholderKey];\n const defaultValue = ModuleTemplateBuilder.PlaceholderDefaultValues[placeholder];\n\n let value: string|symbol;\n\n if (this.defaultAll) {\n value = defaultValue;\n } else {\n switch (placeholder) {\n case ModuleTemplateBuilder.Placeholder.ModuleName:\n case ModuleTemplateBuilder.Placeholder.CommandName:\n case ModuleTemplateBuilder.Placeholder.EventName:\n value = this.defaultAll\n ? defaultValue\n : await text({\n message: `What would you like to name the ${placeholderKey.replace('Name', '').toLowerCase()}?`,\n initialValue: defaultValue,\n placeholder: defaultValue,\n defaultValue,\n validate: (value) => {\n if (!value) return 'Please enter a value';\n if (value.includes(' ')) return 'Please enter a value without spaces';\n }\n });\n break;\n case ModuleTemplateBuilder.Placeholder.CommandContextMenuType:\n const type = await select({\n message: 'Select a command context menu type',\n options: [\n { label: 'Message', value: ApplicationCommandType.Message },\n { label: 'User', value: ApplicationCommandType.User }\n ],\n initialValue: ApplicationCommandType.Message\n });\n\n value = isCancel(type) ? type : `${type}`;\n break;\n case ModuleTemplateBuilder.Placeholder.EventOnce:\n const once = await confirm({\n message: `Would you like to use the event once?`,\n active: 'Yes',\n inactive: 'No',\n initialValue: false\n });\n\n value = isCancel(once) ? once : `${once}`;\n break;\n case ModuleTemplateBuilder.Placeholder.EventEmitter:\n default:\n value = await text({\n message: `What would you like to use for the ${ModuleTemplateBuilder.toTextCase(placeholder)}?`,\n initialValue: defaultValue,\n placeholder: defaultValue,\n defaultValue\n });\n break;\n }\n }\n\n if (isCancel(value)) throw new NotAnError('Operation cancelled');\n if (!this.template) throw new NotAnError('No template selected');\n this.template.content = ModuleTemplateBuilder.removeExpectedErrorComments(this.content.replaceAll(placeholder, value));\n }\n\n return this;\n }\n\n public async setupDirectory(options?: ModuleTemplateBuilder.SetupDirectoryOptions): Promise<this> {\n let directory = options?.directory;\n\n if (!directory) {\n const cwd = process.cwd();\n const tsconfig = this.config.build.tsconfig\n ? await readTSConfig(typeof this.config.build.tsconfig == 'string' ? this.config.build.tsconfig : cwd, { try: true })\n : undefined;\n\n let directories = await ModuleLoader.scanForDirectories(this.config.config.modules);\n directories = await ModuleLoader.resolveSourceDirectories({\n directories,\n baseUrl: tsconfig?.compilerOptions?.baseUrl ?? '.',\n rootDir: tsconfig?.compilerOptions?.rootDir ?? 'src',\n outDir: tsconfig?.compilerOptions?.outDir ?? 'modules',\n cwd\n });\n\n const selectedDirectory = this.defaultAll\n ? directories.at(0)\n : await select({\n message: 'Select a directory',\n options: directories.map(directory => ({\n label: path.relative(cwd, directory),\n value: directory\n }))\n });\n\n if (isCancel(selectedDirectory)) throw new NotAnError('Operation cancelled');\n directory = selectedDirectory;\n }\n\n if (!directory) throw new NotAnError('No directory selected');\n this._directory = directory;\n\n return this;\n }\n\n public async setupFilename(options?: ModuleTemplateBuilder.SetupFilenameOptions): Promise<this> {\n let filename = options?.filename;\n\n if (!filename) {\n const defaultFilename = `${this.template?.name}.${this.typescript ? 'ts' : 'js'}`;\n const selectedFilename = this.defaultAll\n ? defaultFilename\n : await text({\n message: 'What would you like to name the module file?',\n initialValue: defaultFilename,\n placeholder: defaultFilename,\n defaultValue: defaultFilename,\n validate: (value) => {\n if (!value) return 'Please enter a value';\n if (existsSync(path.join(this.directory, value))) return 'File already exists';\n }\n });\n\n if (isCancel(selectedFilename)) throw new NotAnError('Operation cancelled');\n filename = selectedFilename;\n }\n\n if (!filename) throw new NotAnError('No filename selected');\n this.filename = filename;\n\n return this;\n }\n\n public async build({ overwrite, silent }: ModuleTemplateBuilder.BuildOptions = {}): Promise<this> {\n await mkdir(this.directory, { recursive: true });\n await writeFile(this.filepath, this.content, { flag: overwrite === false ? 'wx' : undefined });\n if (!silent) outro(`Module ${colors.green(this.template?.name!)} created in ${colors.cyan(path.relative(process.cwd(), this.filepath))}`);\n return this;\n }\n}\n\nexport namespace ModuleTemplateBuilder {\n export interface Options {\n cli: CLI;\n config: ConfigReader;\n template?: ModuleTemplateBuilder.Data;\n typescript?: boolean;\n directory?: string;\n filename?: string;\n defaultAll?: boolean;\n }\n\n export interface SetupLanguageOptions {\n typescript?: boolean;\n }\n\n export interface SetupTemplateOptions {\n template?: ModuleTemplateBuilder.Data|string;\n }\n\n export interface SetupDirectoryOptions {\n directory?: string;\n }\n\n export interface SetupFilenameOptions {\n filename?: string;\n }\n\n export interface BuildOptions {\n overwrite?: boolean;\n silent?: boolean;\n }\n\n export enum Placeholder {\n ModuleName = '$MODULE_NAME$',\n CommandName = '$COMMAND_NAME$',\n CommandDescription = '$COMMAND_DESCRIPTION$',\n CommandContextMenuType = '$COMMAND_CONTEXT_MENU_TYPE$',\n EventEmitter = '$EVENT_EMITTER$',\n EventName = '$EVENT_NAME$',\n EventOnce = '$EVENT_ONCE$'\n }\n\n export const PlaceholderDefaultValues: Record<Placeholder, string> = {\n [Placeholder.ModuleName]: 'MyModule',\n [Placeholder.CommandName]: 'my-command',\n [Placeholder.CommandDescription]: 'My command',\n [Placeholder.CommandContextMenuType]: `${ApplicationCommandType.Message}`,\n [Placeholder.EventEmitter]: 'null',\n [Placeholder.EventName]: 'my-event',\n [Placeholder.EventOnce]: 'false'\n }\n\n export const SourceDirectory = {\n js: path.join(CLI.root, './assets/modules/javascript'),\n ts: path.join(CLI.root, './assets/modules/typescript')\n };\n\n export const ModuleTypeClassName: Record<ModuleType, string[]> = {\n [ModuleType.Base]: [BaseModule.name],\n [ModuleType.Command]: [MessageCommandModule.name, SlashCommandModule.name, ContextMenuCommandModule.name],\n [ModuleType.Event]: [ClientEventModule.name, EventModule.name, RESTEventModule.name],\n [ModuleType.Postcondition]: [PostconditionModule.name],\n [ModuleType.Precondition]: [PreconditionModule.name]\n };\n\n export interface Data {\n src: string;\n name: string;\n content: string;\n moduleType: ModuleType|null;\n }\n\n export async function resolveModuleTemplates(source: keyof typeof SourceDirectory): Promise<ModuleTemplateBuilder.Data[]> {\n const src = ModuleTemplateBuilder.SourceDirectory[source];\n const files: string[] = await readdir(src);\n const templates: ModuleTemplateBuilder.Data[] = [];\n\n for (const file of files) {\n const filepath = path.join(src, file);\n const content = await readFile(filepath, 'utf-8');\n const moduleType = ModuleTemplateBuilder.getModuleTemplateContentType(content);\n\n templates.push({ src: filepath, name: path.parse(filepath).name, content, moduleType });\n }\n\n return templates;\n }\n\n export function getModuleTemplateContentType(content: string): ModuleType|null {\n const createExtendStatement = (name: string) => `export class ${Placeholder.ModuleName} extends ${name}`;\n\n for (const type of Object.keys(ModuleTypeClassName).map(Number) as ModuleType[]) {\n const statements = ModuleTypeClassName[type].map(createExtendStatement);\n\n for (const statement of statements) {\n if (content.includes(statement)) return type;\n }\n }\n\n return null;\n }\n\n export function hasPlaceholder(placeholder: Placeholder, content: string): boolean {\n return content.includes(placeholder);\n }\n\n export function removeExpectedErrorComments(content: string): string {\n const lines = content.split('\\n');\n\n return lines\n .filter(line => !line.trim().includes('// @ts-expect-error'))\n .join('\\n');\n }\n\n export function toTextCase(string: string): string {\n return String(string)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')\n .replace(/([a-z])([A-Z])/g, (m, a, b) => a + '_' + b.toLowerCase())\n .replace(/[^A-Za-z0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/E,SAAO,QAAQ,SAAS,YAAY;;;CAGjC,SAAS,4BAA4B,SAAyB;AAGjE,SAFc,QAAQ,MAAM,KAAK,CAG5B,QAAO,SAAQ,CAAC,KAAK,MAAM,CAAC,SAAS,sBAAsB,CAAC,CAC5D,KAAK,KAAK;;;CAGZ,SAAS,WAAW,QAAwB;AAC/C,SAAO,OAAO,OAAO,CAChB,QAAQ,kCAAkC,GAAG,CAC7C,QAAQ,oBAAoB,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,aAAa,CAAC,CAClE,QAAQ,qBAAqB,IAAI,CACjC,aAAa"}
|
|
1
|
+
{"version":3,"file":"ModuleTemplateBuilder.mjs","names":[],"sources":["../../../src/classes/templates/ModuleTemplateBuilder.ts"],"sourcesContent":["import path from 'node:path';\nimport { CLI } from '../cli/CLI.js';\nimport { ModuleType } from '../../helpers/constants.js';\nimport { BaseModule } from '../modules/BaseModule.js';\nimport { MessageCommandModule } from '../modules/commands/MessageCommandModule.js';\nimport { SlashCommandModule } from '../modules/commands/SlashCommandModule.js';\nimport { ContextMenuCommandModule } from '../modules/commands/ContextMenuCommandModule.js';\nimport { ClientEventModule } from '../modules/events/ClientEventModule.js';\nimport { EventModule } from '../modules/events/EventModule.js';\nimport { RESTEventModule } from '../modules/events/RESTEventModule.js';\nimport { PostconditionModule } from '../modules/PostconditionModule.js';\nimport { PreconditionModule } from '../modules/PreconditionModule.js';\nimport { mkdir, readdir, readFile, writeFile } from 'node:fs/promises';\nimport { ConfigReader } from '../cli/ConfigReader.js';\nimport { confirm, intro, isCancel, outro, select, text } from '@clack/prompts';\nimport { NotAnError } from '../NotAnError.js';\nimport { ApplicationCommandType } from 'discord.js';\nimport { ModuleLoader } from '../client/ModuleLoader.js';\nimport { existsSync } from 'node:fs';\nimport { readTSConfig } from 'pkg-types';\nimport { colors } from '@prtty/prtty';\n\nexport class ModuleTemplateBuilder {\n public _directory?: string;\n\n public readonly cli: CLI;\n public readonly config: ConfigReader;\n\n public template?: ModuleTemplateBuilder.Data;\n public typescript?: boolean;\n public filename?: string;\n public defaultAll: boolean;\n\n get content() {\n return this.template?.content ?? '';\n }\n\n get directory() {\n return this._directory ?? process.cwd();\n }\n\n get filepath() {\n return path.join(this.directory, this.filename ?? '');\n }\n\n constructor(options: ModuleTemplateBuilder.Options) {\n this.cli = options.cli;\n this.config = options.config;\n this.template = options?.template;\n this.typescript = options?.typescript;\n this._directory = options?.directory;\n this.filename = options?.filename;\n this.defaultAll = options?.defaultAll ?? false;\n }\n\n public async init(): Promise<this> {\n intro(colors.bold().black().bgCyan(` ${this.cli.command.name()} create module - v${this.cli.build} `));\n return this;\n }\n\n public async setupLanguage(options?: ModuleTemplateBuilder.SetupLanguageOptions): Promise<this> {\n this.typescript = options?.typescript ?? this.typescript;\n\n if (!this.typescript) {\n const isTypeScriptDefault = (await ConfigReader.getProjectLang(this.directory)) === 'ts';\n const isTypeScript = this.defaultAll\n ? isTypeScriptDefault\n : await confirm({\n message: 'Would you like to use TypeScript?',\n active: 'Yes',\n inactive: 'No',\n initialValue: isTypeScriptDefault\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 setupTemplate(options?: ModuleTemplateBuilder.SetupTemplateOptions): Promise<this> {\n let template = typeof options?.template === 'object' ? options.template : undefined;\n\n if (!template) {\n const templateName = typeof options?.template === 'string' ? options.template : undefined;\n const templates = await ModuleTemplateBuilder.resolveModuleTemplates(this.typescript ? 'ts' : 'js');\n\n const selectedTemplate = this.defaultAll\n ? templateName ? templates.find(template => template.name === templateName) : templates.at(0)\n : await select({\n message: 'Select a module template',\n options: templates.map(template => ({\n label: template.name,\n value: template\n }))\n });\n\n if (isCancel(selectedTemplate)) throw new NotAnError('Operation cancelled');\n template = selectedTemplate;\n }\n\n this.template = template;\n if (!this.template) throw new NotAnError('No template selected');\n\n return this;\n }\n\n public async setupPlaceholders(): Promise<this> {\n const placeholders = Object.keys(ModuleTemplateBuilder.Placeholder).filter(k => !k.startsWith('$')) as (keyof typeof ModuleTemplateBuilder.Placeholder)[];\n\n for (const placeholderKey of placeholders) {\n if (!ModuleTemplateBuilder.hasPlaceholder(ModuleTemplateBuilder.Placeholder[placeholderKey], this.content)) continue;\n const placeholder = ModuleTemplateBuilder.Placeholder[placeholderKey];\n const defaultValue = ModuleTemplateBuilder.PlaceholderDefaultValues[placeholder];\n\n let value: string|symbol;\n\n if (this.defaultAll) {\n value = defaultValue;\n } else {\n switch (placeholder) {\n case ModuleTemplateBuilder.Placeholder.ModuleName:\n case ModuleTemplateBuilder.Placeholder.CommandName:\n case ModuleTemplateBuilder.Placeholder.EventName:\n value = this.defaultAll\n ? defaultValue\n : await text({\n message: `What would you like to name the ${placeholderKey.replace('Name', '').toLowerCase()}?`,\n initialValue: defaultValue,\n placeholder: defaultValue,\n defaultValue,\n validate: (value) => {\n if (!value) return 'Please enter a value';\n if (value.includes(' ')) return 'Please enter a value without spaces';\n }\n });\n break;\n case ModuleTemplateBuilder.Placeholder.CommandContextMenuType:\n const type = await select({\n message: 'Select a command context menu type',\n options: [\n { label: 'Message', value: ApplicationCommandType.Message },\n { label: 'User', value: ApplicationCommandType.User }\n ],\n initialValue: ApplicationCommandType.Message\n });\n\n value = isCancel(type) ? type : `${type}`;\n break;\n case ModuleTemplateBuilder.Placeholder.EventOnce:\n const once = await confirm({\n message: `Would you like to use the event once?`,\n active: 'Yes',\n inactive: 'No',\n initialValue: false\n });\n\n value = isCancel(once) ? once : `${once}`;\n break;\n case ModuleTemplateBuilder.Placeholder.EventEmitter:\n default:\n value = await text({\n message: `What would you like to use for the ${ModuleTemplateBuilder.toTextCase(placeholder)}?`,\n initialValue: defaultValue,\n placeholder: defaultValue,\n defaultValue\n });\n break;\n }\n }\n\n if (isCancel(value)) throw new NotAnError('Operation cancelled');\n if (!this.template) throw new NotAnError('No template selected');\n this.template.content = ModuleTemplateBuilder.removeExpectedErrorComments(this.content.replaceAll(placeholder, value));\n }\n\n return this;\n }\n\n public async setupDirectory(options?: ModuleTemplateBuilder.SetupDirectoryOptions): Promise<this> {\n let directory = options?.directory;\n\n if (!directory) {\n const cwd = process.cwd();\n const tsconfig = this.config.build.tsconfig\n ? await readTSConfig(typeof this.config.build.tsconfig == 'string' ? this.config.build.tsconfig : cwd, { try: true })\n : undefined;\n\n let directories = await ModuleLoader.scanForDirectories(this.config.config.modules);\n directories = await ModuleLoader.resolveSourceDirectories({\n directories,\n baseUrl: tsconfig?.compilerOptions?.baseUrl ?? '.',\n rootDir: tsconfig?.compilerOptions?.rootDir ?? 'src',\n outDir: tsconfig?.compilerOptions?.outDir ?? 'modules',\n cwd\n });\n\n const selectedDirectory = this.defaultAll\n ? directories.at(0)\n : await select({\n message: 'Select a directory',\n options: directories.map(directory => ({\n label: path.relative(cwd, directory),\n value: directory\n }))\n });\n\n if (isCancel(selectedDirectory)) throw new NotAnError('Operation cancelled');\n directory = selectedDirectory;\n }\n\n if (!directory) throw new NotAnError('No directory selected');\n this._directory = directory;\n\n return this;\n }\n\n public async setupFilename(options?: ModuleTemplateBuilder.SetupFilenameOptions): Promise<this> {\n let filename = options?.filename;\n\n if (!filename) {\n const defaultFilename = `${this.template?.name}.${this.typescript ? 'ts' : 'js'}`;\n const selectedFilename = this.defaultAll\n ? defaultFilename\n : await text({\n message: 'What would you like to name the module file?',\n initialValue: defaultFilename,\n placeholder: defaultFilename,\n defaultValue: defaultFilename,\n validate: (value) => {\n if (!value) return 'Please enter a value';\n if (existsSync(path.join(this.directory, value))) return 'File already exists';\n }\n });\n\n if (isCancel(selectedFilename)) throw new NotAnError('Operation cancelled');\n filename = selectedFilename;\n }\n\n if (!filename) throw new NotAnError('No filename selected');\n this.filename = filename;\n\n return this;\n }\n\n public async build({ overwrite, silent }: ModuleTemplateBuilder.BuildOptions = {}): Promise<this> {\n await mkdir(this.directory, { recursive: true });\n await writeFile(this.filepath, this.content, { flag: overwrite === false ? 'wx' : undefined });\n if (!silent) outro(`Module ${colors.green(this.template?.name!)} created in ${colors.cyan(path.relative(process.cwd(), this.filepath))}`);\n return this;\n }\n}\n\nexport namespace ModuleTemplateBuilder {\n export interface Options {\n cli: CLI;\n config: ConfigReader;\n template?: ModuleTemplateBuilder.Data;\n typescript?: boolean;\n directory?: string;\n filename?: string;\n defaultAll?: boolean;\n }\n\n export interface SetupLanguageOptions {\n typescript?: boolean;\n }\n\n export interface SetupTemplateOptions {\n template?: ModuleTemplateBuilder.Data|string;\n }\n\n export interface SetupDirectoryOptions {\n directory?: string;\n }\n\n export interface SetupFilenameOptions {\n filename?: string;\n }\n\n export interface BuildOptions {\n overwrite?: boolean;\n silent?: boolean;\n }\n\n export enum Placeholder {\n ModuleName = '$MODULE_NAME$',\n CommandName = '$COMMAND_NAME$',\n CommandDescription = '$COMMAND_DESCRIPTION$',\n CommandContextMenuType = '$COMMAND_CONTEXT_MENU_TYPE$',\n EventEmitter = '$EVENT_EMITTER$',\n EventName = '$EVENT_NAME$',\n EventOnce = '$EVENT_ONCE$'\n }\n\n export const PlaceholderDefaultValues: Record<Placeholder, string> = {\n [Placeholder.ModuleName]: 'MyModule',\n [Placeholder.CommandName]: 'my-command',\n [Placeholder.CommandDescription]: 'My command',\n [Placeholder.CommandContextMenuType]: `${ApplicationCommandType.Message}`,\n [Placeholder.EventEmitter]: 'null',\n [Placeholder.EventName]: 'my-event',\n [Placeholder.EventOnce]: 'false'\n }\n\n export const SourceDirectory = {\n js: path.join(CLI.root, './assets/modules/javascript'),\n ts: path.join(CLI.root, './assets/modules/typescript')\n };\n\n export const ModuleTypeClassName: Record<ModuleType, string[]> = {\n [ModuleType.Base]: [BaseModule.name],\n [ModuleType.Command]: [MessageCommandModule.name, SlashCommandModule.name, ContextMenuCommandModule.name],\n [ModuleType.Event]: [ClientEventModule.name, EventModule.name, RESTEventModule.name],\n [ModuleType.Postcondition]: [PostconditionModule.name],\n [ModuleType.Precondition]: [PreconditionModule.name]\n };\n\n export interface Data {\n src: string;\n name: string;\n content: string;\n moduleType: ModuleType|null;\n }\n\n export async function resolveModuleTemplates(source: keyof typeof SourceDirectory): Promise<ModuleTemplateBuilder.Data[]> {\n const src = ModuleTemplateBuilder.SourceDirectory[source];\n const files: string[] = await readdir(src);\n const templates: ModuleTemplateBuilder.Data[] = [];\n\n for (const file of files) {\n const filepath = path.join(src, file);\n const content = await readFile(filepath, 'utf-8');\n const moduleType = ModuleTemplateBuilder.getModuleTemplateContentType(content);\n\n templates.push({ src: filepath, name: path.parse(filepath).name, content, moduleType });\n }\n\n return templates;\n }\n\n export function getModuleTemplateContentType(content: string): ModuleType|null {\n const createExtendStatement = (name: string) => `export class ${Placeholder.ModuleName} extends ${name}`;\n\n for (const type of Object.keys(ModuleTypeClassName).map(Number) as ModuleType[]) {\n const statements = ModuleTypeClassName[type].map(createExtendStatement);\n\n for (const statement of statements) {\n if (content.includes(statement)) return type;\n }\n }\n\n return null;\n }\n\n export function hasPlaceholder(placeholder: Placeholder, content: string): boolean {\n return content.includes(placeholder);\n }\n\n export function removeExpectedErrorComments(content: string): string {\n const lines = content.split('\\n');\n\n return lines\n .filter(line => !line.trim().includes('// @ts-expect-error'))\n .join('\\n');\n }\n\n export function toTextCase(string: string): string {\n return String(string)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')\n .replace(/([a-z])([A-Z])/g, (m, a, b) => a + '_' + b.toLowerCase())\n .replace(/[^A-Za-z0-9]+|_+/g, ' ')\n .toLowerCase();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAa,wBAAb,MAAa,sBAAsB;CAC/B,AAAO;CAEP,AAAgB;CAChB,AAAgB;CAEhB,AAAO;CACP,AAAO;CACP,AAAO;CACP,AAAO;CAEP,IAAI,UAAU;AACV,SAAO,KAAK,UAAU,WAAW;;CAGrC,IAAI,YAAY;AACZ,SAAO,KAAK,cAAc,QAAQ,KAAK;;CAG3C,IAAI,WAAW;AACX,SAAO,KAAK,KAAK,KAAK,WAAW,KAAK,YAAY,GA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 -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";
|
|
@@ -57,8 +57,8 @@ var TemplateBuilder = class TemplateBuilder {
|
|
|
57
57
|
placeholder: `Leave empty to use current directory`,
|
|
58
58
|
defaultValue: process.cwd(),
|
|
59
59
|
validate: (value) => {
|
|
60
|
-
const dir
|
|
61
|
-
if (existsSync(dir
|
|
60
|
+
const dir = path.resolve(value);
|
|
61
|
+
if (existsSync(dir) && !statSync(dir).isDirectory()) return "Invalid folder directory";
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
if (isCancel(dir)) throw new NotAnError("Operation cancelled");
|
|
@@ -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:
|
|
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:
|
|
307
|
+
silent: !isDebugging()
|
|
308
308
|
}),
|
|
309
309
|
indicator: "timer",
|
|
310
310
|
errorMessage: `${colors.bold().red("✗")} Failed to build project`,
|
|
@@ -358,12 +358,12 @@ var TemplateBuilder = class TemplateBuilder {
|
|
|
358
358
|
if (fromStats.isDirectory()) {
|
|
359
359
|
const files = await readdir(from);
|
|
360
360
|
for (const file of files) {
|
|
361
|
-
const data
|
|
361
|
+
const data = {
|
|
362
362
|
basename: file,
|
|
363
363
|
src: path.join(from, file),
|
|
364
364
|
dest: to
|
|
365
365
|
};
|
|
366
|
-
await copy(data
|
|
366
|
+
await copy(data.src, path.join(to, options?.rename ? options.rename(data) : file), options);
|
|
367
367
|
}
|
|
368
368
|
return;
|
|
369
369
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateBuilder.mjs","names":["dir","parseDotenv","data"],"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,CA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AM,KAAK;KAC1B,MAAM;KACT;AAED,UAAM,KACFA,OAAK,KACL,KAAK,KAAK,IACN,SAAS,SACH,QAAQ,OAAOA,OAAK,GACpB,KACT,EACD,QACH;;AAEL;;EAGJ,MAAM,OAAqB;GACvB,UAAU,KAAK,SAAS,KAAK;GAC7B,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,CAA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,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,36 +1,36 @@
|
|
|
1
1
|
import { ModuleType } from "../../helpers/constants.mjs";
|
|
2
2
|
import { AnyModuleData } from "../../helpers/types.mjs";
|
|
3
3
|
import { Validator } from "@reciple/core";
|
|
4
|
-
import * as
|
|
4
|
+
import * as _sapphire_shapeshift8 from "@sapphire/shapeshift";
|
|
5
5
|
|
|
6
6
|
//#region src/classes/validation/BaseModuleValidator.d.ts
|
|
7
7
|
declare class BaseModuleValidator extends Validator {
|
|
8
|
-
static id:
|
|
9
|
-
static moduleType:
|
|
10
|
-
static onEnable:
|
|
11
|
-
static onReady:
|
|
12
|
-
static onDisable:
|
|
13
|
-
static object:
|
|
8
|
+
static id: _sapphire_shapeshift8.StringValidator<string>;
|
|
9
|
+
static moduleType: _sapphire_shapeshift8.NativeEnumValidator<typeof ModuleType>;
|
|
10
|
+
static onEnable: _sapphire_shapeshift8.UnionValidator<Function | undefined>;
|
|
11
|
+
static onReady: _sapphire_shapeshift8.UnionValidator<Function | undefined>;
|
|
12
|
+
static onDisable: _sapphire_shapeshift8.UnionValidator<Function | undefined>;
|
|
13
|
+
static object: _sapphire_shapeshift8.ObjectValidator<{
|
|
14
14
|
id: string | undefined;
|
|
15
15
|
moduleType: ModuleType | undefined;
|
|
16
16
|
onEnable: Function | undefined;
|
|
17
17
|
onReady: Function | undefined;
|
|
18
18
|
onDisable: Function | undefined;
|
|
19
|
-
},
|
|
19
|
+
}, _sapphire_shapeshift8.UndefinedToOptional<{
|
|
20
20
|
id: string | undefined;
|
|
21
21
|
moduleType: ModuleType | undefined;
|
|
22
22
|
onEnable: Function | undefined;
|
|
23
23
|
onReady: Function | undefined;
|
|
24
24
|
onDisable: Function | undefined;
|
|
25
25
|
}>>;
|
|
26
|
-
static resolvable:
|
|
27
|
-
toJSON: Function;
|
|
28
|
-
}> | _sapphire_shapeshift40.UndefinedToOptional<{
|
|
26
|
+
static resolvable: _sapphire_shapeshift8.UnionValidator<_sapphire_shapeshift8.UndefinedToOptional<{
|
|
29
27
|
id: string | undefined;
|
|
30
28
|
moduleType: ModuleType | undefined;
|
|
31
29
|
onEnable: Function | undefined;
|
|
32
30
|
onReady: Function | undefined;
|
|
33
31
|
onDisable: Function | undefined;
|
|
32
|
+
}> | _sapphire_shapeshift8.UndefinedToOptional<{
|
|
33
|
+
toJSON: Function;
|
|
34
34
|
}>>;
|
|
35
35
|
static isValidId(id: unknown): asserts id is string;
|
|
36
36
|
static isValidModuleType(moduleType: unknown): asserts moduleType is ModuleType;
|
|
@@ -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
|
|
6
|
+
import * as _sapphire_shapeshift25 from "@sapphire/shapeshift";
|
|
7
7
|
|
|
8
8
|
//#region src/classes/validation/CommandModuleValidator.d.ts
|
|
9
9
|
declare class CommandModuleValidator extends Validator {
|
|
10
|
-
static object:
|
|
10
|
+
static object: _sapphire_shapeshift25.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:
|
|
19
|
+
data: _sapphire_shapeshift25.UndefinedToOptional<{
|
|
20
20
|
name: any;
|
|
21
21
|
description: any;
|
|
22
22
|
aliases: any;
|
|
23
23
|
options: any;
|
|
24
24
|
flags: any;
|
|
25
|
-
}> |
|
|
25
|
+
}> | _sapphire_shapeshift25.UndefinedToOptional<{
|
|
26
26
|
type: any;
|
|
27
27
|
name: any;
|
|
28
28
|
}>;
|
|
29
29
|
cooldown: number | undefined;
|
|
30
|
-
preconditions:
|
|
30
|
+
preconditions: _sapphire_shapeshift25.UndefinedToOptional<{
|
|
31
31
|
id: any;
|
|
32
32
|
scope: any;
|
|
33
33
|
execute: any;
|
|
34
34
|
}>[] | undefined;
|
|
35
|
-
postconditions:
|
|
35
|
+
postconditions: _sapphire_shapeshift25.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
|
-
},
|
|
43
|
+
}, _sapphire_shapeshift25.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:
|
|
52
|
+
data: _sapphire_shapeshift25.UndefinedToOptional<{
|
|
53
53
|
name: any;
|
|
54
54
|
description: any;
|
|
55
55
|
aliases: any;
|
|
56
56
|
options: any;
|
|
57
57
|
flags: any;
|
|
58
|
-
}> |
|
|
58
|
+
}> | _sapphire_shapeshift25.UndefinedToOptional<{
|
|
59
59
|
type: any;
|
|
60
60
|
name: any;
|
|
61
61
|
}>;
|
|
62
62
|
cooldown: number | undefined;
|
|
63
|
-
preconditions:
|
|
63
|
+
preconditions: _sapphire_shapeshift25.UndefinedToOptional<{
|
|
64
64
|
id: any;
|
|
65
65
|
scope: any;
|
|
66
66
|
execute: any;
|
|
67
67
|
}>[] | undefined;
|
|
68
|
-
postconditions:
|
|
68
|
+
postconditions: _sapphire_shapeshift25.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:
|
|
77
|
+
static resolvable: _sapphire_shapeshift25.UnionValidator<_sapphire_shapeshift25.UndefinedToOptional<{
|
|
78
78
|
toJSON: Function;
|
|
79
|
-
}> |
|
|
79
|
+
}> | _sapphire_shapeshift25.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:
|
|
88
|
+
data: _sapphire_shapeshift25.UndefinedToOptional<{
|
|
89
89
|
name: any;
|
|
90
90
|
description: any;
|
|
91
91
|
aliases: any;
|
|
92
92
|
options: any;
|
|
93
93
|
flags: any;
|
|
94
|
-
}> |
|
|
94
|
+
}> | _sapphire_shapeshift25.UndefinedToOptional<{
|
|
95
95
|
type: any;
|
|
96
96
|
name: any;
|
|
97
97
|
}>;
|
|
98
98
|
cooldown: number | undefined;
|
|
99
|
-
preconditions:
|
|
99
|
+
preconditions: _sapphire_shapeshift25.UndefinedToOptional<{
|
|
100
100
|
id: any;
|
|
101
101
|
scope: any;
|
|
102
102
|
execute: any;
|
|
103
103
|
}>[] | undefined;
|
|
104
|
-
postconditions:
|
|
104
|
+
postconditions: _sapphire_shapeshift25.UndefinedToOptional<{
|
|
105
105
|
id: any;
|
|
106
106
|
scope: any;
|
|
107
107
|
execute: any;
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { ModuleType } from "../../helpers/constants.mjs";
|
|
2
2
|
import { EventModule } from "../modules/events/EventModule.mjs";
|
|
3
|
-
import "../../index.mjs";
|
|
4
3
|
import { Validator } from "@reciple/core";
|
|
5
4
|
import { EventEmitter } from "node:events";
|
|
6
|
-
import * as
|
|
5
|
+
import * as _sapphire_shapeshift0 from "@sapphire/shapeshift";
|
|
7
6
|
|
|
8
7
|
//#region src/classes/validation/EventModuleValidator.d.ts
|
|
9
8
|
declare class EventModuleValidator extends Validator {
|
|
10
|
-
static emitter:
|
|
9
|
+
static emitter: _sapphire_shapeshift0.InstanceValidator<EventEmitter<{
|
|
11
10
|
[x: string]: any[];
|
|
12
11
|
[x: number]: any[];
|
|
13
12
|
[x: symbol]: any[];
|
|
14
13
|
}>>;
|
|
15
|
-
static event:
|
|
16
|
-
static once:
|
|
17
|
-
static onEvent:
|
|
18
|
-
static object:
|
|
14
|
+
static event: _sapphire_shapeshift0.StringValidator<string>;
|
|
15
|
+
static once: _sapphire_shapeshift0.UnionValidator<boolean | undefined>;
|
|
16
|
+
static onEvent: _sapphire_shapeshift0.InstanceValidator<Function>;
|
|
17
|
+
static object: _sapphire_shapeshift0.ObjectValidator<{
|
|
19
18
|
id: string | undefined;
|
|
20
19
|
moduleType: ModuleType | undefined;
|
|
21
20
|
onEnable: Function | undefined;
|
|
@@ -30,7 +29,7 @@ declare class EventModuleValidator extends Validator {
|
|
|
30
29
|
event: string;
|
|
31
30
|
once: boolean | undefined;
|
|
32
31
|
onEvent: Function;
|
|
33
|
-
},
|
|
32
|
+
}, _sapphire_shapeshift0.UndefinedToOptional<{
|
|
34
33
|
id: string | undefined;
|
|
35
34
|
moduleType: ModuleType | undefined;
|
|
36
35
|
onEnable: Function | undefined;
|
|
@@ -46,9 +45,7 @@ declare class EventModuleValidator extends Validator {
|
|
|
46
45
|
once: boolean | undefined;
|
|
47
46
|
onEvent: Function;
|
|
48
47
|
}>>;
|
|
49
|
-
static resolvable:
|
|
50
|
-
toJSON: Function;
|
|
51
|
-
}> | _sapphire_shapeshift7.UndefinedToOptional<{
|
|
48
|
+
static resolvable: _sapphire_shapeshift0.UnionValidator<_sapphire_shapeshift0.UndefinedToOptional<{
|
|
52
49
|
id: string | undefined;
|
|
53
50
|
moduleType: ModuleType | undefined;
|
|
54
51
|
onEnable: Function | undefined;
|
|
@@ -63,6 +60,8 @@ declare class EventModuleValidator extends Validator {
|
|
|
63
60
|
event: string;
|
|
64
61
|
once: boolean | undefined;
|
|
65
62
|
onEvent: Function;
|
|
63
|
+
}> | _sapphire_shapeshift0.UndefinedToOptional<{
|
|
64
|
+
toJSON: Function;
|
|
66
65
|
}>>;
|
|
67
66
|
static isValidEmitter(emitter: unknown): asserts emitter is EventEmitter;
|
|
68
67
|
static isValidEvent(event: unknown): asserts event is string;
|