pwa-kit-style-loader 0.0.0
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/LICENSE +21 -0
- package/README.md +59 -0
- package/dist/init.js +675 -0
- package/package.json +43 -0
- package/postcss.config.js +3 -0
- package/webpack.config.js +22 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PWA Kits
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# pwa-style-loader đŠī¸
|
|
2
|
+
|
|
3
|
+
Enable vanilla CSS đĻ support in Salesforce PWA Kit â instantly.
|
|
4
|
+
|
|
5
|
+
`pwa-style-loader` is a lightweight CLI that adds global CSS capability to Salesforce PWA Kit projects safely and quickly.
|
|
6
|
+
|
|
7
|
+
Built for simplicity and enterprise environments.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Why?
|
|
12
|
+
|
|
13
|
+
Salesforce PWA Kit does not support global CSS imports out of the box.
|
|
14
|
+
|
|
15
|
+
Instead of manually configuring build files and risking setup issues, this CLI enables CSS support in one command.
|
|
16
|
+
|
|
17
|
+
## ⥠Usage
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install pwa-style-loader
|
|
21
|
+
npx pwa-style-loader
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## đ What It Does
|
|
27
|
+
|
|
28
|
+
- Detects if you're inside a Salesforce PWA Kit project
|
|
29
|
+
- Sets up required configuration for global CSS usage
|
|
30
|
+
- Prompts before modifying existing files
|
|
31
|
+
- Makes no silent changes
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Designed For
|
|
36
|
+
|
|
37
|
+
- Enterprise teams
|
|
38
|
+
- Safe configuration workflows
|
|
39
|
+
- Repeatable setup
|
|
40
|
+
- Clean project structure
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Roadmap
|
|
45
|
+
|
|
46
|
+
- SCSS / SASS support
|
|
47
|
+
- Tailwind preset
|
|
48
|
+
|
|
49
|
+
## Maintainer
|
|
50
|
+
|
|
51
|
+
Abhisek Maiti
|
|
52
|
+
SFCC / PWA Kit Developer
|
|
53
|
+
|
|
54
|
+
- GitHub: https://github.com/abhisekmaiti19
|
|
55
|
+
- LinkedIn: https://linkedin.com/in/abhisekmaiti19
|
|
56
|
+
|
|
57
|
+
## đ License
|
|
58
|
+
|
|
59
|
+
MIT
|
package/dist/init.js
ADDED
|
@@ -0,0 +1,675 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
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 __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
|
|
32
|
+
// node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
33
|
+
function assembleStyles() {
|
|
34
|
+
const codes = /* @__PURE__ */ new Map();
|
|
35
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
|
36
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
37
|
+
styles[styleName] = {
|
|
38
|
+
open: `\x1B[${style[0]}m`,
|
|
39
|
+
close: `\x1B[${style[1]}m`
|
|
40
|
+
};
|
|
41
|
+
group[styleName] = styles[styleName];
|
|
42
|
+
codes.set(style[0], style[1]);
|
|
43
|
+
}
|
|
44
|
+
Object.defineProperty(styles, groupName, {
|
|
45
|
+
value: group,
|
|
46
|
+
enumerable: false
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
Object.defineProperty(styles, "codes", {
|
|
50
|
+
value: codes,
|
|
51
|
+
enumerable: false
|
|
52
|
+
});
|
|
53
|
+
styles.color.close = "\x1B[39m";
|
|
54
|
+
styles.bgColor.close = "\x1B[49m";
|
|
55
|
+
styles.color.ansi = wrapAnsi16();
|
|
56
|
+
styles.color.ansi256 = wrapAnsi256();
|
|
57
|
+
styles.color.ansi16m = wrapAnsi16m();
|
|
58
|
+
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
59
|
+
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
60
|
+
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
61
|
+
Object.defineProperties(styles, {
|
|
62
|
+
rgbToAnsi256: {
|
|
63
|
+
value(red, green, blue) {
|
|
64
|
+
if (red === green && green === blue) {
|
|
65
|
+
if (red < 8) {
|
|
66
|
+
return 16;
|
|
67
|
+
}
|
|
68
|
+
if (red > 248) {
|
|
69
|
+
return 231;
|
|
70
|
+
}
|
|
71
|
+
return Math.round((red - 8) / 247 * 24) + 232;
|
|
72
|
+
}
|
|
73
|
+
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
74
|
+
},
|
|
75
|
+
enumerable: false
|
|
76
|
+
},
|
|
77
|
+
hexToRgb: {
|
|
78
|
+
value(hex) {
|
|
79
|
+
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
80
|
+
if (!matches) {
|
|
81
|
+
return [0, 0, 0];
|
|
82
|
+
}
|
|
83
|
+
let [colorString] = matches;
|
|
84
|
+
if (colorString.length === 3) {
|
|
85
|
+
colorString = [...colorString].map((character) => character + character).join("");
|
|
86
|
+
}
|
|
87
|
+
const integer = Number.parseInt(colorString, 16);
|
|
88
|
+
return [
|
|
89
|
+
/* eslint-disable no-bitwise */
|
|
90
|
+
integer >> 16 & 255,
|
|
91
|
+
integer >> 8 & 255,
|
|
92
|
+
integer & 255
|
|
93
|
+
/* eslint-enable no-bitwise */
|
|
94
|
+
];
|
|
95
|
+
},
|
|
96
|
+
enumerable: false
|
|
97
|
+
},
|
|
98
|
+
hexToAnsi256: {
|
|
99
|
+
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
100
|
+
enumerable: false
|
|
101
|
+
},
|
|
102
|
+
ansi256ToAnsi: {
|
|
103
|
+
value(code) {
|
|
104
|
+
if (code < 8) {
|
|
105
|
+
return 30 + code;
|
|
106
|
+
}
|
|
107
|
+
if (code < 16) {
|
|
108
|
+
return 90 + (code - 8);
|
|
109
|
+
}
|
|
110
|
+
let red;
|
|
111
|
+
let green;
|
|
112
|
+
let blue;
|
|
113
|
+
if (code >= 232) {
|
|
114
|
+
red = ((code - 232) * 10 + 8) / 255;
|
|
115
|
+
green = red;
|
|
116
|
+
blue = red;
|
|
117
|
+
} else {
|
|
118
|
+
code -= 16;
|
|
119
|
+
const remainder = code % 36;
|
|
120
|
+
red = Math.floor(code / 36) / 5;
|
|
121
|
+
green = Math.floor(remainder / 6) / 5;
|
|
122
|
+
blue = remainder % 6 / 5;
|
|
123
|
+
}
|
|
124
|
+
const value = Math.max(red, green, blue) * 2;
|
|
125
|
+
if (value === 0) {
|
|
126
|
+
return 30;
|
|
127
|
+
}
|
|
128
|
+
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
129
|
+
if (value === 2) {
|
|
130
|
+
result += 60;
|
|
131
|
+
}
|
|
132
|
+
return result;
|
|
133
|
+
},
|
|
134
|
+
enumerable: false
|
|
135
|
+
},
|
|
136
|
+
rgbToAnsi: {
|
|
137
|
+
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
138
|
+
enumerable: false
|
|
139
|
+
},
|
|
140
|
+
hexToAnsi: {
|
|
141
|
+
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
142
|
+
enumerable: false
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return styles;
|
|
146
|
+
}
|
|
147
|
+
var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default;
|
|
148
|
+
var init_ansi_styles = __esm({
|
|
149
|
+
"node_modules/chalk/source/vendor/ansi-styles/index.js"() {
|
|
150
|
+
ANSI_BACKGROUND_OFFSET = 10;
|
|
151
|
+
wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
152
|
+
wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
153
|
+
wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
|
154
|
+
styles = {
|
|
155
|
+
modifier: {
|
|
156
|
+
reset: [0, 0],
|
|
157
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
158
|
+
bold: [1, 22],
|
|
159
|
+
dim: [2, 22],
|
|
160
|
+
italic: [3, 23],
|
|
161
|
+
underline: [4, 24],
|
|
162
|
+
overline: [53, 55],
|
|
163
|
+
inverse: [7, 27],
|
|
164
|
+
hidden: [8, 28],
|
|
165
|
+
strikethrough: [9, 29]
|
|
166
|
+
},
|
|
167
|
+
color: {
|
|
168
|
+
black: [30, 39],
|
|
169
|
+
red: [31, 39],
|
|
170
|
+
green: [32, 39],
|
|
171
|
+
yellow: [33, 39],
|
|
172
|
+
blue: [34, 39],
|
|
173
|
+
magenta: [35, 39],
|
|
174
|
+
cyan: [36, 39],
|
|
175
|
+
white: [37, 39],
|
|
176
|
+
// Bright color
|
|
177
|
+
blackBright: [90, 39],
|
|
178
|
+
gray: [90, 39],
|
|
179
|
+
// Alias of `blackBright`
|
|
180
|
+
grey: [90, 39],
|
|
181
|
+
// Alias of `blackBright`
|
|
182
|
+
redBright: [91, 39],
|
|
183
|
+
greenBright: [92, 39],
|
|
184
|
+
yellowBright: [93, 39],
|
|
185
|
+
blueBright: [94, 39],
|
|
186
|
+
magentaBright: [95, 39],
|
|
187
|
+
cyanBright: [96, 39],
|
|
188
|
+
whiteBright: [97, 39]
|
|
189
|
+
},
|
|
190
|
+
bgColor: {
|
|
191
|
+
bgBlack: [40, 49],
|
|
192
|
+
bgRed: [41, 49],
|
|
193
|
+
bgGreen: [42, 49],
|
|
194
|
+
bgYellow: [43, 49],
|
|
195
|
+
bgBlue: [44, 49],
|
|
196
|
+
bgMagenta: [45, 49],
|
|
197
|
+
bgCyan: [46, 49],
|
|
198
|
+
bgWhite: [47, 49],
|
|
199
|
+
// Bright color
|
|
200
|
+
bgBlackBright: [100, 49],
|
|
201
|
+
bgGray: [100, 49],
|
|
202
|
+
// Alias of `bgBlackBright`
|
|
203
|
+
bgGrey: [100, 49],
|
|
204
|
+
// Alias of `bgBlackBright`
|
|
205
|
+
bgRedBright: [101, 49],
|
|
206
|
+
bgGreenBright: [102, 49],
|
|
207
|
+
bgYellowBright: [103, 49],
|
|
208
|
+
bgBlueBright: [104, 49],
|
|
209
|
+
bgMagentaBright: [105, 49],
|
|
210
|
+
bgCyanBright: [106, 49],
|
|
211
|
+
bgWhiteBright: [107, 49]
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
modifierNames = Object.keys(styles.modifier);
|
|
215
|
+
foregroundColorNames = Object.keys(styles.color);
|
|
216
|
+
backgroundColorNames = Object.keys(styles.bgColor);
|
|
217
|
+
colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
|
218
|
+
ansiStyles = assembleStyles();
|
|
219
|
+
ansi_styles_default = ansiStyles;
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// node_modules/chalk/source/vendor/supports-color/index.js
|
|
224
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
|
|
225
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
226
|
+
const position = argv.indexOf(prefix + flag);
|
|
227
|
+
const terminatorPosition = argv.indexOf("--");
|
|
228
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
229
|
+
}
|
|
230
|
+
function envForceColor() {
|
|
231
|
+
if ("FORCE_COLOR" in env) {
|
|
232
|
+
if (env.FORCE_COLOR === "true") {
|
|
233
|
+
return 1;
|
|
234
|
+
}
|
|
235
|
+
if (env.FORCE_COLOR === "false") {
|
|
236
|
+
return 0;
|
|
237
|
+
}
|
|
238
|
+
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function translateLevel(level) {
|
|
242
|
+
if (level === 0) {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
level,
|
|
247
|
+
hasBasic: true,
|
|
248
|
+
has256: level >= 2,
|
|
249
|
+
has16m: level >= 3
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
253
|
+
const noFlagForceColor = envForceColor();
|
|
254
|
+
if (noFlagForceColor !== void 0) {
|
|
255
|
+
flagForceColor = noFlagForceColor;
|
|
256
|
+
}
|
|
257
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
258
|
+
if (forceColor === 0) {
|
|
259
|
+
return 0;
|
|
260
|
+
}
|
|
261
|
+
if (sniffFlags) {
|
|
262
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
263
|
+
return 3;
|
|
264
|
+
}
|
|
265
|
+
if (hasFlag("color=256")) {
|
|
266
|
+
return 2;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
270
|
+
return 1;
|
|
271
|
+
}
|
|
272
|
+
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
273
|
+
return 0;
|
|
274
|
+
}
|
|
275
|
+
const min = forceColor || 0;
|
|
276
|
+
if (env.TERM === "dumb") {
|
|
277
|
+
return min;
|
|
278
|
+
}
|
|
279
|
+
if (import_node_process.default.platform === "win32") {
|
|
280
|
+
const osRelease = import_node_os.default.release().split(".");
|
|
281
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
282
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
283
|
+
}
|
|
284
|
+
return 1;
|
|
285
|
+
}
|
|
286
|
+
if ("CI" in env) {
|
|
287
|
+
if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
|
|
288
|
+
return 3;
|
|
289
|
+
}
|
|
290
|
+
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
291
|
+
return 1;
|
|
292
|
+
}
|
|
293
|
+
return min;
|
|
294
|
+
}
|
|
295
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
296
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
297
|
+
}
|
|
298
|
+
if (env.COLORTERM === "truecolor") {
|
|
299
|
+
return 3;
|
|
300
|
+
}
|
|
301
|
+
if (env.TERM === "xterm-kitty") {
|
|
302
|
+
return 3;
|
|
303
|
+
}
|
|
304
|
+
if (env.TERM === "xterm-ghostty") {
|
|
305
|
+
return 3;
|
|
306
|
+
}
|
|
307
|
+
if (env.TERM === "wezterm") {
|
|
308
|
+
return 3;
|
|
309
|
+
}
|
|
310
|
+
if ("TERM_PROGRAM" in env) {
|
|
311
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
312
|
+
switch (env.TERM_PROGRAM) {
|
|
313
|
+
case "iTerm.app": {
|
|
314
|
+
return version >= 3 ? 3 : 2;
|
|
315
|
+
}
|
|
316
|
+
case "Apple_Terminal": {
|
|
317
|
+
return 2;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
322
|
+
return 2;
|
|
323
|
+
}
|
|
324
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
325
|
+
return 1;
|
|
326
|
+
}
|
|
327
|
+
if ("COLORTERM" in env) {
|
|
328
|
+
return 1;
|
|
329
|
+
}
|
|
330
|
+
return min;
|
|
331
|
+
}
|
|
332
|
+
function createSupportsColor(stream, options = {}) {
|
|
333
|
+
const level = _supportsColor(stream, {
|
|
334
|
+
streamIsTTY: stream && stream.isTTY,
|
|
335
|
+
...options
|
|
336
|
+
});
|
|
337
|
+
return translateLevel(level);
|
|
338
|
+
}
|
|
339
|
+
var import_node_process, import_node_os, import_node_tty, env, flagForceColor, supportsColor, supports_color_default;
|
|
340
|
+
var init_supports_color = __esm({
|
|
341
|
+
"node_modules/chalk/source/vendor/supports-color/index.js"() {
|
|
342
|
+
import_node_process = __toESM(require("node:process"), 1);
|
|
343
|
+
import_node_os = __toESM(require("node:os"), 1);
|
|
344
|
+
import_node_tty = __toESM(require("node:tty"), 1);
|
|
345
|
+
({ env } = import_node_process.default);
|
|
346
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
347
|
+
flagForceColor = 0;
|
|
348
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
349
|
+
flagForceColor = 1;
|
|
350
|
+
}
|
|
351
|
+
supportsColor = {
|
|
352
|
+
stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
|
|
353
|
+
stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
|
|
354
|
+
};
|
|
355
|
+
supports_color_default = supportsColor;
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
// node_modules/chalk/source/utilities.js
|
|
360
|
+
function stringReplaceAll(string, substring, replacer) {
|
|
361
|
+
let index = string.indexOf(substring);
|
|
362
|
+
if (index === -1) {
|
|
363
|
+
return string;
|
|
364
|
+
}
|
|
365
|
+
const substringLength = substring.length;
|
|
366
|
+
let endIndex = 0;
|
|
367
|
+
let returnValue = "";
|
|
368
|
+
do {
|
|
369
|
+
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
370
|
+
endIndex = index + substringLength;
|
|
371
|
+
index = string.indexOf(substring, endIndex);
|
|
372
|
+
} while (index !== -1);
|
|
373
|
+
returnValue += string.slice(endIndex);
|
|
374
|
+
return returnValue;
|
|
375
|
+
}
|
|
376
|
+
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
377
|
+
let endIndex = 0;
|
|
378
|
+
let returnValue = "";
|
|
379
|
+
do {
|
|
380
|
+
const gotCR = string[index - 1] === "\r";
|
|
381
|
+
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
382
|
+
endIndex = index + 1;
|
|
383
|
+
index = string.indexOf("\n", endIndex);
|
|
384
|
+
} while (index !== -1);
|
|
385
|
+
returnValue += string.slice(endIndex);
|
|
386
|
+
return returnValue;
|
|
387
|
+
}
|
|
388
|
+
var init_utilities = __esm({
|
|
389
|
+
"node_modules/chalk/source/utilities.js"() {
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
// node_modules/chalk/source/index.js
|
|
394
|
+
var source_exports = {};
|
|
395
|
+
__export(source_exports, {
|
|
396
|
+
Chalk: () => Chalk,
|
|
397
|
+
backgroundColorNames: () => backgroundColorNames,
|
|
398
|
+
backgroundColors: () => backgroundColorNames,
|
|
399
|
+
chalkStderr: () => chalkStderr,
|
|
400
|
+
colorNames: () => colorNames,
|
|
401
|
+
colors: () => colorNames,
|
|
402
|
+
default: () => source_default,
|
|
403
|
+
foregroundColorNames: () => foregroundColorNames,
|
|
404
|
+
foregroundColors: () => foregroundColorNames,
|
|
405
|
+
modifierNames: () => modifierNames,
|
|
406
|
+
modifiers: () => modifierNames,
|
|
407
|
+
supportsColor: () => stdoutColor,
|
|
408
|
+
supportsColorStderr: () => stderrColor
|
|
409
|
+
});
|
|
410
|
+
function createChalk(options) {
|
|
411
|
+
return chalkFactory(options);
|
|
412
|
+
}
|
|
413
|
+
var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, Chalk, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr, source_default;
|
|
414
|
+
var init_source = __esm({
|
|
415
|
+
"node_modules/chalk/source/index.js"() {
|
|
416
|
+
init_ansi_styles();
|
|
417
|
+
init_supports_color();
|
|
418
|
+
init_utilities();
|
|
419
|
+
init_ansi_styles();
|
|
420
|
+
({ stdout: stdoutColor, stderr: stderrColor } = supports_color_default);
|
|
421
|
+
GENERATOR = /* @__PURE__ */ Symbol("GENERATOR");
|
|
422
|
+
STYLER = /* @__PURE__ */ Symbol("STYLER");
|
|
423
|
+
IS_EMPTY = /* @__PURE__ */ Symbol("IS_EMPTY");
|
|
424
|
+
levelMapping = [
|
|
425
|
+
"ansi",
|
|
426
|
+
"ansi",
|
|
427
|
+
"ansi256",
|
|
428
|
+
"ansi16m"
|
|
429
|
+
];
|
|
430
|
+
styles2 = /* @__PURE__ */ Object.create(null);
|
|
431
|
+
applyOptions = (object, options = {}) => {
|
|
432
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
433
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
434
|
+
}
|
|
435
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
436
|
+
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
437
|
+
};
|
|
438
|
+
Chalk = class {
|
|
439
|
+
constructor(options) {
|
|
440
|
+
return chalkFactory(options);
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
chalkFactory = (options) => {
|
|
444
|
+
const chalk2 = (...strings) => strings.join(" ");
|
|
445
|
+
applyOptions(chalk2, options);
|
|
446
|
+
Object.setPrototypeOf(chalk2, createChalk.prototype);
|
|
447
|
+
return chalk2;
|
|
448
|
+
};
|
|
449
|
+
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
450
|
+
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
451
|
+
styles2[styleName] = {
|
|
452
|
+
get() {
|
|
453
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
454
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
455
|
+
return builder;
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
styles2.visible = {
|
|
460
|
+
get() {
|
|
461
|
+
const builder = createBuilder(this, this[STYLER], true);
|
|
462
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
463
|
+
return builder;
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
getModelAnsi = (model, level, type, ...arguments_) => {
|
|
467
|
+
if (model === "rgb") {
|
|
468
|
+
if (level === "ansi16m") {
|
|
469
|
+
return ansi_styles_default[type].ansi16m(...arguments_);
|
|
470
|
+
}
|
|
471
|
+
if (level === "ansi256") {
|
|
472
|
+
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
|
473
|
+
}
|
|
474
|
+
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
|
475
|
+
}
|
|
476
|
+
if (model === "hex") {
|
|
477
|
+
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
|
|
478
|
+
}
|
|
479
|
+
return ansi_styles_default[type][model](...arguments_);
|
|
480
|
+
};
|
|
481
|
+
usedModels = ["rgb", "hex", "ansi256"];
|
|
482
|
+
for (const model of usedModels) {
|
|
483
|
+
styles2[model] = {
|
|
484
|
+
get() {
|
|
485
|
+
const { level } = this;
|
|
486
|
+
return function(...arguments_) {
|
|
487
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
|
488
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
493
|
+
styles2[bgModel] = {
|
|
494
|
+
get() {
|
|
495
|
+
const { level } = this;
|
|
496
|
+
return function(...arguments_) {
|
|
497
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
|
498
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
proto = Object.defineProperties(() => {
|
|
504
|
+
}, {
|
|
505
|
+
...styles2,
|
|
506
|
+
level: {
|
|
507
|
+
enumerable: true,
|
|
508
|
+
get() {
|
|
509
|
+
return this[GENERATOR].level;
|
|
510
|
+
},
|
|
511
|
+
set(level) {
|
|
512
|
+
this[GENERATOR].level = level;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
createStyler = (open, close, parent) => {
|
|
517
|
+
let openAll;
|
|
518
|
+
let closeAll;
|
|
519
|
+
if (parent === void 0) {
|
|
520
|
+
openAll = open;
|
|
521
|
+
closeAll = close;
|
|
522
|
+
} else {
|
|
523
|
+
openAll = parent.openAll + open;
|
|
524
|
+
closeAll = close + parent.closeAll;
|
|
525
|
+
}
|
|
526
|
+
return {
|
|
527
|
+
open,
|
|
528
|
+
close,
|
|
529
|
+
openAll,
|
|
530
|
+
closeAll,
|
|
531
|
+
parent
|
|
532
|
+
};
|
|
533
|
+
};
|
|
534
|
+
createBuilder = (self, _styler, _isEmpty) => {
|
|
535
|
+
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
536
|
+
Object.setPrototypeOf(builder, proto);
|
|
537
|
+
builder[GENERATOR] = self;
|
|
538
|
+
builder[STYLER] = _styler;
|
|
539
|
+
builder[IS_EMPTY] = _isEmpty;
|
|
540
|
+
return builder;
|
|
541
|
+
};
|
|
542
|
+
applyStyle = (self, string) => {
|
|
543
|
+
if (self.level <= 0 || !string) {
|
|
544
|
+
return self[IS_EMPTY] ? "" : string;
|
|
545
|
+
}
|
|
546
|
+
let styler = self[STYLER];
|
|
547
|
+
if (styler === void 0) {
|
|
548
|
+
return string;
|
|
549
|
+
}
|
|
550
|
+
const { openAll, closeAll } = styler;
|
|
551
|
+
if (string.includes("\x1B")) {
|
|
552
|
+
while (styler !== void 0) {
|
|
553
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
554
|
+
styler = styler.parent;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
const lfIndex = string.indexOf("\n");
|
|
558
|
+
if (lfIndex !== -1) {
|
|
559
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
560
|
+
}
|
|
561
|
+
return openAll + string + closeAll;
|
|
562
|
+
};
|
|
563
|
+
Object.defineProperties(createChalk.prototype, styles2);
|
|
564
|
+
chalk = createChalk();
|
|
565
|
+
chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
566
|
+
source_default = chalk;
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
// src/init.js
|
|
571
|
+
var fs = require("fs");
|
|
572
|
+
var path = require("path");
|
|
573
|
+
var readline = require("readline");
|
|
574
|
+
(async () => {
|
|
575
|
+
const chalk2 = (await Promise.resolve().then(() => (init_source(), source_exports))).default;
|
|
576
|
+
console.log(
|
|
577
|
+
chalk2.cyan.bold("\n\u{1F680} pwa-style-loader") + chalk2.gray("\nby Abhisek Maiti") + chalk2.gray("\nAdds vanilla CSS \u{1F366} support to Salesforce PWA Kit") + chalk2.blue("\nGitHub: https://github.com/abhisekmaiti19") + chalk2.magenta("\nLinkedIn: https://linkedin.com/in/abhisekmaiti19\n")
|
|
578
|
+
);
|
|
579
|
+
const ROOT = process.cwd();
|
|
580
|
+
const pkgPath = path.join(ROOT, "package.json");
|
|
581
|
+
if (!fs.existsSync(pkgPath)) {
|
|
582
|
+
console.log(chalk2.red("\u274C package.json not found."));
|
|
583
|
+
console.log(
|
|
584
|
+
chalk2.gray("Please run this command from your project root.\n")
|
|
585
|
+
);
|
|
586
|
+
process.exit(1);
|
|
587
|
+
}
|
|
588
|
+
let userPkg;
|
|
589
|
+
try {
|
|
590
|
+
userPkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
591
|
+
} catch {
|
|
592
|
+
console.log(chalk2.red("\u274C Failed to parse package.json"));
|
|
593
|
+
process.exit(1);
|
|
594
|
+
}
|
|
595
|
+
const isPwaKit = userPkg.ccExtensibility && userPkg.ccExtensibility.extends === "@salesforce/retail-react-app";
|
|
596
|
+
const hasRetailReactApp = userPkg.devDependencies && userPkg.devDependencies["@salesforce/retail-react-app"] || userPkg.dependencies && userPkg.dependencies["@salesforce/retail-react-app"];
|
|
597
|
+
if (!isPwaKit || !hasRetailReactApp) {
|
|
598
|
+
console.log(
|
|
599
|
+
chalk2.red(
|
|
600
|
+
"\n\u274C This does not appear to be a Salesforce PWA Kit project.\n"
|
|
601
|
+
)
|
|
602
|
+
);
|
|
603
|
+
console.log(chalk2.yellow("Expected in package.json:\n"));
|
|
604
|
+
console.log(
|
|
605
|
+
chalk2.gray(`"ccExtensibility": {
|
|
606
|
+
"extends": "@salesforce/retail-react-app"
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
"devDependencies": {
|
|
610
|
+
"@salesforce/retail-react-app": "x.x.x"
|
|
611
|
+
}
|
|
612
|
+
`)
|
|
613
|
+
);
|
|
614
|
+
process.exit(1);
|
|
615
|
+
}
|
|
616
|
+
console.log(chalk2.green("\u2705 Salesforce PWA Kit project detected\n"));
|
|
617
|
+
const WEBPACK_DEST = path.join(ROOT, "webpack.config.js");
|
|
618
|
+
const POSTCSS_DEST = path.join(ROOT, "postcss.config.js");
|
|
619
|
+
const WEBPACK_SRC = path.join(__dirname, "../webpack.config.js");
|
|
620
|
+
const POSTCSS_SRC = path.join(__dirname, "../postcss.config.js");
|
|
621
|
+
const webpackTemplate = fs.readFileSync(WEBPACK_SRC, "utf8");
|
|
622
|
+
const postcssTemplate = fs.readFileSync(POSTCSS_SRC, "utf8");
|
|
623
|
+
const BRAND = `
|
|
624
|
+
/**
|
|
625
|
+
* Generated by pwa-style-loader
|
|
626
|
+
* Author: Abhisek Maiti
|
|
627
|
+
* GitHub: https://github.com/abhisekmaiti19
|
|
628
|
+
* LinkedIn: https://linkedin.com/in/abhisekmaiti19
|
|
629
|
+
*/
|
|
630
|
+
`.trim();
|
|
631
|
+
function askYesNo(question) {
|
|
632
|
+
const rl = readline.createInterface({
|
|
633
|
+
input: process.stdin,
|
|
634
|
+
output: process.stdout
|
|
635
|
+
});
|
|
636
|
+
return new Promise((resolve) => {
|
|
637
|
+
rl.question(question, (answer) => {
|
|
638
|
+
rl.close();
|
|
639
|
+
resolve(/^y(es)?$/i.test(answer.trim()));
|
|
640
|
+
});
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
async function createOrReplace({ dest, template, filename }) {
|
|
644
|
+
if (!fs.existsSync(dest)) {
|
|
645
|
+
fs.writeFileSync(dest, `${BRAND}
|
|
646
|
+
|
|
647
|
+
${template}`);
|
|
648
|
+
console.log(chalk2.green(`\u2705 ${filename} created`));
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
console.log(chalk2.yellow(`\u26A0\uFE0F ${filename} already exists.`));
|
|
652
|
+
const replace = await askYesNo(
|
|
653
|
+
chalk2.cyan(`Do you want to replace ${filename}? (y/N): `)
|
|
654
|
+
);
|
|
655
|
+
if (!replace) {
|
|
656
|
+
console.log(chalk2.gray(`\u2139\uFE0F Skipped ${filename}. No changes made.`));
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
fs.writeFileSync(dest, `${BRAND}
|
|
660
|
+
|
|
661
|
+
${template}`);
|
|
662
|
+
console.log(chalk2.green(`\u2705 ${filename} replaced successfully`));
|
|
663
|
+
}
|
|
664
|
+
await createOrReplace({
|
|
665
|
+
dest: WEBPACK_DEST,
|
|
666
|
+
template: webpackTemplate,
|
|
667
|
+
filename: "webpack.config.js"
|
|
668
|
+
});
|
|
669
|
+
await createOrReplace({
|
|
670
|
+
dest: POSTCSS_DEST,
|
|
671
|
+
template: postcssTemplate,
|
|
672
|
+
filename: "postcss.config.js"
|
|
673
|
+
});
|
|
674
|
+
console.log(chalk2.green("\n\u{1F389} Setup completed the installation!\n"));
|
|
675
|
+
})();
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pwa-kit-style-loader",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Vanilla CSS support for Salesforce PWA Kit (one-command setup)",
|
|
5
|
+
"bin": {
|
|
6
|
+
"pwa-style-loader": "dist/init.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "esbuild src/init.js --bundle --platform=node --outfile=dist/init.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"webpack.config.js",
|
|
14
|
+
"postcss.config.js"
|
|
15
|
+
],
|
|
16
|
+
"keywords": [
|
|
17
|
+
"sfcc",
|
|
18
|
+
"salesforce",
|
|
19
|
+
"pwa-kit",
|
|
20
|
+
"retail-react-app",
|
|
21
|
+
"webpack"
|
|
22
|
+
],
|
|
23
|
+
"author": "Abhisek Maiti <abhisekmaiti19@gmail.com>",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@salesforce/pwa-kit-dev": ">=3"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"autoprefixer": "^10.4.24",
|
|
30
|
+
"chalk": "^5.6.2",
|
|
31
|
+
"css-loader": "^7.1.3",
|
|
32
|
+
"postcss": "^8.5.6",
|
|
33
|
+
"postcss-loader": "^8.2.0",
|
|
34
|
+
"style-loader": "^4.0.0"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@changesets/cli": "^2.29.8",
|
|
41
|
+
"esbuild": "^0.27.3"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const webpackConfig = require("@salesforce/pwa-kit-dev/configs/webpack/config"); // eslint-disable-line
|
|
2
|
+
|
|
3
|
+
// Add or update the rule for CSS processing
|
|
4
|
+
webpackConfig.forEach((config) => {
|
|
5
|
+
if (config.module && config.module.rules) {
|
|
6
|
+
config.module.rules.push({
|
|
7
|
+
test: /\.css$/,
|
|
8
|
+
use: ["style-loader", "css-loader", "postcss-loader"],
|
|
9
|
+
});
|
|
10
|
+
} else {
|
|
11
|
+
config.module = {
|
|
12
|
+
rules: [
|
|
13
|
+
{
|
|
14
|
+
test: /\.css$/,
|
|
15
|
+
use: ["style-loader", "css-loader", "postcss-loader"],
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
module.exports = webpackConfig;
|