New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

postcss-font-grabber

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-font-grabber - npm Package Compare versions

Comparing version 1.0.7 to 2.0.0-alpha.1

dist/contracts/index.d.ts

55

dist/index.js

@@ -1,37 +0,20 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const postcss_1 = __importDefault(require("postcss"));
const font_grabber_1 = require("./font-grabber");
const functions_1 = require("./font-grabber/functions");
function makeInstance(options) {
if (options === undefined) {
throw new Error(`You must specify plugin options.`);
}
return new font_grabber_1.FontGrabber(functions_1.parseOptions(options));
}
exports.makeInstance = makeInstance;
const plugin = postcss_1.default.plugin('postcss-font-grabber', options => {
return makeInstance(options).makeTransformer();
});
var _postcss = require('postcss');
var _postcss2 = _interopRequireDefault(_postcss);
var _fontGrabber = require('./lib/font-grabber');
var _fontGrabber2 = _interopRequireDefault(_fontGrabber);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//
// Make plugin instance.
//
/**
* Postcss Font Grabber
*
* @license Apache 2.0
* @copyright (c) 2016, AaronJan
* @author AaronJan <https://github.com/AaronJan/postcss-font-grabber>
*/
var plugin = _postcss2.default.plugin('postcss-font-grabber', function (opts) {
return _fontGrabber2.default.makePluginHandler(opts);
});
//
// Expose.
//
exports.default = plugin;
module.exports = exports['default'];
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFRQTs7OztBQUNBOzs7Ozs7QUFHQTtBQUNBO0FBQ0E7QUFkQTs7Ozs7Ozs7QUFlQSxJQUFNLFNBQVMsa0JBQVEsTUFBUixDQUFlLHNCQUFmLEVBQXVDLFVBQUMsSUFBRCxFQUFVO0FBQzlELFNBQU8sc0JBQVksaUJBQVosQ0FBOEIsSUFBOUIsQ0FBUDtBQUNELENBRmMsQ0FBZjs7QUFJQTtBQUNBO0FBQ0E7a0JBQ2UsTSIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxyXG4gKiBQb3N0Y3NzIEZvbnQgR3JhYmJlclxyXG4gKlxyXG4gKiBAbGljZW5zZSAgICAgICAgQXBhY2hlIDIuMFxyXG4gKiBAY29weXJpZ2h0ICAoYykgMjAxNiwgQWFyb25KYW5cclxuICogQGF1dGhvciAgICAgICAgIEFhcm9uSmFuIDxodHRwczovL2dpdGh1Yi5jb20vQWFyb25KYW4vcG9zdGNzcy1mb250LWdyYWJiZXI+XHJcbiAqL1xyXG5cclxuaW1wb3J0IHBvc3Rjc3MgZnJvbSAncG9zdGNzcyc7XHJcbmltcG9ydCBGb250R3JhYmJlciBmcm9tICcuL2xpYi9mb250LWdyYWJiZXInO1xyXG5cclxuXHJcbi8vXHJcbi8vIE1ha2UgcGx1Z2luIGluc3RhbmNlLlxyXG4vL1xyXG5jb25zdCBwbHVnaW4gPSBwb3N0Y3NzLnBsdWdpbigncG9zdGNzcy1mb250LWdyYWJiZXInLCAob3B0cykgPT4ge1xyXG4gIHJldHVybiBGb250R3JhYmJlci5tYWtlUGx1Z2luSGFuZGxlcihvcHRzKTtcclxufSk7XHJcblxyXG4vL1xyXG4vLyBFeHBvc2UuXHJcbi8vXHJcbmV4cG9ydCBkZWZhdWx0IHBsdWdpbjtcclxuIl19
exports.postcssFontGrabber = plugin;
//# sourceMappingURL=index.js.map
{
"name": "postcss-font-grabber",
"version": "1.0.7",
"description": "Grab remote font in @font-face, download it and update your CSS, end of story.",
"version": "2.0.0-alpha.1",
"description": "Grab remote font files in @font-face, download them and update your CSS, just like that.",
"author": "AaronJan <aaronjan@qq.com>",
"homepage": "https://github.com/AaronJan/postcss-font-grabber",
"bugs": "https://github.com/AaronJan/postcss-font-grabber/issues",
"repository": {

@@ -12,8 +13,11 @@ "type": "git",

"main": "dist/index.js",
"types": "./index.d.ts",
"engines": {
"node": ">=0.11"
"node": ">=8.0.0"
},
"scripts": {
"test": "nyc ava",
"build": "babel src/ --out-dir dist/ --source-maps inline"
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"build": "tsc"
},

@@ -24,37 +28,22 @@ "keywords": [

"font-face",
"font"
"font",
"download"
],
"license": "Apache-2.0",
"devDependencies": {
"ava": "^0.14.0",
"babel-cli": "^6.9.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-polyfill": "^6.9.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-stage-0": "^6.5.0",
"babel-preset-stage-3": "^6.5.0",
"babel-register": "^6.9.0",
"@types/gulp": "^4.0.5",
"@types/jest": "^23.1.3",
"@types/node": "^10.5.0",
"@types/sinon": "^5.0.1",
"coveralls": "^2.11.9",
"nyc": "^6.4.4"
"gulp": "^4.0.0",
"jest": "^23.2.0",
"sinon": "^6.0.1",
"ts-jest": "^22.4.6",
"ts-node": "^6.2.0",
"typescript": "^2.9.2"
},
"babel": {
"presets": [
"es2015",
"stage-0"
],
"plugins": [
"add-module-exports"
],
"sourceMaps": "inline"
},
"dependencies": {
"lodash": "^4.13.0",
"postcss": "^5.0.21"
},
"ava": {
"babel": "inherit",
"require": [
"babel-register"
]
"postcss": "^6.0.23"
}
}

@@ -1,6 +0,15 @@

# PostCSS Font Grabber
<h1 align=center>
PostCSS Font Grabber
</h1>
[![Build Status](https://travis-ci.org/AaronJan/postcss-font-grabber.svg?branch=master)](https://travis-ci.org/AaronJan/postcss-font-grabber)
[![Coverage Status](https://coveralls.io/repos/github/AaronJan/postcss-font-grabber/badge.svg?branch=master)](https://coveralls.io/github/AaronJan/postcss-font-grabber?branch=master)
<p align="center">
<a href="https://www.npmjs.com/package/postcss-font-grabber"><img src="https://img.shields.io/npm/v/postcss-font-grabber.svg?style=flat-square" alt="Build Status"></a>
<a href="https://www.npmjs.com/package/postcss-font-grabber"><img src="https://img.shields.io/npm/dt/postcss-font-grabber.svg?style=flat-square" alt="Downloads"></a>
<a href="https://travis-ci.org/AaronJan/postcss-font-grabber"><img src="https://img.shields.io/travis/AaronJan/postcss-font-grabber.svg?style=flat-square" alt="Build Status"></a>
<a href="https://coveralls.io/github/AaronJan/postcss-font-grabber?branch=master"><img src="https://img.shields.io/coveralls/AaronJan/postcss-font-grabber.svg?style=flat-square" alt="Coverage Status"></a>
<a href="https://www.npmjs.com/package/postcss-font-grabber"><img src="https://img.shields.io/npm/l/postcss-font-grabber.svg?style=flat-square" alt="License"></a>
</p>
> 🎉 Here is the brand new `2.0` version that is completely rewritten in TypeScript (with typing), for `1.0` please see [HERE](https://github.com/AaronJan/postcss-font-grabber/tree/v1.x)
This is a [PostCSS](https://github.com/postcss/postcss) plugin, only do one thing:

@@ -47,11 +56,15 @@

```javascript
gulp.task('css', function () {
var postcss = require('gulp-postcss');
var postcssFontGrabber = require('postcss-font-grabber');
gulp.task('css', () => {
const postcss = require('gulp-postcss');
const { postcssFontGrabber } = require('postcss-font-grabber');
return gulp.src('src/**/*.css')
.pipe(postcss([
postcssFontGrabber() // I'm here
postcssFontGrabber({
cssDestinationDirectoryPath: 'dist/',
directoryPath: 'dist/fonts/',
autoCreateDirectory: true,
}),
]))
.pipe(gulp.dest('build/'));
.pipe(gulp.dest('dist/'));
});

@@ -66,3 +79,3 @@ ```

```javascript
import postcssFontGrabber from 'postcss-font-grabber';
import { postcssFontGrabber } from 'postcss-font-grabber';

@@ -88,3 +101,7 @@ module.exports = {

return [
postcssFontGrabber() // I'm here
postcssFontGrabber({
cssDestinationDirectoryPath: 'dist/',
directoryPath: 'dist/fonts/',
autoCreateDirectory: true,
}),
];

@@ -101,13 +118,99 @@ }

```javascript
postcssFontGrabber({ dirPath: '../css/build/font/' })
postcssFontGrabber({
cssDestinationDirectoryPath: 'dist/',
directoryPath: 'dist/fonts/',
autoCreateDirectory: true,
})
```
### cssDestinationDirectoryPath
### dirPath
Type: `string`
Type: `String`
TODO
### cssDestinationDirectoryPath
Type: `string`
The folder to save font file to, it's the same folder as the output `CSS` file is in by default.
### autoCreateDirectory
Type: `boolean`
Default: `true`
TODO
## Dig Deeper
You can get the **metadata** of execution details of `PostCSS-Font-Grabber`:
```javascript
import postcss from 'gulp-postcss';
import { makeInstance } from 'postcss-font-grabber';
gulp.task('default', () => {
const fontGrabber = makeInstance({
cssDestinationDirectoryPath: 'dist/',
directoryPath: 'dist/fonts/',
autoCreateDirectory: true,
});
fontGrabber.onDone(meta => {
console.log('meta', JSON.stringify(meta, null, ' '));
});
return gulp.src('src/**/*.css')
.pipe(postcss([
fontGrabber.makeTransformer(),
]))
.pipe(gulp.dest('dist/'));
});
```
### Metadata Format
Here is an example:
```javascript
// Importing module just for demonstration purpose, because the metadata contains URL object.
import url from 'url';
{
"jobResults": [
{
"job": {
"remoteFont": {
"urlObject": url.parse('https://example.com'),
"format": "woff2"
},
"css": {
"sourcePath": "/var/project/public/css/google.css",
"targetDirectoryPath": "/var/project/public/dist/css/fonts"
},
"font": {
"path": "/var/project/public/dist/css/fonts/ea8XadU7WuTxEub_NdWn8WZFuVs.woff2",
"filename": "ea8XadU7WuTxEub_NdWn8WZFuVs.woff2"
}
},
"download": {
"size": 0
}
},
/* More JobResults */
]
}
```
## TODOs
- [ ] Docs
- [ ] Fix download size
- [ ] Support calculating relative path when CSS file has it's own sub-folder
## License

@@ -123,1 +226,3 @@

[PostCSS Copy Assets](https://github.com/shutterstock/postcss-copy-assets)
[Issue Reporters](https://github.com/AaronJan/postcss-font-grabber/issues)
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