@powerlines/plugin-nodejs 0.1.4 → 0.1.5
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/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/plugin-alloy/src/index.cjs +12 -5
- package/dist/plugin-alloy/src/index.mjs +12 -5
- package/dist/plugin-alloy/src/types/components.d.cts +1 -3
- package/dist/plugin-alloy/src/types/components.d.mts +1 -3
- package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +16 -10
- package/dist/plugin-alloy/src/typescript/components/typescript-file.d.cts +1 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.d.mts +1 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +16 -10
- package/dist/powerlines/src/internal/helpers/hooks.d.cts +47 -0
- package/dist/powerlines/src/internal/helpers/hooks.d.mts +49 -0
- package/dist/powerlines/src/types/api.d.cts +104 -0
- package/dist/powerlines/src/types/api.d.mts +104 -0
- package/dist/powerlines/src/types/build.d.cts +43 -3
- package/dist/powerlines/src/types/build.d.mts +42 -4
- package/dist/powerlines/src/types/config.d.cts +60 -4
- package/dist/powerlines/src/types/config.d.mts +60 -4
- package/dist/powerlines/src/types/context.d.cts +113 -1
- package/dist/powerlines/src/types/context.d.mts +113 -3
- package/dist/powerlines/src/types/hooks.d.cts +32 -0
- package/dist/powerlines/src/types/hooks.d.mts +32 -2
- package/dist/powerlines/src/types/plugin.d.cts +35 -61
- package/dist/powerlines/src/types/plugin.d.mts +35 -61
- package/dist/powerlines/src/types/resolved.d.cts +16 -4
- package/dist/powerlines/src/types/resolved.d.mts +16 -5
- package/dist/powerlines/src/types/unplugin.d.cts +22 -0
- package/dist/powerlines/src/types/unplugin.d.mts +23 -0
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -14,7 +14,7 @@ let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
|
14
14
|
const plugin = (options = {}) => {
|
|
15
15
|
return [
|
|
16
16
|
require_index.default(options.babel),
|
|
17
|
-
|
|
17
|
+
require_index$1.default(options.env),
|
|
18
18
|
{
|
|
19
19
|
name: "nodejs",
|
|
20
20
|
configResolved() {
|
package/dist/index.mjs
CHANGED
|
@@ -23,11 +23,18 @@ const plugin = (options = {}) => {
|
|
|
23
23
|
...options
|
|
24
24
|
},
|
|
25
25
|
build: {
|
|
26
|
-
inputOptions: { transform: {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
inputOptions: { transform: {
|
|
27
|
+
typescript: {
|
|
28
|
+
jsxPragma: "Alloy.createElement",
|
|
29
|
+
jsxPragmaFrag: "Alloy.Fragment"
|
|
30
|
+
},
|
|
31
|
+
jsx: {
|
|
32
|
+
runtime: "classic",
|
|
33
|
+
pragma: "Alloy.createElement",
|
|
34
|
+
pragmaFrag: "Alloy.Fragment",
|
|
35
|
+
importSource: "@alloy-js/core"
|
|
36
|
+
}
|
|
37
|
+
} },
|
|
31
38
|
plugins: [(0, __alloy_js_rollup_plugin.default)()],
|
|
32
39
|
external: [
|
|
33
40
|
"@alloy-js/core",
|
|
@@ -21,11 +21,18 @@ const plugin = (options = {}) => {
|
|
|
21
21
|
...options
|
|
22
22
|
},
|
|
23
23
|
build: {
|
|
24
|
-
inputOptions: { transform: {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
inputOptions: { transform: {
|
|
25
|
+
typescript: {
|
|
26
|
+
jsxPragma: "Alloy.createElement",
|
|
27
|
+
jsxPragmaFrag: "Alloy.Fragment"
|
|
28
|
+
},
|
|
29
|
+
jsx: {
|
|
30
|
+
runtime: "classic",
|
|
31
|
+
pragma: "Alloy.createElement",
|
|
32
|
+
pragmaFrag: "Alloy.Fragment",
|
|
33
|
+
importSource: "@alloy-js/core"
|
|
34
|
+
}
|
|
35
|
+
} },
|
|
29
36
|
plugins: [alloy()],
|
|
30
37
|
external: [
|
|
31
38
|
"@alloy-js/core",
|
|
@@ -15,8 +15,6 @@ interface TypescriptFileImportItem {
|
|
|
15
15
|
alias?: string;
|
|
16
16
|
type?: boolean;
|
|
17
17
|
}
|
|
18
|
-
type TypescriptFileImports = Record<string, null | Array<TypescriptFileImportItem | string
|
|
19
|
-
$builtins?: Record<string, null | Array<TypescriptFileImportItem | string>>;
|
|
20
|
-
};
|
|
18
|
+
type TypescriptFileImports = Record<string, null | Array<TypescriptFileImportItem | string>>;
|
|
21
19
|
//#endregion
|
|
22
20
|
export { ComponentProps, TypescriptFileImportItem, TypescriptFileImports };
|
|
@@ -16,8 +16,6 @@ interface TypescriptFileImportItem {
|
|
|
16
16
|
alias?: string;
|
|
17
17
|
type?: boolean;
|
|
18
18
|
}
|
|
19
|
-
type TypescriptFileImports = Record<string, null | Array<TypescriptFileImportItem | string
|
|
20
|
-
$builtins?: Record<string, null | Array<TypescriptFileImportItem | string>>;
|
|
21
|
-
};
|
|
19
|
+
type TypescriptFileImports = Record<string, null | Array<TypescriptFileImportItem | string>>;
|
|
22
20
|
//#endregion
|
|
23
21
|
export { ComponentProps, TypescriptFileImportItem, TypescriptFileImports };
|
|
@@ -152,13 +152,13 @@ function TypescriptFileHeader(props) {
|
|
|
152
152
|
* @returns The rendered source file header.
|
|
153
153
|
*/
|
|
154
154
|
function TypescriptFileHeaderImports(props) {
|
|
155
|
-
const { imports } = props;
|
|
155
|
+
const { imports, builtinImports } = props;
|
|
156
156
|
const context = require_context.usePowerlines();
|
|
157
157
|
const sourceFile = (0, __alloy_js_typescript.useSourceFile)();
|
|
158
158
|
const scope = props.scope ?? sourceFile.scope;
|
|
159
159
|
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
160
160
|
get when() {
|
|
161
|
-
return scope.importedModules.size > 0 || !!imports && Object.keys(imports).length > 0;
|
|
161
|
+
return scope.importedModules.size > 0 || !!builtinImports && Object.keys(builtinImports).length > 0 || !!imports && Object.keys(imports).length > 0;
|
|
162
162
|
},
|
|
163
163
|
get children() {
|
|
164
164
|
return [
|
|
@@ -171,19 +171,25 @@ function TypescriptFileHeaderImports(props) {
|
|
|
171
171
|
get each() {
|
|
172
172
|
return Object.entries(imports ?? {});
|
|
173
173
|
},
|
|
174
|
-
children: ([module$1,
|
|
175
|
-
if (module$1 === "$builtins") return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
|
|
176
|
-
get each() {
|
|
177
|
-
return Object.entries(imported ?? {});
|
|
178
|
-
},
|
|
179
|
-
children: ([builtinModule, builtinImports]) => __alloy_js_core.code`import ${builtinImports === null ? "" : ` from ${builtinImports.filter((i) => !(0, __stryke_type_checks_is_string.isString)(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (builtinImports.filter((i) => !(0, __stryke_type_checks_is_string.isString)(i) && i.default).length > 0 && builtinImports.filter((i) => (0, __stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? ", " : "") + (builtinImports.filter((i) => (0, __stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? `{ ${builtinImports.map((i) => (0, __stryke_type_checks_is_string.isString)(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")} `} "${builtinModule.includes(":") ? builtinModule : `${context.config.output.builtinPrefix}:${builtinModule}`}";`
|
|
180
|
-
});
|
|
181
|
-
const normalImports = imported;
|
|
174
|
+
children: ([module$1, normalImports]) => {
|
|
182
175
|
return __alloy_js_core.code`import ${normalImports === null ? "" : ` from ${normalImports.filter((i) => !(0, __stryke_type_checks_is_string.isString)(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (normalImports.filter((i) => !(0, __stryke_type_checks_is_string.isString)(i) && i.default).length > 0 && normalImports.filter((i) => (0, __stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? ", " : "") + (normalImports.filter((i) => (0, __stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? `{ ${normalImports.map((i) => (0, __stryke_type_checks_is_string.isString)(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")} `} "${module$1}";`;
|
|
183
176
|
}
|
|
184
177
|
});
|
|
185
178
|
}
|
|
186
179
|
}),
|
|
180
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
181
|
+
get when() {
|
|
182
|
+
return builtinImports && Object.keys(builtinImports).length > 0;
|
|
183
|
+
},
|
|
184
|
+
get children() {
|
|
185
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
|
|
186
|
+
get each() {
|
|
187
|
+
return Object.entries(builtinImports ?? {});
|
|
188
|
+
},
|
|
189
|
+
children: ([builtinModule, builtinImports$1]) => __alloy_js_core.code`import ${builtinImports$1 === null ? "" : ` from ${builtinImports$1.filter((i) => !(0, __stryke_type_checks_is_string.isString)(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (builtinImports$1.filter((i) => !(0, __stryke_type_checks_is_string.isString)(i) && i.default).length > 0 && builtinImports$1.filter((i) => (0, __stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? ", " : "") + (builtinImports$1.filter((i) => (0, __stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? `{ ${builtinImports$1.map((i) => (0, __stryke_type_checks_is_string.isString)(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")} `} "${builtinModule.includes(":") ? builtinModule : `${context.config.output.builtinPrefix}:${builtinModule}`}";`
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}),
|
|
187
193
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
188
194
|
get when() {
|
|
189
195
|
return scope.importedModules.size > 0;
|
|
@@ -151,13 +151,13 @@ function TypescriptFileHeader(props) {
|
|
|
151
151
|
* @returns The rendered source file header.
|
|
152
152
|
*/
|
|
153
153
|
function TypescriptFileHeaderImports(props) {
|
|
154
|
-
const { imports } = props;
|
|
154
|
+
const { imports, builtinImports } = props;
|
|
155
155
|
const context = usePowerlines();
|
|
156
156
|
const sourceFile = useSourceFile();
|
|
157
157
|
const scope = props.scope ?? sourceFile.scope;
|
|
158
158
|
return createComponent(Show, {
|
|
159
159
|
get when() {
|
|
160
|
-
return scope.importedModules.size > 0 || !!imports && Object.keys(imports).length > 0;
|
|
160
|
+
return scope.importedModules.size > 0 || !!builtinImports && Object.keys(builtinImports).length > 0 || !!imports && Object.keys(imports).length > 0;
|
|
161
161
|
},
|
|
162
162
|
get children() {
|
|
163
163
|
return [
|
|
@@ -170,19 +170,25 @@ function TypescriptFileHeaderImports(props) {
|
|
|
170
170
|
get each() {
|
|
171
171
|
return Object.entries(imports ?? {});
|
|
172
172
|
},
|
|
173
|
-
children: ([module,
|
|
174
|
-
if (module === "$builtins") return createComponent(For, {
|
|
175
|
-
get each() {
|
|
176
|
-
return Object.entries(imported ?? {});
|
|
177
|
-
},
|
|
178
|
-
children: ([builtinModule, builtinImports]) => code`import ${builtinImports === null ? "" : ` from ${builtinImports.filter((i) => !isString(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (builtinImports.filter((i) => !isString(i) && i.default).length > 0 && builtinImports.filter((i) => isString(i) || !i.default).length > 0 ? ", " : "") + (builtinImports.filter((i) => isString(i) || !i.default).length > 0 ? `{ ${builtinImports.map((i) => isString(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")} `} "${builtinModule.includes(":") ? builtinModule : `${context.config.output.builtinPrefix}:${builtinModule}`}";`
|
|
179
|
-
});
|
|
180
|
-
const normalImports = imported;
|
|
173
|
+
children: ([module, normalImports]) => {
|
|
181
174
|
return code`import ${normalImports === null ? "" : ` from ${normalImports.filter((i) => !isString(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (normalImports.filter((i) => !isString(i) && i.default).length > 0 && normalImports.filter((i) => isString(i) || !i.default).length > 0 ? ", " : "") + (normalImports.filter((i) => isString(i) || !i.default).length > 0 ? `{ ${normalImports.map((i) => isString(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")} `} "${module}";`;
|
|
182
175
|
}
|
|
183
176
|
});
|
|
184
177
|
}
|
|
185
178
|
}),
|
|
179
|
+
createComponent(Show, {
|
|
180
|
+
get when() {
|
|
181
|
+
return builtinImports && Object.keys(builtinImports).length > 0;
|
|
182
|
+
},
|
|
183
|
+
get children() {
|
|
184
|
+
return createComponent(For, {
|
|
185
|
+
get each() {
|
|
186
|
+
return Object.entries(builtinImports ?? {});
|
|
187
|
+
},
|
|
188
|
+
children: ([builtinModule, builtinImports$1]) => code`import ${builtinImports$1 === null ? "" : ` from ${builtinImports$1.filter((i) => !isString(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (builtinImports$1.filter((i) => !isString(i) && i.default).length > 0 && builtinImports$1.filter((i) => isString(i) || !i.default).length > 0 ? ", " : "") + (builtinImports$1.filter((i) => isString(i) || !i.default).length > 0 ? `{ ${builtinImports$1.map((i) => isString(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")} `} "${builtinModule.includes(":") ? builtinModule : `${context.config.output.builtinPrefix}:${builtinModule}`}";`
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}),
|
|
186
192
|
createComponent(Show, {
|
|
187
193
|
get when() {
|
|
188
194
|
return scope.importedModules.size > 0;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SelectHooksOptions } from "../../types/context.cjs";
|
|
2
|
+
import { MaybePromise } from "@stryke/types/base";
|
|
3
|
+
|
|
4
|
+
//#region ../powerlines/src/internal/helpers/hooks.d.ts
|
|
5
|
+
type CallHookOptions = SelectHooksOptions & (({
|
|
6
|
+
/**
|
|
7
|
+
* Whether to call the hooks sequentially or in parallel.
|
|
8
|
+
*
|
|
9
|
+
* @defaultValue true
|
|
10
|
+
*/
|
|
11
|
+
sequential?: true;
|
|
12
|
+
} & ({
|
|
13
|
+
/**
|
|
14
|
+
* How to handle multiple return values from hooks.
|
|
15
|
+
* - "merge": Merge all non-undefined return values (if they are objects).
|
|
16
|
+
* - "first": Return the first non-undefined value.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* Merging only works if the return values are objects.
|
|
20
|
+
*
|
|
21
|
+
* @defaultValue "merge"
|
|
22
|
+
*/
|
|
23
|
+
result: "first";
|
|
24
|
+
} | {
|
|
25
|
+
/**
|
|
26
|
+
* How to handle multiple return values from hooks.
|
|
27
|
+
* - "merge": Merge all non-undefined return values (if they are objects).
|
|
28
|
+
* - "first": Return the first non-undefined value.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Merging only works if the return values are objects.
|
|
32
|
+
*
|
|
33
|
+
* @defaultValue "merge"
|
|
34
|
+
*/
|
|
35
|
+
result?: "merge" | "last";
|
|
36
|
+
/**
|
|
37
|
+
* An indicator specifying if the results of the previous hook should be provided as the **first** parameter of the next hook function, or a function to process the result of the previous hook function and pass the returned value as the next hook's **first** parameter
|
|
38
|
+
*/
|
|
39
|
+
asNextParam?: false | ((previousResult: any) => MaybePromise<any>);
|
|
40
|
+
})) | {
|
|
41
|
+
/**
|
|
42
|
+
* Whether to call the hooks sequentially or in parallel.
|
|
43
|
+
*/
|
|
44
|
+
sequential: false;
|
|
45
|
+
});
|
|
46
|
+
//#endregion
|
|
47
|
+
export { CallHookOptions };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import "../../types/hooks.mjs";
|
|
2
|
+
import { SelectHooksOptions } from "../../types/context.mjs";
|
|
3
|
+
import "../../types/resolved.mjs";
|
|
4
|
+
import { MaybePromise } from "@stryke/types/base";
|
|
5
|
+
|
|
6
|
+
//#region ../powerlines/src/internal/helpers/hooks.d.ts
|
|
7
|
+
type CallHookOptions = SelectHooksOptions & (({
|
|
8
|
+
/**
|
|
9
|
+
* Whether to call the hooks sequentially or in parallel.
|
|
10
|
+
*
|
|
11
|
+
* @defaultValue true
|
|
12
|
+
*/
|
|
13
|
+
sequential?: true;
|
|
14
|
+
} & ({
|
|
15
|
+
/**
|
|
16
|
+
* How to handle multiple return values from hooks.
|
|
17
|
+
* - "merge": Merge all non-undefined return values (if they are objects).
|
|
18
|
+
* - "first": Return the first non-undefined value.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Merging only works if the return values are objects.
|
|
22
|
+
*
|
|
23
|
+
* @defaultValue "merge"
|
|
24
|
+
*/
|
|
25
|
+
result: "first";
|
|
26
|
+
} | {
|
|
27
|
+
/**
|
|
28
|
+
* How to handle multiple return values from hooks.
|
|
29
|
+
* - "merge": Merge all non-undefined return values (if they are objects).
|
|
30
|
+
* - "first": Return the first non-undefined value.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Merging only works if the return values are objects.
|
|
34
|
+
*
|
|
35
|
+
* @defaultValue "merge"
|
|
36
|
+
*/
|
|
37
|
+
result?: "merge" | "last";
|
|
38
|
+
/**
|
|
39
|
+
* An indicator specifying if the results of the previous hook should be provided as the **first** parameter of the next hook function, or a function to process the result of the previous hook function and pass the returned value as the next hook's **first** parameter
|
|
40
|
+
*/
|
|
41
|
+
asNextParam?: false | ((previousResult: any) => MaybePromise<any>);
|
|
42
|
+
})) | {
|
|
43
|
+
/**
|
|
44
|
+
* Whether to call the hooks sequentially or in parallel.
|
|
45
|
+
*/
|
|
46
|
+
sequential: false;
|
|
47
|
+
});
|
|
48
|
+
//#endregion
|
|
49
|
+
export { CallHookOptions };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { CallHookOptions } from "../internal/helpers/hooks.cjs";
|
|
2
|
+
import { InferHookParameters, InferHookReturnType } from "./hooks.cjs";
|
|
3
|
+
import { APIContext, EnvironmentContext, PluginContext } from "./context.cjs";
|
|
4
|
+
import { BuildInlineConfig, CleanInlineConfig, DeployInlineConfig, DocsInlineConfig, LintInlineConfig, NewInlineConfig, PrepareInlineConfig } from "./config.cjs";
|
|
5
|
+
import { ResolvedConfig } from "./resolved.cjs";
|
|
6
|
+
|
|
7
|
+
//#region ../powerlines/src/types/api.d.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Powerlines API Interface
|
|
11
|
+
*/
|
|
12
|
+
interface API<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
|
|
13
|
+
/**
|
|
14
|
+
* The Powerlines shared API context
|
|
15
|
+
*/
|
|
16
|
+
context: APIContext<TResolvedConfig>;
|
|
17
|
+
/**
|
|
18
|
+
* Prepare the Powerlines API
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* This method will prepare the Powerlines API for use, initializing any necessary resources.
|
|
22
|
+
*
|
|
23
|
+
* @param inlineConfig - The inline configuration for the prepare command
|
|
24
|
+
*/
|
|
25
|
+
prepare: (inlineConfig: PrepareInlineConfig | NewInlineConfig | CleanInlineConfig | BuildInlineConfig | LintInlineConfig | DocsInlineConfig | DeployInlineConfig) => Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Create a new Powerlines project
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* This method will create a new Powerlines project in the current directory.
|
|
31
|
+
*
|
|
32
|
+
* @param inlineConfig - The inline configuration for the new command
|
|
33
|
+
* @returns A promise that resolves when the project has been created
|
|
34
|
+
*/
|
|
35
|
+
new: (inlineConfig: NewInlineConfig) => Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Clean any previously prepared artifacts
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* This method will remove the previous Powerlines artifacts from the project.
|
|
41
|
+
*
|
|
42
|
+
* @param inlineConfig - The inline configuration for the clean command
|
|
43
|
+
* @returns A promise that resolves when the clean command has completed
|
|
44
|
+
*/
|
|
45
|
+
clean: (inlineConfig: CleanInlineConfig | PrepareInlineConfig) => Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Lint the project source code
|
|
48
|
+
*
|
|
49
|
+
* @param inlineConfig - The inline configuration for the lint command
|
|
50
|
+
* @returns A promise that resolves when the lint command has completed
|
|
51
|
+
*/
|
|
52
|
+
lint: (inlineConfig: LintInlineConfig) => Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Build the project
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* This method will build the Powerlines project, generating the necessary artifacts.
|
|
58
|
+
*
|
|
59
|
+
* @param inlineConfig - The inline configuration for the build command
|
|
60
|
+
* @returns A promise that resolves when the build command has completed
|
|
61
|
+
*/
|
|
62
|
+
build: (inlineConfig: BuildInlineConfig) => Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Prepare the documentation for the project
|
|
65
|
+
*
|
|
66
|
+
* @param inlineConfig - The inline configuration for the docs command
|
|
67
|
+
* @returns A promise that resolves when the documentation generation has completed
|
|
68
|
+
*/
|
|
69
|
+
docs: (inlineConfig: DocsInlineConfig) => Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Deploy the project source code
|
|
72
|
+
*
|
|
73
|
+
* @remarks
|
|
74
|
+
* This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
|
|
75
|
+
*
|
|
76
|
+
* @param inlineConfig - The inline configuration for the deploy command
|
|
77
|
+
*/
|
|
78
|
+
deploy: (inlineConfig: DeployInlineConfig) => Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Finalization process
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
|
|
84
|
+
*
|
|
85
|
+
* @returns A promise that resolves when the finalization process has completed
|
|
86
|
+
*/
|
|
87
|
+
finalize: () => Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Invokes the configured plugin hooks
|
|
90
|
+
*
|
|
91
|
+
* @remarks
|
|
92
|
+
* By default, it will call the `"pre"`, `"normal"`, and `"post"` ordered hooks in sequence
|
|
93
|
+
*
|
|
94
|
+
* @param hook - The hook to call
|
|
95
|
+
* @param options - The options to provide to the hook
|
|
96
|
+
* @param args - The arguments to pass to the hook
|
|
97
|
+
* @returns The result of the hook call
|
|
98
|
+
*/
|
|
99
|
+
callHook: <TKey extends string>(hook: TKey, options: CallHookOptions & {
|
|
100
|
+
environment?: string | EnvironmentContext<TResolvedConfig>;
|
|
101
|
+
}, ...args: InferHookParameters<PluginContext<TResolvedConfig>, TKey>) => Promise<InferHookReturnType<PluginContext<TResolvedConfig>, TKey> | undefined>;
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export { API };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { CallHookOptions } from "../internal/helpers/hooks.mjs";
|
|
2
|
+
import { InferHookParameters, InferHookReturnType } from "./hooks.mjs";
|
|
3
|
+
import { APIContext, EnvironmentContext, PluginContext } from "./context.mjs";
|
|
4
|
+
import { BuildInlineConfig, CleanInlineConfig, DeployInlineConfig, DocsInlineConfig, LintInlineConfig, NewInlineConfig, PrepareInlineConfig } from "./config.mjs";
|
|
5
|
+
import { ResolvedConfig } from "./resolved.mjs";
|
|
6
|
+
|
|
7
|
+
//#region ../powerlines/src/types/api.d.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Powerlines API Interface
|
|
11
|
+
*/
|
|
12
|
+
interface API<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
|
|
13
|
+
/**
|
|
14
|
+
* The Powerlines shared API context
|
|
15
|
+
*/
|
|
16
|
+
context: APIContext<TResolvedConfig>;
|
|
17
|
+
/**
|
|
18
|
+
* Prepare the Powerlines API
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* This method will prepare the Powerlines API for use, initializing any necessary resources.
|
|
22
|
+
*
|
|
23
|
+
* @param inlineConfig - The inline configuration for the prepare command
|
|
24
|
+
*/
|
|
25
|
+
prepare: (inlineConfig: PrepareInlineConfig | NewInlineConfig | CleanInlineConfig | BuildInlineConfig | LintInlineConfig | DocsInlineConfig | DeployInlineConfig) => Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Create a new Powerlines project
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* This method will create a new Powerlines project in the current directory.
|
|
31
|
+
*
|
|
32
|
+
* @param inlineConfig - The inline configuration for the new command
|
|
33
|
+
* @returns A promise that resolves when the project has been created
|
|
34
|
+
*/
|
|
35
|
+
new: (inlineConfig: NewInlineConfig) => Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Clean any previously prepared artifacts
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* This method will remove the previous Powerlines artifacts from the project.
|
|
41
|
+
*
|
|
42
|
+
* @param inlineConfig - The inline configuration for the clean command
|
|
43
|
+
* @returns A promise that resolves when the clean command has completed
|
|
44
|
+
*/
|
|
45
|
+
clean: (inlineConfig: CleanInlineConfig | PrepareInlineConfig) => Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Lint the project source code
|
|
48
|
+
*
|
|
49
|
+
* @param inlineConfig - The inline configuration for the lint command
|
|
50
|
+
* @returns A promise that resolves when the lint command has completed
|
|
51
|
+
*/
|
|
52
|
+
lint: (inlineConfig: LintInlineConfig) => Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Build the project
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* This method will build the Powerlines project, generating the necessary artifacts.
|
|
58
|
+
*
|
|
59
|
+
* @param inlineConfig - The inline configuration for the build command
|
|
60
|
+
* @returns A promise that resolves when the build command has completed
|
|
61
|
+
*/
|
|
62
|
+
build: (inlineConfig: BuildInlineConfig) => Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Prepare the documentation for the project
|
|
65
|
+
*
|
|
66
|
+
* @param inlineConfig - The inline configuration for the docs command
|
|
67
|
+
* @returns A promise that resolves when the documentation generation has completed
|
|
68
|
+
*/
|
|
69
|
+
docs: (inlineConfig: DocsInlineConfig) => Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Deploy the project source code
|
|
72
|
+
*
|
|
73
|
+
* @remarks
|
|
74
|
+
* This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
|
|
75
|
+
*
|
|
76
|
+
* @param inlineConfig - The inline configuration for the deploy command
|
|
77
|
+
*/
|
|
78
|
+
deploy: (inlineConfig: DeployInlineConfig) => Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Finalization process
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
|
|
84
|
+
*
|
|
85
|
+
* @returns A promise that resolves when the finalization process has completed
|
|
86
|
+
*/
|
|
87
|
+
finalize: () => Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Invokes the configured plugin hooks
|
|
90
|
+
*
|
|
91
|
+
* @remarks
|
|
92
|
+
* By default, it will call the `"pre"`, `"normal"`, and `"post"` ordered hooks in sequence
|
|
93
|
+
*
|
|
94
|
+
* @param hook - The hook to call
|
|
95
|
+
* @param options - The options to provide to the hook
|
|
96
|
+
* @param args - The arguments to pass to the hook
|
|
97
|
+
* @returns The result of the hook call
|
|
98
|
+
*/
|
|
99
|
+
callHook: <TKey extends string>(hook: TKey, options: CallHookOptions & {
|
|
100
|
+
environment?: string | EnvironmentContext<TResolvedConfig>;
|
|
101
|
+
}, ...args: InferHookParameters<PluginContext<TResolvedConfig>, TKey>) => Promise<InferHookReturnType<PluginContext<TResolvedConfig>, TKey> | undefined>;
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export { API };
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { DepOptimizationOptions, UserConfig } from "vite";
|
|
2
|
+
import { UserConfig as UserConfig$1 } from "@farmfe/core";
|
|
3
|
+
import { Configuration } from "@rspack/core";
|
|
4
|
+
import { BuildOptions } from "@storm-software/tsup/types";
|
|
5
|
+
import { UnbuildOptions } from "@storm-software/unbuild/types";
|
|
6
|
+
import { BuildOptions as BuildOptions$1 } from "esbuild";
|
|
7
|
+
import { RolldownOptions } from "rolldown";
|
|
8
|
+
import { OutputOptions, RollupOptions } from "rollup";
|
|
9
|
+
import { UserConfig as UserConfig$2 } from "tsdown";
|
|
10
|
+
import { Configuration as Configuration$1 } from "webpack";
|
|
2
11
|
|
|
3
|
-
|
|
12
|
+
//#region ../powerlines/src/types/build.d.ts
|
|
13
|
+
type UnpluginBuilderVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown" | "bun";
|
|
14
|
+
type BuilderVariant = UnpluginBuilderVariant | "tsup" | "tsdown" | "unbuild";
|
|
15
|
+
type InferUnpluginVariant<TBuildVariant extends BuilderVariant> = TBuildVariant extends "tsup" ? "esbuild" : TBuildVariant extends "tsdown" ? "rolldown" : TBuildVariant extends "unbuild" ? "rollup" : TBuildVariant;
|
|
4
16
|
interface BuildConfig {
|
|
5
17
|
/**
|
|
6
18
|
* The platform to build the project for
|
|
@@ -141,5 +153,33 @@ interface BuildConfig {
|
|
|
141
153
|
override?: Record<string, any>;
|
|
142
154
|
}
|
|
143
155
|
type BuildResolvedConfig = Omit<BuildConfig, "override">;
|
|
156
|
+
type ESBuildBuildConfig = Omit<BuildOptions$1, "entryPoints" | "sourceRoot" | "platform" | "outdir" | "env" | "assets" | "external" | "inject" | "tsconfig" | "tsconfigRaw" | "logLevel"> & BuildConfig;
|
|
157
|
+
type ESBuildResolvedBuildConfig = Omit<BuildOptions$1, "inject"> & BuildResolvedConfig;
|
|
158
|
+
type ViteBuildConfig = Omit<UserConfig, "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw" | "environments" | "output"> & BuildConfig & {
|
|
159
|
+
/**
|
|
160
|
+
* Optimize deps config
|
|
161
|
+
*/
|
|
162
|
+
optimizeDeps?: Omit<DepOptimizationOptions, "extensions">;
|
|
163
|
+
};
|
|
164
|
+
type ViteResolvedBuildConfig = UserConfig & BuildResolvedConfig;
|
|
165
|
+
type WebpackBuildConfig = Omit<Configuration$1, "name" | "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw"> & BuildConfig;
|
|
166
|
+
type WebpackResolvedBuildConfig = Configuration$1 & BuildResolvedConfig;
|
|
167
|
+
type RspackBuildConfig = Omit<Configuration, "name" | "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw"> & BuildConfig;
|
|
168
|
+
type RspackResolvedBuildConfig = Configuration & BuildResolvedConfig;
|
|
169
|
+
type RollupBuildOutputConfig = Omit<OutputOptions, "dir" | "format">;
|
|
170
|
+
type RollupBuildConfig = Omit<RollupOptions, "entry" | "external" | "input" | "output" | "logLevel"> & {
|
|
171
|
+
output: RollupBuildOutputConfig | RollupBuildOutputConfig[];
|
|
172
|
+
} & BuildConfig;
|
|
173
|
+
type RollupResolvedBuildConfig = RollupOptions & BuildResolvedConfig;
|
|
174
|
+
type RolldownBuildConfig = Omit<RolldownOptions, "input" | "external" | "tsconfig" | "logLevel" | "output"> & BuildConfig;
|
|
175
|
+
type RolldownResolvedBuildConfig = RolldownOptions & BuildResolvedConfig;
|
|
176
|
+
type TsupBuildConfig = Partial<Omit<BuildOptions, "userOptions" | "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "clean" | "env" | "entry" | "entryPoints" | "external" | "noExternal" | "skipNodeModulesBundle">> & BuildConfig;
|
|
177
|
+
type TsupResolvedBuildConfig = BuildOptions & BuildResolvedConfig;
|
|
178
|
+
type TsdownBuildConfig = Partial<Omit<UserConfig$2, "name" | "outDir" | "clean" | "cwd" | "tsconfig" | "publicDir" | "copy" | "alias" | "format" | "platform" | "env" | "define" | "entry" | "external" | "noExternal" | "skipNodeModulesBundle">> & BuildConfig;
|
|
179
|
+
type TsdownResolvedBuildConfig = UserConfig$2 & BuildResolvedConfig;
|
|
180
|
+
type UnbuildBuildConfig = Partial<Omit<UnbuildOptions, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">> & BuildConfig;
|
|
181
|
+
type UnbuildResolvedBuildConfig = UnbuildOptions & BuildResolvedConfig;
|
|
182
|
+
type FarmBuildConfig = Partial<Omit<UserConfig$1, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">> & BuildConfig;
|
|
183
|
+
type FarmResolvedBuildConfig = UserConfig$1 & BuildResolvedConfig;
|
|
144
184
|
//#endregion
|
|
145
|
-
export { BuildConfig, BuildResolvedConfig,
|
|
185
|
+
export { BuildConfig, BuildResolvedConfig, BuilderVariant, ESBuildBuildConfig, ESBuildResolvedBuildConfig, FarmBuildConfig, FarmResolvedBuildConfig, InferUnpluginVariant, RolldownBuildConfig, RolldownResolvedBuildConfig, RollupBuildConfig, RollupResolvedBuildConfig, RspackBuildConfig, RspackResolvedBuildConfig, TsdownBuildConfig, TsdownResolvedBuildConfig, TsupBuildConfig, TsupResolvedBuildConfig, UnbuildBuildConfig, UnbuildResolvedBuildConfig, UnpluginBuilderVariant, ViteBuildConfig, ViteResolvedBuildConfig, WebpackBuildConfig, WebpackResolvedBuildConfig };
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import "esbuild";
|
|
1
|
+
import { BuildOptions } from "esbuild";
|
|
2
|
+
import { DepOptimizationOptions, UserConfig } from "vite";
|
|
3
|
+
import { UserConfig as UserConfig$1 } from "@farmfe/core";
|
|
4
|
+
import { Configuration } from "@rspack/core";
|
|
5
|
+
import { BuildOptions as BuildOptions$1 } from "@storm-software/tsup/types";
|
|
6
|
+
import { UnbuildOptions } from "@storm-software/unbuild/types";
|
|
7
|
+
import { RolldownOptions } from "rolldown";
|
|
8
|
+
import { OutputOptions, RollupOptions } from "rollup";
|
|
9
|
+
import { UserConfig as UserConfig$2 } from "tsdown";
|
|
10
|
+
import { Configuration as Configuration$1 } from "webpack";
|
|
2
11
|
|
|
3
12
|
//#region ../powerlines/src/types/build.d.ts
|
|
4
|
-
|
|
5
|
-
type
|
|
13
|
+
type UnpluginBuilderVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown" | "bun";
|
|
14
|
+
type BuilderVariant = UnpluginBuilderVariant | "tsup" | "tsdown" | "unbuild";
|
|
15
|
+
type InferUnpluginVariant<TBuildVariant extends BuilderVariant> = TBuildVariant extends "tsup" ? "esbuild" : TBuildVariant extends "tsdown" ? "rolldown" : TBuildVariant extends "unbuild" ? "rollup" : TBuildVariant;
|
|
6
16
|
interface BuildConfig {
|
|
7
17
|
/**
|
|
8
18
|
* The platform to build the project for
|
|
@@ -143,5 +153,33 @@ interface BuildConfig {
|
|
|
143
153
|
override?: Record<string, any>;
|
|
144
154
|
}
|
|
145
155
|
type BuildResolvedConfig = Omit<BuildConfig, "override">;
|
|
156
|
+
type ESBuildBuildConfig = Omit<BuildOptions, "entryPoints" | "sourceRoot" | "platform" | "outdir" | "env" | "assets" | "external" | "inject" | "tsconfig" | "tsconfigRaw" | "logLevel"> & BuildConfig;
|
|
157
|
+
type ESBuildResolvedBuildConfig = Omit<BuildOptions, "inject"> & BuildResolvedConfig;
|
|
158
|
+
type ViteBuildConfig = Omit<UserConfig, "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw" | "environments" | "output"> & BuildConfig & {
|
|
159
|
+
/**
|
|
160
|
+
* Optimize deps config
|
|
161
|
+
*/
|
|
162
|
+
optimizeDeps?: Omit<DepOptimizationOptions, "extensions">;
|
|
163
|
+
};
|
|
164
|
+
type ViteResolvedBuildConfig = UserConfig & BuildResolvedConfig;
|
|
165
|
+
type WebpackBuildConfig = Omit<Configuration$1, "name" | "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw"> & BuildConfig;
|
|
166
|
+
type WebpackResolvedBuildConfig = Configuration$1 & BuildResolvedConfig;
|
|
167
|
+
type RspackBuildConfig = Omit<Configuration, "name" | "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw"> & BuildConfig;
|
|
168
|
+
type RspackResolvedBuildConfig = Configuration & BuildResolvedConfig;
|
|
169
|
+
type RollupBuildOutputConfig = Omit<OutputOptions, "dir" | "format">;
|
|
170
|
+
type RollupBuildConfig = Omit<RollupOptions, "entry" | "external" | "input" | "output" | "logLevel"> & {
|
|
171
|
+
output: RollupBuildOutputConfig | RollupBuildOutputConfig[];
|
|
172
|
+
} & BuildConfig;
|
|
173
|
+
type RollupResolvedBuildConfig = RollupOptions & BuildResolvedConfig;
|
|
174
|
+
type RolldownBuildConfig = Omit<RolldownOptions, "input" | "external" | "tsconfig" | "logLevel" | "output"> & BuildConfig;
|
|
175
|
+
type RolldownResolvedBuildConfig = RolldownOptions & BuildResolvedConfig;
|
|
176
|
+
type TsupBuildConfig = Partial<Omit<BuildOptions$1, "userOptions" | "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "clean" | "env" | "entry" | "entryPoints" | "external" | "noExternal" | "skipNodeModulesBundle">> & BuildConfig;
|
|
177
|
+
type TsupResolvedBuildConfig = BuildOptions$1 & BuildResolvedConfig;
|
|
178
|
+
type TsdownBuildConfig = Partial<Omit<UserConfig$2, "name" | "outDir" | "clean" | "cwd" | "tsconfig" | "publicDir" | "copy" | "alias" | "format" | "platform" | "env" | "define" | "entry" | "external" | "noExternal" | "skipNodeModulesBundle">> & BuildConfig;
|
|
179
|
+
type TsdownResolvedBuildConfig = UserConfig$2 & BuildResolvedConfig;
|
|
180
|
+
type UnbuildBuildConfig = Partial<Omit<UnbuildOptions, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">> & BuildConfig;
|
|
181
|
+
type UnbuildResolvedBuildConfig = UnbuildOptions & BuildResolvedConfig;
|
|
182
|
+
type FarmBuildConfig = Partial<Omit<UserConfig$1, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">> & BuildConfig;
|
|
183
|
+
type FarmResolvedBuildConfig = UserConfig$1 & BuildResolvedConfig;
|
|
146
184
|
//#endregion
|
|
147
|
-
export { BuildConfig, BuildResolvedConfig,
|
|
185
|
+
export { BuildConfig, BuildResolvedConfig, BuilderVariant, ESBuildBuildConfig, ESBuildResolvedBuildConfig, FarmBuildConfig, FarmResolvedBuildConfig, InferUnpluginVariant, RolldownBuildConfig, RolldownResolvedBuildConfig, RollupBuildConfig, RollupResolvedBuildConfig, RspackBuildConfig, RspackResolvedBuildConfig, TsdownBuildConfig, TsdownResolvedBuildConfig, TsupBuildConfig, TsupResolvedBuildConfig, UnbuildBuildConfig, UnbuildResolvedBuildConfig, UnpluginBuilderVariant, ViteBuildConfig, ViteResolvedBuildConfig, WebpackBuildConfig, WebpackResolvedBuildConfig };
|