@storm-software/workspace-tools
Version:
Tools for managing a Storm workspace, including various Nx generators and executors for common development tasks.
73 lines (59 loc) • 3.49 kB
JavaScript
;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 _chunkIM33U3N5js = require('./chunk-IM33U3N5.js');
var _chunkK7STHRGHjs = require('./chunk-K7STHRGH.js');
var _chunk4WHSR4FKjs = require('./chunk-4WHSR4FK.js');
// src/generators/config-schema/generator.ts
var _devkit = require('@nx/devkit');
var _v4 = require('zod/v4'); var z = _interopRequireWildcard(_v4);
async function configSchemaGeneratorFn(tree, options, config) {
_chunkK7STHRGHjs.writeInfo.call(void 0,
"\u{1F4E6} Running Storm Workspace Configuration JSON Schema generator",
config
);
_chunkK7STHRGHjs.writeTrace.call(void 0,
`Determining the Storm Workspace Configuration JSON Schema...`,
config
);
const jsonSchema = z.toJSONSchema(_chunkK7STHRGHjs.stormWorkspaceConfigSchema, {
target: "draft-7"
});
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.";
_chunkK7STHRGHjs.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]), () => ( _chunk4WHSR4FKjs.findWorkspaceRoot.call(void 0, ))),
options.outputFile.startsWith("./") ? "" : "./"
);
_chunkK7STHRGHjs.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);
_chunkK7STHRGHjs.writeSuccess.call(void 0,
"\u{1F680} Storm Configuration JSON Schema creation has completed successfully!",
config
);
return {
success: true
};
}
var generator_default = _chunkIM33U3N5js.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;