@powerlines/plugin-rollup 0.7.71 โ 0.7.73
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.
- package/dist/powerlines/src/api.cjs +2 -2
- package/dist/powerlines/src/internal/helpers/environment.cjs +1 -1
- package/dist/powerlines/src/internal/helpers/environment.mjs +1 -1
- package/dist/powerlines/src/lib/contexts/api-context.cjs +1 -1
- package/dist/powerlines/src/lib/contexts/api-context.mjs +1 -1
- package/dist/powerlines/src/types/build.d.cts +6 -0
- package/dist/powerlines/src/types/build.d.mts +6 -0
- package/dist/powerlines/src/types/config.d.cts +12 -0
- package/dist/powerlines/src/types/config.d.mts +12 -0
- package/dist/powerlines/src/types/plugin.d.cts +1 -1
- package/dist/powerlines/src/types/plugin.d.mts +1 -1
- package/package.json +6 -6
|
@@ -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(`@stryke/convert/to-array`),f=require(`@stryke/path/join-paths`),p=require(`@stryke/type-checks/is-function`),m=require(`@storm-software/config-tools/types`),h=require(`@babel/core`),g=require(`@storm-software/config-tools/logger/console`),_=require(`@stryke/fs/helpers`),v=require(`@stryke/fs/install`),y=require(`@stryke/fs/list-files`),b=require(`@stryke/fs/package-fns`),x=require(`@stryke/fs/resolve`),S=require(`@stryke/path/append`),C=require(`@stryke/path/replace`),w=require(`@stryke/type-checks/is-error`),T=require(`@stryke/type-checks/is-number`),E=require(`@stryke/type-checks/is-object`),D=require(`@stryke/type-checks/is-promise`),O=require(`@stryke/type-checks/is-set`),k=require(`@stryke/type-checks/is-set-object`),A=require(`@stryke/type-checks/is-set-string`),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.#
|
|
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(`@stryke/convert/to-array`),f=require(`@stryke/path/join-paths`),p=require(`@stryke/type-checks/is-function`),m=require(`@storm-software/config-tools/types`),h=require(`@babel/core`),g=require(`@storm-software/config-tools/logger/console`),_=require(`@stryke/fs/helpers`),v=require(`@stryke/fs/install`),y=require(`@stryke/fs/list-files`),b=require(`@stryke/fs/package-fns`),x=require(`@stryke/fs/resolve`),S=require(`@stryke/path/append`),C=require(`@stryke/path/replace`),w=require(`@stryke/type-checks/is-error`),T=require(`@stryke/type-checks/is-number`),E=require(`@stryke/type-checks/is-object`),D=require(`@stryke/type-checks/is-promise`),O=require(`@stryke/type-checks/is-set`),k=require(`@stryke/type-checks/is-set-object`),A=require(`@stryke/type-checks/is-set-string`),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(m.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(m.LogLevelLabel.TRACE,` ๐๏ธ Preparing the Powerlines project`),this.context.log(m.LogLevelLabel.TRACE,` โ๏ธ Aggregating configuration options for the Powerlines project`),await this.context.withInlineConfig(e),await this.#r(async e=>{if(e.log(m.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(m.LogLevelLabel.DEBUG,`The configuration provided ${(0,d.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
2
|
`)}`:``}.`),await o.resolveTsconfig(e),await i.installDependencies(e),await this.callHook(`configResolved`,{environment:e,order:`post`}),e.log(m.LogLevelLabel.TRACE,`Powerlines configuration has been resolved: \n\n${(0,g.formatLogMessage)(e.config)}`),e.fs.existsSync(e.cachePath)||await(0,_.createDirectory)(e.cachePath),e.fs.existsSync(e.dataPath)||await(0,_.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(m.LogLevelLabel.TRACE,`Preparing the TypeScript definitions for the Powerlines project.`),e.fs.existsSync(e.dtsPath)&&await e.fs.remove(e.dtsPath),e.log(m.LogLevelLabel.TRACE,`Transforming built-ins runtime modules files.`);let r=await Promise.all((await e.getBuiltins()).map(async n=>{let r=await(0,h.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(m.LogLevelLabel.TRACE,`Writing transformed built-in runtime file ${n.id}.`),await e.emitBuiltin(r.code,n.id,n.path),n.path}));if(!await(0,x.resolvePackage)(`typescript`))throw Error(`Could not resolve TypeScript package location. Please ensure TypeScript is installed.`);let i=r.reduce((t,n)=>{let r=(0,C.replacePath)(n,e.workspaceConfig.workspaceRoot);return t.includes(r)||t.push(r),t},[]);e.log(m.LogLevelLabel.TRACE,`Parsing TypeScript configuration for the Powerlines project.`);let s=await n.emitTypes(e,i);e.log(m.LogLevelLabel.TRACE,`Generating TypeScript declaration file ${e.dtsPath}.`);let c=[],l=e=>(0,E.isObject)(e)?e.code:e,d=await this.callHook(`types`,{environment:e,sequential:!0,order:`pre`,result:`merge`,asNextParam:l},s);if(d&&((0,k.isSetObject)(d)?(s=d.code,Array.isArray(d.directives)&&d.directives.length>0&&c.push(...d.directives)):(0,A.isSetString)(d)&&(s=d)),d=await this.callHook(`types`,{environment:e,sequential:!0,order:`normal`,result:`merge`,asNextParam:l},s),d&&((0,k.isSetObject)(d)?(s=d.code,Array.isArray(d.directives)&&d.directives.length>0&&c.push(...d.directives)):(0,A.isSetString)(d)&&(s=d)),d=await this.callHook(`types`,{environment:e,sequential:!0,order:`post`,result:`merge`,asNextParam:l},s),d&&((0,k.isSetObject)(d)?(s=d.code,Array.isArray(d.directives)&&d.directives.length>0&&c.push(...d.directives)):(0,A.isSetString)(d)&&(s=d)),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(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.#
|
|
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}":
|
|
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`);let t=require(`defu`);t=e.__toESM(t);let n=require(`@stryke/string-format/title-case`);const r=`
|
|
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
|
|
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};
|
|
@@ -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(`@stryke/convert/to-array`),o=require(`@storm-software/config-tools/types`),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,a.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(o.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(o.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(`@stryke/convert/to-array`),o=require(`@storm-software/config-tools/types`),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,a.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(o.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(o.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(o.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{
|
|
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{toArray as o}from"@stryke/convert/to-array";import{LogLevelLabel as s}from"@storm-software/config-tools/types";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(o(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(s.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(s.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(s.DEBUG,`Combined all ${Object.keys(this.environments).length} environments into a single global context.`)):t=await this.getEnvironment(),t}};export{d as PowerlinesAPIContext};
|
|
@@ -128,6 +128,12 @@ interface BuildConfig {
|
|
|
128
128
|
* Should the Powerlines CLI processes skip bundling the `node_modules` directory?
|
|
129
129
|
*/
|
|
130
130
|
skipNodeModulesBundle?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* If true, `process.env` referenced in code will be preserved as-is and evaluated in runtime. Otherwise, it is statically replaced as an empty object.
|
|
133
|
+
*
|
|
134
|
+
* @defaultValue false
|
|
135
|
+
*/
|
|
136
|
+
keepProcessEnv?: boolean;
|
|
131
137
|
/**
|
|
132
138
|
* An optional set of override options to apply to the selected build variant.
|
|
133
139
|
*
|
|
@@ -128,6 +128,12 @@ interface BuildConfig {
|
|
|
128
128
|
* Should the Powerlines CLI processes skip bundling the `node_modules` directory?
|
|
129
129
|
*/
|
|
130
130
|
skipNodeModulesBundle?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* If true, `process.env` referenced in code will be preserved as-is and evaluated in runtime. Otherwise, it is statically replaced as an empty object.
|
|
133
|
+
*
|
|
134
|
+
* @defaultValue false
|
|
135
|
+
*/
|
|
136
|
+
keepProcessEnv?: boolean;
|
|
131
137
|
/**
|
|
132
138
|
* An optional set of override options to apply to the selected build variant.
|
|
133
139
|
*
|
|
@@ -300,6 +300,18 @@ interface CommonUserConfig extends BaseConfig {
|
|
|
300
300
|
* Environment-specific configurations
|
|
301
301
|
*/
|
|
302
302
|
environments?: Record<string, EnvironmentConfig>;
|
|
303
|
+
/**
|
|
304
|
+
* Should a single `build` process be ran for each environment?
|
|
305
|
+
*
|
|
306
|
+
* @remarks
|
|
307
|
+
* This option determines how environments are managed during the `build` process. The available options are:
|
|
308
|
+
*
|
|
309
|
+
* - `false`: A separate build is ran for each environment.
|
|
310
|
+
* - `true`: A single build is ran for all environments.
|
|
311
|
+
*
|
|
312
|
+
* @defaultValue false
|
|
313
|
+
*/
|
|
314
|
+
singleBuild?: boolean;
|
|
303
315
|
/**
|
|
304
316
|
* A string identifier that allows a child framework or tool to identify itself when using Powerlines.
|
|
305
317
|
*
|
|
@@ -302,6 +302,18 @@ interface CommonUserConfig extends BaseConfig {
|
|
|
302
302
|
* Environment-specific configurations
|
|
303
303
|
*/
|
|
304
304
|
environments?: Record<string, EnvironmentConfig>;
|
|
305
|
+
/**
|
|
306
|
+
* Should a single `build` process be ran for each environment?
|
|
307
|
+
*
|
|
308
|
+
* @remarks
|
|
309
|
+
* This option determines how environments are managed during the `build` process. The available options are:
|
|
310
|
+
*
|
|
311
|
+
* - `false`: A separate build is ran for each environment.
|
|
312
|
+
* - `true`: A single build is ran for all environments.
|
|
313
|
+
*
|
|
314
|
+
* @defaultValue false
|
|
315
|
+
*/
|
|
316
|
+
singleBuild?: boolean;
|
|
305
317
|
/**
|
|
306
318
|
* A string identifier that allows a child framework or tool to identify itself when using Powerlines.
|
|
307
319
|
*
|
|
@@ -178,7 +178,7 @@ type PluginHooks<TContext extends PluginContext = PluginContext> = { [TKey in ke
|
|
|
178
178
|
}) => MaybePromise<string | ExternalIdResult | null | undefined>, "id">;
|
|
179
179
|
};
|
|
180
180
|
type PluginBuildPlugins<TContext extends PluginContext = PluginContext> = { [TBuildVariant in UnpluginBuildVariant]?: BuildPlugin<TContext, TBuildVariant> };
|
|
181
|
-
interface Plugin<
|
|
181
|
+
interface Plugin<TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> extends Partial<PluginHooks<TContext>>, PluginBuildPlugins<TContext> {
|
|
182
182
|
/**
|
|
183
183
|
* The name of the plugin, for use in deduplication, error messages and logs.
|
|
184
184
|
*/
|
|
@@ -178,7 +178,7 @@ type PluginHooks<TContext extends PluginContext = PluginContext> = { [TKey in ke
|
|
|
178
178
|
}) => MaybePromise<string | ExternalIdResult | null | undefined>, "id">;
|
|
179
179
|
};
|
|
180
180
|
type PluginBuildPlugins<TContext extends PluginContext = PluginContext> = { [TBuildVariant in UnpluginBuildVariant]?: BuildPlugin<TContext, TBuildVariant> };
|
|
181
|
-
interface Plugin<
|
|
181
|
+
interface Plugin<TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> extends Partial<PluginHooks<TContext>>, PluginBuildPlugins<TContext> {
|
|
182
182
|
/**
|
|
183
183
|
* The name of the plugin, for use in deduplication, error messages and logs.
|
|
184
184
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-rollup",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.73",
|
|
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.23",
|
|
153
153
|
"defu": "^6.1.4",
|
|
154
154
|
"jiti": "^2.6.1",
|
|
155
|
-
"powerlines": "^0.
|
|
155
|
+
"powerlines": "^0.31.1",
|
|
156
156
|
"rollup": "^4.53.3",
|
|
157
157
|
"unplugin": "3.0.0-beta.3"
|
|
158
158
|
},
|
|
159
159
|
"devDependencies": {
|
|
160
|
-
"@powerlines/nx": "^0.10.
|
|
161
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
162
|
-
"@types/node": "^24.10.
|
|
160
|
+
"@powerlines/nx": "^0.10.64",
|
|
161
|
+
"@powerlines/plugin-plugin": "^0.12.16",
|
|
162
|
+
"@types/node": "^24.10.4"
|
|
163
163
|
},
|
|
164
164
|
"publishConfig": { "access": "public" },
|
|
165
|
-
"gitHead": "
|
|
165
|
+
"gitHead": "970018c8e5c0c11f91527bdf8981930d6e05fcb2"
|
|
166
166
|
}
|