purgetss 7.1.5 → 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/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 +3 -10
- package/src/shared/config-manager.js +28 -0
package/dist/purgetss.ui.js
CHANGED
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,22 +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'
|
|
17
|
-
import { migrateConfigIfNeeded } from '../../shared/config-manager.js'
|
|
15
|
+
import { ensureConfig } from '../../shared/config-manager.js'
|
|
18
16
|
|
|
19
17
|
/**
|
|
18
|
+
* @deprecated Use ensureConfig() from config-manager.js instead
|
|
20
19
|
* Initialize config if it doesn't exist
|
|
21
20
|
* FIRST migrates any existing config.js, THEN creates default if needed
|
|
22
21
|
*/
|
|
23
22
|
export function initIfNotConfig() {
|
|
24
|
-
|
|
25
|
-
migrateConfigIfNeeded()
|
|
26
|
-
|
|
27
|
-
// Now check if we need to create default config
|
|
28
|
-
if (!fs.existsSync(projectsConfigJS)) {
|
|
29
|
-
createConfigFile()
|
|
30
|
-
}
|
|
23
|
+
ensureConfig()
|
|
31
24
|
}
|
|
32
25
|
|
|
33
26
|
/**
|
|
@@ -25,6 +25,34 @@ import { makeSureFolderExists } from './utils.js'
|
|
|
25
25
|
const require = createRequire(import.meta.url)
|
|
26
26
|
|
|
27
27
|
/**
|
|
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
|
+
*/
|
|
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
|
|
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
|
|
28
56
|
* Migrate config.js to config.cjs for ESM compatibility
|
|
29
57
|
* This must be called BEFORE any config file creation
|
|
30
58
|
*/
|