@storm-software/terraform-tools
Version:
Tools for managing Terraform infrastructure within a Nx workspace.
2,899 lines • 96.7 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 _chunk2NXAAPRNjs = require('./chunk-2NXAAPRN.js');
var _chunk3RG5ZIWIjs = require('./chunk-3RG5ZIWI.js');
// src/generators/init/init.ts
var _devkit = require('@nx/devkit');
// ../workspace-tools/src/utils/cargo.ts
var _child_process = require('child_process');
var _path = require('path'); var path3 = _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)) {
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}`, item);
}
} else {
args.push(`--${key}`, String(value));
}
}
if (context.projectName) {
args.push("-p", context.projectName);
}
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(...args) {
console.log(`> cargo ${args.join(" ")}`);
args.push("--color", "always");
return await Promise.resolve(runProcess("cargo", ...args));
}
function cargoCommandSync(args = "", options) {
const normalizedOptions = {
stdio: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _2 => _2.stdio]), () => ( "inherit")),
env: {
...process.env,
..._optionalChain([options, 'optionalAccess', _3 => _3.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,
success: false
};
}
}
function cargoMetadata() {
const output3 = cargoCommandSync("metadata --format-version=1", {
stdio: "pipe"
});
if (!output3.success) {
console.error("Failed to get cargo metadata");
return null;
}
return JSON.parse(output3.output);
}
function runProcess(processCmd, ...args) {
const metadata = cargoMetadata();
const targetDir = _nullishCoalesce(_optionalChain([metadata, 'optionalAccess', _4 => _4.target_directory]), () => ( _devkit.joinPathFragments.call(void 0, _devkit.workspaceRoot, "dist")));
return new Promise((resolve2) => {
if (process.env.VERCEL) {
return resolve2({ 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"]
});
resolve2({ success: true });
});
}
// ../workspace-tools/src/executors/cargo-build/executor.ts
async function cargoBuildExecutor(options, context) {
const command = buildCargoCommand("build", options, context);
return await cargoCommand(...command);
}
var executor_default = _chunk2NXAAPRNjs.withRunExecutor.call(void 0,
"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(...command);
}
var executor_default2 = _chunk2NXAAPRNjs.withRunExecutor.call(void 0,
"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(...command);
}
var executor_default3 = _chunk2NXAAPRNjs.withRunExecutor.call(void 0,
"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(...command);
}
var executor_default4 = _chunk2NXAAPRNjs.withRunExecutor.call(void 0,
"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(...command);
}
var executor_default5 = _chunk2NXAAPRNjs.withRunExecutor.call(void 0,
"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 _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
var _https = require('https'); var _https2 = _interopRequireDefault(_https);
var LARGE_BUFFER = 1024 * 1e6;
// ../esbuild/src/build.ts
var _esbuild = require('esbuild'); var esbuild = _interopRequireWildcard(_esbuild);
var _globby = require('globby');
// ../build-tools/src/config.ts
var DEFAULT_COMPILED_BANNER = `/*****************************************
*
* \u26A1 Built by Storm Software
*
*****************************************/
`;
var DEFAULT_ENVIRONMENT = "production";
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 _copyassetshandler = require('@nx/js/src/utils/assets/copy-assets-handler');
var _glob = require('glob');
var _promises = require('fs/promises'); var _promises2 = _interopRequireDefault(_promises);
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/"
});
}
_chunk2NXAAPRNjs.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} -> ${_chunk2NXAAPRNjs.joinPaths.call(void 0, outputPath, pendingAsset.output)}`).join("\n")}`,
config
);
const assetHandler = new (0, _copyassetshandler.CopyAssetsHandler)({
projectDir: projectRoot,
rootDir: config.workspaceRoot,
outputDir: outputPath,
assets: pendingAssets
});
await assetHandler.processAllAssetsOnce();
_chunk2NXAAPRNjs.writeTrace.call(void 0, "Completed copying assets to the output directory", config);
if (includeSrc === true) {
_chunk2NXAAPRNjs.writeDebug.call(void 0,
`\u{1F4DD} Adding banner and writing source files: ${_chunk2NXAAPRNjs.joinPaths.call(void 0,
outputPath,
"src"
)}`,
config
);
const files = await _glob.glob.call(void 0, [
_chunk2NXAAPRNjs.joinPaths.call(void 0, config.workspaceRoot, outputPath, "src/**/*.ts"),
_chunk2NXAAPRNjs.joinPaths.call(void 0, config.workspaceRoot, outputPath, "src/**/*.tsx"),
_chunk2NXAAPRNjs.joinPaths.call(void 0, config.workspaceRoot, outputPath, "src/**/*.js"),
_chunk2NXAAPRNjs.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 _buildablelibsutils = require('@nx/js/src/utils/buildable-libs-utils');
var _projectgraph = require('nx/src/project-graph/project-graph');
var addPackageDependencies = async (workspaceRoot3, 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 = _buildablelibsutils.calculateProjectBuildableDependencies.call(void 0,
void 0,
projectGraph,
workspaceRoot3,
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', _5 => _5.node, 'access', _6 => _6.data, 'optionalAccess', _7 => _7.root]) !== projectRoot && _optionalChain([dep, 'access', _8 => _8.node, 'access', _9 => _9.data, 'optionalAccess', _10 => _10.root]) !== workspaceRoot3
)) {
const projectNode = project.node;
if (projectNode.data.root) {
const projectPackageJsonPath = _chunk2NXAAPRNjs.joinPaths.call(void 0,
workspaceRoot3,
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) {
_chunk2NXAAPRNjs.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,
_chunk2NXAAPRNjs.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', _11 => _11.projects, 'optionalAccess', _12 => _12[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', _13 => _13.projects, 'optionalAccess', _14 => _14[projectName2], 'access', _15 => _15.implicitDependencies, 'optionalAccess', _16 => _16.reduce, 'call', _17 => _17((ret, dep) => {
if (_optionalChain([projectConfigurations, 'access', _18 => _18.projects, 'optionalAccess', _19 => _19[dep]])) {
const depPackageJsonPath = _chunk2NXAAPRNjs.joinPaths.call(void 0,
workspaceRoot3,
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', _20 => _20.includes, 'call', _21 => _21(localPackage.name)]) && _optionalChain([packageJson, 'access', _22 => _22.devDependencies, 'optionalAccess', _23 => _23[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', _24 => _24.includes, 'call', _25 => _25(localPackage.name)]) && _optionalChain([packageJson, 'access', _26 => _26.dependencies, 'optionalAccess', _27 => _27[localPackage.name]]) === void 0) {
ret[localPackage.name] = `^${localPackage.version || "0.0.1"}`;
}
return ret;
}, _nullishCoalesce(packageJson.devDependencies, () => ( {})));
} else {
_chunk2NXAAPRNjs.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 workspaceRoot3 = workspaceConfig.workspaceRoot ? workspaceConfig.workspaceRoot : _chunk2NXAAPRNjs.findWorkspaceRoot.call(void 0, );
const workspacePackageJsonContent = await _promises.readFile.call(void 0,
_chunk2NXAAPRNjs.joinPaths.call(void 0, workspaceRoot3, "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 ??= `${_chunk2NXAAPRNjs.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 : _chunk2NXAAPRNjs.joinPaths.call(void 0, "packages", projectName);
return packageJson;
};
// ../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');
// ../esbuild/src/assets.ts
async function copyBuildAssets(context) {
if (!_optionalChain([context, 'access', _28 => _28.result, 'optionalAccess', _29 => _29.errors, 'access', _30 => _30.length]) && _optionalChain([context, 'access', _31 => _31.options, 'access', _32 => _32.assets, 'optionalAccess', _33 => _33.length])) {
_chunk2NXAAPRNjs.writeDebug.call(void 0,
` \u{1F4CB} Copying ${context.options.assets.length} asset files to output directory: ${context.outputPath}`,
context.workspaceConfig
);
const stopwatch = _chunk2NXAAPRNjs.getStopwatch.call(void 0, `${context.options.name} asset copy`);
await copyAssets(
context.workspaceConfig,
_nullishCoalesce(context.options.assets, () => ( [])),
context.outputPath,
context.options.projectRoot,
context.sourceRoot,
true,
false
);
stopwatch();
}
return context;
}
// ../esbuild/src/clean.ts
async function cleanDirectories(directory) {
await _promises.rm.call(void 0, directory, { recursive: true, force: true });
}
// ../esbuild/src/context.ts
var _defu = require('defu'); var _defu2 = _interopRequireDefault(_defu);
var _findworkspaceroot = require('nx/src/utils/find-workspace-root');
// ../esbuild/src/config.ts
var DEFAULT_BUILD_OPTIONS = {
platform: "node",
target: "node22",
format: "esm",
mode: "production",
generatePackageJson: true,
includeSrc: false,
keepNames: true,
metafile: false,
treeshake: true,
splitting: true,
shims: false,
watch: false,
bundle: true,
distDir: "dist",
loader: {
".aac": "file",
".css": "file",
".eot": "file",
".flac": "file",
".gif": "file",
".jpeg": "file",
".jpg": "file",
".mp3": "file",
".mp4": "file",
".ogg": "file",
".otf": "file",
".png": "file",
".svg": "file",
".ttf": "file",
".wav": "file",
".webm": "file",
".webp": "file",
".woff": "file",
".woff2": "file"
},
banner: {
js: DEFAULT_COMPILED_BANNER,
css: DEFAULT_COMPILED_BANNER
}
};
// ../esbuild/src/context.ts
async function resolveContext(userOptions) {
const projectRoot = userOptions.projectRoot;
const workspaceRoot3 = _findworkspaceroot.findWorkspaceRoot.call(void 0, projectRoot);
if (!workspaceRoot3) {
throw new Error("Cannot find Nx workspace root");
}
const workspaceConfig = await _chunk2NXAAPRNjs.getWorkspaceConfig.call(void 0, true, {
workspaceRoot: workspaceRoot3.dir
});
_chunk2NXAAPRNjs.writeDebug.call(void 0, " \u2699\uFE0F Resolving build options", workspaceConfig);
const stopwatch = _chunk2NXAAPRNjs.getStopwatch.call(void 0, "Build options resolution");
const projectGraph = await _devkit.createProjectGraphAsync.call(void 0, {
exitOnError: true
});
const projectJsonPath = _chunk2NXAAPRNjs.joinPaths.call(void 0,
workspaceRoot3.dir,
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 || userOptions.name;
const projectConfigurations = _devkit.readProjectsConfigurationFromProjectGraph.call(void 0, projectGraph);
if (!_optionalChain([projectConfigurations, 'optionalAccess', _34 => _34.projects, 'optionalAccess', _35 => _35[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 options = _defu2.default.call(void 0, userOptions, DEFAULT_BUILD_OPTIONS);
options.name ??= projectName;
const packageJsonPath = _chunk2NXAAPRNjs.joinPaths.call(void 0,
workspaceRoot3.dir,
options.projectRoot,
"package.json"
);
if (!_fs.existsSync.call(void 0, packageJsonPath)) {
throw new Error("Cannot find package.json configuration");
}
const env = getEnv("esbuild", options);
const define = _defu2.default.call(void 0, _nullishCoalesce(options.define, () => ( {})), _nullishCoalesce(env, () => ( {})));
const resolvedOptions = {
...options,
tsconfig: userOptions.tsconfig === null ? void 0 : userOptions.tsconfig ? userOptions.tsconfig : _chunk2NXAAPRNjs.joinPaths.call(void 0, workspaceRoot3.dir, projectRoot, "tsconfig.json"),
metafile: userOptions.mode === "development",
clean: false,
env,
define: {
STORM_FORMAT: JSON.stringify(options.format),
...Object.keys(define).filter((key) => define[key] !== void 0).reduce((res, key) => {
const value = JSON.stringify(define[key]);
const safeKey = key.replaceAll("(", "").replaceAll(")", "");
return {
...res,
[`process.env.${safeKey}`]: value,
[`import.meta.env.${safeKey}`]: value
};
}, {})
}
};
stopwatch();
const context = {
options: resolvedOptions,
clean: userOptions.clean !== false,
workspaceConfig,
projectConfigurations,
projectName,
projectGraph,
sourceRoot: resolvedOptions.sourceRoot || projectJson.sourceRoot || _chunk2NXAAPRNjs.joinPaths.call(void 0, resolvedOptions.projectRoot, "src"),
outputPath: resolvedOptions.outputPath || _chunk2NXAAPRNjs.joinPaths.call(void 0,
workspaceConfig.workspaceRoot,
"dist",
resolvedOptions.projectRoot
),
minify: resolvedOptions.minify || resolvedOptions.mode === "production"
};
context.options.esbuildPlugins = [..._nullishCoalesce(context.options.esbuildPlugins, () => ( []))];
if (context.options.verbose) {
_chunk2NXAAPRNjs.writeDebug.call(void 0,
` \u2699\uFE0F Build options resolved:
${_chunk2NXAAPRNjs.formatLogMessage.call(void 0, context.options)}`,
workspaceConfig
);
}
return context;
}
// ../esbuild/src/package-json.ts
async function generatePackageJson(context) {
if (context.options.generatePackageJson !== false && _fs.existsSync.call(void 0, _chunk2NXAAPRNjs.joinPaths.call(void 0, context.options.projectRoot, "package.json"))) {
_chunk2NXAAPRNjs.writeDebug.call(void 0, " \u270D\uFE0F Writing package.json file", context.workspaceConfig);
const stopwatch = _chunk2NXAAPRNjs.getStopwatch.call(void 0, "Write package.json file");
const packageJsonPath = _chunk2NXAAPRNjs.joinPaths.call(void 0,
context.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(
_chunk2NXAAPRNjs.joinPaths.call(void 0,
context.workspaceConfig.workspaceRoot,
context.options.projectRoot,
"package.json"
),
"utf8"
);
let packageJson = JSON.parse(packageJsonFile);
if (!packageJson) {
throw new Error("Cannot find package.json configuration file");
}
packageJson = await addPackageDependencies(
context.workspaceConfig.workspaceRoot,
context.options.projectRoot,
context.projectName,
packageJson
);
packageJson = await addWorkspacePackageJsonFields(
context.workspaceConfig,
context.options.projectRoot,
context.sourceRoot,
context.projectName,
false,
packageJson
);
if (context.options.entry) {
packageJson.exports ??= {};
packageJson.exports["./package.json"] ??= "./package.json";
const entryPoints = Array.isArray(context.options.entry) ? context.options.entry : Object.keys(context.options.entry);
if (entryPoints.length > 0) {
const defaultEntry = entryPoints.includes("index") ? `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index` : `.${context.options.distDir ? `/${context.options.distDir}` : ""}/${entryPoints[0]}`;
const isEsm = Array.isArray(context.options.format) ? context.options.format.includes("esm") : context.options.format === "esm";
const isCjs = Array.isArray(context.options.format) ? context.options.format.includes("cjs") : context.options.format === "cjs";
const isDts = context.options.dts || context.options.experimentalDts;
packageJson.exports["."] ??= `${defaultEntry}.${isEsm ? "mjs" : isCjs ? "cjs" : "js"}`;
for (const entryPoint of entryPoints) {
packageJson.exports[`./${entryPoint}`] ??= {};
if (isEsm) {
if (isDts) {
packageJson.exports[`./${entryPoint}`].import = {
types: `./dist/${entryPoint}.d.mts`,
default: `./dist/${entryPoint}.mjs`
};
} else {
packageJson.exports[`./${entryPoint}`].import = `./dist/${entryPoint}.mjs`;
}
if (isDts) {
packageJson.exports[`./${entryPoint}`].default = {
types: `./dist/${entryPoint}.d.mts`,
default: `./dist/${entryPoint}.mjs`
};
} else {
packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.mjs`;
}
}
if (isCjs) {
if (isDts) {
packageJson.exports[`./${entryPoint}`].require = {
types: `./dist/${entryPoint}.d.cts`,
default: `./dist/${entryPoint}.cjs`
};
} else {
packageJson.exports[`./${entryPoint}`].require = `./dist/${entryPoint}.cjs`;
}
if (!isEsm) {
if (isDts) {
packageJson.exports[`./${entryPoint}`].default = {
types: `./dist/${entryPoint}.d.cts`,
default: `./dist/${entryPoint}.cjs`
};
} else {
packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.cjs`;
}
}
}
if (!isEsm && !isCjs) {
if (isDts) {
packageJson.exports[`./${entryPoint}`].default = {
types: `./dist/${entryPoint}.d.ts`,
default: `./dist/${entryPoint}.js`
};
} else {
packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.js`;
}
}
}
if (isEsm) {
packageJson.module = `${defaultEntry}.mjs`;
} else {
packageJson.main = `${defaultEntry}.cjs`;
}
if (isDts) {
packageJson.types = `${defaultEntry}.d.${isEsm ? "mts" : isCjs ? "cts" : "ts"}`;
}
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,
_chunk2NXAAPRNjs.joinPaths.call(void 0, context.outputPath, "package.json"),
packageJson
);
stopwatch();
}
return context;
}
// ../esbuild/src/plugins/deps-check.ts
var unusedIgnore = [
// these are our dev dependencies
/@types\/.*?/,
/@typescript-eslint.*?/,
/eslint.*?/,
"esbuild",
"husky",
"is-ci",
"lint-staged",
"prettier",
"typescript",
"ts-node",
"ts-jest",
"@swc/core",
"@swc/jest",
"jest",
// these are missing 3rd party deps
"spdx-exceptions",
"spdx-license-ids",
// type-only, so it is not detected
"ts-toolbelt",
// these are indirectly used by build
"buffer"
];
var missingIgnore = [".prisma", "@prisma/client", "ts-toolbelt"];
var depsCheckPlugin = (bundle) => ({
name: "storm:deps-check",
setup(build3) {
const pkgJsonPath = path3.default.join(process.cwd(), "package.json");
const pkgContents = _chunk3RG5ZIWIjs.__require.call(void 0, pkgJsonPath);
const regDependencies = Object.keys(_nullishCoalesce(pkgContents["dependencies"], () => ( {})));
const devDependencies = Object.keys(_nullishCoalesce(pkgContents["devDependencies"], () => ( {})));
const peerDependencies = Object.keys(_nullishCoalesce(pkgContents["peerDependencies"], () => ( {})));
const dependencies = [
...regDependencies,
...bundle ? devDependencies : []
];
const collectedDependencies = /* @__PURE__ */ new Set();
const onlyPackages = /^[^./](?!:)|^\.[^./]|^\.\.[^/]/;
build3.onResolve({ filter: onlyPackages }, (args) => {
if (args.importer.includes(process.cwd())) {
if (args.path[0] === "@") {
const [org, pkg] = args.path.split("/");
collectedDependencies.add(`${org}/${pkg}`);
} else {
const [pkg] = args.path.split("/");
collectedDependencies.add(pkg);
}
}
return { external: true };
});
build3.onEnd(() => {
const unusedDependencies = [...dependencies].filter((dep) => {
return !collectedDependencies.has(dep) || _module.builtinModules.includes(dep);
});
const missingDependencies = [...collectedDependencies].filter((dep) => {
return !dependencies.includes(dep) && !_module.builtinModules.includes(dep);
});
const filteredUnusedDeps = unusedDependencies.filter((dep) => {
return !unusedIgnore.some((pattern) => dep.match(pattern));
});
const filteredMissingDeps = missingDependencies.filter((dep) => {
return !missingIgnore.some((pattern) => dep.match(pattern)) && !peerDependencies.includes(dep);
});
_chunk2NXAAPRNjs.writeWarning.call(void 0,
`Unused Dependencies: ${JSON.stringify(filteredUnusedDeps)}`
);
_chunk2NXAAPRNjs.writeError.call(void 0,
`Missing Dependencies: ${JSON.stringify(filteredMissingDeps)}`
);
if (filteredMissingDeps.length > 0) {
throw new Error(`Missing dependencies detected - please install them:
${JSON.stringify(filteredMissingDeps)}
`);
}
});
}
});
// ../esbuild/src/tsup.ts
var _tsup = require('tsup');
async function executeTsup(context) {
_chunk2NXAAPRNjs.writeDebug.call(void 0,
` \u{1F680} Running ${context.options.name} build`,
context.workspaceConfig
);
const stopwatch = _chunk2NXAAPRNjs.getStopwatch.call(void 0, `${context.options.name} build`);
await _tsup.build.call(void 0, {
...context.options,
outDir: context.options.distDir ? _chunk2NXAAPRNjs.joinPaths.call(void 0, context.outputPath, context.options.distDir) : context.outputPath,
workspaceConfig: context.workspaceConfig
});
stopwatch();
return context;
}
// ../esbuild/src/build.ts
async function reportResults(context) {
if (_optionalChain([context, 'access', _36 => _36.result, 'optionalAccess', _37 => _37.errors, 'access', _38 => _38.length]) === 0) {
if (context.result.warnings.length > 0) {
_chunk2NXAAPRNjs.writeWarning.call(void 0,
` \u{1F6A7} The following warnings occurred during the build: ${context.result.warnings.map((warning) => warning.text).join("\n")}`,
context.workspaceConfig
);
}
_chunk2NXAAPRNjs.writeSuccess.call(void 0,
` \u{1F4E6} The ${context.options.name} build completed successfully`,
context.workspaceConfig
);
} else if (_optionalChain([context, 'access', _39 => _39.result, 'optionalAccess', _40 => _40.errors]) && _optionalChain([context, 'access', _41 => _41.result, 'optionalAccess', _42 => _42.errors, 'access', _43 => _43.length]) > 0) {
_chunk2NXAAPRNjs.writeError.call(void 0,
` \u274C The ${context.options.name} build failed with the following errors: ${context.result.errors.map((error) => error.text).join("\n")}`,
context.workspaceConfig
);
throw new Error(
`The ${context.options.name} build failed with the following errors: ${context.result.errors.map((error) => error.text).join("\n")}`
);
}
}
async function dependencyCheck(options) {
if (process.env.DEV === "true") {
return void 0;
}
if (process.env.CI && !process.env.BUILDKITE) {
return void 0;
}
const buildPromise = esbuild.build({
entryPoints: _globby.globbySync.call(void 0, "**/*.{j,t}s", {
// We don't check dependencies in ecosystem tests because tests are isolated from the build.
ignore: ["./src/__tests__/**/*", "./tests/e2e/**/*", "./dist/**/*"],
gitignore: true
}),
logLevel: "silent",
// there will be errors
bundle: true,
// we bundle to get everything
write: false,
// no need to write for analysis
outdir: "out",
plugins: [depsCheckPlugin(options.bundle)]
});
await buildPromise.catch(() => {
});
return void 0;
}
async function cleanOutputPath(context) {
if (context.clean !== false && context.outputPath) {
_chunk2NXAAPRNjs.writeDebug.call(void 0,
` \u{1F9F9} Cleaning ${context.options.name} output path: ${context.outputPath}`,
context.workspaceConfig
);
const stopwatch = _chunk2NXAAPRNjs.getStopwatch.call(void 0, `${context.options.name} output clean`);
await cleanDirectories(context.outputPath);
stopwatch();
}
return context;
}
async function build2(options) {
_chunk2NXAAPRNjs.writeDebug.call(void 0, ` \u26A1 Executing Storm ESBuild pipeline`);
const stopwatch = _chunk2NXAAPRNjs.getStopwatch.call(void 0, "ESBuild pipeline");
try {
const opts = Array.isArray(options) ? options : [options];
if (opts.length === 0) {
throw new Error("No build options were provided");
}
const context = await resolveContext(options);
await cleanOutputPath(context);
await Promise.all([
dependencyCheck(context.options),
generatePackageJson(context),
copyBuildAssets(context),
executeTsup(context)
]);
await reportResults(context);
_chunk2NXAAPRNjs.writeSuccess.call(void 0, " \u{1F3C1} ESBuild pipeline build completed successfully");
} catch (error) {
_chunk2NXAAPRNjs.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/esbuild/executor.ts
async function esbuildExecutorFn(options, context, config) {
_chunk2NXAAPRNjs.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."
);
}
await build2({
...options,
projectRoot: _optionalChain([context, 'access', _50 => _50.projectsConfigurations, 'access', _51 => _51.projects, 'optionalAccess', _52 => _52[context.projectName], 'access', _53 => _53.root]),
name: context.projectName,
sourceRoot: _optionalChain([context, 'access', _54 => _54.projectsConfigurations, 'access', _55 => _55.projects, 'optionalAccess', _56 => _56[context.projectName], 'optionalAccess', _57 => _57.sourceRoot]),
format: options.format,
platform: options.format
});
return {
success: true
};
}
var executor_default6 = _chunk2NXAAPRNjs.withRunExecutor.call(void 0,
"Storm ESBuild build",
esbuildExecutorFn,
{
skipReadingConfig: false,
hooks: {
applyDefaultOptions: async (options, config) => {
options.entry ??= ["src/index.ts"];
options.outputPath ??= "dist/{projectRoot}";
options.tsconfig ??= "{projectRoot}/tsconfig.json";
return options;
}
}
}
);
// ../workspace-tools/src/executors/npm-publish/executor.ts
var _prettier = require('prettier');
// ../workspace-tools/src/utils/package-helpers.ts
// ../workspace-tools/src/utils/project-tags.ts
var ProjectTagConstants = {
Language: {
TAG_ID: "language",
TYPESCRIPT: "typescript",
RUST: "rust"
},
ProjectType: {
TAG_ID: "type",
LIBRARY: "library",
APPLICATION: "application"
},
DistStyle: {
TAG_ID: "dist-style",
NORMAL: "normal",
CLEAN: "clean"
},
Provider: {
TAG_ID: "provider"
},
Platform: {
TAG_ID: "platform",
NODE: "node",
BROWSER: "browser",
NEUTRAL: "neutral",
WORKER: "worker"
},
Registry: {
TAG_ID: "registry",
CARGO: "cargo",
NPM: "npm",
CONTAINER: "container",
CYCLONE: "cyclone"
},
Plugin: {
TAG_ID: "plugin"
}
};
var formatProjectTag = (variant, value) => {
return `${variant}:${value}`;
};
var hasProjectTag = (project, variant) => {
project.tags = _nullishCoalesce(project.tags, () => ( []));
const prefix = formatProjectTag(variant, "");
return project.tags.some(
(tag) => tag.startsWith(prefix) && tag.length > prefix.length
);
};
var addProjectTag = (project, variant, value, options = {
overwrite: false
}) => {
project.tags = _nullishCoalesce(project.tags, () => ( []));
if (options.overwrite || !hasProjectTag(project, variant)) {
project.tags = project.tags.filter(
(tag) => !tag.startsWith(formatProjectTag(variant, ""))
);
project.tags.push(formatProjectTag(variant, value));
}
};
// ../workspace-tools/src/utils/pnpm-deps-update.ts
var _readyamlfile = require('read-yaml-file'); var _readyamlfile2 = _interopRequireDefault(_readyamlfile);
// ../workspace-tools/src/executors/npm-publish/executor.ts
var LARGE_BUFFER2 = 1024 * 1e6;
// ../workspace-tools/src/executors/size-limit/executor.ts
var _esbuild2 = require('@size-limit/esbuild'); var _esbuild3 = _interopRequireDefault(_esbuild2);
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', _58 => _58.projectName]) || !_optionalChain([context, 'access', _59 => _59.projectsConfigurations, 'optionalAccess', _60 => _60.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."
);
}
_chunk2NXAAPRNjs.writeInfo.call(void 0, `\u{1F4CF} Running Size-Limit on ${context.projectName}`, config);
_sizelimit2.default.call(void 0, [_file2.default, _esbuild3.default, _esbuildwhy2.default], {
checks: _nullishCoalesce(_nullishCoalesce(options.entry, () => ( _optionalChain([context, 'access', _61 => _61.projectsConfigurations, 'access', _62 => _62.projects, 'access', _63 => _63[context.projectName], 'optionalAccess', _64 => _64.sourceRoot]))), () => ( _devkit.joinPathFragments.call(void 0,
_nullishCoalesce(_optionalChain([context, 'access', _65 => _65.projectsConfigurations, 'access', _66 => _66.projects, 'access', _67 => _67[context.projectName], 'optionalAccess', _68 => _68.root]), () => ( "./")),
"src"
)))
}).then((result) => {
_chunk2NXAAPRNjs.writeInfo.call(void 0,
`\u{1F4CF} ${context.projectName} Size-Limit result: ${JSON.stringify(result)}`,
config
);
});
return {
success: true
};
}
var executor_default7 = _chunk2NXAAPRNjs.withRunExecutor.call(void 0,
"Size-Limit Performance Test Executor",
sizeLimitExecutorFn,
{
skipReadingConfig: false,
hooks: {
applyDefaultOptions: (options) => {
return options;
}
}
}
);
// ../workspace-tools/src/executors/typia/executor.ts
var _fsextra = require('fs-extra');
var _TypiaProgrammerjs = require('typia/lib/programmers/TypiaProgrammer.js');
async function typiaExecutorFn(options, _, config) {
if (options.clean !== false) {
_chunk2NXAAPRNjs.writeInfo.call(void 0, `\u{1F9F9} Cleaning output path: ${options.outputPath}`, config);
_fsextra.removeSync.call(void 0, options.outputPath);
}
await Promise.all(
options.entry.map((entry) => {
_chunk2NXAAPRNjs.writeInfo.call(void 0, `\u{1F680} Running Typia on entry: ${entry}`, config);
return _TypiaProgrammerjs.TypiaProgrammer.build({
input: entry,
output: options.outputPath,
project: options.tsconfig
});
})
);
return {
success: true
};
}
var executor_default8 = _chunk2NXAAPRNjs.withRunExecutor.call(void 0,
"Typia runtime validation generator",
typiaExecutorFn,
{
skipReadingConfig: false,
hooks: {
applyDefaultOptions: (options) => {
options.entry ??= ["{sourceRoot}/index.ts"];
options.outputPath ??= "{sourceRoot}/__generated__/typia";
options.tsconfig ??= "{projectRoot}/tsconfig.json";
options.clean ??= true;
return options;
}
}
}
);
// ../workspace-tools/src/executors/unbuild/executor.ts
var _jiti = require('jiti');
async function unbuildExecutorFn(options, context, config) {
_chunk2NXAAPRNjs.writeInfo.call(void 0, "\u{1F4E6} Running Storm Unbuild executor on the workspace", config);
if (!_optionalChain([context, 'access', _69 => _69.projectsConfigurations, 'optionalAccess', _70 => _70.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 root directory."
);
}
if (!context.projectsConfigurations.projects[context.projectName].root) {
throw new Error(
"The Build process failed because the project root is not valid. Please run this command from a workspace root directory."
);
}
if (!context.projectsConfigurations.projects[context.projectName].sourceRoot) {
throw new Error(
"The Build process failed because the project's source root is not valid. Please run this command from a workspace root directory."
);
}
const jiti = _jiti.createJiti.call(void 0, config.workspaceRoot, {
fsCache: config.skipCache ? false : _chunk2NXAAPRNjs.joinPaths.call(void 0,
config.workspaceRoot,
config.directories.cache || "node_modules/.cache/storm",
"jiti"
),
interopDefault: true
});
const stormUnbuild = await jiti.import(
jiti.esmResolve("@storm-software/unbuild/build")
);
await stormUnbuild.build(
_defu.defu.call(void 0,
{
...options,
projectRoot: context.projectsConfigurations.projects[context.projectName].root,
projectName: context.projectName,
sourceRoot: context.projectsConfigurations.projects[context.projectName].sourceRoot,
platform: options.platform
},
{
stubOptions: {
jiti: {
fsCache: config.skipCache ? false : _chunk2NXAAPRNjs.joinPaths.call(void 0,
config.workspaceRoot,
config.directories.cache || "node_modules/.cache/storm",
"jiti"
)
}
},
rollup: {
emitCJS: true,
watch: false,
dts: {
respectExternal: true
},
esbuild: {
target: options.target,
format: "esm",
platform: options.platform,
minify: _nullishCoalesce(options.minify, () => ( !options.debug)),
sourcemap: _nullishCoalesce(options.sourcemap, () => ( options.debug)),
treeShaking: options.treeShaking
}
}
}
)
);
return {
success: true
};
}
var executor_default9 = _chunk2NXAAPRNjs.withRunExecutor.call(void 0,
"TypeScript Unbuild build",
unbuildExecutorFn,
{
skipReadingConfig: false,
hooks: {
applyDefaultOptions: async (options, config) => {
options.debug ??= false;
options.treeShaking ??= true;
options.buildOnly ??= false;
options.platform ??= "neutral";
options.entry ??= ["{sourceRoot}"];
options.tsconfig ??= "{projectRoot}/tsconfig.json";
return options;
}
}
}
);
// ../workspace-tools/src/generators/browser-library/generator.ts
// ../workspace-tools/src/base/base-generator.ts
var withRunGenerator = (name, generatorFn, generatorOptions = {
skipReadingConfig: false
}) => async (tree, _options) => {
const stopwatch = _chunk2NXAAPRNjs.getStopwatch.call(void 0, name);
let options = _options;
let config;
try {
_chunk2NXAAPRNjs.writeInfo.call(void 0, `\u26A1 Running the ${name} generator...
`, config);
const workspaceRoot3 = _chunk2NXAAPRNjs.findWorkspaceRoot.call(void 0, );
if (!generatorOptions.skipReadingConfig) {
_chunk2NXAAPRNjs.writeDebug.call(void 0,
`Loading the Storm Config from environment variables and storm.config.js file...
- workspaceRoot: ${workspaceRoot3}`,
config
);
config = await _chunk2NXAAPRNjs.getConfig.call(void 0, workspaceRoot3);
}
if (_optionalChain([generatorOptions, 'optionalAccess', _71 => _71.hooks, 'optionalAccess', _72 => _72.applyDefaultOptions])) {
_chunk2NXAAPRNjs.writeDebug.call(void 0, "Running the applyDefaultOptions hook...", config);
options = await Promise.resolve(
generatorOptions.hooks.applyDefaultOptions(options, config)
);
_chunk2NXAAPRNjs.writeDebug.call(void 0, "Completed the applyDefaultOptions hook", config);
}
_chunk2NXAAPRNjs.writeTrace.call(void 0,
`Generator schema options \u2699\uFE0F
${Object.keys(_nullishCoalesce(options, () => ( {}))).map((key) => ` - ${key}=${JSON.stringify(options[key])}`).join("\n")}`,
config
);
const tokenized = await _chunk2NXAAPRNjs.applyWorkspaceTokens.call(void 0,
options,
{ workspaceRoot: tree.root, config },
_chunk2NXAAPRNjs.applyWorkspaceBaseTokens
);
if (_optionalChain([generatorOptions, 'optionalAccess', _73 => _73.hooks, 'optionalAccess', _74 => _74.preProcess])) {
_chunk2NXAAPRNjs.writeDebug.call(void 0, "Running the preProcess hook...", config);
await Promise.resolve(
generatorOptions.hooks.preProcess(tokenized, config)
);
_chunk2NXAAPRNjs.writeDebug.call(void 0, "Completed the preProcess hook", config);
}
const result = await Promise.resolve(
generatorFn(tree, tokenized, config)
);
if (result) {
if (result.success === false || result.error && _optionalChain([result, 'optionalAccess', _75 => _75.error, 'optionalAccess', _76 => _76.message]) && typeof _optionalChain([result, 'optionalAccess', _77 => _77.error, 'optionalAccess', _78 => _78.message]) === "string" && _optionalChain([result, 'optionalAccess', _79 => _79.error, 'optionalAccess', _80 => _80.name]) && typeof _optionalChain([result, 'optionalAccess', _81 => _81.error, 'optionalAccess', _82 => _82.name]) === "string") {
throw new Error(`The ${name} generator failed to run`, {
cause: _optionalChain([result, 'optionalAccess', _83 => _83.error])
});
} else if (result.success && result.data) {
return result;
}
}
if (_optionalChain([generatorOptions, 'optionalAccess', _84 => _84.hooks, 'optionalAccess', _85 => _85.postProcess])) {
_chunk2NXAAPRNjs.writeDebug.call(void 0, "Running the postProcess hook...", config);
await Promise.resolve(generatorOptions.hooks.postProcess(config));
_chunk2NXAAPRNjs.writeDebug.call(void 0, "Completed the postProcess hook", config);
}
return () => {
_chunk2NXAAPRNjs.writeSuccess.call(void 0, `Completed running the ${name} generator!
`, config);
};
} catch (error) {
return () => {
_chunk2NXAAPRNjs.writeFatal.call(void 0,
"A fatal error occurred while running the generator - the process was forced to terminate",
config
);
_chunk2NXAAPRNjs.writeError.call(void 0,
`An exception was thrown in the generator's process
- Details: ${error.message}
- Stacktrace: ${error.stack}`,
config
);
};
} finally {
stopwatch();
}
};
// ../workspace-tools/src/base/typescript-library-generator.ts
var _projectnameandrootutils = require('@nx/devkit/src/generators/project-name-and-root-utils');
var _js = require('@nx/js');
var _init = require('@nx/js/src/generators/init/init'); var _init2 = _interopRequireDefault(_init);
var _generator = require('@nx/js/src/generators/setup-verdaccio/generator'); var _generator2 = _interopRequireDefault(_generator);
// ../workspace-tools/src/utils/versions.ts
var typesNodeVersion = "20.9.0";
var nxVersion = "^18.0.4";
var nodeVersion = "20.11.0";
var pnpmVersion = "8.10.2";
// ../workspace-tools/src/base/typescript-library-generator.ts
async function typeScriptLibraryGeneratorFn(tree, options, config) {
const normalized = await normalizeOptions(tree, { ...options });
const tasks = [];
tasks.push(
await _init2.default.call(void 0, tree, {
...normalized,
tsConfigName: normalized.rootProject ? "tsconfig.json" : "tsconfig.base.json"
})
);
tasks.push(
_devkit.addDependenciesToPackageJson.call(void 0,
tree,
{},
{
"@storm-software/workspace-tools": "latest",
"@storm-software/testing-tools": "latest",
..._nullishCoalesce(options.devDependencies, () => ( {}))
}
)
);
if (normalized.publishable) {
tasks.push(await _generator2.default.call(void 0, tree, { ...normalized, skipFormat: true }));
}
const projectConfig = {
root: normalized.directory,
projectType: "library",
sourceRoot: _chunk2NXAAPRNjs.joinPaths.call(void 0, _nullishCoalesce(normalized.directory, () => ( "")), "src"),
targets: {
build: {
executor: options.buildExecutor,
outputs: ["{options.outputPath}"],
options: {
entry: [_chunk2NXAAPRNjs.joinPaths.call(void 0, normalized.projectRoot, "src", "index.ts")],
outputPath: getOutputPath(normalized),
tsconfig: _chunk2NXAAPRNjs.joinPaths.call(void 0, normalized.projectRoot, "tsconfig.json"),
project: _chunk2NXAAPRNjs.joinPaths.call(void 0, normalized.projectRoot, "package.json"),
defaultConfiguration: "production",
platform: "neutral",
assets: [
{
input: normalized.projectRoot,
glob: "*.md",
output: "/"
},
{
input: "",
glob: "LICENSE",
output: "/"
}
]
},
configurations: {
production: {
debug: false,
verbose: false
},
development: {
debug: true,
verbose: true
}
}
}
}
};
if (options.platform) {
projectConfig.targets.build.options.platform = options.platform === "worker" ? "node" : options.platform;
}
addProjectTag(
projectConfig,
ProjectTagConstants.Platform.TAG_ID,
options.platform === "node" ? ProjectTagConstants.Platform.NODE : options.platform === "worker" ? ProjectTagConstants.Platform.WORKER : options.platform === "browser" ? ProjectTagConstants.Platform.BROWSER : ProjectTagConstants.Platform.NEUTRAL,
{ overwrite: false }
);
createProjectTsConfigJson(tree, normalized);
_devkit.addProjectConfiguration.call(void 0, tree, normalized.name, projectConfig);
let repository = {
type: "github",
url: _optionalChain([config, 'optionalAccess', _86 => _86.repository]) || `https://github.com/${(typeof _optionalChain([config, 'optionalAccess', _87 => _87.organization]) === "string" ? _optionalChain([config, 'optionalAccess', _88 => _88.organization]) : _optionalChain([config, 'optionalAccess', _89 => _89.organization, 'optionalAccess', _90 => _90.name])) || "storm-software"}/${_optionalChain([config, 'optionalAccess', _91 => _91.namespace]) || _optionalChain([config, 'optionalAccess', _92 => _92.name]) || "repository"}.git`
};
let description = options.description || "A package developed by Storm Software used to create modern, scalable web applications.";
if (tree.exists("package.json")) {
const packageJson = _devkit.readJson.call(void 0, tree, "package.json");
if (_optionalChain([packageJson, 'optionalAccess', _93 => _93.repository])) {
repository = packageJson.repository;
}
if (_optionalChain([packageJson, 'optionalAccess', _94 => _94.description])) {
description = packageJson.description;
}
}
if (!normalized.importPath) {
normalized.importPath = normalized.name;
}
const packageJsonPath = _chunk2NXAAPRNjs.joinPaths.call(void 0, normalized.projectRoot, "package.json");
if (tree.exists(packageJsonPath)) {
_devkit.updateJson.call(void 0, tree, packageJsonPath, (json) => {
if (!normalized.importPath) {
normalized.importPath = normalized.name;
}
json.name = normalized.importPath;
json.version = "0.0.1";
if (json.private && (normalized.publishable || normalized.rootProject)) {
json.private = void 0;
}
return {
...json,
version: "0.0.1",
description,
repository: {
...repository,
directory: normalized.projectRoot
},
type: "module",
dependencies: {
...json.dependencies
},
publishConfig: {
access: "public"
}
};
});
} else {
_devkit.writeJson.call(void 0, tree, packageJsonPath, {
name: normalized.importPath,
version: "0.0.1",
description,
repository: {
...repository,
directory: normalized.projectRoot
},
private: !normalized.publishable || normalized.rootProject,
type: "module",
publishConfig: {
access: "public"
}
});
}
if (tree.exists("package.json") && normalized.importPath) {
_devkit.updateJson.call(void 0, tree, "package.json", (json) => ({
...json,
pnpm: {
..._optionalChain([json, 'optionalAccess', _95 => _95.pnpm]),
overrides: {
..._optionalChain([json, 'optionalAccess', _96 => _96.pnpm, 'optionalAccess', _97 => _97.overrides]),
[_nullishCoalesce(normalized.importPath, () => ( ""))]: "workspace:*"
}
}
}));
}
_js.addTsConfigPath.call(void 0, tree, normalized.importPath, [
_chunk2NXAAPRNjs.joinPaths.call(void 0,
normalized.projectRoot,
"./src",
`index.${normalized.js ? "js" : "ts"}`
)
]);
_js.addTsConfigPath.call(void 0, tree, _chunk2NXAAPRNjs.joinPaths.call(void 0, normalized.importPath, "/*"), [
_chunk2NXAAPRNjs.joinPaths.call(void 0, normalized.projectRoot, "./src", "/*")
]);
if (tree.exists("package.json")) {
const packageJson = _devkit.readJson.call(void 0, tree, "package.json");
if (_optionalChain([packageJson, 'optionalAccess', _98 => _98.repository])) {
repository = packageJson.repository;
}
if (_optionalChain([packageJson, 'optionalAccess', _99 => _99.description])) {
description = packageJson.description;
}
}
const tsconfigPath = _chunk2NXAAPRNjs.joinPaths.call(void 0, normalized.projectRoot, "tsconfig.json");
if (tree.exists(tsconfigPath)) {
_devkit.updateJson.call(void 0, tree, tsconfigPath, (json) => {
json.composite ??= true;
return json;
});
} else {
_devkit.writeJson.call(void 0, tree, tsconfigPath, {
extends: `${_devkit.offsetFromRoot.call(void 0, normalized.projectRoot)}tsconfig.base.json`,
composite: true,
compilerOptions: {
outDir: `${_devkit.offsetFromRoot.call(void 0, normalized.projectRoot)}dist/out-tsc`
},
files: [],
include: ["src/**/*.ts", "src/**/*.js"],
exclude: ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
});
}
await _devkit.formatFiles.call(void 0, tree);
return null;
}
function getOutputPath(options) {
const parts = ["dist"];
if (options.projectRoot === ".") {
parts.push(options.name);
} else {
parts.push(options.projectRoot);
}
return _chunk2NXAAPRNjs.joinPaths.call(void 0, ...parts);
}
function createProjectTsConfigJson(tree, options) {
const tsconfig = {
extends: options.rootProject ? void 0 : _js.getRelativePathToRootTsConfig.call(void 0, tree, options.projectRoot),
..._nullishCoalesce(_optionalChain([options, 'optionalAccess', _100 => _100.tsconfigOptions]), () => ( {})),
compilerOptions: {
...options.rootProject ? _js.tsConfigBaseOptions : {},
outDir: _chunk2NXAAPRNjs.joinPaths.call(void 0, _devkit.offsetFromRoot.call(void 0, options.projectRoot), "dist/out-tsc"),
noEmit: true,
..._nullishCoalesce(_optionalChain([options, 'optionalAccess', _101 => _101.tsconfigOptions, 'optionalAccess', _102 => _102.compilerOptions]), () => ( {}))
},
files: [..._nullishCoalesce(_optionalChain([options, 'optionalAccess', _103 => _103.tsconfigOptions, 'optionalAccess', _104 => _104.files]), () => ( []))],
include: [
..._nullishCoalesce(_optionalChain([options, 'optionalAccess', _105 => _105.tsconfigOptions, 'optionalAccess', _106 => _106.include]), () => ( [])),
"src/**/*.ts",
"src/**/*.js",
"bin/**/*"
],
exclude: [
..._nullishCoalesce(_optionalChain([options, 'optionalAccess', _107 => _107.tsconfigOptions, 'optionalAccess', _108 => _108.exclude]), () => ( [])),
"jest.config.ts",
"src/**/*.spec.ts",
"src/**/*.test.ts"
]
};
_devkit.writeJson.call(void 0, tree, _chunk2NXAAPRNjs.joinPaths.call(void 0, options.projectRoot, "tsconfig.json"), tsconfig);
}
async function normalizeOptions(tree, options, config) {
let importPath = options.importPath;
if (!importPath && _optionalChain([config, 'optionalAccess', _109 => _109.namespace])) {
importPath = `@${_optionalChain([config, 'optionalAccess', _110 => _110.namespace])}/${options.name}`;
}
if (options.publishable) {
if (!importPath) {
throw new Error(
`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`
);
}
}
let bundler = "tsc";
if (options.publishable === false && options.buildable === false) {
bundler = "none";
}
const { Linter } = _devkit.ensurePackage.call(void 0, "@nx/eslint", nxVersion);
const rootProject = false;
const {
projectName,
names: projectNames,
projectRoot,
importPath: normalizedImportPath
} = await _projectnameandrootutils.determineProjectNameAndRootOptions.call(void 0, tree, {
name: options.name,
projectType: "library",
directory: options.directory,
importPath,
rootProject
});
const normalized = _devkit.names.call(void 0, projectNames.projectFileName);
const fileName = normalized.fileName;
return {
js: false,
pascalCaseFiles: false,
skipFormat: false,
skipTsConfig: false,
includeBabelRc: false,
unitTestRunner: "jest",
linter: Linter.EsLint,
testEnvironment: "node",
config: "project",
compiler: "tsc",
bundler,
skipTypeCheck: false,
minimal: false,
hasPlugin: false,
isUsingTsSolutionConfig: false,
projectPackageManagerWorkspaceState: "included",
...options,
fileName,
name: projectName,
projectNames,
projectRoot,
parsedTags: options.tags ? options.tags.split(",").map((s) => s.trim()) : [],
importPath: normalizedImportPath,
rootProject,
shouldUseSwcJest: false
};
}
// ../workspace-tools/src/generators/browser-library/generator.ts
async function browserLibraryGeneratorFn(tree, schema, config) {
const filesDir = _chunk2NXAAPRNjs.joinPaths.call(void 0,
__dirname,
"src",
"generators",
"browser-library",
"files"
);
const tsLibraryGeneratorOptions = {
buildExecutor: "@storm-software/workspace-tools:unbuild",
platform: "browser",
devDependencies: {
"@types/react": "^18.3.6",
"@types/react-dom": "^18.3.0"
},
peerDependencies: {
react: "^18.3.0",
"react-dom": "^18.3.0",
"react-native": "*"
},
peerDependenciesMeta: {
"react-dom": {
optional: true
},
"react-native": {
optional: true
}
},
...schema,
description: schema.description,
directory: schema.directory
};
const options = await normalizeOptions(tree, tsLibraryGeneratorOptions);
const { className, name, propertyName } = _devkit.names.call(void 0,
options.projectNames.projectFileName
);
_devkit.generateFiles.call(void 0, tree, filesDir, options.projectRoot, {
...schema,
dot: ".",
className,
name,
namespace: _nullishCoalesce(process.env.STORM_NAMESPACE, () => ( "storm-software")),
description: _nullishCoalesce(schema.description, () => ( "")),
propertyName,
js: !!options.js,
cliCommand: "nx",
strict: void 0,
tmpl: "",
offsetFromRoot: _devkit.offsetFromRoot.call(void 0, options.projectRoot),
buildable: options.bundler && options.bundler !== "none",
hasUnitTestRunner: options.unitTestRunner !== "none",
tsConfigOptions: {
compilerOptions: {
jsx: "react",
types: [
"node",
"@nx/react/typings/cssmodule.d.ts",
"@nx/react/typings/image.d.ts"
]
}
}
});
await typeScriptLibraryGeneratorFn(tree, tsLibraryGeneratorOptions, config);
await _devkit.formatFiles.call(void 0, tree);
return null;
}
var generator_default = withRunGenerator(
"TypeScript Library Creator (Browser Platform)",
browserLibraryGeneratorFn,
{
hooks: {
applyDefaultOptions: (options) => {
options.description ??= "A library used by Storm Software to support browser applications";
options.platform ??= "browser";
return options;
}
}
}
);
// ../workspace-tools/src/generators/config-schema/generator.ts
var _zod = require('zod'); var z = _interopRequireWildcard(_zod);
async function configSchemaGeneratorFn(tree, options, config) {
_chunk2NXAAPRNjs.writeInfo.call(void 0,
"\u{1F4E6} Running Storm Workspace Configuration JSON Schema generator",
config
);
_chunk2NXAAPRNjs.writeTrace.call(void 0,
`Determining the Storm Workspace Configuration JSON Schema...`,
config
);
const jsonSchema = z.toJSONSchema(_chunk2NXAAPRNjs.workspaceConfigSchema, {
target: "draft-7",
metadata: _chunk2NXAAPRNjs.schemaRegistry
});
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.";
_chunk2NXAAPRNjs.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', _111 => _111.workspaceRoot]), () => ( _chunk2NXAAPRNjs.findWorkspaceRoot.call(void 0, ))),
options.outputFile.startsWith("./") ? "" : "./"
);
_chunk2NXAAPRNjs.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);
_chunk2NXAAPRNjs.writeSuccess.call(void 0,
"\u{1F680} Storm Configuration JSON Schema creation has completed successfully!",
config
);
return {
success: true
};
}
var generator_default2 = withRunGenerator(
"Configuration Schema Creator",
configSchemaGeneratorFn,
{
hooks: {
applyDefaultOptions: (options) => {
options.outputFile ??= "{workspaceRoot}/storm-workspace.schema.json";
return options;
}
}
}
);
// ../workspace-tools/src/generators/init/init.ts
async function initGenerator(tree, schema) {
const task = _devkit.addDependenciesToPackageJson.call(void 0,
tree,
{
nx: "^19.6.2",
"@nx/workspace": "^19.6.2",
"@nx/js": "^19.6.2",
"@storm-software/eslint": "latest",
"@storm-software/prettier": "latest",
"@storm-software/config-tools": "latest",
"@storm-software/testing-tools": "latest",
"@storm-software/git-tools": "latest",
"@storm-software/linting-tools": "latest"
},
{}
);
if (!schema.skipFormat) {
await _devkit.formatFiles.call(void 0, tree);
}
return task;
}
// ../workspace-tools/src/generators/neutral-library/generator.ts
async function neutralLibraryGeneratorFn(tree, schema, config) {
const filesDir = _chunk2NXAAPRNjs.joinPaths.call(void 0,
__dirname,
"src",
"generators",
"neutral-library",
"files"
);
const tsLibraryGeneratorOptions = {
...schema,
platform: "neutral",
devDependencies: {},
buildExecutor: "@storm-software/workspace-tools:unbuild"
};
const options = await normalizeOptions(tree, tsLibraryGeneratorOptions);
const { className, name, propertyName } = _devkit.names.call(void 0,
options.projectNames.projectFileName
);
_devkit.generateFiles.call(void 0, tree, filesDir, options.projectRoot, {
...schema,
dot: ".",
className,
name,
namespace: _nullishCoalesce(process.env.STORM_NAMESPACE, () => ( "storm-software")),
description: _nullishCoalesce(schema.description, () => ( "")),
propertyName,
js: !!options.js,
cliCommand: "nx",
strict: void 0,
tmpl: "",
offsetFromRoot: _devkit.offsetFromRoot.call(void 0, options.projectRoot),
buildable: options.bundler && options.bundler !== "none",
hasUnitTestRunner: options.unitTestRunner !== "none"
});
await typeScriptLibraryGeneratorFn(tree, tsLibraryGeneratorOptions, config);
await _devkit.formatFiles.call(void 0, tree);
return null;
}
var generator_default3 = withRunGenerator(
"TypeScript Library Creator (Neutral Platform)",
neutralLibraryGeneratorFn,
{
hooks: {
applyDefaultOptions: (options) => {
options.description ??= "A library used by Storm Software to support either browser or NodeJs applications";
options.platform = "neutral";
return options;
}
}
}
);
// ../workspace-tools/src/generators/node-library/generator.ts
async function nodeLibraryGeneratorFn(tree, schema, config) {
const filesDir = _chunk2NXAAPRNjs.joinPaths.call(void 0,
__dirname,
"src",
"generators",
"node-library",
"files"
);
const tsLibraryGeneratorOptions = {
platform: "node",
devDependencies: {
"@types/node": typesNodeVersion
},
buildExecutor: "@storm-software/workspace-tools:unbuild",
...schema,
directory: schema.directory,
description: schema.description
};
const options = await normalizeOptions(tree, tsLibraryGeneratorOptions);
const { className, name, propertyName } = _devkit.names.call(void 0, options.name);
_devkit.generateFiles.call(void 0, tree, filesDir, options.projectRoot, {
...schema,
dot: ".",
className,
name,
namespace: _nullishCoalesce(process.env.STORM_NAMESPACE, () => ( "storm-software")),
description: _nullishCoalesce(schema.description, () => ( "")),
propertyName,
js: !!options.js,
cliCommand: "nx",
strict: void 0,
tmpl: "",
offsetFromRoot: _devkit.offsetFromRoot.call(void 0, options.projectRoot),
buildable: options.bundler && options.bundler !== "none",
hasUnitTestRunner: options.unitTestRunner !== "none"
});
await typeScriptLibraryGeneratorFn(tree, tsLibraryGeneratorOptions, config);
await _devkit.formatFiles.call(void 0, tree);
return null;
}
var generator_default4 = withRunGenerator(
"TypeScript Library Creator (NodeJs Platform)",
nodeLibraryGeneratorFn,
{
hooks: {
applyDefaultOptions: (options) => {
options.description ??= "A library used by Storm Software to support NodeJs applications";
options.platform ??= "node";
return options;
}
}
}
);
// ../workspace-tools/src/generators/preset/generator.ts
async function presetGeneratorFn(tree, options) {
const projectRoot = ".";
options.description ??= `\u26A1The ${options.namespace ? options.namespace : options.name} monorepo contains utility applications, tools, and various libraries to create modern and scalable web applications.`;
options.namespace ??= options.organization;
_devkit.addProjectConfiguration.call(void 0, tree, `@${options.namespace}/${options.name}`, {
root: projectRoot,
projectType: "application",
targets: {
"local-registry": {
executor: "@nx/js:verdaccio",
options: {
port: 4873,
config: ".verdaccio/config.yml",
storage: "tmp/local-registry/storage"
}
}
}
});
_devkit.updateJson.call(void 0, tree, "package.json", (json) => {
json.scripts = json.scripts || {};
json.version = "0.0.0";
json.triggerEmptyDevReleaseByIncrementingThisNumber = 0;
json.private = true;
json.keywords ??= [
options.name,
options.namespace,
"storm",
"storm-stack",
"storm-ops",
"rust",
"nx",
"graphql",
"sullivanpj",
"monorepo"
];
json.homepage ??= "https://stormsoftware.com";
json.bugs ??= {
url: `https://github.com/${options.organization}/${options.name}/issues`,
email: "support@stormsoftware.com"
};
json.license = "Apache-2.0";
json.author ??= {
name: "Storm Software",
email: "contact@stormsoftware.com",
url: "https://stormsoftware.com"
};
json.maintainers ??= [
{
name: "Storm Software",
email: "contact@stormsoftware.com",
url: "https://stormsoftware.com"
},
{
name: "Pat Sullivan",
email: "admin@stormsoftware.com",
url: "https://patsullivan.org"
}
];
json.funding ??= {
type: "github",
url: "https://github.com/sponsors/storm-software"
};
json.namespace ??= `@${options.namespace}`;
json.description ??= options.description;
options.repositoryUrl ??= `https://github.com/${options.organization}/${options.name}`;
json.repository ??= {
type: "github",
url: `${options.repositoryUrl}.git`
};
json.packageManager ??= "pnpm@10.3.0";
json.engines ??= {
node: ">=20.11.0",
pnpm: ">=10.3.0"
};
json.prettier = "@storm-software/prettier/config.json";
json.nx ??= {
includedScripts: [
"lint-sherif",
"lint-knip",
"lint-ls",
"lint",
"format",
"format-sherif",
"format-readme",
"format-prettier",
"format-toml",
"commit",
"release"
]
};
json.scripts.adr = "pnpm log4brains adr new";
json.scripts["adr-preview"] = "pnpm log4brains preview";
json.scripts.prepare = "pnpm add lefthook -w && pnpm lefthook install";
json.scripts.preinstall = "npx -y only-allow pnpm";
json.scripts["install-csb"] = "corepack enable && pnpm install --no-frozen-lockfile";
json.scripts.clean = "rimraf dist && rimraf --glob packages/**/dist && rimraf --glob tools/**/dist && rimraf --glob docs/**/dist && rimraf --glob apps/**/dist && rimraf --glob libs/**/dist";
json.scripts.nuke = "nx clear-cache && rimraf .nx/cache && rimraf .nx/workspace-data && pnpm clean && rimraf pnpm-lock.yaml && rimraf --glob packages/**/node_modules && rimraf --glob tools/**/node_modules && rimraf node_modules";
json.scripts.prebuild = "pnpm clean";
json.scripts.build = "nx affected -t build --parallel=5";
json.scripts["build-all"] = "nx run-many -t build --all --parallel=5";
json.scripts["build-prod"] = "nx run-many -t build --all --prod --parallel=5";
json.scripts["build-tools"] = "nx run-many -t build --projects=tools/* --parallel=5";
json.scripts["build-docs"] = "nx run-many -t build --projects=docs/* --parallel=5";
if (!options.includeApps) {
json.scripts["build-packages"] = "nx run-many -t build --projects=packages/* --parallel=5";
} else {
json.scripts["build-apps"] = "nx run-many -t build --projects=apps/* --parallel=5";
json.scripts["build-libs"] = "nx run-many -t build --projects=libs/* --parallel=5";
json.scripts["build-storybook"] = "storybook build -s public";
}
json.scripts.nx = "nx";
json.scripts.graph = "nx graph";
json.scripts.lint = "pnpm storm-lint all --skip-cspell --skip-alex";
if (options.includeApps) {
json.scripts.start = "nx serve";
json.scripts.storybook = "pnpm storybook dev -p 6006";
}
json.scripts.help = "nx help";
json.scripts["dep-graph"] = "nx dep-graph";
json.scripts["local-registry"] = `nx local-registry @${options.namespace}/${options.name}`;
json.scripts.e2e = "nx e2e";
if (options.includeApps) {
json.scripts.test = "nx test && pnpm test-storybook";
json.scripts["test-storybook"] = "pnpm test-storybook";
} else {
json.scripts.test = "nx test";
}
json.scripts.lint = "pnpm storm-lint all --skip-cspell --skip-alex";
json.scripts.commit = "pnpm storm-git commit";
json.scripts["api-extractor"] = 'pnpm storm-docs api-extractor --outputPath="docs/api-reference" --clean';
json.scripts.release = "pnpm storm-git release";
json.scripts.format = "nx format:write";
json.scripts["format-sherif"] = "pnpm exec sherif -f -i typescript -i react -i react-dom";
json.scripts["format-toml"] = 'pnpm exec taplo format --config="./node_modules/@storm-software/linting-tools/taplo/config.toml" --cache-path="./node_modules/.cache/storm/taplo"';
json.scripts["format-readme"] = 'pnpm storm-git readme --templates="tools/readme-templates"';
json.scripts["format-prettier"] = "pnpm exec prettier --write --ignore-unknown --no-error-on-unmatched-pattern --cache && git update-index";
json.scripts.lint = "pnpm storm-lint all --skip-cspell";
json.scripts["lint-knip"] = "pnpm exec knip";
json.scripts["lint-sherif"] = "pnpm exec sherif -i typescript -i react -i react-dom";
json.scripts["lint-ls"] = 'pnpm exec ls-lint --config="./node_modules/@storm-software/linting-tools/ls-lint/ls-lint.yml"';
json.packageManager ??= `pnpm@${pnpmVersion}`;
json.engines = {
node: `>=${nodeVersion}`,
pnpm: `>=${pnpmVersion}`
};
return json;
});
_devkit.generateFiles.call(void 0, tree, path3.join(__dirname, "files"), projectRoot, {
...options,
pnpmVersion,
nodeVersion
});
await _devkit.formatFiles.call(void 0, tree);
let dependencies = {
"@ls-lint/ls-lint": "2.2.3",
"@ltd/j-toml": "1.38.0",
"@nx/devkit": "^20.2.2",
"@nx/eslint-plugin": "^20.2.2",
"@nx/js": "^20.2.2",
"@nx/workspace": "^20.2.2",
"@storm-software/config": "latest",
"@storm-software/git-tools": "latest",
"@storm-software/linting-tools": "latest",
"@storm-software/testing-tools": "latest",
"@storm-software/workspace-tools": "latest",
"@storm-software/eslint": "latest",
"@storm-software/cspell": "latest",
"@storm-software/prettier": "latest",
"@taplo/cli": "0.7.0",
"@types/node": "^20.14.10",
copyfiles: "2.4.1",
eslint: "9.5.0",
jest: "29.7.0",
"jest-environment-node": "29.7.0",
knip: "5.25.2",
lefthook: "1.6.18",
nx: "^20.2.2",
prettier: "3.3.2",
"prettier-plugin-prisma": "5.0.0",
rimraf: "5.0.7",
sherif: "0.10.0",
"ts-jest": "29.1.5",
"ts-node": "10.9.2",
tslib: "2.6.3",
typescript: "5.5.3",
verdaccio: "5.31.1"
};
if (options.includeApps) {
dependencies = {
...dependencies,
react: "latest",
"react-dom": "latest",
storybook: "latest",
"@storybook/addons": "latest",
"@nx/react": "latest",
"@nx/next": "latest",
"@nx/node": "latest",
"@nx/storybook": "latest",
"jest-environment-jsdom": "29.7.0"
};
}
if (options.includeRust) {
dependencies = {
...dependencies,
"@monodon/rust": "1.4.0"
};
}
if (options.nxCloud) {
dependencies = {
...dependencies,
"nx-cloud": "latest"
};
}
await Promise.resolve(
_devkit.addDependenciesToPackageJson.call(void 0,
tree,
dependencies,
{},
_devkit.joinPathFragments.call(void 0, projectRoot, "package.json")
)
);
return null;
}
var generator_default5 = withRunGenerator(
"Storm Workspace Preset Generator",
presetGeneratorFn
);
// ../workspace-tools/src/generators/release-version/generator.ts
var _resolvelocalpackagedependencies = require('@nx/js/src/generators/release-version/utils/resolve-local-package-dependencies');
var _updatelockfile = require('@nx/js/src/release/utils/update-lock-file');
// ../git-tools/src/types.ts
var COMMIT_TYPES = {
/* --- Bumps version when selected --- */
"chore": {
"description": "Other changes that don't modify src or test files",
"title": "Chore",
"emoji": "\u2699\uFE0F ",
"semverBump": "patch",
"changelog": {
"title": "Miscellaneous",
"hidden": false
}
},
"fix": {
"description": "A change that resolves an issue previously identified with the package",
"title": "Bug Fix",
"emoji": "\u{1FAB2} ",
"semverBump": "patch",
"changelog": {
"title": "Bug Fixes",
"hidden": false
}
},
"feat": {
"description": "A change that adds a new feature to the package",
"title": "Feature",
"emoji": "\u{1F511} ",
"semverBump": "minor",
"changelog": {
"title": "Features",
"hidden": false
}
},
"ci": {
"description": "Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)",
"title": "Continuous Integration",
"emoji": "\u{1F9F0} ",
"semverBump": "patch",
"changelog": {
"title": "Continuous Integration",
"hidden": false
}
},
"refactor": {
"description": "A code change that neither fixes a bug nor adds a feature",
"title": "Code Refactoring",
"emoji": "\u{1F9EA} ",
"semverBump": "patch",
"changelog": {
"title": "Source Code Improvements",
"hidden": false
}
},
"style": {
"description": "Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)",
"title": "Style Improvements",
"emoji": "\u{1F48E} ",
"semverBump": "patch",
"changelog": {
"title": "Style Improvements",
"hidden": false
}
},
"perf": {
"description": "A code change that improves performance",
"title": "Performance Improvement",
"emoji": "\u23F1\uFE0F ",
"semverBump": "patch",
"changelog": {
"title": "Performance Improvements",
"hidden": false
}
},
/* --- Does not bump version when selected --- */
"docs": {
"description": "A change that only includes documentation updates",
"title": "Documentation",
"emoji": "\u{1F4DC} ",
"semverBump": "none",
"changelog": {
"title": "Documentation",
"hidden": false
}
},
"test": {
"description": "Adding missing tests or correcting existing tests",
"title": "Testing",
"emoji": "\u{1F6A8} ",
"semverBump": "none",
"changelog": {
"title": "Testing",
"hidden": true
}
},
/* --- Not included in commitlint but included in changelog --- */
"deps": {
"description": "Changes that add, update, or remove dependencies. This includes devDependencies and peerDependencies",
"title": "Dependencies",
"emoji": "\u{1F4E6} ",
"hidden": true,
"semverBump": "patch",
"changelog": {
"title": "Dependency Upgrades",
"hidden": false
}
},
/* --- Not included in commitlint or changelog --- */
"build": {
"description": "Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)",
"title": "Build",
"emoji": "\u{1F6E0} ",
"hidden": true,
"semverBump": "none",
"changelog": {
"title": "Build",
"hidden": true
}
},
"release": {
"description": "Publishing a commit containing a newly released version",
"title": "Publish Release",
"emoji": "\u{1F680} ",
"hidden": true,
"semverBump": "none",
"changelog": {
"title": "Publish Release",
"hidden": true
}
}
};
var DEFAULT_COMMIT_QUESTIONS = {
type: {
type: "select",
title: "Commit Type",
description: "Select the commit type that best describes your changes",
enum: Object.keys(COMMIT_TYPES).filter(
(type) => COMMIT_TYPES[type].hidden !== true
).reduce((ret, type) => {
ret[type] = COMMIT_TYPES[type];
return ret;
}, {}),
defaultValue: "chore",
maxLength: 20,
minLength: 3
},
scope: {
type: "select",
title: "Commit Scope",
description: "Select the monorepo project that is primarily impacted by this change",
enum: {},
defaultValue: "monorepo",
maxLength: 50,
minLength: 1
},
subject: {
type: "input",
title: "Commit Subject",
description: "Write a short, imperative tense description of the change",
maxLength: 150,
minLength: 3
},
body: {
type: "input",
title: "Commit Body",
description: "Provide a longer description of the change",
maxLength: 600
},
isBreaking: {
type: "confirm",
title: "Breaking Changes",
description: "Are there any breaking changes as a result of this commit?",
defaultValue: false
},
breakingBody: {
type: "input",
title: "Breaking Changes (Details)",
description: "A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself",
when: (answers) => answers.isBreaking === true,
maxLength: 600,
minLength: 3
},
isIssueAffected: {
type: "confirm",
title: "Open Issue Affected",
description: "Does this change impact any open issues?",
defaultValue: false
},
issuesBody: {
type: "input",
title: "Open Issue Affected (Details)",
description: "If issues are closed, the commit requires a body. Please enter a longer description of the commit itself",
when: (answers) => answers.isIssueAffected === true,
maxLength: 600,
minLength: 3
}
};
// ../workspace-tools/src/generators/release-version/generator.ts
var _config = require('nx/src/command-line/release/config/config');
var _git = require('nx/src/command-line/release/utils/git');
var _resolvesemverspecifier = require('nx/src/command-line/release/utils/resolve-semver-specifier');
var _semver = require('nx/src/command-line/release/utils/semver');
var _versionlegacy = require('nx/src/command-line/release/version-legacy');
var _utils = require('nx/src/tasks-runner/utils');
var _semver3 = require('semver');
// ../workspace-tools/src/base/base-executor.untyped.ts
var _untyped = require('untyped');
var base_executor_untyped_default = _untyped.defineUntypedSchema.call(void 0, {
$schema: {
id: "baseExecutor",
title: "Base Executor",
description: "A base type definition for an executor schema"
},
outputPath: {
$schema: {
title: "Output Path",
type: "string",
format: "path",
description: "The output path for the build"
},
$default: "dist/{projectRoot}"
}
});
// ../workspace-tools/src/base/base-generator.untyped.ts
var base_generator_untyped_default = _untyped.defineUntypedSchema.call(void 0, {
$schema: {
id: "BaseGeneratorSchema",
title: "Base Generator",
description: "A type definition for the base Generator schema"
},
directory: {
$schema: {
title: "Directory",
type: "string",
description: "The directory to create the library in"
}
}
});
// ../workspace-tools/src/base/cargo-base-executor.untyped.ts
var cargo_base_executor_untyped_default = _untyped.defineUntypedSchema.call(void 0, {
...base_executor_untyped_default,
$schema: {
id: "cargoBaseExecutor",
title: "Cargo Base Executor",
description: "A base type definition for a Cargo/rust related executor schema"
},
package: {
$schema: {
title: "Cargo.toml Path",
type: "string",
format: "path",
description: "The path to the Cargo.toml file"
},
$default: "{projectRoot}/Cargo.toml"
},
toolchain: {
$schema: {
title: "Toolchain",
description: "The type of toolchain to use for the build",
enum: ["stable", "beta", "nightly"],
default: "stable"
},
$default: "stable"
},
target: {
$schema: {
title: "Target",
type: "string",
description: "The target to build"
}
},
allTargets: {
$schema: {
title: "All Targets",
type: "boolean",
description: "Build all targets"
}
},
profile: {
$schema: {
title: "Profile",
type: "string",
description: "The profile to build"
}
},
release: {
$schema: {
title: "Release",
type: "boolean",
description: "Build in release mode"
}
},
features: {
$schema: {
title: "Features",
type: "string",
description: "The features to build",
oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }]
}
},
allFeatures: {
$schema: {
title: "All Features",
type: "boolean",
description: "Build all features"
}
}
});
// ../workspace-tools/src/base/typescript-build-executor.untyped.ts
var typescript_build_executor_untyped_default = _untyped.defineUntypedSchema.call(void 0, {
...base_executor_untyped_default,
$schema: {
id: "TypeScriptBuildExecutorSchema",
title: "TypeScript Build Executor",
description: "A type definition for the base TypeScript build executor schema",
required: ["entry", "tsconfig"]
},
entry: {
$schema: {
title: "Entry File(s)",
format: "path",
type: "array",
description: "The entry file or files to build",
items: { type: "string" }
},
$default: ["{sourceRoot}/index.ts"]
},
tsconfig: {
$schema: {
title: "TSConfig Path",
type: "string",
format: "path",
description: "The path to the tsconfig file"
},
$default: "{projectRoot}/tsconfig.json"
},
bundle: {
$schema: {
title: "Bundle",
type: "boolean",
description: "Bundle the output"
}
},
minify: {
$schema: {
title: "Minify",
type: "boolean",
description: "Minify the output"
}
},
debug: {
$schema: {
title: "Debug",
type: "boolean",
description: "Debug the output"
}
},
sourcemap: {
$schema: {
title: "Sourcemap",
type: "boolean",
description: "Generate a sourcemap"
}
},
silent: {
$schema: {
title: "Silent",
type: "boolean",
description: "Should the build run silently - only report errors back to the user"
},
$default: false
},
target: {
$schema: {
title: "Target",
type: "string",
description: "The target to build",
enum: [
"es3",
"es5",
"es6",
"es2015",
"es2016",
"es2017",
"es2018",
"es2019",
"es2020",
"es2021",
"es2022",
"es2023",
"es2024",
"esnext",
"node12",
"node14",
"node16",
"node18",
"node20",
"node22",
"browser",
"chrome58",
"chrome59",
"chrome60"
]
},
$default: "esnext",
$resolve: (val = "esnext") => typeof val === "string" ? val.toLowerCase() : val
},
format: {
$schema: {
title: "Format",
type: "array",
description: "The format to build",
items: {
type: "string",
enum: ["cjs", "esm", "iife"]
}
},
$resolve: (val = ["cjs", "esm"]) => [].concat(val)
},
platform: {
$schema: {
title: "Platform",
type: "string",
description: "The platform to build",
enum: ["neutral", "node", "browser"]
},
$default: "neutral"
},
external: {
$schema: {
title: "External",
type: "array",
description: "The external dependencies"
},
$resolve: (val = []) => [].concat(val)
},
define: {
$schema: {
title: "Define",
type: "object",
tsType: "Record<string, string>",
description: "The define values"
},
$resolve: (val = {}) => val,
$default: {}
},
env: {
$schema: {
title: "Environment Variables",
type: "object",
tsType: "Record<string, string>",
description: "The environment variable values"
},
$resolve: (val = {}) => val,
$default: {}
}
});
// ../workspace-tools/src/base/typescript-library-generator.untyped.ts
var typescript_library_generator_untyped_default = _untyped.defineUntypedSchema.call(void 0, {
...base_generator_untyped_default,
$schema: {
id: "TypeScriptLibraryGeneratorSchema",
title: "TypeScript Library Generator",
description: "A type definition for the base TypeScript Library Generator schema",
required: ["directory", "name"]
},
name: {
$schema: {
title: "Name",
type: "string",
description: "The name of the library"
}
},
description: {
$schema: {
title: "Description",
type: "string",
description: "The description of the library"
}
},
buildExecutor: {
$schema: {
title: "Build Executor",
type: "string",
description: "The executor to use for building the library"
},
$default: "@storm-software/workspace-tools:unbuild"
},
platform: {
$schema: {
title: "Platform",
type: "string",
description: "The platform to target with the library",
enum: ["neutral", "node", "worker", "browser"]
},
$default: "neutral"
},
importPath: {
$schema: {
title: "Import Path",
type: "string",
description: "The import path for the library"
}
},
tags: {
$schema: {
title: "Tags",
type: "string",
description: "The tags for the library"
}
},
unitTestRunner: {
$schema: {
title: "Unit Test Runner",
type: "string",
enum: ["jest", "vitest", "none"],
description: "The unit test runner to use"
}
},
testEnvironment: {
$schema: {
title: "Test Environment",
type: "string",
enum: ["jsdom", "node"],
description: "The test environment to use"
}
},
pascalCaseFiles: {
$schema: {
title: "Pascal Case Files",
type: "boolean",
description: "Use PascalCase for file names"
},
$default: false
},
strict: {
$schema: {
title: "Strict",
type: "boolean",
description: "Enable strict mode"
},
$default: true
},
publishable: {
$schema: {
title: "Publishable",
type: "boolean",
description: "Make the library publishable"
},
$default: false
},
buildable: {
$schema: {
title: "Buildable",
type: "boolean",
description: "Make the library buildable"
},
$default: true
}
});
// ../workspace-tools/src/utils/create-cli-options.ts
// ../workspace-tools/src/utils/get-project-configurations.ts
var _retrieveworkspacefiles = require('nx/src/project-graph/utils/retrieve-workspace-files');
// ../workspace-tools/src/utils/lock-file.ts
var _npmparser = require('nx/src/plugins/js/lock-file/npm-parser');
var _pnpmparser = require('nx/src/plugins/js/lock-file/pnpm-parser');
var _yarnparser = require('nx/src/plugins/js/lock-file/yarn-parser');
var YARN_LOCK_FILE = "yarn.lock";
var NPM_LOCK_FILE = "package-lock.json";
var PNPM_LOCK_FILE = "pnpm-lock.yaml";
var YARN_LOCK_PATH = _path.join.call(void 0, _devkit.workspaceRoot, YARN_LOCK_FILE);
var NPM_LOCK_PATH = _path.join.call(void 0, _devkit.workspaceRoot, NPM_LOCK_FILE);
var PNPM_LOCK_PATH = _path.join.call(void 0, _devkit.workspaceRoot, PNPM_LOCK_FILE);
// ../workspace-tools/src/utils/plugin-helpers.ts
// ../workspace-tools/src/utils/typia-transform.ts
var _transform = require('typia/lib/transform'); var _transform2 = _interopRequireDefault(_transform);
// src/generators/init/init.ts
async function initGenerator2(tree, schema) {
const task = initGenerator(tree, { skipFormat: !!schema.skipFormat });
if (!schema.skipFormat) {
await _devkit.formatFiles.call(void 0, tree);
}
return task;
}
var init_default = initGenerator2;
exports.initGenerator = initGenerator2; exports.init_default = init_default;