@elek-io/core 0.10.0 → 0.11.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/dist/browser/index.browser.d.ts +3268 -829
- package/dist/browser/index.browser.js +112 -147
- package/dist/browser/index.browser.js.map +1 -1
- package/dist/node/index.node.d.ts +3268 -829
- package/dist/node/index.node.js +378 -295
- package/dist/node/index.node.js.map +1 -1
- package/package.json +2 -3
package/dist/node/index.node.js
CHANGED
|
@@ -8,7 +8,7 @@ var __export = (target, all) => {
|
|
|
8
8
|
import Fs7 from "fs-extra";
|
|
9
9
|
|
|
10
10
|
// package.json
|
|
11
|
-
var version = "0.
|
|
11
|
+
var version = "0.11.0";
|
|
12
12
|
|
|
13
13
|
// src/schema/assetSchema.ts
|
|
14
14
|
import z4 from "zod";
|
|
@@ -69,39 +69,6 @@ var supportedLanguageSchema = z.enum([
|
|
|
69
69
|
// (Simplified) Chinese
|
|
70
70
|
]);
|
|
71
71
|
var supportedIconSchema = z.enum(["home", "plus", "foobar"]);
|
|
72
|
-
var supportedAssetMimeTypeSchema = z.enum([
|
|
73
|
-
"image/avif",
|
|
74
|
-
"image/gif",
|
|
75
|
-
"image/jpeg",
|
|
76
|
-
"image/png",
|
|
77
|
-
"image/svg+xml",
|
|
78
|
-
"image/webp",
|
|
79
|
-
"application/pdf",
|
|
80
|
-
"application/zip",
|
|
81
|
-
"video/mp4",
|
|
82
|
-
"video/webm",
|
|
83
|
-
"audio/webm",
|
|
84
|
-
"audio/flac"
|
|
85
|
-
]);
|
|
86
|
-
var supportedAssetExtensionSchema = z.enum([
|
|
87
|
-
"avif",
|
|
88
|
-
"gif",
|
|
89
|
-
"jpg",
|
|
90
|
-
"jpeg",
|
|
91
|
-
"png",
|
|
92
|
-
"svg",
|
|
93
|
-
"webp",
|
|
94
|
-
"pdf",
|
|
95
|
-
"zip",
|
|
96
|
-
"mp4",
|
|
97
|
-
"webm",
|
|
98
|
-
"flac",
|
|
99
|
-
"json"
|
|
100
|
-
]);
|
|
101
|
-
var supportedAssetTypeSchema = z.object({
|
|
102
|
-
extension: supportedAssetExtensionSchema,
|
|
103
|
-
mimeType: supportedAssetMimeTypeSchema
|
|
104
|
-
});
|
|
105
72
|
var objectTypeSchema = z.enum([
|
|
106
73
|
"project",
|
|
107
74
|
"asset",
|
|
@@ -151,48 +118,47 @@ var baseFileSchema = z2.object({
|
|
|
151
118
|
*/
|
|
152
119
|
updated: z2.string().datetime().nullable()
|
|
153
120
|
});
|
|
154
|
-
var baseFileWithLanguageSchema = baseFileSchema.extend({
|
|
155
|
-
/**
|
|
156
|
-
* The language of the file
|
|
157
|
-
*
|
|
158
|
-
* The language is part of the files name and together with it's ID the only unique identifier.
|
|
159
|
-
* That's why the language cannot be changed after creating the file.
|
|
160
|
-
*
|
|
161
|
-
* @todo Maybe remove the above restriction by implementing logic to handle changing the files language inside all services
|
|
162
|
-
*/
|
|
163
|
-
language: supportedLanguageSchema.readonly()
|
|
164
|
-
});
|
|
165
121
|
var fileReferenceSchema = z2.object({
|
|
166
122
|
id: uuidSchema,
|
|
167
|
-
|
|
168
|
-
extension: supportedAssetExtensionSchema.optional()
|
|
123
|
+
extension: z2.string().optional()
|
|
169
124
|
});
|
|
170
125
|
|
|
171
126
|
// src/schema/gitSchema.ts
|
|
172
127
|
import { z as z3 } from "zod";
|
|
173
|
-
var gitRepositoryPathSchema = z3.string();
|
|
174
128
|
var gitSignatureSchema = z3.object({
|
|
175
129
|
name: z3.string(),
|
|
176
130
|
email: z3.string()
|
|
177
131
|
});
|
|
132
|
+
var gitMessageSchema = z3.object({
|
|
133
|
+
method: z3.enum(["create", "update", "delete", "upgrade"]),
|
|
134
|
+
reference: z3.object({
|
|
135
|
+
objectType: objectTypeSchema,
|
|
136
|
+
/**
|
|
137
|
+
* ID of the objectType
|
|
138
|
+
*/
|
|
139
|
+
id: uuidSchema,
|
|
140
|
+
/**
|
|
141
|
+
* Only present if the objectType is of "entry"
|
|
142
|
+
*/
|
|
143
|
+
collectionId: uuidSchema.optional()
|
|
144
|
+
})
|
|
145
|
+
});
|
|
146
|
+
var gitTagSchema = z3.object({
|
|
147
|
+
id: uuidSchema,
|
|
148
|
+
message: z3.string(),
|
|
149
|
+
author: gitSignatureSchema,
|
|
150
|
+
datetime: z3.string().datetime()
|
|
151
|
+
});
|
|
178
152
|
var gitCommitSchema = z3.object({
|
|
179
153
|
/**
|
|
180
154
|
* SHA-1 hash of the commit
|
|
181
155
|
*/
|
|
182
156
|
hash: z3.string(),
|
|
183
|
-
message:
|
|
157
|
+
message: gitMessageSchema,
|
|
184
158
|
author: gitSignatureSchema,
|
|
185
159
|
datetime: z3.string().datetime(),
|
|
186
|
-
tag:
|
|
187
|
-
});
|
|
188
|
-
var GitCommitIconNative = /* @__PURE__ */ ((GitCommitIconNative2) => {
|
|
189
|
-
GitCommitIconNative2["INIT"] = ":tada:";
|
|
190
|
-
GitCommitIconNative2["CREATE"] = ":heavy_plus_sign:";
|
|
191
|
-
GitCommitIconNative2["UPDATE"] = ":wrench:";
|
|
192
|
-
GitCommitIconNative2["DELETE"] = ":heavy_minus_sign:";
|
|
193
|
-
return GitCommitIconNative2;
|
|
194
|
-
})(GitCommitIconNative || {});
|
|
195
|
-
var gitCommitIconSchema = z3.nativeEnum(GitCommitIconNative);
|
|
160
|
+
tag: gitTagSchema.nullable()
|
|
161
|
+
});
|
|
196
162
|
var gitInitOptionsSchema = z3.object({
|
|
197
163
|
/**
|
|
198
164
|
* Use the specified name for the initial branch in the newly created repository. If not specified, fall back to the default name (currently master, but this is subject to change in the future; the name can be customized via the init.defaultBranch configuration variable).
|
|
@@ -211,7 +177,19 @@ var gitCloneOptionsSchema = z3.object({
|
|
|
211
177
|
/**
|
|
212
178
|
* Instead of pointing the newly created HEAD to the branch pointed to by the cloned repository’s HEAD, point to <name> branch instead. In a non-bare repository, this is the branch that will be checked out. --branch can also take tags and detaches the HEAD at that commit in the resulting repository.
|
|
213
179
|
*/
|
|
214
|
-
branch: z3.string()
|
|
180
|
+
branch: z3.string(),
|
|
181
|
+
/**
|
|
182
|
+
* Make a bare Git repository. That is, instead of creating <directory> and placing the administrative files in <directory>`/.git`, make the <directory> itself the $GIT_DIR.
|
|
183
|
+
* Used primarily to copy an existing local repository to a server, where you want to set up the repository as a central point to work with others.
|
|
184
|
+
*
|
|
185
|
+
* The destination path for the cloned repository should end with a .git by convention.
|
|
186
|
+
*
|
|
187
|
+
* @see https://git-scm.com/book/en/v2/Git-on-the-Server-Getting-Git-on-a-Server
|
|
188
|
+
*/
|
|
189
|
+
bare: z3.boolean()
|
|
190
|
+
});
|
|
191
|
+
var gitMergeOptionsSchema = z3.object({
|
|
192
|
+
squash: z3.boolean()
|
|
215
193
|
});
|
|
216
194
|
var gitSwitchOptionsSchema = z3.object({
|
|
217
195
|
/**
|
|
@@ -248,14 +226,28 @@ var gitLogOptionsSchema = z3.object({
|
|
|
248
226
|
*/
|
|
249
227
|
filePath: z3.string().optional()
|
|
250
228
|
});
|
|
229
|
+
var createGitTagSchema = gitTagSchema.pick({
|
|
230
|
+
message: true
|
|
231
|
+
}).extend({
|
|
232
|
+
path: z3.string(),
|
|
233
|
+
hash: z3.string().optional()
|
|
234
|
+
});
|
|
235
|
+
var readGitTagSchema = z3.object({
|
|
236
|
+
path: z3.string(),
|
|
237
|
+
id: uuidSchema.readonly()
|
|
238
|
+
});
|
|
239
|
+
var deleteGitTagSchema = readGitTagSchema.extend({});
|
|
240
|
+
var countGitTagsSchema = z3.object({
|
|
241
|
+
path: z3.string()
|
|
242
|
+
});
|
|
251
243
|
|
|
252
244
|
// src/schema/assetSchema.ts
|
|
253
245
|
var assetFileSchema = baseFileSchema.extend({
|
|
254
246
|
objectType: z4.literal(objectTypeSchema.Enum.asset).readonly(),
|
|
255
247
|
name: z4.string(),
|
|
256
248
|
description: z4.string(),
|
|
257
|
-
extension:
|
|
258
|
-
mimeType:
|
|
249
|
+
extension: z4.string().readonly(),
|
|
250
|
+
mimeType: z4.string().readonly(),
|
|
259
251
|
/**
|
|
260
252
|
* Total size in bytes
|
|
261
253
|
*/
|
|
@@ -331,9 +323,6 @@ var ValueTypeSchema = z5.enum([
|
|
|
331
323
|
var valueContentReferenceBase = z5.object({
|
|
332
324
|
id: uuidSchema
|
|
333
325
|
});
|
|
334
|
-
var valueContentReferenceWithLanguageBase = valueContentReferenceBase.extend({
|
|
335
|
-
language: supportedLanguageSchema
|
|
336
|
-
});
|
|
337
326
|
var valueContentReferenceToAssetSchema = valueContentReferenceBase.extend({
|
|
338
327
|
objectType: z5.literal(objectTypeSchema.Enum.asset)
|
|
339
328
|
});
|
|
@@ -564,7 +553,6 @@ var ReferenceFieldDefinitionBaseSchema = FieldDefinitionBaseSchema.extend({
|
|
|
564
553
|
});
|
|
565
554
|
var assetFieldDefinitionSchema = ReferenceFieldDefinitionBaseSchema.extend({
|
|
566
555
|
fieldType: z7.literal(FieldTypeSchema.Enum.asset),
|
|
567
|
-
allowedMimeTypes: z7.array(supportedAssetMimeTypeSchema).min(1),
|
|
568
556
|
min: z7.number().nullable(),
|
|
569
557
|
max: z7.number().nullable()
|
|
570
558
|
});
|
|
@@ -754,39 +742,16 @@ var constructorElekIoCoreSchema = elekIoCoreOptionsSchema.partial({
|
|
|
754
742
|
file: true
|
|
755
743
|
}).optional();
|
|
756
744
|
|
|
757
|
-
// src/schema/gitTagSchema.ts
|
|
758
|
-
import { z as z10 } from "zod";
|
|
759
|
-
var gitTagSchema = z10.object({
|
|
760
|
-
id: uuidSchema,
|
|
761
|
-
message: z10.string(),
|
|
762
|
-
author: gitSignatureSchema,
|
|
763
|
-
datetime: z10.string().datetime()
|
|
764
|
-
});
|
|
765
|
-
var createGitTagSchema = gitTagSchema.pick({
|
|
766
|
-
message: true
|
|
767
|
-
}).extend({
|
|
768
|
-
path: gitRepositoryPathSchema,
|
|
769
|
-
hash: gitCommitSchema.shape.hash.optional()
|
|
770
|
-
});
|
|
771
|
-
var readGitTagSchema = z10.object({
|
|
772
|
-
path: gitRepositoryPathSchema,
|
|
773
|
-
id: uuidSchema.readonly()
|
|
774
|
-
});
|
|
775
|
-
var deleteGitTagSchema = readGitTagSchema.extend({});
|
|
776
|
-
var countGitTagsSchema = z10.object({
|
|
777
|
-
path: gitRepositoryPathSchema
|
|
778
|
-
});
|
|
779
|
-
|
|
780
745
|
// src/schema/projectSchema.ts
|
|
781
|
-
import { z as
|
|
782
|
-
var projectStatusSchema =
|
|
783
|
-
var projectSettingsSchema =
|
|
784
|
-
language:
|
|
746
|
+
import { z as z10 } from "zod";
|
|
747
|
+
var projectStatusSchema = z10.enum(["foo", "bar", "todo"]);
|
|
748
|
+
var projectSettingsSchema = z10.object({
|
|
749
|
+
language: z10.object({
|
|
785
750
|
default: supportedLanguageSchema,
|
|
786
|
-
supported:
|
|
751
|
+
supported: z10.array(supportedLanguageSchema)
|
|
787
752
|
})
|
|
788
753
|
});
|
|
789
|
-
var projectFolderSchema =
|
|
754
|
+
var projectFolderSchema = z10.enum([
|
|
790
755
|
"assets",
|
|
791
756
|
"collections",
|
|
792
757
|
"shared-values",
|
|
@@ -795,25 +760,27 @@ var projectFolderSchema = z11.enum([
|
|
|
795
760
|
// 'public',
|
|
796
761
|
// 'theme',
|
|
797
762
|
]);
|
|
763
|
+
var projectBranchSchema = z10.enum(["production", "work"]);
|
|
798
764
|
var projectFileSchema = baseFileSchema.extend({
|
|
799
|
-
objectType:
|
|
765
|
+
objectType: z10.literal(objectTypeSchema.Enum.project).readonly(),
|
|
800
766
|
coreVersion: versionSchema,
|
|
801
|
-
name:
|
|
802
|
-
description:
|
|
767
|
+
name: z10.string().trim().min(1, "shared.projectNameRequired"),
|
|
768
|
+
description: z10.string().trim().min(1, "shared.projectDescriptionRequired"),
|
|
803
769
|
version: versionSchema,
|
|
804
770
|
status: projectStatusSchema,
|
|
805
771
|
settings: projectSettingsSchema
|
|
806
772
|
});
|
|
807
773
|
var projectSchema = projectFileSchema.extend({
|
|
774
|
+
remoteOriginUrl: z10.string().nullable(),
|
|
808
775
|
/**
|
|
809
776
|
* Commit history of this Project
|
|
810
777
|
*/
|
|
811
|
-
history:
|
|
778
|
+
history: z10.array(gitCommitSchema),
|
|
812
779
|
/**
|
|
813
780
|
* Full commit history of this Project
|
|
814
781
|
* including all Assets, Collections, Entries and other files
|
|
815
782
|
*/
|
|
816
|
-
fullHistory:
|
|
783
|
+
fullHistory: z10.array(gitCommitSchema)
|
|
817
784
|
});
|
|
818
785
|
var outdatedProjectSchema = projectFileSchema.pick({
|
|
819
786
|
id: true,
|
|
@@ -821,8 +788,8 @@ var outdatedProjectSchema = projectFileSchema.pick({
|
|
|
821
788
|
coreVersion: true
|
|
822
789
|
});
|
|
823
790
|
var projectExportSchema = projectSchema.extend({
|
|
824
|
-
assets:
|
|
825
|
-
collections:
|
|
791
|
+
assets: z10.array(assetExportSchema),
|
|
792
|
+
collections: z10.array(collectionExportSchema)
|
|
826
793
|
});
|
|
827
794
|
var createProjectSchema = projectSchema.pick({
|
|
828
795
|
name: true,
|
|
@@ -832,9 +799,9 @@ var createProjectSchema = projectSchema.pick({
|
|
|
832
799
|
description: true,
|
|
833
800
|
settings: true
|
|
834
801
|
});
|
|
835
|
-
var readProjectSchema =
|
|
802
|
+
var readProjectSchema = z10.object({
|
|
836
803
|
id: uuidSchema.readonly(),
|
|
837
|
-
commitHash:
|
|
804
|
+
commitHash: z10.string().optional().readonly()
|
|
838
805
|
});
|
|
839
806
|
var updateProjectSchema = projectSchema.pick({
|
|
840
807
|
id: true,
|
|
@@ -846,15 +813,17 @@ var updateProjectSchema = projectSchema.pick({
|
|
|
846
813
|
description: true,
|
|
847
814
|
settings: true
|
|
848
815
|
});
|
|
849
|
-
var upgradeProjectSchema =
|
|
816
|
+
var upgradeProjectSchema = z10.object({
|
|
850
817
|
id: uuidSchema.readonly(),
|
|
851
818
|
/**
|
|
852
819
|
* Force the upgrade even if the Project is up-to-date
|
|
853
820
|
*/
|
|
854
|
-
force:
|
|
821
|
+
force: z10.boolean().optional()
|
|
822
|
+
});
|
|
823
|
+
var deleteProjectSchema = readProjectSchema.extend({
|
|
824
|
+
force: z10.boolean().optional()
|
|
855
825
|
});
|
|
856
|
-
var
|
|
857
|
-
var projectUpgradeSchema = z11.object({
|
|
826
|
+
var projectUpgradeSchema = z10.object({
|
|
858
827
|
/**
|
|
859
828
|
* The Core version the Project will be upgraded to
|
|
860
829
|
*/
|
|
@@ -862,45 +831,45 @@ var projectUpgradeSchema = z11.object({
|
|
|
862
831
|
/**
|
|
863
832
|
* Function that will be executed in the process of upgrading a Project
|
|
864
833
|
*/
|
|
865
|
-
run:
|
|
834
|
+
run: z10.function().args(projectFileSchema).returns(z10.promise(z10.void()))
|
|
866
835
|
});
|
|
867
|
-
var cloneProjectSchema =
|
|
868
|
-
url:
|
|
836
|
+
var cloneProjectSchema = z10.object({
|
|
837
|
+
url: z10.string()
|
|
869
838
|
});
|
|
870
|
-
var listBranchesProjectSchema =
|
|
839
|
+
var listBranchesProjectSchema = z10.object({
|
|
871
840
|
id: uuidSchema.readonly()
|
|
872
841
|
});
|
|
873
|
-
var currentBranchProjectSchema =
|
|
842
|
+
var currentBranchProjectSchema = z10.object({
|
|
874
843
|
id: uuidSchema.readonly()
|
|
875
844
|
});
|
|
876
|
-
var switchBranchProjectSchema =
|
|
845
|
+
var switchBranchProjectSchema = z10.object({
|
|
877
846
|
id: uuidSchema.readonly(),
|
|
878
|
-
branch:
|
|
847
|
+
branch: z10.string(),
|
|
879
848
|
options: gitSwitchOptionsSchema.optional()
|
|
880
849
|
});
|
|
881
|
-
var getRemoteOriginUrlProjectSchema =
|
|
850
|
+
var getRemoteOriginUrlProjectSchema = z10.object({
|
|
882
851
|
id: uuidSchema.readonly()
|
|
883
852
|
});
|
|
884
|
-
var setRemoteOriginUrlProjectSchema =
|
|
853
|
+
var setRemoteOriginUrlProjectSchema = z10.object({
|
|
885
854
|
id: uuidSchema.readonly(),
|
|
886
|
-
url:
|
|
855
|
+
url: z10.string()
|
|
887
856
|
});
|
|
888
|
-
var getChangesProjectSchema =
|
|
857
|
+
var getChangesProjectSchema = z10.object({
|
|
889
858
|
id: uuidSchema.readonly()
|
|
890
859
|
});
|
|
891
|
-
var synchronizeProjectSchema =
|
|
860
|
+
var synchronizeProjectSchema = z10.object({
|
|
892
861
|
id: uuidSchema.readonly()
|
|
893
862
|
});
|
|
894
|
-
var searchProjectSchema =
|
|
863
|
+
var searchProjectSchema = z10.object({
|
|
895
864
|
id: uuidSchema.readonly(),
|
|
896
|
-
query:
|
|
865
|
+
query: z10.string(),
|
|
897
866
|
language: supportedLanguageSchema,
|
|
898
|
-
type:
|
|
867
|
+
type: z10.array(objectTypeSchema).optional()
|
|
899
868
|
});
|
|
900
869
|
|
|
901
870
|
// src/schema/serviceSchema.ts
|
|
902
|
-
import { z as
|
|
903
|
-
var serviceTypeSchema =
|
|
871
|
+
import { z as z11 } from "zod";
|
|
872
|
+
var serviceTypeSchema = z11.enum([
|
|
904
873
|
"Git",
|
|
905
874
|
"GitTag",
|
|
906
875
|
"User",
|
|
@@ -912,10 +881,10 @@ var serviceTypeSchema = z12.enum([
|
|
|
912
881
|
"Entry",
|
|
913
882
|
"Value"
|
|
914
883
|
]);
|
|
915
|
-
var listSchema =
|
|
884
|
+
var listSchema = z11.object({
|
|
916
885
|
projectId: uuidSchema,
|
|
917
|
-
limit:
|
|
918
|
-
offset:
|
|
886
|
+
limit: z11.number().optional(),
|
|
887
|
+
offset: z11.number().optional()
|
|
919
888
|
});
|
|
920
889
|
var listCollectionsSchema = listSchema;
|
|
921
890
|
var listEntriesSchema = listSchema.extend({
|
|
@@ -925,33 +894,33 @@ var listAssetsSchema = listSchema;
|
|
|
925
894
|
var listProjectsSchema = listSchema.omit({
|
|
926
895
|
projectId: true
|
|
927
896
|
});
|
|
928
|
-
var listGitTagsSchema =
|
|
929
|
-
path:
|
|
897
|
+
var listGitTagsSchema = z11.object({
|
|
898
|
+
path: z11.string()
|
|
930
899
|
});
|
|
931
900
|
|
|
932
901
|
// src/schema/userSchema.ts
|
|
933
|
-
import
|
|
934
|
-
var UserTypeSchema =
|
|
902
|
+
import z12 from "zod";
|
|
903
|
+
var UserTypeSchema = z12.enum(["local", "cloud"]);
|
|
935
904
|
var baseUserSchema = gitSignatureSchema.extend({
|
|
936
905
|
userType: UserTypeSchema,
|
|
937
906
|
language: supportedLanguageSchema,
|
|
938
|
-
window:
|
|
939
|
-
width:
|
|
940
|
-
height:
|
|
941
|
-
position:
|
|
942
|
-
x:
|
|
943
|
-
y:
|
|
907
|
+
window: z12.object({
|
|
908
|
+
width: z12.number(),
|
|
909
|
+
height: z12.number(),
|
|
910
|
+
position: z12.object({
|
|
911
|
+
x: z12.number(),
|
|
912
|
+
y: z12.number()
|
|
944
913
|
})
|
|
945
914
|
}).nullable()
|
|
946
915
|
});
|
|
947
916
|
var localUserSchema = baseUserSchema.extend({
|
|
948
|
-
userType:
|
|
917
|
+
userType: z12.literal(UserTypeSchema.Enum.local)
|
|
949
918
|
});
|
|
950
919
|
var cloudUserSchema = baseUserSchema.extend({
|
|
951
|
-
userType:
|
|
920
|
+
userType: z12.literal(UserTypeSchema.Enum.cloud),
|
|
952
921
|
id: uuidSchema
|
|
953
922
|
});
|
|
954
|
-
var userFileSchema =
|
|
923
|
+
var userFileSchema = z12.union([localUserSchema, cloudUserSchema]);
|
|
955
924
|
var userSchema = userFileSchema;
|
|
956
925
|
var setUserSchema = userSchema;
|
|
957
926
|
|
|
@@ -990,17 +959,14 @@ var RequiredParameterMissingError = class extends Error {
|
|
|
990
959
|
// src/util/node.ts
|
|
991
960
|
var node_exports = {};
|
|
992
961
|
__export(node_exports, {
|
|
993
|
-
assignDefaultIfMissing: () => assignDefaultIfMissing,
|
|
994
962
|
files: () => files,
|
|
995
963
|
folders: () => folders,
|
|
996
964
|
isNoError: () => isNoError,
|
|
997
965
|
notEmpty: () => notEmpty,
|
|
998
966
|
pathTo: () => pathTo,
|
|
999
967
|
returnResolved: () => returnResolved,
|
|
1000
|
-
spawnChildProcess: () => spawnChildProcess,
|
|
1001
968
|
workingDirectory: () => workingDirectory
|
|
1002
969
|
});
|
|
1003
|
-
import { spawn } from "child_process";
|
|
1004
970
|
import Fs from "fs-extra";
|
|
1005
971
|
import Os from "os";
|
|
1006
972
|
import Path from "path";
|
|
@@ -1065,9 +1031,6 @@ var pathTo = {
|
|
|
1065
1031
|
return Path.join(pathTo.tmp, `${id}.${extension}`);
|
|
1066
1032
|
}
|
|
1067
1033
|
};
|
|
1068
|
-
function assignDefaultIfMissing(value, defaultsTo) {
|
|
1069
|
-
return Object.assign(defaultsTo, value);
|
|
1070
|
-
}
|
|
1071
1034
|
function notEmpty(value) {
|
|
1072
1035
|
if (value === null || value === void 0) {
|
|
1073
1036
|
return false;
|
|
@@ -1100,27 +1063,6 @@ async function returnResolved(promises) {
|
|
|
1100
1063
|
const checked = await Promise.all(toCheck);
|
|
1101
1064
|
return checked.filter(isNoError);
|
|
1102
1065
|
}
|
|
1103
|
-
function spawnChildProcess(command, args, options) {
|
|
1104
|
-
return new Promise((resolve, reject) => {
|
|
1105
|
-
const childProcess = spawn(command, args, options);
|
|
1106
|
-
let log = "";
|
|
1107
|
-
childProcess.stdout.on("data", (data) => {
|
|
1108
|
-
log += data;
|
|
1109
|
-
});
|
|
1110
|
-
childProcess.stderr.on("data", (data) => {
|
|
1111
|
-
log += data;
|
|
1112
|
-
});
|
|
1113
|
-
childProcess.on("error", (error) => {
|
|
1114
|
-
throw error;
|
|
1115
|
-
});
|
|
1116
|
-
childProcess.on("exit", (code) => {
|
|
1117
|
-
if (code === 0) {
|
|
1118
|
-
return resolve(log);
|
|
1119
|
-
}
|
|
1120
|
-
return reject(log);
|
|
1121
|
-
});
|
|
1122
|
-
});
|
|
1123
|
-
}
|
|
1124
1066
|
async function folders(path) {
|
|
1125
1067
|
const dirent = await Fs.readdir(path, { withFileTypes: true });
|
|
1126
1068
|
return dirent.filter((dirent2) => {
|
|
@@ -1144,21 +1086,12 @@ async function files(path, extension) {
|
|
|
1144
1086
|
var AbstractCrudService = class {
|
|
1145
1087
|
type;
|
|
1146
1088
|
options;
|
|
1147
|
-
/**
|
|
1148
|
-
* Dynamically generated git messages for operations
|
|
1149
|
-
*/
|
|
1150
|
-
gitMessage;
|
|
1151
1089
|
/**
|
|
1152
1090
|
* Do not instantiate directly as this is an abstract class
|
|
1153
1091
|
*/
|
|
1154
1092
|
constructor(type, options) {
|
|
1155
1093
|
this.type = type;
|
|
1156
1094
|
this.options = options;
|
|
1157
|
-
this.gitMessage = {
|
|
1158
|
-
create: `${gitCommitIconSchema.enum.CREATE} Created ${this.type}`,
|
|
1159
|
-
update: `${gitCommitIconSchema.enum.UPDATE} Updated ${this.type}`,
|
|
1160
|
-
delete: `${gitCommitIconSchema.enum.DELETE} Deleted ${this.type}`
|
|
1161
|
-
};
|
|
1162
1095
|
}
|
|
1163
1096
|
/**
|
|
1164
1097
|
* Returns a list of all file references of given project and type
|
|
@@ -1218,8 +1151,7 @@ var AbstractCrudService = class {
|
|
|
1218
1151
|
* Searches for all files inside given folder,
|
|
1219
1152
|
* parses their names and returns them as FileReference
|
|
1220
1153
|
*
|
|
1221
|
-
* Ignores files
|
|
1222
|
-
* or [id].[extension] format for their names
|
|
1154
|
+
* Ignores files if the extension is not supported.
|
|
1223
1155
|
*/
|
|
1224
1156
|
async getFileReferences(path) {
|
|
1225
1157
|
const possibleFiles = await files(path);
|
|
@@ -1227,9 +1159,8 @@ var AbstractCrudService = class {
|
|
|
1227
1159
|
possibleFiles.map(async (possibleFile) => {
|
|
1228
1160
|
const fileNameArray = possibleFile.name.split(".");
|
|
1229
1161
|
const fileReference = {
|
|
1230
|
-
id: fileNameArray[0]
|
|
1231
|
-
|
|
1232
|
-
extension: fileNameArray.length === 2 ? fileNameArray[1] : fileNameArray[2]
|
|
1162
|
+
id: fileNameArray[0],
|
|
1163
|
+
extension: fileNameArray[1]
|
|
1233
1164
|
};
|
|
1234
1165
|
try {
|
|
1235
1166
|
return fileReferenceSchema.parse(fileReference);
|
|
@@ -1243,9 +1174,8 @@ var AbstractCrudService = class {
|
|
|
1243
1174
|
};
|
|
1244
1175
|
|
|
1245
1176
|
// src/service/AssetService.ts
|
|
1246
|
-
import { fileTypeFromFile } from "file-type";
|
|
1247
1177
|
import Fs2 from "fs-extra";
|
|
1248
|
-
import
|
|
1178
|
+
import mime from "mime";
|
|
1249
1179
|
|
|
1250
1180
|
// src/util/shared.ts
|
|
1251
1181
|
import slugify from "@sindresorhus/slugify";
|
|
@@ -1286,8 +1216,8 @@ var AssetService = class extends AbstractCrudService {
|
|
|
1286
1216
|
createAssetSchema.parse(props);
|
|
1287
1217
|
const id = uuid();
|
|
1288
1218
|
const projectPath = pathTo.project(props.projectId);
|
|
1289
|
-
const fileType =
|
|
1290
|
-
const size = await this.
|
|
1219
|
+
const fileType = this.getFileType(props.filePath);
|
|
1220
|
+
const size = await this.getFileSize(props.filePath);
|
|
1291
1221
|
const assetPath = pathTo.asset(props.projectId, id, fileType.extension);
|
|
1292
1222
|
const assetFilePath = pathTo.assetFile(props.projectId, id);
|
|
1293
1223
|
const assetFile = {
|
|
@@ -1313,7 +1243,10 @@ var AssetService = class extends AbstractCrudService {
|
|
|
1313
1243
|
throw error;
|
|
1314
1244
|
}
|
|
1315
1245
|
await this.gitService.add(projectPath, [assetFilePath, assetPath]);
|
|
1316
|
-
await this.gitService.commit(projectPath,
|
|
1246
|
+
await this.gitService.commit(projectPath, {
|
|
1247
|
+
method: "create",
|
|
1248
|
+
reference: { objectType: "asset", id }
|
|
1249
|
+
});
|
|
1317
1250
|
return this.toAsset(props.projectId, assetFile);
|
|
1318
1251
|
}
|
|
1319
1252
|
/**
|
|
@@ -1378,10 +1311,8 @@ var AssetService = class extends AbstractCrudService {
|
|
|
1378
1311
|
updated: datetime()
|
|
1379
1312
|
};
|
|
1380
1313
|
if (props.newFilePath) {
|
|
1381
|
-
const fileType =
|
|
1382
|
-
|
|
1383
|
-
);
|
|
1384
|
-
const size = await this.getAssetSize(props.newFilePath);
|
|
1314
|
+
const fileType = this.getFileType(props.newFilePath);
|
|
1315
|
+
const size = await this.getFileSize(props.newFilePath);
|
|
1385
1316
|
const prevAssetPath = pathTo.asset(
|
|
1386
1317
|
props.projectId,
|
|
1387
1318
|
props.id,
|
|
@@ -1405,7 +1336,10 @@ var AssetService = class extends AbstractCrudService {
|
|
|
1405
1336
|
assetFileSchema
|
|
1406
1337
|
);
|
|
1407
1338
|
await this.gitService.add(projectPath, [assetFilePath]);
|
|
1408
|
-
await this.gitService.commit(projectPath,
|
|
1339
|
+
await this.gitService.commit(projectPath, {
|
|
1340
|
+
method: "update",
|
|
1341
|
+
reference: { objectType: "asset", id: assetFile.id }
|
|
1342
|
+
});
|
|
1409
1343
|
return this.toAsset(props.projectId, assetFile);
|
|
1410
1344
|
}
|
|
1411
1345
|
/**
|
|
@@ -1419,7 +1353,10 @@ var AssetService = class extends AbstractCrudService {
|
|
|
1419
1353
|
await Fs2.remove(assetPath);
|
|
1420
1354
|
await Fs2.remove(assetFilePath);
|
|
1421
1355
|
await this.gitService.add(projectPath, [assetFilePath, assetPath]);
|
|
1422
|
-
await this.gitService.commit(projectPath,
|
|
1356
|
+
await this.gitService.commit(projectPath, {
|
|
1357
|
+
method: "delete",
|
|
1358
|
+
reference: { objectType: "asset", id: props.id }
|
|
1359
|
+
});
|
|
1423
1360
|
}
|
|
1424
1361
|
async list(props) {
|
|
1425
1362
|
listAssetsSchema.parse(props);
|
|
@@ -1457,11 +1394,11 @@ var AssetService = class extends AbstractCrudService {
|
|
|
1457
1394
|
return assetSchema.safeParse(obj).success;
|
|
1458
1395
|
}
|
|
1459
1396
|
/**
|
|
1460
|
-
* Returns the size of an
|
|
1397
|
+
* Returns the size of an file in bytes
|
|
1461
1398
|
*
|
|
1462
|
-
* @param path Path of the
|
|
1399
|
+
* @param path Path of the file to get the size from
|
|
1463
1400
|
*/
|
|
1464
|
-
async
|
|
1401
|
+
async getFileSize(path) {
|
|
1465
1402
|
return (await Fs2.stat(path)).size;
|
|
1466
1403
|
}
|
|
1467
1404
|
/**
|
|
@@ -1488,23 +1425,21 @@ var AssetService = class extends AbstractCrudService {
|
|
|
1488
1425
|
*
|
|
1489
1426
|
* @param filePath Path to the file to check
|
|
1490
1427
|
*/
|
|
1491
|
-
|
|
1492
|
-
const
|
|
1493
|
-
if (
|
|
1494
|
-
|
|
1495
|
-
if (isSvg(fileBuffer.toString()) === true) {
|
|
1496
|
-
return {
|
|
1497
|
-
extension: supportedAssetExtensionSchema.Enum.svg,
|
|
1498
|
-
mimeType: supportedAssetMimeTypeSchema.Enum["image/svg+xml"]
|
|
1499
|
-
};
|
|
1500
|
-
}
|
|
1428
|
+
getFileType(filePath) {
|
|
1429
|
+
const mimeType = mime.getType(filePath);
|
|
1430
|
+
if (mimeType === null) {
|
|
1431
|
+
throw new Error(`Unsupported MIME type of file "${filePath}"`);
|
|
1501
1432
|
}
|
|
1502
|
-
const
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1433
|
+
const extension = mime.getExtension(mimeType);
|
|
1434
|
+
if (extension === null) {
|
|
1435
|
+
throw new Error(
|
|
1436
|
+
`Unsupported extension for MIME type "${mimeType}" of file "${filePath}"`
|
|
1437
|
+
);
|
|
1438
|
+
}
|
|
1439
|
+
return {
|
|
1440
|
+
extension,
|
|
1441
|
+
mimeType
|
|
1442
|
+
};
|
|
1508
1443
|
}
|
|
1509
1444
|
/**
|
|
1510
1445
|
* Migrates an potentially outdated Asset file to the current schema
|
|
@@ -1551,7 +1486,10 @@ var CollectionService = class extends AbstractCrudService {
|
|
|
1551
1486
|
collectionFileSchema
|
|
1552
1487
|
);
|
|
1553
1488
|
await this.gitService.add(projectPath, [collectionFilePath]);
|
|
1554
|
-
await this.gitService.commit(projectPath,
|
|
1489
|
+
await this.gitService.commit(projectPath, {
|
|
1490
|
+
method: "create",
|
|
1491
|
+
reference: { objectType: "collection", id }
|
|
1492
|
+
});
|
|
1555
1493
|
return this.toCollection(props.projectId, collectionFile);
|
|
1556
1494
|
}
|
|
1557
1495
|
/**
|
|
@@ -1606,7 +1544,10 @@ var CollectionService = class extends AbstractCrudService {
|
|
|
1606
1544
|
collectionFileSchema
|
|
1607
1545
|
);
|
|
1608
1546
|
await this.gitService.add(projectPath, [collectionFilePath]);
|
|
1609
|
-
await this.gitService.commit(projectPath,
|
|
1547
|
+
await this.gitService.commit(projectPath, {
|
|
1548
|
+
method: "update",
|
|
1549
|
+
reference: { objectType: "collection", id: collectionFile.id }
|
|
1550
|
+
});
|
|
1610
1551
|
return this.toCollection(props.projectId, collectionFile);
|
|
1611
1552
|
}
|
|
1612
1553
|
/**
|
|
@@ -1620,7 +1561,10 @@ var CollectionService = class extends AbstractCrudService {
|
|
|
1620
1561
|
const collectionPath = pathTo.collection(props.projectId, props.id);
|
|
1621
1562
|
await Fs3.remove(collectionPath);
|
|
1622
1563
|
await this.gitService.add(projectPath, [collectionPath]);
|
|
1623
|
-
await this.gitService.commit(projectPath,
|
|
1564
|
+
await this.gitService.commit(projectPath, {
|
|
1565
|
+
method: "delete",
|
|
1566
|
+
reference: { objectType: "collection", id: props.id }
|
|
1567
|
+
});
|
|
1624
1568
|
}
|
|
1625
1569
|
async list(props) {
|
|
1626
1570
|
listCollectionsSchema.parse(props);
|
|
@@ -1743,7 +1687,14 @@ var EntryService = class extends AbstractCrudService {
|
|
|
1743
1687
|
entryFileSchema
|
|
1744
1688
|
);
|
|
1745
1689
|
await this.gitService.add(projectPath, [entryFilePath]);
|
|
1746
|
-
await this.gitService.commit(projectPath,
|
|
1690
|
+
await this.gitService.commit(projectPath, {
|
|
1691
|
+
method: "create",
|
|
1692
|
+
reference: {
|
|
1693
|
+
objectType: "entry",
|
|
1694
|
+
id: entryFile.id,
|
|
1695
|
+
collectionId: props.collectionId
|
|
1696
|
+
}
|
|
1697
|
+
});
|
|
1747
1698
|
return entry;
|
|
1748
1699
|
}
|
|
1749
1700
|
/**
|
|
@@ -1813,7 +1764,14 @@ var EntryService = class extends AbstractCrudService {
|
|
|
1813
1764
|
entryFileSchema
|
|
1814
1765
|
);
|
|
1815
1766
|
await this.gitService.add(projectPath, [entryFilePath]);
|
|
1816
|
-
await this.gitService.commit(projectPath,
|
|
1767
|
+
await this.gitService.commit(projectPath, {
|
|
1768
|
+
method: "update",
|
|
1769
|
+
reference: {
|
|
1770
|
+
objectType: "entry",
|
|
1771
|
+
id: entryFile.id,
|
|
1772
|
+
collectionId: props.collectionId
|
|
1773
|
+
}
|
|
1774
|
+
});
|
|
1817
1775
|
return entry;
|
|
1818
1776
|
}
|
|
1819
1777
|
/**
|
|
@@ -1829,7 +1787,14 @@ var EntryService = class extends AbstractCrudService {
|
|
|
1829
1787
|
);
|
|
1830
1788
|
await Fs4.remove(entryFilePath);
|
|
1831
1789
|
await this.gitService.add(projectPath, [entryFilePath]);
|
|
1832
|
-
await this.gitService.commit(projectPath,
|
|
1790
|
+
await this.gitService.commit(projectPath, {
|
|
1791
|
+
method: "delete",
|
|
1792
|
+
reference: {
|
|
1793
|
+
objectType: "entry",
|
|
1794
|
+
id: props.id,
|
|
1795
|
+
collectionId: props.collectionId
|
|
1796
|
+
}
|
|
1797
|
+
});
|
|
1833
1798
|
}
|
|
1834
1799
|
async list(props) {
|
|
1835
1800
|
listEntriesSchema.parse(props);
|
|
@@ -2203,6 +2168,9 @@ var GitService = class {
|
|
|
2203
2168
|
*/
|
|
2204
2169
|
async clone(url, path, options) {
|
|
2205
2170
|
let args = ["clone", "--progress"];
|
|
2171
|
+
if (options?.bare) {
|
|
2172
|
+
args = [...args, "--bare"];
|
|
2173
|
+
}
|
|
2206
2174
|
if (options?.branch) {
|
|
2207
2175
|
args = [...args, "--branch", options.branch];
|
|
2208
2176
|
}
|
|
@@ -2303,6 +2271,21 @@ var GitService = class {
|
|
|
2303
2271
|
args = [...args, branch];
|
|
2304
2272
|
}
|
|
2305
2273
|
await this.git(path, args);
|
|
2274
|
+
},
|
|
2275
|
+
/**
|
|
2276
|
+
* Delete a branch
|
|
2277
|
+
*
|
|
2278
|
+
* @see https://git-scm.com/docs/git-branch#Documentation/git-branch.txt---delete
|
|
2279
|
+
*
|
|
2280
|
+
* @param path Path to the repository
|
|
2281
|
+
* @param branch Name of the branch to delete
|
|
2282
|
+
*/
|
|
2283
|
+
delete: async (path, branch, force) => {
|
|
2284
|
+
let args = ["branch", "--delete"];
|
|
2285
|
+
if (force === true) {
|
|
2286
|
+
args = [...args, "--force"];
|
|
2287
|
+
}
|
|
2288
|
+
await this.git(path, [...args, branch]);
|
|
2306
2289
|
}
|
|
2307
2290
|
};
|
|
2308
2291
|
remotes = {
|
|
@@ -2374,6 +2357,19 @@ var GitService = class {
|
|
|
2374
2357
|
await this.git(path, args);
|
|
2375
2358
|
}
|
|
2376
2359
|
};
|
|
2360
|
+
/**
|
|
2361
|
+
* Join two development histories together
|
|
2362
|
+
*
|
|
2363
|
+
* @see https://git-scm.com/docs/git-merge
|
|
2364
|
+
*/
|
|
2365
|
+
async merge(path, branch, options) {
|
|
2366
|
+
let args = ["merge"];
|
|
2367
|
+
if (options?.squash === true) {
|
|
2368
|
+
args = [...args, "--squash"];
|
|
2369
|
+
}
|
|
2370
|
+
args = [...args, branch];
|
|
2371
|
+
await this.git(path, args);
|
|
2372
|
+
}
|
|
2377
2373
|
/**
|
|
2378
2374
|
* Reset current HEAD to the specified state
|
|
2379
2375
|
*
|
|
@@ -2455,16 +2451,17 @@ var GitService = class {
|
|
|
2455
2451
|
* @see https://git-scm.com/docs/git-commit
|
|
2456
2452
|
*
|
|
2457
2453
|
* @param path Path to the repository
|
|
2458
|
-
* @param message
|
|
2454
|
+
* @param message An object describing the changes
|
|
2459
2455
|
*/
|
|
2460
2456
|
async commit(path, message) {
|
|
2457
|
+
gitMessageSchema.parse(message);
|
|
2461
2458
|
const user = await this.userService.get();
|
|
2462
2459
|
if (!user) {
|
|
2463
2460
|
throw new NoCurrentUserError();
|
|
2464
2461
|
}
|
|
2465
2462
|
const args = [
|
|
2466
2463
|
"commit",
|
|
2467
|
-
`--message=${message}`,
|
|
2464
|
+
`--message=${JSON.stringify(message)}`,
|
|
2468
2465
|
`--author=${user.name} <${user.email}>`
|
|
2469
2466
|
];
|
|
2470
2467
|
await this.git(path, args);
|
|
@@ -2499,19 +2496,23 @@ var GitService = class {
|
|
|
2499
2496
|
const noEmptyLinesArr = result.stdout.split("\n").filter((line) => {
|
|
2500
2497
|
return line.trim() !== "";
|
|
2501
2498
|
});
|
|
2502
|
-
const lineObjArr =
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2499
|
+
const lineObjArr = await Promise.all(
|
|
2500
|
+
noEmptyLinesArr.map(async (line) => {
|
|
2501
|
+
const lineArray = line.split("|");
|
|
2502
|
+
const tagId = this.refNameToTagName(lineArray[5] || "");
|
|
2503
|
+
const tag = tagId ? await this.tags.read({ path, id: tagId }) : null;
|
|
2504
|
+
return {
|
|
2505
|
+
hash: lineArray[0],
|
|
2506
|
+
message: JSON.parse(lineArray[1] || ""),
|
|
2507
|
+
author: {
|
|
2508
|
+
name: lineArray[2],
|
|
2509
|
+
email: lineArray[3]
|
|
2510
|
+
},
|
|
2511
|
+
datetime: datetime(lineArray[4]),
|
|
2512
|
+
tag
|
|
2513
|
+
};
|
|
2514
|
+
})
|
|
2515
|
+
);
|
|
2515
2516
|
return lineObjArr.filter(this.isGitCommit.bind(this));
|
|
2516
2517
|
}
|
|
2517
2518
|
/**
|
|
@@ -2774,7 +2775,13 @@ var LogService = class {
|
|
|
2774
2775
|
new transports.Console({
|
|
2775
2776
|
handleExceptions: true,
|
|
2776
2777
|
handleRejections: true,
|
|
2777
|
-
format: format.
|
|
2778
|
+
format: format.combine(
|
|
2779
|
+
format.colorize(),
|
|
2780
|
+
format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
|
|
2781
|
+
format.printf((info) => {
|
|
2782
|
+
return `${info.level} [${info["timestamp"]}]: ${info.message}`;
|
|
2783
|
+
})
|
|
2784
|
+
)
|
|
2778
2785
|
})
|
|
2779
2786
|
]
|
|
2780
2787
|
});
|
|
@@ -2785,16 +2792,16 @@ var LogService = class {
|
|
|
2785
2792
|
});
|
|
2786
2793
|
}
|
|
2787
2794
|
debug(message, ...meta) {
|
|
2788
|
-
|
|
2795
|
+
this.logger.debug(message, ...meta);
|
|
2789
2796
|
}
|
|
2790
2797
|
info(message, ...meta) {
|
|
2791
|
-
|
|
2798
|
+
this.logger.info(message, ...meta);
|
|
2792
2799
|
}
|
|
2793
2800
|
warn(message, ...meta) {
|
|
2794
|
-
|
|
2801
|
+
this.logger.warn(message, ...meta);
|
|
2795
2802
|
}
|
|
2796
2803
|
error(message, ...meta) {
|
|
2797
|
-
|
|
2804
|
+
this.logger.error(message, ...meta);
|
|
2798
2805
|
}
|
|
2799
2806
|
read(options) {
|
|
2800
2807
|
return this.logger.query(options);
|
|
@@ -2806,6 +2813,28 @@ import Fs6 from "fs-extra";
|
|
|
2806
2813
|
import Os2 from "os";
|
|
2807
2814
|
import Path4 from "path";
|
|
2808
2815
|
import Semver from "semver";
|
|
2816
|
+
|
|
2817
|
+
// src/error/RemoteOriginMissingError.ts
|
|
2818
|
+
var RemoteOriginMissingError = class extends Error {
|
|
2819
|
+
constructor(projectId) {
|
|
2820
|
+
super(
|
|
2821
|
+
`Tried to delete Project "${projectId}" but it does not have a remote origin. Deleting a Project without a remote origin could lead to data loss. Use the "force" option to delete it anyway.`
|
|
2822
|
+
);
|
|
2823
|
+
this.name = "RemoteOriginMissingError";
|
|
2824
|
+
}
|
|
2825
|
+
};
|
|
2826
|
+
|
|
2827
|
+
// src/error/SynchronizeLocalChangesError.ts
|
|
2828
|
+
var SynchronizeLocalChangesError = class extends Error {
|
|
2829
|
+
constructor(projectId) {
|
|
2830
|
+
super(
|
|
2831
|
+
`Tried to delete Project "${projectId}" but it has local changes that are not yet pushed to the remote origin. Deleting a Project with local changes could lead to data loss. Use the "force" option to delete it anyway.`
|
|
2832
|
+
);
|
|
2833
|
+
this.name = "SynchronizeLocalChangesError";
|
|
2834
|
+
}
|
|
2835
|
+
};
|
|
2836
|
+
|
|
2837
|
+
// src/service/ProjectService.ts
|
|
2809
2838
|
var ProjectService = class extends AbstractCrudService {
|
|
2810
2839
|
coreVersion;
|
|
2811
2840
|
logService;
|
|
@@ -2859,23 +2888,30 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
2859
2888
|
try {
|
|
2860
2889
|
await this.createFolderStructure(projectPath);
|
|
2861
2890
|
await this.createGitignore(projectPath);
|
|
2862
|
-
await this.gitService.init(projectPath, {
|
|
2891
|
+
await this.gitService.init(projectPath, {
|
|
2892
|
+
initialBranch: projectBranchSchema.Enum.production
|
|
2893
|
+
});
|
|
2863
2894
|
await this.jsonFileService.create(
|
|
2864
2895
|
projectFile,
|
|
2865
2896
|
pathTo.projectFile(id),
|
|
2866
2897
|
projectFileSchema
|
|
2867
2898
|
);
|
|
2868
2899
|
await this.gitService.add(projectPath, ["."]);
|
|
2869
|
-
await this.gitService.commit(
|
|
2900
|
+
await this.gitService.commit(projectPath, {
|
|
2901
|
+
method: "create",
|
|
2902
|
+
reference: { objectType: "project", id }
|
|
2903
|
+
});
|
|
2904
|
+
await this.gitService.branches.switch(
|
|
2870
2905
|
projectPath,
|
|
2871
|
-
|
|
2906
|
+
projectBranchSchema.Enum.work,
|
|
2907
|
+
{
|
|
2908
|
+
isNew: true
|
|
2909
|
+
}
|
|
2872
2910
|
);
|
|
2873
|
-
await this.gitService.branches.switch(projectPath, "stage", {
|
|
2874
|
-
isNew: true
|
|
2875
|
-
});
|
|
2876
2911
|
} catch (error) {
|
|
2877
2912
|
await this.delete({
|
|
2878
|
-
id
|
|
2913
|
+
id,
|
|
2914
|
+
force: true
|
|
2879
2915
|
});
|
|
2880
2916
|
throw error;
|
|
2881
2917
|
}
|
|
@@ -2953,7 +2989,10 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
2953
2989
|
};
|
|
2954
2990
|
await this.jsonFileService.update(projectFile, filePath, projectFileSchema);
|
|
2955
2991
|
await this.gitService.add(projectPath, [filePath]);
|
|
2956
|
-
await this.gitService.commit(projectPath,
|
|
2992
|
+
await this.gitService.commit(projectPath, {
|
|
2993
|
+
method: "update",
|
|
2994
|
+
reference: { objectType: "project", id: projectFile.id }
|
|
2995
|
+
});
|
|
2957
2996
|
return await this.toProject(projectFile);
|
|
2958
2997
|
}
|
|
2959
2998
|
/**
|
|
@@ -2965,15 +3004,22 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
2965
3004
|
upgradeProjectSchema.parse(props);
|
|
2966
3005
|
const projectPath = pathTo.project(props.id);
|
|
2967
3006
|
const projectFilePath = pathTo.projectFile(props.id);
|
|
2968
|
-
const
|
|
2969
|
-
if (
|
|
3007
|
+
const currentBranch = await this.gitService.branches.current(projectPath);
|
|
3008
|
+
if (currentBranch !== projectBranchSchema.Enum.work) {
|
|
3009
|
+
await this.gitService.branches.switch(
|
|
3010
|
+
projectPath,
|
|
3011
|
+
projectBranchSchema.Enum.work
|
|
3012
|
+
);
|
|
3013
|
+
}
|
|
3014
|
+
const currentProjectFile = outdatedProjectSchema.passthrough().parse(await this.jsonFileService.unsafeRead(projectFilePath));
|
|
3015
|
+
if (Semver.gt(currentProjectFile.coreVersion, this.coreVersion)) {
|
|
2970
3016
|
throw new ProjectUpgradeError(
|
|
2971
|
-
`The Projects Core version "${
|
|
3017
|
+
`The Projects Core version "${currentProjectFile.coreVersion}" is higher than the current Core version "${this.coreVersion}".`
|
|
2972
3018
|
);
|
|
2973
3019
|
}
|
|
2974
|
-
if (Semver.eq(
|
|
3020
|
+
if (Semver.eq(currentProjectFile.coreVersion, this.coreVersion) && props.force !== true) {
|
|
2975
3021
|
throw new ProjectUpgradeError(
|
|
2976
|
-
`The Projects Core version "${
|
|
3022
|
+
`The Projects Core version "${currentProjectFile.coreVersion}" is already up to date.`
|
|
2977
3023
|
);
|
|
2978
3024
|
}
|
|
2979
3025
|
const assetReferences = await this.listReferences("asset", props.id);
|
|
@@ -2982,11 +3028,11 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
2982
3028
|
props.id
|
|
2983
3029
|
);
|
|
2984
3030
|
this.logService.info(
|
|
2985
|
-
`Attempting to upgrade Project "${props.id}" from Core version ${
|
|
3031
|
+
`Attempting to upgrade Project "${props.id}" from Core version ${currentProjectFile.coreVersion} to ${this.coreVersion}`
|
|
2986
3032
|
);
|
|
2987
|
-
const
|
|
2988
|
-
|
|
2989
|
-
|
|
3033
|
+
const upgradeBranchName = `upgrade/core-${currentProjectFile.coreVersion}-to-${this.coreVersion}`;
|
|
3034
|
+
await this.gitService.branches.switch(projectPath, upgradeBranchName, {
|
|
3035
|
+
isNew: true
|
|
2990
3036
|
});
|
|
2991
3037
|
try {
|
|
2992
3038
|
await Promise.all(
|
|
@@ -3018,22 +3064,45 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
3018
3064
|
);
|
|
3019
3065
|
})
|
|
3020
3066
|
);
|
|
3021
|
-
const migratedProjectFile = this.migrate(
|
|
3067
|
+
const migratedProjectFile = this.migrate(currentProjectFile);
|
|
3022
3068
|
await this.update(migratedProjectFile);
|
|
3023
|
-
this.
|
|
3024
|
-
|
|
3025
|
-
|
|
3069
|
+
await this.gitService.branches.switch(
|
|
3070
|
+
projectPath,
|
|
3071
|
+
projectBranchSchema.Enum.work
|
|
3072
|
+
);
|
|
3073
|
+
await this.gitService.merge(projectPath, upgradeBranchName, {
|
|
3074
|
+
squash: true
|
|
3026
3075
|
});
|
|
3027
|
-
await this.gitService.
|
|
3028
|
-
|
|
3029
|
-
|
|
3076
|
+
await this.gitService.commit(projectPath, {
|
|
3077
|
+
method: "upgrade",
|
|
3078
|
+
reference: { objectType: "project", id: migratedProjectFile.id }
|
|
3030
3079
|
});
|
|
3031
|
-
await this.gitService.tags.
|
|
3080
|
+
await this.gitService.tags.create({
|
|
3032
3081
|
path: projectPath,
|
|
3033
|
-
|
|
3082
|
+
message: `Upgraded Project to Core version ${migratedProjectFile.coreVersion}`
|
|
3034
3083
|
});
|
|
3084
|
+
await this.gitService.branches.delete(
|
|
3085
|
+
projectPath,
|
|
3086
|
+
upgradeBranchName,
|
|
3087
|
+
true
|
|
3088
|
+
);
|
|
3089
|
+
this.logService.info(
|
|
3090
|
+
`Upgraded Project "${projectFilePath}" to Core version "${this.coreVersion}"`,
|
|
3091
|
+
{
|
|
3092
|
+
previous: currentProjectFile,
|
|
3093
|
+
migrated: migratedProjectFile
|
|
3094
|
+
}
|
|
3095
|
+
);
|
|
3035
3096
|
} catch (error) {
|
|
3036
|
-
await this.gitService.
|
|
3097
|
+
await this.gitService.branches.switch(
|
|
3098
|
+
projectPath,
|
|
3099
|
+
projectBranchSchema.Enum.work
|
|
3100
|
+
);
|
|
3101
|
+
await this.gitService.branches.delete(
|
|
3102
|
+
projectPath,
|
|
3103
|
+
upgradeBranchName,
|
|
3104
|
+
true
|
|
3105
|
+
);
|
|
3037
3106
|
throw error;
|
|
3038
3107
|
}
|
|
3039
3108
|
}
|
|
@@ -3062,38 +3131,37 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
3062
3131
|
);
|
|
3063
3132
|
}
|
|
3064
3133
|
};
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
setOriginUrl: async (props) => {
|
|
3077
|
-
setRemoteOriginUrlProjectSchema.parse(props);
|
|
3078
|
-
const projectPath = pathTo.project(props.id);
|
|
3079
|
-
const hasOrigin = await this.gitService.remotes.hasOrigin(projectPath);
|
|
3080
|
-
if (!hasOrigin) {
|
|
3081
|
-
await this.gitService.remotes.addOrigin(projectPath, props.url);
|
|
3082
|
-
} else {
|
|
3083
|
-
await this.gitService.remotes.setOriginUrl(projectPath, props.url);
|
|
3084
|
-
}
|
|
3134
|
+
/**
|
|
3135
|
+
* Updates the remote origin URL of given Project
|
|
3136
|
+
*/
|
|
3137
|
+
async setRemoteOriginUrl(props) {
|
|
3138
|
+
setRemoteOriginUrlProjectSchema.parse(props);
|
|
3139
|
+
const projectPath = pathTo.project(props.id);
|
|
3140
|
+
const hasOrigin = await this.gitService.remotes.hasOrigin(projectPath);
|
|
3141
|
+
if (!hasOrigin) {
|
|
3142
|
+
await this.gitService.remotes.addOrigin(projectPath, props.url);
|
|
3143
|
+
} else {
|
|
3144
|
+
await this.gitService.remotes.setOriginUrl(projectPath, props.url);
|
|
3085
3145
|
}
|
|
3086
|
-
}
|
|
3146
|
+
}
|
|
3087
3147
|
/**
|
|
3088
3148
|
* Returns the differences of the given Projects current branch
|
|
3089
3149
|
* between the local and remote `origin` (commits ahead & behind)
|
|
3090
3150
|
*
|
|
3151
|
+
* Throws an error if the Project does not have a remote origin.
|
|
3152
|
+
*
|
|
3091
3153
|
* - `behind` contains a list of commits on the current branch that are available on the remote `origin` but not yet locally
|
|
3092
3154
|
* - `ahead` contains a list of commits on the current branch that are available locally but not yet on the remote `origin`
|
|
3093
3155
|
*/
|
|
3094
3156
|
async getChanges(props) {
|
|
3095
3157
|
getChangesProjectSchema.parse(props);
|
|
3096
3158
|
const projectPath = pathTo.project(props.id);
|
|
3159
|
+
const hasRemoteOrigin = await this.gitService.remotes.hasOrigin(
|
|
3160
|
+
projectPath
|
|
3161
|
+
);
|
|
3162
|
+
if (hasRemoteOrigin === false) {
|
|
3163
|
+
throw new Error(`Project "${props.id}" does not have a remote origin`);
|
|
3164
|
+
}
|
|
3097
3165
|
const currentBranch = await this.gitService.branches.current(projectPath);
|
|
3098
3166
|
await this.gitService.fetch(projectPath);
|
|
3099
3167
|
const behind = await this.gitService.log(projectPath, {
|
|
@@ -3121,11 +3189,23 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
3121
3189
|
* Deletes given Project
|
|
3122
3190
|
*
|
|
3123
3191
|
* Deletes the whole Project folder including the history, not only the config file.
|
|
3124
|
-
*
|
|
3125
|
-
*
|
|
3192
|
+
* Throws in case a Project is only available locally and could be lost forever,
|
|
3193
|
+
* or changes are not pushed to a remote yet.
|
|
3126
3194
|
*/
|
|
3127
3195
|
async delete(props) {
|
|
3128
3196
|
deleteProjectSchema.parse(props);
|
|
3197
|
+
const hasRemoteOrigin = await this.gitService.remotes.hasOrigin(
|
|
3198
|
+
pathTo.project(props.id)
|
|
3199
|
+
);
|
|
3200
|
+
if (hasRemoteOrigin === false && props.force !== true) {
|
|
3201
|
+
throw new RemoteOriginMissingError(props.id);
|
|
3202
|
+
}
|
|
3203
|
+
if (hasRemoteOrigin === true && props.force !== true) {
|
|
3204
|
+
const changes = await this.getChanges({ id: props.id });
|
|
3205
|
+
if (changes.ahead.length > 0) {
|
|
3206
|
+
throw new SynchronizeLocalChangesError(props.id);
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3129
3209
|
await Fs6.remove(pathTo.project(props.id));
|
|
3130
3210
|
}
|
|
3131
3211
|
/**
|
|
@@ -3220,6 +3300,12 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
3220
3300
|
* Creates a Project from given ProjectFile
|
|
3221
3301
|
*/
|
|
3222
3302
|
async toProject(projectFile) {
|
|
3303
|
+
const projectPath = pathTo.project(projectFile.id);
|
|
3304
|
+
let remoteOriginUrl = null;
|
|
3305
|
+
const hasOrigin = await this.gitService.remotes.hasOrigin(projectPath);
|
|
3306
|
+
if (hasOrigin) {
|
|
3307
|
+
remoteOriginUrl = await this.gitService.remotes.getOriginUrl(projectPath);
|
|
3308
|
+
}
|
|
3223
3309
|
const fullHistory = await this.gitService.log(
|
|
3224
3310
|
pathTo.project(projectFile.id)
|
|
3225
3311
|
);
|
|
@@ -3228,6 +3314,7 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
3228
3314
|
});
|
|
3229
3315
|
return {
|
|
3230
3316
|
...projectFile,
|
|
3317
|
+
remoteOriginUrl,
|
|
3231
3318
|
history,
|
|
3232
3319
|
fullHistory
|
|
3233
3320
|
};
|
|
@@ -3505,7 +3592,6 @@ export {
|
|
|
3505
3592
|
assetFileSchema,
|
|
3506
3593
|
assetSchema,
|
|
3507
3594
|
baseFileSchema,
|
|
3508
|
-
baseFileWithLanguageSchema,
|
|
3509
3595
|
baseUserSchema,
|
|
3510
3596
|
cloneProjectSchema,
|
|
3511
3597
|
cloudUserSchema,
|
|
@@ -3549,11 +3635,11 @@ export {
|
|
|
3549
3635
|
getRemoteOriginUrlProjectSchema,
|
|
3550
3636
|
getValueContentSchemaFromFieldDefinition,
|
|
3551
3637
|
gitCloneOptionsSchema,
|
|
3552
|
-
gitCommitIconSchema,
|
|
3553
3638
|
gitCommitSchema,
|
|
3554
3639
|
gitInitOptionsSchema,
|
|
3555
3640
|
gitLogOptionsSchema,
|
|
3556
|
-
|
|
3641
|
+
gitMergeOptionsSchema,
|
|
3642
|
+
gitMessageSchema,
|
|
3557
3643
|
gitSignatureSchema,
|
|
3558
3644
|
gitSwitchOptionsSchema,
|
|
3559
3645
|
gitTagSchema,
|
|
@@ -3569,6 +3655,7 @@ export {
|
|
|
3569
3655
|
numberFieldDefinitionSchema,
|
|
3570
3656
|
objectTypeSchema,
|
|
3571
3657
|
outdatedProjectSchema,
|
|
3658
|
+
projectBranchSchema,
|
|
3572
3659
|
projectExportSchema,
|
|
3573
3660
|
projectFileSchema,
|
|
3574
3661
|
projectFolderSchema,
|
|
@@ -3593,9 +3680,6 @@ export {
|
|
|
3593
3680
|
setUserSchema,
|
|
3594
3681
|
slug,
|
|
3595
3682
|
stringFieldDefinitionSchema,
|
|
3596
|
-
supportedAssetExtensionSchema,
|
|
3597
|
-
supportedAssetMimeTypeSchema,
|
|
3598
|
-
supportedAssetTypeSchema,
|
|
3599
3683
|
supportedIconSchema,
|
|
3600
3684
|
supportedLanguageSchema,
|
|
3601
3685
|
switchBranchProjectSchema,
|
|
@@ -3624,7 +3708,6 @@ export {
|
|
|
3624
3708
|
valueContentReferenceToAssetSchema,
|
|
3625
3709
|
valueContentReferenceToCollectionSchema,
|
|
3626
3710
|
valueContentReferenceToEntrySchema,
|
|
3627
|
-
valueContentReferenceWithLanguageBase,
|
|
3628
3711
|
valueSchema,
|
|
3629
3712
|
versionSchema
|
|
3630
3713
|
};
|