Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# This ignore file is shared with Prettier. It seems .git/ must be ignored manually now.
.git/

# registry API folder
src/api/registry/

# Project files
temp
test.json
Expand Down
56 changes: 54 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import ora from 'ora'
import chalk from 'chalk'
import minimist from 'minimist'
import fetch, { FetchError } from 'node-fetch'
import { execFile } from 'node:child_process'
import { promisify } from 'node:util'
const execFileAsync = promisify(execFile)

/**
* @import { Ora } from 'ora'
Expand Down Expand Up @@ -86,11 +89,11 @@ const SchemaDialects = [
{ draftVersion: 'draft-03', url: 'http://json-schema.org/draft-03/schema#', isActive: false, isTooHigh: false },
]

/** @type {{ _: string[], fix?: boolean, help?: boolean, SchemaName?: string, 'schema-name'?: string, 'unstable-check-with'?: string }} */
/** @type {{ _: string[], fix?: boolean, help?: boolean, SchemaName?: string, 'schema-name'?: string, 'unstable-check-with'?: string, 'build-xregistry'?: boolean, 'verify-xregistry'?: boolean }} */
const argv = /** @type {any} */ (
minimist(process.argv.slice(2), {
string: ['SchemaName', 'schema-name', 'unstable-check-with'],
boolean: ['help'],
boolean: ['help', 'build-xregistry', 'verify-xregistry'],
})
)
if (argv.SchemaName) {
Expand Down Expand Up @@ -1773,6 +1776,7 @@ TASKS:
check-strict: Checks all or the given schema against the strict meta schema
check-remote: Run all build checks for remote schemas
maintenance: Run maintenance checks
build-xregistry: Build the xRegistry from the catalog.json

EXAMPLES:
node ./cli.js check
Expand All @@ -1797,6 +1801,53 @@ EXAMPLES:
console.info(helpMenu)
process.exit(0)
}
/**
* Executes the xRegistry build process
*/
async function buildXRegistry() {
try {
console.info('Building xRegistry from catalog.json...')
const { stdout, stderr } = await execFileAsync('node', [
'scripts/build-xregistry.js',
])
if (stdout) console.log(stdout)
if (stderr) console.error(stderr)

const { stdout: siteStdout, stderr: siteStderr } = await execFileAsync(
'sh',
['scripts/build_xregistry_site.sh'],
)
if (siteStdout) console.log(siteStdout)
if (siteStderr) console.error(siteStderr)

const { stdout: postStdout, stderr: postStderr } = await execFileAsync(
'node',
['scripts/postprocess-xregistry-site.js'],
)
if (postStdout) console.log(postStdout)
if (postStderr) console.error(postStderr)

return true
} catch (error) {
if (error instanceof Error) {
console.error('Error executing xRegistry build:', error.message)
if ('stdout' in error) console.log(error.stdout)
if ('stderr' in error) console.error(error.stderr)
} else {
console.error('Unknown error occurred during xRegistry build:', error)
}
return false
}
}

/**
* Task to build the xRegistry
*/
async function taskBuildXRegistry() {
if (!(await buildXRegistry())) {
process.exit(1)
}
}

/** @type {Record<string, () => Promise<unknown>>} */
const taskMap = {
Expand All @@ -1807,6 +1858,7 @@ EXAMPLES:
'check-remote': taskCheckRemote,
report: taskReport,
maintenance: taskMaintenance,
'build-xregistry': taskBuildXRegistry,
build: taskCheck, // Undocumented alias.
}
const taskOrFn = argv._[0]
Expand Down
Loading