@storm-software/untyped
Version:
A package containing `untyped` utilities for building Storm Software libraries and applications
88 lines (70 loc) • 3.29 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 _chunk7K3VMZVIcjs = require('./chunk-7K3VMZVI.cjs');
var _chunk5XLEQJ4Jcjs = require('./chunk-5XLEQJ4J.cjs');
var _chunkGG2O4NREcjs = require('./chunk-GG2O4NRE.cjs');
var _chunkFFODXXPTcjs = require('./chunk-FFODXXPT.cjs');
var _chunkTZGBZ6ITcjs = require('./chunk-TZGBZ6IT.cjs');
// src/generate.ts
_chunkTZGBZ6ITcjs.init_cjs_shims.call(void 0, );
var _glob = require('glob');
var _loader = require('untyped/loader');
var getGenerateAction = (config) => async (options) => {
_chunkFFODXXPTcjs.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) => {
_chunkFFODXXPTcjs.writeTrace.call(void 0,
`Generating files for schema file: ${_chunkTZGBZ6ITcjs.joinPaths.call(void 0, file.parentPath, file.name)}`,
config
);
let schema;
try {
schema = await _loader.loadSchema.call(void 0, _chunkTZGBZ6ITcjs.joinPaths.call(void 0, file.parentPath, file.name), {
jiti: {
fsCache: config.skipCache ? false : _chunkTZGBZ6ITcjs.joinPaths.call(void 0,
config.directories.cache || _chunkTZGBZ6ITcjs.joinPaths.call(void 0,
config.workspaceRoot,
"node_modules/.cache/storm"
),
"jiti"
),
interopDefault: true
}
});
} catch (error) {
_chunkFFODXXPTcjs.writeError.call(void 0,
`Error while parsing schema file: ${_chunkTZGBZ6ITcjs.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(_chunk7K3VMZVIcjs.generateDeclarationFile.call(void 0, schema, file, config));
promises.push(_chunkGG2O4NREcjs.generateMarkdownFile.call(void 0, schema, file, config));
promises.push(_chunk5XLEQJ4Jcjs.generateJsonSchemaFile.call(void 0, schema, file, config));
return Promise.all(promises);
})
);
};
exports.getGenerateAction = getGenerateAction;