Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
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: 23 additions & 16 deletions .github/workflows/general.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ jobs:
name: binaries
path: dpkit/compile/build
- name: Test Binaries
run: unzip -j dpkit/compile/build/*linux*.zip "dp*" && ./dp --version
run: |
unzip -j dpkit/compile/build/*linux-x64.zip "dp*"
./dp --version

services:
postgres:
Expand Down Expand Up @@ -120,12 +122,14 @@ jobs:
with:
name: binaries
path: dpkit/compile/build
# - name: Test Binaries
# run: unzip -j dpkit/compile/build/*macos*.zip "dp*" && ./dp --version
- name: Test Binaries
run: |
unzip -j dpkit/compile/build/*macos-arm64.zip "dp*"
./dp --version

test-windows:
needs: [test-compile]
runs-on: macos-latest
runs-on: windows-latest

steps:
- name: Checkout Repo
Expand All @@ -143,20 +147,25 @@ jobs:
run: pnpm ci:install
- name: Build Packages
run: pnpm build
- name: Test Packages
run: pnpm test
- name: Download Binaries
uses: actions/download-artifact@v5
with:
name: binaries
path: dpkit/compile/build
# - name: Test Packages
# run: pnpm win:test
# - name: Download Binaries
# uses: actions/download-artifact@v5
# with:
# name: binaries
# path: dpkit/compile/build
# TODO: Enable Windows tests
# - name: Test Binaries
# run: unzip -j dpkit/compile/build/*windows*.zip "dp*" && ./dp.exe --version
# run: |
# Expand-Archive dpkit\compile\build\*windows*.zip
# $exe = Get-ChildItem -Recurse -Name "dp.exe" | Select-Object -First 1
# icacls ".\$exe" /grant Everyone:F
# & ".\$exe" --version

# We have to split the release step because for some reason
# using semantic-release before compilation inflates the binary sizes
release-draft:
# needs: [test-linux, test-macos, test-windows]
needs: [test-linux, test-macos, test-windows]
if: github.event_name == 'push'
runs-on: ubuntu-latest

Expand Down Expand Up @@ -224,9 +233,7 @@ jobs:
- name: Publish Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.release-draft.outputs.version }}
files: dpkit/compile/build/*.zip
make_latest: true
draft: false
tag_name: v${{ needs.release-draft.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion all/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export * from "@dpkit/github"
export * from "@dpkit/inline"
export * from "@dpkit/table"
export * from "@dpkit/zenodo"
export * from "@dpkit/zip"

// TODO: Enable after migrated away from yauzl-promise (uses native crc32)
//export * from "@dpkit/zip"

export * from "./dialect/index.ts"
export * from "./package/index.ts"
Expand Down
6 changes: 4 additions & 2 deletions all/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import { ParquetPlugin } from "@dpkit/parquet"
import type { TablePlugin } from "@dpkit/table"
import { XlsxPlugin } from "@dpkit/xlsx"
import { ZenodoPlugin } from "@dpkit/zenodo"
import { ZipPlugin } from "@dpkit/zip"

// TODO: Enable after migrated away from yauzl-promise (uses native crc32)
//import { ZipPlugin } from "@dpkit/zip"

export class Dpkit {
plugins: TablePlugin[] = []
Expand All @@ -30,7 +32,7 @@ dpkit.register(DatahubPlugin)
dpkit.register(GithubPlugin)
dpkit.register(ZenodoPlugin)
dpkit.register(FolderPlugin)
dpkit.register(ZipPlugin)
//dpkit.register(ZipPlugin)

// Table functions
dpkit.register(ArrowPlugin)
Expand Down
4 changes: 2 additions & 2 deletions core/general/descriptor/load.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ describe("loadDescriptor", () => {
})

it("throws error for unsupported URL protocol", async () => {
const testUrl = "file:///path/to/schema.json"
const testUrl = "bad:///path/to/schema.json"

await expect(loadDescriptor(testUrl)).rejects.toThrow(
"Unsupported remote protocol: file:",
"Unsupported remote protocol: bad",
)
})

Expand Down
5 changes: 3 additions & 2 deletions core/general/descriptor/load.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { node } from "../node.ts"
import { getProtocol } from "../path.ts"
import { getBasepath, isRemotePath } from "../path.ts"
import { parseDescriptor } from "./process/parse.ts"

Expand All @@ -23,12 +24,12 @@ export async function loadDescriptor(
: await loadLocalDescriptor(path)
}

const ALLOWED_REMOTE_PROTOCOLS = ["http:", "https:", "ftp:", "ftps:"]
const ALLOWED_REMOTE_PROTOCOLS = ["http", "https", "ftp", "ftps"]

async function loadRemoteDescriptor(path: string) {
const url = new URL(path)

const protocol = url.protocol.toLowerCase()
const protocol = getProtocol(path)
if (!ALLOWED_REMOTE_PROTOCOLS.includes(protocol)) {
throw new Error(`Unsupported remote protocol: ${protocol}`)
}
Expand Down
14 changes: 7 additions & 7 deletions core/general/path.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { relative } from "node:path"
import { join, relative } from "node:path"
import { describe, expect, it } from "vitest"
import {
denormalizePath,
Expand Down Expand Up @@ -28,7 +28,7 @@ describe("isRemotePath", () => {
{
description: "file URL",
path: "file:///path/to/file.txt",
isRemote: true,
isRemote: false,
},
{
description: "absolute path",
Expand Down Expand Up @@ -153,12 +153,12 @@ describe("getBasepath", () => {
{
description: "local file path",
path: "some/path/to/file.txt",
basepath: "some/path/to",
basepath: join("some", "path", "to"),
},
{
description: "local path with no file",
path: "some/path/to/",
basepath: "some/path",
basepath: join("some", "path"),
},
{
description: "root level file",
Expand All @@ -176,13 +176,13 @@ describe("normalizePath", () => {
description: "local path without basepath",
path: "path/to/file.txt",
basepath: undefined,
normalizedPath: "path/to/file.txt",
normalizedPath: join("path", "to", "file.txt"),
},
{
description: "local path with local basepath",
path: "file.txt",
basepath: "path/to",
normalizedPath: "path/to/file.txt",
normalizedPath: join("path", "to", "file.txt"),
},
{
description: "remote path",
Expand Down Expand Up @@ -212,7 +212,7 @@ describe("normalizePath", () => {
description: "path with empty basepath",
path: "path/to/file.txt",
basepath: "",
normalizedPath: "path/to/file.txt",
normalizedPath: join("path", "to", "file.txt"),
},
])("$description", ({ path, basepath, normalizedPath }) => {
expect(normalizePath(path, { basepath })).toEqual(normalizedPath)
Expand Down
17 changes: 10 additions & 7 deletions core/general/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ import slugify from "@sindresorhus/slugify"
import { node } from "./node.ts"

export function isRemotePath(path: string) {
try {
new URL(path)
return true
} catch {
return false
}
const protocol = getProtocol(path)
return protocol !== "file"
}

export function getName(filename?: string) {
Expand All @@ -26,7 +22,14 @@ export function getName(filename?: string) {
export function getProtocol(path: string) {
try {
const url = new URL(path)
return url.protocol.replace(":", "")
const protocol = url.protocol.replace(":", "")

// Handle Windows drive letters
if (protocol.length < 2) {
return "file"
}

return protocol
} catch {
return "file"
}
Expand Down
14 changes: 13 additions & 1 deletion dpkit/scripts/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,24 @@ const targets = [
polars: "nodejs-polars-linux-x64-gnu",
libsql: "libsql-linux-x64-gnu",
},
{
name: "bun-linux-arm64",
dpkit: "linux-arm64",
polars: "nodejs-polars-linux-arm64-gnu",
libsql: "libsql-linux-arm64-gnu",
},
{
name: "bun-darwin-x64",
dpkit: "macos-x64",
polars: "nodejs-polars-darwin-x64",
libsql: "libsql-darwin-x64",
},
{
name: "bun-darwin-arm64",
dpkit: "macos-arm64",
polars: "nodejs-polars-darwin-arm64",
libsql: "libsql-darwin-arm64",
},
{
name: "bun-windows-x64",
dpkit: "windows-x64",
Expand Down Expand Up @@ -87,7 +99,7 @@ for (const target of targets) {
`

// For some reason bun creates it with no permissions
if (target.name === "bun-windows-x64") {
if (target.name.startsWith("bun-windows")) {
await $build`chmod +r ${folder}/dp.exe`
}

Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@
"ci:install": "pnpm install --ignore-scripts",
"ci:publish": "pnpm -r publish --access public --ignore-scripts --no-git-checks",
"ci:version": "pnpm -r exec pnpm version --no-git-tag-version",
"check": "pnpm run lint && pnpm run type",
"clean": "rm pnpm-lock.yaml && find . -name 'node_modules' -type d -prune -print -exec rm -rf '{}' +",
"compile": "pnpm -F dpkit compile",
"coverage": "vitest --ui",
"format": "biome check --write",
"lint": "biome check",
"prepare": "husky",
"spec": "vitest run",
"test": "pnpm check && pnpm run spec",
"test": "pnpm lint && pnpm type && pnpm spec",
"win:test": "pnpm spec",
"type": "tsc --noEmit"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@semantic-release/exec": "7.1.0",
"@types/node": "24.2.0",
"@vitest/coverage-v8": "3.1.4",
"@vitest/ui": "3.1.4",
"@vitest/coverage-v8": "3.2.4",
"@vitest/ui": "3.2.4",
"execa": "9.6.0",
"husky": "9.1.7",
"npm-check-updates": "18.0.1",
"semantic-release": "24.2.9",
"tempy": "3.1.0",
"type-fest": "^4.41.0",
"typescript": "5.9.2",
"vitest": "3.1.4"
"vitest": "3.2.4"
},
"packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
}
Loading
Loading