composer and npm

This commit is contained in:
Henry Whitaker
2020-08-25 00:59:44 +01:00
parent 6726d93cc6
commit c8f853dc84
2504 changed files with 88530 additions and 41367 deletions

20
conf/site/node_modules/resolve/.editorconfig generated vendored Normal file
View File

@@ -0,0 +1,20 @@
root = true
[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 150
[CHANGELOG.md]
indent_style = space
indent_size = 2
[*.json]
max_line_length = off
[Makefile]
max_line_length = off

View File

@@ -5,6 +5,8 @@ var nodeModulesPaths = require('./node-modules-paths.js');
var normalizeOptions = require('./normalize-options.js');
var isCore = require('./is-core');
var realpathFS = fs.realpath && typeof fs.realpath.native === 'function' ? fs.realpath.native : fs.realpath;
var defaultIsFile = function isFile(file, cb) {
fs.stat(file, function (err, stat) {
if (!err) {
@@ -25,12 +27,16 @@ var defaultIsDir = function isDirectory(dir, cb) {
});
};
var maybeUnwrapSymlink = function maybeUnwrapSymlink(x, opts, cb) {
var defaultRealpath = function realpath(x, cb) {
realpathFS(x, function (realpathErr, realPath) {
if (realpathErr && realpathErr.code !== 'ENOENT') cb(realpathErr);
else cb(null, realpathErr ? x : realPath);
});
};
var maybeRealpath = function maybeRealpath(realpath, x, opts, cb) {
if (opts && opts.preserveSymlinks === false) {
fs.realpath(x, function (realPathErr, realPath) {
if (realPathErr && realPathErr.code !== 'ENOENT') cb(realPathErr);
else cb(null, realPathErr ? x : realPath);
});
realpath(x, cb);
} else {
cb(null, x);
}
@@ -63,6 +69,7 @@ module.exports = function resolve(x, options, callback) {
var isFile = opts.isFile || defaultIsFile;
var isDirectory = opts.isDirectory || defaultIsDir;
var readFile = opts.readFile || fs.readFile;
var realpath = opts.realpath || defaultRealpath;
var packageIterator = opts.packageIterator;
var extensions = opts.extensions || ['.js'];
@@ -74,7 +81,8 @@ module.exports = function resolve(x, options, callback) {
// ensure that `basedir` is an absolute path at this point, resolving against the process' current working directory
var absoluteStart = path.resolve(basedir);
maybeUnwrapSymlink(
maybeRealpath(
realpath,
absoluteStart,
opts,
function (err, realStart) {
@@ -96,7 +104,7 @@ module.exports = function resolve(x, options, callback) {
} else loadNodeModules(x, basedir, function (err, n, pkg) {
if (err) cb(err);
else if (n) {
return maybeUnwrapSymlink(n, opts, function (err, realN) {
return maybeRealpath(realpath, n, opts, function (err, realN) {
if (err) {
cb(err);
} else {
@@ -117,7 +125,7 @@ module.exports = function resolve(x, options, callback) {
else loadAsDirectory(res, function (err, d, pkg) {
if (err) cb(err);
else if (d) {
maybeUnwrapSymlink(d, opts, function (err, realD) {
maybeRealpath(realpath, d, opts, function (err, realD) {
if (err) {
cb(err);
} else {
@@ -181,7 +189,7 @@ module.exports = function resolve(x, options, callback) {
}
if ((/[/\\]node_modules[/\\]*$/).test(dir)) return cb(null);
maybeUnwrapSymlink(dir, opts, function (unwrapErr, pkgdir) {
maybeRealpath(realpath, dir, opts, function (unwrapErr, pkgdir) {
if (unwrapErr) return loadpkg(path.dirname(dir), cb);
var pkgfile = path.join(pkgdir, 'package.json');
isFile(pkgfile, function (err, ex) {
@@ -209,7 +217,7 @@ module.exports = function resolve(x, options, callback) {
fpkg = opts.package;
}
maybeUnwrapSymlink(x, opts, function (unwrapErr, pkgdir) {
maybeRealpath(realpath, x, opts, function (unwrapErr, pkgdir) {
if (unwrapErr) return cb(unwrapErr);
var pkgfile = path.join(pkgdir, 'package.json');
isFile(pkgfile, function (err, ex) {

View File

@@ -16,7 +16,7 @@
"events": true,
"freelist": "< 6",
"fs": true,
"fs/promises": ">= 10 && < 10.1",
"fs/promises": [">= 10 && < 10.1", ">= 14"],
"_http_agent": ">= 0.11.1",
"_http_client": ">= 0.11.1",
"_http_common": ">= 0.11.1",

View File

@@ -5,6 +5,8 @@ var caller = require('./caller.js');
var nodeModulesPaths = require('./node-modules-paths.js');
var normalizeOptions = require('./normalize-options.js');
var realpathFS = fs.realpathSync && typeof fs.realpathSync.native === 'function' ? fs.realpathSync.native : fs.realpathSync;
var defaultIsFile = function isFile(file) {
try {
var stat = fs.statSync(file);
@@ -25,19 +27,24 @@ var defaultIsDir = function isDirectory(dir) {
return stat.isDirectory();
};
var maybeUnwrapSymlink = function maybeUnwrapSymlink(x, opts) {
if (opts && opts.preserveSymlinks === false) {
try {
return fs.realpathSync(x);
} catch (realPathErr) {
if (realPathErr.code !== 'ENOENT') {
throw realPathErr;
}
var defaultRealpathSync = function realpathSync(x) {
try {
return realpathFS(x);
} catch (realpathErr) {
if (realpathErr.code !== 'ENOENT') {
throw realpathErr;
}
}
return x;
};
var maybeRealpathSync = function maybeRealpathSync(realpathSync, x, opts) {
if (opts && opts.preserveSymlinks === false) {
return realpathSync(x);
}
return x;
};
var getPackageCandidates = function getPackageCandidates(x, start, opts) {
var dirs = nodeModulesPaths(start, opts, x);
for (var i = 0; i < dirs.length; i++) {
@@ -55,6 +62,7 @@ module.exports = function resolveSync(x, options) {
var isFile = opts.isFile || defaultIsFile;
var readFileSync = opts.readFileSync || fs.readFileSync;
var isDirectory = opts.isDirectory || defaultIsDir;
var realpathSync = opts.realpathSync || defaultRealpathSync;
var packageIterator = opts.packageIterator;
var extensions = opts.extensions || ['.js'];
@@ -64,18 +72,18 @@ module.exports = function resolveSync(x, options) {
opts.paths = opts.paths || [];
// ensure that `basedir` is an absolute path at this point, resolving against the process' current working directory
var absoluteStart = maybeUnwrapSymlink(path.resolve(basedir), opts);
var absoluteStart = maybeRealpathSync(realpathSync, path.resolve(basedir), opts);
if ((/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/).test(x)) {
var res = path.resolve(absoluteStart, x);
if (x === '.' || x === '..' || x.slice(-1) === '/') res += '/';
var m = loadAsFileSync(res) || loadAsDirectorySync(res);
if (m) return maybeUnwrapSymlink(m, opts);
if (m) return maybeRealpathSync(realpathSync, m, opts);
} else if (isCore(x)) {
return x;
} else {
var n = loadNodeModulesSync(x, absoluteStart);
if (n) return maybeUnwrapSymlink(n, opts);
if (n) return maybeRealpathSync(realpathSync, n, opts);
}
var err = new Error("Cannot find module '" + x + "' from '" + parent + "'");
@@ -112,7 +120,7 @@ module.exports = function resolveSync(x, options) {
}
if ((/[/\\]node_modules[/\\]*$/).test(dir)) return;
var pkgfile = path.join(maybeUnwrapSymlink(dir, opts), 'package.json');
var pkgfile = path.join(maybeRealpathSync(realpathSync, dir, opts), 'package.json');
if (!isFile(pkgfile)) {
return loadpkg(path.dirname(dir));
@@ -133,7 +141,7 @@ module.exports = function resolveSync(x, options) {
}
function loadAsDirectorySync(x) {
var pkgfile = path.join(maybeUnwrapSymlink(x, opts), '/package.json');
var pkgfile = path.join(maybeRealpathSync(realpathSync, x, opts), '/package.json');
if (isFile(pkgfile)) {
try {
var body = readFileSync(pkgfile, 'UTF8');

View File

@@ -1,33 +1,33 @@
{
"_args": [
[
"resolve@1.15.1",
"resolve@1.17.0",
"/home/henry/Documents/git/Speedtest-tracker-docker/conf/site"
]
],
"_development": true,
"_from": "resolve@1.15.1",
"_id": "resolve@1.15.1",
"_from": "resolve@1.17.0",
"_id": "resolve@1.17.0",
"_inBundle": false,
"_integrity": "sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==",
"_integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==",
"_location": "/resolve",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "resolve@1.15.1",
"raw": "resolve@1.17.0",
"name": "resolve",
"escapedName": "resolve",
"rawSpec": "1.15.1",
"rawSpec": "1.17.0",
"saveSpec": null,
"fetchSpec": "1.15.1"
"fetchSpec": "1.17.0"
},
"_requiredBy": [
"/@babel/core",
"/@babel/plugin-transform-runtime"
],
"_resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz",
"_spec": "1.15.1",
"_resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz",
"_spec": "1.17.0",
"_where": "/home/henry/Documents/git/Speedtest-tracker-docker/conf/site",
"author": {
"name": "James Halliday",
@@ -48,7 +48,7 @@
"object-keys": "^1.1.1",
"safe-publish-latest": "^1.1.4",
"tap": "0.4.13",
"tape": "^5.0.0-next.4"
"tape": "^5.0.0-next.5"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
@@ -77,5 +77,5 @@
"test:multirepo": "cd ./test/resolver/multirepo && npm install && npm test",
"tests-only": "tape test/*.js"
},
"version": "1.15.1"
"version": "1.17.0"
}

View File

@@ -61,6 +61,8 @@ options are:
* opts.isDirectory - function to asynchronously test whether a directory exists
* opts.realpath - function to asynchronously resolve a potential symlink to its real path
* `opts.packageFilter(pkg, pkgfile, dir)` - transform the parsed package.json contents before looking at the "main" field
* pkg - package data
* pkgfile - path to package.json
@@ -119,6 +121,13 @@ default `opts` values:
return cb(err);
});
},
realpath: function realpath(file, cb) {
var realpath = typeof fs.realpath.native === 'function' ? fs.realpath.native : fs.realpath;
realpath(file, function (realPathErr, realPath) {
if (realPathErr && realPathErr.code !== 'ENOENT') cb(realPathErr);
else cb(null, realPathErr ? file : realPath);
});
},
moduleDirectory: 'node_modules',
preserveSymlinks: true
}
@@ -141,6 +150,8 @@ options are:
* opts.isDirectory - function to synchronously test whether a directory exists
* opts.realpathSync - function to synchronously resolve a potential symlink to its real path
* `opts.packageFilter(pkg, dir)` - transform the parsed package.json contents before looking at the "main" field
* pkg - package data
* dir - directory for package.json (Note: the second argument will change to "pkgfile" in v2)
@@ -198,6 +209,17 @@ default `opts` values:
}
return stat.isDirectory();
},
realpathSync: function realpathSync(file) {
try {
var realpath = typeof fs.realpathSync.native === 'function' ? fs.realpathSync.native : fs.realpathSync;
return realpath(file);
} catch (realPathErr) {
if (realPathErr.code !== 'ENOENT') {
throw realPathErr;
}
}
return file;
},
moduleDirectory: 'node_modules',
preserveSymlinks: true
}

View File

@@ -22,6 +22,9 @@ test('mock', function (t) {
},
readFile: function (file, cb) {
cb(null, files[path.resolve(file)]);
},
realpath: function (file, cb) {
cb(null, file);
}
};
}
@@ -70,6 +73,9 @@ test('mock from package', function (t) {
'package': { main: 'bar' },
readFile: function (file, cb) {
cb(null, files[file]);
},
realpath: function (file, cb) {
cb(null, file);
}
};
}
@@ -121,6 +127,9 @@ test('mock package', function (t) {
},
readFile: function (file, cb) {
cb(null, files[path.resolve(file)]);
},
realpath: function (file, cb) {
cb(null, file);
}
};
}
@@ -157,6 +166,9 @@ test('mock package from package', function (t) {
'package': { main: 'bar' },
readFile: function (file, cb) {
cb(null, files[path.resolve(file)]);
},
realpath: function (file, cb) {
cb(null, file);
}
};
}
@@ -167,3 +179,61 @@ test('mock package from package', function (t) {
t.equal(pkg && pkg.main, './baz.js');
});
});
test('symlinked', function (t) {
t.plan(4);
var files = {};
files[path.resolve('/foo/bar/baz.js')] = 'beep';
files[path.resolve('/foo/bar/symlinked/baz.js')] = 'beep';
var dirs = {};
dirs[path.resolve('/foo/bar')] = true;
dirs[path.resolve('/foo/bar/symlinked')] = true;
function opts(basedir) {
return {
preserveSymlinks: false,
basedir: path.resolve(basedir),
isFile: function (file, cb) {
cb(null, Object.prototype.hasOwnProperty.call(files, path.resolve(file)));
},
isDirectory: function (dir, cb) {
cb(null, !!dirs[path.resolve(dir)]);
},
readFile: function (file, cb) {
cb(null, files[path.resolve(file)]);
},
realpath: function (file, cb) {
var resolved = path.resolve(file);
if (resolved.indexOf('symlinked') >= 0) {
cb(null, resolved);
return;
}
var ext = path.extname(resolved);
if (ext) {
var dir = path.dirname(resolved);
var base = path.basename(resolved);
cb(null, path.join(dir, 'symlinked', base));
} else {
cb(null, path.join(resolved, 'symlinked'));
}
}
};
}
resolve('./baz', opts('/foo/bar'), function (err, res, pkg) {
if (err) return t.fail(err);
t.equal(res, path.resolve('/foo/bar/symlinked/baz.js'));
t.equal(pkg, undefined);
});
resolve('./baz.js', opts('/foo/bar'), function (err, res, pkg) {
if (err) return t.fail(err);
t.equal(res, path.resolve('/foo/bar/symlinked/baz.js'));
t.equal(pkg, undefined);
});
});

View File

@@ -22,6 +22,9 @@ test('mock', function (t) {
},
readFileSync: function (file) {
return files[path.resolve(file)];
},
realpathSync: function (file) {
return file;
}
};
}
@@ -69,6 +72,9 @@ test('mock package', function (t) {
},
readFileSync: function (file) {
return files[path.resolve(file)];
},
realpathSync: function (file) {
return file;
}
};
}
@@ -78,3 +84,58 @@ test('mock package', function (t) {
path.resolve('/foo/node_modules/bar/baz.js')
);
});
test('symlinked', function (t) {
t.plan(2);
var files = {};
files[path.resolve('/foo/bar/baz.js')] = 'beep';
files[path.resolve('/foo/bar/symlinked/baz.js')] = 'beep';
var dirs = {};
dirs[path.resolve('/foo/bar')] = true;
dirs[path.resolve('/foo/bar/symlinked')] = true;
function opts(basedir) {
return {
preserveSymlinks: false,
basedir: path.resolve(basedir),
isFile: function (file) {
return Object.prototype.hasOwnProperty.call(files, path.resolve(file));
},
isDirectory: function (dir) {
return !!dirs[path.resolve(dir)];
},
readFileSync: function (file) {
return files[path.resolve(file)];
},
realpathSync: function (file) {
var resolved = path.resolve(file);
if (resolved.indexOf('symlinked') >= 0) {
return resolved;
}
var ext = path.extname(resolved);
if (ext) {
var dir = path.dirname(resolved);
var base = path.basename(resolved);
return path.join(dir, 'symlinked', base);
} else {
return path.join(resolved, 'symlinked');
}
}
};
}
t.equal(
resolve.sync('./baz', opts('/foo/bar')),
path.resolve('/foo/bar/symlinked/baz.js')
);
t.equal(
resolve.sync('./baz.js', opts('/foo/bar')),
path.resolve('/foo/bar/symlinked/baz.js')
);
});