Skip to content
Open
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
2 changes: 1 addition & 1 deletion packages/plugin-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "framer-plugin-tools",
"version": "1.2.0",
"version": "1.2.1",
"description": "CLI Tools for Framer Plugins",
"type": "module",
"main": "dist/index.js",
Expand Down
13 changes: 12 additions & 1 deletion packages/plugin-tools/src/lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import os from "node:os"
import path from "node:path"
import AdmZip from "adm-zip"
import { afterEach, beforeEach, describe, expect, it } from "vitest"
import { detectPackageManager, zipPluginDistribution } from "./lib"
import { detectPackageManager, normalizeZipEntryPaths, zipPluginDistribution } from "./lib"

describe("detectPackageManager", () => {
let tmpDir: string
Expand Down Expand Up @@ -203,6 +203,17 @@ describe("zipPluginDistribution", () => {
expect(entries).toContain("assets/images/logo.png")
})

it("normalizes backslash entry names to use forward slashes", () => {
const zip = new AdmZip()
zip.addFile("nested\\dir\\file.txt", Buffer.from("content", "utf-8"))

normalizeZipEntryPaths(zip)

const entries = zip.getEntries().map(e => e.entryName)
expect(entries).toContain("nested/dir/file.txt")
expect(entries).not.toContain("nested\\dir\\file.txt")
})

it("returns correct zipPath", () => {
const distDir = path.join(tmpDir, "dist")
fs.mkdirSync(distDir)
Expand Down
10 changes: 10 additions & 0 deletions packages/plugin-tools/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ interface ZipPluginDistributionOptions {
zipFileName: string
}

// Normalize all entry paths to use forward slashes
export function normalizeZipEntryPaths(zip: AdmZip): void {
for (const entry of zip.getEntries()) {
if (entry.entryName.includes("\\")) {
entry.entryName = entry.entryName.replace(/\\/g, "/")
}
}
}

export function zipPluginDistribution(options: ZipPluginDistributionOptions): string {
const distPath = path.isAbsolute(options.distPath) ? options.distPath : path.join(options.cwd, options.distPath)

Expand All @@ -54,6 +63,7 @@ export function zipPluginDistribution(options: ZipPluginDistributionOptions): st
zip.addLocalFolder(distPath)
zip.deleteFile(markerFileName)
zip.addFile(markerFileName, Buffer.from("true", "utf-8"))
normalizeZipEntryPaths(zip)
zip.writeZip(zipFilePath)

return zipFilePath
Expand Down
Loading