Files
szci/ts/szci.classes.szciconfig.ts

79 lines
2.0 KiB
TypeScript
Raw Normal View History

import * as plugins from './szci.plugins.ts';
import * as paths from './szci.paths.ts';
2019-08-29 20:26:23 +02:00
import { logger } from './szci.logging.ts';
import { Szci } from './szci.classes.szci.ts';
2019-08-29 20:26:23 +02:00
/**
2025-12-13 13:27:51 +00:00
* the main config interface for szci
2019-08-29 20:26:23 +02:00
*/
export interface ISzciOptions {
2019-08-29 20:26:23 +02:00
projectInfo: plugins.projectinfo.ProjectInfo;
// npm
npmGlobalTools: string[];
npmAccessLevel?: 'private' | 'public';
npmRegistryUrl: string;
// docker
dockerRegistries: string[];
dockerRegistryRepoMap: { [key: string]: string };
dockerBuildargEnvMap: { [key: string]: string };
// gitlab
gitlabRunnerTags: string[];
2019-08-29 20:26:23 +02:00
// urls
2025-12-13 13:27:51 +00:00
urlCloudly?: string;
2023-07-01 22:05:43 +02:00
// cloudron
2023-07-01 22:09:54 +02:00
cloudronAppName?: string;
2019-08-29 20:26:23 +02:00
}
/**
2025-12-13 13:27:51 +00:00
* a config class for Szci
2019-08-29 20:26:23 +02:00
*/
export class SzciConfig {
public szciRef: Szci;
2019-08-29 20:26:23 +02:00
2025-12-13 13:27:51 +00:00
public szciNpmextra!: plugins.npmextra.Npmextra;
public kvStorage!: plugins.npmextra.KeyValueStore;
public szciQenv!: plugins.qenv.Qenv;
2019-08-29 20:26:23 +02:00
2025-12-13 13:27:51 +00:00
private configObject!: ISzciOptions;
2019-08-29 20:26:23 +02:00
constructor(szciRefArg: Szci) {
this.szciRef = szciRefArg;
2023-08-24 17:25:55 +02:00
}
2019-08-29 20:26:23 +02:00
2023-08-24 17:25:55 +02:00
public async init() {
2025-12-13 13:27:51 +00:00
this.szciNpmextra = new plugins.npmextra.Npmextra(paths.cwd);
this.kvStorage = new plugins.npmextra.KeyValueStore({
typeArg: 'userHomeDir',
2025-12-13 13:27:51 +00:00
identityArg: `.szci_${this.szciRef.szciEnv.repo.user}_${this.szciRef.szciEnv.repo.repo}`,
});
2025-12-13 13:27:51 +00:00
this.szciQenv = new plugins.qenv.Qenv(
paths.SzciProjectDir,
paths.SzciProjectNogitDir,
2021-05-14 18:11:12 +00:00
false
2019-08-29 20:26:23 +02:00
);
2019-08-29 20:38:44 +02:00
this.configObject = {
2019-08-29 20:26:23 +02:00
projectInfo: new plugins.projectinfo.ProjectInfo(paths.cwd),
npmGlobalTools: [],
dockerRegistries: [],
dockerRegistryRepoMap: {},
npmAccessLevel: 'private',
npmRegistryUrl: 'registry.npmjs.org',
gitlabRunnerTags: [],
2019-08-29 20:26:23 +02:00
dockerBuildargEnvMap: {},
2025-12-13 13:27:51 +00:00
urlCloudly: await this.szciQenv.getEnvVarOnDemand('SZCI_URL_CLOUDLY'),
2019-08-29 20:26:23 +02:00
};
2025-12-13 13:27:51 +00:00
this.configObject = this.szciNpmextra.dataFor<ISzciOptions>('@ship.zone/szci', this.configObject);
2019-08-29 20:26:23 +02:00
}
public getConfig(): ISzciOptions {
2019-08-29 20:26:23 +02:00
return this.configObject;
}
}