n this talk, we'll look at creating an Ember addon that changes the ember-cli build process. Good examples of existing addons that do this are ember-cli-babel and ember-cli-code-coverage.
We'll walk through developing an addon that automatically warns us if we have missing keys in our translation files. We'll also add a command that lets us sync the keys and get them ready to send for translation.
We'll talk about Broccoli, ember-cli hooks, and how we can take this a step further with a built-in management page and ember-cli-deploy.
EMBER ADDON DEEP DIVE
Modifying the build process
Add behavior and features to any
Modify the build process: add,
remove, or modify ﬁles.
Most addons. Enhance the
Broccoli is the workhorse in
ember-cli for building assets.
It was very common to need to
manually conﬁgure Broccoli.
Most Broccoli conﬁguration lives
in addons; you might not need to
TASK: HELP MANAGE
Managing translation ﬁles can be a
bit of a pain. Let's create an addon
that helps us update locales with
new keys for translation.
FIND A REFERENCE
To use as a guide.
DOES THIS EXIST?
If so, does it ﬁt my use case?
Don't forget to upgrade ember-cli
- cli in the name = build-time
- no cli in the name = run-time
The entry point to addons.
FIND A CLI HOOK
Many could work, we're going to
No need to run this over the whole
app tree. Select only our locales
folder, and process that.
BROCCOLI MERGE TREES
Take the normal app tree + our
funnel tree and merge them.
For each ﬁle in the tree, determine
if it should be processed, and what
the ﬁle contents should be.
Add translations to the dummy
app inside the addon.
Use the ember-cli-build ﬁle to pass
conﬁg options to your addon.
ADD A COMMAND
Create a command deﬁnition, then
add it to your index.js ﬁle.
Add a setting to throw an error if
any locales have missing keys.
Use this.ui.startProgress(), and
return a Promise in the
command's run function.
Node 4+ supports most of what
you're used to: let, const, =>, etc.
See http://node.green for info
Just like auto-generated JSHint
tests in ember-cli.
Create a plugin that conﬁrms
deploy if missing or untranslated
Add server middleware that serves
up a page to view translated
progress, easily import and export
CAN BE WILD.