mirror of
https://github.com/nocobase/nocobase.git
synced 2026-10-24 01:43:57 +08:00
* fix: license validate tips * fix: create license utils * fix: add log to system.log * fix: addep * fix: remove logger * fix: cli add logger * fix: code clean * fix: adjust message * fix: add env test case * fix: change plugin-commerical build * fix: improve cli logs * fix: log format in file * fix: code clean * fix: adjust save key message * fix: plugin-commerical build * fix: license import error * fix: change commerical build * fix: perfect cli instance logs * fix: build commerical error * fix: update cache key * fix: support license invalid status * fix: show doc url in key * fix: remove the domain of service * fix: support plugins get * fix: change prompt * fix: change prompt * fix: improve tips * fix: change key setting * fix: key setting refresh * fix: show license info in setting page * fix: remove license card item title * fix: labels * fix: change license kit version * fix: remove license-kit dep
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
/**
|
|
* This file is part of the NocoBase (R) project.
|
|
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
* Authors: NocoBase Team.
|
|
*
|
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
*/
|
|
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import { exec } from 'child_process';
|
|
|
|
export async function getInstanceId() {
|
|
const dir = path.resolve(process.cwd(), 'storage/.license');
|
|
const filePath = path.resolve(dir, 'instance-id');
|
|
await createInstanceId(true);
|
|
const id = fs.readFileSync(filePath, 'utf-8');
|
|
return id;
|
|
}
|
|
|
|
export async function createInstanceId(force = false) {
|
|
return new Promise((resolve, reject) => {
|
|
exec(`yarn nocobase generate-instance-id ${force ? '--force' : ''}`, (err, stdout, stderr) => {
|
|
if (err) {
|
|
reject(err);
|
|
return;
|
|
}
|
|
resolve(stdout);
|
|
});
|
|
});
|
|
}
|
|
|
|
export async function isLicenseKeyExists() {
|
|
const dir = path.resolve(process.cwd(), 'storage/.license');
|
|
const filePath = path.resolve(dir, 'license-key');
|
|
return fs.existsSync(filePath);
|
|
}
|