editmamei 0.17.4 → 0.17.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,20 +1,59 @@
|
|
|
1
1
|
import { Logger } from '../utils/logger.js';
|
|
2
2
|
import { readLicense } from './store.js';
|
|
3
|
-
import { activate } from './entitlement.js';
|
|
3
|
+
import { activate, isProEntitled } from './entitlement.js';
|
|
4
|
+
import { provisionModules } from '../delivery/provision.js';
|
|
5
|
+
import { readInstalledModule, PRO_SKU } from '../delivery/store.js';
|
|
4
6
|
const logger = new Logger('License');
|
|
5
|
-
|
|
7
|
+
const PROVISION_BOOT_TIMEOUT_MS = 20_000;
|
|
8
|
+
export async function maybeActivateFromEnv(env = process.env, ops = {}, delivery = {}) {
|
|
6
9
|
const key = (env.EDITMAMEI_LICENSE_KEY ?? '').trim();
|
|
7
10
|
if (!key)
|
|
8
11
|
return;
|
|
9
12
|
const cached = readLicense(ops);
|
|
10
|
-
if (cached
|
|
11
|
-
|
|
13
|
+
if (!cached || cached.key !== key) {
|
|
14
|
+
try {
|
|
15
|
+
await activate(key, ops);
|
|
16
|
+
logger.info('Activated Pro from EDITMAMEI_LICENSE_KEY.');
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
logger.warn(`Could not activate from EDITMAMEI_LICENSE_KEY (continuing as Community): ` +
|
|
20
|
+
`${err instanceof Error ? err.message : String(err)}`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
12
24
|
try {
|
|
13
|
-
|
|
14
|
-
|
|
25
|
+
if (isProEntitled(ops) && !readInstalledModule(PRO_SKU, ops)) {
|
|
26
|
+
const provisioning = provisionModules(key, {
|
|
27
|
+
dir: ops.dir,
|
|
28
|
+
now: ops.now,
|
|
29
|
+
config: delivery.config,
|
|
30
|
+
fetchImpl: delivery.fetchImpl,
|
|
31
|
+
sleep: delivery.sleep,
|
|
32
|
+
signingKeys: delivery.signingKeys,
|
|
33
|
+
});
|
|
34
|
+
provisioning.catch(() => { });
|
|
35
|
+
let timer;
|
|
36
|
+
const deadline = new Promise((resolve) => {
|
|
37
|
+
timer = setTimeout(() => resolve(null), delivery.bootTimeoutMs ?? PROVISION_BOOT_TIMEOUT_MS);
|
|
38
|
+
timer.unref?.();
|
|
39
|
+
});
|
|
40
|
+
const prov = await Promise.race([provisioning, deadline]);
|
|
41
|
+
if (timer)
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
if (!prov) {
|
|
44
|
+
logger.warn('Pro module provisioning did not finish in time — continuing as Community; the next start retries.');
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
for (const m of prov.installed)
|
|
48
|
+
logger.info(`Installed ${m.sku} module v${m.version}.`);
|
|
49
|
+
for (const e of prov.errors) {
|
|
50
|
+
logger.warn(`Could not provision the ${e.sku} module (Pro stays dark): ${e.message}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
15
54
|
}
|
|
16
55
|
catch (err) {
|
|
17
|
-
logger.warn(`
|
|
56
|
+
logger.warn(`Pro module provisioning failed (continuing without Pro): ` +
|
|
18
57
|
`${err instanceof Error ? err.message : String(err)}`);
|
|
19
58
|
}
|
|
20
59
|
}
|
|
Binary file
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.17.
|
|
1
|
+
export const VERSION = '0.17.5';
|