@solfacil/girassol 0.59.2 โ†’ 0.59.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@solfacil/girassol",
3
3
  "description": "Girassol design system",
4
- "version": "0.59.2",
4
+ "version": "0.59.3",
5
5
  "license": "MIT",
6
6
  "authors": [
7
7
  {
@@ -40,7 +40,6 @@
40
40
  },
41
41
  "types": "./dist/types/index.d.ts",
42
42
  "scripts": {
43
- "postinstall": "node scripts/update-girassol-icons.mjs",
44
43
  "typecheck": "vue-tsc -p tsconfig.app.json --noEmit",
45
44
  "dev": "vite --port 3333 --host",
46
45
  "build:lib": "vue-tsc --noEmit && vite build",
@@ -61,7 +60,9 @@
61
60
  "prepare": "husky install",
62
61
  "commit": "cz",
63
62
  "pre-commit": "./.husky/run-staged-tests.js",
64
- "semantic-release": "semantic-release"
63
+ "semantic-release": "semantic-release",
64
+ "postinstall": "./scripts/post-install.sh",
65
+ "prebuild:lib": "./scripts/prebuild.sh"
65
66
  },
66
67
  "dependencies": {
67
68
  "@tanstack/vue-virtual": "^3.7.0",
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ if [ ! -d "./node_modules/@solfacil/girassol" ]; then
4
+ mkdir -p ./node_modules/@solfacil/girassol
5
+ fi
6
+
7
+ cp ./icons.json ./node_modules/@solfacil/girassol/icons.json
8
+ cp ./illustration.json ./node_modules/@solfacil/girassol/illustration.json
9
+
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ if [ ! -d "./node_modules/@solfacil/girassol" ]; then
4
+ mkdir -p ./node_modules/@solfacil/girassol
5
+ fi
6
+
7
+ cp ./icons.json ./node_modules/@solfacil/girassol/icons.json
8
+ cp ./illustration.json ./node_modules/@solfacil/girassol/illustration.json
9
+
package/vite.config.ts CHANGED
@@ -11,12 +11,9 @@ import Inspect from 'vite-plugin-inspect'
11
11
  import WindiCSS from 'vite-plugin-windicss'
12
12
 
13
13
  import GirassolComponentsTypes from './vite-modules/generate-component-types'
14
- import GenerateIconsData from './vite-modules/generate-girassol-icons'
15
14
 
16
15
  const currentPath = path.resolve(__dirname)
17
16
 
18
- const girassolPath = path.join(__dirname, 'node_modules/@solfacil/girassol')
19
-
20
17
  // https://vitejs.dev/config/
21
18
  export default defineConfig({
22
19
  build: {
@@ -63,13 +60,12 @@ export default defineConfig({
63
60
  compiler: 'vue3',
64
61
  scale: 1.0,
65
62
  customCollections: {
66
- girassol: async () => JSON.parse(await readFile(`${girassolPath}/icons.json`, 'utf8')),
67
- illustration: async () => JSON.parse(await readFile(`${girassolPath}/illustration.json`, 'utf8')),
63
+ girassol: async () => JSON.parse(await readFile('./icons.json', 'utf8')),
64
+ illustration: async () => JSON.parse(await readFile('./illustration.json', 'utf8')),
68
65
  },
69
66
  }),
70
67
 
71
68
  GirassolComponentsTypes(),
72
- GenerateIconsData(),
73
69
  ],
74
70
 
75
71
  optimizeDeps: {
@@ -1,154 +0,0 @@
1
- import { access, constants, mkdir, readFile, writeFile } from 'fs/promises'
2
- import { dirname, join } from 'path'
3
- import crypto from 'crypto'
4
- import https from 'node-fetch'
5
-
6
- const COLORS = {
7
- Reset: "\x1B[0m",
8
- Bright: "\x1B[1m",
9
- Dim: "\x1B[2m",
10
- Italic: "\x1B[3m",
11
- Underscore: "\x1B[4m",
12
- Blink: "\x1B[5m",
13
- Reverse: "\x1B[7m",
14
- Hidden: "\x1B[8m",
15
- Stroke: "\x1B[9m",
16
-
17
- FgBlack: "\x1B[30m",
18
- FgRed: "\x1B[31m",
19
- FgGreen: "\x1B[32m",
20
- FgYellow: "\x1B[33m",
21
- FgBlue: "\x1B[34m",
22
- FgMagenta: "\x1B[35m",
23
- FgCyan: "\x1B[36m",
24
- FgWhite: "\x1B[37m",
25
- FgGray: "\x1B[90m",
26
-
27
- BgBlack: "\x1B[40m",
28
- BgRed: "\x1B[41m",
29
- BgGreen: "\x1B[42m",
30
- BgYellow: "\x1B[43m",
31
- BgBlue: "\x1B[44m",
32
- BgMagenta: "\x1B[45m",
33
- BgCyan: "\x1B[46m",
34
- BgWhite: "\x1B[47m",
35
- BgGray: "\x1B[100m",
36
- }
37
-
38
- function log(styles, content) {
39
- console.log(...styles, content, COLORS.Reset)
40
- }
41
-
42
- log([COLORS.Bright,COLORS.FgYellow], '======== [GIRASSOL_ICONS] =========')
43
-
44
- const dirname__ = dirname('./node_modules/')
45
- const girassolModules = join(dirname__, 'node_modules/@solfacil/girassol')
46
-
47
- const COLLECTIONS = [
48
- { url: 'https://d1azc1qln24ryf.cloudfront.net/265413/Icons/selection-svg.json', filename: 'icons', collection: 'girassol' },
49
- { url: 'https://d1azc1qln24ryf.cloudfront.net/265413/Ilustrations/selection-svg.json', filename: 'illustration', collection: 'illustration' },
50
- ]
51
-
52
- async function getIcon(url) {
53
- try {
54
- const data = await https(url, { method: 'GET' })
55
- const response = await data.json()
56
-
57
- const hash = crypto.createHash('md5')
58
- hash.update(JSON.stringify(response))
59
-
60
- response.hash = hash.digest('hex')
61
-
62
- return response
63
- }
64
- catch (er) {
65
- console.error('Error', er)
66
- }
67
- }
68
-
69
- function transformIcons(collection, icons) {
70
- const girassol = {
71
- prefix: collection,
72
- hash: icons?.hash,
73
- width: 1024,
74
- height: 1024,
75
- icons: {},
76
- }
77
-
78
- icons.icons.forEach(({ icon, properties }) => {
79
- const name = properties.name
80
- const hasAttributes = icon.attrs.length
81
-
82
- function transformAttribute(index) {
83
- const currentAttributes = icon.attrs[index]
84
-
85
- const style = () =>
86
- Object.entries(currentAttributes)
87
- .flatMap(([property, value]) => `${property}: ${value}`)
88
- .join(';')
89
-
90
- if (hasAttributes && Object.values(currentAttributes))
91
- return `style="${style()}"`
92
- }
93
-
94
- function addPath(path, index) {
95
- return `<path fill="currentColor" d="${path}" ${transformAttribute(index)} />`
96
- }
97
-
98
- const paths = icon.paths
99
- .map(addPath)
100
- .join('')
101
-
102
- Object.assign(girassol.icons, {
103
- [name]: {
104
- body: paths,
105
- },
106
- })
107
- })
108
-
109
- return girassol
110
- }
111
-
112
- function createGirassolIconFiles(filename, collection, data) {
113
- writeFile(`${girassolModules}/${filename}.json`, JSON.stringify(transformIcons(collection, data)))
114
- }
115
-
116
- export async function generateIcons() {
117
- for (const collection of COLLECTIONS) {
118
- try {
119
- const icons = await getIcon(collection.url)
120
-
121
- readFile(`${girassolModules}/${collection.filename}.json`)
122
- .then(response => {
123
- const cached = JSON.parse((response).toString())
124
- const isDifferentHash = icons.hash !== cached.hash
125
-
126
- log([COLORS.Bright,COLORS.FgCyan],
127
- `${isDifferentHash ? ' ๐Ÿ’ก' : ' โœ…'} [${collection.filename}] ${isDifferentHash ? 'has new update' : 'is updated' }`)
128
-
129
- if (isDifferentHash){
130
- log([COLORS.Blink, COLORS.Bright, COLORS.FgCyan],`๐Ÿ‘ท [${collection.filename}] Updating...`)
131
- createGirassolIconFiles(collection.filename, collection.collection, icons)
132
- log([COLORS.Bright,COLORS.FgCyan],` โœ… [${collection.filename}] Updated!`)
133
- }
134
-
135
- })
136
- .catch(() => {
137
- createGirassolIconFiles(collection.filename, collection.collection, icons)
138
- log([COLORS.Bright,COLORS.FgYellow],` ๐Ÿงช [${collection.filename}] Created!`)
139
- })
140
- }
141
- catch(e) {
142
- console.error('ERROR ', e)
143
- }
144
- }
145
- }
146
-
147
- export async function validateFolder() {
148
- try {
149
- await access(girassolModules, constants.R_OK | constants.W_OK)
150
- }
151
- catch {
152
- await mkdir(join(dirname__, 'node_modules/@solfacil/girassol'), { recursive: true })
153
- }
154
- }
@@ -1,4 +0,0 @@
1
- import { generateIcons,validateFolder } from './girassol-icons.mjs'
2
-
3
- validateFolder()
4
- generateIcons()
@@ -1,18 +0,0 @@
1
- import type { Plugin } from 'vite'
2
-
3
- import { generateIcons,validateFolder } from '../scripts/girassol-icons.mjs'
4
-
5
- export default (): Plugin => {
6
- return {
7
- name: 'vite-generate-girassol-icons-data',
8
- apply: 'serve',
9
-
10
- async buildStart() {
11
-
12
- await validateFolder()
13
- await generateIcons()
14
-
15
- console.log('[Girassol icons generated!]')
16
- },
17
- }
18
- }