{"action":"created","issue":{"url":"https://api.github.com/repos/LaxarJS/grunt-laxar/issues/41","labels_url":"https://api.github.com/repos/LaxarJS/grunt-laxar/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/LaxarJS/grunt-laxar/issues/41/comments","events_url":"https://api.github.com/repos/LaxarJS/grunt-laxar/issues/41/events","html_url":"https://github.com/LaxarJS/grunt-laxar/issues/41","id":68598385,"number":41,"title":"directory_tree: use per-artifact configuration for static resources, embeddings and watcher settings","user":{"login":"x1B","id":327904,"avatar_url":"https://avatars.githubusercontent.com/u/327904?v=3","gravatar_id":"","url":"https://api.github.com/users/x1B","html_url":"https://github.com/x1B","followers_url":"https://api.github.com/users/x1B/followers","following_url":"https://api.github.com/users/x1B/following{/other_user}","gists_url":"https://api.github.com/users/x1B/gists{/gist_id}","starred_url":"https://api.github.com/users/x1B/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/x1B/subscriptions","organizations_url":"https://api.github.com/users/x1B/orgs","repos_url":"https://api.github.com/users/x1B/repos","events_url":"https://api.github.com/users/x1B/events{/privacy}","received_events_url":"https://api.github.com/users/x1B/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/LaxarJS/grunt-laxar/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/LaxarJS/grunt-laxar/labels/in%20progress","name":"in progress","color":"ededed"}],"state":"open","locked":false,"assignee":{"login":"x1B","id":327904,"avatar_url":"https://avatars.githubusercontent.com/u/327904?v=3","gravatar_id":"","url":"https://api.github.com/users/x1B","html_url":"https://github.com/x1B","followers_url":"https://api.github.com/users/x1B/followers","following_url":"https://api.github.com/users/x1B/following{/other_user}","gists_url":"https://api.github.com/users/x1B/gists{/gist_id}","starred_url":"https://api.github.com/users/x1B/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/x1B/subscriptions","organizations_url":"https://api.github.com/users/x1B/orgs","repos_url":"https://api.github.com/users/x1B/repos","events_url":"https://api.github.com/users/x1B/events{/privacy}","received_events_url":"https://api.github.com/users/x1B/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/LaxarJS/grunt-laxar/milestones/19","html_url":"https://github.com/LaxarJS/grunt-laxar/milestones/v1.1.0","labels_url":"https://api.github.com/repos/LaxarJS/grunt-laxar/milestones/19/labels","id":1154424,"number":19,"title":"v1.1.0","description":"","creator":{"login":"x1B","id":327904,"avatar_url":"https://avatars.githubusercontent.com/u/327904?v=3","gravatar_id":"","url":"https://api.github.com/users/x1B","html_url":"https://github.com/x1B","followers_url":"https://api.github.com/users/x1B/followers","following_url":"https://api.github.com/users/x1B/following{/other_user}","gists_url":"https://api.github.com/users/x1B/gists{/gist_id}","starred_url":"https://api.github.com/users/x1B/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/x1B/subscriptions","organizations_url":"https://api.github.com/users/x1B/orgs","repos_url":"https://api.github.com/users/x1B/repos","events_url":"https://api.github.com/users/x1B/events{/privacy}","received_events_url":"https://api.github.com/users/x1B/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":0,"state":"open","created_at":"2015-06-08T10:00:25Z","updated_at":"2015-06-25T09:18:31Z","due_on":"2015-09-15T22:00:00Z","closed_at":null},"comments":0,"created_at":"2015-04-15T07:18:17Z","updated_at":"2015-07-01T07:50:12Z","closed_at":null,"body":"### Status Quo (v1.0.0)\r\n\r\nCurrently, the _Gruntfile_ configuration for your average LaxarJS project contains a lot of paths and patterns that are specific to the artifacts used by the application and to their relative location. Especially if artifacts are installed as *bower_components*, things can get tricky. This may lead to subtle, hard-to-diagnose errors where resources cannot be found, or where their correct theme folder is not used.\r\n\r\nAlso, the `watch` task for live reload may become very slow, just by having the wrong set of files somewhere within your project (e.g. a nested *node_modules* somewhere deep in a widget), due to missing exclusion rules.\r\n\r\nIdeally, we would be able to have a Gruntfile that is simplified to the point where there are (almost) only _zero-configuration defaults_  that _just work_, while making sure that everything, especially live reload, is handled in a responsive manner. \r\n\r\n\r\n### The Ansatz\r\n\r\nBased on which artifacts are reachable from a project's *flow* we should determine what files to *watch*, what files to _include/embed_ into the listings, and what JS *modules* to load as dependencies.\r\n\r\nFor this, we add a new task `laxar-artifacts` which creates a model of your entire application based on a set of flows to include. Starting at the flows, the task identifies *pages*, *compositions* and *layouts* and their resources, taking into account the set of installed *themes*. Next, all _widgets_ on these pages and their _controls_ are identified. The resulting model is stored in JSON format, and should be useful not just for other grunt-tasks, but possibly for client-side tooling as well.\r\n\r\nTo allow for additional resources to be watched/listed/included, the artifact's _descriptors_ (widget.json, control.json) will support a new top-level entry `resources` with the following schema:\r\n\r\n```js\r\n{\r\n   type: \"object\",\r\n   properties: {\r\n      \"watch\": { \r\n         type: \"array\", \r\n         items: { type: \"string\" }\r\n      },\r\n      \"list\": { \r\n         type: \"array\", \r\n         items: { type: \"string\" }\r\n      },\r\n      \"embed\": { \r\n         type: \"array\", \r\n         items: { type: \"string\" }\r\n      }\r\n   }\r\n}\r\n```\r\n\r\nUsually, it is *not necessary* to add this information per-artifact, as the defaults will almost always be sufficient.\r\n\r\n\r\n### New Flow-Based Artifacts\r\n\r\nNow that we have a complete model of our flow artifacts, we can start using it to generate the following things:\r\n\r\n* _dependencies_ used by RequireJS (and r.js for production) to find and load AMD modules that implement widgets and controls\r\n\r\n* _resources_ mainly used by the LaxarJS runtime to determine for which artifact HTML/CSS is available, and in which theme\r\n\r\n* _watcher configuration_ used by the development server to know when to reload the application in the browser\r\n\r\n* _merged CSS_ for all artifacts used in a flow, so that CSS is loaded quickly in production.\r\n\r\nBecause each set of flows is handled in isolation, it is possible to split your application into several flows which select from the same set of artifacts. For example, there might be one flow for the regular use of your application, and another flow for configuring and customizing the application. \r\n\r\n\r\n### Flow-Aware Tasks for grunt-Laxar v1.1.0\r\n\r\nTo implement all of this, a new set of flow-aware tasks is needed. Task output is stored under `var/flows/$flowSet` where `$flowSet` is a configurable identifier that corresponds to a set of flow definitions. By default (using the application template), there is one flow-set `main` containing the flow `application/flows/flow.json`. Here are the individual tasks with their outputs:\r\n\r\n\r\n- [x] `laxar-artifacts` collects all artifacts from the set of flows, creating an application model for them (`tooling/artifacts.json`)\r\n\r\n- [x] `laxar-dependencies` collects AMD modules that implement artifacts (`dependencies.js`)\r\n\r\n- [ ] `laxar-resources` generates the resource listings for these artifacts based on which of the associated resources are _actually available_ on the file system\r\n\r\n- [ ] `laxar-watch` configures and launches the grunt `watch` task based on the set of flows and stores the configuration for inspection (`work/watch-configuration.json`, *development only*)\r\n\r\n- [ ] `laxar-merge-css` creates a combined CSS file for this flow, for each theme (`dist/my.theme.css`, *production only*)\r\n\r\n- [ ] `laxar-merge-js` uses *r.js* to produce a single JavaScript file for the flow and all its dependencies (`dist/bundle.js`/`dist/bundle.js.map`, *production only*).\r\n\r\n\r\n### Compatibility with v1.0.0\r\n\r\nAlthough it should be very simple to upgrade any project to using the new tasks, the old tasks will be kept for compatibility with LaxarJS v1.0.0, but may issue deprecation warnings in the future.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/LaxarJS/grunt-laxar/issues/comments/117515662","html_url":"https://github.com/LaxarJS/grunt-laxar/issues/41#issuecomment-117515662","issue_url":"https://api.github.com/repos/LaxarJS/grunt-laxar/issues/41","id":117515662,"user":{"login":"x1B","id":327904,"avatar_url":"https://avatars.githubusercontent.com/u/327904?v=3","gravatar_id":"","url":"https://api.github.com/users/x1B","html_url":"https://github.com/x1B","followers_url":"https://api.github.com/users/x1B/followers","following_url":"https://api.github.com/users/x1B/following{/other_user}","gists_url":"https://api.github.com/users/x1B/gists{/gist_id}","starred_url":"https://api.github.com/users/x1B/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/x1B/subscriptions","organizations_url":"https://api.github.com/users/x1B/orgs","repos_url":"https://api.github.com/users/x1B/repos","events_url":"https://api.github.com/users/x1B/events{/privacy}","received_events_url":"https://api.github.com/users/x1B/received_events","type":"User","site_admin":false},"created_at":"2015-07-01T07:50:12Z","updated_at":"2015-07-01T07:50:12Z","body":"### Updated the description\r\n\r\n- Added lots of information on why and how the task system will change\r\n\r\n- The previous description mentioned a _resources.json_ for listing the files. Instead, we changed the requirements to instead allow for the _widget.json_ and _control.json_ to contain such information, to avoid unnecessary clutter. In the future, support for a _layout.json_ and a _theme.json_ might be added, if there are tangible benefits.\r\n\r\n- Added checkboxes to track task progress\r\n"}}