Closed codeyad closed 7 years ago
The error happens since in generator-loopback, when the datasource generator calls availableConnectors
to return the list of available connectors, loopback-component-storage
is not included:
see https://github.com/strongloop/generator-loopback/blob/master/datasource/index.js#L195
I think we should either add loopback-component-storage
to available connectors or enable availableConnectors
read custom connectors in project and return them as well in the list.
Add console.log('availableConnectors ' + JSON.stringify(this.availableConnectors));
get:
? Enter the data-source name: myDS
? Select the connector for myDS: other
? Enter the connector name without the loopback-connector- prefix: loopback-con
nector-storage
availableConnectors {"memory":{"name":"memory","description":"In-memory db","bas
eModel":"PersistedModel","features":{"discovery":false,"migration":false},"setti
ngs":{"localStorage":{"type":"string","description":"window.localStorage key to
use for persistence (browser only)"},"file":{"type":"string","description":"Full
path to file for persistence (server only)"}},"supportedByStrongLoop":true,"ins
talled":true},"db2":{"name":"db2","description":"IBM DB2","baseModel":"Persisted
Model","features":{"discovery":false,"migration":false},"settings":{"host":{"typ
e":"string"},"port":{"type":"number"},"user":{"type":"string"},"password":{"type
":"string","display":"password"},"database":{"type":"string"}},"package":{"name"
:"loopback-connector-db2","version":"^1.0.0"},"supportedByStrongLoop":true,"inst
alled":false},"cloudant":{"name":"cloudant","description":"IBM Cloudant DB","bas
eModel":"PersistedModel","features":{"discovery":true,"migration":true},"setting
s":{"database":{"type":"string"},"url":{"type":"string"},"username":{"type":"str
ing"},"password":{"type":"string","display":"password"},"modelIndex":{"type":"st
ring"}},"package":{"name":"loopback-connector-cloudant","version":"^1.0.4"},"sup
portedByStrongLoop":true,"installed":false},"mongodb":{"name":"mongodb","descrip
tion":"MongoDB","baseModel":"PersistedModel","features":{"discovery":false,"migr
ation":true},"settings":{"host":{"type":"string"},"port":{"type":"number"},"user
":{"type":"string"},"password":{"type":"string","display":"password"},"database"
:{"type":"string"}},"package":{"name":"loopback-connector-mongodb","version":"^1
.4"},"supportedByStrongLoop":true,"installed":false},"mysql":{"name":"mysql","de
scription":"MySQL","baseModel":"PersistedModel","features":{"discovery":true,"mi
gration":true},"settings":{"host":{"type":"string"},"port":{"type":"number"},"us
er":{"type":"string"},"password":{"type":"string","display":"password"},"databas
e":{"type":"string"}},"package":{"name":"loopback-connector-mysql","version":"^2
.2"},"supportedByStrongLoop":true,"installed":false},"postgresql":{"name":"postg
resql","description":"PostgreSQL","baseModel":"PersistedModel","features":{"disc
overy":true,"migration":true},"settings":{"host":{"type":"string"},"port":{"type
":"number"},"user":{"type":"string"},"password":{"type":"string","display":"pass
word"},"database":{"type":"string"}},"package":{"name":"loopback-connector-postg
resql","version":"^2.4"},"supportedByStrongLoop":true,"installed":false},"oracle
":{"name":"oracle","description":"Oracle","baseModel":"PersistedModel","features
":{"discovery":true,"migration":true},"settings":{"host":{"type":"string"},"port
":{"type":"number"},"user":{"type":"string"},"password":{"type":"string","displa
y":"password"},"database":{"type":"string"}},"package":{"name":"loopback-connect
or-oracle","version":"^2.4"},"supportedByStrongLoop":true,"installed":false},"ms
sql":{"name":"mssql","description":"Microsoft SQL","baseModel":"PersistedModel",
"features":{"discovery":true,"migration":true},"settings":{"host":{"type":"strin
g"},"port":{"type":"number"},"user":{"type":"string"},"password":{"type":"string
","display":"password"},"database":{"type":"string"}},"package":{"name":"loopbac
k-connector-mssql","version":"^2.5"},"supportedByStrongLoop":true,"installed":fa
lse},"rest":{"name":"rest","description":"REST services","baseModel":"Model","fe
atures":{"discovery":false,"migration":false},"settings":{"baseURL":{"type":"str
ing","description":"Base URL for the REST service"},"options":{"type":"object","
description":"Default options for the request"},"operations":{"type":"array","de
scription":"An array of operation templates"},"crud":{"type":"boolean","default"
:false,"description":"Use default CRUD mapping"}},"package":{"name":"loopback-co
nnector-rest","version":"^2.0"},"supportedByStrongLoop":true,"installed":false},
"soap":{"name":"soap","description":"SOAP webservices","baseModel":"Model","feat
ures":{"discovery":false,"migration":false},"package":{"name":"loopback-connecto
r-soap","version":"^2.4"},"settings":{"url":{"type":"string","description":"URL
to the SOAP web service endpoint"},"wsdl":{"type":"string","description":"HTTP U
RL or local file system path to the WSDL file"},"remotingEnabled":{"type":"boole
an","description":"Expose operations as REST APIs"},"operations":{"type":"object
","description":"Maps WSDL binding operations to Node.js methods"}},"supportedBy
StrongLoop":true,"installed":false},"couchbase":{"name":"couchbase","description
":"Couchbase","baseModel":"PersistedModel","features":{"discovery":false,"migrat
ion":false},"settings":{"host":{"type":"string"},"port":{"type":"number"},"n1qlp
ort":{"type":"number"},"name":{"type":"string","description":"The name of the da
tasource"},"connectionTimeout":{"type":"number"},"operationTimeout":{"type":"num
ber"},"env":{"type":"string","description":"Environment variable for debugging"}
},"package":{"name":"loopback-connector-couchbase","version":"^1.0"},"supportedB
yStrongLoop":false,"installed":false},"neo4j":{"name":"neo4j","description":"Neo
4j","baseModel":"PersistedModel","features":{"discovery":false,"migration":false
},"package":{"name":"loopback-connector-neo4j","version":"^0.1"},"supportedByStr
ongLoop":false,"installed":false},"kafka":{"name":"kafka","description":"Kafka",
"baseModel":"PersistedModel","features":{"discovery":false,"migration":false},"p
ackage":{"name":"loopback-connector-kafka","version":"^0.2"},"supportedByStrongL
oop":false,"installed":false},"saphana":{"name":"saphana","description":"SAP HAN
A","baseModel":"PersistedModel","features":{"discovery":true,"migration":true},"
settings":{"host":{"type":"string"},"port":{"type":"number"},"user":{"type":"str
ing"},"password":{"type":"string","display":"password"},"database":{"type":"stri
ng"}},"package":{"name":"loopback-connector-saphana","version":"^0.7"},"supporte
dByStrongLoop":false,"installed":false},"mail":{"name":"mail","description":"Ema
il","baseModel":"Email","features":{"discovery":false,"migration":false},"settin
gs":{"transports":{"type":"array","description":"An array of transport configura
tion objects"}},"supportedByStrongLoop":true,"installed":true}}
@codeyad and anyone run into this issue, I think as a workaround, you can manually add that datasource entry in datasource.json
instead of using generator to create it.
Here is the list of available connectors: https://github.com/strongloop/loopback-workspace/blob/ab5d905eb14a6dfc0948faf62f8ee1b42068c594/available-connectors.json
I think we should either add loopback-component-storage to available connectors or enable availableConnectors read custom connectors in project and return them as well in the list.
Since we allow the user to enter arbitrary connector name, the generator should gracefully handle the case when a connector not in our list is selected. (Think about community-maintained connectors that we are not aware of yet.)
I am proposing the following changes:
availableConnectors
to handle the case when a custom (unknown) connector is selected. This may need changes in multiple places.availableConnectors
, then use the name provided by the user as the package name, e.g. loopback-component-storage
in the example described above.availableConnectors
. Obviously, we don't have that metadata for a custom connector, thus we should skip these prompts and print a message instructing the user to configure the datasource manually by editing the JSON file.@jannyHou the thing is that's one on the ways you can do it according to the doc, i haven't have problems with that before, prolly is the latest version of loopback that has changed it, anyways i think i did manually and also had a problem, gonna check it out again to see if its really possible that way.
@codeyad oh...good to know that. Let me check is there any change broke it. Thank you!
I'm having this same issue
@rwngallego it looks like in the latest version something was changed cause i did several time in the past with previous versions.
@codeyad i am trying to fix this bug and find out the working version. Do you by any chance remember the last time when it worked? Thanks.
----UPDATE
Never mind. i find the pr related: https://github.com/strongloop/generator-loopback/commit/a7862d844587a4d462f159b71d5b7918413b970f
I will figure out a solution to handle custom connectors.
@jannyHou last project i have working with Component Storage has loopback version 2.14.0
@codeyad Thanks! We implement some new features related to connector so it's not possible to regress. I have a pr to fix it: https://github.com/strongloop/generator-loopback/pull/199 Will update here after it's published.
Published in generator-loopback@1.22.0
.
I am trying to use it with the loopback-component-push and still getting this error, even adding it manually. I already follow this instructions: https://docs.strongloop.com/display/public/LB/Push+notifications
Everything is up to date.
@marysgonzalez did you run into exactly same error as described in this issue?
I tried it on my local and it works fine:
jannyHous-MacBook-Pro:aclextend jannyhou$ slc loopback:datasource
? Enter the data-source name: mypush
? Select the connector for mypush: other
? Enter the connector name without the loopback-connector- prefix: loopback-comp
onent-push
? Install loopback-component-push Yes
Please manually add config for your custom connector loopback-component-push in server/datasources.json
npm WARN package.json aclextend@1.0.0 No README data
loopback-component-push@1.5.4 node_modules/loopback-component-push
├── async@1.5.2
├── mpns@2.1.0
├── node-cache@2.1.1
├── debug@2.2.0 (ms@0.7.1)
├── apn@1.6.2 (q@1.4.1)
├── lodash@3.10.1
└── node-gcm@0.9.15 (debug@0.8.1, request@2.74.0)
I am on generator-loopback@1.23.2, not the latest version but already includes the fix. Please make sure you upgraded the generator-lb in your strongloop module or the one in global npm modules folder, depends on which one you are using.
Now when I run slc loopback:datasource, I am getting this error:
TypeError: this.env.adapter.prompt(...).then is not a function
at Base.prompt (/home/henrique/.nvm/versions/node/v5.8.0/lib/node_modules/generator-generator/node_modules/yeoman-generator/lib/base.js:232:45)
I updated, uninstalled and installed again yeoman several times without success.
@marysgonzalez you need to reinstall generator-loopback not only yeoman.
Please run npm install -g generator-loopback
or reinstall the generator-loopback in your strongloop project.
Already done, so indeed with npm, yeoman, generator loopback. Still getting the same issue.
2016-08-22 10:35 GMT-04:00 Janny notifications@github.com:
@marysgonzalez https://github.com/marysgonzalez you need to reinstall generator-loopback not only yeoman. Please run npm install -g generator-loopback or reinstall the generator-loopback in your strongloop project.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/strongloop/loopback/issues/2265#issuecomment-241432543, or mute the thread https://github.com/notifications/unsubscribe-auth/AI3iupeDDONRaZLnhA1IHuIuCDjHdfhXks5qibOVgaJpZM4IRQ5k .
@marysgonzalez hmm, interesting. What's your system and node & npm version? And if possible, could you try reinstall strongloop and see if that solves your problem?
@jannyHou is this issue still relevant?
@bajtos I checked with the latest stongloop & node6, it still works fine:
jannyHous-MacBook-Pro:customdb jannyhou$ slc loopback:datasource
? Enter the data-source name: mypush
? Select the connector for mypush: other
? Enter the connector name without the loopback-connector- prefix: loopback-component-push
? Install loopback-component-push Yes
Please manually add config for your custom connector loopback-component-push in server/datasources.json
customdb@1.0.0 /Users/jannyhou/lb/triage/customdb
I am closing this issue since we couldn't reproduce the bug. Please feel free to reopen it if anyone still runs into same issue has has more details. Thanks.
Thank you, @jannyHou!
hi, i wanna use the loopback-component-torage and when i try to create the DS i got this error: