Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deps): upgrade to helix-fetch v2 #1624

Merged
merged 3 commits into from Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1,542 changes: 1,037 additions & 505 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -31,7 +31,7 @@
},
"dependencies": {
"@adobe/fastly-native-promises": "^1.19.2",
"@adobe/helix-fetch": "^1.9.2",
"@adobe/helix-fetch": "2.0.1",
"@adobe/helix-log": "4.5.3",
"@adobe/helix-shared": "7.19.2",
"@adobe/helix-simulator": "5.1.20",
Expand All @@ -41,7 +41,7 @@
"archiver": "^5.1.0",
"camelcase": "^6.2.0",
"chalk": "4.1.0",
"chokidar": "^3.4.3",
"chokidar": "3.4.3",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was needed, because I got errors on macOS.
see: fsevents/fsevents#355

"dotenv": "^8.0.0",
"ferrum": "^1.7.0",
"fs-extra": "^9.0.1",
Expand Down
6 changes: 4 additions & 2 deletions src/auth.cmd.js
Expand Up @@ -21,7 +21,10 @@ const LoginServer = require('./auth-login-server.js');
const cliutils = require('./cli-util');

const { fetch } = process.env.HELIX_FETCH_FORCE_HTTP1
? fetchAPI.context({ httpsProtocols: ['http1'] })
/* istanbul ignore next */
? fetchAPI.context({
alpnProtocols: [fetchAPI.ALPN_HTTP1_1],
})
: fetchAPI;

const HELIX_APP_HOST = 'https://app.project-helix.io';
Expand Down Expand Up @@ -104,7 +107,6 @@ I received an access token that I can use to access the Helix Bot on your behalf
'User-Agent': 'HelixBot',
Authorization: `token ${this._token}`,
},
json: true,
});

if (!response.ok) {
Expand Down
11 changes: 8 additions & 3 deletions src/deploy.cmd.js
Expand Up @@ -12,7 +12,7 @@

'use strict';

const { fetch } = require('@adobe/helix-fetch');
const fetchAPI = require('@adobe/helix-fetch');
const chalk = require('chalk');
const ow = require('openwhisk');
const glob = require('glob');
Expand All @@ -27,6 +27,13 @@ const AbstractCommand = require('./abstract.cmd.js');
const PackageCommand = require('./package.cmd.js');
const ConfigUtils = require('./config/config-utils.js');

const { fetch } = process.env.HELIX_FETCH_FORCE_HTTP1
/* istanbul ignore next */
? fetchAPI.context({
alpnProtocols: [fetchAPI.ALPN_HTTP1_1],
})
: fetchAPI;

function humanFileSize(size) {
const i = size === 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024));
const p2 = 1024 ** i;
Expand Down Expand Up @@ -271,7 +278,6 @@ class DeployCommand extends AbstractCommand {

const followoptions = {
method: 'POST',
json: true,
tripodsan marked this conversation as resolved.
Show resolved Hide resolved
auth,
tripodsan marked this conversation as resolved.
Show resolved Hide resolved
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -331,7 +337,6 @@ class DeployCommand extends AbstractCommand {

const triggeroptions = {
method: 'POST',
json: true,
auth,
tripodsan marked this conversation as resolved.
Show resolved Hide resolved
headers: {
'Content-Type': 'application/json',
Expand Down
13 changes: 10 additions & 3 deletions src/perf.cmd.js
Expand Up @@ -11,12 +11,19 @@
*/
/* eslint-disable max-classes-per-file */
const chalk = require('chalk');
const { fetch } = require('@adobe/helix-fetch');
const fetchAPI = require('@adobe/helix-fetch');
const path = require('path');
const _ = require('lodash/fp');
const JunitPerformanceReport = require('./junit-utils');
const AbstractCommand = require('./abstract.cmd.js');

const { fetch } = process.env.HELIX_FETCH_FORCE_HTTP1
/* istanbul ignore next */
? fetchAPI.context({
alpnProtocols: [fetchAPI.ALPN_HTTP1_1],
})
: fetchAPI;

class PerformanceError extends Error {

}
Expand Down Expand Up @@ -163,7 +170,7 @@ class PerfCommand extends AbstractCommand {
try {
let response = await fetch(uri, {
method: 'POST',
json: {
body: {
service: this._fastly_namespace,
token: this._fastly_auth,
tests: flatttests,
Expand All @@ -183,7 +190,7 @@ class PerfCommand extends AbstractCommand {
// eslint-disable-next-line no-await-in-loop
response = await fetch(uri, {
method: 'POST',
json: {
body: {
service: this._fastly_namespace,
token: this._fastly_auth,
tests: schedule,
Expand Down
11 changes: 7 additions & 4 deletions src/remotepublish.cmd.js
Expand Up @@ -25,7 +25,10 @@ const GitUtils = require('./git-utils.js');
const cliversion = require('../package.json').version;

const { fetch } = process.env.HELIX_FETCH_FORCE_HTTP1
? fetchAPI.context({ httpsProtocols: ['http1'] })
/* istanbul ignore next */
? fetchAPI.context({
alpnProtocols: [fetchAPI.ALPN_HTTP1_1],
})
: fetchAPI;

class RemotePublishCommand extends AbstractCommand {
Expand Down Expand Up @@ -262,7 +265,7 @@ class RemotePublishCommand extends AbstractCommand {
serviceAddLogger() {
return fetch('https://adobeioruntime.net/api/v1/web/helix/helix-services/logging@v1', {
method: 'POST',
json: {
body: {
service: this._fastly_namespace,
token: this._fastly_auth,
version: this._version,
Expand Down Expand Up @@ -348,7 +351,7 @@ ${e}`);

return fetch(this._publishAPI, {
method: 'POST',
json: body,
body,
}).then(async (res) => {
if (!res.ok) {
const e = new Error(`${res.status} - "${await res.text()}"`);
Expand Down Expand Up @@ -415,7 +418,7 @@ ${e}`);

const response = await fetch(this._configPurgeAPI, {
method: 'POST',
json: {
body: {
github_token: this._githubToken,
content_repositories: Object.keys(repos),
fastly_service_id: this._fastly_namespace,
Expand Down
1 change: 0 additions & 1 deletion test/specs/builder/src/asynchelpx_html.pre.js
Expand Up @@ -26,7 +26,6 @@ async function collectMetadata(req, logger) {
headers: {
'User-Agent': 'Request-Promise',
},
json: true,
};

logger.debug(`Fetching Git Metadata from ${options.uri}`);
Expand Down
1 change: 0 additions & 1 deletion test/specs/builder/src/helpx_html.pre.js
Expand Up @@ -23,7 +23,6 @@ function collectMetadata(req, logger) {
headers: {
'User-Agent': 'Request-Promise',
},
json: true,
};

logger.debug(`Fetching Git Metadata from ${options.uri}`);
Expand Down
6 changes: 3 additions & 3 deletions test/testAuthCmd.js
Expand Up @@ -88,7 +88,7 @@ describe('Integration test for auth', () => {
.on('server-start', async (port) => {
const res = await fetchAPI.fetch(`http://127.0.0.1:${port}/`, {
method: 'POST',
json: {
body: {
token,
},
});
Expand Down Expand Up @@ -134,7 +134,7 @@ describe('Integration test for auth', () => {
.on('server-start', async (port) => {
const res = await fetchAPI.fetch(`http://127.0.0.1:${port}/`, {
method: 'POST',
json: {
body: {
token,
},
});
Expand Down Expand Up @@ -176,7 +176,7 @@ describe('Integration test for auth', () => {
.on('server-start', async (port) => {
const res = await fetchAPI.fetch(`http://127.0.0.1:${port}/`, {
method: 'POST',
json: {
body: {
token,
},
});
Expand Down
4 changes: 3 additions & 1 deletion test/testRemotePublishCmd.js
Expand Up @@ -139,7 +139,9 @@ describe('hlx publish --remote (default)', () => {
it('publishing warns if remote logging fails', async () => {
const scope = nock('https://adobeioruntime.net')
.post('/api/v1/web/helix/helix-services/publish@v2')
.reply(200, {});
.reply(200, {})
.post('/api/v1/web/helix/helix-services/logging@v1')
.reply(404);

const logger = logging.createTestLogger();
const remote = await new RemotePublishCommand(logger)
Expand Down