@powerlines/plugin-tsup 0.12.67 → 0.12.68
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 -1
- package/dist/index.d.cts +3 -4
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +1 -1
- 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 +1 -0
- package/dist/powerlines/src/lib/build/esbuild.mjs +1 -0
- package/dist/powerlines/src/lib/build/tsup.cjs +1 -0
- package/dist/powerlines/src/lib/build/tsup.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 +347 -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 +15 -1
- package/dist/types/plugin.d.mts +15 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +9 -9
- 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-CFbUgJ4k.d.cts +0 -1651
- package/dist/plugin-DqTElOII.d.mts +0 -1653
- package/dist/plugin-pBKbb5K9.cjs +0 -0
- package/dist/types-n6NgD0QK.mjs +0 -1
- package/dist/types-o3zWarRp.cjs +0 -0
- package/dist/unplugin-BXYmXSlG.d.cts +0 -7
- package/dist/unplugin-CukIKFW_.d.mts +0 -7
- package/dist/unplugin-DCxhuGHP.cjs +0 -44
- package/dist/unplugin-Dujx3xzl.mjs +0 -6
|
@@ -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.createTsupPlugin=e.createTsupPlugin;
|
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{createTsupPlugin as e}from"./unplugin.mjs";export{e as createTsupPlugin};
|
|
@@ -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.createEsbuildPlugin)(t.createUnplugin(e))({})}exports.createTsupPlugin=r;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import "../plugin
|
|
2
|
-
import
|
|
1
|
+
import { TsupPluginContext } from "../types/plugin.cjs";
|
|
2
|
+
import * as esbuild0 from "esbuild";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/unplugin.d.ts
|
|
5
|
+
declare function createTsupPlugin(context: TsupPluginContext): esbuild0.Plugin;
|
|
6
|
+
//#endregion
|
|
3
7
|
export { createTsupPlugin };
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import "../plugin
|
|
2
|
-
import
|
|
1
|
+
import { TsupPluginContext } from "../types/plugin.mjs";
|
|
2
|
+
import * as esbuild0 from "esbuild";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/unplugin.d.ts
|
|
5
|
+
declare function createTsupPlugin(context: TsupPluginContext): esbuild0.Plugin;
|
|
6
|
+
//#endregion
|
|
3
7
|
export { createTsupPlugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createUnplugin as e}from"../powerlines/src/lib/unplugin/plugin.mjs";import"../powerlines/src/lib/unplugin/index.mjs";import{createEsbuildPlugin as t}from"unplugin";function n(n){return t(e(n))({})}export{n as createTsupPlugin};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./
|
|
1
|
+
Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./powerlines/src/lib/build/tsup.cjs`),n=require(`./helpers/unplugin.cjs`);require(`./helpers/index.cjs`);let r=require(`@storm-software/config-tools/types`),i=require(`@storm-software/tsup`),a=require(`@stryke/path/append`),o=require(`defu`);o=e.__toESM(o);const s=(e={})=>({name:`tsup`,config(){return this.log(r.LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `tsup` build plugin."),{output:{format:[`cjs`,`esm`]},build:{...e,variant:`tsup`}}},async build(){return(0,i.build)(await(0,i.resolveOptions)((0,o.default)({config:!1,entry:Object.fromEntries(Object.entries(t.resolveTsupEntry(this,this.entry)).map(([e,t])=>[e,(0,a.appendPath)(t,this.config.projectRoot)])),esbuildOptions:(e,t)=>{this.config.build.variant===`tsup`&&this.config.build.esbuildOptions&&this.config.build.esbuildOptions?.(e,t),e.alias={...this.builtins.reduce((e,t)=>{let n=this.fs.ids[t];return n&&(e[t]=n),e},{}),...e.alias}},silent:!1,verbose:!0},t.extractTsupConfig(this),{esbuildPlugins:[n.createTsupPlugin(this)]})))}});var c=s;exports.createTsupPlugin=n.createTsupPlugin,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 { TsupPluginContext, TsupPluginOptions, TsupPluginResolvedConfig, TsupPluginUserConfig, __ΩTsupPluginContext, __ΩTsupPluginOptions, __ΩTsupPluginResolvedConfig, __ΩTsupPluginUserConfig } from "./types/plugin.cjs";
|
|
3
|
+
import { createTsupPlugin } 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 { TsupPluginContext, TsupPluginOptions, TsupPluginResolvedConfig, TsupPluginUserConfig, __ΩTsupPluginContext, __ΩTsupPluginOptions, __ΩTsupPluginResolvedConfig, __ΩTsupPluginUserConfig } from "./types/plugin.mjs";
|
|
3
|
+
import { createTsupPlugin } 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 use Tsup to build the project.
|
|
10
10
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{extractTsupConfig as e,resolveTsupEntry as t}from"./powerlines/src/lib/build/tsup.mjs";import{createTsupPlugin as n}from"./helpers/unplugin.mjs";import"./helpers/index.mjs";import{LogLevelLabel as r}from"@storm-software/config-tools/types";import{build as i,resolveOptions as a}from"@storm-software/tsup";import{appendPath as o}from"@stryke/path/append";import s from"defu";const c=(c={})=>({name:`tsup`,config(){return this.log(r.TRACE,"Providing default configuration for the Powerlines `tsup` build plugin."),{output:{format:[`cjs`,`esm`]},build:{...c,variant:`tsup`}}},async build(){return i(await a(s({config:!1,entry:Object.fromEntries(Object.entries(t(this,this.entry)).map(([e,t])=>[e,o(t,this.config.projectRoot)])),esbuildOptions:(e,t)=>{this.config.build.variant===`tsup`&&this.config.build.esbuildOptions&&this.config.build.esbuildOptions?.(e,t),e.alias={...this.builtins.reduce((e,t)=>{let n=this.fs.ids[t];return n&&(e[t]=n),e},{}),...e.alias}},silent:!1,verbose:!0},e(this),{esbuildPlugins:[n(this)]})))}});var l=c;export{n as createTsupPlugin,l as default,c 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/path/append`),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/type-checks/is-set-string`),v=require(`@babel/core`),y=require(`@storm-software/config-tools/logger/console`),b=require(`@stryke/fs/helpers`),x=require(`@stryke/fs/install`),S=require(`@stryke/fs/package-fns`),C=require(`@stryke/fs/resolve`),w=require(`@stryke/type-checks/is-error`),T=require(`@stryke/type-checks/is-function`),E=require(`@stryke/type-checks/is-number`),D=require(`@stryke/type-checks/is-object`),O=require(`@stryke/type-checks/is-promise`),k=require(`@stryke/type-checks/is-set`),A=require(`@stryke/type-checks/is-set-object`),j=require(`chalk`);j=e.__toESM(j);let M=require(`handlebars`);M=e.__toESM(M);var N=class e{#e;get context(){return this.#e}constructor(e){this.#e=e}static async from(t,n){let r=new e(await l.PowerlinesAPIContext.from(t,n));r.#e.$$internal={api:r,addPlugin:r.#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,y.formatLogMessage)(e.config)}`),e.fs.existsSync(e.cachePath)||await(0,b.createDirectory)(e.cachePath),e.fs.existsSync(e.dataPath)||await(0,b.createDirectory)(e.dataPath),await this.callHook(`prepare`,{environment:e,order:`pre`}),await this.callHook(`prepare`,{environment:e,order:`normal`}),e.config.output.dts!==!1){e.log(d.LogLevelLabel.TRACE,`Preparing the TypeScript definitions for the Powerlines project.`),e.fs.existsSync(e.dtsPath)&&await e.fs.remove(e.dtsPath),e.log(d.LogLevelLabel.TRACE,`Transforming built-ins runtime modules files.`);let r=await Promise.all((await e.getBuiltins()).map(async n=>{let r=await(0,v.transformAsync)(n.code.toString(),{highlightCode:!0,code:!0,ast:!1,cloneInputAst:!1,comments:!0,sourceType:`module`,configFile:!1,babelrc:!1,envName:e.config.mode,caller:{name:`powerlines`},...e.config.transform.babel,filename:n.path,plugins:[[`@babel/plugin-syntax-typescript`],[t.moduleResolverBabelPlugin(e)]]});if(!r?.code)throw Error(`Powerlines - Generate Types failed to compile ${n.id}`);return e.log(d.LogLevelLabel.TRACE,`Writing transformed built-in runtime file ${n.id}.`),await e.emitBuiltin(r.code,n.id,n.path),n.path}));if(!await(0,C.resolvePackage)(`typescript`))throw Error(`Could not resolve TypeScript package location. Please ensure TypeScript is installed.`);let i=r.reduce((t,n)=>{let r=(0,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,_.isSetString)(f)&&(s=f)),f=await this.callHook(`types`,{environment:e,sequential:!0,order:`normal`,result:`merge`,asNextParam:l},s),f&&((0,A.isSetObject)(f)?(s=f.code,Array.isArray(f.directives)&&f.directives.length>0&&c.push(...f.directives)):(0,_.isSetString)(f)&&(s=f)),f=await this.callHook(`types`,{environment:e,sequential:!0,order:`post`,result:`merge`,asNextParam:l},s),f&&((0,A.isSetObject)(f)?(s=f.code,Array.isArray(f.directives)&&f.directives.length>0&&c.push(...f.directives)):(0,_.isSetString)(f)&&(s=f)),s?.trim()||c.length>0)await e.fs.write(e.dtsPath,`${c?`${c.map(e=>`/// <reference types="${e}" />`).join(`
|
|
3
|
+
`)}
|
|
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,f.appendPath)(e.config.output.buildPath,e.workspaceConfig.workspaceRoot),n=(0,p.joinPaths)((0,f.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,_.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,_.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,S.isPackageExists)(e,{paths:[this.context.workspaceConfig.workspaceRoot,this.context.config.projectRoot]});if(!t&&this.context.config.skipInstalls!==!0){this.#e.log(d.LogLevelLabel.WARN,`The plugin package "${e}" is not installed. It will be installed automatically.`);let t=await(0,x.install)(e,{cwd:this.context.config.projectRoot});if((0,E.isNumber)(t.exitCode)&&t.exitCode>0)throw this.#e.log(d.LogLevelLabel.ERROR,t.stderr),Error(`An error occurred while installing the build plugin package "${e}" `)}try{let t=await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve((0,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{appendPath as y}from"@stryke/path/append";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{isSetString as w}from"@stryke/type-checks/is-set-string";import{transformAsync as T}from"@babel/core";import{formatLogMessage as E}from"@storm-software/config-tools/logger/console";import{createDirectory as D}from"@stryke/fs/helpers";import{install as O}from"@stryke/fs/install";import{isPackageExists as k}from"@stryke/fs/package-fns";import{resolvePackage as A}from"@stryke/fs/resolve";import{isError as j}from"@stryke/type-checks/is-error";import{isFunction as M}from"@stryke/type-checks/is-function";import{isNumber as N}from"@stryke/type-checks/is-number";import{isObject as P}from"@stryke/type-checks/is-object";import{isPromiseLike as F}from"@stryke/type-checks/is-promise";import{isSet as I}from"@stryke/type-checks/is-set";import{isSetObject as L}from"@stryke/type-checks/is-set-object";import R from"chalk";import z from"handlebars";Symbol.asyncDispose;export{};
|
|
@@ -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/install`),r=require(`@stryke/fs/package-fns`),i=require(`@stryke/type-checks/is-number`),a=require(`@stryke/string-format/package`);async function o(e,o,s=!1){if(await(0,r.isPackageListed)((0,a.getPackageName)(o),{cwd:e.config.projectRoot})){if((0,a.hasPackageVersion)(o)&&!process.env.POWERLINES_SKIP_VERSION_CHECK&&!await(0,r.doesPackageMatch)((0,a.getPackageName)(o),(0,a.getPackageVersion)(o),e.config.projectRoot)){let n=await(0,r.getPackageListing)((0,a.getPackageName)(o),{cwd:e.config.projectRoot});!n?.version.startsWith(`catalog:`)&&!n?.version.startsWith(`workspace:`)&&e.log(t.LogLevelLabel.WARN,`The package "${(0,a.getPackageName)(o)}" is installed but does not match the expected version ${(0,a.getPackageVersion)(o)} (installed version: ${n?.version||`<Unknown>`}). Please ensure this is intentional before proceeding. Note: You can skip this validation with the "STORM_STACK_SKIP_VERSION_CHECK" environment variable.`)}}else if(e.config.skipInstalls!==!0){e.log(t.LogLevelLabel.WARN,`The package "${o}" is not installed. It will be installed automatically.`);let r=await(0,n.install)(o,{cwd:e.config.projectRoot,dev:s});if((0,i.isNumber)(r.exitCode)&&r.exitCode>0)throw e.log(t.LogLevelLabel.ERROR,r.stderr),Error(`An error occurred while installing the package "${o}"`)}else e.log(t.LogLevelLabel.WARN,`The package "${o}" is not installed. Since the "skipInstalls" option is set to true, it will not be installed automatically.`)}exports.installPackage=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LogLevelLabel as e}from"@storm-software/config-tools/types";import{install as t}from"@stryke/fs/install";import{doesPackageMatch as n,getPackageListing as r,isPackageListed as i}from"@stryke/fs/package-fns";import{isNumber as a}from"@stryke/type-checks/is-number";import{getPackageName as o,getPackageVersion as s,hasPackageVersion as c}from"@stryke/string-format/package";async function l(l,u,d=!1){if(await i(o(u),{cwd:l.config.projectRoot})){if(c(u)&&!process.env.POWERLINES_SKIP_VERSION_CHECK&&!await n(o(u),s(u),l.config.projectRoot)){let t=await r(o(u),{cwd:l.config.projectRoot});!t?.version.startsWith(`catalog:`)&&!t?.version.startsWith(`workspace:`)&&l.log(e.WARN,`The package "${o(u)}" is installed but does not match the expected version ${s(u)} (installed version: ${t?.version||`<Unknown>`}). Please ensure this is intentional before proceeding. Note: You can skip this validation with the "STORM_STACK_SKIP_VERSION_CHECK" environment variable.`)}}else if(l.config.skipInstalls!==!0){l.log(e.WARN,`The package "${u}" is not installed. It will be installed automatically.`);let n=await t(u,{cwd:l.config.projectRoot,dev:d});if(a(n.exitCode)&&n.exitCode>0)throw l.log(e.ERROR,n.stderr),Error(`An error occurred while installing the package "${u}"`)}else l.log(e.WARN,`The package "${u}" is not installed. Since the "skipInstalls" option is set to true, it will not be installed automatically.`)}export{l as installPackage};
|
|
@@ -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/path/join-paths`),i=require(`@stryke/fs/package-fns`),a=require(`chalk`);a=e.__toESM(a);let o=require(`@donedeal0/superdiff`),s=require(`@stryke/fs/json`),c=require(`@stryke/json/storm-json`),l=require(`@stryke/path/file-path-fns`),u=require(`@stryke/string-format/title-case`);function d(e){return(0,r.joinPaths)((0,l.relativePath)((0,r.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot),(0,l.findFilePath)(e.dtsPath)),(0,l.findFileName)(e.dtsPath))}async function f(e){let n=t.getParsedTypeScriptConfig(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig,e.config.tsconfigRaw),r=await(0,s.readJsonFile)(t.getTsconfigFilePath(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig));if(r.compilerOptions??={},e.config.output.dts!==!1){let n=d(e);r.include?.some(r=>t.isIncludeMatchFound(r,[e.dtsPath,n]))||(r.include??=[],r.include.push(n.startsWith(`./`)?n.slice(2):n))}return n.options.lib?.some(e=>[`lib.esnext.d.ts`,`lib.es2021.d.ts`,`lib.es2022.d.ts`,`lib.es2023.d.ts`].includes(e.toLowerCase()))||(r.compilerOptions.lib??=[],r.compilerOptions.lib.push(`esnext`)),n.options.esModuleInterop!==!0&&(r.compilerOptions.esModuleInterop=!0),n.options.isolatedModules!==!0&&(r.compilerOptions.isolatedModules=!0),e.config.build.platform===`node`&&(n.options.types?.some(e=>e.toLowerCase()===`node`||e.toLowerCase()===`@types/node`)||(r.compilerOptions.types??=[],r.compilerOptions.types.push(`node`))),r}async function p(e){if(e.log(n.LogLevelLabel.TRACE,`Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.`),!(0,i.isPackageExists)(`typescript`))throw Error(`The TypeScript package is not installed. Please install the package using the command: "npm install typescript --save-dev"`);let r=t.getTsconfigFilePath(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig);e.tsconfig.originalTsconfigJson=await(0,s.readJsonFile)(r),e.tsconfig.tsconfigJson=await f(e),e.log(n.LogLevelLabel.TRACE,`Writing updated TypeScript configuration (tsconfig.json) file to disk.`),await e.fs.write(r,c.StormJSON.stringify(e.tsconfig.tsconfigJson)),e.tsconfig=t.getParsedTypeScriptConfig(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig,e.config.tsconfigRaw,e.tsconfig.originalTsconfigJson)}async function m(e){let r=await(0,s.readJsonFile)(e.tsconfig.tsconfigFilePath);r?.compilerOptions?.types&&Array.isArray(r.compilerOptions.types)&&!r.compilerOptions.types.length&&delete r.compilerOptions.types;let i=(0,o.getObjectDiff)(e.tsconfig.originalTsconfigJson,r,{ignoreArrayOrder:!0,showOnly:{statuses:[`added`,`deleted`,`updated`],granularity:`deep`}}),l=[],d=(e,t)=>{if(e.status===`added`||e.status===`deleted`||e.status===`updated`)if(e.diff)for(let n of e.diff)d(n,t?`${t}.${e.property}`:e.property);else l.push({field:t?`${t}.${e.property}`:e.property,status:e.status,previous:e.status===`added`?`---`:c.StormJSON.stringify(e.previousValue),current:e.status===`deleted`?`---`:c.StormJSON.stringify(e.currentValue)})};for(let e of i.diff)d(e);if(l.length>0&&e.log(n.LogLevelLabel.WARN,`Updating the following configuration values in "${e.tsconfig.tsconfigFilePath}" file:
|
|
2
|
+
|
|
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{joinPaths as i}from"@stryke/path/join-paths";import{isPackageExists as a}from"@stryke/fs/package-fns";import o from"chalk";import{getObjectDiff as s}from"@donedeal0/superdiff";import{readJsonFile as c}from"@stryke/fs/json";import{StormJSON as l}from"@stryke/json/storm-json";import{findFileName as u,findFilePath as d,relativePath as f}from"@stryke/path/file-path-fns";import{titleCase as p}from"@stryke/string-format/title-case";function m(e){return i(f(i(e.workspaceConfig.workspaceRoot,e.config.projectRoot),d(e.dtsPath)),u(e.dtsPath))}async function h(r){let i=e(r.workspaceConfig.workspaceRoot,r.config.projectRoot,r.config.tsconfig,r.config.tsconfigRaw),a=await c(t(r.workspaceConfig.workspaceRoot,r.config.projectRoot,r.config.tsconfig));if(a.compilerOptions??={},r.config.output.dts!==!1){let e=m(r);a.include?.some(t=>n(t,[r.dtsPath,e]))||(a.include??=[],a.include.push(e.startsWith(`./`)?e.slice(2):e))}return i.options.lib?.some(e=>[`lib.esnext.d.ts`,`lib.es2021.d.ts`,`lib.es2022.d.ts`,`lib.es2023.d.ts`].includes(e.toLowerCase()))||(a.compilerOptions.lib??=[],a.compilerOptions.lib.push(`esnext`)),i.options.esModuleInterop!==!0&&(a.compilerOptions.esModuleInterop=!0),i.options.isolatedModules!==!0&&(a.compilerOptions.isolatedModules=!0),r.config.build.platform===`node`&&(i.options.types?.some(e=>e.toLowerCase()===`node`||e.toLowerCase()===`@types/node`)||(a.compilerOptions.types??=[],a.compilerOptions.types.push(`node`))),a}async function g(n){if(n.log(r.TRACE,`Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.`),!a(`typescript`))throw Error(`The TypeScript package is not installed. Please install the package using the command: "npm install typescript --save-dev"`);let i=t(n.workspaceConfig.workspaceRoot,n.config.projectRoot,n.config.tsconfig);n.tsconfig.originalTsconfigJson=await c(i),n.tsconfig.tsconfigJson=await h(n),n.log(r.TRACE,`Writing updated TypeScript configuration (tsconfig.json) file to disk.`),await n.fs.write(i,l.stringify(n.tsconfig.tsconfigJson)),n.tsconfig=e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,n.config.tsconfig,n.config.tsconfigRaw,n.tsconfig.originalTsconfigJson)}async function _(t){let n=await c(t.tsconfig.tsconfigFilePath);n?.compilerOptions?.types&&Array.isArray(n.compilerOptions.types)&&!n.compilerOptions.types.length&&delete n.compilerOptions.types;let i=s(t.tsconfig.originalTsconfigJson,n,{ignoreArrayOrder:!0,showOnly:{statuses:[`added`,`deleted`,`updated`],granularity:`deep`}}),a=[],u=(e,t)=>{if(e.status===`added`||e.status===`deleted`||e.status===`updated`)if(e.diff)for(let n of e.diff)u(n,t?`${t}.${e.property}`:e.property);else a.push({field:t?`${t}.${e.property}`:e.property,status:e.status,previous:e.status===`added`?`---`:l.stringify(e.previousValue),current:e.status===`deleted`?`---`:l.stringify(e.currentValue)})};for(let e of i.diff)u(e);if(a.length>0&&t.log(r.WARN,`Updating the following configuration values in "${t.tsconfig.tsconfigFilePath}" file:
|
|
2
|
+
|
|
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(`defu`);t=e.__toESM(t);let n=require(`@stryke/path/join-paths`),r=require(`jiti`);function i(e){return(0,t.default)(e,{interopDefault:!0,fsCache:e.mode===`development`?!1:(0,n.joinPaths)(e.cacheDir,`jiti`),moduleCache:e.mode!==`development`})}function a(e){return(0,r.createJiti)((0,n.joinPaths)(e.workspaceRoot,e.projectRoot),i({...e}))}function o(e){let t=(0,r.createJiti)((0,n.joinPaths)(e.workspaceRoot,e.projectRoot),i(e));return t.plugin=a(e),t}exports.createResolver=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"defu";import{joinPaths as t}from"@stryke/path/join-paths";import{createJiti as n}from"jiti";function r(n){return e(n,{interopDefault:!0,fsCache:n.mode===`development`?!1:t(n.cacheDir,`jiti`),moduleCache:n.mode!==`development`})}function i(e){return n(t(e.workspaceRoot,e.projectRoot),r({...e}))}function a(e){let a=n(t(e.workspaceRoot,e.projectRoot),r(e));return a.plugin=i(e),a}export{a as createResolver};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../entry.cjs`);let n=require(`defu`);n=e.__toESM(n);let r=require(`@stryke/helpers/omit`),i=require(`@stryke/path/join-paths`),a=require(`@stryke/path/replace`);require(`@stryke/string-format/camel-case`);let o=require(`@stryke/type-checks/is-string`);function s(e,n=[]){return n.reduce((n,r)=>((0,o.isString)(r)?n[(0,a.replaceExtension)((0,a.replacePath)(r,e.config.sourceRoot||e.config.projectRoot))]=(0,a.replacePath)(r,e.config.sourceRoot||e.config.projectRoot):n[r.output||t.resolveEntryOutput(e,r.input||r)]=t.resolveEntryInputFile(e,r.input||r),n),{})}exports.resolveESBuildEntry=s;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolveEntryInputFile as e,resolveEntryOutput as t}from"../entry.mjs";import n from"defu";import{omit as r}from"@stryke/helpers/omit";import{joinPaths as i}from"@stryke/path/join-paths";import{replaceExtension as a,replacePath as o}from"@stryke/path/replace";import"@stryke/string-format/camel-case";import{isString as s}from"@stryke/type-checks/is-string";function c(n,r=[]){return r.reduce((r,i)=>(s(i)?r[a(o(i,n.config.sourceRoot||n.config.projectRoot))]=o(i,n.config.sourceRoot||n.config.projectRoot):r[i.output||t(n,i.input||i)]=e(n,i.input||i),r),{})}export{c as resolveESBuildEntry};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`./esbuild.cjs`);let n=require(`defu`);n=e.__toESM(n);let r=require(`@storm-software/tsup/constants`),i=require(`@stryke/helpers/omit`);const a={...r.DEFAULT_BUILD_OPTIONS,platform:`neutral`,target:`esnext`,config:!1,minify:!0,sourcemap:!1,cjsInterop:!0,bundle:!0,dts:!0,shims:!0,silent:!0,treeshake:!0,keepNames:!0,splitting:!0,banner:{}};function o(e,n){return t.resolveESBuildEntry(e,n)}function s(e){return(0,n.default)({esbuildOptions:(t,n)=>{e.config.build.variant===`tsup`&&(e.config.build.esbuildOptions?e.config.build.esbuildOptions?.(t,n):e.config.build.override.esbuildOptions&&e.config.build.override.esbuildOptions?.(t,n)),t.alias={...e.builtins.reduce((t,n)=>{let r=e.fs.ids[n];return r&&(t[n]=r),t},{}),...t.alias}},noExternal:e.builtins},e.config.build.variant===`tsup`?e.config.build.override:{},e.config.build.variant===`tsup`?(0,i.omit)(e.config.build,[`override`,`variant`]):{},{name:e.config.name,assets:e.config.output.assets,resolveExtensions:e.config.build.extensions,outputPath:e.config.output.buildPath,projectRoot:e.config.projectRoot,tsconfig:e.tsconfig.tsconfigFilePath,dts:{compilerOptions:e.tsconfig.tsconfigJson.compilerOptions},format:e.config.output.format,mode:e.config.mode,treeshake:e.config.build.variant===`tsup`?e.config.build?.treeshake:e.config.build.variant===`tsup`?e.config.build?.treeShaking:void 0,minify:e.config.mode!==`development`,metafile:e.config.mode===`development`,sourcemap:e.config.mode===`development`,silent:e.config.logLevel===null||e.config.mode===`production`,verbose:e.config.logLevel===null||e.config.logLevel===`trace`||e.config.mode===`development`,workspaceConfig:{workspaceRoot:e.workspaceConfig.workspaceRoot}},a)}exports.extractTsupConfig=s,exports.resolveTsupEntry=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolveESBuildEntry as e}from"./esbuild.mjs";import t from"defu";import{DEFAULT_BUILD_OPTIONS as n}from"@storm-software/tsup/constants";import{omit as r}from"@stryke/helpers/omit";const i={...n,platform:`neutral`,target:`esnext`,config:!1,minify:!0,sourcemap:!1,cjsInterop:!0,bundle:!0,dts:!0,shims:!0,silent:!0,treeshake:!0,keepNames:!0,splitting:!0,banner:{}};function a(t,n){return e(t,n)}function o(e){return t({esbuildOptions:(t,n)=>{e.config.build.variant===`tsup`&&(e.config.build.esbuildOptions?e.config.build.esbuildOptions?.(t,n):e.config.build.override.esbuildOptions&&e.config.build.override.esbuildOptions?.(t,n)),t.alias={...e.builtins.reduce((t,n)=>{let r=e.fs.ids[n];return r&&(t[n]=r),t},{}),...t.alias}},noExternal:e.builtins},e.config.build.variant===`tsup`?e.config.build.override:{},e.config.build.variant===`tsup`?r(e.config.build,[`override`,`variant`]):{},{name:e.config.name,assets:e.config.output.assets,resolveExtensions:e.config.build.extensions,outputPath:e.config.output.buildPath,projectRoot:e.config.projectRoot,tsconfig:e.tsconfig.tsconfigFilePath,dts:{compilerOptions:e.tsconfig.tsconfigJson.compilerOptions},format:e.config.output.format,mode:e.config.mode,treeshake:e.config.build.variant===`tsup`?e.config.build?.treeshake:e.config.build.variant===`tsup`?e.config.build?.treeShaking:void 0,minify:e.config.mode!==`development`,metafile:e.config.mode===`development`,sourcemap:e.config.mode===`development`,silent:e.config.logLevel===null||e.config.mode===`production`,verbose:e.config.logLevel===null||e.config.logLevel===`trace`||e.config.mode===`development`,workspaceConfig:{workspaceRoot:e.workspaceConfig.workspaceRoot}},i)}export{o as extractTsupConfig,a as resolveTsupEntry};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/path/append`),n=require(`defu`);n=e.__toESM(n);let r=require(`@stryke/path/join-paths`),i=require(`@stryke/path/replace`),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,i.replacePath)(p,e))?(0,i.replacePath)(p,e):(0,s.existsSync)((0,r.joinPaths)((0,t.appendPath)(e,c),(0,i.replacePath)(p,e)))?(0,r.joinPaths)((0,t.appendPath)(e,c),(0,i.replacePath)(p,e)):(0,s.existsSync)((0,r.joinPaths)((0,t.appendPath)(e,c),p))?(0,r.joinPaths)((0,t.appendPath)(e,c),p):void 0),g||=(0,s.existsSync)((0,r.joinPaths)((0,t.appendPath)(e,c),`${m}.${f}.config.ts`))?(0,r.joinPaths)((0,t.appendPath)(e,c),`${m}.${f}.config.ts`):(0,s.existsSync)((0,r.joinPaths)((0,t.appendPath)(e,c),`${m}.${f}.config.js`))?(0,r.joinPaths)((0,t.appendPath)(e,c),`${m}.${f}.config.js`):(0,s.existsSync)((0,r.joinPaths)((0,t.appendPath)(e,c),`${m}.${f}.config.mts`))?(0,r.joinPaths)((0,t.appendPath)(e,c),`${m}.${f}.config.mts`):(0,s.existsSync)((0,r.joinPaths)((0,t.appendPath)(e,c),`${m}.${f}.config.mjs`))?(0,r.joinPaths)((0,t.appendPath)(e,c),`${m}.${f}.config.mjs`):(0,s.existsSync)((0,r.joinPaths)((0,t.appendPath)(e,c),`${m}.config.ts`))?(0,r.joinPaths)((0,t.appendPath)(e,c),`${m}.config.ts`):(0,s.existsSync)((0,r.joinPaths)((0,t.appendPath)(e,c),`${m}.config.js`))?(0,r.joinPaths)((0,t.appendPath)(e,c),`${m}.config.js`):(0,s.existsSync)((0,r.joinPaths)((0,t.appendPath)(e,c),`${m}.config.mts`))?(0,r.joinPaths)((0,t.appendPath)(e,c),`${m}.config.mts`):(0,s.existsSync)((0,r.joinPaths)((0,t.appendPath)(e,c),`${m}.config.mjs`))?(0,r.joinPaths)((0,t.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{appendPath as e}from"@stryke/path/append";import t from"defu";import{joinPaths as n}from"@stryke/path/join-paths";import{replacePath as r}from"@stryke/path/replace";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(r(p,s))?r(p,s):o(n(e(s,l),r(p,s)))?n(e(s,l),r(p,s)):o(n(e(s,l),p))?n(e(s,l),p):void 0),g||=o(n(e(s,l),`${m}.${f}.config.ts`))?n(e(s,l),`${m}.${f}.config.ts`):o(n(e(s,l),`${m}.${f}.config.js`))?n(e(s,l),`${m}.${f}.config.js`):o(n(e(s,l),`${m}.${f}.config.mts`))?n(e(s,l),`${m}.${f}.config.mts`):o(n(e(s,l),`${m}.${f}.config.mjs`))?n(e(s,l),`${m}.${f}.config.mjs`):o(n(e(s,l),`${m}.config.ts`))?n(e(s,l),`${m}.config.ts`):o(n(e(s,l),`${m}.config.js`))?n(e(s,l),`${m}.config.js`):o(n(e(s,l),`${m}.config.mts`))?n(e(s,l),`${m}.config.mts`):o(n(e(s,l),`${m}.config.mjs`))?n(e(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(`@stryke/path/append`),p=require(`defu`);p=e.__toESM(p);let m=require(`@stryke/helpers/omit`),h=require(`@stryke/path/replace`),g=require(`@stryke/type-checks/is-string`),_=require(`@stryke/convert/to-array`),v=require(`@stryke/hash/murmurhash`),y=require(`@stryke/helpers/get-unique`),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,_.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,v.murmurhash)({workspaceRoot:this.workspaceConfig?.workspaceRoot,projectRoot:this.config?.projectRoot},{maxLength:u.PROJECT_ROOT_HASH_LENGTH}),configHash:(0,v.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,v.murmurhash)({checksum:this.#n,config:this.meta.configHash},{maxLength:u.CACHE_HASH_LENGTH}))}get dtsPath(){return this.config.output.dts?(0,f.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,v.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,v.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,f.appendPath)(t,this.entryPath),e,(0,p.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,f.appendPath)(t,this.builtinsPath),e,(0,p.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,g.isString)(e)?e:T.StormJSON.stringify(e))}error(e){this.log(d.LogLevelLabel.ERROR,(0,g.isString)(e)?e:T.StormJSON.stringify(e))}warn(e){this.log(d.LogLevelLabel.WARN,(0,g.isString)(e)?e:T.StormJSON.stringify(e))}info(e){this.log(d.LogLevelLabel.INFO,(0,g.isString)(e)?e:T.StormJSON.stringify(e))}debug(e){this.log(d.LogLevelLabel.DEBUG,(0,g.isString)(e)?e:T.StormJSON.stringify(e))}trace(e){this.log(d.LogLevelLabel.TRACE,(0,g.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,p.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,f.appendPath)(`src`,c.projectRoot),output:(0,p.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,y.getUnique)(this.config.userConfig.build.external)),this.config.userConfig.build?.noExternal&&(this.config.userConfig.build.noExternal=(0,y.getUnique)(this.config.userConfig.build.noExternal)),this.config.build.external&&(this.config.build.external=(0,y.getUnique)(this.config.build.external)),this.config.build.noExternal&&(this.config.build.noExternal=(0,y.getUnique)(this.config.build.noExternal)),this.config.output.format=(0,y.getUnique)((0,_.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,y.getUnique)(this.config.output.assets.map(e=>({glob:(0,C.isSetObject)(e)?e.glob:e,input:(0,g.isString)(e)||!e.input||e.input===`.`||e.input===`/`||e.input===`./`?this.workspaceConfig.workspaceRoot:(0,f.appendPath)(e.input,this.workspaceConfig.workspaceRoot),output:(0,f.appendPath)((0,C.isSetObject)(e)&&e.output?(0,M.joinPaths)(this.config.output.outputPath,(0,h.replacePath)(e.output,this.config.output.outputPath)):this.config.output.outputPath,this.workspaceConfig.workspaceRoot),ignore:(0,C.isSetObject)(e)&&e.ignore?(0,_.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,p.default)({entry:Array.isArray(e.entry)&&e.entry.length>0?e.entry:Array.isArray(t?.entry)&&t.entry.length>0?t.entry:[]},(0,m.omit)(e??{},[`entry`]),(0,m.omit)(t??{},[`entry`])),this.config.userConfig.output?.format&&(this.config.userConfig.output.format=(0,y.getUnique)((0,_.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{appendPath as _}from"@stryke/path/append";import v from"defu";import{omit as y}from"@stryke/helpers/omit";import{replacePath as b}from"@stryke/path/replace";import{isString as x}from"@stryke/type-checks/is-string";import{toArray as S}from"@stryke/convert/to-array";import{murmurhash as C}from"@stryke/hash/murmurhash";import{getUnique as w}from"@stryke/helpers/get-unique";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,S(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:C({workspaceRoot:this.workspaceConfig?.workspaceRoot,projectRoot:this.config?.projectRoot},{maxLength:m}),configHash:C(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`,C({checksum:this.#n,config:this.meta.configHash},{maxLength:p}))}get dtsPath(){return this.config.output.dts?_(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=C({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=C({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:_(t,this.entryPath),e,v(n,{type:`entry`}))}async emitBuiltin(e,t,n,r={}){return this.fs.write(n?I(n)?n:L(this.builtinsPath,n):_(t,this.builtinsPath),e,v(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,x(e)?e:A.stringify(e))}error(e){this.log(g.ERROR,x(e)?e:A.stringify(e))}warn(e){this.log(g.WARN,x(e)?e:A.stringify(e))}info(e){this.log(g.INFO,x(e)?e:A.stringify(e))}debug(e){this.log(g.DEBUG,x(e)?e:A.stringify(e))}trace(e){this.log(g.TRACE,x(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=v({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||_(`src`,o.projectRoot),output:v(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=w(this.config.userConfig.build.external)),this.config.userConfig.build?.noExternal&&(this.config.userConfig.build.noExternal=w(this.config.userConfig.build.noExternal)),this.config.build.external&&(this.config.build.external=w(this.config.build.external)),this.config.build.noExternal&&(this.config.build.noExternal=w(this.config.build.noExternal)),this.config.output.format=w(S(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=w(this.config.output.assets.map(e=>({glob:O(e)?e.glob:e,input:x(e)||!e.input||e.input===`.`||e.input===`/`||e.input===`./`?this.workspaceConfig.workspaceRoot:_(e.input,this.workspaceConfig.workspaceRoot),output:_(O(e)&&e.output?L(this.config.output.outputPath,b(e.output,this.config.output.outputPath)):this.config.output.outputPath,this.workspaceConfig.workspaceRoot),ignore:O(e)&&e.ignore?S(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=v({entry:Array.isArray(e.entry)&&e.entry.length>0?e.entry:Array.isArray(t?.entry)&&t.entry.length>0?t.entry:[]},y(e??{},[`entry`]),y(t??{},[`entry`])),this.config.userConfig.output?.format&&(this.config.userConfig.output.format=w(S(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/append`),r=require(`@stryke/path/join-paths`),i=require(`@stryke/path/replace`),a=require(`@stryke/type-checks/is-string`),o=require(`@stryke/convert/parse-type-definition`),s=require(`@stryke/convert/to-array`),c=require(`@stryke/fs/is-file`),l=require(`@stryke/fs/list-files`),u=require(`@stryke/hash/murmurhash`),d=require(`@stryke/helpers/get-unique`),f=require(`@stryke/type-checks/is-set-string`);function p(e,t){return(0,i.replacePath)(t.file,(0,r.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,i.replaceExtension)((0,i.replacePath)((0,i.replacePath)((0,i.replacePath)((0,i.replacePath)((0,i.replacePath)(t.file,(0,r.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.sourceRoot)),(0,r.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot)),e.config.sourceRoot),e.config.projectRoot),(0,i.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,r){return r.map(n=>(0,a.isString)(n)?t.replacePathTokens(e,n):t.replacePathTokens(e,n.file)).map(t=>{let r=(0,o.parseTypeDefinition)(t),a=(0,n.appendPath)(r.file,e.config.projectRoot);return(0,c.isFile)(a)?g(e,{file:(0,i.replacePath)(a,e.config.projectRoot),name:r.name}):(0,l.listFilesSync)(a).map(t=>g(e,{file:t,name:r.name}))}).flat().filter(Boolean)}function v(e=[]){return(0,d.getUniqueBy)((0,s.toArray)(e),e=>(0,f.isSetString)(e)?e:(0,u.murmurhash)(e??{},{maxLength:24}))}exports.getUniqueEntries=v,exports.resolveEntriesSync=_,exports.resolveEntryInputFile=p,exports.resolveEntryOutput=h;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{replacePathTokens as e}from"../plugin-utils/paths.mjs";import{appendPath as t}from"@stryke/path/append";import{joinPaths as n}from"@stryke/path/join-paths";import{replaceExtension as r,replacePath as i}from"@stryke/path/replace";import{isString as a}from"@stryke/type-checks/is-string";import{parseTypeDefinition as o}from"@stryke/convert/parse-type-definition";import{toArray as s}from"@stryke/convert/to-array";import{isFile as c}from"@stryke/fs/is-file";import{listFiles as l,listFilesSync as u}from"@stryke/fs/list-files";import{murmurhash as d}from"@stryke/hash/murmurhash";import{getUniqueBy as f}from"@stryke/helpers/get-unique";import{isSetString as p}from"@stryke/type-checks/is-set-string";function m(e,t){return i(t.file,n(e.workspaceConfig.workspaceRoot,e.config.projectRoot))}function h(e,t){return{file:m(e,t),name:t.name}}function g(e,t){return r(i(i(i(i(i(t.file,n(e.workspaceConfig.workspaceRoot,e.config.sourceRoot)),n(e.workspaceConfig.workspaceRoot,e.config.projectRoot)),e.config.sourceRoot),e.config.projectRoot),i(e.config.sourceRoot,e.config.projectRoot)))}function _(e,t){let n=h(e,t);return{...n,input:n,output:g(e,t)}}function v(n,r){return r.map(t=>a(t)?e(n,t):e(n,t.file)).map(e=>{let r=o(e),a=t(r.file,n.config.projectRoot);return c(a)?_(n,{file:i(a,n.config.projectRoot),name:r.name}):u(a).map(e=>_(n,{file:e,name:r.name}))}).flat().filter(Boolean)}function y(e=[]){return f(s(e),e=>p(e)?e:d(e??{},{maxLength:24}))}export{y as getUniqueEntries,v as resolveEntriesSync,m as resolveEntryInputFile,g as resolveEntryOutput};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/convert/to-array`),n=require(`@stryke/helpers/get-unique`),r=require(`@stryke/type-checks/is-set-string`),i=require(`@stryke/type-checks/is-error`),a=require(`@stryke/type-checks/is-set-object`),o=require(`@stryke/path/file-path-fns`),s=require(`@stryke/path/is-type`),c=require(`@stryke/path/join`),l=require(`@stryke/path/correct-path`),u=require(`@stryke/path/slash`);function d(e){return(0,i.isError)(e)&&`code`in e&&e.code}function f(e){return d(e)&&(e.code===`ENOENT`||e.code===`EISDIR`?null:e)}function p(e){return(0,l.correctPath)((0,u.slash)(e?.toString()||`.`).replace(/^file:\/\//,``))}function m(e,t=`powerlines`){return e.replace(/^\\0/,``).startsWith(`${t.replace(/:$/,``)}`)}function h(e,t=`powerlines`){return`${t.replace(/:$/,``)}:${p(e).replace(RegExp(`^${t.replace(/:$/,``)}:`),``).replace(/^\\0/,``).replace((0,o.findFileDotExtensionSafe)(p(e)),``)}`}function g(e,t,n=`powerlines`){return(0,s.isAbsolutePath)(e)?e:m(p(e),n)?h(p(e),n).replace(RegExp(`^${n.replace(/:$/,``)}:`),t):p(e)}function _(e,i){return(0,n.getUnique)((0,t.toArray)(i).map(t=>(0,a.isSetObject)(t)&&((0,r.isSetString)(t.input)||(0,r.isSetString)(t.glob))?(0,c.joinPaths)(t.input||e,t.glob||`**/*`):(0,r.isSetString)(t)?t:void 0).filter(r.isSetString))}exports.ignoreNotfound=f,exports.normalizeGlobPatterns=_,exports.normalizeId=h,exports.normalizePath=g;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{toArray as e}from"@stryke/convert/to-array";import{getUnique as t}from"@stryke/helpers/get-unique";import{isSetString as n}from"@stryke/type-checks/is-set-string";import{isError as r}from"@stryke/type-checks/is-error";import{isSetObject as i}from"@stryke/type-checks/is-set-object";import{findFileDotExtensionSafe as a}from"@stryke/path/file-path-fns";import{isAbsolutePath as o}from"@stryke/path/is-type";import{joinPaths as s}from"@stryke/path/join";import{correctPath as c}from"@stryke/path/correct-path";import{slash as l}from"@stryke/path/slash";function u(e){return r(e)&&`code`in e&&e.code}function d(e){return u(e)&&(e.code===`ENOENT`||e.code===`EISDIR`?null:e)}function f(e){return c(l(e?.toString()||`.`).replace(/^file:\/\//,``))}function p(e,t=`powerlines`){return e.replace(/^\\0/,``).startsWith(`${t.replace(/:$/,``)}`)}function m(e,t=`powerlines`){return`${t.replace(/:$/,``)}:${f(e).replace(RegExp(`^${t.replace(/:$/,``)}:`),``).replace(/^\\0/,``).replace(a(f(e)),``)}`}function h(e,t,n=`powerlines`){return o(e)?e:p(f(e),n)?m(f(e),n).replace(RegExp(`^${n.replace(/:$/,``)}:`),t):f(e)}function g(r,a){return t(e(a).map(e=>i(e)&&(n(e.input)||n(e.glob))?s(e.input||r,e.glob||`**/*`):n(e)?e:void 0).filter(n))}export{d as ignoreNotfound,g as normalizeGlobPatterns,m as normalizeId,h as normalizePath};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/path/append`),n=require(`@stryke/path/join`),r=require(`@stryke/path/correct-path`),i=require(`node:path`);var a=class{#e=!1;options;constructor(e={base:`/`}){this.options=e,this.options.base=(0,i.resolve)(e.base),this.options.isReadOnly=!!e.isReadOnly}async exists(e){return this.existsSync(e)}async get(e){return this.getSync(e)}async set(e,t){this.options.isReadOnly||this.setSync(e,t)}mkdirSync(e){}async mkdir(e){return Promise.resolve(this.mkdirSync(e))}async remove(e){this.options.isReadOnly||this.removeSync(e)}clearSync(e){if(!this.options.isReadOnly){let t=this.listSync(e||this.options.base);if(!t.length)return;t.map(t=>this.removeSync(e&&!t.startsWith(e)?(0,n.joinPaths)(e,t):t))}}async clear(e){if(!this.options.isReadOnly){let t=await this.list(e||this.options.base);if(!t.length)return;await Promise.all(t.map(async t=>this.remove(e&&!t.startsWith(e)?(0,n.joinPaths)(e,t):t)))}}async list(e){return this.listSync(e)}isDirectorySync(e){return!1}async isDirectory(e){return Promise.resolve(this.isDirectorySync(e))}isFileSync(e){return this.existsSync(e)&&!this.isDirectorySync(e)}async isFile(e){return Promise.resolve(this.isFileSync(e))}dispose(){return Promise.resolve()}async[Symbol.asyncDispose](){return this._dispose()}resolve(e=this.options.base){if(/\.\.:|\.\.$/.test(e))throw Error(`[${this.name}]: Invalid key: ${JSON.stringify(e)} provided to storage adapter.`);return(0,t.appendPath)((0,r.correctPath)(e).replace(/:/g,`/`),this.options.base)}async _dispose(){this.#e||=(await Promise.resolve(this.dispose()),!0)}};exports.BaseStorageAdapter=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{appendPath as e}from"@stryke/path/append";import{joinPaths as t}from"@stryke/path/join";import{correctPath as n}from"@stryke/path/correct-path";import{resolve as r}from"node:path";var i=class{#e=!1;options;constructor(e={base:`/`}){this.options=e,this.options.base=r(e.base),this.options.isReadOnly=!!e.isReadOnly}async exists(e){return this.existsSync(e)}async get(e){return this.getSync(e)}async set(e,t){this.options.isReadOnly||this.setSync(e,t)}mkdirSync(e){}async mkdir(e){return Promise.resolve(this.mkdirSync(e))}async remove(e){this.options.isReadOnly||this.removeSync(e)}clearSync(e){if(!this.options.isReadOnly){let n=this.listSync(e||this.options.base);if(!n.length)return;n.map(n=>this.removeSync(e&&!n.startsWith(e)?t(e,n):n))}}async clear(e){if(!this.options.isReadOnly){let n=await this.list(e||this.options.base);if(!n.length)return;await Promise.all(n.map(async n=>this.remove(e&&!n.startsWith(e)?t(e,n):n)))}}async list(e){return this.listSync(e)}isDirectorySync(e){return!1}async isDirectory(e){return Promise.resolve(this.isDirectorySync(e))}isFileSync(e){return this.existsSync(e)&&!this.isDirectorySync(e)}async isFile(e){return Promise.resolve(this.isFileSync(e))}dispose(){return Promise.resolve()}async[Symbol.asyncDispose](){return this._dispose()}resolve(t=this.options.base){if(/\.\.:|\.\.$/.test(t))throw Error(`[${this.name}]: Invalid key: ${JSON.stringify(t)} provided to storage adapter.`);return e(n(t).replace(/:/g,`/`),this.options.base)}async _dispose(){this.#e||=(await Promise.resolve(this.dispose()),!0)}};export{i as BaseStorageAdapter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../../../_virtual/rolldown_runtime.cjs`),t=require(`../helpers.cjs`),n=require(`./base.cjs`);let r=require(`@stryke/fs/is-file`),i=require(`@stryke/fs/list-files`),a=require(`@stryke/fs/helpers`),o=require(`@stryke/fs/exists`),s=require(`@stryke/fs/read-file`),c=require(`@stryke/fs/write-file`),l=require(`node:fs`),u=require(`node:fs/promises`);var d=class extends n.BaseStorageAdapter{name=`file-system`;constructor(e){super(e)}existsSync(e){return(0,o.existsSync)(this.resolve(e))}async exists(e){return(0,o.exists)(this.resolve(e))}getSync(e){return(0,s.readFileSync)(this.resolve(e))}async get(e){return(0,s.readFile)(this.resolve(e))}setSync(e,t){if(!this.options.isReadOnly)return(0,c.writeFileSync)(this.resolve(e),t)}async set(e,t){if(!this.options.isReadOnly)return(0,c.writeFile)(this.resolve(e),t)}removeSync(e){if(!this.options.isReadOnly)try{return(0,l.unlinkSync)(this.resolve(e))}catch(e){return t.ignoreNotfound(e)}}async remove(e){if(!this.options.isReadOnly)return(0,u.unlink)(this.resolve(e)).catch(t.ignoreNotfound)}mkdirSync(e){(0,a.createDirectorySync)(this.resolve(e))}async mkdir(e){await(0,a.createDirectory)(this.resolve(e))}listSync(e){try{return(0,i.listFilesSync)(this.resolve(e),{ignore:this.options.ignore})}catch(e){return t.ignoreNotfound(e)??[]}}async list(e){return(0,i.listFiles)(this.resolve(e),{ignore:this.options.ignore}).catch(t.ignoreNotfound).then(e=>e||[])}isDirectorySync(e){return(0,r.isDirectory)(this.resolve(e))}isFileSync(e){return!(0,r.isFile)(this.resolve(e))}};exports.FileSystemStorageAdapter=d;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ignoreNotfound as e}from"../helpers.mjs";import{BaseStorageAdapter as t}from"./base.mjs";import{isDirectory as n,isFile as r}from"@stryke/fs/is-file";import{listFiles as i,listFilesSync as a}from"@stryke/fs/list-files";import{createDirectory as o,createDirectorySync as s}from"@stryke/fs/helpers";import{exists as c,existsSync as l}from"@stryke/fs/exists";import{readFile as u,readFileSync as d}from"@stryke/fs/read-file";import{writeFile as f,writeFileSync as p}from"@stryke/fs/write-file";import{unlinkSync as m}from"node:fs";import{unlink as h}from"node:fs/promises";var g=class extends t{name=`file-system`;constructor(e){super(e)}existsSync(e){return l(this.resolve(e))}async exists(e){return c(this.resolve(e))}getSync(e){return d(this.resolve(e))}async get(e){return u(this.resolve(e))}setSync(e,t){if(!this.options.isReadOnly)return p(this.resolve(e),t)}async set(e,t){if(!this.options.isReadOnly)return f(this.resolve(e),t)}removeSync(t){if(!this.options.isReadOnly)try{return m(this.resolve(t))}catch(t){return e(t)}}async remove(t){if(!this.options.isReadOnly)return h(this.resolve(t)).catch(e)}mkdirSync(e){s(this.resolve(e))}async mkdir(e){await o(this.resolve(e))}listSync(t){try{return a(this.resolve(t),{ignore:this.options.ignore})}catch(t){return e(t)??[]}}async list(t){return i(this.resolve(t),{ignore:this.options.ignore}).catch(e).then(e=>e||[])}isDirectorySync(e){return n(this.resolve(e))}isFileSync(e){return!r(this.resolve(e))}};export{g as FileSystemStorageAdapter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../../../_virtual/rolldown_runtime.cjs`),t=require(`./base.cjs`);let n=require(`@stryke/path/is-parent-path`);var r=class extends t.BaseStorageAdapter{name=`virtual`;data=new Map;constructor(e){super(e)}existsSync(e){return this.data.has(this.resolve(e))}getSync(e){return this.data.get(this.resolve(e))??null}setSync(e,t){this.options.isReadOnly||this.data.set(this.resolve(e),t)}removeSync(e){this.options.isReadOnly||this.data.delete(this.resolve(e))}listSync(e){return[...this.data.keys().filter(t=>e?(0,n.isParentPath)(t,this.resolve(e)):!0)]}async dispose(){return this.clear()}};exports.VirtualStorageAdapter=r;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{BaseStorageAdapter as e}from"./base.mjs";import{isParentPath as t}from"@stryke/path/is-parent-path";var n=class extends e{name=`virtual`;data=new Map;constructor(e){super(e)}existsSync(e){return this.data.has(this.resolve(e))}getSync(e){return this.data.get(this.resolve(e))??null}setSync(e,t){this.options.isReadOnly||this.data.set(this.resolve(e),t)}removeSync(e){this.options.isReadOnly||this.data.delete(this.resolve(e))}listSync(e){return[...this.data.keys().filter(n=>e?t(n,this.resolve(e)):!0)]}async dispose(){return this.clear()}};export{n as VirtualStorageAdapter};
|