@storm-software/cloudflare-tools
Version:
A Nx plugin package that contains various executors, generators, and utilities that assist in managing Cloudflare services.
1,281 lines (1,179 loc) • 109 kB
JavaScript
"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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 _chunkNCVDTA5Mjs = require('./chunk-NCVDTA5M.js');
var _chunkYRUROEEPjs = require('./chunk-YRUROEEP.js');
var _chunkFBLD25X4js = require('./chunk-FBLD25X4.js');
var _chunkAWKQRM2Hjs = require('./chunk-AWKQRM2H.js');
// ../config-tools/src/utilities/apply-workspace-tokens.ts
var applyWorkspaceBaseTokens = async (option, tokenParams) => {
let result = option;
if (!result) {
return result;
}
if (tokenParams) {
const optionKeys = Object.keys(tokenParams);
if (optionKeys.some((optionKey) => result.includes(`{${optionKey}}`))) {
for (const optionKey of optionKeys) {
if (result.includes(`{${optionKey}}`)) {
result = result.replaceAll(
`{${optionKey}}`,
_optionalChain([tokenParams, 'optionalAccess', _2 => _2[optionKey]]) || ""
);
}
}
}
}
if (tokenParams.config) {
const configKeys = Object.keys(tokenParams.config);
if (configKeys.some((configKey) => result.includes(`{${configKey}}`))) {
for (const configKey of configKeys) {
if (result.includes(`{${configKey}}`)) {
result = result.replaceAll(
`{${configKey}}`,
tokenParams.config[configKey] || ""
);
}
}
}
}
if (result.includes("{workspaceRoot}")) {
result = result.replaceAll(
"{workspaceRoot}",
_nullishCoalesce(_nullishCoalesce(tokenParams.workspaceRoot, () => ( _optionalChain([tokenParams, 'access', _3 => _3.config, 'optionalAccess', _4 => _4.workspaceRoot]))), () => ( _chunkYRUROEEPjs.findWorkspaceRoot.call(void 0, )))
);
}
return result;
};
var applyWorkspaceProjectTokens = (option, tokenParams) => {
return applyWorkspaceBaseTokens(option, tokenParams);
};
var applyWorkspaceTokens = async (options, tokenParams, tokenizerFn) => {
if (!options) {
return {};
}
const result = {};
for (const option of Object.keys(options)) {
if (typeof options[option] === "string") {
result[option] = await Promise.resolve(
tokenizerFn(options[option], tokenParams)
);
} else if (Array.isArray(options[option])) {
result[option] = await Promise.all(
options[option].map(
async (item) => typeof item === "string" ? await Promise.resolve(tokenizerFn(item, tokenParams)) : item
)
);
} else if (typeof options[option] === "object") {
result[option] = await applyWorkspaceTokens(
options[option],
tokenParams,
tokenizerFn
);
} else {
result[option] = options[option];
}
}
return result;
};
// ../workspace-tools/src/base/base-executor.ts
var _defu = require('defu'); var _defu2 = _interopRequireDefault(_defu);
var withRunExecutor = (name, executorFn, executorOptions = {}) => async (_options, context) => {
const stopwatch = _chunkAWKQRM2Hjs.getStopwatch.call(void 0, name);
let options = _options;
let config = {};
try {
if (!_optionalChain([context, 'access', _5 => _5.projectsConfigurations, 'optionalAccess', _6 => _6.projects]) || !context.projectName || !context.projectsConfigurations.projects[context.projectName]) {
throw new Error(
"The Build process failed because the context is not valid. Please run this command from a workspace."
);
}
const workspaceRoot2 = _chunkYRUROEEPjs.findWorkspaceRoot.call(void 0, );
const projectRoot = context.projectsConfigurations.projects[context.projectName].root || workspaceRoot2;
const sourceRoot = context.projectsConfigurations.projects[context.projectName].sourceRoot || projectRoot || workspaceRoot2;
const projectName = context.projectName;
config.workspaceRoot = workspaceRoot2;
_chunkAWKQRM2Hjs.writeInfo.call(void 0,
`${_chunkAWKQRM2Hjs.brandIcon.call(void 0, config)} Running the ${name} executor for ${projectName} `,
config
);
if (!executorOptions.skipReadingConfig) {
_chunkAWKQRM2Hjs.writeTrace.call(void 0,
`Loading the Storm Config from environment variables and storm.config.js file...
- workspaceRoot: ${workspaceRoot2}
- projectRoot: ${projectRoot}
- sourceRoot: ${sourceRoot}
- projectName: ${projectName}
`,
config
);
config = await _chunkYRUROEEPjs.getConfig.call(void 0, workspaceRoot2);
}
if (_optionalChain([executorOptions, 'optionalAccess', _7 => _7.hooks, 'optionalAccess', _8 => _8.applyDefaultOptions])) {
_chunkAWKQRM2Hjs.writeDebug.call(void 0, "Running the applyDefaultOptions hook...", config);
options = await Promise.resolve(
executorOptions.hooks.applyDefaultOptions(options, config)
);
_chunkAWKQRM2Hjs.writeDebug.call(void 0, "Completed the applyDefaultOptions hook", config);
}
_chunkAWKQRM2Hjs.writeTrace.call(void 0,
`Executor schema options \u2699\uFE0F
${_chunkAWKQRM2Hjs.formatLogMessage.call(void 0, options)}
`,
config
);
const tokenized = await applyWorkspaceTokens(
options,
_defu.defu.call(void 0,
{ workspaceRoot: workspaceRoot2, projectRoot, sourceRoot, projectName, config },
config,
context.projectsConfigurations.projects[context.projectName]
),
applyWorkspaceProjectTokens
);
_chunkAWKQRM2Hjs.writeTrace.call(void 0,
`Executor schema tokenized options \u2699\uFE0F
${_chunkAWKQRM2Hjs.formatLogMessage.call(void 0, tokenized)}
`,
config
);
if (_optionalChain([executorOptions, 'optionalAccess', _9 => _9.hooks, 'optionalAccess', _10 => _10.preProcess])) {
_chunkAWKQRM2Hjs.writeDebug.call(void 0, "Running the preProcess hook...", config);
await Promise.resolve(
executorOptions.hooks.preProcess(tokenized, config)
);
_chunkAWKQRM2Hjs.writeDebug.call(void 0, "Completed the preProcess hook", config);
}
const ret = executorFn(tokenized, context, config);
if (_isFunction(_optionalChain([ret, 'optionalAccess', _11 => _11.next]))) {
const asyncGen = ret;
for await (const iter of asyncGen) {
void iter;
}
}
const result = await Promise.resolve(
ret
);
if (result && (!result.success || result.error && _optionalChain([result, 'optionalAccess', _12 => _12.error, 'optionalAccess', _13 => _13.message]) && typeof _optionalChain([result, 'optionalAccess', _14 => _14.error, 'optionalAccess', _15 => _15.message]) === "string" && _optionalChain([result, 'optionalAccess', _16 => _16.error, 'optionalAccess', _17 => _17.name]) && typeof _optionalChain([result, 'optionalAccess', _18 => _18.error, 'optionalAccess', _19 => _19.name]) === "string")) {
throw new Error(
`Failure determined while running the ${name} executor
${_chunkAWKQRM2Hjs.formatLogMessage.call(void 0,
result
)}`,
{
cause: _optionalChain([result, 'optionalAccess', _20 => _20.error])
}
);
}
if (_optionalChain([executorOptions, 'optionalAccess', _21 => _21.hooks, 'optionalAccess', _22 => _22.postProcess])) {
_chunkAWKQRM2Hjs.writeDebug.call(void 0, "Running the postProcess hook...", config);
await Promise.resolve(executorOptions.hooks.postProcess(config));
_chunkAWKQRM2Hjs.writeDebug.call(void 0, "Completed the postProcess hook", config);
}
_chunkAWKQRM2Hjs.writeSuccess.call(void 0, `Completed running the ${name} task executor!
`, config);
return {
success: true
};
} catch (error) {
_chunkAWKQRM2Hjs.writeFatal.call(void 0,
"A fatal error occurred while running the executor - the process was forced to terminate",
config
);
_chunkAWKQRM2Hjs.writeError.call(void 0,
`An exception was thrown in the executor's process
- Details: ${error.message}
- Stacktrace: ${error.stack}`,
config
);
return {
success: false
};
} finally {
stopwatch();
}
};
var _isFunction = (value) => {
try {
return value instanceof Function || typeof value === "function" || !!(_optionalChain([value, 'optionalAccess', _23 => _23.constructor]) && _optionalChain([value, 'optionalAccess', _24 => _24.call]) && _optionalChain([value, 'optionalAccess', _25 => _25.apply]));
} catch (e) {
return false;
}
};
// ../workspace-tools/src/utils/cargo.ts
var _devkit = require('@nx/devkit');
var _child_process = require('child_process');
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
var _path = require('path'); var path2 = _interopRequireWildcard(_path);
var INVALID_CARGO_ARGS = [
"allFeatures",
"allTargets",
"main",
"outputPath",
"package",
"tsConfig"
];
var buildCargoCommand = (baseCommand, options, context) => {
const args = [];
if (options.toolchain && options.toolchain !== "stable") {
args.push(`+${options.toolchain}`);
}
args.push(baseCommand);
for (const [key, value] of Object.entries(options).filter(
([key2]) => key2 && key2 !== "_"
)) {
if (key === "toolchain" || key === "release" || INVALID_CARGO_ARGS.includes(key)) {
continue;
}
if (typeof value === "boolean") {
if (value) {
args.push(`--${key}`);
}
} else if (Array.isArray(value)) {
for (const item of value) {
args.push(`--${key}`, String(item));
}
} else {
args.push(`--${key}`, String(value));
}
}
if (context.projectName && _optionalChain([context, 'access', _26 => _26.projectsConfigurations, 'optionalAccess', _27 => _27.projects]) && _optionalChain([context, 'access', _28 => _28.projectsConfigurations, 'optionalAccess', _29 => _29.projects, 'access', _30 => _30[context.projectName]]) && _optionalChain([context, 'access', _31 => _31.projectsConfigurations, 'optionalAccess', _32 => _32.projects, 'access', _33 => _33[context.projectName], 'optionalAccess', _34 => _34.root]) && _optionalChain([context, 'access', _35 => _35.projectsConfigurations, 'optionalAccess', _36 => _36.projects, 'access', _37 => _37[context.projectName], 'optionalAccess', _38 => _38.root, 'access', _39 => _39.includes, 'call', _40 => _40("Cargo.toml")])) {
const cargoToml = _chunkNCVDTA5Mjs.parseCargoToml.call(void 0,
_fs.readFileSync.call(void 0,
_devkit.joinPathFragments.call(void 0,
context.projectsConfigurations.projects[context.projectName].root,
"Cargo.toml"
),
"utf-8"
)
);
args.push("-p", cargoToml.package.name);
}
if (options.allFeatures && !args.includes("--all-features")) {
args.push("--all-features");
}
if (options.allTargets && !args.includes("--all-targets")) {
args.push("--all-targets");
}
if (options.release && !args.includes("--profile")) {
args.push("--release");
}
if (options.outputPath && !args.includes("--target-dir")) {
args.push("--target-dir", options.outputPath);
}
return args;
};
async function cargoCommand(workspaceRoot2, ...args) {
console.log(`> cargo ${args.join(" ")}`);
args.push("--color", "always");
return await Promise.resolve(runProcess(workspaceRoot2, "cargo", ...args));
}
function cargoCommandSync(args = "", options) {
const normalizedOptions = {
stdio: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _41 => _41.stdio]), () => ( "inherit")),
env: {
...process.env,
..._optionalChain([options, 'optionalAccess', _42 => _42.env])
}
};
try {
return {
output: _child_process.execSync.call(void 0, `cargo ${args}`, {
encoding: "utf8",
windowsHide: true,
stdio: normalizedOptions.stdio,
env: normalizedOptions.env,
maxBuffer: 1024 * 1024 * 10
}),
success: true
};
} catch (e) {
return {
output: e.message,
success: false
};
}
}
function cargoMetadata() {
const output2 = cargoCommandSync("metadata --format-version=1", {
stdio: "pipe"
});
if (!output2.success) {
console.error("Failed to get cargo metadata");
return null;
}
return JSON.parse(output2.output);
}
function runProcess(workspaceRoot2, processCmd, ...args) {
const metadata = cargoMetadata();
const targetDir = _nullishCoalesce(_optionalChain([metadata, 'optionalAccess', _43 => _43.target_directory]), () => ( _devkit.joinPathFragments.call(void 0, workspaceRoot2, "dist")));
return new Promise((resolve) => {
if (process.env.VERCEL) {
return resolve({ success: true });
}
_child_process.execSync.call(void 0, `${processCmd} ${args.join(" ")}`, {
cwd: process.cwd(),
env: {
...process.env,
RUSTC_WRAPPER: "",
CARGO_TARGET_DIR: targetDir,
CARGO_BUILD_TARGET_DIR: targetDir
},
windowsHide: true,
stdio: ["inherit", "inherit", "inherit"]
});
resolve({ success: true });
});
}
// ../workspace-tools/src/executors/cargo-build/executor.ts
async function cargoBuildExecutor(options, context) {
const command = buildCargoCommand("build", options, context);
return await cargoCommand(context.root, ...command);
}
var executor_default = withRunExecutor(
"Cargo - Build",
cargoBuildExecutor,
{
skipReadingConfig: false,
hooks: {
applyDefaultOptions: (options) => {
options.outputPath ??= "dist/{projectRoot}/target";
options.toolchain ??= "stable";
return options;
}
}
}
);
// ../workspace-tools/src/executors/cargo-check/executor.ts
async function cargoCheckExecutor(options, context) {
const command = buildCargoCommand("check", options, context);
return await cargoCommand(context.root, ...command);
}
var executor_default2 = withRunExecutor(
"Cargo - Check",
cargoCheckExecutor,
{
skipReadingConfig: false,
hooks: {
applyDefaultOptions: (options) => {
options.toolchain ??= "stable";
return options;
}
}
}
);
// ../workspace-tools/src/executors/cargo-clippy/executor.ts
async function cargoClippyExecutor(options, context) {
const command = buildCargoCommand("clippy", options, context);
return await cargoCommand(context.root, ...command);
}
var executor_default3 = withRunExecutor(
"Cargo - Clippy",
cargoClippyExecutor,
{
skipReadingConfig: false,
hooks: {
applyDefaultOptions: (options) => {
options.toolchain ??= "stable";
options.fix ??= false;
return options;
}
}
}
);
// ../workspace-tools/src/executors/cargo-doc/executor.ts
async function cargoDocExecutor(options, context) {
const opts = { ...options };
opts["no-deps"] = opts.noDeps;
delete opts.noDeps;
const command = buildCargoCommand("doc", options, context);
return await cargoCommand(context.root, ...command);
}
var executor_default4 = withRunExecutor(
"Cargo - Doc",
cargoDocExecutor,
{
skipReadingConfig: false,
hooks: {
applyDefaultOptions: (options) => {
options.outputPath ??= "dist/{projectRoot}/docs";
options.toolchain ??= "stable";
options.release ??= options.profile ? false : true;
options.allFeatures ??= true;
options.lib ??= true;
options.bins ??= true;
options.examples ??= true;
options.noDeps ??= false;
return options;
}
}
}
);
// ../workspace-tools/src/executors/cargo-format/executor.ts
async function cargoFormatExecutor(options, context) {
const command = buildCargoCommand("fmt", options, context);
return await cargoCommand(context.root, ...command);
}
var executor_default5 = withRunExecutor(
"Cargo - Format",
cargoFormatExecutor,
{
skipReadingConfig: false,
hooks: {
applyDefaultOptions: (options) => {
options.outputPath ??= "dist/{projectRoot}/target";
options.toolchain ??= "stable";
return options;
}
}
}
);
// ../workspace-tools/src/executors/cargo-publish/executor.ts
var _https = require('https'); var _https2 = _interopRequireDefault(_https);
var LARGE_BUFFER = 1024 * 1e6;
// ../workspace-tools/src/executors/esbuild/executor.ts
var _jiti = require('jiti');
async function esbuildExecutorFn(options, context, config) {
_chunkAWKQRM2Hjs.writeInfo.call(void 0, "\u{1F4E6} Running Storm ESBuild executor on the workspace", config);
if (!_optionalChain([context, 'access', _44 => _44.projectsConfigurations, 'optionalAccess', _45 => _45.projects]) || !context.projectName || !context.projectsConfigurations.projects[context.projectName] || !_optionalChain([context, 'access', _46 => _46.projectsConfigurations, 'access', _47 => _47.projects, 'access', _48 => _48[context.projectName], 'optionalAccess', _49 => _49.root])) {
throw new Error(
"The Build process failed because the context is not valid. Please run this command from a workspace."
);
}
const jiti = _jiti.createJiti.call(void 0, _optionalChain([config, 'optionalAccess', _50 => _50.workspaceRoot]) || process.cwd(), {
fsCache: _optionalChain([config, 'optionalAccess', _51 => _51.skipCache]) ? false : _chunkAWKQRM2Hjs.joinPaths.call(void 0,
_optionalChain([config, 'optionalAccess', _52 => _52.workspaceRoot]) || process.cwd(),
_optionalChain([config, 'optionalAccess', _53 => _53.directories, 'optionalAccess', _54 => _54.cache]) || "node_modules/.cache/storm",
"jiti"
),
interopDefault: true
});
const { build: build2 } = await jiti.import(jiti.esmResolve("@storm-software/esbuild"));
await build2({
...options,
projectRoot: (
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
_optionalChain([context, 'access', _55 => _55.projectsConfigurations, 'access', _56 => _56.projects, 'optionalAccess', _57 => _57[context.projectName], 'access', _58 => _58.root])
),
name: context.projectName,
sourceRoot: _optionalChain([context, 'access', _59 => _59.projectsConfigurations, 'access', _60 => _60.projects, 'optionalAccess', _61 => _61[context.projectName], 'optionalAccess', _62 => _62.sourceRoot]),
format: options.format,
platform: options.platform
});
return {
success: true
};
}
var executor_default6 = withRunExecutor(
"Storm ESBuild build",
esbuildExecutorFn,
{
skipReadingConfig: false,
hooks: {
applyDefaultOptions: async (options) => {
options.entry ??= ["src/index.ts"];
options.outputPath ??= "dist/{projectRoot}";
options.tsconfig ??= "{projectRoot}/tsconfig.json";
return options;
}
}
}
);
// ../workspace-tools/src/executors/napi/executor.ts
var _fileutils = require('nx/src/utils/fileutils');
async function napiExecutor(options, context, config) {
const jiti = _jiti.createJiti.call(void 0, config.workspaceRoot, {
fsCache: config.skipCache ? false : _chunkAWKQRM2Hjs.joinPaths.call(void 0,
config.workspaceRoot,
config.directories.cache || "node_modules/.cache/storm",
"jiti"
),
interopDefault: true
});
const { NapiCli } = await jiti.import(
jiti.esmResolve("@napi-rs/cli")
);
if (!_optionalChain([context, 'access', _63 => _63.projectGraph, 'optionalAccess', _64 => _64.nodes, 'access', _65 => _65[_nullishCoalesce(context.projectName, () => ( ""))]])) {
throw new Error(
"The Napi Build process failed because the project could not be found in the project graph. Please run this command from a workspace root directory."
);
}
const projectRoot = _optionalChain([context, 'access', _66 => _66.projectGraph, 'optionalAccess', _67 => _67.nodes, 'access', _68 => _68[_nullishCoalesce(context.projectName, () => ( ""))], 'optionalAccess', _69 => _69.data, 'access', _70 => _70.root]);
const packageJson = _chunkAWKQRM2Hjs.joinPaths.call(void 0, _nullishCoalesce(projectRoot, () => ( ".")), "package.json");
if (!_fileutils.fileExists.call(void 0, packageJson)) {
throw new Error(`Could not find package.json at ${packageJson}`);
}
const napi = new NapiCli();
const normalizedOptions = { ...options };
const metadata = cargoMetadata();
normalizedOptions.targetDir = options.targetDir || _optionalChain([metadata, 'optionalAccess', _71 => _71.target_directory]) || _chunkAWKQRM2Hjs.joinPaths.call(void 0, config.workspaceRoot, "dist", "target");
normalizedOptions.outputDir = options.outputPath;
normalizedOptions.packageJsonPath ??= packageJson;
if (options.cwd) {
normalizedOptions.cwd = _chunkAWKQRM2Hjs.correctPaths.call(void 0, options.cwd);
} else {
const absoluteProjectRoot = _chunkAWKQRM2Hjs.correctPaths.call(void 0,
_chunkAWKQRM2Hjs.joinPaths.call(void 0, config.workspaceRoot, projectRoot || ".")
);
normalizedOptions.cwd = absoluteProjectRoot;
if (normalizedOptions.outputDir) {
normalizedOptions.outputDir = _chunkAWKQRM2Hjs.relative.call(void 0,
normalizedOptions.cwd,
_chunkAWKQRM2Hjs.correctPaths.call(void 0,
_chunkAWKQRM2Hjs.isAbsolute.call(void 0, normalizedOptions.outputDir) ? normalizedOptions.outputDir : _chunkAWKQRM2Hjs.joinPaths.call(void 0, config.workspaceRoot, normalizedOptions.outputDir)
)
);
}
if (normalizedOptions.packageJsonPath) {
normalizedOptions.packageJsonPath = _chunkAWKQRM2Hjs.relative.call(void 0,
normalizedOptions.cwd,
_chunkAWKQRM2Hjs.correctPaths.call(void 0,
_chunkAWKQRM2Hjs.isAbsolute.call(void 0, normalizedOptions.packageJsonPath) ? normalizedOptions.packageJsonPath : _chunkAWKQRM2Hjs.joinPaths.call(void 0, config.workspaceRoot, normalizedOptions.packageJsonPath)
)
);
}
if (normalizedOptions.configPath) {
normalizedOptions.configPath = _chunkAWKQRM2Hjs.relative.call(void 0,
normalizedOptions.cwd,
_chunkAWKQRM2Hjs.correctPaths.call(void 0,
_chunkAWKQRM2Hjs.isAbsolute.call(void 0, normalizedOptions.configPath) ? normalizedOptions.configPath : _chunkAWKQRM2Hjs.joinPaths.call(void 0, config.workspaceRoot, normalizedOptions.configPath)
)
);
}
if (normalizedOptions.manifestPath) {
normalizedOptions.manifestPath = _chunkAWKQRM2Hjs.relative.call(void 0,
normalizedOptions.cwd,
_chunkAWKQRM2Hjs.correctPaths.call(void 0,
_chunkAWKQRM2Hjs.isAbsolute.call(void 0, normalizedOptions.manifestPath) ? normalizedOptions.manifestPath : _chunkAWKQRM2Hjs.joinPaths.call(void 0, config.workspaceRoot, normalizedOptions.manifestPath)
)
);
}
}
if (process.env.VERCEL) {
return { success: true };
}
_chunkAWKQRM2Hjs.writeDebug.call(void 0,
`Normalized Napi Options:
packageJsonPath: ${normalizedOptions.packageJsonPath}
outputDir: ${normalizedOptions.outputDir}
targetDir: ${normalizedOptions.targetDir}
manifestPath: ${normalizedOptions.manifestPath}
configPath: ${normalizedOptions.configPath}
cwd: ${normalizedOptions.cwd}`,
config
);
const { task } = await napi.build(normalizedOptions);
return { success: true, terminalOutput: await task };
}
var executor_default7 = withRunExecutor(
"Napi - Build Bindings",
napiExecutor,
{
skipReadingConfig: false,
hooks: {
applyDefaultOptions: (options) => {
options.outputPath ??= "{sourceRoot}";
options.toolchain ??= "stable";
options.dtsCache ??= true;
options.platform ??= true;
options.constEnum ??= false;
options.verbose ??= false;
options.jsBinding ??= "binding.js";
options.dts ??= "binding.d.ts";
return options;
}
}
}
);
// ../workspace-tools/src/executors/npm-publish/executor.ts
var _promises = require('fs/promises'); var _promises2 = _interopRequireDefault(_promises);
var _prettier = require('prettier');
// ../workspace-tools/src/utils/github.ts
// ../workspace-tools/src/utils/package-manager.ts
// ../workspace-tools/src/executors/npm-publish/executor.ts
var LARGE_BUFFER2 = 1024 * 1e6;
// ../workspace-tools/src/executors/size-limit/executor.ts
var _esbuild = require('@size-limit/esbuild'); var _esbuild2 = _interopRequireDefault(_esbuild);
var _esbuildwhy = require('@size-limit/esbuild-why'); var _esbuildwhy2 = _interopRequireDefault(_esbuildwhy);
var _file = require('@size-limit/file'); var _file2 = _interopRequireDefault(_file);
var _sizelimit = require('size-limit'); var _sizelimit2 = _interopRequireDefault(_sizelimit);
async function sizeLimitExecutorFn(options, context, config) {
if (!_optionalChain([context, 'optionalAccess', _72 => _72.projectName]) || !_optionalChain([context, 'access', _73 => _73.projectsConfigurations, 'optionalAccess', _74 => _74.projects]) || !context.projectsConfigurations.projects[context.projectName]) {
throw new Error(
"The Size-Limit process failed because the context is not valid. Please run this command from a workspace."
);
}
_chunkAWKQRM2Hjs.writeInfo.call(void 0, `\u{1F4CF} Running Size-Limit on ${context.projectName}`, config);
_sizelimit2.default.call(void 0, [_file2.default, _esbuild2.default, _esbuildwhy2.default], {
checks: _nullishCoalesce(_nullishCoalesce(options.entry, () => ( _optionalChain([context, 'access', _75 => _75.projectsConfigurations, 'access', _76 => _76.projects, 'access', _77 => _77[context.projectName], 'optionalAccess', _78 => _78.sourceRoot]))), () => ( _devkit.joinPathFragments.call(void 0,
_nullishCoalesce(_optionalChain([context, 'access', _79 => _79.projectsConfigurations, 'access', _80 => _80.projects, 'access', _81 => _81[context.projectName], 'optionalAccess', _82 => _82.root]), () => ( "./")),
"src"
)))
}).then((result) => {
_chunkAWKQRM2Hjs.writeInfo.call(void 0,
`\u{1F4CF} ${context.projectName} Size-Limit result: ${JSON.stringify(result)}`,
config
);
});
return {
success: true
};
}
var executor_default8 = withRunExecutor(
"Size-Limit Performance Test Executor",
sizeLimitExecutorFn,
{
skipReadingConfig: false,
hooks: {
applyDefaultOptions: (options) => {
return options;
}
}
}
);
// ../tsdown/src/build.ts
// ../build-tools/src/config.ts
var DEFAULT_ENVIRONMENT = "production";
var DEFAULT_TARGET = "esnext";
var DEFAULT_ORGANIZATION = "storm-software";
// ../build-tools/src/plugins/swc.ts
var _core = require('@swc/core');
// ../build-tools/src/plugins/ts-resolve.ts
var _module = require('module');
var _resolve2 = require('resolve'); var _resolve3 = _interopRequireDefault(_resolve2);
// ../build-tools/src/plugins/type-definitions.ts
// ../build-tools/src/utilities/copy-assets.ts
var _internal = require('@nx/js/internal');
var _glob = require('glob');
var copyAssets = async (config, assets, outputPath, projectRoot, sourceRoot, generatePackageJson2 = true, includeSrc = false, banner, footer) => {
const pendingAssets = Array.from(_nullishCoalesce(assets, () => ( [])));
pendingAssets.push({
input: projectRoot,
glob: "*.md",
output: "."
});
pendingAssets.push({
input: ".",
glob: "LICENSE",
output: "."
});
if (generatePackageJson2 === false) {
pendingAssets.push({
input: projectRoot,
glob: "package.json",
output: "."
});
}
if (includeSrc === true) {
pendingAssets.push({
input: sourceRoot,
glob: "**/{*.ts,*.tsx,*.js,*.jsx}",
output: "src/"
});
}
_chunkAWKQRM2Hjs.writeTrace.call(void 0,
`\u{1F4DD} Copying the following assets to the output directory:
${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${pendingAsset} -> ${outputPath}` : ` - ${pendingAsset.input}/${pendingAsset.glob} -> ${_chunkAWKQRM2Hjs.joinPaths.call(void 0, outputPath, pendingAsset.output)}`).join("\n")}`,
config
);
const assetHandler = new (0, _internal.CopyAssetsHandler)({
projectDir: projectRoot,
rootDir: config.workspaceRoot,
outputDir: outputPath,
assets: pendingAssets
});
await assetHandler.processAllAssetsOnce();
_chunkAWKQRM2Hjs.writeTrace.call(void 0, "Completed copying assets to the output directory", config);
if (includeSrc === true) {
_chunkAWKQRM2Hjs.writeDebug.call(void 0,
`\u{1F4DD} Adding banner and writing source files: ${_chunkAWKQRM2Hjs.joinPaths.call(void 0,
outputPath,
"src"
)}`,
config
);
const files = await _glob.glob.call(void 0, [
_chunkAWKQRM2Hjs.joinPaths.call(void 0, config.workspaceRoot, outputPath, "src/**/*.ts"),
_chunkAWKQRM2Hjs.joinPaths.call(void 0, config.workspaceRoot, outputPath, "src/**/*.tsx"),
_chunkAWKQRM2Hjs.joinPaths.call(void 0, config.workspaceRoot, outputPath, "src/**/*.js"),
_chunkAWKQRM2Hjs.joinPaths.call(void 0, config.workspaceRoot, outputPath, "src/**/*.jsx")
]);
await Promise.allSettled(
files.map(
async (file) => _promises.writeFile.call(void 0,
file,
`${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
${await _promises.readFile.call(void 0, file, "utf8")}
${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`
)
)
);
}
};
// ../build-tools/src/utilities/generate-package-json.ts
var _projectgraph = require('nx/src/project-graph/project-graph');
var addPackageDependencies = async (workspaceRoot2, projectRoot, projectName, packageJson) => {
let projectGraph;
try {
projectGraph = _projectgraph.readCachedProjectGraph.call(void 0, );
} catch (e2) {
await _projectgraph.createProjectGraphAsync.call(void 0, );
projectGraph = _projectgraph.readCachedProjectGraph.call(void 0, );
}
if (!projectGraph) {
throw new Error(
"The Build process failed because the project graph is not available. Please run the build command again."
);
}
const projectDependencies = _internal.calculateProjectBuildableDependencies.call(void 0,
void 0,
projectGraph,
workspaceRoot2,
projectName,
process.env.NX_TASK_TARGET_TARGET || "build",
process.env.NX_TASK_TARGET_CONFIGURATION || "production",
true
);
const localPackages = [];
for (const project of projectDependencies.dependencies.filter(
(dep) => dep.node.type === "lib" && _optionalChain([dep, 'access', _83 => _83.node, 'access', _84 => _84.data, 'optionalAccess', _85 => _85.root]) !== projectRoot && _optionalChain([dep, 'access', _86 => _86.node, 'access', _87 => _87.data, 'optionalAccess', _88 => _88.root]) !== workspaceRoot2
)) {
const projectNode = project.node;
if (projectNode.data.root) {
const projectPackageJsonPath = _chunkAWKQRM2Hjs.joinPaths.call(void 0,
workspaceRoot2,
projectNode.data.root,
"package.json"
);
if (_fs.existsSync.call(void 0, projectPackageJsonPath)) {
const projectPackageJsonContent = await _promises.readFile.call(void 0,
projectPackageJsonPath,
"utf8"
);
const projectPackageJson = JSON.parse(projectPackageJsonContent);
if (projectPackageJson.private !== true) {
localPackages.push(projectPackageJson);
}
}
}
}
if (localPackages.length > 0) {
_chunkAWKQRM2Hjs.writeTrace.call(void 0,
`\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`
);
const projectJsonFile = await _promises.readFile.call(void 0,
_chunkAWKQRM2Hjs.joinPaths.call(void 0, projectRoot, "project.json"),
"utf8"
);
const projectJson = JSON.parse(projectJsonFile);
const projectName2 = projectJson.name;
const projectConfigurations = _projectgraph.readProjectsConfigurationFromProjectGraph.call(void 0, projectGraph);
if (!_optionalChain([projectConfigurations, 'optionalAccess', _89 => _89.projects, 'optionalAccess', _90 => _90[projectName2]])) {
throw new Error(
"The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project."
);
}
const implicitDependencies = _optionalChain([projectConfigurations, 'access', _91 => _91.projects, 'optionalAccess', _92 => _92[projectName2], 'access', _93 => _93.implicitDependencies, 'optionalAccess', _94 => _94.reduce, 'call', _95 => _95((ret, dep) => {
if (_optionalChain([projectConfigurations, 'access', _96 => _96.projects, 'optionalAccess', _97 => _97[dep]])) {
const depPackageJsonPath = _chunkAWKQRM2Hjs.joinPaths.call(void 0,
workspaceRoot2,
projectConfigurations.projects[dep].root,
"package.json"
);
if (_fs.existsSync.call(void 0, depPackageJsonPath)) {
const depPackageJsonContent = _fs.readFileSync.call(void 0,
depPackageJsonPath,
"utf8"
);
const depPackageJson = JSON.parse(depPackageJsonContent);
if (depPackageJson.private !== true && !ret.includes(depPackageJson.name)) {
ret.push(depPackageJson.name);
}
}
}
return ret;
}, [])]);
packageJson.dependencies = localPackages.reduce((ret, localPackage) => {
if (!ret[localPackage.name] && !_optionalChain([implicitDependencies, 'optionalAccess', _98 => _98.includes, 'call', _99 => _99(localPackage.name)]) && _optionalChain([packageJson, 'access', _100 => _100.devDependencies, 'optionalAccess', _101 => _101[localPackage.name]]) === void 0) {
ret[localPackage.name] = `^${localPackage.version || "0.0.1"}`;
}
return ret;
}, _nullishCoalesce(packageJson.dependencies, () => ( {})));
packageJson.devDependencies = localPackages.reduce((ret, localPackage) => {
if (!ret[localPackage.name] && _optionalChain([implicitDependencies, 'optionalAccess', _102 => _102.includes, 'call', _103 => _103(localPackage.name)]) && _optionalChain([packageJson, 'access', _104 => _104.dependencies, 'optionalAccess', _105 => _105[localPackage.name]]) === void 0) {
ret[localPackage.name] = `^${localPackage.version || "0.0.1"}`;
}
return ret;
}, _nullishCoalesce(packageJson.devDependencies, () => ( {})));
} else {
_chunkAWKQRM2Hjs.writeTrace.call(void 0, "\u{1F4E6} No local packages dependencies to add to package.json");
}
return packageJson;
};
var addWorkspacePackageJsonFields = async (workspaceConfig, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
const workspaceRoot2 = workspaceConfig.workspaceRoot ? workspaceConfig.workspaceRoot : _chunkYRUROEEPjs.findWorkspaceRoot.call(void 0, );
const workspacePackageJsonContent = await _promises.readFile.call(void 0,
_chunkAWKQRM2Hjs.joinPaths.call(void 0, workspaceRoot2, "package.json"),
"utf8"
);
const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
packageJson.type ??= "module";
packageJson.sideEffects ??= false;
if (includeSrc === true) {
let distSrc = sourceRoot.replace(projectRoot, "");
if (distSrc.startsWith("/")) {
distSrc = distSrc.substring(1);
}
packageJson.source ??= `${_chunkAWKQRM2Hjs.joinPaths.call(void 0, distSrc, "index.ts").replaceAll("\\", "/")}`;
}
packageJson.files ??= ["dist/**/*"];
if (includeSrc === true && !packageJson.files.includes("src")) {
packageJson.files.push("src/**/*");
}
packageJson.publishConfig ??= {
access: "public"
};
packageJson.description ??= workspacePackageJson.description;
packageJson.homepage ??= workspacePackageJson.homepage;
packageJson.bugs ??= workspacePackageJson.bugs;
packageJson.license ??= workspacePackageJson.license;
packageJson.keywords ??= workspacePackageJson.keywords;
packageJson.funding ??= workspacePackageJson.funding;
packageJson.author ??= workspacePackageJson.author;
packageJson.maintainers ??= workspacePackageJson.maintainers;
if (!packageJson.maintainers && packageJson.author) {
packageJson.maintainers = [packageJson.author];
}
packageJson.contributors ??= workspacePackageJson.contributors;
if (!packageJson.contributors && packageJson.author) {
packageJson.contributors = [packageJson.author];
}
packageJson.repository ??= workspacePackageJson.repository;
packageJson.repository.directory ??= projectRoot ? projectRoot : _chunkAWKQRM2Hjs.joinPaths.call(void 0, "packages", projectName);
return packageJson;
};
var addPackageJsonExport = (file, type = "module", sourceRoot) => {
let entry = file.replaceAll("\\", "/");
if (sourceRoot) {
entry = entry.replace(sourceRoot, "");
}
return {
import: {
types: `./dist/${entry}.d.${type === "module" ? "ts" : "mts"}`,
default: `./dist/${entry}.${type === "module" ? "js" : "mjs"}`
},
require: {
types: `./dist/${entry}.d.${type === "commonjs" ? "ts" : "cts"}`,
default: `./dist/${entry}.${type === "commonjs" ? "js" : "cjs"}`
},
default: {
types: `./dist/${entry}.d.${type !== "fixed" ? "ts" : "mts"}`,
default: `./dist/${entry}.${type !== "fixed" ? "js" : "mjs"}`
}
};
};
// ../build-tools/src/utilities/get-entry-points.ts
// ../build-tools/src/utilities/get-env.ts
var getEnv = (builder, options) => {
return {
STORM_BUILD: builder,
STORM_ORG: options.orgName || DEFAULT_ORGANIZATION,
STORM_NAME: options.name,
STORM_MODE: options.mode || DEFAULT_ENVIRONMENT,
STORM_PLATFORM: options.platform,
STORM_FORMAT: JSON.stringify(options.format),
STORM_TARGET: JSON.stringify(options.target),
...options.env
};
};
// ../build-tools/src/utilities/read-nx-config.ts
// ../build-tools/src/utilities/task-graph.ts
var _createtaskgraph = require('nx/src/tasks-runner/create-task-graph');
// ../tsdown/src/build.ts
var _tsdown = require('tsdown');
// ../tsdown/src/clean.ts
async function cleanDirectories(name = "TSDown", directory, config) {
await _promises.rm.call(void 0, directory, { recursive: true, force: true });
}
// ../tsdown/src/config.ts
function getDefaultOptions(config) {
return {
entry: ["./src/*.ts"],
platform: "node",
target: "esnext",
mode: "production",
dts: true,
unused: {
level: "error",
ignore: ["typescript"]
},
publint: true,
fixedExtension: true,
...config
};
}
function toTSDownFormat(format2) {
if (!format2 || Array.isArray(format2) && format2.length === 0) {
return ["cjs", "es"];
} else if (format2 === "esm") {
return "es";
} else if (Array.isArray(format2)) {
return format2.map((f) => f === "esm" ? "es" : f);
}
return format2;
}
// ../tsdown/src/build.ts
var resolveOptions = async (userOptions) => {
const options = getDefaultOptions(userOptions);
const workspaceRoot2 = _chunkYRUROEEPjs.findWorkspaceRoot.call(void 0, options.projectRoot);
if (!workspaceRoot2) {
throw new Error("Cannot find Nx workspace root");
}
const workspaceConfig = await _chunkYRUROEEPjs.getWorkspaceConfig.call(void 0, options.debug === true, {
workspaceRoot: workspaceRoot2
});
_chunkAWKQRM2Hjs.writeDebug.call(void 0, " \u2699\uFE0F Resolving build options", workspaceConfig);
const stopwatch = _chunkAWKQRM2Hjs.getStopwatch.call(void 0, "Build options resolution");
const projectGraph = await _devkit.createProjectGraphAsync.call(void 0, {
exitOnError: true
});
const projectJsonPath = _chunkAWKQRM2Hjs.joinPaths.call(void 0,
workspaceRoot2,
options.projectRoot,
"project.json"
);
if (!_fs.existsSync.call(void 0, projectJsonPath)) {
throw new Error("Cannot find project.json configuration");
}
const projectJsonFile = await _promises2.default.readFile(projectJsonPath, "utf8");
const projectJson = JSON.parse(projectJsonFile);
const projectName = projectJson.name;
const projectConfigurations = _devkit.readProjectsConfigurationFromProjectGraph.call(void 0, projectGraph);
if (!_optionalChain([projectConfigurations, 'optionalAccess', _106 => _106.projects, 'optionalAccess', _107 => _107[projectName]])) {
throw new Error(
"The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project."
);
}
const packageJsonPath = _chunkAWKQRM2Hjs.joinPaths.call(void 0,
workspaceRoot2,
options.projectRoot,
"package.json"
);
if (!_fs.existsSync.call(void 0, packageJsonPath)) {
throw new Error("Cannot find package.json configuration");
}
const debug = _nullishCoalesce(options.debug, () => ( (options.mode || workspaceConfig.mode) === "development"));
const sourceRoot = projectJson.sourceRoot || _chunkAWKQRM2Hjs.joinPaths.call(void 0, options.projectRoot, "src");
const result = {
name: projectName,
mode: "production",
target: DEFAULT_TARGET,
generatePackageJson: true,
outDir: _chunkAWKQRM2Hjs.joinPaths.call(void 0, "dist", options.projectRoot),
minify: !debug,
plugins: [],
assets: [],
dts: true,
shims: true,
logLevel: workspaceConfig.logLevel === "success" || workspaceConfig.logLevel === "performance" || workspaceConfig.logLevel === "debug" || workspaceConfig.logLevel === "trace" || workspaceConfig.logLevel === "all" ? "info" : workspaceConfig.logLevel === "fatal" ? "error" : workspaceConfig.logLevel,
sourcemap: debug ? "inline" : false,
clean: false,
fixedExtension: true,
nodeProtocol: true,
tsconfig: _chunkAWKQRM2Hjs.joinPaths.call(void 0, options.projectRoot, "tsconfig.json"),
debug,
sourceRoot,
cwd: workspaceConfig.workspaceRoot,
entry: {
["index"]: _chunkAWKQRM2Hjs.joinPaths.call(void 0, sourceRoot, "index.ts")
},
workspace: true,
...options,
treeshake: options.treeShaking !== false,
format: toTSDownFormat(options.format),
workspaceConfig,
projectName,
projectGraph,
projectConfigurations
};
result.env = _defu2.default.call(void 0,
options.env,
getEnv("tsdown", result)
);
stopwatch();
return result;
};
async function generatePackageJson(options) {
if (options.generatePackageJson !== false && _fs.existsSync.call(void 0, _chunkAWKQRM2Hjs.joinPaths.call(void 0, options.projectRoot, "package.json"))) {
_chunkAWKQRM2Hjs.writeDebug.call(void 0, " \u270D\uFE0F Writing package.json file", options.workspaceConfig);
const stopwatch = _chunkAWKQRM2Hjs.getStopwatch.call(void 0, "Write package.json file");
const packageJsonPath = _chunkAWKQRM2Hjs.joinPaths.call(void 0, options.projectRoot, "project.json");
if (!_fs.existsSync.call(void 0, packageJsonPath)) {
throw new Error("Cannot find package.json configuration");
}
const packageJsonFile = await _promises2.default.readFile(
_chunkAWKQRM2Hjs.joinPaths.call(void 0,
options.workspaceConfig.workspaceRoot,
options.projectRoot,
"package.json"
),
"utf8"
);
if (!packageJsonFile) {
throw new Error("Cannot find package.json configuration file");
}
let packageJson = JSON.parse(packageJsonFile);
packageJson = await addPackageDependencies(
options.workspaceConfig.workspaceRoot,
options.projectRoot,
options.projectName,
packageJson
);
packageJson = await addWorkspacePackageJsonFields(
options.workspaceConfig,
options.projectRoot,
options.sourceRoot,
options.projectName,
false,
packageJson
);
packageJson.exports ??= {};
packageJson.exports["./package.json"] ??= "./package.json";
packageJson.exports["."] ??= addPackageJsonExport(
"index",
packageJson.type,
options.sourceRoot
);
let entry = [{ in: "./src/index.ts", out: "./src/index.ts" }];
if (options.entry) {
if (Array.isArray(options.entry)) {
entry = options.entry.map(
(entryPoint) => typeof entryPoint === "string" ? { in: entryPoint, out: entryPoint } : entryPoint
);
}
for (const entryPoint of entry) {
const split = entryPoint.out.split(".");
split.pop();
const entry2 = split.join(".").replaceAll("\\", "/");
packageJson.exports[`./${entry2}`] ??= addPackageJsonExport(
entry2,
options.fixedExtension ? "fixed" : packageJson.type,
options.sourceRoot
);
}
}
packageJson.main = !options.fixedExtension && packageJson.type === "commonjs" ? "./dist/index.js" : "./dist/index.cjs";
packageJson.module = !options.fixedExtension && packageJson.type === "module" ? "./dist/index.js" : "./dist/index.mjs";
packageJson.types = `./dist/index.d.${!options.fixedExtension ? "ts" : "mts"}`;
packageJson.exports = Object.keys(packageJson.exports).reduce(
(ret, key) => {
if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
ret[key.replace("/index", "")] = packageJson.exports[key];
}
return ret;
},
packageJson.exports
);
await _devkit.writeJsonFile.call(void 0, _chunkAWKQRM2Hjs.joinPaths.call(void 0, options.outDir, "package.json"), packageJson);
stopwatch();
}
return options;
}
async function executeTSDown(options) {
_chunkAWKQRM2Hjs.writeDebug.call(void 0, ` \u{1F680} Running ${options.name} build`, options.workspaceConfig);
const stopwatch = _chunkAWKQRM2Hjs.getStopwatch.call(void 0, `${options.name} build`);
await _tsdown.build.call(void 0, {
...options,
entry: options.entry,
config: false
});
stopwatch();
return options;
}
async function copyBuildAssets(options) {
_chunkAWKQRM2Hjs.writeDebug.call(void 0,
` \u{1F4CB} Copying asset files to output directory: ${options.outDir}`,
options.workspaceConfig
);
const stopwatch = _chunkAWKQRM2Hjs.getStopwatch.call(void 0, `${options.name} asset copy`);
await copyAssets(
options.workspaceConfig,
_nullishCoalesce(options.assets, () => ( [])),
options.outDir,
options.projectRoot,
options.sourceRoot,
true,
false
);
stopwatch();
return options;
}
async function reportResults(options) {
_chunkAWKQRM2Hjs.writeSuccess.call(void 0,
` \u{1F4E6} The ${options.name} build completed successfully`,
options.workspaceConfig
);
}
async function cleanOutputPath(options) {
if (options.clean !== false && options.workspaceConfig) {
_chunkAWKQRM2Hjs.writeDebug.call(void 0,
` \u{1F9F9} Cleaning ${options.name} output path: ${options.workspaceConfig}`,
options.workspaceConfig
);
const stopwatch = _chunkAWKQRM2Hjs.getStopwatch.call(void 0, `${options.name} output clean`);
await cleanDirectories(
options.name,
options.outDir,
options.workspaceConfig
);
stopwatch();
}
return options;
}
async function build(options) {
_chunkAWKQRM2Hjs.writeDebug.call(void 0, ` ${_chunkAWKQRM2Hjs.brandIcon.call(void 0, )} Executing Storm TSDown pipeline`);
const stopwatch = _chunkAWKQRM2Hjs.getStopwatch.call(void 0, "TSDown pipeline");
try {
const opts = Array.isArray(options) ? options : [options];
if (opts.length === 0) {
throw new Error("No build options were provided");
}
const resolved = await Promise.all(
opts.map(async (opt) => await resolveOptions(opt))
);
if (resolved.length > 0) {
await cleanOutputPath(resolved[0]);
await generatePackageJson(resolved[0]);
await Promise.all(
resolved.map(async (opt) => {
await executeTSDown(opt);
await copyBuildAssets(opt);
await reportResults(opt);
})
);
} else {
_chunkAWKQRM2Hjs.writeWarning.call(void 0,
" \u{1F6A7} No options were passed to TSBuild. Please check the parameters passed to the `build` function."
);
}
_chunkAWKQRM2Hjs.writeSuccess.call(void 0, " \u{1F3C1} TSDown pipeline build completed successfully");
} catch (error) {
_chunkAWKQRM2Hjs.writeFatal.call(void 0,
"Fatal errors that the build process could not recover from have occured. The build process has been terminated."
);
throw error;
} finally {
stopwatch();
}
}
// ../workspace-tools/src/executors/tsdown/executor.ts
async function tsdownExecutorFn(options, context, config) {
_chunkAWKQRM2Hjs.writeInfo.call(void 0, "\u{1F4E6} Running Storm TSDown executor on the workspace", config);
if (!_optionalChain([context, 'access', _108 => _108.projectsConfigurations, 'optionalAccess', _109 => _109.projects]) || !context.projectName || !context.projectsConfigurations.projects[context.projectName] || !_optionalChain([context, 'access', _110 => _110.projectsConfigurations, 'access', _111 => _111.projects, 'access', _112 => _112[context.projectName], 'optionalAccess', _113 => _113.root])) {
throw new Error(
"The Build process failed because the context is not valid. Please run this command from a workspace."
);
}
await build({
...options,
projectRoot: (
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
_optionalChain([context, 'access', _114 => _114.projectsConfigurations, 'acc