@servable/tools 1.6.3 → 1.6.5
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 +1 -1
- package/src/domain/protocolLoader/base.js +2 -2
- package/src/lib/directoryGlob.js +28 -6
- package/src/manifest/access/index.js +2 -2
- package/src/manifest/extract/route/extractFileWithVariants.js +3 -3
- package/src/manifest/extract/route/extractFiles.js +3 -3
- package/src/manifest/extract/route/index.js +3 -3
- /package/src/lib/{sanitizePath.js → sanitize.js} +0 -0
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"source": "src/index.js",
|
|
5
5
|
"main": "src/index.js",
|
|
6
|
-
"version": "1.6.
|
|
6
|
+
"version": "1.6.5",
|
|
7
7
|
"description": "Servable tools is a utility that builds a protocol's manifest and documents it.",
|
|
8
8
|
"author": "Servable Community",
|
|
9
9
|
"license": "ISC",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import extract from '../../manifest/extract/index.js'
|
|
2
2
|
import { DataTemplateType, ProtocolEnum } from '../../manifest/data/1.0.0/enums.js'
|
|
3
|
-
import sanitizePath from '../../lib/
|
|
3
|
+
import sanitizePath from '../../lib/sanitize.js'
|
|
4
4
|
import importJSDefault from './lib/importJSDefault.js'
|
|
5
5
|
import importJSONDefault from './lib/importJSONDefault.js'
|
|
6
6
|
import access from '../../manifest/access/index.js'
|
|
@@ -43,7 +43,7 @@ export default class ProtocolLoader {
|
|
|
43
43
|
async loadExtraction({ servableConfig } = {}) {
|
|
44
44
|
try {
|
|
45
45
|
this.extraction = await extract({
|
|
46
|
-
path: `${sanitizePath
|
|
46
|
+
path: `${sanitizePath(this.path)}`,
|
|
47
47
|
dataTemplateType: DataTemplateType.Protocol
|
|
48
48
|
})
|
|
49
49
|
// const e = JSON.stringify(this.extraction)
|
package/src/lib/directoryGlob.js
CHANGED
|
@@ -1,13 +1,35 @@
|
|
|
1
1
|
import fg from 'fast-glob'
|
|
2
2
|
|
|
3
|
-
export default async ({ path,
|
|
4
|
-
globOptions = { mark: true },
|
|
5
|
-
}) => {
|
|
3
|
+
export default async ({ path, globOptions = {} }) => {
|
|
6
4
|
try {
|
|
7
|
-
|
|
5
|
+
// Default options to skip test files and common internal dirs
|
|
6
|
+
const defaultOptions = {
|
|
7
|
+
mark: true,
|
|
8
|
+
ignore: [
|
|
9
|
+
'**/lib/**',
|
|
10
|
+
'**/__tests__/**',
|
|
11
|
+
'**/tests/**',
|
|
12
|
+
'**/test/**',
|
|
13
|
+
'**/*.test.js',
|
|
14
|
+
'**/*.spec.js',
|
|
15
|
+
],
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Merge caller options with defaults, unioning ignore patterns
|
|
19
|
+
const mergedIgnore = Array.from(new Set([
|
|
20
|
+
...(defaultOptions.ignore || []),
|
|
21
|
+
...((globOptions && globOptions.ignore) || []),
|
|
22
|
+
]))
|
|
23
|
+
|
|
24
|
+
const options = {
|
|
25
|
+
...defaultOptions,
|
|
26
|
+
...globOptions,
|
|
27
|
+
ignore: mergedIgnore,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const entries = await fg([path], options)
|
|
8
31
|
return Promise.all(entries.map(entry => import(entry)))
|
|
9
|
-
}
|
|
10
|
-
catch (e) {
|
|
32
|
+
} catch (e) {
|
|
11
33
|
console.error(e)
|
|
12
34
|
return null
|
|
13
35
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import extract from '../extract/index.js'
|
|
2
2
|
import accessChildInTreeWithRoute from './accessChildInTreeWithRoute.js'
|
|
3
|
-
import sanitizePath from '../../lib/
|
|
3
|
+
import sanitizePath from '../../lib/sanitize.js'
|
|
4
4
|
import { DataTemplateType } from '../data/1.0.0/enums.js'
|
|
5
5
|
|
|
6
6
|
export default async ({
|
|
@@ -15,7 +15,7 @@ export default async ({
|
|
|
15
15
|
|
|
16
16
|
let extraction = _extraction
|
|
17
17
|
if (!extraction && path) {
|
|
18
|
-
extraction = await extract({ path: `${sanitizePath
|
|
18
|
+
extraction = await extract({ path: `${sanitizePath(path)}`, dataTemplateType: type })
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
if (!extraction) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import checkFileExists from "../../../lib/checkFileExists.js"
|
|
3
|
-
import sanitizePath from '../../../lib/
|
|
3
|
+
import sanitizePath from '../../../lib/sanitize.js'
|
|
4
4
|
|
|
5
5
|
export default async (props) => {
|
|
6
6
|
const {
|
|
@@ -30,9 +30,9 @@ export default async (props) => {
|
|
|
30
30
|
|
|
31
31
|
const fullPathForVariant = ({ variant, fullPath, extensionType }) => {
|
|
32
32
|
if (!variant) {
|
|
33
|
-
return `${sanitizePath
|
|
33
|
+
return `${sanitizePath(`${fullPath}.${extensionType}`)}`
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
// return `/${sanitizePath
|
|
36
|
+
// return `/${sanitizePath(`${fullPath}${variant.trim()}.${extensionType}`)}`
|
|
37
37
|
return `${fullPath}${variant.trim()}.${extensionType}`
|
|
38
38
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import checkFileExists from "../../../lib/checkFileExists.js"
|
|
2
2
|
import importJSONAsync from "../../../lib/importJSONAsync.js"
|
|
3
|
-
import sanitizePath from '../../../lib/
|
|
3
|
+
import sanitizePath from '../../../lib/sanitize.js'
|
|
4
4
|
import fs from "fs"
|
|
5
5
|
import fse from 'fs-extra'
|
|
6
6
|
import imageToBase64 from './imageToBase64.js'
|
|
@@ -18,9 +18,9 @@ export default async (props) => {
|
|
|
18
18
|
const extensionType = mime.getExtension(mimeType)
|
|
19
19
|
|
|
20
20
|
let documentation = null
|
|
21
|
-
let md = `${sanitizePath
|
|
21
|
+
let md = `${sanitizePath(`${props.fullPath}.md`)}`
|
|
22
22
|
if (!(await checkFileExists(md))) {
|
|
23
|
-
md = `${sanitizePath
|
|
23
|
+
md = `${sanitizePath(`${props.fullPath}.mdx`)}`
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
if (await checkFileExists(md)) {
|
|
@@ -3,7 +3,7 @@ import directoryFilesRecursive from '../../../lib/directoryFilesRecursive.js'
|
|
|
3
3
|
import formatFile from '../formatFile.js'
|
|
4
4
|
import foldersInFolder from '../../../lib/foldersInFolder.js'
|
|
5
5
|
import extractFiles from './extractFiles.js'
|
|
6
|
-
import sanitizePath from '../../../lib/
|
|
6
|
+
import sanitizePath from '../../../lib/sanitize.js'
|
|
7
7
|
|
|
8
8
|
export default async (props) => {
|
|
9
9
|
const { item, route, parentLeafPath } = props
|
|
@@ -13,7 +13,7 @@ export default async (props) => {
|
|
|
13
13
|
params = {}
|
|
14
14
|
} = route
|
|
15
15
|
|
|
16
|
-
let fullPath = `${sanitizePath
|
|
16
|
+
let fullPath = `${sanitizePath(`${parentLeafPath}/${route.path}`)}`
|
|
17
17
|
let files = null
|
|
18
18
|
const result = {
|
|
19
19
|
...route,
|
|
@@ -86,7 +86,7 @@ export default async (props) => {
|
|
|
86
86
|
default: break
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
result.leafPath = `${sanitizePath
|
|
89
|
+
result.leafPath = `${sanitizePath(result.leafPath)}`
|
|
90
90
|
|
|
91
91
|
if (files && files.length) {
|
|
92
92
|
files = files.filter(a => a.module)
|
|
File without changes
|