@scandipwa/magento-scripts 1.14.1-alpha.1 → 1.14.1-alpha.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/index.js +13 -0
- package/lib/commands/cli.js +28 -1
- package/lib/commands/execute.js +2 -1
- package/lib/config/docker.js +45 -9
- package/lib/config/get-port-config.js +2 -1
- package/lib/config/port-config.js +1 -0
- package/lib/config/templates/magentorc.template +3 -5
- package/lib/config/templates/php.template.ini +6 -4
- package/lib/config/templates/varnish.template.vcl +241 -0
- package/lib/config/versions/magento-2.3.0.js +9 -0
- package/lib/config/versions/magento-2.3.1.js +9 -0
- package/lib/config/versions/magento-2.3.2-p2.js +9 -0
- package/lib/config/versions/magento-2.3.2.js +9 -0
- package/lib/config/versions/magento-2.3.3-p1.js +9 -0
- package/lib/config/versions/magento-2.3.3.js +9 -0
- package/lib/config/versions/magento-2.3.4-p2.js +9 -0
- package/lib/config/versions/magento-2.3.4.js +9 -0
- package/lib/config/versions/magento-2.3.5-p1.js +9 -0
- package/lib/config/versions/magento-2.3.5-p2.js +9 -0
- package/lib/config/versions/magento-2.3.5.js +9 -0
- package/lib/config/versions/magento-2.3.6-p1.js +9 -0
- package/lib/config/versions/magento-2.3.6.js +9 -0
- package/lib/config/versions/magento-2.3.7-p1.js +9 -0
- package/lib/config/versions/magento-2.3.7-p2.js +9 -0
- package/lib/config/versions/magento-2.3.7-p3.js +9 -0
- package/lib/config/versions/magento-2.3.7.js +9 -0
- package/lib/config/versions/magento-2.4.0-p1.js +9 -0
- package/lib/config/versions/magento-2.4.0.js +9 -0
- package/lib/config/versions/magento-2.4.1-p1.js +9 -0
- package/lib/config/versions/magento-2.4.1.js +9 -0
- package/lib/config/versions/magento-2.4.2-p1.js +9 -0
- package/lib/config/versions/magento-2.4.2-p2.js +9 -0
- package/lib/config/versions/magento-2.4.2.js +9 -0
- package/lib/config/versions/magento-2.4.3-p1.js +9 -0
- package/lib/config/versions/magento-2.4.3-p2.js +9 -0
- package/lib/config/versions/magento-2.4.3.js +9 -0
- package/lib/config/versions/magento-2.4.4.js +9 -0
- package/lib/tasks/cli/create-bashrc-config.js +5 -2
- package/lib/tasks/docker/containers.js +10 -8
- package/lib/tasks/docker/volumes.js +4 -4
- package/lib/tasks/file-system/create-nginx-config.js +5 -0
- package/lib/tasks/file-system/create-php-storm-config.js +82 -0
- package/lib/tasks/file-system/create-varnish-config.js +51 -0
- package/lib/tasks/file-system/index.js +4 -2
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +1 -1
- package/lib/tasks/magento/setup-magento/disable-2fa.js +4 -12
- package/lib/tasks/magento/setup-magento/disable-full-page-cache.js +20 -0
- package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +14 -16
- package/lib/tasks/magento/setup-magento/migrate-database.js +21 -6
- package/lib/tasks/magento/setup-magento/varnish-config.js +63 -0
- package/lib/tasks/mysql/fix-db.js +2 -2
- package/lib/tasks/php/index.js +1 -1
- package/lib/tasks/php/update-env-php.js +16 -1
- package/lib/tasks/php/update-env.php +54 -12
- package/lib/tasks/requirements/docker/index.js +2 -0
- package/lib/tasks/requirements/docker/install.js +11 -11
- package/lib/tasks/requirements/docker/running-status.js +137 -0
- package/lib/tasks/requirements/docker/version.js +2 -0
- package/lib/tasks/requirements/index.js +5 -5
- package/lib/tasks/requirements/php-version.js +3 -1
- package/lib/tasks/start.js +2 -6
- package/lib/tasks/status/index.js +1 -1
- package/lib/tasks/theme/link-theme.js +2 -2
- package/lib/tasks/theme/setup-persisted-query.js +3 -3
- package/lib/tasks/theme/setup-themes.js +2 -2
- package/lib/util/config-file-validator.js +11 -1
- package/lib/util/config-php-json.js +19 -0
- package/lib/util/instance-metadata.js +1 -7
- package/lib/util/is-running-root.js +3 -0
- package/lib/util/php-task.js +6 -2
- package/lib/util/run-php.js +7 -1
- package/lib/util/systemctl.js +46 -0
- package/package.json +2 -3
- package/typings/context.d.ts +1 -2
- package/typings/index.d.ts +19 -0
- package/lib/config/xml-parser.js +0 -61
- package/lib/tasks/file-system/create-phpstorm-config/database-config.js +0 -248
- package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +0 -83
- package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +0 -154
- package/lib/tasks/file-system/create-phpstorm-config/index.js +0 -27
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/coding-standard-config.js +0 -29
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/config.js +0 -54
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +0 -31
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/default-properties-config.js +0 -42
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/eslint-inspection-config.js +0 -37
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/index.js +0 -80
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/magento-coding-standard-config.js +0 -29
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/mess-detector-validation-inspection-config.js +0 -145
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/paths.js +0 -20
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-fixer-validation-inspection-config.js +0 -60
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-validation-inspection-config.js +0 -119
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/stylelint-inspection-config.js +0 -37
- package/lib/tasks/file-system/create-phpstorm-config/keys.js +0 -14
- package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +0 -67
- package/lib/tasks/file-system/create-phpstorm-config/php-config/mess-detector-config.js +0 -57
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-code-sniffer-config.js +0 -76
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-cs-fixer-config.js +0 -63
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-project-shared-configuration-config.js +0 -69
- package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +0 -77
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +0 -98
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/format-setting-config.js +0 -57
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +0 -66
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +0 -64
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +0 -60
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/properties-component-config.js +0 -51
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +0 -74
- package/lib/tasks/file-system/create-phpstorm-config/xml-utils.js +0 -5
- package/lib/tasks/magento/setup-magento/adjust-magento-configuration.js +0 -27
- package/lib/tasks/magento/setup-magento/disable-page-cache.js +0 -11
- package/typings/phpstorm.d.ts +0 -33
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
const os = require('os');
|
|
2
|
+
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
3
|
+
const getIsWsl = require('../../../util/is-wsl');
|
|
4
|
+
const pathExists = require('../../../util/path-exists');
|
|
5
|
+
const sleep = require('../../../util/sleep');
|
|
6
|
+
const { systemctlControl } = require('../../../util/systemctl');
|
|
7
|
+
|
|
8
|
+
const pathToDockerApplication = '/Applications/Docker.app';
|
|
9
|
+
|
|
10
|
+
const getDockerVersion = () => execAsyncSpawn('docker version --format {{.Server.Version}}', {
|
|
11
|
+
withCode: true
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
16
|
+
*/
|
|
17
|
+
const checkDockerStatusMacOS = () => ({
|
|
18
|
+
title: 'Checking Docker status on MacOS',
|
|
19
|
+
task: async (ctx, task) => {
|
|
20
|
+
const { result, code } = await getDockerVersion();
|
|
21
|
+
|
|
22
|
+
if (code !== 0 && result.includes('Is the docker daemon running?')) {
|
|
23
|
+
const dockerOpenAppConfirmation = await task.prompt({
|
|
24
|
+
type: 'Confirm',
|
|
25
|
+
message: 'Looks like Docker is not running, would you like us to open a Docker for Mac application and wait for it to start up?'
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (dockerOpenAppConfirmation && await pathExists(pathToDockerApplication)) {
|
|
29
|
+
await execAsyncSpawn(`open ${pathToDockerApplication}`);
|
|
30
|
+
let ready = false;
|
|
31
|
+
let attempts = 0;
|
|
32
|
+
while (!ready) {
|
|
33
|
+
if (attempts > 24 && !ready) {
|
|
34
|
+
throw new Error('Docker haven\'t started in 2 mins, exiting...');
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const { code: startupCode } = await getDockerVersion();
|
|
38
|
+
if (startupCode !== 0) {
|
|
39
|
+
task.output = `Waiting for Docker to startup for ${attempts * 5} seconds...`;
|
|
40
|
+
attempts++;
|
|
41
|
+
await sleep(5000);
|
|
42
|
+
} else {
|
|
43
|
+
ready = true;
|
|
44
|
+
}
|
|
45
|
+
} catch (e) {
|
|
46
|
+
//
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
task.skip('User skipped running Docker');
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
options: {
|
|
57
|
+
bottomBar: 10
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
63
|
+
*/
|
|
64
|
+
const checkDockerStatusWSL = () => ({
|
|
65
|
+
title: 'Checking Docker status on Windows WSL',
|
|
66
|
+
task: async () => {
|
|
67
|
+
const { result, code } = await getDockerVersion();
|
|
68
|
+
|
|
69
|
+
if (code !== 0 && result.includes('Is the docker daemon running?')) {
|
|
70
|
+
throw new Error(`Docker is not running!
|
|
71
|
+
|
|
72
|
+
Please open Docker Desktop application for Windows and make sure that Docker is running. Then you can try again!`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
79
|
+
*/
|
|
80
|
+
const checkDockerStatusLinux = () => ({
|
|
81
|
+
title: 'Checking Docker status on Linux',
|
|
82
|
+
task: async (ctx, task) => {
|
|
83
|
+
const dockerService = systemctlControl('docker');
|
|
84
|
+
|
|
85
|
+
const isRunning = await dockerService.isRunning();
|
|
86
|
+
const isEnabled = await dockerService.isEnabled();
|
|
87
|
+
|
|
88
|
+
if (!isEnabled && !isRunning) {
|
|
89
|
+
const dockerStartConfirmation = await task.prompt({
|
|
90
|
+
type: 'Confirm',
|
|
91
|
+
message: `Looks like Docker is not enabled and not running, would you like to enable and run it?
|
|
92
|
+
|
|
93
|
+
This action requires root privileges.`
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
if (dockerStartConfirmation) {
|
|
97
|
+
await dockerService.enableAndStart();
|
|
98
|
+
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
task.skip('User skipped running Docker');
|
|
102
|
+
} else if (!isRunning) {
|
|
103
|
+
const dockerStartConfirmation = await task.prompt({
|
|
104
|
+
type: 'Confirm',
|
|
105
|
+
message: `Looks like Docker is not running, would you like to run it?
|
|
106
|
+
|
|
107
|
+
This action requires root privileges.`
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
if (dockerStartConfirmation) {
|
|
111
|
+
await dockerService.start();
|
|
112
|
+
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
task.skip('User skipped running Docker');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
122
|
+
*/
|
|
123
|
+
const checkDockerStatus = () => ({
|
|
124
|
+
title: 'Checking Docker status',
|
|
125
|
+
task: async (ctx, task) => {
|
|
126
|
+
if (os.platform() === 'darwin') {
|
|
127
|
+
return task.newListr(checkDockerStatusMacOS());
|
|
128
|
+
}
|
|
129
|
+
if (!await getIsWsl()) {
|
|
130
|
+
return task.newListr(checkDockerStatusLinux());
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return task.newListr(checkDockerStatusWSL());
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
module.exports = checkDockerStatus;
|
|
@@ -13,6 +13,8 @@ const getDockerVersion = () => ({
|
|
|
13
13
|
const dockerVersion = result.split('').filter((c) => /[\d.]/i.test(c)).join('') || result;
|
|
14
14
|
|
|
15
15
|
ctx.dockerVersion = dockerVersion;
|
|
16
|
+
} else {
|
|
17
|
+
throw new Error(`Got unexpected result during Docker version retrieval!\n\n${ result }`);
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
});
|
|
@@ -13,17 +13,17 @@ const checkRequirements = () => ({
|
|
|
13
13
|
task: (ctx, task) => task.newListr([
|
|
14
14
|
// checking if user is on supported platform
|
|
15
15
|
checkPlatform(),
|
|
16
|
+
// check the Docker installation
|
|
17
|
+
checkDocker(),
|
|
18
|
+
// check for Node.js version
|
|
19
|
+
checkNodeVersion(),
|
|
16
20
|
// check the PHPBrew installation
|
|
17
21
|
checkPHPbrew(),
|
|
18
22
|
// check installed PHP version
|
|
19
23
|
checkPHPVersion(),
|
|
20
|
-
// check the Docker installation
|
|
21
|
-
checkDocker(),
|
|
22
24
|
// check for COMPOSER_AUTH or auth.json
|
|
23
25
|
// localAuthJson(),
|
|
24
|
-
checkComposer()
|
|
25
|
-
// check for Node.js version
|
|
26
|
-
checkNodeVersion()
|
|
26
|
+
checkComposer()
|
|
27
27
|
], {
|
|
28
28
|
concurrent: false,
|
|
29
29
|
exitOnError: true,
|
|
@@ -99,7 +99,7 @@ const checkPHPVersion = () => ({
|
|
|
99
99
|
task: async (ctx, task) => {
|
|
100
100
|
const phpVersionResponse = await execAsyncSpawn('php --version');
|
|
101
101
|
|
|
102
|
-
const phpVersionResponseResult = phpVersionResponse.match(/PHP\s(\d
|
|
102
|
+
const phpVersionResponseResult = phpVersionResponse.match(/PHP\s(\d+\.\d+\.\d+)/i);
|
|
103
103
|
|
|
104
104
|
if (phpVersionResponseResult && phpVersionResponseResult.length > 0) {
|
|
105
105
|
const phpVersion = phpVersionResponseResult[1];
|
|
@@ -123,6 +123,8 @@ To fix that we will build special PHP version that will be used by PHPBrew, plea
|
|
|
123
123
|
);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
+
|
|
127
|
+
task.title = `Using PHP version ${phpVersion} in system`;
|
|
126
128
|
}
|
|
127
129
|
}
|
|
128
130
|
});
|
package/lib/tasks/start.js
CHANGED
|
@@ -29,7 +29,6 @@ const convertLegacyVolumes = require('./docker/convert-legacy-volumes');
|
|
|
29
29
|
const enableMagentoComposerPlugins = require('./magento/enable-magento-composer-plugins');
|
|
30
30
|
const getIsWsl = require('../util/is-wsl');
|
|
31
31
|
const checkForXDGOpen = require('../util/xdg-open-exists');
|
|
32
|
-
const { getInstanceMetadata, constants: { WEB_LOCATION_TITLE } } = require('../util/instance-metadata');
|
|
33
32
|
|
|
34
33
|
/**
|
|
35
34
|
* @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
@@ -190,11 +189,8 @@ const start = () => ({
|
|
|
190
189
|
|
|
191
190
|
return false;
|
|
192
191
|
},
|
|
193
|
-
task: (
|
|
194
|
-
|
|
195
|
-
const locationOnTheWeb = instanceMetadata.frontend.find(({ title }) => title === WEB_LOCATION_TITLE);
|
|
196
|
-
|
|
197
|
-
openBrowser(locationOnTheWeb.text);
|
|
192
|
+
task: ({ ports, config: { overridenConfiguration: { host, ssl } } }) => {
|
|
193
|
+
openBrowser(`${ssl.enabled ? 'https' : 'http'}://${host}${ssl.enabled || ports.app === 80 ? '' : `:${ports.app}`}/`);
|
|
198
194
|
},
|
|
199
195
|
options: {
|
|
200
196
|
showTimer: false
|
|
@@ -91,7 +91,7 @@ const prettyStatus = async (ctx) => {
|
|
|
91
91
|
.addLine(`Image: ${logger.style.file(container.image)}`)
|
|
92
92
|
.addLine(`Network: ${logger.style.link(container.network)}`);
|
|
93
93
|
|
|
94
|
-
if (container.ports.length > 0) {
|
|
94
|
+
if (container.ports && container.ports.length > 0) {
|
|
95
95
|
block.addLine('Port forwarding:');
|
|
96
96
|
container.ports.forEach((port) => {
|
|
97
97
|
const { host, hostPort, containerPort } = parsePort(port);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const symlinkTheme = require('./symlink-theme');
|
|
2
2
|
const installTheme = require('./install-theme');
|
|
3
|
-
const
|
|
3
|
+
const disableFullPageCache = require('../magento/setup-magento/disable-full-page-cache');
|
|
4
4
|
const disablePageBuilder = require('../magento/setup-magento/disable-page-builder');
|
|
5
5
|
const buildTheme = require('./build-theme');
|
|
6
6
|
const upgradeMagento = require('../magento/setup-magento/upgrade-magento');
|
|
@@ -53,7 +53,7 @@ const linkTheme = () => ({
|
|
|
53
53
|
updateEnvPHP(),
|
|
54
54
|
setupPersistedQuery(),
|
|
55
55
|
upgradeMagento(),
|
|
56
|
-
|
|
56
|
+
disableFullPageCache(),
|
|
57
57
|
...(isPageBuilderInstalled && Number(isPagebuilderEnabled) ? [disablePageBuilder()] : []),
|
|
58
58
|
buildTheme(theme)
|
|
59
59
|
]);
|
|
@@ -8,7 +8,7 @@ const runMagentoCommand = require('../../util/run-magento');
|
|
|
8
8
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
9
9
|
*/
|
|
10
10
|
const persistedQuerySetup = () => ({
|
|
11
|
-
title: 'Setting up
|
|
11
|
+
title: 'Setting up Redis configuration for persisted queries',
|
|
12
12
|
task: async (ctx, task) => {
|
|
13
13
|
const { ports, magentoVersion, verbose = false } = ctx;
|
|
14
14
|
const composerLockData = await getJsonfileData(path.join(process.cwd(), 'composer.lock'));
|
|
@@ -29,8 +29,8 @@ const persistedQuerySetup = () => ({
|
|
|
29
29
|
if (
|
|
30
30
|
persistedQueryConfig
|
|
31
31
|
&& persistedQueryConfig.redis
|
|
32
|
-
&& persistedQueryConfig.redis.port === ports.redis
|
|
33
|
-
&& persistedQueryConfig.redis.
|
|
32
|
+
&& persistedQueryConfig.redis.port === `${ ports.redis }`
|
|
33
|
+
&& persistedQueryConfig.redis.host === 'localhost'
|
|
34
34
|
) {
|
|
35
35
|
task.skip();
|
|
36
36
|
return;
|
|
@@ -5,7 +5,7 @@ const symlinkTheme = require('./symlink-theme');
|
|
|
5
5
|
const installTheme = require('./install-theme');
|
|
6
6
|
const setupPersistedQuery = require('./setup-persisted-query');
|
|
7
7
|
const upgradeMagento = require('../magento/setup-magento/upgrade-magento');
|
|
8
|
-
const
|
|
8
|
+
const disableFullPageCache = require('../magento/setup-magento/disable-full-page-cache');
|
|
9
9
|
const buildTheme = require('./build-theme');
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -80,7 +80,7 @@ const setupThemes = () => ({
|
|
|
80
80
|
])
|
|
81
81
|
})).concat([
|
|
82
82
|
upgradeMagento(),
|
|
83
|
-
|
|
83
|
+
disableFullPageCache(),
|
|
84
84
|
setupPersistedQuery()
|
|
85
85
|
])
|
|
86
86
|
);
|
|
@@ -72,6 +72,15 @@ const nginxConfigurationSchema = Joi.object({
|
|
|
72
72
|
configTemplate: Joi.string().optional().custom(fileExistsValidator)
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* @type {Joi.ObjectSchema<import('../../typings').NginxConfiguration>}
|
|
77
|
+
*/
|
|
78
|
+
const varnishConfigurationSchema = Joi.object({
|
|
79
|
+
enabled: Joi.boolean().optional(),
|
|
80
|
+
version: Joi.string().optional(),
|
|
81
|
+
configTemplate: Joi.string().optional().custom(fileExistsValidator)
|
|
82
|
+
});
|
|
83
|
+
|
|
75
84
|
/**
|
|
76
85
|
* @type {Joi.ObjectSchema<import('../../typings').ServiceWithVersion>}
|
|
77
86
|
*/
|
|
@@ -101,7 +110,8 @@ const configurationSchema = Joi.object({
|
|
|
101
110
|
mysql: serviceConfigurationSchema.optional(),
|
|
102
111
|
elasticsearch: serviceConfigurationSchema.optional(),
|
|
103
112
|
redis: serviceConfigurationSchema.optional(),
|
|
104
|
-
composer: composerConfigurationSchema.optional()
|
|
113
|
+
composer: composerConfigurationSchema.optional(),
|
|
114
|
+
varnish: varnishConfigurationSchema.optional()
|
|
105
115
|
});
|
|
106
116
|
|
|
107
117
|
/**
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const runPhpCode = require('./run-php');
|
|
3
|
+
|
|
4
|
+
const configPhpToJson = async (projectPath = process.cwd(), { magentoVersion }) => {
|
|
5
|
+
const { code, result } = await runPhpCode(`-r "echo json_encode(require '${path.join(projectPath, 'app', 'etc', 'config.php')}');"`, {
|
|
6
|
+
magentoVersion
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
if (code !== 0) {
|
|
10
|
+
throw new Error(result);
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(result);
|
|
14
|
+
} catch (e) {
|
|
15
|
+
throw new Error(`Ooops! Something went wrong when trying to parse app/etc/config.php file!\n\n${e}\n\nFile result: ${result}`);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports = configPhpToJson;
|
|
@@ -70,11 +70,5 @@ const getInstanceMetadata = (ctx) => {
|
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
module.exports = {
|
|
73
|
-
getInstanceMetadata
|
|
74
|
-
constants: {
|
|
75
|
-
WEB_LOCAL_LOCATION_TITLE,
|
|
76
|
-
WEB_LOCATION_TITLE,
|
|
77
|
-
WEB_ADMIN_LOCATION_TITLE,
|
|
78
|
-
WEB_ADMIN_CREDENTIALS_TITLE
|
|
79
|
-
}
|
|
73
|
+
getInstanceMetadata
|
|
80
74
|
};
|
package/lib/util/php-task.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
const runPhpCode = require('./run-php');
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @type {(
|
|
4
|
+
* @type {(
|
|
5
|
+
* command: string,
|
|
6
|
+
* options: { noTitle: boolean, env: Record<string, string> }
|
|
7
|
+
* ) => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
5
8
|
*/
|
|
6
9
|
const phpTask = (command, options = {}) => ({
|
|
7
10
|
title: !options.noTitle ? `Running command 'php ${command}` : undefined,
|
|
@@ -10,7 +13,8 @@ const phpTask = (command, options = {}) => ({
|
|
|
10
13
|
task.output = t;
|
|
11
14
|
},
|
|
12
15
|
throwNonZeroCode: true,
|
|
13
|
-
magentoVersion
|
|
16
|
+
magentoVersion,
|
|
17
|
+
env: options.env
|
|
14
18
|
})
|
|
15
19
|
});
|
|
16
20
|
|
package/lib/util/run-php.js
CHANGED
|
@@ -10,6 +10,7 @@ const { getConfigFromMagentoVersion, defaultConfiguration } = require('../config
|
|
|
10
10
|
* @param {() => {}} options.callback
|
|
11
11
|
* @param {Boolean} options.throwNonZeroCode Throw if command return non 0 code.
|
|
12
12
|
* @param {String} options.magentoVersion Magento version for config
|
|
13
|
+
* @param {Record<string, string>} options.env Environment variables
|
|
13
14
|
*/
|
|
14
15
|
const runPhpCode = async (command, options = {}) => {
|
|
15
16
|
const {
|
|
@@ -17,7 +18,12 @@ const runPhpCode = async (command, options = {}) => {
|
|
|
17
18
|
magentoVersion = defaultConfiguration.magentoVersion
|
|
18
19
|
} = options;
|
|
19
20
|
const { php } = await getConfigFromMagentoVersion(magentoVersion);
|
|
20
|
-
|
|
21
|
+
let spawnCommand = `${php.binPath} -c ${php.iniPath} ${command}`;
|
|
22
|
+
if (options.env && Object.keys(options.env).length > 0) {
|
|
23
|
+
const env = Object.entries(options.env).map(([key, value]) => `${key}=${value}`).join(' ');
|
|
24
|
+
spawnCommand = `${env} ${spawnCommand}`;
|
|
25
|
+
}
|
|
26
|
+
const { code, result } = await execAsyncSpawn(spawnCommand, {
|
|
21
27
|
...options,
|
|
22
28
|
withCode: true
|
|
23
29
|
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const { execAsyncSpawn } = require('./exec-async-command');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {String} cmd
|
|
5
|
+
* @param {String} serviceName
|
|
6
|
+
* @param {{ now: boolean }} options
|
|
7
|
+
*/
|
|
8
|
+
const run = (cmd, serviceName, options = {}) => execAsyncSpawn(
|
|
9
|
+
`systemctl ${ cmd }${ serviceName ? ` ${ serviceName }` : '' }${ options.now ? ' --now' : ''}`,
|
|
10
|
+
{
|
|
11
|
+
withCode: true
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const daemonReload = () => run('daemon-reload');
|
|
16
|
+
|
|
17
|
+
const systemctlControl = (serviceName) => ({
|
|
18
|
+
disable: () => run('disable', serviceName),
|
|
19
|
+
enable: () => run('enable', serviceName),
|
|
20
|
+
enableAndStart: () => run('enable', serviceName, { now: true }),
|
|
21
|
+
restart: () => run('restart', serviceName),
|
|
22
|
+
start: () => run('start', serviceName),
|
|
23
|
+
stop: () => run('stop', serviceName),
|
|
24
|
+
isEnabled: async () => {
|
|
25
|
+
try {
|
|
26
|
+
const { result } = await run('is-enabled', serviceName);
|
|
27
|
+
return result.includes('enabled');
|
|
28
|
+
} catch (e) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
isRunning: async () => {
|
|
33
|
+
try {
|
|
34
|
+
const { result } = await run('status', serviceName);
|
|
35
|
+
|
|
36
|
+
return result.includes('active (running)');
|
|
37
|
+
} catch (e) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
module.exports = {
|
|
44
|
+
systemctlControl,
|
|
45
|
+
daemonReload
|
|
46
|
+
};
|
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.14.1-alpha.
|
|
6
|
+
"version": "1.14.1-alpha.4",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"types": "./typings/index.d.ts",
|
|
9
9
|
"license": "OSL-3.0",
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
"conf": "10.1.1",
|
|
27
27
|
"enquirer": "2.3.6",
|
|
28
28
|
"eta": "1.12.3",
|
|
29
|
-
"fast-xml-parser": "^4.0.7",
|
|
30
29
|
"hjson": "^3.2.2",
|
|
31
30
|
"is-installed-globally": "0.4.0",
|
|
32
31
|
"joi": "17.6.0",
|
|
@@ -52,5 +51,5 @@
|
|
|
52
51
|
"mysql",
|
|
53
52
|
"scandipwa"
|
|
54
53
|
],
|
|
55
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "41436e9871ef44477f79f93c751b5d7315de8187"
|
|
56
55
|
}
|
package/typings/context.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import mysql2 from 'mysql2';
|
|
2
2
|
|
|
3
3
|
import { CMAConfiguration, PHPExtensions } from './index';
|
|
4
|
-
import { PHPStormConfig } from './phpstorm';
|
|
5
4
|
|
|
6
5
|
export interface ListrContext {
|
|
7
6
|
magentoVersion: string
|
|
@@ -13,6 +12,7 @@ export interface ListrContext {
|
|
|
13
12
|
mysql: number
|
|
14
13
|
redis: number
|
|
15
14
|
elasticsearch: number
|
|
15
|
+
varnish: number
|
|
16
16
|
}
|
|
17
17
|
arch: 'arm64' | 'x64'
|
|
18
18
|
isArm: boolean
|
|
@@ -83,7 +83,6 @@ export interface ListrContext {
|
|
|
83
83
|
overridenConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
|
|
84
84
|
userConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
|
|
85
85
|
nonOverridenConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
|
|
86
|
-
phpStorm: PHPStormConfig
|
|
87
86
|
}
|
|
88
87
|
systemConfiguration: {
|
|
89
88
|
analytics: boolean
|
package/typings/index.d.ts
CHANGED
|
@@ -21,6 +21,20 @@ export interface NginxConfiguration extends ServiceWithVersion {
|
|
|
21
21
|
configTemplate: string
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
export interface VarnishConfiguration extends ServiceWithVersion {
|
|
25
|
+
/**
|
|
26
|
+
* Enable or disable Varnish in the project
|
|
27
|
+
*/
|
|
28
|
+
enabled: boolean
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Configuration file location
|
|
32
|
+
*
|
|
33
|
+
* @example ./my-varnish-config.vcl
|
|
34
|
+
*/
|
|
35
|
+
configTemplate: string
|
|
36
|
+
}
|
|
37
|
+
|
|
24
38
|
export interface PHPExtension extends Record<string, unknown> {
|
|
25
39
|
version?: string
|
|
26
40
|
/**
|
|
@@ -175,6 +189,11 @@ export interface CMAConfiguration {
|
|
|
175
189
|
* Composer configuration
|
|
176
190
|
*/
|
|
177
191
|
composer: ServiceWithVersion
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Varnish configuration
|
|
195
|
+
*/
|
|
196
|
+
varnish: VarnishConfiguration
|
|
178
197
|
}
|
|
179
198
|
/**
|
|
180
199
|
* Magento configuration
|
package/lib/config/xml-parser.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const { XMLParser, XMLBuilder } = require('fast-xml-parser');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const pathExists = require('../util/path-exists');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @type {import('fast-xml-parser').X2jOptions}
|
|
8
|
-
*/
|
|
9
|
-
const xmlParserConfig = {
|
|
10
|
-
ignoreAttributes: false,
|
|
11
|
-
parseAttributeValue: false,
|
|
12
|
-
trimValues: true,
|
|
13
|
-
allowBooleanAttributes: true
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @type {Partial<import('fast-xml-parser').XmlBuilderOptions>}
|
|
18
|
-
*/
|
|
19
|
-
const xmlBuilderConfig = {
|
|
20
|
-
...xmlParserConfig,
|
|
21
|
-
format: true,
|
|
22
|
-
suppressEmptyNode: true,
|
|
23
|
-
suppressBooleanAttributes: false
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const parser = new XMLParser(xmlParserConfig);
|
|
27
|
-
const builder = new XMLBuilder(xmlBuilderConfig);
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Load xml file to js object
|
|
31
|
-
* @param {String} filePath
|
|
32
|
-
*/
|
|
33
|
-
const loadXmlFile = async (filePath) => {
|
|
34
|
-
const fileData = await fs.promises.readFile(filePath, 'utf-8');
|
|
35
|
-
|
|
36
|
-
return parser.parse(fileData);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Build xml from js object and write it to file
|
|
41
|
-
* @param {String} filePath
|
|
42
|
-
* @param {String} fileData
|
|
43
|
-
*/
|
|
44
|
-
const buildXmlFile = async (filePath, fileData) => {
|
|
45
|
-
const xmlFileData = builder.build(fileData);
|
|
46
|
-
|
|
47
|
-
const { dir } = path.parse(filePath);
|
|
48
|
-
|
|
49
|
-
if (!await pathExists(dir)) {
|
|
50
|
-
await fs.promises.mkdir(dir, {
|
|
51
|
-
recursive: true
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
await fs.promises.writeFile(filePath, xmlFileData, 'utf-8');
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
module.exports = {
|
|
59
|
-
loadXmlFile,
|
|
60
|
-
buildXmlFile
|
|
61
|
-
};
|