@eventcatalog/core 2.7.9 → 2.7.11
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
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @eventcatalog/core
|
|
2
2
|
|
|
3
|
+
## 2.7.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b106e34: chore(core): added logs for builds
|
|
8
|
+
|
|
9
|
+
## 2.7.10
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- d4e2013: chore(core): added ability to check and add properties on users catal…
|
|
14
|
+
|
|
3
15
|
## 2.7.9
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eventcatalog/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.7.
|
|
4
|
+
"version": "2.7.11",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"test": "vitest --config vitest.config.ts",
|
|
17
17
|
"test:ci": "node scripts/ci/test.js",
|
|
18
18
|
"start": "astro dev",
|
|
19
|
-
"build": "npm run scripts:hydrate-content && astro check --minimumSeverity error && astro build",
|
|
19
|
+
"build": "npm run scripts:hydrate-content && node scripts/analytics/log-build.js && astro check --minimumSeverity error && astro build",
|
|
20
20
|
"build:cd": "node scripts/build-ci.js",
|
|
21
21
|
"preview": "astro preview",
|
|
22
22
|
"astro": "astro",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"astro-expressive-code": "^0.36.1",
|
|
50
50
|
"astro-pagefind": "^1.6.0",
|
|
51
51
|
"astro-seo": "^0.8.4",
|
|
52
|
+
"axios": "^1.7.7",
|
|
52
53
|
"dagre": "^0.8.5",
|
|
53
54
|
"diff": "^7.0.0",
|
|
54
55
|
"diff2html": "^3.4.48",
|
|
@@ -65,7 +66,8 @@
|
|
|
65
66
|
"semver": "7.6.3",
|
|
66
67
|
"tailwindcss": "^3.4.3",
|
|
67
68
|
"typescript": "^5.4.5",
|
|
68
|
-
"unist-util-visit": "^5.0.0"
|
|
69
|
+
"unist-util-visit": "^5.0.0",
|
|
70
|
+
"uuid": "^10.0.0"
|
|
69
71
|
},
|
|
70
72
|
"devDependencies": {
|
|
71
73
|
"@parcel/watcher": "^2.4.1",
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import os from 'os';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
|
|
6
|
+
async function getVersion() {
|
|
7
|
+
try {
|
|
8
|
+
const pkg = await fs.readFileSync(path.join(process.env.CATALOG_DIR, 'package.json'));
|
|
9
|
+
const parsed = JSON.parse(pkg);
|
|
10
|
+
return parsed.version;
|
|
11
|
+
} catch (error) {
|
|
12
|
+
console.log(error);
|
|
13
|
+
return 'unknown';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function raiseEvent(eventData) {
|
|
18
|
+
const version = await getVersion();
|
|
19
|
+
|
|
20
|
+
const url = 'https://queue.simpleanalyticscdn.com/events';
|
|
21
|
+
const userAgent = `@eventcatalog/eventcatalog@${version} (${os.platform()}; ${os.arch()}; Node/${process.version})`;
|
|
22
|
+
const headers = {
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const payload = {
|
|
27
|
+
type: 'event',
|
|
28
|
+
hostname: 'eventcatalog.dev',
|
|
29
|
+
event: '@eventcatalog/eventcatalog',
|
|
30
|
+
metadata: {
|
|
31
|
+
...eventData,
|
|
32
|
+
t: `t;${new Date().toISOString()}`,
|
|
33
|
+
ua: userAgent,
|
|
34
|
+
},
|
|
35
|
+
ua: userAgent,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
await axios.post(url, payload, { headers });
|
|
40
|
+
} catch (error) {
|
|
41
|
+
// swallow the error
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { raiseEvent };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getEventCatalogConfigFile, verifyRequiredFieldsAreInCatalogConfigFile } from '../eventcatalog-config-file-utils.js';
|
|
2
|
+
import { raiseEvent } from './analytics.js';
|
|
3
|
+
|
|
4
|
+
const main = async () => {
|
|
5
|
+
if (process.env.NODE_ENV === 'CI') return;
|
|
6
|
+
try {
|
|
7
|
+
await verifyRequiredFieldsAreInCatalogConfigFile(process.env.PROJECT_DIR);
|
|
8
|
+
const configFile = await getEventCatalogConfigFile(process.env.PROJECT_DIR);
|
|
9
|
+
const { cId, organizationName, generators = [] } = configFile;
|
|
10
|
+
const generatorNames = generators.length > 0 ? generators.map((generator) => generator[0]) : ['none'];
|
|
11
|
+
await raiseEvent({
|
|
12
|
+
command: 'build',
|
|
13
|
+
org: organizationName,
|
|
14
|
+
cId,
|
|
15
|
+
generators: generatorNames.toString(),
|
|
16
|
+
});
|
|
17
|
+
} catch (error) {
|
|
18
|
+
// Just swallow the error
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
main();
|
|
@@ -3,6 +3,7 @@ import * as path from 'node:path';
|
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import os from 'node:os';
|
|
6
|
+
import { verifyRequiredFieldsAreInCatalogConfigFile } from './eventcatalog-config-file-utils.js';
|
|
6
7
|
|
|
7
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
9
|
const scriptsDir = path.dirname(__filename);
|
|
@@ -262,6 +263,9 @@ export const catalogToAstro = async (source, astroContentDir, catalogFilesDir) =
|
|
|
262
263
|
|
|
263
264
|
// Copy the components if they are defined
|
|
264
265
|
await copyComponents({ source, target: astroContentDir, catalogFilesDir });
|
|
266
|
+
|
|
267
|
+
// Verify required fields are in the catalog config file
|
|
268
|
+
await verifyRequiredFieldsAreInCatalogConfigFile(source);
|
|
265
269
|
};
|
|
266
270
|
|
|
267
271
|
if (process.env.NODE_ENV !== 'test') {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFile, writeFile, rm } from 'node:fs/promises';
|
|
2
2
|
import { existsSync } from 'fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { v4 as uuidV4 } from 'uuid';
|
|
4
5
|
|
|
5
6
|
// * Very strange behaviour when importing ESM files from catalogs into core.
|
|
6
7
|
// * Core (node) does not know how to handle ESM files, so we have to try and convert them.
|
|
@@ -94,3 +95,16 @@ export const writeEventCatalogConfigFile = async (projectDirectory, newConfig) =
|
|
|
94
95
|
await cleanup(projectDirectory);
|
|
95
96
|
}
|
|
96
97
|
};
|
|
98
|
+
|
|
99
|
+
// Check the eventcatalog.config.js and add any missing required fields on it
|
|
100
|
+
export const verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
|
|
101
|
+
try {
|
|
102
|
+
const config = await getEventCatalogConfigFile(projectDirectory);
|
|
103
|
+
|
|
104
|
+
if (!config.cId) {
|
|
105
|
+
await writeEventCatalogConfigFile(projectDirectory, { cId: uuidV4() });
|
|
106
|
+
}
|
|
107
|
+
} catch (error) {
|
|
108
|
+
// fail silently, it's overly important
|
|
109
|
+
}
|
|
110
|
+
};
|