reciple 10.0.1-dev.4 → 10.0.1-dev.5
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/bin/commands/create.mjs +1 -1
- package/dist/bin/commands/create.mjs.map +1 -1
- package/dist/classes/cli/CLI.mjs +1 -1
- package/dist/classes/cli/ConfigReader.d.mts +1 -0
- package/dist/classes/cli/ConfigReader.mjs +8 -6
- package/dist/classes/cli/ConfigReader.mjs.map +1 -1
- package/dist/classes/templates/TemplateBuilder.d.mts +1 -1
- package/dist/classes/templates/TemplateBuilder.mjs +3 -3
- 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 +18 -18
- package/dist/classes/validation/EventModuleValidator.d.mts +9 -9
- package/dist/classes/validation/PostconditionModule.d.mts +9 -9
- package/dist/classes/validation/PreconditionModule.d.mts +7 -7
- package/dist/package.mjs +2 -2
- package/dist/package.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -34,7 +34,7 @@ var CreateSubcommand = class extends CLISubcommand {
|
|
|
34
34
|
await template.createTemplate();
|
|
35
35
|
await template.createEnvFile({ envFile: this.cli.flags.env[0] });
|
|
36
36
|
await template.build({
|
|
37
|
-
|
|
37
|
+
skipInstall: !flags?.install,
|
|
38
38
|
skipBuild: !flags?.build
|
|
39
39
|
});
|
|
40
40
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.mjs","names":[],"sources":["../../../src/bin/commands/create.ts"],"sourcesContent":["import { Command, Option } from 'commander';\nimport { CLISubcommand } from '../../classes/cli/CLISubcommand.js';\nimport { colors } from '@reciple/utils';\nimport { TemplateBuilder } from '../../classes/templates/TemplateBuilder.js';\nimport { cancel } from '@clack/prompts';\nimport { inspect } from 'node:util';\nimport { NotAnError } from '../../classes/NotAnError.js';\nimport type { PackageManagerName } from 'nypm';\n\nexport default class CreateSubcommand extends CLISubcommand {\n public subcommand: Command = new Command('create')\n .description('Create a new reciple project')\n .argument('[output]', 'The directory to create the project in')\n .option('-c, --config <path>', 'Path to the configuration file')\n .option('-t, --token <DiscordToken>', 'Set your Discord Bot token')\n .option('-T, --typescript', 'Use TypeScript')\n .addOption(new Option('-p, --package-manager <name>', 'The name of the package manager to use')\n .choices(['npm', 'yarn', 'pnpm', 'bun', 'deno'])\n )\n .option('-D, --default', 'Use defaults for prompts')\n .option('--install', 'Install dependencies during setup', true)\n .option('--build', 'Build the project after creation', true)\n .allowUnknownOption(true);\n\n public async execute(): Promise<void> {\n const flags = this.cli.getFlags<CreateSubcommand.Flags>('create');\n const template = new TemplateBuilder({\n cli: this.cli,\n directory: this.subcommand.args[0],\n typescript: flags?.typescript,\n packageManager: flags?.packageManager,\n defaultAll: flags?.default,\n token: flags?.token,\n });\n\n try {\n await template.init();\n await template.createDirectory();\n await template.setupLanguage();\n await template.createConfig();\n await template.setPackageManager();\n await template.createTemplate();\n await template.createEnvFile({ envFile: this.cli.flags.env[0] });\n await template.build({
|
|
1
|
+
{"version":3,"file":"create.mjs","names":[],"sources":["../../../src/bin/commands/create.ts"],"sourcesContent":["import { Command, Option } from 'commander';\nimport { CLISubcommand } from '../../classes/cli/CLISubcommand.js';\nimport { colors } from '@reciple/utils';\nimport { TemplateBuilder } from '../../classes/templates/TemplateBuilder.js';\nimport { cancel } from '@clack/prompts';\nimport { inspect } from 'node:util';\nimport { NotAnError } from '../../classes/NotAnError.js';\nimport type { PackageManagerName } from 'nypm';\n\nexport default class CreateSubcommand extends CLISubcommand {\n public subcommand: Command = new Command('create')\n .description('Create a new reciple project')\n .argument('[output]', 'The directory to create the project in')\n .option('-c, --config <path>', 'Path to the configuration file')\n .option('-t, --token <DiscordToken>', 'Set your Discord Bot token')\n .option('-T, --typescript', 'Use TypeScript')\n .addOption(new Option('-p, --package-manager <name>', 'The name of the package manager to use')\n .choices(['npm', 'yarn', 'pnpm', 'bun', 'deno'])\n )\n .option('-D, --default', 'Use defaults for prompts')\n .option('--install', 'Install dependencies during setup', true)\n .option('--build', 'Build the project after creation', true)\n .allowUnknownOption(true);\n\n public async execute(): Promise<void> {\n const flags = this.cli.getFlags<CreateSubcommand.Flags>('create');\n const template = new TemplateBuilder({\n cli: this.cli,\n directory: this.subcommand.args[0],\n typescript: flags?.typescript,\n packageManager: flags?.packageManager,\n defaultAll: flags?.default,\n token: flags?.token,\n });\n\n try {\n await template.init();\n await template.createDirectory();\n await template.setupLanguage();\n await template.createConfig();\n await template.setPackageManager();\n await template.createTemplate();\n await template.createEnvFile({ envFile: this.cli.flags.env[0] });\n await template.build({ skipInstall: !flags?.install, skipBuild: !flags?.build });\n } catch (error) {\n cancel(colors.red(error instanceof NotAnError ? error.message : inspect(error)));\n }\n }\n}\n\nexport namespace CreateSubcommand {\n export interface Flags {\n config?: string;\n token?: string;\n default?: boolean;\n typescript?: boolean;\n packageManager?: PackageManagerName;\n install: boolean;\n build: boolean;\n }\n}\n"],"mappings":";;;;;;;;;AASA,IAAqB,mBAArB,cAA8C,cAAc;CACxD,AAAO,aAAsB,IAAI,QAAQ,SAAS,CAC7C,YAAY,+BAA+B,CAC3C,SAAS,YAAY,yCAAyC,CAC9D,OAAO,uBAAuB,iCAAiC,CAC/D,OAAO,8BAA8B,6BAA6B,CAClE,OAAO,oBAAoB,iBAAiB,CAC5C,UAAU,IAAI,OAAO,gCAAgC,yCAAyC,CAC1F,QAAQ;EAAC;EAAO;EAAQ;EAAQ;EAAO;EAAO,CAAC,CACnD,CACA,OAAO,iBAAiB,2BAA2B,CACnD,OAAO,aAAa,qCAAqC,KAAK,CAC9D,OAAO,WAAW,oCAAoC,KAAK,CAC3D,mBAAmB,KAAK;CAE7B,MAAa,UAAyB;EAClC,MAAM,QAAQ,KAAK,IAAI,SAAiC,SAAS;EACjE,MAAM,WAAW,IAAI,gBAAgB;GACjC,KAAK,KAAK;GACV,WAAW,KAAK,WAAW,KAAK;GAChC,YAAY,OAAO;GACnB,gBAAgB,OAAO;GACvB,YAAY,OAAO;GACnB,OAAO,OAAO;GACjB,CAAC;AAEF,MAAI;AACA,SAAM,SAAS,MAAM;AACrB,SAAM,SAAS,iBAAiB;AAChC,SAAM,SAAS,eAAe;AAC9B,SAAM,SAAS,cAAc;AAC7B,SAAM,SAAS,mBAAmB;AAClC,SAAM,SAAS,gBAAgB;AAC/B,SAAM,SAAS,cAAc,EAAE,SAAS,KAAK,IAAI,MAAM,IAAI,IAAI,CAAC;AAChE,SAAM,SAAS,MAAM;IAAE,aAAa,CAAC,OAAO;IAAS,WAAW,CAAC,OAAO;IAAO,CAAC;WAC3E,OAAO;AACZ,UAAO,OAAO,IAAI,iBAAiB,aAAa,MAAM,UAAU,QAAQ,MAAM,CAAC,CAAC"}
|
package/dist/classes/cli/CLI.mjs
CHANGED
|
@@ -86,7 +86,7 @@ var CLI = class {
|
|
|
86
86
|
(function(_CLI) {
|
|
87
87
|
_CLI.root = path.join(path.dirname(fileURLToPath(import.meta.url)), "../../../");
|
|
88
88
|
_CLI.bin = path.join(CLI.root, "dist/bin/reciple.js");
|
|
89
|
-
_CLI.version = "10.0.1-dev.
|
|
89
|
+
_CLI.version = "10.0.1-dev.5";
|
|
90
90
|
function stringifyFlags(flags, command, ignored = []) {
|
|
91
91
|
let arr = [];
|
|
92
92
|
for (const [key, value] of Object.entries(flags)) {
|
|
@@ -39,6 +39,7 @@ declare class ConfigReader {
|
|
|
39
39
|
static hasFile(filepath: string): Promise<boolean>;
|
|
40
40
|
static findConfig(directory: string, type?: 'ts' | 'js'): Promise<string | null>;
|
|
41
41
|
static getDefaultContent(type?: 'ts' | 'js'): Promise<string>;
|
|
42
|
+
static getDefault(type?: 'ts' | 'js'): Promise<ConfigReader>;
|
|
42
43
|
}
|
|
43
44
|
declare namespace ConfigReader {
|
|
44
45
|
function getProjectLang(dir: string): Promise<'ts' | 'js'>;
|
|
@@ -52,15 +52,13 @@ var ConfigReader = class ConfigReader {
|
|
|
52
52
|
const type = options.type ?? ConfigReader.getLangTypeFromFilename(options.filepath) ?? "js";
|
|
53
53
|
if (await ConfigReader.hasFile(options.filepath) && !options.overwrite) {
|
|
54
54
|
if (options.throwOnConflict !== false) throw new RecipleError(`config file already exists at ${colors.green(options.filepath)}`);
|
|
55
|
-
const reader
|
|
56
|
-
await reader
|
|
57
|
-
return reader
|
|
55
|
+
const reader = new ConfigReader(options.filepath);
|
|
56
|
+
await reader.read(options.readOptions);
|
|
57
|
+
return reader;
|
|
58
58
|
}
|
|
59
59
|
await mkdir(path.dirname(options.filepath), { recursive: true });
|
|
60
60
|
await writeFile(options.filepath, await this.getDefaultContent(type));
|
|
61
|
-
|
|
62
|
-
await reader.read(options.readOptions);
|
|
63
|
-
return reader;
|
|
61
|
+
return new ConfigReader(options.filepath);
|
|
64
62
|
}
|
|
65
63
|
static async hasFile(filepath) {
|
|
66
64
|
return stat(filepath).then((s) => s.isFile()).catch(() => false);
|
|
@@ -74,6 +72,10 @@ var ConfigReader = class ConfigReader {
|
|
|
74
72
|
const filepath = ConfigReader.defaultConfigFilePaths[type];
|
|
75
73
|
return await readFile(filepath, "utf-8");
|
|
76
74
|
}
|
|
75
|
+
static async getDefault(type = "js") {
|
|
76
|
+
const filepath = ConfigReader.defaultConfigFilePaths[type];
|
|
77
|
+
return new ConfigReader(filepath).read();
|
|
78
|
+
}
|
|
77
79
|
};
|
|
78
80
|
(function(_ConfigReader) {
|
|
79
81
|
async function getProjectLang(dir) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigReader.mjs","names":["filepath: string"
|
|
1
|
+
{"version":3,"file":"ConfigReader.mjs","names":["filepath: string"],"sources":["../../../src/classes/cli/ConfigReader.ts"],"sourcesContent":["import { Client, RecipleError, type Config } from '@reciple/core';\nimport { colors } from '@reciple/utils';\nimport { CLI } from './CLI.js';\nimport path from 'node:path';\nimport { mkdir, readdir, readFile, stat, writeFile } from 'node:fs/promises';\nimport type { ModuleLoader } from '../client/ModuleLoader.js';\nimport type { Logger } from 'prtyprnt';\nimport type { ModuleManager } from '../managers/ModuleManager.js';\nimport type { BuildConfig } from '../../helpers/types.js';\nimport type { EventListeners } from '../client/EventListeners.js';\nimport type { UserConfig } from 'tsdown';\nimport { unrun, type Options } from 'unrun';\nimport { resolveTSConfig } from 'pkg-types';\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\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 constructor(public readonly filepath: string) {}\n\n public async read(options?: Omit<ConfigReader.ReadOptions, 'filepath'>): Promise<ConfigReader> {\n if (!await ConfigReader.hasFile(this.filepath) && options?.createIfNotExists !== false) return ConfigReader.create({\n filepath: this.filepath,\n readOptions: options\n });\n\n const { module } = await unrun<Config>({ ...options, path: this.filepath });\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\n return this;\n }\n\n public async create(options?: Omit<ConfigReader.CreateOptions, 'filepath'>): Promise<ConfigReader> {\n return ConfigReader.create({ ...options, filepath: this.filepath });\n }\n\n public async exists(): Promise<boolean> {\n return await ConfigReader.hasFile(this.filepath);\n }\n\n public static async create(options: ConfigReader.CreateOptions): Promise<ConfigReader> {\n const type = options.type ?? ConfigReader.getLangTypeFromFilename(options.filepath) ?? 'js';\n\n if (await ConfigReader.hasFile(options.filepath) && !options.overwrite) {\n if (options.throwOnConflict !== false) throw new RecipleError(`config file already exists at ${colors.green(options.filepath)}`);\n\n const reader = new ConfigReader(options.filepath);\n await reader.read(options.readOptions);\n return reader;\n }\n\n await mkdir(path.dirname(options.filepath), { recursive: true });\n await writeFile(options.filepath, await this.getDefaultContent(type));\n\n const reader = new ConfigReader(options.filepath);\n\n return reader;\n }\n\n public static async hasFile(filepath: string): Promise<boolean> {\n return stat(filepath)\n .then(s => s.isFile())\n .catch(() => false);\n }\n\n public static async findConfig(directory: string, type?: 'ts'|'js'): Promise<string|null> {\n const validFiles = ConfigReader.defaultConfigFilenames.filter(f => type ? ConfigReader.FileTypes[type].includes(f) : true);\n const files = (await readdir(directory)).find(f => validFiles.includes(f));\n return files ? path.join(directory, files) : null;\n }\n\n public static async getDefaultContent(type: 'ts'|'js' = 'js'): Promise<string> {\n const filepath = ConfigReader.defaultConfigFilePaths[type];\n const content = await readFile(filepath, 'utf-8');\n return content;\n }\n\n public static async getDefault(type: 'ts'|'js' = 'js'): Promise<ConfigReader> {\n const filepath = ConfigReader.defaultConfigFilePaths[type];\n return new ConfigReader(filepath).read();\n }\n}\n\nexport namespace ConfigReader {\n export async function getProjectLang(dir: string): Promise<'ts'|'js'> {\n const hasTsConfig = !!await resolveTSConfig(dir, { try: true });\n const configLangIsTypescript = (await ConfigReader.findConfig(dir).then(f => f ?? '')).endsWith('ts');\n\n return hasTsConfig || configLangIsTypescript ? 'ts' : 'js';\n }\n\n export interface Structure {\n client: Client;\n config: Config;\n }\n\n export interface ReadOptions extends Options {\n createIfNotExists?: boolean;\n createOptions?: Omit<CreateOptions, 'path'>;\n }\n\n export interface CreateOptions {\n filepath: string;\n overwrite?: boolean;\n throwOnConflict?: boolean;\n type?: 'ts' | 'js';\n readOptions?: Omit<ReadOptions, ''>;\n }\n\n export const FileTypes = {\n ts: ['ts', 'mts', 'tsx'],\n js: ['js', 'mjs', 'jsx']\n };\n\n export const defaultConfigFilePaths = {\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 const defaultConfigFilenames = [\n 'reciple.config.ts',\n 'reciple.config.mts',\n 'reciple.config.js',\n 'reciple.config.mjs'\n ];\n\n export function normalizeTsdownConfig({ type, overrides }: { type?: 'ts' | 'js', overrides?: BuildConfig; } = {}): UserConfig {\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 export function createConfigFilename(type: 'ts'|'js', esm: boolean = false): string {\n return `reciple.config.${type === 'ts' ? esm ? 'mts' : 'ts' : esm ? 'mjs' : 'js'}`;\n }\n\n export function getLangTypeFromFilename(filename: string): 'ts'|'js'|null {\n const extention = path.extname(filename).slice(1);\n\n if (FileTypes.ts.includes(extention)) return 'ts';\n if (FileTypes.js.includes(extention)) return 'js';\n return null;\n }\n}\n"],"mappings":";;;;;;;;;AA8BA,IAAa,eAAb,MAAa,aAAa;CACtB,AAAQ,UAAuB;CAC/B,AAAQ,UAAuB;CAC/B,AAAQ,SAA2B;CAEnC,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,YAAY,AAAgBA,UAAkB;EAAlB;;CAE5B,MAAa,KAAK,SAA6E;AAC3F,MAAI,CAAC,MAAM,aAAa,QAAQ,KAAK,SAAS,IAAI,SAAS,sBAAsB,MAAO,QAAO,aAAa,OAAO;GAC/G,UAAU,KAAK;G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AAO,MAAM,QAAQ,OAAO,MAAM,QAAQ;;;CAGzE,SAAS,wBAAwB,UAAkC;EACtE,MAAM,YAAY,KAAK,QAAQ,SAAS,CAAC,MAAM,EAAE;AAEjD,MAAI,UAAU,GAAG,SAAS,UAAU,CAAE,QAAO;AAC7C,MAAI,UAAU,GAAG,SAAS,UAAU,CAAE,QAAO;AAC7C,SAAO"}
|
|
@@ -126,7 +126,7 @@ var TemplateBuilder = class TemplateBuilder {
|
|
|
126
126
|
const moduleTemplates = await ModuleTemplateBuilder.resolveModuleTemplates(this.typescript ? "ts" : "js");
|
|
127
127
|
const moduleOptions = {
|
|
128
128
|
cli: this.cli,
|
|
129
|
-
config: this.
|
|
129
|
+
config: await ConfigReader.getDefault(this.typescript ? "ts" : "js"),
|
|
130
130
|
defaultAll: true,
|
|
131
131
|
typescript: this.typescript
|
|
132
132
|
};
|
|
@@ -258,7 +258,7 @@ var TemplateBuilder = class TemplateBuilder {
|
|
|
258
258
|
}
|
|
259
259
|
async build(options) {
|
|
260
260
|
await this.packageJson?.write(this.packageJsonPath, true);
|
|
261
|
-
if (
|
|
261
|
+
if (options?.skipInstall) await CLI.createSpinnerPromise({
|
|
262
262
|
promise: installDependencies({
|
|
263
263
|
cwd: this.directory,
|
|
264
264
|
packageManager: this.packageManager,
|
|
@@ -283,7 +283,7 @@ var TemplateBuilder = class TemplateBuilder {
|
|
|
283
283
|
outro(`Project created in ${colors.cyan(this.relativeDirectory)}`);
|
|
284
284
|
console.log(`\n${colors.bold(colors.green("✔"))} Start developing:`);
|
|
285
285
|
if (this.relativeDirectory !== "./") console.log(` • ${colors.cyan(colors.bold(`cd ${this.relativeDirectory}`))}`);
|
|
286
|
-
|
|
286
|
+
console.log(` • ${colors.cyan(colors.bold(installDependenciesCommand(this.packageManager ?? "npm")))} ${colors.dim("(Install dependencies)")}`);
|
|
287
287
|
console.log(` • ${colors.cyan(colors.bold(runScriptCommand(this.packageManager ?? "npm", "build")))} ${colors.dim("(Build)")}`);
|
|
288
288
|
console.log(` • ${colors.cyan(colors.bold(runScriptCommand(this.packageManager ?? "npm", "dev")))} ${colors.dim("(Development)")}`);
|
|
289
289
|
console.log(` • ${colors.cyan(colors.bold(runScriptCommand(this.packageManager ?? "npm", "start")))} ${colors.dim("(Production)")}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateBuilder.mjs","names":["dir","packageManager: PackageManagerName|symbol","parseDotenv","dependencies: Record<'ts'|'js'|'both', Partial<Record<'dependencies'|'devDependencies', Record<string, string>>>>","data: CopyMetadata","data"],"sources":["../../../src/classes/templates/TemplateBuilder.ts"],"sourcesContent":["import { colors, 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 } 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';\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\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(colors.black(colors.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 createConfig(options?: TemplateBuilder.CreateConfigOptions): Promise<this> {\n let filepath = options?.filepath;\n\n if (!filepath) {\n filepath = await ConfigReader.findConfig(\n this.directory,\n this.typescript\n ? 'ts'\n : this.typescript === false\n ? 'js'\n : undefined\n )\n ?? path.join(\n this.directory,\n ConfigReader.createConfigFilename(this.typescript ? 'ts' : 'js')\n );\n }\n\n const exists = await ConfigReader.hasFile(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 filepath,\n type: this.typescript ? 'ts' : 'js',\n overwrite: true\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 const modulesDirectory = path.join(this.directory, 'src');\n const moduleTemplates = await ModuleTemplateBuilder.resolveModuleTemplates(this.typescript ? 'ts' : 'js');\n const moduleOptions = {\n cli: this.cli,\n config: this.config!,\n defaultAll: true,\n typescript: this.typescript,\n };\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 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: '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);\n this.packageJson.merge({\n name: this.name,\n version: '0.0.1',\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 private: true\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 build(options?: TemplateBuilder.BuildOptions): Promise<this> {\n await this.packageJson?.write(this.packageJsonPath, true);\n\n if (!options?.skipInstallDependencies) 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(colors.red('✗'))} Failed to install dependencies`,\n successMessage: `${colors.bold(colors.green('✔'))} Dependencies installed successfully`,\n message: `${colors.bold(colors.dim('$'))} Installing dependencies`\n })[0];\n\n if (!options?.skipBuild) 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(colors.red('✗'))} Failed to build project`,\n successMessage: `${colors.bold(colors.green('✔'))} Project built successfully`,\n message: `${colors.bold(colors.dim('$'))} Building project`\n })[0];\n\n outro(`Project created in ${colors.cyan(this.relativeDirectory)}`);\n\n console.log(`\\n${colors.bold(colors.green('✔'))} Start developing:`);\n\n if (this.relativeDirectory !== './') {\n console.log(` • ${colors.cyan(colors.bold(`cd ${this.relativeDirectory}`))}`);\n }\n\n if (options?.skipInstallDependencies) {\n console.log(` • ${colors.cyan(colors.bold(installDependenciesCommand(this.packageManager ?? 'npm')))}`);\n }\n\n console.log(` • ${colors.cyan(colors.bold(runScriptCommand(this.packageManager ?? 'npm', 'build')))} ${colors.dim('(Build)')}`);\n console.log(` • ${colors.cyan(colors.bold(runScriptCommand(this.packageManager ?? 'npm', 'dev')))} ${colors.dim('(Development)')}`);\n console.log(` • ${colors.cyan(colors.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 }\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 CreateEnvFileOptions {\n envFile?: string;\n tokenKey?: string;\n env?: Record<string, string>;\n }\n\n export interface BuildOptions {\n skipInstallDependencies?: boolean;\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":";;;;;;;;;;;;;;;;AAeA,IAAa,kBAAb,MAAa,gBAAgB;CACzB,AAAQ;CAER,AAAO;CACP,AAAO;CACP,AAAO;CACP,AAAO;CAEP,AAAO;CACP,AAAO;CAEP,AAAO;CAEP,IAAI,YAAY;AACZ,SAAO,KAAK,cAAc,QAAQ,KAAK;;CAG3C,IAAI,oBAAoB;AACpB,SAAO,KAAK,SAAS,QAAQ,KAAK,EAAE,KAA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W,MAAM,CAAC;AAClD,QAAM,SAAS,MAAM,GAAG"}
|
|
1
|
+
{"version":3,"file":"TemplateBuilder.mjs","names":["dir","moduleOptions: ModuleTemplateBuilder.Options","packageManager: PackageManagerName|symbol","parseDotenv","dependencies: Record<'ts'|'js'|'both', Partial<Record<'dependencies'|'devDependencies', Record<string, string>>>>","data: CopyMetadata","data"],"sources":["../../../src/classes/templates/TemplateBuilder.ts"],"sourcesContent":["import { colors, 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 } 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';\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\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(colors.black(colors.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 createConfig(options?: TemplateBuilder.CreateConfigOptions): Promise<this> {\n let filepath = options?.filepath;\n\n if (!filepath) {\n filepath = await ConfigReader.findConfig(\n this.directory,\n this.typescript\n ? 'ts'\n : this.typescript === false\n ? 'js'\n : undefined\n )\n ?? path.join(\n this.directory,\n ConfigReader.createConfigFilename(this.typescript ? 'ts' : 'js')\n );\n }\n\n const exists = await ConfigReader.hasFile(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 filepath,\n type: this.typescript ? 'ts' : 'js',\n overwrite: true\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 const modulesDirectory = path.join(this.directory, 'src');\n const moduleTemplates = await ModuleTemplateBuilder.resolveModuleTemplates(this.typescript ? 'ts' : 'js');\n const moduleOptions: ModuleTemplateBuilder.Options = {\n cli: this.cli,\n config: await ConfigReader.getDefault(this.typescript ? 'ts' : 'js'),\n defaultAll: true,\n typescript: this.typescript,\n };\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 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: '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);\n this.packageJson.merge({\n name: this.name,\n version: '0.0.1',\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 private: true\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 build(options?: TemplateBuilder.BuildOptions): Promise<this> {\n await this.packageJson?.write(this.packageJsonPath, true);\n\n if (options?.skipInstall) 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(colors.red('✗'))} Failed to install dependencies`,\n successMessage: `${colors.bold(colors.green('✔'))} Dependencies installed successfully`,\n message: `${colors.bold(colors.dim('$'))} Installing dependencies`\n })[0];\n\n if (!options?.skipBuild) 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(colors.red('✗'))} Failed to build project`,\n successMessage: `${colors.bold(colors.green('✔'))} Project built successfully`,\n message: `${colors.bold(colors.dim('$'))} Building project`\n })[0];\n\n outro(`Project created in ${colors.cyan(this.relativeDirectory)}`);\n\n console.log(`\\n${colors.bold(colors.green('✔'))} Start developing:`);\n\n if (this.relativeDirectory !== './') {\n console.log(` • ${colors.cyan(colors.bold(`cd ${this.relativeDirectory}`))}`);\n }\n\n console.log(` • ${colors.cyan(colors.bold(installDependenciesCommand(this.packageManager ?? 'npm')))} ${colors.dim('(Install dependencies)')}`);\n console.log(` • ${colors.cyan(colors.bold(runScriptCommand(this.packageManager ?? 'npm', 'build')))} ${colors.dim('(Build)')}`);\n console.log(` • ${colors.cyan(colors.bold(runScriptCommand(this.packageManager ?? 'npm', 'dev')))} ${colors.dim('(Development)')}`);\n console.log(` • ${colors.cyan(colors.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 }\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 CreateEnvFileOptions {\n envFile?: string;\n tokenKey?: string;\n env?: Record<string, string>;\n }\n\n export interface BuildOptions {\n skipInstall?: boolean;\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":";;;;;;;;;;;;;;;;AAeA,IAAa,kBAAb,MAAa,gBAAgB;CACzB,AAAQ;CAER,AAAO;CACP,AAAO;CACP,AAAO;CACP,AAAO;CAEP,AAAO;CACP,AAAO;CAEP,AAAO;CAEP,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,IA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
|
|
@@ -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_shapeshift25 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_shapeshift25.StringValidator<string>;
|
|
9
|
+
static moduleType: _sapphire_shapeshift25.NativeEnumValidator<typeof ModuleType>;
|
|
10
|
+
static onEnable: _sapphire_shapeshift25.UnionValidator<Function | undefined>;
|
|
11
|
+
static onReady: _sapphire_shapeshift25.UnionValidator<Function | undefined>;
|
|
12
|
+
static onDisable: _sapphire_shapeshift25.UnionValidator<Function | undefined>;
|
|
13
|
+
static object: _sapphire_shapeshift25.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_shapeshift25.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_shapeshift14.UndefinedToOptional<{
|
|
26
|
+
static resolvable: _sapphire_shapeshift25.UnionValidator<_sapphire_shapeshift25.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_shapeshift25.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_shapeshift0 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_shapeshift0.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_shapeshift0.UndefinedToOptional<{
|
|
20
20
|
name: any;
|
|
21
21
|
description: any;
|
|
22
22
|
aliases: any;
|
|
23
23
|
options: any;
|
|
24
24
|
flags: any;
|
|
25
|
-
}> |
|
|
25
|
+
}> | _sapphire_shapeshift0.UndefinedToOptional<{
|
|
26
26
|
type: any;
|
|
27
27
|
name: any;
|
|
28
28
|
}>;
|
|
29
29
|
cooldown: number | undefined;
|
|
30
|
-
preconditions:
|
|
30
|
+
preconditions: _sapphire_shapeshift0.UndefinedToOptional<{
|
|
31
31
|
id: any;
|
|
32
32
|
scope: any;
|
|
33
33
|
execute: any;
|
|
34
34
|
}>[] | undefined;
|
|
35
|
-
postconditions:
|
|
35
|
+
postconditions: _sapphire_shapeshift0.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_shapeshift0.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_shapeshift0.UndefinedToOptional<{
|
|
53
53
|
name: any;
|
|
54
54
|
description: any;
|
|
55
55
|
aliases: any;
|
|
56
56
|
options: any;
|
|
57
57
|
flags: any;
|
|
58
|
-
}> |
|
|
58
|
+
}> | _sapphire_shapeshift0.UndefinedToOptional<{
|
|
59
59
|
type: any;
|
|
60
60
|
name: any;
|
|
61
61
|
}>;
|
|
62
62
|
cooldown: number | undefined;
|
|
63
|
-
preconditions:
|
|
63
|
+
preconditions: _sapphire_shapeshift0.UndefinedToOptional<{
|
|
64
64
|
id: any;
|
|
65
65
|
scope: any;
|
|
66
66
|
execute: any;
|
|
67
67
|
}>[] | undefined;
|
|
68
|
-
postconditions:
|
|
68
|
+
postconditions: _sapphire_shapeshift0.UndefinedToOptional<{
|
|
69
69
|
id: any;
|
|
70
70
|
scope: any;
|
|
71
71
|
execute: any;
|
|
@@ -74,9 +74,7 @@ declare class CommandModuleValidator extends Validator {
|
|
|
74
74
|
disabledPostconditions: string[] | undefined;
|
|
75
75
|
execute: Function;
|
|
76
76
|
}>>;
|
|
77
|
-
static resolvable:
|
|
78
|
-
toJSON: Function;
|
|
79
|
-
}> | _sapphire_shapeshift33.UndefinedToOptional<{
|
|
77
|
+
static resolvable: _sapphire_shapeshift0.UnionValidator<_sapphire_shapeshift0.UndefinedToOptional<{
|
|
80
78
|
id: string | undefined;
|
|
81
79
|
moduleType: ModuleType | undefined;
|
|
82
80
|
onEnable: Function | undefined;
|
|
@@ -85,23 +83,23 @@ declare class CommandModuleValidator extends Validator {
|
|
|
85
83
|
} & {
|
|
86
84
|
id: string;
|
|
87
85
|
type: _reciple_core0.CommandType;
|
|
88
|
-
data:
|
|
86
|
+
data: _sapphire_shapeshift0.UndefinedToOptional<{
|
|
89
87
|
name: any;
|
|
90
88
|
description: any;
|
|
91
89
|
aliases: any;
|
|
92
90
|
options: any;
|
|
93
91
|
flags: any;
|
|
94
|
-
}> |
|
|
92
|
+
}> | _sapphire_shapeshift0.UndefinedToOptional<{
|
|
95
93
|
type: any;
|
|
96
94
|
name: any;
|
|
97
95
|
}>;
|
|
98
96
|
cooldown: number | undefined;
|
|
99
|
-
preconditions:
|
|
97
|
+
preconditions: _sapphire_shapeshift0.UndefinedToOptional<{
|
|
100
98
|
id: any;
|
|
101
99
|
scope: any;
|
|
102
100
|
execute: any;
|
|
103
101
|
}>[] | undefined;
|
|
104
|
-
postconditions:
|
|
102
|
+
postconditions: _sapphire_shapeshift0.UndefinedToOptional<{
|
|
105
103
|
id: any;
|
|
106
104
|
scope: any;
|
|
107
105
|
execute: any;
|
|
@@ -109,6 +107,8 @@ declare class CommandModuleValidator extends Validator {
|
|
|
109
107
|
disabledPreconditions: string[] | undefined;
|
|
110
108
|
disabledPostconditions: string[] | undefined;
|
|
111
109
|
execute: Function;
|
|
110
|
+
}> | _sapphire_shapeshift0.UndefinedToOptional<{
|
|
111
|
+
toJSON: Function;
|
|
112
112
|
}>>;
|
|
113
113
|
static isValid(value: unknown): asserts value is AnyCommandModuleData;
|
|
114
114
|
}
|
|
@@ -3,15 +3,15 @@ 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
|
|
6
|
+
import * as _sapphire_shapeshift16 from "@sapphire/shapeshift";
|
|
7
7
|
|
|
8
8
|
//#region src/classes/validation/EventModuleValidator.d.ts
|
|
9
9
|
declare class EventModuleValidator extends Validator {
|
|
10
|
-
static emitter:
|
|
11
|
-
static event:
|
|
12
|
-
static once:
|
|
13
|
-
static onEvent:
|
|
14
|
-
static object:
|
|
10
|
+
static emitter: _sapphire_shapeshift16.InstanceValidator<EventEmitter<[never] | Record<string | number | symbol, any[]>>>;
|
|
11
|
+
static event: _sapphire_shapeshift16.StringValidator<string>;
|
|
12
|
+
static once: _sapphire_shapeshift16.UnionValidator<boolean | undefined>;
|
|
13
|
+
static onEvent: _sapphire_shapeshift16.InstanceValidator<Function>;
|
|
14
|
+
static object: _sapphire_shapeshift16.ObjectValidator<{
|
|
15
15
|
id: string | undefined;
|
|
16
16
|
moduleType: ModuleType | undefined;
|
|
17
17
|
onEnable: Function | undefined;
|
|
@@ -22,7 +22,7 @@ declare class EventModuleValidator extends Validator {
|
|
|
22
22
|
event: string;
|
|
23
23
|
once: boolean | undefined;
|
|
24
24
|
onEvent: Function;
|
|
25
|
-
},
|
|
25
|
+
}, _sapphire_shapeshift16.UndefinedToOptional<{
|
|
26
26
|
id: string | undefined;
|
|
27
27
|
moduleType: ModuleType | undefined;
|
|
28
28
|
onEnable: Function | undefined;
|
|
@@ -34,9 +34,9 @@ declare class EventModuleValidator extends Validator {
|
|
|
34
34
|
once: boolean | undefined;
|
|
35
35
|
onEvent: Function;
|
|
36
36
|
}>>;
|
|
37
|
-
static resolvable:
|
|
37
|
+
static resolvable: _sapphire_shapeshift16.UnionValidator<_sapphire_shapeshift16.UndefinedToOptional<{
|
|
38
38
|
toJSON: Function;
|
|
39
|
-
}> |
|
|
39
|
+
}> | _sapphire_shapeshift16.UndefinedToOptional<{
|
|
40
40
|
id: string | undefined;
|
|
41
41
|
moduleType: ModuleType | undefined;
|
|
42
42
|
onEnable: Function | undefined;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { PostconditionModule } from "../modules/PostconditionModule.mjs";
|
|
2
2
|
import { CommandPostconditionReason, CommandType, Validator } from "@reciple/core";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _sapphire_shapeshift35 from "@sapphire/shapeshift";
|
|
4
4
|
|
|
5
5
|
//#region src/classes/validation/PostconditionModule.d.ts
|
|
6
6
|
declare class PostconditionModuleValidator extends Validator {
|
|
7
|
-
static scope:
|
|
8
|
-
static accepts:
|
|
9
|
-
static execute:
|
|
10
|
-
static object:
|
|
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<{
|
|
11
11
|
scope: CommandType[] | undefined;
|
|
12
12
|
execute: Function;
|
|
13
|
-
},
|
|
13
|
+
}, _sapphire_shapeshift35.UndefinedToOptional<{
|
|
14
14
|
scope: CommandType[] | undefined;
|
|
15
15
|
execute: Function;
|
|
16
16
|
}>>;
|
|
17
|
-
static resolvable:
|
|
17
|
+
static resolvable: _sapphire_shapeshift35.UnionValidator<_sapphire_shapeshift35.UndefinedToOptional<{
|
|
18
|
+
toJSON: Function;
|
|
19
|
+
}> | _sapphire_shapeshift35.UndefinedToOptional<{
|
|
18
20
|
scope: CommandType[] | undefined;
|
|
19
21
|
execute: Function;
|
|
20
|
-
}> | _sapphire_shapeshift0.UndefinedToOptional<{
|
|
21
|
-
toJSON: Function;
|
|
22
22
|
}>>;
|
|
23
23
|
static isValidScope(scope: unknown): asserts scope is CommandType[];
|
|
24
24
|
static isValidAccepts(accepts: unknown): asserts accepts is CommandPostconditionReason[];
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { PreconditionModule } from "../modules/PreconditionModule.mjs";
|
|
2
2
|
import { CommandType, Validator } from "@reciple/core";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _sapphire_shapeshift43 from "@sapphire/shapeshift";
|
|
4
4
|
|
|
5
5
|
//#region src/classes/validation/PreconditionModule.d.ts
|
|
6
6
|
declare class PreconditionModuleValidator extends Validator {
|
|
7
|
-
static scope:
|
|
8
|
-
static execute:
|
|
9
|
-
static object:
|
|
7
|
+
static scope: _sapphire_shapeshift43.UnionValidator<CommandType[] | undefined>;
|
|
8
|
+
static execute: _sapphire_shapeshift43.InstanceValidator<Function>;
|
|
9
|
+
static object: _sapphire_shapeshift43.ObjectValidator<{
|
|
10
10
|
scope: CommandType[] | undefined;
|
|
11
11
|
execute: Function;
|
|
12
|
-
},
|
|
12
|
+
}, _sapphire_shapeshift43.UndefinedToOptional<{
|
|
13
13
|
scope: CommandType[] | undefined;
|
|
14
14
|
execute: Function;
|
|
15
15
|
}>>;
|
|
16
|
-
static resolvable:
|
|
16
|
+
static resolvable: _sapphire_shapeshift43.UnionValidator<_sapphire_shapeshift43.UndefinedToOptional<{
|
|
17
17
|
toJSON: Function;
|
|
18
|
-
}> |
|
|
18
|
+
}> | _sapphire_shapeshift43.UndefinedToOptional<{
|
|
19
19
|
scope: CommandType[] | undefined;
|
|
20
20
|
execute: Function;
|
|
21
21
|
}>>;
|
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.1-dev.
|
|
4
|
+
version: "10.0.1-dev.5",
|
|
5
5
|
license: "LGPL-3.0-only",
|
|
6
6
|
description: "The CLI for reciple",
|
|
7
7
|
module: "./dist/index.mjs",
|
|
@@ -68,7 +68,7 @@ var package_default = {
|
|
|
68
68
|
"discord.js": { "optional": false }
|
|
69
69
|
},
|
|
70
70
|
publishConfig: { "access": "public" },
|
|
71
|
-
gitHead: "
|
|
71
|
+
gitHead: "73fbf446422a0f7c828322836c9a781d9ba63dce"
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
//#endregion
|
package/dist/package.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.mjs","names":[],"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"reciple\",\n \"version\": \"10.0.1-dev.
|
|
1
|
+
{"version":3,"file":"package.mjs","names":[],"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"reciple\",\n \"version\": \"10.0.1-dev.5\",\n \"license\": \"LGPL-3.0-only\",\n \"description\": \"The CLI for reciple\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.mts\",\n \"bin\": \"./dist/bin/reciple.mjs\",\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.mts\"\n },\n \"./jsx-runtime\": {\n \"import\": \"./dist/helpers/jsx-runtime.mjs\",\n \"types\": \"./dist/helpers/jsx-runtime.d.mts\"\n }\n },\n \"files\": [\n \"dist\",\n \"assets\",\n \"README.md\"\n ],\n \"scripts\": {\n \"clean\": \"rimraf ./dist\",\n \"build\": \"tsdown --config-loader unrun\",\n \"check\": \"tsc --noEmit\",\n \"prepack\": \"npm run build\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/thenorthsolution/reciple\",\n \"directory\": \"packages/reciple\"\n },\n \"dependencies\": {\n \"@clack/prompts\": \"^0.11.0\",\n \"@dotenvx/dotenvx\": \"^1.51.1\",\n \"@reciple/utils\": \"^10.0.1-dev.1\",\n \"@sapphire/shapeshift\": \"^4.0.0\",\n \"@sapphire/snowflake\": \"^3.5.5\",\n \"commander\": \"^14.0.2\",\n \"github-slugger\": \"^2.0.0\",\n \"globby\": \"^16.0.0\",\n \"micromatch\": \"^4.0.8\",\n \"pkg-types\": \"^2.3.0\",\n \"prtyprnt\": \"^2.0.2\",\n \"semver\": \"^7.7.3\",\n \"ts-mixer\": \"^6.0.4\",\n \"tsdown\": \"^0.17.0-beta.4\",\n \"unrun\": \"^0.2.15\"\n },\n \"devDependencies\": {\n \"@reciple/jsx\": \"^10.0.1-dev.0\",\n \"@types/micromatch\": \"^4.0.10\",\n \"@types/node\": \"^24.10.1\",\n \"@types/semver\": \"^7.7.1\",\n \"nodemon\": \"^3.1.11\",\n \"rolldown\": \"^1.0.0-beta.52\"\n },\n \"peerDependencies\": {\n \"@reciple/core\": \"^10.0.0 || >=10.0.1-dev.0\",\n \"discord.js\": \"^14.25.1\"\n },\n \"peerDependenciesMeta\": {\n \"@reciple/core\": {\n \"optional\": false\n },\n \"discord.js\": {\n \"optional\": false\n }\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"gitHead\": \"73fbf446422a0f7c828322836c9a781d9ba63dce\"\n}\n"],"mappings":";sBAAA;OACU;UACG;UACA;cACI;SACL;QACD;MACF;OACC;UACG;EACT,KAAK;GACH,UAAU;GACV,SAAS;GACV;EACD,iBAAiB;GACf,UAAU;GACV,SAAS;GACV;EACF;QACQ;EACP;EACA;EACA;EACD;UACU;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,WAAW;EACZ;aACa;EACZ,QAAQ;EACR,OAAO;EACP,aAAa;EACd;eACe;EACd,kBAAkB;EAClB,oBAAoB;EACpB,kBAAkB;EAClB,wBAAwB;EACxB,uBAAuB;EACvB,aAAa;EACb,kBAAkB;EAClB,UAAU;EACV,cAAc;EACd,aAAa;EACb,YAAY;EACZ,UAAU;EACV,YAAY;EACZ,UAAU;EACV,SAAS;EACV;kBACkB;EACjB,gBAAgB;EAChB,qBAAqB;EACrB,eAAe;EACf,iBAAiB;EACjB,WAAW;EACX,YAAY;EACb;mBACmB;EAClB,iBAAiB;EACjB,cAAc;EACf;uBACuB;EACtB,iBAAiB,EACf,YAAY,OACb;EACD,cAAc,EACZ,YAAY,OACb;EACF;gBACgB,EACf,UAAU,UACX;UACU;CACZ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reciple",
|
|
3
|
-
"version": "10.0.1-dev.
|
|
3
|
+
"version": "10.0.1-dev.5",
|
|
4
4
|
"license": "LGPL-3.0-only",
|
|
5
5
|
"description": "The CLI for reciple",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"publishConfig": {
|
|
74
74
|
"access": "public"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "73fbf446422a0f7c828322836c9a781d9ba63dce"
|
|
77
77
|
}
|