@florianpat/lando-core 3.23.22-test2 → 3.23.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/CHANGELOG.md +1 -1
- package/builders/_init.js +2 -2
- package/hooks/app-run-events.js +23 -23
- package/lib/app.js +15 -4
- package/lib/docker.js +1 -1
- package/package.json +5 -5
- package/utils/build-tooling-task.js +1 -1
- package/utils/get-app.js +1 -2
- package/utils/get-init-runner-defaults.js +2 -1
- package/utils/parse-events-config.js +21 -1
- package/utils/parse-tooling-config.js +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }})
|
|
2
2
|
|
|
3
|
-
## v3.23.22
|
|
3
|
+
## v3.23.22 - [January 6, 2025](https://github.com/florianPat/lando-core/releases/tag/v3.23.22)
|
|
4
4
|
|
|
5
5
|
## v3.23.22 - [December 17, 2024](https://github.com/lando/core/releases/tag/v3.23.22)
|
|
6
6
|
|
package/builders/_init.js
CHANGED
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
|
17
17
|
dataHome: null,
|
|
18
18
|
},
|
|
19
19
|
builder: (parent, config) => class LandoInit extends parent {
|
|
20
|
-
constructor(userConfRoot, home, app, env = {}, labels = {}, image = 'devwithlando/util:4') {
|
|
20
|
+
constructor(userConfRoot, home, app, _app, env = {}, labels = {}, image = 'devwithlando/util:4') {
|
|
21
21
|
// Basic Init service
|
|
22
22
|
const initService = {
|
|
23
23
|
services: {
|
|
@@ -36,7 +36,7 @@ module.exports = {
|
|
|
36
36
|
initService.services.init.environment.LANDO_SERVICE_TYPE = 'init';
|
|
37
37
|
initService.services.init.labels['io.lando.service-container'] = 'TRUE';
|
|
38
38
|
initService.services.init.labels['io.lando.init-container'] = 'TRUE';
|
|
39
|
-
super('init', _.merge({}, config, {env, home, labels, userConfRoot}), initService);
|
|
39
|
+
super('init', _.merge({}, config, {env, home, labels, userConfRoot, _app}), initService);
|
|
40
40
|
};
|
|
41
41
|
},
|
|
42
42
|
};
|
package/hooks/app-run-events.js
CHANGED
|
@@ -3,33 +3,33 @@
|
|
|
3
3
|
const _ = require('lodash');
|
|
4
4
|
const remove = require('../utils/remove');
|
|
5
5
|
const path = require('path');
|
|
6
|
+
const formatters = require('../lib/formatters');
|
|
6
7
|
|
|
7
8
|
module.exports = async (app, lando, cmds, data, event) => {
|
|
8
9
|
const eventCommands = require('./../utils/parse-events-config')(cmds, app, data, lando);
|
|
9
|
-
// add perm sweeping to all v3 services
|
|
10
|
-
if (!_.isEmpty(eventCommands)) {
|
|
11
|
-
const permsweepers = _(eventCommands)
|
|
12
|
-
.filter(command => command.api === 3)
|
|
13
|
-
.map(command => ({id: command.id, services: _.get(command, 'opts.services', [])}))
|
|
14
|
-
.uniqBy('id')
|
|
15
|
-
.value();
|
|
16
|
-
lando.log.debug('added preemptive perm sweeping to evented v3 services %j', permsweepers.map(s => s.id));
|
|
17
|
-
_.forEach(permsweepers, ({id, services}) => {
|
|
18
|
-
eventCommands.unshift({
|
|
19
|
-
id,
|
|
20
|
-
cmd: '/helpers/user-perms.sh --silent',
|
|
21
|
-
compose: app.compose,
|
|
22
|
-
project: app.project,
|
|
23
|
-
opts: {
|
|
24
|
-
mode: 'attach',
|
|
25
|
-
user: 'root',
|
|
26
|
-
services,
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
10
|
const injectable = _.has(app, 'engine') ? app : lando;
|
|
32
|
-
|
|
11
|
+
|
|
12
|
+
const splitEventCommands = [];
|
|
13
|
+
while (!_.isEmpty(eventCommands)) {
|
|
14
|
+
splitEventCommands.push(
|
|
15
|
+
_.takeWhile(eventCommands,
|
|
16
|
+
(eventCommand, index) => index === 0 || (!!eventCommand.toolingTask === !!eventCommands[index - 1].toolingTask),
|
|
17
|
+
),
|
|
18
|
+
);
|
|
19
|
+
eventCommands.splice(0, _.last(splitEventCommands).length);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return lando.Promise.mapSeries(splitEventCommands, eventCommands => {
|
|
23
|
+
return lando.Promise.mapSeries(eventCommands, eventCommand => {
|
|
24
|
+
if (undefined !== eventCommand.toolingTask) {
|
|
25
|
+
const inquiry = formatters.getInteractive(eventCommand.toolingTask.options, eventCommand.answers);
|
|
26
|
+
return formatters.handleInteractive(inquiry, eventCommand.answers, eventCommand.toolingTask.command, lando)
|
|
27
|
+
.then(answers => eventCommand.toolingTask.run(_.merge(eventCommand.answers, answers)));
|
|
28
|
+
} else {
|
|
29
|
+
return injectable.engine.run(eventCommands);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}).catch(err => {
|
|
33
33
|
const command = _.tail(event.split('-')).join('-');
|
|
34
34
|
if (app.addMessage) {
|
|
35
35
|
const message = _.trim(_.get(err, 'message')) || 'UNKNOWN ERROR';
|
package/lib/app.js
CHANGED
|
@@ -57,7 +57,7 @@ module.exports = class App {
|
|
|
57
57
|
* @alias app.name
|
|
58
58
|
*/
|
|
59
59
|
this.name = require('../utils/slugify')(name);
|
|
60
|
-
this.project =
|
|
60
|
+
this.project = this.name;
|
|
61
61
|
this._serviceApi = 3;
|
|
62
62
|
this._config = lando.config;
|
|
63
63
|
this._defaultService = 'appserver';
|
|
@@ -515,11 +515,11 @@ module.exports = class App {
|
|
|
515
515
|
* Event that only gets triggered if the app never started before (or was destroyed)
|
|
516
516
|
*
|
|
517
517
|
* @since 3.22.3
|
|
518
|
-
* @alias app.events:bootstrap
|
|
519
|
-
* @event bootstrap
|
|
518
|
+
* @alias app.events:pre-bootstrap
|
|
519
|
+
* @event pre-bootstrap
|
|
520
520
|
* @property {App} app The app instance.
|
|
521
521
|
*/
|
|
522
|
-
.then(() => shouldBootstrap ? this.events.emit('bootstrap', this) : undefined)
|
|
522
|
+
.then(() => shouldBootstrap ? this.events.emit('pre-bootstrap', this) : undefined)
|
|
523
523
|
|
|
524
524
|
/**
|
|
525
525
|
* Event that runs before an app starts up.
|
|
@@ -547,6 +547,17 @@ module.exports = class App {
|
|
|
547
547
|
* @event post_start
|
|
548
548
|
*/
|
|
549
549
|
.then(() => this.events.emit('post-start'))
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Event that only gets triggered if the app never started before (or was destroyed)
|
|
553
|
+
*
|
|
554
|
+
* @since 3.22.3
|
|
555
|
+
* @alias app.events:post-bootstrap
|
|
556
|
+
* @event post-bootstrap
|
|
557
|
+
* @property {App} app The app instance.
|
|
558
|
+
*/
|
|
559
|
+
.then(() => shouldBootstrap ? this.events.emit('post-bootstrap', this) : undefined)
|
|
560
|
+
|
|
550
561
|
.then(() => this.log.info('started app.'));
|
|
551
562
|
};
|
|
552
563
|
|
package/lib/docker.js
CHANGED
|
@@ -92,7 +92,7 @@ module.exports = class Landerode extends Dockerode {
|
|
|
92
92
|
// Filter by app name if an app name was given.
|
|
93
93
|
.then(containers => {
|
|
94
94
|
if (options.project) return _.filter(containers, c => c.app === options.project);
|
|
95
|
-
else if (options.app) return _.filter(containers, c => c.app ===
|
|
95
|
+
else if (options.app) return _.filter(containers, c => c.app === options.app);
|
|
96
96
|
return containers;
|
|
97
97
|
})
|
|
98
98
|
// Then finally filter by everything else
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@florianpat/lando-core",
|
|
3
3
|
"description": "The libraries that power all of Lando. Fork by flo for compose integration",
|
|
4
|
-
"version": "3.23.22
|
|
4
|
+
"version": "3.23.22",
|
|
5
5
|
"author": "Florian Patruck @florianPat",
|
|
6
6
|
"license": "GPL-3.0",
|
|
7
7
|
"repository": "florianPat/lando-core",
|
|
@@ -247,9 +247,9 @@
|
|
|
247
247
|
"yargs-parser"
|
|
248
248
|
],
|
|
249
249
|
"dist": {
|
|
250
|
-
"integrity": "sha512-
|
|
251
|
-
"shasum": "
|
|
252
|
-
"filename": "florianpat-lando-core-3.23.22
|
|
253
|
-
"unpackedSize":
|
|
250
|
+
"integrity": "sha512-7Ak4ffLOApUfus6mu06+SGYIHKtpDFx45ACv5gQhuNtY8JgE/xyPL5EwCabkQXkZhwHKkN8nQXRUdFk9d7Tq/w==",
|
|
251
|
+
"shasum": "1f59804c71e8e5ddad072d8fa102ad50d6f3d956",
|
|
252
|
+
"filename": "florianpat-lando-core-3.23.22.tgz",
|
|
253
|
+
"unpackedSize": 60948228
|
|
254
254
|
}
|
|
255
255
|
}
|
|
@@ -36,7 +36,7 @@ module.exports = (config, injected) => {
|
|
|
36
36
|
{},
|
|
37
37
|
require('./build-init-runner')(_.merge(
|
|
38
38
|
{},
|
|
39
|
-
require('./get-init-runner-defaults')(app._lando, {destination: app.root, name: app.project}),
|
|
39
|
+
require('./get-init-runner-defaults')(app._lando, {destination: app.root, name: app.project, _app: app}),
|
|
40
40
|
{cmd: command, workdir: '/app', env},
|
|
41
41
|
)),
|
|
42
42
|
);
|
package/utils/get-app.js
CHANGED
|
@@ -23,8 +23,7 @@ module.exports = (files, userConfRoot) => {
|
|
|
23
23
|
if (!config.name) return {};
|
|
24
24
|
// cast the name to a string...just to make sure.
|
|
25
25
|
config.name = require('../utils/slugify')(config.name);
|
|
26
|
-
|
|
27
|
-
config.project = require('../utils/docker-composify')(config.name);
|
|
26
|
+
config.project = config.name;
|
|
28
27
|
|
|
29
28
|
return _.merge({}, config, {
|
|
30
29
|
configFiles: files,
|
|
@@ -10,6 +10,7 @@ module.exports = (lando, options) => {
|
|
|
10
10
|
lando.config.userConfRoot,
|
|
11
11
|
lando.config.home,
|
|
12
12
|
options.destination,
|
|
13
|
+
_.get(options, '_app', {}),
|
|
13
14
|
_.cloneDeep(lando.config.appEnv),
|
|
14
15
|
_.cloneDeep(lando.config.appLabels),
|
|
15
16
|
_.get(options, 'initImage', 'devwithlando/util:4'),
|
|
@@ -17,7 +18,7 @@ module.exports = (lando, options) => {
|
|
|
17
18
|
const initDir = path.join(lando.config.userConfRoot, 'init', options.name);
|
|
18
19
|
const initFiles = require('./dump-compose-data')(initData, initDir);
|
|
19
20
|
// Start to build out some propz and shiz
|
|
20
|
-
const project = `${lando.config.product}init` +
|
|
21
|
+
const project = `${lando.config.product}init` + options.name;
|
|
21
22
|
const separator = lando.config.orchestratorSeparator;
|
|
22
23
|
// Return
|
|
23
24
|
return {
|
|
@@ -38,6 +38,26 @@ module.exports = (cmds, app, data, lando) => _.map(cmds, cmd => {
|
|
|
38
38
|
// Discover the service
|
|
39
39
|
const command = getCommand(cmd);
|
|
40
40
|
const service = getService(cmd, data, app._defaultService);
|
|
41
|
+
|
|
42
|
+
if ('lando' === service) {
|
|
43
|
+
const yargs = require('yargs');
|
|
44
|
+
const argv = yargs(_.isArray(command) ? command.join(' ') : command).parse();
|
|
45
|
+
const $0 = _.pullAt(argv._, [0])[0];
|
|
46
|
+
const toolingTask = _.find(app.tasks, task => $0 === task.command);
|
|
47
|
+
argv._eventArgs = argv._;
|
|
48
|
+
argv.$0 = undefined;
|
|
49
|
+
argv._ = undefined;
|
|
50
|
+
argv._app = app;
|
|
51
|
+
|
|
52
|
+
if (undefined === toolingTask) {
|
|
53
|
+
throw new Error('Could not find tooling command: ' + $0);
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
toolingTask,
|
|
57
|
+
answers: argv,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
41
61
|
// compute stdio based on compose major version
|
|
42
62
|
const cstdio = _.get(app, '_config.orchestratorMV', 2) ? 'inherit' : ['inherit', 'pipe', 'pipe'];
|
|
43
63
|
|
|
@@ -67,7 +87,7 @@ module.exports = (cmds, app, data, lando) => _.map(cmds, cmd => {
|
|
|
67
87
|
{},
|
|
68
88
|
require('./build-init-runner')(_.merge(
|
|
69
89
|
{},
|
|
70
|
-
require('./get-init-runner-defaults')(lando, {destination: app.root, name: app.project}),
|
|
90
|
+
require('./get-init-runner-defaults')(lando, {destination: app.root, name: app.project, _app: app}),
|
|
71
91
|
{cmd, workdir: '/app'},
|
|
72
92
|
)),
|
|
73
93
|
{isInitEventCommand: true},
|
|
@@ -19,11 +19,11 @@ const getDynamicKeys = (answer, answers = {}) => _(answers)
|
|
|
19
19
|
* Set SERVICE from answers and strip out that noise from the rest of
|
|
20
20
|
* stuff, check answers/argv for --service or -s, validate and then remove
|
|
21
21
|
*/
|
|
22
|
-
const handleDynamic = (config, options = {}, answers = {}, execs = {}) => {
|
|
22
|
+
const handleDynamic = (config, argv, options = {}, answers = {}, execs = {}) => {
|
|
23
23
|
if (_.startsWith(config.service, ':')) {
|
|
24
24
|
const answer = answers[config.service.split(':')[1]];
|
|
25
25
|
// Remove dynamic service option from argv
|
|
26
|
-
_.remove(
|
|
26
|
+
_.remove(argv, arg => _.includes(getDynamicKeys(answer, answers).concat(answer), arg));
|
|
27
27
|
// get the service
|
|
28
28
|
const service = answers[config.service.split(':')[1]];
|
|
29
29
|
// Return updated config
|
|
@@ -40,9 +40,9 @@ const handleDynamic = (config, options = {}, answers = {}, execs = {}) => {
|
|
|
40
40
|
* the first three assuming they are [node, lando.js, options.name]'
|
|
41
41
|
* Check to see if we have global lando opts and remove them if we do
|
|
42
42
|
*/
|
|
43
|
-
const handleOpts = (config, name, argopts = []) => {
|
|
43
|
+
const handleOpts = (config, name, argv, argopts = []) => {
|
|
44
44
|
// Append any user specificed opts
|
|
45
|
-
argopts = argopts.concat(
|
|
45
|
+
argopts = argopts.concat(argv.slice(argv.findIndex(value => value === name.split(' ')[0]) + 1));
|
|
46
46
|
// If we have no args then just return right away
|
|
47
47
|
if (_.isEmpty(argopts)) return config;
|
|
48
48
|
// Return
|
|
@@ -72,9 +72,9 @@ module.exports = (cmd, service, name, options = {}, answers = {}, execs = {}) =>
|
|
|
72
72
|
// Put into an object so we can handle "multi-service" tooling
|
|
73
73
|
.map(cmd => parseCommand(cmd, service, execs))
|
|
74
74
|
// Handle dynamic services
|
|
75
|
-
.map(config => handleDynamic(config, options, answers, execs))
|
|
75
|
+
.map(config => handleDynamic(config, answers._eventArgs ?? process.argv, options, answers, execs))
|
|
76
76
|
// Add in any argv extras if they've been passed in
|
|
77
|
-
.map(config => handleOpts(config, name, handlePassthruOpts(options, answers)))
|
|
77
|
+
.map(config => handleOpts(config, name, answers._eventArgs ?? process.argv, handlePassthruOpts(options, answers)))
|
|
78
78
|
// Wrap the command in /bin/sh if that makes sense
|
|
79
79
|
.map(config => _.merge({}, config, {command: require('./shell-escape')(config.command, true, config.args, config.exec)})) // eslint-disable-line max-len
|
|
80
80
|
// Add any args to the command and compact to remove undefined
|