@storm-software/untyped
Version:
A package containing `untyped` utilities for building Storm Software libraries and applications
90 lines (71 loc) • 3.37 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 _chunkNUF6TW3Hcjs = require('./chunk-NUF6TW3H.cjs');
var _chunkV6SWYUL2cjs = require('./chunk-V6SWYUL2.cjs');
var _chunkGRNXIBZCcjs = require('./chunk-GRNXIBZC.cjs');
var _chunkAJXQFRFTcjs = require('./chunk-AJXQFRFT.cjs');
var _chunkXT3SWD3Hcjs = require('./chunk-XT3SWD3H.cjs');
// src/generate.ts
_chunkXT3SWD3Hcjs.init_cjs_shims.call(void 0, );
var _glob = require('glob');
var _loader = require('untyped/loader');
var getGenerateAction = (config) => async (options) => {
_chunkAJXQFRFTcjs.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) => {
_chunkAJXQFRFTcjs.writeTrace.call(void 0,
`Generating files for schema file: ${_chunkXT3SWD3Hcjs.joinPaths.call(void 0, file.parentPath, file.name)}`,
config
);
let schema;
try {
schema = await _loader.loadSchema.call(void 0, _chunkXT3SWD3Hcjs.joinPaths.call(void 0, file.parentPath, file.name), {
jiti: {
debug: _chunkAJXQFRFTcjs.isVerbose.call(void 0, config.logLevel),
fsCache: config.skipCache ? false : _chunkXT3SWD3Hcjs.joinPaths.call(void 0,
config.directories.cache || _chunkXT3SWD3Hcjs.joinPaths.call(void 0,
config.workspaceRoot,
"node_modules/.cache/storm"
),
"jiti"
),
interopDefault: true
}
});
} catch (error) {
_chunkAJXQFRFTcjs.writeError.call(void 0,
`Error while parsing schema file: ${_chunkXT3SWD3Hcjs.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(_chunkNUF6TW3Hcjs.generateDeclarationFile.call(void 0, schema, file, config));
promises.push(_chunkGRNXIBZCcjs.generateMarkdownFile.call(void 0, schema, file, config));
promises.push(_chunkV6SWYUL2cjs.generateJsonSchemaFile.call(void 0, schema, file, config));
return Promise.all(promises);
})
);
};
exports.getGenerateAction = getGenerateAction;