2022-10-09 16:15:37 +00:00
|
|
|
import * as plugins from './npmci.plugins.js';
|
|
|
|
import * as paths from './npmci.paths.js';
|
2019-08-29 18:26:23 +00:00
|
|
|
|
2022-10-09 16:15:37 +00:00
|
|
|
import { logger } from './npmci.logging.js';
|
|
|
|
import { Npmci } from './npmci.classes.npmci.js';
|
2019-08-29 18:26:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* the main config interface for npmci
|
|
|
|
*/
|
|
|
|
export interface INpmciOptions {
|
|
|
|
projectInfo: plugins.projectinfo.ProjectInfo;
|
|
|
|
|
|
|
|
// npm
|
|
|
|
npmGlobalTools: string[];
|
|
|
|
npmAccessLevel?: 'private' | 'public';
|
|
|
|
npmRegistryUrl: string;
|
|
|
|
|
|
|
|
// docker
|
|
|
|
dockerRegistries: string[];
|
|
|
|
dockerRegistryRepoMap: { [key: string]: string };
|
|
|
|
dockerBuildargEnvMap: { [key: string]: string };
|
|
|
|
|
2022-10-24 19:23:14 +00:00
|
|
|
// gitlab
|
|
|
|
gitlabRunnerTags: string[];
|
|
|
|
|
2019-08-29 18:26:23 +00:00
|
|
|
// urls
|
|
|
|
urlCloudly: string;
|
2023-07-01 20:05:43 +00:00
|
|
|
|
|
|
|
// cloudron
|
2023-07-01 20:09:54 +00:00
|
|
|
cloudronAppName?: string;
|
2019-08-29 18:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* a config class for Npmci
|
|
|
|
*/
|
|
|
|
export class NpmciConfig {
|
|
|
|
public npmciRef: Npmci;
|
|
|
|
|
|
|
|
public npmciNpmextra: plugins.npmextra.Npmextra;
|
|
|
|
public kvStorage: plugins.npmextra.KeyValueStore;
|
|
|
|
public npmciQenv: plugins.qenv.Qenv;
|
|
|
|
|
|
|
|
private configObject: INpmciOptions;
|
|
|
|
|
|
|
|
constructor(npmciRefArg: Npmci) {
|
|
|
|
this.npmciRef = npmciRefArg;
|
2023-08-24 15:25:55 +00:00
|
|
|
}
|
2019-08-29 18:26:23 +00:00
|
|
|
|
2023-08-24 15:25:55 +00:00
|
|
|
public async init() {
|
2019-08-29 18:26:23 +00:00
|
|
|
this.npmciNpmextra = new plugins.npmextra.Npmextra(paths.cwd);
|
2024-11-05 01:38:21 +00:00
|
|
|
this.kvStorage = new plugins.npmextra.KeyValueStore({
|
|
|
|
typeArg: 'userHomeDir',
|
|
|
|
identityArg: `.npmci_${this.npmciRef.npmciEnv.repo.user}_${this.npmciRef.npmciEnv.repo.repo}`,
|
|
|
|
});
|
2019-08-29 18:26:23 +00:00
|
|
|
this.npmciQenv = new plugins.qenv.Qenv(
|
|
|
|
paths.NpmciProjectDir,
|
|
|
|
paths.NpmciProjectNogitDir,
|
2021-05-14 18:11:12 +00:00
|
|
|
false
|
2019-08-29 18:26:23 +00:00
|
|
|
);
|
|
|
|
|
2019-08-29 18:38:44 +00:00
|
|
|
this.configObject = {
|
2019-08-29 18:26:23 +00:00
|
|
|
projectInfo: new plugins.projectinfo.ProjectInfo(paths.cwd),
|
|
|
|
npmGlobalTools: [],
|
|
|
|
dockerRegistries: [],
|
|
|
|
dockerRegistryRepoMap: {},
|
|
|
|
npmAccessLevel: 'private',
|
|
|
|
npmRegistryUrl: 'registry.npmjs.org',
|
2022-10-24 19:23:14 +00:00
|
|
|
gitlabRunnerTags: [],
|
2019-08-29 18:26:23 +00:00
|
|
|
dockerBuildargEnvMap: {},
|
2023-08-24 15:25:55 +00:00
|
|
|
urlCloudly: await this.npmciQenv.getEnvVarOnDemand('NPMCI_URL_CLOUDLY'),
|
2019-08-29 18:26:23 +00:00
|
|
|
};
|
|
|
|
this.configObject = this.npmciNpmextra.dataFor<INpmciOptions>('npmci', this.configObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
public getConfig(): INpmciOptions {
|
|
|
|
return this.configObject;
|
|
|
|
}
|
|
|
|
}
|