cli/ts/classes.gitzoneconfig.ts

48 lines
1.1 KiB
TypeScript
Raw Permalink Normal View History

2024-06-21 17:48:43 +00:00
import * as plugins from './plugins.js';
import * as paths from './paths.js';
export type TGitzoneProjectType = 'npm' | 'service' | 'wcc' | 'website';
/**
* type of the actual gitzone data
*/
export interface IGitzoneConfigData {
projectType: TGitzoneProjectType;
module: {
githost: string;
gitscope: string;
gitrepo: string;
description: string;
npmPackageName: string;
license: string;
projectDomain: string;
};
copy: { [key: string]: string };
2024-06-21 17:48:43 +00:00
npmciOptions: {
npmAccessLevel: 'public' | 'private';
};
}
/**
* gitzone config
*/
export class GitzoneConfig {
public static async fromCwd() {
const gitzoneConfig = new GitzoneConfig();
await gitzoneConfig.readConfigFromCwd();
return gitzoneConfig;
}
public data: IGitzoneConfigData;
public async readConfigFromCwd() {
const npmextraInstance = new plugins.npmextra.Npmextra(paths.cwd);
this.data = npmextraInstance.dataFor<IGitzoneConfigData>('gitzone', {});
this.data.npmciOptions = npmextraInstance.dataFor<IGitzoneConfigData['npmciOptions']>('npmci', {
npmAccessLevel: 'public',
});
}
constructor() {}
}