feat(config): add smartconfig metadata and update TypeScript build configuration docs

This commit is contained in:
2026-03-24 18:13:56 +00:00
parent cfe2eafe89
commit 724e5bf7ec
10 changed files with 1196 additions and 2042 deletions

View File

@@ -17,7 +17,8 @@ export interface ITsPublishJson {
*/
export class TsPublishConfig {
private folderPath: string;
private cachedConfig: ITsPublishJson | null | undefined = undefined;
private cachedConfig: ITsPublishJson | null = null;
private cacheLoaded = false;
constructor(folderPath: string) {
this.folderPath = folderPath;
@@ -35,7 +36,7 @@ export class TsPublishConfig {
* Returns null if file doesn't exist or is invalid
*/
public async load(): Promise<ITsPublishJson | null> {
if (this.cachedConfig !== undefined) {
if (this.cacheLoaded) {
return this.cachedConfig;
}
@@ -43,9 +44,11 @@ export class TsPublishConfig {
const configPath = path.join(this.folderPath, 'tspublish.json');
const content = await fs.promises.readFile(configPath, 'utf8');
this.cachedConfig = JSON.parse(content);
this.cacheLoaded = true;
return this.cachedConfig;
} catch {
this.cachedConfig = null;
this.cacheLoaded = true;
return null;
}
}
@@ -55,7 +58,7 @@ export class TsPublishConfig {
* Returns null if file doesn't exist or is invalid
*/
public loadSync(): ITsPublishJson | null {
if (this.cachedConfig !== undefined) {
if (this.cacheLoaded) {
return this.cachedConfig;
}
@@ -63,9 +66,11 @@ export class TsPublishConfig {
const configPath = path.join(this.folderPath, 'tspublish.json');
const content = fs.readFileSync(configPath, 'utf8');
this.cachedConfig = JSON.parse(content);
this.cacheLoaded = true;
return this.cachedConfig;
} catch {
this.cachedConfig = null;
this.cacheLoaded = true;
return null;
}
}
@@ -111,6 +116,7 @@ export class TsPublishConfig {
* Clear the cached config (useful for reloading)
*/
public clearCache(): void {
this.cachedConfig = undefined;
this.cachedConfig = null;
this.cacheLoaded = false;
}
}