purgetss 7.1.4 → 7.1.6
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 +1 -1
- package/experimental/completions2.js +5 -6
- package/package.json +1 -1
- package/src/cli/commands/build.js +2 -2
- package/src/cli/commands/color-module.js +2 -2
- package/src/cli/commands/init.js +13 -7
- package/src/cli/commands/purge.js +2 -2
- package/src/cli/commands/shades.js +12 -9
- package/src/cli/commands/watch.js +4 -1
- package/src/cli/utils/file-operations.js +4 -6
- package/src/shared/config-manager.js +48 -11
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
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { alloyProject } from '../../shared/utils.js'
|
|
14
|
-
import {
|
|
14
|
+
import { ensureConfig } from '../../shared/config-manager.js'
|
|
15
15
|
import { buildTailwindBasedOnConfigOptions } from '../../core/builders/tailwind-builder.js'
|
|
16
16
|
import { createDefinitionsFile } from './init.js'
|
|
17
17
|
|
|
@@ -27,7 +27,7 @@ import { buildFontAwesome, buildFontAwesomeJS } from '../../dev/builders/fontawe
|
|
|
27
27
|
*/
|
|
28
28
|
export function build(options) {
|
|
29
29
|
if (alloyProject()) {
|
|
30
|
-
|
|
30
|
+
ensureConfig()
|
|
31
31
|
buildTailwindBasedOnConfigOptions(options)
|
|
32
32
|
buildFontAwesome()
|
|
33
33
|
buildFontAwesomeJS()
|
|
@@ -16,7 +16,7 @@ import { createRequire } from 'module'
|
|
|
16
16
|
import { alloyProject, makeSureFolderExists } from '../../shared/utils.js'
|
|
17
17
|
import { projectsConfigJS, projectsLibFolder } from '../../shared/constants.js'
|
|
18
18
|
import { logger } from '../../shared/logger.js'
|
|
19
|
-
import {
|
|
19
|
+
import { ensureConfig } from '../../shared/config-manager.js'
|
|
20
20
|
import { cleanDoubleQuotes } from '../utils/file-operations.js'
|
|
21
21
|
|
|
22
22
|
// Create require for ESM compatibility
|
|
@@ -34,7 +34,7 @@ export function colorModule(options) {
|
|
|
34
34
|
return false
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
ensureConfig()
|
|
38
38
|
const colorModuleConfigFile = require(projectsConfigJS)
|
|
39
39
|
makeSureFolderExists(projectsLibFolder)
|
|
40
40
|
const mainColors = { ...colorModuleConfigFile.theme.colors, ...colorModuleConfigFile.theme.extend.colors }
|
package/src/cli/commands/init.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
/**
|
|
3
3
|
* PurgeTSS v7.1 - Init Command
|
|
4
4
|
*
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
PurgeTSSPackageJSON
|
|
31
31
|
} from '../../shared/constants.js'
|
|
32
32
|
import { logger } from '../../shared/logger.js'
|
|
33
|
-
import { getConfigOptions, getConfigFile } from '../../shared/config-manager.js'
|
|
33
|
+
import { getConfigOptions, getConfigFile, ensureConfig } from '../../shared/config-manager.js'
|
|
34
34
|
import { addHook, deleteHook, createJMKFile } from '../utils/hook-management.js'
|
|
35
35
|
import { getFiles } from '../utils/font-utilities.js'
|
|
36
36
|
import { buildTailwindBasedOnConfigOptions } from '../../core/builders/tailwind-builder.js'
|
|
@@ -162,14 +162,20 @@ export function init(options) {
|
|
|
162
162
|
return false
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
//
|
|
166
|
-
const
|
|
165
|
+
// Check if config.cjs already exists to show appropriate message
|
|
166
|
+
const configExisted = fs.existsSync(projectsConfigJS)
|
|
167
|
+
|
|
168
|
+
// SUPER SIMPLE: Ensure config exists (migrate or create)
|
|
169
|
+
ensureConfig()
|
|
167
170
|
|
|
168
|
-
// config
|
|
169
|
-
if (
|
|
170
|
-
|
|
171
|
+
// Show warning if config already existed (for init command specifically)
|
|
172
|
+
if (configExisted) {
|
|
173
|
+
logger.warn('./purgetss/config.cjs', chalk.red('file already exists!'))
|
|
171
174
|
}
|
|
172
175
|
|
|
176
|
+
// Get commands when needed
|
|
177
|
+
const { methodCommand, oppositeCommand } = getCommands()
|
|
178
|
+
|
|
173
179
|
// tailwind.tss
|
|
174
180
|
if (!fs.existsSync(projectsTailwind_TSS) || options.all) {
|
|
175
181
|
buildTailwindBasedOnConfigOptions(options)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
/**
|
|
3
3
|
* PurgeTSS v7.1 - Purge Command
|
|
4
4
|
*
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
import { logger, setDebugMode } from '../../shared/logger.js'
|
|
29
29
|
import { start, finish, localStart, localFinish } from '../utils/cli-helpers.js'
|
|
30
30
|
import { init } from './init.js'
|
|
31
|
-
import { getConfigOptions, getConfigFile } from '../../shared/config-manager.js'
|
|
31
|
+
import { getConfigOptions, getConfigFile, ensureConfig } from '../../shared/config-manager.js'
|
|
32
32
|
|
|
33
33
|
// Import purger functions from core modules
|
|
34
34
|
import { purgeTailwind } from '../../core/purger/tailwind-purger.js'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
/**
|
|
3
3
|
* PurgeTSS v7.1 - Shades Commands
|
|
4
4
|
*
|
|
@@ -17,7 +17,8 @@ import { createRequire } from 'module'
|
|
|
17
17
|
import { alloyProject, makeSureFolderExists } from '../../shared/utils.js'
|
|
18
18
|
import { projectsConfigJS, projectsLibFolder } from '../../shared/constants.js'
|
|
19
19
|
import { logger } from '../../shared/logger.js'
|
|
20
|
-
import {
|
|
20
|
+
import { ensureConfig, getConfigFile } from '../../shared/config-manager.js'
|
|
21
|
+
import { cleanDoubleQuotes } from '../utils/file-operations.js'
|
|
21
22
|
|
|
22
23
|
// Create require for ESM compatibility
|
|
23
24
|
const require = createRequire(import.meta.url)
|
|
@@ -33,7 +34,7 @@ export function colorModule() {
|
|
|
33
34
|
return false
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
ensureConfig()
|
|
37
38
|
|
|
38
39
|
const colorModuleConfigFile = require(projectsConfigJS)
|
|
39
40
|
|
|
@@ -101,10 +102,15 @@ export async function shades(args, options) {
|
|
|
101
102
|
const colorObject = createColorObject(colorFamily, colorFamily.hexcode, options)
|
|
102
103
|
|
|
103
104
|
const silent = options.tailwind || options.json || options.log
|
|
104
|
-
|
|
105
|
-
//
|
|
105
|
+
|
|
106
|
+
// Ensure config migration happens before getting config file
|
|
107
|
+
if (alloyProject(silent) && !silent) {
|
|
108
|
+
ensureConfig()
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Get config file (after potential migration)
|
|
106
112
|
const configFile = getConfigFile()
|
|
107
|
-
|
|
113
|
+
|
|
108
114
|
if (alloyProject(silent) && !silent) {
|
|
109
115
|
|
|
110
116
|
if (options.override) {
|
|
@@ -174,9 +180,6 @@ function createColorObject(family, hexcode, options) {
|
|
|
174
180
|
return colors
|
|
175
181
|
}
|
|
176
182
|
|
|
177
|
-
// Import config manager
|
|
178
|
-
import { getConfigFile } from '../../shared/config-manager.js'
|
|
179
|
-
|
|
180
183
|
/**
|
|
181
184
|
* Export for CLI usage
|
|
182
185
|
*/
|
|
@@ -15,7 +15,7 @@ import chalk from 'chalk'
|
|
|
15
15
|
import { alloyProject } from '../../shared/utils.js'
|
|
16
16
|
import { projectsAlloyJMKFile } from '../../shared/constants.js'
|
|
17
17
|
import { logger } from '../../shared/logger.js'
|
|
18
|
-
import { getConfigFile } from '../../shared/config-manager.js'
|
|
18
|
+
import { getConfigFile, ensureConfig } from '../../shared/config-manager.js'
|
|
19
19
|
import { disableHook, deleteHook, addHook, enableHook, createJMKFile } from '../utils/hook-management.js'
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -58,6 +58,9 @@ export function watchMode(options) {
|
|
|
58
58
|
return false
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
// Ensure config exists before accessing it
|
|
62
|
+
ensureConfig()
|
|
63
|
+
|
|
61
64
|
if (fs.existsSync(projectsAlloyJMKFile)) {
|
|
62
65
|
// Get commands when needed
|
|
63
66
|
const { methodCommand } = getCommands()
|
|
@@ -12,17 +12,15 @@
|
|
|
12
12
|
|
|
13
13
|
import fs from 'fs'
|
|
14
14
|
import util from 'util'
|
|
15
|
-
import {
|
|
16
|
-
import { createConfigFile } from '../commands/init.js'
|
|
15
|
+
import { ensureConfig } from '../../shared/config-manager.js'
|
|
17
16
|
|
|
18
17
|
/**
|
|
18
|
+
* @deprecated Use ensureConfig() from config-manager.js instead
|
|
19
19
|
* Initialize config if it doesn't exist
|
|
20
|
-
*
|
|
20
|
+
* FIRST migrates any existing config.js, THEN creates default if needed
|
|
21
21
|
*/
|
|
22
22
|
export function initIfNotConfig() {
|
|
23
|
-
|
|
24
|
-
createConfigFile()
|
|
25
|
-
}
|
|
23
|
+
ensureConfig()
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
/**
|
|
@@ -25,23 +25,59 @@ import { makeSureFolderExists } from './utils.js'
|
|
|
25
25
|
const require = createRequire(import.meta.url)
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
28
|
+
* Ensure config file exists - SIMPLE logic
|
|
29
|
+
* 1. If config.cjs exists → use it
|
|
30
|
+
* 2. If config.js exists → rename to config.cjs
|
|
31
|
+
* 3. If nothing exists → create config.cjs
|
|
32
32
|
*/
|
|
33
|
-
export function
|
|
34
|
-
//
|
|
33
|
+
export function ensureConfig() {
|
|
34
|
+
// 1. ¿Existe config.cjs? → Úsalo
|
|
35
|
+
if (fs.existsSync(projectsConfigJS)) {
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 2. ¿Existe config.js? → Renómbralo
|
|
35
40
|
const oldConfigPath = `${projectsPurgeTSSFolder}/config.js`
|
|
41
|
+
if (fs.existsSync(oldConfigPath)) {
|
|
42
|
+
makeSureFolderExists(projectsPurgeTSSFolder)
|
|
43
|
+
fs.renameSync(oldConfigPath, projectsConfigJS)
|
|
44
|
+
logger.info('Migrated config.js to config.cjs for ESM compatibility')
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 3. No existe nada → Crear config.cjs
|
|
49
|
+
makeSureFolderExists(projectsPurgeTSSFolder)
|
|
50
|
+
fs.copyFileSync(srcConfigFile, projectsConfigJS)
|
|
51
|
+
logger.file('./purgetss/config.cjs')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated Use ensureConfig() instead
|
|
56
|
+
* Migrate config.js to config.cjs for ESM compatibility
|
|
57
|
+
* This must be called BEFORE any config file creation
|
|
58
|
+
*/
|
|
59
|
+
export function migrateConfigIfNeeded() {
|
|
60
|
+
const oldConfigPath = `${projectsPurgeTSSFolder}/config.js`
|
|
61
|
+
|
|
62
|
+
// If only config.js exists, migrate it directly
|
|
36
63
|
if (fs.existsSync(oldConfigPath) && !fs.existsSync(projectsConfigJS)) {
|
|
37
64
|
makeSureFolderExists(projectsPurgeTSSFolder)
|
|
38
65
|
fs.renameSync(oldConfigPath, projectsConfigJS)
|
|
39
66
|
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
67
|
}
|
|
68
|
+
// If both exist, preserve config.js (let the user decide)
|
|
69
|
+
else if (fs.existsSync(oldConfigPath) && fs.existsSync(projectsConfigJS)) {
|
|
70
|
+
logger.warn('Both config.js and config.cjs exist. Please manually merge and remove config.js')
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get configuration file with fallback to default template
|
|
76
|
+
* Maintains exact same logic as original getConfigFile()
|
|
77
|
+
*
|
|
78
|
+
* @returns {Object} Configuration object with defaults applied
|
|
79
|
+
*/
|
|
80
|
+
export function getConfigFile() {
|
|
45
81
|
|
|
46
82
|
const configFile = (fs.existsSync(projectsConfigJS))
|
|
47
83
|
? require(projectsConfigJS)
|
|
@@ -56,7 +92,7 @@ export function getConfigFile() {
|
|
|
56
92
|
configFile.purge.options.widgets = configFile.purge.options.widgets ?? false
|
|
57
93
|
configFile.purge.options.safelist = configFile.purge.options.safelist ?? []
|
|
58
94
|
configFile.purge.options.plugins = configFile.purge.options.plugins ?? []
|
|
59
|
-
|
|
95
|
+
|
|
60
96
|
configFile.theme = configFile.theme ?? {}
|
|
61
97
|
configFile.theme.extend = configFile.theme.extend ?? {}
|
|
62
98
|
|
|
@@ -160,5 +196,6 @@ export default {
|
|
|
160
196
|
loadRawConfig,
|
|
161
197
|
getGlobalConfigFile,
|
|
162
198
|
getGlobalConfigOptions,
|
|
199
|
+
migrateConfigIfNeeded,
|
|
163
200
|
defaultTheme
|
|
164
201
|
}
|