@scaleway/configuration-loader 1.0.12 → 2.1.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.
@@ -1,23 +1,18 @@
1
1
 
2
- > @scaleway/configuration-loader@1.0.11 build /home/runner/work/scaleway-sdk-js/scaleway-sdk-js/packages/configuration-loader
2
+ > @scaleway/configuration-loader@2.1.0 build /home/runner/work/scaleway-sdk-js/scaleway-sdk-js/packages/configuration-loader
3
3
  > vite build --config ../../vite.config.ts && pnpm run type:generate
4
4
 
5
- vite v6.4.1 building SSR bundle for production...
5
+ vite v7.2.4 building ssr environment for production...
6
6
  transforming...
7
7
  ✓ 5 modules transformed.
8
8
  rendering chunks...
9
9
  dist/index.js 0.27 kB
10
10
  dist/env.js 0.62 kB
11
11
  dist/path-resolver.js 0.75 kB
12
- dist/yml-loader.js 1.26 kB
12
+ dist/yml-loader.js 1.27 kB
13
13
  dist/config-loader.js 1.93 kB
14
- dist/index.cjs 0.42 kB
15
- dist/env.cjs 0.72 kB
16
- dist/yml-loader.cjs 1.40 kB
17
- dist/path-resolver.cjs 1.47 kB
18
- dist/config-loader.cjs 2.20 kB
19
- ✓ built in 121ms
14
+ ✓ built in 136ms
20
15
 
21
- > @scaleway/configuration-loader@1.0.11 type:generate /home/runner/work/scaleway-sdk-js/scaleway-sdk-js/packages/configuration-loader
16
+ > @scaleway/configuration-loader@2.1.0 type:generate /home/runner/work/scaleway-sdk-js/scaleway-sdk-js/packages/configuration-loader
22
17
  > tsc --declaration -p tsconfig.build.json
23
18
 
package/CHANGELOG.md CHANGED
@@ -3,6 +3,26 @@
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
+ # 2.1.0 (2025-12-19)
7
+
8
+ ### Bug Fixes
9
+
10
+ - exclude generated config files from biome formatting ([#2661](https://github.com/scaleway/scaleway-sdk-js/issues/2661)) ([e6b1391](https://github.com/scaleway/scaleway-sdk-js/commit/e6b1391483b1ff41d3fcbcb40a89a7f46e934663))
11
+
12
+ ### Features
13
+
14
+ - publish packages as ESM only ([#2624](https://github.com/scaleway/scaleway-sdk-js/issues/2624)) ([8ab940d](https://github.com/scaleway/scaleway-sdk-js/commit/8ab940deadfbc8fc0d540148c51868dae63a74af))
15
+
16
+ ## 2.0.0 (2025-01-XX)
17
+
18
+ ### âš  BREAKING CHANGES
19
+
20
+ - packages are ESM only
21
+
22
+ ### :gear: Features
23
+
24
+ - publish packages as ESM only
25
+
6
26
  ## 1.0.12 (2025-10-29)
7
27
 
8
28
  **Note:** Version bump only for package @scaleway/configuration-loader
@@ -1,4 +1,4 @@
1
- import { env } from "process";
1
+ import { env } from "node:process";
2
2
  import { EnvironmentKey } from "./env.js";
3
3
  import { resolveConfigurationFilePath } from "./path-resolver.js";
4
4
  import { loadConfigurationFromFile } from "./yml-loader.js";
@@ -26,13 +26,11 @@ const loadAllProfilesFromConfigurationFile = (params) => {
26
26
  throw new Error("Could not find the path to the configuration file.");
27
27
  }
28
28
  const configs = loadConfigurationFromFile(filePath);
29
- return Object.keys(configs).reduce(
30
- (prev, pKey) => ({
31
- ...prev,
32
- [pKey]: convertFileConfigToSDK(configs[pKey])
33
- }),
34
- {}
35
- );
29
+ const result = {};
30
+ for (const pKey of Object.keys(configs)) {
31
+ result[pKey] = convertFileConfigToSDK(configs[pKey]);
32
+ }
33
+ return result;
36
34
  };
37
35
  const loadProfileFromConfigurationFile = (params) => {
38
36
  const configs = loadAllProfilesFromConfigurationFile(params);
@@ -1,6 +1,6 @@
1
- import { readFileSync } from "fs";
1
+ import { readFileSync } from "node:fs";
2
2
  const STRIP_COMMENT_REGEX = /(^|\s)[;#]/;
3
- const DETECT_SECTION_REGEX = /^\s*([^]+):\s*$/;
3
+ const DETECT_SECTION_REGEX = /^\s*([\s\S]+?):\s*$/;
4
4
  const DETECT_ITEM_REGEX = /^\s*(.+?)\s*:\s*(.+?)\s*$/;
5
5
  const convertYamlToConfiguration = (input) => {
6
6
  let foundProfilesKey = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleway/configuration-loader",
3
- "version": "1.0.12",
3
+ "version": "2.1.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Load configuration via file or environment for NodeJS.",
6
6
  "publishConfig": {
@@ -12,19 +12,17 @@
12
12
  "directory": "packages/configuration-loader"
13
13
  },
14
14
  "engines": {
15
- "node": ">=20.19.4"
15
+ "node": ">=20.19.6"
16
16
  },
17
17
  "type": "module",
18
18
  "exports": {
19
19
  ".": {
20
20
  "types": "./dist/index.d.ts",
21
- "import": "./dist/index.js",
22
- "require": "./dist/index.cjs",
23
21
  "default": "./dist/index.js"
24
22
  }
25
23
  },
26
24
  "devDependencies": {
27
- "@types/node": "18.11.18"
25
+ "@types/node": "18.19.130"
28
26
  },
29
27
  "scripts": {
30
28
  "typecheck": "tsc --noEmit",
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const process = require("process");
4
- const env = require("./env.cjs");
5
- const pathResolver = require("./path-resolver.cjs");
6
- const ymlLoader = require("./yml-loader.cjs");
7
- const convertFileConfigToSDK = (obj) => ({
8
- accessKey: obj.access_key,
9
- apiURL: obj.api_url,
10
- defaultOrganizationId: obj.default_organization_id,
11
- defaultProjectId: obj.default_project_id,
12
- defaultRegion: obj.default_region,
13
- defaultZone: obj.default_zone,
14
- secretKey: obj.secret_key
15
- });
16
- const loadProfileFromEnvironmentValues = () => ({
17
- accessKey: process.env[env.EnvironmentKey.ScwAccessKey],
18
- apiURL: process.env[env.EnvironmentKey.ScwAPIURL],
19
- defaultOrganizationId: process.env[env.EnvironmentKey.ScwDefaultOrganizationId],
20
- defaultProjectId: process.env[env.EnvironmentKey.ScwDefaultProjectId],
21
- defaultRegion: process.env[env.EnvironmentKey.ScwDefaultRegion],
22
- defaultZone: process.env[env.EnvironmentKey.ScwDefaultZone],
23
- secretKey: process.env[env.EnvironmentKey.ScwSecretKey]
24
- });
25
- const loadAllProfilesFromConfigurationFile = (params) => {
26
- const filePath = params?.filepath ?? pathResolver.resolveConfigurationFilePath();
27
- if (typeof filePath !== "string" || filePath.length === 0) {
28
- throw new Error("Could not find the path to the configuration file.");
29
- }
30
- const configs = ymlLoader.loadConfigurationFromFile(filePath);
31
- return Object.keys(configs).reduce(
32
- (prev, pKey) => ({
33
- ...prev,
34
- [pKey]: convertFileConfigToSDK(configs[pKey])
35
- }),
36
- {}
37
- );
38
- };
39
- const loadProfileFromConfigurationFile = (params) => {
40
- const configs = loadAllProfilesFromConfigurationFile(params);
41
- const profileName = params?.profileName ?? "default";
42
- const profileMap = configs[profileName];
43
- if (typeof profileMap !== "object") {
44
- throw new Error(
45
- `Could not find the desired profile '${profileName}' in the configuration file.`
46
- );
47
- }
48
- return profileMap;
49
- };
50
- exports.loadAllProfilesFromConfigurationFile = loadAllProfilesFromConfigurationFile;
51
- exports.loadProfileFromConfigurationFile = loadProfileFromConfigurationFile;
52
- exports.loadProfileFromEnvironmentValues = loadProfileFromEnvironmentValues;
package/dist/env.cjs DELETED
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var EnvironmentKey = /* @__PURE__ */ ((EnvironmentKey2) => {
4
- EnvironmentKey2["ScwConfigPath"] = "SCW_CONFIG_PATH";
5
- EnvironmentKey2["ScwAccessKey"] = "SCW_ACCESS_KEY";
6
- EnvironmentKey2["ScwSecretKey"] = "SCW_SECRET_KEY";
7
- EnvironmentKey2["ScwAPIURL"] = "SCW_API_URL";
8
- EnvironmentKey2["ScwDefaultOrganizationId"] = "SCW_DEFAULT_ORGANIZATION_ID";
9
- EnvironmentKey2["ScwDefaultProjectId"] = "SCW_DEFAULT_PROJECT_ID";
10
- EnvironmentKey2["ScwDefaultRegion"] = "SCW_DEFAULT_REGION";
11
- EnvironmentKey2["ScwDefaultZone"] = "SCW_DEFAULT_ZONE";
12
- return EnvironmentKey2;
13
- })(EnvironmentKey || {});
14
- exports.EnvironmentKey = EnvironmentKey;
package/dist/index.cjs DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const configLoader = require("./config-loader.cjs");
4
- exports.loadAllProfilesFromConfigurationFile = configLoader.loadAllProfilesFromConfigurationFile;
5
- exports.loadProfileFromConfigurationFile = configLoader.loadProfileFromConfigurationFile;
6
- exports.loadProfileFromEnvironmentValues = configLoader.loadProfileFromEnvironmentValues;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const node_os = require("node:os");
4
- const path = require("node:path");
5
- const node_process = require("node:process");
6
- const env = require("./env.cjs");
7
- function _interopNamespaceDefault(e) {
8
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
9
- if (e) {
10
- for (const k in e) {
11
- if (k !== "default") {
12
- const d = Object.getOwnPropertyDescriptor(e, k);
13
- Object.defineProperty(n, k, d.get ? d : {
14
- enumerable: true,
15
- get: () => e[k]
16
- });
17
- }
18
- }
19
- }
20
- n.default = e;
21
- return Object.freeze(n);
22
- }
23
- const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
24
- const getScwConfigurationDirectory = () => {
25
- const xdgConfigPath = node_process.env.XDG_CONFIG_HOME;
26
- if (typeof xdgConfigPath === "string" && xdgConfigPath.length > 0) {
27
- return path__namespace.join(xdgConfigPath, "scw");
28
- }
29
- return path__namespace.join(node_os.homedir(), ".config", "scw");
30
- };
31
- const resolveConfigurationFilePath = () => {
32
- const envFilePath = node_process.env[env.EnvironmentKey.ScwConfigPath];
33
- if (typeof envFilePath === "string" && envFilePath.length > 0) {
34
- return envFilePath;
35
- }
36
- return path__namespace.join(getScwConfigurationDirectory(), "config.yaml");
37
- };
38
- exports.getScwConfigurationDirectory = getScwConfigurationDirectory;
39
- exports.resolveConfigurationFilePath = resolveConfigurationFilePath;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const fs = require("fs");
4
- const STRIP_COMMENT_REGEX = /(^|\s)[;#]/;
5
- const DETECT_SECTION_REGEX = /^\s*([^]+):\s*$/;
6
- const DETECT_ITEM_REGEX = /^\s*(.+?)\s*:\s*(.+?)\s*$/;
7
- const convertYamlToConfiguration = (input) => {
8
- let foundProfilesKey = false;
9
- let currentSection = "default";
10
- const map = {};
11
- if (typeof input !== "string") {
12
- return map;
13
- }
14
- input.split(/\r?\n/).forEach((rawLine) => {
15
- const line = rawLine.split(STRIP_COMMENT_REGEX)[0];
16
- const newSection = DETECT_SECTION_REGEX.exec(line);
17
- if (newSection) {
18
- currentSection = void 0;
19
- if (newSection[1] === "profiles") {
20
- foundProfilesKey = true;
21
- } else if (foundProfilesKey) {
22
- [, currentSection] = newSection;
23
- }
24
- } else if (currentSection) {
25
- const item = DETECT_ITEM_REGEX.exec(line);
26
- if (item) {
27
- if (typeof map[currentSection] !== "object") {
28
- map[currentSection] = {};
29
- }
30
- [, , map[currentSection][item[1]]] = item;
31
- }
32
- }
33
- });
34
- return map;
35
- };
36
- const loadConfigurationFromFile = (filePath) => {
37
- const fileContent = fs.readFileSync(filePath, "utf-8");
38
- return convertYamlToConfiguration(fileContent);
39
- };
40
- exports.convertYamlToConfiguration = convertYamlToConfiguration;
41
- exports.loadConfigurationFromFile = loadConfigurationFromFile;