@webiny/global-config 6.0.0-beta.0 β 6.0.0-rc.0
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/README.md +10 -0
- package/index.js +13 -11
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
1
|
# @webiny/global-config
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> Itβs **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
6
|
+
|
|
7
|
+
π **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
package/index.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import os from "os";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { v4 as uuidv4 } from "uuid";
|
|
4
|
+
import { loadJsonFileSync } from "load-json-file";
|
|
5
|
+
import { writeJsonFileSync } from "write-json-file";
|
|
6
|
+
import { isCI } from "ci-info";
|
|
6
7
|
|
|
7
8
|
const GLOBAL_CONFIG_PATH = path.join(os.homedir(), ".webiny", "config");
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
export const globalConfig = {
|
|
10
11
|
__globalConfig: null,
|
|
11
12
|
get(key) {
|
|
12
13
|
try {
|
|
13
14
|
if (!this.__globalConfig) {
|
|
14
|
-
this.__globalConfig =
|
|
15
|
+
this.__globalConfig = loadJsonFileSync(GLOBAL_CONFIG_PATH);
|
|
15
16
|
if (!this.__globalConfig.id) {
|
|
16
17
|
throw Error("Invalid Webiny config!");
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
|
-
} catch
|
|
20
|
+
} catch {
|
|
20
21
|
// A new config file is written if it doesn't exist or is invalid.
|
|
21
22
|
this.__globalConfig = {
|
|
22
23
|
id: uuidv4(),
|
|
@@ -25,9 +26,10 @@ module.exports.globalConfig = {
|
|
|
25
26
|
// This flag is set to `false` the moment user successfully
|
|
26
27
|
// deploys a Webiny project for the first time. Once they do,
|
|
27
28
|
// they're considered no longer a "new user".
|
|
28
|
-
|
|
29
|
+
// Also, in CI environments, we always set this to `false`.
|
|
30
|
+
newUser: isCI ? false : true
|
|
29
31
|
};
|
|
30
|
-
|
|
32
|
+
writeJsonFileSync(GLOBAL_CONFIG_PATH, this.__globalConfig);
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
return key ? this.__globalConfig[key] : this.__globalConfig;
|
|
@@ -35,7 +37,7 @@ module.exports.globalConfig = {
|
|
|
35
37
|
set(key, value) {
|
|
36
38
|
const globalConfig = this.get();
|
|
37
39
|
globalConfig[key] = value;
|
|
38
|
-
|
|
40
|
+
writeJsonFileSync(GLOBAL_CONFIG_PATH, globalConfig);
|
|
39
41
|
return globalConfig;
|
|
40
42
|
}
|
|
41
43
|
};
|
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/global-config",
|
|
3
|
-
"version": "6.0.0-
|
|
3
|
+
"version": "6.0.0-rc.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"main": "index.js",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"dependencies": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"ci-info": "4.4.0",
|
|
9
|
+
"load-json-file": "7.0.1",
|
|
10
|
+
"uuid": "13.0.0",
|
|
11
|
+
"write-json-file": "7.0.0"
|
|
10
12
|
},
|
|
11
13
|
"publishConfig": {
|
|
12
14
|
"access": "public",
|
|
13
15
|
"directory": "."
|
|
14
16
|
},
|
|
15
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "0f2aa699f4642e550ab62c96fcd050e8d02345c9"
|
|
16
18
|
}
|