@shgysk8zer0/importmap 1.7.13 → 1.8.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shgysk8zer0/importmap",
3
- "version": "1.7.13",
3
+ "version": "1.8.1",
4
4
  "engines": {
5
5
  "node": ">=20.10.0"
6
6
  },
@@ -17,6 +17,9 @@
17
17
  "./importmap": {
18
18
  "import": "./importmap.js"
19
19
  },
20
+ "./*.json": {
21
+ "import": "./*.json"
22
+ },
20
23
  "./*.js": {
21
24
  "import": "./*.js",
22
25
  "require": "./*.cjs"
@@ -33,7 +36,8 @@
33
36
  }
34
37
  },
35
38
  "bin": {
36
- "importmap-utils": "./cli.mjs"
39
+ "importmap-utils": "cli.js",
40
+ "importmap-html": "html.js"
37
41
  },
38
42
  "scripts": {
39
43
  "start": "npx @shgysk8zer0/http-server -c ./http.config.js",
@@ -64,14 +68,13 @@
64
68
  },
65
69
  "homepage": "https://github.com/shgysk8zer0/importmap#readme",
66
70
  "devDependencies": {
67
- "@rollup/plugin-json": "^6.1.0",
68
- "@shgysk8zer0/eslint-config": "^1.0.5",
69
- "@shgysk8zer0/js-utils": "^1.0.2",
71
+ "@shgysk8zer0/eslint-config": "^1.0.7",
72
+ "@shgysk8zer0/js-utils": "^1.0.3",
70
73
  "@shgysk8zer0/rollup-import": "^2.0.2",
71
74
  "eslint": "^10.0.2"
72
75
  },
73
76
  "dependencies": {
74
- "@shgysk8zer0/npm-utils": "^1.1.3",
77
+ "@shgysk8zer0/npm-utils": "^1.1.4",
75
78
  "@shgysk8zer0/polyfills": "^0.6.2",
76
79
  "commander": "^14.0.3"
77
80
  }
package/cli.mjs DELETED
@@ -1,81 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { readJSONFile, writeJSONFile } from '@shgysk8zer0/npm-utils/json.js';
4
- import { readYAMLFile, writeYAMLFile } from '@shgysk8zer0/npm-utils/yaml.js';
5
- import { program } from 'commander';
6
- import { extname } from 'node:path';
7
- import { importmap } from './index.mjs';
8
- // import { updateImportMap } from './html.js';
9
-
10
- function guessFileType(file) {
11
- const ext = extname(file).toLowerCase();
12
-
13
- switch(ext) {
14
- case '.yml':
15
- case '.yaml':
16
- return 'yaml';
17
-
18
- case '.json':
19
- return 'json';
20
-
21
- case '.html':
22
- return 'html';
23
-
24
- default:
25
- throw new TypeError(`"${ext}" is not a supported file extension for file ${file}.`);
26
- }
27
- }
28
-
29
- async function parse(file, { encoding, signal } = {}) {
30
- switch(guessFileType(file)) {
31
- case 'yaml':
32
- return readYAMLFile(file, { encoding, signal });
33
-
34
- case 'json':
35
- return readJSONFile(file, { encoding, signal });
36
-
37
- }
38
- }
39
-
40
- async function init() {
41
- const { version: VERSION } = await readJSONFile(new URL('./package.json', import.meta.url));
42
-
43
- program
44
- .name('importmap-utils')
45
- .version(VERSION)
46
- .description('CLI utility for updating importmap files')
47
- .option('-i, --input [input]', 'local JSON or YAML importmap file')
48
- .option('-e, --encoding [encoding]', 'encoding', 'utf8')
49
- .option('-f, --format [format]', 'output format') // Migrate opt
50
- .option('-o, --output <output>', 'output file')
51
- .parse(process.argv);
52
-
53
- return {
54
- args: program.args,
55
- opts: program.opts(),
56
- };
57
- }
58
-
59
- init().then(async ({ opts: { input, encoding, format, output }}) => {
60
- const mod = typeof input === 'string'
61
- ? await parse(input, { encoding }).then(({ imports, scope = {}, ...rest }) => ({
62
- ...rest,
63
- imports: { ...imports, ...importmap.imports },
64
- scope: { ...scope, ...importmap.scope },
65
- }))
66
- : importmap;
67
-
68
- switch(format ?? guessFileType(output)) {
69
- case 'json':
70
- await writeJSONFile(output, mod, { encoding });
71
- break;
72
-
73
- case 'yaml':
74
- await writeYAMLFile(output, mod, { encoding });
75
- break;
76
-
77
- // case 'html':
78
- // await updateImportMap(output, { spaces: null });
79
- // break;
80
- }
81
- });