fix(build): work with npm 3
This commit is contained in:
43
packages/xo-vmdk-to-vhd/.gitignore
vendored
43
packages/xo-vmdk-to-vhd/.gitignore
vendored
@@ -1,39 +1,6 @@
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
||||
### Node template
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
/.nyc_output/
|
||||
/dist/
|
||||
/node_modules/
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules
|
||||
jspm_packages
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
npm-debug.log
|
||||
npm-debug.log.*
|
||||
|
||||
5
packages/xo-vmdk-to-vhd/.mocha.js
Normal file
5
packages/xo-vmdk-to-vhd/.mocha.js
Normal file
@@ -0,0 +1,5 @@
|
||||
Error.stackTraceLimit = 100
|
||||
|
||||
try { require('trace') } catch (_) {}
|
||||
try { require('clarify') } catch (_) {}
|
||||
try { require('source-map-support/register') } catch (_) {}
|
||||
1
packages/xo-vmdk-to-vhd/.mocha.opts
Normal file
1
packages/xo-vmdk-to-vhd/.mocha.opts
Normal file
@@ -0,0 +1 @@
|
||||
--require ./.mocha.js
|
||||
10
packages/xo-vmdk-to-vhd/.npmignore
Normal file
10
packages/xo-vmdk-to-vhd/.npmignore
Normal file
@@ -0,0 +1,10 @@
|
||||
/examples/
|
||||
example.js
|
||||
example.js.map
|
||||
*.example.js
|
||||
*.example.js.map
|
||||
|
||||
/test/
|
||||
/tests/
|
||||
*.spec.js
|
||||
*.spec.js.map
|
||||
@@ -2,7 +2,9 @@ language: node_js
|
||||
sudo: required
|
||||
dist: trusty
|
||||
node_js:
|
||||
- "4.4"
|
||||
- 'stable'
|
||||
- '4'
|
||||
- '0.12'
|
||||
env:
|
||||
- CXX=g++-4.8
|
||||
addons:
|
||||
|
||||
@@ -1,37 +1,75 @@
|
||||
# xo-vmdk-to-vhd
|
||||
[](https://travis-ci.org/vatesfr/xo-vmdk-to-vhd)
|
||||
JS lib streaming a vmdk file to a vhd
|
||||
# xo-vmdk-to-vhd [](https://travis-ci.org/vatesfr/xo-vmdk-to-vhd)
|
||||
|
||||
To install:
|
||||
> JS lib streaming a vmdk file to a vhd
|
||||
|
||||
## Install
|
||||
|
||||
Installation of the [npm package](https://npmjs.org/package/xo-vmdk-to-vhd):
|
||||
|
||||
```
|
||||
$ npm install xo-vmdk-to-vhd
|
||||
> npm install --save xo-vmdk-to-vhd
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
To convert a VMDK stream to a Fixed VHD stream without buffering the entire input or output:
|
||||
```
|
||||
import convertFromVMDK from 'xo-vmdk-to-vhd'
|
||||
import {createReadStream, createWriteStream} from 'fs-promise'
|
||||
|
||||
const pipe = (await convertFromVMDK(fs.createReadStream(vmdkFileName))).pipe(fs.createWriteStream(vhdFileName))
|
||||
await new Promise((resolve, reject) => {
|
||||
pipe.on('finish', resolve)
|
||||
pipe.on('error', reject)
|
||||
})
|
||||
```js
|
||||
import convertFromVMDK from 'xo-vmdk-to-vhd'
|
||||
import {createReadStream, createWriteStream} from 'fs'
|
||||
|
||||
(async () => {
|
||||
const stream = await convertFromVMDK(fs.createReadStream(vmdkFileName))
|
||||
|
||||
stream.pipe(fs.createWriteStream(vhdFileName))
|
||||
})()
|
||||
```
|
||||
|
||||
or:
|
||||
|
||||
```
|
||||
var converter = require('xo-vmdk-to-vhd').default;
|
||||
```js
|
||||
var convertFromVMDK = require('xo-vmdk-to-vhd').default
|
||||
var createReadStream = require('fs').createReadStream
|
||||
var createWriteStream = require('fs').createWriteStream
|
||||
|
||||
var fs = require('fs-promise')
|
||||
var p = converter(fs.createReadStream(vmdkFileName));
|
||||
p.then(function(stream) {
|
||||
var pipe = stream.pipe(fs.createWriteStream(vhdFileName));
|
||||
return new Promise(function(resolve, reject) {
|
||||
pipe.on('finish', resolve)
|
||||
pipe.on('error', reject)
|
||||
});
|
||||
});
|
||||
convertFromVMDK(fs.createReadStream(vmdkFileName)).then(function (stream) {
|
||||
stream.pipe(fs.createWriteStream(vhdFileName))
|
||||
})
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
### Installing dependencies
|
||||
|
||||
```
|
||||
> npm install
|
||||
```
|
||||
|
||||
### Compilation
|
||||
|
||||
The sources files are watched and automatically recompiled on changes.
|
||||
|
||||
```
|
||||
> npm run dev
|
||||
```
|
||||
|
||||
### Tests
|
||||
|
||||
```
|
||||
> npm run test-dev
|
||||
```
|
||||
|
||||
## Contributions
|
||||
|
||||
Contributions are *very* welcomed, either on the documentation or on
|
||||
the code.
|
||||
|
||||
You may:
|
||||
|
||||
- report any [issue](https://github.com/vatesfr/xo-vmdk-to-vhd/issues/)
|
||||
you've encountered;
|
||||
- fork and create a pull request.
|
||||
|
||||
## License
|
||||
|
||||
AGPLv3.0 © [Vates SAS](https://vates.fr)
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
'use strict'
|
||||
require('babel-polyfill')
|
||||
module.exports = {default: require('./lib/vhd-write').convertFromVMDK}
|
||||
@@ -2,54 +2,62 @@
|
||||
"name": "xo-vmdk-to-vhd",
|
||||
"version": "0.0.2",
|
||||
"license": "AGPL-3.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/vatesfr/xo-vmdk-to-vhd/issues"
|
||||
},
|
||||
"description": "JS lib streaming a vmdk file to a vhd",
|
||||
"keywords": [
|
||||
"vhd",
|
||||
"vmdk"
|
||||
],
|
||||
"homepage": "https://github.com/vatesfr/xo-vmdk-to-vhd/",
|
||||
"bugs": "https://github.com/vatesfr/xo-vmdk-to-vhd/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/vatesfr/xo-vmdk-to-vhd.git"
|
||||
},
|
||||
"keywords": [
|
||||
"xen",
|
||||
"orchestra",
|
||||
"xen-orchestra"
|
||||
"preferGlobal": false,
|
||||
"main": "dist/",
|
||||
"bin": {},
|
||||
"files": [
|
||||
"dist/"
|
||||
],
|
||||
"preferGlobal": true,
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"config.json",
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "NODE_ENV=production babel --source-maps --out-dir=lib/ src/",
|
||||
"depcheck": "dependency-check ./package.json",
|
||||
"dev": "babel --watch --source-maps --out-dir=dist/ src/",
|
||||
"test": "mocha --compilers js:babel-core/register --reporter spec --require babel-polyfill && npm run lint && npm run build",
|
||||
"lint": "standard",
|
||||
"prepublish": "npm run build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.0.0",
|
||||
"babel-core": "^6.3.17",
|
||||
"babel-eslint": "^6.1.2",
|
||||
"babel-preset-es2015": "^6.9.0",
|
||||
"babel-preset-stage-0": "^6.5.0",
|
||||
"babel-register": "^6.11.6",
|
||||
"chai": "^3.5.0",
|
||||
"mocha": "^3.0.0",
|
||||
"standard": "^7.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-polyfill": "^6.9.1",
|
||||
"babel-runtime": "^6.11.6",
|
||||
"child-process-promise": "^2.0.3",
|
||||
"deflate-js": "^0.2.3",
|
||||
"fs-promise": "^0.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.11.4",
|
||||
"babel-eslint": "^6.1.2",
|
||||
"babel-plugin-transform-runtime": "^6.12.0",
|
||||
"babel-preset-es2015": "^6.13.2",
|
||||
"babel-preset-stage-0": "^6.5.0",
|
||||
"chai": "^3.5.0",
|
||||
"clarify": "^2.0.0",
|
||||
"dependency-check": "^2.6.0",
|
||||
"ghooks": "^1.3.2",
|
||||
"mocha": "^3.0.2",
|
||||
"nyc": "^8.1.0",
|
||||
"source-map-support": "^0.4.2",
|
||||
"standard": "^7.1.2",
|
||||
"trace": "^2.3.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "NODE_ENV=production babel --source-maps --out-dir=dist/ src/",
|
||||
"depcheck": "dependency-check ./package.json",
|
||||
"dev": "babel --watch --source-maps --out-dir=dist/ src/",
|
||||
"dev-test": "mocha --opts .mocha.opts --watch --reporter=min \"dist/**/*.spec.js\"",
|
||||
"lint": "standard",
|
||||
"posttest": "npm run lint && npm run depcheck",
|
||||
"prepublish": "npm run build",
|
||||
"test": "nyc mocha --opts .mocha.opts \"dist/**/*.spec.js\""
|
||||
},
|
||||
"babel": {
|
||||
"plugins": [
|
||||
"transform-runtime"
|
||||
],
|
||||
"presets": [
|
||||
"stage-0",
|
||||
"es2015"
|
||||
@@ -57,8 +65,13 @@
|
||||
},
|
||||
"standard": {
|
||||
"ignore": [
|
||||
"lib"
|
||||
"dist"
|
||||
],
|
||||
"parser": "babel-eslint"
|
||||
},
|
||||
"config": {
|
||||
"ghooks": {
|
||||
"commit-msg": "npm test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1
packages/xo-vmdk-to-vhd/src/index.js
Normal file
1
packages/xo-vmdk-to-vhd/src/index.js
Normal file
@@ -0,0 +1 @@
|
||||
export convertFromVMDK from './vhd-write'
|
||||
@@ -1,20 +1,21 @@
|
||||
'use strict'
|
||||
|
||||
import {assert} from 'chai'
|
||||
import {describe, it} from 'mocha'
|
||||
import {readFile} from 'fs-promise'
|
||||
import {createWriteStream} from 'fs'
|
||||
import {describe, it} from 'mocha'
|
||||
import {exec} from 'child-process-promise'
|
||||
import {readFile} from 'fs-promise'
|
||||
|
||||
import {
|
||||
createFooter,
|
||||
createDynamicDiskHeader,
|
||||
computeChecksum,
|
||||
computeGeometryForSize,
|
||||
createDynamicDiskHeader,
|
||||
createFooter,
|
||||
ReadableRawVHDStream,
|
||||
VHDFile
|
||||
} from '../src/vhd-write'
|
||||
} from './vhd-write'
|
||||
|
||||
describe('VHD writing', function () {
|
||||
describe('VHD writing', () => {
|
||||
it('computeChecksum() is correct against some reference values', () => {
|
||||
// those values were taken from a file generated by qemu
|
||||
const testValue1 = '636F6E6563746978000000020001000000000000000002001F34DB9F71656D75000500035769326B0000000000019800000000000001980000030411000000030000000033B3A5E17F94433498376740246E5660'
|
||||
@@ -1,10 +1,9 @@
|
||||
'use strict'
|
||||
|
||||
import {assert} from 'chai'
|
||||
import {createReadStream, readFile} from 'fs-promise'
|
||||
import {describe, it} from 'mocha'
|
||||
import {exec} from 'child-process-promise'
|
||||
import {createReadStream, readFile} from 'fs-promise'
|
||||
import {VirtualBuffer} from '../src/virtual-buffer'
|
||||
|
||||
import {VirtualBuffer} from './virtual-buffer'
|
||||
|
||||
describe('Virtual Buffer', function () {
|
||||
it('can read a file correctly', async () => {
|
||||
@@ -1,12 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
import {assert} from 'chai'
|
||||
import {createReadStream} from 'fs-promise'
|
||||
import {describe, it} from 'mocha'
|
||||
import {exec} from 'child-process-promise'
|
||||
import {createReadStream} from 'fs-promise'
|
||||
import {VMDKDirectParser} from '../src/vmdk-read'
|
||||
|
||||
describe('VMDK reading', function () {
|
||||
import {VMDKDirectParser} from './vmdk-read'
|
||||
|
||||
describe('VMDK reading', () => {
|
||||
it('VMDKDirectParser reads OK', async () => {
|
||||
let rawFileName = 'random-data'
|
||||
let fileName = 'random-data.vmdk'
|
||||
@@ -4,10 +4,11 @@ import {assert} from 'chai'
|
||||
import {describe, it} from 'mocha'
|
||||
import {exec} from 'child-process-promise'
|
||||
import {readFile, createReadStream, createWriteStream} from 'fs-promise'
|
||||
import {readRawContent} from '../src/vmdk-read'
|
||||
import {VHDFile, convertFromVMDK} from '../src/vhd-write'
|
||||
|
||||
describe('VMDK to VHD conversion', function () {
|
||||
import {readRawContent} from './vmdk-read'
|
||||
import {VHDFile, convertFromVMDK} from './vhd-write'
|
||||
|
||||
describe('VMDK to VHD conversion', () => {
|
||||
it('can convert a random data file with readRawContent()', async () => {
|
||||
let inputRawFileName = 'random-data.raw'
|
||||
let vmdkFileName = 'random-data.vmdk'
|
||||
Reference in New Issue
Block a user