Used to add multiple addons to the project's `package.json` and run their `defaultBlueprint` if they provide one. Generally, this would be done from the `afterInstall` hook, to ensure that a package that is required by a given blueprint is available. @method addAddonsToProject
(options)
| 1218 | @return {Promise} |
| 1219 | */ |
| 1220 | addAddonsToProject(options) { |
| 1221 | let taskOptions = { |
| 1222 | packages: [], |
| 1223 | extraArgs: options.extraArgs || [], |
| 1224 | blueprintOptions: options.blueprintOptions || {}, |
| 1225 | }; |
| 1226 | |
| 1227 | let packages = options.packages; |
| 1228 | if (packages && packages.length) { |
| 1229 | taskOptions.packages = packages.map((pkg) => { |
| 1230 | if (typeof pkg === 'string') { |
| 1231 | return pkg; |
| 1232 | } |
| 1233 | |
| 1234 | if (!pkg.name) { |
| 1235 | throw new SilentError('You must provide a package `name` to addAddonsToProject'); |
| 1236 | } |
| 1237 | |
| 1238 | if (pkg.target) { |
| 1239 | pkg.name += `@${pkg.target}`; |
| 1240 | } |
| 1241 | |
| 1242 | return pkg.name; |
| 1243 | }); |
| 1244 | } else { |
| 1245 | throw new SilentError('You must provide package to addAddonsToProject'); |
| 1246 | } |
| 1247 | |
| 1248 | let installText = packages.length > 1 ? 'install addons' : 'install addon'; |
| 1249 | this._writeStatusToUI(chalk.green, installText, taskOptions['packages'].join(', ')); |
| 1250 | |
| 1251 | let previousCwd; |
| 1252 | if (!this.project.isEmberCLIProject()) { |
| 1253 | // The install task adds dependencies based on the current working directory. |
| 1254 | // But in case we created the new project by calling the blueprint with a custom target directory (options.target), |
| 1255 | // the current directory will *not* be the one the project is created in, so we must adjust this here. |
| 1256 | previousCwd = process.cwd(); |
| 1257 | process.chdir(options.blueprintOptions.target); |
| 1258 | } |
| 1259 | |
| 1260 | let result = this.taskFor('addon-install').run(taskOptions); |
| 1261 | if (previousCwd) { |
| 1262 | return result.then(() => process.chdir(previousCwd)); |
| 1263 | } |
| 1264 | |
| 1265 | return result; |
| 1266 | }, |
| 1267 | |
| 1268 | /** |
| 1269 | Used to retrieve a task with the given name. Passes the new task |
nothing calls this directly
no test coverage detected
searching dependent graphs…