@scaleway/configuration-loader 1.0.0 → 1.0.2

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 1.0.2 (2024-02-15)
7
+
8
+ **Note:** Version bump only for package @scaleway/configuration-loader
9
+
10
+ ## 1.0.1 (2024-02-05)
11
+
12
+ **Note:** Version bump only for package @scaleway/configuration-loader
13
+
6
14
  ## 1.0.0 (2023-02-21)
7
15
 
8
16
  ### Features
@@ -42,7 +42,7 @@ const loadProfileFromEnvironmentValues = () => ({
42
42
  * @public
43
43
  */
44
44
  const loadAllProfilesFromConfigurationFile = params => {
45
- const filePath = (params == null ? void 0 : params.filepath) ?? resolveConfigurationFilePath();
45
+ const filePath = params?.filepath ?? resolveConfigurationFilePath();
46
46
  if (typeof filePath !== 'string' || filePath.length === 0) {
47
47
  throw new Error('Could not find the path to the configuration file.');
48
48
  }
@@ -67,7 +67,7 @@ const loadAllProfilesFromConfigurationFile = params => {
67
67
  */
68
68
  const loadProfileFromConfigurationFile = params => {
69
69
  const configs = loadAllProfilesFromConfigurationFile(params);
70
- const profileName = (params == null ? void 0 : params.profileName) ?? 'default';
70
+ const profileName = params?.profileName ?? 'default';
71
71
  const profileMap = configs[profileName];
72
72
  if (typeof profileMap !== 'object') {
73
73
  throw new Error(`Could not find the desired profile '${profileName}' in the configuration file.`);
package/dist/env.js CHANGED
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * Environment Key.
3
3
  */
4
- let EnvironmentKey;
5
- (function (EnvironmentKey) {
4
+ let EnvironmentKey = /*#__PURE__*/function (EnvironmentKey) {
6
5
  EnvironmentKey["ScwConfigPath"] = "SCW_CONFIG_PATH";
7
6
  EnvironmentKey["ScwAccessKey"] = "SCW_ACCESS_KEY";
8
7
  EnvironmentKey["ScwSecretKey"] = "SCW_SECRET_KEY";
@@ -11,6 +10,7 @@ let EnvironmentKey;
11
10
  EnvironmentKey["ScwDefaultProjectId"] = "SCW_DEFAULT_PROJECT_ID";
12
11
  EnvironmentKey["ScwDefaultRegion"] = "SCW_DEFAULT_REGION";
13
12
  EnvironmentKey["ScwDefaultZone"] = "SCW_DEFAULT_ZONE";
14
- })(EnvironmentKey || (EnvironmentKey = {}));
13
+ return EnvironmentKey;
14
+ }({});
15
15
 
16
16
  export { EnvironmentKey };
package/dist/index.cjs CHANGED
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var process = require('process');
4
- var os = require('os');
5
- var path = require('path');
4
+ var node_os = require('node:os');
5
+ var path = require('node:path');
6
+ var node_process = require('node:process');
6
7
  var fs = require('fs');
7
8
 
8
9
  function _interopNamespaceDefault(e) {
@@ -27,8 +28,7 @@ var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
27
28
  /**
28
29
  * Environment Key.
29
30
  */
30
- let EnvironmentKey;
31
- (function (EnvironmentKey) {
31
+ let EnvironmentKey = /*#__PURE__*/function (EnvironmentKey) {
32
32
  EnvironmentKey["ScwConfigPath"] = "SCW_CONFIG_PATH";
33
33
  EnvironmentKey["ScwAccessKey"] = "SCW_ACCESS_KEY";
34
34
  EnvironmentKey["ScwSecretKey"] = "SCW_SECRET_KEY";
@@ -37,7 +37,8 @@ let EnvironmentKey;
37
37
  EnvironmentKey["ScwDefaultProjectId"] = "SCW_DEFAULT_PROJECT_ID";
38
38
  EnvironmentKey["ScwDefaultRegion"] = "SCW_DEFAULT_REGION";
39
39
  EnvironmentKey["ScwDefaultZone"] = "SCW_DEFAULT_ZONE";
40
- })(EnvironmentKey || (EnvironmentKey = {}));
40
+ return EnvironmentKey;
41
+ }({});
41
42
 
42
43
  /**
43
44
  * Gets the Scaleway directory.
@@ -47,11 +48,11 @@ let EnvironmentKey;
47
48
  * @internal
48
49
  */
49
50
  const getScwConfigurationDirectory = () => {
50
- const xdgConfigPath = process.env.XDG_CONFIG_HOME;
51
+ const xdgConfigPath = node_process.env.XDG_CONFIG_HOME;
51
52
  if (typeof xdgConfigPath === 'string' && xdgConfigPath.length > 0) {
52
53
  return path__namespace.join(xdgConfigPath, 'scw');
53
54
  }
54
- return path__namespace.join(os.homedir(), '.config', 'scw');
55
+ return path__namespace.join(node_os.homedir(), '.config', 'scw');
55
56
  };
56
57
 
57
58
  /**
@@ -63,7 +64,7 @@ const getScwConfigurationDirectory = () => {
63
64
  */
64
65
  const resolveConfigurationFilePath = () => {
65
66
  // Try path defined by user in env variables
66
- const envFilePath = process.env[EnvironmentKey.ScwConfigPath];
67
+ const envFilePath = node_process.env[EnvironmentKey.ScwConfigPath];
67
68
  if (typeof envFilePath === 'string' && envFilePath.length > 0) {
68
69
  return envFilePath;
69
70
  }
package/dist/index.d.ts CHANGED
@@ -4,65 +4,66 @@
4
4
  * @public
5
5
  */
6
6
  type Profile = {
7
- /**
8
- * You need an access key and a secret key to connect to Scaleway API.
9
- * Generate your token at the following address: {@link https://console.scaleway.com/project/credentials}
10
- */
11
- accessKey?: string;
12
- /**
13
- * APIURL overrides the API URL of the Scaleway API to the given URL.
14
- * Change that if you want to direct requests to a different endpoint.
15
- *
16
- * @defaultValue `https://api.scaleway.com`
17
- */
18
- apiURL?: string;
19
- /**
20
- * Your organization ID is the identifier of your account inside Scaleway infrastructure.
21
- */
22
- defaultOrganizationId?: string;
23
- /**
24
- * Your project ID is the identifier of the project your resources are attached to.
25
- */
26
- defaultProjectId?: string;
27
- /**
28
- * A region is represented as a geographical area such as France (Paris) or the Netherlands (Amsterdam).
29
- * It can contain multiple availability zones.
30
- *
31
- * Examples: fr-par, nl-ams.
32
- */
33
- defaultRegion?: string;
34
- /**
35
- * A region can be split into many availability zones (AZ).
36
- * Latency between multiple AZ of the same region are low as they have a common network layer.
37
- *
38
- * Examples: fr-par-1, nl-ams-1
39
- */
40
- defaultZone?: string;
41
- /**
42
- * The secret key is the value that can be used to authenticate against the API (the value used in X-Auth-Token HTTP-header).
43
- * The secret key MUST remain secret and not given to anyone or published online.
44
- */
45
- secretKey?: string;
46
- };
7
+ /**
8
+ * You need an access key and a secret key to connect to Scaleway API.
9
+ * Generate your token at the following address: {@link https://console.scaleway.com/project/credentials}
10
+ */
11
+ accessKey?: string
12
+ /**
13
+ * APIURL overrides the API URL of the Scaleway API to the given URL.
14
+ * Change that if you want to direct requests to a different endpoint.
15
+ *
16
+ * @defaultValue `https://api.scaleway.com`
17
+ */
18
+ apiURL?: string
19
+ /**
20
+ * Your organization ID is the identifier of your account inside Scaleway infrastructure.
21
+ */
22
+ defaultOrganizationId?: string
23
+ /**
24
+ * Your project ID is the identifier of the project your resources are attached to.
25
+ */
26
+ defaultProjectId?: string
27
+ /**
28
+ * A region is represented as a geographical area such as France (Paris) or the Netherlands (Amsterdam).
29
+ * It can contain multiple availability zones.
30
+ *
31
+ * Examples: fr-par, nl-ams.
32
+ */
33
+ defaultRegion?: string
34
+ /**
35
+ * A region can be split into many availability zones (AZ).
36
+ * Latency between multiple AZ of the same region are low as they have a common network layer.
37
+ *
38
+ * Examples: fr-par-1, nl-ams-1
39
+ */
40
+ defaultZone?: string
41
+ /**
42
+ * The secret key is the value that can be used to authenticate against the API (the value used in X-Auth-Token HTTP-header).
43
+ * The secret key MUST remain secret and not given to anyone or published online.
44
+ */
45
+ secretKey?: string
46
+ }
47
47
  /** Parameters to load the all the profiles from the configuration file */
48
48
  type AllProfilesFromFileParams = {
49
- /**
50
- * The path at which to locate the configuration file.
51
- *
52
- * Defaults to the value of the `SCW_CONFIG_PATH` environment variable
53
- * or `~/.scw/config` otherwise.
54
- */
55
- filepath?: string;
56
- };
49
+ /**
50
+ * The path at which to locate the configuration file.
51
+ *
52
+ * Defaults to the value of the `SCW_CONFIG_PATH` environment variable
53
+ * or `~/.scw/config` otherwise.
54
+ */
55
+ filepath?: string
56
+ }
57
+
57
58
  /** Parameters to load the profile from the configuration file */
58
59
  type ProfileFromFileParams = AllProfilesFromFileParams & {
59
- /**
60
- * Name of the profile to load.
61
- *
62
- * @defaultValue `default`
63
- * */
64
- profileName?: 'default' | string;
65
- };
60
+ /**
61
+ * Name of the profile to load.
62
+ *
63
+ * @defaultValue `default`
64
+ * */
65
+ profileName?: 'default' | string
66
+ }
66
67
 
67
68
  /**
68
69
  * Loads profile from environment values.
@@ -98,4 +99,4 @@ declare const loadAllProfilesFromConfigurationFile: (params?: Readonly<AllProfil
98
99
  */
99
100
  declare const loadProfileFromConfigurationFile: (params?: Readonly<ProfileFromFileParams>) => Profile;
100
101
 
101
- export { AllProfilesFromFileParams, Profile, ProfileFromFileParams, loadAllProfilesFromConfigurationFile, loadProfileFromConfigurationFile, loadProfileFromEnvironmentValues };
102
+ export { type AllProfilesFromFileParams, type Profile, type ProfileFromFileParams, loadAllProfilesFromConfigurationFile, loadProfileFromConfigurationFile, loadProfileFromEnvironmentValues };
@@ -1,6 +1,6 @@
1
- import { homedir } from 'os';
2
- import * as path from 'path';
3
- import { env } from 'process';
1
+ import { homedir } from 'node:os';
2
+ import * as path from 'node:path';
3
+ import { env } from 'node:process';
4
4
  import { EnvironmentKey } from './env.js';
5
5
 
6
6
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleway/configuration-loader",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Load configuration via file or environment for NodeJS.",
6
6
  "main": "dist/index.cjs",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "type": "module",
21
21
  "devDependencies": {
22
- "@types/node": "^18.11.18"
22
+ "@types/node": "18.11.18"
23
23
  },
24
- "gitHead": "53da2037e927cabe7f148ea2555a8ad590a6a375"
24
+ "gitHead": "a1535f4aee99d01c72320ba30cc9416b254175d2"
25
25
  }