@eventcatalog/core 2.8.7 → 2.8.8
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.
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Tests e2e
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
branches: [ main, master ]
|
|
5
|
+
jobs:
|
|
6
|
+
test:
|
|
7
|
+
timeout-minutes: 60
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- uses: actions/checkout@v4
|
|
11
|
+
- uses: actions/setup-node@v4
|
|
12
|
+
with:
|
|
13
|
+
node-version: lts/*
|
|
14
|
+
- name: Install dependencies
|
|
15
|
+
run: npm ci
|
|
16
|
+
- name: Install Playwright Browsers
|
|
17
|
+
run: npx playwright install --with-deps
|
|
18
|
+
- name: Build catalog
|
|
19
|
+
shell: bash
|
|
20
|
+
run: |
|
|
21
|
+
cp $PROJECT_DIR/eventcatalog.config.js $CATALOG_DIR/eventcatalog.config.js
|
|
22
|
+
cp $PROJECT_DIR/eventcatalog.styles.css $CATALOG_DIR/eventcatalog.styles.css
|
|
23
|
+
npm run build
|
|
24
|
+
env:
|
|
25
|
+
PROJECT_DIR: ./examples/default/
|
|
26
|
+
CATALOG_DIR: ./
|
|
27
|
+
NODE_ENV: CI # Skip analytics
|
|
28
|
+
- name: Run tests
|
|
29
|
+
run: npm run test:e2e
|
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"url": "https://github.com/event-catalog/eventcatalog.git"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
|
-
"version": "2.8.
|
|
9
|
+
"version": "2.8.8",
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"prepublishOnly": "npm run build:bin",
|
|
21
21
|
"test": "vitest --config vitest.config.ts",
|
|
22
22
|
"test:ci": "node scripts/ci/test.js",
|
|
23
|
+
"test:e2e": "playwright test",
|
|
23
24
|
"start": "astro dev",
|
|
24
25
|
"build": "npm run scripts:hydrate-content && node scripts/analytics/log-build.js && astro build",
|
|
25
26
|
"build:cd": "node scripts/build-ci.js",
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
"@types/diff": "^5.2.2",
|
|
53
54
|
"@types/lodash.merge": "4.6.9",
|
|
54
55
|
"@types/node": "^20.14.2",
|
|
56
|
+
"@types/semver": "^7.5.8",
|
|
55
57
|
"astro": "^4.16.5",
|
|
56
58
|
"astro-expressive-code": "^0.36.1",
|
|
57
59
|
"astro-pagefind": "^1.6.0",
|
|
@@ -77,11 +79,11 @@
|
|
|
77
79
|
"tailwindcss": "^3.4.3",
|
|
78
80
|
"typescript": "^5.4.5",
|
|
79
81
|
"unist-util-visit": "^5.0.0",
|
|
80
|
-
"uuid": "^10.0.0"
|
|
81
|
-
"@types/semver": "^7.5.8"
|
|
82
|
+
"uuid": "^10.0.0"
|
|
82
83
|
},
|
|
83
84
|
"devDependencies": {
|
|
84
85
|
"@changesets/cli": "^2.27.5",
|
|
86
|
+
"@playwright/test": "^1.48.1",
|
|
85
87
|
"@types/react": "^18.3.3",
|
|
86
88
|
"@types/react-dom": "^18.3.0",
|
|
87
89
|
"prettier": "^3.3.3",
|
|
@@ -1,38 +1,13 @@
|
|
|
1
1
|
import { readFile, writeFile, rm } from 'node:fs/promises';
|
|
2
|
-
import { existsSync } from 'fs';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { copyFile } from 'node:fs/promises';
|
|
3
4
|
import path from 'node:path';
|
|
4
5
|
import { v4 as uuidV4 } from 'uuid';
|
|
5
6
|
import { pathToFileURL } from 'url';
|
|
7
|
+
import { tmpdir } from 'node:os';
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
// *
|
|
10
|
-
// * This needs sorting out! Sorry if you are reading this, but it unblocked me for now!
|
|
11
|
-
// * @param {*} content
|
|
12
|
-
// * @returns
|
|
13
|
-
// */
|
|
14
|
-
function convertESMtoCJS(content) {
|
|
15
|
-
// Replace import statements with require
|
|
16
|
-
content = content.replace(/import\s+([a-zA-Z0-9{},\s*]+)\s+from\s+['"]([^'"]+)['"];/g, (match, imports, modulePath) => {
|
|
17
|
-
return `const ${imports.trim()} = require('${modulePath}');`;
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// Replace export default with module.exports
|
|
21
|
-
content = content.replace(/export\s+default\s+/g, 'module.exports = ');
|
|
22
|
-
|
|
23
|
-
// Replace named exports with module.exports
|
|
24
|
-
content = content.replace(/export\s+{([^}]+)}/g, (match, exports) => {
|
|
25
|
-
return `module.exports = {${exports.trim()}};`;
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
// Remove declarations of __filename and __dirname
|
|
29
|
-
content = content.replace(/^\s*(const|let|var)\s+__(filename|dirname)\s+=\s+.*;?\s*$/gm, '');
|
|
30
|
-
|
|
31
|
-
return content;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export async function cleanup(projectDirectory) {
|
|
35
|
-
const filePath = path.join(projectDirectory, 'eventcatalog.config.cjs');
|
|
9
|
+
export async function cleanup() {
|
|
10
|
+
const filePath = path.join(tmpdir(), 'eventcatalog.config.mjs');
|
|
36
11
|
if (existsSync(filePath)) {
|
|
37
12
|
await rm(filePath);
|
|
38
13
|
}
|
|
@@ -40,25 +15,20 @@ export async function cleanup(projectDirectory) {
|
|
|
40
15
|
|
|
41
16
|
export const getEventCatalogConfigFile = async (projectDirectory) => {
|
|
42
17
|
try {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// Have to conver the ESM to CJS...
|
|
46
|
-
const configAsCommonJS = convertESMtoCJS(rawFile);
|
|
18
|
+
let configFilePath = path.join(projectDirectory, 'eventcatalog.config.js');
|
|
47
19
|
|
|
48
|
-
await
|
|
20
|
+
const packageJson = await import(/* @vite-ignore */ path.join(projectDirectory, 'package.json'));
|
|
21
|
+
if (packageJson.default?.type !== 'module') {
|
|
22
|
+
await copyFile(configFilePath, path.join(tmpdir(), 'eventcatalog.config.mjs'));
|
|
23
|
+
configFilePath = path.join(tmpdir(), 'eventcatalog.config.mjs');
|
|
24
|
+
}
|
|
49
25
|
|
|
50
|
-
const configFilePath = path.join(projectDirectory, 'eventcatalog.config.cjs');
|
|
51
26
|
const configFileURL = pathToFileURL(configFilePath).href;
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
// Clean up?
|
|
55
|
-
await writeFile(path.join(projectDirectory, 'eventcatalog.config.js'), rawFile);
|
|
56
|
-
|
|
57
|
-
await cleanup(projectDirectory);
|
|
27
|
+
const config = await import(/* @vite-ignore */ configFileURL);
|
|
58
28
|
|
|
59
|
-
return
|
|
60
|
-
}
|
|
61
|
-
await cleanup(
|
|
29
|
+
return config.default;
|
|
30
|
+
} finally {
|
|
31
|
+
await cleanup();
|
|
62
32
|
}
|
|
63
33
|
};
|
|
64
34
|
|
|
@@ -92,10 +62,8 @@ export const writeEventCatalogConfigFile = async (projectDirectory, newConfig) =
|
|
|
92
62
|
|
|
93
63
|
// Write the updated content back to the file
|
|
94
64
|
await writeFile(configFilePath, content);
|
|
95
|
-
|
|
96
|
-
await cleanup(
|
|
97
|
-
} catch (error) {
|
|
98
|
-
await cleanup(projectDirectory);
|
|
65
|
+
} finally {
|
|
66
|
+
await cleanup();
|
|
99
67
|
}
|
|
100
68
|
};
|
|
101
69
|
|