Skip to content

Async Crypto Endeavour #12

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

Merged
merged 4 commits into from
Nov 3, 2016
Merged
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ node_modules
.node_repl_history

dist
lib
24 changes: 18 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
sudo: false
language: node_js
node_js:
- 4
- 5
matrix:
include:
- node_js: 4
env: CXX=g++-4.8
- node_js: 6
env:
- SAUCE=true
- CXX=g++-4.8
- node_js: stable
env: CXX=g++-4.8

# Make sure we have new NPM.
before_install:
Expand All @@ -13,12 +20,17 @@ script:
- npm test
- npm run coverage

addons:
firefox: 'latest'

before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start

after_success:
- npm run coverage-publish

addons:
firefox: 'latest'
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
[![Coverage Status](https://coveralls.io/repos/github/ipfs/js-ipfs-unixfs/badge.svg?branch=master)](https://coveralls.io/github/ipfs/js-ipfs-unixfs?branch=master)
[![Dependency Status](https://david-dm.org/ipfs/js-ipfs-unixfs.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-unixfs)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square)
![](https://img.shields.io/badge/Node.js-%3E%3D4.0.0-orange.svg?style=flat-square)

[![Sauce Test Status](https://saucelabs.com/browser-matrix/js-ipfs-unixfs.svg)](https://saucelabs.com/u/js-ipfs-unixfs)

> JavaScript implementation of IPFS' unixfs (a Unix FileSystem representation on top of a MerkleDAG)

Expand Down
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
"name": "ipfs-unixfs",
"version": "0.1.4",
"description": "JavaScript implementation of IPFS' unixfs (a Unix FileSystem representation on top of a MerkleDAG)",
"main": "lib/index.js",
"jsnext:main": "src/index.js",
"main": "src/index.js",
"browser": {
"fs": false
},
"scripts": {
"test": "aegir-test",
"test:node": "aegir-test node",
Expand All @@ -28,14 +30,17 @@
"bugs": {
"url": "https://github.com/ipfs/js-ipfs-unixfs/issues"
},
"engines": {
"node": ">=4.0.0"
},
"homepage": "https://github.com/ipfs/js-ipfs-unixfs#readme",
"devDependencies": {
"aegir": "^2.1.1",
"aegir": "^9.1.0",
"chai": "^3.5.0",
"pre-commit": "^1.1.2"
"pre-commit": "^1.1.3"
},
"dependencies": {
"protocol-buffers": "^3.1.5"
"protocol-buffers": "^3.1.6"
},
"pre-commit": [
"lint",
Expand Down
18 changes: 0 additions & 18 deletions protos/unixfs.proto

This file was deleted.

5 changes: 1 addition & 4 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
'use strict'

const fs = require('fs')
const path = require('path')
const protobuf = require('protocol-buffers')
const schema = fs.readFileSync(path.resolve(__dirname, '../protos/unixfs.proto'))
const pb = protobuf(schema)
const pb = protobuf(require('./unixfs.proto'))
// encode/decode
const unixfsData = pb.Data
// const unixfsMetadata = pb.MetaData // encode/decode
Expand Down
20 changes: 20 additions & 0 deletions src/unixfs.proto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'

module.exports = `message Data {
enum DataType {
Raw = 0;
Directory = 1;
File = 2;
Metadata = 3;
Symlink = 4;
}

required DataType Type = 1;
optional bytes Data = 2;
optional uint64 filesize = 3;
repeated uint64 blocksizes = 4;
}

message Metadata {
required string MimeType = 1;
}`
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 12 additions & 12 deletions test/unixfs-format.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
'use strict'

const expect = require('chai').expect
const fs = require('fs')
const path = require('path')
const loadFixture = require('aegir/fixtures')

const UnixFS = require('../src')

const raw = loadFixture(__dirname, 'fixtures/raw.unixfs')
const directory = loadFixture(__dirname, 'fixtures/directory.unixfs')
const file = loadFixture(__dirname, 'fixtures/file.txt.unixfs')
const symlink = loadFixture(__dirname, 'fixtures/symlink.txt.unixfs')

describe('unixfs-format', () => {
it('raw', (done) => {
const data = new UnixFS('raw', new Buffer('bananas'))
Expand Down Expand Up @@ -93,7 +97,6 @@ describe('unixfs-format', () => {

describe('interop', () => {
it('raw', (done) => {
const raw = fs.readFileSync(path.join(__dirname, '/test-data/raw.unixfs'))
const unmarsheled = UnixFS.unmarshal(raw)
expect(unmarsheled.data).to.deep.equal(new Buffer('Hello UnixFS\n'))
expect(unmarsheled.type).to.equal('file')
Expand All @@ -102,33 +105,30 @@ describe('unixfs-format', () => {
})

it('directory', (done) => {
const raw = fs.readFileSync(path.join(__dirname, '/test-data/directory.unixfs'))
const unmarsheled = UnixFS.unmarshal(raw)
const unmarsheled = UnixFS.unmarshal(directory)
expect(unmarsheled.data).to.deep.equal(undefined)
expect(unmarsheled.type).to.equal('directory')
expect(unmarsheled.marshal()).to.deep.equal(raw)
expect(unmarsheled.marshal()).to.deep.equal(directory)
done()
})

it('file', (done) => {
const raw = fs.readFileSync(path.join(__dirname, '/test-data/file.txt.unixfs'))
const unmarsheled = UnixFS.unmarshal(raw)
const unmarsheled = UnixFS.unmarshal(file)
expect(unmarsheled.data).to.deep.equal(new Buffer('Hello UnixFS\n'))
expect(unmarsheled.type).to.equal('file')
expect(unmarsheled.marshal()).to.deep.equal(raw)
expect(unmarsheled.marshal()).to.deep.equal(file)
done()
})

it.skip('metadata', (done) => {
})

it('symlink', (done) => {
const raw = fs.readFileSync(path.join(__dirname, '/test-data/symlink.txt.unixfs'))
const unmarsheled = UnixFS.unmarshal(raw)
const unmarsheled = UnixFS.unmarshal(symlink)
expect(unmarsheled.data).to.deep.equal(new Buffer('file.txt'))
expect(unmarsheled.type).to.equal('symlink')
// TODO: waiting on https://github.com/ipfs/js-ipfs-data-importing/issues/3#issuecomment-182440079
// expect(unmarsheled.marshal()).to.deep.equal(raw)
// expect(unmarsheled.marshal()).to.deep.equal(symlink)
done()
})
})
Expand Down