@storm-stack/core
Version:
A build toolkit and runtime used by Storm Software in TypeScript applications
1 lines โข 26.6 kB
Source Map (JSON)
{"version":3,"sources":["../../src/base/engine.ts"],"names":["Engine","context","inlineConfig","workspaceConfig","init","createHooks","createContext","defu","log","LogLevelLabel","TRACE","plugin","options","userConfig","plugins","addPlugin","length","WARN","addHooks","INFO","new","command","_new","clean","prepare","lint","persistedMeta","checksum","meta","build","getPersistedMeta","getChecksum","projectRoot","docs","finalize","config","instance","initPlugin","dependencies","dependency","DEBUG","chalk","bold","cyanBright","name","push","pluginConfig","installPath","startsWith","split","filter","Boolean","splits","isInstalled","isPackageExists","paths","workspaceRoot","skipInstalls","result","install","cwd","isNumber","exitCode","ERROR","stderr","Error","pluginInstance","module","resolver","import","esmResolve","PluginConstructor","default","error","isError","message","String","identifier","isSetObject","camelCase","duplicatePlugin","find","isSame"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DO,IAAMA,SAAN,MAAMA;EA7Db;;;;;EA8DE,YAAA,GAAe,KAAA;;;;AAKf,EAAA,MAAA;;;;AAKA,EAAA,QAAA,GAAqB,EAAA;;;;;;;;AAUXC,EAAAA,OAAAA;;;;;;;AAQV,EAAA,WAAA,CACUC,cACAC,eAAAA,EACR;SAFQD,YAAAA,GAAAA,YAAAA;SACAC,eAAAA,GAAAA,eAAAA;AACP,EAAA;;;;AAKH,EAAA,MAAaC,KAAKF,YAAAA,EAA8C;AAC9D,IAAA,IAAA,CAAK,SAASG,oBAAAA,EAAAA;AACd,IAAA,IAAA,CAAKJ,OAAAA,GAAU,MAAMK,+BAAAA,CACnBC,qBAAAA,CAAKL,cAAc,IAAA,CAAKA,YAAY,CAAA,EACpC,IAAA,CAAKC,eAAe,CAAA;AAGtB,IAAA,IAAA,CAAKF,OAAAA,CAAQO,GAAAA,CAAIC,mBAAAA,CAAcC,KAAAA,EAAO,iCAAA,CAAA;AAEtC,IAAA,KAAA,MAAWC,UAAU,IAAA,CAAKV,OAAAA,CAAQW,QA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IAAA,IAAIc,eAAAA,EAAiB;AACnB,MAAA,IAAA,CAAK/E,OAAAA,CAAQO,GAAAA,CACXC,mBAAAA,CAAcC,KAAAA,EACd,CAAA,UAAA,EAAa+B,sBAAAA,CAAMC,IAAAA,CAAKC,UAAAA,CAAWqC,eAAAA,CAAgBH,UAAU,CAAA,CAAA,sDAAA,CAAyD,CAAA;AAGxHG,MAAAA,eAAAA,CAAgBpE,OAAAA,GAAUL,qBAAAA,CACxByE,eAAAA,CAAgBpE,OAAAA,IAAW,EAAC,EAC5B,IAAA,CAAKX,OAAAA,CAAQW,OAAAA,CAAQE,OAAAA,CAAQoD,cAAAA,CAAeW,UAAU,CAAC,CAAA;AAEzD,MAAA,IAAA,CAAK5E,QAAQW,OAAAA,CAAQE,OAAAA,CAAQkE,eAAAA,CAAgBH,UAAU,IACrDG,eAAAA,CAAgBpE,OAAAA;AAElB,MAAA,OAAO,IAAA;AACT,IAAA;AAEA,IAAA,IAAA,CAAKX,OAAAA,CAAQO,GAAAA,CACXC,mBAAAA,CAAcC,KAAAA,EACd,CAAA,iBAAA,EAAoB+B,sBAAAA,CAAMC,IAAAA,CAAKC,UAAAA,CAAWuB,cAAAA,CAAetB,IAAI,CAAA,CAAA,UAAA,CAAa,CAAA;AAG5E,IAAA,OAAOsB,cAAAA;AACT,EAAA;AACF","file":"chunk-BLQS5HQJ.cjs","sourcesContent":["/* -------------------------------------------------------------------\n\n โก Storm Software - Storm Stack\n\n This code was released as part of the Storm Stack project. Storm Stack\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/storm-stack.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/storm-stack\n Documentation: https://docs.stormsoftware.com/projects/storm-stack\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { install } from \"@stryke/fs/install\";\nimport { isPackageExists } from \"@stryke/fs/package-fns\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isError } from \"@stryke/type-checks/is-error\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport chalk from \"chalk\";\nimport defu from \"defu\";\nimport { createHooks } from \"hookable\";\nimport { build } from \"../commands/build\";\nimport { clean } from \"../commands/clean\";\nimport { docs } from \"../commands/docs\";\nimport { finalize } from \"../commands/finalize\";\nimport { init } from \"../commands/init\";\nimport { lint } from \"../commands/lint\";\nimport { _new } from \"../commands/new\";\nimport { prepare } from \"../commands/prepare\";\nimport { createContext, getChecksum, getPersistedMeta } from \"../lib/context\";\nimport type {\n BuildInlineConfig,\n CleanInlineConfig,\n Context,\n DocsInlineConfig,\n EngineHookFunctions,\n EngineHooks,\n InlineConfig,\n LintInlineConfig,\n NewInlineConfig,\n PrepareInlineConfig,\n WorkspaceConfig\n} from \"../types\";\nimport { PluginConfig } from \"../types/config\";\nimport type { Plugin } from \"./plugin\";\n\n/**\n * The Storm Stack Engine class\n *\n * @remarks\n * This class is responsible for managing the Storm Stack project lifecycle, including initialization, building, and finalization.\n *\n * @public\n */\nexport class Engine {\n #initialized = false;\n\n /**\n * The engine hooks - these allow the plugins to hook into the engines processing\n */\n #hooks!: EngineHooks;\n\n /**\n * The plugins provided in the options\n */\n #plugins: Plugin[] = [];\n\n /**\n * The options provided to Storm Stack\n */\n // protected options: TOptions;\n\n /**\n * The resolved options provided to Storm Stack\n */\n protected context!: Context;\n\n /**\n * Create a new Storm Stack Engine instance\n *\n * @param inlineConfig - The inline configuration for the Storm Stack engine\n * @param workspaceConfig - The workspace configuration for the Storm Stack engine\n */\n public constructor(\n private inlineConfig: InlineConfig,\n private workspaceConfig?: WorkspaceConfig\n ) {}\n\n /**\n * Initialize the engine\n */\n public async init(inlineConfig: InlineConfig): Promise<Context> {\n this.#hooks = createHooks<EngineHookFunctions>();\n this.context = await createContext(\n defu(inlineConfig, this.inlineConfig),\n this.workspaceConfig\n );\n\n this.context.log(LogLevelLabel.TRACE, \"Initializing Storm Stack engine\");\n\n for (const plugin of this.context.options.userConfig.plugins ?? []) {\n await this.addPlugin(plugin);\n }\n\n if (this.#plugins.length === 0) {\n this.context.log(\n LogLevelLabel.WARN,\n \"No Storm Stack plugins or presets were specified in the options. Please ensure this is correct, as it is generally not recommended.\"\n );\n } else {\n for (const plugin of this.#plugins) {\n plugin.addHooks(this.#hooks);\n }\n }\n\n await init(this.context, this.#hooks);\n\n this.context.log(\n LogLevelLabel.INFO,\n \"Storm Stack engine has been initialized\"\n );\n this.#initialized = true;\n\n return this.context;\n }\n\n /**\n * Create a new Storm Stack project\n *\n * @remarks\n * This method will create a new Storm Stack project in the current directory.\n *\n * @param inlineConfig - The inline configuration for the new command\n * @returns A promise that resolves when the project has been created\n */\n public async new(inlineConfig: NewInlineConfig = { command: \"new\" }) {\n if (!this.#initialized) {\n await this.init(inlineConfig);\n }\n\n this.context.log(\n LogLevelLabel.INFO,\n \"๐ Creating a new Storm Stack project\"\n );\n\n await _new(this.context, this.#hooks);\n\n this.context.log(\n LogLevelLabel.TRACE,\n \"Storm Stack - New command completed\"\n );\n }\n\n /**\n * Clean any previously prepared artifacts\n *\n * @remarks\n * This method will remove the previous Storm Stack artifacts from the project.\n *\n * @param inlineConfig - The inline configuration for the clean command\n * @returns A promise that resolves when the clean command has completed\n */\n public async clean(\n inlineConfig: CleanInlineConfig | PrepareInlineConfig = { command: \"clean\" }\n ) {\n if (!this.#initialized) {\n await this.init(inlineConfig);\n }\n\n this.context.log(\n LogLevelLabel.INFO,\n \"๐งน Cleaning the previous Storm Stack artifacts\"\n );\n\n await clean(this.context, this.#hooks);\n\n this.context.log(\n LogLevelLabel.TRACE,\n \"Storm Stack - Clean command completed\"\n );\n }\n\n /**\n * Prepare the Storm Stack project prior to building\n *\n * @remarks\n * This method will create the necessary directories, and write the artifacts files to the project.\n *\n * @param inlineConfig - The inline configuration for the prepare command\n * @returns A promise that resolves when the prepare command has completed\n */\n public async prepare(\n inlineConfig:\n | PrepareInlineConfig\n | LintInlineConfig\n | BuildInlineConfig\n | DocsInlineConfig = {\n command: \"prepare\"\n }\n ) {\n if (!this.#initialized) {\n await this.init(inlineConfig);\n }\n\n // if (\n // existsSync(this.context.artifactsPath) &&\n // inlineConfig.command !== \"lint\" &&\n // inlineConfig.clean\n // ) {\n // await this.clean(inlineConfig as PrepareInlineConfig);\n // }\n\n this.context.log(LogLevelLabel.INFO, \"Preparing the Storm Stack project\");\n\n await prepare(this.context, this.#hooks);\n\n this.context.log(LogLevelLabel.TRACE, \"Storm Stack preparation completed\");\n }\n\n /**\n * Lint the project\n *\n * @param inlineConfig - The inline configuration for the lint command\n * @returns A promise that resolves when the lint command has completed\n */\n public async lint(\n inlineConfig: LintInlineConfig | BuildInlineConfig = { command: \"lint\" }\n ) {\n if (!this.#initialized) {\n await this.init(inlineConfig);\n }\n\n if (this.context.persistedMeta?.checksum !== this.context.meta.checksum) {\n this.context.log(\n LogLevelLabel.INFO,\n \"The Storm Stack project has been modified since the last time `prepare` was ran. Re-preparing the project.\"\n );\n\n await this.prepare(inlineConfig);\n }\n\n this.context.log(LogLevelLabel.INFO, \"Linting the Storm Stack project\");\n\n await lint(this.context, this.#hooks);\n\n this.context.log(LogLevelLabel.TRACE, \"Storm Stack linting completed\");\n }\n\n /**\n * Build the project\n *\n * @remarks\n * This method will build the Storm Stack project, generating the necessary artifacts.\n *\n * @param inlineConfig - The inline configuration for the build command\n * @returns A promise that resolves when the build command has completed\n */\n public async build(inlineConfig: BuildInlineConfig = { command: \"build\" }) {\n if (!this.#initialized) {\n await this.init(inlineConfig);\n }\n\n const persistedMeta = await getPersistedMeta(this.context);\n const checksum = await getChecksum(this.context.options.projectRoot);\n\n if (persistedMeta?.checksum !== checksum) {\n this.context.log(\n LogLevelLabel.INFO,\n \"The Storm Stack project has been modified since the last time `prepare` was ran. Re-preparing the project.\"\n );\n\n await this.prepare(inlineConfig);\n }\n\n this.context.log(LogLevelLabel.INFO, \"Building the Storm Stack project\");\n\n await build(this.context, this.#hooks);\n\n this.context.log(LogLevelLabel.TRACE, \"Storm Stack build completed\");\n }\n\n /**\n * Generate the documentation for the project\n *\n * @param inlineConfig - The inline configuration for the docs command\n * @returns A promise that resolves when the documentation generation has completed\n */\n public async docs(inlineConfig: DocsInlineConfig = { command: \"docs\" }) {\n if (!this.#initialized) {\n await this.init(inlineConfig);\n }\n\n if (this.context.persistedMeta?.checksum !== this.context.meta.checksum) {\n this.context.log(\n LogLevelLabel.INFO,\n \"The Storm Stack project has been modified since the last time `prepare` was ran. Re-preparing the project.\"\n );\n\n await this.prepare(inlineConfig);\n }\n\n this.context.log(\n LogLevelLabel.INFO,\n \"Generating documentation for the Storm Stack project\"\n );\n\n await docs(this.context, this.#hooks);\n\n this.context.log(\n LogLevelLabel.TRACE,\n \"Storm Stack documentation generation completed\"\n );\n }\n\n /**\n * Finalization process\n *\n * @remarks\n * This step includes any final processes or clean up required by Storm Stack. It will be run after each Storm Stack command.\n *\n * @param inlineConfig - The inline configuration for the Storm Stack engine\n * @returns A promise that resolves when the finalization process has completed\n */\n public async finalize(inlineConfig: InlineConfig) {\n if (!this.#initialized) {\n await this.init(inlineConfig);\n }\n\n this.context.log(\n LogLevelLabel.TRACE,\n \"Storm Stack finalize execution started\"\n );\n\n await finalize(this.context, this.#hooks);\n\n this.context.log(\n LogLevelLabel.TRACE,\n \"Storm Stack finalize execution completed\"\n );\n }\n\n /**\n * Add a Storm Stack plugin used in the build process\n *\n * @param config - The import path of the plugin to add\n */\n private async addPlugin(config: string | PluginConfig) {\n if (config) {\n const instance = await this.initPlugin(config);\n if (!instance) {\n return;\n }\n\n if (instance.dependencies) {\n for (const dependency of instance.dependencies) {\n await this.addPlugin(dependency);\n }\n }\n\n this.context.log(\n LogLevelLabel.DEBUG,\n `Successfully initialized the ${chalk.bold.cyanBright(instance.name)} plugin`\n );\n\n this.#plugins.push(instance);\n }\n }\n\n /**\n * Initialize a Storm Stack plugin\n *\n * @param plugin - The import path of the plugin to add\n */\n private async initPlugin(\n plugin: string | PluginConfig\n ): Promise<Plugin | null> {\n const pluginConfig: PluginConfig =\n typeof plugin === \"string\" ? [plugin, {}] : plugin;\n\n let installPath = pluginConfig[0];\n if (\n installPath.startsWith(\"@\") &&\n installPath.split(\"/\").filter(Boolean).length > 2\n ) {\n const splits = installPath.split(\"/\").filter(Boolean);\n installPath = `${splits[0]}/${splits[1]}`;\n }\n\n const isInstalled = isPackageExists(installPath, {\n paths: [\n this.context.options.workspaceConfig.workspaceRoot,\n this.context.options.projectRoot\n ]\n });\n if (!isInstalled && this.context.options.skipInstalls !== true) {\n this.context.log(\n LogLevelLabel.WARN,\n `The plugin package \"${installPath}\" is not installed. It will be installed automatically.`\n );\n\n const result = await install(installPath, {\n cwd: this.context.options.projectRoot\n });\n if (isNumber(result.exitCode) && result.exitCode > 0) {\n this.context.log(LogLevelLabel.ERROR, result.stderr);\n throw new Error(\n `An error occurred while installing the build plugin package \"${installPath}\" `\n );\n }\n }\n\n let pluginInstance!: Plugin;\n try {\n const module = await this.context.resolver.import<{\n default: new (config: any) => Plugin;\n }>(this.context.resolver.esmResolve(pluginConfig[0]));\n\n const PluginConstructor = module.default;\n pluginInstance = new PluginConstructor({\n ...(pluginConfig[1] ?? {}),\n log: this.context.log\n });\n } catch (error) {\n if (!isInstalled) {\n throw new Error(\n `The plugin package \"${pluginConfig[0]}\" is not installed. Please install the package using the command: \"npm install ${pluginConfig[0]} --save-dev\"`\n );\n } else {\n throw new Error(\n `An error occurred while importing the build plugin package \"${pluginConfig[0]}\":\n${isError(error) ? error.message : String(error)}\n\nNote: Please ensure the plugin package's default export is a class that extends \\`Plugin\\` with a constructor that excepts a single arguments of type \\`PluginOptions\\`.`\n );\n }\n }\n\n if (!pluginInstance) {\n throw new Error(\n `The plugin package \"${pluginConfig[0]}\" does not export a valid module.`\n );\n }\n\n if (!pluginInstance.name) {\n throw new Error(\n `The module in the build plugin package \"${pluginConfig[0]}\" must export a \\`name\\` string value.`\n );\n }\n\n if (!pluginInstance.identifier) {\n throw new Error(\n `The module in the build plugin package \"${pluginConfig[0]}\" must export a \\`identifier\\` string value.`\n );\n }\n\n if (!pluginInstance.addHooks) {\n throw new Error(\n `The module in the build plugin package \"${pluginConfig[0]}\" must export a \\`addHooks\\` function value.`\n );\n }\n\n pluginInstance.options ??= pluginConfig[1] ?? {};\n\n this.context.options.plugins[pluginInstance.identifier] = defu(\n pluginInstance.options ?? {},\n isSetObject(this.context.options.plugins[pluginInstance.identifier])\n ? this.context.options.plugins[pluginInstance.identifier]\n : {},\n camelCase(pluginInstance.name) !== camelCase(pluginInstance.identifier) &&\n isSetObject(this.context.options.plugins[pluginInstance.name])\n ? this.context.options.plugins[pluginInstance.name]\n : {}\n );\n pluginInstance.options =\n this.context.options.plugins[pluginInstance.identifier];\n\n const duplicatePlugin = this.#plugins.find(plugin =>\n plugin.isSame(pluginInstance)\n );\n if (duplicatePlugin) {\n this.context.log(\n LogLevelLabel.TRACE,\n `Duplicate ${chalk.bold.cyanBright(duplicatePlugin.identifier)} plugin dependency detected - Skipping initialization.`\n );\n\n duplicatePlugin.options = defu(\n duplicatePlugin.options ?? {},\n this.context.options.plugins[pluginInstance.identifier]\n );\n this.context.options.plugins[duplicatePlugin.identifier] =\n duplicatePlugin.options;\n\n return null;\n }\n\n this.context.log(\n LogLevelLabel.TRACE,\n `Initializing the ${chalk.bold.cyanBright(pluginInstance.name)} plugin...`\n );\n\n return pluginInstance;\n }\n}\n"]}