Skip to content

Commit

Permalink
copy web view out of binary before opening (#2861)
Browse files Browse the repository at this point in the history
Co-authored-by: Aidan Cunniffe <[email protected]>
  • Loading branch information
acunniffe and Aidan Cunniffe authored Aug 29, 2024
1 parent 9ef58c5 commit 47ca076
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "openapi-workspaces",
"license": "MIT",
"private": true,
"version": "1.0.1",
"version": "1.0.2",
"workspaces": [
"projects/json-pointer-helpers",
"projects/openapi-io",
Expand Down
2 changes: 1 addition & 1 deletion projects/fastify-capture/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/fastify-capture",
"license": "MIT",
"packageManager": "[email protected]",
"version": "1.0.1",
"version": "1.0.2",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/json-pointer-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/json-pointer-helpers",
"license": "MIT",
"packageManager": "[email protected]",
"version": "1.0.1",
"version": "1.0.2",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/openapi-io/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/openapi-io",
"license": "MIT",
"packageManager": "[email protected]",
"version": "1.0.1",
"version": "1.0.2",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/openapi-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/openapi-utilities",
"license": "MIT",
"packageManager": "[email protected]",
"version": "1.0.1",
"version": "1.0.2",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/optic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/optic",
"license": "MIT",
"packageManager": "[email protected]",
"version": "1.0.1",
"version": "1.0.2",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
15 changes: 13 additions & 2 deletions projects/optic/src/commands/diff/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import { openUrl } from '../../utils/open-url';
import { renderCloudSetup } from '../../utils/render-cloud';
import { getSpinner } from '../../utils/spinner';
import { CustomUploadFn } from '../../types';
import fs from 'fs-extra';
import os from 'os';

type DiffActionOptions = {
base: string;
Expand Down Expand Up @@ -454,9 +456,18 @@ const getDiffAction =
);
analyticsData.compressedDataLength = compressedData.length;
logger.info('Opening up diff in web view');
const baseHtml = path.resolve(
path.join(__dirname, '../../../web/build/index.html')

const copyPath = path.join(os.tmpdir(), 'optic-changelog');

// This steps is for supporting versions of Optic that use pkg to compile all assets into a binary. Copies it from the virtual file system into userland
await fs.copy(
path.resolve(path.join(__dirname, '../../../web/build')),
copyPath,
{ errorOnExist: false, overwrite: false }
);

const baseHtml = path.resolve(path.join(copyPath, 'index.html'));

maybeChangelogUrl = `${baseHtml}#${compressedData}`;
await flushEvents();
}
Expand Down
2 changes: 1 addition & 1 deletion projects/optic/web/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>Optic Changelog</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
2 changes: 1 addition & 1 deletion projects/rulesets-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/rulesets-base",
"license": "MIT",
"packageManager": "[email protected]",
"version": "1.0.1",
"version": "1.0.2",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/standard-rulesets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/standard-rulesets",
"license": "MIT",
"packageManager": "[email protected]",
"version": "1.0.1",
"version": "1.0.2",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down

0 comments on commit 47ca076

Please sign in to comment.