Skip to content

Commit

Permalink
move task running to @lando/core where it really belongs (#225)
Browse files Browse the repository at this point in the history
* move task running to @lando/core where it really belongs

* but renderer tests need to live here because we want to test the packaged CLI

* update to @lando/core#f8f4bd4 for full self loading core

* update to @lando/core#f8f4bd4 for full self loading core part 2

* update to @lando/core#6c2b56d0 for full self loading core part

* hardcore8d

* hardcore10
  • Loading branch information
pirog authored Oct 18, 2023
1 parent 2e8916e commit bcdbbc0
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 230 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-runtime-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: yarn
- name: Install Yarn dependencies
run: yarn install --prefer-offline --frozen-lockfile
run: yarn install --prefer-offline --frozen-lockfile --production

# @TODO: once we are no longer using github:lando/core-next#main as the repo for @lando/core-next
# eg once we are pulling a package from npm we can remove this
Expand Down
8 changes: 4 additions & 4 deletions bin/lando.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ if (runtime === 4) {
const Cli = require('./../lib/cli');
const cli = new Cli(ENVPREFIX, LOGLEVELCONSOLE, USERCONFROOT, COREBASE);
const bsLevel = (_.has(appConfig, 'recipe')) ? 'APP' : 'TASKS';
const bootstrap = require(`${COREBASE}/lib/bootstrap`);
const getTasks = require(`${COREBASE}/utils/get-tasks`);
debug('starting lando with %o runtime using cli %o', `v${runtime}`, {ENVPREFIX, LOGLEVELCONSOLE, USERCONFROOT, COREBASE});

// Lando cache stuffs
Expand All @@ -175,7 +175,7 @@ if (runtime === 4) {

// Print the cli if we've got tasks cached
if (fs.existsSync(process.landoTaskCacheFile)) {
cli.run(bootstrap.getTasks(appConfig, cli.argv()), appConfig);
cli.run(getTasks(appConfig, cli.argv()), appConfig);
// Otherwise min bootstrap lando so we can generate the task cache first
} else {
// NOTE: we require lando down here because it adds .5 seconds if we do it above
Expand All @@ -187,10 +187,10 @@ if (runtime === 4) {
lando.bootstrap(bsLevel).then(lando => {
// If bootstrap level is APP then we need to get and init our app to generate the app task cache
if (bsLevel === 'APP') {
lando.getApp().init().then(() => cli.run(bootstrap.getTasks(appConfig, cli.argv()), appConfig));
lando.getApp().init().then(() => cli.run(getTasks(appConfig, cli.argv()), appConfig));
// Otherwise run as yooz
} else {
cli.run(bootstrap.getTasks(appConfig, cli.argv()), appConfig);
cli.run(getTasks(appConfig, cli.argv()), appConfig);
}
});
}
Expand Down
1 change: 0 additions & 1 deletion examples/renderer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Run the following commands to get up and running with this example.

```bash
# Should start up successfully
lando poweroff
lando start
```

Expand Down
70 changes: 0 additions & 70 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,76 +476,6 @@ module.exports = class Cli {
this.init(yargs, tasks, config, userConfig);
}

// run a listr tasks list
async runTaskList(tasks, {
ctx = {},
debugRenderer = 'debug',
debugRendererOptions = {},
fallbackRenderer = 'verbose',
fallbackRendererOptions = {},
renderer = 'default',
rendererForce = false,
rendererOptions = {},
listrOptions = {},
} = {}) {
// get the bossman
const {Manager} = require('listr2');

// if rendererForce === false then reset the renderer if we are in debug mode
if (rendererForce === false
&& (this.logLevel > 1
|| this.logLevel === 'info'
|| this.logLevel === 'verbose'
|| this.logLevel === 'debug'
|| this.logLevel === 'silly'
)) {
renderer = debugRenderer;
rendererOptions = debugRendererOptions;
}

// attempt to reset the renderer if its a string and has a renderer we can load
if (typeof renderer === 'string' && fs.existsSync(path.resolve(__dirname, '..', 'renderers', `${renderer}.js`))) {
renderer = require(path.resolve(__dirname, '..', 'renderers', renderer));
}
if (typeof debugRenderer === 'string' && fs.existsSync(path.resolve(__dirname, '..', 'renderers', `${debugRenderer}.js`))) {
debugRenderer = require(path.resolve(__dirname, '..', 'renderers', debugRenderer));
}

// @NOTE: this is mostly just to test to make sure the default renderer works in GHA
if (process.env.LANDO_RENDERER_FORCE === '1') {
fallbackRenderer = renderer;
fallbackRendererOptions = rendererOptions;
}

const defaults = {
ctx,
concurrent: true,
collectErrors: true,
exitOnError: false,
fallbackRenderer,
fallbackRendererOptions,
renderer,
rendererOptions: {
log: require('@lando/core-next/debug')('lando').extend('cli'),
collapseSubtasks: false,
suffixRetries: false,
showErrorMessage: false,
},
showErrorMessage: false,
};

// construct the runner
const runner = new Manager(_.merge({}, defaults, {
...listrOptions,
rendererOptions,
}));

// add the tasks
runner.add(tasks);
// run
return runner.runAll();
}

/*
* Toggle a toggle
*/
Expand Down
13 changes: 4 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
"config/**/*.js",
"hooks/**/*.js",
"lib/**/*.js",
"node_modules/@lando/**/*.js",
"renderers/**/*.js"
"node_modules/@lando/core/**/*.js",
"node_modules/@lando/core-next/**/*.js"
],
"assets": [
"config.yml",
Expand Down Expand Up @@ -104,26 +104,21 @@
},
"dependencies": {
"@lando/argv": "^1.1.0",
"@lando/core": "github:lando/core#0414a88",
"@lando/core": "github:lando/core#45bc04e",
"@lando/core-next": "github:lando/core-next#183d75d",
"@oclif/core": "^1.22.0",
"chalk": "^4",
"cli-table": "^0.3.1",
"cli-table3": "^0.5.1",
"cli-truncate": "2.1.0",
"debug": "^4.3.4",
"figlet": "^1.1.1",
"inquirer": "^6.2.1",
"inquirer-autocomplete-prompt": "^1.0.1",
"is-docker": "^2",
"is-root": "^2",
"listr2": "^6.6.1",
"lodash": "^4.17.21",
"log-update": "4.0.0",
"mkdirp": "^0.5.1",
"sudo-block": "^2.0.0",
"which": "^2.0.2",
"wrap-ansi": "7.0.0",
"yargonaut": "^1.1.2",
"yargs": "^12.0.5"
},
Expand All @@ -140,7 +135,7 @@
"eslint-plugin-vue": "^8.0.3",
"mocha": "^4.1.0",
"nyc": "^12.0.1",
"pkg": "^5.3.1",
"pkg": "^5.8.1",
"rimraf": "^3.0.2",
"sinon": "^4.3.0",
"vuepress": "2.0.0-beta.53"
Expand Down
28 changes: 0 additions & 28 deletions renderers/debug.js

This file was deleted.

62 changes: 0 additions & 62 deletions renderers/lando.js

This file was deleted.

Loading

0 comments on commit bcdbbc0

Please sign in to comment.