From 47ca076d0eeaf974cb12b7bcff038233b89560db Mon Sep 17 00:00:00 2001 From: Aidan Cunniffe Date: Thu, 29 Aug 2024 11:21:58 -0400 Subject: [PATCH] copy web view out of binary before opening (#2861) Co-authored-by: Aidan Cunniffe --- package.json | 2 +- projects/fastify-capture/package.json | 2 +- projects/json-pointer-helpers/package.json | 2 +- projects/openapi-io/package.json | 2 +- projects/openapi-utilities/package.json | 2 +- projects/optic/package.json | 2 +- projects/optic/src/commands/diff/diff.ts | 15 +++++++++++++-- projects/optic/web/public/index.html | 2 +- projects/rulesets-base/package.json | 2 +- projects/standard-rulesets/package.json | 2 +- 10 files changed, 22 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 51aba4dc9c..60e072261d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/projects/fastify-capture/package.json b/projects/fastify-capture/package.json index e17558cfad..fd740fa1ab 100644 --- a/projects/fastify-capture/package.json +++ b/projects/fastify-capture/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/fastify-capture", "license": "MIT", "packageManager": "yarn@4.1.1", - "version": "1.0.1", + "version": "1.0.2", "main": "build/index.js", "types": "build/index.d.ts", "files": [ diff --git a/projects/json-pointer-helpers/package.json b/projects/json-pointer-helpers/package.json index a2500b884c..4b7fa229ca 100644 --- a/projects/json-pointer-helpers/package.json +++ b/projects/json-pointer-helpers/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/json-pointer-helpers", "license": "MIT", "packageManager": "yarn@4.1.1", - "version": "1.0.1", + "version": "1.0.2", "main": "build/index.js", "types": "build/index.d.ts", "files": [ diff --git a/projects/openapi-io/package.json b/projects/openapi-io/package.json index 40f8f1ecbf..5986389ebb 100644 --- a/projects/openapi-io/package.json +++ b/projects/openapi-io/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/openapi-io", "license": "MIT", "packageManager": "yarn@4.1.1", - "version": "1.0.1", + "version": "1.0.2", "main": "build/index.js", "types": "build/index.d.ts", "files": [ diff --git a/projects/openapi-utilities/package.json b/projects/openapi-utilities/package.json index 05d37f9a38..92558657b0 100644 --- a/projects/openapi-utilities/package.json +++ b/projects/openapi-utilities/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/openapi-utilities", "license": "MIT", "packageManager": "yarn@4.1.1", - "version": "1.0.1", + "version": "1.0.2", "main": "build/index.js", "types": "build/index.d.ts", "files": [ diff --git a/projects/optic/package.json b/projects/optic/package.json index 63af7273cf..48b2f36606 100644 --- a/projects/optic/package.json +++ b/projects/optic/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/optic", "license": "MIT", "packageManager": "yarn@4.1.1", - "version": "1.0.1", + "version": "1.0.2", "main": "build/index.js", "types": "build/index.d.ts", "files": [ diff --git a/projects/optic/src/commands/diff/diff.ts b/projects/optic/src/commands/diff/diff.ts index 9643a31e89..ec090724ad 100644 --- a/projects/optic/src/commands/diff/diff.ts +++ b/projects/optic/src/commands/diff/diff.ts @@ -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; @@ -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(); } diff --git a/projects/optic/web/public/index.html b/projects/optic/web/public/index.html index aa069f27cb..c52d3b5a90 100644 --- a/projects/optic/web/public/index.html +++ b/projects/optic/web/public/index.html @@ -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`. --> - React App + Optic Changelog diff --git a/projects/rulesets-base/package.json b/projects/rulesets-base/package.json index a6eff8e9b1..b74afdacea 100644 --- a/projects/rulesets-base/package.json +++ b/projects/rulesets-base/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/rulesets-base", "license": "MIT", "packageManager": "yarn@4.1.1", - "version": "1.0.1", + "version": "1.0.2", "main": "build/index.js", "types": "build/index.d.ts", "files": [ diff --git a/projects/standard-rulesets/package.json b/projects/standard-rulesets/package.json index 3de20a0949..44f673cd44 100644 --- a/projects/standard-rulesets/package.json +++ b/projects/standard-rulesets/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/standard-rulesets", "license": "MIT", "packageManager": "yarn@4.1.1", - "version": "1.0.1", + "version": "1.0.2", "main": "build/index.js", "types": "build/index.d.ts", "files": [