{"action":"created","issue":{"url":"https://api.github.com/repos/makojs/core/issues/62","repository_url":"https://api.github.com/repos/makojs/core","labels_url":"https://api.github.com/repos/makojs/core/issues/62/labels{/name}","comments_url":"https://api.github.com/repos/makojs/core/issues/62/comments","events_url":"https://api.github.com/repos/makojs/core/issues/62/events","html_url":"https://github.com/makojs/core/pull/62","id":180729452,"number":62,"title":"Add build stream interfaces","user":{"login":"darsain","id":538801,"avatar_url":"https://avatars.githubusercontent.com/u/538801?v=3","gravatar_id":"","url":"https://api.github.com/users/darsain","html_url":"https://github.com/darsain","followers_url":"https://api.github.com/users/darsain/followers","following_url":"https://api.github.com/users/darsain/following{/other_user}","gists_url":"https://api.github.com/users/darsain/gists{/gist_id}","starred_url":"https://api.github.com/users/darsain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darsain/subscriptions","organizations_url":"https://api.github.com/users/darsain/orgs","repos_url":"https://api.github.com/users/darsain/repos","events_url":"https://api.github.com/users/darsain/events{/privacy}","received_events_url":"https://api.github.com/users/darsain/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2016-10-03T19:48:08Z","updated_at":"2016-10-08T20:00:38Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/makojs/core/pulls/62","html_url":"https://github.com/makojs/core/pull/62","diff_url":"https://github.com/makojs/core/pull/62.diff","patch_url":"https://github.com/makojs/core/pull/62.patch"},"body":"This PR adds a single method:\r\n\r\n### runner.stream(...[entries])\r\n\r\nReturns a build stream instead of a promise.\r\n\r\nThe stream is readable when any entry is passed, or a transform stream when no arguments are passed (wanted to make it a single duplex stream, but the implementation got over-complicated real quick).\r\n\r\nStreams output all files returned by `build.tree.getFiles()`.\r\n\r\nThe transform stream is an object stream that treats every write as a separate build. So if you want to build multiple entries in a single build, you'll pass them as an array:\r\n\r\n```js\r\nlet stream = runner.stream()\r\nstream.pipe(createConsumingStream())\r\n// build #1, eqv of => runner.build('entry.js')\r\nstream.write('entry.js')\r\n// build #2, eqv of => runner.build(['entry1.js', 'entry2.css'])\r\nstream.write(['entry1.js', 'entry2.css'])\r\n```\r\n\r\n## Use case\r\n\r\nWith this, we'll be able to seamlessly use mako builder with gulp, as well as any vinyl adapters.\r\n\r\nExample vinyl-fs adapter output to `build` folder:\r\n\r\n```js\r\nconst vfs = require('vinyl-fs')\r\nmako()\r\n  .use(someBundle())\r\n  .stream('./index.js')\r\n  .pipe(vfs.dest('build'))\r\n```\r\n\r\nExample build upload to Amazon S3:\r\n\r\n```js\r\nconst s3 = require(\"gulp-s3\")\r\nlet aws = {\r\n  \"key\": \"AKIAI3Z7CUAFHG53DMJA\",\r\n  \"secret\": \"acYxWRu5RRa6CwzQuhdXEfTpbQA+1XQJ7Z1bGTCx\",\r\n  \"bucket\": \"dev.example.com\",\r\n  \"region\": \"eu-west-1\"\r\n}\r\n\r\nmako()\r\n  .use(someBundle())\r\n  .stream('./index.js')\r\n  .pipe(s3(aws))\r\n```\r\n\r\nExample transform stream of local files coming from a vinyl-fs adapter glob, and ending in `build` folder:\r\n\r\n```js\r\nconst vfs = require('vinyl-fs')\r\nvfs.src('./*.js')\r\n  .pipe(mako().use(someBundle()).stream())\r\n  .pipe(vfs.dest('build'))\r\n```\r\n\r\n## For discussion\r\n\r\nI'm not sure I like the implicit nature of `#stream()` returning a different stream type based on existence of arguments. Maybe it would be better to split it into `#readableStream(...entries)` and `#transformStream()`, but I don't like long method names with camelCasing when they are not necessary :)"},"comment":{"url":"https://api.github.com/repos/makojs/core/issues/comments/252445209","html_url":"https://github.com/makojs/core/pull/62#issuecomment-252445209","issue_url":"https://api.github.com/repos/makojs/core/issues/62","id":252445209,"user":{"login":"darsain","id":538801,"avatar_url":"https://avatars.githubusercontent.com/u/538801?v=3","gravatar_id":"","url":"https://api.github.com/users/darsain","html_url":"https://github.com/darsain","followers_url":"https://api.github.com/users/darsain/followers","following_url":"https://api.github.com/users/darsain/following{/other_user}","gists_url":"https://api.github.com/users/darsain/gists{/gist_id}","starred_url":"https://api.github.com/users/darsain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darsain/subscriptions","organizations_url":"https://api.github.com/users/darsain/orgs","repos_url":"https://api.github.com/users/darsain/repos","events_url":"https://api.github.com/users/darsain/events{/privacy}","received_events_url":"https://api.github.com/users/darsain/received_events","type":"User","site_admin":false},"created_at":"2016-10-08T20:00:38Z","updated_at":"2016-10-08T20:00:38Z","body":"Yeah, tree object implementing an iterator would be cool. It won't simplify much for my particular use case here, but it will definitely make working with tree objects in a lot of other places nicer, so 👍.\r\n\r\nBut I wouldn't expect build object to be an iterator to be honest. I would expect it to to contain data about build, and file iterator to be only on a tree object, no?"}}
{"actor":{"display_login":"darsain"}}