Skip to content

Commit 300299f

Browse files
CCM-13342: minor changes from 2025-11-17/separate-workflows-for-docs-002
1 parent ddc54d4 commit 300299f

File tree

16 files changed

+723
-1873
lines changed

16 files changed

+723
-1873
lines changed

src/cloudevents/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ deploy-ci:
147147
pwd && \
148148
ls -la
149149
@echo "from manual test tools versions file contains:"
150-
cat .tool-versions
150+
cat .tool-versions || echo " -> .tool-versions file not found in this directory"
151151
/usr/local/bin/asdf --version
152152
@echo "Setting up asdf environment and adding plugins"
153153
export ASDF_DATA_DIR=$$HOME/.asdf && \

src/cloudevents/jest.config.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ module.exports = {
1717
target: 'ES2020',
1818
moduleResolution: 'node',
1919
noEmit: true
20+
},
21+
diagnostics: {
22+
ignoreCodes: [1343] // Ignore TS1343: import.meta errors
2023
}
2124
}]
2225
},

src/cloudevents/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
"lint": "echo 'no linting configured'",
3535
"lint:fix": "echo 'no linting configured'",
3636
"test": "jest",
37-
"test:coverage": "jest --coverage; node -e \"const fs = require('fs'); fs.mkdirSync('.reports/unit/coverage', {recursive: true}); fs.copyFileSync('coverage/lcov.info', '.reports/unit/coverage/lcov.info');\"",
38-
"test:unit": "jest --coverage; node -e \"const fs = require('fs'); fs.mkdirSync('.reports/unit/coverage', {recursive: true}); fs.copyFileSync('coverage/lcov.info', '.reports/unit/coverage/lcov.info');\"",
37+
"test:coverage": "jest --coverage && node -e \"const fs = require('fs'); fs.mkdirSync('.reports/unit/coverage', {recursive: true}); fs.copyFileSync('coverage/lcov.info', '.reports/unit/coverage/lcov.info');\"",
38+
"test:unit": "jest --coverage && node -e \"const fs = require('fs'); fs.mkdirSync('.reports/unit/coverage', {recursive: true}); fs.copyFileSync('coverage/lcov.info', '.reports/unit/coverage/lcov.info');\"",
3939
"test:watch": "jest --watch",
4040
"typecheck": "echo 'no typechecking configured'",
4141
"update-readme": "tsx tools/generator/readme-generator/update-readme-cli.ts",

src/cloudevents/tools/cache/__tests__/schema-cache-network.test.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ describe('schema-cache network operations', () => {
1919
}
2020
});
2121

22-
beforeAll((done) => {
22+
beforeAll(async () => {
23+
console.log('[TEST] Starting HTTP server setup...');
2324
// Create a local HTTP server for testing
2425
server = http.createServer((req, res) => {
26+
console.log(`[TEST] Server received request for: ${req.url}`);
2527
// Handle different test scenarios based on URL path
2628
if (req.url === '/schema.json') {
2729
res.writeHead(200, { 'Content-Type': 'application/json' });
@@ -50,15 +52,28 @@ describe('schema-cache network operations', () => {
5052
}
5153
});
5254

53-
server.listen(0, 'localhost', () => {
54-
const address = server.address() as AddressInfo;
55-
serverUrl = `http://localhost:${address.port}`;
56-
done();
55+
await new Promise<void>((resolve, reject) => {
56+
server.listen(0, '127.0.0.1', (err?: Error) => {
57+
if (err) {
58+
console.error('[TEST] Server failed to start:', err);
59+
reject(err);
60+
return;
61+
}
62+
const address = server.address() as AddressInfo;
63+
serverUrl = `http://127.0.0.1:${address.port}`;
64+
console.log(`[TEST] Server started successfully on ${serverUrl}`);
65+
resolve();
66+
});
5767
});
5868
});
5969

60-
afterAll((done) => {
61-
server.close(done);
70+
afterAll(async () => {
71+
await new Promise<void>((resolve, reject) => {
72+
server.close((err) => {
73+
if (err) reject(err);
74+
else resolve();
75+
});
76+
});
6277
});
6378

6479
beforeEach(() => {

src/cloudevents/tools/discovery/discover-schema-dependencies.js.bak

Lines changed: 0 additions & 168 deletions
This file was deleted.

src/cloudevents/tools/generator/__tests__/docs-generator.test.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -592,10 +592,19 @@ describe('DocsGenerator', () => {
592592
});
593593

594594
it('should process multiple schemas', async () => {
595-
// Create multiple schema files
596-
fs.writeFileSync(path.join(INPUT_DIR, 'schema1.schema.json'), JSON.stringify({ type: 'object' }));
597-
fs.writeFileSync(path.join(INPUT_DIR, 'schema2.schema.json'), JSON.stringify({ type: 'string' }));
598-
fs.writeFileSync(path.join(INPUT_DIR, 'schema3.schema.yml'), JSON.stringify({ type: 'number' }));
595+
// Create multiple schema files with unique IDs
596+
fs.writeFileSync(path.join(INPUT_DIR, 'schema1.schema.json'), JSON.stringify({
597+
$id: 'schema1.json',
598+
type: 'object'
599+
}));
600+
fs.writeFileSync(path.join(INPUT_DIR, 'schema2.schema.json'), JSON.stringify({
601+
$id: 'schema2.json',
602+
type: 'string'
603+
}));
604+
fs.writeFileSync(path.join(INPUT_DIR, 'schema3.schema.yml'), JSON.stringify({
605+
$id: 'schema3.json',
606+
type: 'number'
607+
}));
599608

600609
const config: DocsGeneratorConfig = {
601610
inputDir: INPUT_DIR,
@@ -606,6 +615,9 @@ describe('DocsGenerator', () => {
606615
const generator = new DocsGenerator(config);
607616
const result = await generator.generate();
608617

618+
if (!result.success) {
619+
console.error('Generation failed:', result.error);
620+
}
609621
expect(result.success).toBe(true);
610622
expect(result.schemasProcessed).toBe(3);
611623
});

src/cloudevents/tools/generator/docs-generator/generate-docs-cli.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,23 @@ export async function handleCli(args: string[]): Promise<CliResult> {
132132
}
133133

134134
// Execute CLI if this module is run directly
135-
if (import.meta.url === `file://${process.argv[1]}`) {
136-
handleCli(process.argv.slice(2)).then((result) => {
137-
process.exit(result.exitCode);
138-
}).catch((err) => {
139-
console.error('Unexpected error:', err);
140-
process.exit(1);
141-
});
135+
// Note: This uses eval to prevent Jest/CommonJS from parsing import.meta
136+
// istanbul ignore next - CLI entry point, difficult to test in Jest
137+
// @ts-ignore
138+
try {
139+
const importMeta = eval('import.meta');
140+
if (importMeta && importMeta.url === `file://${process.argv[1]}`) {
141+
handleCli(process.argv.slice(2)).then((result) => {
142+
process.exit(result.exitCode);
143+
}).catch((err) => {
144+
console.error('Unexpected error:', err);
145+
process.exit(1);
146+
});
147+
}
148+
} catch {
149+
// Intentionally ignoring exception: import.meta not available in CommonJS/Jest environments.
150+
// This is expected when the module is imported rather than executed directly.
151+
if (process.env.DEBUG) {
152+
console.debug('Module loaded in CommonJS/Jest environment (import.meta not available)');
153+
}
142154
}

0 commit comments

Comments
 (0)