Skip to content

support windows #114

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"devDependencies": {
"@types/cytoscape-fcose": "^2.2.4",
"@types/path-browserify": "^1.0.3",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.2",
"@vitejs/plugin-react": "^4.3.4",
Expand All @@ -25,6 +26,7 @@
"cytoscape-fcose": "^2.2.0",
"cytoscape-layout-utilities": "^1.1.1",
"npm": "^10.9.2",
"path-browserify": "^1.0.1",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-icons": "^5.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
LuGitGraph,
} from "react-icons/lu";
import { FileDependencyManifest } from "@nanoapi.io/shared";
import { basename } from "path-browserify";

export default function FileContextMenu(props: {
position: { x: number; y: number };
Expand Down Expand Up @@ -51,7 +52,7 @@ export default function FileContextMenu(props: {
className="rounded-md bg-secondarySurface-light dark:bg-secondarySurface-dark shadow-md border border-border-light dark:border-border-dark p-1"
>
<DropdownMenu.Label>
{props.fileDependencyManifest.filePath.split("/").pop()}
{basename(props.fileDependencyManifest.filePath)}
</DropdownMenu.Label>
<DropdownMenu.Separator />
<DropdownMenu.Item
Expand All @@ -78,7 +79,7 @@ export default function FileContextMenu(props: {
className="px-2 py-1 hover:bg-primary-light dark:hover:bg-primary-dark"
onSelect={() =>
props.showInSidebar(
props.fileDependencyManifest.filePath.split("/").pop() || "",
basename(props.fileDependencyManifest.filePath) || "",
)
}
>
Expand Down
3 changes: 2 additions & 1 deletion packages/app/src/components/FileDetailsPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
metricDependentCount,
metricLinesCount,
} from "@nanoapi.io/shared";
import { basename } from "path-browserify";

// Subcomponent for section headings
function SectionHeading({ children }: { children: React.ReactNode }) {
Expand Down Expand Up @@ -133,7 +134,7 @@ export default function FileDetailsPane(props: {
setOpen: (open: boolean) => void;
}) {
const { fileDependencyManifest, fileAuditManifest, open, setOpen } = props;
const fileName = fileDependencyManifest.filePath.split("/").pop() || "";
const fileName = basename(fileDependencyManifest.filePath);
const fileAlerts = Object.values(fileAuditManifest.alerts) as {
message: { long: string };
metric: string;
Expand Down
11 changes: 8 additions & 3 deletions packages/app/src/components/FileExplorer/FileExplorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
} from "react-icons/md";
import { runExtraction } from "../../service/api/index.js";
import { toast } from "react-toastify";
import { extname, sep } from "path-browserify";

interface TreeData {
id: string;
Expand Down Expand Up @@ -145,7 +146,7 @@ export default function FileExplorer(props: {
return;
}

const segments = file.path.split("/");
const segments = file.path.split(sep);

// Add the file to the tree structure
addFileToTree(rootNodes, segments, "", file.symbols);
Expand Down Expand Up @@ -437,7 +438,11 @@ function NodeElement(props: {
onClick={handleToggle}
>
<div className="flex space-x-2 items-center overflow-hidden">
{languageIcon(props.node.name.split(".").pop() || "txt")}
{languageIcon(
extname(
props.node.name.split(".").pop() || "txt",
).slice(1) || "txt",
)}
<DisplayedPath node={props.node} search={props.search} />
</div>
</Button>
Expand Down Expand Up @@ -746,7 +751,7 @@ function ExtractionElement(props: {
<div className="flex flex-col space-y-2 ml-5">
<div className="flex items-center justify-between space-x-2">
<div className="flex items-center space-x-2">
{languageIcon(props.node.filePath.split(".").pop() || "txt")}
{languageIcon(extname(props.node.filePath).slice(1) || "txt")}
{getDisplayedPath(props.node.filePath)}
</div>
{props.editMode === EditMode.EDITING && (
Expand Down
3 changes: 2 additions & 1 deletion packages/app/src/components/SymbolDetailsPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
metricDependentCount,
metricLinesCount,
} from "@nanoapi.io/shared";
import { basename } from "path-browserify";

// Subcomponent for section headings
function SectionHeading({ children }: { children: React.ReactNode }) {
Expand Down Expand Up @@ -85,7 +86,7 @@ export default function SymbolDetailsPane(props: {
}) {
const { fileDependencyManifest, fileAuditManifest, symbolId, open, setOpen } =
props;
const fileName = fileDependencyManifest.filePath.split("/").pop() || "";
const fileName = basename(fileDependencyManifest.filePath);
const symbolData = fileDependencyManifest.symbols[symbolId];
const symbolName = symbolData?.id || symbolId;
const symbolType = symbolData?.type || "";
Expand Down
8 changes: 3 additions & 5 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@
}
},
"scripts": {
"dev": "cross-env NODE_ENV=development nodemon --no-stdin --exec \"node --loader ts-node/esm\" src/index.ts",
"build:cleanup": "rm -rf ./dist && rm -rf ../app/dist",
"dev": "cross-env NODE_ENV=development nodemon --no-stdin --exec \"node --loader ts-node/esm src/index.ts\"",
"build:app": "npm run build --prefix ../app",
"build:copy-app-dist": "cp -r ../app/dist ./dist/app_dist",
"build:copy-app-dist": "node -e \"import('fs').then(({cpSync}) => cpSync('../app/dist', './dist/app_dist', {recursive: true}))\"",
"build:cli": "tsup",
"build:add-shebang": "echo '#!/usr/bin/env node' | cat - ./dist/index.js > temp && mv temp ./dist/index.js && chmod +x ./dist/index.js",
"build": "npm run build:cleanup && npm run build:app && npm run build:cli && npm run build:copy-app-dist && npm run build:add-shebang",
"build": "npm run build:app && npm run build:cli && npm run build:copy-app-dist",
"start": "node dist/index.js",
"npm:publish": "npm publish",
"release": "npx release-it"
Expand Down
15 changes: 12 additions & 3 deletions packages/cli/src/helpers/fileSystem/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,20 @@ export function writeFilesToDirectory(
if (existsSync(dir)) {
rmSync(dir, { recursive: true });
}
mkdirSync(dir, { recursive: true });

for (const { path, content } of files.values()) {
const fullPath = join(dir, path);
mkdirSync(dirname(fullPath), { recursive: true });
writeFileSync(fullPath, content);
try {
mkdirSync(dirname(fullPath), { recursive: true });
writeFileSync(fullPath, content);
} catch (error) {
if (error instanceof Error) {
console.error(`Failed to write file ${fullPath}: ${error.message}`);
throw new Error(
`Failed to write file ${fullPath}. Check permissions and try again.`,
);
}
throw error;
}
}
}
1 change: 1 addition & 0 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node
import { initCli } from "./cli/index.js";

// remove all warning.
Expand Down
Loading