@scandipwa/magento-scripts 2.0.0-alpha.20 → 2.0.0-alpha.22
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/commands/cli.js +4 -0
- package/lib/commands/logs.js +28 -2
- package/lib/config/docker.js +5 -1
- package/lib/config/templates/magentorc.template +6 -0
- package/lib/tasks/cli/create-bashrc-config.js +3 -1
- package/lib/tasks/docker/project-image-builder.js +1 -1
- package/lib/tasks/file-system/create-phpstorm-config/index.js +2 -1
- package/lib/tasks/file-system/create-vscode-config.js +2 -1
- package/lib/tasks/file-system/index.js +1 -2
- package/lib/tasks/magento/setup-magento/install-magento.js +0 -3
- package/lib/tasks/magento/setup-magento/set-mail-config.js +2 -6
- package/lib/tasks/php/update-env-php.js +0 -1
- package/lib/tasks/status/index.js +31 -1
- package/lib/tasks/theme/retrieve-theme-data.js +1 -1
- package/lib/util/config-file-validator.js +2 -1
- package/package.json +2 -2
- package/typings/index.d.ts +4 -0
package/lib/commands/cli.js
CHANGED
|
@@ -7,6 +7,7 @@ const getProjectConfiguration = require('../config/get-project-configuration');
|
|
|
7
7
|
const checkConfigurationFile = require('../config/check-configuration-file');
|
|
8
8
|
const ConsoleBlock = require('../util/console-block');
|
|
9
9
|
const { checkComposerCredentials } = require('../tasks/requirements/composer-credentials');
|
|
10
|
+
const pkg = require('../../package.json');
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* @param {import('yargs')} yargs
|
|
@@ -41,6 +42,9 @@ module.exports = (yargs) => {
|
|
|
41
42
|
block
|
|
42
43
|
.addHeader('Create Magento App CLI')
|
|
43
44
|
.addEmptyLine()
|
|
45
|
+
.addLine(`Magento version: ${logger.style.link(ctx.magentoVersion)}`)
|
|
46
|
+
.addLine(`${logger.style.file('magento-scripts')} version: ${logger.style.link(pkg.version)}`)
|
|
47
|
+
.addEmptyLine()
|
|
44
48
|
.addLine(`Available aliases: ${logger.style.command('php')}, ${logger.style.command('magento')}, ${logger.style.command('composer')}`)
|
|
45
49
|
.addLine(`Available shortcuts: magento -> ${logger.style.command('m')}, composer -> ${logger.style.command('c')}`)
|
|
46
50
|
.addEmptyLine();
|
package/lib/commands/logs.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
2
|
-
const {
|
|
2
|
+
const { Listr } = require('listr2');
|
|
3
|
+
const { checkRequirements } = require('../tasks/requirements');
|
|
4
|
+
const getMagentoVersionConfig = require('../config/get-magento-version-config');
|
|
3
5
|
const { execAsyncSpawn } = require('../util/exec-async-command');
|
|
6
|
+
const checkConfigurationFile = require('../config/check-configuration-file');
|
|
7
|
+
const getProjectConfiguration = require('../config/get-project-configuration');
|
|
8
|
+
const { getCachedPorts } = require('../config/get-port-config');
|
|
9
|
+
const dockerNetwork = require('../tasks/docker/network');
|
|
4
10
|
|
|
5
11
|
/**
|
|
6
12
|
* @param {import('yargs')} yargs
|
|
@@ -77,7 +83,27 @@ npm run logs re (will match redis)`);
|
|
|
77
83
|
);
|
|
78
84
|
},
|
|
79
85
|
async (argv) => {
|
|
80
|
-
const
|
|
86
|
+
const tasks = new Listr([
|
|
87
|
+
checkRequirements(),
|
|
88
|
+
getMagentoVersionConfig(),
|
|
89
|
+
checkConfigurationFile(),
|
|
90
|
+
getProjectConfiguration(),
|
|
91
|
+
getCachedPorts(),
|
|
92
|
+
dockerNetwork.tasks.createNetwork()
|
|
93
|
+
], {
|
|
94
|
+
concurrent: false,
|
|
95
|
+
exitOnError: true,
|
|
96
|
+
ctx: { throwMagentoVersionMissing: true },
|
|
97
|
+
rendererOptions: { collapse: false, clearOutput: true }
|
|
98
|
+
});
|
|
99
|
+
let ctx;
|
|
100
|
+
try {
|
|
101
|
+
ctx = await tasks.run();
|
|
102
|
+
} catch (e) {
|
|
103
|
+
logger.error(e.message || e);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
const containers = ctx.config.docker.getContainers();
|
|
81
107
|
const services = Object.keys(containers);
|
|
82
108
|
|
|
83
109
|
if (services.includes(argv.scope) || services.some((service) => service.includes(argv.scope))) {
|
package/lib/config/docker.js
CHANGED
|
@@ -300,7 +300,11 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
300
300
|
name: `${ prefix }_maildev`,
|
|
301
301
|
network: isDockerDesktop ? network.name : 'host',
|
|
302
302
|
image: maildev.image,
|
|
303
|
-
user: !isDockerDesktop ? 'root:root' : ''
|
|
303
|
+
user: !isDockerDesktop ? 'root:root' : '',
|
|
304
|
+
connectCommand: ['/bin/sh'],
|
|
305
|
+
healthCheck: {
|
|
306
|
+
cmd: `wget -O - http://127.0.0.1:${ isDockerDesktop ? '1080' : ports.maildevWeb }/healthz || exit 1`
|
|
307
|
+
}
|
|
304
308
|
}
|
|
305
309
|
};
|
|
306
310
|
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
RED='\033[0;31m'
|
|
2
2
|
GREEN='\033[0;32m'
|
|
3
|
+
YELLOW='\033[1;33m'
|
|
4
|
+
ORANGE='\033[0;33m'
|
|
5
|
+
BLUE='\033[0;34m'
|
|
3
6
|
NC='\033[0m' # No Color
|
|
4
7
|
|
|
5
8
|
alias exec="node ./node_modules/.bin/magento-scripts-exec"
|
|
@@ -15,4 +18,7 @@ alias cvc="exec varnish varnishadm ban req.url '~ /' && echo 'Varnish cache clea
|
|
|
15
18
|
alias mariadb="exec mariadb 'mysql -umagento -pmagento'"
|
|
16
19
|
alias mariadbroot="exec mariadb 'mysql -uroot -pscandipwa'"
|
|
17
20
|
|
|
21
|
+
# silence warning on macos
|
|
18
22
|
export BASH_SILENCE_DEPRECATION_WARNING=1
|
|
23
|
+
|
|
24
|
+
export PS1="[${YELLOW}cli${NC}] \w [${YELLOW}<%~ it.magentoVersion %>${NC}] [${GREEN}\t${NC}] \nbash \v: "
|
|
@@ -37,7 +37,7 @@ const addExtensionToBuilder = (builder, ctx) => async ([extensionName, extension
|
|
|
37
37
|
} else if (typeof command === 'function' || command instanceof Promise) {
|
|
38
38
|
runCommand += ` ${await Promise.resolve(command({ ...extensionInstructionsWithoutCommand, ctx }))}`;
|
|
39
39
|
} else {
|
|
40
|
-
runCommand += ` docker-php-ext-install ${extensionInstructionsWithoutCommand.name}`;
|
|
40
|
+
runCommand += ` docker-php-ext-install ${extensionInstructionsWithoutCommand.name || extensionName}`;
|
|
41
41
|
}
|
|
42
42
|
builder
|
|
43
43
|
.comment(`extension ${extensionName} installation command`)
|
|
@@ -8,15 +8,11 @@ const setMailConfig = () => ({
|
|
|
8
8
|
task: async ({ databaseConnection, ports, isDockerDesktop }, task) => {
|
|
9
9
|
await updateTableValues('core_config_data', [
|
|
10
10
|
{
|
|
11
|
-
path: '
|
|
11
|
+
path: 'smtp/configuration_option/port',
|
|
12
12
|
value: `${ ports.maildevSMTP }`
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
|
-
path: '
|
|
16
|
-
value: '0'
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
path: 'system/smtp/host',
|
|
15
|
+
path: 'smtp/configuration_option/host',
|
|
20
16
|
value: isDockerDesktop ? 'host.docker.internal' : 'localhost'
|
|
21
17
|
}
|
|
22
18
|
], { databaseConnection, task });
|
|
@@ -8,6 +8,19 @@ const { getArchSync } = require('../../util/arch');
|
|
|
8
8
|
const ConsoleBlock = require('../../util/console-block');
|
|
9
9
|
const { getInstanceMetadata } = require('../../util/instance-metadata');
|
|
10
10
|
|
|
11
|
+
const isJSON = (str) => {
|
|
12
|
+
try {
|
|
13
|
+
const result = JSON.parse(str);
|
|
14
|
+
if (typeof result === 'object') {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
} catch (e) {
|
|
18
|
+
//
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return false;
|
|
22
|
+
};
|
|
23
|
+
|
|
11
24
|
/**
|
|
12
25
|
* @param {string} port
|
|
13
26
|
* @return {{ host: string, hostPort: string, containerPort: string }}
|
|
@@ -110,7 +123,24 @@ const prettyStatus = async (ctx) => {
|
|
|
110
123
|
if (container.env && Object.keys(container.env).length > 0) {
|
|
111
124
|
block.addLine('Environment variables:');
|
|
112
125
|
for (const [envName, envValue] of Object.entries(container.env)) {
|
|
113
|
-
|
|
126
|
+
if (isJSON(envValue)) {
|
|
127
|
+
const beautifyJSONLines = JSON.stringify(JSON.parse(envValue), null, 1).split('\n');
|
|
128
|
+
|
|
129
|
+
block.addLine(`${' '.repeat(3)} ${logger.style.misc(envName)}=${logger.style.file(beautifyJSONLines.shift())}`);
|
|
130
|
+
|
|
131
|
+
let currentOpeningBracket = 0;
|
|
132
|
+
|
|
133
|
+
beautifyJSONLines.forEach((line) => {
|
|
134
|
+
block.addLine(`${' '.repeat(2 + currentOpeningBracket)}${logger.style.file(line)}`);
|
|
135
|
+
if (['{', '['].some((openingBracketVariant) => line.includes(openingBracketVariant))) {
|
|
136
|
+
currentOpeningBracket++;
|
|
137
|
+
} else if (['}', ']'].some((closingBracketVariant) => line.includes(closingBracketVariant))) {
|
|
138
|
+
currentOpeningBracket--;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
} else {
|
|
142
|
+
block.addLine(`${' '.repeat(3)} ${logger.style.misc(envName)}=${logger.style.file(envValue)}`);
|
|
143
|
+
}
|
|
114
144
|
}
|
|
115
145
|
}
|
|
116
146
|
|
|
@@ -10,7 +10,7 @@ const pathExists = require('../../util/path-exists');
|
|
|
10
10
|
const retrieveThemeData = (themePath) => ({
|
|
11
11
|
title: 'Checking theme folder',
|
|
12
12
|
task: async (ctx) => {
|
|
13
|
-
let absoluteThemePath = path.
|
|
13
|
+
let absoluteThemePath = path.resolve(themePath);
|
|
14
14
|
|
|
15
15
|
// validate if theme is located inside magento directory
|
|
16
16
|
if (!absoluteThemePath.includes(process.cwd())) {
|
|
@@ -53,8 +53,9 @@ const phpExtensionConfiguration = Joi.object()
|
|
|
53
53
|
.pattern(
|
|
54
54
|
Joi.string(),
|
|
55
55
|
Joi.object({
|
|
56
|
+
name: Joi.string().optional(),
|
|
56
57
|
alternativeName: Joi.array().items(Joi.string()).optional(),
|
|
57
|
-
command: Joi.func().optional(),
|
|
58
|
+
command: Joi.alternatives().try(Joi.func(), Joi.string()).optional(),
|
|
58
59
|
dependencies: Joi.array().items(Joi.string()).optional(),
|
|
59
60
|
version: Joi.string().optional()
|
|
60
61
|
})
|
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.22",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"types": "./typings/index.d.ts",
|
|
9
9
|
"license": "OSL-3.0",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"mysql",
|
|
55
55
|
"scandipwa"
|
|
56
56
|
],
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "60dcb5fae28c349ebb6aaa207168a4d7395a7d12"
|
|
58
58
|
}
|
package/typings/index.d.ts
CHANGED
|
@@ -95,6 +95,10 @@ export interface ComposerConfiguration {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
export interface PHPExtensionInstallationInstruction {
|
|
98
|
+
/**
|
|
99
|
+
* Main extension name that will be used for `docker-php-ext-install` command
|
|
100
|
+
*/
|
|
101
|
+
name?: string
|
|
98
102
|
/**
|
|
99
103
|
* Alternative name for extension
|
|
100
104
|
*
|