@scandipwa/magento-scripts 2.0.0-alpha.2 → 2.0.0-alpha.20
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/exec.js +71 -0
- package/index.js +1 -1
- package/lib/commands/cli.js +14 -1
- package/lib/commands/execute.js +2 -57
- package/lib/commands/start.js +24 -3
- package/lib/commands/status.js +9 -1
- package/lib/config/config.js +20 -2
- package/lib/config/docker.js +86 -53
- package/lib/config/get-project-configuration.js +5 -0
- package/lib/config/index.js +10 -3
- package/lib/config/php/versions/php-7.2.js +1 -0
- package/lib/config/php/versions/php-7.3.js +1 -0
- package/lib/config/php/versions/php-7.4.js +1 -0
- package/lib/config/php/versions/php-8.1.js +1 -0
- package/lib/config/php-config.js +4 -3
- package/lib/config/port-config.js +3 -1
- package/lib/config/services/composer/versions/composer-1.js +13 -0
- package/lib/config/services/composer/versions/composer-2.js +8 -0
- package/lib/config/services/composer/versions/index.js +4 -0
- package/lib/config/services/maildev/index.js +7 -0
- package/lib/config/services/nginx/versions/index.js +3 -0
- package/lib/config/services/nginx/versions/nginx-1.18.js +11 -0
- package/lib/config/{ssl-terminator → services/ssl-terminator}/index.js +3 -0
- package/lib/config/templates/magentorc.template +6 -5
- package/lib/config/templates/php-debug.template.ini +31 -0
- package/lib/config/templates/php-fpm.template.conf +1 -2
- package/lib/config/templates/php.template.ini +5 -201
- package/lib/config/templates/ssl-terminator.template.conf +10 -3
- package/lib/config/templates/varnish.template.vcl +20 -13
- package/lib/config/varnish/varnish-6-0.js +4 -0
- package/lib/config/varnish/varnish-6-6.js +4 -0
- package/lib/config/varnish/varnish-7-0.js +4 -0
- package/lib/config/versions/magento-2.2.10.js +41 -0
- package/lib/config/versions/magento-2.3.0.js +8 -10
- package/lib/config/versions/magento-2.3.1.js +8 -10
- package/lib/config/versions/magento-2.3.2-p1.js +8 -10
- package/lib/config/versions/magento-2.3.2-p2.js +8 -10
- package/lib/config/versions/magento-2.3.2.js +8 -10
- package/lib/config/versions/magento-2.3.3-p1.js +8 -10
- package/lib/config/versions/magento-2.3.3.js +8 -10
- package/lib/config/versions/magento-2.3.4-p1.js +8 -10
- package/lib/config/versions/magento-2.3.4-p2.js +8 -10
- package/lib/config/versions/magento-2.3.4.js +8 -10
- package/lib/config/versions/magento-2.3.5-p1.js +8 -10
- package/lib/config/versions/magento-2.3.5-p2.js +8 -10
- package/lib/config/versions/magento-2.3.5.js +8 -10
- package/lib/config/versions/magento-2.3.6-p1.js +8 -10
- package/lib/config/versions/magento-2.3.6.js +8 -10
- package/lib/config/versions/magento-2.3.7-p1.js +8 -10
- package/lib/config/versions/magento-2.3.7-p2.js +8 -10
- package/lib/config/versions/magento-2.3.7-p3.js +8 -10
- package/lib/config/versions/magento-2.3.7-p4.js +42 -0
- package/lib/config/versions/magento-2.3.7.js +8 -10
- package/lib/config/versions/magento-2.4.0-p1.js +8 -10
- package/lib/config/versions/magento-2.4.0.js +8 -10
- package/lib/config/versions/magento-2.4.1-p1.js +8 -10
- package/lib/config/versions/magento-2.4.1.js +8 -10
- package/lib/config/versions/magento-2.4.2-p1.js +8 -10
- package/lib/config/versions/magento-2.4.2-p2.js +8 -10
- package/lib/config/versions/magento-2.4.2.js +8 -10
- package/lib/config/versions/magento-2.4.3-p1.js +8 -10
- package/lib/config/versions/magento-2.4.3-p2.js +8 -10
- package/lib/config/versions/magento-2.4.3-p3.js +44 -0
- package/lib/config/versions/magento-2.4.3.js +8 -10
- package/lib/config/versions/magento-2.4.4-p1.js +44 -0
- package/lib/config/versions/magento-2.4.4.js +8 -10
- package/lib/config/versions/magento-2.4.5.js +44 -0
- package/lib/tasks/cli/create-bashrc-config.js +1 -1
- package/lib/tasks/composer/local-auth-json.js +1 -1
- package/lib/tasks/database/connect-to-database.js +6 -3
- package/lib/tasks/database/create-magento-database.js +5 -2
- package/lib/tasks/database/create-magento-user.js +50 -0
- package/lib/tasks/database/default-magento-database.js +3 -0
- package/lib/tasks/database/default-magento-user.js +7 -0
- package/lib/tasks/database/import-dump-to-database.js +3 -2
- package/lib/tasks/docker/api.d.ts +25 -1
- package/lib/tasks/docker/api.js +31 -1
- package/lib/tasks/docker/containers/container-api.d.ts +21 -0
- package/lib/tasks/docker/containers/container-api.js +82 -17
- package/lib/tasks/docker/containers/tasks.js +44 -13
- package/lib/tasks/docker/convert-composer-home-to-composer-cache-volume.js +52 -0
- package/lib/tasks/docker/convert-mysql-to-mariadb.js +2 -2
- package/lib/tasks/docker/image/image-api.d.ts +44 -0
- package/lib/tasks/docker/image/image-api.js +30 -2
- package/lib/tasks/docker/index.js +6 -1
- package/lib/tasks/docker/project-image-builder.js +36 -13
- package/lib/tasks/docker/system/index.js +5 -0
- package/lib/tasks/docker/system/system-api.d.ts +71 -0
- package/lib/tasks/docker/system/system-api.js +29 -0
- package/lib/tasks/docker/volume/index.js +2 -1
- package/lib/tasks/docker/volume/tasks.js +67 -9
- package/lib/tasks/docker/volume/volume-api.d.ts +40 -0
- package/lib/tasks/docker/volume/volume-api.js +54 -1
- package/lib/tasks/execute.js +100 -0
- package/lib/tasks/file-system/create-nginx-config.js +3 -5
- package/lib/tasks/file-system/create-php-config.js +2 -23
- package/lib/tasks/file-system/create-php-debug-config.js +45 -0
- package/lib/tasks/file-system/create-php-fpm-config.js +2 -4
- package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +13 -3
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +1 -1
- package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -7
- package/lib/tasks/file-system/create-varnish-config.js +4 -7
- package/lib/tasks/file-system/index.js +2 -0
- 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/configure-elasticsearch.js +2 -4
- package/lib/tasks/magento/setup-magento/flush-redis-config.js +3 -6
- package/lib/tasks/magento/setup-magento/index.js +2 -0
- package/lib/tasks/magento/setup-magento/install-magento.js +8 -10
- package/lib/tasks/magento/setup-magento/set-base-url.js +1 -1
- package/lib/tasks/magento/setup-magento/set-mail-config.js +26 -0
- package/lib/tasks/magento/setup-magento/varnish-config.js +4 -9
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +17 -16
- package/lib/tasks/php/php-container.js +7 -3
- package/lib/tasks/php/update-env-php.js +3 -4
- package/lib/tasks/{prefix → project-config}/index.js +6 -6
- package/lib/tasks/requirements/composer-credentials.js +7 -3
- package/lib/tasks/requirements/docker/context.js +88 -0
- package/lib/tasks/requirements/docker/index.js +114 -20
- package/lib/tasks/requirements/docker/install.js +21 -7
- package/lib/tasks/requirements/docker/permissions.js +2 -11
- package/lib/tasks/requirements/docker/running-status.js +94 -24
- package/lib/tasks/requirements/docker/version.js +1 -0
- package/lib/tasks/requirements/index.js +0 -2
- package/lib/tasks/requirements/php-version.js +4 -2
- package/lib/tasks/start.js +27 -8
- package/lib/tasks/status/index.js +29 -20
- package/lib/tasks/stop.js +2 -0
- package/lib/tasks/theme/retrieve-theme-data.js +11 -1
- package/lib/util/config-file-validator.js +15 -2
- package/lib/util/execute-in-container.js +62 -0
- package/lib/util/instance-metadata.js +14 -2
- package/lib/util/systemctl.js +62 -13
- package/package.json +4 -3
- package/typings/context.d.ts +11 -0
- package/typings/index.d.ts +42 -1
- package/lib/tasks/execute/index.js +0 -26
- package/lib/tasks/requirements/dependency/arch.js +0 -50
- package/lib/tasks/requirements/dependency/centos.js +0 -36
- package/lib/tasks/requirements/dependency/fedora.js +0 -36
- package/lib/tasks/requirements/dependency/index.js +0 -33
- package/lib/tasks/requirements/dependency/mac.js +0 -124
- package/lib/tasks/requirements/dependency/ubuntu.js +0 -83
- package/yarn-error.log +0 -9660
package/exec.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const getLatestVersion = require('@scandipwa/scandipwa-dev-utils/latest-version');
|
|
4
|
+
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
5
|
+
const semver = require('semver');
|
|
6
|
+
const isInstalledGlobally = require('is-installed-globally');
|
|
7
|
+
const isRunningRoot = require('./lib/util/is-running-root');
|
|
8
|
+
const { executeTask } = require('./lib/tasks/execute');
|
|
9
|
+
|
|
10
|
+
if (isRunningRoot()) {
|
|
11
|
+
logger.error('Root privileges detected!');
|
|
12
|
+
console.log(`
|
|
13
|
+
We detected that you are running ${ logger.style.misc('magento-scripts') } as root user.
|
|
14
|
+
We cannot allow you to run ${ logger.style.misc('magento-scripts') } with root privileges, this will only cause more problems.
|
|
15
|
+
|
|
16
|
+
If you are experiencing problems with ${ logger.style.misc('Docker') } or ${ logger.style.misc('Magento') } setup, running ${ logger.style.misc('magento-scripts') } as root will not solve those problems.
|
|
17
|
+
`);
|
|
18
|
+
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
process.title = 'magento-scripts';
|
|
23
|
+
|
|
24
|
+
const newVersionIsAPatch = (latestVersion, currentVersion) => {
|
|
25
|
+
const latestVersionParsed = semver.parse(latestVersion);
|
|
26
|
+
const currentVersionParsed = semver.parse(currentVersion);
|
|
27
|
+
|
|
28
|
+
return latestVersionParsed.major === currentVersionParsed.major
|
|
29
|
+
&& latestVersionParsed.minor === currentVersionParsed.minor
|
|
30
|
+
&& latestVersionParsed.patch !== currentVersionParsed.patch;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
(async () => {
|
|
34
|
+
const { version: currentVersion, name } = require('./package.json');
|
|
35
|
+
try {
|
|
36
|
+
const latestVersion = await getLatestVersion(name);
|
|
37
|
+
|
|
38
|
+
if (semver.gt(latestVersion, currentVersion)) {
|
|
39
|
+
const isNewVersionAPath = newVersionIsAPatch(latestVersion, currentVersion);
|
|
40
|
+
|
|
41
|
+
let message = [];
|
|
42
|
+
|
|
43
|
+
if (isNewVersionAPath) {
|
|
44
|
+
message = [
|
|
45
|
+
`A patch for ${ logger.style.misc(name) } is available!`,
|
|
46
|
+
`We recommend to update to latest version ${ logger.style.misc(latestVersion) }!`,
|
|
47
|
+
`-> ${ logger.style.command(`npm i ${ isInstalledGlobally ? '-g ' : '' }${ name }@${ latestVersion }`) }`
|
|
48
|
+
];
|
|
49
|
+
} else {
|
|
50
|
+
message = [
|
|
51
|
+
`${ isInstalledGlobally ? 'Global module' : 'Module' } ${ logger.style.misc(name) } (${currentVersion}) is out-dated.`,
|
|
52
|
+
`Please upgrade it to latest version ${ logger.style.misc(latestVersion) }.`,
|
|
53
|
+
`You can do it by running the following command: ${ logger.style.command(`npm i ${ isInstalledGlobally ? '-g ' : '' }${ name }@${ latestVersion }`) }.`
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
process.isOutOfDateVersion = true;
|
|
58
|
+
process.isOutOfDateVersionMessage = message;
|
|
59
|
+
}
|
|
60
|
+
} catch (e) {
|
|
61
|
+
logger.warn(`Package ${ logger.style.misc(name) } is not yet published.`);
|
|
62
|
+
logger.log(); // add empty line
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const [containername, ...commands] = process.argv.slice(2);
|
|
66
|
+
|
|
67
|
+
return executeTask({
|
|
68
|
+
containername,
|
|
69
|
+
commands
|
|
70
|
+
});
|
|
71
|
+
})();
|
package/index.js
CHANGED
|
@@ -13,7 +13,7 @@ if (isRunningRoot()) {
|
|
|
13
13
|
We detected that you are running ${ logger.style.misc('magento-scripts') } as root user.
|
|
14
14
|
We cannot allow you to run ${ logger.style.misc('magento-scripts') } with root privileges, this will only cause more problems.
|
|
15
15
|
|
|
16
|
-
If you are experiencing problems with ${ logger.style.misc('Docker') }
|
|
16
|
+
If you are experiencing problems with ${ logger.style.misc('Docker') } or ${ logger.style.misc('Magento') } setup, running ${ logger.style.misc('magento-scripts') } as root will not solve those problems.
|
|
17
17
|
`);
|
|
18
18
|
|
|
19
19
|
process.exit(1);
|
package/lib/commands/cli.js
CHANGED
|
@@ -5,7 +5,6 @@ const getMagentoVersionConfig = require('../config/get-magento-version-config');
|
|
|
5
5
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
6
6
|
const getProjectConfiguration = require('../config/get-project-configuration');
|
|
7
7
|
const checkConfigurationFile = require('../config/check-configuration-file');
|
|
8
|
-
// const { installComposer, installPrestissimo } = require('../tasks/composer');
|
|
9
8
|
const ConsoleBlock = require('../util/console-block');
|
|
10
9
|
const { checkComposerCredentials } = require('../tasks/requirements/composer-credentials');
|
|
11
10
|
|
|
@@ -46,6 +45,11 @@ module.exports = (yargs) => {
|
|
|
46
45
|
.addLine(`Available shortcuts: magento -> ${logger.style.command('m')}, composer -> ${logger.style.command('c')}`)
|
|
47
46
|
.addEmptyLine();
|
|
48
47
|
|
|
48
|
+
block
|
|
49
|
+
.addLine(`Execute into any service: ${logger.style.command('exec <service name>')}`)
|
|
50
|
+
.addLine(`Execute into PHP container: ${logger.style.command('exec php')}`)
|
|
51
|
+
.addEmptyLine();
|
|
52
|
+
|
|
49
53
|
if (ctx.config.overridenConfiguration.configuration.varnish.enabled) {
|
|
50
54
|
block.addLine(`Clear Varnish cache: ${logger.style.command('cvc')}`);
|
|
51
55
|
}
|
|
@@ -65,6 +69,15 @@ module.exports = (yargs) => {
|
|
|
65
69
|
.addLine(`Connect to MariaDB server as root: ${logger.style.command('mariadbroot')}`)
|
|
66
70
|
.addEmptyLine();
|
|
67
71
|
|
|
72
|
+
if (ctx.debug) {
|
|
73
|
+
block
|
|
74
|
+
.addLine('Debug PHP in CLI:')
|
|
75
|
+
.addLine('1. Start debugger in VSCode or PHPStorm')
|
|
76
|
+
.addLine(`2. Go to PHP container: ${ logger.style.command('exec php') }`)
|
|
77
|
+
.addLine(`3. Run CLI command with ${ logger.style.code('XDEBUG_SESSION=phpstorm') } environmental variable: ${ logger.style.command('XDEBUG_SESSION=phpstorm magento <command>') }`)
|
|
78
|
+
.addLine('4. Enjoy');
|
|
79
|
+
}
|
|
80
|
+
|
|
68
81
|
block.log();
|
|
69
82
|
|
|
70
83
|
return cli();
|
package/lib/commands/execute.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
const { Listr } = require('listr2');
|
|
3
|
-
const checkConfigurationFile = require('../config/check-configuration-file');
|
|
4
|
-
const getProjectConfiguration = require('../config/get-project-configuration');
|
|
5
|
-
const executeInContainer = require('../tasks/execute');
|
|
6
|
-
const getMagentoVersionConfig = require('../config/get-magento-version-config');
|
|
7
|
-
const { checkRequirements } = require('../tasks/requirements');
|
|
8
|
-
const { getCachedPorts } = require('../config/get-port-config');
|
|
1
|
+
const { executeTask } = require('../tasks/execute');
|
|
9
2
|
|
|
10
3
|
/**
|
|
11
4
|
* @param {import('yargs')} yargs
|
|
@@ -26,55 +19,7 @@ Available containers:
|
|
|
26
19
|
- sslTerminator`);
|
|
27
20
|
},
|
|
28
21
|
async (argv) => {
|
|
29
|
-
|
|
30
|
-
checkRequirements(),
|
|
31
|
-
getMagentoVersionConfig(),
|
|
32
|
-
checkConfigurationFile(),
|
|
33
|
-
getProjectConfiguration(),
|
|
34
|
-
getCachedPorts()
|
|
35
|
-
], {
|
|
36
|
-
concurrent: false,
|
|
37
|
-
exitOnError: true,
|
|
38
|
-
ctx: { throwMagentoVersionMissing: true },
|
|
39
|
-
rendererOptions: { collapse: false, clearOutput: true }
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
let ctx;
|
|
43
|
-
try {
|
|
44
|
-
ctx = await tasks.run();
|
|
45
|
-
} catch (e) {
|
|
46
|
-
logger.error(e.message || e);
|
|
47
|
-
process.exit(1);
|
|
48
|
-
}
|
|
49
|
-
const containers = ctx.config.docker.getContainers(ctx.ports);
|
|
50
|
-
const services = Object.keys(containers);
|
|
51
|
-
|
|
52
|
-
if (services.includes(argv.containername) || services.some((service) => service.includes(argv.containername))) {
|
|
53
|
-
const container = containers[argv.containername]
|
|
54
|
-
? containers[argv.containername]
|
|
55
|
-
: Object.entries(containers).find(([key]) => key.includes(argv.containername))[1];
|
|
56
|
-
|
|
57
|
-
if (argv.commands.length === 0) {
|
|
58
|
-
// if we have default connect command then use it
|
|
59
|
-
if (container.connectCommand) {
|
|
60
|
-
// eslint-disable-next-line no-param-reassign
|
|
61
|
-
argv.commands = container.connectCommand;
|
|
62
|
-
} else {
|
|
63
|
-
// otherwise fall back to bash (if it exists inside container)
|
|
64
|
-
argv.commands.push('bash');
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
logger.logN(`Executing container ${logger.style.misc(container._)} (command: ${logger.style.command(argv.commands[0])})`);
|
|
69
|
-
await executeInContainer({
|
|
70
|
-
containerName: container.name,
|
|
71
|
-
commands: argv.commands
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
logger.error(`No container found "${argv.containername}"`);
|
|
22
|
+
await executeTask(argv);
|
|
78
23
|
}
|
|
79
24
|
);
|
|
80
25
|
};
|
package/lib/commands/start.js
CHANGED
|
@@ -22,6 +22,7 @@ const reportErrors = async (errors) => {
|
|
|
22
22
|
const path = (error.path && ` Error path: ${error.path} `) || '';
|
|
23
23
|
if (error instanceof UnknownError || error instanceof KnownError) {
|
|
24
24
|
logger.error(error.message);
|
|
25
|
+
logger.error(error.stack);
|
|
25
26
|
if (error instanceof UnknownError) {
|
|
26
27
|
await googleAnalytics.trackError(`Unknown Error:${path}${error.stack}`);
|
|
27
28
|
} else {
|
|
@@ -29,9 +30,11 @@ const reportErrors = async (errors) => {
|
|
|
29
30
|
}
|
|
30
31
|
} else if (error instanceof Error) {
|
|
31
32
|
logger.error(error.message);
|
|
33
|
+
logger.error(error.stack);
|
|
32
34
|
await googleAnalytics.trackError(`Regular Error:${path}${error.message}`);
|
|
33
35
|
} else {
|
|
34
36
|
logger.error(error);
|
|
37
|
+
logger.error(error.stack);
|
|
35
38
|
await googleAnalytics.trackError(`Non Error:${path}${error}`); // track non-errors throws
|
|
36
39
|
}
|
|
37
40
|
}
|
|
@@ -83,6 +86,16 @@ module.exports = (yargs) => {
|
|
|
83
86
|
describe: 'Enable verbose logging',
|
|
84
87
|
type: 'boolean',
|
|
85
88
|
default: false
|
|
89
|
+
})
|
|
90
|
+
.option('pull-images', {
|
|
91
|
+
describe: 'Pull Docker images',
|
|
92
|
+
type: 'boolean',
|
|
93
|
+
default: false
|
|
94
|
+
})
|
|
95
|
+
.option('reset-global-config', {
|
|
96
|
+
describe: 'Reset global magento-scripts configuration',
|
|
97
|
+
type: 'boolean',
|
|
98
|
+
default: false
|
|
86
99
|
}),
|
|
87
100
|
async (args = {}) => {
|
|
88
101
|
/**
|
|
@@ -137,6 +150,13 @@ module.exports = (yargs) => {
|
|
|
137
150
|
block.addLine(` ${title}: ${text}`);
|
|
138
151
|
});
|
|
139
152
|
|
|
153
|
+
block.addEmptyLine();
|
|
154
|
+
|
|
155
|
+
block.addLine(logger.style.misc('MailDev'));
|
|
156
|
+
instanceMetadata.maildev.forEach(({ title, text }) => {
|
|
157
|
+
block.addLine(` ${title}: ${text}`);
|
|
158
|
+
});
|
|
159
|
+
|
|
140
160
|
const themes = await getCSAThemes();
|
|
141
161
|
if (themes.length > 0) {
|
|
142
162
|
const theme = themes[0];
|
|
@@ -170,10 +190,11 @@ module.exports = (yargs) => {
|
|
|
170
190
|
);
|
|
171
191
|
logger.log('');
|
|
172
192
|
|
|
173
|
-
if (
|
|
174
|
-
logger.warn('
|
|
193
|
+
if (tasks.err && tasks.err.length > 0) {
|
|
194
|
+
logger.warn('During the start, we encountered some errors that have not impacted the start-up process!');
|
|
195
|
+
logger.log('');
|
|
175
196
|
for (const err of tasks.err) {
|
|
176
|
-
logger.error(
|
|
197
|
+
logger.error(`Error path: ${err.path}\nError message: ${err.message}\n\nError stack: ${err.stack}`);
|
|
177
198
|
}
|
|
178
199
|
}
|
|
179
200
|
|
package/lib/commands/status.js
CHANGED
|
@@ -9,6 +9,7 @@ const { statusContainers } = require('../tasks/docker/containers');
|
|
|
9
9
|
const getProjectConfiguration = require('../config/get-project-configuration');
|
|
10
10
|
const checkConfigurationFile = require('../config/check-configuration-file');
|
|
11
11
|
const checkPHPVersion = require('../tasks/requirements/php-version');
|
|
12
|
+
const { getComposerVersionTask } = require('../tasks/composer');
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @param {import('yargs')} yargs
|
|
@@ -21,7 +22,14 @@ module.exports = (yargs) => {
|
|
|
21
22
|
checkConfigurationFile(),
|
|
22
23
|
getProjectConfiguration(),
|
|
23
24
|
getCachedPorts(),
|
|
24
|
-
|
|
25
|
+
{
|
|
26
|
+
task: (ctx, task) => task.newListr([
|
|
27
|
+
checkPHPVersion(),
|
|
28
|
+
getComposerVersionTask()
|
|
29
|
+
], {
|
|
30
|
+
concurrent: true
|
|
31
|
+
})
|
|
32
|
+
},
|
|
25
33
|
statusContainers()
|
|
26
34
|
], {
|
|
27
35
|
concurrent: false,
|
package/lib/config/config.js
CHANGED
|
@@ -2,6 +2,16 @@ const Conf = require('conf');
|
|
|
2
2
|
|
|
3
3
|
const pkg = require('../../package.json');
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @typedef ProjectConfig
|
|
7
|
+
* @prop {String} [createdAt]
|
|
8
|
+
* @prop {String} [prefix]
|
|
9
|
+
* @prop {Boolean} debug
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @type {import('conf').default<Record<string, ProjectConfig>>}
|
|
14
|
+
*/
|
|
5
15
|
const projectsConfig = new Conf({
|
|
6
16
|
configName: 'projects',
|
|
7
17
|
projectName: 'create-magento-app',
|
|
@@ -10,6 +20,12 @@ const projectsConfig = new Conf({
|
|
|
10
20
|
});
|
|
11
21
|
const projectKey = process.cwd();
|
|
12
22
|
|
|
23
|
+
const setProjectConfig = (key, value) => {
|
|
24
|
+
projectsConfig.set(`${projectKey}.${key}`, value);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const getProjectConfig = () => projectsConfig.get(projectKey);
|
|
28
|
+
|
|
13
29
|
const getProjectsFromProjectKeys = (path, project) => {
|
|
14
30
|
if (project.createdAt) {
|
|
15
31
|
return { [path]: project };
|
|
@@ -21,7 +37,7 @@ const getProjectsFromProjectKeys = (path, project) => {
|
|
|
21
37
|
};
|
|
22
38
|
/**
|
|
23
39
|
*
|
|
24
|
-
* @returns {Record<string,
|
|
40
|
+
* @returns {Record<string, ProjectConfig>}
|
|
25
41
|
*/
|
|
26
42
|
const getProjects = () => {
|
|
27
43
|
const projects = {};
|
|
@@ -45,5 +61,7 @@ const getProjects = () => {
|
|
|
45
61
|
module.exports = {
|
|
46
62
|
projectsConfig,
|
|
47
63
|
projectKey,
|
|
48
|
-
getProjects
|
|
64
|
+
getProjects,
|
|
65
|
+
setProjectConfig,
|
|
66
|
+
getProjectConfig
|
|
49
67
|
};
|
package/lib/config/docker.js
CHANGED
|
@@ -6,6 +6,8 @@ const { isIpAddress } = require('../util/ip');
|
|
|
6
6
|
const systeminformation = require('systeminformation');
|
|
7
7
|
const { deepmerge } = require('../util/deepmerge');
|
|
8
8
|
const defaultEsEnv = require('./services/elasticsearch/default-es-env');
|
|
9
|
+
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
10
|
+
const defaultMagentoUser = require('../tasks/database/default-magento-user');
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
*
|
|
@@ -21,10 +23,11 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
21
23
|
redis,
|
|
22
24
|
elasticsearch,
|
|
23
25
|
mariadb,
|
|
24
|
-
varnish
|
|
26
|
+
varnish,
|
|
27
|
+
maildev
|
|
25
28
|
} = configuration;
|
|
26
29
|
|
|
27
|
-
const php = getPhpConfig(
|
|
30
|
+
const php = getPhpConfig(overridenConfiguration, baseConfig);
|
|
28
31
|
const {
|
|
29
32
|
prefix,
|
|
30
33
|
magentoDir,
|
|
@@ -48,56 +51,65 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
48
51
|
elasticsearch: {
|
|
49
52
|
name: `${ prefix }_elasticsearch-data`
|
|
50
53
|
},
|
|
51
|
-
|
|
52
|
-
name: '
|
|
54
|
+
composer_cache: {
|
|
55
|
+
name: 'composer_cache-data',
|
|
56
|
+
opts: {
|
|
57
|
+
mode: 'z'
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
maildev: {
|
|
61
|
+
name: `${ prefix }_maildev-data`
|
|
53
62
|
}
|
|
54
63
|
};
|
|
55
64
|
|
|
56
|
-
const
|
|
57
|
-
const { isWsl } = ctx;
|
|
58
|
-
const isNotNativeLinux = (!isLinux || isWsl);
|
|
65
|
+
const { isDockerDesktop } = ctx;
|
|
59
66
|
|
|
60
|
-
if (
|
|
67
|
+
if (isDockerDesktop) {
|
|
61
68
|
/**
|
|
62
|
-
* When CMA is running
|
|
63
|
-
* we need
|
|
69
|
+
* When CMA is running with Docker Desktop,
|
|
70
|
+
* we need create named volumes to avoid performance penalty
|
|
64
71
|
*/
|
|
65
72
|
volumes.php = {
|
|
66
73
|
name: `${ prefix }_project-data`,
|
|
74
|
+
driver: 'local',
|
|
67
75
|
opt: {
|
|
68
|
-
type: '
|
|
76
|
+
type: 'none',
|
|
69
77
|
device: path.join(magentoDir),
|
|
70
78
|
o: 'bind'
|
|
71
79
|
}
|
|
72
80
|
};
|
|
73
81
|
volumes.nginx = {
|
|
74
82
|
name: `${ prefix }_nginx-data`,
|
|
83
|
+
driver: 'local',
|
|
75
84
|
opt: {
|
|
76
|
-
type: '
|
|
85
|
+
type: 'none',
|
|
77
86
|
device: path.join(cacheDir, 'nginx', 'conf.d'),
|
|
78
87
|
o: 'bind'
|
|
79
88
|
}
|
|
80
89
|
};
|
|
81
90
|
volumes.appPub = {
|
|
82
91
|
name: `${ prefix }_pub-data`,
|
|
92
|
+
driver: 'local',
|
|
83
93
|
opt: {
|
|
84
|
-
type: '
|
|
94
|
+
type: 'none',
|
|
85
95
|
device: path.join(magentoDir, 'pub'),
|
|
86
96
|
o: 'bind'
|
|
87
97
|
}
|
|
88
98
|
};
|
|
89
99
|
volumes.appSetup = {
|
|
90
100
|
name: `${ prefix }_setup-data`,
|
|
101
|
+
driver: 'local',
|
|
91
102
|
opt: {
|
|
92
|
-
type: '
|
|
103
|
+
type: 'none',
|
|
93
104
|
device: path.join(magentoDir, 'setup'),
|
|
94
105
|
o: 'bind'
|
|
95
106
|
}
|
|
96
107
|
};
|
|
97
108
|
volumes.sslTerminator = {
|
|
98
109
|
name: `${ prefix }_ssl-terminator-data`,
|
|
110
|
+
driver: 'local',
|
|
99
111
|
opt: {
|
|
100
|
-
type: '
|
|
112
|
+
type: 'none',
|
|
101
113
|
device: path.join(cacheDir, 'ssl-terminator', 'conf.d'),
|
|
102
114
|
o: 'bind'
|
|
103
115
|
}
|
|
@@ -106,8 +118,9 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
106
118
|
if (varnish.enabled) {
|
|
107
119
|
volumes.varnish = {
|
|
108
120
|
name: `${ prefix }_varnish-data`,
|
|
121
|
+
driver: 'local',
|
|
109
122
|
opt: {
|
|
110
|
-
type: '
|
|
123
|
+
type: 'none',
|
|
111
124
|
device: path.join(cacheDir, 'varnish'),
|
|
112
125
|
o: 'bind'
|
|
113
126
|
}
|
|
@@ -122,24 +135,23 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
122
135
|
const dockerConfig = {
|
|
123
136
|
php: {
|
|
124
137
|
_: 'PHP',
|
|
125
|
-
ports:
|
|
138
|
+
ports: isDockerDesktop ? [
|
|
126
139
|
`${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.fpm }:9000`
|
|
127
140
|
] : [],
|
|
128
141
|
forwardedPorts: [
|
|
129
|
-
|
|
142
|
+
isDockerDesktop
|
|
130
143
|
? `127.0.0.1:${ ports.fpm }:9000`
|
|
131
144
|
: `127.0.0.1:${ ports.fpm }`
|
|
132
145
|
],
|
|
133
|
-
network:
|
|
146
|
+
network: isDockerDesktop ? network.name : 'host',
|
|
134
147
|
mountVolumes: [
|
|
135
|
-
`${
|
|
136
|
-
`${ volumes.
|
|
148
|
+
`${ !isDockerDesktop ? magentoDir : volumes.php.name }:${containerMagentoDir}`,
|
|
149
|
+
`${ volumes.composer_cache.name }:/composer/home/cache`,
|
|
137
150
|
`${ php.iniPath }:/usr/local/etc/php/php.ini`,
|
|
138
151
|
`${ php.fpmConfPath }:/usr/local/etc/php-fpm.d/zz-docker.conf`
|
|
139
|
-
],
|
|
152
|
+
].concat(ctx.debug ? [`${ php.debugIniPath }:/usr/local/etc/php/conf.d/00-xdebug.ini`] : []),
|
|
140
153
|
env: {
|
|
141
|
-
COMPOSER_AUTH: process.env.COMPOSER_AUTH || ''
|
|
142
|
-
COMPOSER_HOME: '/composer/home'
|
|
154
|
+
COMPOSER_AUTH: JSON.stringify(JSON.parse(process.env.COMPOSER_AUTH), null, 0) || ''
|
|
143
155
|
},
|
|
144
156
|
restart: 'on-failure:5',
|
|
145
157
|
image: `local-cma-project:${ prefix }`,
|
|
@@ -150,15 +162,15 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
150
162
|
],
|
|
151
163
|
name: `${ prefix }_php`,
|
|
152
164
|
connectCommand: ['/bin/sh'],
|
|
153
|
-
user:
|
|
165
|
+
user: ((ctx.platform === 'linux' && isDockerDesktop) || !isDockerDesktop) ? `${os.userInfo().uid}:${os.userInfo().gid}` : ''
|
|
154
166
|
},
|
|
155
167
|
sslTerminator: {
|
|
156
168
|
_: 'SSL Terminator (Nginx)',
|
|
157
|
-
ports:
|
|
169
|
+
ports: isDockerDesktop ? [
|
|
158
170
|
`${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.sslTerminator }:80`
|
|
159
171
|
] : [],
|
|
160
172
|
forwardedPorts: [
|
|
161
|
-
|
|
173
|
+
isDockerDesktop
|
|
162
174
|
? `127.0.0.1:${ ports.sslTerminator }:80`
|
|
163
175
|
: `127.0.0.1:${ ports.sslTerminator }`
|
|
164
176
|
],
|
|
@@ -169,21 +181,21 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
169
181
|
* Mount volumes directly on linux
|
|
170
182
|
*/
|
|
171
183
|
mountVolumes: [
|
|
172
|
-
`${
|
|
184
|
+
`${ !isDockerDesktop ? path.join(cacheDir, 'ssl-terminator', 'conf.d') : volumes.sslTerminator.name }:/etc/nginx/conf.d`
|
|
173
185
|
],
|
|
174
186
|
restart: 'on-failure:5',
|
|
175
|
-
network:
|
|
187
|
+
network: isDockerDesktop ? network.name : 'host',
|
|
176
188
|
image: `${ nginx.version ? `nginx:${ nginx.version }` : nginx.image }`,
|
|
177
189
|
name: `${ prefix }_ssl-terminator`,
|
|
178
190
|
command: "nginx -g 'daemon off;'"
|
|
179
191
|
},
|
|
180
192
|
nginx: {
|
|
181
193
|
_: 'Nginx',
|
|
182
|
-
ports:
|
|
194
|
+
ports: isDockerDesktop ? [
|
|
183
195
|
`${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.app }:80`
|
|
184
196
|
] : [],
|
|
185
197
|
forwardedPorts: [
|
|
186
|
-
|
|
198
|
+
isDockerDesktop
|
|
187
199
|
? `127.0.0.1:${ ports.app }:80`
|
|
188
200
|
: `127.0.0.1:${ ports.app }`
|
|
189
201
|
],
|
|
@@ -193,7 +205,7 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
193
205
|
/**
|
|
194
206
|
* Mount volumes directly on linux
|
|
195
207
|
*/
|
|
196
|
-
mountVolumes:
|
|
208
|
+
mountVolumes: !isDockerDesktop ? [
|
|
197
209
|
`${ cacheDir }/nginx/conf.d:/etc/nginx/conf.d`,
|
|
198
210
|
`${ path.join(magentoDir, 'pub') }:${path.join(containerMagentoDir, 'pub')}`,
|
|
199
211
|
`${ path.join(magentoDir, 'setup') }:${path.join(containerMagentoDir, 'setup')}`
|
|
@@ -203,8 +215,7 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
203
215
|
`${ volumes.appSetup.name }:${path.join(containerMagentoDir, 'setup')}`
|
|
204
216
|
],
|
|
205
217
|
restart: 'on-failure:5',
|
|
206
|
-
|
|
207
|
-
network: isNotNativeLinux ? network.name : 'host',
|
|
218
|
+
network: isDockerDesktop ? network.name : 'host',
|
|
208
219
|
image: `${ nginx.version ? `nginx:${ nginx.version }` : nginx.image }`,
|
|
209
220
|
name: `${ prefix }_nginx`,
|
|
210
221
|
command: "nginx -g 'daemon off;'"
|
|
@@ -217,7 +228,6 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
217
228
|
ports: [`127.0.0.1:${ ports.redis }:6379`],
|
|
218
229
|
forwardedPorts: [`127.0.0.1:${ ports.redis }:6379`],
|
|
219
230
|
mounts: [`source=${ volumes.redis.name },target=/data`],
|
|
220
|
-
// TODO: use connect instead
|
|
221
231
|
network: network.name,
|
|
222
232
|
image: `${ redis.version ? `redis:${ redis.version }` : redis.image }`,
|
|
223
233
|
name: `${ prefix }_redis`,
|
|
@@ -235,22 +245,18 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
235
245
|
`${ path.join(baseConfig.cacheDir, 'mariadb.cnf') }:/etc/mysql/my.cnf`
|
|
236
246
|
],
|
|
237
247
|
env: {
|
|
238
|
-
|
|
239
|
-
MARIADB_ROOT_PASSWORD: 'scandipwa',
|
|
240
|
-
MARIADB_USER: 'magento',
|
|
241
|
-
MARIADB_PASSWORD: 'magento',
|
|
242
|
-
MARIADB_DATABASE: 'magento'
|
|
248
|
+
MARIADB_ROOT_PASSWORD: 'scandipwa'
|
|
243
249
|
},
|
|
244
|
-
command:
|
|
245
|
-
'--log_bin_trust_function_creators=1'
|
|
246
|
-
]
|
|
247
|
-
.join(' '),
|
|
250
|
+
command: '--log_bin_trust_function_creators=1',
|
|
248
251
|
securityOptions: [
|
|
249
252
|
'seccomp=unconfined'
|
|
250
253
|
],
|
|
251
254
|
network: network.name,
|
|
252
255
|
image: `${ mariadb.version ? `mariadb:${ mariadb.version }` : mariadb.image }`,
|
|
253
|
-
name: `${ prefix }_mariadb
|
|
256
|
+
name: `${ prefix }_mariadb`,
|
|
257
|
+
description: `To connect to MariaDB you can use the following users:
|
|
258
|
+
- User ${ logger.style.command('root') } with password ${ logger.style.command('scandipwa') }
|
|
259
|
+
- User ${ logger.style.command(defaultMagentoUser.user) } with password ${ logger.style.command(defaultMagentoUser.password) }`
|
|
254
260
|
},
|
|
255
261
|
elasticsearch: {
|
|
256
262
|
_: 'ElasticSearch',
|
|
@@ -269,11 +275,37 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
269
275
|
network: network.name,
|
|
270
276
|
image: `${ elasticsearch.version ? `elasticsearch:${ elasticsearch.version }` : elasticsearch.image }`,
|
|
271
277
|
name: `${ prefix }_elasticsearch`
|
|
278
|
+
},
|
|
279
|
+
maildev: {
|
|
280
|
+
_: 'MailDev',
|
|
281
|
+
ports: isDockerDesktop ? [
|
|
282
|
+
`127.0.0.1:${ ports.maildevWeb }:1080`,
|
|
283
|
+
`127.0.0.1:${ ports.maildevSMTP }:1025`
|
|
284
|
+
] : [],
|
|
285
|
+
forwardedPorts: isDockerDesktop ? [
|
|
286
|
+
`127.0.0.1:${ ports.maildevWeb }:1080`,
|
|
287
|
+
`127.0.0.1:${ ports.maildevSMTP }:1025`
|
|
288
|
+
] : [
|
|
289
|
+
`127.0.0.1:${ ports.maildevWeb }`,
|
|
290
|
+
`127.0.0.1:${ ports.maildevSMTP }`
|
|
291
|
+
],
|
|
292
|
+
mountVolumes: [
|
|
293
|
+
`${ volumes.maildev.name }:/tmp/maildev`
|
|
294
|
+
],
|
|
295
|
+
env: {
|
|
296
|
+
MAILDEV_SMTP_PORT: isDockerDesktop ? '1025' : ports.maildevSMTP,
|
|
297
|
+
MAILDEV_WEB_PORT: isDockerDesktop ? '1080' : ports.maildevWeb,
|
|
298
|
+
MAILDEV_MAIL_DIRECTORY: '/tmp/maildev'
|
|
299
|
+
},
|
|
300
|
+
name: `${ prefix }_maildev`,
|
|
301
|
+
network: isDockerDesktop ? network.name : 'host',
|
|
302
|
+
image: maildev.image,
|
|
303
|
+
user: !isDockerDesktop ? 'root:root' : ''
|
|
272
304
|
}
|
|
273
305
|
};
|
|
274
306
|
|
|
275
|
-
if (ssl.enabled) {
|
|
276
|
-
dockerConfig.
|
|
307
|
+
if (ssl.enabled && isDockerDesktop) {
|
|
308
|
+
dockerConfig.sslTerminator.ports.push(
|
|
277
309
|
`${isIpAddress(host) ? host : '127.0.0.1'}:443:443`
|
|
278
310
|
);
|
|
279
311
|
}
|
|
@@ -284,13 +316,13 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
284
316
|
image: `${ varnish.version ? `varnish:${ varnish.version }` : varnish.image }`,
|
|
285
317
|
name: `${ prefix }_varnish`,
|
|
286
318
|
mountVolumes: [
|
|
287
|
-
`${
|
|
319
|
+
`${ !isDockerDesktop ? path.join(cacheDir, 'varnish') : volumes.varnish.name }:/etc/varnish`
|
|
288
320
|
],
|
|
289
|
-
ports:
|
|
321
|
+
ports: isDockerDesktop ? [
|
|
290
322
|
`${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.varnish }:80`
|
|
291
323
|
] : [],
|
|
292
324
|
forwardedPorts: [
|
|
293
|
-
|
|
325
|
+
isDockerDesktop
|
|
294
326
|
? `127.0.0.1:${ ports.varnish }:80`
|
|
295
327
|
: `127.0.0.1:${ ports.varnish }`
|
|
296
328
|
],
|
|
@@ -298,12 +330,13 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
298
330
|
VARNISH_SIZE: '2G'
|
|
299
331
|
},
|
|
300
332
|
restart: 'on-failure:30',
|
|
301
|
-
network:
|
|
333
|
+
network: isDockerDesktop ? network.name : 'host',
|
|
302
334
|
// eslint-disable-next-line max-len
|
|
303
|
-
command: `/bin/bash -c "varnishd -a :${
|
|
335
|
+
command: `/bin/bash -c "varnishd -a :${ isDockerDesktop ? 80 : ports.varnish } -t 600 -f /etc/varnish/default.vcl -s Cache=malloc,2048m -s Transient=malloc,512m -p http_resp_hdr_len=70000 -p http_resp_size=100000 && varnishlog"`,
|
|
304
336
|
tmpfs: [
|
|
305
337
|
'/var/lib/varnish:exec'
|
|
306
|
-
]
|
|
338
|
+
],
|
|
339
|
+
description: `Varnish HealthCheck status: ${ logger.style.command(varnish.healthCheck ? 'enabled' : 'disabled') }`
|
|
307
340
|
};
|
|
308
341
|
}
|
|
309
342
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { getProjectConfig } = require('./config');
|
|
1
2
|
const { getConfigFromMagentoVersion } = require('./index');
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -8,6 +9,10 @@ const getProjectConfiguration = () => ({
|
|
|
8
9
|
task: async (ctx) => {
|
|
9
10
|
const { magentoVersion } = ctx;
|
|
10
11
|
|
|
12
|
+
if (typeof ctx.debug !== 'boolean') {
|
|
13
|
+
ctx.debug = getProjectConfig().debug;
|
|
14
|
+
}
|
|
15
|
+
|
|
11
16
|
ctx.config = await getConfigFromMagentoVersion(ctx, {
|
|
12
17
|
magentoVersion
|
|
13
18
|
});
|