@powerlines/plugin-vite 0.14.57 → 0.14.59
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/_virtual/rolldown_runtime.cjs +1 -0
- package/dist/helpers/index.cjs +1 -1
- package/dist/helpers/index.d.cts +1 -3
- package/dist/helpers/index.d.mts +1 -3
- package/dist/helpers/index.mjs +1 -1
- package/dist/helpers/unplugin.cjs +1 -1
- package/dist/helpers/unplugin.d.cts +6 -2
- package/dist/helpers/unplugin.d.mts +6 -2
- package/dist/helpers/unplugin.mjs +1 -1
- package/dist/index.cjs +1 -14
- package/dist/index.d.cts +3 -4
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +1 -14
- package/dist/powerlines/schemas/fs.cjs +1 -0
- package/dist/powerlines/schemas/fs.mjs +1 -0
- package/dist/powerlines/src/api.cjs +11 -0
- package/dist/powerlines/src/api.mjs +1 -0
- package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +1 -0
- package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +1 -0
- package/dist/powerlines/src/internal/helpers/environment.cjs +1 -0
- package/dist/powerlines/src/internal/helpers/environment.mjs +1 -0
- package/dist/powerlines/src/internal/helpers/generate-types.cjs +8 -0
- package/dist/powerlines/src/internal/helpers/generate-types.mjs +8 -0
- package/dist/powerlines/src/internal/helpers/hooks.cjs +1 -0
- package/dist/powerlines/src/internal/helpers/hooks.mjs +1 -0
- package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +3 -0
- package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +3 -0
- package/dist/powerlines/src/internal/helpers/install.cjs +1 -0
- package/dist/powerlines/src/internal/helpers/install.mjs +1 -0
- package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +8 -0
- package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +8 -0
- package/dist/powerlines/src/internal/helpers/resolver.cjs +1 -0
- package/dist/powerlines/src/internal/helpers/resolver.mjs +1 -0
- package/dist/powerlines/src/lib/build/esbuild.cjs +14 -0
- package/dist/powerlines/src/lib/build/esbuild.mjs +14 -0
- package/dist/powerlines/src/lib/build/vite.cjs +1 -0
- package/dist/powerlines/src/lib/build/vite.mjs +1 -0
- package/dist/powerlines/src/lib/config-file.cjs +1 -0
- package/dist/powerlines/src/lib/config-file.mjs +1 -0
- package/dist/powerlines/src/lib/contexts/api-context.cjs +1 -0
- package/dist/powerlines/src/lib/contexts/api-context.mjs +1 -0
- package/dist/powerlines/src/lib/contexts/context.cjs +1 -0
- package/dist/powerlines/src/lib/contexts/context.mjs +1 -0
- package/dist/powerlines/src/lib/contexts/environment-context.cjs +1 -0
- package/dist/powerlines/src/lib/contexts/environment-context.mjs +1 -0
- package/dist/powerlines/src/lib/contexts/plugin-context.cjs +1 -0
- package/dist/powerlines/src/lib/contexts/plugin-context.mjs +1 -0
- package/dist/powerlines/src/lib/entry.cjs +1 -0
- package/dist/powerlines/src/lib/entry.mjs +1 -0
- package/dist/powerlines/src/lib/fs/helpers.cjs +1 -0
- package/dist/powerlines/src/lib/fs/helpers.mjs +1 -0
- package/dist/powerlines/src/lib/fs/storage/base.cjs +1 -0
- package/dist/powerlines/src/lib/fs/storage/base.mjs +1 -0
- package/dist/powerlines/src/lib/fs/storage/file-system.cjs +1 -0
- package/dist/powerlines/src/lib/fs/storage/file-system.mjs +1 -0
- package/dist/powerlines/src/lib/fs/storage/virtual.cjs +1 -0
- package/dist/powerlines/src/lib/fs/storage/virtual.mjs +1 -0
- package/dist/powerlines/src/lib/fs/vfs.cjs +1 -0
- package/dist/powerlines/src/lib/fs/vfs.mjs +1 -0
- package/dist/powerlines/src/lib/logger.cjs +1 -0
- package/dist/powerlines/src/lib/logger.mjs +1 -0
- package/dist/powerlines/src/lib/typescript/ts-morph.cjs +1 -0
- package/dist/powerlines/src/lib/typescript/ts-morph.mjs +1 -0
- package/dist/powerlines/src/lib/typescript/tsconfig.cjs +4 -0
- package/dist/powerlines/src/lib/typescript/tsconfig.mjs +4 -0
- package/dist/powerlines/src/lib/unplugin/factory.cjs +1 -0
- package/dist/powerlines/src/lib/unplugin/factory.mjs +1 -0
- package/dist/powerlines/src/lib/unplugin/helpers.cjs +1 -0
- package/dist/powerlines/src/lib/unplugin/helpers.mjs +1 -0
- package/dist/powerlines/src/lib/unplugin/index.cjs +1 -0
- package/dist/powerlines/src/lib/unplugin/index.mjs +1 -0
- package/dist/powerlines/src/lib/unplugin/plugin.cjs +6 -0
- package/dist/powerlines/src/lib/unplugin/plugin.mjs +6 -0
- package/dist/powerlines/src/lib/utilities/file-header.cjs +10 -0
- package/dist/powerlines/src/lib/utilities/file-header.mjs +10 -0
- package/dist/powerlines/src/lib/utilities/meta.cjs +1 -0
- package/dist/powerlines/src/lib/utilities/meta.mjs +1 -0
- package/dist/powerlines/src/lib/utilities/source-file.cjs +1 -0
- package/dist/powerlines/src/lib/utilities/source-file.mjs +1 -0
- package/dist/powerlines/src/plugin-utils/helpers.cjs +1 -0
- package/dist/powerlines/src/plugin-utils/helpers.mjs +1 -0
- package/dist/powerlines/src/plugin-utils/paths.cjs +1 -0
- package/dist/powerlines/src/plugin-utils/paths.mjs +1 -0
- package/dist/powerlines/src/types/babel.d.mts +4 -0
- package/dist/powerlines/src/types/build.d.cts +143 -0
- package/dist/powerlines/src/types/build.d.mts +143 -0
- package/dist/powerlines/src/types/commands.cjs +1 -0
- package/dist/powerlines/src/types/commands.d.cts +8 -0
- package/dist/powerlines/src/types/commands.d.mts +9 -0
- package/dist/powerlines/src/types/commands.mjs +1 -0
- package/dist/powerlines/src/types/config.d.cts +346 -0
- package/dist/powerlines/src/types/config.d.mts +348 -0
- package/dist/powerlines/src/types/context.d.cts +347 -0
- package/dist/powerlines/src/types/context.d.mts +349 -0
- package/dist/powerlines/src/types/fs.d.cts +458 -0
- package/dist/powerlines/src/types/fs.d.mts +458 -0
- package/dist/powerlines/src/types/hooks.d.mts +2 -0
- package/dist/powerlines/src/types/plugin.cjs +1 -0
- package/dist/powerlines/src/types/plugin.d.cts +232 -0
- package/dist/powerlines/src/types/plugin.d.mts +232 -0
- package/dist/powerlines/src/types/plugin.mjs +1 -0
- package/dist/powerlines/src/types/resolved.d.cts +82 -0
- package/dist/powerlines/src/types/resolved.d.mts +82 -0
- package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
- package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
- package/dist/types/index.cjs +0 -1
- package/dist/types/index.d.cts +1 -2
- package/dist/types/index.d.mts +1 -2
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.cjs +0 -1
- package/dist/types/plugin.d.cts +19 -1
- package/dist/types/plugin.d.mts +19 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +10 -10
- package/dist/helpers-CRPRhztf.mjs +0 -1
- package/dist/helpers-LF26RHol.cjs +0 -0
- package/dist/index-9iG2qHLe.d.mts +0 -1
- package/dist/index-D4ELpJXS.d.cts +0 -1
- package/dist/index-D6CnpA_r.d.cts +0 -1
- package/dist/index-DL0uimUT.d.mts +0 -1
- package/dist/plugin-BjiGfRHE.mjs +0 -1
- package/dist/plugin-DNxw71zw.d.mts +0 -1661
- package/dist/plugin-KSQf40eU.d.cts +0 -1658
- package/dist/plugin-pBKbb5K9.cjs +0 -0
- package/dist/types-n6NgD0QK.mjs +0 -1
- package/dist/types-o3zWarRp.cjs +0 -0
- package/dist/unplugin-CAkRwblv.d.cts +0 -7
- package/dist/unplugin-D-Soc-G5.d.mts +0 -7
- package/dist/unplugin-DD1hF9r3.mjs +0 -6
- package/dist/unplugin-UTNYpV5r.cjs +0 -44
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(
|
|
1
|
+
const e=require(`./unplugin.cjs`);exports.createVitePlugin=e.createVitePlugin;
|
package/dist/helpers/index.d.cts
CHANGED
package/dist/helpers/index.d.mts
CHANGED
package/dist/helpers/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createVitePlugin as e}from"./unplugin.mjs";export{e as createVitePlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../unplugin
|
|
1
|
+
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../powerlines/src/lib/unplugin/plugin.cjs`);require(`../powerlines/src/lib/unplugin/index.cjs`);let n=require(`unplugin`);function r(e){return(0,n.createVitePlugin)(t.createUnplugin(e))({})}exports.createVitePlugin=r;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import "../plugin
|
|
2
|
-
import
|
|
1
|
+
import { VitePluginContext } from "../types/plugin.cjs";
|
|
2
|
+
import * as vite0 from "vite";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/unplugin.d.ts
|
|
5
|
+
declare function createVitePlugin(context: VitePluginContext): vite0.Plugin<any> | vite0.Plugin<any>[];
|
|
6
|
+
//#endregion
|
|
3
7
|
export { createVitePlugin };
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import "../plugin
|
|
2
|
-
import
|
|
1
|
+
import { VitePluginContext } from "../types/plugin.mjs";
|
|
2
|
+
import * as vite0 from "vite";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/unplugin.d.ts
|
|
5
|
+
declare function createVitePlugin(context: VitePluginContext): vite0.Plugin<any> | vite0.Plugin<any>[];
|
|
6
|
+
//#endregion
|
|
3
7
|
export { createVitePlugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createUnplugin as e}from"../powerlines/src/lib/unplugin/plugin.mjs";import"../powerlines/src/lib/unplugin/index.mjs";import{createVitePlugin as t}from"unplugin";function n(n){return t(e(n))({})}export{n as createVitePlugin};
|
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./
|
|
2
|
-
import ${(0,s.camelCase)(e)} from "${t[0]}";
|
|
3
|
-
export { ${(0,s.camelCase)(e)} as "${e}" }`;if(t.length>1)return`
|
|
4
|
-
import ${t[1]===`*`?`* as ${(0,s.camelCase)(e)}`:`{ ${t[1]} as ${(0,s.camelCase)(e)} }`} from "${t[0]}";
|
|
5
|
-
export { ${(0,s.camelCase)(e)} as "${e}" }`}else if(t.length===1)return`
|
|
6
|
-
import ${e} from "${t[0]}";
|
|
7
|
-
export { ${e} };`;else if(t.length>1)return`
|
|
8
|
-
import ${t[1]===`*`?`* as ${e}`:`{ ${t[1]} as ${e} }`} from "${t[0]}";
|
|
9
|
-
export { ${e} };`}else if((0,s.camelCase)(e)!==e)return`
|
|
10
|
-
import ${(0,s.camelCase)(e)} from "${t[0]}";
|
|
11
|
-
export { ${(0,s.camelCase)(e)} as "${e}" }`;else return`
|
|
12
|
-
import ${e} from "${t}";
|
|
13
|
-
export { ${e} };`;return``}).join(`
|
|
14
|
-
`)),(0,i.default)({alias:e.builtins.reduce((t,n)=>{if(!t[n]){let r=e.fs.ids[n];r&&(t[n]=r)}return t},e.config.build.alias?Array.isArray(e.config.build.alias)?e.config.build.alias.reduce((e,t)=>(e[t.find.toString()]||(e[t.find.toString()]=t.replacement),e),{}):e.config.build.alias:{}),inject:t&&Object.keys(t).length>0?[(0,r.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.artifactsPath,`inject-shim.js`)]:void 0},e.config.build.variant===`esbuild`?(0,a.omit)(e.config.build.override,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`]):{},e.config.build.variant===`esbuild`?(0,a.omit)(e.config.build,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`,`variant`,`override`]):{},{mainFields:e.config.build.mainFields,conditions:e.config.build.conditions,define:e.config.build.define,resolveExtensions:e.config.build.extensions,packages:e.config.build.skipNodeModulesBundle?`external`:e.config.build.variant===`esbuild`?e.config.build.packages:void 0,format:Array.isArray(e.config.output.format)?e.config.output.format[0]:e.config.output.format,platform:e.config.build.platform,treeShaking:!!e.config.build?.treeshake||e.config.build?.treeShaking,outdir:e.config.output.buildPath,tsconfig:e.tsconfig.tsconfigFilePath,tsconfigRaw:e.tsconfig.tsconfigJson,minify:e.config.mode!==`development`,metafile:e.config.mode===`development`,sourcemap:e.config.mode===`development`},l)}const d={resolve:{extensions:[`.mjs`,`.js`,`.mts`,`.ts`,`.jsx`,`.tsx`,`.json`]},json:{stringify:!0},logLevel:`silent`,clearScreen:!0};function f(e){return(0,i.default)({resolve:{alias:e.builtins.reduce((t,n)=>{if(!t.find(e=>e.find===n)){let r=e.fs.ids[n];r&&t.push({find:n,replacement:r})}return t},e.config.build.alias?Array.isArray(e.config.build.alias)?e.config.build.alias:Object.entries(e.config.build.alias).reduce((e,[t,n])=>(e.find(e=>e.find===t)||e.push({find:t,replacement:n}),e),[]):[]),dedupe:e.config.build.dedupe,mainFields:e.config.build.mainFields,conditions:e.config.build.conditions,extensions:e.config.build.extensions}},e.config.build.variant===`vite`?e.config.build.override:{},e.config.build.variant===`vite`?(0,a.omit)(e.config.build,[`override`,`variant`]):{},{define:e.config.build.define,rootDir:e.config.sourceRoot,platform:e.config.build.platform,mode:e.config.mode===`development`?`development`:`production`,cacheDir:(0,r.joinPaths)(e.cachePath,`vite`),build:{minify:e.config.mode!==`development`,metafile:e.config.mode===`development`,sourcemap:e.config.mode===`development`,outDir:e.config.output.buildPath,tsconfig:e.tsconfig.tsconfigFilePath,tsconfigRaw:e.tsconfig.tsconfigJson},esbuild:u(e),logLevel:e.config.logLevel??void 0,envDir:e.config.projectRoot},d)}const p=(a={})=>({name:`vite`,config(){return this.log(t.LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `vite` build plugin."),{output:{format:[`cjs`,`esm`]},build:{...d,...a,variant:`vite`}}},async build(){this.log(t.LogLevelLabel.TRACE,`Building the Powerlines plugin.`);let o=(0,i.default)({config:!1,entry:this.entry},f(this),{plugins:[e.t(this)]}),s=`vite`;if(a.rolldown&&(0,n.isPackageExists)(`rolldown-vite`,{paths:[(0,r.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot),this.workspaceConfig.workspaceRoot]})&&(s=`rolldown-vite`),!(0,n.isPackageExists)(s,{paths:[(0,r.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot),this.workspaceConfig.workspaceRoot]}))throw Error(`Failed to find the "${s}" package required for the Powerlines "vite" plugin${a.rolldown?" with the `rolldown` option enabled":``}. Please run "npm install ${s} -D" to install it.`);let c=await this.resolver.import(s);if(!c)throw Error(`Failed to load the "${s}" module - this package is required when using the Powerlines "vite" plugin${a.rolldown?" with the `rolldown` option enabled":``}. Please ensure it is installed correctly.`);await c.build(o)}});var m=p;exports.createVitePlugin=e.t,exports.default=m,exports.plugin=p;
|
|
1
|
+
Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./powerlines/src/lib/build/vite.cjs`),n=require(`./helpers/unplugin.cjs`);require(`./helpers/index.cjs`);let r=require(`@storm-software/config-tools/types`),i=require(`@stryke/fs/package-fns`),a=require(`@stryke/path/join-paths`),o=require(`defu`);o=e.__toESM(o);const s=(e={})=>({name:`vite`,config(){return this.log(r.LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `vite` build plugin."),{output:{format:[`cjs`,`esm`]},build:{...t.DEFAULT_VITE_CONFIG,...e,variant:`vite`}}},async build(){this.log(r.LogLevelLabel.TRACE,`Building the Powerlines plugin.`);let s=(0,o.default)({config:!1,entry:this.entry},t.extractViteConfig(this),{plugins:[n.createVitePlugin(this)]}),c=`vite`;if(e.rolldown&&(0,i.isPackageExists)(`rolldown-vite`,{paths:[(0,a.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot),this.workspaceConfig.workspaceRoot]})&&(c=`rolldown-vite`),!(0,i.isPackageExists)(c,{paths:[(0,a.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot),this.workspaceConfig.workspaceRoot]}))throw Error(`Failed to find the "${c}" package required for the Powerlines "vite" plugin${e.rolldown?" with the `rolldown` option enabled":``}. Please run "npm install ${c} -D" to install it.`);let l=await this.resolver.import(c);if(!l)throw Error(`Failed to load the "${c}" module - this package is required when using the Powerlines "vite" plugin${e.rolldown?" with the `rolldown` option enabled":``}. Please ensure it is installed correctly.`);await l.build(s)}});var c=s;exports.createVitePlugin=n.createVitePlugin,exports.default=c,exports.plugin=s;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import "./
|
|
4
|
-
import "./index-D4ELpJXS.cjs";
|
|
1
|
+
import { Plugin } from "./powerlines/src/types/plugin.cjs";
|
|
2
|
+
import { VitePluginContext, VitePluginOptions, VitePluginResolvedConfig, __ΩVitePluginContext, __ΩVitePluginOptions, __ΩVitePluginResolvedConfig } from "./types/plugin.cjs";
|
|
3
|
+
import { createVitePlugin } from "./helpers/unplugin.cjs";
|
|
5
4
|
|
|
6
5
|
//#region src/index.d.ts
|
|
7
6
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import "./
|
|
4
|
-
import "./index
|
|
1
|
+
import { Plugin } from "./powerlines/src/types/plugin.mjs";
|
|
2
|
+
import { VitePluginContext, VitePluginOptions, VitePluginResolvedConfig, __ΩVitePluginContext, __ΩVitePluginOptions, __ΩVitePluginResolvedConfig } from "./types/plugin.mjs";
|
|
3
|
+
import { createVitePlugin } from "./helpers/unplugin.mjs";
|
|
4
|
+
import "./helpers/index.mjs";
|
|
5
|
+
import "./types/index.mjs";
|
|
5
6
|
|
|
6
7
|
//#region src/index.d.ts
|
|
7
|
-
|
|
8
8
|
/**
|
|
9
9
|
* A Powerlines plugin to assist in developing other Powerlines plugins.
|
|
10
10
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
import ${c(e)} from "${t[0]}";
|
|
3
|
-
export { ${c(e)} as "${e}" }`;if(t.length>1)return`
|
|
4
|
-
import ${t[1]===`*`?`* as ${c(e)}`:`{ ${t[1]} as ${c(e)} }`} from "${t[0]}";
|
|
5
|
-
export { ${c(e)} as "${e}" }`}else if(t.length===1)return`
|
|
6
|
-
import ${e} from "${t[0]}";
|
|
7
|
-
export { ${e} };`;else if(t.length>1)return`
|
|
8
|
-
import ${t[1]===`*`?`* as ${e}`:`{ ${t[1]} as ${e} }`} from "${t[0]}";
|
|
9
|
-
export { ${e} };`}else if(c(e)!==e)return`
|
|
10
|
-
import ${c(e)} from "${t[0]}";
|
|
11
|
-
export { ${c(e)} as "${e}" }`;else return`
|
|
12
|
-
import ${e} from "${t}";
|
|
13
|
-
export { ${e} };`;return``}).join(`
|
|
14
|
-
`)),i({alias:e.builtins.reduce((t,n)=>{if(!t[n]){let r=e.fs.ids[n];r&&(t[n]=r)}return t},e.config.build.alias?Array.isArray(e.config.build.alias)?e.config.build.alias.reduce((e,t)=>(e[t.find.toString()]||(e[t.find.toString()]=t.replacement),e),{}):e.config.build.alias:{}),inject:t&&Object.keys(t).length>0?[r(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.artifactsPath,`inject-shim.js`)]:void 0},e.config.build.variant===`esbuild`?a(e.config.build.override,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`]):{},e.config.build.variant===`esbuild`?a(e.config.build,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`,`variant`,`override`]):{},{mainFields:e.config.build.mainFields,conditions:e.config.build.conditions,define:e.config.build.define,resolveExtensions:e.config.build.extensions,packages:e.config.build.skipNodeModulesBundle?`external`:e.config.build.variant===`esbuild`?e.config.build.packages:void 0,format:Array.isArray(e.config.output.format)?e.config.output.format[0]:e.config.output.format,platform:e.config.build.platform,treeShaking:!!e.config.build?.treeshake||e.config.build?.treeShaking,outdir:e.config.output.buildPath,tsconfig:e.tsconfig.tsconfigFilePath,tsconfigRaw:e.tsconfig.tsconfigJson,minify:e.config.mode!==`development`,metafile:e.config.mode===`development`,sourcemap:e.config.mode===`development`},u)}const f={resolve:{extensions:[`.mjs`,`.js`,`.mts`,`.ts`,`.jsx`,`.tsx`,`.json`]},json:{stringify:!0},logLevel:`silent`,clearScreen:!0};function p(e){return i({resolve:{alias:e.builtins.reduce((t,n)=>{if(!t.find(e=>e.find===n)){let r=e.fs.ids[n];r&&t.push({find:n,replacement:r})}return t},e.config.build.alias?Array.isArray(e.config.build.alias)?e.config.build.alias:Object.entries(e.config.build.alias).reduce((e,[t,n])=>(e.find(e=>e.find===t)||e.push({find:t,replacement:n}),e),[]):[]),dedupe:e.config.build.dedupe,mainFields:e.config.build.mainFields,conditions:e.config.build.conditions,extensions:e.config.build.extensions}},e.config.build.variant===`vite`?e.config.build.override:{},e.config.build.variant===`vite`?a(e.config.build,[`override`,`variant`]):{},{define:e.config.build.define,rootDir:e.config.sourceRoot,platform:e.config.build.platform,mode:e.config.mode===`development`?`development`:`production`,cacheDir:r(e.cachePath,`vite`),build:{minify:e.config.mode!==`development`,metafile:e.config.mode===`development`,sourcemap:e.config.mode===`development`,outDir:e.config.output.buildPath,tsconfig:e.tsconfig.tsconfigFilePath,tsconfigRaw:e.tsconfig.tsconfigJson},esbuild:d(e),logLevel:e.config.logLevel??void 0,envDir:e.config.projectRoot},f)}const m=(a={})=>({name:`vite`,config(){return this.log(t.TRACE,"Providing default configuration for the Powerlines `vite` build plugin."),{output:{format:[`cjs`,`esm`]},build:{...f,...a,variant:`vite`}}},async build(){this.log(t.TRACE,`Building the Powerlines plugin.`);let o=i({config:!1,entry:this.entry},p(this),{plugins:[e(this)]}),s=`vite`;if(a.rolldown&&n(`rolldown-vite`,{paths:[r(this.workspaceConfig.workspaceRoot,this.config.projectRoot),this.workspaceConfig.workspaceRoot]})&&(s=`rolldown-vite`),!n(s,{paths:[r(this.workspaceConfig.workspaceRoot,this.config.projectRoot),this.workspaceConfig.workspaceRoot]}))throw Error(`Failed to find the "${s}" package required for the Powerlines "vite" plugin${a.rolldown?" with the `rolldown` option enabled":``}. Please run "npm install ${s} -D" to install it.`);let c=await this.resolver.import(s);if(!c)throw Error(`Failed to load the "${s}" module - this package is required when using the Powerlines "vite" plugin${a.rolldown?" with the `rolldown` option enabled":``}. Please ensure it is installed correctly.`);await c.build(o)}});var h=m;export{e as createVitePlugin,h as default,m as plugin};
|
|
1
|
+
import{DEFAULT_VITE_CONFIG as e,extractViteConfig as t}from"./powerlines/src/lib/build/vite.mjs";import{createVitePlugin as n}from"./helpers/unplugin.mjs";import"./helpers/index.mjs";import{LogLevelLabel as r}from"@storm-software/config-tools/types";import{isPackageExists as i}from"@stryke/fs/package-fns";import{joinPaths as a}from"@stryke/path/join-paths";import o from"defu";const s=(s={})=>({name:`vite`,config(){return this.log(r.TRACE,"Providing default configuration for the Powerlines `vite` build plugin."),{output:{format:[`cjs`,`esm`]},build:{...e,...s,variant:`vite`}}},async build(){this.log(r.TRACE,`Building the Powerlines plugin.`);let e=o({config:!1,entry:this.entry},t(this),{plugins:[n(this)]}),c=`vite`;if(s.rolldown&&i(`rolldown-vite`,{paths:[a(this.workspaceConfig.workspaceRoot,this.config.projectRoot),this.workspaceConfig.workspaceRoot]})&&(c=`rolldown-vite`),!i(c,{paths:[a(this.workspaceConfig.workspaceRoot,this.config.projectRoot),this.workspaceConfig.workspaceRoot]}))throw Error(`Failed to find the "${c}" package required for the Powerlines "vite" plugin${s.rolldown?" with the `rolldown` option enabled":``}. Please run "npm install ${c} -D" to install it.`);let l=await this.resolver.import(c);if(!l)throw Error(`Failed to load the "${c}" module - this package is required when using the Powerlines "vite" plugin${s.rolldown?" with the `rolldown` option enabled":``}. Please ensure it is installed correctly.`);await l.build(e)}});var c=s;export{n as createVitePlugin,c as default,s as plugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/capnp`);t=e.__toESM(t);var n=class extends t.Struct{static _capnp={displayName:`KeyValuePair`,id:`eabb26cf58b2a14c`,size:new t.ObjectSize(0,2)};get key(){return t.utils.getText(0,this)}set key(e){t.utils.setText(0,e,this)}get value(){return t.utils.getText(1,this)}set value(e){t.utils.setText(1,e,this)}toString(){return`FileMetadata_KeyValuePair_`+super.toString()}},r=class e extends t.Struct{static KeyValuePair=n;static _capnp={displayName:`FileMetadata`,id:`8e2cab5d7e28c7b3`,size:new t.ObjectSize(8,3),defaultType:`normal`};static _Properties;get id(){return t.utils.getText(0,this)}set id(e){t.utils.setText(0,e,this)}get type(){return t.utils.getText(1,this,e._capnp.defaultType)}set type(e){t.utils.setText(1,e,this)}get timestamp(){return t.utils.getUint32(0,this)}set timestamp(e){t.utils.setUint32(0,e,this)}_adoptProperties(e){t.utils.adopt(e,t.utils.getPointer(2,this))}_disownProperties(){return t.utils.disown(this.properties)}get properties(){return t.utils.getList(2,e._Properties,this)}_hasProperties(){return!t.utils.isNull(t.utils.getPointer(2,this))}_initProperties(n){return t.utils.initList(2,e._Properties,n,this)}set properties(e){t.utils.copyFrom(e,t.utils.getPointer(2,this))}toString(){return`FileMetadata_`+super.toString()}},i=class extends t.Struct{static _capnp={displayName:`FileId`,id:`990d6a471072f997`,size:new t.ObjectSize(0,2)};get id(){return t.utils.getText(0,this)}set id(e){t.utils.setText(0,e,this)}get path(){return t.utils.getText(1,this)}set path(e){t.utils.setText(1,e,this)}toString(){return`FileId_`+super.toString()}},a=class extends t.Struct{static _capnp={displayName:`FileStorage`,id:`9dca66ac858c9ebe`,size:new t.ObjectSize(0,2)};get path(){return t.utils.getText(0,this)}set path(e){t.utils.setText(0,e,this)}get code(){return t.utils.getText(1,this)}set code(e){t.utils.setText(1,e,this)}toString(){return`FileStorage_`+super.toString()}},o=class e extends t.Struct{static _capnp={displayName:`FileSystem`,id:`ae0c23d43e56abcf`,size:new t.ObjectSize(0,3)};static _Ids;static _Storage;static _Metadata;_adoptIds(e){t.utils.adopt(e,t.utils.getPointer(0,this))}_disownIds(){return t.utils.disown(this.ids)}get ids(){return t.utils.getList(0,e._Ids,this)}_hasIds(){return!t.utils.isNull(t.utils.getPointer(0,this))}_initIds(n){return t.utils.initList(0,e._Ids,n,this)}set ids(e){t.utils.copyFrom(e,t.utils.getPointer(0,this))}_adoptStorage(e){t.utils.adopt(e,t.utils.getPointer(1,this))}_disownStorage(){return t.utils.disown(this.storage)}get storage(){return t.utils.getList(1,e._Storage,this)}_hasStorage(){return!t.utils.isNull(t.utils.getPointer(1,this))}_initStorage(n){return t.utils.initList(1,e._Storage,n,this)}set storage(e){t.utils.copyFrom(e,t.utils.getPointer(1,this))}_adoptMetadata(e){t.utils.adopt(e,t.utils.getPointer(2,this))}_disownMetadata(){return t.utils.disown(this.metadata)}get metadata(){return t.utils.getList(2,e._Metadata,this)}_hasMetadata(){return!t.utils.isNull(t.utils.getPointer(2,this))}_initMetadata(n){return t.utils.initList(2,e._Metadata,n,this)}set metadata(e){t.utils.copyFrom(e,t.utils.getPointer(2,this))}toString(){return`FileSystem_`+super.toString()}};r._Properties=t.CompositeList(n),o._Ids=t.CompositeList(i),o._Storage=t.CompositeList(a),o._Metadata=t.CompositeList(r),exports.FileSystem=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"@stryke/capnp";var t=class extends e.Struct{static _capnp={displayName:`KeyValuePair`,id:`eabb26cf58b2a14c`,size:new e.ObjectSize(0,2)};get key(){return e.utils.getText(0,this)}set key(t){e.utils.setText(0,t,this)}get value(){return e.utils.getText(1,this)}set value(t){e.utils.setText(1,t,this)}toString(){return`FileMetadata_KeyValuePair_`+super.toString()}},n=class n extends e.Struct{static KeyValuePair=t;static _capnp={displayName:`FileMetadata`,id:`8e2cab5d7e28c7b3`,size:new e.ObjectSize(8,3),defaultType:`normal`};static _Properties;get id(){return e.utils.getText(0,this)}set id(t){e.utils.setText(0,t,this)}get type(){return e.utils.getText(1,this,n._capnp.defaultType)}set type(t){e.utils.setText(1,t,this)}get timestamp(){return e.utils.getUint32(0,this)}set timestamp(t){e.utils.setUint32(0,t,this)}_adoptProperties(t){e.utils.adopt(t,e.utils.getPointer(2,this))}_disownProperties(){return e.utils.disown(this.properties)}get properties(){return e.utils.getList(2,n._Properties,this)}_hasProperties(){return!e.utils.isNull(e.utils.getPointer(2,this))}_initProperties(t){return e.utils.initList(2,n._Properties,t,this)}set properties(t){e.utils.copyFrom(t,e.utils.getPointer(2,this))}toString(){return`FileMetadata_`+super.toString()}},r=class extends e.Struct{static _capnp={displayName:`FileId`,id:`990d6a471072f997`,size:new e.ObjectSize(0,2)};get id(){return e.utils.getText(0,this)}set id(t){e.utils.setText(0,t,this)}get path(){return e.utils.getText(1,this)}set path(t){e.utils.setText(1,t,this)}toString(){return`FileId_`+super.toString()}},i=class extends e.Struct{static _capnp={displayName:`FileStorage`,id:`9dca66ac858c9ebe`,size:new e.ObjectSize(0,2)};get path(){return e.utils.getText(0,this)}set path(t){e.utils.setText(0,t,this)}get code(){return e.utils.getText(1,this)}set code(t){e.utils.setText(1,t,this)}toString(){return`FileStorage_`+super.toString()}},a=class t extends e.Struct{static _capnp={displayName:`FileSystem`,id:`ae0c23d43e56abcf`,size:new e.ObjectSize(0,3)};static _Ids;static _Storage;static _Metadata;_adoptIds(t){e.utils.adopt(t,e.utils.getPointer(0,this))}_disownIds(){return e.utils.disown(this.ids)}get ids(){return e.utils.getList(0,t._Ids,this)}_hasIds(){return!e.utils.isNull(e.utils.getPointer(0,this))}_initIds(n){return e.utils.initList(0,t._Ids,n,this)}set ids(t){e.utils.copyFrom(t,e.utils.getPointer(0,this))}_adoptStorage(t){e.utils.adopt(t,e.utils.getPointer(1,this))}_disownStorage(){return e.utils.disown(this.storage)}get storage(){return e.utils.getList(1,t._Storage,this)}_hasStorage(){return!e.utils.isNull(e.utils.getPointer(1,this))}_initStorage(n){return e.utils.initList(1,t._Storage,n,this)}set storage(t){e.utils.copyFrom(t,e.utils.getPointer(1,this))}_adoptMetadata(t){e.utils.adopt(t,e.utils.getPointer(2,this))}_disownMetadata(){return e.utils.disown(this.metadata)}get metadata(){return e.utils.getList(2,t._Metadata,this)}_hasMetadata(){return!e.utils.isNull(e.utils.getPointer(2,this))}_initMetadata(n){return e.utils.initList(2,t._Metadata,n,this)}set metadata(t){e.utils.copyFrom(t,e.utils.getPointer(2,this))}toString(){return`FileSystem_`+super.toString()}};n._Properties=e.CompositeList(t),a._Ids=e.CompositeList(r),a._Storage=e.CompositeList(i),a._Metadata=e.CompositeList(n);export{a as FileSystem};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const e=require(`../../_virtual/rolldown_runtime.cjs`),t=require(`./internal/babel/module-resolver-plugin.cjs`),n=require(`./internal/helpers/generate-types.cjs`),r=require(`./internal/helpers/hooks.cjs`),i=require(`./internal/helpers/install-dependencies.cjs`),a=require(`./lib/typescript/tsconfig.cjs`),o=require(`./internal/helpers/resolve-tsconfig.cjs`),s=require(`./plugin-utils/helpers.cjs`),c=require(`./lib/utilities/meta.cjs`),l=require(`./lib/contexts/api-context.cjs`),u=require(`./lib/utilities/file-header.cjs`);let d=require(`@storm-software/config-tools/types`),f=require(`@stryke/fs/package-fns`),p=require(`@stryke/path/join-paths`),m=require(`@stryke/path/replace`),h=require(`@stryke/convert/to-array`),g=require(`@stryke/fs/list-files`),_=require(`@stryke/path/append`),v=require(`@stryke/type-checks/is-set-string`),y=require(`@babel/core`),b=require(`@storm-software/config-tools/logger/console`),x=require(`@stryke/fs/helpers`),S=require(`@stryke/fs/install`),C=require(`@stryke/fs/resolve`),w=require(`@stryke/type-checks/is-error`),T=require(`@stryke/type-checks/is-function`),E=require(`@stryke/type-checks/is-number`),D=require(`@stryke/type-checks/is-object`),O=require(`@stryke/type-checks/is-promise`),k=require(`@stryke/type-checks/is-set`),A=require(`@stryke/type-checks/is-set-object`),j=require(`chalk`);j=e.__toESM(j);let M=require(`handlebars`);M=e.__toESM(M);var N=class e{#e;get context(){return this.#e}constructor(e){this.#e=e}static async from(t,n){let r=new e(await l.PowerlinesAPIContext.from(t,n));r.#e.$$internal={api:r,addPlugin:r.#r.bind(r)};for(let e of r.context.config.plugins??[])await r.#r(e);r.context.plugins.length===0&&r.context.log(d.LogLevelLabel.WARN,`No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended.`);let i=await r.callHook(`config`,{environment:await r.context.getEnvironment(),sequential:!0,result:`merge`});return await r.context.withUserConfig(i,{isHighPriority:!1}),r}async prepare(e={command:`prepare`}){this.context.log(d.LogLevelLabel.TRACE,` 🏗️ Preparing the Powerlines project`),this.context.log(d.LogLevelLabel.TRACE,` ⚙️ Aggregating configuration options for the Powerlines project`),await this.context.withInlineConfig(e),await this.#n(async e=>{if(e.log(d.LogLevelLabel.TRACE,`Initializing the processing options for the Powerlines project.`),await this.callHook(`configResolved`,{environment:e,order:`pre`}),await o.initializeTsconfig(e),await this.callHook(`configResolved`,{environment:e,order:`normal`}),e.log(d.LogLevelLabel.DEBUG,`The configuration provided ${(0,h.toArray)(e.config.entry).length} entry point(s), Powerlines has found ${e.entry.length} entry files(s) for the ${e.config.title} project${e.entry.length>0&&e.entry.length<10?`: \n${e.entry.map(e=>`- ${e.input.file||e.file}${e.output?` -> ${e.output}`:``}`).join(`
|
|
2
|
+
`)}`:``}.`),await o.resolveTsconfig(e),await i.installDependencies(e),await this.callHook(`configResolved`,{environment:e,order:`post`}),e.log(d.LogLevelLabel.TRACE,`Powerlines configuration has been resolved: \n\n${(0,b.formatLogMessage)(e.config)}`),e.fs.existsSync(e.cachePath)||await(0,x.createDirectory)(e.cachePath),e.fs.existsSync(e.dataPath)||await(0,x.createDirectory)(e.dataPath),await this.callHook(`prepare`,{environment:e,order:`pre`}),await this.callHook(`prepare`,{environment:e,order:`normal`}),e.config.output.dts!==!1){e.log(d.LogLevelLabel.TRACE,`Preparing the TypeScript definitions for the Powerlines project.`),e.fs.existsSync(e.dtsPath)&&await e.fs.remove(e.dtsPath),e.log(d.LogLevelLabel.TRACE,`Transforming built-ins runtime modules files.`);let r=await Promise.all((await e.getBuiltins()).map(async n=>{let r=await(0,y.transformAsync)(n.code.toString(),{highlightCode:!0,code:!0,ast:!1,cloneInputAst:!1,comments:!0,sourceType:`module`,configFile:!1,babelrc:!1,envName:e.config.mode,caller:{name:`powerlines`},...e.config.transform.babel,filename:n.path,plugins:[[`@babel/plugin-syntax-typescript`],[t.moduleResolverBabelPlugin(e)]]});if(!r?.code)throw Error(`Powerlines - Generate Types failed to compile ${n.id}`);return e.log(d.LogLevelLabel.TRACE,`Writing transformed built-in runtime file ${n.id}.`),await e.emitBuiltin(r.code,n.id,n.path),n.path}));if(!await(0,C.resolvePackage)(`typescript`))throw Error(`Could not resolve TypeScript package location. Please ensure TypeScript is installed.`);let i=r.reduce((t,n)=>{let r=(0,m.replacePath)(n,e.workspaceConfig.workspaceRoot);return t.includes(r)||t.push(r),t},[]);e.log(d.LogLevelLabel.TRACE,`Parsing TypeScript configuration for the Powerlines project.`);let s=await n.emitTypes(e,i);e.log(d.LogLevelLabel.TRACE,`Generating TypeScript declaration file ${e.dtsPath}.`);let c=[],l=e=>(0,D.isObject)(e)?e.code:e,f=await this.callHook(`types`,{environment:e,sequential:!0,order:`pre`,result:`merge`,asNextParam:l},s);if(f&&((0,A.isSetObject)(f)?(s=f.code,Array.isArray(f.directives)&&f.directives.length>0&&c.push(...f.directives)):(0,v.isSetString)(f)&&(s=f)),f=await this.callHook(`types`,{environment:e,sequential:!0,order:`normal`,result:`merge`,asNextParam:l},s),f&&((0,A.isSetObject)(f)?(s=f.code,Array.isArray(f.directives)&&f.directives.length>0&&c.push(...f.directives)):(0,v.isSetString)(f)&&(s=f)),f=await this.callHook(`types`,{environment:e,sequential:!0,order:`post`,result:`merge`,asNextParam:l},s),f&&((0,A.isSetObject)(f)?(s=f.code,Array.isArray(f.directives)&&f.directives.length>0&&c.push(...f.directives)):(0,v.isSetString)(f)&&(s=f)),s?.trim()||c.length>0)await e.fs.write(e.dtsPath,`${c?`${c.map(e=>`/// <reference types="${e}" />`).join(`
|
|
3
|
+
`)}
|
|
4
|
+
|
|
5
|
+
`:``}${u.getFileHeader(e,{directive:null,prettierIgnore:!1})}
|
|
6
|
+
|
|
7
|
+
${n.formatTypes(s)}
|
|
8
|
+
`);else{let t=o.getTsconfigDtsPath(e);if(e.tsconfig.tsconfigJson.include&&a.isIncludeMatchFound(t,e.tsconfig.tsconfigJson.include)){let n=t.startsWith(`./`)?t.slice(2):t;e.tsconfig.tsconfigJson.include=e.tsconfig.tsconfigJson.include.filter(e=>e?.toString()!==n),await e.fs.write(e.tsconfig.tsconfigFilePath,JSON.stringify(e.tsconfig.tsconfigJson,null,2))}}}if(e.tsconfig=a.getParsedTypeScriptConfig(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig),!e.tsconfig)throw Error(`Failed to parse the TypeScript configuration file.`);await this.callHook(`prepare`,{environment:e,order:`post`}),await c.writeMetaFile(e),e.persistedMeta=e.meta}),this.context.log(d.LogLevelLabel.INFO,`Powerlines API has been prepared successfully`)}async new(e){this.context.log(d.LogLevelLabel.INFO,`🆕 Creating a new Powerlines project`),await this.prepare(e),await this.#n(async e=>{e.log(d.LogLevelLabel.TRACE,`Initializing the processing options for the Powerlines project.`),await this.callHook(`new`,{environment:e,order:`pre`});let t=await(0,g.listFiles)((0,p.joinPaths)(e.powerlinesPath,`files/common/**/*.hbs`));for(let n of t){e.log(d.LogLevelLabel.TRACE,`Adding template file: ${n}`);let t=M.default.compile(n);await e.fs.write((0,p.joinPaths)(e.config.projectRoot,n.replace(`.hbs`,``)),t(e))}if(await this.callHook(`new`,{environment:e,order:`normal`}),e.config.projectType===`application`){let t=await(0,g.listFiles)((0,p.joinPaths)(e.powerlinesPath,`files/application/**/*.hbs`));for(let n of t){e.log(d.LogLevelLabel.TRACE,`Adding application template file: ${n}`);let t=M.default.compile(n);await e.fs.write((0,p.joinPaths)(e.config.projectRoot,n.replace(`.hbs`,``)),t(e))}}else{let t=await(0,g.listFiles)((0,p.joinPaths)(e.powerlinesPath,`files/library/**/*.hbs`));for(let n of t){e.log(d.LogLevelLabel.TRACE,`Adding library template file: ${n}`);let t=M.default.compile(n);await e.fs.write((0,p.joinPaths)(e.config.projectRoot,n.replace(`.hbs`,``)),t(e))}}await this.callHook(`new`,{environment:e,order:`post`})}),this.context.log(d.LogLevelLabel.TRACE,`Powerlines - New command completed`)}async clean(e={command:`clean`}){this.context.log(d.LogLevelLabel.INFO,`🧹 Cleaning the previous Powerlines artifacts`),await this.prepare(e),await this.#n(async e=>{this.context.log(d.LogLevelLabel.TRACE,`Cleaning the project's dist and artifacts directories.`),await e.fs.remove((0,p.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.output.buildPath)),await e.fs.remove((0,p.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.output.artifactsPath)),await this.callHook(`clean`,{environment:e,sequential:!1})}),this.context.log(d.LogLevelLabel.TRACE,`Powerlines - Clean command completed`)}async lint(e={command:`lint`}){this.context.log(d.LogLevelLabel.INFO,`📋 Linting the Powerlines project`),await this.prepare(e),await this.#n(async e=>{e.config.lint!==!1&&await this.callHook(`lint`,{environment:e,sequential:!1})}),this.context.log(d.LogLevelLabel.TRACE,`Powerlines linting completed`)}async build(e={command:`build`}){this.context.log(d.LogLevelLabel.INFO,`📦 Building the Powerlines project`),await this.prepare(e),await this.#n(async e=>{if(await this.callHook(`build`,{environment:e,order:`pre`}),await this.callHook(`build`,{environment:e,order:`normal`}),e.config.output.buildPath!==e.config.output.outputPath){let t=(0,_.appendPath)(e.config.output.buildPath,e.workspaceConfig.workspaceRoot),n=(0,p.joinPaths)((0,_.appendPath)(e.config.output.outputPath,e.workspaceConfig.workspaceRoot),`dist`);t!==n&&(e.log(d.LogLevelLabel.INFO,`Copying build output files from project's build directory (${e.config.output.buildPath}) to the workspace's output directory (${e.config.output.outputPath}).`),await e.fs.copy(t,n))}await Promise.all(e.config.output.assets.map(async t=>{e.log(d.LogLevelLabel.DEBUG,`Copying asset(s): ${j.default.redBright(e.workspaceConfig.workspaceRoot===t.input?t.glob:(0,p.joinPaths)((0,m.replacePath)(t.input,e.workspaceConfig.workspaceRoot),t.glob))} -> ${j.default.greenBright((0,p.joinPaths)((0,m.replacePath)(t.output,e.workspaceConfig.workspaceRoot),t.glob))} ${Array.isArray(t.ignore)&&t.ignore.length>0?` (ignoring: ${t.ignore.map(e=>j.default.yellowBright(e)).join(`, `)})`:``}`),await e.fs.copy(t,t.output)})),await this.callHook(`build`,{environment:e,order:`post`})}),this.context.log(d.LogLevelLabel.TRACE,`Powerlines build completed`)}async docs(e={command:`docs`}){this.context.log(d.LogLevelLabel.INFO,`📓 Generating documentation for the Powerlines project`),await this.prepare(e),await this.#n(async t=>{t.log(d.LogLevelLabel.TRACE,`Writing documentation for the Powerlines project artifacts.`),await this.prepare(e),await this.#n(async e=>{await this.callHook(`docs`,{environment:e})})}),this.#e.log(d.LogLevelLabel.TRACE,`Powerlines documentation generation completed`)}async deploy(e={command:`deploy`}){this.context.log(d.LogLevelLabel.INFO,`📦 Deploying the Powerlines project`),await this.prepare(e),await this.#n(async e=>{await this.callHook(`deploy`,{environment:e})}),this.context.log(d.LogLevelLabel.TRACE,`Powerlines deploy completed`)}async finalize(){this.context.log(d.LogLevelLabel.TRACE,`Powerlines finalize execution started`),await this.#n(async e=>{await this.callHook(`finalize`,{environment:e}),await e.fs.dispose()}),this.context.log(d.LogLevelLabel.TRACE,`Powerlines finalize execution completed`)}async callHook(e,t,...n){return r.callHook((0,A.isSetObject)(t?.environment)?t.environment:await this.#e.getEnvironment(t?.environment),e,{sequential:!0,...t},...n)}async[Symbol.asyncDispose](){await this.finalize()}async#t(){return!this.context.config.environments||Object.keys(this.context.config.environments).length<=1?(this.context.log(d.LogLevelLabel.DEBUG,`No environments are configured for this Powerlines project. Using the default environment.`),[await this.context.getEnvironment()]):(this.context.log(d.LogLevelLabel.DEBUG,`Found ${Object.keys(this.context.config.environments).length} configured environment(s) for this Powerlines project.`),(await Promise.all(Object.entries(this.context.config.environments).map(async([e,t])=>{if(!await this.context.getEnvironmentSafe(e)){let n=await this.callHook(`configEnvironment`,{environment:e},e,t);n&&(this.context.environments[e]=await this.context.in(n))}return this.context.environments[e]}))).filter(e=>(0,k.isSet)(e)))}async#n(e){await Promise.all((await this.#t()).map(async t=>Promise.resolve(e(t))))}async#r(e){if(e){let t=await this.#i(e);if(!t)return;if(t.dependsOn)for(let e of t.dependsOn)await this.#r(e);this.context.log(d.LogLevelLabel.DEBUG,`Successfully initialized the ${j.default.bold.cyanBright(t.name)} plugin`),await this.context.addPlugin(t)}}async#i(e){let t=e;if((0,O.isPromiseLike)(e)&&(t=await Promise.resolve(e)),!s.isPluginConfig(t))throw Error(`Invalid plugin specified in the configuration - ${JSON.stringify(t)}. Please ensure the value is a plugin name, an object with the \`plugin\` and \`props\` properties, or an instance of \`Plugin\`.`);let n;if(s.isPlugin(t))n=t;else if((0,T.isFunction)(t))n=await Promise.resolve(t());else if((0,v.isSetString)(t)){let e=await this.#a(t);n=(0,T.isFunction)(e)?await Promise.resolve(e()):e}else if(s.isPluginConfigTuple(t)||s.isPluginConfigObject(t)){let e,r;if(s.isPluginConfigTuple(t)?(e=t[0],r=t?.length===2?t[1]:void 0):(e=t.plugin,r=t.options),(0,v.isSetString)(e)){let t=await this.#a(e);n=(0,T.isFunction)(t)?await Promise.resolve(r?t(r):t()):t}else (0,T.isFunction)(e)?n=await Promise.resolve(e(r)):s.isPlugin(e)&&(n=e)}if(!n)throw Error(`The plugin configuration ${JSON.stringify(t)} is invalid. This configuration must point to a valid Powerlines plugin module.`);if(!s.isPlugin(n))throw Error(`The plugin option ${JSON.stringify(n)} does not export a valid module. This configuration must point to a valid Powerlines plugin module.`);return s.checkDedupe(n,this.context.plugins)?(this.context.log(d.LogLevelLabel.TRACE,`Duplicate ${j.default.bold.cyanBright(n.name)} plugin dependency detected - Skipping initialization.`),null):(this.context.log(d.LogLevelLabel.TRACE,`Initializing the ${j.default.bold.cyanBright(n.name)} plugin...`),n)}async#a(e){if(e.startsWith(`@`)&&e.split(`/`).filter(Boolean).length>2){let t=e.split(`/`).filter(Boolean);e=`${t[0]}/${t[1]}`}let t=(0,f.isPackageExists)(e,{paths:[this.context.workspaceConfig.workspaceRoot,this.context.config.projectRoot]});if(!t&&this.context.config.skipInstalls!==!0){this.#e.log(d.LogLevelLabel.WARN,`The plugin package "${e}" is not installed. It will be installed automatically.`);let t=await(0,S.install)(e,{cwd:this.context.config.projectRoot});if((0,E.isNumber)(t.exitCode)&&t.exitCode>0)throw this.#e.log(d.LogLevelLabel.ERROR,t.stderr),Error(`An error occurred while installing the build plugin package "${e}" `)}try{let t=await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve((0,p.joinPaths)(e,`plugin`))),n=t.plugin??t.default;if(!n)throw Error(`The plugin package "${e}" does not export a valid module.`);return n}catch(n){try{let t=await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(e)),n=t.plugin??t.default;if(!n)throw Error(`The plugin package "${e}" does not export a valid module.`);return n}catch{throw t?Error(`An error occurred while importing the build plugin package "${e}":
|
|
9
|
+
${(0,w.isError)(n)?n.message:String(n)}
|
|
10
|
+
|
|
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"`)}}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{moduleResolverBabelPlugin as e}from"./internal/babel/module-resolver-plugin.mjs";import{emitTypes as t,formatTypes as n}from"./internal/helpers/generate-types.mjs";import{callHook as r}from"./internal/helpers/hooks.mjs";import{installDependencies as i}from"./internal/helpers/install-dependencies.mjs";import{getParsedTypeScriptConfig as a,isIncludeMatchFound as o}from"./lib/typescript/tsconfig.mjs";import{getTsconfigDtsPath as s,initializeTsconfig as c,resolveTsconfig as l}from"./internal/helpers/resolve-tsconfig.mjs";import{checkDedupe as u,isPlugin as d,isPluginConfig as f,isPluginConfigObject as p,isPluginConfigTuple as m}from"./plugin-utils/helpers.mjs";import{writeMetaFile as h}from"./lib/utilities/meta.mjs";import{PowerlinesAPIContext as g}from"./lib/contexts/api-context.mjs";import{getFileHeader as _}from"./lib/utilities/file-header.mjs";import{LogLevelLabel as v}from"@storm-software/config-tools/types";import{isPackageExists as y}from"@stryke/fs/package-fns";import{joinPaths as b}from"@stryke/path/join-paths";import{replacePath as x}from"@stryke/path/replace";import{toArray as S}from"@stryke/convert/to-array";import{listFiles as C}from"@stryke/fs/list-files";import{appendPath as w}from"@stryke/path/append";import{isSetString as T}from"@stryke/type-checks/is-set-string";import{transformAsync as E}from"@babel/core";import{formatLogMessage as D}from"@storm-software/config-tools/logger/console";import{createDirectory as O}from"@stryke/fs/helpers";import{install as k}from"@stryke/fs/install";import{resolvePackage as A}from"@stryke/fs/resolve";import{isError as j}from"@stryke/type-checks/is-error";import{isFunction as M}from"@stryke/type-checks/is-function";import{isNumber as N}from"@stryke/type-checks/is-number";import{isObject as P}from"@stryke/type-checks/is-object";import{isPromiseLike as F}from"@stryke/type-checks/is-promise";import{isSet as I}from"@stryke/type-checks/is-set";import{isSetObject as L}from"@stryke/type-checks/is-set-object";import R from"chalk";import z from"handlebars";Symbol.asyncDispose;export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@babel/helper-plugin-utils`),n=require(`@babel/types`);n=e.__toESM(n);function r(e,t){if(!n.isStringLiteral(e.node))return;let r=e.node.value,i=t.context?.fs.resolveSync(r);i&&e.replaceWith(n.stringLiteral(i.replace(/\.(?:ts|mts|cts)x?$/,``)))}const i=[`require`,`require.resolve`,`System.import`,`jest.genMockFromModule`,`jest.mock`,`jest.unmock`,`jest.doMock`,`jest.dontMock`,`jest.setMock`,`jest.requireActual`,`jest.requireMock`,`require.requireActual`,`require.requireMock`];function a(e,t,r){let{node:i}=t;if(n.isMemberExpression(i))return t.matchesPattern(r);if(!n.isIdentifier(i)||r.includes(`.`))return!1;let a=r.split(`.`)[0];return i.name===a}const o={CallExpression:(e,t)=>{if(t.moduleResolverVisited.has(e))return;let o=e.get(`callee`);(o&&i.some(e=>a(t,o,e))||n.isImport(e.node.callee))&&(t.moduleResolverVisited.add(e),r(e.get(`arguments.0`),t))},"ImportDeclaration|ExportDeclaration|ExportAllDeclaration":(e,t)=>{!e||!e.get(`source`)||t.moduleResolverVisited.has(e)||(t.moduleResolverVisited.add(e),r(e.get(`source`),t))}},s=e=>(0,t.declare)(function(t){let n=new Set;return{name:`powerlines:module-resolver`,manipulateOptions(e){e.filename??=`unknown`},pre(){n=new Set},visitor:{Program:{enter(r,i){r.traverse(o,{...i,context:e,moduleResolverVisited:n,api:t})},exit(r,i){r.traverse(o,{...i,context:e,moduleResolverVisited:n,api:t})}}},post(){n.clear()}}});exports.moduleResolverBabelPlugin=s;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{declare as e}from"@babel/helper-plugin-utils";import*as t from"@babel/types";function n(e,n){if(!t.isStringLiteral(e.node))return;let r=e.node.value,i=n.context?.fs.resolveSync(r);i&&e.replaceWith(t.stringLiteral(i.replace(/\.(?:ts|mts|cts)x?$/,``)))}const r=[`require`,`require.resolve`,`System.import`,`jest.genMockFromModule`,`jest.mock`,`jest.unmock`,`jest.doMock`,`jest.dontMock`,`jest.setMock`,`jest.requireActual`,`jest.requireMock`,`require.requireActual`,`require.requireMock`];function i(e,n,r){let{node:i}=n;if(t.isMemberExpression(i))return n.matchesPattern(r);if(!t.isIdentifier(i)||r.includes(`.`))return!1;let a=r.split(`.`)[0];return i.name===a}const a={CallExpression:(e,a)=>{if(a.moduleResolverVisited.has(e))return;let o=e.get(`callee`);(o&&r.some(e=>i(a,o,e))||t.isImport(e.node.callee))&&(a.moduleResolverVisited.add(e),n(e.get(`arguments.0`),a))},"ImportDeclaration|ExportDeclaration|ExportAllDeclaration":(e,t)=>{!e||!e.get(`source`)||t.moduleResolverVisited.has(e)||(t.moduleResolverVisited.add(e),n(e.get(`source`),t))}},o=t=>e(function(e){let n=new Set;return{name:`powerlines:module-resolver`,manipulateOptions(e){e.filename??=`unknown`},pre(){n=new Set},visitor:{Program:{enter(r,i){r.traverse(a,{...i,context:t,moduleResolverVisited:n,api:e})},exit(r,i){r.traverse(a,{...i,context:t,moduleResolverVisited:n,api:e})}}},post(){n.clear()}}});export{o as moduleResolverBabelPlugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`defu`);t=e.__toESM(t);let n=require(`@stryke/string-format/title-case`);const r=`default`;function i(e,r){return(0,t.default)(r.environments?.[e]??{},{name:e,title:r.title||(0,n.titleCase)(r.name),ssr:!1,mainFields:r.build?.platform===`browser`?[`browser`,`module`,`jsnext:main`,`jsnext`]:[`module`,`jsnext:main`,`jsnext`],extensions:[`.mjs`,`.js`,`.mts`,`.ts`,`.jsx`,`.tsx`,`.json`],consumer:r.build?.platform===`browser`?`client`:`server`,preview:r.build?.platform===`browser`?{port:5173,open:!0,strictPort:!1,host:`localhost`,allowedHosts:[`.`],cors:!0,headers:{}}:void 0},r)}function a(e){return i(`default`,e)}exports.createDefaultEnvironment=a,exports.createEnvironment=i;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"defu";import{titleCase as t}from"@stryke/string-format/title-case";function n(n,r){return e(r.environments?.[n]??{},{name:n,title:r.title||t(r.name),ssr:!1,mainFields:r.build?.platform===`browser`?[`browser`,`module`,`jsnext:main`,`jsnext`]:[`module`,`jsnext:main`,`jsnext`],extensions:[`.mjs`,`.js`,`.mts`,`.ts`,`.jsx`,`.tsx`,`.json`],consumer:r.build?.platform===`browser`?`client`:`server`,preview:r.build?.platform===`browser`?{port:5173,open:!0,strictPort:!1,host:`localhost`,allowedHosts:[`.`],cors:!0,headers:{}}:void 0},r)}function r(e){return n(`default`,e)}export{r as createDefaultEnvironment,n as createEnvironment};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../../lib/typescript/ts-morph.cjs`);let n=require(`@storm-software/config-tools/types`),r=require(`typescript`);function i(e){return e.replace(/import\s*(?:type\s*)?\{?[\w,\s]*(?:\}\s*)?from\s*(?:'|")@?[a-zA-Z0-9-\\/.]*(?:'|");?/g,``).replaceAll(`#private;`,``).replace(/__Ω/g,``)}async function a(e,a){e.log(n.LogLevelLabel.TRACE,`Running the TypeScript compiler for ${a.length} generated runtime files.`);let o=t.createProgram(e,{skipAddingFilesFromTsConfig:!0});o.addSourceFilesAtPaths(a);let s=o.emitToMemory({emitOnlyDtsFiles:!0}),c=``;for(let t of s.getFiles())if(!t.filePath.endsWith(`.map`)&&e.builtins.some(n=>n===t.filePath||e.fs.metadata[n]?.id&&e.fs.metadata[n]?.id===t.filePath)){let n=await e.fs.resolve(t.filePath);c+=`
|
|
2
|
+
declare module "${n}" {
|
|
3
|
+
${t.text.trim().replace(/^\s*export\s*declare\s*/gm,`export `).replace(/^\s*declare\s*/gm,``)}
|
|
4
|
+
}
|
|
5
|
+
`}let l=[];s.getDiagnostics().forEach(e=>{e.getSourceFile()?.getBaseName()?l.push(`${e.getSourceFile()?.getBaseName()} (${(e.getLineNumber()??0)+1}): ${(0,r.flattenDiagnosticMessageText)(e.getMessageText().toString(),`
|
|
6
|
+
`)}`):l.push((0,r.flattenDiagnosticMessageText)(e.getMessageText().toString(),`
|
|
7
|
+
`))});let u=l.join(`
|
|
8
|
+
`);if(u)throw Error(`TypeScript compilation failed: \n\n${u.length>5e3?`${u.slice(0,5e3)}...`:u}`);return i(c)}exports.emitTypes=a,exports.formatTypes=i;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{createProgram as e}from"../../lib/typescript/ts-morph.mjs";import{LogLevelLabel as t}from"@storm-software/config-tools/types";import{flattenDiagnosticMessageText as n}from"typescript";function r(e){return e.replace(/import\s*(?:type\s*)?\{?[\w,\s]*(?:\}\s*)?from\s*(?:'|")@?[a-zA-Z0-9-\\/.]*(?:'|");?/g,``).replaceAll(`#private;`,``).replace(/__Ω/g,``)}async function i(i,a){i.log(t.TRACE,`Running the TypeScript compiler for ${a.length} generated runtime files.`);let o=e(i,{skipAddingFilesFromTsConfig:!0});o.addSourceFilesAtPaths(a);let s=o.emitToMemory({emitOnlyDtsFiles:!0}),c=``;for(let e of s.getFiles())if(!e.filePath.endsWith(`.map`)&&i.builtins.some(t=>t===e.filePath||i.fs.metadata[t]?.id&&i.fs.metadata[t]?.id===e.filePath)){let t=await i.fs.resolve(e.filePath);c+=`
|
|
2
|
+
declare module "${t}" {
|
|
3
|
+
${e.text.trim().replace(/^\s*export\s*declare\s*/gm,`export `).replace(/^\s*declare\s*/gm,``)}
|
|
4
|
+
}
|
|
5
|
+
`}let l=[];s.getDiagnostics().forEach(e=>{e.getSourceFile()?.getBaseName()?l.push(`${e.getSourceFile()?.getBaseName()} (${(e.getLineNumber()??0)+1}): ${n(e.getMessageText().toString(),`
|
|
6
|
+
`)}`):l.push(n(e.getMessageText().toString(),`
|
|
7
|
+
`))});let u=l.join(`
|
|
8
|
+
`);if(u)throw Error(`TypeScript compilation failed: \n\n${u.length>5e3?`${u.slice(0,5e3)}...`:u}`);return r(c)}export{i as emitTypes,r as formatTypes};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@storm-software/config-tools/types`),n=require(`defu`),r=require(`@stryke/type-checks/is-string`),i=require(`@stryke/type-checks/is-function`),a=require(`@stryke/type-checks/is-object`),o=require(`@stryke/type-checks/is-set`),s=require(`chalk`);s=e.__toESM(s);const c=(0,n.createDefu)((e,t,n)=>(0,r.isString)(e[t])&&(0,r.isString)(n)?(e[t]=`${e[t]||``}\n${n||``}`.trim(),!0):!1);async function l(e,l,u,...d){let f=e.selectHooks(l,u);if(f.length>0){e.log(t.LogLevelLabel.DEBUG,` 🧩 Calling plugin hook: ${s.default.bold.cyanBright(`${l}${u?.order?` (${u.order})`:``}`)}`);let p=[];if(u?.sequential===!1)p=await Promise.all(f.map(async e=>{if(!(0,i.isFunction)(e.handle))throw Error(`Plugin hook handler for hook "${l}" is not a function.`);return Promise.resolve(e.handle.apply(e.context,[...d]))}));else for(let e of f){if(!(0,i.isFunction)(e.handle))throw Error(`Plugin hook handler for hook "${l}" is not a function.`);if(u?.result===`first`||u?.asNextParam===!1){if(p.push(await Promise.resolve(e.handle.apply(e.context,[...d]))),u?.result===`first`&&(0,o.isSet)(p[p.length-1]))break}else{let t=[...d];p.length>0&&t.length>0&&(t[0]=(0,i.isFunction)(u.asNextParam)?await Promise.resolve(u.asNextParam(p[0])):p[0]);let n=await Promise.resolve(e.handle.apply(e.context,[...t]));n&&(u?.result===`last`?p=[n]:(0,r.isString)(n)?p=[`${(0,r.isString)(p[0])&&p[0]||``}\n${n||``}`.trim()]:(0,a.isObject)(n)&&(p=[c(n,p[0]??{})]))}}let m=p.filter(e=>(0,o.isSet)(e));if(m.length>0){let e;for(let t of m)e=(0,n.defu)(t,e??{});return e}}}exports.callHook=l;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LogLevelLabel as e}from"@storm-software/config-tools/types";import{createDefu as t,defu as n}from"defu";import{isString as r}from"@stryke/type-checks/is-string";import{isFunction as i}from"@stryke/type-checks/is-function";import{isObject as a}from"@stryke/type-checks/is-object";import{isSet as o}from"@stryke/type-checks/is-set";import s from"chalk";const c=t((e,t,n)=>r(e[t])&&r(n)?(e[t]=`${e[t]||``}\n${n||``}`.trim(),!0):!1);async function l(t,l,u,...d){let f=t.selectHooks(l,u);if(f.length>0){t.log(e.DEBUG,` 🧩 Calling plugin hook: ${s.bold.cyanBright(`${l}${u?.order?` (${u.order})`:``}`)}`);let p=[];if(u?.sequential===!1)p=await Promise.all(f.map(async e=>{if(!i(e.handle))throw Error(`Plugin hook handler for hook "${l}" is not a function.`);return Promise.resolve(e.handle.apply(e.context,[...d]))}));else for(let e of f){if(!i(e.handle))throw Error(`Plugin hook handler for hook "${l}" is not a function.`);if(u?.result===`first`||u?.asNextParam===!1){if(p.push(await Promise.resolve(e.handle.apply(e.context,[...d]))),u?.result===`first`&&o(p[p.length-1]))break}else{let t=[...d];p.length>0&&t.length>0&&(t[0]=i(u.asNextParam)?await Promise.resolve(u.asNextParam(p[0])):p[0]);let n=await Promise.resolve(e.handle.apply(e.context,[...t]));n&&(u?.result===`last`?p=[n]:r(n)?p=[`${r(p[0])&&p[0]||``}\n${n||``}`.trim()]:a(n)&&(p=[c(n,p[0]??{})]))}}let m=p.filter(e=>o(e));if(m.length>0){let e;for(let t of m)e=n(t,e??{});return e}}}export{l as callHook};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`./install.cjs`);let n=require(`@storm-software/config-tools/types`),r=require(`@stryke/string-format/package`);async function i(e){if(e.log(n.LogLevelLabel.TRACE,`Checking and installing missing project dependencies.`),e.dependencies??={},e.devDependencies??={},Object.keys(e.dependencies).length===0&&Object.keys(e.devDependencies).length===0){e.log(n.LogLevelLabel.TRACE,`No dependencies or devDependencies to install. Skipping installation step.`);return}e.log(n.LogLevelLabel.DEBUG,`The following packages are required: \nDependencies: \n${Object.entries(e.dependencies).map(([e,t])=>`- ${e}@${String(t)}`).join(`
|
|
2
|
+
`)}\n\nDevDependencies: \n${Object.entries(e.devDependencies).map(([e,t])=>`- ${e}@${String(t)}`).join(`
|
|
3
|
+
`)}`),await Promise.all([Promise.all(Object.entries(e.dependencies).map(async([n,i])=>t.installPackage(e,`${(0,r.getPackageName)(n)}@${String(i)}`,!1))),Promise.all(Object.entries(e.devDependencies).map(async([n,i])=>t.installPackage(e,`${(0,r.getPackageName)(n)}@${String(i)}`,!0)))])}exports.installDependencies=i;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{installPackage as e}from"./install.mjs";import{LogLevelLabel as t}from"@storm-software/config-tools/types";import{getPackageName as n}from"@stryke/string-format/package";async function r(r){if(r.log(t.TRACE,`Checking and installing missing project dependencies.`),r.dependencies??={},r.devDependencies??={},Object.keys(r.dependencies).length===0&&Object.keys(r.devDependencies).length===0){r.log(t.TRACE,`No dependencies or devDependencies to install. Skipping installation step.`);return}r.log(t.DEBUG,`The following packages are required: \nDependencies: \n${Object.entries(r.dependencies).map(([e,t])=>`- ${e}@${String(t)}`).join(`
|
|
2
|
+
`)}\n\nDevDependencies: \n${Object.entries(r.devDependencies).map(([e,t])=>`- ${e}@${String(t)}`).join(`
|
|
3
|
+
`)}`),await Promise.all([Promise.all(Object.entries(r.dependencies).map(async([t,i])=>e(r,`${n(t)}@${String(i)}`,!1))),Promise.all(Object.entries(r.devDependencies).map(async([t,i])=>e(r,`${n(t)}@${String(i)}`,!0)))])}export{r as installDependencies};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@storm-software/config-tools/types`),n=require(`@stryke/fs/package-fns`),r=require(`@stryke/fs/install`),i=require(`@stryke/type-checks/is-number`),a=require(`@stryke/string-format/package`);async function o(e,o,s=!1){if(await(0,n.isPackageListed)((0,a.getPackageName)(o),{cwd:e.config.projectRoot})){if((0,a.hasPackageVersion)(o)&&!process.env.POWERLINES_SKIP_VERSION_CHECK&&!await(0,n.doesPackageMatch)((0,a.getPackageName)(o),(0,a.getPackageVersion)(o),e.config.projectRoot)){let r=await(0,n.getPackageListing)((0,a.getPackageName)(o),{cwd:e.config.projectRoot});!r?.version.startsWith(`catalog:`)&&!r?.version.startsWith(`workspace:`)&&e.log(t.LogLevelLabel.WARN,`The package "${(0,a.getPackageName)(o)}" is installed but does not match the expected version ${(0,a.getPackageVersion)(o)} (installed version: ${r?.version||`<Unknown>`}). Please ensure this is intentional before proceeding. Note: You can skip this validation with the "STORM_STACK_SKIP_VERSION_CHECK" environment variable.`)}}else if(e.config.skipInstalls!==!0){e.log(t.LogLevelLabel.WARN,`The package "${o}" is not installed. It will be installed automatically.`);let n=await(0,r.install)(o,{cwd:e.config.projectRoot,dev:s});if((0,i.isNumber)(n.exitCode)&&n.exitCode>0)throw e.log(t.LogLevelLabel.ERROR,n.stderr),Error(`An error occurred while installing the package "${o}"`)}else e.log(t.LogLevelLabel.WARN,`The package "${o}" is not installed. Since the "skipInstalls" option is set to true, it will not be installed automatically.`)}exports.installPackage=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LogLevelLabel as e}from"@storm-software/config-tools/types";import{doesPackageMatch as t,getPackageListing as n,isPackageListed as r}from"@stryke/fs/package-fns";import{install as i}from"@stryke/fs/install";import{isNumber as a}from"@stryke/type-checks/is-number";import{getPackageName as o,getPackageVersion as s,hasPackageVersion as c}from"@stryke/string-format/package";async function l(l,u,d=!1){if(await r(o(u),{cwd:l.config.projectRoot})){if(c(u)&&!process.env.POWERLINES_SKIP_VERSION_CHECK&&!await t(o(u),s(u),l.config.projectRoot)){let t=await n(o(u),{cwd:l.config.projectRoot});!t?.version.startsWith(`catalog:`)&&!t?.version.startsWith(`workspace:`)&&l.log(e.WARN,`The package "${o(u)}" is installed but does not match the expected version ${s(u)} (installed version: ${t?.version||`<Unknown>`}). Please ensure this is intentional before proceeding. Note: You can skip this validation with the "STORM_STACK_SKIP_VERSION_CHECK" environment variable.`)}}else if(l.config.skipInstalls!==!0){l.log(e.WARN,`The package "${u}" is not installed. It will be installed automatically.`);let t=await i(u,{cwd:l.config.projectRoot,dev:d});if(a(t.exitCode)&&t.exitCode>0)throw l.log(e.ERROR,t.stderr),Error(`An error occurred while installing the package "${u}"`)}else l.log(e.WARN,`The package "${u}" is not installed. Since the "skipInstalls" option is set to true, it will not be installed automatically.`)}export{l as installPackage};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../../lib/typescript/tsconfig.cjs`);let n=require(`@storm-software/config-tools/types`),r=require(`@stryke/fs/package-fns`),i=require(`@stryke/path/join-paths`),a=require(`chalk`);a=e.__toESM(a);let o=require(`@donedeal0/superdiff`),s=require(`@stryke/fs/json`),c=require(`@stryke/json/storm-json`),l=require(`@stryke/path/file-path-fns`),u=require(`@stryke/string-format/title-case`);function d(e){return(0,i.joinPaths)((0,l.relativePath)((0,i.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot),(0,l.findFilePath)(e.dtsPath)),(0,l.findFileName)(e.dtsPath))}async function f(e){let n=t.getParsedTypeScriptConfig(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig,e.config.tsconfigRaw),r=await(0,s.readJsonFile)(t.getTsconfigFilePath(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig));if(r.compilerOptions??={},e.config.output.dts!==!1){let n=d(e);r.include?.some(r=>t.isIncludeMatchFound(r,[e.dtsPath,n]))||(r.include??=[],r.include.push(n.startsWith(`./`)?n.slice(2):n))}return n.options.lib?.some(e=>[`lib.esnext.d.ts`,`lib.es2021.d.ts`,`lib.es2022.d.ts`,`lib.es2023.d.ts`].includes(e.toLowerCase()))||(r.compilerOptions.lib??=[],r.compilerOptions.lib.push(`esnext`)),n.options.esModuleInterop!==!0&&(r.compilerOptions.esModuleInterop=!0),n.options.isolatedModules!==!0&&(r.compilerOptions.isolatedModules=!0),e.config.build.platform===`node`&&(n.options.types?.some(e=>e.toLowerCase()===`node`||e.toLowerCase()===`@types/node`)||(r.compilerOptions.types??=[],r.compilerOptions.types.push(`node`))),r}async function p(e){if(e.log(n.LogLevelLabel.TRACE,`Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.`),!(0,r.isPackageExists)(`typescript`))throw Error(`The TypeScript package is not installed. Please install the package using the command: "npm install typescript --save-dev"`);let i=t.getTsconfigFilePath(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig);e.tsconfig.originalTsconfigJson=await(0,s.readJsonFile)(i),e.tsconfig.tsconfigJson=await f(e),e.log(n.LogLevelLabel.TRACE,`Writing updated TypeScript configuration (tsconfig.json) file to disk.`),await e.fs.write(i,c.StormJSON.stringify(e.tsconfig.tsconfigJson)),e.tsconfig=t.getParsedTypeScriptConfig(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig,e.config.tsconfigRaw,e.tsconfig.originalTsconfigJson)}async function m(e){let r=await(0,s.readJsonFile)(e.tsconfig.tsconfigFilePath);r?.compilerOptions?.types&&Array.isArray(r.compilerOptions.types)&&!r.compilerOptions.types.length&&delete r.compilerOptions.types;let i=(0,o.getObjectDiff)(e.tsconfig.originalTsconfigJson,r,{ignoreArrayOrder:!0,showOnly:{statuses:[`added`,`deleted`,`updated`],granularity:`deep`}}),l=[],d=(e,t)=>{if(e.status===`added`||e.status===`deleted`||e.status===`updated`)if(e.diff)for(let n of e.diff)d(n,t?`${t}.${e.property}`:e.property);else l.push({field:t?`${t}.${e.property}`:e.property,status:e.status,previous:e.status===`added`?`---`:c.StormJSON.stringify(e.previousValue),current:e.status===`deleted`?`---`:c.StormJSON.stringify(e.currentValue)})};for(let e of i.diff)d(e);if(l.length>0&&e.log(n.LogLevelLabel.WARN,`Updating the following configuration values in "${e.tsconfig.tsconfigFilePath}" file:
|
|
2
|
+
|
|
3
|
+
${l.map((e,t)=>`${a.default.bold.whiteBright(`${t+1}. ${(0,u.titleCase)(e.status)} the ${e.field} field: `)}
|
|
4
|
+
${a.default.red(` - Previous: ${e.previous} `)}
|
|
5
|
+
${a.default.green(` - Updated: ${e.current} `)}
|
|
6
|
+
`).join(`
|
|
7
|
+
`)}
|
|
8
|
+
`),await e.fs.write(e.tsconfig.tsconfigFilePath,c.StormJSON.stringify(r)),e.tsconfig=t.getParsedTypeScriptConfig(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig),!e.tsconfig)throw Error(`Failed to parse the TypeScript configuration file.`)}exports.getTsconfigDtsPath=d,exports.initializeTsconfig=p,exports.resolveTsconfig=m;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{getParsedTypeScriptConfig as e,getTsconfigFilePath as t,isIncludeMatchFound as n}from"../../lib/typescript/tsconfig.mjs";import{LogLevelLabel as r}from"@storm-software/config-tools/types";import{isPackageExists as i}from"@stryke/fs/package-fns";import{joinPaths as a}from"@stryke/path/join-paths";import o from"chalk";import{getObjectDiff as s}from"@donedeal0/superdiff";import{readJsonFile as c}from"@stryke/fs/json";import{StormJSON as l}from"@stryke/json/storm-json";import{findFileName as u,findFilePath as d,relativePath as f}from"@stryke/path/file-path-fns";import{titleCase as p}from"@stryke/string-format/title-case";function m(e){return a(f(a(e.workspaceConfig.workspaceRoot,e.config.projectRoot),d(e.dtsPath)),u(e.dtsPath))}async function h(r){let i=e(r.workspaceConfig.workspaceRoot,r.config.projectRoot,r.config.tsconfig,r.config.tsconfigRaw),a=await c(t(r.workspaceConfig.workspaceRoot,r.config.projectRoot,r.config.tsconfig));if(a.compilerOptions??={},r.config.output.dts!==!1){let e=m(r);a.include?.some(t=>n(t,[r.dtsPath,e]))||(a.include??=[],a.include.push(e.startsWith(`./`)?e.slice(2):e))}return i.options.lib?.some(e=>[`lib.esnext.d.ts`,`lib.es2021.d.ts`,`lib.es2022.d.ts`,`lib.es2023.d.ts`].includes(e.toLowerCase()))||(a.compilerOptions.lib??=[],a.compilerOptions.lib.push(`esnext`)),i.options.esModuleInterop!==!0&&(a.compilerOptions.esModuleInterop=!0),i.options.isolatedModules!==!0&&(a.compilerOptions.isolatedModules=!0),r.config.build.platform===`node`&&(i.options.types?.some(e=>e.toLowerCase()===`node`||e.toLowerCase()===`@types/node`)||(a.compilerOptions.types??=[],a.compilerOptions.types.push(`node`))),a}async function g(n){if(n.log(r.TRACE,`Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.`),!i(`typescript`))throw Error(`The TypeScript package is not installed. Please install the package using the command: "npm install typescript --save-dev"`);let a=t(n.workspaceConfig.workspaceRoot,n.config.projectRoot,n.config.tsconfig);n.tsconfig.originalTsconfigJson=await c(a),n.tsconfig.tsconfigJson=await h(n),n.log(r.TRACE,`Writing updated TypeScript configuration (tsconfig.json) file to disk.`),await n.fs.write(a,l.stringify(n.tsconfig.tsconfigJson)),n.tsconfig=e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,n.config.tsconfig,n.config.tsconfigRaw,n.tsconfig.originalTsconfigJson)}async function _(t){let n=await c(t.tsconfig.tsconfigFilePath);n?.compilerOptions?.types&&Array.isArray(n.compilerOptions.types)&&!n.compilerOptions.types.length&&delete n.compilerOptions.types;let i=s(t.tsconfig.originalTsconfigJson,n,{ignoreArrayOrder:!0,showOnly:{statuses:[`added`,`deleted`,`updated`],granularity:`deep`}}),a=[],u=(e,t)=>{if(e.status===`added`||e.status===`deleted`||e.status===`updated`)if(e.diff)for(let n of e.diff)u(n,t?`${t}.${e.property}`:e.property);else a.push({field:t?`${t}.${e.property}`:e.property,status:e.status,previous:e.status===`added`?`---`:l.stringify(e.previousValue),current:e.status===`deleted`?`---`:l.stringify(e.currentValue)})};for(let e of i.diff)u(e);if(a.length>0&&t.log(r.WARN,`Updating the following configuration values in "${t.tsconfig.tsconfigFilePath}" file:
|
|
2
|
+
|
|
3
|
+
${a.map((e,t)=>`${o.bold.whiteBright(`${t+1}. ${p(e.status)} the ${e.field} field: `)}
|
|
4
|
+
${o.red(` - Previous: ${e.previous} `)}
|
|
5
|
+
${o.green(` - Updated: ${e.current} `)}
|
|
6
|
+
`).join(`
|
|
7
|
+
`)}
|
|
8
|
+
`),await t.fs.write(t.tsconfig.tsconfigFilePath,l.stringify(n)),t.tsconfig=e(t.workspaceConfig.workspaceRoot,t.config.projectRoot,t.config.tsconfig),!t.tsconfig)throw Error(`Failed to parse the TypeScript configuration file.`)}export{m as getTsconfigDtsPath,g as initializeTsconfig,_ as resolveTsconfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/path/join-paths`),n=require(`defu`);n=e.__toESM(n);let r=require(`jiti`);function i(e){return(0,n.default)(e,{interopDefault:!0,fsCache:e.mode===`development`?!1:(0,t.joinPaths)(e.cacheDir,`jiti`),moduleCache:e.mode!==`development`})}function a(e){return(0,r.createJiti)((0,t.joinPaths)(e.workspaceRoot,e.projectRoot),i({...e}))}function o(e){let n=(0,r.createJiti)((0,t.joinPaths)(e.workspaceRoot,e.projectRoot),i(e));return n.plugin=a(e),n}exports.createResolver=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{joinPaths as e}from"@stryke/path/join-paths";import t from"defu";import{createJiti as n}from"jiti";function r(n){return t(n,{interopDefault:!0,fsCache:n.mode===`development`?!1:e(n.cacheDir,`jiti`),moduleCache:n.mode!==`development`})}function i(t){return n(e(t.workspaceRoot,t.projectRoot),r({...t}))}function a(t){let a=n(e(t.workspaceRoot,t.projectRoot),r(t));return a.plugin=i(t),a}export{a as createResolver};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/rolldown_runtime.cjs`);require(`../entry.cjs`);let t=require(`@stryke/path/join-paths`),n=require(`defu`);n=e.__toESM(n);let r=require(`@stryke/helpers/omit`),i=require(`@stryke/path/replace`),a=require(`@stryke/string-format/camel-case`),o=require(`@stryke/type-checks/is-string`);const s={target:`esnext`,platform:`neutral`,format:`esm`,write:!0,minify:!0,sourcemap:!1,bundle:!0,treeShaking:!0,keepNames:!0,splitting:!0,logLevel:`silent`};function c(e){let i=e.config.build.override.inject??e.config.build.inject;return i&&Object.keys(i).length>0&&e.fs.writeSync((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.artifactsPath,`inject-shim.js`),Object.entries(i).map(([e,t])=>{if(t)if(Array.isArray(t)){if((0,a.camelCase)(e)!==e){if(t.length===1)return`
|
|
2
|
+
import ${(0,a.camelCase)(e)} from "${t[0]}";
|
|
3
|
+
export { ${(0,a.camelCase)(e)} as "${e}" }`;if(t.length>1)return`
|
|
4
|
+
import ${t[1]===`*`?`* as ${(0,a.camelCase)(e)}`:`{ ${t[1]} as ${(0,a.camelCase)(e)} }`} from "${t[0]}";
|
|
5
|
+
export { ${(0,a.camelCase)(e)} as "${e}" }`}else if(t.length===1)return`
|
|
6
|
+
import ${e} from "${t[0]}";
|
|
7
|
+
export { ${e} };`;else if(t.length>1)return`
|
|
8
|
+
import ${t[1]===`*`?`* as ${e}`:`{ ${t[1]} as ${e} }`} from "${t[0]}";
|
|
9
|
+
export { ${e} };`}else if((0,a.camelCase)(e)!==e)return`
|
|
10
|
+
import ${(0,a.camelCase)(e)} from "${t[0]}";
|
|
11
|
+
export { ${(0,a.camelCase)(e)} as "${e}" }`;else return`
|
|
12
|
+
import ${e} from "${t}";
|
|
13
|
+
export { ${e} };`;return``}).join(`
|
|
14
|
+
`)),(0,n.default)({alias:e.builtins.reduce((t,n)=>{if(!t[n]){let r=e.fs.ids[n];r&&(t[n]=r)}return t},e.config.build.alias?Array.isArray(e.config.build.alias)?e.config.build.alias.reduce((e,t)=>(e[t.find.toString()]||(e[t.find.toString()]=t.replacement),e),{}):e.config.build.alias:{}),inject:i&&Object.keys(i).length>0?[(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.artifactsPath,`inject-shim.js`)]:void 0},e.config.build.variant===`esbuild`?(0,r.omit)(e.config.build.override,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`]):{},e.config.build.variant===`esbuild`?(0,r.omit)(e.config.build,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`,`variant`,`override`]):{},{mainFields:e.config.build.mainFields,conditions:e.config.build.conditions,define:e.config.build.define,resolveExtensions:e.config.build.extensions,packages:e.config.build.skipNodeModulesBundle?`external`:e.config.build.variant===`esbuild`?e.config.build.packages:void 0,format:Array.isArray(e.config.output.format)?e.config.output.format[0]:e.config.output.format,platform:e.config.build.platform,treeShaking:!!e.config.build?.treeshake||e.config.build?.treeShaking,outdir:e.config.output.buildPath,tsconfig:e.tsconfig.tsconfigFilePath,tsconfigRaw:e.tsconfig.tsconfigJson,minify:e.config.mode!==`development`,metafile:e.config.mode===`development`,sourcemap:e.config.mode===`development`},s)}exports.extractESBuildConfig=c;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import"../entry.mjs";import{joinPaths as e}from"@stryke/path/join-paths";import t from"defu";import{omit as n}from"@stryke/helpers/omit";import{replaceExtension as r,replacePath as i}from"@stryke/path/replace";import{camelCase as a}from"@stryke/string-format/camel-case";import{isString as o}from"@stryke/type-checks/is-string";const s={target:`esnext`,platform:`neutral`,format:`esm`,write:!0,minify:!0,sourcemap:!1,bundle:!0,treeShaking:!0,keepNames:!0,splitting:!0,logLevel:`silent`};function c(r){let i=r.config.build.override.inject??r.config.build.inject;return i&&Object.keys(i).length>0&&r.fs.writeSync(e(r.workspaceConfig.workspaceRoot,r.config.projectRoot,r.artifactsPath,`inject-shim.js`),Object.entries(i).map(([e,t])=>{if(t)if(Array.isArray(t)){if(a(e)!==e){if(t.length===1)return`
|
|
2
|
+
import ${a(e)} from "${t[0]}";
|
|
3
|
+
export { ${a(e)} as "${e}" }`;if(t.length>1)return`
|
|
4
|
+
import ${t[1]===`*`?`* as ${a(e)}`:`{ ${t[1]} as ${a(e)} }`} from "${t[0]}";
|
|
5
|
+
export { ${a(e)} as "${e}" }`}else if(t.length===1)return`
|
|
6
|
+
import ${e} from "${t[0]}";
|
|
7
|
+
export { ${e} };`;else if(t.length>1)return`
|
|
8
|
+
import ${t[1]===`*`?`* as ${e}`:`{ ${t[1]} as ${e} }`} from "${t[0]}";
|
|
9
|
+
export { ${e} };`}else if(a(e)!==e)return`
|
|
10
|
+
import ${a(e)} from "${t[0]}";
|
|
11
|
+
export { ${a(e)} as "${e}" }`;else return`
|
|
12
|
+
import ${e} from "${t}";
|
|
13
|
+
export { ${e} };`;return``}).join(`
|
|
14
|
+
`)),t({alias:r.builtins.reduce((e,t)=>{if(!e[t]){let n=r.fs.ids[t];n&&(e[t]=n)}return e},r.config.build.alias?Array.isArray(r.config.build.alias)?r.config.build.alias.reduce((e,t)=>(e[t.find.toString()]||(e[t.find.toString()]=t.replacement),e),{}):r.config.build.alias:{}),inject:i&&Object.keys(i).length>0?[e(r.workspaceConfig.workspaceRoot,r.config.projectRoot,r.artifactsPath,`inject-shim.js`)]:void 0},r.config.build.variant===`esbuild`?n(r.config.build.override,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`]):{},r.config.build.variant===`esbuild`?n(r.config.build,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`,`variant`,`override`]):{},{mainFields:r.config.build.mainFields,conditions:r.config.build.conditions,define:r.config.build.define,resolveExtensions:r.config.build.extensions,packages:r.config.build.skipNodeModulesBundle?`external`:r.config.build.variant===`esbuild`?r.config.build.packages:void 0,format:Array.isArray(r.config.output.format)?r.config.output.format[0]:r.config.output.format,platform:r.config.build.platform,treeShaking:!!r.config.build?.treeshake||r.config.build?.treeShaking,outdir:r.config.output.buildPath,tsconfig:r.tsconfig.tsconfigFilePath,tsconfigRaw:r.tsconfig.tsconfigJson,minify:r.config.mode!==`development`,metafile:r.config.mode===`development`,sourcemap:r.config.mode===`development`},s)}export{c as extractESBuildConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`./esbuild.cjs`);let n=require(`@stryke/path/join-paths`),r=require(`defu`);r=e.__toESM(r);let i=require(`@stryke/helpers/omit`);const a={resolve:{extensions:[`.mjs`,`.js`,`.mts`,`.ts`,`.jsx`,`.tsx`,`.json`]},json:{stringify:!0},logLevel:`silent`,clearScreen:!0};function o(e){return(0,r.default)({resolve:{alias:e.builtins.reduce((t,n)=>{if(!t.find(e=>e.find===n)){let r=e.fs.ids[n];r&&t.push({find:n,replacement:r})}return t},e.config.build.alias?Array.isArray(e.config.build.alias)?e.config.build.alias:Object.entries(e.config.build.alias).reduce((e,[t,n])=>(e.find(e=>e.find===t)||e.push({find:t,replacement:n}),e),[]):[]),dedupe:e.config.build.dedupe,mainFields:e.config.build.mainFields,conditions:e.config.build.conditions,extensions:e.config.build.extensions}},e.config.build.variant===`vite`?e.config.build.override:{},e.config.build.variant===`vite`?(0,i.omit)(e.config.build,[`override`,`variant`]):{},{define:e.config.build.define,rootDir:e.config.sourceRoot,platform:e.config.build.platform,mode:e.config.mode===`development`?`development`:`production`,cacheDir:(0,n.joinPaths)(e.cachePath,`vite`),build:{minify:e.config.mode!==`development`,metafile:e.config.mode===`development`,sourcemap:e.config.mode===`development`,outDir:e.config.output.buildPath,tsconfig:e.tsconfig.tsconfigFilePath,tsconfigRaw:e.tsconfig.tsconfigJson},esbuild:t.extractESBuildConfig(e),logLevel:e.config.logLevel??void 0,envDir:e.config.projectRoot},a)}exports.DEFAULT_VITE_CONFIG=a,exports.extractViteConfig=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{extractESBuildConfig as e}from"./esbuild.mjs";import{joinPaths as t}from"@stryke/path/join-paths";import n from"defu";import{omit as r}from"@stryke/helpers/omit";const i={resolve:{extensions:[`.mjs`,`.js`,`.mts`,`.ts`,`.jsx`,`.tsx`,`.json`]},json:{stringify:!0},logLevel:`silent`,clearScreen:!0};function a(a){return n({resolve:{alias:a.builtins.reduce((e,t)=>{if(!e.find(e=>e.find===t)){let n=a.fs.ids[t];n&&e.push({find:t,replacement:n})}return e},a.config.build.alias?Array.isArray(a.config.build.alias)?a.config.build.alias:Object.entries(a.config.build.alias).reduce((e,[t,n])=>(e.find(e=>e.find===t)||e.push({find:t,replacement:n}),e),[]):[]),dedupe:a.config.build.dedupe,mainFields:a.config.build.mainFields,conditions:a.config.build.conditions,extensions:a.config.build.extensions}},a.config.build.variant===`vite`?a.config.build.override:{},a.config.build.variant===`vite`?r(a.config.build,[`override`,`variant`]):{},{define:a.config.build.define,rootDir:a.config.sourceRoot,platform:a.config.build.platform,mode:a.config.mode===`development`?`development`:`production`,cacheDir:t(a.cachePath,`vite`),build:{minify:a.config.mode!==`development`,metafile:a.config.mode===`development`,sourcemap:a.config.mode===`development`,outDir:a.config.output.buildPath,tsconfig:a.tsconfig.tsconfigFilePath,tsconfigRaw:a.tsconfig.tsconfigJson},esbuild:e(a),logLevel:a.config.logLevel??void 0,envDir:a.config.projectRoot},i)}export{i as DEFAULT_VITE_CONFIG,a as extractViteConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/path/join-paths`),n=require(`defu`);n=e.__toESM(n);let r=require(`@stryke/path/replace`),i=require(`@stryke/path/append`),a=require(`@stryke/type-checks/is-function`),o=require(`@stryke/type-checks/is-set-object`),s=require(`@stryke/fs/exists`),c=require(`@storm-software/config-tools/get-config`),l=require(`c12`);async function u(e,t){return(0,n.default)({workspaceRoot:e},await(0,c.getWorkspaceConfig)(!0,{cwd:t,workspaceRoot:e,useDefault:!0}))}async function d(e,c,u,d,f=`production`,p,m=`powerlines`){let h={},g;if(p&&(g=(0,s.existsSync)((0,r.replacePath)(p,e))?(0,r.replacePath)(p,e):(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),(0,r.replacePath)(p,e)))?(0,t.joinPaths)((0,i.appendPath)(e,c),(0,r.replacePath)(p,e)):(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),p))?(0,t.joinPaths)((0,i.appendPath)(e,c),p):void 0),g||=(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.ts`))?(0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.ts`):(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.js`))?(0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.js`):(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.mts`))?(0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.mts`):(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.mjs`))?(0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.${f}.config.mjs`):(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.config.ts`))?(0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.config.ts`):(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.config.js`))?(0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.config.js`):(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.config.mts`))?(0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.config.mts`):(0,s.existsSync)((0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.config.mjs`))?(0,t.joinPaths)((0,i.appendPath)(e,c),`${m}.config.mjs`):void 0,g){let e=await u.import(u.esmResolve(g));if(e){let t={};(0,a.isFunction)(e)&&(t=await Promise.resolve(e({command:d,mode:f,isSsrBuild:!1,isPreview:!1}))),(0,o.isSetObject)(t)&&(h={...t,config:t,configFile:g})}}let _=await(0,l.loadConfig)({cwd:e,name:m,envName:f,globalRc:!0,packageJson:!0,dotenv:!0,jiti:u});return(0,n.default)(h,(0,o.isSetObject)(_?.config)?{..._.config,..._}:{})}exports.loadUserConfigFile=d,exports.loadWorkspaceConfig=u;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{joinPaths as e}from"@stryke/path/join-paths";import t from"defu";import{replacePath as n}from"@stryke/path/replace";import{appendPath as r}from"@stryke/path/append";import{isFunction as i}from"@stryke/type-checks/is-function";import{isSetObject as a}from"@stryke/type-checks/is-set-object";import{existsSync as o}from"@stryke/fs/exists";import{getWorkspaceConfig as s}from"@storm-software/config-tools/get-config";import{loadConfig as c}from"c12";async function l(e,n){return t({workspaceRoot:e},await s(!0,{cwd:n,workspaceRoot:e,useDefault:!0}))}async function u(s,l,u,d,f=`production`,p,m=`powerlines`){let h={},g;if(p&&(g=o(n(p,s))?n(p,s):o(e(r(s,l),n(p,s)))?e(r(s,l),n(p,s)):o(e(r(s,l),p))?e(r(s,l),p):void 0),g||=o(e(r(s,l),`${m}.${f}.config.ts`))?e(r(s,l),`${m}.${f}.config.ts`):o(e(r(s,l),`${m}.${f}.config.js`))?e(r(s,l),`${m}.${f}.config.js`):o(e(r(s,l),`${m}.${f}.config.mts`))?e(r(s,l),`${m}.${f}.config.mts`):o(e(r(s,l),`${m}.${f}.config.mjs`))?e(r(s,l),`${m}.${f}.config.mjs`):o(e(r(s,l),`${m}.config.ts`))?e(r(s,l),`${m}.config.ts`):o(e(r(s,l),`${m}.config.js`))?e(r(s,l),`${m}.config.js`):o(e(r(s,l),`${m}.config.mts`))?e(r(s,l),`${m}.config.mts`):o(e(r(s,l),`${m}.config.mjs`))?e(r(s,l),`${m}.config.mjs`):void 0,g){let e=await u.import(u.esmResolve(g));if(e){let t={};i(e)&&(t=await Promise.resolve(e({command:d,mode:f,isSsrBuild:!1,isPreview:!1}))),a(t)&&(h={...t,config:t,configFile:g})}}let _=await c({cwd:s,name:m,envName:f,globalRc:!0,packageJson:!0,dotenv:!0,jiti:u});return t(h,a(_?.config)?{..._.config,..._}:{})}export{u as loadUserConfigFile,l as loadWorkspaceConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../../internal/helpers/environment.cjs`),n=require(`../config-file.cjs`),r=require(`./context.cjs`),i=require(`./environment-context.cjs`);let a=require(`@storm-software/config-tools/types`),o=require(`@stryke/convert/to-array`),s=require(`@stryke/fs/resolve`),c=require(`@stryke/type-checks/is-set-object`),l=require(`chalk`);l=e.__toESM(l);var u=class e extends r.PowerlinesContext{#e={};#t=[];#n;static async from(t,r){let i=new e(await n.loadWorkspaceConfig(t,r.root));await i.withUserConfig(r);let a=await(0,s.resolvePackage)(`powerlines`);if(!a)throw Error("Could not resolve `powerlines` package location.");return i.powerlinesPath=a,i}get $$internal(){return super.$$internal}set $$internal(e){super.$$internal=e;for(let e of Object.values(this.environments))e.$$internal=super.$$internal}get environments(){return this.#e}get log(){return this.#n||=this.createLog(`engine`),this.#n}get plugins(){return this.#t}constructor(e){super(e)}async init(e={}){await super.init(e),await Promise.all((0,o.toArray)(this.config.userConfig.environments&&Object.keys(this.config.userConfig.environments).length>0?Object.keys(this.config.userConfig.environments).map(e=>t.createEnvironment(e,this.config.userConfig)):t.createDefaultEnvironment(this.config.userConfig)).map(async e=>{this.#e[e.name]=await this.in(e)}))}async in(e){let t;t=this.environments[e.name]?this.environments[e.name]:await i.PowerlinesEnvironmentContext.fromConfig(this.workspaceConfig,this.config),(0,c.isSetObject)(this.config.inlineConfig)&&await t.withInlineConfig(this.config.inlineConfig),t.environment=e,t.plugins=[];for(let e of this.plugins)await t.addPlugin(e);return t}async withUserConfig(e,t={isHighPriority:!0}){await super.withUserConfig(e,t),await Promise.all(Object.keys(this.#e).map(async n=>{await this.#e[n].withUserConfig(e,t)}))}async withInlineConfig(e,t={isHighPriority:!0}){await super.withInlineConfig(e,t),await Promise.all(Object.keys(this.#e).map(async n=>{await this.#e[n].withInlineConfig(e,t)}))}async addPlugin(e){this.plugins.push(e),await Promise.all(Object.keys(this.environments).map(async t=>{await this.environments[t].addPlugin(e)}))}async getEnvironment(e){let n;if(e&&(n=this.environments[e]),Object.keys(this.environments).length===1&&(n=this.environments[Object.keys(this.environments)[0]],this.log(a.LogLevelLabel.DEBUG,`Applying the only configured environment: ${l.default.bold.cyanBright(n?.environment.name)}`)),!n){if(e)throw Error(`Environment "${e}" not found.`);n=await this.in(t.createDefaultEnvironment(this.config.userConfig)),this.log(a.LogLevelLabel.WARN,`No environment specified, and no default environment found. Using a temporary default environment: ${l.default.bold.cyanBright(n?.environment.name)}`)}return n}async getEnvironmentSafe(e){try{return await this.getEnvironment(e)}catch{return}}};exports.PowerlinesAPIContext=u;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createDefaultEnvironment as e,createEnvironment as t}from"../../internal/helpers/environment.mjs";import{loadWorkspaceConfig as n}from"../config-file.mjs";import{PowerlinesContext as r}from"./context.mjs";import{PowerlinesEnvironmentContext as i}from"./environment-context.mjs";import{LogLevelLabel as a}from"@storm-software/config-tools/types";import{toArray as o}from"@stryke/convert/to-array";import{resolvePackage as s}from"@stryke/fs/resolve";import{isSetObject as c}from"@stryke/type-checks/is-set-object";import l from"chalk";var u=class u extends r{#e={};#t=[];#n;static async from(e,t){let r=new u(await n(e,t.root));await r.withUserConfig(t);let i=await s(`powerlines`);if(!i)throw Error("Could not resolve `powerlines` package location.");return r.powerlinesPath=i,r}get $$internal(){return super.$$internal}set $$internal(e){super.$$internal=e;for(let e of Object.values(this.environments))e.$$internal=super.$$internal}get environments(){return this.#e}get log(){return this.#n||=this.createLog(`engine`),this.#n}get plugins(){return this.#t}constructor(e){super(e)}async init(n={}){await super.init(n),await Promise.all(o(this.config.userConfig.environments&&Object.keys(this.config.userConfig.environments).length>0?Object.keys(this.config.userConfig.environments).map(e=>t(e,this.config.userConfig)):e(this.config.userConfig)).map(async e=>{this.#e[e.name]=await this.in(e)}))}async in(e){let t;t=this.environments[e.name]?this.environments[e.name]:await i.fromConfig(this.workspaceConfig,this.config),c(this.config.inlineConfig)&&await t.withInlineConfig(this.config.inlineConfig),t.environment=e,t.plugins=[];for(let e of this.plugins)await t.addPlugin(e);return t}async withUserConfig(e,t={isHighPriority:!0}){await super.withUserConfig(e,t),await Promise.all(Object.keys(this.#e).map(async n=>{await this.#e[n].withUserConfig(e,t)}))}async withInlineConfig(e,t={isHighPriority:!0}){await super.withInlineConfig(e,t),await Promise.all(Object.keys(this.#e).map(async n=>{await this.#e[n].withInlineConfig(e,t)}))}async addPlugin(e){this.plugins.push(e),await Promise.all(Object.keys(this.environments).map(async t=>{await this.environments[t].addPlugin(e)}))}async getEnvironment(t){let n;if(t&&(n=this.environments[t]),Object.keys(this.environments).length===1&&(n=this.environments[Object.keys(this.environments)[0]],this.log(a.DEBUG,`Applying the only configured environment: ${l.bold.cyanBright(n?.environment.name)}`)),!n){if(t)throw Error(`Environment "${t}" not found.`);n=await this.in(e(this.config.userConfig)),this.log(a.WARN,`No environment specified, and no default environment found. Using a temporary default environment: ${l.bold.cyanBright(n?.environment.name)}`)}return n}async getEnvironmentSafe(e){try{return await this.getEnvironment(e)}catch{return}}};export{u as PowerlinesAPIContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../../plugin-utils/paths.cjs`),n=require(`../entry.cjs`),r=require(`../typescript/ts-morph.cjs`),i=require(`../typescript/tsconfig.cjs`),a=require(`../config-file.cjs`),o=require(`../../internal/helpers/resolver.cjs`),s=require(`../../plugin-utils/helpers.cjs`),c=require(`../logger.cjs`),l=require(`../fs/vfs.cjs`),u=require(`../utilities/meta.cjs`);let d=require(`@storm-software/config-tools/types`),f=require(`defu`);f=e.__toESM(f);let p=require(`@stryke/helpers/omit`),m=require(`@stryke/path/replace`),h=require(`@stryke/type-checks/is-string`),g=require(`@stryke/convert/to-array`),_=require(`@stryke/hash/murmurhash`),v=require(`@stryke/helpers/get-unique`),y=require(`@stryke/path/append`),b=require(`@stryke/type-checks/is-set-string`),x=require(`@stryke/fs/get-workspace-root`),S=require(`@stryke/fs/resolve`),C=require(`@stryke/type-checks/is-set-object`),w=require(`@stryke/fs/json`),T=require(`@stryke/json/storm-json`),E=require(`@stryke/string-format/title-case`),D=require(`@stryke/fs/exists`),O=require(`@stryke/env/get-env-paths`),k=require(`@stryke/hash/hash-files`),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 r=new e(await a.loadWorkspaceConfig(t,n.root));await r.withUserConfig(n);let i=await(0,S.resolvePackage)(`powerlines`);if(!i)throw Error("Could not resolve `powerlines` package location.");return r.powerlinesPath=i,r}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 n.resolveEntriesSync(this,(0,g.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,_.murmurhash)({workspaceRoot:this.workspaceConfig?.workspaceRoot,projectRoot:this.config?.projectRoot},{maxLength:u.PROJECT_ROOT_HASH_LENGTH}),configHash:(0,_.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,O.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,_.murmurhash)({checksum:this.#n,config:this.meta.configHash},{maxLength:u.CACHE_HASH_LENGTH}))}get dtsPath(){return this.config.output.dts?(0,y.appendPath)(this.config.output.dts,this.workspaceConfig.workspaceRoot):(0,M.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`powerlines.d.ts`)}get relativeToWorkspaceRoot(){return(0,x.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||=r.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,_.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,_.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,C.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,y.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,y.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,D.existsSync)(e))throw Error(`The workspace package.json file could not be found at ${e}`);this.packageJson=await(0,w.readJsonFile)(e),this.workspaceConfig.repository??=(0,b.isSetString)(this.packageJson?.repository)?this.packageJson.repository:this.packageJson?.repository?.url}await this.init(this.config.inlineConfig,t)}fatal(e){this.log(d.LogLevelLabel.FATAL,(0,h.isString)(e)?e:T.StormJSON.stringify(e))}error(e){this.log(d.LogLevelLabel.ERROR,(0,h.isString)(e)?e:T.StormJSON.stringify(e))}warn(e){this.log(d.LogLevelLabel.WARN,(0,h.isString)(e)?e:T.StormJSON.stringify(e))}info(e){this.log(d.LogLevelLabel.INFO,(0,h.isString)(e)?e:T.StormJSON.stringify(e))}debug(e){this.log(d.LogLevelLabel.DEBUG,(0,h.isString)(e)?e:T.StormJSON.stringify(e))}trace(e){this.log(d.LogLevelLabel.TRACE,(0,h.isString)(e)?e:T.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,k.hashDirectory)(e,{ignore:[`node_modules`,`.git`,`.nx`,`.cache`,`.storm`,`tmp`,`dist`]}),this.#n}constructor(e){this.#t=e,this.#o=(0,O.getEnvPaths)({orgId:`storm-software`,appId:`powerlines`,workspaceRoot:e.workspaceRoot})}resolvedConfig={};logFn;async init(e={},r={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,D.existsSync)(t)&&(this.projectJson=await(0,w.readJsonFile)(t));let n=(0,M.joinPaths)(c.projectRoot,`package.json`);(0,D.existsSync)(n)&&(this.packageJson=await(0,w.readJsonFile)(n)),this.#n=await this.generateChecksum(c.projectRoot),this.resolver=o.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 r=await a.loadUserConfigFile(c.projectRoot,this.workspaceConfig.workspaceRoot,this.resolver,c.command,c.mode,c.configFile,c.framework);this.mergeUserConfig(r.config),z.set(c,{projectJson:this.projectJson,packageJson:this.packageJson,checksum:this.#n,resolver:this.resolver,userConfig:r})}e.tsconfig??=i.getTsconfigFilePath(this.workspaceConfig.workspaceRoot,c.projectRoot,e.tsconfig),(0,C.isSetObject)(e)&&(this.resolvedConfig=(0,f.default)({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||(0,y.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`}]})},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=n.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,E.titleCase)(this.config.name),this.config.userConfig.build?.external&&(this.config.userConfig.build.external=(0,v.getUnique)(this.config.userConfig.build.external)),this.config.userConfig.build?.noExternal&&(this.config.userConfig.build.noExternal=(0,v.getUnique)(this.config.userConfig.build.noExternal)),this.config.build.external&&(this.config.build.external=(0,v.getUnique)(this.config.build.external)),this.config.build.noExternal&&(this.config.build.noExternal=(0,v.getUnique)(this.config.build.noExternal)),this.config.output.format=(0,v.getUnique)((0,g.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,v.getUnique)(this.config.output.assets.map(e=>({glob:(0,C.isSetObject)(e)?e.glob:e,input:(0,h.isString)(e)||!e.input||e.input===`.`||e.input===`/`||e.input===`./`?this.workspaceConfig.workspaceRoot:(0,y.appendPath)(e.input,this.workspaceConfig.workspaceRoot),output:(0,y.appendPath)((0,C.isSetObject)(e)&&e.output?(0,M.joinPaths)(this.config.output.outputPath,(0,m.replacePath)(e.output,this.config.output.outputPath)):this.config.output.outputPath,this.workspaceConfig.workspaceRoot),ignore:(0,C.isSetObject)(e)&&e.ignore?(0,g.toArray)(e.ignore):void 0}))),this.config.plugins=(this.config.plugins??[]).filter(Boolean).reduce((e,t)=>(s.isPlugin(t)&&s.checkDedupe(t,e.filter(e=>s.isPlugin(e)))||e.push(t),e),[]),this.config.tsconfig&&(this.config.tsconfig=t.replacePathTokens(this,this.config.tsconfig)),this.config.output.dts&&(this.config.output.dts=t.replacePathTokens(this,this.config.output.dts)),this.config.build.polyfill&&(this.config.build.polyfill=this.config.build.polyfill.map(e=>t.replacePathTokens(this,e))),this.config.output.assets&&(this.config.output.assets=this.config.output.assets.map(e=>({...e,glob:t.replacePathTokens(this,e.glob),ignore:e.ignore?e.ignore.map(e=>t.replacePathTokens(this,e)):void 0,input:t.replacePathTokens(this,e.input),output:t.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,v.getUnique)((0,g.toArray)(this.config.userConfig.output?.format))),this.config.userConfig.plugins=(this.config.userConfig.plugins??[]).filter(Boolean).reduce((e,t)=>(s.isPlugin(t)&&s.checkDedupe(t,e.filter(e=>s.isPlugin(e)))||e.push(t),e),[])}};exports.PowerlinesContext=B;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{replacePathTokens as e}from"../../plugin-utils/paths.mjs";import{getUniqueEntries as t,resolveEntriesSync as n}from"../entry.mjs";import{createProgram as r}from"../typescript/ts-morph.mjs";import{getTsconfigFilePath as i}from"../typescript/tsconfig.mjs";import{loadUserConfigFile as a,loadWorkspaceConfig as o}from"../config-file.mjs";import{createResolver as s}from"../../internal/helpers/resolver.mjs";import{checkDedupe as c,isPlugin as l}from"../../plugin-utils/helpers.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{LogLevelLabel as g}from"@storm-software/config-tools/types";import _ from"defu";import{omit as v}from"@stryke/helpers/omit";import{replacePath as y}from"@stryke/path/replace";import{isString as b}from"@stryke/type-checks/is-string";import{toArray as x}from"@stryke/convert/to-array";import{murmurhash as S}from"@stryke/hash/murmurhash";import{getUnique as C}from"@stryke/helpers/get-unique";import{appendPath as w}from"@stryke/path/append";import{isSetString as T}from"@stryke/type-checks/is-set-string";import{relativeToWorkspaceRoot as E}from"@stryke/fs/get-workspace-root";import{resolvePackage as D}from"@stryke/fs/resolve";import{isSetObject as O}from"@stryke/type-checks/is-set-object";import{readJsonFile as k}from"@stryke/fs/json";import{StormJSON as A}from"@stryke/json/storm-json";import{titleCase as j}from"@stryke/string-format/title-case";import{existsSync as M}from"@stryke/fs/exists";import{getEnvPaths as N}from"@stryke/env/get-env-paths";import{hashDirectory as P}from"@stryke/hash/hash-files";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 o(e,t.root));await n.withUserConfig(t);let r=await D(`powerlines`);if(!r)throw Error("Could not resolve `powerlines` package location.");return n.powerlinesPath=r,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 n(this,x(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:S({workspaceRoot:this.workspaceConfig?.workspaceRoot,projectRoot:this.config?.projectRoot},{maxLength:m}),configHash:S(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||=N({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`,S({checksum:this.#n,config:this.meta.configHash},{maxLength:p}))}get dtsPath(){return this.config.output.dts?w(this.config.output.dts,this.workspaceConfig.workspaceRoot):L(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`powerlines.d.ts`)}get relativeToWorkspaceRoot(){return E(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||=r(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=S({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=S({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 O(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:w(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):w(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(!M(e))throw Error(`The workspace package.json file could not be found at ${e}`);this.packageJson=await k(e),this.workspaceConfig.repository??=T(this.packageJson?.repository)?this.packageJson.repository:this.packageJson?.repository?.url}await this.init(this.config.inlineConfig,t)}fatal(e){this.log(g.FATAL,b(e)?e:A.stringify(e))}error(e){this.log(g.ERROR,b(e)?e:A.stringify(e))}warn(e){this.log(g.WARN,b(e)?e:A.stringify(e))}info(e){this.log(g.INFO,b(e)?e:A.stringify(e))}debug(e){this.log(g.DEBUG,b(e)?e:A.stringify(e))}trace(e){this.log(g.TRACE,b(e)?e:A.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 P(e,{ignore:[`node_modules`,`.git`,`.nx`,`.cache`,`.storm`,`tmp`,`dist`]}),this.#n}constructor(e){this.#t=e,this.#o=N({orgId:`storm-software`,appId:`powerlines`,workspaceRoot:e.workspaceRoot})}resolvedConfig={};logFn;async init(n={},r={isHighPriority:!0}){let o={projectRoot:n.root??this.config.projectRoot??this.config.userConfig?.root??this.config.inlineConfig?.root,mode:(n.mode??this.config.mode)||this.workspaceConfig.mode,skipCache:n.skipCache??this.config.skipCache??!1,configFile:n.configFile??this.config.configFile,framework:n.framework??this.config.framework??`powerlines`,command:this.config.inlineConfig?.command};if(J.has(o)){let e=J.get(o);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 e=L(o.projectRoot,`project.json`);M(e)&&(this.projectJson=await k(e));let t=L(o.projectRoot,`package.json`);M(t)&&(this.packageJson=await k(t)),this.#n=await this.generateChecksum(o.projectRoot),this.resolver=s({workspaceRoot:this.workspaceConfig.workspaceRoot,projectRoot:o.projectRoot,cacheDir:this.cachePath,mode:o.mode,logLevel:n.logLevel||this.config?.logLevel||this.workspaceConfig.logLevel||`info`,skipCache:o.skipCache});let r=await a(o.projectRoot,this.workspaceConfig.workspaceRoot,this.resolver,o.command,o.mode,o.configFile,o.framework);this.mergeUserConfig(r.config),J.set(o,{projectJson:this.projectJson,packageJson:this.packageJson,checksum:this.#n,resolver:this.resolver,userConfig:r})}n.tsconfig??=i(this.workspaceConfig.workspaceRoot,o.projectRoot,n.tsconfig),O(n)&&(this.resolvedConfig=_({inlineConfig:this.config.inlineConfig,userConfig:this.config.userConfig},r.isHighPriority?this.#f(n):{},{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||w(`src`,o.projectRoot),output:_(n.output??{},{outputPath:o.projectRoot?L(this.workspaceConfig?.directories?.build||`dist`,o.projectRoot):this.workspaceConfig?.directories?.build||`dist`,artifactsPath:L(o.projectRoot,`.${n.framework??`powerlines`}`),dts:L(o.projectRoot,`${n.framework??`powerlines`}.d.ts`),builtinPrefix:n.framework??`powerlines`,assets:[{glob:`LICENSE`},{input:o.projectRoot,glob:`*.md`},{input:o.projectRoot,glob:`package.json`}]})},r.isHighPriority?{}:this.#f(n),{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=t(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??=j(this.config.name),this.config.userConfig.build?.external&&(this.config.userConfig.build.external=C(this.config.userConfig.build.external)),this.config.userConfig.build?.noExternal&&(this.config.userConfig.build.noExternal=C(this.config.userConfig.build.noExternal)),this.config.build.external&&(this.config.build.external=C(this.config.build.external)),this.config.build.noExternal&&(this.config.build.noExternal=C(this.config.build.noExternal)),this.config.output.format=C(x(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=C(this.config.output.assets.map(e=>({glob:O(e)?e.glob:e,input:b(e)||!e.input||e.input===`.`||e.input===`/`||e.input===`./`?this.workspaceConfig.workspaceRoot:w(e.input,this.workspaceConfig.workspaceRoot),output:w(O(e)&&e.output?L(this.config.output.outputPath,y(e.output,this.config.output.outputPath)):this.config.output.outputPath,this.workspaceConfig.workspaceRoot),ignore:O(e)&&e.ignore?x(e.ignore):void 0}))),this.config.plugins=(this.config.plugins??[]).filter(Boolean).reduce((e,t)=>(l(t)&&c(t,e.filter(e=>l(e)))||e.push(t),e),[]),this.config.tsconfig&&(this.config.tsconfig=e(this,this.config.tsconfig)),this.config.output.dts&&(this.config.output.dts=e(this,this.config.output.dts)),this.config.build.polyfill&&(this.config.build.polyfill=this.config.build.polyfill.map(t=>e(this,t))),this.config.output.assets&&(this.config.output.assets=this.config.output.assets.map(t=>({...t,glob:e(this,t.glob),ignore:t.ignore?t.ignore.map(t=>e(this,t)):void 0,input:e(this,t.input),output:e(this,t.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=C(x(this.config.userConfig.output?.format))),this.config.userConfig.plugins=(this.config.userConfig.plugins??[]).filter(Boolean).reduce((e,t)=>(l(t)&&c(t,e.filter(e=>l(e)))||e.push(t),e),[])}};export{Y as PowerlinesContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../../plugin-utils/helpers.cjs`),n=require(`./context.cjs`),r=require(`../../types/plugin.cjs`),i=require(`./plugin-context.cjs`);let a=require(`@stryke/fs/resolve`),o=require(`@stryke/type-checks/is-function`),s=require(`@stryke/type-checks/is-object`);var c=class e extends n.PowerlinesContext{#e={};static async fromConfig(t,n){let r=new e(n,t);await r.init();let i=await(0,a.resolvePackage)(`powerlines`);if(!i)throw Error("Could not resolve `powerlines` package location.");return r.powerlinesPath=i,r}environment;plugins=[];get config(){return super.config}get hooks(){return this.#e}async addPlugin(e){let n=e;if((0,o.isFunction)(e.applyToEnvironment)){let r=await Promise.resolve(e.applyToEnvironment(this.environment));if(!r||(0,s.isObject)(r)&&Object.keys(r).length===0)return;if(t.isPluginConfig(r))return this.$$internal.addPlugin(r);n=t.isPlugin(r)?r:e}let a=i.createPluginContext(n,this);this.plugins.push({plugin:n,context:a}),this.#e=Object.keys(n).filter(e=>!r.PLUGIN_NON_HOOK_FIELDS.includes(e)).reduce((e,r)=>{let i=r,s=n[i];if(!t.isPluginHook(s))return e;if(t.isHookExternal(i))e[i]??=[],e[i].push({plugin:n,hook:t.getHookHandler(s).bind(a)});else{if(e[i]??={},n.enforce)return e[i][`${n.enforce}Enforced`]??=[],t.addPluginHook(a,n,s,e[i][`${n.enforce}Enforced`]),e;if((0,o.isFunction)(s)||!s.order)return e[i].normal??=[],t.addPluginHook(a,n,s,e[i].normal),e;e[i][`${s.order}Ordered`]??=[],t.addPluginHook(a,n,s,e[i][`${s.order}Ordered`])}return e},this.hooks)}selectHooks(e,n){let r=[];if(this.hooks[e])if(t.isHookExternal(e))r.push(...this.hooks[e].map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}}));else{let t=this.hooks[e];n?.order?n?.order===`pre`?(r.push(...(t.preOrdered??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}})),r.push(...(t.preEnforced??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}}))):n?.order===`post`?(r.push(...(t.postOrdered??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}})),r.push(...(t.postEnforced??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}}))):r.push(...(t.normal??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}})):(r.push(...this.selectHooks(e,{order:`pre`})),r.push(...this.selectHooks(e,{order:`normal`})),r.push(...this.selectHooks(e,{order:`post`})))}return r}constructor(e,t){super(t),this.resolvedConfig=e}};exports.PowerlinesEnvironmentContext=c;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{addPluginHook as e,getHookHandler as t,isHookExternal as n,isPlugin as r,isPluginConfig as i,isPluginHook as a}from"../../plugin-utils/helpers.mjs";import{PowerlinesContext as o}from"./context.mjs";import{PLUGIN_NON_HOOK_FIELDS as s}from"../../types/plugin.mjs";import{createPluginContext as c}from"./plugin-context.mjs";import{resolvePackage as l}from"@stryke/fs/resolve";import{isFunction as u}from"@stryke/type-checks/is-function";import{isObject as d}from"@stryke/type-checks/is-object";var f=class f extends o{#e={};static async fromConfig(e,t){let n=new f(t,e);await n.init();let r=await l(`powerlines`);if(!r)throw Error("Could not resolve `powerlines` package location.");return n.powerlinesPath=r,n}environment;plugins=[];get config(){return super.config}get hooks(){return this.#e}async addPlugin(o){let l=o;if(u(o.applyToEnvironment)){let e=await Promise.resolve(o.applyToEnvironment(this.environment));if(!e||d(e)&&Object.keys(e).length===0)return;if(i(e))return this.$$internal.addPlugin(e);l=r(e)?e:o}let f=c(l,this);this.plugins.push({plugin:l,context:f}),this.#e=Object.keys(l).filter(e=>!s.includes(e)).reduce((r,i)=>{let o=i,s=l[o];if(!a(s))return r;if(n(o))r[o]??=[],r[o].push({plugin:l,hook:t(s).bind(f)});else{if(r[o]??={},l.enforce)return r[o][`${l.enforce}Enforced`]??=[],e(f,l,s,r[o][`${l.enforce}Enforced`]),r;if(u(s)||!s.order)return r[o].normal??=[],e(f,l,s,r[o].normal),r;r[o][`${s.order}Ordered`]??=[],e(f,l,s,r[o][`${s.order}Ordered`])}return r},this.hooks)}selectHooks(e,t){let r=[];if(this.hooks[e])if(n(e))r.push(...this.hooks[e].map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}}));else{let n=this.hooks[e];t?.order?t?.order===`pre`?(r.push(...(n.preOrdered??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}})),r.push(...(n.preEnforced??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}}))):t?.order===`post`?(r.push(...(n.postOrdered??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}})),r.push(...(n.postEnforced??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}}))):r.push(...(n.normal??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}})):(r.push(...this.selectHooks(e,{order:`pre`})),r.push(...this.selectHooks(e,{order:`normal`})),r.push(...this.selectHooks(e,{order:`post`})))}return r}constructor(e,t){super(t),this.resolvedConfig=e}};export{f as PowerlinesEnvironmentContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@storm-software/config-tools/types`),n=require(`@stryke/type-checks/is-string`);function r(e,r){let i=e=>(0,n.isString)(e)?e:e.message,a=r.extendLog(e.name),o=async(e,t,...n)=>r.$$internal.api.callHook(e,{sequential:!0,result:`merge`,...t,environment:r},...n);return new Proxy({},{get(e,n){return n===`$$internal`?{...r.$$internal,environment:r,callHook:o}:n===`log`||n===`logger`?a:n===`error`?e=>{a(t.LogLevelLabel.ERROR,i(e))}:n===`warn`?e=>{a(t.LogLevelLabel.WARN,i(e))}:n===`info`?e=>{a(t.LogLevelLabel.INFO,i(e))}:n===`debug`?e=>{a(t.LogLevelLabel.DEBUG,i(e))}:n===`trace`?e=>{a(t.LogLevelLabel.TRACE,i(e))}:r[n]},set(e,n,i){return[`$$internal`,`environment`,`config`,`log`,`logger`,`error`,`warn`,`plugins`,`hooks`,`addPlugin`,`selectHooks`].includes(n)?(a(t.LogLevelLabel.WARN,`Cannot set read-only property "${String(n)}"`),!1):(r[n]=i,!0)}})}exports.createPluginContext=r;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LogLevelLabel as e}from"@storm-software/config-tools/types";import{isString as t}from"@stryke/type-checks/is-string";function n(n,r){let i=e=>t(e)?e:e.message,a=r.extendLog(n.name),o=async(e,t,...n)=>r.$$internal.api.callHook(e,{sequential:!0,result:`merge`,...t,environment:r},...n);return new Proxy({},{get(t,n){return n===`$$internal`?{...r.$$internal,environment:r,callHook:o}:n===`log`||n===`logger`?a:n===`error`?t=>{a(e.ERROR,i(t))}:n===`warn`?t=>{a(e.WARN,i(t))}:n===`info`?t=>{a(e.INFO,i(t))}:n===`debug`?t=>{a(e.DEBUG,i(t))}:n===`trace`?t=>{a(e.TRACE,i(t))}:r[n]},set(t,n,i){return[`$$internal`,`environment`,`config`,`log`,`logger`,`error`,`warn`,`plugins`,`hooks`,`addPlugin`,`selectHooks`].includes(n)?(a(e.WARN,`Cannot set read-only property "${String(n)}"`),!1):(r[n]=i,!0)}})}export{n as createPluginContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../_virtual/rolldown_runtime.cjs`),t=require(`../plugin-utils/paths.cjs`);let n=require(`@stryke/path/join-paths`),r=require(`@stryke/path/replace`),i=require(`@stryke/type-checks/is-string`),a=require(`@stryke/convert/parse-type-definition`),o=require(`@stryke/convert/to-array`),s=require(`@stryke/fs/is-file`),c=require(`@stryke/fs/list-files`),l=require(`@stryke/hash/murmurhash`),u=require(`@stryke/helpers/get-unique`),d=require(`@stryke/path/append`),f=require(`@stryke/type-checks/is-set-string`);function p(e,t){return(0,r.replacePath)(t.file,(0,n.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot))}function m(e,t){return{file:p(e,t),name:t.name}}function h(e,t){return(0,r.replaceExtension)((0,r.replacePath)((0,r.replacePath)((0,r.replacePath)((0,r.replacePath)((0,r.replacePath)(t.file,(0,n.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.sourceRoot)),(0,n.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot)),e.config.sourceRoot),e.config.projectRoot),(0,r.replacePath)(e.config.sourceRoot,e.config.projectRoot)))}function g(e,t){let n=m(e,t);return{...n,input:n,output:h(e,t)}}function _(e,n){return n.map(n=>(0,i.isString)(n)?t.replacePathTokens(e,n):t.replacePathTokens(e,n.file)).map(t=>{let n=(0,a.parseTypeDefinition)(t),i=(0,d.appendPath)(n.file,e.config.projectRoot);return(0,s.isFile)(i)?g(e,{file:(0,r.replacePath)(i,e.config.projectRoot),name:n.name}):(0,c.listFilesSync)(i).map(t=>g(e,{file:t,name:n.name}))}).flat().filter(Boolean)}function v(e=[]){return(0,u.getUniqueBy)((0,o.toArray)(e),e=>(0,f.isSetString)(e)?e:(0,l.murmurhash)(e??{},{maxLength:24}))}exports.getUniqueEntries=v,exports.resolveEntriesSync=_;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{replacePathTokens as e}from"../plugin-utils/paths.mjs";import{joinPaths as t}from"@stryke/path/join-paths";import{replaceExtension as n,replacePath as r}from"@stryke/path/replace";import{isString as i}from"@stryke/type-checks/is-string";import{parseTypeDefinition as a}from"@stryke/convert/parse-type-definition";import{toArray as o}from"@stryke/convert/to-array";import{isFile as s}from"@stryke/fs/is-file";import{listFiles as c,listFilesSync as l}from"@stryke/fs/list-files";import{murmurhash as u}from"@stryke/hash/murmurhash";import{getUniqueBy as d}from"@stryke/helpers/get-unique";import{appendPath as f}from"@stryke/path/append";import{isSetString as p}from"@stryke/type-checks/is-set-string";function m(e,n){return r(n.file,t(e.workspaceConfig.workspaceRoot,e.config.projectRoot))}function h(e,t){return{file:m(e,t),name:t.name}}function g(e,i){return n(r(r(r(r(r(i.file,t(e.workspaceConfig.workspaceRoot,e.config.sourceRoot)),t(e.workspaceConfig.workspaceRoot,e.config.projectRoot)),e.config.sourceRoot),e.config.projectRoot),r(e.config.sourceRoot,e.config.projectRoot)))}function _(e,t){let n=h(e,t);return{...n,input:n,output:g(e,t)}}function v(t,n){return n.map(n=>i(n)?e(t,n):e(t,n.file)).map(e=>{let n=a(e),i=f(n.file,t.config.projectRoot);return s(i)?_(t,{file:r(i,t.config.projectRoot),name:n.name}):l(i).map(e=>_(t,{file:e,name:n.name}))}).flat().filter(Boolean)}function y(e=[]){return d(o(e),e=>p(e)?e:u(e??{},{maxLength:24}))}export{y as getUniqueEntries,v as resolveEntriesSync};
|