Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: plugins list json #94

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions pluginsList.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[
{
"value": "@godspeedsystems/plugins-express-as-http",
"name": "plugins-express-as-http",
"description": "Express as HTTP server plugin for Godspeed Framework."
},

{
"value": "@godspeedsystems/plugins-cron-as-eventsource",
"name": "plugins-cron-as-eventsource",
"description": "Cron as eventsource plugin for Godspeed Framework."
},
{
"value": "@godspeedsystems/plugins-graphql-as-eventsource",
"name": "plugins-graphql-as-eventsource",
"description": "Graphql as eventsource plugin for Godspeed Framework."
},
{
"value": "@godspeedsystems/plugins-prisma-as-datastore",
"name": "plugins-prisma-as-datastore",
"description": "Prisma as a datasource plugin for Godspeed Framework."
},
{
"value": "@godspeedsystems/plugins-aws-as-datasource",
"name": "plugins-aws-as-datasource",
"description": "AWS as a datasource plugin for Godspeed Framework."
},
{
"value": "@godspeedsystems/plugins-axios-as-datasource",
"name": "plugins-axios-as-datasource",
"description": "Axios as a datasource plugin for Godspeed Framework."
},
{
"value": "@godspeedsystems/plugins-excel-as-datasource",
"name": "plugins-excel-as-datasource",
"description": "Excel as a datasource plugin for Godspeed Framework."
},
{
"value": "@godspeedsystems/plugins-mailer-as-datasource",
"name": "plugins-mailer-as-datasource",
"description": "Mailer as a datasource plugin for Godspeed Framework."
},
{
"value": "@godspeedsystems/plugins-mongoose-as-datasource",
"name": "plugins-mongoose-as-datasource",
"description": "Mongoose as a datasource plugin for Godspeed Framework."
},
{
"value": "@godspeedsystems/plugins-redis-as-datasource",
"name": "plugins-redis-as-datasource",
"description": "Redis as a datasource plugin for Godspeed Framework."
},
{
"value": "@godspeedsystems/plugins-kafka-as-datasource-as-eventsource",
"name": "plugins-kafka-as-datasource-as-eventsource",
"description": "Kafka as a datasource and eventsource plugin for Godspeed Framework."
},
{
"value": "@godspeedsystems/plugins-elasticgraph-as-datasource",
"name": "plugins-elasticgraph-as-datasource",
"description": "Elasticgraph as a datasource plugin for Godspeed Framework."
},
{
"value": "@godspeedsystems/plugins-salesforce-as-datasource-as-eventsource",
"name": "plugins-salesforce-as-datasource-as-eventsource",
"description": "Salesforce as a datasource plugin for Godspeed Framework."
}
]
93 changes: 55 additions & 38 deletions src/commands/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const addAction = async (pluginsList: string[]) => {
let yamlFileName = Module.CONFIG_FILE_NAME as string;
let defaultConfig = Module.DEFAULT_CONFIG || ({} as PlainObject);

switch (moduleType) {
switch (moduleType) {
case "BOTH":
{
mkdirSync(
Expand Down Expand Up @@ -212,16 +212,25 @@ const add = program
.action(async (pluginName: string) => {
let givenPluginName = pluginName;

const command = "npm search @godspeedsystems/plugins --json";
const stdout = execSync(command, { encoding: "utf-8" });
const availablePlugins = JSON.parse(stdout.trim());
const pluginNames = availablePlugins.map(
(plugin: { value: any; name: any; description: any }) => ({
value: plugin.name,
Name: plugin.name.split("plugins-")[1],
Description: plugin.description,
})
);
// Search the plugins list from npm

// const command = "npm search @godspeedsystems/plugins --json";
// const stdout = execSync(command, { encoding: "utf-8" });
// const availablePlugins = JSON.parse(stdout.trim());

// Load the plugins list from JSON file
const pluginsFilePath = path.resolve(__dirname, '../../../pluginsList.json');
const pluginsData = fs.readFileSync(pluginsFilePath, { encoding: 'utf-8' });
const availablePlugins = JSON.parse(pluginsData);

// Map to the format expected by the UI
const pluginNames = availablePlugins.map((plugin: { value: any; name: any; description: any }) => ({
value: plugin.value,
Name: plugin.name.split("plugins-")[1],
Description: plugin.description,
}));

console.log("Available plugins:", pluginNames);

let pkgPath = path.join(cwd(), "package.json");
let localpluginsList = existsSync(pkgPath)
Expand Down Expand Up @@ -473,8 +482,22 @@ const remove = program
return;
}

const command = "npm search @godspeedsystems/plugins --json";
const stdout = execSync(command, { encoding: "utf-8" });
// const command = "npm search @godspeedsystems/plugins --json";
// const stdout = execSync(command, { encoding: "utf-8" });
// const availablePlugins = JSON.parse(stdout.trim());

// Load the plugins list from JSON file
const pluginsFilePath = path.resolve(__dirname, '../../../pluginsList.json');
const pluginsData = fs.readFileSync(pluginsFilePath, { encoding: 'utf-8' });
const availablePlugins = JSON.parse(pluginsData);

// Map to the format expected by the UI
const pluginNames = availablePlugins.map((plugin: { value: any; name: any; description: any }) => ({
value: plugin.value,
Name: plugin.name.split("plugins-")[1],
Description: plugin.description,
}));

let pkgPath = path.join(cwd(), "package.json");
pluginsList = existsSync(pkgPath)
? JSON.parse(readFileSync(pkgPath, { encoding: "utf-8" })).dependencies
Expand All @@ -485,17 +508,6 @@ const remove = program
!isGSPlugin && delete pluginsList[pluginName];
}

// console.log(pluginsList)
const availablePlugins = JSON.parse(stdout.trim());

const pluginNames = availablePlugins.map(
(plugin: { value: any; name: any; description: any }) => ({
value: plugin.name,
Name: plugin.name.split("plugins-")[1],
Description: plugin.description,
})
);

const commonPlugins = pluginNames.filter(
(plugin: { value: string | number }) => pluginsList[plugin.value]
);
Expand All @@ -504,7 +516,7 @@ const remove = program
const tableCheckboxPrompt = {
type: "search-table",
name: "gsPlugin",
message: "Please select godspeed plugin to install:",
message: "Please select godspeed plugin to uninstall:",
wordWrap: true,
pageSize: 5,
searchable: true,
Expand Down Expand Up @@ -599,8 +611,23 @@ const update = program
}
}

const command = "npm search @godspeedsystems/plugins --json";
const stdout = execSync(command, { encoding: "utf-8" });
// const command = "npm search @godspeedsystems/plugins --json";
// const stdout = execSync(command, { encoding: "utf-8" });
// const availablePlugins = JSON.parse(stdout.trim());

// Load the plugins list from JSON file
const pluginsFilePath = path.resolve(__dirname, '../../../pluginsList.json');
const pluginsData = fs.readFileSync(pluginsFilePath, { encoding: 'utf-8' });
const availablePlugins = JSON.parse(pluginsData);

// Map to the format expected by the UI
const pluginNames = availablePlugins.map((plugin: { value: any; name: any; description: any }) => ({
value: plugin.value,
Name: plugin.name.split("plugins-")[1],
Description: plugin.description,
}));


let pkgPath = path.join(cwd(), "package.json");
pluginsList = existsSync(pkgPath)
? JSON.parse(readFileSync(pkgPath, { encoding: "utf-8" })).dependencies
Expand All @@ -612,16 +639,6 @@ const update = program
}

// console.log(pluginsList)
const availablePlugins = JSON.parse(stdout.trim());

const pluginNames = availablePlugins.map(
(plugin: { value: string; name: string; description: string }) => ({
value: plugin.name,
Name: plugin.name.split("plugins-")[1],
Description: plugin.description,
})
);

const commonPlugins = pluginNames.filter(
(plugin: any) => pluginsList[plugin.value]
);
Expand All @@ -631,7 +648,7 @@ const update = program
const tableCheckboxPrompt = {
type: "search-table",
name: "gsPlugin",
message: "Please select godspeed plugin to install:",
message: "Please select godspeed plugin to update:",
wordWrap: true,
pageSize: 5,
searchable: true,
Expand Down
Loading