@powerlines/plugin-vite 0.14.62 → 0.14.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.mjs +1 -1
  3. package/dist/powerlines/src/api.cjs +3 -3
  4. package/dist/powerlines/src/api.mjs +1 -1
  5. package/dist/powerlines/src/internal/helpers/environment.cjs +1 -1
  6. package/dist/powerlines/src/internal/helpers/environment.mjs +1 -1
  7. package/dist/powerlines/src/internal/helpers/hooks.d.cts +48 -0
  8. package/dist/powerlines/src/internal/helpers/hooks.d.mts +50 -0
  9. package/dist/powerlines/src/internal/helpers/install.cjs +1 -1
  10. package/dist/powerlines/src/internal/helpers/install.mjs +1 -1
  11. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +1 -1
  12. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +1 -1
  13. package/dist/powerlines/src/internal/helpers/resolver.cjs +1 -1
  14. package/dist/powerlines/src/internal/helpers/resolver.mjs +1 -1
  15. package/dist/powerlines/src/lib/build/esbuild.cjs +2 -2
  16. package/dist/powerlines/src/lib/build/esbuild.mjs +2 -2
  17. package/dist/powerlines/src/lib/build/vite.cjs +1 -1
  18. package/dist/powerlines/src/lib/build/vite.mjs +1 -1
  19. package/dist/powerlines/src/lib/config-file.cjs +1 -1
  20. package/dist/powerlines/src/lib/config-file.mjs +1 -1
  21. package/dist/powerlines/src/lib/contexts/api-context.cjs +1 -1
  22. package/dist/powerlines/src/lib/contexts/api-context.mjs +1 -1
  23. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +1 -1
  24. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +1 -1
  25. package/dist/powerlines/src/types/api.d.cts +104 -0
  26. package/dist/powerlines/src/types/api.d.mts +104 -0
  27. package/dist/powerlines/src/types/build.d.cts +13 -2
  28. package/dist/powerlines/src/types/build.d.mts +13 -2
  29. package/dist/powerlines/src/types/config.d.cts +59 -1
  30. package/dist/powerlines/src/types/config.d.mts +60 -2
  31. package/dist/powerlines/src/types/context.d.cts +112 -1
  32. package/dist/powerlines/src/types/context.d.mts +112 -3
  33. package/dist/powerlines/src/types/hooks.d.cts +30 -0
  34. package/dist/powerlines/src/types/hooks.d.mts +30 -2
  35. package/dist/powerlines/src/types/internal.d.cts +58 -0
  36. package/dist/powerlines/src/types/internal.d.mts +58 -0
  37. package/dist/powerlines/src/types/plugin.d.cts +5 -2
  38. package/dist/powerlines/src/types/plugin.d.mts +5 -2
  39. package/dist/powerlines/src/types/resolved.d.mts +1 -0
  40. package/dist/types/internal.cjs +0 -0
  41. package/dist/types/internal.d.cts +14 -0
  42. package/dist/types/internal.d.mts +14 -0
  43. package/dist/types/internal.mjs +1 -0
  44. package/dist/types/plugin.d.cts +1 -8
  45. package/dist/types/plugin.d.mts +1 -8
  46. package/package.json +8 -13
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./powerlines/src/lib/build/vite.cjs`),n=require(`./helpers/unplugin.cjs`);require(`./helpers/index.cjs`);let r=require(`@storm-software/config-tools/types`),i=require(`@stryke/fs/package-fns`),a=require(`@stryke/path/join-paths`),o=require(`defu`);o=e.__toESM(o);const s=(e={})=>({name:`vite`,config(){return this.log(r.LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `vite` build plugin."),{output:{format:[`cjs`,`esm`]},build:{...t.DEFAULT_VITE_CONFIG,...e,variant:`vite`}}},async build(){this.log(r.LogLevelLabel.TRACE,`Building the Powerlines plugin.`);let s=(0,o.default)({config:!1,entry:this.entry},t.extractViteConfig(this),{plugins:[n.createVitePlugin(this)]}),c=`vite`;if(e.rolldown&&(0,i.isPackageExists)(`rolldown-vite`,{paths:[(0,a.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot),this.workspaceConfig.workspaceRoot]})&&(c=`rolldown-vite`),!(0,i.isPackageExists)(c,{paths:[(0,a.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot),this.workspaceConfig.workspaceRoot]}))throw Error(`Failed to find the "${c}" package required for the Powerlines "vite" plugin${e.rolldown?" with the `rolldown` option enabled":``}. Please run "npm install ${c} -D" to install it.`);let l=await this.resolver.import(c);if(!l)throw Error(`Failed to load the "${c}" module - this package is required when using the Powerlines "vite" plugin${e.rolldown?" with the `rolldown` option enabled":``}. Please ensure it is installed correctly.`);await l.build(s)}});var c=s;exports.createVitePlugin=n.createVitePlugin,exports.default=c,exports.plugin=s;
1
+ Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./powerlines/src/lib/build/vite.cjs`),n=require(`./helpers/unplugin.cjs`);require(`./helpers/index.cjs`);let r=require(`@storm-software/config-tools/types`),i=require(`defu`);i=e.__toESM(i);let a=require(`vite`);const o=(e={})=>({name:`vite`,config(){return this.log(r.LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `vite` build plugin."),{output:{format:[`cjs`,`esm`]},build:{...t.DEFAULT_VITE_CONFIG,...e,variant:`vite`},singleBuild:!0}},async build(){this.log(r.LogLevelLabel.TRACE,`Building the Powerlines plugin.`);let e=this?.$$internal?.api?.context?.environments;if(!e||Object.keys(e).length===0)throw Error(`No environments found in the Powerlines context. At least one environment should have been generated - please report this issue to https://github.com/storm-software/powerlines/issues.`);this.log(r.LogLevelLabel.TRACE,`Running Vite for ${Object.keys(e).length} environments.`),await(0,a.build)((0,i.default)({config:!1,entry:this.entry,environments:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t.extractViteConfig(n)]))},t.extractViteConfig(this),{plugins:[n.createVitePlugin(this)]}))}});var s=o;exports.createVitePlugin=n.createVitePlugin,exports.default=s,exports.plugin=o;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{DEFAULT_VITE_CONFIG as e,extractViteConfig as t}from"./powerlines/src/lib/build/vite.mjs";import{createVitePlugin as n}from"./helpers/unplugin.mjs";import"./helpers/index.mjs";import{LogLevelLabel as r}from"@storm-software/config-tools/types";import{isPackageExists as i}from"@stryke/fs/package-fns";import{joinPaths as a}from"@stryke/path/join-paths";import o from"defu";const s=(s={})=>({name:`vite`,config(){return this.log(r.TRACE,"Providing default configuration for the Powerlines `vite` build plugin."),{output:{format:[`cjs`,`esm`]},build:{...e,...s,variant:`vite`}}},async build(){this.log(r.TRACE,`Building the Powerlines plugin.`);let e=o({config:!1,entry:this.entry},t(this),{plugins:[n(this)]}),c=`vite`;if(s.rolldown&&i(`rolldown-vite`,{paths:[a(this.workspaceConfig.workspaceRoot,this.config.projectRoot),this.workspaceConfig.workspaceRoot]})&&(c=`rolldown-vite`),!i(c,{paths:[a(this.workspaceConfig.workspaceRoot,this.config.projectRoot),this.workspaceConfig.workspaceRoot]}))throw Error(`Failed to find the "${c}" package required for the Powerlines "vite" plugin${s.rolldown?" with the `rolldown` option enabled":``}. Please run "npm install ${c} -D" to install it.`);let l=await this.resolver.import(c);if(!l)throw Error(`Failed to load the "${c}" module - this package is required when using the Powerlines "vite" plugin${s.rolldown?" with the `rolldown` option enabled":``}. Please ensure it is installed correctly.`);await l.build(e)}});var c=s;export{n as createVitePlugin,c as default,s as plugin};
1
+ import{DEFAULT_VITE_CONFIG as e,extractViteConfig as t}from"./powerlines/src/lib/build/vite.mjs";import{createVitePlugin as n}from"./helpers/unplugin.mjs";import"./helpers/index.mjs";import{LogLevelLabel as r}from"@storm-software/config-tools/types";import i from"defu";import{build as a}from"vite";const o=(o={})=>({name:`vite`,config(){return this.log(r.TRACE,"Providing default configuration for the Powerlines `vite` build plugin."),{output:{format:[`cjs`,`esm`]},build:{...e,...o,variant:`vite`},singleBuild:!0}},async build(){this.log(r.TRACE,`Building the Powerlines plugin.`);let e=this?.$$internal?.api?.context?.environments;if(!e||Object.keys(e).length===0)throw Error(`No environments found in the Powerlines context. At least one environment should have been generated - please report this issue to https://github.com/storm-software/powerlines/issues.`);this.log(r.TRACE,`Running Vite for ${Object.keys(e).length} environments.`),await a(i({config:!1,entry:this.entry,environments:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n)]))},t(this),{plugins:[n(this)]}))}});var s=o;export{n as createVitePlugin,s as default,o as plugin};
@@ -1,11 +1,11 @@
1
- const e=require(`../../_virtual/rolldown_runtime.cjs`),t=require(`./internal/babel/module-resolver-plugin.cjs`),n=require(`./internal/helpers/generate-types.cjs`),r=require(`./internal/helpers/hooks.cjs`),i=require(`./internal/helpers/install-dependencies.cjs`),a=require(`./lib/typescript/tsconfig.cjs`),o=require(`./internal/helpers/resolve-tsconfig.cjs`),s=require(`./plugin-utils/helpers.cjs`),c=require(`./lib/utilities/meta.cjs`),l=require(`./lib/contexts/api-context.cjs`),u=require(`./lib/utilities/file-header.cjs`);let d=require(`@storm-software/config-tools/types`),f=require(`@stryke/fs/package-fns`),p=require(`@stryke/path/join-paths`),m=require(`@stryke/path/replace`),h=require(`@stryke/convert/to-array`),g=require(`@stryke/fs/list-files`),_=require(`@stryke/path/append`),v=require(`@stryke/type-checks/is-set-string`),y=require(`@babel/core`),b=require(`@storm-software/config-tools/logger/console`),x=require(`@stryke/fs/helpers`),S=require(`@stryke/fs/install`),C=require(`@stryke/fs/resolve`),w=require(`@stryke/type-checks/is-error`),T=require(`@stryke/type-checks/is-function`),E=require(`@stryke/type-checks/is-number`),D=require(`@stryke/type-checks/is-object`),O=require(`@stryke/type-checks/is-promise`),k=require(`@stryke/type-checks/is-set`),A=require(`@stryke/type-checks/is-set-object`),j=require(`chalk`);j=e.__toESM(j);let M=require(`handlebars`);M=e.__toESM(M);var N=class e{#e;get context(){return this.#e}constructor(e){this.#e=e}static async from(t,n){let r=new e(await l.PowerlinesAPIContext.from(t,n));r.#e.$$internal={api:r,addPlugin:r.#r.bind(r)};for(let e of r.context.config.plugins??[])await r.#r(e);r.context.plugins.length===0&&r.context.log(d.LogLevelLabel.WARN,`No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended.`);let i=await r.callHook(`config`,{environment:await r.context.getEnvironment(),sequential:!0,result:`merge`});return await r.context.withUserConfig(i,{isHighPriority:!1}),r}async prepare(e={command:`prepare`}){this.context.log(d.LogLevelLabel.TRACE,` 🏗️ Preparing the Powerlines project`),this.context.log(d.LogLevelLabel.TRACE,` ⚙️ Aggregating configuration options for the Powerlines project`),await this.context.withInlineConfig(e),await this.#n(async e=>{if(e.log(d.LogLevelLabel.TRACE,`Initializing the processing options for the Powerlines project.`),await this.callHook(`configResolved`,{environment:e,order:`pre`}),await o.initializeTsconfig(e),await this.callHook(`configResolved`,{environment:e,order:`normal`}),e.log(d.LogLevelLabel.DEBUG,`The configuration provided ${(0,h.toArray)(e.config.entry).length} entry point(s), Powerlines has found ${e.entry.length} entry files(s) for the ${e.config.title} project${e.entry.length>0&&e.entry.length<10?`: \n${e.entry.map(e=>`- ${e.input.file||e.file}${e.output?` -> ${e.output}`:``}`).join(`
2
- `)}`:``}.`),await o.resolveTsconfig(e),await i.installDependencies(e),await this.callHook(`configResolved`,{environment:e,order:`post`}),e.log(d.LogLevelLabel.TRACE,`Powerlines configuration has been resolved: \n\n${(0,b.formatLogMessage)(e.config)}`),e.fs.existsSync(e.cachePath)||await(0,x.createDirectory)(e.cachePath),e.fs.existsSync(e.dataPath)||await(0,x.createDirectory)(e.dataPath),await this.callHook(`prepare`,{environment:e,order:`pre`}),await this.callHook(`prepare`,{environment:e,order:`normal`}),e.config.output.dts!==!1){e.log(d.LogLevelLabel.TRACE,`Preparing the TypeScript definitions for the Powerlines project.`),e.fs.existsSync(e.dtsPath)&&await e.fs.remove(e.dtsPath),e.log(d.LogLevelLabel.TRACE,`Transforming built-ins runtime modules files.`);let r=await Promise.all((await e.getBuiltins()).map(async n=>{let r=await(0,y.transformAsync)(n.code.toString(),{highlightCode:!0,code:!0,ast:!1,cloneInputAst:!1,comments:!0,sourceType:`module`,configFile:!1,babelrc:!1,envName:e.config.mode,caller:{name:`powerlines`},...e.config.transform.babel,filename:n.path,plugins:[[`@babel/plugin-syntax-typescript`],[t.moduleResolverBabelPlugin(e)]]});if(!r?.code)throw Error(`Powerlines - Generate Types failed to compile ${n.id}`);return e.log(d.LogLevelLabel.TRACE,`Writing transformed built-in runtime file ${n.id}.`),await e.emitBuiltin(r.code,n.id,n.path),n.path}));if(!await(0,C.resolvePackage)(`typescript`))throw Error(`Could not resolve TypeScript package location. Please ensure TypeScript is installed.`);let i=r.reduce((t,n)=>{let r=(0,m.replacePath)(n,e.workspaceConfig.workspaceRoot);return t.includes(r)||t.push(r),t},[]);e.log(d.LogLevelLabel.TRACE,`Parsing TypeScript configuration for the Powerlines project.`);let s=await n.emitTypes(e,i);e.log(d.LogLevelLabel.TRACE,`Generating TypeScript declaration file ${e.dtsPath}.`);let c=[],l=e=>(0,D.isObject)(e)?e.code:e,f=await this.callHook(`types`,{environment:e,sequential:!0,order:`pre`,result:`merge`,asNextParam:l},s);if(f&&((0,A.isSetObject)(f)?(s=f.code,Array.isArray(f.directives)&&f.directives.length>0&&c.push(...f.directives)):(0,v.isSetString)(f)&&(s=f)),f=await this.callHook(`types`,{environment:e,sequential:!0,order:`normal`,result:`merge`,asNextParam:l},s),f&&((0,A.isSetObject)(f)?(s=f.code,Array.isArray(f.directives)&&f.directives.length>0&&c.push(...f.directives)):(0,v.isSetString)(f)&&(s=f)),f=await this.callHook(`types`,{environment:e,sequential:!0,order:`post`,result:`merge`,asNextParam:l},s),f&&((0,A.isSetObject)(f)?(s=f.code,Array.isArray(f.directives)&&f.directives.length>0&&c.push(...f.directives)):(0,v.isSetString)(f)&&(s=f)),s?.trim()||c.length>0)await e.fs.write(e.dtsPath,`${c?`${c.map(e=>`/// <reference types="${e}" />`).join(`
1
+ const e=require(`../../_virtual/rolldown_runtime.cjs`),t=require(`./internal/babel/module-resolver-plugin.cjs`),n=require(`./internal/helpers/generate-types.cjs`),r=require(`./internal/helpers/hooks.cjs`),i=require(`./internal/helpers/install-dependencies.cjs`),a=require(`./lib/typescript/tsconfig.cjs`),o=require(`./internal/helpers/resolve-tsconfig.cjs`),s=require(`./plugin-utils/helpers.cjs`),c=require(`./lib/utilities/meta.cjs`),l=require(`./lib/contexts/api-context.cjs`),u=require(`./lib/utilities/file-header.cjs`);let d=require(`@storm-software/config-tools/types`),f=require(`@stryke/path/join-paths`),p=require(`@stryke/path/replace`),m=require(`@stryke/convert/to-array`),h=require(`@stryke/fs/list-files`),g=require(`@stryke/path/append`),_=require(`@stryke/type-checks/is-set-string`),v=require(`@babel/core`),y=require(`@storm-software/config-tools/logger/console`),b=require(`@stryke/fs/helpers`),x=require(`@stryke/fs/install`),S=require(`@stryke/fs/package-fns`),C=require(`@stryke/fs/resolve`),w=require(`@stryke/type-checks/is-error`),T=require(`@stryke/type-checks/is-function`),E=require(`@stryke/type-checks/is-number`),D=require(`@stryke/type-checks/is-object`),O=require(`@stryke/type-checks/is-promise`),k=require(`@stryke/type-checks/is-set`),A=require(`@stryke/type-checks/is-set-object`),j=require(`chalk`);j=e.__toESM(j);let M=require(`handlebars`);M=e.__toESM(M);var N=class e{#e;get context(){return this.#e}constructor(e){this.#e=e}static async from(t,n){let r=new e(await l.PowerlinesAPIContext.from(t,n));r.#e.$$internal={api:r,addPlugin:r.#i.bind(r)};for(let e of r.context.config.plugins??[])await r.#i(e);r.context.plugins.length===0&&r.context.log(d.LogLevelLabel.WARN,`No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended.`);let i=await r.callHook(`config`,{environment:await r.context.getEnvironment(),sequential:!0,result:`merge`});return await r.context.withUserConfig(i,{isHighPriority:!1}),r}async prepare(e={command:`prepare`}){this.context.log(d.LogLevelLabel.TRACE,` 🏗️ Preparing the Powerlines project`),this.context.log(d.LogLevelLabel.TRACE,` ⚙️ Aggregating configuration options for the Powerlines project`),await this.context.withInlineConfig(e),await this.#r(async e=>{if(e.log(d.LogLevelLabel.TRACE,`Initializing the processing options for the Powerlines project.`),await this.callHook(`configResolved`,{environment:e,order:`pre`}),await o.initializeTsconfig(e),await this.callHook(`configResolved`,{environment:e,order:`normal`}),e.log(d.LogLevelLabel.DEBUG,`The configuration provided ${(0,m.toArray)(e.config.entry).length} entry point(s), Powerlines has found ${e.entry.length} entry files(s) for the ${e.config.title} project${e.entry.length>0&&e.entry.length<10?`: \n${e.entry.map(e=>`- ${e.input.file||e.file}${e.output?` -> ${e.output}`:``}`).join(`
2
+ `)}`:``}.`),await o.resolveTsconfig(e),await i.installDependencies(e),await this.callHook(`configResolved`,{environment:e,order:`post`}),e.log(d.LogLevelLabel.TRACE,`Powerlines configuration has been resolved: \n\n${(0,y.formatLogMessage)(e.config)}`),e.fs.existsSync(e.cachePath)||await(0,b.createDirectory)(e.cachePath),e.fs.existsSync(e.dataPath)||await(0,b.createDirectory)(e.dataPath),await this.callHook(`prepare`,{environment:e,order:`pre`}),await this.callHook(`prepare`,{environment:e,order:`normal`}),e.config.output.dts!==!1){e.log(d.LogLevelLabel.TRACE,`Preparing the TypeScript definitions for the Powerlines project.`),e.fs.existsSync(e.dtsPath)&&await e.fs.remove(e.dtsPath),e.log(d.LogLevelLabel.TRACE,`Transforming built-ins runtime modules files.`);let r=await Promise.all((await e.getBuiltins()).map(async n=>{let r=await(0,v.transformAsync)(n.code.toString(),{highlightCode:!0,code:!0,ast:!1,cloneInputAst:!1,comments:!0,sourceType:`module`,configFile:!1,babelrc:!1,envName:e.config.mode,caller:{name:`powerlines`},...e.config.transform.babel,filename:n.path,plugins:[[`@babel/plugin-syntax-typescript`],[t.moduleResolverBabelPlugin(e)]]});if(!r?.code)throw Error(`Powerlines - Generate Types failed to compile ${n.id}`);return e.log(d.LogLevelLabel.TRACE,`Writing transformed built-in runtime file ${n.id}.`),await e.emitBuiltin(r.code,n.id,n.path),n.path}));if(!await(0,C.resolvePackage)(`typescript`))throw Error(`Could not resolve TypeScript package location. Please ensure TypeScript is installed.`);let i=r.reduce((t,n)=>{let r=(0,p.replacePath)(n,e.workspaceConfig.workspaceRoot);return t.includes(r)||t.push(r),t},[]);e.log(d.LogLevelLabel.TRACE,`Parsing TypeScript configuration for the Powerlines project.`);let s=await n.emitTypes(e,i);e.log(d.LogLevelLabel.TRACE,`Generating TypeScript declaration file ${e.dtsPath}.`);let c=[],l=e=>(0,D.isObject)(e)?e.code:e,f=await this.callHook(`types`,{environment:e,sequential:!0,order:`pre`,result:`merge`,asNextParam:l},s);if(f&&((0,A.isSetObject)(f)?(s=f.code,Array.isArray(f.directives)&&f.directives.length>0&&c.push(...f.directives)):(0,_.isSetString)(f)&&(s=f)),f=await this.callHook(`types`,{environment:e,sequential:!0,order:`normal`,result:`merge`,asNextParam:l},s),f&&((0,A.isSetObject)(f)?(s=f.code,Array.isArray(f.directives)&&f.directives.length>0&&c.push(...f.directives)):(0,_.isSetString)(f)&&(s=f)),f=await this.callHook(`types`,{environment:e,sequential:!0,order:`post`,result:`merge`,asNextParam:l},s),f&&((0,A.isSetObject)(f)?(s=f.code,Array.isArray(f.directives)&&f.directives.length>0&&c.push(...f.directives)):(0,_.isSetString)(f)&&(s=f)),s?.trim()||c.length>0)await e.fs.write(e.dtsPath,`${c?`${c.map(e=>`/// <reference types="${e}" />`).join(`
3
3
  `)}
4
4
 
5
5
  `:``}${u.getFileHeader(e,{directive:null,prettierIgnore:!1})}
6
6
 
7
7
  ${n.formatTypes(s)}
8
- `);else{let t=o.getTsconfigDtsPath(e);if(e.tsconfig.tsconfigJson.include&&a.isIncludeMatchFound(t,e.tsconfig.tsconfigJson.include)){let n=t.startsWith(`./`)?t.slice(2):t;e.tsconfig.tsconfigJson.include=e.tsconfig.tsconfigJson.include.filter(e=>e?.toString()!==n),await e.fs.write(e.tsconfig.tsconfigFilePath,JSON.stringify(e.tsconfig.tsconfigJson,null,2))}}}if(e.tsconfig=a.getParsedTypeScriptConfig(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig),!e.tsconfig)throw Error(`Failed to parse the TypeScript configuration file.`);await this.callHook(`prepare`,{environment:e,order:`post`}),await c.writeMetaFile(e),e.persistedMeta=e.meta}),this.context.log(d.LogLevelLabel.INFO,`Powerlines API has been prepared successfully`)}async new(e){this.context.log(d.LogLevelLabel.INFO,`🆕 Creating a new Powerlines project`),await this.prepare(e),await this.#n(async e=>{e.log(d.LogLevelLabel.TRACE,`Initializing the processing options for the Powerlines project.`),await this.callHook(`new`,{environment:e,order:`pre`});let t=await(0,g.listFiles)((0,p.joinPaths)(e.powerlinesPath,`files/common/**/*.hbs`));for(let n of t){e.log(d.LogLevelLabel.TRACE,`Adding template file: ${n}`);let t=M.default.compile(n);await e.fs.write((0,p.joinPaths)(e.config.projectRoot,n.replace(`.hbs`,``)),t(e))}if(await this.callHook(`new`,{environment:e,order:`normal`}),e.config.projectType===`application`){let t=await(0,g.listFiles)((0,p.joinPaths)(e.powerlinesPath,`files/application/**/*.hbs`));for(let n of t){e.log(d.LogLevelLabel.TRACE,`Adding application template file: ${n}`);let t=M.default.compile(n);await e.fs.write((0,p.joinPaths)(e.config.projectRoot,n.replace(`.hbs`,``)),t(e))}}else{let t=await(0,g.listFiles)((0,p.joinPaths)(e.powerlinesPath,`files/library/**/*.hbs`));for(let n of t){e.log(d.LogLevelLabel.TRACE,`Adding library template file: ${n}`);let t=M.default.compile(n);await e.fs.write((0,p.joinPaths)(e.config.projectRoot,n.replace(`.hbs`,``)),t(e))}}await this.callHook(`new`,{environment:e,order:`post`})}),this.context.log(d.LogLevelLabel.TRACE,`Powerlines - New command completed`)}async clean(e={command:`clean`}){this.context.log(d.LogLevelLabel.INFO,`🧹 Cleaning the previous Powerlines artifacts`),await this.prepare(e),await this.#n(async e=>{this.context.log(d.LogLevelLabel.TRACE,`Cleaning the project's dist and artifacts directories.`),await e.fs.remove((0,p.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.output.buildPath)),await e.fs.remove((0,p.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.output.artifactsPath)),await this.callHook(`clean`,{environment:e,sequential:!1})}),this.context.log(d.LogLevelLabel.TRACE,`Powerlines - Clean command completed`)}async lint(e={command:`lint`}){this.context.log(d.LogLevelLabel.INFO,`📋 Linting the Powerlines project`),await this.prepare(e),await this.#n(async e=>{e.config.lint!==!1&&await this.callHook(`lint`,{environment:e,sequential:!1})}),this.context.log(d.LogLevelLabel.TRACE,`Powerlines linting completed`)}async build(e={command:`build`}){this.context.log(d.LogLevelLabel.INFO,`📦 Building the Powerlines project`),await this.prepare(e),await this.#n(async e=>{if(await this.callHook(`build`,{environment:e,order:`pre`}),await this.callHook(`build`,{environment:e,order:`normal`}),e.config.output.buildPath!==e.config.output.outputPath){let t=(0,_.appendPath)(e.config.output.buildPath,e.workspaceConfig.workspaceRoot),n=(0,p.joinPaths)((0,_.appendPath)(e.config.output.outputPath,e.workspaceConfig.workspaceRoot),`dist`);t!==n&&(e.log(d.LogLevelLabel.INFO,`Copying build output files from project's build directory (${e.config.output.buildPath}) to the workspace's output directory (${e.config.output.outputPath}).`),await e.fs.copy(t,n))}await Promise.all(e.config.output.assets.map(async t=>{e.log(d.LogLevelLabel.DEBUG,`Copying asset(s): ${j.default.redBright(e.workspaceConfig.workspaceRoot===t.input?t.glob:(0,p.joinPaths)((0,m.replacePath)(t.input,e.workspaceConfig.workspaceRoot),t.glob))} -> ${j.default.greenBright((0,p.joinPaths)((0,m.replacePath)(t.output,e.workspaceConfig.workspaceRoot),t.glob))} ${Array.isArray(t.ignore)&&t.ignore.length>0?` (ignoring: ${t.ignore.map(e=>j.default.yellowBright(e)).join(`, `)})`:``}`),await e.fs.copy(t,t.output)})),await this.callHook(`build`,{environment:e,order:`post`})}),this.context.log(d.LogLevelLabel.TRACE,`Powerlines build completed`)}async docs(e={command:`docs`}){this.context.log(d.LogLevelLabel.INFO,`📓 Generating documentation for the Powerlines project`),await this.prepare(e),await this.#n(async t=>{t.log(d.LogLevelLabel.TRACE,`Writing documentation for the Powerlines project artifacts.`),await this.prepare(e),await this.#n(async e=>{await this.callHook(`docs`,{environment:e})})}),this.#e.log(d.LogLevelLabel.TRACE,`Powerlines documentation generation completed`)}async deploy(e={command:`deploy`}){this.context.log(d.LogLevelLabel.INFO,`📦 Deploying the Powerlines project`),await this.prepare(e),await this.#n(async e=>{await this.callHook(`deploy`,{environment:e})}),this.context.log(d.LogLevelLabel.TRACE,`Powerlines deploy completed`)}async finalize(){this.context.log(d.LogLevelLabel.TRACE,`Powerlines finalize execution started`),await this.#n(async e=>{await this.callHook(`finalize`,{environment:e}),await e.fs.dispose()}),this.context.log(d.LogLevelLabel.TRACE,`Powerlines finalize execution completed`)}async callHook(e,t,...n){return r.callHook((0,A.isSetObject)(t?.environment)?t.environment:await this.#e.getEnvironment(t?.environment),e,{sequential:!0,...t},...n)}async[Symbol.asyncDispose](){await this.finalize()}async#t(){return!this.context.config.environments||Object.keys(this.context.config.environments).length<=1?(this.context.log(d.LogLevelLabel.DEBUG,`No environments are configured for this Powerlines project. Using the default environment.`),[await this.context.getEnvironment()]):(this.context.log(d.LogLevelLabel.DEBUG,`Found ${Object.keys(this.context.config.environments).length} configured environment(s) for this Powerlines project.`),(await Promise.all(Object.entries(this.context.config.environments).map(async([e,t])=>{if(!await this.context.getEnvironmentSafe(e)){let n=await this.callHook(`configEnvironment`,{environment:e},e,t);n&&(this.context.environments[e]=await this.context.in(n))}return this.context.environments[e]}))).filter(e=>(0,k.isSet)(e)))}async#n(e){await Promise.all((await this.#t()).map(async t=>Promise.resolve(e(t))))}async#r(e){if(e){let t=await this.#i(e);if(!t)return;if(t.dependsOn)for(let e of t.dependsOn)await this.#r(e);this.context.log(d.LogLevelLabel.DEBUG,`Successfully initialized the ${j.default.bold.cyanBright(t.name)} plugin`),await this.context.addPlugin(t)}}async#i(e){let t=e;if((0,O.isPromiseLike)(e)&&(t=await Promise.resolve(e)),!s.isPluginConfig(t))throw Error(`Invalid plugin specified in the configuration - ${JSON.stringify(t)}. Please ensure the value is a plugin name, an object with the \`plugin\` and \`props\` properties, or an instance of \`Plugin\`.`);let n;if(s.isPlugin(t))n=t;else if((0,T.isFunction)(t))n=await Promise.resolve(t());else if((0,v.isSetString)(t)){let e=await this.#a(t);n=(0,T.isFunction)(e)?await Promise.resolve(e()):e}else if(s.isPluginConfigTuple(t)||s.isPluginConfigObject(t)){let e,r;if(s.isPluginConfigTuple(t)?(e=t[0],r=t?.length===2?t[1]:void 0):(e=t.plugin,r=t.options),(0,v.isSetString)(e)){let t=await this.#a(e);n=(0,T.isFunction)(t)?await Promise.resolve(r?t(r):t()):t}else (0,T.isFunction)(e)?n=await Promise.resolve(e(r)):s.isPlugin(e)&&(n=e)}if(!n)throw Error(`The plugin configuration ${JSON.stringify(t)} is invalid. This configuration must point to a valid Powerlines plugin module.`);if(!s.isPlugin(n))throw Error(`The plugin option ${JSON.stringify(n)} does not export a valid module. This configuration must point to a valid Powerlines plugin module.`);return s.checkDedupe(n,this.context.plugins)?(this.context.log(d.LogLevelLabel.TRACE,`Duplicate ${j.default.bold.cyanBright(n.name)} plugin dependency detected - Skipping initialization.`),null):(this.context.log(d.LogLevelLabel.TRACE,`Initializing the ${j.default.bold.cyanBright(n.name)} plugin...`),n)}async#a(e){if(e.startsWith(`@`)&&e.split(`/`).filter(Boolean).length>2){let t=e.split(`/`).filter(Boolean);e=`${t[0]}/${t[1]}`}let t=(0,f.isPackageExists)(e,{paths:[this.context.workspaceConfig.workspaceRoot,this.context.config.projectRoot]});if(!t&&this.context.config.skipInstalls!==!0){this.#e.log(d.LogLevelLabel.WARN,`The plugin package "${e}" is not installed. It will be installed automatically.`);let t=await(0,S.install)(e,{cwd:this.context.config.projectRoot});if((0,E.isNumber)(t.exitCode)&&t.exitCode>0)throw this.#e.log(d.LogLevelLabel.ERROR,t.stderr),Error(`An error occurred while installing the build plugin package "${e}" `)}try{let t=await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve((0,p.joinPaths)(e,`plugin`))),n=t.plugin??t.default;if(!n)throw Error(`The plugin package "${e}" does not export a valid module.`);return n}catch(n){try{let t=await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(e)),n=t.plugin??t.default;if(!n)throw Error(`The plugin package "${e}" does not export a valid module.`);return n}catch{throw t?Error(`An error occurred while importing the build plugin package "${e}":
8
+ `);else{let t=o.getTsconfigDtsPath(e);if(e.tsconfig.tsconfigJson.include&&a.isIncludeMatchFound(t,e.tsconfig.tsconfigJson.include)){let n=t.startsWith(`./`)?t.slice(2):t;e.tsconfig.tsconfigJson.include=e.tsconfig.tsconfigJson.include.filter(e=>e?.toString()!==n),await e.fs.write(e.tsconfig.tsconfigFilePath,JSON.stringify(e.tsconfig.tsconfigJson,null,2))}}}if(e.tsconfig=a.getParsedTypeScriptConfig(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig),!e.tsconfig)throw Error(`Failed to parse the TypeScript configuration file.`);await this.callHook(`prepare`,{environment:e,order:`post`}),await c.writeMetaFile(e),e.persistedMeta=e.meta}),this.context.log(d.LogLevelLabel.INFO,`Powerlines API has been prepared successfully`)}async new(e){this.context.log(d.LogLevelLabel.INFO,`🆕 Creating a new Powerlines project`),await this.prepare(e),await this.#r(async e=>{e.log(d.LogLevelLabel.TRACE,`Initializing the processing options for the Powerlines project.`),await this.callHook(`new`,{environment:e,order:`pre`});let t=await(0,h.listFiles)((0,f.joinPaths)(e.powerlinesPath,`files/common/**/*.hbs`));for(let n of t){e.log(d.LogLevelLabel.TRACE,`Adding template file: ${n}`);let t=M.default.compile(n);await e.fs.write((0,f.joinPaths)(e.config.projectRoot,n.replace(`.hbs`,``)),t(e))}if(await this.callHook(`new`,{environment:e,order:`normal`}),e.config.projectType===`application`){let t=await(0,h.listFiles)((0,f.joinPaths)(e.powerlinesPath,`files/application/**/*.hbs`));for(let n of t){e.log(d.LogLevelLabel.TRACE,`Adding application template file: ${n}`);let t=M.default.compile(n);await e.fs.write((0,f.joinPaths)(e.config.projectRoot,n.replace(`.hbs`,``)),t(e))}}else{let t=await(0,h.listFiles)((0,f.joinPaths)(e.powerlinesPath,`files/library/**/*.hbs`));for(let n of t){e.log(d.LogLevelLabel.TRACE,`Adding library template file: ${n}`);let t=M.default.compile(n);await e.fs.write((0,f.joinPaths)(e.config.projectRoot,n.replace(`.hbs`,``)),t(e))}}await this.callHook(`new`,{environment:e,order:`post`})}),this.context.log(d.LogLevelLabel.TRACE,`Powerlines - New command completed`)}async clean(e={command:`clean`}){this.context.log(d.LogLevelLabel.INFO,`🧹 Cleaning the previous Powerlines artifacts`),await this.prepare(e),await this.#r(async e=>{this.context.log(d.LogLevelLabel.TRACE,`Cleaning the project's dist and artifacts directories.`),await e.fs.remove((0,f.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.output.buildPath)),await e.fs.remove((0,f.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.output.artifactsPath)),await this.callHook(`clean`,{environment:e,sequential:!1})}),this.context.log(d.LogLevelLabel.TRACE,`Powerlines - Clean command completed`)}async lint(e={command:`lint`}){this.context.log(d.LogLevelLabel.INFO,`📋 Linting the Powerlines project`),await this.prepare(e),await this.#r(async e=>{e.config.lint!==!1&&await this.callHook(`lint`,{environment:e,sequential:!1})}),this.context.log(d.LogLevelLabel.TRACE,`Powerlines linting completed`)}async build(e={command:`build`}){this.context.log(d.LogLevelLabel.INFO,`📦 Building the Powerlines project`),await this.prepare(e),this.context.config.singleBuild?await this.#t(await this.#e.toEnvironment()):await this.#r(async e=>{await this.#t(e)}),this.context.log(d.LogLevelLabel.TRACE,`Powerlines build completed`)}async docs(e={command:`docs`}){this.context.log(d.LogLevelLabel.INFO,`📓 Generating documentation for the Powerlines project`),await this.prepare(e),await this.#r(async t=>{t.log(d.LogLevelLabel.TRACE,`Writing documentation for the Powerlines project artifacts.`),await this.prepare(e),await this.#r(async e=>{await this.callHook(`docs`,{environment:e})})}),this.#e.log(d.LogLevelLabel.TRACE,`Powerlines documentation generation completed`)}async deploy(e={command:`deploy`}){this.context.log(d.LogLevelLabel.INFO,`📦 Deploying the Powerlines project`),await this.prepare(e),await this.#r(async e=>{await this.callHook(`deploy`,{environment:e})}),this.context.log(d.LogLevelLabel.TRACE,`Powerlines deploy completed`)}async finalize(){this.context.log(d.LogLevelLabel.TRACE,`Powerlines finalize execution started`),await this.#r(async e=>{await this.callHook(`finalize`,{environment:e}),await e.fs.dispose()}),this.context.log(d.LogLevelLabel.TRACE,`Powerlines finalize execution completed`)}async callHook(e,t,...n){return r.callHook((0,A.isSetObject)(t?.environment)?t.environment:await this.#e.getEnvironment(t?.environment),e,{sequential:!0,...t},...n)}async[Symbol.asyncDispose](){await this.finalize()}async#t(e){if(await this.callHook(`build`,{environment:e,order:`pre`}),await this.callHook(`build`,{environment:e,order:`normal`}),e.config.output.buildPath!==e.config.output.outputPath){let t=(0,g.appendPath)(e.config.output.buildPath,e.workspaceConfig.workspaceRoot),n=(0,f.joinPaths)((0,g.appendPath)(e.config.output.outputPath,e.workspaceConfig.workspaceRoot),`dist`);t!==n&&(e.log(d.LogLevelLabel.INFO,`Copying build output files from project's build directory (${e.config.output.buildPath}) to the workspace's output directory (${e.config.output.outputPath}).`),await e.fs.copy(t,n))}await Promise.all(e.config.output.assets.map(async t=>{e.log(d.LogLevelLabel.DEBUG,`Copying asset(s): ${j.default.redBright(e.workspaceConfig.workspaceRoot===t.input?t.glob:(0,f.joinPaths)((0,p.replacePath)(t.input,e.workspaceConfig.workspaceRoot),t.glob))} -> ${j.default.greenBright((0,f.joinPaths)((0,p.replacePath)(t.output,e.workspaceConfig.workspaceRoot),t.glob))} ${Array.isArray(t.ignore)&&t.ignore.length>0?` (ignoring: ${t.ignore.map(e=>j.default.yellowBright(e)).join(`, `)})`:``}`),await e.fs.copy(t,t.output)})),await this.callHook(`build`,{environment:e,order:`post`})}async#n(){return!this.context.config.environments||Object.keys(this.context.config.environments).length<=1?(this.context.log(d.LogLevelLabel.DEBUG,`No environments are configured for this Powerlines project. Using the default environment.`),[await this.context.getEnvironment()]):(this.context.log(d.LogLevelLabel.DEBUG,`Found ${Object.keys(this.context.config.environments).length} configured environment(s) for this Powerlines project.`),(await Promise.all(Object.entries(this.context.config.environments).map(async([e,t])=>{if(!await this.context.getEnvironmentSafe(e)){let n=await this.callHook(`configEnvironment`,{environment:e},e,t);n&&(this.context.environments[e]=await this.context.in(n))}return this.context.environments[e]}))).filter(e=>(0,k.isSet)(e)))}async#r(e){await Promise.all((await this.#n()).map(async t=>Promise.resolve(e(t))))}async#i(e){if(e){let t=await this.#a(e);if(!t)return;if(t.dependsOn)for(let e of t.dependsOn)await this.#i(e);this.context.log(d.LogLevelLabel.DEBUG,`Successfully initialized the ${j.default.bold.cyanBright(t.name)} plugin`),await this.context.addPlugin(t)}}async#a(e){let t=e;if((0,O.isPromiseLike)(e)&&(t=await Promise.resolve(e)),!s.isPluginConfig(t))throw Error(`Invalid plugin specified in the configuration - ${JSON.stringify(t)}. Please ensure the value is a plugin name, an object with the \`plugin\` and \`props\` properties, or an instance of \`Plugin\`.`);let n;if(s.isPlugin(t))n=t;else if((0,T.isFunction)(t))n=await Promise.resolve(t());else if((0,_.isSetString)(t)){let e=await this.#o(t);n=(0,T.isFunction)(e)?await Promise.resolve(e()):e}else if(s.isPluginConfigTuple(t)||s.isPluginConfigObject(t)){let e,r;if(s.isPluginConfigTuple(t)?(e=t[0],r=t?.length===2?t[1]:void 0):(e=t.plugin,r=t.options),(0,_.isSetString)(e)){let t=await this.#o(e);n=(0,T.isFunction)(t)?await Promise.resolve(r?t(r):t()):t}else (0,T.isFunction)(e)?n=await Promise.resolve(e(r)):s.isPlugin(e)&&(n=e)}if(!n)throw Error(`The plugin configuration ${JSON.stringify(t)} is invalid. This configuration must point to a valid Powerlines plugin module.`);if(!s.isPlugin(n))throw Error(`The plugin option ${JSON.stringify(n)} does not export a valid module. This configuration must point to a valid Powerlines plugin module.`);return s.checkDedupe(n,this.context.plugins)?(this.context.log(d.LogLevelLabel.TRACE,`Duplicate ${j.default.bold.cyanBright(n.name)} plugin dependency detected - Skipping initialization.`),null):(this.context.log(d.LogLevelLabel.TRACE,`Initializing the ${j.default.bold.cyanBright(n.name)} plugin...`),n)}async#o(e){if(e.startsWith(`@`)&&e.split(`/`).filter(Boolean).length>2){let t=e.split(`/`).filter(Boolean);e=`${t[0]}/${t[1]}`}let t=(0,S.isPackageExists)(e,{paths:[this.context.workspaceConfig.workspaceRoot,this.context.config.projectRoot]});if(!t&&this.context.config.skipInstalls!==!0){this.#e.log(d.LogLevelLabel.WARN,`The plugin package "${e}" is not installed. It will be installed automatically.`);let t=await(0,x.install)(e,{cwd:this.context.config.projectRoot});if((0,E.isNumber)(t.exitCode)&&t.exitCode>0)throw this.#e.log(d.LogLevelLabel.ERROR,t.stderr),Error(`An error occurred while installing the build plugin package "${e}" `)}try{let t=await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve((0,f.joinPaths)(e,`plugin`))),n=t.plugin??t.default;if(!n)throw Error(`The plugin package "${e}" does not export a valid module.`);return n}catch(n){try{let t=await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(e)),n=t.plugin??t.default;if(!n)throw Error(`The plugin package "${e}" does not export a valid module.`);return n}catch{throw t?Error(`An error occurred while importing the build plugin package "${e}":
9
9
  ${(0,w.isError)(n)?n.message:String(n)}
10
10
 
11
11
  Note: 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\`.`):Error(`The plugin package "${e}" is not installed. Please install the package using the command: "npm install ${e} --save-dev"`)}}}};
@@ -1 +1 @@
1
- import{moduleResolverBabelPlugin as e}from"./internal/babel/module-resolver-plugin.mjs";import{emitTypes as t,formatTypes as n}from"./internal/helpers/generate-types.mjs";import{callHook as r}from"./internal/helpers/hooks.mjs";import{installDependencies as i}from"./internal/helpers/install-dependencies.mjs";import{getParsedTypeScriptConfig as a,isIncludeMatchFound as o}from"./lib/typescript/tsconfig.mjs";import{getTsconfigDtsPath as s,initializeTsconfig as c,resolveTsconfig as l}from"./internal/helpers/resolve-tsconfig.mjs";import{checkDedupe as u,isPlugin as d,isPluginConfig as f,isPluginConfigObject as p,isPluginConfigTuple as m}from"./plugin-utils/helpers.mjs";import{writeMetaFile as h}from"./lib/utilities/meta.mjs";import{PowerlinesAPIContext as g}from"./lib/contexts/api-context.mjs";import{getFileHeader as _}from"./lib/utilities/file-header.mjs";import{LogLevelLabel as v}from"@storm-software/config-tools/types";import{isPackageExists as y}from"@stryke/fs/package-fns";import{joinPaths as b}from"@stryke/path/join-paths";import{replacePath as x}from"@stryke/path/replace";import{toArray as S}from"@stryke/convert/to-array";import{listFiles as C}from"@stryke/fs/list-files";import{appendPath as w}from"@stryke/path/append";import{isSetString as T}from"@stryke/type-checks/is-set-string";import{transformAsync as E}from"@babel/core";import{formatLogMessage as D}from"@storm-software/config-tools/logger/console";import{createDirectory as O}from"@stryke/fs/helpers";import{install as k}from"@stryke/fs/install";import{resolvePackage as A}from"@stryke/fs/resolve";import{isError as j}from"@stryke/type-checks/is-error";import{isFunction as M}from"@stryke/type-checks/is-function";import{isNumber as N}from"@stryke/type-checks/is-number";import{isObject as P}from"@stryke/type-checks/is-object";import{isPromiseLike as F}from"@stryke/type-checks/is-promise";import{isSet as I}from"@stryke/type-checks/is-set";import{isSetObject as L}from"@stryke/type-checks/is-set-object";import R from"chalk";import z from"handlebars";Symbol.asyncDispose;export{};
1
+ import{moduleResolverBabelPlugin as e}from"./internal/babel/module-resolver-plugin.mjs";import{emitTypes as t,formatTypes as n}from"./internal/helpers/generate-types.mjs";import{callHook as r}from"./internal/helpers/hooks.mjs";import{installDependencies as i}from"./internal/helpers/install-dependencies.mjs";import{getParsedTypeScriptConfig as a,isIncludeMatchFound as o}from"./lib/typescript/tsconfig.mjs";import{getTsconfigDtsPath as s,initializeTsconfig as c,resolveTsconfig as l}from"./internal/helpers/resolve-tsconfig.mjs";import{checkDedupe as u,isPlugin as d,isPluginConfig as f,isPluginConfigObject as p,isPluginConfigTuple as m}from"./plugin-utils/helpers.mjs";import{writeMetaFile as h}from"./lib/utilities/meta.mjs";import{PowerlinesAPIContext as g}from"./lib/contexts/api-context.mjs";import{getFileHeader as _}from"./lib/utilities/file-header.mjs";import{LogLevelLabel as v}from"@storm-software/config-tools/types";import{joinPaths as y}from"@stryke/path/join-paths";import{replacePath as b}from"@stryke/path/replace";import{toArray as x}from"@stryke/convert/to-array";import{listFiles as S}from"@stryke/fs/list-files";import{appendPath as C}from"@stryke/path/append";import{isSetString as w}from"@stryke/type-checks/is-set-string";import{transformAsync as T}from"@babel/core";import{formatLogMessage as E}from"@storm-software/config-tools/logger/console";import{createDirectory as D}from"@stryke/fs/helpers";import{install as O}from"@stryke/fs/install";import{isPackageExists as k}from"@stryke/fs/package-fns";import{resolvePackage as A}from"@stryke/fs/resolve";import{isError as j}from"@stryke/type-checks/is-error";import{isFunction as M}from"@stryke/type-checks/is-function";import{isNumber as N}from"@stryke/type-checks/is-number";import{isObject as P}from"@stryke/type-checks/is-object";import{isPromiseLike as F}from"@stryke/type-checks/is-promise";import{isSet as I}from"@stryke/type-checks/is-set";import{isSetObject as L}from"@stryke/type-checks/is-set-object";import R from"chalk";import z from"handlebars";Symbol.asyncDispose;export{};
@@ -1 +1 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`defu`);t=e.__toESM(t);let n=require(`@stryke/string-format/title-case`);const r=`default`;function i(e,r){return(0,t.default)(r.environments?.[e]??{},{name:e,title:r.title||(0,n.titleCase)(r.name),ssr:!1,mainFields:r.build?.platform===`browser`?[`browser`,`module`,`jsnext:main`,`jsnext`]:[`module`,`jsnext:main`,`jsnext`],extensions:[`.mjs`,`.js`,`.mts`,`.ts`,`.jsx`,`.tsx`,`.json`],consumer:r.build?.platform===`browser`?`client`:`server`,preview:r.build?.platform===`browser`?{port:5173,open:!0,strictPort:!1,host:`localhost`,allowedHosts:[`.`],cors:!0,headers:{}}:void 0},r)}function a(e){return i(`default`,e)}exports.createDefaultEnvironment=a,exports.createEnvironment=i;
1
+ const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`defu`);t=e.__toESM(t);let n=require(`@stryke/string-format/title-case`);const r=`__DEFAULT__`,i=`__GLOBAL__`;function a(e,r){return(0,t.default)(r.environments?.[e]??{},{name:e,title:r.title||(0,n.titleCase)(r.name),ssr:!1,mainFields:r.build?.platform===`browser`?[`browser`,`module`,`jsnext:main`,`jsnext`]:[`module`,`jsnext:main`,`jsnext`],extensions:[`.mjs`,`.js`,`.mts`,`.ts`,`.jsx`,`.tsx`,`.json`],consumer:r.build?.platform===`browser`?`client`:`server`,preview:r.build?.platform===`browser`?{port:5173,open:!0,strictPort:!1,host:`localhost`,allowedHosts:[`.`],cors:!0,headers:{}}:void 0},r)}function o(e){return a(`__DEFAULT__`,e)}exports.GLOBAL_ENVIRONMENT=`__GLOBAL__`,exports.createDefaultEnvironment=o,exports.createEnvironment=a;
@@ -1 +1 @@
1
- import e from"defu";import{titleCase as t}from"@stryke/string-format/title-case";function n(n,r){return e(r.environments?.[n]??{},{name:n,title:r.title||t(r.name),ssr:!1,mainFields:r.build?.platform===`browser`?[`browser`,`module`,`jsnext:main`,`jsnext`]:[`module`,`jsnext:main`,`jsnext`],extensions:[`.mjs`,`.js`,`.mts`,`.ts`,`.jsx`,`.tsx`,`.json`],consumer:r.build?.platform===`browser`?`client`:`server`,preview:r.build?.platform===`browser`?{port:5173,open:!0,strictPort:!1,host:`localhost`,allowedHosts:[`.`],cors:!0,headers:{}}:void 0},r)}function r(e){return n(`default`,e)}export{r as createDefaultEnvironment,n as createEnvironment};
1
+ import e from"defu";import{titleCase as t}from"@stryke/string-format/title-case";const n=`__GLOBAL__`;function r(n,r){return e(r.environments?.[n]??{},{name:n,title:r.title||t(r.name),ssr:!1,mainFields:r.build?.platform===`browser`?[`browser`,`module`,`jsnext:main`,`jsnext`]:[`module`,`jsnext:main`,`jsnext`],extensions:[`.mjs`,`.js`,`.mts`,`.ts`,`.jsx`,`.tsx`,`.json`],consumer:r.build?.platform===`browser`?`client`:`server`,preview:r.build?.platform===`browser`?{port:5173,open:!0,strictPort:!1,host:`localhost`,allowedHosts:[`.`],cors:!0,headers:{}}:void 0},r)}function i(e){return r(`__DEFAULT__`,e)}export{n as GLOBAL_ENVIRONMENT,i as createDefaultEnvironment,r as createEnvironment};
@@ -0,0 +1,48 @@
1
+ import { SelectHooksOptions } from "../../types/context.cjs";
2
+ import { MaybePromise } from "@stryke/types/base";
3
+ import { ArrayValues } from "@stryke/types/array";
4
+
5
+ //#region ../powerlines/src/internal/helpers/hooks.d.ts
6
+ type CallHookOptions = SelectHooksOptions & (({
7
+ /**
8
+ * Whether to call the hooks sequentially or in parallel.
9
+ *
10
+ * @defaultValue true
11
+ */
12
+ sequential?: true;
13
+ } & ({
14
+ /**
15
+ * How to handle multiple return values from hooks.
16
+ * - "merge": Merge all non-undefined return values (if they are objects).
17
+ * - "first": Return the first non-undefined value.
18
+ *
19
+ * @remarks
20
+ * Merging only works if the return values are objects.
21
+ *
22
+ * @defaultValue "merge"
23
+ */
24
+ result: "first";
25
+ } | {
26
+ /**
27
+ * How to handle multiple return values from hooks.
28
+ * - "merge": Merge all non-undefined return values (if they are objects).
29
+ * - "first": Return the first non-undefined value.
30
+ *
31
+ * @remarks
32
+ * Merging only works if the return values are objects.
33
+ *
34
+ * @defaultValue "merge"
35
+ */
36
+ result?: "merge" | "last";
37
+ /**
38
+ * An indicator specifying if the results of the previous hook should be provided as the **first** parameter of the next hook function, or a function to process the result of the previous hook function and pass the returned value as the next hook's **first** parameter
39
+ */
40
+ asNextParam?: false | ((previousResult: any) => MaybePromise<any>);
41
+ })) | {
42
+ /**
43
+ * Whether to call the hooks sequentially or in parallel.
44
+ */
45
+ sequential: false;
46
+ });
47
+ //#endregion
48
+ export { CallHookOptions };
@@ -0,0 +1,50 @@
1
+ import "../../types/resolved.mjs";
2
+ import "../../types/hooks.mjs";
3
+ import { SelectHooksOptions } from "../../types/context.mjs";
4
+ import { MaybePromise } from "@stryke/types/base";
5
+ import { ArrayValues } from "@stryke/types/array";
6
+
7
+ //#region ../powerlines/src/internal/helpers/hooks.d.ts
8
+ type CallHookOptions = SelectHooksOptions & (({
9
+ /**
10
+ * Whether to call the hooks sequentially or in parallel.
11
+ *
12
+ * @defaultValue true
13
+ */
14
+ sequential?: true;
15
+ } & ({
16
+ /**
17
+ * How to handle multiple return values from hooks.
18
+ * - "merge": Merge all non-undefined return values (if they are objects).
19
+ * - "first": Return the first non-undefined value.
20
+ *
21
+ * @remarks
22
+ * Merging only works if the return values are objects.
23
+ *
24
+ * @defaultValue "merge"
25
+ */
26
+ result: "first";
27
+ } | {
28
+ /**
29
+ * How to handle multiple return values from hooks.
30
+ * - "merge": Merge all non-undefined return values (if they are objects).
31
+ * - "first": Return the first non-undefined value.
32
+ *
33
+ * @remarks
34
+ * Merging only works if the return values are objects.
35
+ *
36
+ * @defaultValue "merge"
37
+ */
38
+ result?: "merge" | "last";
39
+ /**
40
+ * An indicator specifying if the results of the previous hook should be provided as the **first** parameter of the next hook function, or a function to process the result of the previous hook function and pass the returned value as the next hook's **first** parameter
41
+ */
42
+ asNextParam?: false | ((previousResult: any) => MaybePromise<any>);
43
+ })) | {
44
+ /**
45
+ * Whether to call the hooks sequentially or in parallel.
46
+ */
47
+ sequential: false;
48
+ });
49
+ //#endregion
50
+ export { CallHookOptions };
@@ -1 +1 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@storm-software/config-tools/types`),n=require(`@stryke/fs/package-fns`),r=require(`@stryke/fs/install`),i=require(`@stryke/type-checks/is-number`),a=require(`@stryke/string-format/package`);async function o(e,o,s=!1){if(await(0,n.isPackageListed)((0,a.getPackageName)(o),{cwd:e.config.projectRoot})){if((0,a.hasPackageVersion)(o)&&!process.env.POWERLINES_SKIP_VERSION_CHECK&&!await(0,n.doesPackageMatch)((0,a.getPackageName)(o),(0,a.getPackageVersion)(o),e.config.projectRoot)){let r=await(0,n.getPackageListing)((0,a.getPackageName)(o),{cwd:e.config.projectRoot});!r?.version.startsWith(`catalog:`)&&!r?.version.startsWith(`workspace:`)&&e.log(t.LogLevelLabel.WARN,`The package "${(0,a.getPackageName)(o)}" is installed but does not match the expected version ${(0,a.getPackageVersion)(o)} (installed version: ${r?.version||`<Unknown>`}). Please ensure this is intentional before proceeding. Note: You can skip this validation with the "STORM_STACK_SKIP_VERSION_CHECK" environment variable.`)}}else if(e.config.skipInstalls!==!0){e.log(t.LogLevelLabel.WARN,`The package "${o}" is not installed. It will be installed automatically.`);let n=await(0,r.install)(o,{cwd:e.config.projectRoot,dev:s});if((0,i.isNumber)(n.exitCode)&&n.exitCode>0)throw e.log(t.LogLevelLabel.ERROR,n.stderr),Error(`An error occurred while installing the package "${o}"`)}else e.log(t.LogLevelLabel.WARN,`The package "${o}" is not installed. Since the "skipInstalls" option is set to true, it will not be installed automatically.`)}exports.installPackage=o;
1
+ const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@storm-software/config-tools/types`),n=require(`@stryke/fs/install`),r=require(`@stryke/fs/package-fns`),i=require(`@stryke/type-checks/is-number`),a=require(`@stryke/string-format/package`);async function o(e,o,s=!1){if(await(0,r.isPackageListed)((0,a.getPackageName)(o),{cwd:e.config.projectRoot})){if((0,a.hasPackageVersion)(o)&&!process.env.POWERLINES_SKIP_VERSION_CHECK&&!await(0,r.doesPackageMatch)((0,a.getPackageName)(o),(0,a.getPackageVersion)(o),e.config.projectRoot)){let n=await(0,r.getPackageListing)((0,a.getPackageName)(o),{cwd:e.config.projectRoot});!n?.version.startsWith(`catalog:`)&&!n?.version.startsWith(`workspace:`)&&e.log(t.LogLevelLabel.WARN,`The package "${(0,a.getPackageName)(o)}" is installed but does not match the expected version ${(0,a.getPackageVersion)(o)} (installed version: ${n?.version||`<Unknown>`}). Please ensure this is intentional before proceeding. Note: You can skip this validation with the "STORM_STACK_SKIP_VERSION_CHECK" environment variable.`)}}else if(e.config.skipInstalls!==!0){e.log(t.LogLevelLabel.WARN,`The package "${o}" is not installed. It will be installed automatically.`);let r=await(0,n.install)(o,{cwd:e.config.projectRoot,dev:s});if((0,i.isNumber)(r.exitCode)&&r.exitCode>0)throw e.log(t.LogLevelLabel.ERROR,r.stderr),Error(`An error occurred while installing the package "${o}"`)}else e.log(t.LogLevelLabel.WARN,`The package "${o}" is not installed. Since the "skipInstalls" option is set to true, it will not be installed automatically.`)}exports.installPackage=o;
@@ -1 +1 @@
1
- import{LogLevelLabel as e}from"@storm-software/config-tools/types";import{doesPackageMatch as t,getPackageListing as n,isPackageListed as r}from"@stryke/fs/package-fns";import{install as i}from"@stryke/fs/install";import{isNumber as a}from"@stryke/type-checks/is-number";import{getPackageName as o,getPackageVersion as s,hasPackageVersion as c}from"@stryke/string-format/package";async function l(l,u,d=!1){if(await r(o(u),{cwd:l.config.projectRoot})){if(c(u)&&!process.env.POWERLINES_SKIP_VERSION_CHECK&&!await t(o(u),s(u),l.config.projectRoot)){let t=await n(o(u),{cwd:l.config.projectRoot});!t?.version.startsWith(`catalog:`)&&!t?.version.startsWith(`workspace:`)&&l.log(e.WARN,`The package "${o(u)}" is installed but does not match the expected version ${s(u)} (installed version: ${t?.version||`<Unknown>`}). Please ensure this is intentional before proceeding. Note: You can skip this validation with the "STORM_STACK_SKIP_VERSION_CHECK" environment variable.`)}}else if(l.config.skipInstalls!==!0){l.log(e.WARN,`The package "${u}" is not installed. It will be installed automatically.`);let t=await i(u,{cwd:l.config.projectRoot,dev:d});if(a(t.exitCode)&&t.exitCode>0)throw l.log(e.ERROR,t.stderr),Error(`An error occurred while installing the package "${u}"`)}else l.log(e.WARN,`The package "${u}" is not installed. Since the "skipInstalls" option is set to true, it will not be installed automatically.`)}export{l as installPackage};
1
+ import{LogLevelLabel as e}from"@storm-software/config-tools/types";import{install as t}from"@stryke/fs/install";import{doesPackageMatch as n,getPackageListing as r,isPackageListed as i}from"@stryke/fs/package-fns";import{isNumber as a}from"@stryke/type-checks/is-number";import{getPackageName as o,getPackageVersion as s,hasPackageVersion as c}from"@stryke/string-format/package";async function l(l,u,d=!1){if(await i(o(u),{cwd:l.config.projectRoot})){if(c(u)&&!process.env.POWERLINES_SKIP_VERSION_CHECK&&!await n(o(u),s(u),l.config.projectRoot)){let t=await r(o(u),{cwd:l.config.projectRoot});!t?.version.startsWith(`catalog:`)&&!t?.version.startsWith(`workspace:`)&&l.log(e.WARN,`The package "${o(u)}" is installed but does not match the expected version ${s(u)} (installed version: ${t?.version||`<Unknown>`}). Please ensure this is intentional before proceeding. Note: You can skip this validation with the "STORM_STACK_SKIP_VERSION_CHECK" environment variable.`)}}else if(l.config.skipInstalls!==!0){l.log(e.WARN,`The package "${u}" is not installed. It will be installed automatically.`);let n=await t(u,{cwd:l.config.projectRoot,dev:d});if(a(n.exitCode)&&n.exitCode>0)throw l.log(e.ERROR,n.stderr),Error(`An error occurred while installing the package "${u}"`)}else l.log(e.WARN,`The package "${u}" is not installed. Since the "skipInstalls" option is set to true, it will not be installed automatically.`)}export{l as installPackage};
@@ -1,4 +1,4 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../../lib/typescript/tsconfig.cjs`);let n=require(`@storm-software/config-tools/types`),r=require(`@stryke/fs/package-fns`),i=require(`@stryke/path/join-paths`),a=require(`chalk`);a=e.__toESM(a);let o=require(`@donedeal0/superdiff`),s=require(`@stryke/fs/json`),c=require(`@stryke/json/storm-json`),l=require(`@stryke/path/file-path-fns`),u=require(`@stryke/string-format/title-case`);function d(e){return(0,i.joinPaths)((0,l.relativePath)((0,i.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot),(0,l.findFilePath)(e.dtsPath)),(0,l.findFileName)(e.dtsPath))}async function f(e){let n=t.getParsedTypeScriptConfig(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig,e.config.tsconfigRaw),r=await(0,s.readJsonFile)(t.getTsconfigFilePath(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig));if(r.compilerOptions??={},e.config.output.dts!==!1){let n=d(e);r.include?.some(r=>t.isIncludeMatchFound(r,[e.dtsPath,n]))||(r.include??=[],r.include.push(n.startsWith(`./`)?n.slice(2):n))}return n.options.lib?.some(e=>[`lib.esnext.d.ts`,`lib.es2021.d.ts`,`lib.es2022.d.ts`,`lib.es2023.d.ts`].includes(e.toLowerCase()))||(r.compilerOptions.lib??=[],r.compilerOptions.lib.push(`esnext`)),n.options.esModuleInterop!==!0&&(r.compilerOptions.esModuleInterop=!0),n.options.isolatedModules!==!0&&(r.compilerOptions.isolatedModules=!0),e.config.build.platform===`node`&&(n.options.types?.some(e=>e.toLowerCase()===`node`||e.toLowerCase()===`@types/node`)||(r.compilerOptions.types??=[],r.compilerOptions.types.push(`node`))),r}async function p(e){if(e.log(n.LogLevelLabel.TRACE,`Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.`),!(0,r.isPackageExists)(`typescript`))throw Error(`The TypeScript package is not installed. Please install the package using the command: "npm install typescript --save-dev"`);let i=t.getTsconfigFilePath(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig);e.tsconfig.originalTsconfigJson=await(0,s.readJsonFile)(i),e.tsconfig.tsconfigJson=await f(e),e.log(n.LogLevelLabel.TRACE,`Writing updated TypeScript configuration (tsconfig.json) file to disk.`),await e.fs.write(i,c.StormJSON.stringify(e.tsconfig.tsconfigJson)),e.tsconfig=t.getParsedTypeScriptConfig(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig,e.config.tsconfigRaw,e.tsconfig.originalTsconfigJson)}async function m(e){let r=await(0,s.readJsonFile)(e.tsconfig.tsconfigFilePath);r?.compilerOptions?.types&&Array.isArray(r.compilerOptions.types)&&!r.compilerOptions.types.length&&delete r.compilerOptions.types;let i=(0,o.getObjectDiff)(e.tsconfig.originalTsconfigJson,r,{ignoreArrayOrder:!0,showOnly:{statuses:[`added`,`deleted`,`updated`],granularity:`deep`}}),l=[],d=(e,t)=>{if(e.status===`added`||e.status===`deleted`||e.status===`updated`)if(e.diff)for(let n of e.diff)d(n,t?`${t}.${e.property}`:e.property);else l.push({field:t?`${t}.${e.property}`:e.property,status:e.status,previous:e.status===`added`?`---`:c.StormJSON.stringify(e.previousValue),current:e.status===`deleted`?`---`:c.StormJSON.stringify(e.currentValue)})};for(let e of i.diff)d(e);if(l.length>0&&e.log(n.LogLevelLabel.WARN,`Updating the following configuration values in "${e.tsconfig.tsconfigFilePath}" file:
1
+ const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../../lib/typescript/tsconfig.cjs`);let n=require(`@storm-software/config-tools/types`),r=require(`@stryke/path/join-paths`),i=require(`@stryke/fs/package-fns`),a=require(`chalk`);a=e.__toESM(a);let o=require(`@donedeal0/superdiff`),s=require(`@stryke/fs/json`),c=require(`@stryke/json/storm-json`),l=require(`@stryke/path/file-path-fns`),u=require(`@stryke/string-format/title-case`);function d(e){return(0,r.joinPaths)((0,l.relativePath)((0,r.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot),(0,l.findFilePath)(e.dtsPath)),(0,l.findFileName)(e.dtsPath))}async function f(e){let n=t.getParsedTypeScriptConfig(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig,e.config.tsconfigRaw),r=await(0,s.readJsonFile)(t.getTsconfigFilePath(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig));if(r.compilerOptions??={},e.config.output.dts!==!1){let n=d(e);r.include?.some(r=>t.isIncludeMatchFound(r,[e.dtsPath,n]))||(r.include??=[],r.include.push(n.startsWith(`./`)?n.slice(2):n))}return n.options.lib?.some(e=>[`lib.esnext.d.ts`,`lib.es2021.d.ts`,`lib.es2022.d.ts`,`lib.es2023.d.ts`].includes(e.toLowerCase()))||(r.compilerOptions.lib??=[],r.compilerOptions.lib.push(`esnext`)),n.options.esModuleInterop!==!0&&(r.compilerOptions.esModuleInterop=!0),n.options.isolatedModules!==!0&&(r.compilerOptions.isolatedModules=!0),e.config.build.platform===`node`&&(n.options.types?.some(e=>e.toLowerCase()===`node`||e.toLowerCase()===`@types/node`)||(r.compilerOptions.types??=[],r.compilerOptions.types.push(`node`))),r}async function p(e){if(e.log(n.LogLevelLabel.TRACE,`Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.`),!(0,i.isPackageExists)(`typescript`))throw Error(`The TypeScript package is not installed. Please install the package using the command: "npm install typescript --save-dev"`);let r=t.getTsconfigFilePath(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig);e.tsconfig.originalTsconfigJson=await(0,s.readJsonFile)(r),e.tsconfig.tsconfigJson=await f(e),e.log(n.LogLevelLabel.TRACE,`Writing updated TypeScript configuration (tsconfig.json) file to disk.`),await e.fs.write(r,c.StormJSON.stringify(e.tsconfig.tsconfigJson)),e.tsconfig=t.getParsedTypeScriptConfig(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig,e.config.tsconfigRaw,e.tsconfig.originalTsconfigJson)}async function m(e){let r=await(0,s.readJsonFile)(e.tsconfig.tsconfigFilePath);r?.compilerOptions?.types&&Array.isArray(r.compilerOptions.types)&&!r.compilerOptions.types.length&&delete r.compilerOptions.types;let i=(0,o.getObjectDiff)(e.tsconfig.originalTsconfigJson,r,{ignoreArrayOrder:!0,showOnly:{statuses:[`added`,`deleted`,`updated`],granularity:`deep`}}),l=[],d=(e,t)=>{if(e.status===`added`||e.status===`deleted`||e.status===`updated`)if(e.diff)for(let n of e.diff)d(n,t?`${t}.${e.property}`:e.property);else l.push({field:t?`${t}.${e.property}`:e.property,status:e.status,previous:e.status===`added`?`---`:c.StormJSON.stringify(e.previousValue),current:e.status===`deleted`?`---`:c.StormJSON.stringify(e.currentValue)})};for(let e of i.diff)d(e);if(l.length>0&&e.log(n.LogLevelLabel.WARN,`Updating the following configuration values in "${e.tsconfig.tsconfigFilePath}" file:
2
2
 
3
3
  ${l.map((e,t)=>`${a.default.bold.whiteBright(`${t+1}. ${(0,u.titleCase)(e.status)} the ${e.field} field: `)}
4
4
  ${a.default.red(` - Previous: ${e.previous} `)}
@@ -1,4 +1,4 @@
1
- import{getParsedTypeScriptConfig as e,getTsconfigFilePath as t,isIncludeMatchFound as n}from"../../lib/typescript/tsconfig.mjs";import{LogLevelLabel as r}from"@storm-software/config-tools/types";import{isPackageExists as i}from"@stryke/fs/package-fns";import{joinPaths as a}from"@stryke/path/join-paths";import o from"chalk";import{getObjectDiff as s}from"@donedeal0/superdiff";import{readJsonFile as c}from"@stryke/fs/json";import{StormJSON as l}from"@stryke/json/storm-json";import{findFileName as u,findFilePath as d,relativePath as f}from"@stryke/path/file-path-fns";import{titleCase as p}from"@stryke/string-format/title-case";function m(e){return a(f(a(e.workspaceConfig.workspaceRoot,e.config.projectRoot),d(e.dtsPath)),u(e.dtsPath))}async function h(r){let i=e(r.workspaceConfig.workspaceRoot,r.config.projectRoot,r.config.tsconfig,r.config.tsconfigRaw),a=await c(t(r.workspaceConfig.workspaceRoot,r.config.projectRoot,r.config.tsconfig));if(a.compilerOptions??={},r.config.output.dts!==!1){let e=m(r);a.include?.some(t=>n(t,[r.dtsPath,e]))||(a.include??=[],a.include.push(e.startsWith(`./`)?e.slice(2):e))}return i.options.lib?.some(e=>[`lib.esnext.d.ts`,`lib.es2021.d.ts`,`lib.es2022.d.ts`,`lib.es2023.d.ts`].includes(e.toLowerCase()))||(a.compilerOptions.lib??=[],a.compilerOptions.lib.push(`esnext`)),i.options.esModuleInterop!==!0&&(a.compilerOptions.esModuleInterop=!0),i.options.isolatedModules!==!0&&(a.compilerOptions.isolatedModules=!0),r.config.build.platform===`node`&&(i.options.types?.some(e=>e.toLowerCase()===`node`||e.toLowerCase()===`@types/node`)||(a.compilerOptions.types??=[],a.compilerOptions.types.push(`node`))),a}async function g(n){if(n.log(r.TRACE,`Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.`),!i(`typescript`))throw Error(`The TypeScript package is not installed. Please install the package using the command: "npm install typescript --save-dev"`);let a=t(n.workspaceConfig.workspaceRoot,n.config.projectRoot,n.config.tsconfig);n.tsconfig.originalTsconfigJson=await c(a),n.tsconfig.tsconfigJson=await h(n),n.log(r.TRACE,`Writing updated TypeScript configuration (tsconfig.json) file to disk.`),await n.fs.write(a,l.stringify(n.tsconfig.tsconfigJson)),n.tsconfig=e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,n.config.tsconfig,n.config.tsconfigRaw,n.tsconfig.originalTsconfigJson)}async function _(t){let n=await c(t.tsconfig.tsconfigFilePath);n?.compilerOptions?.types&&Array.isArray(n.compilerOptions.types)&&!n.compilerOptions.types.length&&delete n.compilerOptions.types;let i=s(t.tsconfig.originalTsconfigJson,n,{ignoreArrayOrder:!0,showOnly:{statuses:[`added`,`deleted`,`updated`],granularity:`deep`}}),a=[],u=(e,t)=>{if(e.status===`added`||e.status===`deleted`||e.status===`updated`)if(e.diff)for(let n of e.diff)u(n,t?`${t}.${e.property}`:e.property);else a.push({field:t?`${t}.${e.property}`:e.property,status:e.status,previous:e.status===`added`?`---`:l.stringify(e.previousValue),current:e.status===`deleted`?`---`:l.stringify(e.currentValue)})};for(let e of i.diff)u(e);if(a.length>0&&t.log(r.WARN,`Updating the following configuration values in "${t.tsconfig.tsconfigFilePath}" file:
1
+ import{getParsedTypeScriptConfig as e,getTsconfigFilePath as t,isIncludeMatchFound as n}from"../../lib/typescript/tsconfig.mjs";import{LogLevelLabel as r}from"@storm-software/config-tools/types";import{joinPaths as i}from"@stryke/path/join-paths";import{isPackageExists as a}from"@stryke/fs/package-fns";import o from"chalk";import{getObjectDiff as s}from"@donedeal0/superdiff";import{readJsonFile as c}from"@stryke/fs/json";import{StormJSON as l}from"@stryke/json/storm-json";import{findFileName as u,findFilePath as d,relativePath as f}from"@stryke/path/file-path-fns";import{titleCase as p}from"@stryke/string-format/title-case";function m(e){return i(f(i(e.workspaceConfig.workspaceRoot,e.config.projectRoot),d(e.dtsPath)),u(e.dtsPath))}async function h(r){let i=e(r.workspaceConfig.workspaceRoot,r.config.projectRoot,r.config.tsconfig,r.config.tsconfigRaw),a=await c(t(r.workspaceConfig.workspaceRoot,r.config.projectRoot,r.config.tsconfig));if(a.compilerOptions??={},r.config.output.dts!==!1){let e=m(r);a.include?.some(t=>n(t,[r.dtsPath,e]))||(a.include??=[],a.include.push(e.startsWith(`./`)?e.slice(2):e))}return i.options.lib?.some(e=>[`lib.esnext.d.ts`,`lib.es2021.d.ts`,`lib.es2022.d.ts`,`lib.es2023.d.ts`].includes(e.toLowerCase()))||(a.compilerOptions.lib??=[],a.compilerOptions.lib.push(`esnext`)),i.options.esModuleInterop!==!0&&(a.compilerOptions.esModuleInterop=!0),i.options.isolatedModules!==!0&&(a.compilerOptions.isolatedModules=!0),r.config.build.platform===`node`&&(i.options.types?.some(e=>e.toLowerCase()===`node`||e.toLowerCase()===`@types/node`)||(a.compilerOptions.types??=[],a.compilerOptions.types.push(`node`))),a}async function g(n){if(n.log(r.TRACE,`Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.`),!a(`typescript`))throw Error(`The TypeScript package is not installed. Please install the package using the command: "npm install typescript --save-dev"`);let i=t(n.workspaceConfig.workspaceRoot,n.config.projectRoot,n.config.tsconfig);n.tsconfig.originalTsconfigJson=await c(i),n.tsconfig.tsconfigJson=await h(n),n.log(r.TRACE,`Writing updated TypeScript configuration (tsconfig.json) file to disk.`),await n.fs.write(i,l.stringify(n.tsconfig.tsconfigJson)),n.tsconfig=e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,n.config.tsconfig,n.config.tsconfigRaw,n.tsconfig.originalTsconfigJson)}async function _(t){let n=await c(t.tsconfig.tsconfigFilePath);n?.compilerOptions?.types&&Array.isArray(n.compilerOptions.types)&&!n.compilerOptions.types.length&&delete n.compilerOptions.types;let i=s(t.tsconfig.originalTsconfigJson,n,{ignoreArrayOrder:!0,showOnly:{statuses:[`added`,`deleted`,`updated`],granularity:`deep`}}),a=[],u=(e,t)=>{if(e.status===`added`||e.status===`deleted`||e.status===`updated`)if(e.diff)for(let n of e.diff)u(n,t?`${t}.${e.property}`:e.property);else a.push({field:t?`${t}.${e.property}`:e.property,status:e.status,previous:e.status===`added`?`---`:l.stringify(e.previousValue),current:e.status===`deleted`?`---`:l.stringify(e.currentValue)})};for(let e of i.diff)u(e);if(a.length>0&&t.log(r.WARN,`Updating the following configuration values in "${t.tsconfig.tsconfigFilePath}" file:
2
2
 
3
3
  ${a.map((e,t)=>`${o.bold.whiteBright(`${t+1}. ${p(e.status)} the ${e.field} field: `)}
4
4
  ${o.red(` - Previous: ${e.previous} `)}
@@ -1 +1 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/path/join-paths`),n=require(`defu`);n=e.__toESM(n);let r=require(`jiti`);function i(e){return(0,n.default)(e,{interopDefault:!0,fsCache:e.mode===`development`?!1:(0,t.joinPaths)(e.cacheDir,`jiti`),moduleCache:e.mode!==`development`})}function a(e){return(0,r.createJiti)((0,t.joinPaths)(e.workspaceRoot,e.projectRoot),i({...e}))}function o(e){let n=(0,r.createJiti)((0,t.joinPaths)(e.workspaceRoot,e.projectRoot),i(e));return n.plugin=a(e),n}exports.createResolver=o;
1
+ const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`defu`);t=e.__toESM(t);let n=require(`@stryke/path/join-paths`),r=require(`jiti`);function i(e){return(0,t.default)(e,{interopDefault:!0,fsCache:e.mode===`development`?!1:(0,n.joinPaths)(e.cacheDir,`jiti`),moduleCache:e.mode!==`development`})}function a(e){return(0,r.createJiti)((0,n.joinPaths)(e.workspaceRoot,e.projectRoot),i({...e}))}function o(e){let t=(0,r.createJiti)((0,n.joinPaths)(e.workspaceRoot,e.projectRoot),i(e));return t.plugin=a(e),t}exports.createResolver=o;
@@ -1 +1 @@
1
- import{joinPaths as e}from"@stryke/path/join-paths";import t from"defu";import{createJiti as n}from"jiti";function r(n){return t(n,{interopDefault:!0,fsCache:n.mode===`development`?!1:e(n.cacheDir,`jiti`),moduleCache:n.mode!==`development`})}function i(t){return n(e(t.workspaceRoot,t.projectRoot),r({...t}))}function a(t){let a=n(e(t.workspaceRoot,t.projectRoot),r(t));return a.plugin=i(t),a}export{a as createResolver};
1
+ import e from"defu";import{joinPaths as t}from"@stryke/path/join-paths";import{createJiti as n}from"jiti";function r(n){return e(n,{interopDefault:!0,fsCache:n.mode===`development`?!1:t(n.cacheDir,`jiti`),moduleCache:n.mode!==`development`})}function i(e){return n(t(e.workspaceRoot,e.projectRoot),r({...e}))}function a(e){let a=n(t(e.workspaceRoot,e.projectRoot),r(e));return a.plugin=i(e),a}export{a as createResolver};
@@ -1,4 +1,4 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`);require(`../entry.cjs`);let t=require(`@stryke/path/join-paths`),n=require(`defu`);n=e.__toESM(n);let r=require(`@stryke/helpers/omit`),i=require(`@stryke/path/replace`),a=require(`@stryke/string-format/camel-case`),o=require(`@stryke/type-checks/is-string`);const s={target:`esnext`,platform:`neutral`,format:`esm`,write:!0,minify:!0,sourcemap:!1,bundle:!0,treeShaking:!0,keepNames:!0,splitting:!0,logLevel:`silent`};function c(e){let i=e.config.build.override.inject??e.config.build.inject;return i&&Object.keys(i).length>0&&e.fs.writeSync((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.artifactsPath,`inject-shim.js`),Object.entries(i).map(([e,t])=>{if(t)if(Array.isArray(t)){if((0,a.camelCase)(e)!==e){if(t.length===1)return`
1
+ const e=require(`../../../../_virtual/rolldown_runtime.cjs`);require(`../entry.cjs`);let t=require(`defu`);t=e.__toESM(t);let n=require(`@stryke/helpers/omit`),r=require(`@stryke/path/join-paths`),i=require(`@stryke/path/replace`),a=require(`@stryke/string-format/camel-case`),o=require(`@stryke/type-checks/is-string`);const s={target:`esnext`,platform:`neutral`,format:`esm`,write:!0,minify:!0,sourcemap:!1,bundle:!0,treeShaking:!0,keepNames:!0,splitting:!0,logLevel:`silent`};function c(e){let i=e.config.build.override.inject??e.config.build.inject;return i&&Object.keys(i).length>0&&e.fs.writeSync((0,r.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.artifactsPath,`inject-shim.js`),Object.entries(i).map(([e,t])=>{if(t)if(Array.isArray(t)){if((0,a.camelCase)(e)!==e){if(t.length===1)return`
2
2
  import ${(0,a.camelCase)(e)} from "${t[0]}";
3
3
  export { ${(0,a.camelCase)(e)} as "${e}" }`;if(t.length>1)return`
4
4
  import ${t[1]===`*`?`* as ${(0,a.camelCase)(e)}`:`{ ${t[1]} as ${(0,a.camelCase)(e)} }`} from "${t[0]}";
@@ -11,4 +11,4 @@ import ${(0,a.camelCase)(e)} from "${t[0]}";
11
11
  export { ${(0,a.camelCase)(e)} as "${e}" }`;else return`
12
12
  import ${e} from "${t}";
13
13
  export { ${e} };`;return``}).join(`
14
- `)),(0,n.default)({alias:e.builtins.reduce((t,n)=>{if(!t[n]){let r=e.fs.ids[n];r&&(t[n]=r)}return t},e.config.build.alias?Array.isArray(e.config.build.alias)?e.config.build.alias.reduce((e,t)=>(e[t.find.toString()]||(e[t.find.toString()]=t.replacement),e),{}):e.config.build.alias:{}),inject:i&&Object.keys(i).length>0?[(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.artifactsPath,`inject-shim.js`)]:void 0},e.config.build.variant===`esbuild`?(0,r.omit)(e.config.build.override,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`]):{},e.config.build.variant===`esbuild`?(0,r.omit)(e.config.build,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`,`variant`,`override`]):{},{mainFields:e.config.build.mainFields,conditions:e.config.build.conditions,define:e.config.build.define,resolveExtensions:e.config.build.extensions,packages:e.config.build.skipNodeModulesBundle?`external`:e.config.build.variant===`esbuild`?e.config.build.packages:void 0,format:Array.isArray(e.config.output.format)?e.config.output.format[0]:e.config.output.format,platform:e.config.build.platform,treeShaking:!!e.config.build?.treeshake||e.config.build?.treeShaking,outdir:e.config.output.buildPath,tsconfig:e.tsconfig.tsconfigFilePath,tsconfigRaw:e.tsconfig.tsconfigJson,minify:e.config.mode!==`development`,metafile:e.config.mode===`development`,sourcemap:e.config.mode===`development`},s)}exports.extractESBuildConfig=c;
14
+ `)),(0,t.default)({alias:e.builtins.reduce((t,n)=>{if(!t[n]){let r=e.fs.ids[n];r&&(t[n]=r)}return t},e.config.build.alias?Array.isArray(e.config.build.alias)?e.config.build.alias.reduce((e,t)=>(e[t.find.toString()]||(e[t.find.toString()]=t.replacement),e),{}):e.config.build.alias:{}),inject:i&&Object.keys(i).length>0?[(0,r.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.artifactsPath,`inject-shim.js`)]:void 0},e.config.build.variant===`esbuild`?(0,n.omit)(e.config.build.override,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`]):{},e.config.build.variant===`esbuild`?(0,n.omit)(e.config.build,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`,`variant`,`override`]):{},{mainFields:e.config.build.mainFields,conditions:e.config.build.conditions,define:e.config.build.define,resolveExtensions:e.config.build.extensions,packages:e.config.build.skipNodeModulesBundle?`external`:e.config.build.variant===`esbuild`?e.config.build.packages:void 0,format:Array.isArray(e.config.output.format)?e.config.output.format[0]:e.config.output.format,platform:e.config.build.platform,treeShaking:!!e.config.build?.treeshake||e.config.build?.treeShaking,outdir:e.config.output.buildPath,tsconfig:e.tsconfig.tsconfigFilePath,tsconfigRaw:e.tsconfig.tsconfigJson,minify:e.config.mode!==`development`,metafile:e.config.mode===`development`,sourcemap:e.config.mode===`development`},s)}exports.extractESBuildConfig=c;
@@ -1,4 +1,4 @@
1
- import"../entry.mjs";import{joinPaths as e}from"@stryke/path/join-paths";import t from"defu";import{omit as n}from"@stryke/helpers/omit";import{replaceExtension as r,replacePath as i}from"@stryke/path/replace";import{camelCase as a}from"@stryke/string-format/camel-case";import{isString as o}from"@stryke/type-checks/is-string";const s={target:`esnext`,platform:`neutral`,format:`esm`,write:!0,minify:!0,sourcemap:!1,bundle:!0,treeShaking:!0,keepNames:!0,splitting:!0,logLevel:`silent`};function c(r){let i=r.config.build.override.inject??r.config.build.inject;return i&&Object.keys(i).length>0&&r.fs.writeSync(e(r.workspaceConfig.workspaceRoot,r.config.projectRoot,r.artifactsPath,`inject-shim.js`),Object.entries(i).map(([e,t])=>{if(t)if(Array.isArray(t)){if(a(e)!==e){if(t.length===1)return`
1
+ import"../entry.mjs";import e from"defu";import{omit as t}from"@stryke/helpers/omit";import{joinPaths as n}from"@stryke/path/join-paths";import{replaceExtension as r,replacePath as i}from"@stryke/path/replace";import{camelCase as a}from"@stryke/string-format/camel-case";import{isString as o}from"@stryke/type-checks/is-string";const s={target:`esnext`,platform:`neutral`,format:`esm`,write:!0,minify:!0,sourcemap:!1,bundle:!0,treeShaking:!0,keepNames:!0,splitting:!0,logLevel:`silent`};function c(r){let i=r.config.build.override.inject??r.config.build.inject;return i&&Object.keys(i).length>0&&r.fs.writeSync(n(r.workspaceConfig.workspaceRoot,r.config.projectRoot,r.artifactsPath,`inject-shim.js`),Object.entries(i).map(([e,t])=>{if(t)if(Array.isArray(t)){if(a(e)!==e){if(t.length===1)return`
2
2
  import ${a(e)} from "${t[0]}";
3
3
  export { ${a(e)} as "${e}" }`;if(t.length>1)return`
4
4
  import ${t[1]===`*`?`* as ${a(e)}`:`{ ${t[1]} as ${a(e)} }`} from "${t[0]}";
@@ -11,4 +11,4 @@ import ${a(e)} from "${t[0]}";
11
11
  export { ${a(e)} as "${e}" }`;else return`
12
12
  import ${e} from "${t}";
13
13
  export { ${e} };`;return``}).join(`
14
- `)),t({alias:r.builtins.reduce((e,t)=>{if(!e[t]){let n=r.fs.ids[t];n&&(e[t]=n)}return e},r.config.build.alias?Array.isArray(r.config.build.alias)?r.config.build.alias.reduce((e,t)=>(e[t.find.toString()]||(e[t.find.toString()]=t.replacement),e),{}):r.config.build.alias:{}),inject:i&&Object.keys(i).length>0?[e(r.workspaceConfig.workspaceRoot,r.config.projectRoot,r.artifactsPath,`inject-shim.js`)]:void 0},r.config.build.variant===`esbuild`?n(r.config.build.override,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`]):{},r.config.build.variant===`esbuild`?n(r.config.build,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`,`variant`,`override`]):{},{mainFields:r.config.build.mainFields,conditions:r.config.build.conditions,define:r.config.build.define,resolveExtensions:r.config.build.extensions,packages:r.config.build.skipNodeModulesBundle?`external`:r.config.build.variant===`esbuild`?r.config.build.packages:void 0,format:Array.isArray(r.config.output.format)?r.config.output.format[0]:r.config.output.format,platform:r.config.build.platform,treeShaking:!!r.config.build?.treeshake||r.config.build?.treeShaking,outdir:r.config.output.buildPath,tsconfig:r.tsconfig.tsconfigFilePath,tsconfigRaw:r.tsconfig.tsconfigJson,minify:r.config.mode!==`development`,metafile:r.config.mode===`development`,sourcemap:r.config.mode===`development`},s)}export{c as extractESBuildConfig};
14
+ `)),e({alias:r.builtins.reduce((e,t)=>{if(!e[t]){let n=r.fs.ids[t];n&&(e[t]=n)}return e},r.config.build.alias?Array.isArray(r.config.build.alias)?r.config.build.alias.reduce((e,t)=>(e[t.find.toString()]||(e[t.find.toString()]=t.replacement),e),{}):r.config.build.alias:{}),inject:i&&Object.keys(i).length>0?[n(r.workspaceConfig.workspaceRoot,r.config.projectRoot,r.artifactsPath,`inject-shim.js`)]:void 0},r.config.build.variant===`esbuild`?t(r.config.build.override,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`]):{},r.config.build.variant===`esbuild`?t(r.config.build,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`,`variant`,`override`]):{},{mainFields:r.config.build.mainFields,conditions:r.config.build.conditions,define:r.config.build.define,resolveExtensions:r.config.build.extensions,packages:r.config.build.skipNodeModulesBundle?`external`:r.config.build.variant===`esbuild`?r.config.build.packages:void 0,format:Array.isArray(r.config.output.format)?r.config.output.format[0]:r.config.output.format,platform:r.config.build.platform,treeShaking:!!r.config.build?.treeshake||r.config.build?.treeShaking,outdir:r.config.output.buildPath,tsconfig:r.tsconfig.tsconfigFilePath,tsconfigRaw:r.tsconfig.tsconfigJson,minify:r.config.mode!==`development`,metafile:r.config.mode===`development`,sourcemap:r.config.mode===`development`},s)}export{c as extractESBuildConfig};
@@ -1 +1 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`./esbuild.cjs`);let n=require(`@stryke/path/join-paths`),r=require(`defu`);r=e.__toESM(r);let i=require(`@stryke/helpers/omit`);const a={resolve:{extensions:[`.mjs`,`.js`,`.mts`,`.ts`,`.jsx`,`.tsx`,`.json`]},json:{stringify:!0},logLevel:`silent`,clearScreen:!0};function o(e){return(0,r.default)({resolve:{alias:e.builtins.reduce((t,n)=>{if(!t.find(e=>e.find===n)){let r=e.fs.ids[n];r&&t.push({find:n,replacement:r})}return t},e.config.build.alias?Array.isArray(e.config.build.alias)?e.config.build.alias:Object.entries(e.config.build.alias).reduce((e,[t,n])=>(e.find(e=>e.find===t)||e.push({find:t,replacement:n}),e),[]):[]),dedupe:e.config.build.dedupe,mainFields:e.config.build.mainFields,conditions:e.config.build.conditions,extensions:e.config.build.extensions}},e.config.build.variant===`vite`?e.config.build.override:{},e.config.build.variant===`vite`?(0,i.omit)(e.config.build,[`override`,`variant`]):{},{define:e.config.build.define,rootDir:e.config.sourceRoot,platform:e.config.build.platform,mode:e.config.mode===`development`?`development`:`production`,cacheDir:(0,n.joinPaths)(e.cachePath,`vite`),build:{minify:e.config.mode!==`development`,metafile:e.config.mode===`development`,sourcemap:e.config.mode===`development`,outDir:e.config.output.buildPath,tsconfig:e.tsconfig.tsconfigFilePath,tsconfigRaw:e.tsconfig.tsconfigJson},esbuild:t.extractESBuildConfig(e),logLevel:e.config.logLevel??void 0,envDir:e.config.projectRoot},a)}exports.DEFAULT_VITE_CONFIG=a,exports.extractViteConfig=o;
1
+ const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`./esbuild.cjs`);let n=require(`defu`);n=e.__toESM(n);let r=require(`@stryke/helpers/omit`),i=require(`@stryke/path/join-paths`);const a={resolve:{extensions:[`.mjs`,`.js`,`.mts`,`.ts`,`.jsx`,`.tsx`,`.json`]},json:{stringify:!0},logLevel:`silent`,clearScreen:!0};function o(e){return(0,n.default)({resolve:{alias:e.builtins.reduce((t,n)=>{if(!t.find(e=>e.find===n)){let r=e.fs.ids[n];r&&t.push({find:n,replacement:r})}return t},e.config.build.alias?Array.isArray(e.config.build.alias)?e.config.build.alias:Object.entries(e.config.build.alias).reduce((e,[t,n])=>(e.find(e=>e.find===t)||e.push({find:t,replacement:n}),e),[]):[]),dedupe:e.config.build.dedupe,mainFields:e.config.build.mainFields,conditions:e.config.build.conditions,extensions:e.config.build.extensions}},e.config.build.variant===`vite`?(0,n.default)(e.config.build.override??{},{optimizeDeps:e.config.build.override?.optimizeDeps??{}},{optimizeDeps:{extensions:e.config.build.override?.extensions}}):{},e.config.build.variant===`vite`?(0,n.default)((0,r.omit)(e.config.build,[`override`,`variant`]),{optimizeDeps:e.config.build?.optimizeDeps??{}},{optimizeDeps:{extensions:e.config.build.extensions}}):{},{keepProcessEnv:e.config.build.keepProcessEnv,define:e.config.build.define,rootDir:e.config.sourceRoot,platform:e.config.build.platform,mode:e.config.mode===`development`?`development`:`production`,cacheDir:(0,i.joinPaths)(e.cachePath,`vite`),build:{minify:e.config.mode!==`development`,metafile:e.config.mode===`development`,sourcemap:e.config.mode===`development`,outDir:e.config.output.buildPath,tsconfig:e.tsconfig.tsconfigFilePath,tsconfigRaw:e.tsconfig.tsconfigJson},esbuild:t.extractESBuildConfig(e),logLevel:e.config.logLevel??void 0,envDir:e.config.projectRoot},a)}exports.DEFAULT_VITE_CONFIG=a,exports.extractViteConfig=o;
@@ -1 +1 @@
1
- import{extractESBuildConfig as e}from"./esbuild.mjs";import{joinPaths as t}from"@stryke/path/join-paths";import n from"defu";import{omit as r}from"@stryke/helpers/omit";const i={resolve:{extensions:[`.mjs`,`.js`,`.mts`,`.ts`,`.jsx`,`.tsx`,`.json`]},json:{stringify:!0},logLevel:`silent`,clearScreen:!0};function a(a){return n({resolve:{alias:a.builtins.reduce((e,t)=>{if(!e.find(e=>e.find===t)){let n=a.fs.ids[t];n&&e.push({find:t,replacement:n})}return e},a.config.build.alias?Array.isArray(a.config.build.alias)?a.config.build.alias:Object.entries(a.config.build.alias).reduce((e,[t,n])=>(e.find(e=>e.find===t)||e.push({find:t,replacement:n}),e),[]):[]),dedupe:a.config.build.dedupe,mainFields:a.config.build.mainFields,conditions:a.config.build.conditions,extensions:a.config.build.extensions}},a.config.build.variant===`vite`?a.config.build.override:{},a.config.build.variant===`vite`?r(a.config.build,[`override`,`variant`]):{},{define:a.config.build.define,rootDir:a.config.sourceRoot,platform:a.config.build.platform,mode:a.config.mode===`development`?`development`:`production`,cacheDir:t(a.cachePath,`vite`),build:{minify:a.config.mode!==`development`,metafile:a.config.mode===`development`,sourcemap:a.config.mode===`development`,outDir:a.config.output.buildPath,tsconfig:a.tsconfig.tsconfigFilePath,tsconfigRaw:a.tsconfig.tsconfigJson},esbuild:e(a),logLevel:a.config.logLevel??void 0,envDir:a.config.projectRoot},i)}export{i as DEFAULT_VITE_CONFIG,a as extractViteConfig};
1
+ import{extractESBuildConfig as e}from"./esbuild.mjs";import t from"defu";import{omit as n}from"@stryke/helpers/omit";import{joinPaths as r}from"@stryke/path/join-paths";const i={resolve:{extensions:[`.mjs`,`.js`,`.mts`,`.ts`,`.jsx`,`.tsx`,`.json`]},json:{stringify:!0},logLevel:`silent`,clearScreen:!0};function a(a){return t({resolve:{alias:a.builtins.reduce((e,t)=>{if(!e.find(e=>e.find===t)){let n=a.fs.ids[t];n&&e.push({find:t,replacement:n})}return e},a.config.build.alias?Array.isArray(a.config.build.alias)?a.config.build.alias:Object.entries(a.config.build.alias).reduce((e,[t,n])=>(e.find(e=>e.find===t)||e.push({find:t,replacement:n}),e),[]):[]),dedupe:a.config.build.dedupe,mainFields:a.config.build.mainFields,conditions:a.config.build.conditions,extensions:a.config.build.extensions}},a.config.build.variant===`vite`?t(a.config.build.override??{},{optimizeDeps:a.config.build.override?.optimizeDeps??{}},{optimizeDeps:{extensions:a.config.build.override?.extensions}}):{},a.config.build.variant===`vite`?t(n(a.config.build,[`override`,`variant`]),{optimizeDeps:a.config.build?.optimizeDeps??{}},{optimizeDeps:{extensions:a.config.build.extensions}}):{},{keepProcessEnv:a.config.build.keepProcessEnv,define:a.config.build.define,rootDir:a.config.sourceRoot,platform:a.config.build.platform,mode:a.config.mode===`development`?`development`:`production`,cacheDir:r(a.cachePath,`vite`),build:{minify:a.config.mode!==`development`,metafile:a.config.mode===`development`,sourcemap:a.config.mode===`development`,outDir:a.config.output.buildPath,tsconfig:a.tsconfig.tsconfigFilePath,tsconfigRaw:a.tsconfig.tsconfigJson},esbuild:e(a),logLevel:a.config.logLevel??void 0,envDir:a.config.projectRoot},i)}export{i as DEFAULT_VITE_CONFIG,a as extractViteConfig};
@@ -1 +1 @@
1
- const e=require(`../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/path/join-paths`),n=require(`defu`);n=e.__toESM(n);let r=require(`@stryke/path/replace`),i=require(`@stryke/path/append`),a=require(`@stryke/type-checks/is-function`),o=require(`@stryke/type-checks/is-set-object`),s=require(`@stryke/fs/exists`),c=require(`@storm-software/config-tools/get-config`),l=require(`c12`);async function u(e,t){return(0,n.default)({workspaceRoot:e},await(0,c.getWorkspaceConfig)(!0,{cwd:t,workspaceRoot:e,useDefault:!0}))}async function d(e,c,u,d,f=`production`,p,m=`powerlines`){let h={},g;if(p&&(g=(0,s.existsSync)((0,r.replacePath)(p,e))?(0,r.replacePath)(p,e):(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),(0,r.replacePath)(p,e)))?(0,t.joinPaths)((0,i.appendPath)(e,c),(0,r.replacePath)(p,e)):(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),p))?(0,t.joinPaths)((0,i.appendPath)(e,c),p):void 0),g||=(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.ts`))?(0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.ts`):(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.js`))?(0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.js`):(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.mts`))?(0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.mts`):(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.mjs`))?(0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.mjs`):(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.config.ts`))?(0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.config.ts`):(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.config.js`))?(0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.config.js`):(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.config.mts`))?(0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.config.mts`):(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.config.mjs`))?(0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.config.mjs`):void 0,g){let e=await u.import(u.esmResolve(g));if(e){let t={};(0,a.isFunction)(e)&&(t=await Promise.resolve(e({command:d,mode:f,isSsrBuild:!1,isPreview:!1}))),(0,o.isSetObject)(t)&&(h={...t,config:t,configFile:g})}}let _=await(0,l.loadConfig)({cwd:e,name:m,envName:f,globalRc:!0,packageJson:!0,dotenv:!0,jiti:u});return(0,n.default)(h,(0,o.isSetObject)(_?.config)?{..._.config,..._}:{})}exports.loadUserConfigFile=d,exports.loadWorkspaceConfig=u;
1
+ const e=require(`../../../_virtual/rolldown_runtime.cjs`);let t=require(`defu`);t=e.__toESM(t);let n=require(`@stryke/path/join-paths`),r=require(`@stryke/path/replace`),i=require(`@stryke/path/append`),a=require(`@stryke/type-checks/is-function`),o=require(`@stryke/type-checks/is-set-object`),s=require(`@stryke/fs/exists`),c=require(`@storm-software/config-tools/get-config`),l=require(`c12`);async function u(e,n){return(0,t.default)({workspaceRoot:e},await(0,c.getWorkspaceConfig)(!0,{cwd:n,workspaceRoot:e,useDefault:!0}))}async function d(e,c,u,d,f=`production`,p,m=`powerlines`){let h={},g;if(p&&(g=(0,s.existsSync)((0,r.replacePath)(p,e))?(0,r.replacePath)(p,e):(0,s.existsSync)((0,n.joinPaths)((0,i.appendPath)(e,c),(0,r.replacePath)(p,e)))?(0,n.joinPaths)((0,i.appendPath)(e,c),(0,r.replacePath)(p,e)):(0,s.existsSync)((0,n.joinPaths)((0,i.appendPath)(e,c),p))?(0,n.joinPaths)((0,i.appendPath)(e,c),p):void 0),g||=(0,s.existsSync)((0,n.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.ts`))?(0,n.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.ts`):(0,s.existsSync)((0,n.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.js`))?(0,n.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.js`):(0,s.existsSync)((0,n.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.mts`))?(0,n.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.mts`):(0,s.existsSync)((0,n.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.mjs`))?(0,n.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.mjs`):(0,s.existsSync)((0,n.joinPaths)((0,i.appendPath)(e,c),`${m}.config.ts`))?(0,n.joinPaths)((0,i.appendPath)(e,c),`${m}.config.ts`):(0,s.existsSync)((0,n.joinPaths)((0,i.appendPath)(e,c),`${m}.config.js`))?(0,n.joinPaths)((0,i.appendPath)(e,c),`${m}.config.js`):(0,s.existsSync)((0,n.joinPaths)((0,i.appendPath)(e,c),`${m}.config.mts`))?(0,n.joinPaths)((0,i.appendPath)(e,c),`${m}.config.mts`):(0,s.existsSync)((0,n.joinPaths)((0,i.appendPath)(e,c),`${m}.config.mjs`))?(0,n.joinPaths)((0,i.appendPath)(e,c),`${m}.config.mjs`):void 0,g){let e=await u.import(u.esmResolve(g));if(e){let t={};(0,a.isFunction)(e)&&(t=await Promise.resolve(e({command:d,mode:f,isSsrBuild:!1,isPreview:!1}))),(0,o.isSetObject)(t)&&(h={...t,config:t,configFile:g})}}let _=await(0,l.loadConfig)({cwd:e,name:m,envName:f,globalRc:!0,packageJson:!0,dotenv:!0,jiti:u});return(0,t.default)(h,(0,o.isSetObject)(_?.config)?{..._.config,..._}:{})}exports.loadUserConfigFile=d,exports.loadWorkspaceConfig=u;
@@ -1 +1 @@
1
- import{joinPaths as e}from"@stryke/path/join-paths";import t from"defu";import{replacePath as n}from"@stryke/path/replace";import{appendPath as r}from"@stryke/path/append";import{isFunction as i}from"@stryke/type-checks/is-function";import{isSetObject as a}from"@stryke/type-checks/is-set-object";import{existsSync as o}from"@stryke/fs/exists";import{getWorkspaceConfig as s}from"@storm-software/config-tools/get-config";import{loadConfig as c}from"c12";async function l(e,n){return t({workspaceRoot:e},await s(!0,{cwd:n,workspaceRoot:e,useDefault:!0}))}async function u(s,l,u,d,f=`production`,p,m=`powerlines`){let h={},g;if(p&&(g=o(n(p,s))?n(p,s):o(e(r(s,l),n(p,s)))?e(r(s,l),n(p,s)):o(e(r(s,l),p))?e(r(s,l),p):void 0),g||=o(e(r(s,l),`${m}.${f}.config.ts`))?e(r(s,l),`${m}.${f}.config.ts`):o(e(r(s,l),`${m}.${f}.config.js`))?e(r(s,l),`${m}.${f}.config.js`):o(e(r(s,l),`${m}.${f}.config.mts`))?e(r(s,l),`${m}.${f}.config.mts`):o(e(r(s,l),`${m}.${f}.config.mjs`))?e(r(s,l),`${m}.${f}.config.mjs`):o(e(r(s,l),`${m}.config.ts`))?e(r(s,l),`${m}.config.ts`):o(e(r(s,l),`${m}.config.js`))?e(r(s,l),`${m}.config.js`):o(e(r(s,l),`${m}.config.mts`))?e(r(s,l),`${m}.config.mts`):o(e(r(s,l),`${m}.config.mjs`))?e(r(s,l),`${m}.config.mjs`):void 0,g){let e=await u.import(u.esmResolve(g));if(e){let t={};i(e)&&(t=await Promise.resolve(e({command:d,mode:f,isSsrBuild:!1,isPreview:!1}))),a(t)&&(h={...t,config:t,configFile:g})}}let _=await c({cwd:s,name:m,envName:f,globalRc:!0,packageJson:!0,dotenv:!0,jiti:u});return t(h,a(_?.config)?{..._.config,..._}:{})}export{u as loadUserConfigFile,l as loadWorkspaceConfig};
1
+ import e from"defu";import{joinPaths as t}from"@stryke/path/join-paths";import{replacePath as n}from"@stryke/path/replace";import{appendPath as r}from"@stryke/path/append";import{isFunction as i}from"@stryke/type-checks/is-function";import{isSetObject as a}from"@stryke/type-checks/is-set-object";import{existsSync as o}from"@stryke/fs/exists";import{getWorkspaceConfig as s}from"@storm-software/config-tools/get-config";import{loadConfig as c}from"c12";async function l(t,n){return e({workspaceRoot:t},await s(!0,{cwd:n,workspaceRoot:t,useDefault:!0}))}async function u(s,l,u,d,f=`production`,p,m=`powerlines`){let h={},g;if(p&&(g=o(n(p,s))?n(p,s):o(t(r(s,l),n(p,s)))?t(r(s,l),n(p,s)):o(t(r(s,l),p))?t(r(s,l),p):void 0),g||=o(t(r(s,l),`${m}.${f}.config.ts`))?t(r(s,l),`${m}.${f}.config.ts`):o(t(r(s,l),`${m}.${f}.config.js`))?t(r(s,l),`${m}.${f}.config.js`):o(t(r(s,l),`${m}.${f}.config.mts`))?t(r(s,l),`${m}.${f}.config.mts`):o(t(r(s,l),`${m}.${f}.config.mjs`))?t(r(s,l),`${m}.${f}.config.mjs`):o(t(r(s,l),`${m}.config.ts`))?t(r(s,l),`${m}.config.ts`):o(t(r(s,l),`${m}.config.js`))?t(r(s,l),`${m}.config.js`):o(t(r(s,l),`${m}.config.mts`))?t(r(s,l),`${m}.config.mts`):o(t(r(s,l),`${m}.config.mjs`))?t(r(s,l),`${m}.config.mjs`):void 0,g){let e=await u.import(u.esmResolve(g));if(e){let t={};i(e)&&(t=await Promise.resolve(e({command:d,mode:f,isSsrBuild:!1,isPreview:!1}))),a(t)&&(h={...t,config:t,configFile:g})}}let _=await c({cwd:s,name:m,envName:f,globalRc:!0,packageJson:!0,dotenv:!0,jiti:u});return e(h,a(_?.config)?{..._.config,..._}:{})}export{u as loadUserConfigFile,l as loadWorkspaceConfig};
@@ -1 +1 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../../internal/helpers/environment.cjs`),n=require(`../config-file.cjs`),r=require(`./context.cjs`),i=require(`./environment-context.cjs`);let a=require(`@storm-software/config-tools/types`),o=require(`@stryke/convert/to-array`),s=require(`@stryke/fs/resolve`),c=require(`@stryke/type-checks/is-set-object`),l=require(`chalk`);l=e.__toESM(l);var u=class e extends r.PowerlinesContext{#e={};#t=[];#n;static async from(t,r){let i=new e(await n.loadWorkspaceConfig(t,r.root));await i.withUserConfig(r);let a=await(0,s.resolvePackage)(`powerlines`);if(!a)throw Error("Could not resolve `powerlines` package location.");return i.powerlinesPath=a,i}get $$internal(){return super.$$internal}set $$internal(e){super.$$internal=e;for(let e of Object.values(this.environments))e.$$internal=super.$$internal}get environments(){return this.#e}get log(){return this.#n||=this.createLog(`engine`),this.#n}get plugins(){return this.#t}constructor(e){super(e)}async init(e={}){await super.init(e),await Promise.all((0,o.toArray)(this.config.userConfig.environments&&Object.keys(this.config.userConfig.environments).length>0?Object.keys(this.config.userConfig.environments).map(e=>t.createEnvironment(e,this.config.userConfig)):t.createDefaultEnvironment(this.config.userConfig)).map(async e=>{this.#e[e.name]=await this.in(e)}))}async in(e){let t;t=this.environments[e.name]?this.environments[e.name]:await i.PowerlinesEnvironmentContext.fromConfig(this.workspaceConfig,this.config),(0,c.isSetObject)(this.config.inlineConfig)&&await t.withInlineConfig(this.config.inlineConfig),t.environment=e,t.plugins=[];for(let e of this.plugins)await t.addPlugin(e);return t}async withUserConfig(e,t={isHighPriority:!0}){await super.withUserConfig(e,t),await Promise.all(Object.keys(this.#e).map(async n=>{await this.#e[n].withUserConfig(e,t)}))}async withInlineConfig(e,t={isHighPriority:!0}){await super.withInlineConfig(e,t),await Promise.all(Object.keys(this.#e).map(async n=>{await this.#e[n].withInlineConfig(e,t)}))}async addPlugin(e){this.plugins.push(e),await Promise.all(Object.keys(this.environments).map(async t=>{await this.environments[t].addPlugin(e)}))}async getEnvironment(e){let n;if(e&&(n=this.environments[e]),Object.keys(this.environments).length===1&&(n=this.environments[Object.keys(this.environments)[0]],this.log(a.LogLevelLabel.DEBUG,`Applying the only configured environment: ${l.default.bold.cyanBright(n?.environment.name)}`)),!n){if(e)throw Error(`Environment "${e}" not found.`);n=await this.in(t.createDefaultEnvironment(this.config.userConfig)),this.log(a.LogLevelLabel.WARN,`No environment specified, and no default environment found. Using a temporary default environment: ${l.default.bold.cyanBright(n?.environment.name)}`)}return n}async getEnvironmentSafe(e){try{return await this.getEnvironment(e)}catch{return}}};exports.PowerlinesAPIContext=u;
1
+ const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../../internal/helpers/environment.cjs`),n=require(`../config-file.cjs`),r=require(`./context.cjs`),i=require(`./environment-context.cjs`);let a=require(`@storm-software/config-tools/types`),o=require(`@stryke/convert/to-array`),s=require(`@stryke/fs/resolve`),c=require(`@stryke/type-checks/is-set-object`),l=require(`chalk`);l=e.__toESM(l);var u=class e extends r.PowerlinesContext{#e={};#t=[];#n;static async from(t,r){let i=new e(await n.loadWorkspaceConfig(t,r.root));await i.withUserConfig(r);let a=await(0,s.resolvePackage)(`powerlines`);if(!a)throw Error("Could not resolve `powerlines` package location.");return i.powerlinesPath=a,i}get $$internal(){return super.$$internal}set $$internal(e){super.$$internal=e;for(let e of Object.values(this.environments))e.$$internal=super.$$internal}get environments(){return this.#e}get log(){return this.#n||=this.createLog(`engine`),this.#n}get plugins(){return this.#t}constructor(e){super(e)}async init(e={}){await super.init(e),await Promise.all((0,o.toArray)(this.config.userConfig.environments&&Object.keys(this.config.userConfig.environments).length>0?Object.keys(this.config.userConfig.environments).map(e=>t.createEnvironment(e,this.config.userConfig)):t.createDefaultEnvironment(this.config.userConfig)).map(async e=>{this.#e[e.name]=await this.in(e)}))}async in(e){let t;t=this.environments[e.name]?this.environments[e.name]:await i.PowerlinesEnvironmentContext.fromConfig(this.workspaceConfig,this.config),(0,c.isSetObject)(this.config.inlineConfig)&&await t.withInlineConfig(this.config.inlineConfig),t.environment=e,t.plugins=[];for(let e of this.plugins)await t.addPlugin(e);return t}async withUserConfig(e,t={isHighPriority:!0}){await super.withUserConfig(e,t),await Promise.all(Object.keys(this.#e).map(async n=>{await this.#e[n].withUserConfig(e,t)}))}async withInlineConfig(e,t={isHighPriority:!0}){await super.withInlineConfig(e,t),await Promise.all(Object.keys(this.#e).map(async n=>{await this.#e[n].withInlineConfig(e,t)}))}async addPlugin(e){this.plugins.push(e),await Promise.all(Object.keys(this.environments).map(async t=>{await this.environments[t].addPlugin(e)}))}async getEnvironment(e){let n;if(e&&(n=this.environments[e]),Object.keys(this.environments).length===1&&(n=this.environments[Object.keys(this.environments)[0]],this.log(a.LogLevelLabel.DEBUG,`Applying the only configured environment: ${l.default.bold.cyanBright(n?.environment.name)}`)),!n){if(e)throw Error(`Environment "${e}" not found.`);n=await this.in(t.createDefaultEnvironment(this.config.userConfig)),this.log(a.LogLevelLabel.WARN,`No environment specified, and no default environment found. Using a temporary default environment: ${l.default.bold.cyanBright(n?.environment.name)}`)}return n}async getEnvironmentSafe(e){try{return await this.getEnvironment(e)}catch{return}}async toEnvironment(){let e;return Object.keys(this.environments).length>1?(e=await this.in(t.createEnvironment(t.GLOBAL_ENVIRONMENT,this.config.userConfig)),this.log(a.LogLevelLabel.DEBUG,`Combined all ${Object.keys(this.environments).length} environments into a single global context.`)):e=await this.getEnvironment(),e}};exports.PowerlinesAPIContext=u;
@@ -1 +1 @@
1
- import{createDefaultEnvironment as e,createEnvironment as t}from"../../internal/helpers/environment.mjs";import{loadWorkspaceConfig as n}from"../config-file.mjs";import{PowerlinesContext as r}from"./context.mjs";import{PowerlinesEnvironmentContext as i}from"./environment-context.mjs";import{LogLevelLabel as a}from"@storm-software/config-tools/types";import{toArray as o}from"@stryke/convert/to-array";import{resolvePackage as s}from"@stryke/fs/resolve";import{isSetObject as c}from"@stryke/type-checks/is-set-object";import l from"chalk";var u=class u extends r{#e={};#t=[];#n;static async from(e,t){let r=new u(await n(e,t.root));await r.withUserConfig(t);let i=await s(`powerlines`);if(!i)throw Error("Could not resolve `powerlines` package location.");return r.powerlinesPath=i,r}get $$internal(){return super.$$internal}set $$internal(e){super.$$internal=e;for(let e of Object.values(this.environments))e.$$internal=super.$$internal}get environments(){return this.#e}get log(){return this.#n||=this.createLog(`engine`),this.#n}get plugins(){return this.#t}constructor(e){super(e)}async init(n={}){await super.init(n),await Promise.all(o(this.config.userConfig.environments&&Object.keys(this.config.userConfig.environments).length>0?Object.keys(this.config.userConfig.environments).map(e=>t(e,this.config.userConfig)):e(this.config.userConfig)).map(async e=>{this.#e[e.name]=await this.in(e)}))}async in(e){let t;t=this.environments[e.name]?this.environments[e.name]:await i.fromConfig(this.workspaceConfig,this.config),c(this.config.inlineConfig)&&await t.withInlineConfig(this.config.inlineConfig),t.environment=e,t.plugins=[];for(let e of this.plugins)await t.addPlugin(e);return t}async withUserConfig(e,t={isHighPriority:!0}){await super.withUserConfig(e,t),await Promise.all(Object.keys(this.#e).map(async n=>{await this.#e[n].withUserConfig(e,t)}))}async withInlineConfig(e,t={isHighPriority:!0}){await super.withInlineConfig(e,t),await Promise.all(Object.keys(this.#e).map(async n=>{await this.#e[n].withInlineConfig(e,t)}))}async addPlugin(e){this.plugins.push(e),await Promise.all(Object.keys(this.environments).map(async t=>{await this.environments[t].addPlugin(e)}))}async getEnvironment(t){let n;if(t&&(n=this.environments[t]),Object.keys(this.environments).length===1&&(n=this.environments[Object.keys(this.environments)[0]],this.log(a.DEBUG,`Applying the only configured environment: ${l.bold.cyanBright(n?.environment.name)}`)),!n){if(t)throw Error(`Environment "${t}" not found.`);n=await this.in(e(this.config.userConfig)),this.log(a.WARN,`No environment specified, and no default environment found. Using a temporary default environment: ${l.bold.cyanBright(n?.environment.name)}`)}return n}async getEnvironmentSafe(e){try{return await this.getEnvironment(e)}catch{return}}};export{u as PowerlinesAPIContext};
1
+ import{GLOBAL_ENVIRONMENT as e,createDefaultEnvironment as t,createEnvironment as n}from"../../internal/helpers/environment.mjs";import{loadWorkspaceConfig as r}from"../config-file.mjs";import{PowerlinesContext as i}from"./context.mjs";import{PowerlinesEnvironmentContext as a}from"./environment-context.mjs";import{LogLevelLabel as o}from"@storm-software/config-tools/types";import{toArray as s}from"@stryke/convert/to-array";import{resolvePackage as c}from"@stryke/fs/resolve";import{isSetObject as l}from"@stryke/type-checks/is-set-object";import u from"chalk";var d=class d extends i{#e={};#t=[];#n;static async from(e,t){let n=new d(await r(e,t.root));await n.withUserConfig(t);let i=await c(`powerlines`);if(!i)throw Error("Could not resolve `powerlines` package location.");return n.powerlinesPath=i,n}get $$internal(){return super.$$internal}set $$internal(e){super.$$internal=e;for(let e of Object.values(this.environments))e.$$internal=super.$$internal}get environments(){return this.#e}get log(){return this.#n||=this.createLog(`engine`),this.#n}get plugins(){return this.#t}constructor(e){super(e)}async init(e={}){await super.init(e),await Promise.all(s(this.config.userConfig.environments&&Object.keys(this.config.userConfig.environments).length>0?Object.keys(this.config.userConfig.environments).map(e=>n(e,this.config.userConfig)):t(this.config.userConfig)).map(async e=>{this.#e[e.name]=await this.in(e)}))}async in(e){let t;t=this.environments[e.name]?this.environments[e.name]:await a.fromConfig(this.workspaceConfig,this.config),l(this.config.inlineConfig)&&await t.withInlineConfig(this.config.inlineConfig),t.environment=e,t.plugins=[];for(let e of this.plugins)await t.addPlugin(e);return t}async withUserConfig(e,t={isHighPriority:!0}){await super.withUserConfig(e,t),await Promise.all(Object.keys(this.#e).map(async n=>{await this.#e[n].withUserConfig(e,t)}))}async withInlineConfig(e,t={isHighPriority:!0}){await super.withInlineConfig(e,t),await Promise.all(Object.keys(this.#e).map(async n=>{await this.#e[n].withInlineConfig(e,t)}))}async addPlugin(e){this.plugins.push(e),await Promise.all(Object.keys(this.environments).map(async t=>{await this.environments[t].addPlugin(e)}))}async getEnvironment(e){let n;if(e&&(n=this.environments[e]),Object.keys(this.environments).length===1&&(n=this.environments[Object.keys(this.environments)[0]],this.log(o.DEBUG,`Applying the only configured environment: ${u.bold.cyanBright(n?.environment.name)}`)),!n){if(e)throw Error(`Environment "${e}" not found.`);n=await this.in(t(this.config.userConfig)),this.log(o.WARN,`No environment specified, and no default environment found. Using a temporary default environment: ${u.bold.cyanBright(n?.environment.name)}`)}return n}async getEnvironmentSafe(e){try{return await this.getEnvironment(e)}catch{return}}async toEnvironment(){let t;return Object.keys(this.environments).length>1?(t=await this.in(n(e,this.config.userConfig)),this.log(o.DEBUG,`Combined all ${Object.keys(this.environments).length} environments into a single global context.`)):t=await this.getEnvironment(),t}};export{d as PowerlinesAPIContext};
@@ -1,4 +1,4 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/path/join-paths`),n=require(`defu`);n=e.__toESM(n);let r=require(`@stryke/path/append`),i=require(`typescript`);i=e.__toESM(i);let a=require(`@stryke/fs/json`),o=require(`@stryke/fs/exists`);function s(e,t,n){let r;if(n?r=c(e,t,n):(r=c(e,t,`tsconfig.app.json`),r||(r=c(e,t,`tsconfig.lib.json`),r||=c(e,t,`tsconfig.json`))),!r)throw Error(`Cannot find the \`tsconfig.json\` configuration file for the project at ${t}.`);return r}function c(e,t,n){let i=n;if(!(!(0,o.existsSync)(i)&&(i=(0,r.appendPath)(n,t),!(0,o.existsSync)(i)&&(i=(0,r.appendPath)(n,(0,r.appendPath)(t,e)),!(0,o.existsSync)(i)))))return i}function l(e,t,n=[`.ts`,`.tsx`,`.d.ts`]){return t.find(t=>e?.toString().toLowerCase()===t?.toString().toLowerCase()||e?.toString().toLowerCase()===`./${t?.toString().toLowerCase()}`||`./${e?.toString().toLowerCase()}`===t?.toString().toLowerCase()||n.some(n=>`${e?.toString().toLowerCase()}${n}`===t?.toString().toLowerCase()||`${e?.toString().toLowerCase()}${n}`==`./${t?.toString().toLowerCase()}`||`${t?.toString().toLowerCase()}${n}`==`./${e?.toString().toLowerCase()}`||e?.toString().toLowerCase()===`${t?.toString().toLowerCase()}${n}`||e?.toString().toLowerCase()===`./${t?.toString().toLowerCase()}${n}`||t?.toString().toLowerCase()===`./${e?.toString().toLowerCase()}${n}`))}function u(e,t){return l(e,t,`.ts,.tsx,.d.ts,.js,.jsx,.mjs,.cjs,.mts,.cts,/*.ts,/*.tsx,/*.d.ts,/*.js,/*.jsx,/*.mjs,/*.cjs,/*.mts,/*.cts,/**/*.ts,/**/*.tsx,/**/*.d.ts,/**/*.js,/**/*.jsx,/**/*.mjs,/**/*.cjs,/**/*.mts,/**/*.cts`.split(`,`))}function d(e,t){return u(e,t)!==void 0}function f(e,o,c,l={},u,d=i.default.sys){let f=s(e,o,c),p=(0,a.readJsonFileSync)(f);if(!p)throw Error(`Cannot find the \`tsconfig.json\` configuration file at ${(0,t.joinPaths)(o,c??`tsconfig.json`)}`);let m=i.default.parseJsonConfigFileContent((0,n.default)(l??{},p),d,(0,r.appendPath)(o,e));if(m.errors.length>0){let e=`Cannot parse the TypeScript compiler options. Please investigate the following issues:
1
+ const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`defu`);t=e.__toESM(t);let n=require(`@stryke/path/join-paths`),r=require(`@stryke/path/append`),i=require(`typescript`);i=e.__toESM(i);let a=require(`@stryke/fs/json`),o=require(`@stryke/fs/exists`);function s(e,t,n){let r;if(n?r=c(e,t,n):(r=c(e,t,`tsconfig.app.json`),r||(r=c(e,t,`tsconfig.lib.json`),r||=c(e,t,`tsconfig.json`))),!r)throw Error(`Cannot find the \`tsconfig.json\` configuration file for the project at ${t}.`);return r}function c(e,t,n){let i=n;if(!(!(0,o.existsSync)(i)&&(i=(0,r.appendPath)(n,t),!(0,o.existsSync)(i)&&(i=(0,r.appendPath)(n,(0,r.appendPath)(t,e)),!(0,o.existsSync)(i)))))return i}function l(e,t,n=[`.ts`,`.tsx`,`.d.ts`]){return t.find(t=>e?.toString().toLowerCase()===t?.toString().toLowerCase()||e?.toString().toLowerCase()===`./${t?.toString().toLowerCase()}`||`./${e?.toString().toLowerCase()}`===t?.toString().toLowerCase()||n.some(n=>`${e?.toString().toLowerCase()}${n}`===t?.toString().toLowerCase()||`${e?.toString().toLowerCase()}${n}`==`./${t?.toString().toLowerCase()}`||`${t?.toString().toLowerCase()}${n}`==`./${e?.toString().toLowerCase()}`||e?.toString().toLowerCase()===`${t?.toString().toLowerCase()}${n}`||e?.toString().toLowerCase()===`./${t?.toString().toLowerCase()}${n}`||t?.toString().toLowerCase()===`./${e?.toString().toLowerCase()}${n}`))}function u(e,t){return l(e,t,`.ts,.tsx,.d.ts,.js,.jsx,.mjs,.cjs,.mts,.cts,/*.ts,/*.tsx,/*.d.ts,/*.js,/*.jsx,/*.mjs,/*.cjs,/*.mts,/*.cts,/**/*.ts,/**/*.tsx,/**/*.d.ts,/**/*.js,/**/*.jsx,/**/*.mjs,/**/*.cjs,/**/*.mts,/**/*.cts`.split(`,`))}function d(e,t){return u(e,t)!==void 0}function f(e,o,c,l={},u,d=i.default.sys){let f=s(e,o,c),p=(0,a.readJsonFileSync)(f);if(!p)throw Error(`Cannot find the \`tsconfig.json\` configuration file at ${(0,n.joinPaths)(o,c??`tsconfig.json`)}`);let m=i.default.parseJsonConfigFileContent((0,t.default)(l??{},p),d,(0,r.appendPath)(o,e));if(m.errors.length>0){let e=`Cannot parse the TypeScript compiler options. Please investigate the following issues:
2
2
  ${m.errors.map(e=>`- ${(e.category!==void 0&&e.code?`[${e.category}-${e.code}]: `:``)+e.messageText.toString()}`).join(`
3
3
  `)}
4
4
  `;throw Error(e)}return{...m,originalTsconfigJson:u??p,tsconfigJson:p,tsconfigFilePath:f}}exports.getParsedTypeScriptConfig=f,exports.getTsconfigFilePath=s,exports.isIncludeMatchFound=d;
@@ -1,4 +1,4 @@
1
- import{joinPaths as e}from"@stryke/path/join-paths";import t from"defu";import{appendPath as n}from"@stryke/path/append";import r from"typescript";import{readJsonFileSync as i}from"@stryke/fs/json";import{existsSync as a}from"@stryke/fs/exists";function o(e,t,n){let r;if(n?r=s(e,t,n):(r=s(e,t,`tsconfig.app.json`),r||(r=s(e,t,`tsconfig.lib.json`),r||=s(e,t,`tsconfig.json`))),!r)throw Error(`Cannot find the \`tsconfig.json\` configuration file for the project at ${t}.`);return r}function s(e,t,r){let i=r;if(!(!a(i)&&(i=n(r,t),!a(i)&&(i=n(r,n(t,e)),!a(i)))))return i}function c(e,t,n=[`.ts`,`.tsx`,`.d.ts`]){return t.find(t=>e?.toString().toLowerCase()===t?.toString().toLowerCase()||e?.toString().toLowerCase()===`./${t?.toString().toLowerCase()}`||`./${e?.toString().toLowerCase()}`===t?.toString().toLowerCase()||n.some(n=>`${e?.toString().toLowerCase()}${n}`===t?.toString().toLowerCase()||`${e?.toString().toLowerCase()}${n}`==`./${t?.toString().toLowerCase()}`||`${t?.toString().toLowerCase()}${n}`==`./${e?.toString().toLowerCase()}`||e?.toString().toLowerCase()===`${t?.toString().toLowerCase()}${n}`||e?.toString().toLowerCase()===`./${t?.toString().toLowerCase()}${n}`||t?.toString().toLowerCase()===`./${e?.toString().toLowerCase()}${n}`))}function l(e,t){return c(e,t,`.ts,.tsx,.d.ts,.js,.jsx,.mjs,.cjs,.mts,.cts,/*.ts,/*.tsx,/*.d.ts,/*.js,/*.jsx,/*.mjs,/*.cjs,/*.mts,/*.cts,/**/*.ts,/**/*.tsx,/**/*.d.ts,/**/*.js,/**/*.jsx,/**/*.mjs,/**/*.cjs,/**/*.mts,/**/*.cts`.split(`,`))}function u(e,t){return l(e,t)!==void 0}function d(a,s,c,l={},u,d=r.sys){let f=o(a,s,c),p=i(f);if(!p)throw Error(`Cannot find the \`tsconfig.json\` configuration file at ${e(s,c??`tsconfig.json`)}`);let m=r.parseJsonConfigFileContent(t(l??{},p),d,n(s,a));if(m.errors.length>0){let e=`Cannot parse the TypeScript compiler options. Please investigate the following issues:
1
+ import e from"defu";import{joinPaths as t}from"@stryke/path/join-paths";import{appendPath as n}from"@stryke/path/append";import r from"typescript";import{readJsonFileSync as i}from"@stryke/fs/json";import{existsSync as a}from"@stryke/fs/exists";function o(e,t,n){let r;if(n?r=s(e,t,n):(r=s(e,t,`tsconfig.app.json`),r||(r=s(e,t,`tsconfig.lib.json`),r||=s(e,t,`tsconfig.json`))),!r)throw Error(`Cannot find the \`tsconfig.json\` configuration file for the project at ${t}.`);return r}function s(e,t,r){let i=r;if(!(!a(i)&&(i=n(r,t),!a(i)&&(i=n(r,n(t,e)),!a(i)))))return i}function c(e,t,n=[`.ts`,`.tsx`,`.d.ts`]){return t.find(t=>e?.toString().toLowerCase()===t?.toString().toLowerCase()||e?.toString().toLowerCase()===`./${t?.toString().toLowerCase()}`||`./${e?.toString().toLowerCase()}`===t?.toString().toLowerCase()||n.some(n=>`${e?.toString().toLowerCase()}${n}`===t?.toString().toLowerCase()||`${e?.toString().toLowerCase()}${n}`==`./${t?.toString().toLowerCase()}`||`${t?.toString().toLowerCase()}${n}`==`./${e?.toString().toLowerCase()}`||e?.toString().toLowerCase()===`${t?.toString().toLowerCase()}${n}`||e?.toString().toLowerCase()===`./${t?.toString().toLowerCase()}${n}`||t?.toString().toLowerCase()===`./${e?.toString().toLowerCase()}${n}`))}function l(e,t){return c(e,t,`.ts,.tsx,.d.ts,.js,.jsx,.mjs,.cjs,.mts,.cts,/*.ts,/*.tsx,/*.d.ts,/*.js,/*.jsx,/*.mjs,/*.cjs,/*.mts,/*.cts,/**/*.ts,/**/*.tsx,/**/*.d.ts,/**/*.js,/**/*.jsx,/**/*.mjs,/**/*.cjs,/**/*.mts,/**/*.cts`.split(`,`))}function u(e,t){return l(e,t)!==void 0}function d(a,s,c,l={},u,d=r.sys){let f=o(a,s,c),p=i(f);if(!p)throw Error(`Cannot find the \`tsconfig.json\` configuration file at ${t(s,c??`tsconfig.json`)}`);let m=r.parseJsonConfigFileContent(e(l??{},p),d,n(s,a));if(m.errors.length>0){let e=`Cannot parse the TypeScript compiler options. Please investigate the following issues:
2
2
  ${m.errors.map(e=>`- ${(e.category!==void 0&&e.code?`[${e.category}-${e.code}]: `:``)+e.messageText.toString()}`).join(`
3
3
  `)}
4
4
  `;throw Error(e)}return{...m,originalTsconfigJson:u??p,tsconfigJson:p,tsconfigFilePath:f}}export{d as getParsedTypeScriptConfig,o as getTsconfigFilePath,u as isIncludeMatchFound};
@@ -0,0 +1,104 @@
1
+ import { ResolvedConfig } from "./resolved.cjs";
2
+ import { BuildInlineConfig, CleanInlineConfig, DeployInlineConfig, DocsInlineConfig, LintInlineConfig, NewInlineConfig, PrepareInlineConfig } from "./config.cjs";
3
+ import { HookKeys, InferHookParameters, InferHookReturnType } from "./hooks.cjs";
4
+ import { APIContext, EnvironmentContext, PluginContext } from "./context.cjs";
5
+ import { CallHookOptions } from "../internal/helpers/hooks.cjs";
6
+
7
+ //#region ../powerlines/src/types/api.d.ts
8
+
9
+ /**
10
+ * Powerlines API Interface
11
+ */
12
+ interface API<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
13
+ /**
14
+ * The Powerlines shared API context
15
+ */
16
+ context: APIContext<TResolvedConfig>;
17
+ /**
18
+ * Prepare the Powerlines API
19
+ *
20
+ * @remarks
21
+ * This method will prepare the Powerlines API for use, initializing any necessary resources.
22
+ *
23
+ * @param inlineConfig - The inline configuration for the prepare command
24
+ */
25
+ prepare: (inlineConfig: PrepareInlineConfig | NewInlineConfig | CleanInlineConfig | BuildInlineConfig | LintInlineConfig | DocsInlineConfig | DeployInlineConfig) => Promise<void>;
26
+ /**
27
+ * Create a new Powerlines project
28
+ *
29
+ * @remarks
30
+ * This method will create a new Powerlines project in the current directory.
31
+ *
32
+ * @param inlineConfig - The inline configuration for the new command
33
+ * @returns A promise that resolves when the project has been created
34
+ */
35
+ new: (inlineConfig: NewInlineConfig) => Promise<void>;
36
+ /**
37
+ * Clean any previously prepared artifacts
38
+ *
39
+ * @remarks
40
+ * This method will remove the previous Powerlines artifacts from the project.
41
+ *
42
+ * @param inlineConfig - The inline configuration for the clean command
43
+ * @returns A promise that resolves when the clean command has completed
44
+ */
45
+ clean: (inlineConfig: CleanInlineConfig | PrepareInlineConfig) => Promise<void>;
46
+ /**
47
+ * Lint the project source code
48
+ *
49
+ * @param inlineConfig - The inline configuration for the lint command
50
+ * @returns A promise that resolves when the lint command has completed
51
+ */
52
+ lint: (inlineConfig: LintInlineConfig) => Promise<void>;
53
+ /**
54
+ * Build the project
55
+ *
56
+ * @remarks
57
+ * This method will build the Powerlines project, generating the necessary artifacts.
58
+ *
59
+ * @param inlineConfig - The inline configuration for the build command
60
+ * @returns A promise that resolves when the build command has completed
61
+ */
62
+ build: (inlineConfig: BuildInlineConfig) => Promise<void>;
63
+ /**
64
+ * Prepare the documentation for the project
65
+ *
66
+ * @param inlineConfig - The inline configuration for the docs command
67
+ * @returns A promise that resolves when the documentation generation has completed
68
+ */
69
+ docs: (inlineConfig: DocsInlineConfig) => Promise<void>;
70
+ /**
71
+ * Deploy the project source code
72
+ *
73
+ * @remarks
74
+ * This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
75
+ *
76
+ * @param inlineConfig - The inline configuration for the deploy command
77
+ */
78
+ deploy: (inlineConfig: DeployInlineConfig) => Promise<void>;
79
+ /**
80
+ * Finalization process
81
+ *
82
+ * @remarks
83
+ * This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
84
+ *
85
+ * @returns A promise that resolves when the finalization process has completed
86
+ */
87
+ finalize: () => Promise<void>;
88
+ /**
89
+ * Invokes the configured plugin hooks
90
+ *
91
+ * @remarks
92
+ * By default, it will call the `"pre"`, `"normal"`, and `"post"` ordered hooks in sequence
93
+ *
94
+ * @param hook - The hook to call
95
+ * @param options - The options to provide to the hook
96
+ * @param args - The arguments to pass to the hook
97
+ * @returns The result of the hook call
98
+ */
99
+ callHook: <TKey extends HookKeys<PluginContext<TResolvedConfig>>>(hook: TKey, options: CallHookOptions & {
100
+ environment?: string | EnvironmentContext<TResolvedConfig>;
101
+ }, ...args: InferHookParameters<PluginContext<TResolvedConfig>, TKey>) => Promise<InferHookReturnType<PluginContext<TResolvedConfig>, TKey> | undefined>;
102
+ }
103
+ //#endregion
104
+ export { API };