Versie 0.2.0
This commit is contained in:
commit
e77d8fd373
495 files changed
+81026
No files matched your search
@@ -0,0 +1,24 @@
|
||||
// Generated, do not edit. sha256:446976735f7157c5e0705294189119a2714fb95130e9b9374ed76421fa83e2f5
|
||||
import { writeFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { CONFIG } from '../../shared/config.js';
|
||||
import { parseLicense, verifySignature, coversVersion, appVersion } from '../license.mjs';
|
||||
import { installDir } from '../portfolios.mjs';
|
||||
import { fail } from '../../shared/app-error.js';
|
||||
|
||||
export async function installLicense(text) {
|
||||
let parsed;
|
||||
try {
|
||||
parsed = parseLicense(String(text ?? ''));
|
||||
} catch (err) {
|
||||
fail('license.installUnreadable', { reason: err.message }, `This is not a valid licence file: ${err.message}`);
|
||||
}
|
||||
if (!verifySignature(parsed)) {
|
||||
fail('license.installBadSignature', null, 'The signature does not belong to this licence, or it was not issued for this app.');
|
||||
}
|
||||
|
||||
writeFileSync(join(installDir(), CONFIG.LICENSE.FILE_NAME), `${JSON.stringify(parsed, null, 2)}\n`);
|
||||
|
||||
const version = appVersion();
|
||||
return { license: parsed.license, version, covers: coversVersion(parsed.license, version) };
|
||||
}
|
||||
Reference in new issue
Block a user