feat: Filter out enterprise apps if there is no ee license
This commit is contained in:
@@ -5,6 +5,7 @@ import cloneDeep from 'lodash/cloneDeep.js';
|
|||||||
import addAuthenticationSteps from './add-authentication-steps.js';
|
import addAuthenticationSteps from './add-authentication-steps.js';
|
||||||
import addReconnectionSteps from './add-reconnection-steps.js';
|
import addReconnectionSteps from './add-reconnection-steps.js';
|
||||||
import { fileURLToPath, pathToFileURL } from 'url';
|
import { fileURLToPath, pathToFileURL } from 'url';
|
||||||
|
import { hasValidLicense } from './license.ee.js';
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
@@ -13,9 +14,14 @@ const apps = fs
|
|||||||
.reduce((apps, dirent) => {
|
.reduce((apps, dirent) => {
|
||||||
if (!dirent.isDirectory()) return apps;
|
if (!dirent.isDirectory()) return apps;
|
||||||
|
|
||||||
apps[dirent.name] = import(
|
const indexPath = join(__dirname, '../apps', dirent.name, 'index.js');
|
||||||
pathToFileURL(join(__dirname, '../apps', dirent.name, 'index.js'))
|
const indexEePath = join(__dirname, '../apps', dirent.name, 'index.ee.js');
|
||||||
);
|
|
||||||
|
if (fs.existsSync(indexEePath) && hasValidLicense()) {
|
||||||
|
apps[dirent.name] = import(pathToFileURL(indexEePath));
|
||||||
|
} else {
|
||||||
|
apps[dirent.name] = import(pathToFileURL(indexPath));
|
||||||
|
}
|
||||||
|
|
||||||
return apps;
|
return apps;
|
||||||
}, {});
|
}, {});
|
||||||
@@ -85,10 +91,8 @@ const addStaticSubsteps = (stepType, appData, step) => {
|
|||||||
arguments: step.arguments,
|
arguments: step.arguments,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
computedStep.substeps.push(testStep(stepType));
|
computedStep.substeps.push(testStep(stepType));
|
||||||
|
|
||||||
return computedStep;
|
return computedStep;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default getApp;
|
export default getApp;
|
||||||
|
|||||||
@@ -3,26 +3,45 @@ import path, { join } from 'path';
|
|||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import appInfoConverter from '../helpers/app-info-converter.js';
|
import appInfoConverter from '../helpers/app-info-converter.js';
|
||||||
import getApp from '../helpers/get-app.js';
|
import getApp from '../helpers/get-app.js';
|
||||||
|
import { hasValidLicense } from '../helpers/license.ee.js';
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
static folderPath = join(__dirname, '../apps');
|
static folderPath = join(__dirname, '../apps');
|
||||||
|
|
||||||
static list = fs
|
static async list() {
|
||||||
.readdirSync(this.folderPath)
|
const directories = fs
|
||||||
.filter((file) => fs.statSync(join(this.folderPath, file)).isDirectory());
|
.readdirSync(this.folderPath)
|
||||||
|
.filter((file) => fs.statSync(join(this.folderPath, file)).isDirectory());
|
||||||
|
|
||||||
|
if (!(await hasValidLicense())) {
|
||||||
|
// Filter out enterprise apps if no valid license
|
||||||
|
const nonEnterpriseApps = [];
|
||||||
|
|
||||||
|
for (const dir of directories) {
|
||||||
|
const appData = await getApp(dir, true);
|
||||||
|
if (!appData.enterprise) {
|
||||||
|
nonEnterpriseApps.push(dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nonEnterpriseApps;
|
||||||
|
}
|
||||||
|
|
||||||
|
return directories;
|
||||||
|
}
|
||||||
|
|
||||||
static async findAll(name, stripFuncs = true) {
|
static async findAll(name, stripFuncs = true) {
|
||||||
|
const appList = await this.list();
|
||||||
|
|
||||||
if (!name)
|
if (!name)
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
this.list.map(
|
appList.map(async (name) => await this.findOneByName(name, stripFuncs))
|
||||||
async (name) => await this.findOneByName(name, stripFuncs)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
this.list
|
appList
|
||||||
.filter((app) => app.includes(name.toLowerCase()))
|
.filter((app) => app.includes(name.toLowerCase()))
|
||||||
.map((name) => this.findOneByName(name, stripFuncs))
|
.map((name) => this.findOneByName(name, stripFuncs))
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user