First upload version 0.0.1
This commit is contained in:
3
node_modules/@reflink/reflink-win32-x64-msvc/README.md
generated
vendored
Normal file
3
node_modules/@reflink/reflink-win32-x64-msvc/README.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# `reflink-win32-x64-msvc`
|
||||
|
||||
This is the **x86_64-pc-windows-msvc** binary for `reflink`
|
||||
23
node_modules/@reflink/reflink-win32-x64-msvc/package.json
generated
vendored
Normal file
23
node_modules/@reflink/reflink-win32-x64-msvc/package.json
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "@reflink/reflink-win32-x64-msvc",
|
||||
"version": "0.1.19",
|
||||
"repository": {
|
||||
"url": "https://github.com/pnpm/reflink.git",
|
||||
"type": "git",
|
||||
"directory": "win32-x64-msvc"
|
||||
},
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"main": "reflink.win32-x64-msvc.node",
|
||||
"files": [
|
||||
"reflink.win32-x64-msvc.node"
|
||||
],
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
}
|
||||
BIN
node_modules/@reflink/reflink-win32-x64-msvc/reflink.win32-x64-msvc.node
generated
vendored
Normal file
BIN
node_modules/@reflink/reflink-win32-x64-msvc/reflink.win32-x64-msvc.node
generated
vendored
Normal file
Binary file not shown.
53
node_modules/@reflink/reflink/README.md
generated
vendored
Normal file
53
node_modules/@reflink/reflink/README.md
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
# @reflink/reflink
|
||||
|
||||
[](https://www.npmjs.com/package/@reflink/reflink)
|
||||
[](https://github.com/pnpm/reflink/actions)
|
||||
|
||||
Copy-on-write file cloning for Node.js, powered by NAPI-RS and built upon [reflink-copy](https://github.com/cargo-bins/reflink-copy). This package supports a variety of platforms, including ARM and x86 architectures.
|
||||
|
||||
### Supported Platforms
|
||||
- Linux
|
||||
- MacOS
|
||||
- Windows (Server 2012+ and Windows Dev Drives)
|
||||
|
||||
## Installation
|
||||
|
||||
Just install `@reflink/reflink` using your favorite package manager:
|
||||
|
||||
```bash
|
||||
pnpm add @reflink/reflink
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
The package provides both synchronous and asynchronous methods to clone files.
|
||||
|
||||
### TypeScript Usage
|
||||
|
||||
First, import the package:
|
||||
|
||||
```typescript
|
||||
import { reflinkFileSync, reflinkFile } from '@reflink/reflink';
|
||||
```
|
||||
|
||||
#### Synchronous Method
|
||||
|
||||
```typescript
|
||||
reflinkFileSync('source.txt', 'destination.txt');
|
||||
```
|
||||
|
||||
#### Asynchronous Method
|
||||
|
||||
```typescript
|
||||
await reflinkFile('source.txt', 'destination.txt');
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
This package is tested using `vitest`. You can run the tests locally using:
|
||||
|
||||
```bash
|
||||
pnpm install
|
||||
pnpm build
|
||||
pnpm test
|
||||
```
|
||||
16
node_modules/@reflink/reflink/binding.d.ts
generated
vendored
Normal file
16
node_modules/@reflink/reflink/binding.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
/* auto-generated by NAPI-RS */
|
||||
|
||||
export declare function reflinkFile(src: string, dst: string): Promise<number | ReflinkError>
|
||||
export declare function reflinkFileSync(src: string, dst: string): number | ReflinkError
|
||||
/** Contains all properties to construct an actual error. */
|
||||
export class ReflinkError {
|
||||
message: string
|
||||
path: string
|
||||
dest: string
|
||||
code?: string
|
||||
errno?: number
|
||||
constructor(message: string, path: string, dest: string, code?: string, errno?: number)
|
||||
}
|
||||
259
node_modules/@reflink/reflink/binding.js
generated
vendored
Normal file
259
node_modules/@reflink/reflink/binding.js
generated
vendored
Normal file
@@ -0,0 +1,259 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
|
||||
/* auto-generated by NAPI-RS */
|
||||
|
||||
const { existsSync, readFileSync } = require('fs')
|
||||
const { join } = require('path')
|
||||
|
||||
const { platform, arch } = process
|
||||
|
||||
let nativeBinding = null
|
||||
let localFileExisted = false
|
||||
let loadError = null
|
||||
|
||||
function isMusl() {
|
||||
// For Node 10
|
||||
if (!process.report || typeof process.report.getReport !== 'function') {
|
||||
try {
|
||||
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
||||
return readFileSync(lddPath, 'utf8').includes('musl')
|
||||
} catch (e) {
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
const { glibcVersionRuntime } = process.report.getReport().header
|
||||
return !glibcVersionRuntime
|
||||
}
|
||||
}
|
||||
|
||||
switch (platform) {
|
||||
case 'android':
|
||||
switch (arch) {
|
||||
case 'arm64':
|
||||
localFileExisted = existsSync(join(__dirname, 'reflink.android-arm64.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./reflink.android-arm64.node')
|
||||
} else {
|
||||
nativeBinding = require('@reflink/reflink-android-arm64')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
case 'arm':
|
||||
localFileExisted = existsSync(join(__dirname, 'reflink.android-arm-eabi.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./reflink.android-arm-eabi.node')
|
||||
} else {
|
||||
nativeBinding = require('@reflink/reflink-android-arm-eabi')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported architecture on Android ${arch}`)
|
||||
}
|
||||
break
|
||||
case 'win32':
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'reflink.win32-x64-msvc.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./reflink.win32-x64-msvc.node')
|
||||
} else {
|
||||
nativeBinding = require('@reflink/reflink-win32-x64-msvc')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
case 'ia32':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'reflink.win32-ia32-msvc.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./reflink.win32-ia32-msvc.node')
|
||||
} else {
|
||||
nativeBinding = require('@reflink/reflink-win32-ia32-msvc')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
case 'arm64':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'reflink.win32-arm64-msvc.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./reflink.win32-arm64-msvc.node')
|
||||
} else {
|
||||
nativeBinding = require('@reflink/reflink-win32-arm64-msvc')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
||||
}
|
||||
break
|
||||
case 'darwin':
|
||||
localFileExisted = existsSync(join(__dirname, 'reflink.darwin-universal.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./reflink.darwin-universal.node')
|
||||
} else {
|
||||
nativeBinding = require('@reflink/reflink-darwin-universal')
|
||||
}
|
||||
break
|
||||
} catch {}
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
localFileExisted = existsSync(join(__dirname, 'reflink.darwin-x64.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./reflink.darwin-x64.node')
|
||||
} else {
|
||||
nativeBinding = require('@reflink/reflink-darwin-x64')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
case 'arm64':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'reflink.darwin-arm64.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./reflink.darwin-arm64.node')
|
||||
} else {
|
||||
nativeBinding = require('@reflink/reflink-darwin-arm64')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
||||
}
|
||||
break
|
||||
case 'freebsd':
|
||||
if (arch !== 'x64') {
|
||||
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
||||
}
|
||||
localFileExisted = existsSync(join(__dirname, 'reflink.freebsd-x64.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./reflink.freebsd-x64.node')
|
||||
} else {
|
||||
nativeBinding = require('@reflink/reflink-freebsd-x64')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
case 'linux':
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
if (isMusl()) {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'reflink.linux-x64-musl.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./reflink.linux-x64-musl.node')
|
||||
} else {
|
||||
nativeBinding = require('@reflink/reflink-linux-x64-musl')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
} else {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'reflink.linux-x64-gnu.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./reflink.linux-x64-gnu.node')
|
||||
} else {
|
||||
nativeBinding = require('@reflink/reflink-linux-x64-gnu')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'arm64':
|
||||
if (isMusl()) {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'reflink.linux-arm64-musl.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./reflink.linux-arm64-musl.node')
|
||||
} else {
|
||||
nativeBinding = require('@reflink/reflink-linux-arm64-musl')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
} else {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'reflink.linux-arm64-gnu.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./reflink.linux-arm64-gnu.node')
|
||||
} else {
|
||||
nativeBinding = require('@reflink/reflink-linux-arm64-gnu')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'arm':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'reflink.linux-arm-gnueabihf.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./reflink.linux-arm-gnueabihf.node')
|
||||
} else {
|
||||
nativeBinding = require('@reflink/reflink-linux-arm-gnueabihf')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
|
||||
}
|
||||
|
||||
if (!nativeBinding) {
|
||||
if (loadError) {
|
||||
throw loadError
|
||||
}
|
||||
throw new Error(`Failed to load native binding`)
|
||||
}
|
||||
|
||||
const { ReflinkError, reflinkFile, reflinkFileSync } = nativeBinding
|
||||
|
||||
module.exports.ReflinkError = ReflinkError
|
||||
module.exports.reflinkFile = reflinkFile
|
||||
module.exports.reflinkFileSync = reflinkFileSync
|
||||
14
node_modules/@reflink/reflink/index.d.ts
generated
vendored
Normal file
14
node_modules/@reflink/reflink/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Create a reflink asynchronously.
|
||||
* @param {String} src Source of the reflink.
|
||||
* @param {String} dst Target of the reflink.
|
||||
* @returns {Promise.<number>}
|
||||
*/
|
||||
export function reflinkFile(src: string, dst: string): Promise<number>;
|
||||
/**
|
||||
* Create a reflink asynchronously.
|
||||
* @param {String} src Source of the reflink.
|
||||
* @param {String} dst Target of the reflink.
|
||||
* @returns {number}
|
||||
*/
|
||||
export function reflinkFileSync(src: string, dst: string): number;
|
||||
51
node_modules/@reflink/reflink/index.js
generated
vendored
Normal file
51
node_modules/@reflink/reflink/index.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
//@ts-check
|
||||
const binding = require('./binding');
|
||||
|
||||
/**
|
||||
* Throw a reflink error.
|
||||
* @param {binding.ReflinkError} reflinkError Error properties.
|
||||
* @returns {Error & binding.ReflinkError}
|
||||
*/
|
||||
function createReflinkError(reflinkError) {
|
||||
const error = new Error(reflinkError.message)
|
||||
return Object.assign(error, {
|
||||
path: reflinkError.path,
|
||||
dest: reflinkError.dest,
|
||||
code: reflinkError.code,
|
||||
errno: reflinkError.errno,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Either throw the reflink error or return the number.
|
||||
* @param {number | binding.ReflinkError} result Result of the binding function.
|
||||
* @returns {number}
|
||||
*/
|
||||
function handleReflinkResult(result) {
|
||||
if (typeof result === 'number') {
|
||||
return result;
|
||||
} else {
|
||||
throw createReflinkError(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a reflink asynchronously.
|
||||
* @param {String} src Source of the reflink.
|
||||
* @param {String} dst Target of the reflink.
|
||||
* @returns {Promise.<number>}
|
||||
*/
|
||||
const reflinkFile = (src, dst) => binding.reflinkFile(src, dst).then(handleReflinkResult);
|
||||
|
||||
/**
|
||||
* Create a reflink asynchronously.
|
||||
* @param {String} src Source of the reflink.
|
||||
* @param {String} dst Target of the reflink.
|
||||
* @returns {number}
|
||||
*/
|
||||
const reflinkFileSync = (src, dst) => handleReflinkResult(binding.reflinkFileSync(src, dst));
|
||||
|
||||
module.exports = {
|
||||
reflinkFile,
|
||||
reflinkFileSync,
|
||||
};
|
||||
63
node_modules/@reflink/reflink/package.json
generated
vendored
Normal file
63
node_modules/@reflink/reflink/package.json
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "@reflink/reflink",
|
||||
"version": "0.1.19",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"url": "https://github.com/pnpm/reflink"
|
||||
},
|
||||
"napi": {
|
||||
"name": "reflink",
|
||||
"triples": {
|
||||
"additional": [
|
||||
"aarch64-apple-darwin",
|
||||
"aarch64-unknown-linux-gnu",
|
||||
"aarch64-unknown-linux-musl",
|
||||
"aarch64-pc-windows-msvc",
|
||||
"x86_64-unknown-linux-musl"
|
||||
]
|
||||
},
|
||||
"npmClient": "npm"
|
||||
},
|
||||
"files": [
|
||||
"binding.js",
|
||||
"binding.d.ts",
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@napi-rs/cli": "^2.16.3",
|
||||
"@types/node": "^20.8.0",
|
||||
"chalk": "^5.3.0",
|
||||
"rimraf": "^5.0.5",
|
||||
"typescript": "^5.2.2",
|
||||
"vitest": "^0.34.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
},
|
||||
"scripts": {
|
||||
"artifacts": "napi artifacts",
|
||||
"build": "pnpm gen-dts && napi build --js binding.js --dts binding.d.ts --platform --release",
|
||||
"build:debug": "pnpm gen-dts && napi build --js binding.js --dts binding.d.ts --platform",
|
||||
"gen-dts": "tsc --checkJs index.js --declaration --emitDeclarationOnly",
|
||||
"prepublishOnly": "napi prepublish -t npm",
|
||||
"pretest": "pnpm build",
|
||||
"test": "cargo t && vitest && rimraf -g __reflink-tests-*",
|
||||
"bench": "node benchmark.mjs",
|
||||
"universal": "napi universal",
|
||||
"version": "napi version"
|
||||
},
|
||||
"packageManager": "pnpm@9.12.3",
|
||||
"optionalDependencies": {
|
||||
"@reflink/reflink-win32-x64-msvc": "0.1.19",
|
||||
"@reflink/reflink-darwin-x64": "0.1.19",
|
||||
"@reflink/reflink-linux-x64-gnu": "0.1.19",
|
||||
"@reflink/reflink-darwin-arm64": "0.1.19",
|
||||
"@reflink/reflink-linux-arm64-gnu": "0.1.19",
|
||||
"@reflink/reflink-linux-arm64-musl": "0.1.19",
|
||||
"@reflink/reflink-win32-arm64-msvc": "0.1.19",
|
||||
"@reflink/reflink-linux-x64-musl": "0.1.19"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user