-
Notifications
You must be signed in to change notification settings - Fork 17
Update implementions index.js and README. #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a2c8d6b
Bring over w3c/implementations/index.js.
BigBlueHat b628335
Update README intro, TOC, and Tags header.
BigBlueHat 0b89e26
More README matching with the VC WG variant.
BigBlueHat 09fd679
Add latest local testing setup info.
BigBlueHat e5cb9f6
Simplify tags section.
BigBlueHat 64fd9a6
Fix contributing and copyright sections.
BigBlueHat 049fc3f
Add Test Suite Settings section to README.
BigBlueHat 1eeed54
Fix dates & copyright holder list in README.
BigBlueHat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,52 @@ | ||
/*! | ||
* Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved. | ||
/* | ||
* Copyright 2022-2025 Digital Bazaar, Inc. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
import appRoot from 'app-root-path'; | ||
import {createRequire} from 'node:module'; | ||
import {join} from 'node:path'; | ||
|
||
const require = createRequire(import.meta.url); | ||
const requireDir = require('require-dir'); | ||
// get all the remote implementations in this dir | ||
const remote = Object.values(requireDir('./')); | ||
|
||
const dir = requireDir('./'); | ||
|
||
// gets local implementations from an optional config file | ||
const getLocalImplementations = () => { | ||
// gets local manifests from an optional config file | ||
const getLocalManifest = fileName => { | ||
try { | ||
const path = join( | ||
appRoot.toString(), '.localImplementationsConfig.cjs'); | ||
appRoot.toString(), fileName); | ||
return require(path); | ||
} catch(e) { | ||
if(e?.code === 'MODULE_NOT_FOUND') { | ||
return []; | ||
return {}; | ||
} | ||
throw e; | ||
} | ||
}; | ||
|
||
export const implementerFiles = Object.values(dir) | ||
.concat(getLocalImplementations()); | ||
const localConfig = getLocalManifest('localConfig.cjs'); | ||
export const localSettings = (Object.keys(localConfig).length > 0) ? | ||
// if there is a localConfig.settings overwrite local defaults | ||
{...{enableInteropTests: false, testAllImplementations: false}, | ||
...localConfig?.settings} : | ||
// otherwise, return the global defaults | ||
// FIXME: ...consider renaming `localSettings` as it can hold global ones... | ||
{enableInteropTests: true, testAllImplementations: true}; | ||
|
||
// get localConfig and look for an implementations property | ||
let local = localConfig?.implementations || []; | ||
// it's an easy typo to set `implementations` to an object...instead of an array | ||
if(!Array.isArray(local)) { | ||
local = [local]; | ||
} | ||
// concat all the implementation manifests together | ||
const all = remote.concat(local); | ||
|
||
// if local implementations are defined only return local implementations | ||
export const implementerFiles = local.length ? | ||
// unless testAllImplementations is true...in which case, include them all | ||
(localSettings.testAllImplementations === true ? all : local) : | ||
all; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.