Unexpected token and octokit deprecation error
- Dominant language
- TypeScript
- Stars
- 5.5k
- Forks
- 381
- Avg merge
- 2h 8m
- Merged PRs (30d)
- 6
Description
I'm running a simple example dangerfile.js straight from the docs, using the latest 7.0.2:
```js
import { message, danger } from 'danger';
import { readFileSync } from 'fs';
const modifiedMD = danger.git.modified_files.join('- ');
message(`Changed Files in this PR: \n - ${modifiedMD}`);
```
and `yarn danger local` throws both syntax error and deprecation notice:
```
> yarn danger local
yarn run v1.13.0
$ /node_modules/.bin/danger local
Error: new Octokit({headers}) is deprecated. Use {userAgent, previews} instead. See https://github.com/octokit/rest.js#client-options
at parseOptions (/node_modules/@octokit/rest/lib/parse-client-options.js:43:18)
at new Octokit (/node_modules/@octokit/rest/lib/constructor.js:14:50)
at apiForDSL (/node_modules/danger/distribution/runner/jsonToDSL.js:114:15)
at Object. (/node_modules/danger/distribution/runner/jsonToDSL.js:72:23)
at step (/node_modules/danger/distribution/runner/jsonToDSL.js:43:23)
at Object.next (/node_modules/danger/distribution/runner/jsonToDSL.js:24:53)
at /node_modules/danger/distribution/runner/jsonToDSL.js:18:71
at new Promise ()
at __awaiter (/node_modules/danger/distribution/runner/jsonToDSL.js:14:12)
at Object.exports.jsonToDSL (/node_modules/danger/distribution/runner/jsonToDSL.js:65:53)
Error: octokit.authenticate() is deprecated. Use "auth" constructor option instead.
at authenticate (/node_modules/@octokit/rest/plugins/authentication-deprecated/authenticate.js:4:16)
at apiForDSL (/node_modules/danger/distribution/runner/jsonToDSL.js:116:13)
at Object. (/node_modules/danger/distribution/runner/jsonToDSL.js:72:23)
at step (/node_modules/danger/distribution/runner/jsonToDSL.js:43:23)
at Object.next (/node_modules/danger/distribution/runner/jsonToDSL.js:24:53)
at /node_modules/danger/distribution/runner/jsonToDSL.js:18:71
at new Promise ()
at __awaiter (/node_modules/danger/distribution/runner/jsonToDSL.js:14:12)
at Object.exports.jsonToDSL (/node_modules/danger/distribution/runner/jsonToDSL.js:65:53)
at Object. (/node_modules/danger/distribution/runner/jsonToContext.js:55:54)
Unable to evaluate the Dangerfile
dangerfile.js:14
import { readFileSync } from 'fs';
^
SyntaxError: Unexpected token {
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.requireFromString [as default] (/node_modules/require-from-string/index.js:28:4)
at Object. (/node_modules/danger/distribution/runner/runners/inline.js:144:63)
at step (/node_modules/danger/distribution/runner/runners/inline.js:32:23)
at Object.next (/node_modules/danger/distribution/runner/runners/inline.js:13:53)
at /node_modules/danger/distribution/runner/runners/inline.js:7:71
at new Promise ()
Error: new Octokit({headers}) is deprecated. Use {userAgent, previews} instead. See https://github.com/octokit/rest.js#client-options
at parseOptions (/node_modules/@octokit/rest/lib/parse-client-options.js:43:18)
at new Octokit (/node_modules/@octokit/rest/lib/constructor.js:14:50)
at apiForDSL (/node_modules/danger/distribution/runner/jsonToDSL.js:114:15)
at Object. (/node_modules/danger/distribution/runner/jsonToDSL.js:72:23)
at step (/node_modules/danger/distribution/runner/jsonToDSL.js:43:23)
at Object.next (/node_modules/danger/distribution/runner/jsonToDSL.js:24:53)
at /node_modules/danger/distribution/runner/jsonToDSL.js:18:71
at new Promise ()
at __awaiter (/node_modules/danger/distribution/runner/jsonToDSL.js:14:12)
at Object.exports.jsonToDSL (/node_modules/danger/distribution/runner/jsonToDSL.js:65:53)
Error: octokit.authenticate() is deprecated. Use "auth" constructor option instead.
at authenticate (/node_modules/@octokit/rest/plugins/authentication-deprecated/authenticate.js:4:16)
at apiForDSL (/node_modules/danger/distribution/runner/jsonToDSL.js:116:13)
at Object. (/node_modules/danger/distribution/runner/jsonToDSL.js:72:23)
at step (/node_modules/danger/distribution/runner/jsonToDSL.js:43:23)
at Object.next (/node_modules/danger/distribution/runner/jsonToDSL.js:24:53)
at /node_modules/danger/distribution/runner/jsonToDSL.js:18:71
at new Promise ()
at __awaiter (/node_modules/danger/distribution/runner/jsonToDSL.js:14:12)
at Object.exports.jsonToDSL (/node_modules/danger/distribution/runner/jsonToDSL.js:65:53)
at Object. (/node_modules/danger/distribution/commands/utils/runDangerSubprocess.js:159:54)
Danger: ⅹ Failing the build, there is 1 fail.
## Failures
Danger failed to run `dangerfile.js`.
## Markdowns
## Error SyntaxError
Unexpected token {
dangerfile.js:14
import { readFileSync } from 'fs';
^
SyntaxError: Unexpected token {
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.requireFromString [as default] (/node_modules/require-from-string/index.js:28:4)
at Object. (/node_modules/danger/distribution/runner/runners/inline.js:144:63)
at step (/node_modules/danger/distribution/runner/runners/inline.js:32:23)
at Object.next (/node_modules/danger/distribution/runner/runners/inline.js:13:53)
at /node_modules/danger/distribution/runner/runners/inline.js:7:71
at new Promise ()
### Dangerfile
---------^
```
Am I missing something?
Contributor guide
Research direction
Start with the documented dangerfile.js example and the runner paths named in the trace, especially distribution/runner/jsonToDSL.js and distribution/runner/runners/inline.js. Reproduce with yarn danger local and trace the syntax and Octokit deprecation errors; done means the example evaluates successfully without these failures.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100