create-reciple 9.0.3 → 9.1.1
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.js +25 -97
- package/dist/bin.js.map +1 -1
- package/dist/classes/Addon.d.ts +44 -0
- package/dist/classes/Addon.js +86 -0
- package/dist/classes/Addon.js.map +1 -0
- package/dist/classes/Setup.d.ts +25 -0
- package/dist/classes/Setup.js +130 -0
- package/dist/classes/Setup.js.map +1 -0
- package/dist/classes/TemplateBuilder.d.ts +24 -0
- package/dist/classes/TemplateBuilder.js +107 -0
- package/dist/classes/TemplateBuilder.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/constants.d.ts +2 -32
- package/dist/utils/constants.js +15 -3
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/helpers.d.ts +0 -7
- package/dist/utils/helpers.js +1 -52
- package/dist/utils/helpers.js.map +1 -1
- package/package.json +10 -7
- package/dist/utils/addons.d.ts +0 -14
- package/dist/utils/addons.js +0 -34
- package/dist/utils/addons.js.map +0 -1
package/dist/bin.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { confirm, intro, isCancel, multiselect, outro, password, select, text } from '@clack/prompts';
|
|
3
2
|
import { packageJson, packageManagers, templatesFolder } from './utils/constants.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import availableAddons from './utils/addons.js';
|
|
7
|
-
import { existsSync, statSync } from 'node:fs';
|
|
3
|
+
import { getTemplates } from './utils/helpers.js';
|
|
4
|
+
import { Setup } from './classes/Setup.js';
|
|
8
5
|
import { kleur } from 'fallout-utility';
|
|
6
|
+
import { outro } from '@clack/prompts';
|
|
9
7
|
import { Command } from 'commander';
|
|
10
|
-
import
|
|
8
|
+
import { TemplateBuilder } from './classes/TemplateBuilder.js';
|
|
11
9
|
const command = new Command()
|
|
12
10
|
.name(packageJson.name)
|
|
13
11
|
.description(packageJson.description)
|
|
@@ -22,98 +20,28 @@ const command = new Command()
|
|
|
22
20
|
command.parse(process.argv);
|
|
23
21
|
const options = command.opts();
|
|
24
22
|
const templates = await getTemplates(templatesFolder);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
const setup = new Setup({
|
|
24
|
+
dir: command.args[0] || undefined,
|
|
25
|
+
isTypescript: (options.typescript !== 'null' ? options.typescript : '') || undefined,
|
|
26
|
+
packageManager: (options.packageManager !== 'null' ? options.packageManager : '') || undefined,
|
|
27
|
+
token: options.token || undefined,
|
|
28
|
+
addons: Array.isArray(options.addons) && options.addons.length ? options.addons : undefined
|
|
29
|
+
});
|
|
30
|
+
await setup.prompt(options.force || false);
|
|
31
|
+
const template = templates.find(p => p.language === (setup.isTypescript ? 'Typescript' : 'Javascript'));
|
|
32
|
+
if (!template) {
|
|
33
|
+
setup.cancelPrompts(`Template not found`);
|
|
34
|
+
process.exit(1);
|
|
34
35
|
}
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
placeholder: `Leave empty to use current directory`,
|
|
39
|
-
defaultValue: process.cwd(),
|
|
40
|
-
validate: value => {
|
|
41
|
-
const dir = path.resolve(value);
|
|
42
|
-
if (!existsSync(dir))
|
|
43
|
-
return;
|
|
44
|
-
if (!statSync(dir).isDirectory())
|
|
45
|
-
return 'Invalid folder directory';
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
if (isCancel(newDir))
|
|
49
|
-
cancelPrompts();
|
|
50
|
-
dir = newDir;
|
|
36
|
+
if (setup.packageManager && !packageManagers.some(p => p.value === setup.packageManager)) {
|
|
37
|
+
setup.cancelPrompts(`Invalid package manager`);
|
|
38
|
+
process.exit(1);
|
|
51
39
|
}
|
|
52
|
-
|
|
53
|
-
if (!options.force && !(await isDirEmpty(dir))) {
|
|
54
|
-
const override = await confirm({
|
|
55
|
-
message: `Directory is not empty! Would you like to override its existing files?`,
|
|
56
|
-
initialValue: false,
|
|
57
|
-
active: `Yes`,
|
|
58
|
-
inactive: `No`
|
|
59
|
-
});
|
|
60
|
-
if (isCancel(override) || override === false)
|
|
61
|
-
cancelPrompts();
|
|
62
|
-
}
|
|
63
|
-
if (typescript === null) {
|
|
64
|
-
const isTypescript = await confirm({
|
|
65
|
-
message: `Would you like to use typescript?`,
|
|
66
|
-
initialValue: false,
|
|
67
|
-
active: `Yes`,
|
|
68
|
-
inactive: `No`
|
|
69
|
-
});
|
|
70
|
-
if (isCancel(isTypescript))
|
|
71
|
-
cancelPrompts();
|
|
72
|
-
typescript = isTypescript;
|
|
73
|
-
}
|
|
74
|
-
if (addons && !addons.length) {
|
|
75
|
-
const selectedAddons = await multiselect({
|
|
76
|
-
message: `Select a addons from Reciple ${kleur.gray('(Press space to select, and enter to submit)')}`,
|
|
77
|
-
options: Object.keys(availableAddons).map(a => ({
|
|
78
|
-
label: a,
|
|
79
|
-
value: a
|
|
80
|
-
})),
|
|
81
|
-
required: false
|
|
82
|
-
});
|
|
83
|
-
if (isCancel(selectedAddons))
|
|
84
|
-
cancelPrompts();
|
|
85
|
-
addons = selectedAddons;
|
|
86
|
-
}
|
|
87
|
-
if (packageManager === null) {
|
|
88
|
-
const resolvedPackageManager = resolvePackageManager();
|
|
89
|
-
let firstPackageManagerIndex = packageManagers.findIndex(p => resolvedPackageManager && resolvedPackageManager === p.value);
|
|
90
|
-
firstPackageManagerIndex = firstPackageManagerIndex === -1 ? packageManagers.length - 1 : firstPackageManagerIndex;
|
|
91
|
-
const newPackageManager = await select({
|
|
92
|
-
message: 'Select your preferred package manager',
|
|
93
|
-
options: [
|
|
94
|
-
packageManagers[firstPackageManagerIndex],
|
|
95
|
-
...packageManagers.filter((p, i) => i !== firstPackageManagerIndex)
|
|
96
|
-
]
|
|
97
|
-
});
|
|
98
|
-
if (isCancel(newPackageManager))
|
|
99
|
-
cancelPrompts();
|
|
100
|
-
packageManager = newPackageManager !== 'none' ? newPackageManager : null;
|
|
101
|
-
}
|
|
102
|
-
if (token === null) {
|
|
103
|
-
const newToken = await password({
|
|
104
|
-
message: `Enter your Discord bot token from Developers Portal`,
|
|
105
|
-
mask: '*'
|
|
106
|
-
});
|
|
107
|
-
if (isCancel(newToken))
|
|
108
|
-
cancelPrompts();
|
|
109
|
-
token = newToken;
|
|
110
|
-
}
|
|
111
|
-
const template = templates.find(p => p.language === (typescript ? 'Typescript' : 'Javascript'));
|
|
112
|
-
if (!template)
|
|
113
|
-
cancelPrompts({ reason: `Template not found` });
|
|
114
|
-
if (packageManager && !packageManagers.some(p => p.value === packageManager))
|
|
115
|
-
cancelPrompts({ reason: `Invalid package manager` });
|
|
116
|
-
if (setup)
|
|
40
|
+
if (setup.isDone)
|
|
117
41
|
outro(`Setup Done! Creating from ${kleur.cyan().bold(template.name)} template`);
|
|
118
|
-
|
|
42
|
+
const templateBuilder = new TemplateBuilder({
|
|
43
|
+
setup: setup.toJSON(),
|
|
44
|
+
template
|
|
45
|
+
});
|
|
46
|
+
await templateBuilder.build();
|
|
119
47
|
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAA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|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { AbbreviatedVersion } from 'package-json';
|
|
3
|
+
import { PackageJson } from 'fallout-utility';
|
|
4
|
+
export interface AddonOptions {
|
|
5
|
+
module: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
/**
|
|
8
|
+
* @default 'https://registry.npmjs.org'
|
|
9
|
+
*/
|
|
10
|
+
registry?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface AddonReadTarballData {
|
|
13
|
+
packageJson: PackageJson;
|
|
14
|
+
initialModuleContent: {
|
|
15
|
+
js?: string;
|
|
16
|
+
ts?: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare class Addon implements AddonOptions {
|
|
20
|
+
static readonly NPM_REGISTRY = "https://registry.npmjs.org";
|
|
21
|
+
static readonly YARN_REGISTRY = "https://registry.yarnpkg.com";
|
|
22
|
+
static readonly PNPM_REGISTRY = "https://registry.npmjs.org";
|
|
23
|
+
static readonly BUN_REGISTRY = "https://registry.npmjs.org";
|
|
24
|
+
static readonly DEFAULT_ADDON_VERSIONS: {
|
|
25
|
+
'reciple-interaction-events': string;
|
|
26
|
+
'reciple-anticrash': string;
|
|
27
|
+
'reciple-dev-commands': string;
|
|
28
|
+
'reciple-registry-cache': string;
|
|
29
|
+
};
|
|
30
|
+
module: string;
|
|
31
|
+
version?: string;
|
|
32
|
+
registry?: string;
|
|
33
|
+
metadata?: AbbreviatedVersion;
|
|
34
|
+
tarball?: Buffer;
|
|
35
|
+
tarballData?: AddonReadTarballData;
|
|
36
|
+
get tarballURL(): string | null;
|
|
37
|
+
get tarballShasum(): string | null;
|
|
38
|
+
get tmpDir(): string | null;
|
|
39
|
+
constructor(options: AddonOptions);
|
|
40
|
+
fetch(): Promise<AbbreviatedVersion>;
|
|
41
|
+
readTarball(): Promise<AddonReadTarballData>;
|
|
42
|
+
protected downloadTarball(): Promise<Buffer | undefined>;
|
|
43
|
+
protected verifyTarball(buffer: Buffer): Promise<boolean>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import fetchPackage from 'package-json';
|
|
2
|
+
import { tgz } from 'compressing';
|
|
3
|
+
import { createHash } from 'crypto';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { readFile } from 'fs/promises';
|
|
7
|
+
import { existsAsync } from '@reciple/utils';
|
|
8
|
+
export class Addon {
|
|
9
|
+
static NPM_REGISTRY = 'https://registry.npmjs.org';
|
|
10
|
+
static YARN_REGISTRY = 'https://registry.yarnpkg.com';
|
|
11
|
+
static PNPM_REGISTRY = Addon.NPM_REGISTRY;
|
|
12
|
+
static BUN_REGISTRY = Addon.NPM_REGISTRY;
|
|
13
|
+
static DEFAULT_ADDON_VERSIONS = {
|
|
14
|
+
'reciple-interaction-events': '^3',
|
|
15
|
+
'reciple-anticrash': '^3',
|
|
16
|
+
'reciple-dev-commands': '^3',
|
|
17
|
+
'reciple-registry-cache': '^3',
|
|
18
|
+
};
|
|
19
|
+
module;
|
|
20
|
+
version;
|
|
21
|
+
registry;
|
|
22
|
+
metadata;
|
|
23
|
+
tarball;
|
|
24
|
+
tarballData;
|
|
25
|
+
get tarballURL() { return this.metadata?.dist.tarball ?? null; }
|
|
26
|
+
get tarballShasum() { return this.metadata?.dist.shasum ?? null; }
|
|
27
|
+
get tmpDir() { return this.tarballShasum && path.join(path.dirname(fileURLToPath(import.meta.url)), '../../tmp', this.tarballShasum); }
|
|
28
|
+
constructor(options) {
|
|
29
|
+
this.module = options?.module;
|
|
30
|
+
this.registry = options?.registry ?? Addon.NPM_REGISTRY;
|
|
31
|
+
}
|
|
32
|
+
async fetch() {
|
|
33
|
+
this.metadata ??= await fetchPackage(this.module, { version: this.version, registry: this.registry });
|
|
34
|
+
await this.downloadTarball();
|
|
35
|
+
this.version = this.metadata.version;
|
|
36
|
+
return this.metadata;
|
|
37
|
+
}
|
|
38
|
+
async readTarball() {
|
|
39
|
+
if (!this.tarball || !this.tmpDir)
|
|
40
|
+
throw new Error('Tarball not downloaded');
|
|
41
|
+
if (this.tarballData)
|
|
42
|
+
return this.tarballData;
|
|
43
|
+
if (!(await existsAsync(this.tmpDir)))
|
|
44
|
+
await tgz.uncompress(this.tarball, this.tmpDir);
|
|
45
|
+
const packageJson = JSON.parse(await readFile(path.join(this.tmpDir, 'package/package.json'), 'utf-8'));
|
|
46
|
+
let initialModuleContent = {};
|
|
47
|
+
if (('initialModuleContent' in packageJson)) {
|
|
48
|
+
if (typeof packageJson.initialModuleContent === 'string') {
|
|
49
|
+
const content = await readFile(path.join(this.tmpDir, 'package/', packageJson.initialModuleContent), 'utf-8');
|
|
50
|
+
initialModuleContent.js = content;
|
|
51
|
+
initialModuleContent.ts = content;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
if ('js' in packageJson.initialModuleContent)
|
|
55
|
+
initialModuleContent.js = await readFile(path.join(this.tmpDir, 'package/', packageJson.initialModuleContent.js), 'utf-8');
|
|
56
|
+
if ('ts' in packageJson.initialModuleContent)
|
|
57
|
+
initialModuleContent.ts = await readFile(path.join(this.tmpDir, 'package/', packageJson.initialModuleContent.ts), 'utf-8');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return this.tarballData = {
|
|
61
|
+
packageJson,
|
|
62
|
+
initialModuleContent
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
async downloadTarball() {
|
|
66
|
+
if (!this.tarballURL)
|
|
67
|
+
return;
|
|
68
|
+
if (this.tarball)
|
|
69
|
+
return this.tarball;
|
|
70
|
+
const response = await fetch(this.tarballURL);
|
|
71
|
+
if (!response.ok)
|
|
72
|
+
return;
|
|
73
|
+
const data = await response.arrayBuffer();
|
|
74
|
+
const buffer = Buffer.from(data);
|
|
75
|
+
if (!await this.verifyTarball(buffer))
|
|
76
|
+
throw new Error('Tarball shasum does not match');
|
|
77
|
+
return this.tarball = buffer;
|
|
78
|
+
}
|
|
79
|
+
async verifyTarball(buffer) {
|
|
80
|
+
const i = createHash('sha1');
|
|
81
|
+
i.update(buffer);
|
|
82
|
+
const shasum = i.digest('hex');
|
|
83
|
+
return shasum === this.tarballShasum;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=Addon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Addon.js","sourceRoot":"","sources":["../../src/classes/Addon.ts"],"names":[],"mappings":"AAAA,OAAO,YAAoC,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAmB7C,MAAM,OAAO,KAAK;IACd,MAAM,CAAU,YAAY,GAAG,4BAA4B,CAAC;IAC5D,MAAM,CAAU,aAAa,GAAG,8BAA8B,CAAC;IAC/D,MAAM,CAAU,aAAa,GAAG,KAAK,CAAC,YAAY,CAAC;IACnD,MAAM,CAAU,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;IAClD,MAAM,CAAU,sBAAsB,GAAG;QACrC,4BAA4B,EAAE,IAAI;QAClC,mBAAmB,EAAE,IAAI;QACzB,sBAAsB,EAAE,IAAI;QAC5B,wBAAwB,EAAE,IAAI;KACjC,CAAC;IAEK,MAAM,CAAS;IACf,OAAO,CAAU;IACjB,QAAQ,CAAU;IAClB,QAAQ,CAAsB;IAC9B,OAAO,CAAU;IACjB,WAAW,CAAwB;IAE1C,IAAI,UAAU,KAAK,OAAO,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC;IAChE,IAAI,aAAa,KAAK,OAAO,IAAI,CA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C,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC9C,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,OAAO;QAEzB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC;QAC1C,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEjC,IAAI,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAExF,OAAO,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACjC,CAAC;IAES,KAAK,CAAC,aAAa,CAAC,MAAc;QACxC,MAAM,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;QAC7B,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAEjB,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAE/B,OAAO,MAAM,KAAK,IAAI,CAAC,aAAa,CAAC;IACzC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PackageManager } from '@reciple/utils';
|
|
2
|
+
export interface SetupOptions {
|
|
3
|
+
dir?: string;
|
|
4
|
+
isTypescript?: boolean;
|
|
5
|
+
packageManager?: PackageManager | null;
|
|
6
|
+
addons?: string[];
|
|
7
|
+
token?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class Setup implements SetupOptions {
|
|
10
|
+
dir?: string;
|
|
11
|
+
isTypescript?: boolean;
|
|
12
|
+
packageManager?: PackageManager | null;
|
|
13
|
+
addons?: string[];
|
|
14
|
+
token?: string;
|
|
15
|
+
get isDone(): boolean;
|
|
16
|
+
constructor(options?: SetupOptions);
|
|
17
|
+
prompt(force?: boolean): Promise<this>;
|
|
18
|
+
promptDir(dir?: string): Promise<string>;
|
|
19
|
+
promptIsTypescript(isTypescript?: boolean): Promise<boolean>;
|
|
20
|
+
promptAddons(addons?: string[]): Promise<string[]>;
|
|
21
|
+
promptPackageManager(packageManager?: PackageManager | null): Promise<PackageManager | null>;
|
|
22
|
+
promptToken(token?: string): Promise<string>;
|
|
23
|
+
cancelPrompts(reason?: string): Promise<never>;
|
|
24
|
+
toJSON(): SetupOptions;
|
|
25
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { cancel, confirm, intro, isCancel, multiselect, password, select, text } from '@clack/prompts';
|
|
2
|
+
import { resolvePackageManager } from '@reciple/utils';
|
|
3
|
+
import { kleur } from 'fallout-utility/strings';
|
|
4
|
+
import { existsSync, statSync } from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { Addon } from './Addon.js';
|
|
7
|
+
import { packageJson, packageManagers } from '../utils/constants.js';
|
|
8
|
+
import { isDirEmpty } from '../utils/helpers.js';
|
|
9
|
+
export class Setup {
|
|
10
|
+
dir;
|
|
11
|
+
isTypescript;
|
|
12
|
+
packageManager;
|
|
13
|
+
addons;
|
|
14
|
+
token;
|
|
15
|
+
get isDone() {
|
|
16
|
+
return !!(this.dir && this.isTypescript && this.packageManager !== undefined && this.addons && this.token);
|
|
17
|
+
}
|
|
18
|
+
constructor(options) {
|
|
19
|
+
this.dir = options?.dir ? path.resolve(options?.dir) : undefined;
|
|
20
|
+
this.isTypescript = options?.isTypescript;
|
|
21
|
+
this.packageManager = options?.packageManager;
|
|
22
|
+
this.addons = options?.addons;
|
|
23
|
+
this.token = options?.token;
|
|
24
|
+
}
|
|
25
|
+
async prompt(force = false) {
|
|
26
|
+
if (this.isDone)
|
|
27
|
+
return this;
|
|
28
|
+
intro(kleur.cyan().bold(`${packageJson.name} v${packageJson.version}`));
|
|
29
|
+
await this.promptDir(this.dir);
|
|
30
|
+
this.dir ||= process.cwd();
|
|
31
|
+
if (!force && !(await isDirEmpty(this.dir))) {
|
|
32
|
+
const override = await confirm({
|
|
33
|
+
message: `Directory is not empty! Would you like to continue?`,
|
|
34
|
+
initialValue: false,
|
|
35
|
+
active: `Yes`,
|
|
36
|
+
inactive: `No`
|
|
37
|
+
});
|
|
38
|
+
if (isCancel(override) || override === false) {
|
|
39
|
+
await this.cancelPrompts();
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
await this.promptIsTypescript(this.isTypescript);
|
|
44
|
+
await this.promptPackageManager(this.packageManager);
|
|
45
|
+
await this.promptAddons(this.addons);
|
|
46
|
+
await this.promptToken(this.token);
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
async promptDir(dir) {
|
|
50
|
+
if (dir)
|
|
51
|
+
return this.dir = dir;
|
|
52
|
+
const newDir = await text({
|
|
53
|
+
message: `Enter project directory`,
|
|
54
|
+
placeholder: `Leave empty to use current directory`,
|
|
55
|
+
defaultValue: process.cwd(),
|
|
56
|
+
validate: value => {
|
|
57
|
+
const dir = path.resolve(value);
|
|
58
|
+
if (!existsSync(dir))
|
|
59
|
+
return;
|
|
60
|
+
if (!statSync(dir).isDirectory())
|
|
61
|
+
return 'Invalid folder directory';
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return isCancel(newDir) ? this.cancelPrompts() : this.dir = path.resolve(newDir);
|
|
65
|
+
}
|
|
66
|
+
async promptIsTypescript(isTypescript) {
|
|
67
|
+
if (typeof isTypescript === 'boolean')
|
|
68
|
+
return this.isTypescript = isTypescript;
|
|
69
|
+
const newIsTypescript = await confirm({
|
|
70
|
+
message: `Would you like to use typescript?`,
|
|
71
|
+
initialValue: false,
|
|
72
|
+
active: `Yes`,
|
|
73
|
+
inactive: `No`
|
|
74
|
+
});
|
|
75
|
+
return isCancel(newIsTypescript) ? this.cancelPrompts() : this.isTypescript = newIsTypescript;
|
|
76
|
+
}
|
|
77
|
+
async promptAddons(addons) {
|
|
78
|
+
if (addons)
|
|
79
|
+
return this.addons = addons;
|
|
80
|
+
const newAddons = await multiselect({
|
|
81
|
+
message: `Select a addons from Reciple ${kleur.gray('(Press space to select, and enter to submit)')}`,
|
|
82
|
+
options: Object.keys(Addon.DEFAULT_ADDON_VERSIONS).map(a => ({
|
|
83
|
+
label: a,
|
|
84
|
+
value: a
|
|
85
|
+
})),
|
|
86
|
+
required: false
|
|
87
|
+
});
|
|
88
|
+
return isCancel(newAddons) ? this.cancelPrompts() : this.addons = newAddons;
|
|
89
|
+
}
|
|
90
|
+
async promptPackageManager(packageManager) {
|
|
91
|
+
if (packageManager !== undefined)
|
|
92
|
+
return this.packageManager = packageManager;
|
|
93
|
+
const resolvedPackageManager = resolvePackageManager();
|
|
94
|
+
let firstPackageManagerIndex = packageManagers.findIndex(p => resolvedPackageManager && resolvedPackageManager === p.value);
|
|
95
|
+
firstPackageManagerIndex = firstPackageManagerIndex === -1 ? packageManagers.length - 1 : firstPackageManagerIndex;
|
|
96
|
+
const newPackageManager = await select({
|
|
97
|
+
message: 'Select your preferred package manager',
|
|
98
|
+
options: [
|
|
99
|
+
packageManagers[firstPackageManagerIndex],
|
|
100
|
+
...packageManagers.filter((p, i) => i !== firstPackageManagerIndex)
|
|
101
|
+
]
|
|
102
|
+
});
|
|
103
|
+
if (isCancel(newPackageManager))
|
|
104
|
+
return this.cancelPrompts();
|
|
105
|
+
return this.packageManager = newPackageManager !== 'none' ? newPackageManager : null;
|
|
106
|
+
}
|
|
107
|
+
async promptToken(token) {
|
|
108
|
+
if (typeof token === 'string')
|
|
109
|
+
return this.token = token;
|
|
110
|
+
const newToken = await password({
|
|
111
|
+
message: `Enter your Discord bot token from Developers Portal`,
|
|
112
|
+
mask: '*'
|
|
113
|
+
});
|
|
114
|
+
return isCancel(newToken) ? this.cancelPrompts() : this.token = newToken;
|
|
115
|
+
}
|
|
116
|
+
async cancelPrompts(reason) {
|
|
117
|
+
cancel(reason ?? 'Operation cancelled');
|
|
118
|
+
process.exit(0);
|
|
119
|
+
}
|
|
120
|
+
toJSON() {
|
|
121
|
+
return {
|
|
122
|
+
dir: this.dir,
|
|
123
|
+
isTypescript: this.isTypescript,
|
|
124
|
+
packageManager: this.packageManager,
|
|
125
|
+
token: this.token,
|
|
126
|
+
addons: this.addons
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=Setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Setup.js","sourceRoot":"","sources":["../../src/classes/Setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACvG,OAAO,EAAkB,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAUjD,MAAM,OAAO,KAAK;IACP,GAAG,CAAU;IACb,YAAY,CAAW;IACvB,cAAc,CAAuB;IACrC,MAAM,CAAY;IAClB,KAAK,CAAU;IAEtB,IAAI,MAAM;QACN,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/G,CAAC;IAED,YAAY,OAAsB;QAC9B,IAAI,CAAC,GAAG,GAAG,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC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AC,KAAK,wBAAwB,CAAC;aACtE;SACJ,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,iBAAiB,CAAC;YAAE,OAAO,IAAI,CAAC,aAAa,EAAE,CAAC;QAE7D,OAAO,IAAI,CAAC,cAAc,GAAG,iBAAiB,KAAK,MAAM,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC;IACzF,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,KAAc;QACnC,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEzD,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC;YAC5B,OAAO,EAAE,qDAAqD;YAC9D,IAAI,EAAE,GAAG;SACZ,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;IAC7E,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,MAAe;QACtC,MAAM,CAAC,MAAM,IAAI,qBAAqB,CAAC,CAAC;QACxC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAEM,MAAM;QACT,OAAO;YACH,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;SACtB,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TemplateMetadata } from '../utils/types.js';
|
|
2
|
+
import { SetupOptions } from './Setup.js';
|
|
3
|
+
import { RecipleConfig } from 'reciple';
|
|
4
|
+
export interface TemplateBuilderOptions {
|
|
5
|
+
setup: SetupOptions;
|
|
6
|
+
template: TemplateMetadata;
|
|
7
|
+
}
|
|
8
|
+
export declare class TemplateBuilder implements TemplateBuilderOptions {
|
|
9
|
+
setup: SetupOptions;
|
|
10
|
+
template: TemplateMetadata;
|
|
11
|
+
config?: RecipleConfig;
|
|
12
|
+
get dir(): string;
|
|
13
|
+
get packageJsonPath(): string;
|
|
14
|
+
get packageManagerPlaceholders(): Record<"SCRIPT_RUN" | "BIN_EXEC" | "INSTALL_ALL" | "INSTALL_PKG" | "UNINSTALL_PKG", string>;
|
|
15
|
+
constructor(options: TemplateBuilderOptions);
|
|
16
|
+
build(): Promise<void>;
|
|
17
|
+
copyTemplateFiles(): Promise<void>;
|
|
18
|
+
copyAssets(): Promise<void>;
|
|
19
|
+
setupPackageJson(): Promise<void>;
|
|
20
|
+
setupConfig(): Promise<void>;
|
|
21
|
+
setupAddons(): Promise<void>;
|
|
22
|
+
setupEnv(): Promise<void>;
|
|
23
|
+
installDependencies(): Promise<void>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { existsAsync } from '@reciple/utils';
|
|
2
|
+
import { mkdir, readFile, writeFile } from 'fs/promises';
|
|
3
|
+
import { recursiveCopyFiles, runScript } from '../utils/helpers.js';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { packageManagerPlaceholders, packages, root } from '../utils/constants.js';
|
|
6
|
+
import { Addon } from './Addon.js';
|
|
7
|
+
import detectIndent from 'detect-indent';
|
|
8
|
+
import { kleur } from 'fallout-utility';
|
|
9
|
+
import { ConfigReader } from 'reciple';
|
|
10
|
+
export class TemplateBuilder {
|
|
11
|
+
setup;
|
|
12
|
+
template;
|
|
13
|
+
config;
|
|
14
|
+
get dir() {
|
|
15
|
+
return this.setup.dir ?? process.cwd();
|
|
16
|
+
}
|
|
17
|
+
get packageJsonPath() {
|
|
18
|
+
return path.join(this.dir, 'package.json');
|
|
19
|
+
}
|
|
20
|
+
get packageManagerPlaceholders() {
|
|
21
|
+
return packageManagerPlaceholders[this.setup.packageManager ?? 'npm'];
|
|
22
|
+
}
|
|
23
|
+
constructor(options) {
|
|
24
|
+
this.setup = options.setup;
|
|
25
|
+
this.template = options.template;
|
|
26
|
+
}
|
|
27
|
+
async build() {
|
|
28
|
+
if (!await existsAsync(this.dir))
|
|
29
|
+
await mkdir(this.dir, { recursive: true });
|
|
30
|
+
await this.copyTemplateFiles();
|
|
31
|
+
await this.copyAssets();
|
|
32
|
+
await this.setupPackageJson();
|
|
33
|
+
await this.setupConfig();
|
|
34
|
+
await this.setupAddons();
|
|
35
|
+
await this.setupEnv();
|
|
36
|
+
if (this.setup.packageManager)
|
|
37
|
+
await this.installDependencies();
|
|
38
|
+
console.log(`${kleur.bold(kleur.green('✔') + ' Your project is ready!')}`);
|
|
39
|
+
console.log(`\nStart developing:`);
|
|
40
|
+
if (path.relative(process.cwd(), this.dir) !== '') {
|
|
41
|
+
console.log(` • ${kleur.cyan().bold('cd ' + path.relative(process.cwd(), this.dir))}`);
|
|
42
|
+
}
|
|
43
|
+
if (!this.setup.packageManager)
|
|
44
|
+
console.log(` • ${kleur.cyan().bold(this.packageManagerPlaceholders.INSTALL_ALL)} (or ${packageManagerPlaceholders.pnpm.INSTALL_ALL}, etc)`);
|
|
45
|
+
console.log(` • ${kleur.cyan().bold(`${this.packageManagerPlaceholders.SCRIPT_RUN} dev`)}`);
|
|
46
|
+
}
|
|
47
|
+
async copyTemplateFiles() {
|
|
48
|
+
await recursiveCopyFiles(this.template.path, this.dir, f => f.replace('dot.', '.'));
|
|
49
|
+
}
|
|
50
|
+
async copyAssets() {
|
|
51
|
+
if (await existsAsync(path.join(root, 'assets'))) {
|
|
52
|
+
await recursiveCopyFiles(path.join(root, 'assets'), this.dir, f => f.replace('dot.', '.'));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async setupPackageJson() {
|
|
56
|
+
let packageJson = await readFile(this.packageJsonPath, 'utf-8');
|
|
57
|
+
for (const pkg of Object.keys(packages)) {
|
|
58
|
+
packageJson = packageJson.replaceAll(`"${pkg}"`, `"${packages[pkg] ?? "*"}"`);
|
|
59
|
+
}
|
|
60
|
+
for (const placeholder of Object.keys(this.packageManagerPlaceholders)) {
|
|
61
|
+
packageJson = packageJson.replaceAll(placeholder, this.packageManagerPlaceholders[placeholder]);
|
|
62
|
+
}
|
|
63
|
+
await writeFile(this.packageJsonPath, packageJson, 'utf-8');
|
|
64
|
+
}
|
|
65
|
+
async setupConfig() {
|
|
66
|
+
this.config = (await ConfigReader.readConfigJS(path.join(this.dir, 'reciple.mjs'))).config;
|
|
67
|
+
}
|
|
68
|
+
async setupAddons() {
|
|
69
|
+
const addons = (this.setup.addons ?? []).map(a => new Addon({ module: a, version: Addon.DEFAULT_ADDON_VERSIONS[a] || undefined }));
|
|
70
|
+
if (!addons.length)
|
|
71
|
+
return;
|
|
72
|
+
let packageJsonData = await readFile(this.packageJsonPath, 'utf-8');
|
|
73
|
+
let packageJson = JSON.parse(packageJsonData);
|
|
74
|
+
let packageJsonIndentSize = detectIndent(packageJsonData).indent || ' ';
|
|
75
|
+
for (const addon of addons) {
|
|
76
|
+
await addon.fetch();
|
|
77
|
+
await addon.readTarball();
|
|
78
|
+
const moduleContent = this.setup.isTypescript ? addon.tarballData?.initialModuleContent.ts : addon.tarballData?.initialModuleContent.js;
|
|
79
|
+
if (!moduleContent)
|
|
80
|
+
continue;
|
|
81
|
+
const modulesFolder = path.join(this.dir, this.setup.isTypescript ? 'src' : 'modules');
|
|
82
|
+
await mkdir(modulesFolder, { recursive: true });
|
|
83
|
+
const modulePath = path.join(modulesFolder, `${addon.module}.${this.setup.isTypescript ? 'ts' : 'js'}`);
|
|
84
|
+
await writeFile(modulePath, moduleContent);
|
|
85
|
+
packageJson.dependencies = {
|
|
86
|
+
...packageJson.dependencies,
|
|
87
|
+
[addon.module]: addon.version,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
await writeFile(this.packageJsonPath, JSON.stringify(packageJson, null, packageJsonIndentSize), 'utf-8');
|
|
91
|
+
}
|
|
92
|
+
async setupEnv() {
|
|
93
|
+
const file = path.resolve(path.join(this.dir, '.env'));
|
|
94
|
+
let content = '';
|
|
95
|
+
if (await existsAsync(file))
|
|
96
|
+
content = await readFile(file, 'utf-8');
|
|
97
|
+
if (!content.includes('TOKEN=')) {
|
|
98
|
+
content += `\n# Replace this value to your Discord bot token from https://discord.com/developers/applications\nTOKEN="${this.setup.token ?? ''}"`;
|
|
99
|
+
content = content.trim();
|
|
100
|
+
}
|
|
101
|
+
await writeFile(file, content);
|
|
102
|
+
}
|
|
103
|
+
async installDependencies() {
|
|
104
|
+
await runScript(this.packageManagerPlaceholders.INSTALL_ALL, this.dir);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=TemplateBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateBuilder.js","sourceRoot":"","sources":["../../src/classes/TemplateBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,0BAA0B,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,KAAK,EAAe,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAiB,MAAM,SAAS,CAAC;AAOtD,MAAM,OAAO,eAAe;IACjB,KAAK,CAAe;IACpB,QAAQ,CAAmB;IAE3B,MAAM,CAAiB;IAE9B,IAAI,GAAG;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,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B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;QAEvD,IAAI,OAAO,GAAW,EAAE,CAAC;QACzB,IAAI,MAAM,WAAW,CAAC,IAAI,CAAC;YAAE,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAErE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,OAAO,IAAI,6GAA6G,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,GAAG,CAAC;YAClJ,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAC7B,CAAC;QAED,MAAM,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAEM,KAAK,CAAC,mBAAmB;QAC5B,MAAM,SAAS,CAAC,IAAI,CAAC,0BAA0B,CAAC,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3E,CAAC;CACJ"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
|
|
@@ -8,35 +8,5 @@ export declare const packageManagers: {
|
|
|
8
8
|
hint?: string;
|
|
9
9
|
value: PackageManager | 'none';
|
|
10
10
|
}[];
|
|
11
|
-
export declare const packages:
|
|
12
|
-
|
|
13
|
-
RECIPLE_CORE: string | undefined;
|
|
14
|
-
TYPESCRIPT: string | undefined;
|
|
15
|
-
RIMRAF: string | undefined;
|
|
16
|
-
RECIPLE: string | undefined;
|
|
17
|
-
DISCORDJS: string | undefined;
|
|
18
|
-
NODEMON: string | undefined;
|
|
19
|
-
};
|
|
20
|
-
export declare const packageManagerPlaceholders: {
|
|
21
|
-
npm: {
|
|
22
|
-
SCRIPT_RUN: string;
|
|
23
|
-
BIN_EXEC: string;
|
|
24
|
-
INSTALL_ALL: string;
|
|
25
|
-
INSTALL_PKG: string;
|
|
26
|
-
UNINSTALL_PKG: string;
|
|
27
|
-
};
|
|
28
|
-
pnpm: {
|
|
29
|
-
SCRIPT_RUN: string;
|
|
30
|
-
BIN_EXEC: string;
|
|
31
|
-
INSTALL_ALL: string;
|
|
32
|
-
INSTALL_PKG: string;
|
|
33
|
-
UNINSTALL_PKG: string;
|
|
34
|
-
};
|
|
35
|
-
yarn: {
|
|
36
|
-
SCRIPT_RUN: string;
|
|
37
|
-
BIN_EXEC: string;
|
|
38
|
-
INSTALL_ALL: string;
|
|
39
|
-
INSTALL_PKG: string;
|
|
40
|
-
UNINSTALL_PKG: string;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
11
|
+
export declare const packages: Record<string, string>;
|
|
12
|
+
export declare const packageManagerPlaceholders: Record<PackageManager, Record<'SCRIPT_RUN' | 'BIN_EXEC' | 'INSTALL_ALL' | 'INSTALL_PKG' | 'UNINSTALL_PKG', string>>;
|
package/dist/utils/constants.js
CHANGED
|
@@ -20,6 +20,11 @@ export const packageManagers = [
|
|
|
20
20
|
hint: 'Uses pnpm as package manager',
|
|
21
21
|
value: 'pnpm'
|
|
22
22
|
},
|
|
23
|
+
{
|
|
24
|
+
label: 'bun',
|
|
25
|
+
hint: 'Uses bun as package manager',
|
|
26
|
+
value: 'bun'
|
|
27
|
+
},
|
|
23
28
|
{
|
|
24
29
|
label: 'none',
|
|
25
30
|
hint: 'Setup package manager later',
|
|
@@ -28,11 +33,11 @@ export const packageManagers = [
|
|
|
28
33
|
];
|
|
29
34
|
export const packages = {
|
|
30
35
|
'TYPES_NODE': packageJson.devDependencies['@types/node'],
|
|
31
|
-
'RECIPLE_CORE': packageJson.
|
|
36
|
+
'RECIPLE_CORE': packageJson.dependencies['@reciple/core'],
|
|
32
37
|
'TYPESCRIPT': packageJson.devDependencies['typescript'],
|
|
33
38
|
'RIMRAF': packageJson.devDependencies['rimraf'],
|
|
34
|
-
'RECIPLE': packageJson.
|
|
35
|
-
'DISCORDJS': packageJson.
|
|
39
|
+
'RECIPLE': packageJson.dependencies['reciple'],
|
|
40
|
+
'DISCORDJS': packageJson.dependencies['discord.js'],
|
|
36
41
|
'NODEMON': packageJson.devDependencies['nodemon']
|
|
37
42
|
};
|
|
38
43
|
export const packageManagerPlaceholders = {
|
|
@@ -56,6 +61,13 @@ export const packageManagerPlaceholders = {
|
|
|
56
61
|
'INSTALL_ALL': 'yarn',
|
|
57
62
|
'INSTALL_PKG': 'yarn add',
|
|
58
63
|
'UNINSTALL_PKG': 'yarn remove'
|
|
64
|
+
},
|
|
65
|
+
'bun': {
|
|
66
|
+
'SCRIPT_RUN': 'bun run',
|
|
67
|
+
'BIN_EXEC': 'bunx',
|
|
68
|
+
'INSTALL_ALL': 'bun install',
|
|
69
|
+
'INSTALL_PKG': 'bun add',
|
|
70
|
+
'UNINSTALL_PKG': 'bun remove'
|
|
59
71
|
}
|
|
60
72
|
};
|
|
61
73
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE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,KAAK;QACjB,aAAa,EAAE,aAAa;QAC5B,aAAa,EAAE,aAAa;QAC5B,eAAe,EAAE,eAAe;KACnC;IACD,MAAM,EAAE;QACJ,YAAY,EAAE,UAAU;QACxB,UAAU,EAAE,WAAW;QACvB,aAAa,EAAE,cAAc;QAC7B,aAAa,EAAE,UAAU;QACzB,eAAe,EAAE,aAAa;KACjC;IACD,MAAM,EAAE;QACJ,YAAY,EAAE,UAAU;QACxB,UAAU,EAAE,WAAW;QACvB,aAAa,EAAE,MAAM;QACrB,aAAa,EAAE,UAAU;QACzB,eAAe,EAAE,aAAa;KACjC;IACD,KAAK,EAAE;QACH,YAAY,EAAE,SAAS;QACvB,UAAU,EAAE,MAAM;QAClB,aAAa,EAAE,aAAa;QAC5B,aAAa,EAAE,SAAS;QACxB,eAAe,EAAE,YAAY;KAChC;CACJ,CAAC"}
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import { PackageManager } from '@reciple/utils';
|
|
2
1
|
import { TemplateMetadata } from './types.js';
|
|
3
2
|
export declare function getTemplates(dir: string): Promise<TemplateMetadata[]>;
|
|
4
|
-
export declare function cancelPrompts(options?: {
|
|
5
|
-
reason?: string;
|
|
6
|
-
code?: number;
|
|
7
|
-
}): never;
|
|
8
|
-
export declare function createDotEnv(dir: string, defaultToken?: string): Promise<string>;
|
|
9
|
-
export declare function create(template: TemplateMetadata, dir: string, packageManager?: PackageManager, addons?: string[], token?: string): Promise<void>;
|
|
10
3
|
export declare function recursiveCopyFiles(from: string, to: string, rename?: (f: string) => string): Promise<void>;
|
|
11
4
|
export declare function runScript(command: string, cwd?: string): Promise<void>;
|
|
12
5
|
export declare function isDirEmpty(dir: string): Promise<boolean>;
|
package/dist/utils/helpers.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { copyFile, mkdir, readFile, readdir, stat
|
|
2
|
-
import { packageManagerPlaceholders, packages, root } from './constants.js';
|
|
1
|
+
import { copyFile, mkdir, readFile, readdir, stat } from 'node:fs/promises';
|
|
3
2
|
import { existsAsync } from '@reciple/utils';
|
|
4
3
|
import { kleur } from 'fallout-utility/strings';
|
|
5
4
|
import { execSync } from 'node:child_process';
|
|
6
|
-
import { installAddons } from './addons.js';
|
|
7
|
-
import { cancel } from '@clack/prompts';
|
|
8
|
-
import { exit } from 'node:process';
|
|
9
5
|
import path from 'node:path';
|
|
10
6
|
export async function getTemplates(dir) {
|
|
11
7
|
if (!await existsAsync(dir)) {
|
|
@@ -34,53 +30,6 @@ export async function getTemplates(dir) {
|
|
|
34
30
|
}
|
|
35
31
|
return templates;
|
|
36
32
|
}
|
|
37
|
-
export function cancelPrompts(options) {
|
|
38
|
-
cancel(options?.reason ?? 'Operation cancelled');
|
|
39
|
-
exit(options?.code ?? 1);
|
|
40
|
-
}
|
|
41
|
-
export async function createDotEnv(dir, defaultToken) {
|
|
42
|
-
const file = path.resolve(path.join(dir, '.env'));
|
|
43
|
-
let content = '';
|
|
44
|
-
if (await existsAsync(file))
|
|
45
|
-
content = await readFile(file, 'utf-8');
|
|
46
|
-
if (!content.includes('TOKEN=')) {
|
|
47
|
-
content += `\n# Replace this value to your Discord bot token from https://discord.com/developers/applications\nTOKEN="${defaultToken ?? ''}"`;
|
|
48
|
-
content = content.trim();
|
|
49
|
-
}
|
|
50
|
-
await writeFile(file, content);
|
|
51
|
-
return content;
|
|
52
|
-
}
|
|
53
|
-
export async function create(template, dir, packageManager, addons, token) {
|
|
54
|
-
if (!await existsAsync(dir))
|
|
55
|
-
mkdir(dir, { recursive: true });
|
|
56
|
-
await recursiveCopyFiles(template.path, dir, f => f.replace('dot.', '.'));
|
|
57
|
-
if (await existsAsync(path.join(root, 'assets'))) {
|
|
58
|
-
await recursiveCopyFiles(path.join(root, 'assets'), dir, f => f.replace('dot.', '.'));
|
|
59
|
-
}
|
|
60
|
-
let packageJsonData = await readFile(path.join(dir, 'package.json'), 'utf-8');
|
|
61
|
-
const placeholders = packageManagerPlaceholders[packageManager ?? 'npm'];
|
|
62
|
-
for (const pkg of Object.keys(packages)) {
|
|
63
|
-
packageJsonData = packageJsonData.replaceAll(`"${pkg}"`, `"${packages[pkg] ?? "*"}"`);
|
|
64
|
-
}
|
|
65
|
-
for (const placeholder of Object.keys(placeholders)) {
|
|
66
|
-
packageJsonData = packageJsonData.replaceAll(placeholder, placeholders[placeholder]);
|
|
67
|
-
}
|
|
68
|
-
await writeFile(path.join(dir, 'package.json'), packageJsonData);
|
|
69
|
-
if (packageManager)
|
|
70
|
-
await runScript(placeholders['INSTALL_ALL'], dir);
|
|
71
|
-
await runScript(`${packageManagerPlaceholders['npm']['BIN_EXEC']} reciple@${packages['RECIPLE']?.substring(1)} "${dir}" --setup -c reciple.mjs`, dir);
|
|
72
|
-
await createDotEnv(dir, token);
|
|
73
|
-
if (addons?.length)
|
|
74
|
-
await installAddons(dir, template.language === 'Typescript' ? 'ts' : 'js', addons, placeholders['INSTALL_PKG']);
|
|
75
|
-
console.log(`${kleur.bold(kleur.green('✔') + ' Your project is ready!')}`);
|
|
76
|
-
console.log(`\nStart developing:`);
|
|
77
|
-
if (path.relative(process.cwd(), dir) !== '') {
|
|
78
|
-
console.log(` • ${kleur.cyan().bold('cd ' + path.relative(process.cwd(), dir))}`);
|
|
79
|
-
}
|
|
80
|
-
if (!packageManager)
|
|
81
|
-
console.log(` • ${kleur.cyan().bold(placeholders.INSTALL_ALL)} (or ${packageManagerPlaceholders.pnpm.INSTALL_ALL}, etc)`);
|
|
82
|
-
console.log(` • ${kleur.cyan().bold(`${placeholders.SCRIPT_RUN} dev`)}`);
|
|
83
|
-
}
|
|
84
33
|
export async function recursiveCopyFiles(from, to, rename) {
|
|
85
34
|
if ((await stat(from)).isDirectory()) {
|
|
86
35
|
const contents = await readdir(from);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA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ord bot project builder",
|
|
4
4
|
"license": "GPL-3.0",
|
|
5
|
-
"version": "9.
|
|
5
|
+
"version": "9.1.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"module": "./dist/index.js",
|
|
@@ -35,18 +35,21 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@clack/prompts": "^0.7.0",
|
|
38
|
-
"@reciple/
|
|
38
|
+
"@reciple/core": "^9.0.3",
|
|
39
|
+
"@reciple/utils": "^9.0.2",
|
|
39
40
|
"commander": "^12.1.0",
|
|
40
|
-
"
|
|
41
|
+
"compressing": "^1.10.1",
|
|
42
|
+
"detect-indent": "^7.0.1",
|
|
43
|
+
"discord.js": "^14.15.2",
|
|
44
|
+
"fallout-utility": "^2.9.1",
|
|
45
|
+
"package-json": "^10.0.0",
|
|
46
|
+
"reciple": "^9.0.3"
|
|
41
47
|
},
|
|
42
48
|
"devDependencies": {
|
|
43
|
-
"@reciple/core": "^9.0.2",
|
|
44
49
|
"@types/node": "^20.12.12",
|
|
45
|
-
"discord.js": "^14.15.2",
|
|
46
50
|
"nodemon": "^3.1.2",
|
|
47
|
-
"reciple": "^9.0.2",
|
|
48
51
|
"rimraf": "^5.0.7",
|
|
49
52
|
"typescript": "^5.4.5"
|
|
50
53
|
},
|
|
51
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "c2cfe308a3a3b03d191fbc5723f88fb0c295e512"
|
|
52
55
|
}
|
package/dist/utils/addons.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type AddonModuleType = 'js' | 'ts';
|
|
2
|
-
export declare const addonCreators: {
|
|
3
|
-
'reciple-interaction-events': typeof addRecipleInteractionEvents;
|
|
4
|
-
'reciple-anticrash': typeof addRecipleAnticrash;
|
|
5
|
-
'reciple-dev-commands': typeof addRecipleDevCommands;
|
|
6
|
-
'reciple-registry-cache': typeof addRecipleRegistryCache;
|
|
7
|
-
};
|
|
8
|
-
export declare function createAddonModuleFileContent(pkg: string, imports: string[] | string, classExport: string, type: AddonModuleType, params?: string): string;
|
|
9
|
-
export declare function addRecipleInteractionEvents(dir: string, type: AddonModuleType): Promise<void>;
|
|
10
|
-
export declare function addRecipleAnticrash(dir: string, type: AddonModuleType): Promise<void>;
|
|
11
|
-
export declare function addRecipleDevCommands(dir: string, type: AddonModuleType): Promise<void>;
|
|
12
|
-
export declare function addRecipleRegistryCache(dir: string, type: AddonModuleType): Promise<void>;
|
|
13
|
-
export declare function installAddons(dir: string, type: AddonModuleType, addons: string[], installPackage?: string): Promise<void>;
|
|
14
|
-
export default addonCreators;
|
package/dist/utils/addons.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { writeFile } from 'node:fs/promises';
|
|
2
|
-
import { runScript } from './helpers.js';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
export const addonCreators = {
|
|
5
|
-
'reciple-interaction-events': addRecipleInteractionEvents,
|
|
6
|
-
'reciple-anticrash': addRecipleAnticrash,
|
|
7
|
-
'reciple-dev-commands': addRecipleDevCommands,
|
|
8
|
-
'reciple-registry-cache': addRecipleRegistryCache
|
|
9
|
-
};
|
|
10
|
-
export function createAddonModuleFileContent(pkg, imports, classExport, type, params) {
|
|
11
|
-
const importStatement = `import ${typeof imports === 'string' ? imports : ('{ ' + imports.join(', ') + ' }')} from '${pkg}';`;
|
|
12
|
-
const exportStatement = `export default new ${classExport}(${params ?? ''});`;
|
|
13
|
-
return importStatement + '\n\n' + exportStatement;
|
|
14
|
-
}
|
|
15
|
-
export async function addRecipleInteractionEvents(dir, type) {
|
|
16
|
-
await writeFile(path.join(dir, type === 'js' ? 'modules' : 'src', `RecipleInteractionEvents.${type}`), createAddonModuleFileContent('reciple-interaction-events', ['InteractionEventManager'], 'InteractionEventManager', type));
|
|
17
|
-
}
|
|
18
|
-
export async function addRecipleAnticrash(dir, type) {
|
|
19
|
-
await writeFile(path.join(dir, type === 'js' ? 'modules' : 'src', `RecipleAnticrash.${type}`), createAddonModuleFileContent('reciple-anticrash', ['RecipleAnticrash'], 'RecipleAnticrash', type));
|
|
20
|
-
}
|
|
21
|
-
export async function addRecipleDevCommands(dir, type) {
|
|
22
|
-
await writeFile(path.join(dir, type === 'js' ? 'modules' : 'src', `RecipleDevCommands.${type}`), createAddonModuleFileContent('reciple-dev-commands', ['DevCommandManager'], 'DevCommandManager', type, `{\n devGuilds: [],\n devUsers: []\n}`));
|
|
23
|
-
}
|
|
24
|
-
export async function addRecipleRegistryCache(dir, type) {
|
|
25
|
-
await writeFile(path.join(dir, type === 'js' ? 'modules' : 'src', `RecipleRegistryCache.${type}`), createAddonModuleFileContent('reciple-registry-cache', ['RegistryCacheManager'], 'RegistryCacheManager', type));
|
|
26
|
-
}
|
|
27
|
-
export async function installAddons(dir, type, addons, installPackage) {
|
|
28
|
-
await runScript((installPackage ?? 'npm i') + ' ' + addons.map(a => a + '@3').join(' '), dir);
|
|
29
|
-
for (const addon of addons) {
|
|
30
|
-
await addonCreators[addon](dir, type);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export default addonCreators;
|
|
34
|
-
//# sourceMappingURL=addons.js.map
|
package/dist/utils/addons.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addons.js","sourceRoot":"","sources":["../../src/utils/addons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,4BAA4B,EAAE,2BAA2B;IACzD,mBAAmB,EAAE,mBAAmB;IACxC,sBAAsB,EAAE,qBAAqB;IAC7C,wBAAwB,EAAE,uBAAuB;CACpD,CAAC;AAEF,MAAM,UAAU,4BAA4B,CAAC,GAAW,EAAE,OAAwB,EAAE,WAAmB,EAAE,IAAq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