@kapeta/local-cluster-service 0.19.2 → 0.19.4
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/CHANGELOG.md +14 -0
- package/dist/cjs/src/assetManager.js +6 -1
- package/dist/cjs/src/definitionsManager.js +10 -2
- package/dist/cjs/src/repositoryManager.js +5 -2
- package/dist/esm/src/assetManager.js +6 -1
- package/dist/esm/src/definitionsManager.js +10 -2
- package/dist/esm/src/repositoryManager.js +5 -2
- package/package.json +1 -1
- package/src/assetManager.ts +6 -1
- package/src/definitionsManager.ts +12 -4
- package/src/repositoryManager.ts +5 -2
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## [0.19.4](https://github.com/kapetacom/local-cluster-service/compare/v0.19.3...v0.19.4) (2023-09-05)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* Do not rename local sample if we already have ([095737e](https://github.com/kapetacom/local-cluster-service/commit/095737e7cfd94ec1e5dc8efcb178fbf88f67d783))
|
7
|
+
|
8
|
+
## [0.19.3](https://github.com/kapetacom/local-cluster-service/compare/v0.19.2...v0.19.3) (2023-09-05)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* if codegen is already started for block - run after ([#69](https://github.com/kapetacom/local-cluster-service/issues/69)) ([a1b13ee](https://github.com/kapetacom/local-cluster-service/commit/a1b13eeab8413be8c165419ee36c26e3509338b4))
|
14
|
+
|
1
15
|
## [0.19.2](https://github.com/kapetacom/local-cluster-service/compare/v0.19.1...v0.19.2) (2023-09-05)
|
2
16
|
|
3
17
|
|
@@ -16,6 +16,7 @@ const definitionsManager_1 = require("./definitionsManager");
|
|
16
16
|
const utils_1 = require("./utils/utils");
|
17
17
|
const taskManager_1 = require("./taskManager");
|
18
18
|
const cacheManager_1 = require("./cacheManager");
|
19
|
+
const node_uuid_1 = __importDefault(require("node-uuid"));
|
19
20
|
const CACHE_TTL = 60 * 60 * 1000; // 1 hour
|
20
21
|
const toKey = (ref) => `assetManager:asset:${ref}`;
|
21
22
|
function enrichAsset(asset) {
|
@@ -180,10 +181,14 @@ class AssetManager {
|
|
180
181
|
ref = (0, utils_1.normalizeKapetaUri)(ref);
|
181
182
|
if (await codeGeneratorManager_1.codeGeneratorManager.canGenerateCode(block)) {
|
182
183
|
const assetTitle = block.metadata.title ? block.metadata.title : (0, nodejs_utils_1.parseKapetaUri)(block.metadata.name).name;
|
183
|
-
|
184
|
+
const taskId = `codegen:${node_uuid_1.default.v4()}`;
|
185
|
+
const group = `codegen:${ref}`;
|
186
|
+
// We group the codegen tasks since we want to run them all but only 1 at a time per block
|
187
|
+
taskManager_1.taskManager.add(taskId, async () => {
|
184
188
|
await codeGeneratorManager_1.codeGeneratorManager.generate(ymlPath, block);
|
185
189
|
}, {
|
186
190
|
name: `Generating code for ${assetTitle}`,
|
191
|
+
group, //Group prevents multiple tasks from running at the same time
|
187
192
|
});
|
188
193
|
return true;
|
189
194
|
}
|
@@ -15,9 +15,12 @@ const nodejs_registry_utils_1 = require("@kapeta/nodejs-registry-utils");
|
|
15
15
|
const progressListener_1 = require("./progressListener");
|
16
16
|
const path_1 = __importDefault(require("path"));
|
17
17
|
exports.SAMPLE_PLAN_NAME = 'kapeta/sample-nodejs-plan';
|
18
|
-
function
|
18
|
+
function getRenamed(definition, targetHandle) {
|
19
19
|
const originalUri = (0, nodejs_utils_1.parseKapetaUri)(definition.definition.metadata.name);
|
20
|
-
|
20
|
+
return `${targetHandle}/${originalUri.name}`;
|
21
|
+
}
|
22
|
+
function applyHandleChange(definition, targetHandle) {
|
23
|
+
definition.definition.metadata.name = getRenamed(definition, targetHandle);
|
21
24
|
return definition;
|
22
25
|
}
|
23
26
|
function normalizeFilters(kindFilter) {
|
@@ -50,6 +53,11 @@ class DefinitionsManager {
|
|
50
53
|
// Not logged in yet, so we can't rewrite the sample plan
|
51
54
|
return definitions;
|
52
55
|
}
|
56
|
+
const newName = getRenamed(samplePlan, profile.handle);
|
57
|
+
if (definitions.some((d) => d.definition.metadata.name === newName && d.version === 'local')) {
|
58
|
+
// We already have a local version of the sample plan
|
59
|
+
return definitions;
|
60
|
+
}
|
53
61
|
console.log('Rewriting sample plan to use handle %s', profile.handle);
|
54
62
|
applyHandleChange(samplePlan, profile.handle);
|
55
63
|
const planDef = samplePlan.definition;
|
@@ -26,9 +26,9 @@ const DEFAULT_PROVIDERS = [
|
|
26
26
|
'kapeta/resource-type-web-fragment',
|
27
27
|
'kapeta/resource-type-mongodb',
|
28
28
|
'kapeta/resource-type-postgresql',
|
29
|
+
'kapeta/resource-type-smtp-client',
|
29
30
|
'kapeta/language-target-react-ts',
|
30
31
|
'kapeta/language-target-nodejs',
|
31
|
-
'kapeta/language-target-java-spring-boot',
|
32
32
|
];
|
33
33
|
class RepositoryManager extends node_events_1.EventEmitter {
|
34
34
|
_registryService;
|
@@ -84,7 +84,10 @@ class RepositoryManager extends node_events_1.EventEmitter {
|
|
84
84
|
throw e;
|
85
85
|
}
|
86
86
|
cacheManager_1.cacheManager.flush();
|
87
|
-
|
87
|
+
if (await definitionsManager_1.definitionsManager.exists(ref)) {
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
throw new Error(`Failed to install asset: ${ref}`);
|
88
91
|
};
|
89
92
|
};
|
90
93
|
const tasks = [];
|
@@ -16,6 +16,7 @@ const definitionsManager_1 = require("./definitionsManager");
|
|
16
16
|
const utils_1 = require("./utils/utils");
|
17
17
|
const taskManager_1 = require("./taskManager");
|
18
18
|
const cacheManager_1 = require("./cacheManager");
|
19
|
+
const node_uuid_1 = __importDefault(require("node-uuid"));
|
19
20
|
const CACHE_TTL = 60 * 60 * 1000; // 1 hour
|
20
21
|
const toKey = (ref) => `assetManager:asset:${ref}`;
|
21
22
|
function enrichAsset(asset) {
|
@@ -180,10 +181,14 @@ class AssetManager {
|
|
180
181
|
ref = (0, utils_1.normalizeKapetaUri)(ref);
|
181
182
|
if (await codeGeneratorManager_1.codeGeneratorManager.canGenerateCode(block)) {
|
182
183
|
const assetTitle = block.metadata.title ? block.metadata.title : (0, nodejs_utils_1.parseKapetaUri)(block.metadata.name).name;
|
183
|
-
|
184
|
+
const taskId = `codegen:${node_uuid_1.default.v4()}`;
|
185
|
+
const group = `codegen:${ref}`;
|
186
|
+
// We group the codegen tasks since we want to run them all but only 1 at a time per block
|
187
|
+
taskManager_1.taskManager.add(taskId, async () => {
|
184
188
|
await codeGeneratorManager_1.codeGeneratorManager.generate(ymlPath, block);
|
185
189
|
}, {
|
186
190
|
name: `Generating code for ${assetTitle}`,
|
191
|
+
group, //Group prevents multiple tasks from running at the same time
|
187
192
|
});
|
188
193
|
return true;
|
189
194
|
}
|
@@ -15,9 +15,12 @@ const nodejs_registry_utils_1 = require("@kapeta/nodejs-registry-utils");
|
|
15
15
|
const progressListener_1 = require("./progressListener");
|
16
16
|
const path_1 = __importDefault(require("path"));
|
17
17
|
exports.SAMPLE_PLAN_NAME = 'kapeta/sample-nodejs-plan';
|
18
|
-
function
|
18
|
+
function getRenamed(definition, targetHandle) {
|
19
19
|
const originalUri = (0, nodejs_utils_1.parseKapetaUri)(definition.definition.metadata.name);
|
20
|
-
|
20
|
+
return `${targetHandle}/${originalUri.name}`;
|
21
|
+
}
|
22
|
+
function applyHandleChange(definition, targetHandle) {
|
23
|
+
definition.definition.metadata.name = getRenamed(definition, targetHandle);
|
21
24
|
return definition;
|
22
25
|
}
|
23
26
|
function normalizeFilters(kindFilter) {
|
@@ -50,6 +53,11 @@ class DefinitionsManager {
|
|
50
53
|
// Not logged in yet, so we can't rewrite the sample plan
|
51
54
|
return definitions;
|
52
55
|
}
|
56
|
+
const newName = getRenamed(samplePlan, profile.handle);
|
57
|
+
if (definitions.some((d) => d.definition.metadata.name === newName && d.version === 'local')) {
|
58
|
+
// We already have a local version of the sample plan
|
59
|
+
return definitions;
|
60
|
+
}
|
53
61
|
console.log('Rewriting sample plan to use handle %s', profile.handle);
|
54
62
|
applyHandleChange(samplePlan, profile.handle);
|
55
63
|
const planDef = samplePlan.definition;
|
@@ -26,9 +26,9 @@ const DEFAULT_PROVIDERS = [
|
|
26
26
|
'kapeta/resource-type-web-fragment',
|
27
27
|
'kapeta/resource-type-mongodb',
|
28
28
|
'kapeta/resource-type-postgresql',
|
29
|
+
'kapeta/resource-type-smtp-client',
|
29
30
|
'kapeta/language-target-react-ts',
|
30
31
|
'kapeta/language-target-nodejs',
|
31
|
-
'kapeta/language-target-java-spring-boot',
|
32
32
|
];
|
33
33
|
class RepositoryManager extends node_events_1.EventEmitter {
|
34
34
|
_registryService;
|
@@ -84,7 +84,10 @@ class RepositoryManager extends node_events_1.EventEmitter {
|
|
84
84
|
throw e;
|
85
85
|
}
|
86
86
|
cacheManager_1.cacheManager.flush();
|
87
|
-
|
87
|
+
if (await definitionsManager_1.definitionsManager.exists(ref)) {
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
throw new Error(`Failed to install asset: ${ref}`);
|
88
91
|
};
|
89
92
|
};
|
90
93
|
const tasks = [];
|
package/package.json
CHANGED
package/src/assetManager.ts
CHANGED
@@ -13,6 +13,7 @@ import { normalizeKapetaUri } from './utils/utils';
|
|
13
13
|
import { taskManager } from './taskManager';
|
14
14
|
import { SourceOfChange } from './types';
|
15
15
|
import { cacheManager } from './cacheManager';
|
16
|
+
import uuid from 'node-uuid';
|
16
17
|
|
17
18
|
const CACHE_TTL = 60 * 60 * 1000; // 1 hour
|
18
19
|
|
@@ -242,13 +243,17 @@ class AssetManager {
|
|
242
243
|
ref = normalizeKapetaUri(ref);
|
243
244
|
if (await codeGeneratorManager.canGenerateCode(block)) {
|
244
245
|
const assetTitle = block.metadata.title ? block.metadata.title : parseKapetaUri(block.metadata.name).name;
|
246
|
+
const taskId = `codegen:${uuid.v4()}`;
|
247
|
+
const group = `codegen:${ref}`;
|
248
|
+
// We group the codegen tasks since we want to run them all but only 1 at a time per block
|
245
249
|
taskManager.add(
|
246
|
-
|
250
|
+
taskId,
|
247
251
|
async () => {
|
248
252
|
await codeGeneratorManager.generate(ymlPath, block);
|
249
253
|
},
|
250
254
|
{
|
251
255
|
name: `Generating code for ${assetTitle}`,
|
256
|
+
group, //Group prevents multiple tasks from running at the same time
|
252
257
|
}
|
253
258
|
);
|
254
259
|
return true;
|
@@ -12,9 +12,12 @@ import Path from 'path';
|
|
12
12
|
|
13
13
|
export const SAMPLE_PLAN_NAME = 'kapeta/sample-nodejs-plan';
|
14
14
|
|
15
|
-
function
|
15
|
+
function getRenamed(definition: DefinitionInfo, targetHandle: string) {
|
16
16
|
const originalUri = parseKapetaUri(definition.definition.metadata.name);
|
17
|
-
|
17
|
+
return `${targetHandle}/${originalUri.name}`;
|
18
|
+
}
|
19
|
+
function applyHandleChange(definition: DefinitionInfo, targetHandle: string) {
|
20
|
+
definition.definition.metadata.name = getRenamed(definition, targetHandle);
|
18
21
|
return definition;
|
19
22
|
}
|
20
23
|
|
@@ -55,10 +58,15 @@ class DefinitionsManager {
|
|
55
58
|
return definitions;
|
56
59
|
}
|
57
60
|
|
58
|
-
|
61
|
+
const newName = getRenamed(samplePlan, profile.handle);
|
59
62
|
|
60
|
-
|
63
|
+
if (definitions.some((d) => d.definition.metadata.name === newName && d.version === 'local')) {
|
64
|
+
// We already have a local version of the sample plan
|
65
|
+
return definitions;
|
66
|
+
}
|
61
67
|
|
68
|
+
console.log('Rewriting sample plan to use handle %s', profile.handle);
|
69
|
+
applyHandleChange(samplePlan, profile.handle);
|
62
70
|
const planDef = samplePlan.definition as Plan;
|
63
71
|
|
64
72
|
const blockRefs = new Set<string>();
|
package/src/repositoryManager.ts
CHANGED
@@ -24,9 +24,9 @@ const DEFAULT_PROVIDERS = [
|
|
24
24
|
'kapeta/resource-type-web-fragment',
|
25
25
|
'kapeta/resource-type-mongodb',
|
26
26
|
'kapeta/resource-type-postgresql',
|
27
|
+
'kapeta/resource-type-smtp-client',
|
27
28
|
'kapeta/language-target-react-ts',
|
28
29
|
'kapeta/language-target-nodejs',
|
29
|
-
'kapeta/language-target-java-spring-boot',
|
30
30
|
];
|
31
31
|
|
32
32
|
class RepositoryManager extends EventEmitter {
|
@@ -90,7 +90,10 @@ class RepositoryManager extends EventEmitter {
|
|
90
90
|
throw e;
|
91
91
|
}
|
92
92
|
cacheManager.flush();
|
93
|
-
|
93
|
+
if (await definitionsManager.exists(ref)) {
|
94
|
+
return;
|
95
|
+
}
|
96
|
+
throw new Error(`Failed to install asset: ${ref}`);
|
94
97
|
};
|
95
98
|
};
|
96
99
|
|