@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.
Files changed (3) hide show
  1. package/README.md +10 -0
  2. package/index.js +13 -11
  3. 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
- const os = require("os");
2
- const path = require("path");
3
- const { v4: uuidv4 } = require("uuid");
4
- const readJson = require("load-json-file");
5
- const writeJson = require("write-json-file");
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
- module.exports.globalConfig = {
10
+ export const globalConfig = {
10
11
  __globalConfig: null,
11
12
  get(key) {
12
13
  try {
13
14
  if (!this.__globalConfig) {
14
- this.__globalConfig = readJson.sync(GLOBAL_CONFIG_PATH);
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 (e) {
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
- newUser: true
29
+ // Also, in CI environments, we always set this to `false`.
30
+ newUser: isCI ? false : true
29
31
  };
30
- writeJson.sync(GLOBAL_CONFIG_PATH, this.__globalConfig);
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
- writeJson.sync(GLOBAL_CONFIG_PATH, globalConfig);
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-beta.0",
3
+ "version": "6.0.0-rc.0",
4
+ "type": "module",
4
5
  "main": "index.js",
5
6
  "license": "MIT",
6
7
  "dependencies": {
7
- "load-json-file": "6.2.0",
8
- "uuid": "8.3.2",
9
- "write-json-file": "4.3.0"
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": "aa8dbfbbd5ad13ec271adba6f2431e02991a300f"
17
+ "gitHead": "0f2aa699f4642e550ab62c96fcd050e8d02345c9"
16
18
  }