@scandipwa/magento-scripts 2.0.0-alpha.2 → 2.0.0-alpha.5
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/docker.js +1 -1
- package/lib/config/templates/ssl-terminator.template.conf +8 -3
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +1 -1
- package/lib/tasks/magento/enable-magento-composer-plugins.js +85 -30
- package/lib/tasks/magento/install-magento-project.js +3 -2
- package/lib/tasks/magento/setup-magento/set-base-url.js +1 -1
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +3 -1
- package/lib/tasks/requirements/docker/index.js +3 -1
- package/package.json +2 -2
package/lib/config/docker.js
CHANGED
|
@@ -12,20 +12,25 @@ upstream app_backend {
|
|
|
12
12
|
server {
|
|
13
13
|
listen <%= it.hostPort %>;
|
|
14
14
|
<% if (it.config.ssl.enabled) { %> listen 443 ssl;
|
|
15
|
-
server_name <%= it.networkToBindTo %>;
|
|
16
15
|
|
|
16
|
+
ssl on;
|
|
17
17
|
ssl_certificate /etc/nginx/conf.d/ssl_certificate.pem;
|
|
18
18
|
ssl_certificate_key /etc/nginx/conf.d/ssl_certificate-key.pem;
|
|
19
19
|
ssl_protocols TLSv1.2;<% } %>
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
<% if (it.config.host) { %>
|
|
22
|
+
server_name <%= it.config.host %><% if (it.config.ssl.enabled) { %> <%= it.networkToBindTo %><% } %>;
|
|
23
|
+
<% } else { %>
|
|
24
|
+
server_name <% if (it.config.ssl.enabled) { %> <%= it.networkToBindTo %><% } else { %>_<% } %>;
|
|
25
|
+
<% } %>
|
|
22
26
|
|
|
23
27
|
location / {
|
|
24
28
|
proxy_buffer_size 128k;
|
|
25
29
|
proxy_buffers 4 256k;
|
|
26
30
|
proxy_busy_buffers_size 256k;
|
|
27
31
|
proxy_set_header X-Real-IP $remote_addr;
|
|
28
|
-
proxy_set_header X-Forwarded-For $
|
|
32
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
33
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
29
34
|
proxy_set_header Host $http_host;
|
|
30
35
|
proxy_http_version 1.1;
|
|
31
36
|
proxy_set_header Connection "";
|
|
@@ -31,7 +31,7 @@ const setupPHPWorkspaceProjectConfiguration = async (workspaceConfigs, ctx) => {
|
|
|
31
31
|
hasChanges = true;
|
|
32
32
|
workspaceConfigs.push({
|
|
33
33
|
[nameKey]: PHP_WORKSPACE_PROJECT_CONFIGURATION_COMPONENT_NAME,
|
|
34
|
-
[
|
|
34
|
+
[interpreterNameKey]: currentInterpreterImage,
|
|
35
35
|
include_path: []
|
|
36
36
|
});
|
|
37
37
|
}
|
|
@@ -4,7 +4,6 @@ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
|
4
4
|
const semver = require('semver');
|
|
5
5
|
const pathExists = require('../../util/path-exists');
|
|
6
6
|
const getJsonfileData = require('../../util/get-jsonfile-data');
|
|
7
|
-
const KnownError = require('../../errors/known-error');
|
|
8
7
|
|
|
9
8
|
const vendorPath = path.join(process.cwd(), 'vendor');
|
|
10
9
|
const composerJsonPath = path.join(process.cwd(), 'composer.json');
|
|
@@ -86,29 +85,80 @@ const enableMagentoComposerPlugins = () => ({
|
|
|
86
85
|
} = composerJsonData;
|
|
87
86
|
const allowPluginsKeys = Object.keys(allowPlugins);
|
|
88
87
|
|
|
88
|
+
const missingPluginsFromAllowPlugins = composerPlugins.filter((plugin) => {
|
|
89
|
+
const [pluginVendor, pluginName] = plugin.split('/');
|
|
90
|
+
return !allowPluginsKeys.some((allowedPlugin) => {
|
|
91
|
+
const [allowedPluginVendor, allowedPluginName] = allowedPlugin.split('/');
|
|
92
|
+
if (allowedPluginVendor === pluginVendor) {
|
|
93
|
+
if (allowedPluginName === '*') {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return allowedPluginName === pluginName;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return false;
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
89
104
|
if (
|
|
90
105
|
allowPluginsKeys.length === 0
|
|
91
|
-
||
|
|
106
|
+
|| missingPluginsFromAllowPlugins.length > 0
|
|
92
107
|
) {
|
|
93
|
-
const
|
|
108
|
+
const missingVendors = missingPluginsFromAllowPlugins.reduce((acc, val) => {
|
|
109
|
+
const [pluginVendor] = val.split('/');
|
|
110
|
+
|
|
111
|
+
if (acc.length === 0) {
|
|
112
|
+
return [pluginVendor];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (!acc.includes(pluginVendor)) {
|
|
116
|
+
return [...acc, pluginVendor];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return acc;
|
|
120
|
+
}, []);
|
|
121
|
+
|
|
122
|
+
const pluginOptions = [
|
|
123
|
+
{
|
|
124
|
+
name: 'all-individual',
|
|
125
|
+
message: 'Enable all individually'
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: 'manual',
|
|
129
|
+
message: 'Configure manually'
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: 'skip',
|
|
133
|
+
message: 'Skip this step'
|
|
134
|
+
}
|
|
135
|
+
];
|
|
136
|
+
|
|
137
|
+
if (missingVendors.length === 1) {
|
|
138
|
+
pluginOptions.unshift({
|
|
139
|
+
name: 'all',
|
|
140
|
+
message: `Enable all (${logger.style.code(`"${missingVendors[0]}/*"`)})`
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
94
144
|
const answerForEnablingPlugins = await task.prompt({
|
|
95
145
|
type: 'Select',
|
|
96
146
|
message: `Composer 2.2 requires manually allowing composer-plugins to run.
|
|
97
147
|
Magento requires the following plugins to correctly operate:
|
|
98
148
|
|
|
99
|
-
${
|
|
149
|
+
${missingPluginsFromAllowPlugins.map((p) => logger.style.code(p)).join('\n')}
|
|
100
150
|
|
|
101
151
|
Do you want to enable them all or disable some of them?`,
|
|
102
|
-
choices:
|
|
152
|
+
choices: pluginOptions
|
|
103
153
|
});
|
|
104
154
|
|
|
105
155
|
switch (answerForEnablingPlugins.toLowerCase()) {
|
|
106
|
-
case '
|
|
156
|
+
case 'all': {
|
|
107
157
|
composerJsonData.config = {
|
|
108
158
|
...(composerJsonData.config || {}),
|
|
109
159
|
'allow-plugins': {
|
|
110
160
|
...allowPlugins,
|
|
111
|
-
|
|
161
|
+
[`${missingVendors[0]}/*`]: true
|
|
112
162
|
}
|
|
113
163
|
};
|
|
114
164
|
|
|
@@ -117,36 +167,41 @@ Do you want to enable them all or disable some of them?`,
|
|
|
117
167
|
});
|
|
118
168
|
break;
|
|
119
169
|
}
|
|
120
|
-
case '
|
|
170
|
+
case 'all-individual': {
|
|
171
|
+
composerJsonData.config = {
|
|
172
|
+
...(composerJsonData.config || {}),
|
|
173
|
+
'allow-plugins': {
|
|
174
|
+
...allowPlugins,
|
|
175
|
+
...missingPluginsFromAllowPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
await fs.promises.writeFile(composerJsonPath, JSON.stringify(composerJsonData, null, 4), {
|
|
180
|
+
encoding: 'utf-8'
|
|
181
|
+
});
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
case 'manual': {
|
|
121
185
|
const userEnabledPlugins = await task.prompt({
|
|
122
186
|
type: 'MultiSelect',
|
|
123
187
|
message: 'Please pick plugins you want to enable!',
|
|
124
|
-
choices:
|
|
188
|
+
choices: missingPluginsFromAllowPlugins.map((p) => ({ name: p }))
|
|
125
189
|
});
|
|
126
190
|
|
|
127
|
-
const
|
|
128
|
-
type: 'Confirm',
|
|
129
|
-
message: `Please confirm enabling of the following plugins:\n\n${userEnabledPlugins.map((p) => logger.style.code(p)).join('\n')}\n`
|
|
130
|
-
});
|
|
191
|
+
const disabledPlugins = composerPlugins.filter((p) => !userEnabledPlugins.includes(p));
|
|
131
192
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
...(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
...userEnabledPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
|
|
141
|
-
}
|
|
142
|
-
};
|
|
193
|
+
composerJsonData.config = {
|
|
194
|
+
...(composerJsonData.config || {}),
|
|
195
|
+
'allow-plugins': {
|
|
196
|
+
...allowPlugins,
|
|
197
|
+
...disabledPlugins.reduce((acc, val) => ({ ...acc, [val]: false }), {}),
|
|
198
|
+
...userEnabledPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
|
|
199
|
+
}
|
|
200
|
+
};
|
|
143
201
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
} else {
|
|
148
|
-
throw new KnownError('Please confirm your choice or choose other option.');
|
|
149
|
-
}
|
|
202
|
+
await fs.promises.writeFile(composerJsonPath, JSON.stringify(composerJsonData, null, 4), {
|
|
203
|
+
encoding: 'utf-8'
|
|
204
|
+
});
|
|
150
205
|
|
|
151
206
|
break;
|
|
152
207
|
}
|
|
@@ -97,8 +97,9 @@ const createMagentoProject = async (ctx, task, {
|
|
|
97
97
|
`"${tempDir}"`
|
|
98
98
|
];
|
|
99
99
|
|
|
100
|
-
await runPHPContainerCommand(ctx, `
|
|
101
|
-
|
|
100
|
+
await runPHPContainerCommand(ctx, `bash -c 'mkdir ${tempDir} && \
|
|
101
|
+
composer ${installCommand.join(' ')} && \
|
|
102
|
+
mv ${tempDir}/composer.json ${ctx.config.baseConfig.containerMagentoDir}/composer.json'`);
|
|
102
103
|
};
|
|
103
104
|
|
|
104
105
|
/**
|
|
@@ -17,7 +17,7 @@ module.exports = () => ({
|
|
|
17
17
|
databaseConnection
|
|
18
18
|
} = ctx;
|
|
19
19
|
const isNgrok = host.endsWith('ngrok.io');
|
|
20
|
-
const enableSecureFrontend = ssl.enabled ? '1' : '0';
|
|
20
|
+
const enableSecureFrontend = (ctx.config.overridenConfiguration.configuration.varnish.enabled && ssl.enabled) ? '1' : '0';
|
|
21
21
|
const location = `${host}${ !isNgrok && ports.sslTerminator !== 80 ? `:${ports.sslTerminator }` : '' }/`;
|
|
22
22
|
const secureLocation = `${host}/`; // SSL will work only on port 443, so you cannot run multiple projects with SSL at the same time.
|
|
23
23
|
const httpUrl = `http://${location}`;
|
|
@@ -37,7 +37,9 @@ const getIsHealthCheckRequestBroken = async (ctx) => {
|
|
|
37
37
|
*/
|
|
38
38
|
const waitingForVarnish = () => ({
|
|
39
39
|
title: 'Waiting for Varnish to return code 200',
|
|
40
|
-
skip: (ctx) => ctx.debug
|
|
40
|
+
skip: (ctx) => ctx.debug
|
|
41
|
+
|| !ctx.config.overridenConfiguration.configuration.varnish.enabled
|
|
42
|
+
|| ctx.config.overridenConfiguration.ssl.enabled,
|
|
41
43
|
task: async (ctx, task) => {
|
|
42
44
|
const pureMagentoVersion = ctx.magentoVersion.match(/^([0-9]+\.[0-9]+\.[0-9]+)/)[1];
|
|
43
45
|
|
|
@@ -30,6 +30,7 @@ NOTE: After installation it's recommended to log out and log back in so your gro
|
|
|
30
30
|
if (automaticallyInstallDocker) {
|
|
31
31
|
return task.newListr([
|
|
32
32
|
installDocker(),
|
|
33
|
+
checkDockerSocketPermissions(),
|
|
33
34
|
getDockerVersion(),
|
|
34
35
|
{
|
|
35
36
|
task: (ctx) => {
|
|
@@ -80,6 +81,7 @@ Would you like to install it automatically using brew cask or you prefer to inst
|
|
|
80
81
|
if (confirmationToInstallDocker === 'automatic') {
|
|
81
82
|
return task.newListr([
|
|
82
83
|
installDockerOnMac(),
|
|
84
|
+
checkDockerSocketPermissions(),
|
|
83
85
|
checkDockerStatus(),
|
|
84
86
|
getDockerVersion(),
|
|
85
87
|
setVersionInContextTask(task)
|
|
@@ -122,6 +124,7 @@ const checkDocker = () => ({
|
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
return task.newListr([
|
|
127
|
+
checkDockerSocketPermissions(),
|
|
125
128
|
checkDockerStatus(),
|
|
126
129
|
getDockerVersion(),
|
|
127
130
|
setVersionInContextTask(task)
|
|
@@ -134,7 +137,6 @@ const checkDocker = () => ({
|
|
|
134
137
|
*/
|
|
135
138
|
module.exports = () => ({
|
|
136
139
|
task: (ctx, task) => task.newListr([
|
|
137
|
-
checkDockerSocketPermissions(),
|
|
138
140
|
checkDocker(),
|
|
139
141
|
checkDockerPerformance()
|
|
140
142
|
], {
|
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": "2.0.0-alpha.
|
|
6
|
+
"version": "2.0.0-alpha.5",
|
|
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": "ed87e306b9c10d353bf485c093f8883c29e05cef"
|
|
57
57
|
}
|