-
Notifications
You must be signed in to change notification settings - Fork 2
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
pkg.json: test coverage, reference impl #44
Draft
justinmk
wants to merge
5
commits into
main
Choose a base branch
from
pkgjson
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
714bb92
pkg.json: test with NPM's package.json parser
justinmk 64f5d78
fix: generate_json_schema.lua removes final newline
justinmk 4e493c8
use "nvim -l" instead of "lua"
justinmk 208acf5
build: eliminate "lua-cjson" dependency
justinmk 1628a29
WIP: schema
justinmk 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 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 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 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 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,117 +1,117 @@ | ||
{ | ||
"type": "object", | ||
"title": "packspec", | ||
"required": [ | ||
"package", | ||
"source" | ||
], | ||
"additionalProperties": false, | ||
"properties": { | ||
"packspec": { | ||
"type": "string", | ||
"description": "The current specification version. (0.1.0) at this time.", | ||
"pattern": "^(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))*$" | ||
}, | ||
"dependencies": { | ||
"patternProperties": { | ||
".*": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"releases_only": { | ||
"description": "Whether the package manager should only resolve version\nconstraints to include tagged releases.", | ||
"type": "boolean" | ||
}, | ||
"version": { | ||
"type": "string", | ||
"description": "Version constraints on the package.\n * Accepted operators are the relational operators of Lua:\n == \\~= < > <= >= , as well as a special operator, \\~>,\n inspired by the \"pessimistic operator\" of RubyGems\n (\"\\~> 2\" means \">= 2, < 3\"; \"~> 2.4\" means \">= 2.4, < 2.5\").\n No operator means an implicit == (i.e., \"lfs 1.0\" is the\n same as \"lfs == 1.0\"). \"lua\" is an special dependency name;\n it matches not a rock, but the version of Lua in use.\n Multiple version constraints can be joined with a `comma`,\n e.g. `\"neovim >= 5.0, < 7.0\"`.\n * If no version is specified, then HEAD is assumed valid.\n * If no upper bound is specified, then any commit after the\n tag corresponding to the lower bound is assumed valid. The\n commit chosen is up to the plugin manager's discretion, but\n implementers are strongly encouraged to always use the\n latest valid commit.\n * If an upper bound is specified, then the the tag\n corresponding to that upper bound is the latest commit that\n is valid", | ||
"pattern": "^((==|~=|<|>|<=|>=|~>)\\s*)?(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))*(\\s*,\\s*((==|~=|<|>|<=|>=|~>)\\s*)?(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))*)*$" | ||
}, | ||
"source": { | ||
"type": "string", | ||
"description": "Source of the dependency. See previous `source` description.", | ||
"pattern": "^\\w+:\/\/" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"version": { | ||
"type": "string", | ||
"description": "The version of the package. Should obey semantic versioning\nconventions, for example `0.1.0`. Plugins should have a git commit\nwith a `tag` matching this version. For all version identifiers,\nimplementation should check for a `version` prefixed with `v` in the\ngit repository, as this is a common convention.", | ||
"pattern": "^(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))*$" | ||
}, | ||
"external_dependencies": { | ||
"description": "Like dependencies, this specifies packages which are required for the\npackage but should *not* be managed by the Neovim package manager, such\nas `gcc` or `cmake`. Package managers are encouraged to provide a\nnotification to the user if the dependency is not available.", | ||
"patternProperties": { | ||
".*": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"version": { | ||
"type": "string", | ||
"description": "Same as `dependencies`", | ||
"pattern": "^((==|~=|<|>|<=|>=|~>)\\s*)?(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))*(\\s*,\\s*((==|~=|<|>|<=|>=|~>)\\s*)?(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))*)*$" | ||
"pattern": "^((==|~=|<|>|<=|>=|~>)\\s*)?(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))*(\\s*,\\s*((==|~=|<|>|<=|>=|~>)\\s*)?(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))*)*$", | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"type": "object" | ||
} | ||
} | ||
}, | ||
"description": "Like dependencies, this specifies packages which are required for the\npackage but should *not* be managed by the Neovim package manager, such\nas `gcc` or `cmake`. Package managers are encouraged to provide a\nnotification to the user if the dependency is not available." | ||
}, | ||
"package": { | ||
"description": "The name of the package", | ||
"packspec": { | ||
"description": "The current specification version. (0.1.0) at this time.", | ||
"pattern": "^(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))*$", | ||
"type": "string" | ||
}, | ||
"package": { | ||
"type": "string", | ||
"description": "The name of the package" | ||
}, | ||
"description": { | ||
"additionalProperties": false, | ||
"description": "Description of the package", | ||
"properties": { | ||
"summary": { | ||
"description": "Short description of the package, typically less than 100 character\nlong.", | ||
"type": "string" | ||
"type": "string", | ||
"description": "Short description of the package, typically less than 100 character\nlong." | ||
}, | ||
"homepage": { | ||
"description": "Homepage of the package. In most cases this will be the GitHub URL.", | ||
"type": "string" | ||
"type": "string", | ||
"description": "Homepage of the package. In most cases this will be the GitHub URL." | ||
}, | ||
"detailed": { | ||
"type": "string", | ||
"description": "Long-form description of the package, this should convey the\npackage's principal functionality to the user without being as\ndetailed as the package readme." | ||
}, | ||
"license": { | ||
"type": "string", | ||
"description": "This is [SPDX](https:\/\/spdx.org\/licenses\/) license identifier. Dual\nlicensing is indicated via joining the relevant licenses via `\/`." | ||
}, | ||
"author": { | ||
"additionalProperties": false, | ||
"description": "Author of the package", | ||
"properties": { | ||
"email": { | ||
"type": "string", | ||
"description": "Author email" | ||
}, | ||
"name": { | ||
"description": "Author name", | ||
"type": "string", | ||
"description": "Author name" | ||
} | ||
}, | ||
"type": "object" | ||
} | ||
}, | ||
"type": "object" | ||
}, | ||
"version": { | ||
"description": "The version of the package. Should obey semantic versioning\nconventions, for example `0.1.0`. Plugins should have a git commit\nwith a `tag` matching this version. For all version identifiers,\nimplementation should check for a `version` prefixed with `v` in the\ngit repository, as this is a common convention.", | ||
"pattern": "^(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))*$", | ||
"type": "string" | ||
}, | ||
"$schema": { | ||
"type": "string", | ||
"description": "The optional json schema URI for validation with json-language-server." | ||
}, | ||
"dependencies": { | ||
"patternProperties": { | ||
".*": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"version": { | ||
"description": "Version constraints on the package.\n * Accepted operators are the relational operators of Lua:\n == \\~= < > <= >= , as well as a special operator, \\~>,\n inspired by the \"pessimistic operator\" of RubyGems\n (\"\\~> 2\" means \">= 2, < 3\"; \"~> 2.4\" means \">= 2.4, < 2.5\").\n No operator means an implicit == (i.e., \"lfs 1.0\" is the\n same as \"lfs == 1.0\"). \"lua\" is an special dependency name;\n it matches not a rock, but the version of Lua in use.\n Multiple version constraints can be joined with a `comma`,\n e.g. `\"neovim >= 5.0, < 7.0\"`.\n * If no version is specified, then HEAD is assumed valid.\n * If no upper bound is specified, then any commit after the\n tag corresponding to the lower bound is assumed valid. The\n commit chosen is up to the plugin manager's discretion, but\n implementers are strongly encouraged to always use the\n latest valid commit.\n * If an upper bound is specified, then the the tag\n corresponding to that upper bound is the latest commit that\n is valid", | ||
"pattern": "^((==|~=|<|>|<=|>=|~>)\\s*)?(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))*(\\s*,\\s*((==|~=|<|>|<=|>=|~>)\\s*)?(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))*)*$", | ||
"type": "string" | ||
}, | ||
"email": { | ||
"description": "Author email", | ||
"releases_only": { | ||
"type": "boolean", | ||
"description": "Whether the package manager should only resolve version\nconstraints to include tagged releases." | ||
}, | ||
"source": { | ||
"description": "Source of the dependency. See previous `source` description.", | ||
"pattern": "^\\w+:\/\/", | ||
"type": "string" | ||
} | ||
}, | ||
"type": "object", | ||
"description": "Author of the package", | ||
"additionalProperties": false | ||
}, | ||
"license": { | ||
"description": "This is [SPDX](https:\/\/spdx.org\/licenses\/) license identifier. Dual\nlicensing is indicated via joining the relevant licenses via `\/`.", | ||
"type": "string" | ||
}, | ||
"detailed": { | ||
"description": "Long-form description of the package, this should convey the\npackage's principal functionality to the user without being as\ndetailed as the package readme.", | ||
"type": "string" | ||
"type": "object" | ||
} | ||
}, | ||
"type": "object", | ||
"description": "Description of the package", | ||
"additionalProperties": false | ||
} | ||
}, | ||
"source": { | ||
"pattern": "^\\w+:\/\/", | ||
"type": "string", | ||
"description": "The URL of the package source archive. Examples:\n\"http:\/\/github.com\/downloads\/keplerproject\/wsapi\/wsapi-1.3.4.tar.gz\",\n\"git:\/\/github.com\/keplerproject\/wsapi.git\". Different protocols are\nsupported:\n\n * `luarocks:\/\/` - for luarocks packages\n * `file:\/\/` - for URLs in the local filesystem (note that for Unix\n paths, the root slash is the third slash, resulting in paths like\n \"file:\/\/\/full\/path\/filename\"\n * `git:\/\/` - for the Git source control manager\n * `git+https:\/\/` - for the Git source control manager when using\n repositories that need https:\/\/ URLs.\n * `git+ssh:\/\/` - for the Git source control manager when using\n repositories that need SSH login, such as [email protected]\/myrepo.\n * `http:\/\/` - for HTTP URLs\n * `https:\/\/` - for HTTPS URLs", | ||
"examples": [ | ||
"luarocks:\/\/argparse", | ||
"git:\/\/github.com\/nvim-lua\/plenary.nvim" | ||
] | ||
}, | ||
"$schema": { | ||
"description": "The optional json schema URI for validation with json-language-server.", | ||
], | ||
"description": "The URL of the package source archive. Examples:\n\"http:\/\/github.com\/downloads\/keplerproject\/wsapi\/wsapi-1.3.4.tar.gz\",\n\"git:\/\/github.com\/keplerproject\/wsapi.git\". Different protocols are\nsupported:\n\n * `luarocks:\/\/` - for luarocks packages\n * `file:\/\/` - for URLs in the local filesystem (note that for Unix\n paths, the root slash is the third slash, resulting in paths like\n \"file:\/\/\/full\/path\/filename\"\n * `git:\/\/` - for the Git source control manager\n * `git+https:\/\/` - for the Git source control manager when using\n repositories that need https:\/\/ URLs.\n * `git+ssh:\/\/` - for the Git source control manager when using\n repositories that need SSH login, such as [email protected]\/myrepo.\n * `http:\/\/` - for HTTP URLs\n * `https:\/\/` - for HTTPS URLs", | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"description": "A package specification for Neovim" | ||
"title": "packspec", | ||
"description": "A package specification for Neovim", | ||
"required": [ | ||
"package", | ||
"source" | ||
], | ||
"type": "object" | ||
} |
This file contains 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,12 +1,9 @@ | ||
#! /usr/bin/env lua5.1 | ||
|
||
-- local cjson = require('cjson') | ||
local schema = require('packspec.schema') | ||
-- TODO(justinmk): could eliminate format_cjson if `vim.json.encode()` had formatting options. | ||
local format_json = require('utils.format_cjson') | ||
local encoded_json = format_json(schema, "\n", " ") | ||
|
||
local file = io.open('schema/packspec_schema.json', 'w') | ||
|
||
local encoded_json = format_json(schema, "\n", " ")..'\n' | ||
local file = assert(io.open('schema/packspec_schema.json', 'w')) | ||
io.output(file) | ||
io.write(encoded_json) | ||
io.close(file) |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Test pkg.json against NPM's read-package-json library | ||
|
||
`pkg.json` tries to be a subset of NPM's `package.json` format. The tests in | ||
this directory test `pkg.json` samples using NPM's `read-package-json` library. | ||
|
||
To run the tests: | ||
|
||
cd test-npm/ | ||
npm ci | ||
npm run test |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
test-npm/
micro-project is just a way to get an idea of how closepkg.json
is topackage.json
. Ideally it would be a strict subset but probably can't be. Any divergences will be reflected in the test files here.