|
| 1 | +import { intro } from '@clack/prompts'; |
| 2 | +import { Command } from '@oclif/core'; |
| 3 | +import { initLogger } from '../domains/logging/logger'; |
| 4 | +import checkNode from '../domains/magento2/functions/checkNode'; |
| 5 | +import checkYarn from '../domains/magento2/functions/checkYarn'; |
| 6 | +import { checkDocker, getMagentoDomainName } from '../domains/magento2/docker'; |
| 7 | +import { getMagentoDetails } from '../domains/magento2/functions'; |
| 8 | +import { installMagento } from '../domains/magento2/installMagento'; |
| 9 | +import { simpleLog } from '../domains/magento2/functions/terminalHelpers'; |
| 10 | +import picocolors from 'picocolors'; |
| 11 | +import { t } from 'i18next'; |
| 12 | + |
| 13 | +export default class M2Only extends Command { |
| 14 | + static override description = 'Install local Magento 2 instance'; |
| 15 | + |
| 16 | + static override examples = ['<%= config.bin %> <%= command.id %>']; |
| 17 | + |
| 18 | + static override flags = {}; |
| 19 | + |
| 20 | + static override args = []; |
| 21 | + |
| 22 | + async run(): Promise<void> { |
| 23 | + const { writeLog, deleteLog } = initLogger(); |
| 24 | + |
| 25 | + intro('Welcome to the Magento 2 local instance installer!'); |
| 26 | + |
| 27 | + await checkNode(writeLog); |
| 28 | + await checkYarn(writeLog); |
| 29 | + await checkDocker(writeLog); |
| 30 | + |
| 31 | + const { magentoDirName, magentoAccessKey, magentoSecretKey } = |
| 32 | + await getMagentoDetails(); |
| 33 | + |
| 34 | + const magentoDomain = await getMagentoDomainName( |
| 35 | + t('command.generate_store.magento.domain') |
| 36 | + ); |
| 37 | + |
| 38 | + await installMagento({ |
| 39 | + isInstallMagento: true, |
| 40 | + magentoDirName, |
| 41 | + magentoDomain, |
| 42 | + magentoAccessKey, |
| 43 | + magentoSecretKey, |
| 44 | + writeLog |
| 45 | + }); |
| 46 | + |
| 47 | + deleteLog(); |
| 48 | + |
| 49 | + simpleLog('Magento 2 local instance installed!'); |
| 50 | + simpleLog(''); |
| 51 | + |
| 52 | + simpleLog('Happy coding! 🎉', picocolors.green); |
| 53 | + |
| 54 | + this.exit(0); |
| 55 | + } |
| 56 | +} |
0 commit comments