From 48d081867bb54d3206a2ad327b8502667163119b Mon Sep 17 00:00:00 2001 From: Scott J Dickerson Date: Thu, 14 Nov 2024 18:56:17 -0500 Subject: [PATCH] :seedling: Refactor shared package imports The `@shared/types` package does not actually exist. It was only working because there was a vestigial reference for it in the `package-lock.json` file from before the shared workspace package was renamed from `@shared/types` to `@editor-extensions/shared`. `@shared/types` was pointing to the shared workspace. Fixes: - Remove the `@shared/types` reference in the lock file - Refactor all of the imports to pull from the current npm package name Signed-off-by: Scott J Dickerson --- package-lock.json | 8 +---- shared/package.json | 30 +++++++++---------- vscode/package.json | 3 +- vscode/src/client/analyzerClient.ts | 2 +- vscode/src/commands.ts | 2 +- vscode/src/data/analyzerResults.ts | 2 +- vscode/src/data/loadResults.ts | 2 +- vscode/src/data/loadStaticResults.ts | 2 +- vscode/src/data/storage.ts | 2 +- vscode/src/data/virtualStorage.ts | 2 +- vscode/src/extensionState.ts | 2 +- vscode/src/test/analyzerResults.test.ts | 2 +- vscode/src/utilities/typeGuards.ts | 2 +- webview-ui/package.json | 5 ++-- webview-ui/src/App.tsx | 2 +- .../src/components/GuidedApproachWizard.tsx | 2 +- .../src/components/ViolationIncidentsList.tsx | 2 +- 17 files changed, 32 insertions(+), 40 deletions(-) diff --git a/package-lock.json b/package-lock.json index b53383f1..9b1e8783 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1518,10 +1518,6 @@ "win32" ] }, - "node_modules/@shared/types": { - "resolved": "shared", - "link": true - }, "node_modules/@sindresorhus/merge-streams": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-2.3.0.tgz", @@ -8663,7 +8659,7 @@ }, "shared": { "name": "@editor-extensions/shared", - "version": "1.0.0", + "version": "0.0.1", "devDependencies": { "rimraf": "^5.0.0", "typescript": "^5.0.0" @@ -8673,7 +8669,6 @@ "name": "editor-extensions-vscode", "version": "0.0.1", "dependencies": { - "@shared/types": "^1.0.0", "babel-loader": "^9.2.1", "diff": "^7.0.0" }, @@ -8781,7 +8776,6 @@ "@patternfly/react-core": "6.0.0-prerelease.15", "@patternfly/react-icons": "^5.4.0", "@patternfly/react-table": "^5.4.1", - "@shared/types": "^1.0.0", "vscode-webview": "^1.0.1-beta.1" }, "devDependencies": { diff --git a/shared/package.json b/shared/package.json index 1c7d910e..107fbad7 100644 --- a/shared/package.json +++ b/shared/package.json @@ -1,16 +1,16 @@ { - "name": "@editor-extensions/shared", - "version": "1.0.0", - "private": true, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", - "scripts": { - "build": "tsc -b tsconfig.json", - "clean": "rimraf dist", - "prebuild": "npm run clean" - }, - "devDependencies": { - "rimraf": "^5.0.0", - "typescript": "^5.0.0" - } - } \ No newline at end of file + "name": "@editor-extensions/shared", + "version": "0.0.1", + "private": true, + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "scripts": { + "build": "tsc -b tsconfig.json", + "clean": "rimraf dist", + "prebuild": "npm run clean" + }, + "devDependencies": { + "rimraf": "^5.0.0", + "typescript": "^5.0.0" + } +} diff --git a/vscode/package.json b/vscode/package.json index 04a35af9..f9e39988 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -473,8 +473,7 @@ "webpack-cli": "^5.1.4" }, "dependencies": { - "@shared/types": "^1.0.0", "babel-loader": "^9.2.1", "diff": "^7.0.0" } -} \ No newline at end of file +} diff --git a/vscode/src/client/analyzerClient.ts b/vscode/src/client/analyzerClient.ts index 1bb6801d..301b417f 100644 --- a/vscode/src/client/analyzerClient.ts +++ b/vscode/src/client/analyzerClient.ts @@ -2,7 +2,7 @@ import { ChildProcessWithoutNullStreams, exec, spawn } from "child_process"; import * as vscode from "vscode"; import * as os from "os"; import * as fs from "fs"; -import { Incident, RuleSet } from "@shared/types"; +import { Incident, RuleSet } from "@editor-extensions/shared"; import path from "path"; diff --git a/vscode/src/commands.ts b/vscode/src/commands.ts index e4557b01..41a3c5a7 100644 --- a/vscode/src/commands.ts +++ b/vscode/src/commands.ts @@ -18,7 +18,7 @@ import { loadSolution, loadStaticResults, } from "./data"; -import { GetSolutionResult, RuleSet } from "@shared/types"; +import { GetSolutionResult, RuleSet } from "@editor-extensions/shared"; import { applyAll, revertAll, diff --git a/vscode/src/data/analyzerResults.ts b/vscode/src/data/analyzerResults.ts index f943ba1e..49f21348 100644 --- a/vscode/src/data/analyzerResults.ts +++ b/vscode/src/data/analyzerResults.ts @@ -1,7 +1,7 @@ import * as vscode from "vscode"; import * as fs from "fs"; import * as yaml from "js-yaml"; -import { RuleSet, Category, Incident } from "@shared/types"; +import { RuleSet, Category, Incident } from "@editor-extensions/shared"; //Assuming that output is in form of yaml export function readYamlFile(filePath: string): RuleSet[] | undefined { diff --git a/vscode/src/data/loadResults.ts b/vscode/src/data/loadResults.ts index b245b15f..f249ae97 100644 --- a/vscode/src/data/loadResults.ts +++ b/vscode/src/data/loadResults.ts @@ -1,4 +1,4 @@ -import { GetSolutionResult, RuleSet } from "@shared/types"; +import { GetSolutionResult, RuleSet } from "@editor-extensions/shared"; import { processIncidents } from "./analyzerResults"; import { ExtensionState } from "src/extensionState"; import { writeDataFile } from "./storage"; diff --git a/vscode/src/data/loadStaticResults.ts b/vscode/src/data/loadStaticResults.ts index e26a4b20..35585497 100644 --- a/vscode/src/data/loadStaticResults.ts +++ b/vscode/src/data/loadStaticResults.ts @@ -1,5 +1,5 @@ import * as vscode from "vscode"; -import { RuleSet } from "@shared/types"; +import { RuleSet } from "@editor-extensions/shared"; import { loadStateFromDataFolder, readDataFiles } from "./storage"; export const loadStaticResults = async () => { diff --git a/vscode/src/data/storage.ts b/vscode/src/data/storage.ts index 3aa09b00..b26c759a 100644 --- a/vscode/src/data/storage.ts +++ b/vscode/src/data/storage.ts @@ -2,7 +2,7 @@ import path from "path"; import * as vscode from "vscode"; import fs from "fs"; -import { RuleSet, GetSolutionResult } from "@shared/types"; +import { RuleSet, GetSolutionResult } from "@editor-extensions/shared"; import { isAnalysis, isSolution, diff --git a/vscode/src/data/virtualStorage.ts b/vscode/src/data/virtualStorage.ts index c1abb2d7..4d209bed 100644 --- a/vscode/src/data/virtualStorage.ts +++ b/vscode/src/data/virtualStorage.ts @@ -1,4 +1,4 @@ -import { GetSolutionResult } from "@shared/types"; +import { GetSolutionResult } from "@editor-extensions/shared"; import { Uri, window, workspace } from "vscode"; import { ExtensionState } from "src/extensionState"; import * as Diff from "diff"; diff --git a/vscode/src/extensionState.ts b/vscode/src/extensionState.ts index 654cb8dc..4b22019c 100644 --- a/vscode/src/extensionState.ts +++ b/vscode/src/extensionState.ts @@ -4,7 +4,7 @@ import { MemFS } from "./data/fileSystemProvider"; import { KonveyorGUIWebviewViewProvider } from "./KonveyorGUIWebviewViewProvider"; import * as vscode from "vscode"; import { LocalChange } from "./data/virtualStorage"; -import { RuleSet } from "@shared/types"; +import { RuleSet } from "@editor-extensions/shared"; export class SharedState { private state: Map = new Map(); diff --git a/vscode/src/test/analyzerResults.test.ts b/vscode/src/test/analyzerResults.test.ts index 770a5590..9e18f1f6 100644 --- a/vscode/src/test/analyzerResults.test.ts +++ b/vscode/src/test/analyzerResults.test.ts @@ -2,7 +2,7 @@ import * as assert from "assert"; import { DiagnosticSeverity } from "vscode"; import * as path from "path"; import { processIncidents, readYamlFile } from "../data/analyzerResults"; -import { RuleSet } from "@shared/types"; +import { RuleSet } from "@editor-extensions/shared"; suite("Extension Test Suite", () => { test("processIncidents should populate diagnostics correctly", () => { diff --git a/vscode/src/utilities/typeGuards.ts b/vscode/src/utilities/typeGuards.ts index beea83e0..a9b62dd7 100644 --- a/vscode/src/utilities/typeGuards.ts +++ b/vscode/src/utilities/typeGuards.ts @@ -1,4 +1,4 @@ -import { GetSolutionResult, RuleSet } from "@shared/types"; +import { GetSolutionResult, RuleSet } from "@editor-extensions/shared"; import { Uri } from "vscode"; const isString = (obj: unknown): obj is string => typeof obj === "string"; diff --git a/webview-ui/package.json b/webview-ui/package.json index fb95931c..c8c40f47 100644 --- a/webview-ui/package.json +++ b/webview-ui/package.json @@ -14,8 +14,7 @@ "@patternfly/react-core": "6.0.0-prerelease.15", "@patternfly/react-icons": "^5.4.0", "@patternfly/react-table": "^5.4.1", - "vscode-webview": "^1.0.1-beta.1", - "@shared/types": "^1.0.0" + "vscode-webview": "^1.0.1-beta.1" }, "devDependencies": { "@types/vscode-webview": "^1.57.5", @@ -25,4 +24,4 @@ "optionalDependencies": { "@rollup/rollup-linux-x64-gnu": "4.9.5" } -} \ No newline at end of file +} diff --git a/webview-ui/src/App.tsx b/webview-ui/src/App.tsx index ce74a9c9..3ee741f7 100644 --- a/webview-ui/src/App.tsx +++ b/webview-ui/src/App.tsx @@ -20,7 +20,7 @@ import { vscode } from "./utils/vscode"; import GuidedApproachWizard from "./components/GuidedApproachWizard"; import ProgressIndicator from "./components/ProgressIndicator"; import ViolationIncidentsList from "./components/ViolationIncidentsList"; -import { Incident, RuleSet } from "@shared/types"; +import { Incident, RuleSet } from "@editor-extensions/shared"; const App: React.FC = () => { const [analysisResults, setAnalysisResults] = useState(); diff --git a/webview-ui/src/components/GuidedApproachWizard.tsx b/webview-ui/src/components/GuidedApproachWizard.tsx index b9242b16..5fc08e25 100644 --- a/webview-ui/src/components/GuidedApproachWizard.tsx +++ b/webview-ui/src/components/GuidedApproachWizard.tsx @@ -16,7 +16,7 @@ import { } from "@patternfly/react-core"; import ViolationIncidentsList from "./ViolationIncidentsList"; import { vscode } from "../utils/vscode"; -import { Incident, Violation } from "@shared/types/src/types"; +import { Incident, Violation } from "@editor-extensions/shared/src/types"; interface GuidedApproachWizardProps { violations: Violation[]; diff --git a/webview-ui/src/components/ViolationIncidentsList.tsx b/webview-ui/src/components/ViolationIncidentsList.tsx index d4c3b527..a8ae5bd2 100644 --- a/webview-ui/src/components/ViolationIncidentsList.tsx +++ b/webview-ui/src/components/ViolationIncidentsList.tsx @@ -34,7 +34,7 @@ import { FileIcon, EllipsisVIcon, } from "@patternfly/react-icons"; -import { Incident, Violation } from "@shared/types"; +import { Incident, Violation } from "@editor-extensions/shared"; type SortOption = "description" | "incidentCount" | "severity";