Skip to content

Adding support for NPM as an extension source#121

Open
michaeljolley wants to merge 1 commit into
mainfrom
dev/mjolley/npm-source
Open

Adding support for NPM as an extension source#121
michaeljolley wants to merge 1 commit into
mainfrom
dev/mjolley/npm-source

Conversation

@michaeljolley

Copy link
Copy Markdown
Collaborator

This pull request adds support for validating npm packages as extension install sources. The changes update the schema definitions to allow specifying npm packages, update documentation accordingly, and enhance the validation script to check npm package existence and provide helpful warnings.

Schema and documentation updates:

  • .github/schemas/extension.schema.json and .github/schemas/gallery.schema.json: Added support for specifying npm packages as valid install sources by allowing "type": "npm" with an id field. [1] [2]
  • .github/PULL_REQUEST_TEMPLATE.md: Updated checklist to mention npm as a valid install source.

Validation script enhancements:

  • .github/scripts/validate.py: Added validate_npm_source function to check npm package existence via the npm registry, including proper URL encoding for scoped packages. It also warns if the package name does not match the extension title.
  • .github/scripts/validate.py: Integrated npm validation into the main validation flow for extensions specifying an npm source.
  • .github/scripts/validate.py: Added necessary imports and constants for npm registry access. [1] [2]

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds npm as a supported extension install source across the repository’s JSON schemas and CI validation, enabling extensions to reference npm packages in installSources.

Changes:

  • Extended extension.schema.json and gallery.schema.json to allow installSources entries with "type": "npm" and an id.
  • Updated the PR submission checklist to include npm as a valid install source.
  • Added npm registry validation in .github/scripts/validate.py (existence check + warning behavior).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
.github/scripts/validate.py Adds npm registry validation and integrates it into extension validation flow.
.github/schemas/gallery.schema.json Allows gallery entries to specify npm install sources.
.github/schemas/extension.schema.json Allows extension manifests to specify npm install sources.
.github/PULL_REQUEST_TEMPLATE.md Updates checklist to mention npm as an install source option.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +427 to +435
# The registry "name" field is the canonical package name; compare it to
# the extension title as a loose sanity check.
registry_name = data.get("name", "")
if registry_name and registry_name.strip().lower() != extension_title.strip().lower():
warnings.append(
f"{display_path}: npm package name mismatch — "
f"npm has \"{registry_name}\" but extension.json title is "
f"\"{extension_title}\""
)
# Scoped packages (e.g. "@scope/name") must have the slash percent-encoded
# in the URL, but the leading "@" must remain unencoded.
encoded_id = urllib.parse.quote(package_id, safe="@")
url = f"{NPM_PKGS_URL}{encoded_id}"
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.

3 participants