-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use less restrictive license, docs, test action
- Loading branch information
Showing
9 changed files
with
134 additions
and
540 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: update-dependencies | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "42 19 * * *" | ||
|
||
jobs: | ||
update-dependencies: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: vx.x.x | ||
- name: Update dependencies | ||
run: | | ||
export DATA=deno task update | tail -n 1 | tr -dc '0-9' | ||
echo "::set-env name=DATA::$DATA" | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v3 | ||
id: pr | ||
with: | ||
commit-message: "Update dependencies" | ||
title: Update dependencies | ||
body: > | ||
Updated $DATA dependencies | ||
Generated by [deno-outdated](https://github.com/LeoDog896/deno-outdated). | ||
branch: deno-dependency-updates | ||
author: GitHub <[email protected]> | ||
delete-branch: true | ||
- name: Retrieve commit sha | ||
id: commit | ||
run: | | ||
echo "::set-output name=sha::$(git rev-parse HEAD)" | ||
- name: Set commit status with pending | ||
uses: Sibz/github-status-action@v1 | ||
with: | ||
authToken: ${{ secrets.GITHUB_TOKEN }} | ||
context: "Basic tests" | ||
state: "pending" | ||
sha: ${{ steps.commit.outputs.sha }} | ||
- name: Basic tests | ||
id: test | ||
continue-on-error: true | ||
run: | | ||
deno task test | ||
- name: Set commit status with outcome | ||
uses: Sibz/github-status-action@v1 | ||
with: | ||
authToken: ${{ secrets.GITHUB_TOKEN }} | ||
context: "Basic tests" | ||
description: "To run other CI actions close/reopen this PR" | ||
state: ${{ steps.test.outcome }} | ||
sha: ${{ steps.commit.outputs.sha }} |
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 |
---|---|---|
|
@@ -4,8 +4,6 @@ | |
|
||
Pins your dependencies to the latest version & updates existing ones. | ||
|
||
Also check out: [uud](https://github.com/hayd/deno-udd) | ||
|
||
```bash | ||
deno install --allow-read=./ --allow-net --allow-write=./ -f -n=deno-outdated https://deno.land/x/deno_outdated/cli.ts | ||
``` | ||
|
@@ -39,13 +37,18 @@ const x = 'https://deno.land/[email protected]/testing/asserts.ts' // i-deno-outdated | |
|
||
Currently works with: | ||
|
||
- https://deno.land/x | ||
- https://deno.land/ | ||
- https://esm.sh/ | ||
- https://cdn.jsdelivr.net | ||
- https://unpkg.com | ||
|
||
(Want to add more? Contribute to `regex.ts`) | ||
|
||
## What's the difference between this and [UDD](https://github.com/hayd/deno-udd)? | ||
|
||
This tool aims to be similar to deno native tools such as `deno fmt` and | ||
`deno lint`, or aka shellable | ||
|
||
## Internal layout | ||
|
||
Updating works by finding URLs in a source file, removing their version | ||
|
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,9 +1,14 @@ | ||
import { Command } from "https://deno.land/x/[email protected]/command/mod.ts"; | ||
import { basename, join } from "https://deno.land/std@0.152.0/path/mod.ts"; | ||
import { basename, join } from "https://deno.land/std@0.153.0/path/mod.ts"; | ||
import { findAndReplace } from "./change.ts"; | ||
|
||
/** | ||
* Recursively find all files in a directory | ||
* @param path The starting parent path | ||
* @param ignore The files to ignore | ||
*/ | ||
export async function* recursiveReaddir( | ||
path: string, | ||
path = Deno.cwd(), | ||
ignore: string[] = [], | ||
): AsyncGenerator<string, void> { | ||
for await (const dirEntry of Deno.readDir(path)) { | ||
|
@@ -18,17 +23,15 @@ export async function* recursiveReaddir( | |
} | ||
|
||
async function update( | ||
quiet: boolean, | ||
check: boolean, | ||
quiet = false, | ||
check = false, | ||
ignore: string[] = [], | ||
lineIgnore: string, | ||
lineIgnore = "i-deno-outdated", | ||
debug = false, | ||
) { | ||
let count = 0; | ||
// TODO .gitignore | ||
for await (const file of recursiveReaddir(Deno.cwd(), [...ignore, ".git"])) { | ||
if (debug) console.log(`Scanning ${file}`); | ||
|
||
if (ignore.includes(basename(file))) { | ||
if (debug) console.log(`Ignoring ${file}`); | ||
continue; | ||
|
@@ -59,32 +62,25 @@ async function update( | |
|
||
await new Command() | ||
.name("deno-outdated") | ||
.version("0.0.1") | ||
.option("-d --debug", "Show all scanned files", { | ||
default: false, | ||
}) | ||
.option("-q --quiet", "Silence any output", { | ||
default: false, | ||
}) | ||
.option("-i --ignore [ignore...:string]]", "list of files to ignore", { | ||
separator: " ", | ||
}) | ||
.version("0.3.0") | ||
.option("-d, --debug", "Show all scanned files") | ||
.option("-q, --quiet", "Silence any output") | ||
.option( | ||
"-c, --check", | ||
"Check files without updating them", | ||
) | ||
.option( | ||
"-l --line-ignore [line-ignore:string]", | ||
"The text of the comment to ignore", | ||
{ | ||
default: "i-deno-outdated", | ||
}, | ||
) | ||
.option( | ||
"-c --check", | ||
"True if the editor shouldn't change files and tell you about outdated dependencies.", | ||
{ | ||
default: false, | ||
}, | ||
) | ||
.option("-i --ignore [ignore...:string]]", "list of files to ignore", { | ||
separator: " ", | ||
}) | ||
.description( | ||
"Check for outdated dependencies for deno.land/x and other various 3rd party vendors", | ||
"Check and update outdated dependencies for various 3rd party vendors", | ||
) | ||
.action(async ({ quiet, ignore, lineIgnore, debug, check }) => { | ||
const count = await update( | ||
|
@@ -94,6 +90,6 @@ await new Command() | |
typeof lineIgnore === "string" ? lineIgnore : "i-deno-outdated", | ||
debug, | ||
); | ||
if (!quiet) console.log(`Updated ${count} file${count === 1 ? "" : "s"}`); | ||
if (!quiet) console.log(`${check ? "Checked" : "Updated"} ${count} file${count === 1 ? "" : "s"}`); | ||
}) | ||
.parse(Deno.args); |
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ import { | |
assert, | ||
assertEquals, | ||
assertNotEquals, | ||
} from "https://deno.land/std@0.152.0/testing/asserts.ts"; | ||
} from "https://deno.land/std@0.153.0/testing/asserts.ts"; | ||
|
||
Deno.test("Source code translation works", async () => { | ||
const source = "const x = 'https://deno.land/[email protected]/testing/asserts.ts'"; // i-deno-outdated | ||
|
@@ -27,7 +27,10 @@ const x = 'https://deno.land/[email protected]/testing/asserts.ts' // i-deno-outdated | |
// ensure that the escape character bug does not exist | ||
assert(!lines[0].includes("%22")); | ||
|
||
assert(!lines[0].includes("i-deno-outdated"), "i-deno-outdated exists in the first line of the source string") | ||
assert( | ||
!lines[0].includes("i-deno-outdated"), | ||
"i-deno-outdated exists in the first line of the source string", | ||
); | ||
assertNotEquals(lines[0], sourceLines[0]); // the deno-outdated line exists only exists in the code and not the string (as proven above) | ||
assertEquals(lines[1], sourceLines[1]); | ||
|
||
|
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,10 +1,20 @@ | ||
import { apply } from "./regex.ts"; | ||
import { checkRedirect } from "./redirect.ts"; | ||
|
||
export async function updateOrSelf(url: string): Promise<string> { | ||
return (await checkRedirect(apply(url) ?? url)) ?? url; | ||
/** | ||
* Removes any versioning from a URL and finds the latest redirect for it | ||
* @param url The URL to check against | ||
* @returns The updated URL or undefined if it wasn't updated. | ||
*/ | ||
export async function update(url: string): Promise<string | undefined> { | ||
return (await checkRedirect(apply(url) ?? url)); | ||
} | ||
|
||
export async function update(url: string): Promise<string | undefined> { | ||
return (await checkRedirect(apply(url) ?? url)) ?? undefined; | ||
/** | ||
* Removes any versioning from a URL and finds the latest redirect for it | ||
* @param url The URL to check against | ||
* @returns The url whether it was updated or not. | ||
*/ | ||
export async function updateOrSelf(url: string): Promise<string> { | ||
return await update(url) ?? url; | ||
} |