Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

asset-pipe-client

Package Overview
Dependencies
Maintainers
3
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asset-pipe-client - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

39

lib/main.js

@@ -22,2 +22,4 @@ 'use strict';

const assetTypes = ['js', 'css'];
function post(options) {

@@ -42,3 +44,3 @@ const opts = {

body = JSON.parse(body);
} catch (err) {}
} catch (err) {} // eslint-disable-line no-empty
resolve({ response, body });

@@ -92,3 +94,6 @@ });

return post({
url: url.resolve(this.options.buildServerUri, endpoints.UPLOAD),
url: url.resolve(
this.options.buildServerUri,
`${endpoints.UPLOAD}/js`
),
body: writer.bundle().pipe(JSONStream.stringify()),

@@ -101,3 +106,6 @@ });

return post({
url: url.resolve(this.options.buildServerUri, endpoints.UPLOAD),
url: url.resolve(
this.options.buildServerUri,
`${endpoints.UPLOAD}/css`
),
body: writer.pipe(JSONStream.stringify()),

@@ -158,5 +166,26 @@ });

async createRemoteBundle(sources) {
async createRemoteBundle(sources, type) {
assert(
Array.isArray(sources),
`Expected argument 'sources' to be an array. Instead got ${typeof sources}`
);
assert(
sources.every(source => typeof source === 'string'),
`Expected all entries in array 'sources' to be strings. Instead got ${sources}`
);
assert(
sources.every(source => source.includes('.json')),
`Expected ALL items in array 'sources' to end with .json. Instead got ${sources}`
);
assert(
assetTypes.includes(type),
`Expected argument 'type' to be one of ${assetTypes.join(
'|'
)}. Instead got '${type}'`
);
const { response, body } = await post({
url: url.resolve(this.options.buildServerUri, endpoints.BUNDLE),
url: url.resolve(
this.options.buildServerUri,
`${endpoints.BUNDLE}/${type}`
),
body: JSON.stringify(sources),

@@ -163,0 +192,0 @@ });

2

package.json

@@ -1,1 +0,1 @@

{"name":"asset-pipe-client","version":"1.0.0","author":"Trygve Lie <post@trygve-lie.com>","files":["bin","lib"],"description":"Asset pipe client","main":"./lib/main.js","bin":"./bin/cli.js","repository":{"type":"git","url":"https://github.com/asset-pipe/asset-pipe-client.git"},"keywords":["assets"],"contributors":["Trygve Lie <post@trygve-lie.com>","Richard Walker <digitalsadhu@gmail.com>","Sveinung Røsaker <sveinung.rosaker@gmail.com>","Trygve Lie (http://www.trygve-lie.com/)","Sveinung Røsaker (https://github.com/sveisvei)","Greenkeeper (http://greenkeeper.io/)"],"bugs":{"url":"https://github.com/asset-pipe/asset-pipe-client/issues"},"license":"MIT","dependencies":{"JSONStream":"^1.3.0","asset-pipe-css-writer":"^1.0.0-alpha.1","asset-pipe-js-writer":"1.0.0-beta.5","commander":"2.10.0","is-stream":"^1.1.0","request":"^2.79.0"},"devDependencies":{"asset-pipe-test-es5a":"^1.0.0","asset-pipe-test-es5b":"^1.0.0","body-parser":"^1.18.2","commitizen":"^2.9.6","cz-conventional-changelog":"^2.0.0","eslint":"^4.9.0","eslint-config-finn":"^2.0.0","eslint-config-finn-prettier":"^3.0.1","express":"^4.16.2","husky":"^0.14.3","jest":"^21.2.1","lint-staged":"^4.2.3","prettier":"^1.7.4","projectz":"^1.4.0","semantic-release":"^8.2.0"},"scripts":{"lint:format":"eslint --fix .","lint":"eslint .","test":"jest --coverage","precommit":"lint-staged","cm":"git-cz","readme":"projectz compile","semantic-release":"semantic-release pre && npm publish && semantic-release post"},"jest":{"clearMocks":true,"coverageThreshold":{"global":{"branches":100,"functions":100,"lines":100,"statements":100}}},"lint-staged":{"*.js":["eslint --fix --config ./.eslintrc","git add"],"{package.json,README.md,LICENSE.md}":["projectz compile","git add"]},"config":{"commitizen":{"path":"cz-conventional-changelog"}},"badges":{"list":["travisci","npmversion","daviddm","daviddmdev"]},"maintainers":[]}
{"name":"asset-pipe-client","version":"2.0.0","author":"Trygve Lie <post@trygve-lie.com>","files":["bin","lib"],"description":"Asset pipe client","main":"./lib/main.js","bin":"./bin/cli.js","repository":{"type":"git","url":"https://github.com/asset-pipe/asset-pipe-client.git"},"keywords":["assets"],"contributors":["Trygve Lie <post@trygve-lie.com>","Richard Walker <digitalsadhu@gmail.com>","Sveinung Røsaker <sveinung.rosaker@gmail.com>","Trygve Lie (http://www.trygve-lie.com/)","Sveinung Røsaker (https://github.com/sveisvei)","Greenkeeper (http://greenkeeper.io/)","Richard Walker (https://github.com/digitalsadhu)"],"bugs":{"url":"https://github.com/asset-pipe/asset-pipe-client/issues"},"license":"MIT","dependencies":{"JSONStream":"^1.3.0","asset-pipe-css-writer":"^1.0.0-alpha.1","asset-pipe-js-writer":"1.0.0-beta.5","commander":"2.11.0","is-stream":"^1.1.0","request":"^2.79.0"},"devDependencies":{"asset-pipe-test-es5a":"^1.0.0","asset-pipe-test-es5b":"^1.0.0","body-parser":"^1.18.2","commitizen":"^2.9.6","cz-conventional-changelog":"^2.0.0","eslint":"^4.9.0","eslint-config-finn":"^3.0.0","eslint-config-finn-prettier":"^3.0.1","express":"^4.16.2","husky":"^0.14.3","jest":"^21.2.1","lint-staged":"^4.2.3","prettier":"^1.7.4","projectz":"^1.4.0","semantic-release":"^8.2.0"},"scripts":{"lint:format":"eslint --fix .","lint":"eslint .","test":"jest --coverage","precommit":"lint-staged","cm":"git-cz","readme":"projectz compile","semantic-release":"semantic-release pre && npm publish && semantic-release post"},"jest":{"clearMocks":true,"coverageThreshold":{"global":{"branches":100,"functions":100,"lines":100,"statements":100}}},"lint-staged":{"*.js":["eslint --fix --config ./.eslintrc","git add"],"{package.json,README.md,LICENSE.md}":["projectz compile","git add"]},"config":{"commitizen":{"path":"cz-conventional-changelog"}},"badges":{"list":["travisci","npmversion","daviddm","daviddmdev"]},"maintainers":[]}

@@ -20,7 +20,7 @@ <!-- TITLE/ -->

A client for read an [CommonJS module][commonjs] entry point and uploading it as an asset feeds to- and
triggering builds of executable asset bundles in the [asset-pipe-build-server][asset-pipe-build-server].
A client for reading an asset file entry point and uploading it as an asset feed to a [asset-pipe-build-server][asset-pipe-build-server]
and for triggering builds of executable asset bundles in the said server.
Creating asset bundles with [asset-pipe][asset-pipe] is a two step process. The first step is to upload
an asset feed to the [asset-pipe-build-server][asset-pipe-build-server]. On an upload the asset-feed
an asset feed to the [asset-pipe-build-server][asset-pipe-build-server]. On upload the asset-feed
will be persisted and the [asset-pipe-build-server][asset-pipe-build-server] will return the generated

@@ -30,10 +30,9 @@ filename of the uploaded asset-feed.

The second step is then to create a bundle out of one or multiple asset-feeds. This is done by providing
the unique ID(s) of the asset-feeds one want to use to build an asset bundle to the
the unique ID(s) of the asset-feeds one wants to use to build an asset bundle to the
[asset-pipe-build-server][asset-pipe-build-server]. The build server will then create an executable asset
bundle out of these asset-feeds and persist this. It will respond with the URL to the bundle.
This client helps with remotly triggering these steps in the [asset-pipe-build-server][asset-pipe-build-server].
This client helps with remotely triggering these steps in the [asset-pipe-build-server][asset-pipe-build-server].
## Installation

@@ -45,4 +44,2 @@

## Example I

@@ -70,9 +67,10 @@

## Example II
Build an javascript bundle out of two asset feeds:
Read a CSS file entry point and upload it as an asset-feed to the
[asset-pipe-build-server][asset-pipe-build-server]:
```js
const Client = require('asset-pipe-client');
const client = new Client({

@@ -82,6 +80,26 @@ buildServerUri: 'http://127.0.0.1:7100',

client.uploadFeed(['/path/to/styles.css'])
.then((content) => {
// content contains filename of created the asset-feed
console.log(content);
})
.catch((error) => {
console.log(error);
});
```
## Example III
Build a javascript bundle out of two asset feeds:
```js
const Client = require('asset-pipe-client');
const client = new Client({
buildServerUri: 'http://127.0.0.1:7100',
});
bundle.createRemoteBundle([
'f09a737b36b7ca19a224e0d78cc50222d636fd7af6f7913b01521590d0d7fe02.json',
'c50ca03a63650502e1b72baf4e493d2eaa0e4aa38aa2951825e101b1d6ddb68b.json'
])
'f09a737b36b7ca19a224e0d78cc50222d636fd7af6f7913b01521590d0d7fe02.json',
'c50ca03a63650502e1b72baf4e493d2eaa0e4aa38aa2951825e101b1d6ddb68b.json'
], 'js')
.then((content) => {

@@ -96,12 +114,35 @@ // content contains URI to the created bundle

## Example IIII
Build a CSS bundle out of two asset feeds:
```js
const Client = require('asset-pipe-client');
const client = new Client({
buildServerUri: 'http://127.0.0.1:7100',
});
bundle.createRemoteBundle([
'f09a737b36b7ca19a224e0d78cc50222d636fd7af6f7913b01521590d0d7fe02.json',
'c50ca03a63650502e1b72baf4e493d2eaa0e4aa38aa2951825e101b1d6ddb68b.json'
], 'css')
.then((content) => {
// content contains URI to the created bundle
console.log(content);
})
.catch((error) => {
console.log(error);
});
```
## API
Under the hood, the [asset-pipe][asset-pipe] project build on [browserify][Browserify]. Multiple methods
in this module are therefor underlaying Browserify methods where all features found in Browserify can
Under the hood, when working with javascript, the [asset-pipe][asset-pipe] project builds on [browserify][Browserify].
Multiple methods in this module are therefor underlaying Browserify methods where all features found in Browserify can
be used. Such methods will in this documentation point to the related documentation in Browserify.
This module have the following API:
When working with CSS the underlying POST CSS is used but the implementation is not exposed so there are no additional supported methods.
This module has the following API:
### constructor(options)

@@ -116,2 +157,3 @@

Same as the [Browserify transform][browserify-transform] method.
*NOTE:* Only applicable when uploading javascript feeds.

@@ -121,12 +163,13 @@ ### plugin()

Same as the [Browserify plugin][browserify-plugin] method.
*NOTE:* Only applicable when uploading javascript feeds.
### uploadFeed(files)
Read the [CommonJS module][commonjs] entry point and uploads it as an asset feeds to the [asset-pipe-build-server][asset-pipe-build-server].
Read the [CommonJS module][commonjs] or CSS file entry point and uploads it as an asset feed to the [asset-pipe-build-server][asset-pipe-build-server].
* `files` - Array - List of CommonJS module entry points - Same as `files` in the [Browserify constructor][browserify-opts]
* `files` - Array - Either list of CommonJS module entry points - Same as `files` in the [Browserify constructor][browserify-opts] OR list of paths to CSS files
Returns a promise.
### createRemoteBundle(feeds)
### createRemoteBundle(feeds, type)

@@ -136,9 +179,8 @@ Creates an asset bundle on the [asset-pipe-build-server][asset-pipe-build-server].

* `feeds` - Array - List of asset-feed filenames.
* `type` - string - Either 'js' or 'css'
## Transpilers
Since [asset-pipe][asset-pipe] is built on [browserify][Browserify] under the hood, its fully possible
to take advantage of the different transpiers available for [browserify][Browserify].
to take advantage of the different transpiers available for [browserify][Browserify] when working with javascript.

@@ -145,0 +187,0 @@ As an example, here is how Babel is applied:

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc