Skip to content

Commit

Permalink
Merge pull request #610 from nats-io/dependencies
Browse files Browse the repository at this point in the history
[LIC] updated dependencies.md
  • Loading branch information
aricart authored Oct 14, 2023
2 parents 29ce5ec + b82452e commit 00cbba6
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 4 deletions.
104 changes: 104 additions & 0 deletions bin/dependencies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright 2023 The NATS Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {
extname,
join,
resolve,
} from "https://deno.land/std@0.200.0/path/mod.ts";

// resolve the specified directories to fq
// let dirs = ["src", "nats-base-client", "jetstream", "bin"].map((n) => {
let dirs = ["."].map((n) => {
return resolve(n);
});

// collect a list of all the files
const files: string[] = [];
for (const d of dirs) {
for await (const fn of Deno.readDir(d)) {
// expand nested dirs
if (fn.isDirectory) {
dirs.push(join(d, fn.name));
continue;
} else if (fn.isFile) {
const ext = extname(fn.name);
if (ext === ".ts" || ext === ".js") {
files.push(join(d, fn.name));
}
}
}
}

const m = new Map<string, string[]>();

// process each file - remove extensions from requires/import
for (const fn of files) {
const data = await Deno.readFile(fn);
let txt = new TextDecoder().decode(data);
const iter = txt.matchAll(/from\s+"(\S+.[t|j]s)"/gim);
for (let s of iter) {
let dep = s[1];
if (dep.startsWith(`./`) || dep.startsWith(`../`)) {
// this is local code
continue;
}
if (dep.includes("nats-io/nats.deno")) {
// self dep
continue;
}
if (dep.includes("deno.land/x/nats@")) {
// this is self-reference
continue;
}
if (dep.includes("https://deno.land/x/nkeys.js@")) {
dep = "https://github.com/nats-io/nkeys.js";
}
if (dep.includes("nats-io/nkeys.js")) {
dep = "https://github.com/nats-io/nkeys.js";
}
if (dep.includes("nats-io/jwt.js")) {
dep = "https://github.com/nats-io/jwt.js";
}
if (dep.includes("deno.land/x/cobra@")) {
dep = "https://deno.land/x/cobra/mod.ts";
}
if (dep.includes("deno.land/x/cobra/")) {
dep = "https://deno.land/x/cobra/mod.ts";
}
if (dep.includes("deno.land/std@")) {
dep = "https://github.com/denoland/deno_std";
}

if (dep.includes("chiefbiiko/sha256")) {
dep = "https://github.com/chiefbiiko/sha256";
}
let v = m.get(dep);
if (!v) {
v = [];
}
v.push(fn);
m.set(dep, v);
}
}

const keys = Array.from(m.keys()).sort();
for (const k of keys) {
console.log(k);
const v = m.get(k);
for (const f of v!) {
console.log(`\t${f}`);
}
}
13 changes: 9 additions & 4 deletions dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

This file lists the dependencies used in this repository.

| Dependency | License |
| ------------------------------------------ | ----------- |
| https://deno.land/std@0.200.0/flags/mod.ts | MIT License |
| http://github.com/nats-io/nkeys.js | Apache-2.0 |
| Dependency | License |
| ------------------------------------ | ----------- |
| https://deno.land/std@0.200.0 | MIT License |
| https://deno.land/x/cobra | MIT License |
| https://deno.land/x/progress | MIT License |
| https://deno.land/x/emit | MIT License |
| http://github.com/nats-io/nkeys.js | Apache-2.0 |
| http://github.com/nats-io/jwt.js | Apache-2.0 |
| https://github.com/chiefbiiko/sha256 | Apache-2.0 |

0 comments on commit 00cbba6

Please sign in to comment.