@contentful/experience-design-system-types 2.35.1-dev-build-e76d41c1.0 → 2.35.1-dev-build-9d6916d7.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/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-types",
3
- "version": "2.35.1-dev-build-e76d41c1.0",
3
+ "version": "2.35.1-dev-build-9d6916d7.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/src/index.js",
@@ -11,6 +11,11 @@
11
11
  "types": "./dist/src/index.d.ts",
12
12
  "import": "./dist/src/index.js",
13
13
  "node": "./dist/src/index.js"
14
+ },
15
+ "./config": {
16
+ "types": "./dist/src/config/index.d.ts",
17
+ "import": "./dist/src/config/index.js",
18
+ "node": "./dist/src/config/index.js"
14
19
  }
15
20
  },
16
21
  "publishConfig": {
@@ -0,0 +1,9 @@
1
+ export declare function configRoot(): string;
2
+ export declare const configFilePath: () => string;
3
+ export declare const runsFilePath: () => string;
4
+ export declare const debugSessionsDir: () => string;
5
+ export type Settings = Record<string, unknown>;
6
+ export declare function readSettings(): Promise<Settings>;
7
+ export declare function writeSettings(settings: Settings): Promise<void>;
8
+ export declare function updateSettings(patch: Settings): Promise<void>;
9
+ export declare const oldConfigDir: () => string;
@@ -0,0 +1,39 @@
1
+ import { randomBytes } from 'node:crypto';
2
+ import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
3
+ import { homedir } from 'node:os';
4
+ import { dirname, join } from 'node:path';
5
+ // The single source of truth for where the CLI keeps files on disk and how settings are read and written.
6
+ // Both the CLI and the legacy package import this; nothing else calls homedir() or touches these files.
7
+ //
8
+ // ~/.contentful/experience-design-system-cli/
9
+ // config.json every setting: credentials, preferences, defaults (mode 0600)
10
+ // state/ runs.json
11
+ // debug/ per-session debug logs
12
+ // pipeline.db pipeline session database
13
+ export function configRoot() {
14
+ return process.env['EDS_HOME'] || join(homedir(), '.contentful', 'experience-design-system-cli');
15
+ }
16
+ export const configFilePath = () => join(configRoot(), 'config.json');
17
+ export const runsFilePath = () => join(configRoot(), 'state', 'runs.json');
18
+ export const debugSessionsDir = () => join(configRoot(), 'debug', 'sessions');
19
+ export async function readSettings() {
20
+ try {
21
+ return JSON.parse(await readFile(configFilePath(), 'utf8'));
22
+ }
23
+ catch {
24
+ return {};
25
+ }
26
+ }
27
+ // Write-then-rename so a crash can never leave a half-written config.
28
+ export async function writeSettings(settings) {
29
+ const path = configFilePath();
30
+ await mkdir(dirname(path), { recursive: true });
31
+ const tmp = `${path}.${process.pid}.${randomBytes(4).toString('hex')}.tmp`;
32
+ await writeFile(tmp, `${JSON.stringify(settings, null, 2)}\n`, { mode: 0o600 });
33
+ await rename(tmp, path);
34
+ }
35
+ export async function updateSettings(patch) {
36
+ await writeSettings({ ...(await readSettings()), ...patch });
37
+ }
38
+ // Directory the config used to live in; only the migration reads from it.
39
+ export const oldConfigDir = () => join(homedir(), '.config', 'experiences');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-types",
3
- "version": "2.35.1-dev-build-e76d41c1.0",
3
+ "version": "2.35.1-dev-build-9d6916d7.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/src/index.js",
@@ -11,6 +11,11 @@
11
11
  "types": "./dist/src/index.d.ts",
12
12
  "import": "./dist/src/index.js",
13
13
  "node": "./dist/src/index.js"
14
+ },
15
+ "./config": {
16
+ "types": "./dist/src/config/index.d.ts",
17
+ "import": "./dist/src/config/index.js",
18
+ "node": "./dist/src/config/index.js"
14
19
  }
15
20
  },
16
21
  "publishConfig": {