Skip to content

Commit

Permalink
fix plugin install with deps bug (#6414)
Browse files Browse the repository at this point in the history
* fix cp

* remove patch log

* console logs

* handle bad oauth2 config
  • Loading branch information
jackkav authored Aug 29, 2023
1 parent 00ef2e8 commit 38cc96e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/insomnia/src/main/install-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default async function(lookupName: string) {
console.log(`[plugins] Moving plugin from ${tmpDir} to ${pluginDir}`);

// Move entire module to plugins folder
await cp(path.join(tmpDir, moduleName), pluginDir, { recursive: true });
await cp(path.join(tmpDir, moduleName), pluginDir, { recursive: true, verbatimSymlinks: true });

// Move each dependency into node_modules folder
const pluginModulesDir = path.join(pluginDir, 'node_modules');
Expand All @@ -78,7 +78,7 @@ export default async function(lookupName: string) {
}

const dest = path.join(pluginModulesDir, filename);
await cp(src, dest, { recursive: true });
await cp(src, dest, { recursive: true, verbatimSymlinks: true });
}
} catch (err) {
reject(err);
Expand Down
17 changes: 11 additions & 6 deletions packages/insomnia/src/network/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,18 @@ export async function getAuthHeader(renderedRequest: RenderedRequest, url: strin
// ID of "{{request_id}}.graphql". Here we are removing the .graphql suffix and
// pretending we are fetching a token for the original request. This makes sure
// the same tokens are used for schema fetching. See issue #835 on GitHub.
const tokenId = requestId.match(/\.graphql$/) ? requestId.replace(/\.graphql$/, '') : requestId;
const oAuth2Token = await getOAuth2Token(tokenId, authentication as AuthTypeOAuth2);
try {
const tokenId = requestId.match(/\.graphql$/) ? requestId.replace(/\.graphql$/, '') : requestId;
const oAuth2Token = await getOAuth2Token(tokenId, authentication as AuthTypeOAuth2);

if (oAuth2Token) {
const token = oAuth2Token.accessToken;
return _buildBearerHeader(token, authentication.tokenPrefix);
} else {
if (oAuth2Token) {
const token = oAuth2Token.accessToken;
return _buildBearerHeader(token, authentication.tokenPrefix);
}
return;
} catch (err) {
// TODO: Show this error in the UI
console.log('[oauth2] Failed to get token', err);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ export const OneLineEditor = forwardRef<OneLineEditorHandle, OneLineEditorProps>
const text = e.clipboardData?.getData('text/plain');
// TODO: watch out for pasting urls that are curl<something>, e.g. curl.se would be picked up here without the space
if (onPaste && text && text.startsWith('curl ')) {
console.log('curl PASTE event', text);
onPaste(text);
}
});
Expand Down
1 change: 0 additions & 1 deletion packages/insomnia/src/ui/routes/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ export const runAllTestsAction: ActionFunction = async ({
parentId: testSuiteId,
});
invariant(unitTests, 'No unit tests found');
console.log('unitTests', unitTests);

const tests: Test[] = unitTests
.filter(t => t !== null)
Expand Down
2 changes: 0 additions & 2 deletions packages/insomnia/src/ui/routes/request.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ export const updateRequestAction: ActionFunction = async ({ request, params }) =
const req = await requestOperations.getById(requestId);
invariant(req, 'Request not found');
const patch = await request.json();
console.log('patch', patch);
// TODO: if gRPC, we should also copy the protofile to the destination workspace - INS-267
const isMimeTypeChanged = isRequest(req) && patch.body && patch.body.mimeType !== req.body.mimeType;
if (isMimeTypeChanged) {
Expand Down Expand Up @@ -283,7 +282,6 @@ export const connectAction: ActionFunction = async ({ request, params }) => {
for (const change of changes) {
const [event, doc] = change;
if (isRequestMeta(doc) && doc.parentId === requestId && event === 'update') {
console.log('Response meta received', doc);
resolve(null);
}
}
Expand Down

0 comments on commit 38cc96e

Please sign in to comment.