denali-js / core

An opinionated, ORM agnostic framework for building robust JSON APIs in Node
http://denalijs.org
Apache License 2.0
73 stars 14 forks source link

Default addon blueprint never called when using `denali install` #435

Closed knownasilya closed 6 years ago

knownasilya commented 6 years ago

This code never runs: https://github.com/denali-js/core/blob/master/commands/install.ts#L73

The blueprints object doesn't have the record, and eslint and babel are all messed up..

Logs:

△ ~/sandbox/lft-api DEBUG=@denali-js/cli:blueprint denali install @denali-js/typescript                                           ⇡ master :: 11h19m :: ⬡
cli v0.1.1 [local] | denali v0.1.1 [local]
✔ Addon package found
✔ Addon package installed
  @denali-js/cli:blueprint discovering available blueprints from [ @denali-js/core, @denali-js/typescript, @denali-js/eslint, @denali-js/babel ] addons +0ms
  @denali-js/cli:blueprint looking for blueprints in /Users/iradchenko/sandbox/lft-api/node_modules/@denali-js/core/dist/blueprints +1ms
  @denali-js/cli:blueprint found 9 blueprints for @denali-js/core: [ acceptance-test, action, initializer, migration, model, orm-adapter, resource, serializer, service ] +22ms
  @denali-js/cli:blueprint looking for blueprints in /Users/iradchenko/sandbox/lft-api/node_modules/@denali-js/typescript/dist/blueprints +0ms
  @denali-js/cli:blueprint found 1 blueprints for @denali-js/typescript: [ default ] +8ms
  @denali-js/cli:blueprint looking for blueprints in /Users/iradchenko/sandbox/lft-api/node_modules/@denali-js/eslint/dist/blueprints +0ms
  @denali-js/cli:blueprint found 1 blueprints for @denali-js/eslint: [ default ] +1ms
  @denali-js/cli:blueprint looking for blueprints in /Users/iradchenko/sandbox/lft-api/node_modules/@denali-js/babel/dist/blueprints +0ms
  @denali-js/cli:blueprint found 1 blueprints for @denali-js/babel: [ default ] +1ms

Here is the blueprints object:

{ 'acceptance-test': 
   { [Function: ResourceBlueprint]
     blueprintName: 'acceptance-test',
     description: 'Generates a blank acceptance test',
     longDescription: 'Usage: denali generate acceptance-test <name>\n\nGenerates a blank acceptance test, suitable for testing your app end-to-end with simulated HTTP requests and responses.',
     params: '<name>',
     dir: '/Users/iradchenko/sandbox/lft-api/node_modules/@denali-js/core/dist/blueprints/acceptance-test' },
  action: 
   { [Function: ActionBlueprint]
     blueprintName: 'action',
     description: 'Generates a new action class & unit tests',
     longDescription: 'Usage: denali generate action <name> [options]\n\nGenerates an action with the given name (can be a deeply nested path), along with unit test stubs.\n\nGuides: http://denalijs.org/master/guides/application/actions/',
     params: '<name>',
     flags: { method: [Object] },
     runsInApp: true,
     dir: '/Users/iradchenko/sandbox/lft-api/node_modules/@denali-js/core/dist/blueprints/action' },
  initializer: 
   { [Function: InitializerBlueprint]
     blueprintName: 'initializer',
     description: 'Generates a blank initializer',
     longDescription: 'Usage: denali generate initializer <name>\n\nGenerates a blank service class.\n\nGuides: http://denalijs.org/master/guides/application/initializers/',
     params: '<name>',
     dir: '/Users/iradchenko/sandbox/lft-api/node_modules/@denali-js/core/dist/blueprints/initializer' },
  migration: 
   { [Function: MigrationBlueprint]
     blueprintName: 'migration',
     description: 'Generates a database schema migration',
     longDescription: 'Usage: denali generate migration <name> [options]\n\nGenerates a new blank migration. The filename will include the current Unix timestamp to ensure proper sorting and execution order when running migrations.\n\nGuides: http://denalijs.org/master/guides/data/migrations/',
     params: '<name>',
     dir: '/Users/iradchenko/sandbox/lft-api/node_modules/@denali-js/core/dist/blueprints/migration' },
  model: 
   { [Function: ModelBlueprint]
     blueprintName: 'model',
     description: 'Generates a blank model',
     longDescription: 'Usage: denali generate model <name> [options]\n\nGenerates a blank model, along with a serializer for that model, and unit tests for both.\n\nGuides: http://denalijs.org/master/guides/data/models/',
     params: '<name>',
     dir: '/Users/iradchenko/sandbox/lft-api/node_modules/@denali-js/core/dist/blueprints/model' },
  'orm-adapter': 
   { [Function: ORMAdapterBlueprint]
     blueprintName: 'orm-adapter',
     description: 'Generates a blank ORM adapter with stubs for all the required methods',
     longDescription: 'Usage: denali generate orm-adapter <name> [options]\n\nGenerates a new ORM adapter with stubs for all the required adapter methods. Note: this is typically an advanced use case (i.e. using a niche, specialty database). You should check to make sure there isn\'t already a Denali addon that implements the ORM adapter you need.\n\nGuides: http://denalijs.org/master/guides/data/orm-adapters/',
     params: '<name>',
     dir: '/Users/iradchenko/sandbox/lft-api/node_modules/@denali-js/core/dist/blueprints/orm-adapter' },
  resource: 
   { [Function: ResourceBlueprint]
     blueprintName: 'resource',
     description: 'Generates a model, serializer, CRUD actions, and tests for a resource',
     longDescription: 'Usage: denali generate resource <name> [options]\n\nGenerates a complete, end-to-end RESTful resource scaffold. This includes a Model to represent the data, a Serializer to determine how to send it over the wire, CRUD actions for manipulating the resource, and tests for all of the above.',
     params: '<name>',
     dir: '/Users/iradchenko/sandbox/lft-api/node_modules/@denali-js/core/dist/blueprints/resource' },
  serializer: 
   { [Function: SerializerBlueprint]
     blueprintName: 'serializer',
     description: 'Generates a blank serializer',
     longDescription: 'Usage: denali generate serializer <name> [options]\n\nGenerates a blank serializer for the given model.\n\nGuides: http://denalijs.org/master/guides/data/serializers/',
     params: '<name>',
     dir: '/Users/iradchenko/sandbox/lft-api/node_modules/@denali-js/core/dist/blueprints/serializer' },
  service: 
   { [Function: ServiceBlueprint]
     blueprintName: 'service',
     description: 'Generates a blank service',
     longDescription: 'Usage: denali generate service <name> [options]\n\nGenerates a blank service class.\n\nGuides: http://denalijs.org/master/guides/application/services/',
     params: '<name>',
     dir: '/Users/iradchenko/sandbox/lft-api/node_modules/@denali-js/core/dist/blueprints/service' },
  default: 
   { [Function: DenaliBabelBlueprint]
     blueprintName: 'default',
     description: 'Generate the default .babelrc and install babel plugins',
     dir: '/Users/iradchenko/sandbox/lft-api/node_modules/@denali-js/babel/dist/blueprints/default' },
  'undefined:default': 
   { [Function: DenaliEslintBlueprint]
     blueprintName: 'default',
     description: 'Generate the default .eslintrc and installs the babel-eslint parser',
     dir: '/Users/iradchenko/sandbox/lft-api/node_modules/@denali-js/eslint/dist/blueprints/default' } }

So it finds the blueprints, but probably adds them incorrectly. Looks like clobberedBlueprint (https://github.com/denali-js/cli/blob/master/lib/blueprint.ts#L146) doesn't have an addon attribute.

The issue is here: https://github.com/denali-js/cli/blob/master/lib/blueprint.ts#L132 The code uses the one with default, which doesn't have addon set.

@davewasmer

davewasmer commented 6 years ago

Yea, this is a change in the new namespaced packages - they all now define their default blueprint as default rather than $ADDON_NAME. I made this change to hopefully reduce potential confusion (default seems a little clearer, although I'm open to other names - maybe something like post-install?).

The CLI still needs to be updated to handle the different name, and I think this also exposed a latent bug you are seeing where clobbered blueprints don't get correctly namespaced because it seems like the aren't properly retrieving the addon name.