Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
citreae535 committed Mar 23, 2023
0 parents commit 038df3f
Show file tree
Hide file tree
Showing 16 changed files with 1,584 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node_modules
out

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
11 changes: 11 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.github/
.vscode/
node_modules/
src/
out/*.map
.gitignore
rome.json
tsconfig.json
pnpm-lock.yaml
*.md
*.vsix
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Support for Cargo's sparse protocol and sparse cache index.
- Support for crates.io remote and local mirrors.
- Support for alternate registries that use the sparse protocol.
- Support for package renaming.

### Changed

- Bumped minimum VSCode version from 1.45 to 1.72.
- Hover messages on the decorators are simplified.
- Logs are written to VSCode's output channel, and they are more structured and detailed.
- Replaced handwritten TOML parser with `toml-eslint-parser`.
- Replaced handwritten semver parser with `semver`.
- Changed the HTTP client library from unmaintained `request-promise` to `node-fetch`.
- Changed the linter from deprecated `tslint` to `rome`.
- Changed the bundler from `webpack` to `esbuild`.
- Changed the package manager from `npm` to `pnpm`.

### Removed

- Support for Cargo's Git index protocol and cache.
- All actions, commands, and completions.
- Decorator customizations.
- Unused dependencies and dead code.
- Status bar items are temporarily removed.
- Unit tests are removed for now.
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2018 Seray Uzgur
Copyright (c) 2023 citreae535

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Sparse Crates

**Sparse Crates**, an extension helping Rust developers spot outdated dependencies in `Cargo.toml` manifest files.

This is a fork of the extension [**crates**](https://github.com/serayuzgur/crates) by [Seray Uzgur](https://github.com/serayuzgur) with significant changes and rewrites.

## New Features

- Cargo's new [sparse protocol](https://rust-lang.github.io/rfcs/2789-sparse-index.html)
- Remote and local crates.io mirrors (HTTP/HTTPS/file URLs)
- Alternate registries (HTTP/HTTPS/file URLs)
- Package rename
- Detailed logs in VSCode output channel

## Planned Features and TODO

- Status bar items and notifications
- Parse and show dependency versions from Cargo.lock
- Units tests

## Configurations

- `sparse-crates.useCargoCache`: If true, Cargo's index cache is searched first before the registries. Cache must be stored in the sparse format.

- `sparse-crates.cratesIoIndex`: The index URL of the default crates.io registry. Change this value only if you use a remote or local mirror of crates.io. The index must use the sparse protocol. Use a file URL if the mirror is on disk.

- `sparse-crates.cratesIoCache`: The index cache directory of the default crates.io registry. Change this value only if you use a remote or local mirror of crates.io. You can find the directories at CARGO_HOME/registry/index.

- `sparse-crates.registries`: An array of alternate registries. Each item is an object with two required and two optional properties.
```json
{
"name": "(Required) The name of the registry. The name of the registry. It must be the same as your dependencies' \"registry\" key.",
"index": "(Required) The index URL of the registry. The index must use the sparse protocol. Use a file URL if the registry is on disk.",
"cache": "(Optional) Cargo's index cache directory of the registry. You can find the directories at CARGO_HOME/registry/index. Cache is not searched for the registry if this property is not given.",
"docs": "(Optional) The docs URL of the registry, if one exists. The link to the docs of a specific version of a crate is obtained by `${docs}${name}/${version}`. This is only used when rendering hover messages on the decorators."
}
```

## Thanks

- [Seray Uzgur](https://github.com/serayuzgur), the original author of [**crates**](https://github.com/serayuzgur/crates)
109 changes: 109 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"private": true,
"name": "sparse-crates",
"version": "0.1.0",
"publisher": "citreae535",
"engines": {
"vscode": "^1.72.0",
"node": ">=16"
},
"license": "MIT",
"displayName": "Sparse Crates",
"description": "Helps Rust developers spot outdated dependencies in `Cargo.toml` manifest files. Supports crates.io, alternate registries, and crates.io mirrors that offers the sparse protocol.",
"categories": [
"Programming Languages"
],
"keywords": [
"rust",
"cargo",
"crates"
],
"main": "./out/extension.cjs",
"activationEvents": [
"workspaceContains:**/Cargo.toml"
],
"contributes": {
"configuration": {
"title": "Sparse Crates",
"properties": {
"sparse-crates.useCargoCache": {
"type": "boolean",
"scope": "resource",
"default": true,
"description": "If true, Cargo's index cache is searched first before the registries. Cache must be stored in the sparse format."
},
"sparse-crates.cratesIoIndex": {
"type": "string",
"scope": "resource",
"format": "uri",
"default": "https://index.crates.io/",
"description": "The index URL of the default crates.io registry. Change this value only if you use a mirror of crates.io. The index must use the sparse protocol. Use a file URL if the mirror is on disk."
},
"sparse-crates.cratesIoCache": {
"type": "string",
"scope": "resource",
"default": "index.crates.io-6f17d22bba15001f",
"markdownDescription": "The index cache directory of the default crates.io registry. Change this value only if you use a remote or local mirror of crates.io. You can find the directories at CARGO_HOME/registry/index."
},
"sparse-crates.registries": {
"type": "array",
"scope": "resource",
"items": {
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "The name of the registry. It must be the same as your dependencies' \"registry\" key."
},
"index": {
"type": "string",
"format": "uri",
"description": "The index URL of the registry. The index must use the sparse protocol. Use a file URL if the registry is on disk."
},
"cache": {
"type": "string",
"description": "Cargo's index cache directory of the registry. You can find the directories at CARGO_HOME/registry/index. Cache is not searched for the registry if this property is not given."
},
"docs": {
"type": "string",
"format": "uri",
"description": "The docs URL of the registry, if one exists. The link to the docs of a specific version of a crate is obtained by `${docs}${name}/${version}`. This is only used when rendering hover messages on the decorators."
}
},
"required": [
"name",
"index"
]
},
"default": [],
"description": "A list of alternate registries. The index of an alternate registry must support the sparse protocol."
}
}
}
},
"extensionKind": [
"workspace"
],
"type": "module",
"scripts": {
"vscode:prepublish": "pnpm run esbuild-base --minify",
"esbuild-base": "tsc && rome ci src && esbuild src/extension.ts --outfile=out/extension.cjs --bundle --external:vscode --platform=node --target=node16",
"build": "pnpm run esbuild-base --sourcemap",
"watch": "pnpm run esbuild-base --sourcemap --watch",
"package": "pnpm vsce package --no-dependencies"
},
"devDependencies": {
"@types/eslint": "^8.21.3",
"@types/node": "^18.15.3",
"@types/semver": "^7.3.13",
"@types/vscode": "1.72.0",
"esbuild": "^0.17.12",
"rome": "^11.0.0",
"typescript": "^5.0.2"
},
"dependencies": {
"node-fetch": "^3.3.1",
"semver": "^7.3.8",
"toml-eslint-parser": "^0.5.0"
}
}
Loading

0 comments on commit 038df3f

Please sign in to comment.