@scandipwa/magento-scripts 1.14.0 → 1.14.1-alpha.10

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.
Files changed (91) hide show
  1. package/index.js +13 -0
  2. package/lib/commands/cli.js +28 -1
  3. package/lib/commands/execute.js +2 -1
  4. package/lib/config/docker.js +85 -12
  5. package/lib/config/get-port-config.js +7 -2
  6. package/lib/config/port-config.js +3 -1
  7. package/lib/config/scandipwa-versions.js +2 -1
  8. package/lib/config/ssl-terminator/index.js +10 -0
  9. package/lib/config/templates/magentorc.template +3 -5
  10. package/lib/config/templates/nginx.template.conf +0 -14
  11. package/lib/config/templates/php-fpm.template.conf +1 -0
  12. package/lib/config/templates/php.template.ini +6 -4
  13. package/lib/config/templates/ssl-terminator.template.conf +27 -0
  14. package/lib/config/templates/varnish.template.vcl +250 -0
  15. package/lib/config/varnish/varnish-6-0.js +11 -0
  16. package/lib/config/varnish/varnish-6-6.js +11 -0
  17. package/lib/config/varnish/varnish-7-0.js +11 -0
  18. package/lib/config/versions/magento-2.3.0.js +9 -1
  19. package/lib/config/versions/magento-2.3.1.js +9 -1
  20. package/lib/config/versions/magento-2.3.2-p2.js +9 -1
  21. package/lib/config/versions/magento-2.3.2.js +9 -1
  22. package/lib/config/versions/magento-2.3.3-p1.js +9 -1
  23. package/lib/config/versions/magento-2.3.3.js +9 -1
  24. package/lib/config/versions/magento-2.3.4-p2.js +9 -1
  25. package/lib/config/versions/magento-2.3.4.js +9 -1
  26. package/lib/config/versions/magento-2.3.5-p1.js +9 -1
  27. package/lib/config/versions/magento-2.3.5-p2.js +9 -1
  28. package/lib/config/versions/magento-2.3.5.js +9 -1
  29. package/lib/config/versions/magento-2.3.6-p1.js +9 -1
  30. package/lib/config/versions/magento-2.3.6.js +9 -1
  31. package/lib/config/versions/magento-2.3.7-p1.js +9 -1
  32. package/lib/config/versions/magento-2.3.7-p2.js +55 -0
  33. package/lib/config/versions/magento-2.3.7-p3.js +55 -0
  34. package/lib/config/versions/magento-2.3.7.js +9 -1
  35. package/lib/config/versions/magento-2.4.0-p1.js +9 -1
  36. package/lib/config/versions/magento-2.4.0.js +9 -1
  37. package/lib/config/versions/magento-2.4.1-p1.js +9 -1
  38. package/lib/config/versions/magento-2.4.1.js +9 -1
  39. package/lib/config/versions/magento-2.4.2-p1.js +9 -1
  40. package/lib/config/versions/magento-2.4.2-p2.js +9 -1
  41. package/lib/config/versions/magento-2.4.2.js +9 -1
  42. package/lib/config/versions/magento-2.4.3-p1.js +9 -1
  43. package/lib/config/versions/magento-2.4.3-p2.js +59 -0
  44. package/lib/config/versions/magento-2.4.3.js +9 -1
  45. package/lib/config/versions/magento-2.4.4.js +59 -0
  46. package/lib/tasks/cli/create-bashrc-config.js +5 -2
  47. package/lib/tasks/docker/containers.js +13 -8
  48. package/lib/tasks/docker/volumes.js +4 -4
  49. package/lib/tasks/file-system/create-nginx-config.js +7 -39
  50. package/lib/tasks/file-system/create-ssl-terminator-config.js +94 -0
  51. package/lib/tasks/file-system/create-varnish-config.js +74 -0
  52. package/lib/tasks/file-system/index.js +5 -1
  53. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +1 -1
  54. package/lib/tasks/magento/setup-magento/disable-2fa.js +4 -12
  55. package/lib/tasks/magento/setup-magento/disable-full-page-cache.js +20 -0
  56. package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +14 -16
  57. package/lib/tasks/magento/setup-magento/migrate-database.js +24 -11
  58. package/lib/tasks/magento/setup-magento/set-base-url.js +7 -2
  59. package/lib/tasks/magento/setup-magento/upgrade-magento.js +17 -3
  60. package/lib/tasks/magento/setup-magento/varnish-config.js +69 -0
  61. package/lib/tasks/mysql/fix-db.js +2 -2
  62. package/lib/tasks/php/index.js +1 -1
  63. package/lib/tasks/php/update-env-php.js +16 -1
  64. package/lib/tasks/php/update-env.php +56 -12
  65. package/lib/tasks/requirements/docker/index.js +2 -0
  66. package/lib/tasks/requirements/docker/install.js +11 -11
  67. package/lib/tasks/requirements/docker/running-status.js +137 -0
  68. package/lib/tasks/requirements/docker/version.js +2 -0
  69. package/lib/tasks/requirements/index.js +5 -5
  70. package/lib/tasks/requirements/php-version.js +3 -1
  71. package/lib/tasks/start.js +9 -10
  72. package/lib/tasks/status/index.js +25 -9
  73. package/lib/tasks/theme/build-theme.js +26 -8
  74. package/lib/tasks/theme/install-theme.js +16 -4
  75. package/lib/tasks/theme/link-theme.js +2 -2
  76. package/lib/tasks/theme/setup-persisted-query.js +3 -3
  77. package/lib/tasks/theme/setup-themes.js +3 -2
  78. package/lib/tasks/theme/symlink-theme.js +18 -3
  79. package/lib/util/config-file-validator.js +12 -1
  80. package/lib/util/config-php-json.js +19 -0
  81. package/lib/util/instance-metadata.js +9 -3
  82. package/lib/util/is-running-root.js +3 -0
  83. package/lib/util/match-filesystem.js +2 -1
  84. package/lib/util/php-task.js +6 -2
  85. package/lib/util/run-php.js +7 -1
  86. package/lib/util/systemctl.js +46 -0
  87. package/package.json +12 -2
  88. package/typings/context.d.ts +5 -1
  89. package/typings/index.d.ts +32 -1
  90. package/lib/tasks/magento/setup-magento/adjust-magento-configuration.js +0 -27
  91. package/lib/tasks/magento/setup-magento/disable-page-cache.js +0 -11
@@ -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.0",
6
+ "version": "1.14.1-alpha.10",
7
7
  "main": "./index.js",
8
8
  "types": "./typings/index.d.ts",
9
9
  "license": "OSL-3.0",
@@ -41,5 +41,15 @@
41
41
  "publishConfig": {
42
42
  "access": "public"
43
43
  },
44
- "gitHead": "60c7a2bacde24256dcb2d17128e41c0b371987a7"
44
+ "keywords": [
45
+ "magento",
46
+ "docker",
47
+ "php",
48
+ "nginx",
49
+ "redis",
50
+ "elasticsearch",
51
+ "mysql",
52
+ "scandipwa"
53
+ ],
54
+ "gitHead": "7d4d0843836447fa9ae49ad9927aa9eb2e92ca98"
45
55
  }
@@ -12,9 +12,12 @@ export interface ListrContext {
12
12
  mysql: number
13
13
  redis: number
14
14
  elasticsearch: number
15
+ varnish: number
16
+ sslTerminator: number
15
17
  }
16
18
  arch: 'arm64' | 'x64'
17
19
  isArm: boolean
20
+ isWsl: boolean
18
21
  platform?: NodeJS.Platform
19
22
  platformVersion?: string
20
23
  /**
@@ -51,7 +54,7 @@ export interface ListrContext {
51
54
  o: string
52
55
  }
53
56
  }>
54
- getContainers(): Record<'nginx' | 'redis' | 'mysql' | 'elasticsearch', {
57
+ getContainers(): Record<'nginx' | 'redis' | 'mysql' | 'elasticsearch' | 'varnish', {
55
58
  _: string
56
59
  ports: string[]
57
60
  healthCheck: {
@@ -88,4 +91,5 @@ export interface ListrContext {
88
91
  useNonOverlappingPorts: boolean
89
92
  }
90
93
  mysqlConnection: mysql2.Connection
94
+ isSetupUpgradeNeeded?: boolean
91
95
  }
@@ -10,7 +10,14 @@ export interface ServiceWithVersion {
10
10
  version: string
11
11
  }
12
12
 
13
- // export inter/
13
+ export interface SSLTerminatorConfiguration extends ServiceWithVersion {
14
+ /**
15
+ * Configuration file location
16
+ *
17
+ * @example ./my-ssl-terminator-config.conf
18
+ */
19
+ configTemplate: string
20
+ }
14
21
 
15
22
  export interface NginxConfiguration extends ServiceWithVersion {
16
23
  /**
@@ -21,6 +28,20 @@ export interface NginxConfiguration extends ServiceWithVersion {
21
28
  configTemplate: string
22
29
  }
23
30
 
31
+ export interface VarnishConfiguration extends ServiceWithVersion {
32
+ /**
33
+ * Enable or disable Varnish in the project
34
+ */
35
+ enabled: boolean
36
+
37
+ /**
38
+ * Configuration file location
39
+ *
40
+ * @example ./my-varnish-config.vcl
41
+ */
42
+ configTemplate: string
43
+ }
44
+
24
45
  export interface PHPExtension extends Record<string, unknown> {
25
46
  version?: string
26
47
  /**
@@ -175,6 +196,16 @@ export interface CMAConfiguration {
175
196
  * Composer configuration
176
197
  */
177
198
  composer: ServiceWithVersion
199
+
200
+ /**
201
+ * Varnish configuration
202
+ */
203
+ varnish: VarnishConfiguration
204
+
205
+ /**
206
+ * SSL Terminator configuration
207
+ */
208
+ sslTerminator: SSLTerminatorConfiguration
178
209
  }
179
210
  /**
180
211
  * Magento configuration
@@ -1,27 +0,0 @@
1
- const { isTableExists } = require('../../../util/database');
2
-
3
- /**
4
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
5
- */
6
- const adjustMagentoConfiguration = () => ({
7
- title: 'Adjusting Magento Database Configuration',
8
- skip: async (ctx) => !(await isTableExists('magento', 'core_config_data', ctx)),
9
- task: async (ctx) => {
10
- const { mysqlConnection } = ctx;
11
-
12
- // delete varnish configuration if exists
13
- await mysqlConnection.query(`
14
- DELETE FROM core_config_data WHERE path LIKE '%varnish%';
15
- `);
16
-
17
- // update cache policy to not use varnish
18
- // 0 - magento cache, 2 - varnish cache
19
- await mysqlConnection.query(`
20
- UPDATE core_config_data
21
- SET value = ?
22
- WHERE path = ?;
23
- `, ['0', 'system/full_page_cache/caching_application']);
24
- }
25
- });
26
-
27
- module.exports = adjustMagentoConfiguration;
@@ -1,11 +0,0 @@
1
- const magentoTask = require('../../../util/magento-task');
2
-
3
- /**
4
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
5
- */
6
- const disablePageCache = () => ({
7
- title: 'Disabling full_page cache in Magento',
8
- task: (ctx, task) => task.newListr(magentoTask('cache:disable full_page'))
9
- });
10
-
11
- module.exports = disablePageCache;