purgetss 7.1.4 → 7.1.5
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/purgetss.ui.js
CHANGED
|
@@ -18,7 +18,10 @@ import { colores } from '../src/shared/brand-colors.js'
|
|
|
18
18
|
export { colores }
|
|
19
19
|
const purgeLabel = colores.purgeLabel
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
import * as helpers from '../src/shared/helpers.js'
|
|
22
|
+
import { getConfigFile } from '../src/shared/config-manager.js'
|
|
23
|
+
import { projectsConfigJS } from '../src/shared/constants.js'
|
|
24
|
+
const tiCompletionsFile = require('../lib/completions/titanium/completions-v3.json')
|
|
22
25
|
|
|
23
26
|
const logger = {
|
|
24
27
|
info: (...args) => console.log(purgeLabel, args.join(' ')),
|
|
@@ -27,11 +30,7 @@ const logger = {
|
|
|
27
30
|
file: (...args) => console.log(purgeLabel, chalk.yellow(args.join(' ')), 'file created!')
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
const tiCompletionsFile = require('../lib/completions/titanium/completions-v3.json')
|
|
32
|
-
const srcConfigFile = path.resolve(__dirname, '../lib/templates/purgetss.config.js.cjs')
|
|
33
|
-
|
|
34
|
-
const configFile = (fs.existsSync(projectsConfigJS)) ? require(projectsConfigJS) : require(srcConfigFile)
|
|
33
|
+
const configFile = getConfigFile()
|
|
35
34
|
configFile.purge = configFile.purge ?? { mode: 'all' }
|
|
36
35
|
configFile.theme = configFile.theme ?? {}
|
|
37
36
|
configFile.theme.extend = configFile.theme.extend ?? {}
|
package/package.json
CHANGED
|
@@ -14,12 +14,17 @@ import fs from 'fs'
|
|
|
14
14
|
import util from 'util'
|
|
15
15
|
import { projectsConfigJS } from '../../shared/constants.js'
|
|
16
16
|
import { createConfigFile } from '../commands/init.js'
|
|
17
|
+
import { migrateConfigIfNeeded } from '../../shared/config-manager.js'
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Initialize config if it doesn't exist
|
|
20
|
-
*
|
|
21
|
+
* FIRST migrates any existing config.js, THEN creates default if needed
|
|
21
22
|
*/
|
|
22
23
|
export function initIfNotConfig() {
|
|
24
|
+
// CRITICAL: Migrate config.js to config.cjs BEFORE checking if file exists
|
|
25
|
+
migrateConfigIfNeeded()
|
|
26
|
+
|
|
27
|
+
// Now check if we need to create default config
|
|
23
28
|
if (!fs.existsSync(projectsConfigJS)) {
|
|
24
29
|
createConfigFile()
|
|
25
30
|
}
|
|
@@ -25,23 +25,31 @@ import { makeSureFolderExists } from './utils.js'
|
|
|
25
25
|
const require = createRequire(import.meta.url)
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* @returns {Object} Configuration object with defaults applied
|
|
28
|
+
* Migrate config.js to config.cjs for ESM compatibility
|
|
29
|
+
* This must be called BEFORE any config file creation
|
|
32
30
|
*/
|
|
33
|
-
export function
|
|
34
|
-
// Auto-migration: rename config.js to config.cjs for ESM compatibility
|
|
31
|
+
export function migrateConfigIfNeeded() {
|
|
35
32
|
const oldConfigPath = `${projectsPurgeTSSFolder}/config.js`
|
|
33
|
+
|
|
34
|
+
// If only config.js exists, migrate it directly
|
|
36
35
|
if (fs.existsSync(oldConfigPath) && !fs.existsSync(projectsConfigJS)) {
|
|
37
36
|
makeSureFolderExists(projectsPurgeTSSFolder)
|
|
38
37
|
fs.renameSync(oldConfigPath, projectsConfigJS)
|
|
39
38
|
logger.info('Migrated config.js to config.cjs for ESM compatibility')
|
|
40
|
-
} else if (fs.existsSync(oldConfigPath) && fs.existsSync(projectsConfigJS)) {
|
|
41
|
-
// Remove old config.js if both exist
|
|
42
|
-
fs.unlinkSync(oldConfigPath)
|
|
43
|
-
logger.info('Removed duplicate config.js file')
|
|
44
39
|
}
|
|
40
|
+
// If both exist, preserve config.js (let the user decide)
|
|
41
|
+
else if (fs.existsSync(oldConfigPath) && fs.existsSync(projectsConfigJS)) {
|
|
42
|
+
logger.warn('Both config.js and config.cjs exist. Please manually merge and remove config.js')
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Get configuration file with fallback to default template
|
|
48
|
+
* Maintains exact same logic as original getConfigFile()
|
|
49
|
+
*
|
|
50
|
+
* @returns {Object} Configuration object with defaults applied
|
|
51
|
+
*/
|
|
52
|
+
export function getConfigFile() {
|
|
45
53
|
|
|
46
54
|
const configFile = (fs.existsSync(projectsConfigJS))
|
|
47
55
|
? require(projectsConfigJS)
|
|
@@ -56,7 +64,7 @@ export function getConfigFile() {
|
|
|
56
64
|
configFile.purge.options.widgets = configFile.purge.options.widgets ?? false
|
|
57
65
|
configFile.purge.options.safelist = configFile.purge.options.safelist ?? []
|
|
58
66
|
configFile.purge.options.plugins = configFile.purge.options.plugins ?? []
|
|
59
|
-
|
|
67
|
+
|
|
60
68
|
configFile.theme = configFile.theme ?? {}
|
|
61
69
|
configFile.theme.extend = configFile.theme.extend ?? {}
|
|
62
70
|
|
|
@@ -160,5 +168,6 @@ export default {
|
|
|
160
168
|
loadRawConfig,
|
|
161
169
|
getGlobalConfigFile,
|
|
162
170
|
getGlobalConfigOptions,
|
|
171
|
+
migrateConfigIfNeeded,
|
|
163
172
|
defaultTheme
|
|
164
173
|
}
|