@joycostudio/scripts 0.0.1

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.
@@ -0,0 +1,132 @@
1
+ const SVG_ATTR_MAP = {
2
+ // Fill and stroke attributes
3
+ 'fill-rule': 'fillRule',
4
+ 'fill-opacity': 'fillOpacity',
5
+ 'stroke-width': 'strokeWidth',
6
+ 'stroke-linecap': 'strokeLinecap',
7
+ 'stroke-linejoin': 'strokeLinejoin',
8
+ 'stroke-miterlimit': 'strokeMiterlimit',
9
+ 'stroke-dasharray': 'strokeDasharray',
10
+ 'stroke-dashoffset': 'strokeDashoffset',
11
+ 'stroke-opacity': 'strokeOpacity',
12
+
13
+ // Clipping and masking
14
+ 'clip-rule': 'clipRule',
15
+ 'clip-path': 'clipPath',
16
+ 'mask-type': 'maskType',
17
+ 'mask-units': 'maskUnits',
18
+ 'mask-content-units': 'maskContentUnits',
19
+
20
+ // Color and filters
21
+ 'color-interpolation': 'colorInterpolation',
22
+ 'color-interpolation-filters': 'colorInterpolationFilters',
23
+ 'color-profile': 'colorProfile',
24
+ 'color-rendering': 'colorRendering',
25
+ 'flood-color': 'floodColor',
26
+ 'flood-opacity': 'floodOpacity',
27
+ 'lighting-color': 'lightingColor',
28
+ 'stop-color': 'stopColor',
29
+ 'stop-opacity': 'stopOpacity',
30
+
31
+ // Text attributes
32
+ 'font-family': 'fontFamily',
33
+ 'font-size': 'fontSize',
34
+ 'font-size-adjust': 'fontSizeAdjust',
35
+ 'font-stretch': 'fontStretch',
36
+ 'font-style': 'fontStyle',
37
+ 'font-variant': 'fontVariant',
38
+ 'font-weight': 'fontWeight',
39
+ 'text-anchor': 'textAnchor',
40
+ 'text-decoration': 'textDecoration',
41
+ 'text-rendering': 'textRendering',
42
+ 'unicode-bidi': 'unicodeBidi',
43
+ 'writing-mode': 'writingMode',
44
+ 'letter-spacing': 'letterSpacing',
45
+ 'word-spacing': 'wordSpacing',
46
+ 'text-length': 'textLength',
47
+ 'length-adjust': 'lengthAdjust',
48
+
49
+ // Gradient and pattern attributes
50
+ 'gradient-units': 'gradientUnits',
51
+ 'gradient-transform': 'gradientTransform',
52
+ 'pattern-units': 'patternUnits',
53
+ 'pattern-content-units': 'patternContentUnits',
54
+ 'pattern-transform': 'patternTransform',
55
+ 'spread-method': 'spreadMethod',
56
+
57
+ // Animation attributes
58
+ 'animation-name': 'animationName',
59
+ 'animation-duration': 'animationDuration',
60
+ 'animation-timing-function': 'animationTimingFunction',
61
+ 'animation-delay': 'animationDelay',
62
+ 'animation-iteration-count': 'animationIterationCount',
63
+ 'animation-direction': 'animationDirection',
64
+ 'animation-fill-mode': 'animationFillMode',
65
+ 'animation-play-state': 'animationPlayState',
66
+
67
+ // Marker attributes
68
+ 'marker-start': 'markerStart',
69
+ 'marker-mid': 'markerMid',
70
+ 'marker-end': 'markerEnd',
71
+ 'marker-units': 'markerUnits',
72
+ 'marker-width': 'markerWidth',
73
+ 'marker-height': 'markerHeight',
74
+ 'ref-x': 'refX',
75
+ 'ref-y': 'refY',
76
+
77
+ // Filter attributes
78
+ 'filter-units': 'filterUnits',
79
+ 'primitive-units': 'primitiveUnits',
80
+
81
+ // Viewbox and coordinate system
82
+ 'view-box': 'viewBox',
83
+ 'preserve-aspect-ratio': 'preserveAspectRatio',
84
+
85
+ // Miscellaneous
86
+ 'shape-rendering': 'shapeRendering',
87
+ 'image-rendering': 'imageRendering',
88
+ 'pointer-events': 'pointerEvents',
89
+ 'vector-effect': 'vectorEffect',
90
+ 'baseline-shift': 'baselineShift',
91
+ 'dominant-baseline': 'dominantBaseline',
92
+ 'glyph-orientation-horizontal': 'glyphOrientationHorizontal',
93
+ 'glyph-orientation-vertical': 'glyphOrientationVertical',
94
+ 'text-decoration': 'textDecoration',
95
+ 'enable-background': 'enableBackground',
96
+ }
97
+
98
+ module.exports = function transformer(file, api) {
99
+ const j = api.jscodeshift
100
+ const root = j(file.source)
101
+
102
+ function isSvgElement(path) {
103
+ return (
104
+ path.node.openingElement.name.type === 'JSXIdentifier' &&
105
+ path.node.openingElement.name.name === 'svg'
106
+ )
107
+ }
108
+
109
+ function renameAttrs(path) {
110
+ path.node.openingElement.attributes.forEach(attr => {
111
+ if (
112
+ attr.type === 'JSXAttribute' &&
113
+ attr.name &&
114
+ SVG_ATTR_MAP[attr.name.name]
115
+ ) {
116
+ attr.name.name = SVG_ATTR_MAP[attr.name.name]
117
+ }
118
+ })
119
+ }
120
+
121
+ root
122
+ .find(j.JSXElement)
123
+ .filter(isSvgElement)
124
+ .forEach(svgPath => {
125
+ renameAttrs(svgPath)
126
+ j(svgPath)
127
+ .find(j.JSXElement)
128
+ .forEach(renameAttrs)
129
+ })
130
+
131
+ return root.toSource({ quote: 'single' })
132
+ }
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@joycostudio/scripts",
3
+ "version": "0.0.1",
4
+ "description": "Joyco utility scripts as a pnpx CLI",
5
+ "bin": {
6
+ "scripts": "dist/cli.js"
7
+ },
8
+ "main": "dist/cli.js",
9
+ "files": [
10
+ "dist/",
11
+ "lib/",
12
+ "README.md"
13
+ ],
14
+ "keywords": [
15
+ "cli",
16
+ "scripts",
17
+ "joyco"
18
+ ],
19
+ "author": "joyco.studio",
20
+ "license": "ISC",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/joyco-studio/scripts.git",
24
+ "directory": "cli"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "packageManager": "pnpm@10.11.0",
30
+ "dependencies": {
31
+ "commander": "^12.1.0",
32
+ "jscodeshift": "^0.15.2",
33
+ "sharp": "^0.34.3"
34
+ },
35
+ "devDependencies": {
36
+ "@types/node": "^25.0.3",
37
+ "esbuild": "^0.27.2",
38
+ "ts-node": "^10.9.2",
39
+ "typescript": "^5.6.3"
40
+ },
41
+ "scripts": {
42
+ "build": "node esbuild.config.mjs",
43
+ "test": "node --test -r ts-node/register/transpile-only \"test/**/*.test.ts\"",
44
+ "tscheck": "tsc --noEmit"
45
+ }
46
+ }