@contentful/experience-design-system-types 2.36.2-dev-build-d983d04c.0 → 2.36.2-dev-build-7b317500.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 +6 -1
- package/dist/src/config/index.d.ts +9 -0
- package/dist/src/config/index.js +40 -0
- package/package.json +6 -1
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experience-design-system-types",
|
|
3
|
-
"version": "2.36.2-dev-build-
|
|
3
|
+
"version": "2.36.2-dev-build-7b317500.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,40 @@
|
|
|
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
|
+
// The CLI and the bundled legacy import both use this; nothing else calls homedir() or touches these files.
|
|
7
|
+
//
|
|
8
|
+
// ~/.contentful/experience-design-system-cli/
|
|
9
|
+
// config.json every setting: credentials, preferences, debug mode (mode 0600) [CLI]
|
|
10
|
+
// debug/ per-session debug logs [CLI]
|
|
11
|
+
// state/ runs.json, run history [legacy, until deleted]
|
|
12
|
+
// reviews/ review artifacts [legacy, until deleted]
|
|
13
|
+
// pipeline.db session database, including the generation cache [legacy, until deleted]
|
|
14
|
+
export function configRoot() {
|
|
15
|
+
return process.env['EDS_HOME'] || join(homedir(), '.contentful', 'experience-design-system-cli');
|
|
16
|
+
}
|
|
17
|
+
export const configFilePath = () => join(configRoot(), 'config.json');
|
|
18
|
+
export const runsFilePath = () => join(configRoot(), 'state', 'runs.json');
|
|
19
|
+
export const debugSessionsDir = () => join(configRoot(), 'debug', 'sessions');
|
|
20
|
+
export async function readSettings() {
|
|
21
|
+
try {
|
|
22
|
+
return JSON.parse(await readFile(configFilePath(), 'utf8'));
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// Write-then-rename so a crash can never leave a half-written config.
|
|
29
|
+
export async function writeSettings(settings) {
|
|
30
|
+
const path = configFilePath();
|
|
31
|
+
await mkdir(dirname(path), { recursive: true });
|
|
32
|
+
const tmp = `${path}.${process.pid}.${randomBytes(4).toString('hex')}.tmp`;
|
|
33
|
+
await writeFile(tmp, `${JSON.stringify(settings, null, 2)}\n`, { mode: 0o600 });
|
|
34
|
+
await rename(tmp, path);
|
|
35
|
+
}
|
|
36
|
+
export async function updateSettings(patch) {
|
|
37
|
+
await writeSettings({ ...(await readSettings()), ...patch });
|
|
38
|
+
}
|
|
39
|
+
// Directory the config used to live in; only the migration reads from it.
|
|
40
|
+
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.36.2-dev-build-
|
|
3
|
+
"version": "2.36.2-dev-build-7b317500.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": {
|