UEA-Prodem

This commit is contained in:
2026-06-10 12:38:42 -03:00
parent 3f33154e16
commit c41625e542
9352 changed files with 1128292 additions and 14752 deletions
+26
View File
@@ -0,0 +1,26 @@
# resolve package - session notes
## Versioning
- Manual versioning only - do NOT use `npm version`
- Edit package.json version directly, commit with message `v{version}`, then create annotated tag
- Changelog lives in git tag annotations, not a separate file
- Tag format: `git tag -a v{version} -m "{changelog}"`
## Code style
- `__proto__: null` on ALL object literals (prototype pollution protection)
- `.slice()` not `.substring()`
- One exported function per file
- Move nested/inner functions to module level when feasible
- Prefer non-hoisted declarations (function declarations at module level, not expressions)
- No mutation - copy objects instead of modifying inputs
## Testing
- `test/list-exports` is a git submodule with sparse checkout
- Tests should cover ALL entrypoints from fixtures, not just `'.'` subpaths
- Use `extensions: ['.js', '.json']` when testing exports resolution
## exports field implementation
- Uses `node-exports-info` for category semantics
- Categories: pre-exports, broken, conditions, patterns, pattern-trailers, current
- `exportsCategory` option or `engines: true` to auto-detect from consumer's engines.node
- Self-reference resolution respects node_modules boundaries
+26
View File
@@ -0,0 +1,26 @@
{
"permissions": {
"allow": [
"WebFetch(domain:github.com)",
"WebSearch",
"WebFetch(domain:raw.githubusercontent.com)",
"WebFetch(domain:api.github.com)",
"WebFetch(domain:www.npmjs.com)",
"Bash(tree:*)",
"Bash(find:*)",
"Bash(npm view:*)",
"Bash(node test/resolver_sync.js:*)",
"Bash(xxd:*)",
"Bash(npm info:*)",
"Bash(grep:*)",
"Bash(npm run submodule:update:*)",
"Bash(git rev-parse:*)",
"Bash(git -C test/list-exports diff packages/tests/fixtures/resolve-2/project/test/resolver/nested_symlinks/mylib/async.js)",
"Bash(gh run list:*)",
"Bash(ls:*)",
"Bash(tape test/homedir.js)",
"Bash(tape test/default_paths.js)",
"Bash(tape test/mock.js)"
]
}
}
+80
View File
@@ -0,0 +1,80 @@
import ljharb from '@ljharb/eslint-config/flat';
export default [
...ljharb,
{
ignores: [
'test/resolver/malformed_package_json/package.json',
'test/list-exports/**',
],
},
{
rules: {
'array-bracket-newline': 'off',
complexity: 'off',
'consistent-return': 'off',
curly: 'off',
'dot-notation': ['error', { allowKeywords: true }],
'func-name-matching': 'off',
'func-style': 'off',
'global-require': 'warn',
'id-length': ['error', { min: 1, max: 40 }],
'max-depth': 'off',
'max-lines-per-function': 'off',
'max-lines': 'off',
'max-nested-callbacks': 'off',
'max-params': 'off',
'max-statements-per-line': ['error', { max: 2 }],
'max-statements': 'off',
'multiline-comment-style': 'off',
'no-magic-numbers': 'off',
'no-shadow': 'off',
'no-use-before-define': 'off',
'sort-keys': 'off',
strict: 'off',
},
},
{
files: ['**/*.js'],
rules: {
indent: ['error', 4],
},
},
{
files: ['bin/**'],
rules: {
'no-process-exit': 'off',
},
},
{
files: ['example/**'],
rules: {
'no-console': 'off',
},
},
{
files: ['test/resolver/nested_symlinks/mylib/*.js'],
rules: {
'no-throw-literal': 'off',
},
},
{
files: ['test/**'],
languageOptions: {
ecmaVersion: 5,
parserOptions: {
allowReserved: false,
},
},
rules: {
'dot-notation': ['error', { allowPattern: 'throws' }],
'max-lines': 'off',
'max-lines-per-function': 'off',
'no-unused-vars': ['error', {
vars: 'all',
args: 'none',
caughtErrors: 'none',
}],
},
},
];
+49
View File
@@ -0,0 +1,49 @@
'use strict';
var path = require('path');
var test = require('tape');
var mockProperty = require('mock-property');
var homedirPath = require.resolve('../lib/homedir');
var asyncPath = require.resolve('../async');
var libAsyncPath = require.resolve('../lib/async');
var syncPath = require.resolve('../sync');
var libSyncPath = require.resolve('../lib/sync');
function mockNullHomedir(t) {
t.teardown(mockProperty(require.cache, homedirPath, {
value: { id: homedirPath, filename: homedirPath, loaded: true, exports: function () { return null; } }
}));
}
test('async: null homedir does not throw', function (t) {
t.plan(2);
mockNullHomedir(t);
t.teardown(mockProperty(require.cache, asyncPath, { 'delete': true }));
t.teardown(mockProperty(require.cache, libAsyncPath, { 'delete': true }));
var resolve = require('../lib/async');
var dir = path.join(__dirname, 'resolver');
resolve('./baz', { basedir: dir }, function (err, res) {
t.error(err, 'no error');
t.equal(res, path.join(dir, 'baz', 'quux.js'), 'resolves correctly with null homedir');
});
});
test('sync: null homedir does not throw', function (t) {
mockNullHomedir(t);
t.teardown(mockProperty(require.cache, syncPath, { 'delete': true }));
t.teardown(mockProperty(require.cache, libSyncPath, { 'delete': true }));
var resolveSync = require('../lib/sync');
var dir = path.join(__dirname, 'resolver');
var res = resolveSync('./baz', { basedir: dir });
t.equal(res, path.join(dir, 'baz', 'quux.js'), 'resolves correctly with null homedir');
t.end();
});
+112
View File
@@ -0,0 +1,112 @@
'use strict';
var os = require('os');
var test = require('tape');
var mockProperty = require('mock-property');
var envKeys = ['HOME', 'USERPROFILE', 'HOMEDRIVE', 'HOMEPATH', 'LOGNAME', 'USER', 'LNAME', 'USERNAME'];
function mockEnv(t, key, value) {
var has = key in process.env;
var orig = process.env[key];
if (arguments.length > 2) {
process.env[key] = value;
} else {
delete process.env[key];
}
t.teardown(function () {
if (has) {
process.env[key] = orig;
} else {
delete process.env[key];
}
});
}
function clearEnv(t) {
for (var i = 0; i < envKeys.length; i++) {
mockEnv(t, envKeys[i]);
}
}
function getFallback(t) {
t.teardown(mockProperty(os, 'homedir', { value: undefined }));
var homedirPath = require.resolve('../lib/homedir');
t.teardown(mockProperty(require.cache, homedirPath, { 'delete': true }));
return require('../lib/homedir');
}
test('homedir fallback', function (t) {
t.test('win32: HOMEDRIVE without HOMEPATH does not produce a false concatenation', function (st) {
clearEnv(st);
st.teardown(mockProperty(process, 'platform', { value: 'win32' }));
var homedir = getFallback(st);
mockEnv(st, 'HOMEDRIVE', 'C:');
st.equal(homedir(), null, 'returns null when only HOMEDRIVE is set');
st.end();
});
t.test('win32: HOMEPATH without HOMEDRIVE does not produce a false concatenation', function (st) {
clearEnv(st);
st.teardown(mockProperty(process, 'platform', { value: 'win32' }));
var homedir = getFallback(st);
mockEnv(st, 'HOMEPATH', '\\Users\\foo');
st.equal(homedir(), null, 'returns null when only HOMEPATH is set');
st.end();
});
t.test('win32: HOMEDRIVE + HOMEPATH both set returns concatenation', function (st) {
clearEnv(st);
st.teardown(mockProperty(process, 'platform', { value: 'win32' }));
var homedir = getFallback(st);
mockEnv(st, 'HOMEDRIVE', 'C:');
mockEnv(st, 'HOMEPATH', '\\Users\\foo');
st.equal(homedir(), 'C:\\Users\\foo', 'returns concatenated drive and path');
st.end();
});
t.test('win32: USERPROFILE takes precedence over HOMEDRIVE+HOMEPATH', function (st) {
clearEnv(st);
st.teardown(mockProperty(process, 'platform', { value: 'win32' }));
var homedir = getFallback(st);
mockEnv(st, 'USERPROFILE', 'C:\\Users\\bar');
mockEnv(st, 'HOMEDRIVE', 'C:');
mockEnv(st, 'HOMEPATH', '\\Users\\foo');
st.equal(homedir(), 'C:\\Users\\bar', 'returns USERPROFILE');
st.end();
});
t.test('win32: falls back to HOME when HOMEDRIVE/HOMEPATH are partial', function (st) {
clearEnv(st);
st.teardown(mockProperty(process, 'platform', { value: 'win32' }));
var homedir = getFallback(st);
mockEnv(st, 'HOME', 'C:\\Users\\baz');
mockEnv(st, 'HOMEDRIVE', 'C:');
st.equal(homedir(), 'C:\\Users\\baz', 'falls back to HOME');
st.end();
});
t.end();
});
+24
View File
@@ -0,0 +1,24 @@
var test = require('tape');
var path = require('path');
var resolve = require('../');
test('synchronous pathfilter', function (t) {
var res;
var resolverDir = __dirname + '/pathfilter/deep_ref';
function pathFilter(pkg, x, remainder) {
t.equal(pkg.version, '1.2.3');
t.equal(x, path.join(resolverDir, 'node_modules', 'deep', 'ref'));
t.equal(remainder, 'ref');
return 'alt';
}
res = resolve.sync('deep/ref', { basedir: resolverDir });
t.equal(res, path.join(resolverDir, 'node_modules', 'deep', 'ref.js'));
res = resolve.sync('deep/deeper/ref', { basedir: resolverDir });
t.equal(res, path.join(resolverDir, 'node_modules', 'deep', 'deeper', 'ref.js'));
res = resolve.sync('deep/ref', { basedir: resolverDir, pathFilter: pathFilter });
t.equal(res, path.join(resolverDir, 'node_modules', 'deep', 'alt.js'));
t.end();
});