UNPKG

@storm-stack/core

Version:

A build toolkit and runtime used by Storm Software in TypeScript applications

1 lines 12.7 kB
{"version":3,"sources":["../../src/commands/new/application/index.ts","../../src/commands/new/library/index.ts","../../src/commands/new/index.ts"],"names":["newApplication","context","hooks","log","LogLevelLabel","TRACE","packagePath","resolvePackage","Error","files","listFiles","joinPaths","file","template","compile","writeFile","options","projectRoot","replace","callHook","catch","error","ERROR","message","stack","cause","newLibrary","Handlebars","_new","projectType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,eAAsBA,cAAAA,CAAeC,SAAkBC,KAAAA,EAAkB;AACvED,EAAAA,OAAAA,CAAQE,GAAAA,CACNC,mBAAAA,CAAcC,KAAAA,EACd,CAAA,6CAAA,CAA+C,CAAA;AAGjD,EAAA,MAAMC,WAAAA,GAAc,MAAMC,sBAAAA,CAAe,mBAAA,CAAA;AACzC,EAAA,IAAI,CAACD,WAAAA,EAAa;AAChB,IAAA,MAAM,IAAIE,MACR,gFAAA,CAAA;AAEJ,EAAA;AAEA,EAAA,MAAMC,QAAQ,MAAMC,mBAAAA,CAClBC,mBAAAA,CAAUL,WAAAA,EAAa,4BAAA,CAAA,CAAA;AAEzB,EAAA,KAAA,MAAWM,QAAQH,KAAAA,EAAO;AACxBR,IAAAA,OAAAA,CAAQE,GAAAA,CAAIC,mBAAAA,CAAcC,KAAAA,EAAO,CAAA,sBAAA,EAAyBO,IAAAA,CAAAA,CAAM,CAAA;AAEhE,IAAA,MAAMC,QAAAA,GAAsBC,+BAAQF,IAAAA,CAAAA;AACpC,IAAA,MAAMG,2BAAAA,CACJd,OAAAA,CAAQE,GAAAA,EACRQ,mBAAAA,CAAUV,QAAQe,OAAAA,CAAQC,WAAAA,EAAaL,IAAAA,CAAKM,OAAAA,CAAQ,QAAQ,EAAA,CAAA,CAAA,EAC5DL,QAAAA,CAASZ,OAAAA,CAAAA,CAAAA;AAEb,EAAA;AAEA,EAAA,MAAMC,MAAMiB,QAAAA,CAAS,iB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AAAA,OAAAA,CAAQE,GAAAA,CAAIC,mBAAAA,CAAcC,KAAAA,EAAO,CAAA,sBAAA,EAAyBO,IAAAA,CAAAA,CAAM,CAAA;AAEhE,IAAA,MAAMC,QAAAA,GAAWc,UAAAA,CAAWb,OAAAA,CAAQF,IAAAA,CAAAA;AACpC,IAAA,MAAMG,2BAAAA,CACJd,OAAAA,CAAQE,GAAAA,EACRQ,mBAAAA,CAAUV,QAAQe,OAAAA,CAAQC,WAAAA,EAAaL,IAAAA,CAAKM,OAAAA,CAAQ,QAAQ,EAAA,CAAA,CAAA,EAC5DL,QAAAA,CAASZ,OAAAA,CAAAA,CAAAA;AAEb,EAAA;AAEA,EAAA,IAAIA,OAAAA,CAAQe,OAAAA,CAAQa,WAAAA,KAAgB,aAAA,EAAe;AACjD,IAAA,MAAM7B,cAAAA,CAAeC,SAASC,KAAAA,CAAAA;EAChC,CAAA,MAAO;AACL,IAAA,MAAMwB,UAAAA,CAAWzB,SAASC,KAAAA,CAAAA;AAC5B,EAAA;AAEA,EAAA,MAAMA,MAAMiB,QAAAA,CAAS,cAAA,EAAgBlB,OAAAA,CAAAA,CAASmB,KAAAA,CAAM,CAACC,KAAAA,KAAAA;AACnDpB,IAAAA,OAAAA,CAAQE,GAAAA,CACNC,mBAAAA,CAAckB,KAAAA,EACd,CAAA,+EAAA,EAAkFD,MAAME,OAAO,CAAA;EAAMF,KAAAA,CAAMG,KAAAA,IAAS,EAAA,CAAA,CAAI,CAAA;AAG1H,IAAA,MAAM,IAAIhB,MACR,+EAAA,EACA;MAAEiB,KAAAA,EAAOJ;KAAM,CAAA;EAEnB,CAAA,CAAA;AACF;AAnDsBO,wBAAAA,CAAAA,IAAAA,EAAAA,MAAAA,CAAAA","file":"chunk-HWHNTZRT.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 { listFiles } from \"@stryke/fs/list-files\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { resolvePackage } from \"@stryke/path/resolve\";\nimport * as Handlebars from \"handlebars\";\nimport { writeFile } from \"../../../lib/utilities/write-file\";\nimport type { EngineHooks } from \"../../../types/build\";\nimport type { Context } from \"../../../types/context\";\n\n/**\n * Adds a new Storm Stack application project.\n *\n * @param context - The build context.\n * @param hooks - The engine hooks.\n */\nexport async function newApplication(context: Context, hooks: EngineHooks) {\n context.log(\n LogLevelLabel.TRACE,\n `Adding a new Storm Stack application project.`\n );\n\n const packagePath = await resolvePackage(\"@storm-stack/core\");\n if (!packagePath) {\n throw new Error(\n \"Could not resolve the Storm Stack core package. Please ensure it is installed.\"\n );\n }\n\n const files = await listFiles(\n joinPaths(packagePath, \"files/application/**/*.hbs\")\n );\n for (const file of files) {\n context.log(LogLevelLabel.TRACE, `Adding template file: ${file}`);\n\n const template = Handlebars.compile(file);\n await writeFile(\n context.log,\n joinPaths(context.options.projectRoot, file.replace(\".hbs\", \"\")),\n template(context)\n );\n }\n\n await hooks.callHook(\"new:application\", context).catch((error: Error) => {\n context.log(\n LogLevelLabel.ERROR,\n `An error occured while creating a new Storm Stack application project: ${error.message} \\n${error.stack ?? \"\"}`\n );\n throw new Error(\n \"An error occured while creating a new Storm Stack application project\",\n {\n cause: error\n }\n );\n });\n}\n","/* -------------------------------------------------------------------\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 { listFiles } from \"@stryke/fs/list-files\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { resolvePackage } from \"@stryke/path/resolve\";\nimport { writeFile } from \"../../../lib/utilities/write-file\";\nimport type { EngineHooks } from \"../../../types/build\";\nimport type { Context } from \"../../../types/context\";\n\n/**\n * Adds a new Storm Stack library project.\n *\n * @param context - The build context.\n * @param hooks - The engine hooks.\n */\nexport async function newLibrary(context: Context, hooks: EngineHooks) {\n context.log(LogLevelLabel.TRACE, `Adding a new Storm Stack library project.`);\n\n const packagePath = await resolvePackage(\"@storm-stack/core\");\n if (!packagePath) {\n throw new Error(\n \"Could not resolve the Storm Stack core package. Please ensure it is installed.\"\n );\n }\n\n const files = await listFiles(\n joinPaths(packagePath, \"files/library/**/*.hbs\")\n );\n\n for (const file of files) {\n context.log(LogLevelLabel.TRACE, `Adding template file: ${file}`);\n\n const template = Handlebars.compile(file);\n await writeFile(\n context.log,\n joinPaths(context.options.projectRoot, file.replace(\".hbs\", \"\")),\n template(context)\n );\n }\n\n await hooks.callHook(\"new:library\", context).catch((error: Error) => {\n context.log(\n LogLevelLabel.ERROR,\n `An error occured while creating a new Storm Stack library project: ${error.message} \\n${error.stack ?? \"\"}`\n );\n throw new Error(\n \"An error occured while creating a new Storm Stack library project\",\n {\n cause: error\n }\n );\n });\n}\n","/* -------------------------------------------------------------------\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 { listFiles } from \"@stryke/fs/list-files\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { resolvePackage } from \"@stryke/path/resolve\";\nimport { writeFile } from \"../../lib/utilities/write-file\";\nimport type { EngineHooks } from \"../../types/build\";\nimport type { Context } from \"../../types/context\";\nimport { newApplication } from \"./application\";\nimport { newLibrary } from \"./library\";\n\n/**\n * Creates a new Storm Stack project.\n *\n * @param context - The build context.\n * @param hooks - The engine hooks.\n */\nexport async function _new(context: Context, hooks: EngineHooks) {\n await hooks.callHook(\"new:begin\", context).catch((error: Error) => {\n context.log(\n LogLevelLabel.ERROR,\n `An error occured while starting the new process to add a Storm Stack project: ${error.message} \\n${error.stack ?? \"\"}`\n );\n\n throw new Error(\n \"An error occured while starting the new process to add a Storm Stack project\",\n { cause: error }\n );\n });\n\n const packagePath = await resolvePackage(\"@storm-stack/core\");\n if (!packagePath) {\n throw new Error(\n \"Could not resolve the Storm Stack core package. Please ensure it is installed.\"\n );\n }\n\n const files = await listFiles(\n joinPaths(packagePath, \"files/common/**/*.hbs\")\n );\n for (const file of files) {\n context.log(LogLevelLabel.TRACE, `Adding template file: ${file}`);\n\n const template = Handlebars.compile(file);\n await writeFile(\n context.log,\n joinPaths(context.options.projectRoot, file.replace(\".hbs\", \"\")),\n template(context)\n );\n }\n\n if (context.options.projectType === \"application\") {\n await newApplication(context, hooks);\n } else {\n await newLibrary(context, hooks);\n }\n\n await hooks.callHook(\"new:complete\", context).catch((error: Error) => {\n context.log(\n LogLevelLabel.ERROR,\n `An error occured while finishing the new process to add a Storm Stack project: ${error.message} \\n${error.stack ?? \"\"}`\n );\n\n throw new Error(\n \"An error occured while finishing the new process to add a Storm Stack project\",\n { cause: error }\n );\n });\n}\n"]}