@a5gard/bifrost-plugin 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/index.js +96 -80
- package/package.json +44 -41
package/README.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# bifrost-plugin
|
|
2
2
|
|
|
3
3
|
Plugin installer / wizard for bifrost projects.
|
|
4
4
|
|
|
5
|
-
## Installing A Plugin
|
|
6
5
|
|
|
7
6
|
### Interactive Mode
|
|
8
7
|
|
|
@@ -17,7 +16,9 @@ Entering interactive mode it will display the following options:
|
|
|
17
16
|
- Plugin wizard ( guide in creating your own plugin )
|
|
18
17
|
- Submit Plugin
|
|
19
18
|
|
|
20
|
-
##
|
|
19
|
+
## Installing A Plugin
|
|
20
|
+
|
|
21
|
+
### `List available plugins to install`
|
|
21
22
|
|
|
22
23
|
Running the following command will start plugin installation process:
|
|
23
24
|
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { Command } from "commander";
|
|
5
|
-
import
|
|
5
|
+
import inquirer4 from "inquirer";
|
|
6
6
|
import chalk5 from "chalk";
|
|
7
7
|
|
|
8
8
|
// src/utils.ts
|
|
@@ -29,13 +29,13 @@ import path3 from "path";
|
|
|
29
29
|
import { execSync } from "child_process";
|
|
30
30
|
import ora from "ora";
|
|
31
31
|
import chalk2 from "chalk";
|
|
32
|
-
import
|
|
32
|
+
import inquirer2 from "inquirer";
|
|
33
33
|
|
|
34
34
|
// src/config-manager.ts
|
|
35
35
|
import fs2 from "fs-extra";
|
|
36
36
|
import path2 from "path";
|
|
37
37
|
import chalk from "chalk";
|
|
38
|
-
import
|
|
38
|
+
import inquirer from "inquirer";
|
|
39
39
|
async function processConfigFiles(pluginGithub, configs) {
|
|
40
40
|
for (const config of configs) {
|
|
41
41
|
const targetPath = path2.join(process.cwd(), config.targetFile);
|
|
@@ -61,16 +61,18 @@ Target file ${config.targetFile} does not exist. Skipping...`));
|
|
|
61
61
|
console.log(chalk.gray("\u2500".repeat(50)));
|
|
62
62
|
console.log(configContent);
|
|
63
63
|
console.log(chalk.gray("\u2500".repeat(50)));
|
|
64
|
-
const { action } = await
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
const { action } = await inquirer.prompt([
|
|
65
|
+
{
|
|
66
|
+
type: "list",
|
|
67
|
+
name: "action",
|
|
68
|
+
message: `How would you like to handle ${config.targetFile}?`,
|
|
69
|
+
choices: [
|
|
70
|
+
{ name: "Auto-apply changes", value: "auto" },
|
|
71
|
+
{ name: "Copy to clipboard (manual)", value: "manual" },
|
|
72
|
+
{ name: "Skip this configuration", value: "skip" }
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
]);
|
|
74
76
|
if (action === "skip") {
|
|
75
77
|
console.log(chalk.yellow(`Skipped ${config.targetFile}`));
|
|
76
78
|
continue;
|
|
@@ -228,21 +230,25 @@ async function installPlugin(pluginGithub, projectPlatform) {
|
|
|
228
230
|
}
|
|
229
231
|
spinner = ora("Installing plugin files...").start();
|
|
230
232
|
for (const file of pluginConfig.files) {
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
233
|
+
const { useDefault } = await inquirer2.prompt([
|
|
234
|
+
{
|
|
235
|
+
type: "confirm",
|
|
236
|
+
name: "useDefault",
|
|
237
|
+
message: `Install ${file.name} to ${file.location}?`,
|
|
238
|
+
default: true
|
|
239
|
+
}
|
|
240
|
+
]);
|
|
237
241
|
let finalTargetPath = path3.join(process.cwd(), file.location);
|
|
238
|
-
if (!
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
242
|
+
if (!useDefault) {
|
|
243
|
+
const { location } = await inquirer2.prompt([
|
|
244
|
+
{
|
|
245
|
+
type: "input",
|
|
246
|
+
name: "location",
|
|
247
|
+
message: `Enter custom location for ${file.name}:`,
|
|
248
|
+
default: file.location
|
|
249
|
+
}
|
|
250
|
+
]);
|
|
251
|
+
finalTargetPath = path3.join(process.cwd(), location);
|
|
246
252
|
}
|
|
247
253
|
const fileUrl = `https://raw.githubusercontent.com/${pluginGithub}/main/files/${file.name}`;
|
|
248
254
|
const fileResponse = await fetch(fileUrl);
|
|
@@ -310,46 +316,46 @@ function detectPackageManager() {
|
|
|
310
316
|
import fs4 from "fs-extra";
|
|
311
317
|
import path4 from "path";
|
|
312
318
|
import chalk3 from "chalk";
|
|
313
|
-
import
|
|
319
|
+
import inquirer3 from "inquirer";
|
|
314
320
|
import { execSync as execSync2 } from "child_process";
|
|
315
321
|
async function createPlugin() {
|
|
316
322
|
console.log(chalk3.blue.bold("\n\u{1F680} Bifrost Plugin Creator\n"));
|
|
317
|
-
const answers = await
|
|
323
|
+
const answers = await inquirer3.prompt([
|
|
318
324
|
{
|
|
319
|
-
type: "
|
|
325
|
+
type: "input",
|
|
320
326
|
name: "name",
|
|
321
327
|
message: "Plugin name:",
|
|
322
328
|
validate: (value) => value.length > 0 ? true : "Plugin name is required"
|
|
323
329
|
},
|
|
324
330
|
{
|
|
325
|
-
type: "
|
|
331
|
+
type: "list",
|
|
326
332
|
name: "platform",
|
|
327
333
|
message: "Select platform:",
|
|
328
334
|
choices: [
|
|
329
|
-
{
|
|
330
|
-
{
|
|
331
|
-
{
|
|
332
|
-
{
|
|
335
|
+
{ name: "Remix", value: "remix" },
|
|
336
|
+
{ name: "Next.js", value: "nextjs" },
|
|
337
|
+
{ name: "Vite", value: "vite" },
|
|
338
|
+
{ name: "Other", value: "other" }
|
|
333
339
|
]
|
|
334
340
|
},
|
|
335
341
|
{
|
|
336
|
-
type: "
|
|
342
|
+
type: "input",
|
|
337
343
|
name: "description",
|
|
338
344
|
message: "Description:",
|
|
339
345
|
validate: (value) => value.length > 0 ? true : "Description is required"
|
|
340
346
|
},
|
|
341
347
|
{
|
|
342
|
-
type: "
|
|
348
|
+
type: "input",
|
|
343
349
|
name: "tags",
|
|
344
350
|
message: "Tags (comma-separated):",
|
|
345
|
-
|
|
346
|
-
|
|
351
|
+
default: "",
|
|
352
|
+
filter: (value) => value ? value.split(",").map((t) => t.trim()).filter(Boolean) : []
|
|
347
353
|
},
|
|
348
354
|
{
|
|
349
355
|
type: "confirm",
|
|
350
356
|
name: "addLibraries",
|
|
351
357
|
message: "Would you like to supply required libraries now?",
|
|
352
|
-
|
|
358
|
+
default: false
|
|
353
359
|
}
|
|
354
360
|
]);
|
|
355
361
|
if (!answers.name) {
|
|
@@ -359,32 +365,38 @@ async function createPlugin() {
|
|
|
359
365
|
let libraries = [];
|
|
360
366
|
if (answers.addLibraries) {
|
|
361
367
|
console.log(chalk3.gray("\nFormat: @remix-run/react, remix-auth, react"));
|
|
362
|
-
const { libraryInput } = await
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
+
const { libraryInput } = await inquirer3.prompt([
|
|
369
|
+
{
|
|
370
|
+
type: "input",
|
|
371
|
+
name: "libraryInput",
|
|
372
|
+
message: "Libraries:",
|
|
373
|
+
default: ""
|
|
374
|
+
}
|
|
375
|
+
]);
|
|
368
376
|
if (libraryInput) {
|
|
369
377
|
libraries = libraryInput.split(",").map((l) => l.trim()).filter(Boolean);
|
|
370
378
|
}
|
|
371
379
|
}
|
|
372
|
-
const { githubUsername } = await
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
380
|
+
const { githubUsername } = await inquirer3.prompt([
|
|
381
|
+
{
|
|
382
|
+
type: "input",
|
|
383
|
+
name: "githubUsername",
|
|
384
|
+
message: "GitHub username:",
|
|
385
|
+
validate: (value) => value.length > 0 ? true : "GitHub username is required"
|
|
386
|
+
}
|
|
387
|
+
]);
|
|
378
388
|
if (!githubUsername) {
|
|
379
389
|
console.log(chalk3.yellow("\nPlugin creation cancelled"));
|
|
380
390
|
process.exit(0);
|
|
381
391
|
}
|
|
382
|
-
const { autoGithub } = await
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
392
|
+
const { autoGithub } = await inquirer3.prompt([
|
|
393
|
+
{
|
|
394
|
+
type: "confirm",
|
|
395
|
+
name: "autoGithub",
|
|
396
|
+
message: "Auto-create and push to GitHub?",
|
|
397
|
+
default: true
|
|
398
|
+
}
|
|
399
|
+
]);
|
|
388
400
|
const pluginDir = path4.join(process.cwd(), answers.name);
|
|
389
401
|
if (await fs4.pathExists(pluginDir)) {
|
|
390
402
|
console.error(chalk3.red(`
|
|
@@ -535,10 +547,10 @@ MIT \xA9 ${username}
|
|
|
535
547
|
import fs5 from "fs-extra";
|
|
536
548
|
import path5 from "path";
|
|
537
549
|
import chalk4 from "chalk";
|
|
538
|
-
import
|
|
550
|
+
import prompts from "prompts";
|
|
539
551
|
import { execSync as execSync3 } from "child_process";
|
|
540
552
|
var REGISTRY_REPO = "A5GARD/BIFROST-PLUGIN";
|
|
541
|
-
var REGISTRY_FILE = "
|
|
553
|
+
var REGISTRY_FILE = "registry.bifrost";
|
|
542
554
|
async function submitPlugin() {
|
|
543
555
|
console.log(chalk4.blue.bold("\n\u{1F4E4} Submit Plugin to Registry\n"));
|
|
544
556
|
const pluginConfigPath = path5.join(process.cwd(), "plugin.bifrost");
|
|
@@ -557,7 +569,7 @@ async function submitPlugin() {
|
|
|
557
569
|
console.log(`Tags: ${chalk4.white(pluginConfig.tags.join(", "))}`);
|
|
558
570
|
console.log(`Libraries: ${chalk4.white(pluginConfig.libraries.join(", "))}`);
|
|
559
571
|
console.log(chalk4.gray("\u2500".repeat(50)));
|
|
560
|
-
const { confirm } = await
|
|
572
|
+
const { confirm } = await prompts({
|
|
561
573
|
type: "confirm",
|
|
562
574
|
name: "confirm",
|
|
563
575
|
message: "Submit this plugin to the registry?",
|
|
@@ -695,16 +707,18 @@ Error: ${error instanceof Error ? error.message : "Unknown error"}`));
|
|
|
695
707
|
});
|
|
696
708
|
async function interactiveMode() {
|
|
697
709
|
console.log(chalk5.blue.bold("\n\u{1F309} bifrost Plugin Manager\n"));
|
|
698
|
-
const { action } = await
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
710
|
+
const { action } = await inquirer4.prompt([
|
|
711
|
+
{
|
|
712
|
+
type: "list",
|
|
713
|
+
name: "action",
|
|
714
|
+
message: "What would you like to do?",
|
|
715
|
+
choices: [
|
|
716
|
+
{ name: "List available plugins to install", value: "list" },
|
|
717
|
+
{ name: "Plugin wizard (create your own plugin)", value: "create" },
|
|
718
|
+
{ name: "Submit plugin to registry", value: "submit" }
|
|
719
|
+
]
|
|
720
|
+
}
|
|
721
|
+
]);
|
|
708
722
|
if (!action) {
|
|
709
723
|
console.log(chalk5.yellow("\nCancelled"));
|
|
710
724
|
process.exit(0);
|
|
@@ -736,15 +750,17 @@ async function listPlugins() {
|
|
|
736
750
|
console.log(chalk5.yellow(`No plugins available for platform: ${projectConfig.platform}`));
|
|
737
751
|
process.exit(0);
|
|
738
752
|
}
|
|
739
|
-
const { selectedPlugin } = await
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
753
|
+
const { selectedPlugin } = await inquirer4.prompt([
|
|
754
|
+
{
|
|
755
|
+
type: "list",
|
|
756
|
+
name: "selectedPlugin",
|
|
757
|
+
message: "Select a plugin to install:",
|
|
758
|
+
choices: compatiblePlugins.map((p) => ({
|
|
759
|
+
name: `${p.name} - ${p.description}`,
|
|
760
|
+
value: p
|
|
761
|
+
}))
|
|
762
|
+
}
|
|
763
|
+
]);
|
|
748
764
|
if (!selectedPlugin) {
|
|
749
765
|
console.log(chalk5.yellow("Installation cancelled"));
|
|
750
766
|
process.exit(0);
|
package/package.json
CHANGED
|
@@ -1,41 +1,44 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@a5gard/bifrost-plugin",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Plugin installer / wizard for bifrost projects",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"bifrost-plugin": "dist/index.js"
|
|
8
|
-
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"chalk": "^5.3.0",
|
|
31
|
-
"
|
|
32
|
-
"fs-extra": "^11.2.0"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@a5gard/bifrost-plugin",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "Plugin installer / wizard for bifrost projects",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"bifrost-plugin": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"copy-registry": "bun copy-registry.js",
|
|
11
|
+
"build:tsup": "tsup src/index.ts --format esm --dts --clean",
|
|
12
|
+
"build": "npm run build:tsup && npm run copy-registry ",
|
|
13
|
+
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
14
|
+
"typecheck": "tsc --noEmit"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"bifrost",
|
|
21
|
+
"plugin",
|
|
22
|
+
"cli"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"author": "8an3",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"chalk": "^5.3.0",
|
|
31
|
+
"commander": "^11.1.0",
|
|
32
|
+
"fs-extra": "^11.2.0",
|
|
33
|
+
"inquirer": "^13.2.2",
|
|
34
|
+
"ora": "^8.0.1",
|
|
35
|
+
"prompts": "^2.4.2"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/fs-extra": "^11.0.4",
|
|
39
|
+
"@types/node": "^20.11.5",
|
|
40
|
+
"@types/prompts": "^2.4.9",
|
|
41
|
+
"tsup": "^8.0.1",
|
|
42
|
+
"typescript": "^5.3.3"
|
|
43
|
+
}
|
|
44
|
+
}
|