@shgysk8zer0/importmap 1.3.0 → 1.3.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/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [v1.3.1] - 2023-11-20
10
+
11
+ ### Changed
12
+ - Update imports
13
+
14
+ ### Fixed
15
+ - Convert JSON/YAML paths to `file:` URLs
16
+
9
17
  ## [v1.3.0] - 2023-10-31
10
18
 
11
19
  ### Added
package/importmap.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "imports": {
3
- "@shgysk8zer0/kazoo/": "https://unpkg.com/@shgysk8zer0/kazoo@0.2.5/",
3
+ "@shgysk8zer0/kazoo/": "https://unpkg.com/@shgysk8zer0/kazoo@0.2.7/",
4
4
  "@shgysk8zer0/konami": "https://unpkg.com/@shgysk8zer0/konami@1.1.1/konami.js",
5
5
  "@shgysk8zer0/polyfills": "https://unpkg.com/@shgysk8zer0/polyfills@0.2.6/all.min.js",
6
6
  "@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills@0.2.6/",
7
7
  "@shgysk8zer0/jswaggersheets": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/swagger.js",
8
8
  "@shgysk8zer0/jswaggersheets/": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/",
9
9
  "@shgysk8zer0/jss/": "https://unpkg.com/@shgysk8zer0/jss@1.0.1/",
10
- "@shgysk8zer0/consts/": "https://unpkg.com/@shgysk8zer0/consts@1.0.7/",
10
+ "@shgysk8zer0/consts/": "https://unpkg.com/@shgysk8zer0/consts@1.0.8/",
11
11
  "@shgysk8zer0/http/": "https://unpkg.com/@shgysk8zer0/http@1.0.5/",
12
12
  "@shgysk8zer0/http-status": "https://unpkg.com/@shgysk8zer0/http-status@1.1.1/http-status.js",
13
13
  "@shgysk8zer0/components/": "https://unpkg.com/@shgysk8zer0/components@0.1.5/",
@@ -17,8 +17,8 @@
17
17
  "urlpattern-polyfill": "https://unpkg.com/urlpattern-polyfill@9.0.0/index.js",
18
18
  "highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.9.0/es/highlight.min.js",
19
19
  "highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.9.0/",
20
- "marked": "https://unpkg.com/marked@9.1.4/lib/marked.esm.js",
21
- "marked-highlight": "https://unpkg.com/marked-highlight@2.0.6/src/index.js",
20
+ "marked": "https://unpkg.com/marked@10.0.0/lib/marked.esm.js",
21
+ "marked-highlight": "https://unpkg.com/marked-highlight@2.0.7/src/index.js",
22
22
  "firebase/": "https://www.gstatic.com/firebasejs/9.23.0/"
23
23
  },
24
24
  "scope": {}
package/index.cjs CHANGED
@@ -4,16 +4,17 @@ var promises = require('node:fs/promises');
4
4
  var node_crypto = require('node:crypto');
5
5
  var yaml_js = require('@shgysk8zer0/npm-utils/yaml.js');
6
6
  var json_js = require('@shgysk8zer0/npm-utils/json.js');
7
+ var path_js = require('@shgysk8zer0/npm-utils/path.js');
7
8
 
8
9
  const imports$1 = {
9
- "@shgysk8zer0/kazoo/": "https://unpkg.com/@shgysk8zer0/kazoo@0.2.5/",
10
+ "@shgysk8zer0/kazoo/": "https://unpkg.com/@shgysk8zer0/kazoo@0.2.7/",
10
11
  "@shgysk8zer0/konami": "https://unpkg.com/@shgysk8zer0/konami@1.1.1/konami.js",
11
12
  "@shgysk8zer0/polyfills": "https://unpkg.com/@shgysk8zer0/polyfills@0.2.6/all.min.js",
12
13
  "@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills@0.2.6/",
13
14
  "@shgysk8zer0/jswaggersheets": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/swagger.js",
14
15
  "@shgysk8zer0/jswaggersheets/": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/",
15
16
  "@shgysk8zer0/jss/": "https://unpkg.com/@shgysk8zer0/jss@1.0.1/",
16
- "@shgysk8zer0/consts/": "https://unpkg.com/@shgysk8zer0/consts@1.0.7/",
17
+ "@shgysk8zer0/consts/": "https://unpkg.com/@shgysk8zer0/consts@1.0.8/",
17
18
  "@shgysk8zer0/http/": "https://unpkg.com/@shgysk8zer0/http@1.0.5/",
18
19
  "@shgysk8zer0/http-status": "https://unpkg.com/@shgysk8zer0/http-status@1.1.1/http-status.js",
19
20
  "@shgysk8zer0/components/": "https://unpkg.com/@shgysk8zer0/components@0.1.5/",
@@ -23,8 +24,8 @@ const imports$1 = {
23
24
  "urlpattern-polyfill": "https://unpkg.com/urlpattern-polyfill@9.0.0/index.js",
24
25
  "highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.9.0/es/highlight.min.js",
25
26
  "highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.9.0/",
26
- marked: "https://unpkg.com/marked@9.1.4/lib/marked.esm.js",
27
- "marked-highlight": "https://unpkg.com/marked-highlight@2.0.6/src/index.js",
27
+ marked: "https://unpkg.com/marked@10.0.0/lib/marked.esm.js",
28
+ "marked-highlight": "https://unpkg.com/marked-highlight@2.0.7/src/index.js",
28
29
  "firebase/": "https://www.gstatic.com/firebasejs/9.23.0/"
29
30
  };
30
31
  const scope$1 = {
@@ -111,26 +112,39 @@ async function update(imports) {
111
112
  }
112
113
 
113
114
  async function updateYAML(file) {
114
- const importmap = await yaml_js.readYAMLFile(file);
115
- const { updated, imports } = await update(importmap.imports);
116
-
117
- if (updated) {
118
- await yaml_js.writeYAMLFile(file, { ...importmap, imports: { ...importmap.imports, ...imports }});
119
- return true;
115
+ if (typeof file === 'string') {
116
+ return await updateJSON(path_js.getFileURL(file));
117
+ } else if (file instanceof URL && file.protocol === 'file:') {
118
+ const importmap = await yaml_js.readYAMLFile(file);
119
+ const { updated, imports } = await update(importmap.imports);
120
+
121
+ if (updated) {
122
+ await yaml_js.writeYAMLFile(file, { ...importmap, imports: { ...importmap.imports, ...imports }});
123
+ return true;
124
+ } else {
125
+ return false;
126
+ }
120
127
  } else {
121
- return false;
128
+ throw new TypeError('File must be a path or file: URL.');
122
129
  }
130
+
123
131
  }
124
132
 
125
133
  async function updateJSON(file) {
126
- const importmap = await json_js.readJSONFile(file);
127
- const { updated, imports } = await update(importmap.imports);
128
-
129
- if (updated) {
130
- await json_js.writeJSONFile(file, { ...importmap, imports: { ...importmap.imports, ...imports }});
131
- return true;
134
+ if (typeof file === 'string') {
135
+ return await updateJSON(path_js.getFileURL(file));
136
+ } else if (file instanceof URL && file.protocol === 'file:') {
137
+ const importmap = await json_js.readJSONFile(file);
138
+ const { updated, imports } = await update(importmap.imports);
139
+
140
+ if (updated) {
141
+ await json_js.writeJSONFile(file, { ...importmap, imports: { ...importmap.imports, ...imports }});
142
+ return true;
143
+ } else {
144
+ return false;
145
+ }
132
146
  } else {
133
- return false;
147
+ throw new TypeError('File must be a path or file: URL.');
134
148
  }
135
149
  }
136
150
 
package/index.mjs CHANGED
@@ -2,16 +2,17 @@ import { writeFile } from 'node:fs/promises';
2
2
  import { createHash } from 'node:crypto';
3
3
  import { readYAMLFile, writeYAMLFile } from '@shgysk8zer0/npm-utils/yaml.js';
4
4
  import { readJSONFile, writeJSONFile } from '@shgysk8zer0/npm-utils/json.js';
5
+ import { getFileURL } from '@shgysk8zer0/npm-utils/path.js';
5
6
 
6
7
  const imports$1 = {
7
- "@shgysk8zer0/kazoo/": "https://unpkg.com/@shgysk8zer0/kazoo@0.2.5/",
8
+ "@shgysk8zer0/kazoo/": "https://unpkg.com/@shgysk8zer0/kazoo@0.2.7/",
8
9
  "@shgysk8zer0/konami": "https://unpkg.com/@shgysk8zer0/konami@1.1.1/konami.js",
9
10
  "@shgysk8zer0/polyfills": "https://unpkg.com/@shgysk8zer0/polyfills@0.2.6/all.min.js",
10
11
  "@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills@0.2.6/",
11
12
  "@shgysk8zer0/jswaggersheets": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/swagger.js",
12
13
  "@shgysk8zer0/jswaggersheets/": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/",
13
14
  "@shgysk8zer0/jss/": "https://unpkg.com/@shgysk8zer0/jss@1.0.1/",
14
- "@shgysk8zer0/consts/": "https://unpkg.com/@shgysk8zer0/consts@1.0.7/",
15
+ "@shgysk8zer0/consts/": "https://unpkg.com/@shgysk8zer0/consts@1.0.8/",
15
16
  "@shgysk8zer0/http/": "https://unpkg.com/@shgysk8zer0/http@1.0.5/",
16
17
  "@shgysk8zer0/http-status": "https://unpkg.com/@shgysk8zer0/http-status@1.1.1/http-status.js",
17
18
  "@shgysk8zer0/components/": "https://unpkg.com/@shgysk8zer0/components@0.1.5/",
@@ -21,8 +22,8 @@ const imports$1 = {
21
22
  "urlpattern-polyfill": "https://unpkg.com/urlpattern-polyfill@9.0.0/index.js",
22
23
  "highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.9.0/es/highlight.min.js",
23
24
  "highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.9.0/",
24
- marked: "https://unpkg.com/marked@9.1.4/lib/marked.esm.js",
25
- "marked-highlight": "https://unpkg.com/marked-highlight@2.0.6/src/index.js",
25
+ marked: "https://unpkg.com/marked@10.0.0/lib/marked.esm.js",
26
+ "marked-highlight": "https://unpkg.com/marked-highlight@2.0.7/src/index.js",
26
27
  "firebase/": "https://www.gstatic.com/firebasejs/9.23.0/"
27
28
  };
28
29
  const scope$1 = {
@@ -109,26 +110,39 @@ async function update(imports) {
109
110
  }
110
111
 
111
112
  async function updateYAML(file) {
112
- const importmap = await readYAMLFile(file);
113
- const { updated, imports } = await update(importmap.imports);
114
-
115
- if (updated) {
116
- await writeYAMLFile(file, { ...importmap, imports: { ...importmap.imports, ...imports }});
117
- return true;
113
+ if (typeof file === 'string') {
114
+ return await updateJSON(getFileURL(file));
115
+ } else if (file instanceof URL && file.protocol === 'file:') {
116
+ const importmap = await readYAMLFile(file);
117
+ const { updated, imports } = await update(importmap.imports);
118
+
119
+ if (updated) {
120
+ await writeYAMLFile(file, { ...importmap, imports: { ...importmap.imports, ...imports }});
121
+ return true;
122
+ } else {
123
+ return false;
124
+ }
118
125
  } else {
119
- return false;
126
+ throw new TypeError('File must be a path or file: URL.');
120
127
  }
128
+
121
129
  }
122
130
 
123
131
  async function updateJSON(file) {
124
- const importmap = await readJSONFile(file);
125
- const { updated, imports } = await update(importmap.imports);
126
-
127
- if (updated) {
128
- await writeJSONFile(file, { ...importmap, imports: { ...importmap.imports, ...imports }});
129
- return true;
132
+ if (typeof file === 'string') {
133
+ return await updateJSON(getFileURL(file));
134
+ } else if (file instanceof URL && file.protocol === 'file:') {
135
+ const importmap = await readJSONFile(file);
136
+ const { updated, imports } = await update(importmap.imports);
137
+
138
+ if (updated) {
139
+ await writeJSONFile(file, { ...importmap, imports: { ...importmap.imports, ...imports }});
140
+ return true;
141
+ } else {
142
+ return false;
143
+ }
130
144
  } else {
131
- return false;
145
+ throw new TypeError('File must be a path or file: URL.');
132
146
  }
133
147
  }
134
148
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shgysk8zer0/importmap",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "engines": {
5
5
  "node": ">=18.0.0"
6
6
  },
@@ -58,9 +58,9 @@
58
58
  },
59
59
  "homepage": "https://github.com/shgysk8zer0/importmap#readme",
60
60
  "devDependencies": {
61
- "@babel/eslint-parser": "^7.22.15",
61
+ "@babel/eslint-parser": "^7.23.3",
62
62
  "@babel/eslint-plugin": "^7.22.10",
63
- "@babel/plugin-syntax-import-assertions": "^7.22.5",
63
+ "@babel/plugin-syntax-import-assertions": "^7.23.3",
64
64
  "@rollup/plugin-json": "^6.0.1",
65
65
  "@shgysk8zer0/js-utils": "^1.0.1",
66
66
  "@shgysk8zer0/rollup-import": "^1.2.2"
package/unpkg.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { readYAMLFile, writeYAMLFile } from '@shgysk8zer0/npm-utils/yaml.js';
2
2
  import { readJSONFile, writeJSONFile } from '@shgysk8zer0/npm-utils/json.js';
3
+ import { getFileURL } from '@shgysk8zer0/npm-utils/path.js';
3
4
  import { parseUnpkgURL, getUnpkgURL, getLatestVersion, UNPKG } from './utils.js';
4
5
 
5
6
  export async function update(imports) {
@@ -23,25 +24,38 @@ export async function update(imports) {
23
24
  }
24
25
 
25
26
  export async function updateYAML(file) {
26
- const importmap = await readYAMLFile(file);
27
- const { updated, imports } = await update(importmap.imports);
28
-
29
- if (updated) {
30
- await writeYAMLFile(file, { ...importmap, imports: { ...importmap.imports, ...imports }});
31
- return true;
27
+ if (typeof file === 'string') {
28
+ return await updateJSON(getFileURL(file));
29
+ } else if (file instanceof URL && file.protocol === 'file:') {
30
+ const importmap = await readYAMLFile(file);
31
+ const { updated, imports } = await update(importmap.imports);
32
+
33
+ if (updated) {
34
+ await writeYAMLFile(file, { ...importmap, imports: { ...importmap.imports, ...imports }});
35
+ return true;
36
+ } else {
37
+ return false;
38
+ }
32
39
  } else {
33
- return false;
40
+ throw new TypeError('File must be a path or file: URL.');
34
41
  }
42
+
35
43
  }
36
44
 
37
45
  export async function updateJSON(file) {
38
- const importmap = await readJSONFile(file);
39
- const { updated, imports } = await update(importmap.imports);
40
-
41
- if (updated) {
42
- await writeJSONFile(file, { ...importmap, imports: { ...importmap.imports, ...imports }});
43
- return true;
46
+ if (typeof file === 'string') {
47
+ return await updateJSON(getFileURL(file));
48
+ } else if (file instanceof URL && file.protocol === 'file:') {
49
+ const importmap = await readJSONFile(file);
50
+ const { updated, imports } = await update(importmap.imports);
51
+
52
+ if (updated) {
53
+ await writeJSONFile(file, { ...importmap, imports: { ...importmap.imports, ...imports }});
54
+ return true;
55
+ } else {
56
+ return false;
57
+ }
44
58
  } else {
45
- return false;
59
+ throw new TypeError('File must be a path or file: URL.');
46
60
  }
47
61
  }
package/update.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import { unpkg } from '@shgysk8zer0/importmap';
2
2
 
3
- await unpkg.updateJSON('importmap.json');
3
+ await unpkg.updateJSON('importmap.json').catch(console.error);