Skip to content

Commit f51f89a

Browse files
committed
feat: m2 instance cli command
1 parent dc4572d commit f51f89a

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

packages/cli/src/commands/m2-only.ts

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
}

packages/cli/src/domains/magento2/docker/checkDocker.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ const checkDocker = async (
2626

2727
if (!isDockerInstalled) {
2828
writeLog(
29-
'Docker is not installed or not running. Please make sure that prerequisites are complied with and run command again. For more information, please visit https://docs.vuestorefront.io/magento/installation-setup/configure-magento.html'
29+
'Docker is not installed or not running. Please make sure that prerequisites are complied with and run command again.'
3030
);
3131
logSimpleErrorMessage(
32-
'Docker is not installed or not running. Please make sure that prerequisites are complied with and run command again. For more information, please visit https://docs.vuestorefront.io/magento/installation-setup/configure-magento.html'
32+
'Docker is not installed or not running. Please make sure that prerequisites are complied with and run command again.'
3333
);
3434
logSimpleInfoMessage(t('command.generate_store.magento.failed_log'));
3535
process.exit(1);

packages/cli/src/domains/magento2/functions/getMagentoDetails.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { t } from 'i18next';
77
import handleMagentoKeys from '../prompts/handleMagentoKeys';
88
import { note } from '@clack/prompts';
99

10-
const getMagentoDetails = async (projectName: string) => {
10+
const getMagentoDetails = async (projectName?: string) => {
1111
let magentoAccessKey: string;
1212
let magentoSecretKey: string;
1313

0 commit comments

Comments
 (0)