Skip to content

Commit 6aa6055

Browse files
committed
fix: fix plugin installation script #589
1 parent 4da2e07 commit 6aa6055

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

admin-ui/build/cli-tools.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const mkdirp = require('mkdirp');
55
const config = require('./../config');
66

77
function dirParamToPath(dirParam) {
8-
switch(dirParam) {
8+
switch (dirParam) {
99
case 'dist':
1010
return config.distDir;
1111
case 'serve':
@@ -15,20 +15,20 @@ function dirParamToPath(dirParam) {
1515
}
1616

1717
const commands = {
18-
clear: function(value) {
18+
clear: function (value) {
1919
const targetPath = dirParamToPath(value);
2020

21-
if(targetPath) {
21+
if (targetPath) {
2222
rimraf.sync(targetPath);
2323

2424
console.info('Cleared target directory: %s', targetPath);
2525
}
2626
},
2727

28-
create: function(value) {
28+
create: function (value) {
2929
const targetPath = dirParamToPath(value);
3030

31-
if(targetPath) {
31+
if (targetPath) {
3232
mkdirp.sync(targetPath);
3333

3434
console.info('Created target directory: %s', targetPath);
@@ -40,7 +40,7 @@ program
4040
.option('-c, --clear [serve/dist]')
4141
.option('-cr, --create [serve/dist]')
4242
.parse(process.argv);
43-
const options = program.opts();
43+
const options = program.opts();
4444
for (const commandName in commands) {
4545
if (commands.hasOwnProperty(commandName) && options[commandName]) {
4646
commands[commandName](options[commandName]);

admin-ui/build/plugin-cli.js

+22-22
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ const unzipper = require('unzipper')
88
const rimraf = require('rimraf')
99

1010
function dirParamToPath(dirParam) {
11-
switch(dirParam) {
12-
case 'plugins_repo':
13-
return config.pluginsRepoDir
14-
case 'plugins':
15-
return config.pluginsDir
16-
case 'rootDir':
17-
return config.rootDir
11+
switch (dirParam) {
12+
case 'plugins_repo':
13+
return config.pluginsRepoDir
14+
case 'plugins':
15+
return config.pluginsDir
16+
case 'rootDir':
17+
return config.rootDir
1818
}
1919
return null
2020
}
2121

2222
const commands = {
23-
cleanExceptDefault: function(args) {
23+
cleanExceptDefault: function (args) {
2424
let plugins = []
2525
try {
2626
plugins = args.split(',')
27-
} catch(e) {
27+
} catch (e) {
2828
console.error('The args passed is invalid or undefined. All plugins will be removed.')
2929
}
3030

31-
const pluginsDir = dirParamToPath('plugins')
31+
const pluginsDir = dirParamToPath('plugins')
3232

3333
fse.readdirSync(pluginsDir)
3434
.map(file => path.join(pluginsDir, file))
@@ -37,7 +37,7 @@ const commands = {
3737
//.filter(path => fse.readdirSync(path).length === 0)
3838
.map(path => rimraf.sync(path))
3939
},
40-
resetPluginConfig: function() {
40+
resetPluginConfig: function () {
4141
const pluginsDir = dirParamToPath('plugins')
4242
const configJson = []
4343

@@ -48,7 +48,7 @@ const commands = {
4848
.map(path => configJson.push(this.createPluginEntry(this.getLastFolderName(path))))
4949
fse.writeFileSync(path.join(dirParamToPath('rootDir'), 'plugins.config.json'), JSON.stringify(configJson, null, 2))
5050
},
51-
addPlugin: function(sourcePath) {
51+
addPlugin: function (sourcePath) {
5252
const pluginsPath = dirParamToPath('plugins')
5353

5454
if (!fse.existsSync(sourcePath)) {
@@ -70,12 +70,12 @@ const commands = {
7070
fse.writeFileSync(path.join(dirParamToPath('rootDir'), 'plugins.config.json'), JSON.stringify(pluginsObj, null, 2))
7171

7272
},
73-
removePlugin: function(pluginName) {
73+
removePlugin: function (pluginName) {
7474
try {
7575
const pluginsPath = dirParamToPath('plugins')
7676
const pluginDirName = path.dirname(pluginsObj.filter(ele => ele.key === pluginName)[0].metadataFile).replace('./', '')
7777
const pluginPathInRepo = path.join(pluginsPath, pluginDirName)
78-
78+
7979
if (fse.existsSync(pluginPathInRepo)) {
8080
rimraf.sync(pluginPathInRepo)
8181
fse.writeFileSync(
@@ -87,24 +87,24 @@ const commands = {
8787
console.error('Error in enabling plugin. Check the plugin keys entered in args.')
8888
}
8989
},
90-
createPluginEntry: function(pluginKey) {
90+
createPluginEntry: function (pluginKey) {
9191
const pluginObj = {}
9292
pluginObj.key = pluginKey
93-
pluginObj.metadataFile = './' + pluginKey+ '/plugin-metadata'
93+
pluginObj.metadataFile = './' + pluginKey + '/plugin-metadata'
9494
return pluginObj
9595
},
96-
showAllPlugins: function() {
97-
if(pluginsObj.length == 0) {
96+
showAllPlugins: function () {
97+
if (pluginsObj.length == 0) {
9898
console.log('- No Plugin in repo.')
9999
return
100100
}
101101
console.log('Following plugins are present.')
102102
pluginsObj.forEach(ele => {
103-
console.log('- '+ele.key)
103+
console.log('- ' + ele.key)
104104
})
105105
},
106-
getLastFolderName: function(path) {
107-
return path.replace(/\\/g, '/').split('/').filter(function(el) {
106+
getLastFolderName: function (path) {
107+
return path.replace(/\\/g, '/').split('/').filter(function (el) {
108108
return el.trim().length > 0
109109
}).pop()
110110
}
@@ -117,7 +117,7 @@ program
117117
.option('-ap, --addPlugin []')
118118
.option('-rp, --removePlugin []')
119119
.parse(process.argv)
120-
const options = program.opts();
120+
const options = program.opts();
121121
for (const commandName in commands) {
122122
// eslint-disable-next-line no-prototype-builtins
123123
if (commands.hasOwnProperty(commandName) && options[commandName]) {

0 commit comments

Comments
 (0)