diff --git a/index.js b/index.js index cf1704d..6c816f2 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ const Blueprint = require('ember-cli/lib/models/blueprint'); const fs = require('fs-extra'); const { join } = require('path'); +const emberCliUpdate = require('./lib/ember-cli-update'); const appBlueprint = Blueprint.lookup('app'); @@ -19,13 +20,7 @@ module.exports = { }); }, - async afterInstall(options) { - // there doesn't seem to be a way to tell ember-cli to not prompt to override files that were added in the beforeInstall - // so I'm just copying a few over at this stage - await fs.copy(join(__dirname, 'files-override'), options.target, { - overwrite: true, - }); - + async updateDeps(options) { // this.addPackagesToProject doesn't respect the packageManager that the blueprint specified 🙈 so we're skipping a level here let installTask = this.taskFor('npm-install'); await installTask.run({ @@ -49,6 +44,14 @@ module.exports = { packages: ['ember-fetch'], packageManager: options.packageManager, }); + }, + + async afterInstall(options) { + // there doesn't seem to be a way to tell ember-cli to not prompt to override files that were added in the beforeInstall + // so I'm just copying a few over at this stage + await fs.copy(join(__dirname, 'files-override'), options.target, { + overwrite: true, + }); let packageJson = join(options.target, 'package.json'); let json = await fs.readJSON(packageJson); @@ -61,5 +64,14 @@ module.exports = { }; await fs.writeFile(packageJson, JSON.stringify(json, null, 2)); + + await emberCliUpdate({ + projectDir: options.target, + projectName: options.projectName, + version: require('./package.json').version, + options, + }); + + await this.updateDeps(options); }, }; diff --git a/lib/ember-cli-update.js b/lib/ember-cli-update.js new file mode 100644 index 0000000..20c9094 --- /dev/null +++ b/lib/ember-cli-update.js @@ -0,0 +1,34 @@ +const fs = require('fs-extra'); +const { join } = require('path'); + +module.exports = async function ({ + projectDir, + projectName, + version, + options = [], +} = {}) { + fs.writeJSON( + join(projectDir, 'config', 'ember-cli-update.json'), + { + schemaVersion: '1.0.0', + projectName, + packages: [ + { + name: '@embroider/app-blueprint', + version, + blueprints: [ + { + name: '@embroider/app-blueprint', + isBaseBlueprint: true, + // TODO pass more of the original options through + options: [`--package-manager ${options.packageManager}`], + }, + ], + }, + ], + }, + { + spaces: 2, + }, + ); +};