@scandipwa/magento-scripts 1.15.0 → 1.15.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,7 @@ const pathExists = require('../util/path-exists');
5
5
  const { deepmerge } = require('../util/deepmerge');
6
6
  const { defaultMagentoConfig } = require('./magento-config');
7
7
  const setConfigFile = require('../util/set-config');
8
+ const getJsonfileData = require('../util/get-jsonfile-data');
8
9
 
9
10
  /**
10
11
  * @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
@@ -16,6 +17,8 @@ const checkConfigurationFile = () => ({
16
17
  const { cacheDir, templateDir } = getBaseConfig(projectPath);
17
18
  const configJSFilePath = path.join(projectPath, 'cma.js');
18
19
  const magentoConfigFilePath = path.join(cacheDir, 'app-config.json');
20
+ const composerJsonPath = path.join(process.cwd(), 'composer.json');
21
+ const composerData = await getJsonfileData(composerJsonPath);
19
22
 
20
23
  if (!await pathExists(configJSFilePath)) {
21
24
  const legacyMagentoConfigExists = await pathExists(magentoConfigFilePath);
@@ -28,7 +31,19 @@ const checkConfigurationFile = () => ({
28
31
  );
29
32
 
30
33
  magentoConfiguration = legacyMagentoConfig.magento || legacyMagentoConfig;
31
- } else {
34
+ } else if (composerData) {
35
+ if (composerData.require['magento/product-community-edition']) {
36
+ magentoConfiguration = deepmerge(defaultMagentoConfig, {
37
+ edition: 'community'
38
+ });
39
+ } else if (composerData.require['magento/product-enterprise-edition']) {
40
+ magentoConfiguration = deepmerge(defaultMagentoConfig, {
41
+ edition: 'enterprise'
42
+ });
43
+ }
44
+ }
45
+
46
+ if (!magentoConfiguration) {
32
47
  const magentoEdition = await task.prompt({
33
48
  type: 'Select',
34
49
  message: `Please select Magento edition you want to install.
@@ -1,5 +1,10 @@
1
+ RED='\033[0;31m'
2
+ GREEN='\033[0;32m'
3
+ NC='\033[0m' # No Color
4
+
1
5
  alias php="$HOME/.phpbrew/php/php-<%= it.php.version %>/bin/php -c $PWD/node_modules/.create-magento-app-cache/php.ini"
2
6
  alias magento="php $PWD/bin/magento"
7
+ alias magneto="echo -e 'Not ${RED}magneto${NC} but ${GREEN}magento${NC} please! or at least ${GREEN}m${NC}!' && magento"
3
8
  alias m="magento"
4
9
  alias composer="php $PWD/node_modules/.create-magento-app-cache/composer/composer.phar"
5
10
  alias c="composer"
@@ -86,33 +86,35 @@ const setupExcludedFolders = (excludedFoldersConfig) => {
86
86
  return hasChanges;
87
87
  };
88
88
 
89
- const createModulesXML = async () => {
89
+ const getIMLFilePath = async () => {
90
90
  const filePath = path.join(process.cwd(), '.idea', `${path.parse(process.cwd()).base}.iml`);
91
- const fileFormattedPath = formatPathForPHPStormConfig(filePath);
92
- const fileFormattedUrl = `file://${fileFormattedPath}`;
93
-
94
- const modulesConfig = {
95
- '?xml': {
96
- '@_version': '1.0',
97
- '@_encoding': 'UTF-8'
98
- },
99
- project: {
100
- '@_version': '4',
101
- component: {
102
- '@_name': 'ProjectModuleManager',
103
- modules: [
104
- {
105
- module: {
106
- '@_fileurl': fileFormattedUrl,
107
- '@_filepath': fileFormattedPath
91
+ if (!await pathExists(pathToModulesConfig)) {
92
+ const fileFormattedPath = formatPathForPHPStormConfig(filePath);
93
+ const fileFormattedUrl = `file://${fileFormattedPath}`;
94
+
95
+ const modulesConfig = {
96
+ '?xml': {
97
+ '@_version': '1.0',
98
+ '@_encoding': 'UTF-8'
99
+ },
100
+ project: {
101
+ '@_version': '4',
102
+ component: {
103
+ '@_name': 'ProjectModuleManager',
104
+ modules: [
105
+ {
106
+ module: {
107
+ '@_fileurl': fileFormattedUrl,
108
+ '@_filepath': fileFormattedPath
109
+ }
108
110
  }
109
- }
110
- ]
111
+ ]
112
+ }
111
113
  }
112
- }
113
- };
114
+ };
114
115
 
115
- await buildXmlFile(pathToModulesConfig, modulesConfig);
116
+ await buildXmlFile(pathToModulesConfig, modulesConfig);
117
+ }
116
118
 
117
119
  return filePath;
118
120
  };
@@ -125,19 +127,21 @@ const setupExcludedFoldersConfig = () => ({
125
127
  task: async (ctx, task) => {
126
128
  if (await pathExists(pathToModulesConfig)) {
127
129
  const projectFilePath = await getProjectConfigFilePath();
128
- const projectConfigData = await loadXmlFile(projectFilePath);
129
- const excludedFoldersConfig = getExcludedFoldersConfig(projectConfigData);
130
- const hasChanges = setupExcludedFolders(excludedFoldersConfig);
131
- if (hasChanges) {
132
- await buildXmlFile(projectFilePath, projectConfigData);
133
- } else {
134
- task.skip();
135
- }
130
+ if (await pathExists(projectFilePath)) {
131
+ const projectConfigData = await loadXmlFile(projectFilePath);
132
+ const excludedFoldersConfig = getExcludedFoldersConfig(projectConfigData);
133
+ const hasChanges = setupExcludedFolders(excludedFoldersConfig);
134
+ if (hasChanges) {
135
+ await buildXmlFile(projectFilePath, projectConfigData);
136
+ } else {
137
+ task.skip();
138
+ }
136
139
 
137
- return;
140
+ return;
141
+ }
138
142
  }
139
143
 
140
- const projectFilePath = await createModulesXML();
144
+ const projectFilePath = await getIMLFilePath();
141
145
  const projectConfigData = {
142
146
  '?xml': {
143
147
  '@_version': '1.0',
@@ -11,6 +11,27 @@ const setupPhpCSFixerValidationInspection = require('./php-cs-fixer-validation-i
11
11
  const setupPhpCSValidationInspection = require('./php-cs-validation-inspection-config');
12
12
  const setupStyleLintInspection = require('./stylelint-inspection-config');
13
13
 
14
+ const inspectionProfileDefaults = {
15
+ component: {
16
+ [nameKey]: 'InspectionProjectProfileManager',
17
+ profile: {
18
+ '@_version': '1.0',
19
+ option: {
20
+ [nameKey]: 'myName',
21
+ [valueKey]: 'Project Default'
22
+ },
23
+ inspection_tool: [
24
+ {
25
+ [classKey]: 'PhpStanGlobal',
26
+ '@_enabled': 'true',
27
+ '@_level': 'ERROR',
28
+ '@_enabled_by_default': 'true'
29
+ }
30
+ ]
31
+ }
32
+ }
33
+ };
34
+
14
35
  /**
15
36
  * @type {() => import('listr2').ListrTask<import('../../../../../typings/context').ListrContext>}
16
37
  */
@@ -25,6 +46,26 @@ const setupInspectionToolsConfig = () => ({
25
46
 
26
47
  if (await pathExists(phpStorm.inspectionTools.path)) {
27
48
  const inspectionToolsData = await loadXmlFile(phpStorm.inspectionTools.path);
49
+
50
+ if (!inspectionToolsData.component) {
51
+ inspectionToolsData.component = inspectionProfileDefaults.component;
52
+ }
53
+
54
+ if (!inspectionToolsData.component.profile) {
55
+ inspectionToolsData.component.profile = inspectionProfileDefaults.component.profile;
56
+ }
57
+
58
+ if (!inspectionToolsData.component.profile.inspection_tool) {
59
+ inspectionToolsData.component.profile.inspection_tool = [];
60
+ }
61
+
62
+ // eslint-disable-next-line max-len
63
+ if (!Array.isArray(inspectionToolsData.component.profile.inspection_tool) && Boolean(inspectionToolsData.component.profile.inspection_tool)) {
64
+ inspectionToolsData.component.profile.inspection_tool = [
65
+ inspectionToolsData.component.profile.inspection_tool
66
+ ];
67
+ }
68
+
28
69
  const inspectionTools = inspectionToolsData.component.profile.inspection_tool;
29
70
  const hasChanges = await Promise.all([
30
71
  setupPhpCSFixerValidationInspection(inspectionTools),
@@ -1,5 +1,6 @@
1
1
  const { loadXmlFile, buildXmlFile } = require('../../../../config/xml-parser');
2
2
  const pathExists = require('../../../../util/path-exists');
3
+ const { setupXMLStructure } = require('../setup-xml-structure');
3
4
  const setupMessDetector = require('./mess-detector-config');
4
5
  const setupPHPCodeSniffer = require('./php-code-sniffer-config');
5
6
  const setupPHPCSFixer = require('./php-cs-fixer-config');
@@ -23,7 +24,7 @@ const setupPhpConfig = () => ({
23
24
  } = ctx;
24
25
 
25
26
  if (await pathExists(phpStorm.php.path)) {
26
- const phpConfigContent = await loadXmlFile(phpStorm.php.path);
27
+ const phpConfigContent = setupXMLStructure(await loadXmlFile(phpStorm.php.path));
27
28
  const phpConfigs = phpConfigContent.project.component;
28
29
  const hasChanges = await Promise.all([
29
30
  setupMessDetector(phpConfigs),
@@ -41,16 +42,7 @@ const setupPhpConfig = () => ({
41
42
  return;
42
43
  }
43
44
 
44
- const phpConfigContent = {
45
- '?xml': {
46
- '@_version': '1.0',
47
- '@_encoding': 'UTF-8'
48
- },
49
- project: {
50
- '@_version': '4',
51
- component: []
52
- }
53
- };
45
+ const phpConfigContent = setupXMLStructure();
54
46
  const phpConfigs = phpConfigContent.project.component;
55
47
 
56
48
  await Promise.all([
@@ -0,0 +1,39 @@
1
+ const xmlConfiguration = {
2
+ '?xml': {
3
+ '@_version': '1.0',
4
+ '@_encoding': 'UTF-8'
5
+ },
6
+ project: {
7
+ '@_version': '4',
8
+ component: []
9
+ }
10
+ };
11
+
12
+ const setupXMLStructure = (data = {}) => {
13
+ if (!data) {
14
+ data = xmlConfiguration;
15
+ }
16
+ if (!('?xml' in data['?xml'])) {
17
+ data['?xml'] = xmlConfiguration['?xml'];
18
+ }
19
+
20
+ if (!('project' in data)) {
21
+ data.project = xmlConfiguration.project;
22
+ }
23
+
24
+ if (!('component' in data.project)) {
25
+ data.project.component = xmlConfiguration.project.component;
26
+ }
27
+
28
+ if (!Array.isArray(data.project.component) && Boolean(data.project.component)) {
29
+ data.project.component = [
30
+ data.project.component
31
+ ];
32
+ }
33
+
34
+ return data;
35
+ };
36
+
37
+ module.exports = {
38
+ setupXMLStructure
39
+ };
@@ -67,16 +67,6 @@ const setupComposerSettings = async (workspaceConfigs) => {
67
67
  [pharPathKey]: composerPharFormattedPath
68
68
  };
69
69
  }
70
-
71
- const composerSettingsMissingProperties = Object.entries(defaultComposerSettingsProperties)
72
- .filter(([key]) => !(key in composerSettingsComponent));
73
-
74
- if (composerSettingsMissingProperties.length > 0) {
75
- hasChanges = true;
76
- composerSettingsMissingProperties.forEach(([key, value]) => {
77
- composerSettingsComponent[key] = value;
78
- });
79
- }
80
70
  } else {
81
71
  hasChanges = true;
82
72
  workspaceConfigs.push({
@@ -1,5 +1,6 @@
1
1
  const { loadXmlFile, buildXmlFile } = require('../../../../config/xml-parser');
2
2
  const pathExists = require('../../../../util/path-exists');
3
+ const { setupXMLStructure } = require('../setup-xml-structure');
3
4
  const setupComposerSettings = require('./composer-settings-config');
4
5
  const setupFormatOnSave = require('./format-setting-config');
5
6
  const setupPHPDebugGeneral = require('./php-debug-general-config');
@@ -20,7 +21,7 @@ const setupWorkspaceConfig = () => ({
20
21
  } = ctx;
21
22
 
22
23
  if (await pathExists(phpStorm.xdebug.path)) {
23
- const workspaceConfiguration = await loadXmlFile(phpStorm.xdebug.path);
24
+ const workspaceConfiguration = setupXMLStructure(await loadXmlFile(phpStorm.xdebug.path));
24
25
  const workspaceConfigs = workspaceConfiguration.project.component;
25
26
  const hasChanges = await Promise.all([
26
27
  setupPHPDebugGeneral(workspaceConfigs, phpStorm),
@@ -38,16 +39,7 @@ const setupWorkspaceConfig = () => ({
38
39
  return;
39
40
  }
40
41
 
41
- const workspaceConfiguration = {
42
- '?xml': {
43
- '@_version': '1.0',
44
- '@_encoding': 'UTF-8'
45
- },
46
- project: {
47
- '@_version': '4',
48
- component: []
49
- }
50
- };
42
+ const workspaceConfiguration = setupXMLStructure();
51
43
  const workspaceConfigs = workspaceConfiguration.project.component;
52
44
 
53
45
  await Promise.all([
@@ -27,13 +27,13 @@ const adjustComposerJson = async ({
27
27
  const composerData = await getJsonFileData(path.join(baseConfig.magentoDir, 'composer.json'));
28
28
 
29
29
  // fix composer magento repository
30
- if (!composerData.repositories
30
+ if (composerData && (!composerData.repositories
31
31
  || (Array.isArray(composerData.repositories)
32
32
  && !composerData.repositories.some((repo) => repo.type === 'composer' && repo.url.includes('repo.magento.com'))
33
33
  )
34
34
  || (typeof composerData.repositories === 'object'
35
35
  && !Object.values(composerData.repositories).some((repo) => repo.type === 'composer' && repo.url.includes('repo.magento.com')))
36
- ) {
36
+ )) {
37
37
  task.output = 'No Magento repository is set in composer.json! Setting up...';
38
38
  await runComposerCommand('config repo.0 composer https://repo.magento.com', {
39
39
  magentoVersion,
@@ -44,7 +44,7 @@ const adjustComposerJson = async ({
44
44
  }
45
45
 
46
46
  // if composer-root-update-plugin is not installed in composer, install it.
47
- if (!composerData.require['magento/composer-root-update-plugin']) {
47
+ if (composerData && !composerData.require['magento/composer-root-update-plugin']) {
48
48
  task.output = 'Installing magento/composer-root-update-plugin!';
49
49
  await runComposerCommand('require magento/composer-root-update-plugin:^1',
50
50
  {
@@ -56,8 +56,8 @@ const adjustComposerJson = async ({
56
56
  }
57
57
 
58
58
  // if for some reason both editions are installed, throw an error
59
- if (
60
- composerData.require[magentoProductCommunityEdition]
59
+ if (composerData
60
+ && composerData.require[magentoProductCommunityEdition]
61
61
  && composerData.require[magentoProductEnterpriseEdition]
62
62
  ) {
63
63
  throw new KnownError('Somehow, both Magento editions are installed!\nPlease choose only one edition an modify your composer.json manually!');
@@ -67,7 +67,7 @@ const adjustComposerJson = async ({
67
67
  .find((edition) => edition !== magentoProductSelectedEdition);
68
68
 
69
69
  // if opposite edition is installed than selected in config file, throw an error
70
- if (composerData.require[oppositeEdition]) {
70
+ if (composerData && composerData.require[oppositeEdition]) {
71
71
  throw new KnownError(`You have installed ${oppositeEdition} but selected magento.edition as ${magentoEdition} in config file!
72
72
 
73
73
  Change magento edition in config file or manually reinstall correct magento edition!`);
@@ -75,7 +75,7 @@ Change magento edition in config file or manually reinstall correct magento edit
75
75
 
76
76
  // if magento package is not installed in composer, require it.
77
77
 
78
- if (!composerData.require[magentoProductSelectedEdition]) {
78
+ if (composerData && !composerData.require[magentoProductSelectedEdition]) {
79
79
  task.output = `Installing ${magentoProductSelectedEdition}=${magentoPackageVersion}!`;
80
80
  await runComposerCommand(`require ${magentoProductSelectedEdition}:${magentoPackageVersion}`,
81
81
  {
@@ -170,7 +170,7 @@ const installMagento = () => ({
170
170
  task.title = `Installing Magento ${magentoPackageVersion}`;
171
171
  task.output = 'Creating Magento project';
172
172
 
173
- if (!await pathExists(path.join(baseConfig.magentoDir, 'composer.json'))) {
173
+ if (!await pathExists(path.join(process.cwd(), 'composer.json'))) {
174
174
  await createMagentoProject({
175
175
  magentoProject,
176
176
  magentoPackageVersion,
@@ -1,6 +1,10 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
1
3
  const semver = require('semver');
2
4
  const UnknownError = require('../../../errors/unknown-error');
3
5
  const runMagentoCommand = require('../../../util/run-magento');
6
+ const envPhpToJson = require('../../../util/env-php-json');
7
+ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
4
8
 
5
9
  /**
6
10
  * @type {({ isDbEmpty }: { isDbEmpty: boolean }) => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
@@ -20,6 +24,21 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
20
24
  ports
21
25
  } = ctx;
22
26
  const { mysql: { env } } = docker.getContainers(ports);
27
+ const envPhpData = await envPhpToJson(process.cwd(), {
28
+ magentoVersion: ctx.magentoVersion
29
+ });
30
+
31
+ const envPhpHaveEncryptionKey = envPhpData && envPhpData.crypt && envPhpData.crypt.key && envPhpData.crypt.key;
32
+
33
+ let encryptionKeyOption = null;
34
+
35
+ if (ctx.encryptionKey) {
36
+ encryptionKeyOption = `--key='${ctx.encryptionKey}'`;
37
+ }
38
+
39
+ if (envPhpHaveEncryptionKey && !encryptionKeyOption) {
40
+ encryptionKeyOption = `--key='${envPhpData.crypt.key}'`;
41
+ }
23
42
 
24
43
  let installed = false;
25
44
 
@@ -46,6 +65,7 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
46
65
  --admin-user='${ magentoConfiguration.user }' \
47
66
  --admin-password='${ magentoConfiguration.password }' \
48
67
  ${ !isMagento23 ? elasticsearchConfiguration : '' } \
68
+ ${encryptionKeyOption || ''} \
49
69
  --session-save=redis \
50
70
  --session-save-redis-host='127.0.0.1' \
51
71
  --session-save-redis-port='${ ports.redis }' \
@@ -85,6 +105,34 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
85
105
  }
86
106
  }
87
107
 
108
+ if (errors.length > 0) {
109
+ if (envPhpHaveEncryptionKey && errors.some(
110
+ (e) => e.message.includes('The default website isn\'t defined. Set the website and try again.')
111
+ )
112
+ ) {
113
+ const confirmToWipeEnvPhp = await task.prompt({
114
+ type: 'Confirm',
115
+ message: `We detected that your encryption key in ${logger.style.file('app/etc/env.php')} file is not accepted by Magento installer.
116
+ To fix this issue we will need to ${logger.style.misc('DELETE')} ${logger.style.file('app/etc/env.php')} file. It will be recreated but existing encryption key but if you any custom configuration in it will be lost.
117
+
118
+ Without this you will not be able to install Magento at this moment.
119
+
120
+ Do you want to continue?`
121
+ });
122
+
123
+ if (confirmToWipeEnvPhp) {
124
+ try {
125
+ await fs.promises.unlink(path.join(process.cwd(), 'app', 'etc', 'env.php'));
126
+ } catch (e) {
127
+ throw new UnknownError(`Unexpected error occurred during deleting of app/etc/env.php file!\n\n${e}`);
128
+ }
129
+ ctx.encryptionKey = envPhpData.crypt.key;
130
+
131
+ return task.run(ctx);
132
+ }
133
+ }
134
+ }
135
+
88
136
  if (!installed) {
89
137
  const errorMessages = errors.map((e) => e.message).join('\n\n');
90
138
  throw new UnknownError(`Unable to install Magento!\n${errorMessages}`);
@@ -2,31 +2,57 @@ const mysql = require('mysql2/promise');
2
2
  const UnknownError = require('../../errors/unknown-error');
3
3
  const { execAsyncSpawn } = require('../../util/exec-async-command');
4
4
  const sleep = require('../../util/sleep');
5
+ const { createMagentoDatabase } = require('./create-magento-database');
5
6
 
6
7
  /**
7
- * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
8
+ * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
8
9
  */
9
- const connectToMySQL = () => ({
10
- title: 'Connecting to MySQL server...',
11
- skip: (ctx) => ctx.skipSetup,
10
+ const waitForMySQLInitialization = () => ({
11
+ title: 'Waiting for MySQL to initialize',
12
+ task: async (ctx, task) => {
13
+ const { mysql: { name } } = ctx.config.docker.getContainers();
14
+ let mysqlReadyForConnections = false;
15
+ while (!mysqlReadyForConnections) {
16
+ const mysqlOutput = await execAsyncSpawn(`docker logs ${name}`);
17
+ if (mysqlOutput.includes('ready for connections')) {
18
+ mysqlReadyForConnections = true;
19
+ break;
20
+ } else if (mysqlOutput.includes('Initializing database files')) {
21
+ task.output = `MySQL is initializing database files!
22
+ Please wait, this will take some time and do not restart the MySQL container until initialization is finished!`;
23
+
24
+ let mysqlFinishedInitialization = false;
25
+ while (!mysqlFinishedInitialization) {
26
+ const mysqlOutput = await execAsyncSpawn(`docker logs ${name}`);
27
+ if (mysqlOutput.includes('MySQL init process done.') && !mysqlFinishedInitialization) {
28
+ mysqlFinishedInitialization = true;
29
+ break;
30
+ }
31
+ await sleep(2000);
32
+ }
33
+ }
34
+
35
+ await sleep(2000);
36
+ }
37
+ },
38
+ options: {
39
+ bottomBar: 10
40
+ }
41
+ });
42
+
43
+ /**
44
+ * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
45
+ */
46
+ const gettingMySQLConnection = () => ({
47
+ title: 'Getting MySQL connection',
12
48
  task: async (ctx, task) => {
13
49
  const { config: { docker }, ports } = ctx;
14
- const { mysql: { env, name } } = docker.getContainers();
50
+ const { mysql: { env } } = docker.getContainers();
15
51
  let tries = 0;
16
- let maxTries = 20;
52
+ const maxTries = 20;
17
53
  const errors = [];
18
54
  while (tries < maxTries) {
19
55
  tries++;
20
-
21
- if (maxTries !== 120) {
22
- const mysqlOutput = await execAsyncSpawn(`docker logs ${name}`);
23
- if (mysqlOutput.includes('Initializing database files')) {
24
- maxTries = 120;
25
- task.output = `MySQL is initializing database files!
26
- Please wait, this will take some time and do not restart the MySQL container until initialization is finished!`;
27
- }
28
- await sleep(2000);
29
- }
30
56
  try {
31
57
  const connection = await mysql.createConnection({
32
58
  host: '127.0.0.1',
@@ -49,7 +75,25 @@ Please wait, this will take some time and do not restart the MySQL container unt
49
75
  }
50
76
 
51
77
  task.title = 'MySQL server connected!';
52
- },
78
+ }
79
+ });
80
+
81
+ /**
82
+ * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
83
+ */
84
+ const connectToMySQL = () => ({
85
+ title: 'Connecting to MySQL server',
86
+ skip: (ctx) => ctx.skipSetup,
87
+ task: (ctx, task) => task.newListr([
88
+ waitForMySQLInitialization(),
89
+ createMagentoDatabase(),
90
+ gettingMySQLConnection()
91
+ ], {
92
+ concurrent: false,
93
+ rendererOptions: {
94
+ collapse: true
95
+ }
96
+ }),
53
97
  options: {
54
98
  bottomBar: 10
55
99
  }
@@ -0,0 +1,18 @@
1
+ const { execAsyncSpawn } = require('../../util/exec-async-command');
2
+
3
+ /**
4
+ * Will create database 'magento' in MySQL if it does not exist for some reason
5
+ * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
6
+ */
7
+ const createMagentoDatabase = () => ({
8
+ title: 'Creating Magento database in MySQL',
9
+ task: async (ctx) => {
10
+ const { mysql } = ctx.config.docker.getContainers();
11
+
12
+ await execAsyncSpawn(`docker exec ${mysql.name} mysql -umagento -pmagento -h 127.0.0.1 -e "CREATE DATABASE IF NOT EXISTS magento;"`);
13
+ }
14
+ });
15
+
16
+ module.exports = {
17
+ createMagentoDatabase
18
+ };
@@ -17,7 +17,7 @@ const installPHPBrewDependencies = () => ({
17
17
  if (process.platform === 'darwin') {
18
18
  const installedDependencies = (await execAsyncSpawn(`${await getBrewCommand({ native: true })} list`)).split('\n');
19
19
 
20
- const dependenciesToInstall = ['php', 'autoconf', 'pkg-config'].filter((dep) => !installedDependencies.includes(dep));
20
+ const dependenciesToInstall = ['php', 'autoconf', 'pkg-config', 'gd'].filter((dep) => !installedDependencies.includes(dep));
21
21
 
22
22
  if (dependenciesToInstall.length === 0) {
23
23
  task.skip();
@@ -6,7 +6,7 @@ const getCSAThemes = async ({ cwd = process.cwd() } = {}) => {
6
6
  path.join(cwd, 'composer.json')
7
7
  );
8
8
 
9
- if (!composerData.repositories) {
9
+ if (!composerData || !composerData.repositories) {
10
10
  return [];
11
11
  }
12
12
 
@@ -253,6 +253,9 @@ class Analytics {
253
253
  // eslint-disable-next-line no-empty
254
254
  } catch (e) {
255
255
  console.log('Failed to report telemetry data');
256
+ if (process.env.GA_DEBUG) {
257
+ logger.error(e);
258
+ }
256
259
  }
257
260
  }
258
261
 
@@ -1,9 +1,14 @@
1
1
  const path = require('path');
2
2
  const UnknownError = require('../errors/unknown-error');
3
+ const pathExists = require('./path-exists');
3
4
  const runPhpCode = require('./run-php');
4
5
 
5
6
  const envPhpToJson = async (projectPath = process.cwd(), { magentoVersion }) => {
6
- const { code, result } = await runPhpCode(`-r "echo json_encode(require '${path.join(projectPath, 'app', 'etc', 'env.php')}');"`, {
7
+ const envPhpPath = path.join(projectPath, 'app', 'etc', 'env.php');
8
+ if (!await pathExists(envPhpPath)) {
9
+ return null;
10
+ }
11
+ const { code, result } = await runPhpCode(`-r "echo json_encode(require '${envPhpPath}');"`, {
7
12
  magentoVersion
8
13
  });
9
14
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Scripts and configuration used by CMA.",
4
4
  "homepage": "https://docs.create-magento-app.com/",
5
5
  "repository": "github:scandipwa/create-magento-app",
6
- "version": "1.15.0",
6
+ "version": "1.15.3",
7
7
  "main": "./index.js",
8
8
  "types": "./typings/index.d.ts",
9
9
  "license": "OSL-3.0",
@@ -36,7 +36,7 @@
36
36
  "mysql2": "2.3.2",
37
37
  "node-ssh": "12.0.0",
38
38
  "semver": "7.3.5",
39
- "smol-request": "2.1.1",
39
+ "smol-request": "^2.1.2",
40
40
  "systeminformation": "5.11.7",
41
41
  "yargs": "17.3.1"
42
42
  },
@@ -53,5 +53,5 @@
53
53
  "mysql",
54
54
  "scandipwa"
55
55
  ],
56
- "gitHead": "a38fc88b515a4a44d8e037f54b66d6021888e8e4"
56
+ "gitHead": "b3a98d7f1ad13d8566f07cf3896a0ba0d64eb005"
57
57
  }