UNPKG

@storm-software/workspace-tools

Version:

Tools for managing a Storm workspace, including various Nx generators and executors for common development tasks.

77 lines (61 loc) 3.59 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _chunk7OQWJH4Bjs = require('./chunk-7OQWJH4B.js'); var _chunkBSW6NZVBjs = require('./chunk-BSW6NZVB.js'); var _chunkIHMF6RANjs = require('./chunk-IHMF6RAN.js'); var _chunkLMYTVXGXjs = require('./chunk-LMYTVXGX.js'); // src/generators/config-schema/generator.ts var _devkit = require('@nx/devkit'); var _zod = require('zod'); var z = _interopRequireWildcard(_zod); async function configSchemaGeneratorFn(tree, options, config) { _chunkIHMF6RANjs.writeInfo.call(void 0, "\u{1F4E6} Running Storm Workspace Configuration JSON Schema generator", config ); _chunkIHMF6RANjs.writeTrace.call(void 0, `Determining the Storm Workspace Configuration JSON Schema...`, config ); const jsonSchema = z.toJSONSchema(_chunkBSW6NZVBjs.workspaceConfigSchema, { target: "draft-7", metadata: _chunkBSW6NZVBjs.schemaRegistry }); jsonSchema.$id ??= "https://public.storm-cdn.com/schemas/storm-workspace.schema.json"; jsonSchema.title ??= "Storm Workspace Configuration JSON Schema"; jsonSchema.description ??= "This JSON Schema defines the structure of the Storm Workspace configuration file (`storm-workspace.json`). It is used to validate the configuration file and ensure that it adheres to the expected format."; _chunkIHMF6RANjs.writeTrace.call(void 0, jsonSchema, config); if (!options.outputFile) { throw new Error( "The `outputFile` option is required. Please specify the output file path." ); } const outputPath = options.outputFile.replaceAll("{workspaceRoot}", "").replaceAll( _nullishCoalesce(_optionalChain([config, 'optionalAccess', _ => _.workspaceRoot]), () => ( _chunkLMYTVXGXjs.findWorkspaceRoot.call(void 0, ))), options.outputFile.startsWith("./") ? "" : "./" ); _chunkIHMF6RANjs.writeTrace.call(void 0, `\u{1F4DD} Writing Storm Configuration JSON Schema to "${outputPath}"`, config ); _devkit.writeJson.call(void 0, tree, outputPath, jsonSchema, { spaces: 2 }); await _devkit.formatFiles.call(void 0, tree); _chunkIHMF6RANjs.writeSuccess.call(void 0, "\u{1F680} Storm Configuration JSON Schema creation has completed successfully!", config ); return { success: true }; } var generator_default = _chunk7OQWJH4Bjs.withRunGenerator.call(void 0, "Configuration Schema Creator", configSchemaGeneratorFn, { hooks: { applyDefaultOptions: (options) => { options.outputFile ??= "{workspaceRoot}/storm-workspace.schema.json"; return options; } } } ); exports.configSchemaGeneratorFn = configSchemaGeneratorFn; exports.generator_default = generator_default;