diff --git a/blueprints/admin-app/files/app/adapters/application.js b/blueprints/admin-app/files/app/adapters/application.js deleted file mode 100644 index 04cbcb6..0000000 --- a/blueprints/admin-app/files/app/adapters/application.js +++ /dev/null @@ -1,5 +0,0 @@ -import DS from 'ember-data'; - -export default DS.ActiveModelAdapter.extend({ - namespace: 'api/v1' -}); diff --git a/blueprints/admin-app/files/app/navigation.js b/blueprints/admin-app/files/app/navigation.js index b7bc0df..0c6c876 100644 --- a/blueprints/admin-app/files/app/navigation.js +++ b/blueprints/admin-app/files/app/navigation.js @@ -1,5 +1,3 @@ export default function() { - this.navigate("Dashboard", { - route: "dashboard" - }); + this.navigate("Dashboard", { route: "dashboard" }); } diff --git a/blueprints/table-view-resource/files/app/__controllerPath__/__controllerName__.js b/blueprints/table-view-resource/files/__root__/__controllerPath__/__controllerName__.js similarity index 100% rename from blueprints/table-view-resource/files/app/__controllerPath__/__controllerName__.js rename to blueprints/table-view-resource/files/__root__/__controllerPath__/__controllerName__.js diff --git a/blueprints/table-view-resource/files/app/__modelPath__/__modelName__.js b/blueprints/table-view-resource/files/__root__/__modelPath__/__modelName__.js similarity index 100% rename from blueprints/table-view-resource/files/app/__modelPath__/__modelName__.js rename to blueprints/table-view-resource/files/__root__/__modelPath__/__modelName__.js diff --git a/blueprints/table-view-resource/index.js b/blueprints/table-view-resource/index.js index 35bc5f2..d8c4fde 100644 --- a/blueprints/table-view-resource/index.js +++ b/blueprints/table-view-resource/index.js @@ -1,6 +1,6 @@ var inflection = require('ember-cli/node_modules/inflection'); -var processTextContent = require('ember-cli-admin/lib/proccess-text-content').processTextContent; var path = require('path'); +var chalk = require('ember-cli/node_modules/chalk'); module.exports = { description: 'Generates tableview resource', @@ -13,7 +13,7 @@ module.exports = { } return inflection.singularize(options.dasherizedModuleName); }, - __controllerName__: function(options){ + __controllerName__: function(options) { if (options.pod) { return "controller"; } @@ -21,7 +21,7 @@ module.exports = { }, __controllerPath__: function(options) { if (options.pod) { - return path.join(options.podPath, inflection.pluralize(options.dasherizedModuleName)); + return path.join(options.podPath, inflection.pluralize(options.dasherizedModuleName)); } return 'controllers'; }, @@ -30,25 +30,39 @@ module.exports = { return path.join(options.podPath, inflection.singularize(options.dasherizedModuleName)); } return 'models'; + }, + __root__: function(options) { + if (options.inRepoAddon) { + return path.join('lib', options.inRepoAddon, 'addon'); + } + + if (options.inDummy) { + return path.join('tests', 'dummy', 'app'); + } + + if (options.inAddon) { + return 'addon'; + } + + return 'app'; } }; }, - beforeInstall: function(options){ - var process = processTextContent.bind(this); + afterInstall: function(options) { var entityName = options.entity.name; - var navigationStr = '\n\t\tthis.navigate("' + inflection.titleize(entityName) + '", { route: "' + entityName + '" });' - var routerStr = '\n\tthis.resources("' + entityName + '");' - process('app/initializers/navigation.js', - { - insert: { - 'this.navigate("Dashboard", { route: "dashboard" });': navigationStr - } - }); - process('app/router.js', - { - insert: { - 'MetaRoute.map(Router, function() {': routerStr - } + var navigationStr = '\n this.navigate("' + inflection.titleize(entityName) + '", { route: "' + entityName + '" });' + var routerStr = '\n this.resources("' + entityName + '");' + + var self = this; + + return this.insertIntoFile('app/navigation.js', navigationStr, { + after: '});' + }).then(function() { + return self.insertIntoFile('app/router.js', routerStr, { + after: 'MetaRoute.map(Router, function() {' }); + }).then(function() { + self._writeStatusToUI(chalk.green, '[ember-cli-admin] add table-view-resource', entityName); + }); } }; diff --git a/blueprints/tree-view-resource/files/app/__controllerPath__/__controllerName__.js b/blueprints/tree-view-resource/files/__root__/__controllerPath__/__controllerName__.js similarity index 100% rename from blueprints/tree-view-resource/files/app/__controllerPath__/__controllerName__.js rename to blueprints/tree-view-resource/files/__root__/__controllerPath__/__controllerName__.js diff --git a/blueprints/tree-view-resource/files/app/__modelPath__/__modelName__.js b/blueprints/tree-view-resource/files/__root__/__modelPath__/__modelName__.js similarity index 100% rename from blueprints/tree-view-resource/files/app/__modelPath__/__modelName__.js rename to blueprints/tree-view-resource/files/__root__/__modelPath__/__modelName__.js diff --git a/blueprints/tree-view-resource/index.js b/blueprints/tree-view-resource/index.js index 676502b..7f5acb4 100644 --- a/blueprints/tree-view-resource/index.js +++ b/blueprints/tree-view-resource/index.js @@ -1,5 +1,5 @@ var inflection = require('ember-cli/node_modules/inflection'); -var processTextContent = require('ember-cli-admin/lib/proccess-text-content').processTextContent; +var chalk = require('ember-cli/node_modules/chalk'); var path = require('path'); module.exports = { @@ -37,25 +37,39 @@ module.exports = { return path.join(options.podPath, inflection.singularize(options.dasherizedModuleName)); } return 'models'; + }, + __root__: function(options) { + if (options.inRepoAddon) { + return path.join('lib', options.inRepoAddon, 'addon'); + } + + if (options.inDummy) { + return path.join('tests', 'dummy', 'app'); + } + + if (options.inAddon) { + return 'addon'; + } + + return 'app'; } }; }, - beforeInstall: function(options){ - var process = processTextContent.bind(this); + afterInstall: function(options) { var entityName = options.entity.name; - var navigationStr = '\n\t\tthis.navigate("' + inflection.titleize(entityName) + '", { route: "' + entityName + '" });' - var routerStr = '\n\tthis.resources("' + entityName + '");' - process('app/initializers/navigation.js', - { - insert: { - 'this.navigate("Dashboard", { route: "dashboard" });': navigationStr - } - }); - process('app/router.js', - { - insert: { - 'MetaRoute.map(Router, function() {': routerStr - } + var navigationStr = '\n this.navigate("' + inflection.titleize(entityName) + '", { route: "' + entityName + '" });' + var routerStr = '\n this.resources("' + entityName + '");' + + var self = this; + + return this.insertIntoFile('app/navigation.js', navigationStr, { + after: '});' + }).then(function() { + return self.insertIntoFile('app/router.js', routerStr, { + after: 'MetaRoute.map(Router, function() {' }); + }).then(function() { + self._writeStatusToUI(chalk.green, '[ember-cli-admin] add tree-view-resource', entityName); + }); } };