@powerlines/plugin-rollup 0.7.80 โ†’ 0.7.82

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.
@@ -5,7 +5,7 @@ const e=require(`../../_virtual/rolldown_runtime.cjs`),t=require(`./internal/bab
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(m.LogLevelLabel.INFO,`Powerlines API has been prepared successfully`)}async new(e){this.context.log(m.LogLevelLabel.INFO,`๐Ÿ†• Creating a new Powerlines project`),await this.prepare(e),await this.#r(async e=>{e.log(m.LogLevelLabel.TRACE,`Initializing the processing options for the Powerlines project.`),await this.callHook(`new`,{environment:e,order:`pre`});let t=await(0,y.listFiles)((0,f.joinPaths)(e.powerlinesPath,`files/common/**/*.hbs`));for(let n of t){e.log(m.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,y.listFiles)((0,f.joinPaths)(e.powerlinesPath,`files/application/**/*.hbs`));for(let n of t){e.log(m.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,y.listFiles)((0,f.joinPaths)(e.powerlinesPath,`files/library/**/*.hbs`));for(let n of t){e.log(m.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(m.LogLevelLabel.TRACE,`Powerlines - New command completed`)}async clean(e={command:`clean`}){this.context.log(m.LogLevelLabel.INFO,`๐Ÿงน Cleaning the previous Powerlines artifacts`),await this.prepare(e),await this.#r(async e=>{this.context.log(m.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(m.LogLevelLabel.TRACE,`Powerlines - Clean command completed`)}async lint(e={command:`lint`}){this.context.log(m.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(m.LogLevelLabel.TRACE,`Powerlines linting completed`)}async build(e={command:`build`}){this.context.log(m.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(m.LogLevelLabel.TRACE,`Powerlines build completed`)}async docs(e={command:`docs`}){this.context.log(m.LogLevelLabel.INFO,`๐Ÿ““ Generating documentation for the Powerlines project`),await this.prepare(e),await this.#r(async t=>{t.log(m.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(m.LogLevelLabel.TRACE,`Powerlines documentation generation completed`)}async deploy(e={command:`deploy`}){this.context.log(m.LogLevelLabel.INFO,`๐Ÿ“ฆ Deploying the Powerlines project`),await this.prepare(e),await this.#r(async e=>{await this.callHook(`deploy`,{environment:e})}),this.context.log(m.LogLevelLabel.TRACE,`Powerlines deploy completed`)}async finalize(){this.context.log(m.LogLevelLabel.TRACE,`Powerlines finalize execution started`),await this.#r(async e=>{await this.callHook(`finalize`,{environment:e}),await e.fs.dispose()}),this.context.log(m.LogLevelLabel.TRACE,`Powerlines finalize execution completed`)}async callHook(e,t,...n){return r.callHook((0,k.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,S.appendPath)(e.config.output.buildPath,e.workspaceConfig.workspaceRoot),n=(0,f.joinPaths)((0,S.appendPath)(e.config.output.outputPath,e.workspaceConfig.workspaceRoot),`dist`);t!==n&&(e.log(m.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(m.LogLevelLabel.DEBUG,`Copying asset(s): ${j.default.redBright(e.workspaceConfig.workspaceRoot===t.input?t.glob:(0,f.joinPaths)((0,C.replacePath)(t.input,e.workspaceConfig.workspaceRoot),t.glob))} -> ${j.default.greenBright((0,f.joinPaths)((0,C.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(m.LogLevelLabel.DEBUG,`No environments are configured for this Powerlines project. Using the default environment.`),[await this.context.getEnvironment()]):(this.context.log(m.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,O.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(m.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,D.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,p.isFunction)(t))n=await Promise.resolve(t());else if((0,A.isSetString)(t)){let e=await this.#o(t);n=(0,p.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,A.isSetString)(e)){let t=await this.#o(e);n=(0,p.isFunction)(t)?await Promise.resolve(r?t(r):t()):t}else (0,p.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(m.LogLevelLabel.TRACE,`Duplicate ${j.default.bold.cyanBright(n.name)} plugin dependency detected - Skipping initialization.`),null):(this.context.log(m.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,b.isPackageExists)(e,{paths:[this.context.workspaceConfig.workspaceRoot,this.context.config.projectRoot]});if(!t&&this.context.config.skipInstalls!==!0){this.#e.log(m.LogLevelLabel.WARN,`The plugin package "${e}" is not installed. It will be installed automatically.`);let t=await(0,v.install)(e,{cwd:this.context.config.projectRoot});if((0,T.isNumber)(t.exitCode)&&t.exitCode>0)throw this.#e.log(m.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}":
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(m.LogLevelLabel.INFO,`Powerlines API has been prepared successfully`)}async new(e){this.context.log(m.LogLevelLabel.INFO,`๐Ÿ†• Creating a new Powerlines project`),await this.prepare(e),await this.#r(async e=>{e.log(m.LogLevelLabel.TRACE,`Initializing the processing options for the Powerlines project.`),await this.callHook(`new`,{environment:e,order:`pre`});let t=await(0,y.listFiles)((0,f.joinPaths)(e.powerlinesPath,`files/common/**/*.hbs`));for(let n of t){e.log(m.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,y.listFiles)((0,f.joinPaths)(e.powerlinesPath,`files/application/**/*.hbs`));for(let n of t){e.log(m.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,y.listFiles)((0,f.joinPaths)(e.powerlinesPath,`files/library/**/*.hbs`));for(let n of t){e.log(m.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(m.LogLevelLabel.TRACE,`Powerlines - New command completed`)}async clean(e={command:`clean`}){this.context.log(m.LogLevelLabel.INFO,`๐Ÿงน Cleaning the previous Powerlines artifacts`),await this.prepare(e),await this.#r(async e=>{this.context.log(m.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(m.LogLevelLabel.TRACE,`Powerlines - Clean command completed`)}async lint(e={command:`lint`}){this.context.log(m.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(m.LogLevelLabel.TRACE,`Powerlines linting completed`)}async build(e={command:`build`}){this.context.log(m.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(m.LogLevelLabel.TRACE,`Powerlines build completed`)}async docs(e={command:`docs`}){this.context.log(m.LogLevelLabel.INFO,`๐Ÿ““ Generating documentation for the Powerlines project`),await this.prepare(e),await this.#r(async t=>{t.log(m.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(m.LogLevelLabel.TRACE,`Powerlines documentation generation completed`)}async deploy(e={command:`deploy`}){this.context.log(m.LogLevelLabel.INFO,`๐Ÿ“ฆ Deploying the Powerlines project`),await this.prepare(e),await this.#r(async e=>{await this.callHook(`deploy`,{environment:e})}),this.context.log(m.LogLevelLabel.TRACE,`Powerlines deploy completed`)}async finalize(){this.context.log(m.LogLevelLabel.TRACE,`Powerlines finalize execution started`),await this.#r(async e=>{await this.callHook(`finalize`,{environment:e}),await e.fs.dispose()}),this.context.log(m.LogLevelLabel.TRACE,`Powerlines finalize execution completed`)}async callHook(e,t,...n){return r.callHook((0,k.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,S.appendPath)(e.config.output.buildPath,e.workspaceConfig.workspaceRoot),n=(0,f.joinPaths)((0,S.appendPath)(e.config.output.outputPath,e.workspaceConfig.workspaceRoot),`dist`);e.fs.existsSync(t)&&t!==n&&(e.log(m.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(m.LogLevelLabel.DEBUG,`Copying asset(s): ${j.default.redBright(e.workspaceConfig.workspaceRoot===t.input?t.glob:(0,f.joinPaths)((0,C.replacePath)(t.input,e.workspaceConfig.workspaceRoot),t.glob))} -> ${j.default.greenBright((0,f.joinPaths)((0,C.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(m.LogLevelLabel.DEBUG,`No environments are configured for this Powerlines project. Using the default environment.`),[await this.context.getEnvironment()]):(this.context.log(m.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,O.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(m.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,D.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,p.isFunction)(t))n=await Promise.resolve(t());else if((0,A.isSetString)(t)){let e=await this.#o(t);n=(0,p.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,A.isSetString)(e)){let t=await this.#o(e);n=(0,p.isFunction)(t)?await Promise.resolve(r?t(r):t()):t}else (0,p.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(m.LogLevelLabel.TRACE,`Duplicate ${j.default.bold.cyanBright(n.name)} plugin dependency detected - Skipping initialization.`),null):(this.context.log(m.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,b.isPackageExists)(e,{paths:[this.context.workspaceConfig.workspaceRoot,this.context.config.projectRoot]});if(!t&&this.context.config.skipInstalls!==!0){this.#e.log(m.LogLevelLabel.WARN,`The plugin package "${e}" is not installed. It will be installed automatically.`);let t=await(0,v.install)(e,{cwd:this.context.config.projectRoot});if((0,T.isNumber)(t.exitCode)&&t.exitCode>0)throw this.#e.log(m.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
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../typescript/ts-morph.cjs`),n=require(`../typescript/tsconfig.cjs`),r=require(`../config-file.cjs`),i=require(`../../internal/helpers/resolver.cjs`),a=require(`../../plugin-utils/helpers.cjs`),o=require(`../../plugin-utils/paths.cjs`),s=require(`../entry.cjs`),c=require(`../logger.cjs`),l=require(`../fs/vfs.cjs`),u=require(`../utilities/meta.cjs`);let d=require(`@stryke/convert/to-array`),f=require(`defu`);f=e.__toESM(f);let p=require(`@stryke/helpers/omit`),m=require(`@stryke/type-checks/is-string`),h=require(`@storm-software/config-tools/types`),g=require(`@stryke/fs/get-workspace-root`),_=require(`@stryke/fs/resolve`),v=require(`@stryke/path/append`),y=require(`@stryke/path/replace`),b=require(`@stryke/type-checks/is-set-object`),x=require(`@stryke/type-checks/is-set-string`),S=require(`@stryke/fs/json`),C=require(`@stryke/json/storm-json`),w=require(`@stryke/string-format/title-case`),T=require(`@stryke/fs/exists`),E=require(`@stryke/env/get-env-paths`),D=require(`@stryke/hash/hash-files`),O=require(`@stryke/hash/murmurhash`),k=require(`@stryke/helpers/get-unique`),A=require(`@stryke/http/fetch`),j=require(`@stryke/path/is-type`),M=require(`@stryke/path/join`),N=require(`@stryke/type-checks/is-null`),P=require(`@stryke/unique-id/uuid`),F=require(`bundle-require`),I=require(`flat-cache`),L=require(`oxc-parser`),R=require(`undici`);const z=new WeakMap;(0,R.setGlobalDispatcher)(new R.Agent({keepAliveTimeout:1e4}).compose(R.interceptors.retry({maxRetries:3,minTimeout:1e3,maxTimeout:1e4,timeoutFactor:2,retryAfter:!0})));var B=class e{#e={};#t;#n=null;#r=(0,P.uuid)();#i=(0,P.uuid)();#a=Date.now();#o;#s;#c;#l;#u;#d;#f(e={}){return{variant:e.build?.variant,projectType:e.type,projectRoot:e.root,name:e.name,title:e.title,description:e.description,sourceRoot:e.sourceRoot,configFile:e.configFile,customLogger:e.customLogger,logLevel:e.logLevel,tsconfig:e.tsconfig,tsconfigRaw:e.tsconfigRaw,skipCache:e.skipCache,skipInstalls:e.skipInstalls,entry:e.entry,output:e.output,plugins:e.plugins,mode:e.mode,lint:e.lint,transform:e.transform,build:e.build,framework:e.framework,...e}}static async from(t,n){let i=new e(await r.loadWorkspaceConfig(t,n.root));await i.withUserConfig(n);let a=await(0,_.resolvePackage)(`powerlines`);if(!a)throw Error("Could not resolve `powerlines` package location.");return i.powerlinesPath=a,i}dependencies={};devDependencies={};persistedMeta=void 0;powerlinesPath;packageJson;projectJson=void 0;resolver;resolvePatterns=[];get $$internal(){return this.#e}set $$internal(e){this.#e=e}get entry(){return s.resolveEntriesSync(this,(0,d.toArray)(this.config.entry))}get tsconfig(){return this.#c||(this.tsconfig={tsconfigFilePath:this.config.tsconfig}),this.#c}set tsconfig(e){this.#c=e,this.resolvePatterns=(0,F.tsconfigPathsToRegExp)(e?.options?.paths??{})}get fs(){return this.#s||=l.VirtualFileSystem.createSync(this),this.#s}get checksum(){return this.#n}get meta(){return{buildId:this.#r,releaseId:this.#i,checksum:this.#n,timestamp:this.#a,projectRootHash:(0,O.murmurhash)({workspaceRoot:this.workspaceConfig?.workspaceRoot,projectRoot:this.config?.projectRoot},{maxLength:u.PROJECT_ROOT_HASH_LENGTH}),configHash:(0,O.murmurhash)(this.config,{maxLength:u.CACHE_HASH_LENGTH})}}get config(){return this.resolvedConfig??{}}get log(){return this.logFn||=this.createLog(),this.logFn}get workspaceConfig(){return this.#t}get envPaths(){return this.#o||=(0,E.getEnvPaths)({orgId:`storm-software`,appId:`powerlines`,workspaceRoot:this.workspaceConfig.workspaceRoot}),this.#o}get artifactsPath(){return(0,M.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot,this.config.output.artifactsPath)}get builtinsPath(){return(0,M.joinPaths)(this.artifactsPath,`builtins`)}get entryPath(){return(0,M.joinPaths)(this.artifactsPath,`entry`)}get dataPath(){return(0,M.joinPaths)(this.envPaths.data,`projects`,u.getPrefixedProjectRootHash(this.config.name,this.meta.projectRootHash))}get cachePath(){return(0,M.joinPaths)(this.envPaths.cache,`projects`,(0,O.murmurhash)({checksum:this.#n,config:this.meta.configHash},{maxLength:u.CACHE_HASH_LENGTH}))}get dtsPath(){return this.config.output.dts?(0,v.appendPath)(this.config.output.dts,this.workspaceConfig.workspaceRoot):(0,M.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`powerlines.d.ts`)}get relativeToWorkspaceRoot(){return(0,g.relativeToWorkspaceRoot)(this.config.projectRoot)}get builtins(){return Object.values(this.fs.metadata).filter(e=>e&&e.type===`builtin`).map(e=>e?.id).filter(Boolean)}get program(){return this.#l||=t.createProgram(this,{skipAddingFilesFromTsConfig:!0}),this.#l}get parserCache(){return this.#u||=(0,I.create)({cacheId:`parser`,cacheDir:this.cachePath,ttl:7200*1e3,lruSize:5e3,persistInterval:250}),this.#u}get requestCache(){return this.#d||=(0,I.create)({cacheId:`http`,cacheDir:this.cachePath,ttl:300*1e3,lruSize:5e3,persistInterval:250}),this.#d}async fetch(e,t={}){let n=(0,O.murmurhash)({input:e.toString(),options:JSON.stringify(t)});if(!this.config.skipCache&&!t.skipCache){let e=this.requestCache.get(n);if(e)return new R.Response(e.body,{status:e.status,statusText:e.statusText,headers:e.headers})}let r=await(0,A.fetchRequest)(e,{timeout:12e3,...t}),i={body:await r.text(),status:r.status,statusText:r.statusText,headers:Object.fromEntries(r.headers.entries())};if(!this.config.skipCache&&!t.skipCache)try{this.requestCache.set(n,i)}catch{}return new R.Response(i.body,{status:i.status,statusText:i.statusText,headers:i.headers})}async parse(e,t={}){let n=(0,O.murmurhash)({code:e,options:t}),r;return!this.config.skipCache&&(r=this.parserCache.get(n),r)?r:(r=await(0,L.parse)(`source.${t.lang||`ts`}`,e,{...t,sourceType:`module`,showSemanticErrors:this.config.mode===`development`}),this.config.skipCache||this.parserCache.set(n,r),r)}async resolve(e,t,n={}){let r=e;if(this.config.build.alias)if(Array.isArray(this.config.build.alias)){let e=this.config.build.alias.find(e=>(0,F.match)(r,[e.find]));e&&(r=e.replacement)}else (0,b.isSetObject)(this.config.build.alias)&&this.config.build.alias[e]&&(r=this.config.build.alias[e]);if(this.fs.isVirtual(r)){let e=await this.fs.resolve(r,t,{conditions:this.config.build.conditions,extensions:this.config.build.extensions,...n});return e?{id:`\0${e}`,external:this.config.projectType!==`application`}:void 0}if(this.config.build.skipNodeModulesBundle){if((0,F.match)(r,this.resolvePatterns)||(0,F.match)(r,this.config.build.noExternal))return;if((0,F.match)(r,this.config.build.external)||r.startsWith(`node:`)||!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(r))return{id:r,external:!0}}else{if((0,F.match)(r,this.config.build.noExternal))return;if((0,F.match)(r,this.config.build.external)||r.startsWith(`node:`))return{id:r,external:!0}}}async load(e){let t=await this.fs.resolve(e);if(!t)return;let n=await this.fs.read(t);if(n)return{code:n,map:null}}async getBuiltins(){return Promise.all(Object.entries(this.fs.metadata).filter(([,e])=>e&&e.type===`builtin`).map(async([e,t])=>{let n=await this.fs.read(e);return{...t,path:e,code:n}}))}async emitEntry(e,t,n={}){return this.fs.write((0,j.isAbsolute)(t)?t:(0,v.appendPath)(t,this.entryPath),e,(0,f.default)(n,{type:`entry`}))}async emitBuiltin(e,t,n,r={}){return this.fs.write(n?(0,j.isAbsolute)(n)?n:(0,M.joinPaths)(this.builtinsPath,n):(0,v.appendPath)(t,this.builtinsPath),e,(0,f.default)(r,{type:`builtin`}))}async withUserConfig(e,t={isHighPriority:!0}){this.mergeUserConfig(e),await this.init(this.config.userConfig,t)}async withInlineConfig(e,t={isHighPriority:!0}){if(this.config.inlineConfig=e,e.command===`new`){let e=(0,M.joinPaths)(this.workspaceConfig.workspaceRoot,`package.json`);if(!(0,T.existsSync)(e))throw Error(`The workspace package.json file could not be found at ${e}`);this.packageJson=await(0,S.readJsonFile)(e),this.workspaceConfig.repository??=(0,x.isSetString)(this.packageJson?.repository)?this.packageJson.repository:this.packageJson?.repository?.url}await this.init(this.config.inlineConfig,t)}fatal(e){this.log(h.LogLevelLabel.FATAL,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}error(e){this.log(h.LogLevelLabel.ERROR,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}warn(e){this.log(h.LogLevelLabel.WARN,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}info(e){this.log(h.LogLevelLabel.INFO,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}debug(e){this.log(h.LogLevelLabel.DEBUG,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}trace(e){this.log(h.LogLevelLabel.TRACE,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}createLog(e=null){return c.createLog(e,{...this.config,logLevel:(0,N.isNull)(this.config.logLevel)?`silent`:this.config.logLevel})}extendLog(e){return c.extendLog(this.log,e)}async generateChecksum(e=this.config.projectRoot){return this.#n=await(0,D.hashDirectory)(e,{ignore:[`node_modules`,`.git`,`.nx`,`.cache`,`.storm`,`tmp`,`dist`]}),this.#n}constructor(e){this.#t=e,this.#o=(0,E.getEnvPaths)({orgId:`storm-software`,appId:`powerlines`,workspaceRoot:e.workspaceRoot})}resolvedConfig={};logFn;async init(e={},t={isHighPriority:!0}){let c={projectRoot:e.root??this.config.projectRoot??this.config.userConfig?.root??this.config.inlineConfig?.root,mode:(e.mode??this.config.mode)||this.workspaceConfig.mode,skipCache:e.skipCache??this.config.skipCache??!1,configFile:e.configFile??this.config.configFile,framework:e.framework??this.config.framework??`powerlines`,command:this.config.inlineConfig?.command};if(z.has(c)){let e=z.get(c);this.projectJson=e.projectJson,this.packageJson=e.packageJson,this.#n=e.checksum,this.resolver=e.resolver,this.mergeUserConfig(e.userConfig.config,this.config.userConfig)}else{let t=(0,M.joinPaths)(c.projectRoot,`project.json`);(0,T.existsSync)(t)&&(this.projectJson=await(0,S.readJsonFile)(t));let n=(0,M.joinPaths)(c.projectRoot,`package.json`);(0,T.existsSync)(n)&&(this.packageJson=await(0,S.readJsonFile)(n)),this.#n=await this.generateChecksum(c.projectRoot),this.resolver=i.createResolver({workspaceRoot:this.workspaceConfig.workspaceRoot,projectRoot:c.projectRoot,cacheDir:this.cachePath,mode:c.mode,logLevel:e.logLevel||this.config?.logLevel||this.workspaceConfig.logLevel||`info`,skipCache:c.skipCache});let a=await r.loadUserConfigFile(c.projectRoot,this.workspaceConfig.workspaceRoot,this.resolver,c.command,c.mode,c.configFile,c.framework);this.mergeUserConfig(a.config),z.set(c,{projectJson:this.projectJson,packageJson:this.packageJson,checksum:this.#n,resolver:this.resolver,userConfig:a})}e.tsconfig??=n.getTsconfigFilePath(this.workspaceConfig.workspaceRoot,c.projectRoot,e.tsconfig),(0,b.isSetObject)(e)&&(this.resolvedConfig=(0,f.default)({inlineConfig:this.config.inlineConfig,userConfig:this.config.userConfig},t.isHighPriority?this.#f(e):{},{command:this.config.inlineConfig?.command,...this.#f(this.config.inlineConfig)},this.#f(this.config.userConfig),{mode:this.workspaceConfig?.mode,logLevel:this.workspaceConfig?.logLevel,skipCache:this.workspaceConfig?.skipCache},{name:this.projectJson?.name||this.packageJson?.name,version:this.packageJson?.version,description:this.packageJson?.description,sourceRoot:this.projectJson?.sourceRoot||(0,v.appendPath)(`src`,c.projectRoot),output:(0,f.default)(e.output??{},{outputPath:c.projectRoot?(0,M.joinPaths)(this.workspaceConfig?.directories?.build||`dist`,c.projectRoot):this.workspaceConfig?.directories?.build||`dist`,artifactsPath:(0,M.joinPaths)(c.projectRoot,`.${e.framework??`powerlines`}`),dts:(0,M.joinPaths)(c.projectRoot,`${e.framework??`powerlines`}.d.ts`),builtinPrefix:e.framework??`powerlines`,assets:[{glob:`LICENSE`},{input:c.projectRoot,glob:`*.md`},{input:c.projectRoot,glob:`package.json`}]})},t.isHighPriority?{}:this.#f(e),{inlineConfig:{},userConfig:{},framework:`powerlines`,platform:`neutral`,mode:`production`,projectType:`application`,logLevel:`info`,preview:!1,environments:{},transform:{babel:{plugins:[],presets:[]}},lint:{eslint:{}},build:{target:`esnext`,override:{}}})),this.config.entry=s.getUniqueEntries(this.config.entry),this.config.name?.startsWith(`@`)&&this.config.name.split(`/`).filter(Boolean).length>1&&(this.config.name=this.config.name.split(`/`).filter(Boolean)[1]),this.config.title??=(0,w.titleCase)(this.config.name),this.config.userConfig.build?.external&&(this.config.userConfig.build.external=(0,k.getUnique)(this.config.userConfig.build.external)),this.config.userConfig.build?.noExternal&&(this.config.userConfig.build.noExternal=(0,k.getUnique)(this.config.userConfig.build.noExternal)),this.config.build.external&&(this.config.build.external=(0,k.getUnique)(this.config.build.external)),this.config.build.noExternal&&(this.config.build.noExternal=(0,k.getUnique)(this.config.build.noExternal)),this.config.output.format=(0,k.getUnique)((0,d.toArray)(this.config.output?.format??(this.config.projectType===`library`?[`cjs`,`esm`]:[`esm`]))),this.config.projectRoot&&this.config.projectRoot!==`.`&&this.config.projectRoot!==`./`&&this.config.projectRoot!==this.workspaceConfig.workspaceRoot?(this.config.output.outputPath??=(0,M.joinPaths)(`dist`,this.config.projectRoot),this.config.output.buildPath??=(0,M.joinPaths)(this.config.projectRoot,`dist`)):(this.config.output.outputPath??=`dist`,this.config.output.buildPath??=`dist`),this.config.output.assets=(0,k.getUnique)(this.config.output.assets.map(e=>({glob:(0,b.isSetObject)(e)?e.glob:e,input:(0,m.isString)(e)||!e.input||e.input===`.`||e.input===`/`||e.input===`./`?this.workspaceConfig.workspaceRoot:(0,v.appendPath)(e.input,this.workspaceConfig.workspaceRoot),output:(0,v.appendPath)((0,b.isSetObject)(e)&&e.output?(0,M.joinPaths)(this.config.output.outputPath,(0,y.replacePath)(e.output,this.config.output.outputPath)):this.config.output.outputPath,this.workspaceConfig.workspaceRoot),ignore:(0,b.isSetObject)(e)&&e.ignore?(0,d.toArray)(e.ignore):void 0}))),this.config.plugins=(this.config.plugins??[]).filter(Boolean).reduce((e,t)=>(a.isPlugin(t)&&a.checkDedupe(t,e.filter(e=>a.isPlugin(e)))||e.push(t),e),[]),this.config.tsconfig&&(this.config.tsconfig=o.replacePathTokens(this,this.config.tsconfig)),this.config.output.dts&&(this.config.output.dts=o.replacePathTokens(this,this.config.output.dts)),this.config.build.polyfill&&(this.config.build.polyfill=this.config.build.polyfill.map(e=>o.replacePathTokens(this,e))),this.config.output.assets&&(this.config.output.assets=this.config.output.assets.map(e=>({...e,glob:o.replacePathTokens(this,e.glob),ignore:e.ignore?e.ignore.map(e=>o.replacePathTokens(this,e)):void 0,input:o.replacePathTokens(this,e.input),output:o.replacePathTokens(this,e.output)}))),this.#s??=await l.VirtualFileSystem.create(this)}mergeUserConfig(e={},t=this.config.userConfig??{}){this.config.userConfig=(0,f.default)({entry:Array.isArray(e.entry)&&e.entry.length>0?e.entry:Array.isArray(t?.entry)&&t.entry.length>0?t.entry:[]},(0,p.omit)(e??{},[`entry`]),(0,p.omit)(t??{},[`entry`])),this.config.userConfig.output?.format&&(this.config.userConfig.output.format=(0,k.getUnique)((0,d.toArray)(this.config.userConfig.output?.format))),this.config.userConfig.plugins=(this.config.userConfig.plugins??[]).filter(Boolean).reduce((e,t)=>(a.isPlugin(t)&&a.checkDedupe(t,e.filter(e=>a.isPlugin(e)))||e.push(t),e),[])}};exports.PowerlinesContext=B;
1
+ const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../typescript/ts-morph.cjs`),n=require(`../typescript/tsconfig.cjs`),r=require(`../config-file.cjs`),i=require(`../../internal/helpers/resolver.cjs`),a=require(`../../plugin-utils/helpers.cjs`),o=require(`../../plugin-utils/paths.cjs`),s=require(`../entry.cjs`),c=require(`../logger.cjs`),l=require(`../fs/vfs.cjs`),u=require(`../utilities/meta.cjs`);let d=require(`@stryke/convert/to-array`),f=require(`defu`);f=e.__toESM(f);let p=require(`@stryke/helpers/omit`),m=require(`@stryke/type-checks/is-string`),h=require(`@storm-software/config-tools/types`),g=require(`@stryke/fs/get-workspace-root`),_=require(`@stryke/fs/resolve`),v=require(`@stryke/path/append`),y=require(`@stryke/path/replace`),b=require(`@stryke/type-checks/is-set-object`),x=require(`@stryke/type-checks/is-set-string`),S=require(`@stryke/fs/json`),C=require(`@stryke/json/storm-json`),w=require(`@stryke/string-format/title-case`),T=require(`@stryke/fs/exists`),E=require(`@stryke/env/get-env-paths`),D=require(`@stryke/hash/hash-files`),O=require(`@stryke/hash/murmurhash`),k=require(`@stryke/helpers/get-unique`),A=require(`@stryke/http/fetch`),j=require(`@stryke/path/is-type`),M=require(`@stryke/path/join`),N=require(`@stryke/type-checks/is-null`),P=require(`@stryke/unique-id/uuid`),F=require(`bundle-require`),I=require(`flat-cache`),L=require(`oxc-parser`),R=require(`undici`);const z=new WeakMap;(0,R.setGlobalDispatcher)(new R.Agent({keepAliveTimeout:1e4}).compose(R.interceptors.retry({maxRetries:3,minTimeout:1e3,maxTimeout:1e4,timeoutFactor:2,retryAfter:!0})));var B=class e{#e={};#t;#n=null;#r=(0,P.uuid)();#i=(0,P.uuid)();#a=Date.now();#o;#s;#c;#l;#u;#d;#f(e={}){return{variant:e.build?.variant,projectType:e.type,projectRoot:e.root,name:e.name,title:e.title,description:e.description,sourceRoot:e.sourceRoot,configFile:e.configFile,customLogger:e.customLogger,logLevel:e.logLevel,tsconfig:e.tsconfig,tsconfigRaw:e.tsconfigRaw,skipCache:e.skipCache,skipInstalls:e.skipInstalls,entry:e.entry,output:e.output,plugins:e.plugins,mode:e.mode,lint:e.lint,transform:e.transform,build:e.build,framework:e.framework,...e}}static async from(t,n){let i=new e(await r.loadWorkspaceConfig(t,n.root));await i.withUserConfig(n);let a=await(0,_.resolvePackage)(`powerlines`);if(!a)throw Error("Could not resolve `powerlines` package location.");return i.powerlinesPath=a,i}dependencies={};devDependencies={};persistedMeta=void 0;powerlinesPath;packageJson;projectJson=void 0;resolver;resolvePatterns=[];get $$internal(){return this.#e}set $$internal(e){this.#e=e}get entry(){return s.resolveEntriesSync(this,(0,d.toArray)(this.config.entry))}get tsconfig(){return this.#c||(this.tsconfig={tsconfigFilePath:this.config.tsconfig}),this.#c}set tsconfig(e){this.#c=e,this.resolvePatterns=(0,F.tsconfigPathsToRegExp)(e?.options?.paths??{})}get fs(){return this.#s||=l.VirtualFileSystem.createSync(this),this.#s}get checksum(){return this.#n}get meta(){return{buildId:this.#r,releaseId:this.#i,checksum:this.#n,timestamp:this.#a,projectRootHash:(0,O.murmurhash)({workspaceRoot:this.workspaceConfig?.workspaceRoot,projectRoot:this.config?.projectRoot},{maxLength:u.PROJECT_ROOT_HASH_LENGTH}),configHash:(0,O.murmurhash)(this.config,{maxLength:u.CACHE_HASH_LENGTH})}}get config(){return this.resolvedConfig??{}}get log(){return this.logFn||=this.createLog(),this.logFn}get workspaceConfig(){return this.#t}get envPaths(){return this.#o||=(0,E.getEnvPaths)({orgId:`storm-software`,appId:`powerlines`,workspaceRoot:this.workspaceConfig.workspaceRoot}),this.#o}get artifactsPath(){return(0,M.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot,this.config.output.artifactsPath)}get builtinsPath(){return(0,M.joinPaths)(this.artifactsPath,`builtins`)}get entryPath(){return(0,M.joinPaths)(this.artifactsPath,`entry`)}get dataPath(){return(0,M.joinPaths)(this.envPaths.data,`projects`,u.getPrefixedProjectRootHash(this.config.name,this.meta.projectRootHash))}get cachePath(){return(0,M.joinPaths)(this.envPaths.cache,`projects`,(0,O.murmurhash)({checksum:this.#n,config:this.meta.configHash},{maxLength:u.CACHE_HASH_LENGTH}))}get dtsPath(){return this.config.output.dts?(0,v.appendPath)(this.config.output.dts,this.workspaceConfig.workspaceRoot):(0,M.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`powerlines.d.ts`)}get relativeToWorkspaceRoot(){return(0,g.relativeToWorkspaceRoot)(this.config.projectRoot)}get builtins(){return Object.values(this.fs.metadata).filter(e=>e&&e.type===`builtin`).map(e=>e?.id).filter(Boolean)}get program(){return this.#l||=t.createProgram(this,{skipAddingFilesFromTsConfig:!0}),this.#l}get parserCache(){return this.#u||=(0,I.create)({cacheId:`parser`,cacheDir:this.cachePath,ttl:7200*1e3,lruSize:5e3,persistInterval:250}),this.#u}get requestCache(){return this.#d||=(0,I.create)({cacheId:`http`,cacheDir:this.cachePath,ttl:300*1e3,lruSize:5e3,persistInterval:250}),this.#d}async fetch(e,t={}){let n=(0,O.murmurhash)({input:e.toString(),options:JSON.stringify(t)});if(!this.config.skipCache&&!t.skipCache){let e=this.requestCache.get(n);if(e)return new R.Response(e.body,{status:e.status,statusText:e.statusText,headers:e.headers})}let r=await(0,A.fetchRequest)(e,{timeout:12e3,...t}),i={body:await r.text(),status:r.status,statusText:r.statusText,headers:Object.fromEntries(r.headers.entries())};if(!this.config.skipCache&&!t.skipCache)try{this.requestCache.set(n,i)}catch{}return new R.Response(i.body,{status:i.status,statusText:i.statusText,headers:i.headers})}async parse(e,t={}){let n=(0,O.murmurhash)({code:e,options:t}),r;return!this.config.skipCache&&(r=this.parserCache.get(n),r)?r:(r=await(0,L.parse)(`source.${t.lang||`ts`}`,e,{...t,sourceType:`module`,showSemanticErrors:this.config.mode===`development`}),this.config.skipCache||this.parserCache.set(n,r),r)}async resolve(e,t,n={}){let r=e;if(this.config.build.alias)if(Array.isArray(this.config.build.alias)){let e=this.config.build.alias.find(e=>(0,F.match)(r,[e.find]));e&&(r=e.replacement)}else (0,b.isSetObject)(this.config.build.alias)&&this.config.build.alias[e]&&(r=this.config.build.alias[e]);if(this.fs.isVirtual(r)){let e=await this.fs.resolve(r,t,{conditions:this.config.build.conditions,extensions:this.config.build.extensions,...n});return e?{id:`\0${e}`,external:this.config.projectType!==`application`}:void 0}if(this.config.build.skipNodeModulesBundle){if((0,F.match)(r,this.resolvePatterns)||(0,F.match)(r,this.config.build.noExternal))return;if((0,F.match)(r,this.config.build.external)||r.startsWith(`node:`)||!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(r))return{id:r,external:!0}}else{if((0,F.match)(r,this.config.build.noExternal))return;if((0,F.match)(r,this.config.build.external)||r.startsWith(`node:`))return{id:r,external:!0}}}async load(e){let t=await this.fs.resolve(e);if(!t)return;let n=await this.fs.read(t);if(n)return{code:n,map:null}}async getBuiltins(){return Promise.all(Object.entries(this.fs.metadata).filter(([,e])=>e&&e.type===`builtin`).map(async([e,t])=>{let n=await this.fs.read(e);return{...t,path:e,code:n}}))}async emitEntry(e,t,n={}){return this.fs.write((0,j.isAbsolute)(t)?t:(0,v.appendPath)(t,this.entryPath),e,(0,f.default)(n,{type:`entry`}))}async emitBuiltin(e,t,n,r={}){return this.fs.write(n?(0,j.isAbsolute)(n)?n:(0,M.joinPaths)(this.builtinsPath,n):(0,v.appendPath)(t,this.builtinsPath),e,(0,f.default)(r,{type:`builtin`}))}async withUserConfig(e,t={isHighPriority:!0}){this.mergeUserConfig(e),await this.init(this.config.userConfig,t)}async withInlineConfig(e,t={isHighPriority:!0}){if(this.config.inlineConfig=e,e.command===`new`){let e=(0,M.joinPaths)(this.workspaceConfig.workspaceRoot,`package.json`);if(!(0,T.existsSync)(e))throw Error(`The workspace package.json file could not be found at ${e}`);this.packageJson=await(0,S.readJsonFile)(e),this.workspaceConfig.repository??=(0,x.isSetString)(this.packageJson?.repository)?this.packageJson.repository:this.packageJson?.repository?.url}await this.init(this.config.inlineConfig,t)}fatal(e){this.log(h.LogLevelLabel.FATAL,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}error(e){this.log(h.LogLevelLabel.ERROR,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}warn(e){this.log(h.LogLevelLabel.WARN,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}info(e){this.log(h.LogLevelLabel.INFO,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}debug(e){this.log(h.LogLevelLabel.DEBUG,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}trace(e){this.log(h.LogLevelLabel.TRACE,(0,m.isString)(e)?e:C.StormJSON.stringify(e))}createLog(e=null){return c.createLog(e,{...this.config,logLevel:(0,N.isNull)(this.config.logLevel)?`silent`:this.config.logLevel})}extendLog(e){return c.extendLog(this.log,e)}async generateChecksum(e=this.config.projectRoot){return this.#n=await(0,D.hashDirectory)(e,{ignore:[`node_modules`,`.git`,`.nx`,`.cache`,`.storm`,`tmp`,`dist`]}),this.#n}constructor(e){this.#t=e,this.#o=(0,E.getEnvPaths)({orgId:`storm-software`,appId:`powerlines`,workspaceRoot:e.workspaceRoot})}resolvedConfig={};logFn;async init(e={},t={isHighPriority:!0}){let c={projectRoot:e.root??this.config.projectRoot??this.config.userConfig?.root??this.config.inlineConfig?.root,mode:(e.mode??this.config.mode)||this.workspaceConfig.mode,skipCache:e.skipCache??this.config.skipCache??!1,configFile:e.configFile??this.config.configFile,framework:e.framework??this.config.framework??`powerlines`,command:this.config.inlineConfig?.command};if(z.has(c)){let e=z.get(c);this.projectJson=e.projectJson,this.packageJson=e.packageJson,this.#n=e.checksum,this.resolver=e.resolver,this.mergeUserConfig(e.userConfig.config,this.config.userConfig)}else{let t=(0,M.joinPaths)(c.projectRoot,`project.json`);(0,T.existsSync)(t)&&(this.projectJson=await(0,S.readJsonFile)(t));let n=(0,M.joinPaths)(c.projectRoot,`package.json`);(0,T.existsSync)(n)&&(this.packageJson=await(0,S.readJsonFile)(n)),this.#n=await this.generateChecksum(c.projectRoot),this.resolver=i.createResolver({workspaceRoot:this.workspaceConfig.workspaceRoot,projectRoot:c.projectRoot,cacheDir:this.cachePath,mode:c.mode,logLevel:e.logLevel||this.config?.logLevel||this.workspaceConfig.logLevel||`info`,skipCache:c.skipCache});let a=await r.loadUserConfigFile(c.projectRoot,this.workspaceConfig.workspaceRoot,this.resolver,c.command,c.mode,c.configFile,c.framework);this.mergeUserConfig(a.config),z.set(c,{projectJson:this.projectJson,packageJson:this.packageJson,checksum:this.#n,resolver:this.resolver,userConfig:a})}e.tsconfig??=n.getTsconfigFilePath(this.workspaceConfig.workspaceRoot,c.projectRoot,e.tsconfig),(0,b.isSetObject)(e)&&(this.resolvedConfig=(0,f.default)({inlineConfig:this.config.inlineConfig,userConfig:this.config.userConfig},t.isHighPriority?this.#f(e):{},{command:this.config.inlineConfig?.command,...this.#f(this.config.inlineConfig)},this.#f(this.config.userConfig),{mode:this.workspaceConfig?.mode,logLevel:this.workspaceConfig?.logLevel,skipCache:this.workspaceConfig?.skipCache},{name:this.projectJson?.name||this.packageJson?.name,version:this.packageJson?.version,description:this.packageJson?.description,sourceRoot:this.projectJson?.sourceRoot||(0,v.appendPath)(`src`,c.projectRoot),output:(0,f.default)(e.output??{},{outputPath:c.projectRoot?(0,M.joinPaths)(this.workspaceConfig?.directories?.build||`dist`,c.projectRoot):this.workspaceConfig?.directories?.build||`dist`,artifactsPath:(0,M.joinPaths)(c.projectRoot,`.${e.framework??`powerlines`}`),dts:(0,M.joinPaths)(c.projectRoot,`${e.framework??`powerlines`}.d.ts`),builtinPrefix:e.framework??`powerlines`,assets:[{glob:`LICENSE`},{input:c.projectRoot,glob:`*.md`},{input:c.projectRoot,glob:`package.json`}]})},t.isHighPriority?{}:this.#f(e),{inlineConfig:{},userConfig:{},framework:`powerlines`,platform:`neutral`,mode:`production`,projectType:`application`,logLevel:`info`,preview:!1,environments:{},transform:{babel:{plugins:[],presets:[]}},lint:{eslint:{}},build:{target:`esnext`,override:{}}})),this.config.entry=s.getUniqueEntries(this.config.entry),this.config.name?.startsWith(`@`)&&this.config.name.split(`/`).filter(Boolean).length>1&&(this.config.name=this.config.name.split(`/`).filter(Boolean)[1]),this.config.title??=(0,w.titleCase)(this.config.name),this.config.userConfig.build?.external&&(this.config.userConfig.build.external=(0,k.getUnique)(this.config.userConfig.build.external)),this.config.userConfig.build?.noExternal&&(this.config.userConfig.build.noExternal=(0,k.getUnique)(this.config.userConfig.build.noExternal)),this.config.build.external&&(this.config.build.external=(0,k.getUnique)(this.config.build.external)),this.config.build.noExternal&&(this.config.build.noExternal=(0,k.getUnique)(this.config.build.noExternal)),this.config.output.format=(0,k.getUnique)((0,d.toArray)(this.config.output?.format??(this.config.projectType===`library`?[`cjs`,`esm`]:[`esm`]))),this.config.projectRoot&&this.config.projectRoot!==`.`&&this.config.projectRoot!==`./`&&this.config.projectRoot!==this.workspaceConfig.workspaceRoot?(this.config.output.outputPath??=(0,M.joinPaths)(`dist`,this.config.projectRoot),this.config.output.buildPath??=(0,M.joinPaths)(this.config.projectRoot,`dist`)):(this.config.output.outputPath??=`dist`,this.config.output.buildPath??=`dist`),this.config.output.assets=(0,k.getUnique)(this.config.output.assets.map(e=>({glob:(0,b.isSetObject)(e)?e.glob:e,input:(0,m.isString)(e)||!e.input||e.input===`.`||e.input===`/`||e.input===`./`?this.workspaceConfig.workspaceRoot:(0,v.appendPath)(e.input,this.workspaceConfig.workspaceRoot),output:(0,v.appendPath)((0,b.isSetObject)(e)&&e.output?(0,M.joinPaths)(this.config.output.outputPath,(0,y.replacePath)((0,y.replacePath)(e.output,(0,y.replacePath)(this.config.output.outputPath,this.workspaceConfig.workspaceRoot)),this.config.output.outputPath)):this.config.output.outputPath,this.workspaceConfig.workspaceRoot),ignore:(0,b.isSetObject)(e)&&e.ignore?(0,d.toArray)(e.ignore):void 0}))),this.config.plugins=(this.config.plugins??[]).filter(Boolean).reduce((e,t)=>(a.isPlugin(t)&&a.checkDedupe(t,e.filter(e=>a.isPlugin(e)))||e.push(t),e),[]),this.config.tsconfig&&(this.config.tsconfig=o.replacePathTokens(this,this.config.tsconfig)),this.config.output.dts&&(this.config.output.dts=o.replacePathTokens(this,this.config.output.dts)),this.config.build.polyfill&&(this.config.build.polyfill=this.config.build.polyfill.map(e=>o.replacePathTokens(this,e))),this.config.output.assets&&(this.config.output.assets=this.config.output.assets.map(e=>({...e,glob:o.replacePathTokens(this,e.glob),ignore:e.ignore?e.ignore.map(e=>o.replacePathTokens(this,e)):void 0,input:o.replacePathTokens(this,e.input),output:o.replacePathTokens(this,e.output)}))),this.#s??=await l.VirtualFileSystem.create(this)}mergeUserConfig(e={},t=this.config.userConfig??{}){this.config.userConfig=(0,f.default)({entry:Array.isArray(e.entry)&&e.entry.length>0?e.entry:Array.isArray(t?.entry)&&t.entry.length>0?t.entry:[]},(0,p.omit)(e??{},[`entry`]),(0,p.omit)(t??{},[`entry`])),this.config.userConfig.output?.format&&(this.config.userConfig.output.format=(0,k.getUnique)((0,d.toArray)(this.config.userConfig.output?.format))),this.config.userConfig.plugins=(this.config.userConfig.plugins??[]).filter(Boolean).reduce((e,t)=>(a.isPlugin(t)&&a.checkDedupe(t,e.filter(e=>a.isPlugin(e)))||e.push(t),e),[])}};exports.PowerlinesContext=B;
@@ -1 +1 @@
1
- import{createProgram as e}from"../typescript/ts-morph.mjs";import{getTsconfigFilePath as t}from"../typescript/tsconfig.mjs";import{loadUserConfigFile as n,loadWorkspaceConfig as r}from"../config-file.mjs";import{createResolver as i}from"../../internal/helpers/resolver.mjs";import{checkDedupe as a,isPlugin as o}from"../../plugin-utils/helpers.mjs";import{replacePathTokens as s}from"../../plugin-utils/paths.mjs";import{getUniqueEntries as c,resolveEntriesSync as l}from"../entry.mjs";import{createLog as u,extendLog as d}from"../logger.mjs";import{VirtualFileSystem as f}from"../fs/vfs.mjs";import{CACHE_HASH_LENGTH as p,PROJECT_ROOT_HASH_LENGTH as m,getPrefixedProjectRootHash as h}from"../utilities/meta.mjs";import{toArray as g}from"@stryke/convert/to-array";import _ from"defu";import{omit as v}from"@stryke/helpers/omit";import{isString as y}from"@stryke/type-checks/is-string";import{LogLevelLabel as b}from"@storm-software/config-tools/types";import{relativeToWorkspaceRoot as x}from"@stryke/fs/get-workspace-root";import{resolvePackage as S}from"@stryke/fs/resolve";import{appendPath as C}from"@stryke/path/append";import{replacePath as w}from"@stryke/path/replace";import{isSetObject as T}from"@stryke/type-checks/is-set-object";import{isSetString as E}from"@stryke/type-checks/is-set-string";import{readJsonFile as D}from"@stryke/fs/json";import{StormJSON as O}from"@stryke/json/storm-json";import{titleCase as k}from"@stryke/string-format/title-case";import{existsSync as A}from"@stryke/fs/exists";import{getEnvPaths as j}from"@stryke/env/get-env-paths";import{hashDirectory as M}from"@stryke/hash/hash-files";import{murmurhash as N}from"@stryke/hash/murmurhash";import{getUnique as P}from"@stryke/helpers/get-unique";import{fetchRequest as F}from"@stryke/http/fetch";import{isAbsolute as I}from"@stryke/path/is-type";import{joinPaths as L}from"@stryke/path/join";import{isNull as R}from"@stryke/type-checks/is-null";import{uuid as z}from"@stryke/unique-id/uuid";import{match as B,tsconfigPathsToRegExp as V}from"bundle-require";import{create as H}from"flat-cache";import{parse as U}from"oxc-parser";import{Agent as W,Response as G,interceptors as K,setGlobalDispatcher as q}from"undici";const J=new WeakMap;q(new W({keepAliveTimeout:1e4}).compose(K.retry({maxRetries:3,minTimeout:1e3,maxTimeout:1e4,timeoutFactor:2,retryAfter:!0})));var Y=class W{#e={};#t;#n=null;#r=z();#i=z();#a=Date.now();#o;#s;#c;#l;#u;#d;#f(e={}){return{variant:e.build?.variant,projectType:e.type,projectRoot:e.root,name:e.name,title:e.title,description:e.description,sourceRoot:e.sourceRoot,configFile:e.configFile,customLogger:e.customLogger,logLevel:e.logLevel,tsconfig:e.tsconfig,tsconfigRaw:e.tsconfigRaw,skipCache:e.skipCache,skipInstalls:e.skipInstalls,entry:e.entry,output:e.output,plugins:e.plugins,mode:e.mode,lint:e.lint,transform:e.transform,build:e.build,framework:e.framework,...e}}static async from(e,t){let n=new W(await r(e,t.root));await n.withUserConfig(t);let i=await S(`powerlines`);if(!i)throw Error("Could not resolve `powerlines` package location.");return n.powerlinesPath=i,n}dependencies={};devDependencies={};persistedMeta=void 0;powerlinesPath;packageJson;projectJson=void 0;resolver;resolvePatterns=[];get $$internal(){return this.#e}set $$internal(e){this.#e=e}get entry(){return l(this,g(this.config.entry))}get tsconfig(){return this.#c||(this.tsconfig={tsconfigFilePath:this.config.tsconfig}),this.#c}set tsconfig(e){this.#c=e,this.resolvePatterns=V(e?.options?.paths??{})}get fs(){return this.#s||=f.createSync(this),this.#s}get checksum(){return this.#n}get meta(){return{buildId:this.#r,releaseId:this.#i,checksum:this.#n,timestamp:this.#a,projectRootHash:N({workspaceRoot:this.workspaceConfig?.workspaceRoot,projectRoot:this.config?.projectRoot},{maxLength:m}),configHash:N(this.config,{maxLength:p})}}get config(){return this.resolvedConfig??{}}get log(){return this.logFn||=this.createLog(),this.logFn}get workspaceConfig(){return this.#t}get envPaths(){return this.#o||=j({orgId:`storm-software`,appId:`powerlines`,workspaceRoot:this.workspaceConfig.workspaceRoot}),this.#o}get artifactsPath(){return L(this.workspaceConfig.workspaceRoot,this.config.projectRoot,this.config.output.artifactsPath)}get builtinsPath(){return L(this.artifactsPath,`builtins`)}get entryPath(){return L(this.artifactsPath,`entry`)}get dataPath(){return L(this.envPaths.data,`projects`,h(this.config.name,this.meta.projectRootHash))}get cachePath(){return L(this.envPaths.cache,`projects`,N({checksum:this.#n,config:this.meta.configHash},{maxLength:p}))}get dtsPath(){return this.config.output.dts?C(this.config.output.dts,this.workspaceConfig.workspaceRoot):L(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`powerlines.d.ts`)}get relativeToWorkspaceRoot(){return x(this.config.projectRoot)}get builtins(){return Object.values(this.fs.metadata).filter(e=>e&&e.type===`builtin`).map(e=>e?.id).filter(Boolean)}get program(){return this.#l||=e(this,{skipAddingFilesFromTsConfig:!0}),this.#l}get parserCache(){return this.#u||=H({cacheId:`parser`,cacheDir:this.cachePath,ttl:7200*1e3,lruSize:5e3,persistInterval:250}),this.#u}get requestCache(){return this.#d||=H({cacheId:`http`,cacheDir:this.cachePath,ttl:300*1e3,lruSize:5e3,persistInterval:250}),this.#d}async fetch(e,t={}){let n=N({input:e.toString(),options:JSON.stringify(t)});if(!this.config.skipCache&&!t.skipCache){let e=this.requestCache.get(n);if(e)return new G(e.body,{status:e.status,statusText:e.statusText,headers:e.headers})}let r=await F(e,{timeout:12e3,...t}),i={body:await r.text(),status:r.status,statusText:r.statusText,headers:Object.fromEntries(r.headers.entries())};if(!this.config.skipCache&&!t.skipCache)try{this.requestCache.set(n,i)}catch{}return new G(i.body,{status:i.status,statusText:i.statusText,headers:i.headers})}async parse(e,t={}){let n=N({code:e,options:t}),r;return!this.config.skipCache&&(r=this.parserCache.get(n),r)?r:(r=await U(`source.${t.lang||`ts`}`,e,{...t,sourceType:`module`,showSemanticErrors:this.config.mode===`development`}),this.config.skipCache||this.parserCache.set(n,r),r)}async resolve(e,t,n={}){let r=e;if(this.config.build.alias)if(Array.isArray(this.config.build.alias)){let e=this.config.build.alias.find(e=>B(r,[e.find]));e&&(r=e.replacement)}else T(this.config.build.alias)&&this.config.build.alias[e]&&(r=this.config.build.alias[e]);if(this.fs.isVirtual(r)){let e=await this.fs.resolve(r,t,{conditions:this.config.build.conditions,extensions:this.config.build.extensions,...n});return e?{id:`\0${e}`,external:this.config.projectType!==`application`}:void 0}if(this.config.build.skipNodeModulesBundle){if(B(r,this.resolvePatterns)||B(r,this.config.build.noExternal))return;if(B(r,this.config.build.external)||r.startsWith(`node:`)||!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(r))return{id:r,external:!0}}else{if(B(r,this.config.build.noExternal))return;if(B(r,this.config.build.external)||r.startsWith(`node:`))return{id:r,external:!0}}}async load(e){let t=await this.fs.resolve(e);if(!t)return;let n=await this.fs.read(t);if(n)return{code:n,map:null}}async getBuiltins(){return Promise.all(Object.entries(this.fs.metadata).filter(([,e])=>e&&e.type===`builtin`).map(async([e,t])=>{let n=await this.fs.read(e);return{...t,path:e,code:n}}))}async emitEntry(e,t,n={}){return this.fs.write(I(t)?t:C(t,this.entryPath),e,_(n,{type:`entry`}))}async emitBuiltin(e,t,n,r={}){return this.fs.write(n?I(n)?n:L(this.builtinsPath,n):C(t,this.builtinsPath),e,_(r,{type:`builtin`}))}async withUserConfig(e,t={isHighPriority:!0}){this.mergeUserConfig(e),await this.init(this.config.userConfig,t)}async withInlineConfig(e,t={isHighPriority:!0}){if(this.config.inlineConfig=e,e.command===`new`){let e=L(this.workspaceConfig.workspaceRoot,`package.json`);if(!A(e))throw Error(`The workspace package.json file could not be found at ${e}`);this.packageJson=await D(e),this.workspaceConfig.repository??=E(this.packageJson?.repository)?this.packageJson.repository:this.packageJson?.repository?.url}await this.init(this.config.inlineConfig,t)}fatal(e){this.log(b.FATAL,y(e)?e:O.stringify(e))}error(e){this.log(b.ERROR,y(e)?e:O.stringify(e))}warn(e){this.log(b.WARN,y(e)?e:O.stringify(e))}info(e){this.log(b.INFO,y(e)?e:O.stringify(e))}debug(e){this.log(b.DEBUG,y(e)?e:O.stringify(e))}trace(e){this.log(b.TRACE,y(e)?e:O.stringify(e))}createLog(e=null){return u(e,{...this.config,logLevel:R(this.config.logLevel)?`silent`:this.config.logLevel})}extendLog(e){return d(this.log,e)}async generateChecksum(e=this.config.projectRoot){return this.#n=await M(e,{ignore:[`node_modules`,`.git`,`.nx`,`.cache`,`.storm`,`tmp`,`dist`]}),this.#n}constructor(e){this.#t=e,this.#o=j({orgId:`storm-software`,appId:`powerlines`,workspaceRoot:e.workspaceRoot})}resolvedConfig={};logFn;async init(e={},r={isHighPriority:!0}){let l={projectRoot:e.root??this.config.projectRoot??this.config.userConfig?.root??this.config.inlineConfig?.root,mode:(e.mode??this.config.mode)||this.workspaceConfig.mode,skipCache:e.skipCache??this.config.skipCache??!1,configFile:e.configFile??this.config.configFile,framework:e.framework??this.config.framework??`powerlines`,command:this.config.inlineConfig?.command};if(J.has(l)){let e=J.get(l);this.projectJson=e.projectJson,this.packageJson=e.packageJson,this.#n=e.checksum,this.resolver=e.resolver,this.mergeUserConfig(e.userConfig.config,this.config.userConfig)}else{let t=L(l.projectRoot,`project.json`);A(t)&&(this.projectJson=await D(t));let r=L(l.projectRoot,`package.json`);A(r)&&(this.packageJson=await D(r)),this.#n=await this.generateChecksum(l.projectRoot),this.resolver=i({workspaceRoot:this.workspaceConfig.workspaceRoot,projectRoot:l.projectRoot,cacheDir:this.cachePath,mode:l.mode,logLevel:e.logLevel||this.config?.logLevel||this.workspaceConfig.logLevel||`info`,skipCache:l.skipCache});let a=await n(l.projectRoot,this.workspaceConfig.workspaceRoot,this.resolver,l.command,l.mode,l.configFile,l.framework);this.mergeUserConfig(a.config),J.set(l,{projectJson:this.projectJson,packageJson:this.packageJson,checksum:this.#n,resolver:this.resolver,userConfig:a})}e.tsconfig??=t(this.workspaceConfig.workspaceRoot,l.projectRoot,e.tsconfig),T(e)&&(this.resolvedConfig=_({inlineConfig:this.config.inlineConfig,userConfig:this.config.userConfig},r.isHighPriority?this.#f(e):{},{command:this.config.inlineConfig?.command,...this.#f(this.config.inlineConfig)},this.#f(this.config.userConfig),{mode:this.workspaceConfig?.mode,logLevel:this.workspaceConfig?.logLevel,skipCache:this.workspaceConfig?.skipCache},{name:this.projectJson?.name||this.packageJson?.name,version:this.packageJson?.version,description:this.packageJson?.description,sourceRoot:this.projectJson?.sourceRoot||C(`src`,l.projectRoot),output:_(e.output??{},{outputPath:l.projectRoot?L(this.workspaceConfig?.directories?.build||`dist`,l.projectRoot):this.workspaceConfig?.directories?.build||`dist`,artifactsPath:L(l.projectRoot,`.${e.framework??`powerlines`}`),dts:L(l.projectRoot,`${e.framework??`powerlines`}.d.ts`),builtinPrefix:e.framework??`powerlines`,assets:[{glob:`LICENSE`},{input:l.projectRoot,glob:`*.md`},{input:l.projectRoot,glob:`package.json`}]})},r.isHighPriority?{}:this.#f(e),{inlineConfig:{},userConfig:{},framework:`powerlines`,platform:`neutral`,mode:`production`,projectType:`application`,logLevel:`info`,preview:!1,environments:{},transform:{babel:{plugins:[],presets:[]}},lint:{eslint:{}},build:{target:`esnext`,override:{}}})),this.config.entry=c(this.config.entry),this.config.name?.startsWith(`@`)&&this.config.name.split(`/`).filter(Boolean).length>1&&(this.config.name=this.config.name.split(`/`).filter(Boolean)[1]),this.config.title??=k(this.config.name),this.config.userConfig.build?.external&&(this.config.userConfig.build.external=P(this.config.userConfig.build.external)),this.config.userConfig.build?.noExternal&&(this.config.userConfig.build.noExternal=P(this.config.userConfig.build.noExternal)),this.config.build.external&&(this.config.build.external=P(this.config.build.external)),this.config.build.noExternal&&(this.config.build.noExternal=P(this.config.build.noExternal)),this.config.output.format=P(g(this.config.output?.format??(this.config.projectType===`library`?[`cjs`,`esm`]:[`esm`]))),this.config.projectRoot&&this.config.projectRoot!==`.`&&this.config.projectRoot!==`./`&&this.config.projectRoot!==this.workspaceConfig.workspaceRoot?(this.config.output.outputPath??=L(`dist`,this.config.projectRoot),this.config.output.buildPath??=L(this.config.projectRoot,`dist`)):(this.config.output.outputPath??=`dist`,this.config.output.buildPath??=`dist`),this.config.output.assets=P(this.config.output.assets.map(e=>({glob:T(e)?e.glob:e,input:y(e)||!e.input||e.input===`.`||e.input===`/`||e.input===`./`?this.workspaceConfig.workspaceRoot:C(e.input,this.workspaceConfig.workspaceRoot),output:C(T(e)&&e.output?L(this.config.output.outputPath,w(e.output,this.config.output.outputPath)):this.config.output.outputPath,this.workspaceConfig.workspaceRoot),ignore:T(e)&&e.ignore?g(e.ignore):void 0}))),this.config.plugins=(this.config.plugins??[]).filter(Boolean).reduce((e,t)=>(o(t)&&a(t,e.filter(e=>o(e)))||e.push(t),e),[]),this.config.tsconfig&&(this.config.tsconfig=s(this,this.config.tsconfig)),this.config.output.dts&&(this.config.output.dts=s(this,this.config.output.dts)),this.config.build.polyfill&&(this.config.build.polyfill=this.config.build.polyfill.map(e=>s(this,e))),this.config.output.assets&&(this.config.output.assets=this.config.output.assets.map(e=>({...e,glob:s(this,e.glob),ignore:e.ignore?e.ignore.map(e=>s(this,e)):void 0,input:s(this,e.input),output:s(this,e.output)}))),this.#s??=await f.create(this)}mergeUserConfig(e={},t=this.config.userConfig??{}){this.config.userConfig=_({entry:Array.isArray(e.entry)&&e.entry.length>0?e.entry:Array.isArray(t?.entry)&&t.entry.length>0?t.entry:[]},v(e??{},[`entry`]),v(t??{},[`entry`])),this.config.userConfig.output?.format&&(this.config.userConfig.output.format=P(g(this.config.userConfig.output?.format))),this.config.userConfig.plugins=(this.config.userConfig.plugins??[]).filter(Boolean).reduce((e,t)=>(o(t)&&a(t,e.filter(e=>o(e)))||e.push(t),e),[])}};export{Y as PowerlinesContext};
1
+ import{createProgram as e}from"../typescript/ts-morph.mjs";import{getTsconfigFilePath as t}from"../typescript/tsconfig.mjs";import{loadUserConfigFile as n,loadWorkspaceConfig as r}from"../config-file.mjs";import{createResolver as i}from"../../internal/helpers/resolver.mjs";import{checkDedupe as a,isPlugin as o}from"../../plugin-utils/helpers.mjs";import{replacePathTokens as s}from"../../plugin-utils/paths.mjs";import{getUniqueEntries as c,resolveEntriesSync as l}from"../entry.mjs";import{createLog as u,extendLog as d}from"../logger.mjs";import{VirtualFileSystem as f}from"../fs/vfs.mjs";import{CACHE_HASH_LENGTH as p,PROJECT_ROOT_HASH_LENGTH as m,getPrefixedProjectRootHash as h}from"../utilities/meta.mjs";import{toArray as g}from"@stryke/convert/to-array";import _ from"defu";import{omit as v}from"@stryke/helpers/omit";import{isString as y}from"@stryke/type-checks/is-string";import{LogLevelLabel as b}from"@storm-software/config-tools/types";import{relativeToWorkspaceRoot as x}from"@stryke/fs/get-workspace-root";import{resolvePackage as S}from"@stryke/fs/resolve";import{appendPath as C}from"@stryke/path/append";import{replacePath as w}from"@stryke/path/replace";import{isSetObject as T}from"@stryke/type-checks/is-set-object";import{isSetString as E}from"@stryke/type-checks/is-set-string";import{readJsonFile as D}from"@stryke/fs/json";import{StormJSON as O}from"@stryke/json/storm-json";import{titleCase as k}from"@stryke/string-format/title-case";import{existsSync as A}from"@stryke/fs/exists";import{getEnvPaths as j}from"@stryke/env/get-env-paths";import{hashDirectory as M}from"@stryke/hash/hash-files";import{murmurhash as N}from"@stryke/hash/murmurhash";import{getUnique as P}from"@stryke/helpers/get-unique";import{fetchRequest as F}from"@stryke/http/fetch";import{isAbsolute as I}from"@stryke/path/is-type";import{joinPaths as L}from"@stryke/path/join";import{isNull as R}from"@stryke/type-checks/is-null";import{uuid as z}from"@stryke/unique-id/uuid";import{match as B,tsconfigPathsToRegExp as V}from"bundle-require";import{create as H}from"flat-cache";import{parse as U}from"oxc-parser";import{Agent as W,Response as G,interceptors as K,setGlobalDispatcher as q}from"undici";const J=new WeakMap;q(new W({keepAliveTimeout:1e4}).compose(K.retry({maxRetries:3,minTimeout:1e3,maxTimeout:1e4,timeoutFactor:2,retryAfter:!0})));var Y=class W{#e={};#t;#n=null;#r=z();#i=z();#a=Date.now();#o;#s;#c;#l;#u;#d;#f(e={}){return{variant:e.build?.variant,projectType:e.type,projectRoot:e.root,name:e.name,title:e.title,description:e.description,sourceRoot:e.sourceRoot,configFile:e.configFile,customLogger:e.customLogger,logLevel:e.logLevel,tsconfig:e.tsconfig,tsconfigRaw:e.tsconfigRaw,skipCache:e.skipCache,skipInstalls:e.skipInstalls,entry:e.entry,output:e.output,plugins:e.plugins,mode:e.mode,lint:e.lint,transform:e.transform,build:e.build,framework:e.framework,...e}}static async from(e,t){let n=new W(await r(e,t.root));await n.withUserConfig(t);let i=await S(`powerlines`);if(!i)throw Error("Could not resolve `powerlines` package location.");return n.powerlinesPath=i,n}dependencies={};devDependencies={};persistedMeta=void 0;powerlinesPath;packageJson;projectJson=void 0;resolver;resolvePatterns=[];get $$internal(){return this.#e}set $$internal(e){this.#e=e}get entry(){return l(this,g(this.config.entry))}get tsconfig(){return this.#c||(this.tsconfig={tsconfigFilePath:this.config.tsconfig}),this.#c}set tsconfig(e){this.#c=e,this.resolvePatterns=V(e?.options?.paths??{})}get fs(){return this.#s||=f.createSync(this),this.#s}get checksum(){return this.#n}get meta(){return{buildId:this.#r,releaseId:this.#i,checksum:this.#n,timestamp:this.#a,projectRootHash:N({workspaceRoot:this.workspaceConfig?.workspaceRoot,projectRoot:this.config?.projectRoot},{maxLength:m}),configHash:N(this.config,{maxLength:p})}}get config(){return this.resolvedConfig??{}}get log(){return this.logFn||=this.createLog(),this.logFn}get workspaceConfig(){return this.#t}get envPaths(){return this.#o||=j({orgId:`storm-software`,appId:`powerlines`,workspaceRoot:this.workspaceConfig.workspaceRoot}),this.#o}get artifactsPath(){return L(this.workspaceConfig.workspaceRoot,this.config.projectRoot,this.config.output.artifactsPath)}get builtinsPath(){return L(this.artifactsPath,`builtins`)}get entryPath(){return L(this.artifactsPath,`entry`)}get dataPath(){return L(this.envPaths.data,`projects`,h(this.config.name,this.meta.projectRootHash))}get cachePath(){return L(this.envPaths.cache,`projects`,N({checksum:this.#n,config:this.meta.configHash},{maxLength:p}))}get dtsPath(){return this.config.output.dts?C(this.config.output.dts,this.workspaceConfig.workspaceRoot):L(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`powerlines.d.ts`)}get relativeToWorkspaceRoot(){return x(this.config.projectRoot)}get builtins(){return Object.values(this.fs.metadata).filter(e=>e&&e.type===`builtin`).map(e=>e?.id).filter(Boolean)}get program(){return this.#l||=e(this,{skipAddingFilesFromTsConfig:!0}),this.#l}get parserCache(){return this.#u||=H({cacheId:`parser`,cacheDir:this.cachePath,ttl:7200*1e3,lruSize:5e3,persistInterval:250}),this.#u}get requestCache(){return this.#d||=H({cacheId:`http`,cacheDir:this.cachePath,ttl:300*1e3,lruSize:5e3,persistInterval:250}),this.#d}async fetch(e,t={}){let n=N({input:e.toString(),options:JSON.stringify(t)});if(!this.config.skipCache&&!t.skipCache){let e=this.requestCache.get(n);if(e)return new G(e.body,{status:e.status,statusText:e.statusText,headers:e.headers})}let r=await F(e,{timeout:12e3,...t}),i={body:await r.text(),status:r.status,statusText:r.statusText,headers:Object.fromEntries(r.headers.entries())};if(!this.config.skipCache&&!t.skipCache)try{this.requestCache.set(n,i)}catch{}return new G(i.body,{status:i.status,statusText:i.statusText,headers:i.headers})}async parse(e,t={}){let n=N({code:e,options:t}),r;return!this.config.skipCache&&(r=this.parserCache.get(n),r)?r:(r=await U(`source.${t.lang||`ts`}`,e,{...t,sourceType:`module`,showSemanticErrors:this.config.mode===`development`}),this.config.skipCache||this.parserCache.set(n,r),r)}async resolve(e,t,n={}){let r=e;if(this.config.build.alias)if(Array.isArray(this.config.build.alias)){let e=this.config.build.alias.find(e=>B(r,[e.find]));e&&(r=e.replacement)}else T(this.config.build.alias)&&this.config.build.alias[e]&&(r=this.config.build.alias[e]);if(this.fs.isVirtual(r)){let e=await this.fs.resolve(r,t,{conditions:this.config.build.conditions,extensions:this.config.build.extensions,...n});return e?{id:`\0${e}`,external:this.config.projectType!==`application`}:void 0}if(this.config.build.skipNodeModulesBundle){if(B(r,this.resolvePatterns)||B(r,this.config.build.noExternal))return;if(B(r,this.config.build.external)||r.startsWith(`node:`)||!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(r))return{id:r,external:!0}}else{if(B(r,this.config.build.noExternal))return;if(B(r,this.config.build.external)||r.startsWith(`node:`))return{id:r,external:!0}}}async load(e){let t=await this.fs.resolve(e);if(!t)return;let n=await this.fs.read(t);if(n)return{code:n,map:null}}async getBuiltins(){return Promise.all(Object.entries(this.fs.metadata).filter(([,e])=>e&&e.type===`builtin`).map(async([e,t])=>{let n=await this.fs.read(e);return{...t,path:e,code:n}}))}async emitEntry(e,t,n={}){return this.fs.write(I(t)?t:C(t,this.entryPath),e,_(n,{type:`entry`}))}async emitBuiltin(e,t,n,r={}){return this.fs.write(n?I(n)?n:L(this.builtinsPath,n):C(t,this.builtinsPath),e,_(r,{type:`builtin`}))}async withUserConfig(e,t={isHighPriority:!0}){this.mergeUserConfig(e),await this.init(this.config.userConfig,t)}async withInlineConfig(e,t={isHighPriority:!0}){if(this.config.inlineConfig=e,e.command===`new`){let e=L(this.workspaceConfig.workspaceRoot,`package.json`);if(!A(e))throw Error(`The workspace package.json file could not be found at ${e}`);this.packageJson=await D(e),this.workspaceConfig.repository??=E(this.packageJson?.repository)?this.packageJson.repository:this.packageJson?.repository?.url}await this.init(this.config.inlineConfig,t)}fatal(e){this.log(b.FATAL,y(e)?e:O.stringify(e))}error(e){this.log(b.ERROR,y(e)?e:O.stringify(e))}warn(e){this.log(b.WARN,y(e)?e:O.stringify(e))}info(e){this.log(b.INFO,y(e)?e:O.stringify(e))}debug(e){this.log(b.DEBUG,y(e)?e:O.stringify(e))}trace(e){this.log(b.TRACE,y(e)?e:O.stringify(e))}createLog(e=null){return u(e,{...this.config,logLevel:R(this.config.logLevel)?`silent`:this.config.logLevel})}extendLog(e){return d(this.log,e)}async generateChecksum(e=this.config.projectRoot){return this.#n=await M(e,{ignore:[`node_modules`,`.git`,`.nx`,`.cache`,`.storm`,`tmp`,`dist`]}),this.#n}constructor(e){this.#t=e,this.#o=j({orgId:`storm-software`,appId:`powerlines`,workspaceRoot:e.workspaceRoot})}resolvedConfig={};logFn;async init(e={},r={isHighPriority:!0}){let l={projectRoot:e.root??this.config.projectRoot??this.config.userConfig?.root??this.config.inlineConfig?.root,mode:(e.mode??this.config.mode)||this.workspaceConfig.mode,skipCache:e.skipCache??this.config.skipCache??!1,configFile:e.configFile??this.config.configFile,framework:e.framework??this.config.framework??`powerlines`,command:this.config.inlineConfig?.command};if(J.has(l)){let e=J.get(l);this.projectJson=e.projectJson,this.packageJson=e.packageJson,this.#n=e.checksum,this.resolver=e.resolver,this.mergeUserConfig(e.userConfig.config,this.config.userConfig)}else{let t=L(l.projectRoot,`project.json`);A(t)&&(this.projectJson=await D(t));let r=L(l.projectRoot,`package.json`);A(r)&&(this.packageJson=await D(r)),this.#n=await this.generateChecksum(l.projectRoot),this.resolver=i({workspaceRoot:this.workspaceConfig.workspaceRoot,projectRoot:l.projectRoot,cacheDir:this.cachePath,mode:l.mode,logLevel:e.logLevel||this.config?.logLevel||this.workspaceConfig.logLevel||`info`,skipCache:l.skipCache});let a=await n(l.projectRoot,this.workspaceConfig.workspaceRoot,this.resolver,l.command,l.mode,l.configFile,l.framework);this.mergeUserConfig(a.config),J.set(l,{projectJson:this.projectJson,packageJson:this.packageJson,checksum:this.#n,resolver:this.resolver,userConfig:a})}e.tsconfig??=t(this.workspaceConfig.workspaceRoot,l.projectRoot,e.tsconfig),T(e)&&(this.resolvedConfig=_({inlineConfig:this.config.inlineConfig,userConfig:this.config.userConfig},r.isHighPriority?this.#f(e):{},{command:this.config.inlineConfig?.command,...this.#f(this.config.inlineConfig)},this.#f(this.config.userConfig),{mode:this.workspaceConfig?.mode,logLevel:this.workspaceConfig?.logLevel,skipCache:this.workspaceConfig?.skipCache},{name:this.projectJson?.name||this.packageJson?.name,version:this.packageJson?.version,description:this.packageJson?.description,sourceRoot:this.projectJson?.sourceRoot||C(`src`,l.projectRoot),output:_(e.output??{},{outputPath:l.projectRoot?L(this.workspaceConfig?.directories?.build||`dist`,l.projectRoot):this.workspaceConfig?.directories?.build||`dist`,artifactsPath:L(l.projectRoot,`.${e.framework??`powerlines`}`),dts:L(l.projectRoot,`${e.framework??`powerlines`}.d.ts`),builtinPrefix:e.framework??`powerlines`,assets:[{glob:`LICENSE`},{input:l.projectRoot,glob:`*.md`},{input:l.projectRoot,glob:`package.json`}]})},r.isHighPriority?{}:this.#f(e),{inlineConfig:{},userConfig:{},framework:`powerlines`,platform:`neutral`,mode:`production`,projectType:`application`,logLevel:`info`,preview:!1,environments:{},transform:{babel:{plugins:[],presets:[]}},lint:{eslint:{}},build:{target:`esnext`,override:{}}})),this.config.entry=c(this.config.entry),this.config.name?.startsWith(`@`)&&this.config.name.split(`/`).filter(Boolean).length>1&&(this.config.name=this.config.name.split(`/`).filter(Boolean)[1]),this.config.title??=k(this.config.name),this.config.userConfig.build?.external&&(this.config.userConfig.build.external=P(this.config.userConfig.build.external)),this.config.userConfig.build?.noExternal&&(this.config.userConfig.build.noExternal=P(this.config.userConfig.build.noExternal)),this.config.build.external&&(this.config.build.external=P(this.config.build.external)),this.config.build.noExternal&&(this.config.build.noExternal=P(this.config.build.noExternal)),this.config.output.format=P(g(this.config.output?.format??(this.config.projectType===`library`?[`cjs`,`esm`]:[`esm`]))),this.config.projectRoot&&this.config.projectRoot!==`.`&&this.config.projectRoot!==`./`&&this.config.projectRoot!==this.workspaceConfig.workspaceRoot?(this.config.output.outputPath??=L(`dist`,this.config.projectRoot),this.config.output.buildPath??=L(this.config.projectRoot,`dist`)):(this.config.output.outputPath??=`dist`,this.config.output.buildPath??=`dist`),this.config.output.assets=P(this.config.output.assets.map(e=>({glob:T(e)?e.glob:e,input:y(e)||!e.input||e.input===`.`||e.input===`/`||e.input===`./`?this.workspaceConfig.workspaceRoot:C(e.input,this.workspaceConfig.workspaceRoot),output:C(T(e)&&e.output?L(this.config.output.outputPath,w(w(e.output,w(this.config.output.outputPath,this.workspaceConfig.workspaceRoot)),this.config.output.outputPath)):this.config.output.outputPath,this.workspaceConfig.workspaceRoot),ignore:T(e)&&e.ignore?g(e.ignore):void 0}))),this.config.plugins=(this.config.plugins??[]).filter(Boolean).reduce((e,t)=>(o(t)&&a(t,e.filter(e=>o(e)))||e.push(t),e),[]),this.config.tsconfig&&(this.config.tsconfig=s(this,this.config.tsconfig)),this.config.output.dts&&(this.config.output.dts=s(this,this.config.output.dts)),this.config.build.polyfill&&(this.config.build.polyfill=this.config.build.polyfill.map(e=>s(this,e))),this.config.output.assets&&(this.config.output.assets=this.config.output.assets.map(e=>({...e,glob:s(this,e.glob),ignore:e.ignore?e.ignore.map(e=>s(this,e)):void 0,input:s(this,e.input),output:s(this,e.output)}))),this.#s??=await f.create(this)}mergeUserConfig(e={},t=this.config.userConfig??{}){this.config.userConfig=_({entry:Array.isArray(e.entry)&&e.entry.length>0?e.entry:Array.isArray(t?.entry)&&t.entry.length>0?t.entry:[]},v(e??{},[`entry`]),v(t??{},[`entry`])),this.config.userConfig.output?.format&&(this.config.userConfig.output.format=P(g(this.config.userConfig.output?.format))),this.config.userConfig.plugins=(this.config.userConfig.plugins??[]).filter(Boolean).reduce((e,t)=>(o(t)&&a(t,e.filter(e=>o(e)))||e.push(t),e),[])}};export{Y as PowerlinesContext};
@@ -1 +1 @@
1
- import{isString as e}from"@stryke/type-checks/is-string";import{isSetObject as t}from"@stryke/type-checks/is-set-object";import"@stryke/fs/read-file";function n(n){return n?e(n)?n:t(n)&&`code`in n?n.code:n.toString():``}export{n as getString};
1
+ import{isString as e}from"@stryke/type-checks/is-string";import{isSetObject as t}from"@stryke/type-checks/is-set-object";import"@stryke/fs/read-file";import"magic-string";function n(n){return n?e(n)?n:t(n)&&`code`in n?n.code:n.toString():``}export{n as getString};
@@ -6,6 +6,7 @@ import { TSConfig } from "./tsconfig.mjs";
6
6
  import { PluginContext } from "./context.mjs";
7
7
  import { LogLevelLabel } from "@storm-software/config-tools/types";
8
8
  import { transformAsync } from "@babel/core";
9
+ import "c12";
9
10
  import { PreviewOptions } from "vite";
10
11
  import { MaybePromise } from "@stryke/types/base";
11
12
  import { Format } from "@storm-software/build-tools/types";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-rollup",
3
- "version": "0.7.80",
3
+ "version": "0.7.82",
4
4
  "type": "module",
5
5
  "description": "A package containing a Powerlines plugin to assist in developing other Powerlines plugins.",
6
6
  "repository": {
@@ -152,15 +152,15 @@
152
152
  "@stryke/types": "^0.10.25",
153
153
  "defu": "^6.1.4",
154
154
  "jiti": "^2.6.1",
155
- "powerlines": "^0.32.1",
155
+ "powerlines": "^0.32.3",
156
156
  "rollup": "^4.53.5",
157
157
  "unplugin": "3.0.0-beta.3"
158
158
  },
159
159
  "devDependencies": {
160
- "@powerlines/nx": "^0.11.2",
161
- "@powerlines/plugin-plugin": "^0.12.23",
160
+ "@powerlines/nx": "^0.11.4",
161
+ "@powerlines/plugin-plugin": "^0.12.25",
162
162
  "@types/node": "^24.10.4"
163
163
  },
164
164
  "publishConfig": { "access": "public" },
165
- "gitHead": "c3c651a6535cbd8c4b65707d25f5592937524e2e"
165
+ "gitHead": "c8076b5e60eb462eaa49e0e00f3f86989c1a6d9c"
166
166
  }