UNPKG

@storm-software/workspace-tools

Version:

Tools for managing a Storm workspace, including various Nx generators and executors for common development tasks.

91 lines (88 loc) 2.63 kB
import { normalizeOptions, typeScriptLibraryGeneratorFn } from "./chunk-YZLAY7R4.mjs"; import { withRunGenerator } from "./chunk-4LIIIWIV.mjs"; import { joinPaths } from "./chunk-ATIBREWM.mjs"; import { __dirname, __name } from "./chunk-2BPV2XV2.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; } __name(browserLibraryGeneratorFn, "browserLibraryGeneratorFn"); var generator_default = withRunGenerator("TypeScript Library Creator (Browser Platform)", browserLibraryGeneratorFn, { hooks: { applyDefaultOptions: /* @__PURE__ */ __name((options) => { options.description ??= "A library used by Storm Software to support browser applications"; options.platform ??= "browser"; return options; }, "applyDefaultOptions") } }); export { browserLibraryGeneratorFn, generator_default };