@powerlines/plugin-nitro 0.1.17 → 0.1.19
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 +29 -0
- package/dist/index.cjs +61 -46
- package/dist/index.mjs +59 -46
- 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/plugin-utils/get-config-path.cjs +1 -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 +43 -3
- 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 -4
- package/dist/powerlines/src/types/unplugin.d.cts +22 -0
- package/dist/powerlines/src/types/unplugin.d.mts +23 -0
- package/package.json +4 -4
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
3
|
const require_get_config_path = require('./powerlines/src/plugin-utils/get-config-path.cjs');
|
|
3
4
|
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
4
5
|
let __stryke_path_append = require("@stryke/path/append");
|
|
6
|
+
let defu = require("defu");
|
|
7
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
5
8
|
let nitro_builder = require("nitro/builder");
|
|
6
9
|
|
|
7
10
|
//#region src/index.ts
|
|
@@ -9,55 +12,67 @@ let nitro_builder = require("nitro/builder");
|
|
|
9
12
|
* A Powerlines plugin to integrate with Nitro.
|
|
10
13
|
*/
|
|
11
14
|
const plugin = (options = {}) => {
|
|
12
|
-
return [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
name: "nitro:config",
|
|
18
|
+
async config() {
|
|
19
|
+
this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Providing default configuration for the Powerlines `nitro` plugin.");
|
|
20
|
+
let configFile = options.configFile;
|
|
21
|
+
if (!configFile) configFile = require_get_config_path.getConfigPath(this, "nitro");
|
|
22
|
+
return { nitro: {
|
|
23
|
+
configFile: configFile ? (0, __stryke_path_append.appendPath)(configFile, this.workspaceConfig.workspaceRoot) : void 0,
|
|
24
|
+
...options
|
|
25
|
+
} };
|
|
26
|
+
},
|
|
27
|
+
configResolved() {
|
|
28
|
+
this.config.nitro.compatibilityDate = this.config.compatibilityDate;
|
|
29
|
+
this.config.nitro.workspaceDir = this.workspaceConfig.workspaceRoot;
|
|
30
|
+
this.config.nitro.alias = this.config.build.alias;
|
|
31
|
+
switch (this.config.logLevel) {
|
|
32
|
+
case "error":
|
|
33
|
+
this.config.nitro.logLevel = 1;
|
|
34
|
+
break;
|
|
35
|
+
case "warn":
|
|
36
|
+
this.config.nitro.logLevel = 2;
|
|
37
|
+
break;
|
|
38
|
+
case "info":
|
|
39
|
+
this.config.nitro.logLevel = 3;
|
|
40
|
+
break;
|
|
41
|
+
case "debug":
|
|
42
|
+
this.config.nitro.logLevel = 4;
|
|
43
|
+
break;
|
|
44
|
+
case "trace":
|
|
45
|
+
this.config.nitro.logLevel = 5;
|
|
46
|
+
break;
|
|
47
|
+
case null:
|
|
48
|
+
this.config.nitro.logLevel = 0;
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
this.config.nitro.logLevel = 2;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
49
54
|
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "nitro:init",
|
|
58
|
+
configResolved: {
|
|
59
|
+
order: "post",
|
|
60
|
+
async handler() {
|
|
61
|
+
this.nitro ??= {};
|
|
62
|
+
this.nitro.nitro = await (0, nitro_builder.createNitro)(this.config.nitro);
|
|
63
|
+
}
|
|
58
64
|
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "nitro:vite",
|
|
68
|
+
vite: { config(_, configEnv) {
|
|
69
|
+
this.config.nitro.dev = configEnv.command === "serve";
|
|
70
|
+
this.config.nitro.builder = "vite";
|
|
71
|
+
this.config.nitro.rootDir = this.config.projectRoot;
|
|
72
|
+
this.config.nitro = (0, defu.default)(this.config.nitro, this.config);
|
|
73
|
+
} }
|
|
59
74
|
}
|
|
60
|
-
|
|
75
|
+
];
|
|
61
76
|
};
|
|
62
77
|
var src_default = plugin;
|
|
63
78
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getConfigPath } from "./powerlines/src/plugin-utils/get-config-path.mjs";
|
|
2
2
|
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
3
3
|
import { appendPath } from "@stryke/path/append";
|
|
4
|
+
import defu from "defu";
|
|
4
5
|
import { createNitro } from "nitro/builder";
|
|
5
6
|
|
|
6
7
|
//#region src/index.ts
|
|
@@ -8,55 +9,67 @@ import { createNitro } from "nitro/builder";
|
|
|
8
9
|
* A Powerlines plugin to integrate with Nitro.
|
|
9
10
|
*/
|
|
10
11
|
const plugin = (options = {}) => {
|
|
11
|
-
return [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
name: "nitro:config",
|
|
15
|
+
async config() {
|
|
16
|
+
this.log(LogLevelLabel.TRACE, "Providing default configuration for the Powerlines `nitro` plugin.");
|
|
17
|
+
let configFile = options.configFile;
|
|
18
|
+
if (!configFile) configFile = getConfigPath(this, "nitro");
|
|
19
|
+
return { nitro: {
|
|
20
|
+
configFile: configFile ? appendPath(configFile, this.workspaceConfig.workspaceRoot) : void 0,
|
|
21
|
+
...options
|
|
22
|
+
} };
|
|
23
|
+
},
|
|
24
|
+
configResolved() {
|
|
25
|
+
this.config.nitro.compatibilityDate = this.config.compatibilityDate;
|
|
26
|
+
this.config.nitro.workspaceDir = this.workspaceConfig.workspaceRoot;
|
|
27
|
+
this.config.nitro.alias = this.config.build.alias;
|
|
28
|
+
switch (this.config.logLevel) {
|
|
29
|
+
case "error":
|
|
30
|
+
this.config.nitro.logLevel = 1;
|
|
31
|
+
break;
|
|
32
|
+
case "warn":
|
|
33
|
+
this.config.nitro.logLevel = 2;
|
|
34
|
+
break;
|
|
35
|
+
case "info":
|
|
36
|
+
this.config.nitro.logLevel = 3;
|
|
37
|
+
break;
|
|
38
|
+
case "debug":
|
|
39
|
+
this.config.nitro.logLevel = 4;
|
|
40
|
+
break;
|
|
41
|
+
case "trace":
|
|
42
|
+
this.config.nitro.logLevel = 5;
|
|
43
|
+
break;
|
|
44
|
+
case null:
|
|
45
|
+
this.config.nitro.logLevel = 0;
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
this.config.nitro.logLevel = 2;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
48
51
|
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "nitro:init",
|
|
55
|
+
configResolved: {
|
|
56
|
+
order: "post",
|
|
57
|
+
async handler() {
|
|
58
|
+
this.nitro ??= {};
|
|
59
|
+
this.nitro.nitro = await createNitro(this.config.nitro);
|
|
60
|
+
}
|
|
57
61
|
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "nitro:vite",
|
|
65
|
+
vite: { config(_, configEnv) {
|
|
66
|
+
this.config.nitro.dev = configEnv.command === "serve";
|
|
67
|
+
this.config.nitro.builder = "vite";
|
|
68
|
+
this.config.nitro.rootDir = this.config.projectRoot;
|
|
69
|
+
this.config.nitro = defu(this.config.nitro, this.config);
|
|
70
|
+
} }
|
|
58
71
|
}
|
|
59
|
-
|
|
72
|
+
];
|
|
60
73
|
};
|
|
61
74
|
var src_default = plugin;
|
|
62
75
|
|
|
@@ -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 "../../types/resolved.mjs";
|
|
3
|
+
import { SelectHooksOptions } from "../../types/context.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 { BuildInlineConfig, CleanInlineConfig, DeployInlineConfig, DocsInlineConfig, LintInlineConfig, NewInlineConfig, PrepareInlineConfig } from "./config.cjs";
|
|
2
|
+
import { InferHookParameters, InferHookReturnType } from "./hooks.cjs";
|
|
3
|
+
import { ResolvedConfig } from "./resolved.cjs";
|
|
4
|
+
import { APIContext, EnvironmentContext, PluginContext } from "./context.cjs";
|
|
5
|
+
import { CallHookOptions } from "../internal/helpers/hooks.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 { BuildInlineConfig, CleanInlineConfig, DeployInlineConfig, DocsInlineConfig, LintInlineConfig, NewInlineConfig, PrepareInlineConfig } from "./config.mjs";
|
|
2
|
+
import { InferHookParameters, InferHookReturnType } from "./hooks.mjs";
|
|
3
|
+
import { ResolvedConfig } from "./resolved.mjs";
|
|
4
|
+
import { APIContext, EnvironmentContext, PluginContext } from "./context.mjs";
|
|
5
|
+
import { CallHookOptions } from "../internal/helpers/hooks.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 { OutputOptions, RollupOptions } from "rollup";
|
|
2
|
+
import { UserConfig } 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 { UserConfig as UserConfig$1 } from "tsdown";
|
|
9
|
+
import { DepOptimizationOptions, UserConfig as UserConfig$2 } from "vite";
|
|
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$2, "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw" | "environments" | "output"> & BuildConfig & {
|
|
159
|
+
/**
|
|
160
|
+
* Optimize deps config
|
|
161
|
+
*/
|
|
162
|
+
optimizeDeps?: Omit<DepOptimizationOptions, "extensions">;
|
|
163
|
+
};
|
|
164
|
+
type ViteResolvedBuildConfig = UserConfig$2 & 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$1, "name" | "outDir" | "clean" | "cwd" | "tsconfig" | "publicDir" | "copy" | "alias" | "format" | "platform" | "env" | "define" | "entry" | "external" | "noExternal" | "skipNodeModulesBundle">> & BuildConfig;
|
|
179
|
+
type TsdownResolvedBuildConfig = UserConfig$1 & 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, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">> & BuildConfig;
|
|
183
|
+
type FarmResolvedBuildConfig = UserConfig & 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 };
|