@powerlines/plugin-style-dictionary 0.3.577 → 0.3.579
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +135 -6
- package/dist/index.mjs +104 -1
- package/package.json +6 -6
- package/dist/_virtual/_rolldown/runtime.cjs +0 -28
- package/dist/helpers/resolve-hooks.cjs +0 -92
- package/dist/helpers/resolve-hooks.mjs +0 -93
- package/dist/helpers/resolve-hooks.mjs.map +0 -1
- package/dist/style-dictionary/file-header.cjs +0 -16
- package/dist/style-dictionary/file-header.mjs +0 -17
- package/dist/style-dictionary/file-header.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,143 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: ((k) => from[k]).bind(null, key),
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
require('./types/index.cjs');
|
|
4
30
|
let _power_plant_style_dictionary = require("@power-plant/style-dictionary");
|
|
5
|
-
_power_plant_style_dictionary =
|
|
31
|
+
_power_plant_style_dictionary = __toESM(_power_plant_style_dictionary, 1);
|
|
6
32
|
let _powerlines_plugin_power_plant = require("@powerlines/plugin-power-plant");
|
|
7
|
-
_powerlines_plugin_power_plant =
|
|
33
|
+
_powerlines_plugin_power_plant = __toESM(_powerlines_plugin_power_plant, 1);
|
|
8
34
|
let _storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
9
35
|
let defu = require("defu");
|
|
10
|
-
defu =
|
|
36
|
+
defu = __toESM(defu, 1);
|
|
37
|
+
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
38
|
+
let powerlines_schema = require("powerlines/schema");
|
|
39
|
+
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
40
|
+
|
|
41
|
+
//#region src/style-dictionary/file-header.ts
|
|
42
|
+
const fileHeader = (context) => ({
|
|
43
|
+
name: "powerlines/file-header",
|
|
44
|
+
fileHeader: (defaultMessages = []) => {
|
|
45
|
+
return [
|
|
46
|
+
`Generated by ${(0, _stryke_string_format_title_case.titleCase)(context.config.framework?.name) || "Powerlines"}`,
|
|
47
|
+
"NOTE: Do not edit this file manually - it will be overwritten automatically by the \"prepare\" command",
|
|
48
|
+
...defaultMessages
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
11
52
|
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/helpers/resolve-hooks.ts
|
|
55
|
+
async function resolveBuilder(context, input) {
|
|
56
|
+
if ((0, _stryke_type_checks_is_function.isFunction)(input)) return input;
|
|
57
|
+
return (0, powerlines_schema.resolve)(context, input);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Resolves Powerlines Style Dictionary custom hook builders into a Style
|
|
61
|
+
* Dictionary {@link Hooks} config object for `@power-plant/style-dictionary`.
|
|
62
|
+
*/
|
|
63
|
+
async function resolveStyleDictionaryHooks(context, options) {
|
|
64
|
+
const hooks = {};
|
|
65
|
+
const defaultFileHeader = fileHeader(context);
|
|
66
|
+
hooks.fileHeaders = { [defaultFileHeader.name]: defaultFileHeader.fileHeader };
|
|
67
|
+
if (options.customActions) {
|
|
68
|
+
const builder = await resolveBuilder(context, options.customActions);
|
|
69
|
+
const actions = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
70
|
+
hooks.actions = {
|
|
71
|
+
...hooks.actions,
|
|
72
|
+
...Object.fromEntries(Object.entries(actions).map(([name, action]) => {
|
|
73
|
+
const { name: _actionName, ...rest } = action;
|
|
74
|
+
return [name, rest];
|
|
75
|
+
}))
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (options.customFileHeaders) {
|
|
79
|
+
const builder = await resolveBuilder(context, options.customFileHeaders);
|
|
80
|
+
const fileHeaders = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
81
|
+
hooks.fileHeaders = {
|
|
82
|
+
...hooks.fileHeaders,
|
|
83
|
+
...fileHeaders
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (options.customFilters) {
|
|
87
|
+
const builder = await resolveBuilder(context, options.customFilters);
|
|
88
|
+
const filters = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
89
|
+
hooks.filters = {
|
|
90
|
+
...hooks.filters,
|
|
91
|
+
...Object.fromEntries(Object.entries(filters).map(([name, filter]) => [name, filter.filter]))
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (options.customFormats) {
|
|
95
|
+
const builder = await resolveBuilder(context, options.customFormats);
|
|
96
|
+
const formats = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
97
|
+
hooks.formats = {
|
|
98
|
+
...hooks.formats,
|
|
99
|
+
...Object.fromEntries(Object.entries(formats).map(([name, format]) => [name, format.format]))
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (options.customPreprocessors) {
|
|
103
|
+
const builder = await resolveBuilder(context, options.customPreprocessors);
|
|
104
|
+
const preprocessors = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
105
|
+
hooks.preprocessors = {
|
|
106
|
+
...hooks.preprocessors,
|
|
107
|
+
...Object.fromEntries(Object.entries(preprocessors).map(([name, preprocessor]) => [name, preprocessor.preprocessor]))
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
if (options.customParsers) {
|
|
111
|
+
const builder = await resolveBuilder(context, options.customParsers);
|
|
112
|
+
const parsers = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
113
|
+
hooks.parsers = {
|
|
114
|
+
...hooks.parsers,
|
|
115
|
+
...Object.fromEntries(parsers.map(({ name, ...parser }) => [name, parser]))
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (options.customTransforms) {
|
|
119
|
+
const builder = await resolveBuilder(context, options.customTransforms);
|
|
120
|
+
const transforms = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
121
|
+
hooks.transforms = {
|
|
122
|
+
...hooks.transforms,
|
|
123
|
+
...Object.fromEntries(Object.entries(transforms).map(([name, transform]) => {
|
|
124
|
+
const { name: _transformName, ...rest } = transform;
|
|
125
|
+
return [name, rest];
|
|
126
|
+
}))
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
if (options.customTransformGroups) {
|
|
130
|
+
const builder = await resolveBuilder(context, options.customTransformGroups);
|
|
131
|
+
const transformGroups = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
132
|
+
hooks.transformGroups = {
|
|
133
|
+
...hooks.transformGroups,
|
|
134
|
+
...transformGroups
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return hooks;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
12
141
|
//#region src/index.ts
|
|
13
142
|
/**
|
|
14
143
|
* A Powerlines plugin to integrate Style Dictionary for code generation via Power Plant.
|
|
@@ -28,7 +157,7 @@ const plugin = (options = {}) => {
|
|
|
28
157
|
},
|
|
29
158
|
async configResolved() {
|
|
30
159
|
const { skipBuild: _skipBuild, tokens, customActions, customFileHeaders, customFilters, customFormats, customPreprocessors, customParsers, customTransforms, customTransformGroups, hooks: existingHooks, ...styleDictionaryOptions } = this.config.styleDictionary;
|
|
31
|
-
const resolvedHooks = await
|
|
160
|
+
const resolvedHooks = await resolveStyleDictionaryHooks(this, {
|
|
32
161
|
customActions,
|
|
33
162
|
customFileHeaders,
|
|
34
163
|
customFilters,
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,112 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./types/index.mjs";
|
|
2
2
|
import styleDictionaryGenerator from "@power-plant/style-dictionary";
|
|
3
3
|
import powerPlant from "@powerlines/plugin-power-plant";
|
|
4
4
|
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
5
5
|
import defu from "defu";
|
|
6
|
+
import { isFunction } from "@stryke/type-checks/is-function";
|
|
7
|
+
import { resolve } from "powerlines/schema";
|
|
8
|
+
import { titleCase } from "@stryke/string-format/title-case";
|
|
6
9
|
|
|
10
|
+
//#region src/style-dictionary/file-header.ts
|
|
11
|
+
const fileHeader = (context) => ({
|
|
12
|
+
name: "powerlines/file-header",
|
|
13
|
+
fileHeader: (defaultMessages = []) => {
|
|
14
|
+
return [
|
|
15
|
+
`Generated by ${titleCase(context.config.framework?.name) || "Powerlines"}`,
|
|
16
|
+
"NOTE: Do not edit this file manually - it will be overwritten automatically by the \"prepare\" command",
|
|
17
|
+
...defaultMessages
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/helpers/resolve-hooks.ts
|
|
24
|
+
async function resolveBuilder(context, input) {
|
|
25
|
+
if (isFunction(input)) return input;
|
|
26
|
+
return resolve(context, input);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolves Powerlines Style Dictionary custom hook builders into a Style
|
|
30
|
+
* Dictionary {@link Hooks} config object for `@power-plant/style-dictionary`.
|
|
31
|
+
*/
|
|
32
|
+
async function resolveStyleDictionaryHooks(context, options) {
|
|
33
|
+
const hooks = {};
|
|
34
|
+
const defaultFileHeader = fileHeader(context);
|
|
35
|
+
hooks.fileHeaders = { [defaultFileHeader.name]: defaultFileHeader.fileHeader };
|
|
36
|
+
if (options.customActions) {
|
|
37
|
+
const builder = await resolveBuilder(context, options.customActions);
|
|
38
|
+
const actions = isFunction(builder) ? builder(context) : builder;
|
|
39
|
+
hooks.actions = {
|
|
40
|
+
...hooks.actions,
|
|
41
|
+
...Object.fromEntries(Object.entries(actions).map(([name, action]) => {
|
|
42
|
+
const { name: _actionName, ...rest } = action;
|
|
43
|
+
return [name, rest];
|
|
44
|
+
}))
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (options.customFileHeaders) {
|
|
48
|
+
const builder = await resolveBuilder(context, options.customFileHeaders);
|
|
49
|
+
const fileHeaders = isFunction(builder) ? builder(context) : builder;
|
|
50
|
+
hooks.fileHeaders = {
|
|
51
|
+
...hooks.fileHeaders,
|
|
52
|
+
...fileHeaders
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (options.customFilters) {
|
|
56
|
+
const builder = await resolveBuilder(context, options.customFilters);
|
|
57
|
+
const filters = isFunction(builder) ? builder(context) : builder;
|
|
58
|
+
hooks.filters = {
|
|
59
|
+
...hooks.filters,
|
|
60
|
+
...Object.fromEntries(Object.entries(filters).map(([name, filter]) => [name, filter.filter]))
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (options.customFormats) {
|
|
64
|
+
const builder = await resolveBuilder(context, options.customFormats);
|
|
65
|
+
const formats = isFunction(builder) ? builder(context) : builder;
|
|
66
|
+
hooks.formats = {
|
|
67
|
+
...hooks.formats,
|
|
68
|
+
...Object.fromEntries(Object.entries(formats).map(([name, format]) => [name, format.format]))
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (options.customPreprocessors) {
|
|
72
|
+
const builder = await resolveBuilder(context, options.customPreprocessors);
|
|
73
|
+
const preprocessors = isFunction(builder) ? builder(context) : builder;
|
|
74
|
+
hooks.preprocessors = {
|
|
75
|
+
...hooks.preprocessors,
|
|
76
|
+
...Object.fromEntries(Object.entries(preprocessors).map(([name, preprocessor]) => [name, preprocessor.preprocessor]))
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (options.customParsers) {
|
|
80
|
+
const builder = await resolveBuilder(context, options.customParsers);
|
|
81
|
+
const parsers = isFunction(builder) ? builder(context) : builder;
|
|
82
|
+
hooks.parsers = {
|
|
83
|
+
...hooks.parsers,
|
|
84
|
+
...Object.fromEntries(parsers.map(({ name, ...parser }) => [name, parser]))
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (options.customTransforms) {
|
|
88
|
+
const builder = await resolveBuilder(context, options.customTransforms);
|
|
89
|
+
const transforms = isFunction(builder) ? builder(context) : builder;
|
|
90
|
+
hooks.transforms = {
|
|
91
|
+
...hooks.transforms,
|
|
92
|
+
...Object.fromEntries(Object.entries(transforms).map(([name, transform]) => {
|
|
93
|
+
const { name: _transformName, ...rest } = transform;
|
|
94
|
+
return [name, rest];
|
|
95
|
+
}))
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (options.customTransformGroups) {
|
|
99
|
+
const builder = await resolveBuilder(context, options.customTransformGroups);
|
|
100
|
+
const transformGroups = isFunction(builder) ? builder(context) : builder;
|
|
101
|
+
hooks.transformGroups = {
|
|
102
|
+
...hooks.transformGroups,
|
|
103
|
+
...transformGroups
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return hooks;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
7
110
|
//#region src/index.ts
|
|
8
111
|
/**
|
|
9
112
|
* A Powerlines plugin to integrate Style Dictionary for code generation via Power Plant.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-style-dictionary",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.579",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A Powerlines plugin to generate project code with Style Dictionary.",
|
|
6
6
|
"keywords": [
|
|
@@ -96,20 +96,20 @@
|
|
|
96
96
|
"files": ["dist"],
|
|
97
97
|
"dependencies": {
|
|
98
98
|
"@power-plant/core": "^0.0.89",
|
|
99
|
-
"@power-plant/style-dictionary": "^0.0.
|
|
100
|
-
"@powerlines/plugin-power-plant": "^0.1.
|
|
99
|
+
"@power-plant/style-dictionary": "^0.0.74",
|
|
100
|
+
"@powerlines/plugin-power-plant": "^0.1.66",
|
|
101
101
|
"@storm-software/config-tools": "^1.190.133",
|
|
102
102
|
"@stryke/string-format": "^0.17.50",
|
|
103
103
|
"@stryke/type-checks": "^0.6.41",
|
|
104
104
|
"@stryke/types": "^0.12.36",
|
|
105
105
|
"defu": "^6.1.7",
|
|
106
|
-
"powerlines": "^0.47.
|
|
106
|
+
"powerlines": "^0.47.209",
|
|
107
107
|
"style-dictionary": "^5.5.1"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
110
|
+
"@powerlines/plugin-plugin": "^0.12.622",
|
|
111
111
|
"@types/node": "^25.9.5"
|
|
112
112
|
},
|
|
113
113
|
"publishConfig": { "access": "public" },
|
|
114
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "88974b224a5cdb97dbd377373c9ed7f8a8780324"
|
|
115
115
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
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 || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
exports.__toESM = __toESM;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
const require_file_header = require('../style-dictionary/file-header.cjs');
|
|
2
|
-
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
3
|
-
let powerlines_schema = require("powerlines/schema");
|
|
4
|
-
|
|
5
|
-
//#region src/helpers/resolve-hooks.ts
|
|
6
|
-
async function resolveBuilder(context, input) {
|
|
7
|
-
if ((0, _stryke_type_checks_is_function.isFunction)(input)) return input;
|
|
8
|
-
return (0, powerlines_schema.resolve)(context, input);
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Resolves Powerlines Style Dictionary custom hook builders into a Style
|
|
12
|
-
* Dictionary {@link Hooks} config object for `@power-plant/style-dictionary`.
|
|
13
|
-
*/
|
|
14
|
-
async function resolveStyleDictionaryHooks(context, options) {
|
|
15
|
-
const hooks = {};
|
|
16
|
-
const defaultFileHeader = require_file_header.fileHeader(context);
|
|
17
|
-
hooks.fileHeaders = { [defaultFileHeader.name]: defaultFileHeader.fileHeader };
|
|
18
|
-
if (options.customActions) {
|
|
19
|
-
const builder = await resolveBuilder(context, options.customActions);
|
|
20
|
-
const actions = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
21
|
-
hooks.actions = {
|
|
22
|
-
...hooks.actions,
|
|
23
|
-
...Object.fromEntries(Object.entries(actions).map(([name, action]) => {
|
|
24
|
-
const { name: _actionName, ...rest } = action;
|
|
25
|
-
return [name, rest];
|
|
26
|
-
}))
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
if (options.customFileHeaders) {
|
|
30
|
-
const builder = await resolveBuilder(context, options.customFileHeaders);
|
|
31
|
-
const fileHeaders = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
32
|
-
hooks.fileHeaders = {
|
|
33
|
-
...hooks.fileHeaders,
|
|
34
|
-
...fileHeaders
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
if (options.customFilters) {
|
|
38
|
-
const builder = await resolveBuilder(context, options.customFilters);
|
|
39
|
-
const filters = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
40
|
-
hooks.filters = {
|
|
41
|
-
...hooks.filters,
|
|
42
|
-
...Object.fromEntries(Object.entries(filters).map(([name, filter]) => [name, filter.filter]))
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
if (options.customFormats) {
|
|
46
|
-
const builder = await resolveBuilder(context, options.customFormats);
|
|
47
|
-
const formats = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
48
|
-
hooks.formats = {
|
|
49
|
-
...hooks.formats,
|
|
50
|
-
...Object.fromEntries(Object.entries(formats).map(([name, format]) => [name, format.format]))
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
if (options.customPreprocessors) {
|
|
54
|
-
const builder = await resolveBuilder(context, options.customPreprocessors);
|
|
55
|
-
const preprocessors = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
56
|
-
hooks.preprocessors = {
|
|
57
|
-
...hooks.preprocessors,
|
|
58
|
-
...Object.fromEntries(Object.entries(preprocessors).map(([name, preprocessor]) => [name, preprocessor.preprocessor]))
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
if (options.customParsers) {
|
|
62
|
-
const builder = await resolveBuilder(context, options.customParsers);
|
|
63
|
-
const parsers = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
64
|
-
hooks.parsers = {
|
|
65
|
-
...hooks.parsers,
|
|
66
|
-
...Object.fromEntries(parsers.map(({ name, ...parser }) => [name, parser]))
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
if (options.customTransforms) {
|
|
70
|
-
const builder = await resolveBuilder(context, options.customTransforms);
|
|
71
|
-
const transforms = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
72
|
-
hooks.transforms = {
|
|
73
|
-
...hooks.transforms,
|
|
74
|
-
...Object.fromEntries(Object.entries(transforms).map(([name, transform]) => {
|
|
75
|
-
const { name: _transformName, ...rest } = transform;
|
|
76
|
-
return [name, rest];
|
|
77
|
-
}))
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
if (options.customTransformGroups) {
|
|
81
|
-
const builder = await resolveBuilder(context, options.customTransformGroups);
|
|
82
|
-
const transformGroups = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
83
|
-
hooks.transformGroups = {
|
|
84
|
-
...hooks.transformGroups,
|
|
85
|
-
...transformGroups
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
return hooks;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
//#endregion
|
|
92
|
-
exports.resolveStyleDictionaryHooks = resolveStyleDictionaryHooks;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { fileHeader } from "../style-dictionary/file-header.mjs";
|
|
2
|
-
import { isFunction } from "@stryke/type-checks/is-function";
|
|
3
|
-
import { resolve } from "powerlines/schema";
|
|
4
|
-
|
|
5
|
-
//#region src/helpers/resolve-hooks.ts
|
|
6
|
-
async function resolveBuilder(context, input) {
|
|
7
|
-
if (isFunction(input)) return input;
|
|
8
|
-
return resolve(context, input);
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Resolves Powerlines Style Dictionary custom hook builders into a Style
|
|
12
|
-
* Dictionary {@link Hooks} config object for `@power-plant/style-dictionary`.
|
|
13
|
-
*/
|
|
14
|
-
async function resolveStyleDictionaryHooks(context, options) {
|
|
15
|
-
const hooks = {};
|
|
16
|
-
const defaultFileHeader = fileHeader(context);
|
|
17
|
-
hooks.fileHeaders = { [defaultFileHeader.name]: defaultFileHeader.fileHeader };
|
|
18
|
-
if (options.customActions) {
|
|
19
|
-
const builder = await resolveBuilder(context, options.customActions);
|
|
20
|
-
const actions = isFunction(builder) ? builder(context) : builder;
|
|
21
|
-
hooks.actions = {
|
|
22
|
-
...hooks.actions,
|
|
23
|
-
...Object.fromEntries(Object.entries(actions).map(([name, action]) => {
|
|
24
|
-
const { name: _actionName, ...rest } = action;
|
|
25
|
-
return [name, rest];
|
|
26
|
-
}))
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
if (options.customFileHeaders) {
|
|
30
|
-
const builder = await resolveBuilder(context, options.customFileHeaders);
|
|
31
|
-
const fileHeaders = isFunction(builder) ? builder(context) : builder;
|
|
32
|
-
hooks.fileHeaders = {
|
|
33
|
-
...hooks.fileHeaders,
|
|
34
|
-
...fileHeaders
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
if (options.customFilters) {
|
|
38
|
-
const builder = await resolveBuilder(context, options.customFilters);
|
|
39
|
-
const filters = isFunction(builder) ? builder(context) : builder;
|
|
40
|
-
hooks.filters = {
|
|
41
|
-
...hooks.filters,
|
|
42
|
-
...Object.fromEntries(Object.entries(filters).map(([name, filter]) => [name, filter.filter]))
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
if (options.customFormats) {
|
|
46
|
-
const builder = await resolveBuilder(context, options.customFormats);
|
|
47
|
-
const formats = isFunction(builder) ? builder(context) : builder;
|
|
48
|
-
hooks.formats = {
|
|
49
|
-
...hooks.formats,
|
|
50
|
-
...Object.fromEntries(Object.entries(formats).map(([name, format]) => [name, format.format]))
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
if (options.customPreprocessors) {
|
|
54
|
-
const builder = await resolveBuilder(context, options.customPreprocessors);
|
|
55
|
-
const preprocessors = isFunction(builder) ? builder(context) : builder;
|
|
56
|
-
hooks.preprocessors = {
|
|
57
|
-
...hooks.preprocessors,
|
|
58
|
-
...Object.fromEntries(Object.entries(preprocessors).map(([name, preprocessor]) => [name, preprocessor.preprocessor]))
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
if (options.customParsers) {
|
|
62
|
-
const builder = await resolveBuilder(context, options.customParsers);
|
|
63
|
-
const parsers = isFunction(builder) ? builder(context) : builder;
|
|
64
|
-
hooks.parsers = {
|
|
65
|
-
...hooks.parsers,
|
|
66
|
-
...Object.fromEntries(parsers.map(({ name, ...parser }) => [name, parser]))
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
if (options.customTransforms) {
|
|
70
|
-
const builder = await resolveBuilder(context, options.customTransforms);
|
|
71
|
-
const transforms = isFunction(builder) ? builder(context) : builder;
|
|
72
|
-
hooks.transforms = {
|
|
73
|
-
...hooks.transforms,
|
|
74
|
-
...Object.fromEntries(Object.entries(transforms).map(([name, transform]) => {
|
|
75
|
-
const { name: _transformName, ...rest } = transform;
|
|
76
|
-
return [name, rest];
|
|
77
|
-
}))
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
if (options.customTransformGroups) {
|
|
81
|
-
const builder = await resolveBuilder(context, options.customTransformGroups);
|
|
82
|
-
const transformGroups = isFunction(builder) ? builder(context) : builder;
|
|
83
|
-
hooks.transformGroups = {
|
|
84
|
-
...hooks.transformGroups,
|
|
85
|
-
...transformGroups
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
return hooks;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
//#endregion
|
|
92
|
-
export { resolveStyleDictionaryHooks };
|
|
93
|
-
//# sourceMappingURL=resolve-hooks.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-hooks.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
2
|
-
|
|
3
|
-
//#region src/style-dictionary/file-header.ts
|
|
4
|
-
const fileHeader = (context) => ({
|
|
5
|
-
name: "powerlines/file-header",
|
|
6
|
-
fileHeader: (defaultMessages = []) => {
|
|
7
|
-
return [
|
|
8
|
-
`Generated by ${(0, _stryke_string_format_title_case.titleCase)(context.config.framework?.name) || "Powerlines"}`,
|
|
9
|
-
"NOTE: Do not edit this file manually - it will be overwritten automatically by the \"prepare\" command",
|
|
10
|
-
...defaultMessages
|
|
11
|
-
];
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
exports.fileHeader = fileHeader;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { titleCase } from "@stryke/string-format/title-case";
|
|
2
|
-
|
|
3
|
-
//#region src/style-dictionary/file-header.ts
|
|
4
|
-
const fileHeader = (context) => ({
|
|
5
|
-
name: "powerlines/file-header",
|
|
6
|
-
fileHeader: (defaultMessages = []) => {
|
|
7
|
-
return [
|
|
8
|
-
`Generated by ${titleCase(context.config.framework?.name) || "Powerlines"}`,
|
|
9
|
-
"NOTE: Do not edit this file manually - it will be overwritten automatically by the \"prepare\" command",
|
|
10
|
-
...defaultMessages
|
|
11
|
-
];
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { fileHeader };
|
|
17
|
-
//# sourceMappingURL=file-header.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-header.mjs","names":[],"sources":[],"mappings":""}
|