moontraze 1.0.3 → 1.0.4
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.
- package/lib/config.js +14 -3
- package/package.json +1 -1
package/lib/config.js
CHANGED
|
@@ -17,12 +17,23 @@ const DEFAULTS = {
|
|
|
17
17
|
domain: process.env.MOONTRAZE_DOMAIN || 'moontraze.com',
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
function migrate(cfg) {
|
|
21
|
+
const next = { ...DEFAULTS, ...cfg };
|
|
22
|
+
// old frelanceo → moontraze
|
|
23
|
+
if (next.apiUrl && String(next.apiUrl).includes('frelanceo')) {
|
|
24
|
+
next.apiUrl = DEFAULTS.apiUrl;
|
|
25
|
+
}
|
|
26
|
+
if (next.domain && String(next.domain).includes('frelanceo')) {
|
|
27
|
+
next.domain = DEFAULTS.domain;
|
|
28
|
+
}
|
|
29
|
+
return next;
|
|
30
|
+
}
|
|
31
|
+
|
|
20
32
|
function getConfig() {
|
|
21
33
|
try {
|
|
22
34
|
if (fs.existsSync(GLOBAL_FILE)) {
|
|
23
35
|
const saved = JSON.parse(fs.readFileSync(GLOBAL_FILE, 'utf8'));
|
|
24
|
-
|
|
25
|
-
return { ...DEFAULTS, ...saved };
|
|
36
|
+
return migrate(saved);
|
|
26
37
|
}
|
|
27
38
|
} catch (_) {}
|
|
28
39
|
return { ...DEFAULTS };
|
|
@@ -30,7 +41,7 @@ function getConfig() {
|
|
|
30
41
|
|
|
31
42
|
function setConfig(partial) {
|
|
32
43
|
ensureDir(GLOBAL_DIR);
|
|
33
|
-
const next = { ...getConfig(), ...partial };
|
|
44
|
+
const next = migrate({ ...getConfig(), ...partial });
|
|
34
45
|
fs.writeFileSync(GLOBAL_FILE, JSON.stringify(next, null, 2));
|
|
35
46
|
return next;
|
|
36
47
|
}
|