Skip to content

Commit

Permalink
fix: now the yarn dev command will work again with remote cozies
Browse files Browse the repository at this point in the history
  • Loading branch information
doubleface committed May 21, 2018
1 parent 8868608 commit e1608d5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 64 deletions.
20 changes: 10 additions & 10 deletions packages/cozy-jobs-cli/src/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ const path = require('path')
const fs = require('fs')

const authenticate = require('./cozy-authenticate')
const initDevAccount = require('./init-dev-account')

const DEFAULT_MANIFEST_PATH = path.resolve('manifest.konnector')
const DEFAULT_TOKEN_PATH = path.resolve('.token.json')

let useFolder = false
let file, manifest

program
Expand Down Expand Up @@ -45,20 +43,22 @@ const token = program.token || DEFAULT_TOKEN_PATH
authenticate({ tokenPath: token, manifestPath: manifest })
.then(result => {
const credentials = result.creds
const scopes = result.scopes
if (scopes.includes('io.cozy.files')) useFolder = true

// check if the token is valid
process.env.COZY_CREDENTIALS = JSON.stringify(credentials)
})
.then(() => initDevAccount({manifestPath: manifest}))
.then((accountId) => {
process.env.COZY_FIELDS = JSON.stringify({
account: accountId,
folder_to_save: useFolder ? 'io.cozy.files.root-dir' : ''
})
.then(() => {
const BaseKonnector = require('cozy-konnector-libs').BaseKonnector
BaseKonnector.prototype.init = () => {
return Promise.resolve({
...config.fields,
folderPath: '/'
})
}

// sentry is not needed in dev mode
process.env.SENTRY_DSN = 'false'

return require(file)
})
.catch(err => {
Expand Down
50 changes: 0 additions & 50 deletions packages/cozy-jobs-cli/src/init-dev-account.js

This file was deleted.

6 changes: 2 additions & 4 deletions packages/cozy-konnector-libs/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ yarn standalone

The requests to the cozy-stack will be stubbed using the [./fixture.json] file as source of data
and when cozy-client-js is asked to create or update data, the data will be output to the console.
The bills (or any file) will be saved in the . directory.
The bills (or any file) will be saved in the ./data directory.

It is possible to add an argument to this command which tells which file to run. Default is
defined in `package.json` `main` section or ./src/index.js
Expand Down Expand Up @@ -66,7 +66,7 @@ This command will register your konnector as an OAuth application to the cozy-st
the cozy-stack is supposed to be located in http://cozy.tools:8080. If this is not your case, just
update the COZY_URL field in [./konnector-dev-config.json].

After that, your konnector is running but should not work since you did not specify any credentials to
After that, your connector is running but should not work since you did not specify any credentials to
the target service. You can do this also in [./konnector-dev-config.json] in the "fields" section.

The files are saved in the root directory of your cozy by default.
Expand All @@ -81,7 +81,5 @@ defined in `package.json` `main` section or ./src/index.js
$ cozy-run-dev <file> [-t token.json] [-m manifest.webapp]
```

As for the `standalone` command, you can specify which file to run. Default is `./index.js`.

- `-t`, `--token` : Specify where the token should be saved
- `-m`, `--manifest` : Specify the manifest.path that should be used for the permissions

0 comments on commit e1608d5

Please sign in to comment.