tailwindcss 0.0.0-insiders.fa693e5 → 0.0.0-insiders.fa9be73
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/README.md +1 -1
- package/index.css +5 -0
- package/lib/cli/build/index.js +29 -20
- package/lib/cli/build/plugin.js +200 -139
- package/lib/cli/build/utils.js +31 -21
- package/lib/cli/build/watching.js +26 -22
- package/lib/cli/help/index.js +17 -15
- package/lib/cli/index.js +74 -82
- package/lib/cli/init/index.js +30 -13
- package/lib/cli.js +1 -5
- package/lib/corePluginList.js +6 -1
- package/lib/corePlugins.js +1980 -1888
- package/lib/css/preflight.css +15 -4
- package/lib/featureFlags.js +36 -22
- package/lib/index.js +1 -5
- package/lib/lib/cacheInvalidation.js +10 -8
- package/lib/lib/collapseAdjacentRules.js +9 -7
- package/lib/lib/collapseDuplicateDeclarations.js +11 -9
- package/lib/lib/content.js +50 -20
- package/lib/lib/defaultExtractor.js +29 -33
- package/lib/lib/detectNesting.js +13 -11
- package/lib/lib/evaluateTailwindFunctions.js +43 -39
- package/lib/lib/expandApplyAtRules.js +64 -50
- package/lib/lib/expandTailwindAtRules.js +97 -57
- package/lib/lib/findAtConfigPath.js +11 -9
- package/lib/lib/generateRules.js +127 -113
- package/lib/lib/getModuleDependencies.js +85 -37
- package/lib/lib/handleImportAtRules.js +50 -0
- package/lib/lib/load-config.js +42 -0
- package/lib/lib/normalizeTailwindDirectives.js +26 -39
- package/lib/lib/offsets.js +53 -51
- package/lib/lib/partitionApplyAtRules.js +5 -3
- package/lib/lib/regex.js +26 -12
- package/lib/lib/remap-bitfield.js +3 -1
- package/lib/lib/resolveDefaultsAtRules.js +49 -45
- package/lib/lib/setupContextUtils.js +263 -228
- package/lib/lib/setupTrackingContext.js +32 -28
- package/lib/lib/sharedState.js +37 -36
- package/lib/lib/substituteScreenAtRules.js +9 -7
- package/lib/plugin.js +110 -44
- package/lib/postcss-plugins/nesting/index.js +5 -3
- package/lib/postcss-plugins/nesting/plugin.js +19 -17
- package/lib/processTailwindFeatures.js +19 -17
- package/lib/public/colors.js +269 -245
- package/lib/public/create-plugin.js +5 -3
- package/lib/public/default-config.js +6 -4
- package/lib/public/default-theme.js +6 -4
- package/lib/public/load-config.js +12 -0
- package/lib/public/resolve-config.js +6 -4
- package/lib/util/applyImportantSelector.js +36 -0
- package/lib/util/bigSign.js +3 -1
- package/lib/util/buildMediaQuery.js +5 -3
- package/lib/util/cloneDeep.js +4 -2
- package/lib/util/cloneNodes.js +4 -2
- package/lib/util/color.js +30 -26
- package/lib/util/colorNames.js +752 -0
- package/lib/util/configurePlugins.js +3 -1
- package/lib/util/createPlugin.js +3 -1
- package/lib/util/createUtilityPlugin.js +8 -6
- package/lib/util/dataTypes.js +210 -118
- package/lib/util/defaults.js +9 -7
- package/lib/util/escapeClassName.js +9 -7
- package/lib/util/escapeCommas.js +4 -2
- package/lib/util/flattenColorPalette.js +5 -3
- package/lib/util/formatVariantSelector.js +57 -137
- package/lib/util/getAllConfigs.js +11 -8
- package/lib/util/hashConfig.js +6 -4
- package/lib/util/isKeyframeRule.js +4 -2
- package/lib/util/isPlainObject.js +4 -2
- package/lib/util/isSyntacticallyValidPropertyValue.js +13 -11
- package/lib/util/log.js +31 -10
- package/lib/util/nameClass.js +16 -10
- package/lib/util/negateValue.js +11 -9
- package/lib/util/normalizeConfig.js +101 -69
- package/lib/util/normalizeScreens.js +30 -22
- package/lib/util/parseAnimationValue.js +41 -39
- package/lib/util/parseBoxShadowValue.js +24 -20
- package/lib/util/parseDependency.js +7 -5
- package/lib/util/parseGlob.js +10 -8
- package/lib/util/parseObjectStyles.js +10 -8
- package/lib/util/pluginUtils.js +54 -63
- package/lib/util/prefixSelector.js +9 -7
- package/lib/util/pseudoElements.js +209 -0
- package/lib/util/removeAlphaVariables.js +4 -2
- package/lib/util/resolveConfig.js +64 -52
- package/lib/util/resolveConfigPath.js +28 -12
- package/lib/util/responsive.js +7 -5
- package/lib/util/splitAtTopLevelOnly.js +12 -4
- package/lib/util/tap.js +3 -1
- package/lib/util/toColorValue.js +4 -2
- package/lib/util/toPath.js +5 -3
- package/lib/util/transformThemeValue.js +30 -28
- package/lib/util/validateConfig.js +31 -7
- package/lib/util/validateFormalSyntax.js +8 -6
- package/lib/util/withAlphaVariable.js +11 -7
- package/lib/value-parser/LICENSE +22 -0
- package/lib/value-parser/README.md +3 -0
- package/lib/value-parser/index.d.js +2 -0
- package/lib/value-parser/index.js +22 -0
- package/lib/value-parser/parse.js +259 -0
- package/lib/value-parser/stringify.js +38 -0
- package/lib/value-parser/unit.js +86 -0
- package/lib/value-parser/walk.js +16 -0
- package/loadConfig.d.ts +4 -0
- package/loadConfig.js +2 -0
- package/package.json +47 -59
- package/scripts/release-notes.js +1 -1
- package/src/cli/build/index.js +11 -7
- package/src/cli/build/plugin.js +96 -69
- package/src/cli/build/watching.js +4 -2
- package/src/cli/index.js +9 -26
- package/src/cli/init/index.js +37 -8
- package/src/cli.js +1 -5
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +141 -48
- package/src/css/preflight.css +15 -4
- package/src/featureFlags.js +7 -7
- package/src/index.js +1 -5
- package/src/lib/content.js +33 -1
- package/src/lib/defaultExtractor.js +12 -14
- package/src/lib/evaluateTailwindFunctions.js +4 -1
- package/src/lib/expandApplyAtRules.js +15 -1
- package/src/lib/expandTailwindAtRules.js +73 -33
- package/src/lib/generateRules.js +71 -47
- package/src/lib/getModuleDependencies.js +70 -30
- package/src/lib/handleImportAtRules.js +34 -0
- package/src/lib/load-config.ts +31 -0
- package/src/lib/normalizeTailwindDirectives.js +0 -27
- package/src/lib/offsets.js +3 -3
- package/src/lib/setupContextUtils.js +64 -51
- package/src/lib/setupTrackingContext.js +6 -8
- package/src/lib/sharedState.js +10 -20
- package/src/plugin.js +86 -60
- package/src/processTailwindFeatures.js +3 -2
- package/src/public/colors.js +22 -0
- package/src/public/default-config.js +1 -1
- package/src/public/default-theme.js +2 -2
- package/src/public/load-config.js +2 -0
- package/src/util/applyImportantSelector.js +27 -0
- package/src/util/color.js +2 -2
- package/src/util/colorNames.js +150 -0
- package/src/util/dataTypes.js +75 -16
- package/src/util/formatVariantSelector.js +14 -102
- package/src/util/getAllConfigs.js +2 -2
- package/src/util/log.js +24 -0
- package/src/util/normalizeConfig.js +39 -11
- package/src/util/pluginUtils.js +11 -38
- package/src/util/prefixSelector.js +1 -0
- package/src/util/pseudoElements.js +167 -0
- package/src/util/resolveConfig.js +42 -24
- package/src/util/resolveConfigPath.js +12 -1
- package/src/util/splitAtTopLevelOnly.js +8 -1
- package/src/util/validateConfig.js +23 -0
- package/src/value-parser/LICENSE +22 -0
- package/src/value-parser/README.md +3 -0
- package/src/value-parser/index.d.ts +177 -0
- package/src/value-parser/index.js +28 -0
- package/src/value-parser/parse.js +303 -0
- package/src/value-parser/stringify.js +41 -0
- package/src/value-parser/unit.js +118 -0
- package/src/value-parser/walk.js +18 -0
- package/stubs/.gitignore +1 -0
- package/stubs/.prettierrc.json +6 -0
- package/stubs/{defaultConfig.stub.js → config.full.js} +56 -11
- package/stubs/{simpleConfig.stub.js → config.simple.js} +1 -2
- package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -1
- package/stubs/postcss.config.js +5 -0
- package/stubs/tailwind.config.cjs +2 -0
- package/stubs/tailwind.config.js +2 -0
- package/stubs/tailwind.config.ts +3 -0
- package/types/config.d.ts +10 -12
- package/types/generated/colors.d.ts +22 -0
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +34 -1
- package/types/index.d.ts +7 -3
- package/lib/cli/build/deps.js +0 -54
- package/lib/cli-peer-dependencies.js +0 -28
- package/lib/constants.js +0 -44
- package/lib/oxide/cli/build/deps.js +0 -81
- package/lib/oxide/cli/build/index.js +0 -47
- package/lib/oxide/cli/build/plugin.js +0 -364
- package/lib/oxide/cli/build/utils.js +0 -77
- package/lib/oxide/cli/build/watching.js +0 -177
- package/lib/oxide/cli/help/index.js +0 -70
- package/lib/oxide/cli/index.js +0 -220
- package/lib/oxide/cli/init/index.js +0 -35
- package/lib/oxide/cli.js +0 -5
- package/lib/oxide/postcss-plugin.js +0 -2
- package/peers/index.js +0 -79461
- package/scripts/swap-engines.js +0 -40
- package/src/cli/build/deps.js +0 -56
- package/src/cli-peer-dependencies.js +0 -15
- package/src/constants.js +0 -17
- package/src/oxide/cli/build/deps.ts +0 -91
- package/src/oxide/cli/build/index.ts +0 -47
- package/src/oxide/cli/build/plugin.ts +0 -436
- package/src/oxide/cli/build/utils.ts +0 -74
- package/src/oxide/cli/build/watching.ts +0 -225
- package/src/oxide/cli/help/index.ts +0 -69
- package/src/oxide/cli/index.ts +0 -212
- package/src/oxide/cli/init/index.ts +0 -32
- package/src/oxide/cli.ts +0 -1
- package/src/oxide/postcss-plugin.ts +0 -1
package/lib/cli/build/utils.js
CHANGED
|
@@ -10,41 +10,51 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
indentRecursive: ()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
indentRecursive: function() {
|
|
14
|
+
return indentRecursive;
|
|
15
|
+
},
|
|
16
|
+
formatNodes: function() {
|
|
17
|
+
return formatNodes;
|
|
18
|
+
},
|
|
19
|
+
readFileWithRetries: function() {
|
|
20
|
+
return readFileWithRetries;
|
|
21
|
+
},
|
|
22
|
+
drainStdin: function() {
|
|
23
|
+
return drainStdin;
|
|
24
|
+
},
|
|
25
|
+
outputFile: function() {
|
|
26
|
+
return outputFile;
|
|
27
|
+
}
|
|
18
28
|
});
|
|
19
|
-
const _fs = /*#__PURE__*/
|
|
20
|
-
const _path = /*#__PURE__*/
|
|
21
|
-
function
|
|
29
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
30
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
31
|
+
function _interop_require_default(obj) {
|
|
22
32
|
return obj && obj.__esModule ? obj : {
|
|
23
33
|
default: obj
|
|
24
34
|
};
|
|
25
35
|
}
|
|
26
36
|
function indentRecursive(node, indent = 0) {
|
|
27
37
|
node.each && node.each((child, i)=>{
|
|
28
|
-
if (!child.raws.before || !child.raws.before.trim() || child.raws.before.includes(
|
|
29
|
-
child.raws.before = `\n${node.type !==
|
|
38
|
+
if (!child.raws.before || !child.raws.before.trim() || child.raws.before.includes('\n')) {
|
|
39
|
+
child.raws.before = `\n${node.type !== 'rule' && i > 0 ? '\n' : ''}${' '.repeat(indent)}`;
|
|
30
40
|
}
|
|
31
|
-
child.raws.after = `\n${
|
|
41
|
+
child.raws.after = `\n${' '.repeat(indent)}`;
|
|
32
42
|
indentRecursive(child, indent + 1);
|
|
33
43
|
});
|
|
34
44
|
}
|
|
35
45
|
function formatNodes(root) {
|
|
36
46
|
indentRecursive(root);
|
|
37
47
|
if (root.first) {
|
|
38
|
-
root.first.raws.before =
|
|
48
|
+
root.first.raws.before = '';
|
|
39
49
|
}
|
|
40
50
|
}
|
|
41
51
|
async function readFileWithRetries(path, tries = 5) {
|
|
42
52
|
for(let n = 0; n <= tries; n++){
|
|
43
53
|
try {
|
|
44
|
-
return await _fs.default.promises.readFile(path,
|
|
54
|
+
return await _fs.default.promises.readFile(path, 'utf8');
|
|
45
55
|
} catch (err) {
|
|
46
56
|
if (n !== tries) {
|
|
47
|
-
if (err.code ===
|
|
57
|
+
if (err.code === 'ENOENT' || err.code === 'EBUSY') {
|
|
48
58
|
await new Promise((resolve)=>setTimeout(resolve, 10));
|
|
49
59
|
continue;
|
|
50
60
|
}
|
|
@@ -55,24 +65,24 @@ async function readFileWithRetries(path, tries = 5) {
|
|
|
55
65
|
}
|
|
56
66
|
function drainStdin() {
|
|
57
67
|
return new Promise((resolve, reject)=>{
|
|
58
|
-
let result =
|
|
59
|
-
process.stdin.on(
|
|
68
|
+
let result = '';
|
|
69
|
+
process.stdin.on('data', (chunk)=>{
|
|
60
70
|
result += chunk;
|
|
61
71
|
});
|
|
62
|
-
process.stdin.on(
|
|
63
|
-
process.stdin.on(
|
|
72
|
+
process.stdin.on('end', ()=>resolve(result));
|
|
73
|
+
process.stdin.on('error', (err)=>reject(err));
|
|
64
74
|
});
|
|
65
75
|
}
|
|
66
76
|
async function outputFile(file, newContents) {
|
|
67
77
|
try {
|
|
68
|
-
let currentContents = await _fs.default.promises.readFile(file,
|
|
78
|
+
let currentContents = await _fs.default.promises.readFile(file, 'utf8');
|
|
69
79
|
if (currentContents === newContents) {
|
|
70
80
|
return; // Skip writing the file
|
|
71
81
|
}
|
|
72
|
-
} catch
|
|
82
|
+
} catch (e) {}
|
|
73
83
|
// Write the file
|
|
74
84
|
await _fs.default.promises.mkdir(_path.default.dirname(file), {
|
|
75
85
|
recursive: true
|
|
76
86
|
});
|
|
77
|
-
await _fs.default.promises.writeFile(file, newContents,
|
|
87
|
+
await _fs.default.promises.writeFile(file, newContents, 'utf8');
|
|
78
88
|
}
|
|
@@ -5,22 +5,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "createWatcher", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: ()
|
|
8
|
+
get: function() {
|
|
9
|
+
return createWatcher;
|
|
10
|
+
}
|
|
9
11
|
});
|
|
10
|
-
const _chokidar = /*#__PURE__*/
|
|
11
|
-
const _fs = /*#__PURE__*/
|
|
12
|
-
const _micromatch = /*#__PURE__*/
|
|
13
|
-
const
|
|
14
|
-
const _path = /*#__PURE__*/
|
|
15
|
-
const
|
|
16
|
-
function
|
|
12
|
+
const _chokidar = /*#__PURE__*/ _interop_require_default(require("chokidar"));
|
|
13
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
14
|
+
const _micromatch = /*#__PURE__*/ _interop_require_default(require("micromatch"));
|
|
15
|
+
const _normalizepath = /*#__PURE__*/ _interop_require_default(require("normalize-path"));
|
|
16
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
17
|
+
const _utils = require("./utils.js");
|
|
18
|
+
function _interop_require_default(obj) {
|
|
17
19
|
return obj && obj.__esModule ? obj : {
|
|
18
20
|
default: obj
|
|
19
21
|
};
|
|
20
22
|
}
|
|
21
|
-
function createWatcher(args, { state
|
|
22
|
-
let shouldPoll = args[
|
|
23
|
-
let shouldCoalesceWriteEvents = shouldPoll || process.platform ===
|
|
23
|
+
function createWatcher(args, { state, rebuild }) {
|
|
24
|
+
let shouldPoll = args['--poll'];
|
|
25
|
+
let shouldCoalesceWriteEvents = shouldPoll || process.platform === 'win32';
|
|
24
26
|
// Polling interval in milliseconds
|
|
25
27
|
// Used only when polling or coalescing add/change events on Windows
|
|
26
28
|
let pollInterval = 10;
|
|
@@ -64,7 +66,9 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
64
66
|
// Clear all pending rebuilds for the about-to-be-built files
|
|
65
67
|
changes.forEach((change)=>pendingRebuilds.delete(change.file));
|
|
66
68
|
// Resolve the promise even when the rebuild fails
|
|
67
|
-
return rebuild(changes).then(()=>{}, ()=>{
|
|
69
|
+
return rebuild(changes).then(()=>{}, (e)=>{
|
|
70
|
+
console.error(e.toString());
|
|
71
|
+
});
|
|
68
72
|
}
|
|
69
73
|
/**
|
|
70
74
|
*
|
|
@@ -84,7 +88,7 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
84
88
|
pendingRebuilds.add(file);
|
|
85
89
|
changedContent.push({
|
|
86
90
|
file,
|
|
87
|
-
content: content !== null && content !== void 0 ? content : ()=>_fs.default.promises.readFile(file,
|
|
91
|
+
content: content !== null && content !== void 0 ? content : ()=>_fs.default.promises.readFile(file, 'utf8'),
|
|
88
92
|
extension: _path.default.extname(file).slice(1)
|
|
89
93
|
});
|
|
90
94
|
if (_timer) {
|
|
@@ -103,13 +107,13 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
103
107
|
chain = chain.then(rebuildAndContinue, rebuildAndContinue);
|
|
104
108
|
return chain;
|
|
105
109
|
}
|
|
106
|
-
watcher.on(
|
|
107
|
-
watcher.on(
|
|
110
|
+
watcher.on('change', (file)=>recordChangedFile(file));
|
|
111
|
+
watcher.on('add', (file)=>recordChangedFile(file));
|
|
108
112
|
// Restore watching any files that are "removed"
|
|
109
113
|
// This can happen when a file is pseudo-atomically replaced (a copy is created, overwritten, the old one is unlinked, and the new one is renamed)
|
|
110
114
|
// TODO: An an optimization we should allow removal when the config changes
|
|
111
|
-
watcher.on(
|
|
112
|
-
file = (0,
|
|
115
|
+
watcher.on('unlink', (file)=>{
|
|
116
|
+
file = (0, _normalizepath.default)(file);
|
|
113
117
|
// Only re-add the file if it's not covered by a dynamic pattern
|
|
114
118
|
if (!_micromatch.default.some([
|
|
115
119
|
file
|
|
@@ -121,8 +125,8 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
121
125
|
// will only fire a rename event for atomic writes and not a change event
|
|
122
126
|
// This is very likely a chokidar bug but it's one we need to work around
|
|
123
127
|
// We treat this as a change event and rebuild the CSS
|
|
124
|
-
watcher.on(
|
|
125
|
-
if (evt !==
|
|
128
|
+
watcher.on('raw', (evt, filePath, meta)=>{
|
|
129
|
+
if (evt !== 'rename') {
|
|
126
130
|
return;
|
|
127
131
|
}
|
|
128
132
|
let watchedPath = meta.watchedPath;
|
|
@@ -148,7 +152,7 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
148
152
|
// We need to read the file as early as possible outside of the chain
|
|
149
153
|
// because it may be gone by the time we get to it. doing the read
|
|
150
154
|
// immediately increases the chance that the file is still there
|
|
151
|
-
let content = await (0,
|
|
155
|
+
let content = await (0, _utils.readFileWithRetries)(_path.default.resolve(filePath));
|
|
152
156
|
if (content === undefined) {
|
|
153
157
|
return;
|
|
154
158
|
}
|
|
@@ -157,7 +161,7 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
157
161
|
// This is because the order of events and timing is different on Linux
|
|
158
162
|
// @ts-ignore: TypeScript isn't picking up that content is a string here
|
|
159
163
|
await recordChangedFile(filePath, ()=>content, true);
|
|
160
|
-
} catch
|
|
164
|
+
} catch (e) {
|
|
161
165
|
// If reading the file fails, it's was probably a deleted temporary file
|
|
162
166
|
// So we can ignore it and no rebuild is needed
|
|
163
167
|
}
|
|
@@ -171,7 +175,7 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
171
175
|
fswatcher: watcher,
|
|
172
176
|
refreshWatchedFiles () {
|
|
173
177
|
watcher.add(Array.from(state.contextDependencies));
|
|
174
|
-
watcher.add(Array.from(state.
|
|
178
|
+
watcher.add(Array.from(state.configBag.dependencies));
|
|
175
179
|
watcher.add(state.contentPatterns.all);
|
|
176
180
|
}
|
|
177
181
|
};
|
package/lib/cli/help/index.js
CHANGED
|
@@ -5,47 +5,49 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "help", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: ()
|
|
8
|
+
get: function() {
|
|
9
|
+
return help;
|
|
10
|
+
}
|
|
9
11
|
});
|
|
10
|
-
const
|
|
11
|
-
function
|
|
12
|
+
const _packagejson = /*#__PURE__*/ _interop_require_default(require("../../../package.json"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
12
14
|
return obj && obj.__esModule ? obj : {
|
|
13
15
|
default: obj
|
|
14
16
|
};
|
|
15
17
|
}
|
|
16
|
-
function help({ message
|
|
18
|
+
function help({ message, usage, commands, options }) {
|
|
17
19
|
let indent = 2;
|
|
18
20
|
// Render header
|
|
19
21
|
console.log();
|
|
20
|
-
console.log(`${
|
|
22
|
+
console.log(`${_packagejson.default.name} v${_packagejson.default.version}`);
|
|
21
23
|
// Render message
|
|
22
24
|
if (message) {
|
|
23
25
|
console.log();
|
|
24
|
-
for (let msg of message.split(
|
|
26
|
+
for (let msg of message.split('\n')){
|
|
25
27
|
console.log(msg);
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
// Render usage
|
|
29
31
|
if (usage && usage.length > 0) {
|
|
30
32
|
console.log();
|
|
31
|
-
console.log(
|
|
33
|
+
console.log('Usage:');
|
|
32
34
|
for (let example of usage){
|
|
33
|
-
console.log(
|
|
35
|
+
console.log(' '.repeat(indent), example);
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
// Render commands
|
|
37
39
|
if (commands && commands.length > 0) {
|
|
38
40
|
console.log();
|
|
39
|
-
console.log(
|
|
41
|
+
console.log('Commands:');
|
|
40
42
|
for (let command of commands){
|
|
41
|
-
console.log(
|
|
43
|
+
console.log(' '.repeat(indent), command);
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
// Render options
|
|
45
47
|
if (options) {
|
|
46
48
|
let groupedOptions = {};
|
|
47
49
|
for (let [key, value] of Object.entries(options)){
|
|
48
|
-
if (typeof value ===
|
|
50
|
+
if (typeof value === 'object') {
|
|
49
51
|
groupedOptions[key] = {
|
|
50
52
|
...value,
|
|
51
53
|
flags: [
|
|
@@ -57,13 +59,13 @@ function help({ message , usage , commands , options }) {
|
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
console.log();
|
|
60
|
-
console.log(
|
|
61
|
-
for (let { flags
|
|
62
|
+
console.log('Options:');
|
|
63
|
+
for (let { flags, description, deprecated } of Object.values(groupedOptions)){
|
|
62
64
|
if (deprecated) continue;
|
|
63
65
|
if (flags.length === 1) {
|
|
64
|
-
console.log(
|
|
66
|
+
console.log(' '.repeat(indent + 4 /* 4 = "-i, ".length */ ), flags.slice().reverse().join(', ').padEnd(20, ' '), description);
|
|
65
67
|
} else {
|
|
66
|
-
console.log(
|
|
68
|
+
console.log(' '.repeat(indent), flags.slice().reverse().join(', ').padEnd(24, ' '), description);
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
}
|
package/lib/cli/index.js
CHANGED
|
@@ -3,34 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
const _path = /*#__PURE__*/
|
|
7
|
-
const _arg = /*#__PURE__*/
|
|
8
|
-
const _fs = /*#__PURE__*/
|
|
6
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
7
|
+
const _arg = /*#__PURE__*/ _interop_require_default(require("arg"));
|
|
8
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
9
9
|
const _build = require("./build");
|
|
10
10
|
const _help = require("./help");
|
|
11
11
|
const _init = require("./init");
|
|
12
|
-
function
|
|
12
|
+
function _interop_require_default(obj) {
|
|
13
13
|
return obj && obj.__esModule ? obj : {
|
|
14
14
|
default: obj
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
function isESM() {
|
|
18
|
-
const pkgPath = _path.default.resolve("./package.json");
|
|
19
|
-
try {
|
|
20
|
-
let pkg = JSON.parse(_fs.default.readFileSync(pkgPath, "utf8"));
|
|
21
|
-
return pkg.type && pkg.type === "module";
|
|
22
|
-
} catch (err) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
let configs = isESM() ? {
|
|
27
|
-
tailwind: "tailwind.config.cjs",
|
|
28
|
-
postcss: "postcss.config.cjs"
|
|
29
|
-
} : {
|
|
30
|
-
tailwind: "tailwind.config.js",
|
|
31
|
-
postcss: "postcss.config.js"
|
|
32
|
-
};
|
|
33
|
-
// ---
|
|
34
17
|
function oneOf(...options) {
|
|
35
18
|
return Object.assign((value = true)=>{
|
|
36
19
|
for (let option of options){
|
|
@@ -39,7 +22,7 @@ function oneOf(...options) {
|
|
|
39
22
|
return parsed;
|
|
40
23
|
}
|
|
41
24
|
}
|
|
42
|
-
throw new Error(
|
|
25
|
+
throw new Error('...');
|
|
43
26
|
}, {
|
|
44
27
|
manualParsing: true
|
|
45
28
|
});
|
|
@@ -48,84 +31,93 @@ let commands = {
|
|
|
48
31
|
init: {
|
|
49
32
|
run: _init.init,
|
|
50
33
|
args: {
|
|
51
|
-
|
|
34
|
+
'--esm': {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
description: `Initialize configuration file as ESM`
|
|
37
|
+
},
|
|
38
|
+
'--ts': {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
description: `Initialize configuration file as TypeScript`
|
|
41
|
+
},
|
|
42
|
+
'--postcss': {
|
|
52
43
|
type: Boolean,
|
|
53
|
-
description: `Initialize a
|
|
44
|
+
description: `Initialize a \`postcss.config.js\` file`
|
|
54
45
|
},
|
|
55
|
-
|
|
46
|
+
'--full': {
|
|
56
47
|
type: Boolean,
|
|
57
|
-
description: `
|
|
48
|
+
description: `Include the default values for all options in the generated configuration file`
|
|
58
49
|
},
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
'-f': '--full',
|
|
51
|
+
'-p': '--postcss'
|
|
61
52
|
}
|
|
62
53
|
},
|
|
63
54
|
build: {
|
|
64
55
|
run: _build.build,
|
|
65
56
|
args: {
|
|
66
|
-
|
|
57
|
+
'--input': {
|
|
67
58
|
type: String,
|
|
68
|
-
description:
|
|
59
|
+
description: 'Input file'
|
|
69
60
|
},
|
|
70
|
-
|
|
61
|
+
'--output': {
|
|
71
62
|
type: String,
|
|
72
|
-
description:
|
|
63
|
+
description: 'Output file'
|
|
73
64
|
},
|
|
74
|
-
|
|
65
|
+
'--watch': {
|
|
75
66
|
type: oneOf(String, Boolean),
|
|
76
|
-
description:
|
|
67
|
+
description: 'Watch for changes and rebuild as needed'
|
|
77
68
|
},
|
|
78
|
-
|
|
69
|
+
'--poll': {
|
|
79
70
|
type: Boolean,
|
|
80
|
-
description:
|
|
71
|
+
description: 'Use polling instead of filesystem events when watching'
|
|
81
72
|
},
|
|
82
|
-
|
|
73
|
+
'--content': {
|
|
83
74
|
type: String,
|
|
84
|
-
description:
|
|
75
|
+
description: 'Content paths to use for removing unused classes'
|
|
85
76
|
},
|
|
86
|
-
|
|
77
|
+
'--purge': {
|
|
87
78
|
type: String,
|
|
88
79
|
deprecated: true
|
|
89
80
|
},
|
|
90
|
-
|
|
81
|
+
'--postcss': {
|
|
91
82
|
type: oneOf(String, Boolean),
|
|
92
|
-
description:
|
|
83
|
+
description: 'Load custom PostCSS configuration'
|
|
93
84
|
},
|
|
94
|
-
|
|
85
|
+
'--minify': {
|
|
95
86
|
type: Boolean,
|
|
96
|
-
description:
|
|
87
|
+
description: 'Minify the output'
|
|
97
88
|
},
|
|
98
|
-
|
|
89
|
+
'--config': {
|
|
99
90
|
type: String,
|
|
100
|
-
description:
|
|
91
|
+
description: 'Path to a custom config file'
|
|
101
92
|
},
|
|
102
|
-
|
|
93
|
+
'--no-autoprefixer': {
|
|
94
|
+
deprecated: true,
|
|
103
95
|
type: Boolean,
|
|
104
|
-
description:
|
|
96
|
+
description: 'Disable autoprefixer'
|
|
105
97
|
},
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
98
|
+
'-c': '--config',
|
|
99
|
+
'-i': '--input',
|
|
100
|
+
'-o': '--output',
|
|
101
|
+
'-m': '--minify',
|
|
102
|
+
'-w': '--watch',
|
|
103
|
+
'-p': '--poll'
|
|
112
104
|
}
|
|
113
105
|
}
|
|
114
106
|
};
|
|
115
107
|
let sharedFlags = {
|
|
116
|
-
|
|
108
|
+
'--help': {
|
|
117
109
|
type: Boolean,
|
|
118
|
-
description:
|
|
110
|
+
description: 'Display usage information'
|
|
119
111
|
},
|
|
120
|
-
|
|
112
|
+
'-h': '--help'
|
|
121
113
|
};
|
|
122
114
|
if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.argv[2] === undefined || process.argv.slice(2).every((flag)=>sharedFlags[flag] !== undefined))) {
|
|
123
115
|
(0, _help.help)({
|
|
124
116
|
usage: [
|
|
125
|
-
|
|
126
|
-
|
|
117
|
+
'tailwindcss [--input input.css] [--output output.css] [--watch] [options...]',
|
|
118
|
+
'tailwindcss init [--full] [--postcss] [options...]'
|
|
127
119
|
],
|
|
128
|
-
commands: Object.keys(commands).filter((command)=>command !==
|
|
120
|
+
commands: Object.keys(commands).filter((command)=>command !== 'build').map((command)=>`${command} [options]`),
|
|
129
121
|
options: {
|
|
130
122
|
...commands.build.args,
|
|
131
123
|
...sharedFlags
|
|
@@ -133,48 +125,48 @@ if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.
|
|
|
133
125
|
});
|
|
134
126
|
process.exit(0);
|
|
135
127
|
}
|
|
136
|
-
let command = ((arg =
|
|
128
|
+
let command = ((arg = '')=>arg.startsWith('-') ? undefined : arg)(process.argv[2]) || 'build';
|
|
137
129
|
if (commands[command] === undefined) {
|
|
138
130
|
if (_fs.default.existsSync(_path.default.resolve(command))) {
|
|
139
131
|
// TODO: Deprecate this in future versions
|
|
140
132
|
// Check if non-existing command, might be a file.
|
|
141
|
-
command =
|
|
133
|
+
command = 'build';
|
|
142
134
|
} else {
|
|
143
135
|
(0, _help.help)({
|
|
144
136
|
message: `Invalid command: ${command}`,
|
|
145
137
|
usage: [
|
|
146
|
-
|
|
138
|
+
'tailwindcss <command> [options]'
|
|
147
139
|
],
|
|
148
|
-
commands: Object.keys(commands).filter((command)=>command !==
|
|
140
|
+
commands: Object.keys(commands).filter((command)=>command !== 'build').map((command)=>`${command} [options]`),
|
|
149
141
|
options: sharedFlags
|
|
150
142
|
});
|
|
151
143
|
process.exit(1);
|
|
152
144
|
}
|
|
153
145
|
}
|
|
154
146
|
// Execute command
|
|
155
|
-
let { args: flags
|
|
147
|
+
let { args: flags, run } = commands[command];
|
|
156
148
|
let args = (()=>{
|
|
157
149
|
try {
|
|
158
150
|
let result = (0, _arg.default)(Object.fromEntries(Object.entries({
|
|
159
151
|
...flags,
|
|
160
152
|
...sharedFlags
|
|
161
153
|
}).filter(([_key, value])=>{
|
|
162
|
-
var _value_type;
|
|
163
|
-
return !(value === null ||
|
|
154
|
+
var _value_type, _value;
|
|
155
|
+
return !((_value = value) === null || _value === void 0 ? void 0 : (_value_type = _value.type) === null || _value_type === void 0 ? void 0 : _value_type.manualParsing);
|
|
164
156
|
}).map(([key, value])=>[
|
|
165
157
|
key,
|
|
166
|
-
typeof value ===
|
|
158
|
+
typeof value === 'object' ? value.type : value
|
|
167
159
|
])), {
|
|
168
160
|
permissive: true
|
|
169
161
|
});
|
|
170
162
|
// Manual parsing of flags to allow for special flags like oneOf(Boolean, String)
|
|
171
|
-
for(let i = result[
|
|
172
|
-
let flag = result[
|
|
173
|
-
if (!flag.startsWith(
|
|
174
|
-
let [flagName, flagValue] = flag.split(
|
|
163
|
+
for(let i = result['_'].length - 1; i >= 0; --i){
|
|
164
|
+
let flag = result['_'][i];
|
|
165
|
+
if (!flag.startsWith('-')) continue;
|
|
166
|
+
let [flagName, flagValue] = flag.split('=');
|
|
175
167
|
let handler = flags[flagName];
|
|
176
168
|
// Resolve flagName & handler
|
|
177
|
-
while(typeof handler ===
|
|
169
|
+
while(typeof handler === 'string'){
|
|
178
170
|
flagName = handler;
|
|
179
171
|
handler = flags[handler];
|
|
180
172
|
}
|
|
@@ -184,18 +176,18 @@ let args = (()=>{
|
|
|
184
176
|
// --flag value syntax was used so we need to pull `value` from `args`
|
|
185
177
|
if (flagValue === undefined) {
|
|
186
178
|
// Parse args for current flag
|
|
187
|
-
while(result[
|
|
188
|
-
args.push(result[
|
|
179
|
+
while(result['_'][offset] && !result['_'][offset].startsWith('-')){
|
|
180
|
+
args.push(result['_'][offset++]);
|
|
189
181
|
}
|
|
190
182
|
// Cleanup manually parsed flags + args
|
|
191
|
-
result[
|
|
183
|
+
result['_'].splice(i, 1 + args.length);
|
|
192
184
|
// No args were provided, use default value defined in handler
|
|
193
185
|
// One arg was provided, use that directly
|
|
194
186
|
// Multiple args were provided so pass them all in an array
|
|
195
187
|
flagValue = args.length === 0 ? undefined : args.length === 1 ? args[0] : args;
|
|
196
188
|
} else {
|
|
197
189
|
// Remove the whole flag from the args array
|
|
198
|
-
result[
|
|
190
|
+
result['_'].splice(i, 1);
|
|
199
191
|
}
|
|
200
192
|
// Set the resolved value in the `result` object
|
|
201
193
|
result[flagName] = handler.type(flagValue, flagName);
|
|
@@ -206,16 +198,16 @@ let args = (()=>{
|
|
|
206
198
|
//
|
|
207
199
|
// E.g.: tailwindcss input.css -> _: ['build', 'input.css']
|
|
208
200
|
// E.g.: tailwindcss build input.css -> _: ['build', 'input.css']
|
|
209
|
-
if (result[
|
|
210
|
-
result[
|
|
201
|
+
if (result['_'][0] !== command) {
|
|
202
|
+
result['_'].unshift(command);
|
|
211
203
|
}
|
|
212
204
|
return result;
|
|
213
205
|
} catch (err) {
|
|
214
|
-
if (err.code ===
|
|
206
|
+
if (err.code === 'ARG_UNKNOWN_OPTION') {
|
|
215
207
|
(0, _help.help)({
|
|
216
208
|
message: err.message,
|
|
217
209
|
usage: [
|
|
218
|
-
|
|
210
|
+
'tailwindcss <command> [options]'
|
|
219
211
|
],
|
|
220
212
|
options: sharedFlags
|
|
221
213
|
});
|
|
@@ -224,7 +216,7 @@ let args = (()=>{
|
|
|
224
216
|
throw err;
|
|
225
217
|
}
|
|
226
218
|
})();
|
|
227
|
-
if (args[
|
|
219
|
+
if (args['--help']) {
|
|
228
220
|
(0, _help.help)({
|
|
229
221
|
options: {
|
|
230
222
|
...flags,
|
|
@@ -236,4 +228,4 @@ if (args["--help"]) {
|
|
|
236
228
|
});
|
|
237
229
|
process.exit(0);
|
|
238
230
|
}
|
|
239
|
-
run(args
|
|
231
|
+
run(args);
|