46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import * as plugins from './tsdocker.plugins.js';
|
|
import * as paths from './tsdocker.paths.js';
|
|
import * as fs from 'fs';
|
|
import type { ITsDockerConfig } from './interfaces/index.js';
|
|
|
|
// Re-export ITsDockerConfig as IConfig for backward compatibility
|
|
export type IConfig = ITsDockerConfig & {
|
|
exitCode?: number;
|
|
};
|
|
|
|
const getQenvKeyValueObject = async () => {
|
|
let qenvKeyValueObjectArray: { [key: string]: string | number };
|
|
if (fs.existsSync(plugins.path.join(paths.cwd, 'qenv.yml'))) {
|
|
qenvKeyValueObjectArray = new plugins.qenv.Qenv(paths.cwd, '.nogit/').keyValueObject;
|
|
} else {
|
|
qenvKeyValueObjectArray = {};
|
|
}
|
|
return qenvKeyValueObjectArray;
|
|
};
|
|
|
|
const buildConfig = async (qenvKeyValueObjectArg: { [key: string]: string | number }) => {
|
|
const npmextra = new plugins.npmextra.Npmextra(paths.cwd);
|
|
const config = npmextra.dataFor<IConfig>('@git.zone/tsdocker', {
|
|
// Legacy options (backward compatible)
|
|
baseImage: 'hosttoday/ht-docker-node:npmdocker',
|
|
init: 'rm -rf node_nodules/ && yarn install',
|
|
command: 'npmci npm test',
|
|
dockerSock: false,
|
|
keyValueObject: qenvKeyValueObjectArg,
|
|
|
|
// New Docker build options
|
|
registries: [],
|
|
registryRepoMap: {},
|
|
buildArgEnvMap: {},
|
|
platforms: ['linux/amd64'],
|
|
push: false,
|
|
testDir: undefined,
|
|
});
|
|
return config;
|
|
};
|
|
|
|
export let run = async (): Promise<IConfig> => {
|
|
const config = await getQenvKeyValueObject().then(buildConfig);
|
|
return config;
|
|
};
|