GlobalConfig Class — astro Architecture
Architecture documentation for the GlobalConfig class in config.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD fef0c5f1_0353_567c_a80e_149e04466a6f["GlobalConfig"] 5b90aac1_20dd_dfa0_03a8_c2a798e9dc65["config.ts"] fef0c5f1_0353_567c_a80e_149e04466a6f -->|defined in| 5b90aac1_20dd_dfa0_03a8_c2a798e9dc65 2dc89cbf_0106_10a9_1a8e_e4ad9c3f9c3a["constructor()"] fef0c5f1_0353_567c_a80e_149e04466a6f -->|method| 2dc89cbf_0106_10a9_1a8e_e4ad9c3f9c3a 9d5599b6_08fa_90b0_54c3_7f4b15aaec38["store()"] fef0c5f1_0353_567c_a80e_149e04466a6f -->|method| 9d5599b6_08fa_90b0_54c3_7f4b15aaec38 8bfd8863_ff85_cd7c_4056_ab4a176e58ab["ensureDir()"] fef0c5f1_0353_567c_a80e_149e04466a6f -->|method| 8bfd8863_ff85_cd7c_4056_ab4a176e58ab 09d19e93_c3b2_b72b_a1e5_79df795a76f9["write()"] fef0c5f1_0353_567c_a80e_149e04466a6f -->|method| 09d19e93_c3b2_b72b_a1e5_79df795a76f9 7d72ac16_08b1_9320_1adc_4c02621313bb["clear()"] fef0c5f1_0353_567c_a80e_149e04466a6f -->|method| 7d72ac16_08b1_9320_1adc_4c02621313bb 025253d7_f765_cd96_325a_543cfd480db6["delete()"] fef0c5f1_0353_567c_a80e_149e04466a6f -->|method| 025253d7_f765_cd96_325a_543cfd480db6 78d29a64_3765_ad1d_a576_f4752f9fff17["get()"] fef0c5f1_0353_567c_a80e_149e04466a6f -->|method| 78d29a64_3765_ad1d_a576_f4752f9fff17 992020ae_c9a2_915b_f777_f790e5940af2["has()"] fef0c5f1_0353_567c_a80e_149e04466a6f -->|method| 992020ae_c9a2_915b_f777_f790e5940af2 76b12680_8f46_4254_def6_568b98b724c0["set()"] fef0c5f1_0353_567c_a80e_149e04466a6f -->|method| 76b12680_8f46_4254_def6_568b98b724c0
Relationship Graph
Source Code
packages/telemetry/src/config.ts lines 35–88
export class GlobalConfig {
private dir: string;
private file: string;
constructor(private project: ConfigOptions) {
this.dir = getConfigDir(this.project.name);
this.file = path.join(this.dir, 'config.json');
}
private _store?: Record<string, any>;
private get store(): Record<string, any> {
if (this._store) return this._store;
this.ensureDir();
if (fs.existsSync(this.file)) {
try {
this._store = JSON.parse(fs.readFileSync(this.file).toString());
} catch {}
}
if (!this._store) {
this._store = {};
this.write();
}
return this._store;
}
private set store(value: Record<string, any>) {
this._store = value;
this.write();
}
private ensureDir() {
fs.mkdirSync(this.dir, { recursive: true });
}
write() {
fs.writeFileSync(this.file, JSON.stringify(this.store, null, '\t'));
}
clear(): void {
this.store = {};
fs.rmSync(this.file, { recursive: true });
}
delete(key: string): boolean {
dset(this.store, key, undefined);
this.write();
return true;
}
get(key: string): any {
return dget(this.store, key);
}
has(key: string): boolean {
return typeof this.get(key) !== 'undefined';
}
set(key: string, value: any): void {
dset(this.store, key, value);
this.write();
}
}
Defined In
Source
Frequently Asked Questions
What is the GlobalConfig class?
GlobalConfig is a class in the astro codebase, defined in packages/telemetry/src/config.ts.
Where is GlobalConfig defined?
GlobalConfig is defined in packages/telemetry/src/config.ts at line 35.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free