@storm-software/untyped
Version:
A package containing `untyped` utilities for building Storm Software libraries and applications
74 lines (54 loc) • 3.24 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true}); 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 _chunkIP2KIQ7Zcjs = require('./chunk-IP2KIQ7Z.cjs');
var _chunkKPDOE54Pcjs = require('./chunk-KPDOE54P.cjs');
var _chunkACUIVJCHcjs = require('./chunk-ACUIVJCH.cjs');
var _chunk73TYVR4Dcjs = require('./chunk-73TYVR4D.cjs');
var _chunkPBRGYMWBcjs = require('./chunk-PBRGYMWB.cjs');
// src/generate.ts
_chunkPBRGYMWBcjs.init_cjs_shims.call(void 0, );
var _glob = require('glob');
var _loader = require('untyped/loader');
var getGenerateAction = /* @__PURE__ */ _chunkPBRGYMWBcjs.__name.call(void 0, (config) => async (options) => {
_chunk73TYVR4Dcjs.writeTrace.call(void 0, `Running Storm Untyped with options: ${JSON.stringify(options)}`, config);
const files = await _glob.glob.call(void 0, options.entry || "**/{untyped.ts,*.untyped.ts}", {
ignore: [
"**/{*.stories.tsx,*.stories.ts,*.spec.tsx,*.spec.ts}",
"**/dist/**",
"**/tmp/**",
"**/node_modules/**",
"**/.git/**",
"**/.cache/**",
"**/.nx/**"
],
withFileTypes: true,
cwd: config.workspaceRoot
});
await Promise.all(files.map(async (file) => {
_chunk73TYVR4Dcjs.writeTrace.call(void 0, `Generating files for schema file: ${_chunkPBRGYMWBcjs.joinPaths.call(void 0, file.parentPath, file.name)}`, config);
let schema;
try {
schema = await _loader.loadSchema.call(void 0, _chunkPBRGYMWBcjs.joinPaths.call(void 0, file.parentPath, file.name), {
jiti: {
debug: _chunk73TYVR4Dcjs.isVerbose.call(void 0, config.logLevel),
fsCache: config.skipCache ? false : _chunkPBRGYMWBcjs.joinPaths.call(void 0, config.directories.cache || _chunkPBRGYMWBcjs.joinPaths.call(void 0, config.workspaceRoot, "node_modules/.cache/storm"), "jiti"),
interopDefault: true
}
});
} catch (error) {
_chunk73TYVR4Dcjs.writeError.call(void 0, `Error while parsing schema file: ${_chunkPBRGYMWBcjs.joinPaths.call(void 0, file.parentPath, file.name)}
Error:
${_optionalChain([error, 'optionalAccess', _ => _.message]) ? error.message : JSON.stringify(error)}${_optionalChain([error, 'optionalAccess', _2 => _2.stack]) ? `
Stack Trace: ${error.stack}` : ""}
Parsed schema:
${JSON.stringify(schema)}
`, config);
throw error;
}
const promises = [];
promises.push(_chunkIP2KIQ7Zcjs.generateDeclarationFile.call(void 0, schema, file, config));
promises.push(_chunkACUIVJCHcjs.generateMarkdownFile.call(void 0, schema, file, config));
promises.push(_chunkKPDOE54Pcjs.generateJsonSchemaFile.call(void 0, schema, file, config));
return Promise.all(promises);
}));
}, "getGenerateAction");
exports.getGenerateAction = getGenerateAction;