@scandipwa/magento-scripts 2.0.0-alpha.20 → 2.0.0-alpha.21

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.
@@ -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();
@@ -1,6 +1,12 @@
1
1
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
2
- const { docker } = require('../config');
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 containers = (await docker).getContainers();
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))) {
@@ -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: "
@@ -17,7 +17,9 @@ const createBashrcConfigFile = () => ({
17
17
  overwrite: true,
18
18
  templateArgs: {
19
19
  php,
20
- varnishEnabled
20
+ varnishEnabled,
21
+ config: ctx.config,
22
+ magentoVersion: ctx.magentoVersion
21
23
  }
22
24
  });
23
25
  } catch (e) {
@@ -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`)
@@ -22,7 +22,8 @@ const createPhpStormConfig = () => ({
22
22
  setupStylelintConfig(),
23
23
  setupESLintConfig()
24
24
  ], {
25
- concurrent: true
25
+ concurrent: true,
26
+ exitOnError: false
26
27
  })
27
28
  });
28
29
 
@@ -121,7 +121,8 @@ const createVSCodeConfig = () => ({
121
121
  } catch (e) {
122
122
  throw new UnknownError(`Unexpected error accrued during launch.json config creation!\n\n${e}`);
123
123
  }
124
- }
124
+ },
125
+ exitOnError: false
125
126
  });
126
127
 
127
128
  module.exports = createVSCodeConfig;
@@ -24,8 +24,7 @@ const prepareFileSystem = () => ({
24
24
  createVarnishConfig(),
25
25
  createMariaDBConfig()
26
26
  ], {
27
- concurrent: true,
28
- exitOnError: false
27
+ concurrent: true
29
28
  })
30
29
  });
31
30
 
@@ -141,9 +141,6 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
141
141
  installed = true;
142
142
  } catch (e) {
143
143
  errors.push(e);
144
- if (tries === 2) {
145
- throw e;
146
- }
147
144
  }
148
145
 
149
146
  if (installed) {
@@ -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: 'system/smtp/port',
11
+ path: 'smtp/configuration_option/port',
12
12
  value: `${ ports.maildevSMTP }`
13
13
  },
14
14
  {
15
- path: 'system/smtp/disable',
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
- block.addLine(`${' '.repeat(3)} ${logger.style.misc(envName)}=${logger.style.file(envValue)}`);
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.join(process.cwd(), themePath);
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.20",
6
+ "version": "2.0.0-alpha.21",
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": "6c6e5821a2da7ca52685724a56c72770004f3a5a"
57
+ "gitHead": "eebb5c8ce3b1d60cef1bb723028b1392b4869bb9"
58
58
  }
@@ -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
  *