cli/ts/classes.gitzoneconfig.ts

48 lines
1.1 KiB
TypeScript

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 };
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() {}
}