@gluestack/framework
Advanced tools
Comparing version 0.0.4 to 0.0.5
const { fileExists } = require('../helpers/file'); | ||
const getPlugin = require('../helpers/getPlugin'); | ||
const { success, error } = require('../helpers/print'); | ||
@@ -21,12 +22,2 @@ | ||
async function getPlugin(currentDir) { | ||
try { | ||
const { GlueStackPlugin } = require(`${currentDir}`); | ||
return new GlueStackPlugin(); | ||
} catch (e) { | ||
error('Plugin not initialized'); | ||
process.exit(0); | ||
} | ||
} | ||
module.exports = async () => { | ||
@@ -37,5 +28,5 @@ const currentDir = process.cwd(); | ||
const plugin = await getPlugin(currentDir); | ||
const plugin = await getPlugin(currentDir, true); | ||
success(`${packageJson.name} is at v${plugin.getVersion()}`); | ||
}; |
@@ -7,2 +7,3 @@ const commands = () => { | ||
require('./plugin-version'), | ||
require('./plugin-list'), | ||
require('./install'), | ||
@@ -9,0 +10,0 @@ ]; |
27
glue.js
#!/usr/bin/env node | ||
const commander = require('./helpers/commander'); | ||
const app = require('./lib/app'); | ||
const { bootPlugins } = require('./helpers/meta/plugins'); | ||
const { init, addCommands, close } = require('./helpers/commander'); | ||
class App { | ||
constructor(commander) { | ||
this.cli = commander; | ||
} | ||
populatePlugins(plugins) { | ||
this.plugins = plugins; | ||
} | ||
} | ||
const commanderInit = async () => { | ||
const commanderInit = async (app) => { | ||
// initialise the commander | ||
await commander.init(); | ||
await init(); | ||
// register commands to the commander | ||
await commander.addCommands(); | ||
await addCommands(app); | ||
// close commander | ||
await commander.close(); | ||
await close(); | ||
}; | ||
const initApp = async () => { | ||
return new App(commander); | ||
}; | ||
const glue = async () => { | ||
// initialise the commander | ||
const app = await initApp(commander); | ||
// initialise the commander | ||
app.populatePlugins(await bootPlugins()); | ||
@@ -36,0 +21,0 @@ |
@@ -21,11 +21,7 @@ const { Command } = require('commander'); | ||
// adds all the commands from the directory | ||
commander.addCommands = async () => { | ||
commander.addCommands = async (app) => { | ||
commands().forEach((cmd) => cmd(program)); | ||
app.commands.forEach((cmd) => cmd(program)); | ||
}; | ||
// adds all the commands from the directory | ||
commander.addCommand = async (program) => { | ||
return cmd(program); | ||
}; | ||
// parses and closes the command | ||
@@ -32,0 +28,0 @@ commander.close = async () => { |
@@ -0,1 +1,2 @@ | ||
const getPlugin = require('./getPlugin'); | ||
const { info } = require('./print'); | ||
@@ -19,8 +20,2 @@ const exec = require('child_process').exec; | ||
async function getPlugin(packageName) { | ||
let dir = `${process.cwd()}/node_modules/${packageName}`; | ||
const { GlueStackPlugin } = require(`${dir}`); | ||
return new GlueStackPlugin(); | ||
} | ||
module.exports = async ( | ||
@@ -37,3 +32,5 @@ serviceName, | ||
const plugin = await getPlugin(packageName); | ||
const plugin = await getPlugin( | ||
`${process.cwd()}/node_modules/${packageName}` | ||
); | ||
await plugin.runPostInstall(folderName); | ||
@@ -40,0 +37,0 @@ |
const { readFile, writeFile } = require('../file'); | ||
const getPlugin = require('../getPlugin'); | ||
@@ -40,12 +41,5 @@ const writePlugin = async ( | ||
return data.filter((item) => { | ||
try { | ||
const { | ||
GlueStackPlugin, | ||
} = require(`${projectPath}/${item.package}`); | ||
const plugin = new GlueStackPlugin(); | ||
plugin.runBootstrap(); | ||
} catch (e) { | ||
// | ||
} | ||
return data.filter(async (item) => { | ||
const plugin = await getPlugin(`${projectPath}/${item.package}`); | ||
plugin.runBootstrap(); | ||
}); | ||
@@ -52,0 +46,0 @@ }; |
{ | ||
"name": "@gluestack/framework", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Framework code of gluestack", | ||
@@ -5,0 +5,0 @@ "main": "glue.js", |
@@ -8,2 +8,7 @@ import IGlueStackPlugin from '@gluestack/framework/types/plugin/interface'; | ||
name: string = 'My Plugin'; | ||
app: any = null; | ||
constructor(app: any) { | ||
this.app = app; | ||
} | ||
@@ -10,0 +15,0 @@ getVersion(): string { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
28583
52
911
12
10