@storm-software/workspace-tools
Version:
Tools for managing a Storm workspace, including various Nx generators and executors for common development tasks.
106 lines (103 loc) • 2.57 kB
JavaScript
import {
normalizeOptions,
typeScriptLibraryGeneratorFn
} from "./chunk-M3YWCYUX.mjs";
import {
withRunGenerator
} from "./chunk-C76K2E2A.mjs";
import {
joinPaths
} from "./chunk-TBW5MCN6.mjs";
import {
__dirname
} from "./chunk-3YDFOWNH.mjs";
// src/generators/browser-library/generator.ts
import {
formatFiles,
generateFiles,
names,
offsetFromRoot
} from "@nx/devkit";
async function browserLibraryGeneratorFn(tree, schema, config) {
const filesDir = joinPaths(
__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 } = names(
options.projectNames.projectFileName
);
generateFiles(tree, filesDir, options.projectRoot, {
...schema,
dot: ".",
className,
name,
namespace: process.env.STORM_NAMESPACE ?? "storm-software",
description: schema.description ?? "",
propertyName,
js: !!options.js,
cliCommand: "nx",
strict: void 0,
tmpl: "",
offsetFromRoot: offsetFromRoot(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 formatFiles(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;
}
}
}
);
export {
browserLibraryGeneratorFn,
generator_default
};