import { Logger } from '@refloat/logger'
import { spawnSync } from 'child_process'

export const defaultTags = [process.arch === 'x64' ? 'amd64' : process.arch]

const logger = Logger.create('tags')
const checks = {
	bash: 'bash --version',
	docker: 'docker version',
	'docker-cli': 'docker --version',
}

if (process.platform === 'darwin') {
	defaultTags.push('unix', 'macos')
} else if (process.platform === 'linux') {
	defaultTags.push('unix', 'linux')
} else if (process.platform === 'win32') {
	defaultTags.push('windows')
}

for (const tag of Object.keys(checks) as Array<keyof typeof checks>) {
	const process = spawnSync(checks[tag], { shell: true })

	if (process.status === 0 && !process.error) {
		defaultTags.push(tag)
	}
}
