@powerlines/plugin-webpack 0.5.137 → 0.5.138
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/helpers/unplugin.cjs +2 -3
- package/dist/helpers/unplugin.mjs +1 -2
- package/dist/index.cjs +3 -4
- package/dist/index.mjs +4 -5
- package/dist/powerlines/src/types/babel.d.mts +1 -3
- package/dist/powerlines/src/types/config.d.mts +1 -2
- package/dist/powerlines/src/types/context.d.mts +5 -5
- package/dist/powerlines/src/types/fs.d.mts +1 -1
- package/dist/powerlines/src/types/tsconfig.d.mts +1 -1
- package/package.json +5 -10
- package/dist/powerlines/schemas/fs.cjs +0 -226
- package/dist/powerlines/schemas/fs.mjs +0 -224
- package/dist/powerlines/src/api.cjs +0 -580
- package/dist/powerlines/src/api.mjs +0 -578
- package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +0 -86
- package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +0 -84
- package/dist/powerlines/src/internal/helpers/environment.cjs +0 -52
- package/dist/powerlines/src/internal/helpers/environment.mjs +0 -48
- package/dist/powerlines/src/internal/helpers/generate-types.cjs +0 -51
- package/dist/powerlines/src/internal/helpers/generate-types.mjs +0 -49
- package/dist/powerlines/src/internal/helpers/hooks.cjs +0 -66
- package/dist/powerlines/src/internal/helpers/hooks.mjs +0 -64
- package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +0 -25
- package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +0 -24
- package/dist/powerlines/src/internal/helpers/install.cjs +0 -37
- package/dist/powerlines/src/internal/helpers/install.mjs +0 -36
- package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +0 -98
- package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +0 -94
- package/dist/powerlines/src/internal/helpers/resolver.cjs +0 -43
- package/dist/powerlines/src/internal/helpers/resolver.mjs +0 -41
- package/dist/powerlines/src/lib/build/webpack.cjs +0 -47
- package/dist/powerlines/src/lib/build/webpack.mjs +0 -45
- package/dist/powerlines/src/lib/config-file.cjs +0 -79
- package/dist/powerlines/src/lib/config-file.mjs +0 -76
- package/dist/powerlines/src/lib/contexts/api-context.cjs +0 -184
- package/dist/powerlines/src/lib/contexts/api-context.mjs +0 -182
- package/dist/powerlines/src/lib/contexts/context.cjs +0 -933
- package/dist/powerlines/src/lib/contexts/context.mjs +0 -931
- package/dist/powerlines/src/lib/contexts/environment-context.cjs +0 -195
- package/dist/powerlines/src/lib/contexts/environment-context.mjs +0 -194
- package/dist/powerlines/src/lib/contexts/plugin-context.cjs +0 -75
- package/dist/powerlines/src/lib/contexts/plugin-context.mjs +0 -74
- package/dist/powerlines/src/lib/entry.cjs +0 -69
- package/dist/powerlines/src/lib/entry.mjs +0 -67
- package/dist/powerlines/src/lib/fs/helpers.cjs +0 -85
- package/dist/powerlines/src/lib/fs/helpers.mjs +0 -81
- package/dist/powerlines/src/lib/fs/storage/base.cjs +0 -196
- package/dist/powerlines/src/lib/fs/storage/base.mjs +0 -195
- package/dist/powerlines/src/lib/fs/storage/file-system.cjs +0 -170
- package/dist/powerlines/src/lib/fs/storage/file-system.mjs +0 -169
- package/dist/powerlines/src/lib/fs/storage/virtual.cjs +0 -88
- package/dist/powerlines/src/lib/fs/storage/virtual.mjs +0 -87
- package/dist/powerlines/src/lib/fs/vfs.cjs +0 -830
- package/dist/powerlines/src/lib/fs/vfs.mjs +0 -828
- package/dist/powerlines/src/lib/logger.cjs +0 -58
- package/dist/powerlines/src/lib/logger.mjs +0 -55
- package/dist/powerlines/src/lib/typescript/ts-morph.cjs +0 -104
- package/dist/powerlines/src/lib/typescript/ts-morph.mjs +0 -102
- package/dist/powerlines/src/lib/typescript/tsconfig.cjs +0 -149
- package/dist/powerlines/src/lib/typescript/tsconfig.mjs +0 -144
- package/dist/powerlines/src/lib/unplugin/factory.cjs +0 -6
- package/dist/powerlines/src/lib/unplugin/factory.mjs +0 -8
- package/dist/powerlines/src/lib/unplugin/helpers.cjs +0 -29
- package/dist/powerlines/src/lib/unplugin/helpers.mjs +0 -27
- package/dist/powerlines/src/lib/unplugin/index.cjs +0 -3
- package/dist/powerlines/src/lib/unplugin/index.mjs +0 -5
- package/dist/powerlines/src/lib/unplugin/plugin.cjs +0 -128
- package/dist/powerlines/src/lib/unplugin/plugin.mjs +0 -127
- package/dist/powerlines/src/lib/utilities/file-header.cjs +0 -22
- package/dist/powerlines/src/lib/utilities/file-header.mjs +0 -21
- package/dist/powerlines/src/lib/utilities/meta.cjs +0 -45
- package/dist/powerlines/src/lib/utilities/meta.mjs +0 -41
- package/dist/powerlines/src/lib/utilities/source-file.cjs +0 -22
- package/dist/powerlines/src/lib/utilities/source-file.mjs +0 -21
- package/dist/powerlines/src/plugin-utils/helpers.cjs +0 -167
- package/dist/powerlines/src/plugin-utils/helpers.mjs +0 -156
- package/dist/powerlines/src/plugin-utils/paths.cjs +0 -36
- package/dist/powerlines/src/plugin-utils/paths.mjs +0 -35
- package/dist/powerlines/src/types/build.cjs +0 -23
- package/dist/powerlines/src/types/build.mjs +0 -21
- package/dist/powerlines/src/types/commands.cjs +0 -16
- package/dist/powerlines/src/types/commands.mjs +0 -15
- package/dist/powerlines/src/types/plugin.cjs +0 -33
- package/dist/powerlines/src/types/plugin.mjs +0 -32
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { UNPLUGIN_BUILDER_VARIANTS } from "../../types/build.mjs";
|
|
2
|
-
import { defu } from "defu";
|
|
3
|
-
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
4
|
-
|
|
5
|
-
//#region ../powerlines/src/lib/unplugin/helpers.ts
|
|
6
|
-
/**
|
|
7
|
-
* Merges a base plugin context with an unplugin context, combining their properties.
|
|
8
|
-
*
|
|
9
|
-
* @param context - The base plugin context to merge into.
|
|
10
|
-
* @param unplugin - The unplugin context to merge from.
|
|
11
|
-
* @returns The merged context.
|
|
12
|
-
*/
|
|
13
|
-
function combineContexts(context, unplugin) {
|
|
14
|
-
return defu(context, unplugin);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Checks if a value is a valid UnpluginBuilderVariant.
|
|
18
|
-
*
|
|
19
|
-
* @param str - The value to check.
|
|
20
|
-
* @returns True if the value is a UnpluginBuilderVariant, false otherwise.
|
|
21
|
-
*/
|
|
22
|
-
function isUnpluginBuilderVariant(str) {
|
|
23
|
-
return isSetString(str) && UNPLUGIN_BUILDER_VARIANTS.includes(str);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
export { combineContexts, isUnpluginBuilderVariant };
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_logger = require('../logger.cjs');
|
|
3
|
-
const require_helpers = require('./helpers.cjs');
|
|
4
|
-
const require_source_file = require('../utilities/source-file.cjs');
|
|
5
|
-
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
6
|
-
let unplugin = require("unplugin");
|
|
7
|
-
let __stryke_path_replace = require("@stryke/path/replace");
|
|
8
|
-
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
9
|
-
let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
10
|
-
|
|
11
|
-
//#region ../powerlines/src/lib/unplugin/plugin.ts
|
|
12
|
-
/**
|
|
13
|
-
* Creates a Powerlines unplugin instance.
|
|
14
|
-
*
|
|
15
|
-
* @param context - The plugin context.
|
|
16
|
-
* @returns The unplugin instance.
|
|
17
|
-
*/
|
|
18
|
-
function createUnplugin(context) {
|
|
19
|
-
const ctx = context;
|
|
20
|
-
(0, unplugin.setParseImpl)(ctx.parse);
|
|
21
|
-
return () => {
|
|
22
|
-
const log = require_logger.extendLog(ctx.log, "unplugin");
|
|
23
|
-
log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, "Initializing Unplugin");
|
|
24
|
-
try {
|
|
25
|
-
async function buildStart() {
|
|
26
|
-
log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, "Powerlines build plugin starting...");
|
|
27
|
-
await ctx.$$internal.callHook("buildStart", { sequential: true });
|
|
28
|
-
}
|
|
29
|
-
async function resolveId(id, importer, opts = { isEntry: false }) {
|
|
30
|
-
const resolved = await (async () => {
|
|
31
|
-
let result = await ctx.$$internal.callHook("resolveId", {
|
|
32
|
-
sequential: true,
|
|
33
|
-
result: "first",
|
|
34
|
-
order: "pre"
|
|
35
|
-
}, id, importer, opts);
|
|
36
|
-
if (result) return result;
|
|
37
|
-
result = await ctx.$$internal.callHook("resolveId", {
|
|
38
|
-
sequential: true,
|
|
39
|
-
result: "first",
|
|
40
|
-
order: "normal"
|
|
41
|
-
}, id, importer, opts);
|
|
42
|
-
if (result) return result;
|
|
43
|
-
result = await ctx.resolve(id, importer, opts);
|
|
44
|
-
if (result) return result;
|
|
45
|
-
return ctx.$$internal.callHook("resolveId", {
|
|
46
|
-
sequential: true,
|
|
47
|
-
result: "first",
|
|
48
|
-
order: "post"
|
|
49
|
-
}, id, importer, opts);
|
|
50
|
-
})();
|
|
51
|
-
if (resolved && opts.isEntry && ctx.config.build.polyfill && ctx.config.build.polyfill.length > 0) {
|
|
52
|
-
const entry = ctx.entry.find((entry$1) => entry$1.file === ((0, __stryke_type_checks_is_string.isString)(resolved) ? resolved : resolved.id));
|
|
53
|
-
if (entry) {
|
|
54
|
-
entry.file = `${(0, __stryke_path_replace.replaceExtension)((0, __stryke_type_checks_is_string.isString)(resolved) ? resolved : resolved.id)}-polyfill.ts`;
|
|
55
|
-
entry.output ||= entry.output?.replace((0, __stryke_path_file_path_fns.findFileName)(entry.output, { withExtension: true }), entry.file);
|
|
56
|
-
await ctx.emitEntry(`
|
|
57
|
-
${ctx.config.build.polyfill.map((p) => `import "${p}";`).join("\n")}
|
|
58
|
-
|
|
59
|
-
export * from "${(0, __stryke_type_checks_is_string.isString)(resolved) ? resolved : resolved.id}";
|
|
60
|
-
`, entry.file);
|
|
61
|
-
return entry.file;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return resolved;
|
|
65
|
-
}
|
|
66
|
-
async function load(id) {
|
|
67
|
-
let result = await ctx.$$internal.callHook("load", {
|
|
68
|
-
sequential: true,
|
|
69
|
-
result: "first",
|
|
70
|
-
order: "pre"
|
|
71
|
-
}, id);
|
|
72
|
-
if (result) return result;
|
|
73
|
-
result = await ctx.$$internal.callHook("load", {
|
|
74
|
-
sequential: true,
|
|
75
|
-
result: "first",
|
|
76
|
-
order: "normal"
|
|
77
|
-
}, id);
|
|
78
|
-
if (result) return result;
|
|
79
|
-
result = await ctx.load(id);
|
|
80
|
-
if (result) return result;
|
|
81
|
-
return ctx.$$internal.callHook("load", {
|
|
82
|
-
sequential: true,
|
|
83
|
-
result: "first",
|
|
84
|
-
order: "post"
|
|
85
|
-
}, id);
|
|
86
|
-
}
|
|
87
|
-
async function transform(code, id) {
|
|
88
|
-
let transformed = code;
|
|
89
|
-
for (const hook of ctx.$$internal.environment.selectHooks("transform")) {
|
|
90
|
-
const result = await hook.handler.apply(require_helpers.combineContexts(ctx, this), [require_source_file.getString(transformed), id]);
|
|
91
|
-
if (result) transformed = result;
|
|
92
|
-
}
|
|
93
|
-
return transformed;
|
|
94
|
-
}
|
|
95
|
-
async function buildEnd() {
|
|
96
|
-
log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, "Powerlines build plugin finishing...");
|
|
97
|
-
return ctx.$$internal.callHook("buildEnd", { sequential: true });
|
|
98
|
-
}
|
|
99
|
-
async function writeBundle() {
|
|
100
|
-
log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, "Finalizing Powerlines project output...");
|
|
101
|
-
return ctx.$$internal.callHook("writeBundle", { sequential: true });
|
|
102
|
-
}
|
|
103
|
-
return {
|
|
104
|
-
name: "powerlines",
|
|
105
|
-
api: ctx.$$internal.api,
|
|
106
|
-
resolveId: {
|
|
107
|
-
filter: { id: { include: [/.*/] } },
|
|
108
|
-
handler: resolveId
|
|
109
|
-
},
|
|
110
|
-
load: {
|
|
111
|
-
filter: { id: { include: [/.*/] } },
|
|
112
|
-
handler: load
|
|
113
|
-
},
|
|
114
|
-
transform,
|
|
115
|
-
buildStart,
|
|
116
|
-
buildEnd,
|
|
117
|
-
writeBundle,
|
|
118
|
-
vite: { sharedDuringBuild: true }
|
|
119
|
-
};
|
|
120
|
-
} catch (error) {
|
|
121
|
-
log(__storm_software_config_tools_types.LogLevelLabel.FATAL, error?.message);
|
|
122
|
-
throw error;
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
//#endregion
|
|
128
|
-
exports.createUnplugin = createUnplugin;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { extendLog } from "../logger.mjs";
|
|
2
|
-
import { combineContexts } from "./helpers.mjs";
|
|
3
|
-
import { getString } from "../utilities/source-file.mjs";
|
|
4
|
-
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
5
|
-
import { setParseImpl } from "unplugin";
|
|
6
|
-
import { replaceExtension } from "@stryke/path/replace";
|
|
7
|
-
import { isString } from "@stryke/type-checks/is-string";
|
|
8
|
-
import { findFileName } from "@stryke/path/file-path-fns";
|
|
9
|
-
|
|
10
|
-
//#region ../powerlines/src/lib/unplugin/plugin.ts
|
|
11
|
-
/**
|
|
12
|
-
* Creates a Powerlines unplugin instance.
|
|
13
|
-
*
|
|
14
|
-
* @param context - The plugin context.
|
|
15
|
-
* @returns The unplugin instance.
|
|
16
|
-
*/
|
|
17
|
-
function createUnplugin(context) {
|
|
18
|
-
const ctx = context;
|
|
19
|
-
setParseImpl(ctx.parse);
|
|
20
|
-
return () => {
|
|
21
|
-
const log = extendLog(ctx.log, "unplugin");
|
|
22
|
-
log(LogLevelLabel.DEBUG, "Initializing Unplugin");
|
|
23
|
-
try {
|
|
24
|
-
async function buildStart() {
|
|
25
|
-
log(LogLevelLabel.DEBUG, "Powerlines build plugin starting...");
|
|
26
|
-
await ctx.$$internal.callHook("buildStart", { sequential: true });
|
|
27
|
-
}
|
|
28
|
-
async function resolveId(id, importer, opts = { isEntry: false }) {
|
|
29
|
-
const resolved = await (async () => {
|
|
30
|
-
let result = await ctx.$$internal.callHook("resolveId", {
|
|
31
|
-
sequential: true,
|
|
32
|
-
result: "first",
|
|
33
|
-
order: "pre"
|
|
34
|
-
}, id, importer, opts);
|
|
35
|
-
if (result) return result;
|
|
36
|
-
result = await ctx.$$internal.callHook("resolveId", {
|
|
37
|
-
sequential: true,
|
|
38
|
-
result: "first",
|
|
39
|
-
order: "normal"
|
|
40
|
-
}, id, importer, opts);
|
|
41
|
-
if (result) return result;
|
|
42
|
-
result = await ctx.resolve(id, importer, opts);
|
|
43
|
-
if (result) return result;
|
|
44
|
-
return ctx.$$internal.callHook("resolveId", {
|
|
45
|
-
sequential: true,
|
|
46
|
-
result: "first",
|
|
47
|
-
order: "post"
|
|
48
|
-
}, id, importer, opts);
|
|
49
|
-
})();
|
|
50
|
-
if (resolved && opts.isEntry && ctx.config.build.polyfill && ctx.config.build.polyfill.length > 0) {
|
|
51
|
-
const entry = ctx.entry.find((entry$1) => entry$1.file === (isString(resolved) ? resolved : resolved.id));
|
|
52
|
-
if (entry) {
|
|
53
|
-
entry.file = `${replaceExtension(isString(resolved) ? resolved : resolved.id)}-polyfill.ts`;
|
|
54
|
-
entry.output ||= entry.output?.replace(findFileName(entry.output, { withExtension: true }), entry.file);
|
|
55
|
-
await ctx.emitEntry(`
|
|
56
|
-
${ctx.config.build.polyfill.map((p) => `import "${p}";`).join("\n")}
|
|
57
|
-
|
|
58
|
-
export * from "${isString(resolved) ? resolved : resolved.id}";
|
|
59
|
-
`, entry.file);
|
|
60
|
-
return entry.file;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return resolved;
|
|
64
|
-
}
|
|
65
|
-
async function load(id) {
|
|
66
|
-
let result = await ctx.$$internal.callHook("load", {
|
|
67
|
-
sequential: true,
|
|
68
|
-
result: "first",
|
|
69
|
-
order: "pre"
|
|
70
|
-
}, id);
|
|
71
|
-
if (result) return result;
|
|
72
|
-
result = await ctx.$$internal.callHook("load", {
|
|
73
|
-
sequential: true,
|
|
74
|
-
result: "first",
|
|
75
|
-
order: "normal"
|
|
76
|
-
}, id);
|
|
77
|
-
if (result) return result;
|
|
78
|
-
result = await ctx.load(id);
|
|
79
|
-
if (result) return result;
|
|
80
|
-
return ctx.$$internal.callHook("load", {
|
|
81
|
-
sequential: true,
|
|
82
|
-
result: "first",
|
|
83
|
-
order: "post"
|
|
84
|
-
}, id);
|
|
85
|
-
}
|
|
86
|
-
async function transform(code, id) {
|
|
87
|
-
let transformed = code;
|
|
88
|
-
for (const hook of ctx.$$internal.environment.selectHooks("transform")) {
|
|
89
|
-
const result = await hook.handler.apply(combineContexts(ctx, this), [getString(transformed), id]);
|
|
90
|
-
if (result) transformed = result;
|
|
91
|
-
}
|
|
92
|
-
return transformed;
|
|
93
|
-
}
|
|
94
|
-
async function buildEnd() {
|
|
95
|
-
log(LogLevelLabel.DEBUG, "Powerlines build plugin finishing...");
|
|
96
|
-
return ctx.$$internal.callHook("buildEnd", { sequential: true });
|
|
97
|
-
}
|
|
98
|
-
async function writeBundle() {
|
|
99
|
-
log(LogLevelLabel.DEBUG, "Finalizing Powerlines project output...");
|
|
100
|
-
return ctx.$$internal.callHook("writeBundle", { sequential: true });
|
|
101
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
name: "powerlines",
|
|
104
|
-
api: ctx.$$internal.api,
|
|
105
|
-
resolveId: {
|
|
106
|
-
filter: { id: { include: [/.*/] } },
|
|
107
|
-
handler: resolveId
|
|
108
|
-
},
|
|
109
|
-
load: {
|
|
110
|
-
filter: { id: { include: [/.*/] } },
|
|
111
|
-
handler: load
|
|
112
|
-
},
|
|
113
|
-
transform,
|
|
114
|
-
buildStart,
|
|
115
|
-
buildEnd,
|
|
116
|
-
writeBundle,
|
|
117
|
-
vite: { sharedDuringBuild: true }
|
|
118
|
-
};
|
|
119
|
-
} catch (error) {
|
|
120
|
-
log(LogLevelLabel.FATAL, error?.message);
|
|
121
|
-
throw error;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
//#endregion
|
|
127
|
-
export { createUnplugin };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
3
|
-
|
|
4
|
-
//#region ../powerlines/src/lib/utilities/file-header.ts
|
|
5
|
-
function getBaseFileHeader(context) {
|
|
6
|
-
return `
|
|
7
|
-
// Generated with ${(0, __stryke_string_format_title_case.titleCase)(context.config.framework)}
|
|
8
|
-
// Note: Do not edit this file manually - it will be overwritten automatically
|
|
9
|
-
`;
|
|
10
|
-
}
|
|
11
|
-
function getFileHeader(context, options = {}) {
|
|
12
|
-
const { directive = null, prettierIgnore = false } = options;
|
|
13
|
-
return `/* eslint-disable */
|
|
14
|
-
// biome-ignore lint: disable
|
|
15
|
-
${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
|
|
16
|
-
${getBaseFileHeader(context)}
|
|
17
|
-
|
|
18
|
-
`;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
exports.getFileHeader = getFileHeader;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { titleCase } from "@stryke/string-format/title-case";
|
|
2
|
-
|
|
3
|
-
//#region ../powerlines/src/lib/utilities/file-header.ts
|
|
4
|
-
function getBaseFileHeader(context) {
|
|
5
|
-
return `
|
|
6
|
-
// Generated with ${titleCase(context.config.framework)}
|
|
7
|
-
// Note: Do not edit this file manually - it will be overwritten automatically
|
|
8
|
-
`;
|
|
9
|
-
}
|
|
10
|
-
function getFileHeader(context, options = {}) {
|
|
11
|
-
const { directive = null, prettierIgnore = false } = options;
|
|
12
|
-
return `/* eslint-disable */
|
|
13
|
-
// biome-ignore lint: disable
|
|
14
|
-
${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
|
|
15
|
-
${getBaseFileHeader(context)}
|
|
16
|
-
|
|
17
|
-
`;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { getFileHeader };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
3
|
-
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
4
|
-
let __stryke_fs_list_files = require("@stryke/fs/list-files");
|
|
5
|
-
let __stryke_fs_json = require("@stryke/fs/json");
|
|
6
|
-
let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
7
|
-
let __stryke_fs_exists = require("@stryke/fs/exists");
|
|
8
|
-
let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
9
|
-
let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
|
|
10
|
-
require("@stryke/fs/remove-file");
|
|
11
|
-
|
|
12
|
-
//#region ../powerlines/src/lib/utilities/meta.ts
|
|
13
|
-
const PROJECT_ROOT_HASH_LENGTH = 45;
|
|
14
|
-
const CACHE_HASH_LENGTH = 62;
|
|
15
|
-
/**
|
|
16
|
-
* Generates a prefixed project root hash object.
|
|
17
|
-
*
|
|
18
|
-
* @remarks
|
|
19
|
-
* This function returns a string where the project root hash is prefixed with the project name plus a hyphen. If the total length of this string combination exceeds 45 characters, it will truncate the hash.
|
|
20
|
-
*
|
|
21
|
-
* @param name - The name of the project.
|
|
22
|
-
* @param projectRootHash - The hash of the project root.
|
|
23
|
-
* @returns An object containing the name and project root hash.
|
|
24
|
-
*/
|
|
25
|
-
function getPrefixedProjectRootHash(name, projectRootHash) {
|
|
26
|
-
const combined = `${(0, __stryke_string_format_kebab_case.kebabCase)(name)}_${projectRootHash}`;
|
|
27
|
-
return combined.length > PROJECT_ROOT_HASH_LENGTH ? combined.slice(0, PROJECT_ROOT_HASH_LENGTH) : combined;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Writes the meta file for the context.
|
|
31
|
-
*
|
|
32
|
-
* @param context - The context to write the meta file for.
|
|
33
|
-
* @returns A promise that resolves when the meta file has been written.
|
|
34
|
-
*/
|
|
35
|
-
async function writeMetaFile(context) {
|
|
36
|
-
const metaFilePath = (0, __stryke_path_join_paths.joinPaths)(context.dataPath, "meta.json");
|
|
37
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, `Writing runtime metadata to ${metaFilePath}`);
|
|
38
|
-
await context.fs.write(metaFilePath, JSON.stringify(context.meta, null, 2));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
exports.CACHE_HASH_LENGTH = CACHE_HASH_LENGTH;
|
|
43
|
-
exports.PROJECT_ROOT_HASH_LENGTH = PROJECT_ROOT_HASH_LENGTH;
|
|
44
|
-
exports.getPrefixedProjectRootHash = getPrefixedProjectRootHash;
|
|
45
|
-
exports.writeMetaFile = writeMetaFile;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
2
|
-
import { joinPaths } from "@stryke/path/join-paths";
|
|
3
|
-
import { listFiles } from "@stryke/fs/list-files";
|
|
4
|
-
import { readJsonFile } from "@stryke/fs/json";
|
|
5
|
-
import { hasFileExtension } from "@stryke/path/file-path-fns";
|
|
6
|
-
import { existsSync } from "@stryke/fs/exists";
|
|
7
|
-
import { getUnique } from "@stryke/helpers/get-unique";
|
|
8
|
-
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
9
|
-
import "@stryke/fs/remove-file";
|
|
10
|
-
|
|
11
|
-
//#region ../powerlines/src/lib/utilities/meta.ts
|
|
12
|
-
const PROJECT_ROOT_HASH_LENGTH = 45;
|
|
13
|
-
const CACHE_HASH_LENGTH = 62;
|
|
14
|
-
/**
|
|
15
|
-
* Generates a prefixed project root hash object.
|
|
16
|
-
*
|
|
17
|
-
* @remarks
|
|
18
|
-
* This function returns a string where the project root hash is prefixed with the project name plus a hyphen. If the total length of this string combination exceeds 45 characters, it will truncate the hash.
|
|
19
|
-
*
|
|
20
|
-
* @param name - The name of the project.
|
|
21
|
-
* @param projectRootHash - The hash of the project root.
|
|
22
|
-
* @returns An object containing the name and project root hash.
|
|
23
|
-
*/
|
|
24
|
-
function getPrefixedProjectRootHash(name, projectRootHash) {
|
|
25
|
-
const combined = `${kebabCase(name)}_${projectRootHash}`;
|
|
26
|
-
return combined.length > PROJECT_ROOT_HASH_LENGTH ? combined.slice(0, PROJECT_ROOT_HASH_LENGTH) : combined;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Writes the meta file for the context.
|
|
30
|
-
*
|
|
31
|
-
* @param context - The context to write the meta file for.
|
|
32
|
-
* @returns A promise that resolves when the meta file has been written.
|
|
33
|
-
*/
|
|
34
|
-
async function writeMetaFile(context) {
|
|
35
|
-
const metaFilePath = joinPaths(context.dataPath, "meta.json");
|
|
36
|
-
context.log(LogLevelLabel.DEBUG, `Writing runtime metadata to ${metaFilePath}`);
|
|
37
|
-
await context.fs.write(metaFilePath, JSON.stringify(context.meta, null, 2));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
export { CACHE_HASH_LENGTH, PROJECT_ROOT_HASH_LENGTH, getPrefixedProjectRootHash, writeMetaFile };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
3
|
-
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
4
|
-
let __stryke_fs_read_file = require("@stryke/fs/read-file");
|
|
5
|
-
require("magic-string");
|
|
6
|
-
|
|
7
|
-
//#region ../powerlines/src/lib/utilities/source-file.ts
|
|
8
|
-
/**
|
|
9
|
-
* Get the string from the source.
|
|
10
|
-
*
|
|
11
|
-
* @param code - The source string or magic string.
|
|
12
|
-
* @returns The source string.
|
|
13
|
-
*/
|
|
14
|
-
function getString(code) {
|
|
15
|
-
if (!code) return "";
|
|
16
|
-
if ((0, __stryke_type_checks_is_string.isString)(code)) return code;
|
|
17
|
-
if ((0, __stryke_type_checks_is_set_object.isSetObject)(code) && "code" in code) return code.code;
|
|
18
|
-
return code.toString();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
exports.getString = getString;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
2
|
-
import { isString } from "@stryke/type-checks/is-string";
|
|
3
|
-
import "@stryke/fs/read-file";
|
|
4
|
-
import "magic-string";
|
|
5
|
-
|
|
6
|
-
//#region ../powerlines/src/lib/utilities/source-file.ts
|
|
7
|
-
/**
|
|
8
|
-
* Get the string from the source.
|
|
9
|
-
*
|
|
10
|
-
* @param code - The source string or magic string.
|
|
11
|
-
* @returns The source string.
|
|
12
|
-
*/
|
|
13
|
-
function getString(code) {
|
|
14
|
-
if (!code) return "";
|
|
15
|
-
if (isString(code)) return code;
|
|
16
|
-
if (isSetObject(code) && "code" in code) return code.code;
|
|
17
|
-
return code.toString();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { getString };
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_build = require('../types/build.cjs');
|
|
3
|
-
const require_plugin = require('../types/plugin.cjs');
|
|
4
|
-
let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
5
|
-
let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
6
|
-
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
7
|
-
let __stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
|
|
8
|
-
|
|
9
|
-
//#region ../powerlines/src/plugin-utils/helpers.ts
|
|
10
|
-
/**
|
|
11
|
-
* Type guard to check if an object is a {@link Plugin}
|
|
12
|
-
*
|
|
13
|
-
* @param value - The object to check
|
|
14
|
-
* @returns True if the object is a {@link Plugin}, false otherwise
|
|
15
|
-
*/
|
|
16
|
-
function isPlugin(value) {
|
|
17
|
-
return (0, __stryke_type_checks_is_set_object.isSetObject)(value) && "name" in value && (0, __stryke_type_checks_is_set_string.isSetString)(value.name) && ((0, __stryke_type_checks_is_undefined.isUndefined)(value.api) || "api" in value && (0, __stryke_type_checks_is_set_object.isSetObject)(value.api)) && ((0, __stryke_type_checks_is_undefined.isUndefined)(value.applyToEnvironment) || "applyToEnvironment" in value && (0, __stryke_type_checks_is_function.isFunction)(value.applyToEnvironment)) && ((0, __stryke_type_checks_is_undefined.isUndefined)(value.dedupe) || "dedupe" in value && (0, __stryke_type_checks_is_function.isFunction)(value.dedupe)) && require_plugin.PLUGIN_HOOKS_FIELDS.every((hook) => (0, __stryke_type_checks_is_undefined.isUndefined)(value[hook]) || hook in value && (isPluginHookFunction(value[hook]) || hook === "config" && (0, __stryke_type_checks_is_set_object.isSetObject)(value[hook]))) && require_build.BUILDER_VARIANTS.every((variant) => (0, __stryke_type_checks_is_undefined.isUndefined)(value[variant]) || variant in value && (0, __stryke_type_checks_is_set_object.isSetObject)(value[variant]));
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Type guard to check if an object is a {@link PluginConfigObject}
|
|
21
|
-
*
|
|
22
|
-
* @param value - The object to check
|
|
23
|
-
* @returns True if the object is a {@link PluginConfigObject}, false otherwise
|
|
24
|
-
*/
|
|
25
|
-
function isPluginConfigObject(value) {
|
|
26
|
-
return (0, __stryke_type_checks_is_set_object.isSetObject)(value) && "plugin" in value && (((0, __stryke_type_checks_is_set_string.isSetString)(value.plugin) || (0, __stryke_type_checks_is_function.isFunction)(value.plugin)) && "options" in value && (0, __stryke_type_checks_is_set_object.isSetObject)(value.options) || isPlugin(value.plugin));
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Type guard to check if an object is a {@link PluginConfigTuple}
|
|
30
|
-
*
|
|
31
|
-
* @param value - The object to check
|
|
32
|
-
* @returns True if the object is a {@link PluginConfigTuple}, false otherwise
|
|
33
|
-
*/
|
|
34
|
-
function isPluginConfigTuple(value) {
|
|
35
|
-
return Array.isArray(value) && (value.length === 1 || value.length === 2) && (((0, __stryke_type_checks_is_set_string.isSetString)(value[0]) || (0, __stryke_type_checks_is_function.isFunction)(value[0])) && value.length > 1 && (0, __stryke_type_checks_is_set_object.isSetObject)(value[1]) || isPlugin(value[0]));
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Type guard to check if an object is a {@link PluginConfig}
|
|
39
|
-
*
|
|
40
|
-
* @param value - The object to check
|
|
41
|
-
* @returns True if the object is a {@link PluginConfig}, false otherwise
|
|
42
|
-
*/
|
|
43
|
-
function isPluginConfig(value) {
|
|
44
|
-
return (0, __stryke_type_checks_is_set_string.isSetString)(value) || (0, __stryke_type_checks_is_function.isFunction)(value) || isPlugin(value) || isPluginConfigObject(value) || isPluginConfigTuple(value) || Array.isArray(value) && value.every((item) => isPluginConfig(item));
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Type guard to check if an value is a {@link PluginHook} function
|
|
48
|
-
*
|
|
49
|
-
* @param value - The value to check
|
|
50
|
-
* @returns True if the value is a {@link PluginHook} function, false otherwise
|
|
51
|
-
*/
|
|
52
|
-
function isPluginHookObject(value) {
|
|
53
|
-
return (0, __stryke_type_checks_is_set_object.isSetObject)(value) && "handler" in value && (0, __stryke_type_checks_is_function.isFunction)(value.handler);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Type guard to check if an value is a {@link PluginHook} function
|
|
57
|
-
*
|
|
58
|
-
* @param value - The value to check
|
|
59
|
-
* @returns True if the value is a {@link PluginHook} function, false otherwise
|
|
60
|
-
*/
|
|
61
|
-
function isPluginHookFunction(value) {
|
|
62
|
-
return (0, __stryke_type_checks_is_function.isFunction)(value) || isPluginHookObject(value);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Type guard to check if an object is a {@link PluginHook}
|
|
66
|
-
*
|
|
67
|
-
* @param value - The object to check
|
|
68
|
-
* @returns True if the object is a {@link PluginHook}, false otherwise
|
|
69
|
-
*/
|
|
70
|
-
function isPluginHook(value) {
|
|
71
|
-
return isPluginHookFunction(value) || isPluginHookObject(value);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Extract the hook handler function from a plugin hook
|
|
75
|
-
*
|
|
76
|
-
* @param pluginHook - The plugin hook to extract the handler function from
|
|
77
|
-
* @returns The hook handler function
|
|
78
|
-
*/
|
|
79
|
-
function getHookHandler(pluginHook) {
|
|
80
|
-
return (0, __stryke_type_checks_is_function.isFunction)(pluginHook) ? pluginHook : pluginHook.handler;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Check if a hook is external.
|
|
84
|
-
*
|
|
85
|
-
* @param keys - The name of the hook to check.
|
|
86
|
-
* @returns True if the hook is external, false otherwise.
|
|
87
|
-
*/
|
|
88
|
-
function isUnpluginHookKey(keys) {
|
|
89
|
-
return require_build.UNPLUGIN_BUILDER_VARIANTS.some((variant) => keys.startsWith(`${variant}:`));
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Check if a hook is internal.
|
|
93
|
-
*
|
|
94
|
-
* @param keys - The name of the hook to check.
|
|
95
|
-
* @returns True if the hook is external, false otherwise.
|
|
96
|
-
*/
|
|
97
|
-
function isPluginHookField(keys) {
|
|
98
|
-
return !isUnpluginHookKey(keys) && require_plugin.PLUGIN_HOOKS_FIELDS.includes(keys);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Check if a hook is external.
|
|
102
|
-
*
|
|
103
|
-
* @param field - The name of the hook to check.
|
|
104
|
-
* @returns True if the hook is external, false otherwise.
|
|
105
|
-
*/
|
|
106
|
-
function isUnpluginHookField(field) {
|
|
107
|
-
return !isPluginHookField(field) && require_build.UNPLUGIN_BUILDER_VARIANTS.includes(field);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Check if a plugin should be deduplicated.
|
|
111
|
-
*
|
|
112
|
-
* @param plugin - The plugin to check
|
|
113
|
-
* @param plugins - The list of plugins to check against
|
|
114
|
-
* @returns True if the plugin should be deduplicated, false otherwise
|
|
115
|
-
*/
|
|
116
|
-
function checkDedupe(plugin, plugins) {
|
|
117
|
-
return plugin.dedupe === false || plugins.some((p) => p.dedupe !== false && ((0, __stryke_type_checks_is_function.isFunction)(p.dedupe) && p.dedupe(plugin) || p.name === plugin.name));
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Add a plugin hook to the hooks list.
|
|
121
|
-
*
|
|
122
|
-
* @param context - The plugin context
|
|
123
|
-
* @param plugin - The plugin to add the hook from
|
|
124
|
-
* @param pluginHook - The plugin hook to add
|
|
125
|
-
* @param hooksList - The list of hooks to add to
|
|
126
|
-
*/
|
|
127
|
-
function addPluginHook(context, plugin, pluginHook, hooksList) {
|
|
128
|
-
if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin).filter(Boolean))) {
|
|
129
|
-
const handler = ((...args) => getHookHandler(pluginHook).apply(context, args));
|
|
130
|
-
if (!handler) return;
|
|
131
|
-
hooksList.push({
|
|
132
|
-
plugin,
|
|
133
|
-
handler
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Check the provided {@link PluginConfig}, and return a stringified version of the invalid configuration. If an array is provided, check each item in the array.
|
|
139
|
-
*
|
|
140
|
-
* @param config - The plugin configuration to check
|
|
141
|
-
* @returns Null if the configuration is valid, otherwise an array of stringified invalid configurations
|
|
142
|
-
*/
|
|
143
|
-
function findInvalidPluginConfig(config) {
|
|
144
|
-
if (isPluginConfig(config)) return null;
|
|
145
|
-
if (Array.isArray(config)) {
|
|
146
|
-
const invalidItems = [];
|
|
147
|
-
config.forEach((item) => {
|
|
148
|
-
const invalid = findInvalidPluginConfig(item);
|
|
149
|
-
if (invalid) invalidItems.push(...invalid.map((i) => JSON.stringify(i, null, 2)));
|
|
150
|
-
});
|
|
151
|
-
return invalidItems.length > 0 ? invalidItems : null;
|
|
152
|
-
}
|
|
153
|
-
return [JSON.stringify(config, null, 2)];
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
//#endregion
|
|
157
|
-
exports.addPluginHook = addPluginHook;
|
|
158
|
-
exports.checkDedupe = checkDedupe;
|
|
159
|
-
exports.findInvalidPluginConfig = findInvalidPluginConfig;
|
|
160
|
-
exports.isPlugin = isPlugin;
|
|
161
|
-
exports.isPluginConfig = isPluginConfig;
|
|
162
|
-
exports.isPluginConfigObject = isPluginConfigObject;
|
|
163
|
-
exports.isPluginConfigTuple = isPluginConfigTuple;
|
|
164
|
-
exports.isPluginHook = isPluginHook;
|
|
165
|
-
exports.isPluginHookField = isPluginHookField;
|
|
166
|
-
exports.isUnpluginHookField = isUnpluginHookField;
|
|
167
|
-
exports.isUnpluginHookKey = isUnpluginHookKey;
|