Skip to content

Commit

Permalink
Add blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
mkszepp committed Jan 2, 2024
1 parent 9352da5 commit 773043c
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
73 changes: 73 additions & 0 deletions ember-basic-dropdown/blueprints/ember-basic-dropdown/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/* eslint-env node */
'use strict';

const path = require('path');
const fs = require('fs');
const EOL = require('os').EOL;

module.exports = {
normalizeEntityName() {
// this prevents an error when the entityName is
// not specified (since that doesn't actually matter
// to us
},

afterInstall() {
let dependencies = this.project.dependencies();
let skipStyleImport = false;

if ('ember-power-select' in dependencies) {
skipStyleImport = true;
}

if (!skipStyleImport) {
let type;
let importStatement = '\n@import "ember-basic-dropdown";\n';
if ('ember-cli-sass' in dependencies) {
type = 'scss';
} else if ('ember-cli-less' in dependencies) {
type = 'less';
}

if (type) {
let stylePath = path.join('app', 'styles');
let file = path.join(stylePath, `app.${type}`);

if (!fs.existsSync(stylePath)) {
fs.mkdirSync(stylePath);
}
if (fs.existsSync(file)) {
this.ui.writeLine(`Added import statement to ${file}`);
this.insertIntoFile(file, importStatement, {});
} else {
fs.writeFileSync(file, importStatement);
this.ui.writeLine(`Created ${file}`);
}
} else {
let file = path.join('app', `app.js`);
if (!fs.existsSync(file)) {
file = path.join('app', `app.ts`);
}
if (fs.existsSync(file)) {
this.ui.writeLine(`Added import statement to ${file}`);
this.insertIntoFile(file, "import 'ember-basic-dropdown/styles';", {
after: "config/environment';" + EOL,
});
}
}
}

let templatePath = path.join('app', 'templates');
let applicationFile = path.join(templatePath, `application.hbs`);
if (fs.existsSync(applicationFile)) {
this.ui.writeLine(`Added wormhole statement to ${applicationFile}`);
this.insertIntoFile(
applicationFile,
`${EOL}<BasicDropdownWormhole />`,
{},
);
}

this.cleanRemove('<BasicDropdownWormhole />');
},
};
1 change: 1 addition & 0 deletions ember-basic-dropdown/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default [
// "app" tree. Things in here should also be in publicEntrypoints above, but
// not everything in publicEntrypoints necessarily needs to go here.
addon.appReexports([
'blueprints/**/*.js',
'components/**/*.js',
'modifiers/**/*.js',
'test-support/*.js',
Expand Down

0 comments on commit 773043c

Please sign in to comment.