@aikdna/studio-core 0.4.1 → 0.5.0
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/index.js +13 -6
- package/src/pipeline.js +98 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -21,6 +21,7 @@ const cards = require('./cards');
|
|
|
21
21
|
const compile = require('./compile');
|
|
22
22
|
const evidence = require('./evidence');
|
|
23
23
|
const packaging = require('./packaging');
|
|
24
|
+
const pipeline = require('./pipeline');
|
|
24
25
|
const project = require('./project');
|
|
25
26
|
const provenance = require('./provenance');
|
|
26
27
|
const quality = require('./quality');
|
|
@@ -32,17 +33,23 @@ const validateCards = require('./quality/validate-cards');
|
|
|
32
33
|
const delta = require('./testlab/delta');
|
|
33
34
|
|
|
34
35
|
module.exports = {
|
|
36
|
+
// Stable
|
|
37
|
+
project,
|
|
35
38
|
cards,
|
|
36
39
|
compile,
|
|
37
|
-
evidence,
|
|
38
|
-
packaging,
|
|
39
|
-
project,
|
|
40
|
-
provenance,
|
|
41
40
|
quality,
|
|
41
|
+
provenance,
|
|
42
|
+
pipeline,
|
|
43
|
+
|
|
44
|
+
// Experimental
|
|
45
|
+
evidence,
|
|
42
46
|
testlab,
|
|
43
|
-
|
|
47
|
+
delta,
|
|
44
48
|
feynman,
|
|
45
49
|
contradiction,
|
|
46
50
|
validateCards,
|
|
47
|
-
|
|
51
|
+
versioning,
|
|
52
|
+
|
|
53
|
+
// Internal
|
|
54
|
+
packaging,
|
|
48
55
|
};
|
package/src/pipeline.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createStudioPipeline(project, options) — Official convenience API.
|
|
3
|
+
*
|
|
4
|
+
* Provides the recommended Studio workflow as a single callable pipeline.
|
|
5
|
+
* Third-party apps should use this instead of manually calling individual modules.
|
|
6
|
+
*
|
|
7
|
+
* Stable API (semver guaranteed).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const { validateProject } = require('./project');
|
|
11
|
+
const { computeReadiness } = require('./quality');
|
|
12
|
+
const { compileDomain, generateReadme } = require('./compile');
|
|
13
|
+
const { buildProvenance } = require('./provenance');
|
|
14
|
+
const { validateAllCards } = require('./quality/validate-cards');
|
|
15
|
+
|
|
16
|
+
function createStudioPipeline(project, options = {}) {
|
|
17
|
+
return new StudioPipeline(project, options);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class StudioPipeline {
|
|
21
|
+
constructor(project, options = {}) {
|
|
22
|
+
this.project = project;
|
|
23
|
+
this.options = options;
|
|
24
|
+
this.results = {};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
validateProject() {
|
|
28
|
+
const r = validateProject(this.project);
|
|
29
|
+
this.results.project_valid = r;
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
validateCards() {
|
|
34
|
+
const issues = validateAllCards(this.project);
|
|
35
|
+
this.results.card_validation = { total: issues.length, issues };
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
computeReadiness() {
|
|
40
|
+
const r = computeReadiness(this.project);
|
|
41
|
+
this.results.readiness = r;
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
compile() {
|
|
46
|
+
const r = compileDomain(this.project);
|
|
47
|
+
this.results.compile = r;
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
generateReadme(readmeOptions = {}) {
|
|
52
|
+
const r = generateReadme(this.project, readmeOptions);
|
|
53
|
+
this.results.readme = r;
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
buildProvenance() {
|
|
58
|
+
if (!this.results.compile) throw new Error('Must call compile() before buildProvenance()');
|
|
59
|
+
const r = buildProvenance(this.project, this.results.compile.files);
|
|
60
|
+
this.results.provenance = r;
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
runAll(options = {}) {
|
|
65
|
+
this.validateProject();
|
|
66
|
+
this.validateCards();
|
|
67
|
+
this.computeReadiness();
|
|
68
|
+
this.compile();
|
|
69
|
+
if (options.generateReadme !== false) this.generateReadme(options.readmeOptions);
|
|
70
|
+
if (options.buildProvenance !== false) this.buildProvenance();
|
|
71
|
+
return this.toResult();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
get readyness() { return this.results.readiness; }
|
|
75
|
+
get compiled() { return this.results.compile; }
|
|
76
|
+
get kdnaFiles() { return this.results.compile?.files || {}; }
|
|
77
|
+
get isPublishable() { return this.results.readiness?.publishable === true; }
|
|
78
|
+
|
|
79
|
+
toResult() {
|
|
80
|
+
return {
|
|
81
|
+
project_valid: this.results.project_valid?.valid === true,
|
|
82
|
+
card_issues: this.results.card_validation?.total || 0,
|
|
83
|
+
readiness: this.results.readiness?.grade || 'unknown',
|
|
84
|
+
publishable: this.results.readiness?.publishable || false,
|
|
85
|
+
score: this.results.readiness?.score || 0,
|
|
86
|
+
kdna_files: this.results.compile?.stats?.kdna_files || 0,
|
|
87
|
+
locked_cards: this.results.compile?.stats?.locked_cards || 0,
|
|
88
|
+
excluded_cards: this.results.compile?.stats?.excluded_cards || 0,
|
|
89
|
+
build_id: this.results.provenance?.build_id || null,
|
|
90
|
+
fingerprint: this.results.provenance?.content_fingerprint || null,
|
|
91
|
+
blocking: this.results.readiness?.blocking || [],
|
|
92
|
+
warnings: this.results.readiness?.warnings || [],
|
|
93
|
+
next_step: this.results.readiness?.next_step || '',
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
module.exports = { createStudioPipeline };
|