Giter Club home page Giter Club logo

octopus's Introduction

octopus Build Status

Octopus is a set of modules for start but to manage a multi-module npm project with traits:

  • tasks to recursively discover/load npm modules;
  • have means for incremental task running - run tests for all, change 1 module, run tests for just one changed module and its dependees;
  • presets for managing versions across multiple modules, sync module versions;
  • generic tasks that you compose and achieve basically anything.

Core modules

Presets

Example usage

Octopus does literally eats it's own dogfood and octopus repo is managed with start task-runner and octopus tasks including:

  • using git prepush hook to:
  • incrementally npm install and link modules in repo (see module.exports.bootstrap in tasks.js below);
  • incrementally run tests for modules in repo (see module.exports.test in tasks.js below);
  • clean all modules in repo (see module.exports.clean in tasks.js below);
  • release/publish new versions of changed modules (see module.exports.release in tasks.js below);
  • add custom tasks for what you need (ee module.exports.docs in tasks below).

Sample tasks.js file as prescribed by start:

const Start = require('start').default,
  reporter = require('octopus-start-reporter'),
  modules = require('octopus-start-preset-modules'),
  dependencies = require('octopus-start-preset-dependencies'),
  startTasks = require('octopus-start-tasks'),
  startModulesTasks = require('octopus-start-modules-tasks'),
  prepush = require('octopus-start-preset-prepush'),
  idea = require('octopus-start-preset-idea'),
  depcheck = require('octopus-start-preset-depcheck'),
  markdownMagic = require('markdown-magic');

const start = Start(reporter());

module.exports['modules:list'] = () => start(modules.list());
module.exports['modules:where'] = moduleName => start(modules.where(moduleName));
module.exports['modules:sync'] = () => start(modules.sync());
module.exports['deps:sync'] = () => start(dependencies.sync());
module.exports['deps:unmanaged'] = () => start(dependencies.unmanaged());
module.exports['deps:extraneous'] = () => start(dependencies.extraneous());
module.exports['deps:latest'] = () => start(dependencies.latest());
module.exports['idea'] = () => start(idea());
module.exports['init'] = () => start(prepush());
module.exports['depcheck'] = () => start(depcheck({ignoreMatches: ['start-simple-cli']}));

module.exports.sync = () => start(
  modules.sync(),
  dependencies.sync(),
  dependencies.unmanaged(),
  dependencies.extraneous(),
  module.exports.docs
)

module.exports.bootstrap = () => start(
  startModulesTasks.modules.load(),
  startModulesTasks.modules.removeUnchanged('bootstrap'),
  startModulesTasks.iter.async()((module, input, asyncReporter) => Start(asyncReporter)(
    startTasks.ifTrue(module.dependencies.length > 0)(() =>
      Start(asyncReporter)(startModulesTasks.module.exec(module)(`npm link ${module.dependencies.map(item => item.name).join(' ')}`))
    ),
    startModulesTasks.module.exec(module)('npm install --cache-min 3600 && npm link'),
    startModulesTasks.module.markBuilt(module, 'bootstrap')
  ))
)

module.exports.test = () => start(
  startModulesTasks.modules.load(),
  startModulesTasks.modules.removeUnchanged('test'),
  startModulesTasks.iter.async()((module, input, asyncReporter) => Start(asyncReporter)(
    startModulesTasks.module.exec(module)('npm run test'),
    startModulesTasks.module.markBuilt(module, 'test')
  ))
)

module.exports.clean = () => start(
  startModulesTasks.modules.load(),
  startModulesTasks.iter.async()((module, input, asyncReporter) => Start(asyncReporter)(
    startModulesTasks.module.exec(module)('rm -rf node_modules && rm -rf target && rm -f npm-shrinkwarp.json && rm -f yarn.lock && rm -f npm-debug.log*')
    )
  )
)

module.exports.release = () => start(
  startModulesTasks.modules.load(),
  startModulesTasks.iter.async()((module, input, asyncReporter) => Start(asyncReporter)(
    startModulesTasks.module.exec(module)('npm run release'),
    startModulesTasks.module.exec(module)('npm publish || true')
  ))
)

module.exports.docs = () => start(() => {
  return function generateDocs(log /*, reporter*/) {
    return Promise.resolve().then(() => {
      markdownMagic('./*.md');
    })
  }
});

And package.json that contains needed dependencies and npm scripts, of which:

  • postinstall - installs git prepush hook to execute sync export before pushing to remote;
  • start - to be able to execute any tasks defined in tasks.js like:
npm start bootstrap

That's it - for available tasks explore repo, see examples. Or open issues/pull requests. Enjoy!

octopus's People

Contributors

viliusl avatar itaipelles avatar hugebdu avatar laurynaslubys avatar leeor avatar adiramsalem avatar

Stargazers

larsw avatar Brian Kimball avatar Sibelius Seraphini avatar Ivan Kotov avatar Yaniv Efraim avatar Michael Salaverry avatar Eugene Lerman avatar Svyatoslav avatar Daniel Blendea avatar Kenneth Pullen avatar Bnaya Peretz avatar Gabriel Grinberg avatar  avatar

Watchers

Imran Nazar avatar Shmulik Flint avatar Slava Pozdniakov avatar Luis Godinez avatar Valentin Lavrinenko avatar Ivan Kamenev avatar Hed avatar James Cloos avatar Jonathan Bensaid avatar  avatar yaniv even haim avatar  avatar Eyal Yaniv avatar Adam Matan avatar Yoav Abrahami avatar Boris Litvinsky avatar Danny Steinhoff avatar Constantin Farber avatar Yoav Amit avatar Avi Haimov avatar Mykyta Shyrin avatar Shai Ben-Yehuda avatar  avatar Omar Shibli avatar Algimantas Krasauskas avatar  avatar Mariya Feldman avatar Denys avatar Gilad Artzi avatar Mantas Indrašius avatar Guy Sopher avatar Ofer LaOr avatar  avatar Kristina avatar avgar marciano avatar Ariel avatar Noam Katzir avatar Rob Rush avatar Ziv Levy avatar JJ Major avatar  avatar Roman Shevchuk avatar Guy Ben Moshe avatar Sagy Rozman avatar itay shmool avatar  gal sharir avatar Dovile avatar Nikita Bunchuk avatar Valera avatar Jony Vesterman Cohen avatar Andrey Makarov avatar Dan Bar-Shalom avatar Vytenis Butkevicius avatar Matan Lieberman avatar Uri Tagger avatar Oleksii Makodzeba avatar Lev Vidrak avatar Yuval Aviyam avatar Daniel Bond avatar Olesia Zaichenko avatar Andrii Ziabriev avatar Albert Elrom avatar  avatar Maor Hamami avatar Noam Moravtchik avatar Gregory Bondar avatar Gil Meir avatar Alan Brian Dardic avatar Yossi Ankri avatar nadav abrahami avatar Dror avatar Evaldas avatar Ward Abbass avatar Vadym Mateushev avatar Jurij Mikelionis avatar Aviva Herman avatar uri bechar avatar Vladimir Sorkin avatar dafna tamir avatar Artur Rieznik avatar Ariel Wine avatar Audrius Petreikis avatar Regimantas Merkys avatar Ilya Lytvynov avatar Ohad Laufer avatar Leonid Zhuk avatar Michaelda avatar mrokas avatar Nissan Nimni avatar Oren Zakay avatar yaniv zadok avatar Dan Koren avatar Tomer Cohen avatar Nir Kosover avatar Peter Tarasenko avatar Alena Kapatsyn avatar Dmytro Lukianchuk avatar Tomer Chajaj avatar Gal Morad avatar Noam Sagi avatar

octopus's Issues

add run-script command?

So that you could define scripts in octopus.json and execute those. I would use for chores like checking if there are no unused deps, etc.

add support to build tree for only changed modules

Now given you do clean checkout of x branch and do octo bootstrap or octo run test it builds all tree all modules. Idea is to filter graph and instruct it to build only modules and dependees where there were (are) changes when compared to master. This would give quite a benefit for verifying pull requests as feedback time would decrease alot in many cases.

It could be controlled via flag -g or smth like that.

fix error feedback

Now on failure there is no useful input (swallows output) whereas it should print stdout/stderr.

octo-release: add

Ok, so octopus-cli supports engines: yarn, npm. wnpm-release does not. Maybe wnpm-release should be enhanced to support engines and then octo-release would just use wnpm-release.

How it would look like:

octo-release --help

  - engine: yarn, npm, autodetect, where autodetect detects engine from octopus.json. autodetect is on by default.

octopus-start-modules-tasks: async-task: does not run at all

given we do a partial run:

  startModulesTasks.modules.load(),
  startModulesTasks.modules.removeUnchanged(),

it fails to run, as it does not find modules that can run (as there are unexecuted dependencies in current run, though those are actually built).

Need to filter-out dependencies that are already built

add `all` as type of task

now we have forEach and async that respect dependency graph. In some cases we just need to do mass changes disrespecting dependency grap - 'rm -rf node_modules'. Add all task that resembles Promise.all.

add support for precache

now we have some support for -p (parallel), but it mostly fails for:

  • npm due to existing links;
  • yarn - as it cannot download/add to cache in parallel.

what worked for me well is when I:

  • add all dependencies to managed;
  • use same versions;
  • do install on those (yarn downloads and caches them);
  • then do bootstrap -cap 24.

It's still not bulletproof, but it worked nicely and I did cut bootstrap time to < 10 mins for 80 module repo.

add depcheck module

so that I could do smth like this in my tasks.js

const startDepcheck = require('octopus-start-depcheck');

module.exports.depCheck = startpDepcheck({ignoreMatches: ['mocha*']});
// rest of tasks

make prepush hooks scriptable

now prepush hooks are hardcoded (octo modules sync --save && octo deps sync --save).

make them customazable via:
octopus.json

{
  "scripts": {
    "prepush": "octo deps sync --save && octo modules sync --save && echo 1"
  }
}

modules: traverse into private packages

Traverse into private packages, and if they contain other modules, ignore them - otherwise add them.

Some packages might be private just because they are not intended to be published - ex. docker apps, where published thing is docker image and not npm package, or test-apps that should run in ci, but no need to publish

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.