@florianpat/lando-core 3.23.27-1florianPat.0 → 3.23.27-2florianPat.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }})
2
2
 
3
- ## v3.23.27-1florianPat.0 - [February 17, 2025](https://github.com/florianPat/lando-core/releases/tag/v3.23.27-1florianPat.0)
3
+ ## v3.23.27-2florianPat.0 - [February 19, 2025](https://github.com/florianPat/lando-core/releases/tag/v3.23.27-2florianPat.0)
4
4
 
5
5
  ## v3.23.26 - [January 24, 2025](https://github.com/lando/core/releases/tag/v3.23.26)
6
6
 
package/app.js CHANGED
@@ -113,6 +113,9 @@ module.exports = async (app, lando) => {
113
113
  // Add tooling if applicable
114
114
  app.events.on('post-init', async () => await require('./hooks/app-add-tooling')(app, lando));
115
115
 
116
+ // Add _init tooling for bootstrap reference
117
+ app.events.on('pre-bootstrap', async () => await require('./hooks/app-add-init-tooling')(app, lando));
118
+
116
119
  // Collect info so we can inject LANDO_INFO
117
120
  // @NOTE: this is not currently the full lando info because a lot of it requires the app to be on
118
121
  app.events.on('post-init', 10, async () => await require('./hooks/app-set-lando-info')(app, lando));
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ const _ = require('lodash');
4
+
5
+ module.exports = async (app, lando) => {
6
+ if (!_.isEmpty(_.get(app, 'config.tooling', {}))) {
7
+ app.log.verbose('additional tooling detected');
8
+
9
+ // Add the _init tasks for the bootstrap event!
10
+ // TODO(flo): They are duplicated through "app-add-tooling" but I do not care for now!
11
+ _.forEach(require('../utils/get-tooling-tasks')(app.config.tooling, app), task => {
12
+ if (task.service !== '_init') {
13
+ return;
14
+ }
15
+
16
+ app.log.debug('adding app cli task %s', task.name);
17
+ const injectable = _.has(app, 'engine') ? app : lando;
18
+ app.tasks.push(require('../utils/build-tooling-task')(task, injectable));
19
+ });
20
+ }
21
+ };
package/lib/app.js CHANGED
@@ -11,8 +11,8 @@ const fs = require('node:fs');
11
11
  /*
12
12
  * Helper to init and then report
13
13
  */
14
- const initAndReport = (app, method = 'start') => {
15
- return app.init().then(() => {
14
+ const initAndReport = (app, method, shouldBootstrap = false) => {
15
+ return app.init({shouldBootstrap}).then(() => {
16
16
  app.metrics.report(method, utils.metricsParse(app));
17
17
  return Promise.resolve(true);
18
18
  });
@@ -257,6 +257,8 @@ module.exports = class App {
257
257
  .then(() => this.log.info('destroyed app.'));
258
258
  };
259
259
 
260
+ static isBootstrapCommand = undefined;
261
+
260
262
  /**
261
263
  * Initializes the app
262
264
  *
@@ -270,21 +272,37 @@ module.exports = class App {
270
272
  * @fires ready
271
273
  * @return {Promise} A Promise.
272
274
  */
273
- init({noEngine = false} = {}) {
275
+ init({noEngine = false, shouldBootstrap = false} = {}) {
274
276
  // We should only need to initialize once, if we have just go right to app ready
275
277
  if (this.initialized) return this.events.emit('ready', this);
278
+ if (undefined === App.isBootstrapCommand) {
279
+ App.isBootstrapCommand = !fs.existsSync(this._dir);
280
+ }
281
+ const bootstrapping = App.isBootstrapCommand && shouldBootstrap && !noEngine;
282
+ if (bootstrapping) {
283
+ console.log(require('yargonaut').chalk().cyan('Looks like this is the first time to start the app. Lets bootstrap it...'));
284
+ }
285
+
286
+ return loadPlugins(this, this._lando)
287
+ /**
288
+ * Event that only gets triggered if the app never started before (or was destroyed)
289
+ *
290
+ * @since 3.23.25
291
+ * @alias app.events:pre-bootstrap
292
+ * @event pre-bootstrap
293
+ * @property {App} app The app instance.
294
+ */
295
+ .then(() => bootstrapping ? this.events.emit('pre-bootstrap', this) : undefined)
276
296
  // Get compose data if we have any, otherwise set to []
277
- return require('../utils/load-compose-files')(
297
+ .then(() => noEngine === true ? [] : require('../utils/load-compose-files')(
278
298
  _.get(this, 'config.compose', []),
279
299
  this.root,
280
300
  this._dir,
281
301
  (composeFiles, outputFilePath) =>
282
302
  this.engine.getComposeConfig({compose: composeFiles, project: this.project, outputFilePath}),
283
- )
303
+ ))
284
304
  .then(composeFileData => {
285
- if (undefined !== composeFileData) {
286
- this.composeData = [new this.ComposeService('compose', {}, composeFileData)];
287
- }
305
+ this.composeData = [new this.ComposeService('compose', {}, ...composeFileData)];
288
306
  // Validate and set env files
289
307
  this.envFiles = require('../utils/normalize-files')(_.get(this, 'config.env_file', []), this.root);
290
308
  // Log some things
@@ -303,8 +321,6 @@ module.exports = class App {
303
321
  * @event pre_init
304
322
  * @property {App} app The app instance.
305
323
  */
306
- .then(() => loadPlugins(this, this._lando))
307
-
308
324
  .then(() => this.events.emit('pre-init', this))
309
325
  // Actually assemble this thing so its ready for that engine
310
326
  .then(() => {
@@ -501,25 +517,15 @@ module.exports = class App {
501
517
  * @alias app.start
502
518
  * @fires pre_start
503
519
  * @fires post_start
520
+ * @fires post_bootstrap
504
521
  * @return {Promise} A Promise.
505
522
  *
506
523
  */
507
524
  start() {
508
525
  // Log
509
526
  this.log.info('starting app...');
510
- const shouldBootstrap = fs.existsSync(this._dir);
511
-
512
- return initAndReport(this)
513
527
 
514
- /**
515
- * Event that only gets triggered if the app never started before (or was destroyed)
516
- *
517
- * @since 3.22.3
518
- * @alias app.events:pre-bootstrap
519
- * @event pre-bootstrap
520
- * @property {App} app The app instance.
521
- */
522
- .then(() => shouldBootstrap ? this.events.emit('pre-bootstrap', this) : undefined)
528
+ return initAndReport(this, 'start', true)
523
529
 
524
530
  /**
525
531
  * Event that runs before an app starts up.
@@ -551,12 +557,12 @@ module.exports = class App {
551
557
  /**
552
558
  * Event that only gets triggered if the app never started before (or was destroyed)
553
559
  *
554
- * @since 3.22.3
560
+ * @since 3.23.25
555
561
  * @alias app.events:post-bootstrap
556
562
  * @event post-bootstrap
557
563
  * @property {App} app The app instance.
558
564
  */
559
- .then(() => shouldBootstrap ? this.events.emit('post-bootstrap', this) : undefined)
565
+ .then(() => App.isBootstrapCommand ? this.events.emit('post-bootstrap', this) : undefined)
560
566
 
561
567
  .then(() => this.log.info('started app.'));
562
568
  };
package/lib/engine.js CHANGED
@@ -172,7 +172,7 @@ module.exports = class Engine {
172
172
  * return lando.engine.exists(compose);
173
173
  */
174
174
  exists(data) {
175
- return this.engineCmd('exists', data);
175
+ return this.engineCmd('exists', _.merge({}, {separator: this.separator}, data));
176
176
  };
177
177
 
178
178
  /*
package/lib/formatters.js CHANGED
@@ -135,7 +135,7 @@ exports.handleInteractive = (inquiry, argv, command, lando) => lando.Promise.try
135
135
  // NOTE: We need to clone deep here otherwise any apps with interactive options get 2x all their events
136
136
  // NOTE: Not exactly clear on why app here gets conflated with the app returned from lando.getApp
137
137
  const app = _.cloneDeep(lando.getApp(argv._app.root));
138
- return app.init().then(() => {
138
+ return app.init({noEngine: true}).then(() => {
139
139
  inquiry = exports.getInteractive(_.find(app.tasks.concat(lando.tasks), {command: command}).options, argv);
140
140
  return inquirer.prompt(_.sortBy(inquiry, 'weight'));
141
141
  });
package/lib/router.js CHANGED
@@ -55,7 +55,7 @@ exports.destroy = (data, compose, docker) => retryEach(data, datum => {
55
55
  exports.exists = (data, compose, docker, ids = []) => {
56
56
  if (data.compose) return compose('getId', data).then(id => !_.isEmpty(id));
57
57
  else {
58
- return docker.list()
58
+ return docker.list({}, data.separator)
59
59
  .each(container => {
60
60
  ids.push(container.id);
61
61
  ids.push(container.name);
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.27-1florianPat.0",
4
+ "version": "3.23.27-2florianPat.0",
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-EF8oq87DSgrav9p/64DkDyDuudJ/hW3soeFWiiuZzhjIIZ52UV98g6DGiIjVVyowcVtuAL6sAf/cidZkv7s+tQ==",
251
- "shasum": "7fa58d190ddcacde2bb53ede9fffc5d92c0bb42c",
252
- "filename": "florianpat-lando-core-3.23.27-1florianPat.0.tgz",
253
- "unpackedSize": 60965868
250
+ "integrity": "sha512-nJ+omUdEgvWWSzY820agmarvTKCfYXYkslyaSNxCZOtyctgzRioHpx4qXRvYnoaHS6q6zjCwSShslZAGwPyyyw==",
251
+ "shasum": "864b2749e3dd4bf4691b29fd9aeb45046c61f402",
252
+ "filename": "florianpat-lando-core-3.23.27-2florianPat.0.tgz",
253
+ "unpackedSize": 60967423
254
254
  }
255
255
  }
@@ -23,7 +23,7 @@ module.exports = (config, injected) => {
23
23
  const run = answers => {
24
24
  let initToolingRunner = null;
25
25
 
26
- return injected.Promise.try(() => (_.isEmpty(app.compose)) ? app.init() : true)
26
+ return injected.Promise.try(() => (_.isEmpty(app.compose) && '_init' !== service) ? app.init() : true)
27
27
  // Kick off the pre event wrappers
28
28
  .then(() => app.events.emit(`pre-${eventName}`, config, answers))
29
29
  // Get an interable of our commandz
@@ -74,5 +74,6 @@ module.exports = (config, injected) => {
74
74
  describe,
75
75
  run,
76
76
  options,
77
+ service,
77
78
  };
78
79
  };
@@ -3,6 +3,7 @@
3
3
  const _ = require('lodash');
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
+ const App = require('../lib/app');
6
7
 
7
8
  /*
8
9
  * Paths to /
@@ -40,9 +41,10 @@ const loadCacheFile = file => {
40
41
  */
41
42
  const appRunner = command => (argv, lando) => {
42
43
  const app = lando.getApp(argv._app.root);
44
+ const service = _.get(app.config, `tooling.${command}.service`, '');
43
45
  return lando.events.emit('pre-app-runner', app)
44
46
  .then(() => lando.events.emit('pre-command-runner', app))
45
- .then(() => app.init().then(() => _.find(app.tasks, {command}).run(argv)));
47
+ .then(() => app.init({noEngine: '_init' === service}).then(() => _.find(app.tasks, {command}).run(argv)));
46
48
  };
47
49
 
48
50
  /*
@@ -128,7 +130,7 @@ module.exports = (config = {}, argv = {}, tasks = []) => {
128
130
 
129
131
  // If the tooling command is being called lets assess whether we can get away with engine bootstrap level
130
132
  const ids = _(config.tooling).map(task => task.id).filter(_.identity).value();
131
- const level = (_.includes(ids, argv._[0])) ? getBsLevel(config, argv._[0]) : 'app';
133
+ const level = !App.isBootstrapCommand && (_.includes(ids, argv._[0])) ? getBsLevel(config, argv._[0]) : 'app';
132
134
 
133
135
  // Load all the tasks, remember we need to remove "disabled" tasks (eg non-object tasks) here
134
136
  _.forEach(_.get(config, 'tooling', {}), (task, command) => {
@@ -12,7 +12,7 @@ const remove = require('./remove');
12
12
  module.exports = async (files, dir, landoComposeConfigDir = undefined, outputConfigFunction = undefined) => {
13
13
  const composeFilePaths = _(require('./normalize-files')(files, dir)).value();
14
14
  if (_.isEmpty(composeFilePaths)) {
15
- return {};
15
+ return [];
16
16
  }
17
17
 
18
18
  if (undefined === outputConfigFunction) {
@@ -29,5 +29,5 @@ module.exports = async (files, dir, landoComposeConfigDir = undefined, outputCon
29
29
  fs.unlinkSync(outputFile);
30
30
  remove(path.dirname(outputFile));
31
31
 
32
- return result;
32
+ return [result];
33
33
  };