@powerlines/plugin-env 0.15.133 → 0.15.135
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/babel/plugin.cjs +3 -3
- package/dist/babel/plugin.d.cts +2 -2
- package/dist/babel/plugin.d.mts +3 -2
- package/dist/babel/plugin.mjs +1 -1
- package/dist/helpers/automd-generator.cjs +2 -2
- package/dist/helpers/automd-generator.d.cts +1 -1
- package/dist/helpers/automd-generator.d.mts +1 -1
- package/dist/helpers/automd-generator.mjs +1 -1
- package/dist/helpers/load.cjs +4 -4
- package/dist/helpers/load.mjs +2 -2
- package/dist/helpers/persistence.cjs +5 -5
- package/dist/helpers/persistence.d.cts +1 -1
- package/dist/helpers/persistence.d.mts +1 -1
- package/dist/helpers/persistence.mjs +1 -1
- package/dist/helpers/reflect.cjs +0 -13
- package/dist/helpers/reflect.mjs +0 -13
- package/dist/index.cjs +2 -3
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/plugin-alloy/src/core/components/output.cjs +33 -0
- package/dist/plugin-alloy/src/core/components/output.mjs +32 -0
- package/dist/plugin-alloy/src/core/contexts/context.cjs +116 -0
- package/dist/plugin-alloy/src/core/contexts/context.mjs +116 -0
- package/dist/plugin-alloy/src/index.cjs +98 -0
- package/dist/plugin-alloy/src/index.mjs +96 -0
- package/dist/plugin-alloy/src/internal/unctx.cjs +9 -0
- package/dist/plugin-alloy/src/internal/unctx.mjs +8 -0
- 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/lib/constants/environments.cjs +6 -0
- package/dist/powerlines/src/lib/constants/environments.mjs +5 -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/babel.cjs +11 -0
- package/dist/powerlines/src/types/babel.d.cts +21 -0
- package/dist/powerlines/src/types/babel.d.mts +21 -0
- package/dist/powerlines/src/types/babel.mjs +10 -0
- package/dist/powerlines/src/types/build.d.cts +185 -0
- package/dist/powerlines/src/types/build.d.mts +185 -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/config.cjs +30 -0
- package/dist/powerlines/src/types/config.d.cts +424 -0
- package/dist/powerlines/src/types/config.d.mts +426 -0
- package/dist/powerlines/src/types/config.mjs +29 -0
- package/dist/powerlines/src/types/context.cjs +285 -0
- package/dist/powerlines/src/types/context.d.cts +514 -0
- package/dist/powerlines/src/types/context.d.mts +514 -0
- package/dist/powerlines/src/types/context.mjs +283 -0
- package/dist/powerlines/src/types/fs.d.cts +486 -0
- package/dist/powerlines/src/types/fs.d.mts +486 -0
- package/dist/powerlines/src/types/hooks.d.cts +32 -0
- package/dist/powerlines/src/types/hooks.d.mts +32 -0
- package/dist/powerlines/src/types/index.d.mts +12 -0
- package/dist/powerlines/src/types/plugin.d.cts +205 -0
- package/dist/powerlines/src/types/plugin.d.mts +205 -0
- package/dist/powerlines/src/types/resolved.d.cts +93 -0
- package/dist/powerlines/src/types/resolved.d.mts +93 -0
- package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
- package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
- package/dist/powerlines/src/types/unplugin.d.cts +22 -0
- package/dist/powerlines/src/types/unplugin.d.mts +23 -0
- package/dist/types/plugin.d.cts +1 -1
- package/package.json +16 -16
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { unctx } from "../../internal/unctx.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../plugin-alloy/src/core/contexts/context.ts
|
|
4
|
+
const __ΩRecord = [
|
|
5
|
+
"K",
|
|
6
|
+
"T",
|
|
7
|
+
"Record",
|
|
8
|
+
"l'e#\"Rb!b\"Pde\"!N#!w#y"
|
|
9
|
+
];
|
|
10
|
+
const __ΩMetaItem = [
|
|
11
|
+
"builtin",
|
|
12
|
+
"entry",
|
|
13
|
+
"kind",
|
|
14
|
+
"The kind of metadata item.",
|
|
15
|
+
"skipFormat",
|
|
16
|
+
"Whether to skip formatting for this output.",
|
|
17
|
+
"StoragePreset",
|
|
18
|
+
"storage",
|
|
19
|
+
"The storage preset or adapter name for the output files.",
|
|
20
|
+
"MetaItem",
|
|
21
|
+
"PP.!.\"&J4#8?$)4%8?&P\"w'&J4(8?)&\"LMw*y"
|
|
22
|
+
];
|
|
23
|
+
const __ΩPowerlinesContextInterface = [
|
|
24
|
+
"PluginContext",
|
|
25
|
+
"TContext",
|
|
26
|
+
() => __ΩRecord,
|
|
27
|
+
() => __ΩMetaItem,
|
|
28
|
+
"TMeta",
|
|
29
|
+
"value",
|
|
30
|
+
"The current Powerlines context.",
|
|
31
|
+
"meta",
|
|
32
|
+
"The current render metadata.",
|
|
33
|
+
"PowerlinesContextInterface",
|
|
34
|
+
"\"w!c\"&n$o##c%Pe\"!4&?'e\"\"4(?)Mw*y"
|
|
35
|
+
];
|
|
36
|
+
/**
|
|
37
|
+
* Hook to access the Powerlines Context.
|
|
38
|
+
*
|
|
39
|
+
* @returns The Context.
|
|
40
|
+
*/
|
|
41
|
+
function usePowerlinesContext() {
|
|
42
|
+
return unctx.tryUse();
|
|
43
|
+
}
|
|
44
|
+
usePowerlinesContext.__type = [
|
|
45
|
+
() => __ΩPowerlinesContextInterface,
|
|
46
|
+
"usePowerlinesContext",
|
|
47
|
+
"Hook to access the Powerlines Context.",
|
|
48
|
+
"PP\"\"o!#,J/\"?#"
|
|
49
|
+
];
|
|
50
|
+
/**
|
|
51
|
+
* Hook to safely access the {@link PluginContext | Powerlines context}.
|
|
52
|
+
*
|
|
53
|
+
* @returns The Powerlines context or null if not set.
|
|
54
|
+
*/
|
|
55
|
+
function usePowerlinesSafe() {
|
|
56
|
+
return (usePowerlinesContext.Ω = [["PluginContext", "\"w!"]], usePowerlinesContext())?.value ?? null;
|
|
57
|
+
}
|
|
58
|
+
usePowerlinesSafe.__type = [
|
|
59
|
+
"usePowerlinesSafe",
|
|
60
|
+
"Hook to safely access the {@link PluginContext | Powerlines context}.",
|
|
61
|
+
"PP\",J/!?\""
|
|
62
|
+
];
|
|
63
|
+
/**
|
|
64
|
+
* Hook to access the {@link PluginContext | Powerlines context}.
|
|
65
|
+
*
|
|
66
|
+
* @returns The Powerlines context.
|
|
67
|
+
*/
|
|
68
|
+
function usePowerlines() {
|
|
69
|
+
const powerlines = (usePowerlinesSafe.Ω = [["PluginContext", "\"w!"]], usePowerlinesSafe());
|
|
70
|
+
if (!powerlines) throw new Error("Powerlines - Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.");
|
|
71
|
+
return powerlines;
|
|
72
|
+
}
|
|
73
|
+
usePowerlines.__type = [
|
|
74
|
+
"usePowerlines",
|
|
75
|
+
"Hook to access the {@link PluginContext | Powerlines context}.",
|
|
76
|
+
"P\"/!?\""
|
|
77
|
+
];
|
|
78
|
+
/**
|
|
79
|
+
* Hook to safely access the render context's metadata.
|
|
80
|
+
*
|
|
81
|
+
* @returns The Powerlines context or null if not set.
|
|
82
|
+
*/
|
|
83
|
+
function useMetaSafe() {
|
|
84
|
+
return (usePowerlinesContext.Ω = [["PluginContext", "\"w!"], [
|
|
85
|
+
() => __ΩRecord,
|
|
86
|
+
() => __ΩMetaItem,
|
|
87
|
+
"&n\"o!#"
|
|
88
|
+
]], usePowerlinesContext())?.meta ?? null;
|
|
89
|
+
}
|
|
90
|
+
useMetaSafe.__type = [
|
|
91
|
+
"useMetaSafe",
|
|
92
|
+
"Hook to safely access the render context's metadata.",
|
|
93
|
+
"PP\",J/!?\""
|
|
94
|
+
];
|
|
95
|
+
/**
|
|
96
|
+
* Hook to access the render context's metadata.
|
|
97
|
+
*
|
|
98
|
+
* @returns The Powerlines context.
|
|
99
|
+
*/
|
|
100
|
+
function useMeta() {
|
|
101
|
+
const meta = (useMetaSafe.Ω = [[
|
|
102
|
+
() => __ΩRecord,
|
|
103
|
+
() => __ΩMetaItem,
|
|
104
|
+
"&n\"o!#"
|
|
105
|
+
]], useMetaSafe());
|
|
106
|
+
if (!meta) throw new Error("Powerlines metadata is not available in the rendering context. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.");
|
|
107
|
+
return meta;
|
|
108
|
+
}
|
|
109
|
+
useMeta.__type = [
|
|
110
|
+
"useMeta",
|
|
111
|
+
"Hook to access the render context's metadata.",
|
|
112
|
+
"P\"/!?\""
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
export { __ΩPowerlinesContextInterface };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_output = require('./core/components/output.cjs');
|
|
3
|
+
const require_unctx = require('./internal/unctx.cjs');
|
|
4
|
+
let __alloy_js_core = require("@alloy-js/core");
|
|
5
|
+
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
6
|
+
let __alloy_js_rollup_plugin = require("@alloy-js/rollup-plugin");
|
|
7
|
+
__alloy_js_rollup_plugin = require_rolldown_runtime.__toESM(__alloy_js_rollup_plugin);
|
|
8
|
+
let __stryke_json_storm_json = require("@stryke/json/storm-json");
|
|
9
|
+
let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
10
|
+
|
|
11
|
+
//#region ../plugin-alloy/src/index.tsx
|
|
12
|
+
/**
|
|
13
|
+
* Alloy-js plugin for Powerlines.
|
|
14
|
+
*
|
|
15
|
+
* @param options - The Alloy-js plugin user configuration options.
|
|
16
|
+
* @returns A Powerlines plugin that integrates Alloy-js transformations.
|
|
17
|
+
*/
|
|
18
|
+
const plugin = (options = {}) => {
|
|
19
|
+
return [{
|
|
20
|
+
name: "alloy:config",
|
|
21
|
+
config() {
|
|
22
|
+
this.debug("Updating configuration options to support Alloy-js builds.");
|
|
23
|
+
return {
|
|
24
|
+
alloy: {
|
|
25
|
+
typescript: true,
|
|
26
|
+
...options
|
|
27
|
+
},
|
|
28
|
+
build: {
|
|
29
|
+
inputOptions: { transform: { jsx: "preserve" } },
|
|
30
|
+
plugins: [(0, __alloy_js_rollup_plugin.default)()],
|
|
31
|
+
external: [/^@alloy-js\//],
|
|
32
|
+
noExternal: ["@powerlines/plugin-alloy"]
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
async configResolved() {
|
|
37
|
+
this.debug("Ensuring TypeScript configuration is set up for Alloy-js.");
|
|
38
|
+
if (this.tsconfig.tsconfigJson.compilerOptions?.jsx !== "preserve" || this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource !== "@alloy-js/core") {
|
|
39
|
+
this.tsconfig.tsconfigJson.compilerOptions ??= {};
|
|
40
|
+
if (this.tsconfig.tsconfigJson.compilerOptions.jsx !== "preserve") this.tsconfig.tsconfigJson.compilerOptions.jsx = "preserve";
|
|
41
|
+
if (this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource !== "@alloy-js/core") this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource = "@alloy-js/core";
|
|
42
|
+
await this.fs.write(this.tsconfig.tsconfigFilePath, __stryke_json_storm_json.StormJSON.stringify(this.tsconfig.tsconfigJson));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
name: "alloy:attach-render",
|
|
47
|
+
configResolved: {
|
|
48
|
+
order: "pre",
|
|
49
|
+
async handler() {
|
|
50
|
+
this.debug("Attaching the `render` method to the context object.");
|
|
51
|
+
this.render = async (children) => {
|
|
52
|
+
const meta = {};
|
|
53
|
+
await require_unctx.unctx.callAsync({
|
|
54
|
+
value: this,
|
|
55
|
+
meta
|
|
56
|
+
}, async () => {
|
|
57
|
+
const _self$ = this;
|
|
58
|
+
await (0, __alloy_js_core.traverseOutput)(await (0, __alloy_js_core.renderAsync)((0, __alloy_js_core_jsx_runtime.createComponent)(require_output.Output, {
|
|
59
|
+
context: _self$,
|
|
60
|
+
meta,
|
|
61
|
+
get basePath() {
|
|
62
|
+
return _self$.workspaceConfig.workspaceRoot;
|
|
63
|
+
},
|
|
64
|
+
children
|
|
65
|
+
})), {
|
|
66
|
+
visitDirectory: (directory) => {
|
|
67
|
+
if (this.fs.existsSync(directory.path)) return;
|
|
68
|
+
this.fs.mkdirSync(directory.path);
|
|
69
|
+
},
|
|
70
|
+
visitFile: (file) => {
|
|
71
|
+
if ("contents" in file) {
|
|
72
|
+
const metadata = meta[file.path] ?? {};
|
|
73
|
+
if (metadata.kind === "builtin") {
|
|
74
|
+
if (!metadata.id) throw new Error(`Built-in file "${file.path}" is missing its ID in the render metadata.`);
|
|
75
|
+
this.emitBuiltinSync(file.contents, metadata.id, {
|
|
76
|
+
skipFormat: metadata.skipFormat,
|
|
77
|
+
storage: metadata.storage,
|
|
78
|
+
extension: (0, __stryke_path_file_path_fns.findFileExtension)(file.path)
|
|
79
|
+
});
|
|
80
|
+
} else if (metadata.kind === "entry") this.emitEntrySync(file.contents, file.path, {
|
|
81
|
+
skipFormat: metadata.skipFormat,
|
|
82
|
+
storage: metadata.storage,
|
|
83
|
+
...metadata.typeDefinition ?? {}
|
|
84
|
+
});
|
|
85
|
+
else this.emitSync(file.contents, file.path, metadata);
|
|
86
|
+
} else this.fs.copySync(file.sourcePath, file.path);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}];
|
|
94
|
+
};
|
|
95
|
+
var src_default = plugin;
|
|
96
|
+
|
|
97
|
+
//#endregion
|
|
98
|
+
exports.default = src_default;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Output as Output$1 } from "./core/components/output.mjs";
|
|
2
|
+
import { unctx } from "./internal/unctx.mjs";
|
|
3
|
+
import { renderAsync, traverseOutput } from "@alloy-js/core";
|
|
4
|
+
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
5
|
+
import rollupPlugin from "@alloy-js/rollup-plugin";
|
|
6
|
+
import { StormJSON } from "@stryke/json/storm-json";
|
|
7
|
+
import { findFileExtension } from "@stryke/path/file-path-fns";
|
|
8
|
+
|
|
9
|
+
//#region ../plugin-alloy/src/index.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Alloy-js plugin for Powerlines.
|
|
12
|
+
*
|
|
13
|
+
* @param options - The Alloy-js plugin user configuration options.
|
|
14
|
+
* @returns A Powerlines plugin that integrates Alloy-js transformations.
|
|
15
|
+
*/
|
|
16
|
+
const plugin = (options = {}) => {
|
|
17
|
+
return [{
|
|
18
|
+
name: "alloy:config",
|
|
19
|
+
config() {
|
|
20
|
+
this.debug("Updating configuration options to support Alloy-js builds.");
|
|
21
|
+
return {
|
|
22
|
+
alloy: {
|
|
23
|
+
typescript: true,
|
|
24
|
+
...options
|
|
25
|
+
},
|
|
26
|
+
build: {
|
|
27
|
+
inputOptions: { transform: { jsx: "preserve" } },
|
|
28
|
+
plugins: [rollupPlugin()],
|
|
29
|
+
external: [/^@alloy-js\//],
|
|
30
|
+
noExternal: ["@powerlines/plugin-alloy"]
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
async configResolved() {
|
|
35
|
+
this.debug("Ensuring TypeScript configuration is set up for Alloy-js.");
|
|
36
|
+
if (this.tsconfig.tsconfigJson.compilerOptions?.jsx !== "preserve" || this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource !== "@alloy-js/core") {
|
|
37
|
+
this.tsconfig.tsconfigJson.compilerOptions ??= {};
|
|
38
|
+
if (this.tsconfig.tsconfigJson.compilerOptions.jsx !== "preserve") this.tsconfig.tsconfigJson.compilerOptions.jsx = "preserve";
|
|
39
|
+
if (this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource !== "@alloy-js/core") this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource = "@alloy-js/core";
|
|
40
|
+
await this.fs.write(this.tsconfig.tsconfigFilePath, StormJSON.stringify(this.tsconfig.tsconfigJson));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
name: "alloy:attach-render",
|
|
45
|
+
configResolved: {
|
|
46
|
+
order: "pre",
|
|
47
|
+
async handler() {
|
|
48
|
+
this.debug("Attaching the `render` method to the context object.");
|
|
49
|
+
this.render = async (children) => {
|
|
50
|
+
const meta = {};
|
|
51
|
+
await unctx.callAsync({
|
|
52
|
+
value: this,
|
|
53
|
+
meta
|
|
54
|
+
}, async () => {
|
|
55
|
+
const _self$ = this;
|
|
56
|
+
await traverseOutput(await renderAsync(createComponent(Output$1, {
|
|
57
|
+
context: _self$,
|
|
58
|
+
meta,
|
|
59
|
+
get basePath() {
|
|
60
|
+
return _self$.workspaceConfig.workspaceRoot;
|
|
61
|
+
},
|
|
62
|
+
children
|
|
63
|
+
})), {
|
|
64
|
+
visitDirectory: (directory) => {
|
|
65
|
+
if (this.fs.existsSync(directory.path)) return;
|
|
66
|
+
this.fs.mkdirSync(directory.path);
|
|
67
|
+
},
|
|
68
|
+
visitFile: (file) => {
|
|
69
|
+
if ("contents" in file) {
|
|
70
|
+
const metadata = meta[file.path] ?? {};
|
|
71
|
+
if (metadata.kind === "builtin") {
|
|
72
|
+
if (!metadata.id) throw new Error(`Built-in file "${file.path}" is missing its ID in the render metadata.`);
|
|
73
|
+
this.emitBuiltinSync(file.contents, metadata.id, {
|
|
74
|
+
skipFormat: metadata.skipFormat,
|
|
75
|
+
storage: metadata.storage,
|
|
76
|
+
extension: findFileExtension(file.path)
|
|
77
|
+
});
|
|
78
|
+
} else if (metadata.kind === "entry") this.emitEntrySync(file.contents, file.path, {
|
|
79
|
+
skipFormat: metadata.skipFormat,
|
|
80
|
+
storage: metadata.storage,
|
|
81
|
+
...metadata.typeDefinition ?? {}
|
|
82
|
+
});
|
|
83
|
+
else this.emitSync(file.contents, file.path, metadata);
|
|
84
|
+
} else this.fs.copySync(file.sourcePath, file.path);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}];
|
|
92
|
+
};
|
|
93
|
+
var src_default = plugin;
|
|
94
|
+
|
|
95
|
+
//#endregion
|
|
96
|
+
export { src_default as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_context = require('../core/contexts/context.cjs');
|
|
3
|
+
let unctx = require("unctx");
|
|
4
|
+
|
|
5
|
+
//#region ../plugin-alloy/src/internal/unctx.ts
|
|
6
|
+
const unctx$1 = (unctx.createContext.Ω = [[() => require_context.__ΩPowerlinesContextInterface, "\"\"o!#"]], (0, unctx.createContext)());
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.unctx = unctx$1;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { __ΩPowerlinesContextInterface } from "../core/contexts/context.mjs";
|
|
2
|
+
import { createContext } from "unctx";
|
|
3
|
+
|
|
4
|
+
//#region ../plugin-alloy/src/internal/unctx.ts
|
|
5
|
+
const unctx = (createContext.Ω = [[() => __ΩPowerlinesContextInterface, "\"\"o!#"]], createContext());
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { unctx };
|
|
@@ -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 };
|