@servable/tools 1.0.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/LICENSE +21 -0
- package/README.md +33 -0
- package/package.json +106 -0
- package/src/config/candidates/featureCandidates/index.js +48 -0
- package/src/config/candidates/index.js +18 -0
- package/src/config/index.js +2 -0
- package/src/config/validate/feature/index.js +7 -0
- package/src/config/validate/index.js +5 -0
- package/src/document/1.0.0/all/build/class/index.js +67 -0
- package/src/document/1.0.0/all/build/feature/index.js +135 -0
- package/src/document/1.0.0/all/index.js +17 -0
- package/src/document/1.0.0/all/write/class/index.js +25 -0
- package/src/document/1.0.0/all/write/feature/index.js +43 -0
- package/src/document/1.0.0/all/write/index.js +10 -0
- package/src/document/1.0.0/all/write/utils/chunk.js +19 -0
- package/src/document/1.0.0/chunks/build/class/class.js +20 -0
- package/src/document/1.0.0/chunks/build/class/functions.js +21 -0
- package/src/document/1.0.0/chunks/build/class/lib.js +21 -0
- package/src/document/1.0.0/chunks/build/class/seed.js +21 -0
- package/src/document/1.0.0/chunks/build/class/triggers.js +26 -0
- package/src/document/1.0.0/chunks/build/feature/afterInit.js +20 -0
- package/src/document/1.0.0/chunks/build/feature/beforeInit.js +20 -0
- package/src/document/1.0.0/chunks/build/feature/class.js +42 -0
- package/src/document/1.0.0/chunks/build/feature/config.js +20 -0
- package/src/document/1.0.0/chunks/build/feature/functions.js +20 -0
- package/src/document/1.0.0/chunks/build/feature/lib.js +21 -0
- package/src/document/1.0.0/chunks/build/feature/liveClasses.js +20 -0
- package/src/document/1.0.0/chunks/build/feature/schema.js +206 -0
- package/src/document/1.0.0/chunks/build/feature/seed.js +20 -0
- package/src/document/1.0.0/chunks/build/feature/system.js +20 -0
- package/src/document/1.0.0/chunks/build/feature/triggers.js +20 -0
- package/src/document/1.0.0/generateGithubReadme/build/chunks/_generateBadge.js +4 -0
- package/src/document/1.0.0/generateGithubReadme/build/chunks/_githubPackage.js +4 -0
- package/src/document/1.0.0/generateGithubReadme/build/chunks/adapters.js +40 -0
- package/src/document/1.0.0/generateGithubReadme/build/chunks/apis.js +39 -0
- package/src/document/1.0.0/generateGithubReadme/build/chunks/categories.js +32 -0
- package/src/document/1.0.0/generateGithubReadme/build/chunks/dependencies/build.js +29 -0
- package/src/document/1.0.0/generateGithubReadme/build/chunks/dependencies/index.js +40 -0
- package/src/document/1.0.0/generateGithubReadme/build/chunks/footer.js +33 -0
- package/src/document/1.0.0/generateGithubReadme/build/chunks/githubTags.js +42 -0
- package/src/document/1.0.0/generateGithubReadme/build/chunks/install.js +29 -0
- package/src/document/1.0.0/generateGithubReadme/build/chunks/packages.js +26 -0
- package/src/document/1.0.0/generateGithubReadme/build/chunks/registry.js +42 -0
- package/src/document/1.0.0/generateGithubReadme/build/chunks/usage.js +68 -0
- package/src/document/1.0.0/generateGithubReadme/build/index.js +224 -0
- package/src/document/1.0.0/generateGithubReadme/index.js +28 -0
- package/src/document/1.1.0/all/build/class/index.js +67 -0
- package/src/document/1.1.0/all/build/feature/index.js +135 -0
- package/src/document/1.1.0/all/index.js +17 -0
- package/src/document/1.1.0/all/write/class/index.js +25 -0
- package/src/document/1.1.0/all/write/feature/index.js +43 -0
- package/src/document/1.1.0/all/write/index.js +10 -0
- package/src/document/1.1.0/all/write/utils/chunk.js +19 -0
- package/src/document/1.1.0/chunks/build/class/class.js +20 -0
- package/src/document/1.1.0/chunks/build/class/functions.js +21 -0
- package/src/document/1.1.0/chunks/build/class/lib.js +21 -0
- package/src/document/1.1.0/chunks/build/class/seed.js +21 -0
- package/src/document/1.1.0/chunks/build/class/triggers.js +26 -0
- package/src/document/1.1.0/chunks/build/feature/afterInit.js +20 -0
- package/src/document/1.1.0/chunks/build/feature/beforeInit.js +20 -0
- package/src/document/1.1.0/chunks/build/feature/class.js +42 -0
- package/src/document/1.1.0/chunks/build/feature/config.js +20 -0
- package/src/document/1.1.0/chunks/build/feature/functions.js +20 -0
- package/src/document/1.1.0/chunks/build/feature/lib.js +21 -0
- package/src/document/1.1.0/chunks/build/feature/liveClasses.js +20 -0
- package/src/document/1.1.0/chunks/build/feature/schema.js +206 -0
- package/src/document/1.1.0/chunks/build/feature/seed.js +20 -0
- package/src/document/1.1.0/chunks/build/feature/system.js +20 -0
- package/src/document/1.1.0/chunks/build/feature/triggers.js +20 -0
- package/src/document/1.1.0/generateGithubReadme/build/chunks/_generateBadge.js +4 -0
- package/src/document/1.1.0/generateGithubReadme/build/chunks/_githubPackage.js +4 -0
- package/src/document/1.1.0/generateGithubReadme/build/chunks/adapters.js +40 -0
- package/src/document/1.1.0/generateGithubReadme/build/chunks/apis.js +39 -0
- package/src/document/1.1.0/generateGithubReadme/build/chunks/categories.js +32 -0
- package/src/document/1.1.0/generateGithubReadme/build/chunks/dependencies/build.js +29 -0
- package/src/document/1.1.0/generateGithubReadme/build/chunks/dependencies/index.js +40 -0
- package/src/document/1.1.0/generateGithubReadme/build/chunks/footer.js +33 -0
- package/src/document/1.1.0/generateGithubReadme/build/chunks/githubTags.js +42 -0
- package/src/document/1.1.0/generateGithubReadme/build/chunks/install.js +29 -0
- package/src/document/1.1.0/generateGithubReadme/build/chunks/packages.js +26 -0
- package/src/document/1.1.0/generateGithubReadme/build/chunks/registry.js +42 -0
- package/src/document/1.1.0/generateGithubReadme/build/chunks/usage.js +68 -0
- package/src/document/1.1.0/generateGithubReadme/build/index.js +224 -0
- package/src/document/1.1.0/generateGithubReadme/index.js +28 -0
- package/src/document/gateway/all/index.js +23 -0
- package/src/document/gateway/generateGithubReadme/index.js +24 -0
- package/src/domain/feature/factory/absoluteModuleSrcPath.js +10 -0
- package/src/domain/feature/factory/featurePath.js +41 -0
- package/src/domain/feature/factory/index.js +71 -0
- package/src/domain/feature/index.js +117 -0
- package/src/domain/feature/lib/instancesPathIdUniqueId.js +17 -0
- package/src/domain/featureInstance/factory/getLoaderWithPayload.js +7 -0
- package/src/domain/featureInstance/factory/index.js +65 -0
- package/src/domain/featureInstance/factory/instancesWithPath.js +12 -0
- package/src/domain/featureInstance/index.js +199 -0
- package/src/domain/featureLoader/base.js +100 -0
- package/src/domain/featureLoader/factory/getModule.js +40 -0
- package/src/domain/featureLoader/factory/index.js +9 -0
- package/src/domain/featureLoader/lib/importJSDefault.js +12 -0
- package/src/domain/featureLoader/lib/importJSONDefault.js +14 -0
- package/src/domain/featureLoader/lib/mergeClassFeatures.js +17 -0
- package/src/domain/featureLoader/lib/triggerItems.js +8 -0
- package/src/domain/featureLoader/v1.0.0.js +861 -0
- package/src/domain/featureLoader/v1.1.0.js +871 -0
- package/src/domain/lib/checkFileExists.js +6 -0
- package/src/domain/servable/index.js +19 -0
- package/src/domain/servable/parse/index.js +5 -0
- package/src/domain/servable/parse/utils/index.js +216 -0
- package/src/index.js +29 -0
- package/src/lib/adaptConfig/basic.js +85 -0
- package/src/lib/adaptFeaturePayload.js +18 -0
- package/src/lib/checkFileExists.js +6 -0
- package/src/lib/cleanFeatures.js +25 -0
- package/src/lib/directories.js +49 -0
- package/src/lib/directoryFilesRecursive.js +83 -0
- package/src/lib/directoryGlob.js +14 -0
- package/src/lib/ensureDirectoryExists.js +14 -0
- package/src/lib/featureApiVersion.js +30 -0
- package/src/lib/foldersInFolder.js +46 -0
- package/src/lib/getModuleDir.js +19 -0
- package/src/lib/importFileAsText.js +15 -0
- package/src/lib/importJSONAsync.js +16 -0
- package/src/lib/sanitizePath.js +4 -0
- package/src/manifest/access/accessChildInTreeWithRoute.js +49 -0
- package/src/manifest/access/index.js +58 -0
- package/src/manifest/data/1.0.0/class.json +233 -0
- package/src/manifest/data/1.0.0/enums.js +255 -0
- package/src/manifest/data/1.0.0/feature.json +503 -0
- package/src/manifest/data/1.0.0/schema.json +145 -0
- package/src/manifest/data/1.1.0/class.json +233 -0
- package/src/manifest/data/1.1.0/enums.js +267 -0
- package/src/manifest/data/1.1.0/feature.json +542 -0
- package/src/manifest/data/1.1.0/schema.json +145 -0
- package/src/manifest/extract/extractAst.js +36 -0
- package/src/manifest/extract/extractItem.js +70 -0
- package/src/manifest/extract/formatFile.js +22 -0
- package/src/manifest/extract/index.js +23 -0
- package/src/manifest/extract/route/extractFileWithVariants.js +38 -0
- package/src/manifest/extract/route/extractFiles.js +87 -0
- package/src/manifest/extract/route/imageToBase64.js +42 -0
- package/src/manifest/extract/route/index.js +102 -0
- package/src/manifest/extract/templateDataForId.js +44 -0
- package/src/schema/build/buildFeature/classStruct/extractFeaturesFeatures.js +29 -0
- package/src/schema/build/buildFeature/classStruct/featureInClassClassSchema.js +36 -0
- package/src/schema/build/buildFeature/classStruct/index.js +62 -0
- package/src/schema/build/buildFeature/classStruct/preserveMostRestricted.js +68 -0
- package/src/schema/build/buildFeature/extractClassesFeature.js +49 -0
- package/src/schema/build/buildFeature/index.js +119 -0
- package/src/schema/build/index.js +54 -0
- package/src/schema/build/lib/getFeaturesLiveClasses.js +14 -0
- package/src/schema/build/lib/updateFeaturesExcerpt.js +24 -0
- package/src/schema/index.js +57 -0
- package/src/schema/validate/handleFeature/computeVersions.js +48 -0
- package/src/schema/validate/handleFeature/index.js +5 -0
- package/src/schema/validate/index.js +52 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
|
|
2
|
+
export default async props => {
|
|
3
|
+
const { path, extraction, mainPackage, index } = props
|
|
4
|
+
const payload = []
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
if (!mainPackage || !mainPackage.usage) {
|
|
8
|
+
return { payload, name: 'Usage', id: 'usage', }
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const { howTo, template, parameters } = mainPackage.usage
|
|
12
|
+
payload.push({
|
|
13
|
+
h2: 'Usage'
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
payload.push({
|
|
17
|
+
h3: 'Template'
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
payload.push({
|
|
21
|
+
p: "Add this template to your class' features.json file. Fill the values to fit your needs with the right parameters."
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
payload.push({
|
|
25
|
+
code: {
|
|
26
|
+
"language": "json",
|
|
27
|
+
"content": JSON.stringify(template, null, 2)
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
payload.push({
|
|
32
|
+
h3: 'Parameters'
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
// payload.push({
|
|
36
|
+
// code: {
|
|
37
|
+
// "language": "json",
|
|
38
|
+
// "content": JSON.stringify(parameters)
|
|
39
|
+
// }
|
|
40
|
+
// })
|
|
41
|
+
|
|
42
|
+
if (parameters && parameters.length) {
|
|
43
|
+
const rows = []
|
|
44
|
+
parameters.forEach(param => {
|
|
45
|
+
const { type = "", name: id = "", message = "", defaultValue = "", validators } = param
|
|
46
|
+
rows.push([
|
|
47
|
+
type,
|
|
48
|
+
id,
|
|
49
|
+
message,
|
|
50
|
+
defaultValue,
|
|
51
|
+
])
|
|
52
|
+
})
|
|
53
|
+
if (rows && rows.length) {
|
|
54
|
+
payload.push({
|
|
55
|
+
table: {
|
|
56
|
+
headers: ["type", "id", "Message", "Default value"],
|
|
57
|
+
rows
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
payload.push({
|
|
63
|
+
p: 'No parameters'
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return { payload, name: 'Usage', id: 'usage', }
|
|
68
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import gitUrlParse from "git-url-parse"
|
|
2
|
+
import { FeatureEnum } from "../../../../manifest/data/1.0.0/enums.js"
|
|
3
|
+
// import append from "../utils/builder/append.js"
|
|
4
|
+
import access from '../../../../manifest/access/index.js'
|
|
5
|
+
import buildSeed from '../../chunks/build/feature/seed.js'
|
|
6
|
+
import buildFeatureClass from '../../chunks/build/feature/class.js'
|
|
7
|
+
import buildConfig from '../../chunks/build/feature/config.js'
|
|
8
|
+
import buildLiveClasses from '../../chunks/build/feature/liveClasses.js'
|
|
9
|
+
import buildAfterInit from '../../chunks/build/feature/afterInit.js'
|
|
10
|
+
import buildBeforeInit from '../../chunks/build/feature/beforeInit.js'
|
|
11
|
+
import buildFunctions from '../../chunks/build/feature/functions.js'
|
|
12
|
+
import buildSchema from '../../chunks/build/feature/schema.js'
|
|
13
|
+
import buildSystem from '../../chunks/build/feature/system.js'
|
|
14
|
+
import buildLib from '../../chunks/build/feature/lib.js'
|
|
15
|
+
import buildGithubTags from './chunks/githubTags.js'
|
|
16
|
+
import buildRegistry from './chunks/registry.js'
|
|
17
|
+
import buildInstall from './chunks/install.js'
|
|
18
|
+
import buildUsage from './chunks/usage.js'
|
|
19
|
+
import buildFooter from './chunks/footer.js'
|
|
20
|
+
import buildPackages from './chunks/packages.js'
|
|
21
|
+
import buildDependencies from './chunks/dependencies/index.js'
|
|
22
|
+
import buildTriggers from '../../chunks/build/feature/triggers.js'
|
|
23
|
+
import buildAdapters from './chunks/adapters.js'
|
|
24
|
+
import buildApis from './chunks/apis.js'
|
|
25
|
+
import buildCategories from './chunks/categories.js'
|
|
26
|
+
|
|
27
|
+
export default async props => {
|
|
28
|
+
const { path, includeChunksInMain = true } = props
|
|
29
|
+
let payload = []
|
|
30
|
+
const chunks = {}
|
|
31
|
+
let extraction = null
|
|
32
|
+
let githubPackageName = null
|
|
33
|
+
let npmPackageName = null
|
|
34
|
+
let mainPackage = null
|
|
35
|
+
let packages
|
|
36
|
+
let version = null
|
|
37
|
+
let index = await access({
|
|
38
|
+
item: FeatureEnum.Index,
|
|
39
|
+
extraction,
|
|
40
|
+
path
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
if (index && index.data && index.data.module) {
|
|
44
|
+
packages = index.data.module.packages
|
|
45
|
+
mainPackage = index.data.module
|
|
46
|
+
const { name, description, id, } = mainPackage
|
|
47
|
+
version = mainPackage.version
|
|
48
|
+
payload.push({ h1: `${name} *feature for Servable*` })
|
|
49
|
+
payload.push({ p: `**${id}**` })
|
|
50
|
+
|
|
51
|
+
npmPackageName = id
|
|
52
|
+
if (mainPackage.repository) {
|
|
53
|
+
const { owner, name: _packageName } = gitUrlParse(mainPackage.repository.url)
|
|
54
|
+
githubPackageName = `${owner}/${_packageName}`
|
|
55
|
+
} else if (npmPackageName) {
|
|
56
|
+
githubPackageName = npmPackageName.replace('@')
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
chunks.githubTags = await buildGithubTags({ path, npmPackageName, githubPackageName })
|
|
62
|
+
// payload.push({ h2: chunks.githubTags.name })
|
|
63
|
+
payload = payload.concat(chunks.githubTags.payload)
|
|
64
|
+
|
|
65
|
+
let icon = await access({
|
|
66
|
+
item: FeatureEnum.Assets.Icon,
|
|
67
|
+
// variant: FeatureEnum.Assets.Icon.variants.x2,
|
|
68
|
+
mimeType: FeatureEnum.Assets.Icon.mimeTypes.SVG,
|
|
69
|
+
extraction,
|
|
70
|
+
path
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
// if (icon && icon.data && icon.data.module) {
|
|
75
|
+
// Github does not displaya svg
|
|
76
|
+
if (false) {
|
|
77
|
+
const data = icon.data.module.replace('<svg ', '<svg width="100px" height="100px" ')
|
|
78
|
+
payload.push({
|
|
79
|
+
// p: icon.data.module,
|
|
80
|
+
p: data
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
icon = await access({
|
|
85
|
+
item: FeatureEnum.Assets.Icon,
|
|
86
|
+
variant: FeatureEnum.Assets.Icon.variants.x2,
|
|
87
|
+
mimeType: FeatureEnum.Assets.Icon.mimeTypes.PNG,
|
|
88
|
+
extraction,
|
|
89
|
+
path
|
|
90
|
+
})
|
|
91
|
+
if (icon && icon.data && icon.data.module && icon.data.module.base64) {
|
|
92
|
+
// Github does not displaya svg
|
|
93
|
+
// payload.push({
|
|
94
|
+
// img: {
|
|
95
|
+
// title: 'icon',
|
|
96
|
+
// source: `${icon.data.module.base64}`,
|
|
97
|
+
// alt: 'icon',
|
|
98
|
+
// style: { width: "20px" }
|
|
99
|
+
// }
|
|
100
|
+
// })
|
|
101
|
+
// Can't resize
|
|
102
|
+
// payload.push({
|
|
103
|
+
// img: {
|
|
104
|
+
// title: 'icon',
|
|
105
|
+
// source: `src/assets/icon.png`,
|
|
106
|
+
// alt: 'icon',
|
|
107
|
+
// style: { width: "20px" }
|
|
108
|
+
// }
|
|
109
|
+
// })
|
|
110
|
+
payload.push({
|
|
111
|
+
p: '<img src="src/assets/icon.png" alt="drawing" style="width:80px;" />'
|
|
112
|
+
})
|
|
113
|
+
payload.push({
|
|
114
|
+
p: '\n'
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
if (index && index.data && index.data.documentation) {
|
|
123
|
+
payload.push({ p: index.data.documentation })
|
|
124
|
+
// payload.push({ p: '' })
|
|
125
|
+
} else if (index && index.data && index.data.module) {
|
|
126
|
+
payload.push({ p: description })
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
chunks.registry = await buildRegistry({ path, mainPackage, index })
|
|
130
|
+
// payload.push({ h2: chunks.githubTags.name })
|
|
131
|
+
payload = payload.concat(chunks.registry.payload)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
chunks.install = await buildInstall({ path, npmPackageName, githubPackageName })
|
|
135
|
+
// payload.push({ h2: chunks.githubTags.name })
|
|
136
|
+
payload = payload.concat(chunks.install.payload)
|
|
137
|
+
|
|
138
|
+
chunks.adapters = await buildAdapters({ mainPackage })
|
|
139
|
+
// payload.push({ h2: chunks.githubTags.name })
|
|
140
|
+
payload = payload.concat(chunks.adapters.payload)
|
|
141
|
+
|
|
142
|
+
chunks.apis = await buildApis({ mainPackage })
|
|
143
|
+
// payload.push({ h2: chunks.githubTags.name })
|
|
144
|
+
payload = payload.concat(chunks.apis.payload)
|
|
145
|
+
|
|
146
|
+
chunks.categories = await buildCategories({ mainPackage })
|
|
147
|
+
// payload.push({ h2: chunks.githubTags.name })
|
|
148
|
+
payload = payload.concat(chunks.categories.payload)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
chunks.packages = await buildPackages({ packages })
|
|
152
|
+
// payload.push({ h2: chunks.githubTags.name })
|
|
153
|
+
payload = payload.concat(chunks.packages.payload)
|
|
154
|
+
|
|
155
|
+
chunks.dependencies = await buildDependencies({ dependencies: mainPackage.dependencies })
|
|
156
|
+
// payload.push({ h2: chunks.githubTags.name })
|
|
157
|
+
payload = payload.concat(chunks.dependencies.payload)
|
|
158
|
+
|
|
159
|
+
chunks.usage = await buildUsage({ path, mainPackage, index })
|
|
160
|
+
// payload.push({ h2: chunks.githubTags.name })
|
|
161
|
+
payload = payload.concat(chunks.usage.payload)
|
|
162
|
+
|
|
163
|
+
// payload.push({ hr: `` })
|
|
164
|
+
// payload.push({ p: `*Generated documentation below*` })
|
|
165
|
+
|
|
166
|
+
chunks.seed = await buildSeed({ path })
|
|
167
|
+
payload.push({ h2: chunks.seed.name })
|
|
168
|
+
payload = payload.concat(chunks.seed.payload)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
chunks.featureClass = await buildFeatureClass({ path })
|
|
173
|
+
payload.push({ h2: chunks.featureClass.name })
|
|
174
|
+
payload = payload.concat(chunks.featureClass.payload)
|
|
175
|
+
|
|
176
|
+
chunks.beforeInit = await buildBeforeInit({ path })
|
|
177
|
+
payload.push({ h2: chunks.beforeInit.name })
|
|
178
|
+
payload = payload.concat(chunks.beforeInit.payload)
|
|
179
|
+
|
|
180
|
+
chunks.afterInit = await buildAfterInit({ path })
|
|
181
|
+
payload.push({ h2: chunks.afterInit.name })
|
|
182
|
+
payload = payload.concat(chunks.afterInit.payload)
|
|
183
|
+
|
|
184
|
+
chunks.config = await buildConfig({ path })
|
|
185
|
+
payload.push({ h2: chunks.config.name })
|
|
186
|
+
payload = payload.concat(chunks.config.payload)
|
|
187
|
+
|
|
188
|
+
chunks.functions = await buildFunctions({ path })
|
|
189
|
+
payload.push({ h2: chunks.functions.name })
|
|
190
|
+
payload = payload.concat(chunks.functions.payload)
|
|
191
|
+
|
|
192
|
+
chunks.liveClasses = await buildLiveClasses({ path })
|
|
193
|
+
payload.push({ h2: chunks.liveClasses.name })
|
|
194
|
+
payload = payload.concat(chunks.liveClasses.payload)
|
|
195
|
+
|
|
196
|
+
chunks.schema = await buildSchema({ path, version })
|
|
197
|
+
payload.push({ h2: chunks.schema.name })
|
|
198
|
+
payload = payload.concat(chunks.schema.payload)
|
|
199
|
+
|
|
200
|
+
chunks.system = await buildSystem({ path })
|
|
201
|
+
payload.push({ h2: chunks.system.name })
|
|
202
|
+
payload = payload.concat(chunks.system.payload)
|
|
203
|
+
|
|
204
|
+
chunks.lib = await buildLib({ path })
|
|
205
|
+
payload.push({ h2: chunks.lib.name })
|
|
206
|
+
payload = payload.concat(chunks.lib.payload)
|
|
207
|
+
|
|
208
|
+
chunks.triggers = await buildTriggers({ path })
|
|
209
|
+
payload.push({ h2: chunks.triggers.name })
|
|
210
|
+
payload = payload.concat(chunks.triggers.payload)
|
|
211
|
+
|
|
212
|
+
chunks.footer = await buildFooter({ path })
|
|
213
|
+
payload = payload.concat(chunks.footer.payload)
|
|
214
|
+
|
|
215
|
+
payload = payload.filter(a => a)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
return {
|
|
221
|
+
payload,
|
|
222
|
+
chunks,
|
|
223
|
+
}
|
|
224
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import build from './build/index.js'
|
|
2
|
+
import json2md from 'json2md'
|
|
3
|
+
import fse from 'fs-extra'
|
|
4
|
+
|
|
5
|
+
export default async props => {
|
|
6
|
+
const {
|
|
7
|
+
path,
|
|
8
|
+
targetPath,
|
|
9
|
+
write = true,
|
|
10
|
+
includeAuxiliary = true,
|
|
11
|
+
print = false } = props
|
|
12
|
+
|
|
13
|
+
const item = await build({ path })
|
|
14
|
+
if (print) {
|
|
15
|
+
console.log(item)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
payload,
|
|
20
|
+
} = item
|
|
21
|
+
|
|
22
|
+
if (write && targetPath) {
|
|
23
|
+
const text = json2md(payload)
|
|
24
|
+
await fse.outputFile(targetPath, text)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return item
|
|
28
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import featureApiVersion from '../../../lib/featureApiVersion.js'
|
|
2
|
+
import _path from "path"
|
|
3
|
+
import { fileURLToPath } from "url"
|
|
4
|
+
import { dirname } from "path"
|
|
5
|
+
import checkFileExists from '../../../lib/checkFileExists.js'
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
7
|
+
const __dirname = dirname(__filename)
|
|
8
|
+
|
|
9
|
+
export default async props => {
|
|
10
|
+
const { path, } = props
|
|
11
|
+
const apiVersion = await featureApiVersion({ path })
|
|
12
|
+
if (!apiVersion) {
|
|
13
|
+
throw new Error('No api version found')
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const modulePath = _path.resolve(__dirname, `../../${apiVersion}/all/index.js`)
|
|
17
|
+
if (!(await checkFileExists(modulePath))) {
|
|
18
|
+
throw new Error('No module found for api version')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const module = (await import(modulePath)).default
|
|
22
|
+
return module(props)
|
|
23
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import featureApiVersion from '../../../lib/featureApiVersion.js'
|
|
2
|
+
import _path from "path"
|
|
3
|
+
import { fileURLToPath } from "url"
|
|
4
|
+
import { dirname } from "path"
|
|
5
|
+
import checkFileExists from '../../../lib/checkFileExists.js'
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
7
|
+
const __dirname = dirname(__filename)
|
|
8
|
+
|
|
9
|
+
export default async props => {
|
|
10
|
+
const { path, } = props
|
|
11
|
+
const apiVersion = await featureApiVersion({ path })
|
|
12
|
+
if (!apiVersion) {
|
|
13
|
+
throw new Error('No api version found')
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const modulePath = _path.resolve(__dirname, `../../${apiVersion}/generateGithubReadme/index.js`)
|
|
17
|
+
if (!(await checkFileExists(modulePath))) {
|
|
18
|
+
throw new Error('No module found for api version')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
console.log('EZZEZEZEZEZE', apiVersion)
|
|
22
|
+
const module = (await import(modulePath)).default
|
|
23
|
+
return module(props)
|
|
24
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
import checkFileExists from '../../../lib/checkFileExists.js'
|
|
3
|
+
import absoluteModuleSrcPath from './absoluteModuleSrcPath.js'
|
|
4
|
+
|
|
5
|
+
export default async (props) => {
|
|
6
|
+
const { id, module, servableConfig } = props
|
|
7
|
+
let featurePath = null
|
|
8
|
+
|
|
9
|
+
if (typeof module === 'object'
|
|
10
|
+
&& Object.keys(module).length) {
|
|
11
|
+
const item = Object.keys(module)[0]
|
|
12
|
+
if (item) {
|
|
13
|
+
featurePath = absoluteModuleSrcPath(item)
|
|
14
|
+
return featurePath
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (servableConfig.features
|
|
19
|
+
&& servableConfig.features.external
|
|
20
|
+
&& servableConfig.features.external[id]) {
|
|
21
|
+
featurePath = absoluteModuleSrcPath(servableConfig.features.external[id])
|
|
22
|
+
return featurePath
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (servableConfig.features
|
|
26
|
+
&& servableConfig.features.local
|
|
27
|
+
&& servableConfig.features.local.length) {
|
|
28
|
+
|
|
29
|
+
let i = 0
|
|
30
|
+
do {
|
|
31
|
+
const repo = servableConfig.features.local[i]
|
|
32
|
+
featurePath = `${repo}/${id}`
|
|
33
|
+
if ((await checkFileExists(featurePath))) {
|
|
34
|
+
return featurePath
|
|
35
|
+
}
|
|
36
|
+
i++
|
|
37
|
+
} while (i < servableConfig.features.local.length)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return null
|
|
41
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import featurePath from './featurePath.js'
|
|
2
|
+
|
|
3
|
+
import _ from 'underscore'
|
|
4
|
+
import FeatureClass from '../index.js'
|
|
5
|
+
|
|
6
|
+
export default async ({
|
|
7
|
+
featurePayload,
|
|
8
|
+
servableConfig,
|
|
9
|
+
featuresCache,
|
|
10
|
+
instancesPathId
|
|
11
|
+
}) => {
|
|
12
|
+
|
|
13
|
+
const { id, module, version, type, } = featurePayload
|
|
14
|
+
let path = featurePayload.path
|
|
15
|
+
if (!path) {
|
|
16
|
+
path = await featurePath({
|
|
17
|
+
id,
|
|
18
|
+
module,
|
|
19
|
+
version,
|
|
20
|
+
servableConfig
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!path) {
|
|
25
|
+
return null
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let feature = null
|
|
29
|
+
const valueInCache = cacheValue({
|
|
30
|
+
featurePayload: {
|
|
31
|
+
...featurePayload,
|
|
32
|
+
path
|
|
33
|
+
}, featuresCache
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
if (valueInCache) {
|
|
37
|
+
feature = valueInCache.feature
|
|
38
|
+
} else {
|
|
39
|
+
feature = new FeatureClass({ id, type })
|
|
40
|
+
featuresCache.push({
|
|
41
|
+
id,
|
|
42
|
+
module,
|
|
43
|
+
version,
|
|
44
|
+
path,
|
|
45
|
+
feature
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
await feature.addInstanceIfNeeded({
|
|
50
|
+
featurePayload: {
|
|
51
|
+
...featurePayload,
|
|
52
|
+
path
|
|
53
|
+
},
|
|
54
|
+
instancesPathId,
|
|
55
|
+
servableConfig
|
|
56
|
+
})
|
|
57
|
+
// console.log(instancesPathId)
|
|
58
|
+
return feature
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
const cacheValue = ({ featurePayload, featuresCache }) => {
|
|
63
|
+
const { id, module, version, path } = featurePayload
|
|
64
|
+
const candidates = _.where(featuresCache, {
|
|
65
|
+
id,
|
|
66
|
+
// version,
|
|
67
|
+
// path,
|
|
68
|
+
// module
|
|
69
|
+
})
|
|
70
|
+
return (candidates && candidates.length) ? candidates[0] : null
|
|
71
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import semver from 'semver'
|
|
2
|
+
import * as FeatureInstanceFactory from '../featureInstance/factory/index.js'
|
|
3
|
+
|
|
4
|
+
export default class Feature {
|
|
5
|
+
_id = null
|
|
6
|
+
_type = null
|
|
7
|
+
|
|
8
|
+
_instances = []
|
|
9
|
+
_extractionStatus = 0
|
|
10
|
+
|
|
11
|
+
constructor(props) {
|
|
12
|
+
const {
|
|
13
|
+
id,
|
|
14
|
+
type,
|
|
15
|
+
} = props
|
|
16
|
+
|
|
17
|
+
this._id = id
|
|
18
|
+
this._type = type
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async addInstanceIfNeeded({
|
|
22
|
+
featurePayload,
|
|
23
|
+
servableConfig,
|
|
24
|
+
instancesPathId }) {
|
|
25
|
+
return FeatureInstanceFactory.getWithCache({
|
|
26
|
+
featurePayload,
|
|
27
|
+
servableConfig,
|
|
28
|
+
instancesPathId,
|
|
29
|
+
instances: this.instances
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// #region getters and setters
|
|
34
|
+
get instances() {
|
|
35
|
+
return this._instances
|
|
36
|
+
}
|
|
37
|
+
set instances(value) {
|
|
38
|
+
this._instances = value
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
instancesClassesPayloads() {
|
|
42
|
+
return this.instances.map(instance =>
|
|
43
|
+
({
|
|
44
|
+
featurePayload: instance.featurePayload,
|
|
45
|
+
instancesPathId: instance.instancesPathId,
|
|
46
|
+
instancesPathIdString: instance._instancesPathIdString,
|
|
47
|
+
instance
|
|
48
|
+
}))
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
get mainInstance() {
|
|
52
|
+
if (!this.instances || !this.instances.length) {
|
|
53
|
+
return null
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (this.instances.length === 1) {
|
|
57
|
+
return this.instances[0]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let _versions = this.instances.sort((a, b) => {
|
|
61
|
+
if (!a.module || !b.module) {
|
|
62
|
+
return 0
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const order = semver.compare(a.version, b.version)
|
|
66
|
+
return order
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
return _versions[0]
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
set mainInstance(value) {
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
get version() {
|
|
76
|
+
return this.mainInstance.version
|
|
77
|
+
}
|
|
78
|
+
set version(value) {
|
|
79
|
+
this.mainInstance.version = semver.clean(value)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
get params() {
|
|
83
|
+
return this.mainInstance.params
|
|
84
|
+
}
|
|
85
|
+
set params(value) {
|
|
86
|
+
this.mainInstance.params = value
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
get loader() {
|
|
90
|
+
return this.mainInstance
|
|
91
|
+
}
|
|
92
|
+
set loader(value) {
|
|
93
|
+
// this.defaultVersion.loader = value
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
get extractionStatus() {
|
|
97
|
+
return this._extractionStatus
|
|
98
|
+
}
|
|
99
|
+
set extractionStatus(value) {
|
|
100
|
+
this._extractionStatus = value
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
get schema() {
|
|
104
|
+
return this.mainInstance.schema
|
|
105
|
+
}
|
|
106
|
+
set schema(value) {
|
|
107
|
+
this.mainInstance.schema = value
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
get id() {
|
|
111
|
+
return this._id
|
|
112
|
+
}
|
|
113
|
+
set id(value) {
|
|
114
|
+
this._id = value
|
|
115
|
+
}
|
|
116
|
+
// #endregion
|
|
117
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
export default ({ instancesPathId, currentFeatureId }) => {
|
|
3
|
+
const a = instancesPathId.map(i => {
|
|
4
|
+
switch (i.type) {
|
|
5
|
+
case 'class': {
|
|
6
|
+
return `🌸 ${i.value.className}`
|
|
7
|
+
}
|
|
8
|
+
case 'feature': {
|
|
9
|
+
return `🐝 ${i.value.id}`
|
|
10
|
+
}
|
|
11
|
+
default:
|
|
12
|
+
return null
|
|
13
|
+
}
|
|
14
|
+
}).filter(a => a).join(' ')
|
|
15
|
+
|
|
16
|
+
return `${a} 🐝 ${currentFeatureId}`
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as FeatureLoaderFactory from '../../featureLoader/factory/index.js'
|
|
2
|
+
|
|
3
|
+
export default async ({ featurePayload }) => {
|
|
4
|
+
const { path, version } = featurePayload
|
|
5
|
+
const _loader = await FeatureLoaderFactory.getByPathAndVersion({ path, version })
|
|
6
|
+
return _loader
|
|
7
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import getLoaderWithPayload from './getLoaderWithPayload.js'
|
|
2
|
+
import FeatureInstanceClass from '../index.js'
|
|
3
|
+
import instancesWithPath from './instancesWithPath.js'
|
|
4
|
+
|
|
5
|
+
export const getWithCache = async ({
|
|
6
|
+
featurePayload,
|
|
7
|
+
servableConfig,
|
|
8
|
+
instancesPathId,
|
|
9
|
+
instances,
|
|
10
|
+
}) => {
|
|
11
|
+
|
|
12
|
+
const { id, module, version, path } = featurePayload
|
|
13
|
+
|
|
14
|
+
if (!instancesPathId || !instancesPathId.length) {
|
|
15
|
+
return null
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const instancePathOfInterest = instancesPathId[instancesPathId.length - 1]
|
|
19
|
+
let { type, value: { className } } = instancePathOfInterest
|
|
20
|
+
|
|
21
|
+
switch (type) {
|
|
22
|
+
case 'class': {
|
|
23
|
+
} break
|
|
24
|
+
case 'feature': {
|
|
25
|
+
if (instancePathOfInterest.value.id === 'app') {
|
|
26
|
+
className = '_root'
|
|
27
|
+
} break
|
|
28
|
+
}
|
|
29
|
+
default: {
|
|
30
|
+
return null
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let instance = instancesWithPath({
|
|
35
|
+
className,
|
|
36
|
+
instances,
|
|
37
|
+
path
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
if (instance) {
|
|
41
|
+
return instance
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const loader = await getLoaderWithPayload({ featurePayload })
|
|
45
|
+
instance = new FeatureInstanceClass({
|
|
46
|
+
featurePayload,
|
|
47
|
+
className,
|
|
48
|
+
loader,
|
|
49
|
+
instancesPathId
|
|
50
|
+
})
|
|
51
|
+
instance = new Proxy(instance, {
|
|
52
|
+
get(target, prop) {
|
|
53
|
+
if (prop in target) {
|
|
54
|
+
return target[prop]
|
|
55
|
+
} else if (prop in loader) {
|
|
56
|
+
return loader[prop].bind(loader); // default value
|
|
57
|
+
}
|
|
58
|
+
return target[prop]
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
instances.push(instance)
|
|
62
|
+
await instance.load({ servableConfig })
|
|
63
|
+
|
|
64
|
+
return instance
|
|
65
|
+
}
|