Important
This has been replaced by the addon blueprint, @ember/addon-blueprint.
View the outdated README
This blueprint is a preview of the v2 app blueprint and was intended to an experiment to see what was needed to ship v2 addons. While the blueprint was successful in its aims, this blueprint will never become the default for newly generated Ember addons. The DX hit of forcing every Ember developer to maintain a monorepo was too high a bar and the Ember Core Tooling team decided it didn't match the expectations of the Ember community. We are currently developing a non-monorepo version of the addon blueprint that is still work in progress but you can try it out now: https://github.com/ember-cli/ember-addon-blueprint
Anyone considering a new migration of a v1 addon to v2 should use the new
@ember/addon-blueprintand not this one π
Blueprint for scaffolding ember v2 addons
For migrating a v1 addon to a v2 addon, you may follow Porting Addons to V2 and this blog post Migrating an Ember addon to the next-gen v2 format .
This is still work in progress.
The blueprint contains a number of assumptions, e.g. using a monorepo using (yarn or npm) workspaces, with separate workspaces for the addon and the test-app. But there is plenty of room for bikeshedding here, so if you have suggestions about better ways to set this up, then please file an issue to discuss!
npx ember-cli@latest addon my-addon -b @embroider/addon-blueprint --pnpmFor all these options, you'll see a warning printed from ember-cli about unsupported options.
ember-cli doesn't have a way to detect if flags are used by a blueprint.
Sets up the new addon with pnpm as a default package manager.
Example:
npx ember-cli@latest addon my-addon -b @embroider/addon-blueprint --pnpm
cd my-addonSets up the new addon with npm as a default.
Example:
npx ember-cli@latest addon my-addon -b @embroider/addon-blueprint --npm
cd my-addonSets up the new addon with yarn as a default.
Example:
npx ember-cli@latest addon my-addon -b @embroider/addon-blueprint --yarn
cd my-addonThe location / folder name of the addon can be customized via --addon-location.
Examples:
ember addon my-addon -b @embroider/addon-blueprint --addon-location=packages/the-addon
# generates
# my-addon/packages/the-addonThe location / folder name of the addon can be customized via --test-app-location.
Examples:
npx ember-cli@latest addon my-addon -b @embroider/addon-blueprint --test-app-location=test-app
# generates
# my-addon/test-appBy default, {test app name} will be used.
The name of the test-app can be customized via --test-app-name.
Examples:
npx ember-cli@latest addon my-addon -b @embroider/addon-blueprint --test-app-name=test-app-for-my-addon
# generates
# my-addon/test-app-for-my-addonBy default, test-app will be used.
Will only create the addon, similar to the v1 addon behavior of ember addon my-addon.
This is useful for incremental migrations of v1 addons to v2 addons where the process from the
Porting Addons to V2
guide.
npx ember-cli@latest addon my-addon -b @embroider/addon-blueprint --addon-only
# generates non-monorepo:
# my-addon/
# .git
# package.jsonFor incremental migration in monorepos, you'll want to also supply the --skip-git flag.
Sets up the new addon with typescript support.
Example:
npx ember-cli@latest addon my-addon -b @embroider/addon-blueprint --typescriptThe blueprint supports ember-cli-update to update your addon with any changes that occurred in the blueprint since you created the addon. So to update your addons boilerplate, simply run ember-cli-update (or npx ember-cli-update if you haven't installed it globally).
For additional instructions, please consult its documentation.
To generate a new v2 addon inside an existing monorepo, cd to that repo's directory and run the command as usual. The blueprint will auto-detect an existing package.json and adapt to it. Specifically it will not create or override any files at the root folder, like the package.json itself.
Most likely though you would not want to use the default locations for the addon and the test app. Instead you should establish a convention how multiple addons and test-apps are located. With the aforementioned path options you can then make the blueprint emit the packages in the correct place.
Some more things to pay attention to:
- Pass the package manager option (
--npm,--yarn,--pnpm) that you already use! - Make sure that the chosen addon and test-app locations are all covered by the configured workspace layout of your package manager!
- Each package should have a distinct name, so make provide unique names for your test apps instead of the default
test-appby using the--test-app-nameoption. - There is no
startscript at the rootpackage.jsonanymore to start both the addon's build and the test app in watch mode. So you would have to run thatstartscript with your package manager in both locations in parallel (separate terminal windows/tabs). - Pass the
skip-gitoption to not auto-commit the generated files. Most likely there will be things to adapt to you specific requirements before committing. - The blueprint will omit all files usually generated at the root folder, including
.prettierrc.js, and instead use whatever you have already defined in your existing monorepo. So you should run thelint:fixscript for both the addon and the test-app, and eventually address any non-fixable linting issues or other configuration conventions related to your specific setup.
Some examples...
We group by the name of the addon, the addon's package and its test app are co-located sub-folders:
project-monorepo
βββ addons
βββ my-addon
β βββ package
β βββ test-app
βββ ...
To generate this run:
cd project-monorepo
npx ember-cli@latest addon my-addon -b @embroider/addon-blueprint \
--skip-git \
--skip-npm \
--addon-location="addons/my-addon/package" \
--test-app-name="test-app-for-my-addon" \
--test-app-location="addons/my-addon/test-app"Addons and test-apps are separated:
project-monorepo
βββ addons
β βββ my-addon
β βββ ...
βββ tests
βββ my-addon
βββ ...
To generate this run:
cd project-monorepo
npx ember-cli@latest addon my-addon -b @embroider/addon-blueprint \
--skip-git \
--skip-npm \
--addon-location="addons/my-addon" \
--test-app-name="test-app-for-my-addon" \
--test-app-location="tests/my-addon"This project is licensed under the MIT License.