purgetss 7.1.2 → 7.1.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.
@@ -1,4 +1,4 @@
1
- // PurgeTSS v7.1.0
1
+ // PurgeTSS v7.1.3
2
2
  // Created by César Estrada
3
3
  // https://purgetss.com
4
4
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "purgetss",
4
- "version": "7.1.2",
4
+ "version": "7.1.3",
5
5
  "main": "src/index.js",
6
6
  "bin": {
7
7
  "purgetss": "bin/purgetss"
@@ -31,6 +31,9 @@
31
31
  "test:integration": "node tests/run-tests.js integration",
32
32
  "test:count": "node tests/unit/shared/function-counter.test.js",
33
33
  "test:cli-realtime": "node tests/e2e/cli-commands-realtime.test.js",
34
+ "test:install-local": "node tests/e2e/installation-simulation.test.js",
35
+ "test:install-global": "node tests/e2e/global-installation-simulation.test.js",
36
+ "test:install": "npm run test:install-local && npm run test:install-global",
34
37
  "build": "npm run build:all",
35
38
  "notifier": "node ./lib/test-function",
36
39
  "build:module": "node ./src/dev/builders/module-builder.js",
@@ -70,6 +73,7 @@
70
73
  "chroma-js": "^3.1.2",
71
74
  "command-exists": "^1.2.9",
72
75
  "commander": "^14.0.0",
76
+ "css": "^3.0.0",
73
77
  "fontname": "^1.0.1",
74
78
  "framework7-icons": "^5.0.5",
75
79
  "glob": "^9.3.5",
@@ -79,7 +83,6 @@
79
83
  "ntcjs": "^1.1.3",
80
84
  "path": "^0.12.7",
81
85
  "prompts": "^2.4.2",
82
- "read-css": "^0.3.0",
83
86
  "tailwindcss": "^3.4.17",
84
87
  "traverse": "^0.6.11",
85
88
  "update-notifier": "^7.3.1",
@@ -87,10 +90,12 @@
87
90
  "xml-js": "^1.6.11"
88
91
  },
89
92
  "devDependencies": {
90
- "eslint": "^9.16.0",
91
93
  "@eslint/js": "^9.16.0",
94
+ "css-tree": "^3.1.0",
95
+ "eslint": "^9.16.0",
96
+ "eslint-plugin-import": "^2.31.0",
92
97
  "eslint-plugin-n": "^16.6.2",
93
98
  "eslint-plugin-promise": "^7.2.1",
94
- "eslint-plugin-import": "^2.31.0"
99
+ "read-css": "^0.3.0"
95
100
  }
96
101
  }
@@ -17,7 +17,7 @@ import path from 'path'
17
17
  import FontName from 'fontname'
18
18
  import _ from 'lodash'
19
19
  import chalk from 'chalk'
20
- import readCSS from 'read-css'
20
+ import css from 'css'
21
21
  import { alloyProject, makeSureFolderExists } from '../../shared/utils.js'
22
22
  import { getFiles, getFileName } from '../utils/font-utilities.js'
23
23
  import {
@@ -343,7 +343,7 @@ export function buildFonts(options) {
343
343
  // Process styles files
344
344
  _.each(files, file => {
345
345
  if (file.endsWith('.css') || file.endsWith('.CSS')) {
346
- const cssFile = readCSS(file)
346
+ const cssFile = css.parse(fs.readFileSync(file, 'utf8'))
347
347
  const theFile = file.split('/')
348
348
  const theCSSFile = theFile.pop()
349
349
  const prefix = options.fontClassFromFilename ? theCSSFile.split('.').shift() : null
@@ -12,7 +12,7 @@ import fs from 'fs'
12
12
  import path from 'path'
13
13
  import { fileURLToPath } from 'url'
14
14
  import _ from 'lodash'
15
- import readCSS from 'read-css'
15
+ import css from 'css'
16
16
  import { logger } from '../../shared/logger.js'
17
17
 
18
18
  const __filename = fileURLToPath(import.meta.url)
@@ -148,25 +148,24 @@ export function processFontawesomeStyles(data) {
148
148
  * @param {string} webFonts - Web fonts folder path
149
149
  */
150
150
  export function processFontAwesomeTSS(CSSFile, templateTSS, resetTSS, fontFamilies, webFonts) {
151
- readCSS(CSSFile, (err, data) => {
152
- if (err) throw err
151
+ const cssContent = fs.readFileSync(CSSFile, 'utf8')
152
+ const data = css.parse(cssContent)
153
153
 
154
- let tssClasses = fs.readFileSync(path.resolve(projectRoot, templateTSS), 'utf8') + '\n'
154
+ let tssClasses = fs.readFileSync(path.resolve(projectRoot, templateTSS), 'utf8') + '\n'
155
155
 
156
- tssClasses += fs.readFileSync(path.resolve(projectRoot, resetTSS), 'utf8') + '\n'
156
+ tssClasses += fs.readFileSync(path.resolve(projectRoot, resetTSS), 'utf8') + '\n'
157
157
 
158
- tssClasses += processFontawesomeStyles(data)
158
+ tssClasses += processFontawesomeStyles(data)
159
159
 
160
- fs.writeFileSync(projectsFA_TSS_File, tssClasses, err2 => {
161
- throw err2
162
- })
160
+ fs.writeFileSync(projectsFA_TSS_File, tssClasses, err2 => {
161
+ throw err2
162
+ })
163
163
 
164
- logger.file('./purgetss/styles/fontawesome.tss')
164
+ logger.file('./purgetss/styles/fontawesome.tss')
165
165
 
166
- makeSureFolderExists(projectsFontsFolder)
166
+ makeSureFolderExists(projectsFontsFolder)
167
167
 
168
- copyProFonts(fontFamilies, webFonts)
169
- })
168
+ copyProFonts(fontFamilies, webFonts)
170
169
  }
171
170
 
172
171
  /**
@@ -175,8 +174,9 @@ export function processFontAwesomeTSS(CSSFile, templateTSS, resetTSS, fontFamili
175
174
  * @param {string} faJS - Path to FontAwesome JS template
176
175
  */
177
176
  export function processFontAwesomeJS(CSSFile, faJS) {
178
- readCSS(CSSFile, (err, data) => {
179
- if (err) throw err
177
+ try {
178
+ const cssContent = fs.readFileSync(CSSFile, 'utf8')
179
+ const data = css.parse(cssContent)
180
180
 
181
181
  const rules = _.map(data.stylesheet.rules, rule => {
182
182
  if (rule.type === 'rule' && rule.selectors[0].includes(':before') && !rule.selectors[0].includes('.fad')) {
@@ -214,7 +214,9 @@ export function processFontAwesomeJS(CSSFile, faJS) {
214
214
  })
215
215
 
216
216
  logger.file('./app/lib/fontawesome.js')
217
- })
217
+ } catch (err) {
218
+ throw err
219
+ }
218
220
  }
219
221
 
220
222
  /**
@@ -14,7 +14,7 @@ import fs from 'fs'
14
14
  import path from 'path'
15
15
  import { fileURLToPath } from 'url'
16
16
  import _ from 'lodash'
17
- import readCSS from 'read-css'
17
+ import css from 'css'
18
18
  import { logger } from '../../../shared/logger.js'
19
19
 
20
20
  const __filename = fileURLToPath(import.meta.url)
@@ -31,27 +31,26 @@ if (!fs.existsSync(path.resolve(projectRoot, './dist'))) {
31
31
  * COPIED exactly from original constructor() function
32
32
  */
33
33
  export function buildFontAwesome() {
34
- readCSS(path.resolve(projectRoot, './node_modules/@fortawesome/fontawesome-free/css/all.css'), (err, data) => {
35
- if (err) throw err
34
+ const cssContent = fs.readFileSync(path.resolve(projectRoot, './node_modules/@fortawesome/fontawesome-free/css/all.css'), 'utf8')
35
+ const data = css.parse(cssContent)
36
36
 
37
- let tssClasses = fs.readFileSync(path.resolve(projectRoot, './lib/templates/fontawesome/free-template.tss'), 'utf8') + '\n'
37
+ let tssClasses = fs.readFileSync(path.resolve(projectRoot, './lib/templates/fontawesome/free-template.tss'), 'utf8') + '\n'
38
38
 
39
- tssClasses += fs.readFileSync(path.resolve(projectRoot, './lib/templates/fontawesome/free-reset.tss'), 'utf8')
39
+ tssClasses += fs.readFileSync(path.resolve(projectRoot, './lib/templates/fontawesome/free-reset.tss'), 'utf8')
40
40
 
41
- tssClasses += processCSS(data)
41
+ tssClasses += processCSS(data)
42
42
 
43
- fs.writeFileSync(path.resolve(projectRoot, './dist/fontawesome.tss'), tssClasses, _err => {
44
- throw _err
45
- })
46
-
47
- logger.file('./dist/fontawesome.tss')
43
+ fs.writeFileSync(path.resolve(projectRoot, './dist/fontawesome.tss'), tssClasses, _err => {
44
+ throw _err
48
45
  })
46
+
47
+ logger.file('./dist/fontawesome.tss')
49
48
  }
50
49
 
51
50
  /**
52
51
  * Process CSS data to TSS format
53
52
  * COPIED exactly from original processCSS() function - NO CHANGES
54
- *
53
+ *
55
54
  * @param {Object} data - CSS data from readCSS
56
55
  * @returns {string} Processed TSS classes
57
56
  */
@@ -79,4 +78,4 @@ export function processCSS(data) {
79
78
  // Execute if run directly
80
79
  if (import.meta.url === `file://${process.argv[1]}`) {
81
80
  buildFontAwesome()
82
- }
81
+ }
@@ -14,7 +14,7 @@ import fs from 'fs'
14
14
  import path from 'path'
15
15
  import { fileURLToPath } from 'url'
16
16
  import _ from 'lodash'
17
- import read from 'read-css'
17
+ import css from 'css'
18
18
  import { logger } from '../../../shared/logger.js'
19
19
 
20
20
  const __filename = fileURLToPath(import.meta.url)
@@ -31,44 +31,43 @@ if (!fs.existsSync(path.resolve(projectRoot, './dist'))) {
31
31
  * COPIED exactly from original constructor() function
32
32
  */
33
33
  export function buildFontAwesomeJS() {
34
- read(path.resolve(projectRoot, './node_modules/@fortawesome/fontawesome-free/css/all.css'), (err, data) => {
35
- if (err) throw err
36
-
37
- const rules = _.map(data.stylesheet.rules, rule => {
38
- if (rule.type === 'rule' && rule.selectors && rule.declarations[0].value.includes('"\\')) {
39
- return {
40
- selector: rule.selectors[0].replace('::before', '').replace(':before', '').replace('.', ''),
41
- property: ('0000' + rule.declarations[0].value.replace('\"\\', '').replace('\"', '')).slice(-4)
42
- }
34
+ const cssContent = fs.readFileSync(path.resolve(projectRoot, './node_modules/@fortawesome/fontawesome-free/css/all.css'), 'utf8')
35
+ const data = css.parse(cssContent)
36
+
37
+ const rules = _.map(data.stylesheet.rules, rule => {
38
+ if (rule.type === 'rule' && rule.selectors && rule.declarations[0].value.includes('"\\')) {
39
+ return {
40
+ selector: rule.selectors[0].replace('::before', '').replace(':before', '').replace('.', ''),
41
+ property: ('0000' + rule.declarations[0].value.replace('\"\\', '').replace('\"', '')).slice(-4)
43
42
  }
44
- })
45
-
46
- let fontawesome = fs.readFileSync(path.resolve(projectRoot, './lib/templates/fontawesome/free-template.js.cjs'), 'utf8')
43
+ }
44
+ })
47
45
 
48
- fontawesome += '\n' + fs.readFileSync(path.resolve(projectRoot, './lib/templates/icon-functions.js.cjs'), 'utf8')
46
+ let fontawesome = fs.readFileSync(path.resolve(projectRoot, './lib/templates/fontawesome/free-template.js.cjs'), 'utf8')
49
47
 
50
- let exportIcons = '\nconst icons = {\n'
48
+ fontawesome += '\n' + fs.readFileSync(path.resolve(projectRoot, './lib/templates/icon-functions.js.cjs'), 'utf8')
51
49
 
52
- _.each(rules, rule => {
53
- if (rule) {
54
- exportIcons += `\t'${prettifyFontName(rule.selector)}': '\\u${rule.property}',\n`
55
- }
56
- })
50
+ let exportIcons = '\nconst icons = {\n'
57
51
 
58
- exportIcons += '};\n'
52
+ _.each(rules, rule => {
53
+ if (rule) {
54
+ exportIcons += `\t'${prettifyFontName(rule.selector)}': '\\u${rule.property}',\n`
55
+ }
56
+ })
59
57
 
60
- exportIcons += 'exports.icons = icons;\n'
58
+ exportIcons += '};\n'
61
59
 
62
- exportIcons += '\nconst iconKeys = Object.keys(icons)\n'
60
+ exportIcons += 'exports.icons = icons;\n'
63
61
 
64
- fontawesome += exportIcons
62
+ exportIcons += '\nconst iconKeys = Object.keys(icons)\n'
65
63
 
66
- fs.writeFileSync(path.resolve(projectRoot, './dist/fontawesome.js'), fontawesome, _err => {
67
- throw _err
68
- })
64
+ fontawesome += exportIcons
69
65
 
70
- logger.file('./dist/fontawesome.js')
66
+ fs.writeFileSync(path.resolve(projectRoot, './dist/fontawesome.js'), fontawesome, _err => {
67
+ throw _err
71
68
  })
69
+
70
+ logger.file('./dist/fontawesome.js')
72
71
  }
73
72
 
74
73
  /**
@@ -17,7 +17,7 @@ import { isNotJunk } from 'junk'
17
17
  import glob from 'glob'
18
18
  import chalk from 'chalk'
19
19
  import convert from 'xml-js'
20
- import readCSS from 'read-css'
20
+ import css from 'css'
21
21
  import traverse from 'traverse'
22
22
  import inquirer from 'inquirer'
23
23
  import FontName from 'fontname'
@@ -718,7 +718,7 @@ function buildFonts(options) {
718
718
  // ! Process styles files
719
719
  _.each(files, file => {
720
720
  if (file.endsWith('.css') || file.endsWith('.CSS')) {
721
- const cssFile = readCSS(file)
721
+ const cssFile = css.parse(fs.readFileSync(file, 'utf8'))
722
722
  const theFile = file.split('/')
723
723
  const theCSSFile = theFile.pop()
724
724
  const prefix = options.fontClassFromFilename ? theCSSFile.split('.').shift() : null