Comparing version 0.5.1 to 0.6.0-rc.1
@@ -20,14 +20,4 @@ // src/cli/main.ts | ||
// src/scanner/index.ts | ||
function make_scanner(format) { | ||
if (format === "npm") { | ||
return transform; | ||
} | ||
throw new Error(`unknown format - ${format}`); | ||
} | ||
// src/presets/lodash.ts | ||
const check = (pkg) => pkg.startsWith("lodash.") || pkg === "lodash"; | ||
// src/common.ts | ||
const id = (a) => a; | ||
const always_false = () => false; | ||
@@ -38,2 +28,11 @@ function lookup(sample) { | ||
} | ||
function starts_with(s) { | ||
return (str) => str.startsWith(s); | ||
} | ||
function includes_with(s) { | ||
return (str) => str.includes(s); | ||
} | ||
function eqeqeq(b) { | ||
return (a) => a === b; | ||
} | ||
const split_by_comma = split_by(","); | ||
@@ -76,2 +75,35 @@ function split_by(by, trim = true) { | ||
// src/scanner/deno-info.ts | ||
const prefix2 = " npm:/"; | ||
const prefix_len = prefix2.length; | ||
const not_includes_with_star_AND_includes_with_prefix = and( | ||
not(includes_with("*")), | ||
includes_with(prefix2) | ||
); | ||
const valid = filter(not_includes_with_star_AND_includes_with_prefix); | ||
async function* transform2(source) { | ||
for await (const line of valid(source)) { | ||
const index = prefix_len + line.indexOf(prefix2); | ||
const pkg = line.slice(index, line.lastIndexOf("@")); | ||
yield pkg; | ||
} | ||
} | ||
// src/scanner/index.ts | ||
function make_scanner(format) { | ||
if (format == null) { | ||
return id; | ||
} | ||
if (format === "npm") { | ||
return transform; | ||
} | ||
if (format === "deno-info") { | ||
return transform2; | ||
} | ||
throw new Error(`unknown format - ${format}`); | ||
} | ||
// src/presets/lodash.ts | ||
const check = or(starts_with("lodash."), eqeqeq("lodash")); | ||
// src/presets/nolyfill.ts | ||
@@ -276,3 +308,3 @@ const list = Array.of( | ||
function collect({ flags, lines }) { | ||
const { extra = [], ignore = [], ...rest } = flags; | ||
const { format, extra = [], ignore = [], ...rest } = flags; | ||
const pred = make_predicate({ | ||
@@ -284,3 +316,3 @@ extra: lookup(extra.flatMap(split_by_comma)), | ||
const result = filter(pred)( | ||
make_scanner("npm")( | ||
make_scanner(format)( | ||
lines | ||
@@ -336,2 +368,8 @@ ) | ||
options: { | ||
"no-npm": { | ||
type: "boolean" | ||
}, | ||
format: { | ||
type: "string" | ||
}, | ||
extra: { | ||
@@ -358,3 +396,12 @@ type: "string", | ||
}); | ||
return values; | ||
const { format = "npm", "no-npm": no_npm, ...rest } = values; | ||
formatting: if (format === "npm" || format === "deno-info") { | ||
if (format === "npm" && no_npm === true) { | ||
break formatting; | ||
} | ||
return { ...rest, format }; | ||
} else { | ||
throw new Error(`unknown format - ${format}`); | ||
} | ||
return rest; | ||
} | ||
@@ -361,0 +408,0 @@ async function main({ |
{ | ||
"name": "pkg-fence", | ||
"version": "0.5.1", | ||
"version": "0.6.0-rc.1", | ||
"description": "A command line tool that glance over package lockfile.", | ||
@@ -18,2 +18,3 @@ "license": "AGPL-3.0-only", | ||
"./LICENSE.txt", | ||
"./CHANGELOG.md", | ||
"./README.md" | ||
@@ -20,0 +21,0 @@ ], |
47070
6
402