@servable/tools 1.6.1 → 1.6.3
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 +2 -2
- package/src/document/1.0.0/all/write/index.js +2 -2
- package/src/document/1.0.0/all/write/protocol/index.js +1 -1
- package/src/document/1.0.0/all/write/utils/chunk.js +1 -1
- package/src/document/1.1.0/all/write/index.js +2 -2
- package/src/document/1.1.0/all/write/protocol/index.js +1 -1
- package/src/document/1.1.0/all/write/utils/chunk.js +1 -1
- package/src/domain/protocolLoader/base.js +1 -1
- package/src/domain/protocolLoader/v1.0.0.js +14 -0
- package/src/domain/protocolLoader/v1.1.0.js +5 -0
- package/src/manifest/access/index.js +1 -1
- package/src/manifest/extract/route/extractFileWithVariants.js +2 -2
- package/src/manifest/extract/route/extractFiles.js +2 -2
- package/src/manifest/extract/route/index.js +2 -2
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.3",
|
|
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",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"json2md": "^2.0.0",
|
|
79
79
|
"mime": "^4.0.0",
|
|
80
80
|
"parse-comments": "^1.0.0",
|
|
81
|
-
"path-sanitizer": "^
|
|
81
|
+
"path-sanitizer": "^3.1.0",
|
|
82
82
|
"semver": "^7.5.4",
|
|
83
83
|
"jimp": "^1.6.0",
|
|
84
84
|
"underscore": "^1.13.3"
|
|
@@ -3,8 +3,8 @@ import fs from 'fs'
|
|
|
3
3
|
|
|
4
4
|
export default async ({ payload, path }) => {
|
|
5
5
|
const { path, protocol, classes } = payload
|
|
6
|
-
const rootPath = sanitizePath(`${path}/generated`)
|
|
6
|
+
const rootPath = sanitizePath.default(`${path}/generated`)
|
|
7
7
|
|
|
8
|
-
const protocolPath = sanitizePath(`${rootPath}/index.md`)
|
|
8
|
+
const protocolPath = sanitizePath.default(`${rootPath}/index.md`)
|
|
9
9
|
fs.promises.writeFile(protocolPath, protocol)
|
|
10
10
|
}
|
|
@@ -12,7 +12,7 @@ export default async ({ item, path, includeAuxiliary }) => {
|
|
|
12
12
|
classes,
|
|
13
13
|
} = item
|
|
14
14
|
|
|
15
|
-
const rootPath = sanitizePath(`${path}/documentation/generated`)
|
|
15
|
+
const rootPath = sanitizePath.default(`${path}/documentation/generated`)
|
|
16
16
|
|
|
17
17
|
if ((await checkFileExists(rootPath))) {
|
|
18
18
|
await fse.emptyDir(rootPath)
|
|
@@ -10,7 +10,7 @@ export default async ({ chunk, path, includeAuxiliary }) => {
|
|
|
10
10
|
auxiliary
|
|
11
11
|
} = chunk
|
|
12
12
|
|
|
13
|
-
const chunkPath = `/${sanitizePath(`${path}/${id}.md`)}`
|
|
13
|
+
const chunkPath = `/${sanitizePath.default(`${path}/${id}.md`)}`
|
|
14
14
|
let text = json2md([{ h1: name }, ...payload])
|
|
15
15
|
if (includeAuxiliary && auxiliary) {
|
|
16
16
|
text = `${text}\n${auxiliary}`
|
|
@@ -3,8 +3,8 @@ import fs from 'fs'
|
|
|
3
3
|
|
|
4
4
|
export default async ({ payload, path }) => {
|
|
5
5
|
const { path, protocol, classes } = payload
|
|
6
|
-
const rootPath = sanitizePath(`${path}/generated`)
|
|
6
|
+
const rootPath = sanitizePath.default(`${path}/generated`)
|
|
7
7
|
|
|
8
|
-
const protocolPath = sanitizePath(`${rootPath}/index.md`)
|
|
8
|
+
const protocolPath = sanitizePath.default(`${rootPath}/index.md`)
|
|
9
9
|
fs.promises.writeFile(protocolPath, protocol)
|
|
10
10
|
}
|
|
@@ -12,7 +12,7 @@ export default async ({ item, path, includeAuxiliary }) => {
|
|
|
12
12
|
classes,
|
|
13
13
|
} = item
|
|
14
14
|
|
|
15
|
-
const rootPath = sanitizePath(`${path}/documentation/generated`)
|
|
15
|
+
const rootPath = sanitizePath.default(`${path}/documentation/generated`)
|
|
16
16
|
|
|
17
17
|
if ((await checkFileExists(rootPath))) {
|
|
18
18
|
await fse.emptyDir(rootPath)
|
|
@@ -10,7 +10,7 @@ export default async ({ chunk, path, includeAuxiliary }) => {
|
|
|
10
10
|
auxiliary
|
|
11
11
|
} = chunk
|
|
12
12
|
|
|
13
|
-
const chunkPath = `/${sanitizePath(`${path}/${id}.md`)}`
|
|
13
|
+
const chunkPath = `/${sanitizePath.default(`${path}/${id}.md`)}`
|
|
14
14
|
let text = json2md([{ h1: name }, ...payload])
|
|
15
15
|
if (includeAuxiliary && auxiliary) {
|
|
16
16
|
text = `${text}\n${auxiliary}`
|
|
@@ -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(this.path)}`,
|
|
46
|
+
path: `${sanitizePath.default(this.path)}`,
|
|
47
47
|
dataTemplateType: DataTemplateType.Protocol
|
|
48
48
|
})
|
|
49
49
|
// const e = JSON.stringify(this.extraction)
|
|
@@ -316,6 +316,20 @@ export default class ProtocolLoaderV1_0_0 extends BaseClass {
|
|
|
316
316
|
return this._importJSDefault({ path, })
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
+
async beforeEnd() {
|
|
320
|
+
const cacheKey = 'beforeEnd'
|
|
321
|
+
if (this._valueInCache(cacheKey)) {
|
|
322
|
+
return this._valueInCache(cacheKey)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const path = `${this.path}/beforeEnd/index.js`
|
|
326
|
+
if (!(await checkFileExists(path))) {
|
|
327
|
+
return null
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return this._importJSDefault({ path, })
|
|
331
|
+
}
|
|
332
|
+
|
|
319
333
|
configFolder() {
|
|
320
334
|
return `${this.path}/config`
|
|
321
335
|
}
|
|
@@ -301,6 +301,11 @@ export default class ProtocolLoaderV1_1_0 extends BaseClass {
|
|
|
301
301
|
return main ? main.beforeInit : null
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
+
async beforeEnd() {
|
|
305
|
+
const main = await this.main()
|
|
306
|
+
return main ? main.beforeEnd : null
|
|
307
|
+
}
|
|
308
|
+
|
|
304
309
|
async main() {
|
|
305
310
|
|
|
306
311
|
const path = `${this.path}/main.js`
|
|
@@ -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(path)}`, dataTemplateType: type })
|
|
18
|
+
extraction = await extract({ path: `${sanitizePath.default(path)}`, dataTemplateType: type })
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
if (!extraction) {
|
|
@@ -30,9 +30,9 @@ export default async (props) => {
|
|
|
30
30
|
|
|
31
31
|
const fullPathForVariant = ({ variant, fullPath, extensionType }) => {
|
|
32
32
|
if (!variant) {
|
|
33
|
-
return `${sanitizePath(`${fullPath}.${extensionType}`)}`
|
|
33
|
+
return `${sanitizePath.default(`${fullPath}.${extensionType}`)}`
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
// return `/${sanitizePath(`${fullPath}${variant.trim()}.${extensionType}`)}`
|
|
36
|
+
// return `/${sanitizePath.default(`${fullPath}${variant.trim()}.${extensionType}`)}`
|
|
37
37
|
return `${fullPath}${variant.trim()}.${extensionType}`
|
|
38
38
|
}
|
|
@@ -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(`${props.fullPath}.md`)}`
|
|
21
|
+
let md = `${sanitizePath.default(`${props.fullPath}.md`)}`
|
|
22
22
|
if (!(await checkFileExists(md))) {
|
|
23
|
-
md = `${sanitizePath(`${props.fullPath}.mdx`)}`
|
|
23
|
+
md = `${sanitizePath.default(`${props.fullPath}.mdx`)}`
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
if (await checkFileExists(md)) {
|
|
@@ -13,7 +13,7 @@ export default async (props) => {
|
|
|
13
13
|
params = {}
|
|
14
14
|
} = route
|
|
15
15
|
|
|
16
|
-
let fullPath = `${sanitizePath(`${parentLeafPath}/${route.path}`)}`
|
|
16
|
+
let fullPath = `${sanitizePath.default(`${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(result.leafPath)}`
|
|
89
|
+
result.leafPath = `${sanitizePath.default(result.leafPath)}`
|
|
90
90
|
|
|
91
91
|
if (files && files.length) {
|
|
92
92
|
files = files.filter(a => a.module)
|