@scandipwa/magento-scripts 1.13.2 → 1.13.3
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/execute.js +33 -20
- package/lib/commands/logs.js +13 -1
- package/lib/commands/start.js +4 -2
- package/lib/config/dependencies-for-platforms.js +2 -1
- package/lib/tasks/cleanup.js +2 -0
- package/lib/tasks/magento/remove-magento.js +18 -20
- package/lib/tasks/magento/setup-magento/set-base-url.js +3 -3
- package/lib/tasks/requirements/dependency/ubuntu.js +40 -1
- package/lib/tasks/start.js +1 -1
- package/package.json +2 -2
package/lib/commands/execute.js
CHANGED
|
@@ -6,33 +6,46 @@ const executeInContainer = require('../tasks/execute');
|
|
|
6
6
|
* @param {import('yargs')} yargs
|
|
7
7
|
*/
|
|
8
8
|
module.exports = (yargs) => {
|
|
9
|
-
yargs.command(
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
yargs.command(
|
|
10
|
+
'exec <container name> [commands...]',
|
|
11
|
+
'Execute command in docker container',
|
|
12
|
+
(yargs) => {
|
|
13
|
+
yargs.usage(`Usage: npm run exec <container name> [commands...]
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
Available containers:
|
|
16
|
+
- mysql
|
|
17
|
+
- nginx
|
|
18
|
+
- redis
|
|
19
|
+
- elasticsearch`);
|
|
20
|
+
},
|
|
21
|
+
async (argv) => {
|
|
22
|
+
const containers = (await docker).getContainers();
|
|
23
|
+
const services = Object.keys(containers);
|
|
17
24
|
|
|
18
|
-
if (argv.
|
|
25
|
+
if (services.includes(argv.containername) || services.some((service) => service.includes(argv.containername))) {
|
|
26
|
+
const container = containers[argv.containername]
|
|
27
|
+
? containers[argv.containername]
|
|
28
|
+
: Object.entries(containers).find(([key]) => key.includes(argv.containername))[1];
|
|
29
|
+
|
|
30
|
+
if (argv.commands.length === 0) {
|
|
19
31
|
// if we have default connect command then use it
|
|
20
|
-
|
|
32
|
+
if (container.connectCommand) {
|
|
21
33
|
// eslint-disable-next-line no-param-reassign
|
|
22
|
-
|
|
23
|
-
|
|
34
|
+
argv.commands = container.connectCommand;
|
|
35
|
+
} else {
|
|
24
36
|
// otherwise fall back to bash (if it exists inside container)
|
|
25
|
-
|
|
37
|
+
argv.commands.push('bash');
|
|
38
|
+
}
|
|
26
39
|
}
|
|
40
|
+
await executeInContainer({
|
|
41
|
+
containerName: container.name,
|
|
42
|
+
commands: argv.commands
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return;
|
|
27
46
|
}
|
|
28
|
-
await executeInContainer({
|
|
29
|
-
containerName: container.name,
|
|
30
|
-
commands: argv.commands
|
|
31
|
-
});
|
|
32
47
|
|
|
33
|
-
|
|
48
|
+
logger.error(`No container found "${argv.containername}"`);
|
|
34
49
|
}
|
|
35
|
-
|
|
36
|
-
logger.error(`No container found "${argv.containername}"`);
|
|
37
|
-
});
|
|
50
|
+
);
|
|
38
51
|
};
|
package/lib/commands/logs.js
CHANGED
|
@@ -10,6 +10,18 @@ module.exports = (yargs) => {
|
|
|
10
10
|
'logs <scope>',
|
|
11
11
|
'Display application logs.',
|
|
12
12
|
(yargs) => {
|
|
13
|
+
yargs.usage(`Usage: npm run logs <scope>
|
|
14
|
+
|
|
15
|
+
Available scopes:
|
|
16
|
+
- magento
|
|
17
|
+
- mysql
|
|
18
|
+
- redis
|
|
19
|
+
- nginx
|
|
20
|
+
- elasticsearch
|
|
21
|
+
|
|
22
|
+
And you can use name matching:
|
|
23
|
+
npm run logs ma (will match magento)
|
|
24
|
+
npm run logs re (will match redis)`);
|
|
13
25
|
yargs.option(
|
|
14
26
|
'tail',
|
|
15
27
|
{
|
|
@@ -91,7 +103,7 @@ module.exports = (yargs) => {
|
|
|
91
103
|
|
|
92
104
|
return;
|
|
93
105
|
}
|
|
94
|
-
|
|
106
|
+
console.log(argv);
|
|
95
107
|
logger.error(`No service found "${argv.scope}"`);
|
|
96
108
|
process.exit(1);
|
|
97
109
|
}
|
package/lib/commands/start.js
CHANGED
|
@@ -95,12 +95,14 @@ module.exports = (yargs) => {
|
|
|
95
95
|
systemConfiguration: { analytics }
|
|
96
96
|
} = ctx;
|
|
97
97
|
|
|
98
|
+
const webLocation = `${ssl.enabled ? 'https' : 'http'}://${host}${ssl.enabled || ports.app === 80 ? '' : `:${ports.app}`}/`;
|
|
99
|
+
|
|
98
100
|
const block = new ConsoleBlock();
|
|
99
101
|
block
|
|
100
102
|
.addHeader('Magento 2')
|
|
101
103
|
.addEmptyLine()
|
|
102
|
-
.addLine(`Web location: ${logger.style.link(
|
|
103
|
-
.addLine(`Magento Admin panel location: ${logger.style.link(`${
|
|
104
|
+
.addLine(`Web location: ${logger.style.link(webLocation)}`)
|
|
105
|
+
.addLine(`Magento Admin panel location: ${logger.style.link(`${webLocation}${magentoConfiguration.adminuri}`)}`)
|
|
104
106
|
.addLine(`Magento Admin panel credentials: ${logger.style.misc(magentoConfiguration.user)} - ${logger.style.misc(magentoConfiguration.password)}`);
|
|
105
107
|
|
|
106
108
|
const themes = await getCSAThemes();
|
package/lib/tasks/cleanup.js
CHANGED
|
@@ -5,6 +5,7 @@ const {
|
|
|
5
5
|
uninstallMagento,
|
|
6
6
|
removeMagento
|
|
7
7
|
} = require('./magento');
|
|
8
|
+
const getMagentoVersionConfig = require('../config/get-magento-version-config');
|
|
8
9
|
const { stopPhpFpm } = require('./php-fpm');
|
|
9
10
|
const getProjectConfiguration = require('../config/get-project-configuration');
|
|
10
11
|
const checkConfigurationFile = require('../config/check-configuration-file');
|
|
@@ -16,6 +17,7 @@ const cleanup = () => ({
|
|
|
16
17
|
title: 'Cleanup project',
|
|
17
18
|
task: (ctx, task) => task.newListr([
|
|
18
19
|
checkConfigurationFile(),
|
|
20
|
+
getMagentoVersionConfig(),
|
|
19
21
|
getProjectConfiguration(),
|
|
20
22
|
stopPhpFpm(),
|
|
21
23
|
stopServices(),
|
|
@@ -37,29 +37,27 @@ const magentoFiles = [
|
|
|
37
37
|
*/
|
|
38
38
|
const removeMagento = () => ({
|
|
39
39
|
title: 'Remove magento application folder',
|
|
40
|
-
|
|
40
|
+
skip: async (ctx) => {
|
|
41
41
|
const { config: { baseConfig } } = ctx;
|
|
42
42
|
const appPathExists = await pathExists(baseConfig.magentoDir);
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}))
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
task.skip();
|
|
44
|
+
return !(appPathExists && ctx.force);
|
|
45
|
+
},
|
|
46
|
+
task: async (ctx) => {
|
|
47
|
+
const { config: { baseConfig } } = ctx;
|
|
48
|
+
await Promise.all(magentoFiles.map(async (fileName) => {
|
|
49
|
+
const filePath = path.join(baseConfig.magentoDir, fileName);
|
|
50
|
+
const fileExists = await pathExists(filePath);
|
|
51
|
+
if (!fileExists) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const file = await fs.promises.stat(filePath);
|
|
55
|
+
if (file.isFile()) {
|
|
56
|
+
await fs.promises.unlink(filePath);
|
|
57
|
+
} else if (file.isDirectory()) {
|
|
58
|
+
await fs.promises.rmdir(filePath, { recursive: true });
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
63
61
|
}
|
|
64
62
|
});
|
|
65
63
|
|
|
@@ -11,11 +11,11 @@ module.exports = () => ({
|
|
|
11
11
|
config: { overridenConfiguration: { host, ssl } },
|
|
12
12
|
mysqlConnection
|
|
13
13
|
} = ctx;
|
|
14
|
+
const enableSecureFrontend = ssl.enabled ? '1' : '0';
|
|
14
15
|
const location = `${host}${ ports.app !== 80 ? `:${ports.app}` : '' }/`;
|
|
16
|
+
const secureLocation = `${host}/`; // SSL will work only on port 443, so you cannot run multiple projects with SSL at the same time.
|
|
15
17
|
const httpUrl = `http://${location}`;
|
|
16
|
-
const httpsUrl = `https://${
|
|
17
|
-
|
|
18
|
-
const enableSecureFrontend = ssl.enabled ? '1' : '0';
|
|
18
|
+
const httpsUrl = `https://${secureLocation}`;
|
|
19
19
|
|
|
20
20
|
await updateTableValues('core_config_data', [
|
|
21
21
|
{ path: 'web/unsecure/base_url', value: httpUrl },
|
|
@@ -1,9 +1,31 @@
|
|
|
1
|
+
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
2
|
+
const os = require('os');
|
|
1
3
|
const dependenciesForPlatforms = require('../../../config/dependencies-for-platforms');
|
|
2
|
-
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
4
|
+
const { execAsyncSpawn, execCommandTask } = require('../../../util/exec-async-command');
|
|
3
5
|
const installDependenciesTask = require('../../../util/install-dependencies-task');
|
|
4
6
|
|
|
5
7
|
const pkgRegex = /^(\S+)\/\S+\s(\S+)\s\S+\s\S+$/i;
|
|
6
8
|
|
|
9
|
+
const updateSystem = () => ({
|
|
10
|
+
title: 'Updating Ubuntu system',
|
|
11
|
+
task: async (ctx, task) => {
|
|
12
|
+
task.output = 'Enter your sudo password!';
|
|
13
|
+
task.output = logger.style.command(`>[sudo] password for ${ os.userInfo().username }:`);
|
|
14
|
+
|
|
15
|
+
return task.newListr(
|
|
16
|
+
execCommandTask('sudo apt update', {
|
|
17
|
+
callback: (t) => {
|
|
18
|
+
task.output = t;
|
|
19
|
+
},
|
|
20
|
+
pipeInput: true
|
|
21
|
+
})
|
|
22
|
+
);
|
|
23
|
+
},
|
|
24
|
+
options: {
|
|
25
|
+
bottomBar: 10
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
7
29
|
/**
|
|
8
30
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
9
31
|
*/
|
|
@@ -28,6 +50,23 @@ const ubuntuDependenciesCheck = () => ({
|
|
|
28
50
|
.map((dep) => (Array.isArray(dep) ? dep[0] : dep));
|
|
29
51
|
|
|
30
52
|
if (dependenciesToInstall.length > 0) {
|
|
53
|
+
const runSystemUpdate = await task.prompt({
|
|
54
|
+
type: 'Confirm',
|
|
55
|
+
message: `Would you like to run ${logger.style.command('apt update')} before installing missing ${dependenciesToInstall.length} dependenc${dependenciesToInstall.length > 1 ? 'ies' : 'y'}?`
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
if (runSystemUpdate) {
|
|
59
|
+
return task.newListr([
|
|
60
|
+
updateSystem(),
|
|
61
|
+
installDependenciesTask({
|
|
62
|
+
platform: 'Ubuntu',
|
|
63
|
+
dependenciesToInstall
|
|
64
|
+
})
|
|
65
|
+
], {
|
|
66
|
+
concurrent: false
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
31
70
|
return task.newListr(
|
|
32
71
|
installDependenciesTask({
|
|
33
72
|
platform: 'Ubuntu',
|
package/lib/tasks/start.js
CHANGED
|
@@ -174,7 +174,7 @@ const start = () => ({
|
|
|
174
174
|
title: 'Opening browser',
|
|
175
175
|
skip: (ctx) => ctx.noOpen,
|
|
176
176
|
task: ({ ports, config: { overridenConfiguration: { host, ssl } } }) => {
|
|
177
|
-
openBrowser(`${ssl.enabled ? 'https' : 'http'}://${host}${ports.app === 80 ? '' : `:${ports.app}`}/`);
|
|
177
|
+
openBrowser(`${ssl.enabled ? 'https' : 'http'}://${host}${ssl.enabled || ports.app === 80 ? '' : `:${ports.app}`}/`);
|
|
178
178
|
},
|
|
179
179
|
options: {
|
|
180
180
|
showTimer: false
|
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.13.
|
|
6
|
+
"version": "1.13.3",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"types": "./typings/index.d.ts",
|
|
9
9
|
"license": "OSL-3.0",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "b03f5e0d8d7899f8d217b5eda38e7daabc63dccd"
|
|
46
46
|
}
|