mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
feat(core): Add license:info command (#6047)
* feat(core): Add license:info command * revert changes to start.ts * revert changes to start.ts * fix typo
This commit is contained in:
committed by
GitHub
parent
54f99a7d0d
commit
ab12d3e327
@@ -12,34 +12,6 @@ import {
|
||||
} from './constants';
|
||||
import { Service } from 'typedi';
|
||||
|
||||
async function loadCertStr(): Promise<TLicenseBlock> {
|
||||
// if we have an ephemeral license, we don't want to load it from the database
|
||||
const ephemeralLicense = config.get('license.cert');
|
||||
if (ephemeralLicense) {
|
||||
return ephemeralLicense;
|
||||
}
|
||||
const databaseSettings = await Db.collections.Settings.findOne({
|
||||
where: {
|
||||
key: SETTINGS_LICENSE_CERT_KEY,
|
||||
},
|
||||
});
|
||||
|
||||
return databaseSettings?.value ?? '';
|
||||
}
|
||||
|
||||
async function saveCertStr(value: TLicenseBlock): Promise<void> {
|
||||
// if we have an ephemeral license, we don't want to save it to the database
|
||||
if (config.get('license.cert')) return;
|
||||
await Db.collections.Settings.upsert(
|
||||
{
|
||||
key: SETTINGS_LICENSE_CERT_KEY,
|
||||
value,
|
||||
loadOnStartup: false,
|
||||
},
|
||||
['key'],
|
||||
);
|
||||
}
|
||||
|
||||
@Service()
|
||||
export class License {
|
||||
private logger: ILogger;
|
||||
@@ -67,8 +39,8 @@ export class License {
|
||||
autoRenewEnabled,
|
||||
autoRenewOffset,
|
||||
logger: this.logger,
|
||||
loadCertStr,
|
||||
saveCertStr,
|
||||
loadCertStr: async () => this.loadCertStr(),
|
||||
saveCertStr: async (value: TLicenseBlock) => this.saveCertStr(value),
|
||||
deviceFingerprint: () => instanceId,
|
||||
});
|
||||
|
||||
@@ -80,6 +52,34 @@ export class License {
|
||||
}
|
||||
}
|
||||
|
||||
async loadCertStr(): Promise<TLicenseBlock> {
|
||||
// if we have an ephemeral license, we don't want to load it from the database
|
||||
const ephemeralLicense = config.get('license.cert');
|
||||
if (ephemeralLicense) {
|
||||
return ephemeralLicense;
|
||||
}
|
||||
const databaseSettings = await Db.collections.Settings.findOne({
|
||||
where: {
|
||||
key: SETTINGS_LICENSE_CERT_KEY,
|
||||
},
|
||||
});
|
||||
|
||||
return databaseSettings?.value ?? '';
|
||||
}
|
||||
|
||||
async saveCertStr(value: TLicenseBlock): Promise<void> {
|
||||
// if we have an ephemeral license, we don't want to save it to the database
|
||||
if (config.get('license.cert')) return;
|
||||
await Db.collections.Settings.upsert(
|
||||
{
|
||||
key: SETTINGS_LICENSE_CERT_KEY,
|
||||
value,
|
||||
loadOnStartup: false,
|
||||
},
|
||||
['key'],
|
||||
);
|
||||
}
|
||||
|
||||
async activate(activationKey: string): Promise<void> {
|
||||
if (!this.manager) {
|
||||
return;
|
||||
@@ -185,4 +185,12 @@ export class License {
|
||||
getPlanName(): string {
|
||||
return (this.getFeatureValue('planName') ?? 'Community') as string;
|
||||
}
|
||||
|
||||
getInfo(): string {
|
||||
if (!this.manager) {
|
||||
return 'n/a';
|
||||
}
|
||||
|
||||
return this.manager.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user