@scandipwa/magento-scripts 1.15.1 → 1.15.4
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.
- package/lib/config/index.js +1 -3
- package/lib/config/templates/dataSources.local.template.xml +1 -1
- package/lib/config/templates/dataSources.template.xml +1 -1
- package/lib/config/templates/magentorc.template +5 -0
- package/lib/tasks/file-system/create-phpstorm-config/database-config.js +31 -34
- package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +39 -20
- package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +37 -33
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/default-properties-config.js +3 -3
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/index.js +47 -10
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/inspection-tools-config.js +11 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +10 -26
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-config.js +20 -0
- package/lib/tasks/file-system/create-phpstorm-config/setup-xml-structure.js +40 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +1 -11
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +16 -26
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +6 -7
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +5 -6
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +7 -7
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/workspace-config.js +20 -0
- package/lib/tasks/magento/install-magento.js +8 -8
- package/lib/tasks/magento/setup-magento/install-magento.js +48 -0
- package/lib/tasks/magento/setup-magento/upgrade-magento.js +1 -1
- package/lib/tasks/mysql/connect-to-mysql.js +61 -17
- package/lib/tasks/mysql/create-magento-database.js +18 -0
- package/lib/tasks/php/install-sodium.js +1 -1
- package/lib/tasks/requirements/phpbrew/install.js +1 -1
- package/lib/util/CSA-theme.js +1 -1
- package/lib/util/env-php-json.js +6 -1
- package/lib/util/exec-async-command.d.ts +0 -10
- package/lib/util/exec-async.d.ts +10 -0
- package/lib/util/open-browser.js +1 -1
- package/package.json +2 -2
- package/lib/config/phpstorm/debug-config.js +0 -46
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
const { loadXmlFile, buildXmlFile } = require('../../../../config/xml-parser');
|
|
2
2
|
const pathExists = require('../../../../util/path-exists');
|
|
3
|
+
const { getPhpConfig } = require('../php-config/php-config');
|
|
4
|
+
const { setupXMLStructure } = require('../setup-xml-structure');
|
|
3
5
|
const setupComposerSettings = require('./composer-settings-config');
|
|
4
6
|
const setupFormatOnSave = require('./format-setting-config');
|
|
5
7
|
const setupPHPDebugGeneral = require('./php-debug-general-config');
|
|
6
8
|
const setupPHPServers = require('./php-server-config');
|
|
7
9
|
const setupPropertiesComponent = require('./properties-component-config');
|
|
8
10
|
const setupRunManager = require('./run-manager-config');
|
|
11
|
+
const { getWorkspaceConfig } = require('./workspace-config');
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* @type {() => import('listr2').ListrTask<import('../../../../../typings/context').ListrContext>}
|
|
@@ -13,24 +16,20 @@ const setupRunManager = require('./run-manager-config');
|
|
|
13
16
|
const setupWorkspaceConfig = () => ({
|
|
14
17
|
title: 'Set up Workspace configuration',
|
|
15
18
|
task: async (ctx, task) => {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} = ctx;
|
|
21
|
-
|
|
22
|
-
if (await pathExists(phpStorm.xdebug.path)) {
|
|
23
|
-
const workspaceConfiguration = await loadXmlFile(phpStorm.xdebug.path);
|
|
19
|
+
const workspaceConfig = getWorkspaceConfig(ctx.config.overridenConfiguration);
|
|
20
|
+
const phpConfig = getPhpConfig(ctx.config.overridenConfiguration);
|
|
21
|
+
if (await pathExists(workspaceConfig.path)) {
|
|
22
|
+
const workspaceConfiguration = setupXMLStructure(await loadXmlFile(workspaceConfig.path));
|
|
24
23
|
const workspaceConfigs = workspaceConfiguration.project.component;
|
|
25
24
|
const hasChanges = await Promise.all([
|
|
26
|
-
setupPHPDebugGeneral(workspaceConfigs,
|
|
27
|
-
setupPHPServers(workspaceConfigs,
|
|
28
|
-
setupRunManager(workspaceConfigs,
|
|
25
|
+
setupPHPDebugGeneral(workspaceConfigs, workspaceConfig),
|
|
26
|
+
setupPHPServers(workspaceConfigs, workspaceConfig),
|
|
27
|
+
setupRunManager(workspaceConfigs, workspaceConfig),
|
|
29
28
|
setupPropertiesComponent(workspaceConfigs)
|
|
30
29
|
]);
|
|
31
30
|
|
|
32
31
|
if (hasChanges.includes(true)) {
|
|
33
|
-
await buildXmlFile(
|
|
32
|
+
await buildXmlFile(phpConfig.path, workspaceConfiguration);
|
|
34
33
|
} else {
|
|
35
34
|
task.skip();
|
|
36
35
|
}
|
|
@@ -38,28 +37,19 @@ const setupWorkspaceConfig = () => ({
|
|
|
38
37
|
return;
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
const workspaceConfiguration =
|
|
42
|
-
'?xml': {
|
|
43
|
-
'@_version': '1.0',
|
|
44
|
-
'@_encoding': 'UTF-8'
|
|
45
|
-
},
|
|
46
|
-
project: {
|
|
47
|
-
'@_version': '4',
|
|
48
|
-
component: []
|
|
49
|
-
}
|
|
50
|
-
};
|
|
40
|
+
const workspaceConfiguration = setupXMLStructure();
|
|
51
41
|
const workspaceConfigs = workspaceConfiguration.project.component;
|
|
52
42
|
|
|
53
43
|
await Promise.all([
|
|
54
|
-
setupPHPDebugGeneral(workspaceConfigs,
|
|
55
|
-
setupPHPServers(workspaceConfigs,
|
|
56
|
-
setupRunManager(workspaceConfigs,
|
|
44
|
+
setupPHPDebugGeneral(workspaceConfigs, workspaceConfig),
|
|
45
|
+
setupPHPServers(workspaceConfigs, workspaceConfig),
|
|
46
|
+
setupRunManager(workspaceConfigs, workspaceConfig),
|
|
57
47
|
setupPropertiesComponent(workspaceConfigs),
|
|
58
48
|
setupComposerSettings(workspaceConfigs),
|
|
59
49
|
setupFormatOnSave(workspaceConfigs)
|
|
60
50
|
]);
|
|
61
51
|
|
|
62
|
-
await buildXmlFile(
|
|
52
|
+
await buildXmlFile(workspaceConfig.path, workspaceConfiguration);
|
|
63
53
|
}
|
|
64
54
|
});
|
|
65
55
|
|
package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js
CHANGED
|
@@ -10,11 +10,10 @@ const ignoreConnectionsThroughUnregisteredServersKey = '@_ignore_connections_thr
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @param {Array} workspaceConfigs
|
|
13
|
-
* @param {import('
|
|
13
|
+
* @param {ReturnType<typeof import('./workspace-config').getWorkspaceConfig>} workspaceConfig
|
|
14
14
|
* @returns {Promise<Boolean>}
|
|
15
15
|
*/
|
|
16
|
-
const setupPHPDebugGeneral = async (workspaceConfigs,
|
|
17
|
-
const { xdebug } = phpStormConfiguration;
|
|
16
|
+
const setupPHPDebugGeneral = async (workspaceConfigs, workspaceConfig) => {
|
|
18
17
|
let hasChanges = false;
|
|
19
18
|
const phpDebugGeneralComponent = workspaceConfigs.find(
|
|
20
19
|
(workspaceConfig) => workspaceConfig[nameKey] === PHP_DEBUG_GENERAL_COMPONENT_NAME
|
|
@@ -31,10 +30,10 @@ const setupPHPDebugGeneral = async (workspaceConfigs, phpStormConfiguration) =>
|
|
|
31
30
|
|
|
32
31
|
if (!(xdebugDebugPortKey in phpDebugGeneralComponent)) {
|
|
33
32
|
hasChanges = true;
|
|
34
|
-
phpDebugGeneralComponent[xdebugDebugPortKey] =
|
|
33
|
+
phpDebugGeneralComponent[xdebugDebugPortKey] = workspaceConfig.v3Port;
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
const missingXDebugPorts = [
|
|
36
|
+
const missingXDebugPorts = [workspaceConfig.v3Port, workspaceConfig.v2Port].filter(
|
|
38
37
|
(port) => !phpDebugGeneralComponent.xdebug_debug_ports.some((xPort) => xPort[portKey] === port)
|
|
39
38
|
);
|
|
40
39
|
|
|
@@ -50,9 +49,9 @@ const setupPHPDebugGeneral = async (workspaceConfigs, phpStormConfiguration) =>
|
|
|
50
49
|
hasChanges = true;
|
|
51
50
|
workspaceConfigs.push({
|
|
52
51
|
[nameKey]: PHP_DEBUG_GENERAL_COMPONENT_NAME,
|
|
53
|
-
[xdebugDebugPortKey]:
|
|
52
|
+
[xdebugDebugPortKey]: workspaceConfig.v3Port,
|
|
54
53
|
[ignoreConnectionsThroughUnregisteredServersKey]: 'true',
|
|
55
|
-
xdebug_debug_ports: [
|
|
54
|
+
xdebug_debug_ports: [workspaceConfig.v3Port, workspaceConfig.v2Port].map((port) => ({
|
|
56
55
|
[portKey]: port
|
|
57
56
|
}))
|
|
58
57
|
});
|
|
@@ -6,20 +6,19 @@ const hostKey = '@_host';
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @param {Array} workspaceConfigs
|
|
9
|
-
* @param {import('
|
|
9
|
+
* @param {ReturnType<typeof import('./workspace-config').getWorkspaceConfig>} workspaceConfig
|
|
10
10
|
* @returns {Promise<Boolean>}
|
|
11
11
|
*/
|
|
12
|
-
const setupPHPServers = async (workspaceConfigs,
|
|
13
|
-
const { xdebug } = phpStormConfiguration;
|
|
12
|
+
const setupPHPServers = async (workspaceConfigs, workspaceConfig) => {
|
|
14
13
|
let hasChanges = false;
|
|
15
14
|
const phpServersComponent = workspaceConfigs.find(
|
|
16
15
|
(workspaceConfig) => workspaceConfig[nameKey] === PHP_SERVERS_COMPONENT_NAME
|
|
17
16
|
);
|
|
18
17
|
|
|
19
18
|
const defaultServerConfig = {
|
|
20
|
-
[hostKey]:
|
|
19
|
+
[hostKey]: workspaceConfig.debugServerAddress,
|
|
21
20
|
id: '7e16e907-9ce3-4559-9d26-a30a5650d11f',
|
|
22
|
-
[nameKey]:
|
|
21
|
+
[nameKey]: workspaceConfig.serverName
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
if (phpServersComponent) {
|
|
@@ -31,7 +30,7 @@ const setupPHPServers = async (workspaceConfigs, phpStormConfiguration) => {
|
|
|
31
30
|
phpServersComponent.servers = [];
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
const serverConfiguration = phpServersComponent.servers.find((server) => server.server[nameKey] ===
|
|
33
|
+
const serverConfiguration = phpServersComponent.servers.find((server) => server.server[nameKey] === workspaceConfig.serverName);
|
|
35
34
|
|
|
36
35
|
if (!serverConfiguration) {
|
|
37
36
|
hasChanges = true;
|
|
@@ -9,23 +9,22 @@ const sessionIdKey = '@_session_id';
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @param {Array} workspaceConfigs
|
|
12
|
-
* @param {import('
|
|
12
|
+
* @param {ReturnType<typeof import('./workspace-config').getWorkspaceConfig>} workspaceConfig
|
|
13
13
|
* @returns {Promise<Boolean>}
|
|
14
14
|
*/
|
|
15
|
-
const setupRunManager = async (workspaceConfigs,
|
|
16
|
-
const { xdebug } = phpStormConfiguration;
|
|
15
|
+
const setupRunManager = async (workspaceConfigs, workspaceConfig) => {
|
|
17
16
|
let hasChanges = false;
|
|
18
17
|
const runManagerComponent = workspaceConfigs.find(
|
|
19
18
|
(workspaceConfig) => workspaceConfig[nameKey] === RUN_MANAGER_COMPONENT_NAME
|
|
20
19
|
);
|
|
21
20
|
|
|
22
21
|
const defaultRunManagerConfiguration = {
|
|
23
|
-
[nameKey]:
|
|
22
|
+
[nameKey]: workspaceConfig.runManagerName,
|
|
24
23
|
'@_type': PHP_REMOTE_DEBUG_RUN_CONFIGURATION_TYPE,
|
|
25
24
|
'@_factoryName': 'PHP Remote Debug',
|
|
26
25
|
'@_filter_connections': 'FILTER',
|
|
27
|
-
[serverNameKey]:
|
|
28
|
-
[sessionIdKey]:
|
|
26
|
+
[serverNameKey]: workspaceConfig.serverName,
|
|
27
|
+
[sessionIdKey]: workspaceConfig.sessionId,
|
|
29
28
|
method: {
|
|
30
29
|
'@_v': '2'
|
|
31
30
|
}
|
|
@@ -41,7 +40,8 @@ const setupRunManager = async (workspaceConfigs, phpStormConfiguration) => {
|
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
const phpRemoteDebugRunConfiguration = runManagerComponent.configuration.find(
|
|
44
|
-
|
|
43
|
+
// eslint-disable-next-line max-len
|
|
44
|
+
(configuration) => configuration['@_type'] === PHP_REMOTE_DEBUG_RUN_CONFIGURATION_TYPE && configuration[nameKey] === workspaceConfig.runManagerName
|
|
45
45
|
);
|
|
46
46
|
|
|
47
47
|
if (!phpRemoteDebugRunConfiguration) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { baseConfig } = require('../../../../config');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {import('../../../../../typings/index').CMAConfiguration} app
|
|
6
|
+
*/
|
|
7
|
+
const getWorkspaceConfig = (app) => ({
|
|
8
|
+
v2Port: '9111',
|
|
9
|
+
v3Port: '9003',
|
|
10
|
+
debugServerAddress: `http://${ app.host }`,
|
|
11
|
+
serverName: 'create-magento-app',
|
|
12
|
+
runManagerName: 'create-magento-app',
|
|
13
|
+
sessionId: 'PHPSTORM',
|
|
14
|
+
path: path.join(process.cwd(), '.idea', 'workspace.xml'),
|
|
15
|
+
templatePath: path.join(baseConfig.templateDir, 'workspace.template.xml')
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
module.exports = {
|
|
19
|
+
getWorkspaceConfig
|
|
20
|
+
};
|
|
@@ -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(
|
|
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
|
-
* @
|
|
8
|
+
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
8
9
|
*/
|
|
9
|
-
const
|
|
10
|
-
title: '
|
|
11
|
-
|
|
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
|
|
50
|
+
const { mysql: { env } } = docker.getContainers();
|
|
15
51
|
let tries = 0;
|
|
16
|
-
|
|
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
|
+
};
|
|
@@ -33,7 +33,7 @@ const installSodiumExtension = () => ({
|
|
|
33
33
|
const extractedArchivePath = path.join(tempDir, 'libsodium-stable');
|
|
34
34
|
const enabledExtensions = await getEnabledExtensions(ctx.config);
|
|
35
35
|
|
|
36
|
-
if (
|
|
36
|
+
if (enabledExtensions.sodium !== undefined) {
|
|
37
37
|
cmaGlobalConfig.set(HAS_LIBSODIUM_BEEN_INSTALLED, true);
|
|
38
38
|
task.skip();
|
|
39
39
|
return;
|
|
@@ -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();
|
package/lib/util/CSA-theme.js
CHANGED
package/lib/util/env-php-json.js
CHANGED
|
@@ -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
|
|
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
|
|
|
@@ -25,16 +25,6 @@ export function execAsyncSpawn (
|
|
|
25
25
|
options?: ExecAsyncSpawnOptions<true>
|
|
26
26
|
): Promise<{ code: number, result: string }>;
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
* Execute bash command
|
|
30
|
-
* @param command Bash command
|
|
31
|
-
* @param options Child process exec options ([docs](https://nodejs.org/dist/latest-v14.x/docs/api/child_process.html#child_process_child_process_exec_command_options_callback))
|
|
32
|
-
*/
|
|
33
|
-
export function execAsync(
|
|
34
|
-
command: string,
|
|
35
|
-
options?: { encoding: BufferEncoding } & ExecOptions
|
|
36
|
-
): Promise<string>
|
|
37
|
-
|
|
38
28
|
export function execCommandTask(
|
|
39
29
|
command: string,
|
|
40
30
|
options?: Omit<ExecAsyncSpawnOptions<false>, 'callback'>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
/**
|
|
3
|
+
* Execute bash command
|
|
4
|
+
* @param command Bash command
|
|
5
|
+
* @param options Child process exec options ([docs](https://nodejs.org/dist/latest-v14.x/docs/api/child_process.html#child_process_child_process_exec_command_options_callback))
|
|
6
|
+
*/
|
|
7
|
+
export function execAsync(
|
|
8
|
+
command: string,
|
|
9
|
+
options?: { encoding: BufferEncoding } & ExecOptions
|
|
10
|
+
): Promise<string>
|
package/lib/util/open-browser.js
CHANGED
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.
|
|
6
|
+
"version": "1.15.4",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"types": "./typings/index.d.ts",
|
|
9
9
|
"license": "OSL-3.0",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"mysql",
|
|
54
54
|
"scandipwa"
|
|
55
55
|
],
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "dca735e563dd90fd22fbb8bf706c122f2002bda8"
|
|
57
57
|
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
|
|
3
|
-
const getPhpStormConfig = (app, config) => {
|
|
4
|
-
const [majorPHPVersion, minorPHPVersion] = app.configuration.php.version.split('.');
|
|
5
|
-
const phpLanguageLevel = `${ majorPHPVersion }.${ minorPHPVersion }`;
|
|
6
|
-
const { templateDir } = config;
|
|
7
|
-
const phpStormConfiguration = {
|
|
8
|
-
xdebug: {
|
|
9
|
-
v2Port: '9111',
|
|
10
|
-
v3Port: '9003',
|
|
11
|
-
debugServerAddress: `http://${ app.host }`,
|
|
12
|
-
serverName: 'create-magento-app',
|
|
13
|
-
runManagerName: 'create-magento-app',
|
|
14
|
-
sessionId: 'PHPSTORM',
|
|
15
|
-
path: path.join(process.cwd(), '.idea', 'workspace.xml'),
|
|
16
|
-
templatePath: path.join(templateDir, 'workspace.template.xml')
|
|
17
|
-
},
|
|
18
|
-
php: {
|
|
19
|
-
phpLanguageLevel,
|
|
20
|
-
path: path.join(process.cwd(), '.idea', 'php.xml'),
|
|
21
|
-
templatePath: path.join(templateDir, 'php.template.xml')
|
|
22
|
-
},
|
|
23
|
-
database: {
|
|
24
|
-
driver: 'mysql',
|
|
25
|
-
dataSourceManagerName: 'mysql 8.0',
|
|
26
|
-
dataSourcesLocal: {
|
|
27
|
-
path: path.join(process.cwd(), '.idea', 'dataSources.local.xml'),
|
|
28
|
-
templatePath: path.join(templateDir, 'dataSources.local.template.xml')
|
|
29
|
-
},
|
|
30
|
-
dataSources: {
|
|
31
|
-
path: path.join(process.cwd(), '.idea', 'dataSources.xml'),
|
|
32
|
-
templatePath: path.join(templateDir, 'dataSources.template.xml')
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
inspectionTools: {
|
|
36
|
-
path: path.join(process.cwd(), '.idea', 'inspectionProfiles', 'Project_Default.xml'),
|
|
37
|
-
templatePath: path.join(templateDir, 'Project_Default.template.xml')
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
return phpStormConfiguration;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
module.exports = {
|
|
45
|
-
getPhpStormConfig
|
|
46
|
-
};
|