importmapify 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deno.json +2 -1
- package/dist/mod.mjs +20 -6
- package/package.json +2 -1
package/deno.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/denoland/deno/refs/heads/main/cli/schemas/config-file.v1.json",
|
|
3
3
|
"name": "@kjanat/importmapify",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"exports": "./src/mod.ts",
|
|
6
6
|
"publish": {
|
|
7
7
|
"include": [
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"lock": false,
|
|
52
52
|
"jsrDepsInNodeModules": false,
|
|
53
53
|
"minimumDependencyAge": {
|
|
54
|
+
"age": 0,
|
|
54
55
|
"exclude": ["jsr:@kjanat/*", "npm:@kjanat/*"]
|
|
55
56
|
}
|
|
56
57
|
}
|
package/dist/mod.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { bold, cyan, detectHyperlinkSupport } from "ansispeck";
|
|
2
3
|
import { CLIError, cli, command, flag } from "dreamcli";
|
|
3
4
|
import fs, { existsSync, readFileSync } from "node:fs";
|
|
4
5
|
import path, { dirname } from "node:path";
|
|
@@ -478,6 +479,12 @@ function defineConfig(options) {
|
|
|
478
479
|
}
|
|
479
480
|
//#endregion
|
|
480
481
|
//#region src/cli.ts
|
|
482
|
+
const EXAMPLE_TOKEN = /(?:'[^']*'|"[^"]*"|\S)+/g;
|
|
483
|
+
function highlightExample(example) {
|
|
484
|
+
const tokens = example.match(EXAMPLE_TOKEN);
|
|
485
|
+
if (tokens === null) return example;
|
|
486
|
+
return tokens.map((token, index) => index === 0 ? bold(token) : token.startsWith("-") ? cyan(token) : token).join(" ");
|
|
487
|
+
}
|
|
481
488
|
function parseKeyValue(raw, flagName, code) {
|
|
482
489
|
const eq = raw.indexOf("=");
|
|
483
490
|
if (eq === -1) throw new CLIError(`--${flagName} expects key=value, got "${raw}"`, {
|
|
@@ -571,9 +578,9 @@ async function resolveGenerateOptions(flags) {
|
|
|
571
578
|
const generateCommand = command("generate").description("Expand package.json subpath-pattern imports into a Deno import map.").flag("root", flag.path({
|
|
572
579
|
mustExist: true,
|
|
573
580
|
type: "directory"
|
|
574
|
-
}).default(cwd()).describe("Project root containing the manifest.").alias("r")).flag("manifest", flag.string().default("package.json").describe("Manifest path, relative to root.").alias("m")).flag("out", flag.string().default(DEFAULT_OUT).describe("Output path resolved against root; relative, absolute, or file:// URL.").alias("o")).flag("import", flag.array(flag.string()).describe("Additional import entry as key=value. Repeatable.").alias("i")).flag("package", flag.array(flag.string()).describe("Package as name=target, expanded to a conformant bare and trailing-slash pair. Repeatable.").alias("p")).flag("ext", flag.array(flag.string()).describe("Restrict pattern matches to these file extensions. Repeatable.").alias("e")).flag("scope", flag.array(flag.string()).describe("Scoped import as prefix::key=value. Repeatable.").alias("s")).flag("condition", flag.array(flag.string()).describe("Condition to try when a target is a conditional object. Repeatable.").alias("c")).flag("config", flag.string().describe("Config file path; skips discovery.").alias("C")).flag("no-config", flag.boolean().describe("Skip config file discovery.")).flag("check", flag.boolean().describe("Exit 1 if the output file is stale instead of writing it.")).flag("stdout", flag.boolean().describe("Print the import map to stdout instead of writing it.")).example("importmapify --stdout", "Print the generated import map").example(`importmapify --package 'dreamcli=jsr:@kjanat/dreamcli@^3' --scope './tests/::dreamcli/testkit=jsr:@kjanat/dreamcli@^3/testkit'
|
|
575
|
-
const { log, error, setExitCode } = out;
|
|
576
|
-
const { check, stdout } = flags;
|
|
581
|
+
}).default(cwd()).describe("Project root containing the manifest.").alias("r")).flag("manifest", flag.string().default("package.json").describe("Manifest path, relative to root.").alias("m")).flag("out", flag.string().default(DEFAULT_OUT).describe("Output path resolved against root; relative, absolute, or file:// URL.").alias("o")).flag("import", flag.array(flag.string()).describe("Additional import entry as key=value. Repeatable.").alias("i")).flag("package", flag.array(flag.string()).describe("Package as name=target, expanded to a conformant bare and trailing-slash pair. Repeatable.").alias("p")).flag("ext", flag.array(flag.string()).describe("Restrict pattern matches to these file extensions. Repeatable.").alias("e")).flag("scope", flag.array(flag.string()).describe("Scoped import as prefix::key=value. Repeatable.").alias("s")).flag("condition", flag.array(flag.string()).describe("Condition to try when a target is a conditional object. Repeatable.").alias("c")).flag("config", flag.string().describe("Config file path; skips discovery.").alias("C")).flag("no-config", flag.boolean().describe("Skip config file discovery.")).flag("check", flag.boolean().describe("Exit 1 if the output file is stale instead of writing it.")).flag("stdout", flag.boolean().describe("Print the import map to stdout instead of writing it.")).flag("quiet", flag.boolean().describe("Suppress the confirmation message on stderr.").alias("q")).example(highlightExample("importmapify --stdout"), "Print the generated import map").example(highlightExample(`importmapify --package 'dreamcli=jsr:@kjanat/dreamcli@^3' --scope './tests/::dreamcli/testkit=jsr:@kjanat/dreamcli@^3/testkit'`), "Add global and test-scoped dependencies").example(highlightExample("importmapify --check"), "Fail when the generated file is stale").action(async ({ flags, out }) => {
|
|
582
|
+
const { log, warn, error, setExitCode } = out;
|
|
583
|
+
const { check, stdout, quiet } = flags;
|
|
577
584
|
if (check && stdout) throw new CLIError("--check and --stdout are mutually exclusive", {
|
|
578
585
|
code: "conflicting-flags",
|
|
579
586
|
exitCode: 2
|
|
@@ -595,10 +602,11 @@ const generateCommand = command("generate").description("Expand package.json sub
|
|
|
595
602
|
setExitCode(1);
|
|
596
603
|
return;
|
|
597
604
|
}
|
|
598
|
-
|
|
605
|
+
if (!quiet) warn(`${outPath} is up to date`);
|
|
599
606
|
return;
|
|
600
607
|
}
|
|
601
|
-
|
|
608
|
+
const written = writeImportMap(options);
|
|
609
|
+
if (!quiet) warn(`Wrote ${written}`);
|
|
602
610
|
});
|
|
603
611
|
//#endregion
|
|
604
612
|
//#region src/mod.ts
|
|
@@ -623,6 +631,12 @@ const cli$1 = cli("importmapify").manifest({
|
|
|
623
631
|
from: import.meta.url,
|
|
624
632
|
files: ["package.json", "deno.json"]
|
|
625
633
|
}).links().default(generateCommand).completions({ as: "flag" });
|
|
626
|
-
if (import.meta.main) cli$1.run(
|
|
634
|
+
if (import.meta.main) cli$1.run({ help: {
|
|
635
|
+
hyperlinks: detectHyperlinkSupport(),
|
|
636
|
+
theme: (c) => ({
|
|
637
|
+
headerName: (input) => c.bold(c.underline(input)),
|
|
638
|
+
headerVersion: (input) => c.dim(c.underline(input))
|
|
639
|
+
})
|
|
640
|
+
} });
|
|
627
641
|
//#endregion
|
|
628
642
|
export { createImportMap, defineConfig, formatImportMap, packageEntries, writeImportMap };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "importmapify",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Expand package.json subpath-pattern imports into explicit Deno import map entries.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deno",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"volta:bump": "volta pin node@latest npm@11; node --version>.node-version; run bd"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
+
"ansispeck": "^0.2.0",
|
|
68
69
|
"dreamcli": "npm:@kjanat/dreamcli@^3.0.0-rc.11"
|
|
69
70
|
},
|
|
70
71
|
"devDependencies": {
|