@cyberismo/data-handler 0.0.20 → 0.0.22
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/dist/command-handler.js +13 -24
- package/dist/command-handler.js.map +1 -1
- package/dist/command-manager.d.ts +21 -6
- package/dist/command-manager.js +34 -32
- package/dist/command-manager.js.map +1 -1
- package/dist/commands/calculate.js +101 -46
- package/dist/commands/calculate.js.map +1 -1
- package/dist/commands/create.js +420 -320
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/edit.js +117 -68
- package/dist/commands/edit.js.map +1 -1
- package/dist/commands/export.js +301 -252
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/fetch.js +205 -156
- package/dist/commands/fetch.js.map +1 -1
- package/dist/commands/import.js +189 -134
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/migrate.js +91 -45
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/move.js +347 -267
- package/dist/commands/move.js.map +1 -1
- package/dist/commands/remove.d.ts +1 -0
- package/dist/commands/remove.js +202 -135
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/rename.js +233 -187
- package/dist/commands/rename.js.map +1 -1
- package/dist/commands/show.d.ts +8 -8
- package/dist/commands/show.js +477 -372
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/transition.js +119 -73
- package/dist/commands/transition.js.map +1 -1
- package/dist/commands/update.js +8 -3
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/validate.js +1 -1
- package/dist/commands/validate.js.map +1 -1
- package/dist/containers/project/calculation-engine.js +0 -1
- package/dist/containers/project/calculation-engine.js.map +1 -1
- package/dist/containers/project/card-cache.js +1 -1
- package/dist/containers/project/card-cache.js.map +1 -1
- package/dist/containers/project.d.ts +16 -0
- package/dist/containers/project.js +59 -1
- package/dist/containers/project.js.map +1 -1
- package/dist/containers/template.js +1 -1
- package/dist/containers/template.js.map +1 -1
- package/dist/interfaces/command-options.d.ts +1 -0
- package/dist/interfaces/resource-interfaces.d.ts +5 -12
- package/dist/interfaces/resource-interfaces.js.map +1 -1
- package/dist/macros/base-macro.js +1 -1
- package/dist/macros/base-macro.js.map +1 -1
- package/dist/macros/graph/index.js +3 -1
- package/dist/macros/graph/index.js.map +1 -1
- package/dist/macros/include/index.js +16 -1
- package/dist/macros/include/index.js.map +1 -1
- package/dist/macros/include/types.d.ts +15 -12
- package/dist/macros/index.js +4 -1
- package/dist/macros/index.js.map +1 -1
- package/dist/macros/report/index.js +1 -1
- package/dist/macros/report/index.js.map +1 -1
- package/dist/module-manager.js +5 -3
- package/dist/module-manager.js.map +1 -1
- package/dist/project-settings.js +2 -2
- package/dist/project-settings.js.map +1 -1
- package/dist/resources/card-type-resource.js +1 -1
- package/dist/resources/card-type-resource.js.map +1 -1
- package/dist/resources/create-defaults.js +0 -1
- package/dist/resources/create-defaults.js.map +1 -1
- package/dist/resources/field-type-resource.js +2 -5
- package/dist/resources/field-type-resource.js.map +1 -1
- package/dist/resources/file-resource.js +4 -1
- package/dist/resources/file-resource.js.map +1 -1
- package/dist/resources/folder-resource.d.ts +1 -1
- package/dist/resources/folder-resource.js +4 -1
- package/dist/resources/folder-resource.js.map +1 -1
- package/dist/resources/graph-model-resource.d.ts +1 -8
- package/dist/resources/graph-model-resource.js +0 -14
- package/dist/resources/graph-model-resource.js.map +1 -1
- package/dist/resources/graph-view-resource.d.ts +1 -8
- package/dist/resources/graph-view-resource.js +0 -14
- package/dist/resources/graph-view-resource.js.map +1 -1
- package/dist/resources/link-type-resource.js +1 -1
- package/dist/resources/link-type-resource.js.map +1 -1
- package/dist/resources/report-resource.d.ts +1 -8
- package/dist/resources/report-resource.js +0 -14
- package/dist/resources/report-resource.js.map +1 -1
- package/dist/resources/resource-object.d.ts +11 -1
- package/dist/resources/resource-object.js +19 -2
- package/dist/resources/resource-object.js.map +1 -1
- package/dist/resources/template-resource.d.ts +1 -9
- package/dist/resources/template-resource.js +0 -15
- package/dist/resources/template-resource.js.map +1 -1
- package/dist/resources/workflow-resource.d.ts +6 -0
- package/dist/resources/workflow-resource.js +29 -13
- package/dist/resources/workflow-resource.js.map +1 -1
- package/dist/utils/card-utils.js +1 -1
- package/dist/utils/card-utils.js.map +1 -1
- package/dist/utils/commit-context.d.ts +23 -0
- package/dist/utils/commit-context.js +30 -0
- package/dist/utils/commit-context.js.map +1 -0
- package/dist/utils/csv.d.ts +8 -0
- package/dist/utils/csv.js +11 -0
- package/dist/utils/csv.js.map +1 -1
- package/dist/utils/file-utils.js +3 -1
- package/dist/utils/file-utils.js.map +1 -1
- package/dist/utils/git-manager.d.ts +29 -0
- package/dist/utils/git-manager.js +76 -0
- package/dist/utils/git-manager.js.map +1 -0
- package/dist/utils/handlebars-helpers.d.ts +22 -0
- package/dist/utils/handlebars-helpers.js +78 -0
- package/dist/utils/handlebars-helpers.js.map +1 -0
- package/dist/utils/json.d.ts +17 -10
- package/dist/utils/json.js +27 -14
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/log-utils.d.ts +7 -2
- package/dist/utils/log-utils.js +28 -3
- package/dist/utils/log-utils.js.map +1 -1
- package/dist/utils/report.d.ts +0 -19
- package/dist/utils/report.js +4 -63
- package/dist/utils/report.js.map +1 -1
- package/dist/utils/rw-lock.d.ts +71 -0
- package/dist/utils/rw-lock.js +220 -0
- package/dist/utils/rw-lock.js.map +1 -0
- package/dist/utils/user-preferences.js +3 -3
- package/dist/utils/user-preferences.js.map +1 -1
- package/package.json +10 -10
- package/src/command-handler.ts +14 -22
- package/src/command-manager.ts +43 -37
- package/src/commands/calculate.ts +8 -1
- package/src/commands/create.ts +39 -6
- package/src/commands/edit.ts +3 -0
- package/src/commands/export.ts +8 -2
- package/src/commands/fetch.ts +3 -0
- package/src/commands/import.ts +5 -0
- package/src/commands/migrate.ts +2 -0
- package/src/commands/move.ts +34 -0
- package/src/commands/remove.ts +24 -2
- package/src/commands/rename.ts +2 -0
- package/src/commands/show.ts +63 -34
- package/src/commands/transition.ts +2 -0
- package/src/commands/update.ts +9 -3
- package/src/commands/validate.ts +1 -1
- package/src/containers/project/calculation-engine.ts +0 -1
- package/src/containers/project/card-cache.ts +1 -0
- package/src/containers/project.ts +75 -1
- package/src/containers/template.ts +1 -1
- package/src/interfaces/command-options.ts +1 -0
- package/src/interfaces/resource-interfaces.ts +5 -12
- package/src/macros/base-macro.ts +1 -1
- package/src/macros/graph/index.ts +3 -0
- package/src/macros/include/index.ts +19 -1
- package/src/macros/include/types.ts +15 -12
- package/src/macros/index.ts +4 -1
- package/src/macros/report/index.ts +1 -0
- package/src/module-manager.ts +5 -2
- package/src/project-settings.ts +2 -1
- package/src/resources/card-type-resource.ts +1 -1
- package/src/resources/create-defaults.ts +0 -1
- package/src/resources/field-type-resource.ts +2 -4
- package/src/resources/file-resource.ts +3 -1
- package/src/resources/folder-resource.ts +7 -2
- package/src/resources/graph-model-resource.ts +1 -25
- package/src/resources/graph-view-resource.ts +1 -25
- package/src/resources/link-type-resource.ts +1 -1
- package/src/resources/report-resource.ts +1 -25
- package/src/resources/resource-object.ts +22 -1
- package/src/resources/template-resource.ts +0 -23
- package/src/resources/workflow-resource.ts +45 -16
- package/src/utils/card-utils.ts +1 -1
- package/src/utils/commit-context.ts +45 -0
- package/src/utils/csv.ts +12 -0
- package/src/utils/file-utils.ts +3 -1
- package/src/utils/git-manager.ts +87 -0
- package/src/utils/handlebars-helpers.ts +95 -0
- package/src/utils/json.ts +29 -15
- package/src/utils/log-utils.ts +33 -4
- package/src/utils/report.ts +8 -74
- package/src/utils/rw-lock.ts +279 -0
- package/src/utils/user-preferences.ts +3 -0
package/dist/commands/create.js
CHANGED
|
@@ -10,6 +10,40 @@
|
|
|
10
10
|
details. You should have received a copy of the GNU Affero General Public
|
|
11
11
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
12
|
*/
|
|
13
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
14
|
+
var useValue = arguments.length > 2;
|
|
15
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
16
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
17
|
+
}
|
|
18
|
+
return useValue ? value : void 0;
|
|
19
|
+
};
|
|
20
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
21
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
22
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
23
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
24
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
25
|
+
var _, done = false;
|
|
26
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
27
|
+
var context = {};
|
|
28
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
29
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
30
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
31
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
32
|
+
if (kind === "accessor") {
|
|
33
|
+
if (result === void 0) continue;
|
|
34
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
35
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
36
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
37
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
38
|
+
}
|
|
39
|
+
else if (_ = accept(result)) {
|
|
40
|
+
if (kind === "field") initializers.unshift(_);
|
|
41
|
+
else descriptor[key] = _;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
45
|
+
done = true;
|
|
46
|
+
};
|
|
13
47
|
// node
|
|
14
48
|
import { join, resolve } from 'node:path';
|
|
15
49
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
@@ -18,352 +52,418 @@ import { errorFunction } from '../utils/error-utils.js';
|
|
|
18
52
|
import { Project } from '../containers/project.js';
|
|
19
53
|
import { Validate } from './validate.js';
|
|
20
54
|
import { EMPTY_RANK, sortItems } from '../utils/lexorank.js';
|
|
55
|
+
import { ROOT } from '../utils/constants.js';
|
|
21
56
|
import { isModulePath } from '../utils/card-utils.js';
|
|
22
57
|
import { resourceName, resourceNameToString } from '../utils/resource-utils.js';
|
|
58
|
+
import { write } from '../utils/rw-lock.js';
|
|
23
59
|
import { writeJsonFile } from '../utils/json.js';
|
|
24
60
|
// todo: Is there a easy to way to make JSON schema into a TypeScript interface/type?
|
|
25
61
|
// Check this out: https://www.npmjs.com/package/json-schema-to-ts
|
|
26
62
|
/**
|
|
27
63
|
* Handles all create commands.
|
|
28
64
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (cardTypeName === undefined) {
|
|
81
|
-
throw new Error(`Input validation error: card type cannot be empty`);
|
|
65
|
+
let Create = (() => {
|
|
66
|
+
let _instanceExtraInitializers = [];
|
|
67
|
+
let _addCards_decorators;
|
|
68
|
+
let _addHubLocation_decorators;
|
|
69
|
+
let _createAttachment_decorators;
|
|
70
|
+
let _createCalculation_decorators;
|
|
71
|
+
let _createCard_decorators;
|
|
72
|
+
let _createCardType_decorators;
|
|
73
|
+
let _createFieldType_decorators;
|
|
74
|
+
let _createGraphModel_decorators;
|
|
75
|
+
let _createGraphView_decorators;
|
|
76
|
+
let _createLabel_decorators;
|
|
77
|
+
let _createLinkType_decorators;
|
|
78
|
+
let _createLink_decorators;
|
|
79
|
+
let _createReport_decorators;
|
|
80
|
+
let _createTemplate_decorators;
|
|
81
|
+
let _createWorkflow_decorators;
|
|
82
|
+
return class Create {
|
|
83
|
+
static {
|
|
84
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
85
|
+
_addCards_decorators = [write((cardTypeName, templateName) => `Add cards of type ${cardTypeName} to template ${templateName}`)];
|
|
86
|
+
_addHubLocation_decorators = [write((hubUrl) => `Add hub ${hubUrl}`)];
|
|
87
|
+
_createAttachment_decorators = [write((cardKey, attachment) => `Add attachment ${attachment} to ${cardKey}`)];
|
|
88
|
+
_createCalculation_decorators = [write((calculationName) => `Create calculation ${calculationName}`)];
|
|
89
|
+
_createCard_decorators = [write((templateName) => `Create card from template ${templateName}`)];
|
|
90
|
+
_createCardType_decorators = [write((cardTypeName) => `Create card type ${cardTypeName}`)];
|
|
91
|
+
_createFieldType_decorators = [write((fieldTypeName) => `Create field type ${fieldTypeName}`)];
|
|
92
|
+
_createGraphModel_decorators = [write((graphModelName) => `Create graph model ${graphModelName}`)];
|
|
93
|
+
_createGraphView_decorators = [write((graphViewName) => `Create graph view ${graphViewName}`)];
|
|
94
|
+
_createLabel_decorators = [write((cardKey, label) => `Add label ${label} to ${cardKey}`)];
|
|
95
|
+
_createLinkType_decorators = [write((linkTypeName) => `Create link type ${linkTypeName}`)];
|
|
96
|
+
_createLink_decorators = [write((cardKey, destinationCardKey, linkType) => `Create ${linkType} link from ${cardKey} to ${destinationCardKey}`)];
|
|
97
|
+
_createReport_decorators = [write((name) => `Create report ${name}`)];
|
|
98
|
+
_createTemplate_decorators = [write((templateName) => `Create template ${templateName}`)];
|
|
99
|
+
_createWorkflow_decorators = [write((workflowName) => `Create workflow ${workflowName}`)];
|
|
100
|
+
__esDecorate(this, null, _addCards_decorators, { kind: "method", name: "addCards", static: false, private: false, access: { has: obj => "addCards" in obj, get: obj => obj.addCards }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
101
|
+
__esDecorate(this, null, _addHubLocation_decorators, { kind: "method", name: "addHubLocation", static: false, private: false, access: { has: obj => "addHubLocation" in obj, get: obj => obj.addHubLocation }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
102
|
+
__esDecorate(this, null, _createAttachment_decorators, { kind: "method", name: "createAttachment", static: false, private: false, access: { has: obj => "createAttachment" in obj, get: obj => obj.createAttachment }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
103
|
+
__esDecorate(this, null, _createCalculation_decorators, { kind: "method", name: "createCalculation", static: false, private: false, access: { has: obj => "createCalculation" in obj, get: obj => obj.createCalculation }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
104
|
+
__esDecorate(this, null, _createCard_decorators, { kind: "method", name: "createCard", static: false, private: false, access: { has: obj => "createCard" in obj, get: obj => obj.createCard }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
105
|
+
__esDecorate(this, null, _createCardType_decorators, { kind: "method", name: "createCardType", static: false, private: false, access: { has: obj => "createCardType" in obj, get: obj => obj.createCardType }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
106
|
+
__esDecorate(this, null, _createFieldType_decorators, { kind: "method", name: "createFieldType", static: false, private: false, access: { has: obj => "createFieldType" in obj, get: obj => obj.createFieldType }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
107
|
+
__esDecorate(this, null, _createGraphModel_decorators, { kind: "method", name: "createGraphModel", static: false, private: false, access: { has: obj => "createGraphModel" in obj, get: obj => obj.createGraphModel }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
108
|
+
__esDecorate(this, null, _createGraphView_decorators, { kind: "method", name: "createGraphView", static: false, private: false, access: { has: obj => "createGraphView" in obj, get: obj => obj.createGraphView }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
109
|
+
__esDecorate(this, null, _createLabel_decorators, { kind: "method", name: "createLabel", static: false, private: false, access: { has: obj => "createLabel" in obj, get: obj => obj.createLabel }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
110
|
+
__esDecorate(this, null, _createLinkType_decorators, { kind: "method", name: "createLinkType", static: false, private: false, access: { has: obj => "createLinkType" in obj, get: obj => obj.createLinkType }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
111
|
+
__esDecorate(this, null, _createLink_decorators, { kind: "method", name: "createLink", static: false, private: false, access: { has: obj => "createLink" in obj, get: obj => obj.createLink }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
112
|
+
__esDecorate(this, null, _createReport_decorators, { kind: "method", name: "createReport", static: false, private: false, access: { has: obj => "createReport" in obj, get: obj => obj.createReport }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
113
|
+
__esDecorate(this, null, _createTemplate_decorators, { kind: "method", name: "createTemplate", static: false, private: false, access: { has: obj => "createTemplate" in obj, get: obj => obj.createTemplate }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
114
|
+
__esDecorate(this, null, _createWorkflow_decorators, { kind: "method", name: "createWorkflow", static: false, private: false, access: { has: obj => "createWorkflow" in obj, get: obj => obj.createWorkflow }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
115
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
82
116
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (isModulePath(templateObject.templateFolder())) {
|
|
87
|
-
throw new Error(`Cannot add cards to imported module templates`);
|
|
117
|
+
project = __runInitializers(this, _instanceExtraInitializers);
|
|
118
|
+
constructor(project) {
|
|
119
|
+
this.project = project;
|
|
88
120
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
121
|
+
static JSONFileContent = [
|
|
122
|
+
{
|
|
123
|
+
path: '.cards/local',
|
|
124
|
+
content: [{ id: 'cardsConfigSchema', version: 1 }],
|
|
125
|
+
name: Project.schemaContentFile,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
path: '.cards/local',
|
|
129
|
+
content: {
|
|
130
|
+
schemaVersion: SCHEMA_VERSION,
|
|
131
|
+
cardKeyPrefix: '$PROJECT-PREFIX',
|
|
132
|
+
name: '$PROJECT-NAME',
|
|
133
|
+
description: '',
|
|
134
|
+
modules: [],
|
|
135
|
+
hubs: [],
|
|
136
|
+
},
|
|
137
|
+
name: Project.projectConfigFileName,
|
|
138
|
+
},
|
|
139
|
+
];
|
|
140
|
+
static gitIgnoreContent = [
|
|
141
|
+
'.calc',
|
|
142
|
+
'.asciidoctor',
|
|
143
|
+
'.vscode',
|
|
144
|
+
'*.html',
|
|
145
|
+
'*.pdf',
|
|
146
|
+
'*.puml',
|
|
147
|
+
'**/.DS_Store',
|
|
148
|
+
'*-debug.log',
|
|
149
|
+
'*-error.log',
|
|
150
|
+
'.temp',
|
|
151
|
+
'.logs',
|
|
152
|
+
'.cache',
|
|
153
|
+
];
|
|
154
|
+
/**
|
|
155
|
+
* Adds new cards to a template.
|
|
156
|
+
* @param cardTypeName Card type for new cards.
|
|
157
|
+
* @param templateName Template name to add cards into.
|
|
158
|
+
* @param card Optional, if defined adds a new child-card under the card.
|
|
159
|
+
* @param count How many cards to add. By default one.
|
|
160
|
+
* @returns non-empty string array with ids of added cards
|
|
161
|
+
*/
|
|
162
|
+
async addCards(cardTypeName, templateName, card, count = 1) {
|
|
163
|
+
if (!templateName ||
|
|
164
|
+
!Validate.validateFolder(join(this.project.basePath, templateName))) {
|
|
165
|
+
throw new Error(`Input validation error: template name is invalid '${templateName}'`);
|
|
101
166
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
* @param buffer (Optional) attachment buffer
|
|
125
|
-
*/
|
|
126
|
-
async createAttachment(cardKey, attachment, buffer) {
|
|
127
|
-
try {
|
|
128
|
-
await this.project.createCardAttachment(cardKey, attachment, buffer || attachment);
|
|
129
|
-
}
|
|
130
|
-
catch (error) {
|
|
131
|
-
throw new Error(errorFunction(error));
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Creates a calculation resource.
|
|
136
|
-
* @param calculationName name for the calculation resource
|
|
137
|
-
*/
|
|
138
|
-
async createCalculation(calculationName) {
|
|
139
|
-
return this.project.resources
|
|
140
|
-
.byType(calculationName, 'calculations')
|
|
141
|
-
.create();
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Creates card(s) to a project. All cards from template are instantiated to the project.
|
|
145
|
-
* @param templateName name of a template to use
|
|
146
|
-
* @param parentCardKey (Optional) card-key of a parent card. If missing, cards are added to the card root.
|
|
147
|
-
* @returns array of card keys that were created. Cards are sorted by their parent key and rank. Template root cards are first but the order between other card groups is not guaranteed. However, the order of cards within a group is guaranteed to be ordered by rank.
|
|
148
|
-
*/
|
|
149
|
-
async createCard(templateName, parentCardKey) {
|
|
150
|
-
const templateResource = this.project.resources.byType(templateName, 'templates');
|
|
151
|
-
Validate.getInstance().validResourceName('templates', resourceNameToString(resourceName(templateName)), this.project.allModulePrefixes());
|
|
152
|
-
await templateResource.validate();
|
|
153
|
-
const specificCard = parentCardKey
|
|
154
|
-
? this.project.findCard(parentCardKey)
|
|
155
|
-
: undefined;
|
|
156
|
-
const templateObject = templateResource.templateObject();
|
|
157
|
-
if (!templateObject || !templateObject.isCreated()) {
|
|
158
|
-
throw new Error(`Template '${templateName}' not found from project`);
|
|
159
|
-
}
|
|
160
|
-
const createdCards = await templateObject.createCards(specificCard);
|
|
161
|
-
if (createdCards.length > 0) {
|
|
162
|
-
// Note: This assumes that parent keys will be ahead of 'a' in the sort order.
|
|
163
|
-
const sorted = sortItems(createdCards, (item) => {
|
|
164
|
-
return `${item.parent === 'root' ? 'a' : item.parent}${item.metadata?.rank || EMPTY_RANK}`;
|
|
167
|
+
if (cardTypeName === undefined) {
|
|
168
|
+
throw new Error(`Input validation error: card type cannot be empty`);
|
|
169
|
+
}
|
|
170
|
+
const templateResource = this.project.resources.byType(templateName, 'templates');
|
|
171
|
+
const templateObject = templateResource.templateObject();
|
|
172
|
+
const specificCard = card ? templateObject.findCard(card) : undefined;
|
|
173
|
+
if (isModulePath(templateObject.templateFolder())) {
|
|
174
|
+
throw new Error(`Cannot add cards to imported module templates`);
|
|
175
|
+
}
|
|
176
|
+
// Collect all add-card promises and settle them in parallel.
|
|
177
|
+
const promiseContainer = [];
|
|
178
|
+
const cardsContainer = [];
|
|
179
|
+
for (let cardCount = 0; cardCount < count; ++cardCount) {
|
|
180
|
+
promiseContainer.push(templateObject.addCard(cardTypeName, specificCard));
|
|
181
|
+
}
|
|
182
|
+
const promisesResult = await Promise.allSettled(promiseContainer).then((results) => {
|
|
183
|
+
for (const result of results) {
|
|
184
|
+
if (result.status !== 'fulfilled') {
|
|
185
|
+
throw new Error(result.reason);
|
|
186
|
+
}
|
|
187
|
+
cardsContainer.push(result.value);
|
|
188
|
+
}
|
|
165
189
|
});
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
async createCardType(cardTypeName, workflowName) {
|
|
176
|
-
return this.project.resources
|
|
177
|
-
.byType(cardTypeName, 'cardTypes')
|
|
178
|
-
.createCardType(workflowName);
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Creates a new field type.
|
|
182
|
-
* @param fieldTypeName name for the field type.
|
|
183
|
-
* @param dataType data type for the field type
|
|
184
|
-
*/
|
|
185
|
-
async createFieldType(fieldTypeName, dataType) {
|
|
186
|
-
return this.project.resources
|
|
187
|
-
.byType(fieldTypeName, 'fieldTypes')
|
|
188
|
-
.createFieldType(dataType);
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Creates a new graph model.
|
|
192
|
-
* @param graphModelName name for the graph model.
|
|
193
|
-
*/
|
|
194
|
-
async createGraphModel(graphModelName) {
|
|
195
|
-
return this.project.resources
|
|
196
|
-
.byType(graphModelName, 'graphModels')
|
|
197
|
-
.create();
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Creates a new graph view.
|
|
201
|
-
* @param graphViewName name for the graph view.
|
|
202
|
-
*/
|
|
203
|
-
async createGraphView(graphViewName) {
|
|
204
|
-
return this.project.resources.byType(graphViewName, 'graphViews').create();
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Creates a label in the given card
|
|
208
|
-
* @param cardKey The card to which the label is added to
|
|
209
|
-
* @param label The label being added
|
|
210
|
-
*/
|
|
211
|
-
async createLabel(cardKey, label) {
|
|
212
|
-
if (!Validate.isValidLabelName(label)) {
|
|
213
|
-
throw new Error(`Not a valid label name'`);
|
|
214
|
-
}
|
|
215
|
-
const card = this.project.findCard(cardKey);
|
|
216
|
-
const labels = structuredClone(card.metadata?.labels) ?? [];
|
|
217
|
-
if (labels.includes(label)) {
|
|
218
|
-
throw new Error('Label already exists');
|
|
219
|
-
}
|
|
220
|
-
labels.push(label);
|
|
221
|
-
return this.project.updateCardMetadataKey(cardKey, 'labels', labels);
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Creates a new link type.
|
|
225
|
-
* @param linkTypeName name for the link type.
|
|
226
|
-
*/
|
|
227
|
-
async createLinkType(linkTypeName) {
|
|
228
|
-
return this.project.resources.byType(linkTypeName, 'linkTypes').create();
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Creates a link between two cards.
|
|
232
|
-
* @param cardKey The card to update
|
|
233
|
-
* @param destinationCardKey The card to link to
|
|
234
|
-
* @param linkType The type of link to add
|
|
235
|
-
* @param linkDescription Optional description of the link
|
|
236
|
-
*/
|
|
237
|
-
async createLink(cardKey, destinationCardKey, linkType, linkDescription) {
|
|
238
|
-
if (cardKey === destinationCardKey) {
|
|
239
|
-
throw new Error('Cannot link card to itself');
|
|
190
|
+
if (cardsContainer.length === 0) {
|
|
191
|
+
throw new Error(`Invalid value for 'repeat:' "${count}"`);
|
|
192
|
+
}
|
|
193
|
+
if (promisesResult === undefined) {
|
|
194
|
+
return cardsContainer;
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
throw new Error('Unknown error');
|
|
198
|
+
}
|
|
240
199
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
.
|
|
247
|
-
.show();
|
|
248
|
-
// make sure that if linkDescription is not enabled, linkDescription is not provided
|
|
249
|
-
if (!linkTypeObject.enableLinkDescription &&
|
|
250
|
-
linkDescription !== undefined) {
|
|
251
|
-
throw new Error(`Link type '${linkType}' does not allow link description`);
|
|
200
|
+
/**
|
|
201
|
+
* Adds a new hub location.
|
|
202
|
+
* @param hubUrl URL of the hub
|
|
203
|
+
*/
|
|
204
|
+
async addHubLocation(hubUrl) {
|
|
205
|
+
return this.project.configuration.addHub(hubUrl);
|
|
252
206
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
207
|
+
/**
|
|
208
|
+
* Adds an attachment to a card.
|
|
209
|
+
* @param cardKey card ID
|
|
210
|
+
* @param attachment path to an attachment file or attachment name if buffer is defined
|
|
211
|
+
* @param buffer (Optional) attachment buffer
|
|
212
|
+
*/
|
|
213
|
+
async createAttachment(cardKey, attachment, buffer) {
|
|
214
|
+
try {
|
|
215
|
+
await this.project.createCardAttachment(cardKey, attachment, buffer || attachment);
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
throw new Error(errorFunction(error), { cause: error });
|
|
219
|
+
}
|
|
258
220
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
221
|
+
/**
|
|
222
|
+
* Creates a calculation resource.
|
|
223
|
+
* @param calculationName name for the calculation resource
|
|
224
|
+
*/
|
|
225
|
+
async createCalculation(calculationName) {
|
|
226
|
+
return this.project.resources
|
|
227
|
+
.byType(calculationName, 'calculations')
|
|
228
|
+
.create();
|
|
264
229
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
230
|
+
/**
|
|
231
|
+
* Creates card(s) to a project. All cards from template are instantiated to the project.
|
|
232
|
+
* @param templateName name of a template to use
|
|
233
|
+
* @param parentCardKey (Optional) card-key of a parent card. If missing, cards are added to the card root.
|
|
234
|
+
* @returns array of card keys that were created. Cards are sorted by their parent key and rank. Template root cards are first but the order between other card groups is not guaranteed. However, the order of cards within a group is guaranteed to be ordered by rank.
|
|
235
|
+
*/
|
|
236
|
+
async createCard(templateName, parentCardKey) {
|
|
237
|
+
const templateResource = this.project.resources.byType(templateName, 'templates');
|
|
238
|
+
Validate.getInstance().validResourceName('templates', resourceNameToString(resourceName(templateName)), this.project.allModulePrefixes());
|
|
239
|
+
await templateResource.validate();
|
|
240
|
+
const specificCard = parentCardKey
|
|
241
|
+
? this.project.findCard(parentCardKey)
|
|
242
|
+
: undefined;
|
|
243
|
+
const templateObject = templateResource.templateObject();
|
|
244
|
+
if (!templateObject || !templateObject.isCreated()) {
|
|
245
|
+
throw new Error(`Template '${templateName}' not found from project`);
|
|
246
|
+
}
|
|
247
|
+
const createdCards = await templateObject.createCards(specificCard);
|
|
248
|
+
if (createdCards.length > 0) {
|
|
249
|
+
const rootParent = specificCard?.key ?? ROOT;
|
|
250
|
+
const rootCards = [];
|
|
251
|
+
const childCards = [];
|
|
252
|
+
for (const card of createdCards) {
|
|
253
|
+
if (card.parent === rootParent) {
|
|
254
|
+
rootCards.push(card);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
childCards.push(card);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return [
|
|
261
|
+
...sortItems(rootCards, (item) => item.metadata?.rank || EMPTY_RANK),
|
|
262
|
+
...childCards,
|
|
263
|
+
];
|
|
264
|
+
}
|
|
265
|
+
return [];
|
|
271
266
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
* Creates a new project.
|
|
282
|
-
* @param projectPath where to create the project.
|
|
283
|
-
* @param projectPrefix prefix for the project.
|
|
284
|
-
* @param projectName name for the project.
|
|
285
|
-
* @param projectCategory category for the project (empty string if not provided).
|
|
286
|
-
* @param projectDescription description for the project (empty string if not provided).
|
|
287
|
-
*/
|
|
288
|
-
static async createProject(projectPath, projectPrefix, projectName, projectCategory, projectDescription) {
|
|
289
|
-
projectPath = resolve(projectPath);
|
|
290
|
-
if (!projectPath) {
|
|
291
|
-
throw new Error('Cannot create project without a path');
|
|
267
|
+
/**
|
|
268
|
+
* Creates a card type.
|
|
269
|
+
* @param cardTypeName name for the card type.
|
|
270
|
+
* @param workflowName workflow name to use in the card type.
|
|
271
|
+
*/
|
|
272
|
+
async createCardType(cardTypeName, workflowName) {
|
|
273
|
+
return this.project.resources
|
|
274
|
+
.byType(cardTypeName, 'cardTypes')
|
|
275
|
+
.createCardType(workflowName);
|
|
292
276
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
277
|
+
/**
|
|
278
|
+
* Creates a new field type.
|
|
279
|
+
* @param fieldTypeName name for the field type.
|
|
280
|
+
* @param dataType data type for the field type
|
|
281
|
+
*/
|
|
282
|
+
async createFieldType(fieldTypeName, dataType) {
|
|
283
|
+
return this.project.resources
|
|
284
|
+
.byType(fieldTypeName, 'fieldTypes')
|
|
285
|
+
.createFieldType(dataType);
|
|
296
286
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
287
|
+
/**
|
|
288
|
+
* Creates a new graph model.
|
|
289
|
+
* @param graphModelName name for the graph model.
|
|
290
|
+
*/
|
|
291
|
+
async createGraphModel(graphModelName) {
|
|
292
|
+
return this.project.resources
|
|
293
|
+
.byType(graphModelName, 'graphModels')
|
|
294
|
+
.create();
|
|
301
295
|
}
|
|
302
|
-
|
|
303
|
-
|
|
296
|
+
/**
|
|
297
|
+
* Creates a new graph view.
|
|
298
|
+
* @param graphViewName name for the graph view.
|
|
299
|
+
*/
|
|
300
|
+
async createGraphView(graphViewName) {
|
|
301
|
+
return this.project.resources.byType(graphViewName, 'graphViews').create();
|
|
304
302
|
}
|
|
305
|
-
|
|
306
|
-
|
|
303
|
+
/**
|
|
304
|
+
* Creates a label in the given card
|
|
305
|
+
* @param cardKey The card to which the label is added to
|
|
306
|
+
* @param label The label being added
|
|
307
|
+
*/
|
|
308
|
+
async createLabel(cardKey, label) {
|
|
309
|
+
if (!Validate.isValidLabelName(label)) {
|
|
310
|
+
throw new Error(`Not a valid label name'`);
|
|
311
|
+
}
|
|
312
|
+
const card = this.project.findCard(cardKey);
|
|
313
|
+
const labels = structuredClone(card.metadata?.labels) ?? [];
|
|
314
|
+
if (labels.includes(label)) {
|
|
315
|
+
throw new Error('Label already exists');
|
|
316
|
+
}
|
|
317
|
+
labels.push(label);
|
|
318
|
+
return this.project.updateCardMetadataKey(cardKey, 'labels', labels);
|
|
307
319
|
}
|
|
308
|
-
|
|
309
|
-
|
|
320
|
+
/**
|
|
321
|
+
* Creates a new link type.
|
|
322
|
+
* @param linkTypeName name for the link type.
|
|
323
|
+
*/
|
|
324
|
+
async createLinkType(linkTypeName) {
|
|
325
|
+
return this.project.resources.byType(linkTypeName, 'linkTypes').create();
|
|
310
326
|
}
|
|
311
|
-
|
|
312
|
-
|
|
327
|
+
/**
|
|
328
|
+
* Creates a link between two cards.
|
|
329
|
+
* @param cardKey The card to update
|
|
330
|
+
* @param destinationCardKey The card to link to
|
|
331
|
+
* @param linkType The type of link to add
|
|
332
|
+
* @param linkDescription Optional description of the link
|
|
333
|
+
*/
|
|
334
|
+
async createLink(cardKey, destinationCardKey, linkType, linkDescription) {
|
|
335
|
+
if (cardKey === destinationCardKey) {
|
|
336
|
+
throw new Error('Cannot link card to itself');
|
|
337
|
+
}
|
|
338
|
+
// Determine the card path
|
|
339
|
+
const card = this.project.findCard(cardKey);
|
|
340
|
+
const destinationCard = this.project.findCard(destinationCardKey);
|
|
341
|
+
// make sure the link type exists
|
|
342
|
+
const linkTypeObject = this.project.resources
|
|
343
|
+
.byType(linkType, 'linkTypes')
|
|
344
|
+
.show();
|
|
345
|
+
// make sure that if linkDescription is not enabled, linkDescription is not provided
|
|
346
|
+
if (!linkTypeObject.enableLinkDescription &&
|
|
347
|
+
linkDescription !== undefined) {
|
|
348
|
+
throw new Error(`Link type '${linkType}' does not allow link description`);
|
|
349
|
+
}
|
|
350
|
+
// make sure source card key exists in the link type sourceCardTypes
|
|
351
|
+
// if sourceCardTypes is empty, any card can be linked
|
|
352
|
+
if (linkTypeObject.sourceCardTypes.length > 0 &&
|
|
353
|
+
!linkTypeObject.sourceCardTypes.includes(card.metadata.cardType)) {
|
|
354
|
+
throw new Error(`Card type '${card.metadata?.cardType}' cannot be linked with link type '${linkType}'`);
|
|
355
|
+
}
|
|
356
|
+
// make sure destination card key exists in the link type destinationCardTypes
|
|
357
|
+
// if destinationCardTypes is empty, any card can be linked
|
|
358
|
+
if (linkTypeObject.destinationCardTypes.length > 0 &&
|
|
359
|
+
!linkTypeObject.destinationCardTypes.includes(destinationCard.metadata.cardType)) {
|
|
360
|
+
throw new Error(`Card type '${destinationCard.metadata.cardType}' cannot be linked with link type '${linkType}'`);
|
|
361
|
+
}
|
|
362
|
+
// if contains the same link, do not add it again
|
|
363
|
+
const existingLink = card.metadata?.links.find((l) => l.linkType === linkType &&
|
|
364
|
+
l.cardKey === destinationCardKey &&
|
|
365
|
+
l.linkDescription === linkDescription);
|
|
366
|
+
if (existingLink) {
|
|
367
|
+
throw new Error(`Link from card '${cardKey}' to card '${destinationCardKey}' already exists`);
|
|
368
|
+
}
|
|
369
|
+
const links = card.metadata?.links || [];
|
|
370
|
+
links.push({
|
|
371
|
+
linkType,
|
|
372
|
+
cardKey: destinationCardKey,
|
|
373
|
+
linkDescription,
|
|
374
|
+
});
|
|
375
|
+
await this.project.updateCardMetadataKey(cardKey, 'links', links);
|
|
313
376
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
377
|
+
/**
|
|
378
|
+
* Creates a new project.
|
|
379
|
+
* @param projectPath where to create the project.
|
|
380
|
+
* @param projectPrefix prefix for the project.
|
|
381
|
+
* @param projectName name for the project.
|
|
382
|
+
* @param projectCategory category for the project (empty string if not provided).
|
|
383
|
+
* @param projectDescription description for the project (empty string if not provided).
|
|
384
|
+
*/
|
|
385
|
+
static async createProject(projectPath, projectPrefix, projectName, projectCategory, projectDescription) {
|
|
386
|
+
// No lock required, since we are creating a new project
|
|
387
|
+
projectPath = resolve(projectPath);
|
|
388
|
+
if (!projectPath) {
|
|
389
|
+
throw new Error('Cannot create project without a path');
|
|
390
|
+
}
|
|
391
|
+
const projectFolders = ['.cards/local', 'cardRoot'];
|
|
392
|
+
if (!Validate.validateFolder(projectPath)) {
|
|
393
|
+
throw new Error(`Input validation error: folder name '${projectPath}' is invalid`);
|
|
394
|
+
}
|
|
395
|
+
if (projectPrefix === undefined ||
|
|
396
|
+
projectPrefix.length < 3 ||
|
|
397
|
+
projectPrefix.length > 10) {
|
|
398
|
+
throw new Error(`Input validation error: prefix must be from 3 to 10 characters long. '${projectPrefix}' does not fulfill the condition.`);
|
|
399
|
+
}
|
|
400
|
+
if (!Validate.isValidProjectName(projectName)) {
|
|
401
|
+
throw new Error(`Input validation error: invalid project name '${projectName}'`);
|
|
402
|
+
}
|
|
403
|
+
if (!Validate.validatePrefix(projectPrefix)) {
|
|
404
|
+
throw new Error(`Input validation error: invalid prefix '${projectPrefix}'`);
|
|
405
|
+
}
|
|
406
|
+
if (Project.isCreated(projectPath)) {
|
|
407
|
+
throw new Error('Project already exists');
|
|
408
|
+
}
|
|
409
|
+
if (!Validate.isValidProjectName(projectName)) {
|
|
410
|
+
throw new Error(`Input validation error: invalid project name '${projectName}'`);
|
|
411
|
+
}
|
|
412
|
+
await mkdir(projectPath, { recursive: true }).then(async () => {
|
|
413
|
+
return await Promise.all(projectFolders.map((folder) => mkdir(`${projectPath}/${folder}`, { recursive: true })));
|
|
414
|
+
});
|
|
415
|
+
await Promise.all(Create.JSONFileContent.map(async (entry) => {
|
|
416
|
+
if ('cardKeyPrefix' in entry.content) {
|
|
417
|
+
if (entry.content.cardKeyPrefix.includes('$PROJECT-PREFIX')) {
|
|
418
|
+
entry.content.cardKeyPrefix = projectPrefix.toLowerCase();
|
|
419
|
+
}
|
|
420
|
+
if (entry.content.name.includes('$PROJECT-NAME')) {
|
|
421
|
+
entry.content.name = projectName;
|
|
422
|
+
}
|
|
423
|
+
if (projectCategory) {
|
|
424
|
+
entry.content.category = projectCategory;
|
|
425
|
+
}
|
|
426
|
+
if (projectDescription) {
|
|
427
|
+
entry.content.description = projectDescription;
|
|
428
|
+
}
|
|
330
429
|
}
|
|
430
|
+
await writeJsonFile(join(projectPath, entry.path, entry.name), entry.content);
|
|
431
|
+
}));
|
|
432
|
+
try {
|
|
433
|
+
await writeFile(join(projectPath, '.gitignore'), this.gitIgnoreContent.join('\n') + '\n');
|
|
434
|
+
}
|
|
435
|
+
catch {
|
|
436
|
+
console.error('Failed to create project');
|
|
331
437
|
}
|
|
332
|
-
await writeJsonFile(join(projectPath, entry.path, entry.name), entry.content);
|
|
333
|
-
}));
|
|
334
|
-
try {
|
|
335
|
-
await writeFile(join(projectPath, '.gitignore'), this.gitIgnoreContent.join('\n') + '\n');
|
|
336
438
|
}
|
|
337
|
-
|
|
338
|
-
|
|
439
|
+
/**
|
|
440
|
+
* Creates a report
|
|
441
|
+
* @param name name of the report
|
|
442
|
+
*/
|
|
443
|
+
async createReport(name) {
|
|
444
|
+
return this.project.resources.byType(name, 'reports').createReport();
|
|
339
445
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
async createWorkflow(workflowName, workflowContent) {
|
|
364
|
-
return this.project.resources
|
|
365
|
-
.byType(workflowName, 'workflows')
|
|
366
|
-
.create(workflowContent ? JSON.parse(workflowContent) : undefined);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
446
|
+
/**
|
|
447
|
+
* Creates a new template to a project.
|
|
448
|
+
* @param templateName Name of the template.
|
|
449
|
+
* @param templateContent JSON content for the template file.
|
|
450
|
+
*/
|
|
451
|
+
async createTemplate(templateName, templateContent) {
|
|
452
|
+
return this.project.resources
|
|
453
|
+
.byType(templateName, 'templates')
|
|
454
|
+
.create(templateContent ? JSON.parse(templateContent) : undefined);
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Creates a workflow.
|
|
458
|
+
* @param workflowName workflow name
|
|
459
|
+
* @param workflowContent workflow content JSON
|
|
460
|
+
*/
|
|
461
|
+
async createWorkflow(workflowName, workflowContent) {
|
|
462
|
+
return this.project.resources
|
|
463
|
+
.byType(workflowName, 'workflows')
|
|
464
|
+
.create(workflowContent ? JSON.parse(workflowContent) : undefined);
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
})();
|
|
468
|
+
export { Create };
|
|
369
469
|
//# sourceMappingURL=create.js.map
|