Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vercel/pkg
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ceaf9dd8fa643e45ccf1324a4a8e610a1603b26d
Choose a base ref
...
head repository: vercel/pkg
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 72a919d1836f46e9cd6f465d30ea036bd00566e1
Choose a head ref

Commits on Sep 22, 2018

  1. Update repo banner

    evilrabbit authored Sep 22, 2018
    1
    Copy the full SHA
    e67e307 View commit details
  2. Update repo banner

    evilrabbit authored Sep 22, 2018
    1
    Copy the full SHA
    27cb4d1 View commit details

Commits on Nov 29, 2018

  1. bump outdated dependencies

    igorklopov committed Nov 29, 2018
    1
    Copy the full SHA
    5dbeb9c View commit details

Commits on Nov 30, 2018

  1. 1
    Copy the full SHA
    480bb89 View commit details
  2. fix test for puppeteer

    igorklopov committed Nov 30, 2018
    1
    Copy the full SHA
    a210419 View commit details
  3. 1
    Copy the full SHA
    9c5d799 View commit details
  4. minor rename for clarity

    igorklopov committed Nov 30, 2018
    1
    Copy the full SHA
    3f540c0 View commit details
  5. Release 4.3.5

    igorklopov committed Nov 30, 2018
    1
    Copy the full SHA
    723aa6b View commit details

Commits on Dec 1, 2018

  1. tolerate root-ish "files" entry paths in package.json

    fixes everything dependent on 'array-from'
    igorklopov committed Dec 1, 2018
    1
    Copy the full SHA
    2faf045 View commit details
  2. 1
    Copy the full SHA
    90754ed View commit details
  3. Clarify scripts and assets entries support arrays (#514)

    Code already supported this; I'm just updating README
    
    closes #367
    unitof authored and igorklopov committed Dec 1, 2018
    1
    Copy the full SHA
    8600289 View commit details
  4. 1
    Copy the full SHA
    2b1b278 View commit details

Commits on Dec 2, 2018

  1. Fixes small typo in readme

    it's -> its
    ronkorving authored and igorklopov committed Dec 2, 2018
    1
    Copy the full SHA
    d271f13 View commit details

Commits on Dec 12, 2018

  1. Fix handling of files with for-await-of loops (#538)

    * Fix handling of files with for-await-of loops
    
    * Revert accidental change
    
    * Fix lint errors
    Matt Willer authored and rauchg committed Dec 12, 2018
    1
    Copy the full SHA
    2e39a52 View commit details

Commits on Dec 13, 2018

  1. Add Support for tinify, svgo and sqip (#417) (#418)

    * Add Support for tinify, svgo and sqip (#417)
    
    * Add missing test cases (#417)
    alexanderbartels authored and rauchg committed Dec 13, 2018
    1
    Copy the full SHA
    42946d5 View commit details

Commits on Jan 10, 2019

  1. 1
    Copy the full SHA
    9db59ff View commit details
  2. 1
    Copy the full SHA
    3890e84 View commit details
  3. 1
    Copy the full SHA
    dda3119 View commit details
  4. bumped dependencies

    igorklopov committed Jan 10, 2019
    1
    Copy the full SHA
    b19d97a View commit details
  5. Release 4.3.6

    igorklopov committed Jan 10, 2019
    1
    Copy the full SHA
    d226b6f View commit details
  6. bump pkg-fetch version

    igorklopov committed Jan 10, 2019
    1
    Copy the full SHA
    bdb59b3 View commit details
  7. Release 4.3.7

    igorklopov committed Jan 10, 2019
    1
    Copy the full SHA
    4bdbd6a View commit details

Commits on Apr 16, 2019

  1. Copy the full SHA
    95e9334 View commit details
  2. Release 4.3.8-canary.0

    igorklopov committed Apr 16, 2019
    Copy the full SHA
    619fc78 View commit details

Commits on Apr 27, 2019

  1. Fix pkg example express app (#668)

    * Fix pkg example express app
    
    Currently, following the instructions provided in the README result in pkg failing to build the executable. The error output references "node7" as being an undefined target in package.json.
    
    pkg relies on pkg-fetch for retrieving Node versions to be used as targets in building executables. As of pkg-fetch v2.5, no node v7.x.x is listed as an available source. Changing "node7" to "node10" fixes this issue as it is available via pkg-fetch v2.5.
    
    Additionally, this PR:
    *) Adds files/folders to .gitignore related to the example express app which should not be included in master.
    *) Improves README ducumentation for example express app.
    
    * Revise example app node target version
    
    Changed `pkg` target from `node10` to `node8` in order to pass CI build errors due to missing peer dependency for babel at that version.
    DaneTheory authored and igorklopov committed Apr 27, 2019
    Copy the full SHA
    e736f85 View commit details

Commits on May 1, 2019

  1. Copy the full SHA
    3775ab6 View commit details

Commits on May 8, 2019

  1. bump pkg-fetch

    igorklopov committed May 8, 2019
    Copy the full SHA
    9121a16 View commit details
  2. Copy the full SHA
    58f81cf View commit details
  3. Copy the full SHA
    589c6a5 View commit details

Commits on May 9, 2019

  1. Copy the full SHA
    215af15 View commit details

Commits on May 10, 2019

  1. Copy the full SHA
    8616bb6 View commit details
  2. Copy the full SHA
    005117c View commit details
  3. Copy the full SHA
    b0da4ee View commit details
  4. adjustments (#680)

    * adjust promisify to node 10+
    
    * run test-50-reject-* on linux only
    
    * set host to node12
    
    * enable armv7 in test-42-fetch-all
    
    * add 12->6 to npm version map in test-79-npm
    
    * remove unneeded test-50-bakery-4
    igorklopov authored May 10, 2019
    Copy the full SHA
    1d47858 View commit details

Commits on May 11, 2019

  1. Copy the full SHA
    ee56bd7 View commit details
  2. Copy the full SHA
    3952f39 View commit details
  3. Copy the full SHA
    460b1c9 View commit details
  4. Release 4.4.0

    igorklopov committed May 11, 2019
    1
    Copy the full SHA
    50da752 View commit details

Commits on Nov 30, 2019

  1. Copy the full SHA
    061a977 View commit details

Commits on Dec 7, 2019

  1. Copy the full SHA
    7ff6430 View commit details
  2. update dependencies

    igorklopov committed Dec 7, 2019
    Copy the full SHA
    89a1a49 View commit details

Commits on Dec 8, 2019

  1. Copy the full SHA
    718d974 View commit details
  2. Copy the full SHA
    7af8d04 View commit details
  3. Release 4.4.1

    igorklopov committed Dec 8, 2019
    Copy the full SHA
    72a919d View commit details
Showing with 2,638 additions and 1,973 deletions.
  1. +10 −0 .gitignore
  2. +1 −1 .travis.yml
  3. +7 −3 README.md
  4. +15 −0 dictionary/google-closure-compiler-java.js
  5. +8 −0 dictionary/sqip.js
  6. +13 −0 dictionary/svgo.js
  7. +9 −0 dictionary/tinify.js
  8. +1 −1 examples/express/package.json
  9. +15 −1 examples/express/readme.md
  10. +1 −1 lib/detector.js
  11. +2 −1 lib/fabricator.js
  12. +14 −9 lib/follow.js
  13. +2 −0 lib/index.js
  14. +2 −2 lib/producer.js
  15. +2 −2 lib/refiner.js
  16. +19 −50 lib/walker.js
  17. +31 −29 package.json
  18. +32 −31 prelude/bootstrap.js
  19. +9 −4 test/test-42-fetch-all/main.js
  20. +29 −14 test/test-50-bakery-4/main.js
  21. +1 −14 test/test-50-bakery-4/test-x-index.js
  22. +35 −0 test/test-50-for-await-of/main.js
  23. +33 −0 test/test-50-for-await-of/test-x-index.js
  24. +3 −1 test/test-50-fs-runtime-layer-2/main.js
  25. +8 −8 test/test-50-may-exclude/test-x-index.js
  26. +33 −0 test/test-50-package-json-8b/main.js
  27. +7 −0 test/test-50-package-json-8b/package.json
  28. +13 −0 test/test-50-package-json-8b/sub/sub/test-y-require.js
  29. +4 −0 test/test-50-package-json-8b/sub/test-x-index.js
  30. +6 −0 test/test-50-package-json-8b/sub/test-z-require.js
  31. +1 −0 test/test-50-package-json-8b/test-z-data.css
  32. +0 −4 test/test-50-promisify/main.js
  33. +3 −0 test/test-50-reject-4/main.js
  34. +3 −0 test/test-50-reject-6/main.js
  35. +8 −3 test/test-50-spawn/test-spawn-a-2.js
  36. +3 −7 test/test-50-spawn/test-spawn-a-3.js
  37. +2 −4 test/test-50-spawn/test-spawn-a-4.js
  38. +28 −0 test/test-50-spawn/test-spawn-a-5.js
  39. +6 −0 test/test-79-npm/google-closure-compiler-java/google-closure-compiler-java.js
  40. +7 −0 test/test-79-npm/google-closure-compiler-java/google-closure-compiler-java.meta.js
  41. +1 −0 test/test-79-npm/google-closure-compiler-java/package.json
  42. +1 −1 test/test-79-npm/google-closure-compiler/google-closure-compiler.meta.js
  43. +8 −0 test/test-79-npm/google-closure-compiler/google-closure-compiler@20180610.0.2.js
  44. +7 −0 test/test-79-npm/google-closure-compiler/google-closure-compiler@20180610.0.2.meta.js
  45. +1 −1 test/test-79-npm/main.js
  46. +2 −2 test/test-79-npm/mongoose/mongoose.meta.js
  47. +6 −3 test/test-79-npm/puppeteer/puppeteer.js
  48. +10 −0 test/test-79-npm/sharp/sharp.js
  49. +1 −0 test/test-79-npm/sqip/package.json
  50. +6 −0 test/test-79-npm/sqip/sqip.js
  51. +1 −0 test/test-79-npm/svgo/package.json
  52. +6 −0 test/test-79-npm/svgo/svgo.js
  53. +1 −0 test/test-79-npm/tinify/package.json
  54. +6 −0 test/test-79-npm/tinify/tinify.js
  55. +19 −9 test/test.js
  56. +2,136 −1,767 yarn.lock
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -6,3 +6,13 @@

# logs
npm-debug.log

# General macOS
.DS_Store
examples/.DS_Store

# Example pkg'd application
examples/express/express-example

# Example dependencies
examples/express/node_modules
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language:
- node_js
node_js: 10
node_js: 12
services:
- mongodb
sudo: true
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![](http://res.cloudinary.com/zeit-inc/image/upload/v1509936789/repositories/pkg/pkg-banner.png)
![](http://res.cloudinary.com/zeit-inc/image/upload/v1509936789/repositories/pkg/pkg-repo-banner-new.png)

[![Build Status](https://travis-ci.org/zeit/pkg.svg?branch=master)](https://travis-ci.org/zeit/pkg)
[![Coverage Status](https://coveralls.io/repos/github/zeit/pkg/badge.svg?branch=master)](https://coveralls.io/github/zeit/pkg?branch=master)
@@ -45,12 +45,12 @@ option. A canonical target consists of 3 elements, separated by
dashes, for example `node6-macos-x64` or `node4-linux-armv6`:

* **nodeRange** node${n} or latest
* **platform** freebsd, linux, macos, win
* **platform** freebsd, linux, alpine, macos, win
* **arch** x64, x86, armv6, armv7

You may omit any element (and specify just `node6` for example).
The omitted elements will be taken from current platform or
system-wide Node.js installation (it's version and arch).
system-wide Node.js installation (its version and arch).
There is also an alias `host`, that means that all 3 elements
are taken from current platform/Node.js. By default targets are
`linux,macos,win` for current Node.js version and arch.
@@ -77,6 +77,10 @@ your `package.json` file.
"assets": "views/**/*"
}
```
You may also specify arrays of globs:
```
"assets": [ "assets/**/*", "images/**/*" ]
```
Just be sure to call `pkg package.json` or `pkg .` to make use
of `scripts` and `assets` entries.

15 changes: 15 additions & 0 deletions dictionary/google-closure-compiler-java.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

module.exports = {
pkg: {
patches: {
'index.js': [
'require.resolve(\'./compiler.jar\')',
'require(\'path\').join(require(\'path\').dirname(process.execPath), \'compiler/compiler.jar\')'
]
},
deployFiles: [
[ 'compiler.jar', 'compiler/compiler.jar' ]
]
}
};
8 changes: 8 additions & 0 deletions dictionary/sqip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

/**
* primitive Binaries must be installed on the system.
* e.g. go get -u github.com/fogleman/primitive
*/
module.exports = {
};
13 changes: 13 additions & 0 deletions dictionary/svgo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

module.exports = {
pkg: {
scripts: [
'lib/**/*.js',
'plugins/*.js'
],
assets: [
'.svgo.yml'
]
}
};
9 changes: 9 additions & 0 deletions dictionary/tinify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

module.exports = {
pkg: {
assets: [
'lib/data/cacert.pem'
]
}
};
2 changes: 1 addition & 1 deletion examples/express/package.json
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
"views/**/*"
],
"targets": [
"node7"
"node8"
]
}
}
16 changes: 15 additions & 1 deletion examples/express/readme.md
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
Run `pkg .` here!
# Express-Example

> This example illustrates using `pkg` on a simple Express based app
## Instructions

1. Run `npm install`
2. Run `pkg .`

That's it!

## Post Success Notes

* Upon success, `pkg` will create an executable named "express-example". This file can be found at the root of the example project directory.
* To see the app in action, run the executable then navigate to http://localhost:8080/ in your browser.
2 changes: 1 addition & 1 deletion lib/detector.js
Original file line number Diff line number Diff line change
@@ -333,7 +333,7 @@ module.exports.parse = function (body) {
allowImportExportEverywhere: true,
allowReturnOutsideFunction: true,
ecmaVersion: 8,
plugins: [ 'estree', 'objectRestSpread' ]
plugins: [ 'estree' ]
});
};

3 changes: 2 additions & 1 deletion lib/fabricator.js
Original file line number Diff line number Diff line change
@@ -44,7 +44,8 @@ const children = {};
export function fabricate (bakes, fabricator, snap, body, cb) {
bakes = bakes.filter(function (bake) {
// list of bakes that don't influence the bytecode
return ![ '--prof', '--v8-options' ].includes(bake);
const bake2 = bake.replace(/_/g, '-');
return ![ '--prof', '--v8-options', '--trace-opt', '--trace-deopt' ].includes(bake2);
});

const cmd = fabricator.binaryPath;
23 changes: 14 additions & 9 deletions lib/follow.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import fs from 'fs';
import { sync } from 'resolve';

export default function follow (x, opts) {
// TODO async version
return new Promise((resolve) => {
resolve(sync(x, opts));
// TODO own implementation with foreign tests
// TODO async follow
/*
resolve_(x, opts, (error, result) => {
if (error) return reject(error);
resolve(result);
});
*/
resolve(sync(x, {
basedir: opts.basedir,
extensions: opts.extensions,
readFileSync: (file) => {
opts.readFile(file);
return fs.readFileSync(file);
},
packageFilter: (config, base) => {
opts.packageFilter(config, base);
return config;
}
}));
});
}
2 changes: 2 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable require-atomic-updates */

import { exists, mkdirp, readFile, remove, stat } from 'fs-extra';
import { log, wasReported } from './log.js';
import { need, system } from 'pkg-fetch';
4 changes: 2 additions & 2 deletions lib/producer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { STORE_BLOB, STORE_CONTENT, snapshotify } from '../prelude/common.js';
import { log, wasReported } from './log.js';
import Multistream from 'multistream';
import assert from 'assert';
import { fabricateTwice } from './fabricator.js';
import fs from 'fs';
import intoStream from 'into-stream';
import multistream from 'multistream';
import streamMeter from 'stream-meter';

function discoverPlaceholder (binaryBuffer, searchString, padder) {
@@ -115,7 +115,7 @@ export default function ({ backpack, bakes, slash, target }) {
let preludePosition;
let preludeSize;

multistream((cb) => {
new Multistream((cb) => {
if (count === 0) {
return cb(undefined, next(
intoStream(binaryBuffer)
4 changes: 2 additions & 2 deletions lib/refiner.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@ import { STORE_LINKS, retrieveDenominator,
substituteDenominator } from '../prelude/common.js';
import path from 'path';

const win32 = process.platform === 'win32';

function hasParent (file, records) {
const dirname = path.dirname(file);
if (dirname === file) return false; // root directory
@@ -37,8 +39,6 @@ function purgeTopDirectories (records) {
}
}

const win32 = process.platform === 'win32';

function denominate (records, entrypoint, denominator) {
const newRecords = {};

69 changes: 19 additions & 50 deletions lib/walker.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable require-atomic-updates */

import { ALIAS_AS_RELATIVE, ALIAS_AS_RESOLVABLE,
STORE_BLOB, STORE_CONTENT, STORE_LINKS, STORE_STAT,
isDotJS, isDotJSON, isDotNODE, isPackageJson, normalizePath
@@ -12,14 +14,7 @@ import globby from 'globby';
import natives from './natives.js';
import path from 'path';

function shortFromAlias (alias) {
// alias = fs-promise or @types/node
if (alias[0] === '@') {
return alias.match(/^([^\\/]+[\\/][^\\/]+)/)[0];
} else {
return alias.match(/^[^\\/]+/)[0];
}
}
const win32 = process.platform === 'win32';

function isPublic (config) {
if (config.private) return false;
@@ -65,8 +60,9 @@ function upon (p, base) {
p = p.slice(1);
negate = true;
}
if (!path.isAbsolute(p)) {
p = path.join(base, p);
p = path.join(base, p);
if (win32) {
p = p.replace(/\\/g, '/');
}
if (negate) {
p = '!' + p;
@@ -409,28 +405,29 @@ class Walker {
}

async stepDerivatives_ALIAS_AS_RESOLVABLE (record, marker, derivative) { // eslint-disable-line camelcase
const catcher = {};
let stage = 0;
let newPackage;
let newMarker;

catcher.readFileSync = (file) => {
// only first occurence from loadNodeModulesSync
if (stage === 2) return;
assert(stage === 0);
// was taken from resolve/lib/sync.js
const isNear = /^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[\\/])/;
const near = isNear.test(derivative.alias);

const catchReadFile = (file) => {
if (near) return;
if (stage !== 0) return;
assert(isPackageJson(file), 'walker: ' +
file + ' must be package.json');
newPackage = file;
newMarker = undefined;
stage = 1;
return fs.readFileSync(file);
};

catcher.packageFilter = (config, base) => {
assert(stage === 1);
const catchPackageFilter = (config, base) => {
if (near) return;
if (stage !== 1) return;
newMarker = { config, configPath: newPackage, base };
stage = 2;
return config;
};

let newFile, failure;
@@ -443,42 +440,13 @@ class Walker {
// is not taken in require('./typos')
// in 'normalize-package-data/lib/fixer.js'
extensions: [ '.js', '.json', '.node' ],
readFileSync: catcher.readFileSync,
packageFilter: catcher.packageFilter
readFile: catchReadFile,
packageFilter: catchPackageFilter
});
} catch (error) {
failure = error;
}

// was taken from resolve/lib/sync.js
const isNear = /^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[\\/])/;
let mainNotFound = false;

if (!isNear.test(derivative.alias)) {
const short = shortFromAlias(derivative.alias);
// 'npm' !== 'npm/bin/npm-cli.js'
if (short !== derivative.alias) {
try {
await follow(short, {
basedir: path.dirname(record.file),
extensions: [ '.js', '.json', '.node' ],
readFileSync: catcher.readFileSync,
packageFilter: catcher.packageFilter
});
} catch (error) {
// the purpose is to fire 'packageFilter'
// in cases like require('npm/bin/npm-cli.js')
// because otherwise it will not be fired
// (only loadAsFileSync is executed)
}
}
// 'babel-runtime' === 'babel-runtime'
if (short === derivative.alias) {
mainNotFound = failure && newMarker &&
newMarker.config && !newMarker.config.main;
}
}

assert((newPackage && newMarker) ||
(!newPackage && !newMarker), 'Probably, package.json is malformed');

@@ -493,6 +461,7 @@ class Walker {

if (failure) {
const { toplevel } = marker;
const mainNotFound = !newFile && newMarker;
const debug = !toplevel || derivative.mayExclude ||
(mainNotFound && derivative.fromDependencies);
const level = debug ? 'debug' : 'warn';
Loading