@scandipwa/magento-scripts 2.0.0-alpha.15 → 2.0.0-alpha.17

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.
@@ -50,8 +50,11 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
50
50
  elasticsearch: {
51
51
  name: `${ prefix }_elasticsearch-data`
52
52
  },
53
- composer_home: {
54
- name: 'composer_home-data'
53
+ composer_cache: {
54
+ name: 'composer_cache-data',
55
+ opts: {
56
+ mode: 'z'
57
+ }
55
58
  }
56
59
  };
57
60
 
@@ -139,13 +142,12 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
139
142
  network: isDockerDesktop ? network.name : 'host',
140
143
  mountVolumes: [
141
144
  `${ !isDockerDesktop ? magentoDir : volumes.php.name }:${containerMagentoDir}`,
142
- `${ volumes.composer_home.name }:/composer/home`,
145
+ `${ volumes.composer_cache.name }:/composer/home/cache`,
143
146
  `${ php.iniPath }:/usr/local/etc/php/php.ini`,
144
147
  `${ php.fpmConfPath }:/usr/local/etc/php-fpm.d/zz-docker.conf`
145
148
  ].concat(ctx.debug ? [`${ php.debugIniPath }:/usr/local/etc/php/conf.d/00-xdebug.ini`] : []),
146
149
  env: {
147
- COMPOSER_AUTH: JSON.stringify(JSON.parse(process.env.COMPOSER_AUTH), null, 0) || '',
148
- COMPOSER_HOME: '/composer/home'
150
+ COMPOSER_AUTH: JSON.stringify(JSON.parse(process.env.COMPOSER_AUTH), null, 0) || ''
149
151
  },
150
152
  restart: 'on-failure:5',
151
153
  image: `local-cma-project:${ prefix }`,
@@ -2,7 +2,12 @@
2
2
  * @returns {import('../../../../../typings/index').ComposerConfiguration}
3
3
  */
4
4
  const composer1 = () => ({
5
- version: '1'
5
+ version: '1',
6
+ plugins: {
7
+ 'hirak/prestissimo': {
8
+ enabled: true
9
+ }
10
+ }
6
11
  });
7
12
 
8
13
  module.exports = composer1;
@@ -0,0 +1,39 @@
1
+ const { defaultMagentoConfig } = require('../magento-config');
2
+ const { magento23PHPExtensionList } = require('../magento/required-php-extensions');
3
+ const { repo } = require('../php/base-repo');
4
+ const { php72 } = require('../php/versions');
5
+ const { composer1 } = require('../services/composer/versions');
6
+ const { elasticsearch68 } = require('../services/elasticsearch/versions');
7
+ const { nginx118 } = require('../services/nginx/versions');
8
+ const { sslTerminator } = require('../services/ssl-terminator');
9
+ const { varnish66 } = require('../varnish/varnish-6-6');
10
+
11
+ module.exports = ({ templateDir } = {}) => ({
12
+ magentoVersion: '2.2.10',
13
+ configuration: {
14
+ php: php72({
15
+ templateDir,
16
+ extensions: magento23PHPExtensionList,
17
+ baseImage: `${ repo }:php-7.2-magento-2.3`
18
+ }),
19
+ nginx: nginx118({ templateDir }),
20
+ redis: {
21
+ version: '5.0'
22
+ },
23
+ mysql: {
24
+ version: '5.7'
25
+ },
26
+ mariadb: {
27
+ version: '10.2'
28
+ },
29
+ elasticsearch: elasticsearch68(),
30
+ composer: composer1(),
31
+ varnish: varnish66({ templateDir }),
32
+ sslTerminator: sslTerminator({ templateDir })
33
+ },
34
+ magento: defaultMagentoConfig,
35
+ host: 'localhost',
36
+ ssl: {
37
+ enabled: false
38
+ }
39
+ });
@@ -0,0 +1,43 @@
1
+ const { containerApi } = require('./containers');
2
+ const volumeApi = require('./volume/volume-api');
3
+
4
+ const composeHomeDataVolumeName = 'composer_home-data';
5
+
6
+ /**
7
+ * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
8
+ */
9
+ const convertComposerHomeToComposerCacheVolume = () => ({
10
+ skip: async () => {
11
+ const volumeList = await volumeApi.ls({
12
+ formatToJSON: true,
13
+ filter: `name=${ composeHomeDataVolumeName }`
14
+ });
15
+
16
+ return volumeList.length === 0;
17
+ },
18
+ task: async (ctx, task) => {
19
+ if (ctx.platform === 'linux' && !ctx.isDockerDesktop) {
20
+ await volumeApi.rm({ volumes: [composeHomeDataVolumeName] });
21
+ return;
22
+ }
23
+
24
+ const { composer_cache } = ctx.config.docker.volumes;
25
+ task.title = `Migrating from ${ composer_cache.name } volume to ${ composeHomeDataVolumeName }...`;
26
+ await containerApi.run({
27
+ rm: true,
28
+ detach: false,
29
+ mountVolumes: [
30
+ `${ composeHomeDataVolumeName }:/from:ro`,
31
+ `${ composer_cache.name }:/to`
32
+ ],
33
+ image: 'alpine',
34
+ command: 'ash -c "cd /from/cache; cp -av . /to"'
35
+ });
36
+
37
+ await volumeApi.rm({ volumes: [composeHomeDataVolumeName] });
38
+ }
39
+ });
40
+
41
+ module.exports = {
42
+ convertComposerHomeToComposerCacheVolume
43
+ };
@@ -1,6 +1,6 @@
1
1
  const path = require('path');
2
+ const os = require('os');
2
3
  const { DockerFileBuilder } = require('../../util/dockerfile-builder');
3
- const semver = require('semver');
4
4
  const { execAsyncSpawn } = require('../../util/exec-async-command');
5
5
  const KnownError = require('../../errors/known-error');
6
6
  const { runContainerImage } = require('../../util/run-container-image');
@@ -93,12 +93,27 @@ const buildDockerFileInstructions = async (ctx, { image, tag }) => {
93
93
  .comment('make composer executable')
94
94
  .run('chmod +x ./composer')
95
95
  .comment('move composer to bin directory')
96
- .run('mv composer /usr/local/bin/composer');
96
+ .run('mv composer /usr/local/bin/composer')
97
+ .run('mkdir -p /composer/home/cache')
98
+ .env({
99
+ COMPOSER_HOME: '/composer/home',
100
+ COMPOSER_CACHE_DIR: '/composer/home/cache'
101
+ });
102
+
103
+ if (composer.plugins && Object.values(composer.plugins).length > 0) {
104
+ for (const [pluginName, pluginOptions] of Object.entries(composer.plugins)) {
105
+ if (pluginOptions.enabled) {
106
+ dockerFileInstructions
107
+ .comment(`install ${pluginName} composer global package`)
108
+ // eslint-disable-next-line max-len
109
+ .run(`composer global require ${pluginName}${ pluginOptions.options ? ` ${pluginOptions.options}` : '' }${ pluginOptions.options ? ` ${pluginOptions.options}` : ''}`);
110
+ }
111
+ }
112
+ }
97
113
 
98
- if (semver.satisfies(composer.version, '^1')) {
114
+ if (!ctx.isDockerDesktop) {
99
115
  dockerFileInstructions
100
- .comment('install prestissimo composer plugin')
101
- .run('composer global require hirak/prestissimo');
116
+ .run(`chown -R ${os.userInfo().uid}:${os.userInfo().gid} /composer/home`);
102
117
  }
103
118
 
104
119
  dockerFileInstructions
@@ -86,8 +86,8 @@ const removeLocalVolumes = () => ({
86
86
  await Promise.all(existingLocalVolumesDetails.map(async (v) => {
87
87
  if (v.Containers && Object.entries(v.Containers).length > 0) {
88
88
  await Promise.all(Object.values(v.Containers).map(async (c) => {
89
- await containerApi.stop(c.Name);
90
- await containerApi.rm(c.Name);
89
+ await containerApi.stop([c.Name]);
90
+ await containerApi.rm([c.Name]);
91
91
  }));
92
92
  }
93
93
  }));
@@ -89,7 +89,7 @@ const rm = async (options, execOptions = {}) => {
89
89
  */
90
90
  const inspect = async (options, execOptions = {}) => {
91
91
  const {
92
- image: volume,
92
+ volume,
93
93
  format,
94
94
  formatToJSON = false
95
95
  } = options;
@@ -29,6 +29,7 @@ const volumes = require('./docker/volume/tasks');
29
29
  const convertMySQLDatabaseToMariaDB = require('./docker/convert-mysql-to-mariadb');
30
30
  const { cmaGlobalConfig } = require('../config/cma-config');
31
31
  const { setProjectConfigTask } = require('./project-config');
32
+ const { convertComposerHomeToComposerCacheVolume } = require('./docker/convert-composer-home-to-composer-cache-volume');
32
33
 
33
34
  /**
34
35
  * @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
@@ -123,6 +124,7 @@ const configureProject = () => ({
123
124
  getComposerVersionTask(),
124
125
  prepareFileSystem(),
125
126
  volumes.createVolumes(),
127
+ convertComposerHomeToComposerCacheVolume(),
126
128
  installMagentoProject(),
127
129
  enableMagentoComposerPlugins(),
128
130
  startServices(),
@@ -116,7 +116,17 @@ const composerConfigurationSchema = Joi.object({
116
116
  }
117
117
 
118
118
  return versionValidator(value);
119
- })
119
+ }),
120
+ plugins: Joi.object()
121
+ .pattern(
122
+ Joi.string(),
123
+ Joi.object({
124
+ version: Joi.string().optional(),
125
+ options: Joi.string().optional(),
126
+ enabled: Joi.boolean().optional()
127
+ })
128
+ .unknown()
129
+ )
120
130
  });
121
131
 
122
132
  /**
@@ -45,12 +45,10 @@ const runInContainer = (options, commands) => {
45
45
  tty: true,
46
46
  detach: false,
47
47
  rm: true,
48
- command: commands.map((command) => command.split(' ')).flat().join(' ')
48
+ command: commands.join(' ')
49
49
  });
50
50
 
51
- const args = runArgs.slice(1).map((command) => command.split(' ')).flat();
52
-
53
- spawn('docker', args, { stdio: [0, 1, 2] });
51
+ spawn('bash', ['-c', runArgs.join(' ')], { stdio: [0, 1, 2] });
54
52
 
55
53
  return new Promise((_resolve) => {
56
54
  // never resolve
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.15",
6
+ "version": "2.0.0-alpha.17",
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": "df32030f4809af581a3ff909f215d31f74bc0207"
57
+ "gitHead": "8c4f3c41e8c96d259e22748b47d1b3a524af12f8"
58
58
  }
@@ -87,6 +87,10 @@ export interface ComposerConfiguration {
87
87
  plugins: Record<string, {
88
88
  version?: string
89
89
  options?: string
90
+ /**
91
+ * Enable composer plugin
92
+ */
93
+ enabled?: boolean
90
94
  }>
91
95
  }
92
96