Skip to content

Commit

Permalink
Reverted node-fetch removal.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemyslaw-zan committed Sep 14, 2023
1 parent 463c6d5 commit 808ad5e
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/ckeditor5-dev-ci/bin/circle-workflow-notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
'use strict';

const { execSync } = require( 'child_process' );
const fetch = require( 'node-fetch' );
const minimist = require( 'minimist' );
const processJobStatuses = require( '../lib/process-job-statuses' );

Expand Down
1 change: 1 addition & 0 deletions packages/ckeditor5-dev-ci/bin/notify-circle-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/* eslint-env node */

const fetch = require( 'node-fetch' );
const slackNotify = require( 'slack-notify' );
const formatMessage = require( '../lib/format-message' );

Expand Down
1 change: 1 addition & 0 deletions packages/ckeditor5-dev-ci/lib/format-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

'use strict';

const fetch = require( 'node-fetch' );
const bots = require( './data/bots.json' );
const members = require( './data/members.json' );

Expand Down
1 change: 1 addition & 0 deletions packages/ckeditor5-dev-ci/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"keywords": [],
"dependencies": {
"minimist": "^1.2.5",
"node-fetch": "^2.6.7",
"slack-notify": "^2.0.6"
},
"devDependencies": {
Expand Down
15 changes: 6 additions & 9 deletions packages/ckeditor5-dev-ci/tests/format-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,24 @@ describe( 'lib/format-message', () => {

beforeEach( () => {
stubs = {
fetch: sinon.stub( global, 'fetch' )
nodeFetch: sinon.stub()
};

formatMessage = proxyquire( '../lib/format-message', {
'node-fetch': stubs.nodeFetch,
'./data/members.json': {
ExampleNick: 'slackId'
}
} );
} );

afterEach( () => {
sinon.restore();
} );

describe( 'formatMessage()', () => {
it( 'should be a function', () => {
expect( formatMessage ).to.be.a( 'function' );
} );

it( 'should display a message for bot if a login is included in the "bots" array', async () => {
stubs.fetch.resolves( {
stubs.nodeFetch.resolves( {
json() {
return Promise.resolve( {
author: {
Expand Down Expand Up @@ -75,7 +72,7 @@ describe( 'lib/format-message', () => {
} );

it( 'should display a message for bot if a login is unavailable but author name is included in the "bots" array', async () => {
stubs.fetch.resolves( {
stubs.nodeFetch.resolves( {
json() {
return Promise.resolve( {
author: null,
Expand Down Expand Up @@ -112,7 +109,7 @@ describe( 'lib/format-message', () => {
} );

it( 'should mention the channel if a login is unavailable and author name is not included in the "bots" array', async () => {
stubs.fetch.resolves( {
stubs.nodeFetch.resolves( {
json() {
return Promise.resolve( {
author: null,
Expand Down Expand Up @@ -149,7 +146,7 @@ describe( 'lib/format-message', () => {
} );

it( 'should find a Slack account based on a GitHub account case-insensitive', async () => {
stubs.fetch.resolves( {
stubs.nodeFetch.resolves( {
json() {
return Promise.resolve( {
author: {
Expand Down
3 changes: 2 additions & 1 deletion packages/ckeditor5-dev-transifex/lib/transifexservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

const { transifexApi } = require( '@transifex/api' );
const fetch = require( 'node-fetch' );

const MAX_REQUEST_ATTEMPTS = 10;
const REQUEST_RETRY_TIMEOUT = 3000; // In milliseconds.
Expand Down Expand Up @@ -320,7 +321,7 @@ function createDownloadRequest( resource, language, numberOfAttempts = 1 ) {
* attempt. There are three possible cases that are handled during downloading a file:
*
* (1) According to the Transifex API v3.0, when the requested file is ready for download, the Transifex service returns HTTP code 303,
* which is the redirection to the new location, where the file is available. By default, `fetch` follows redirections so the requested
* which is the redirection to the new location, where the file is available. By default, `node-fetch` follows redirections so the requested
* file is downloaded automatically.
* (2) If the requested file is not ready yet, but the response status from the Transifex service was successful and the number of retries
* has not reached the limit yet, the request is queued and retried after the REQUEST_RETRY_TIMEOUT timeout.
Expand Down
1 change: 1 addition & 0 deletions packages/ckeditor5-dev-transifex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"chalk": "^4.0.0",
"inquirer": "^7.1.0",
"@transifex/api": "^4.2.1",
"node-fetch": "^2.6.7",
"cli-table": "^0.3.1"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion packages/ckeditor5-dev-transifex/tests/transifexservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ describe( 'dev-transifex/transifex-service', () => {
}
},

fetch: sinon.stub( global, 'fetch' )
fetch: sinon.stub()
};

mockery.registerMock( '@transifex/api', { transifexApi: stubs.transifexApi } );
mockery.registerMock( 'node-fetch', stubs.fetch );

transifexService = require( '../lib/transifexservice' );
} );
Expand Down

0 comments on commit 808ad5e

Please sign in to comment.