Skip to content

Support non node environment validation#24

Open
brenthosie wants to merge 5 commits intomasterfrom
support-non-node-environment-validation
Open

Support non node environment validation#24
brenthosie wants to merge 5 commits intomasterfrom
support-non-node-environment-validation

Conversation

@brenthosie
Copy link
Member

Description

Changes to allow validator to still be the "source of truth for validation" but can be used in a web context.

Related Issue

https://jira.corp.adobe.com/browse/PDCL-14485

Motivation and Context

This was a node-only project and wouldn't work due to it's inherent step of gathering files from the file system.

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Brent Hosie added 5 commits March 5, 2026 16:21
Split validation into schema, file checks, and Node-only file gathering.
The default export is unchanged for Node consumers.

Add a ./validatesubpath that takes (descriptor, fileList) so browser consumers can run
full validation without Node APIs.

- @adobe/reactor-validator/schema (schema validation only)
- @adobe/reactor-validator/files (file validation with caller-provided file list).
…onsumers, be a little more restrictive with the viewBasePath.
@brenthosie brenthosie requested a review from markhicken March 6, 2026 17:36
Copy link
Member

@markhicken markhicken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the windows path change thing and maybe the mobile validation. Everything else is probably optional. Let me know if you want to chat about anything.

Nice update!

};

var joinPath = function() {
return [].slice.call(arguments).filter(Boolean).join('/').replace(/\/+/g, '/');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably fix this to work for Windows as well.

gatherFilesInNodeEnvironment uses pathUtil.relative() which returns backslash-separated paths on windows. But, validateFiles.js constructs lookup paths using forward slashes via joinPath().

On windows, the fileSet would contain src\view\config.html but the validator would look for src/view/config.html causing false validation failures.

Looks like the old code avoided this because it used pathUtil.resolve() everywhere.

In gatherFilesInNodeEnvironment we could normalize separators to /...
result.push(relPath.replace(/\\/g, '/'));

...or normalize the file list in validateFiles.js when building the Set.

if (!viewBasePath) return;

var viewBaseNorm = viewBasePath.replace(/\/+$/, '');
if (fileSet.has(viewBaseNorm)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI - AI found a non-urgent edge case...

This checks if viewBaseNorm appears as an exact file in the set. If it does, it's assumed to be a file (not a directory). This is a reasonable heuristic for real-world extension packages. However, the redundant p === viewBaseNorm check at line 38 inside the some() can never succeed at that point (if the path were in the set as a file, we'd have already returned an error). Not harmful, but slightly confusing.

return result;
};

module.exports = gatherFilesInNodeEnvironment;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

web-manifest.test.js and edge-manifest.test.js do cover this code, but there are no direct tests verifying:

  • Recursive directory traversal
  • Handling of symlinks, empty directories, or special characters in filenames
  • Path separator output on different OS

Maybe consider if we need unit tests for these cases.

var schemas = {
web: require('@adobe/reactor-turbine-schemas/schemas/extension-package-web.json'),
edge: require('@adobe/reactor-turbine-schemas/schemas/extension-package-edge.json'),
mobile: require('@adobe/reactor-turbine-schemas/schemas/extension-package-mobile.json')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Web and edge have test fixtures and tests, but I don't think mobile is used, right?

"version": "3.0.0-beta.5",
"description": "Validates a Tags extension package.",
"main": "lib/index.js",
"exports": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI thoughts:

exports field may need a wildcard or additional entries

The exports field only exposes . and ./validate. If consumers were previously doing deep imports like require('@adobe/reactor-validator/lib/index'), those would now fail with ERR_PACKAGE_PATH_NOT_EXPORTED. This is appropriate for a semver major bump but worth documenting in migration notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants