Connecteur COZY permettant de récupérer et stocker ses factures Enercoop.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 6.8 KiB

6 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. [Cozy][cozy] <YOUR SUPER NEW KONNECTOR NAME>
  2. =======================================
  3. What's Cozy?
  4. ------------
  5. ![Cozy Logo](https://cdn.rawgit.com/cozy/cozy-guidelines/master/templates/cozy_logo_small.svg)
  6. [Cozy] is a platform that brings all your web services in the same private space. With it, your webapps and your devices can share data easily, providing you with a new experience. You can install Cozy on your own hardware where no one's tracking you.
  7. What's this new konnector?
  8. --------------------------
  9. <YOUR DESCRIPTION HERE>
  10. ### Open a Pull-Request
  11. If you want to work on this konnector and submit code modifications, feel free to open pull-requests! See the [contributing guide][contribute] for more information about how to properly open pull-requests.
  12. ### Cozy-konnector-libs
  13. This connector uses [cozy-konnector-libs](https://github.com/cozy/cozy-konnector-libs). You can
  14. find more documentation about it there.
  15. ### Test the connector without an accessible cozy-stack
  16. If you just want to test this connector without any cozy available.
  17. You first need an installed [nodejs] (LTS version is fine).
  18. Just run :
  19. ```sh
  20. npm install
  21. npm run standalone
  22. ```
  23. The requests to the cozy-stack will be stubbed using the [./fixture.json] file as source of data
  24. and when cozy-client is asked to create or update data, the data will be output to the console.
  25. The bills (or any file) will be saved in the . directory.
  26. ### Run the connector linked to a cozy-stack
  27. If you do not want to have to install the konnector on a cozy v3 to test it, you can register the
  28. konnector as an OAuth application with the following commands :
  29. ```sh
  30. npm install
  31. npm run dev
  32. ```
  33. This command will register your konnector as an OAuth application to the cozy-stack. By default,
  34. the cozy-stack is supposed to be located in http://cozy.tools:8080. If this is not your case, just
  35. update the COZY_URL field in [./konnector-dev-config-json].
  36. After that, your konnector is running but should not work since you did not specify any credentials to
  37. the target service. You can do this also in [./konnector-dev-config.json] in the "fields"
  38. attribute.
  39. Now run `yarn dev` one more time, it should be ok.
  40. The files are saved in the root directory of your cozy by default.
  41. ### How does the cozy-stack run the connector ?
  42. The cozy-stack runs the connector in a nsjail container to be sure it does not affect the environment.
  43. The connector is run by calling npm start with the following envrionment variables :
  44. - COZY_CREDENTIALS needs to be the result of `cozy-stack instances token-cli <instance name> <scope>`
  45. - COZY_URL is the full http or https url to your cozy
  46. - COZY_FIELDS is something like :
  47. ```javascript
  48. {
  49. "data":{
  50. "attributes":{
  51. "arguments":{
  52. "account":"cf31eaef5d899404a7e8c3737c1c2d1f",
  53. "folder_to_save":"folderPathId",
  54. "slug":"mykonnector"
  55. }
  56. }
  57. }
  58. }
  59. ```
  60. The "account" field is the id of the record with doctype "io.cozy.accounts" which will be used as
  61. parameters for your konnector.
  62. ### Build (without Travis)
  63. To be able to run the connector, the cozy stack needs a connector which is built into only one
  64. file, without needing to npm install it, this will be a lot faster to install.
  65. There is a command in package.json to help you to do that : `npm run build`
  66. This command uses [webpack] to bundle all the code needed by your connector into one file.
  67. This will generate an index.js file in the build directory and add all files the connector will need.
  68. You can deploy this build by using the specific script : `npm run deploy`
  69. This command will commit and push your build in the branch `build` fo your project.
  70. And your konnector can now be installed using the following url :
  71. git://github.com/cozy/cozy-konnector-<yourkonnector>.git#build
  72. ### Build using Travis CI
  73. This project contains a `.travis.yml` config file which allows you to build your connector
  74. automatically using [Travis-CI][travis].
  75. You can follow these steps to enable building using Travis:
  76. * On your [travis-ci.org][travis] account, find your project name (should be the same than your Github repository) and enable Travis by using the related checkbox.
  77. * Once enabled, go to this project on Travis by clicking on it and go to the "Settings" menu by using the "More options" menu at the top right.
  78. * Enable these three options:
  79. * "Build only if .travis.yml is present"
  80. * "Build branch updates" (run Travis after each branch update)
  81. * "Build pull request updates" (run Travis after each Pull Request update)
  82. * Then, you have to generate a Github token in [your Github account settings](https://github.com/settings/tokens). Here is the [Github blog post about API token](https://github.com/blog/1509-personal-api-tokens). Don't forget to authorize the access to the repo scope like following: ![repo scope](https://cloud.githubusercontent.com/assets/10224453/26671128/aa735ec2-46b4-11e7-9cd0-25310100e05e.png)
  83. * Then, add an environment variable (still in your Travis project settings) named `GITHUB_TOKEN` and use your previous generated Github token as value (We highly recommand you to __keep the checkbox "Display value in build log" to OFF value__ in order to keep your token value hidden in the Travis logs.)
  84. Now Travis is ready to build your project, it should build it each time your push a commit in your repository or create a pull request.
  85. > __Note:__ Travis will push your build to your `build` branch ONLY for commits made on your master branch (included PR merge commits). You can see the related Travis statement [here](https://github.com/cozy/cozy-konnector-template/blob/master/.travis.yml#L27).
  86. ### Add your new connector to [Cozy Collect](https://github.com/cozy/cozy-collect)
  87. The Cozy Collect application will soon use an application store as source of connectors. But for
  88. now, if you want to add your new connector to Cozy Collect, you can submit a message in the forum
  89. in the [collect section](https://forum.cozy.io/c/francais/collect-fr), and we will handle this for
  90. you.
  91. ### Standard
  92. We use [standard] to format the `index.js` file. You can run it with:
  93. ```sh
  94. npm run lint
  95. ```
  96. ### Maintainer
  97. The lead maintainers for this konnector is <YOUR NAME>
  98. ### Get in touch
  99. You can reach the Cozy Community by:
  100. - Chatting with us on IRC [#cozycloud on Freenode][freenode]
  101. - Posting on our [Forum]
  102. - Posting issues on the [Github repos][github]
  103. - Say Hi! on [Twitter]
  104. License
  105. -------
  106. <YOUR KONNECTOR NAME> is developed by <your name> and distributed under the [AGPL v3 license][agpl-3.0].
  107. [cozy]: https://cozy.io "Cozy Cloud"
  108. [agpl-3.0]: https://www.gnu.org/licenses/agpl-3.0.html
  109. [freenode]: http://webchat.freenode.net/?randomnick=1&channels=%23cozycloud&uio=d4
  110. [forum]: https://forum.cozy.io/
  111. [github]: https://github.com/cozy/
  112. [nodejs]: https://nodejs.org/
  113. [standard]: https://standardjs.com
  114. [twitter]: https://twitter.com/mycozycloud
  115. [webpack]: https://webpack.js.org
  116. [yarn]: https://yarnpkg.com
  117. [travis]: https://travis-ci.org