tailwindcss 0.0.0-insiders.fb796cd → 0.0.0-insiders.fb85c8f
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 +24 -19
- package/lib/cli/build/plugin.js +178 -125
- package/lib/cli/build/utils.js +31 -21
- package/lib/cli/build/watching.js +22 -20
- package/lib/cli/help/index.js +17 -15
- package/lib/cli/index.js +63 -62
- package/lib/cli/init/index.js +22 -20
- package/lib/cli.js +1 -5
- package/lib/corePluginList.js +7 -2
- package/lib/corePlugins.js +2006 -1900
- package/lib/css/preflight.css +24 -7
- package/lib/featureFlags.js +32 -26
- package/lib/index.js +1 -5
- package/lib/lib/cacheInvalidation.js +13 -9
- package/lib/lib/collapseAdjacentRules.js +12 -8
- package/lib/lib/collapseDuplicateDeclarations.js +11 -9
- package/lib/lib/content.js +50 -20
- package/lib/lib/defaultExtractor.js +49 -37
- package/lib/lib/detectNesting.js +13 -11
- package/lib/lib/evaluateTailwindFunctions.js +42 -38
- package/lib/lib/expandApplyAtRules.js +62 -49
- package/lib/lib/expandTailwindAtRules.js +102 -58
- package/lib/lib/findAtConfigPath.js +11 -9
- package/lib/lib/generateRules.js +124 -104
- package/lib/lib/getModuleDependencies.js +33 -31
- package/lib/lib/handleImportAtRules.js +50 -0
- package/lib/lib/load-config.js +29 -12
- 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 +237 -213
- package/lib/lib/setupTrackingContext.js +30 -27
- package/lib/lib/sharedState.js +37 -36
- package/lib/lib/substituteScreenAtRules.js +9 -7
- package/lib/plugin.js +112 -44
- package/lib/postcss-plugins/nesting/index.js +5 -3
- package/lib/postcss-plugins/nesting/plugin.js +18 -16
- package/lib/processTailwindFeatures.js +19 -17
- package/lib/public/colors.js +269 -267
- 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 +5 -3
- package/lib/public/resolve-config.js +6 -4
- package/lib/util/applyImportantSelector.js +27 -13
- 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 +36 -14
- 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 +262 -121
- package/lib/util/defaults.js +6 -4
- package/lib/util/escapeClassName.js +7 -5
- package/lib/util/escapeCommas.js +4 -2
- package/lib/util/flattenColorPalette.js +5 -3
- package/lib/util/formatVariantSelector.js +54 -125
- package/lib/util/getAllConfigs.js +9 -7
- package/lib/util/hashConfig.js +6 -4
- package/lib/util/isKeyframeRule.js +4 -2
- package/lib/util/isPlainObject.js +5 -3
- 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 +91 -75
- 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 +62 -39
- 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 +60 -51
- package/lib/util/resolveConfigPath.js +15 -11
- package/lib/util/responsive.js +7 -5
- package/lib/util/splitAtTopLevelOnly.js +6 -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/nesting/index.d.ts +4 -0
- package/package.json +47 -59
- package/resolveConfig.d.ts +22 -3
- package/scripts/generate-types.js +1 -2
- package/scripts/release-notes.js +1 -1
- package/src/cli/build/index.js +4 -0
- package/src/cli/build/plugin.js +74 -52
- package/src/cli/build/watching.js +1 -1
- package/src/cli/index.js +1 -0
- package/src/cli.js +1 -5
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +128 -28
- package/src/css/preflight.css +24 -7
- package/src/featureFlags.js +7 -14
- package/src/index.js +1 -5
- package/src/lib/content.js +33 -1
- package/src/lib/defaultExtractor.js +30 -17
- package/src/lib/evaluateTailwindFunctions.js +4 -1
- package/src/lib/expandApplyAtRules.js +13 -0
- package/src/lib/expandTailwindAtRules.js +76 -33
- package/src/lib/generateRules.js +42 -33
- package/src/lib/handleImportAtRules.js +34 -0
- package/src/lib/load-config.ts +17 -5
- package/src/lib/normalizeTailwindDirectives.js +0 -27
- package/src/lib/offsets.js +3 -3
- package/src/lib/setupContextUtils.js +58 -50
- package/src/lib/setupTrackingContext.js +2 -4
- package/src/lib/sharedState.js +10 -20
- package/src/plugin.js +86 -60
- package/src/processTailwindFeatures.js +3 -2
- package/src/util/applyImportantSelector.js +20 -12
- package/src/util/cloneNodes.js +35 -14
- package/src/util/color.js +2 -2
- package/src/util/colorNames.js +150 -0
- package/src/util/dataTypes.js +135 -24
- package/src/util/formatVariantSelector.js +13 -101
- package/src/util/isPlainObject.js +1 -1
- package/src/util/log.js +24 -0
- package/src/util/normalizeConfig.js +37 -27
- package/src/util/pluginUtils.js +17 -9
- package/src/util/prefixSelector.js +1 -0
- package/src/util/pseudoElements.js +167 -0
- package/src/util/resolveConfig.js +42 -24
- 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/config.full.js +110 -15
- package/stubs/config.simple.js +1 -1
- package/stubs/postcss.config.cjs +0 -1
- package/stubs/postcss.config.js +0 -1
- package/types/config.d.ts +14 -15
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +59 -9
- 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/oxide/cli/build/deps.js +0 -81
- package/lib/oxide/cli/build/index.js +0 -51
- package/lib/oxide/cli/build/plugin.js +0 -373
- 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 -214
- package/lib/oxide/cli/init/index.js +0 -50
- 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/oxide/cli/build/deps.ts +0 -91
- package/src/oxide/cli/build/index.ts +0 -47
- package/src/oxide/cli/build/plugin.ts +0 -442
- 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 -204
- package/src/oxide/cli/init/index.ts +0 -59
- 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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
drainStdin: function() {
|
|
14
|
+
return drainStdin;
|
|
15
|
+
},
|
|
16
|
+
formatNodes: function() {
|
|
17
|
+
return formatNodes;
|
|
18
|
+
},
|
|
19
|
+
indentRecursive: function() {
|
|
20
|
+
return indentRecursive;
|
|
21
|
+
},
|
|
22
|
+
outputFile: function() {
|
|
23
|
+
return outputFile;
|
|
24
|
+
},
|
|
25
|
+
readFileWithRetries: function() {
|
|
26
|
+
return readFileWithRetries;
|
|
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;
|
|
@@ -86,7 +88,7 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
86
88
|
pendingRebuilds.add(file);
|
|
87
89
|
changedContent.push({
|
|
88
90
|
file,
|
|
89
|
-
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'),
|
|
90
92
|
extension: _path.default.extname(file).slice(1)
|
|
91
93
|
});
|
|
92
94
|
if (_timer) {
|
|
@@ -105,13 +107,13 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
105
107
|
chain = chain.then(rebuildAndContinue, rebuildAndContinue);
|
|
106
108
|
return chain;
|
|
107
109
|
}
|
|
108
|
-
watcher.on(
|
|
109
|
-
watcher.on(
|
|
110
|
+
watcher.on('change', (file)=>recordChangedFile(file));
|
|
111
|
+
watcher.on('add', (file)=>recordChangedFile(file));
|
|
110
112
|
// Restore watching any files that are "removed"
|
|
111
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)
|
|
112
114
|
// TODO: An an optimization we should allow removal when the config changes
|
|
113
|
-
watcher.on(
|
|
114
|
-
file = (0,
|
|
115
|
+
watcher.on('unlink', (file)=>{
|
|
116
|
+
file = (0, _normalizepath.default)(file);
|
|
115
117
|
// Only re-add the file if it's not covered by a dynamic pattern
|
|
116
118
|
if (!_micromatch.default.some([
|
|
117
119
|
file
|
|
@@ -123,8 +125,8 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
123
125
|
// will only fire a rename event for atomic writes and not a change event
|
|
124
126
|
// This is very likely a chokidar bug but it's one we need to work around
|
|
125
127
|
// We treat this as a change event and rebuild the CSS
|
|
126
|
-
watcher.on(
|
|
127
|
-
if (evt !==
|
|
128
|
+
watcher.on('raw', (evt, filePath, meta)=>{
|
|
129
|
+
if (evt !== 'rename' || filePath === null) {
|
|
128
130
|
return;
|
|
129
131
|
}
|
|
130
132
|
let watchedPath = meta.watchedPath;
|
|
@@ -150,7 +152,7 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
150
152
|
// We need to read the file as early as possible outside of the chain
|
|
151
153
|
// because it may be gone by the time we get to it. doing the read
|
|
152
154
|
// immediately increases the chance that the file is still there
|
|
153
|
-
let content = await (0,
|
|
155
|
+
let content = await (0, _utils.readFileWithRetries)(_path.default.resolve(filePath));
|
|
154
156
|
if (content === undefined) {
|
|
155
157
|
return;
|
|
156
158
|
}
|
|
@@ -159,7 +161,7 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
159
161
|
// This is because the order of events and timing is different on Linux
|
|
160
162
|
// @ts-ignore: TypeScript isn't picking up that content is a string here
|
|
161
163
|
await recordChangedFile(filePath, ()=>content, true);
|
|
162
|
-
} catch
|
|
164
|
+
} catch (e) {
|
|
163
165
|
// If reading the file fails, it's was probably a deleted temporary file
|
|
164
166
|
// So we can ignore it and no rebuild is needed
|
|
165
167
|
}
|
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,13 +3,13 @@
|
|
|
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
|
};
|
|
@@ -22,7 +22,7 @@ function oneOf(...options) {
|
|
|
22
22
|
return parsed;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
throw new Error(
|
|
25
|
+
throw new Error('...');
|
|
26
26
|
}, {
|
|
27
27
|
manualParsing: true
|
|
28
28
|
});
|
|
@@ -31,92 +31,93 @@ let commands = {
|
|
|
31
31
|
init: {
|
|
32
32
|
run: _init.init,
|
|
33
33
|
args: {
|
|
34
|
-
|
|
34
|
+
'--esm': {
|
|
35
35
|
type: Boolean,
|
|
36
36
|
description: `Initialize configuration file as ESM`
|
|
37
37
|
},
|
|
38
|
-
|
|
38
|
+
'--ts': {
|
|
39
39
|
type: Boolean,
|
|
40
40
|
description: `Initialize configuration file as TypeScript`
|
|
41
41
|
},
|
|
42
|
-
|
|
42
|
+
'--postcss': {
|
|
43
43
|
type: Boolean,
|
|
44
44
|
description: `Initialize a \`postcss.config.js\` file`
|
|
45
45
|
},
|
|
46
|
-
|
|
46
|
+
'--full': {
|
|
47
47
|
type: Boolean,
|
|
48
48
|
description: `Include the default values for all options in the generated configuration file`
|
|
49
49
|
},
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
'-f': '--full',
|
|
51
|
+
'-p': '--postcss'
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
build: {
|
|
55
55
|
run: _build.build,
|
|
56
56
|
args: {
|
|
57
|
-
|
|
57
|
+
'--input': {
|
|
58
58
|
type: String,
|
|
59
|
-
description:
|
|
59
|
+
description: 'Input file'
|
|
60
60
|
},
|
|
61
|
-
|
|
61
|
+
'--output': {
|
|
62
62
|
type: String,
|
|
63
|
-
description:
|
|
63
|
+
description: 'Output file'
|
|
64
64
|
},
|
|
65
|
-
|
|
65
|
+
'--watch': {
|
|
66
66
|
type: oneOf(String, Boolean),
|
|
67
|
-
description:
|
|
67
|
+
description: 'Watch for changes and rebuild as needed'
|
|
68
68
|
},
|
|
69
|
-
|
|
69
|
+
'--poll': {
|
|
70
70
|
type: Boolean,
|
|
71
|
-
description:
|
|
71
|
+
description: 'Use polling instead of filesystem events when watching'
|
|
72
72
|
},
|
|
73
|
-
|
|
73
|
+
'--content': {
|
|
74
74
|
type: String,
|
|
75
|
-
description:
|
|
75
|
+
description: 'Content paths to use for removing unused classes'
|
|
76
76
|
},
|
|
77
|
-
|
|
77
|
+
'--purge': {
|
|
78
78
|
type: String,
|
|
79
79
|
deprecated: true
|
|
80
80
|
},
|
|
81
|
-
|
|
81
|
+
'--postcss': {
|
|
82
82
|
type: oneOf(String, Boolean),
|
|
83
|
-
description:
|
|
83
|
+
description: 'Load custom PostCSS configuration'
|
|
84
84
|
},
|
|
85
|
-
|
|
85
|
+
'--minify': {
|
|
86
86
|
type: Boolean,
|
|
87
|
-
description:
|
|
87
|
+
description: 'Minify the output'
|
|
88
88
|
},
|
|
89
|
-
|
|
89
|
+
'--config': {
|
|
90
90
|
type: String,
|
|
91
|
-
description:
|
|
91
|
+
description: 'Path to a custom config file'
|
|
92
92
|
},
|
|
93
|
-
|
|
93
|
+
'--no-autoprefixer': {
|
|
94
|
+
deprecated: true,
|
|
94
95
|
type: Boolean,
|
|
95
|
-
description:
|
|
96
|
+
description: 'Disable autoprefixer'
|
|
96
97
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
'-c': '--config',
|
|
99
|
+
'-i': '--input',
|
|
100
|
+
'-o': '--output',
|
|
101
|
+
'-m': '--minify',
|
|
102
|
+
'-w': '--watch',
|
|
103
|
+
'-p': '--poll'
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
};
|
|
106
107
|
let sharedFlags = {
|
|
107
|
-
|
|
108
|
+
'--help': {
|
|
108
109
|
type: Boolean,
|
|
109
|
-
description:
|
|
110
|
+
description: 'Display usage information'
|
|
110
111
|
},
|
|
111
|
-
|
|
112
|
+
'-h': '--help'
|
|
112
113
|
};
|
|
113
114
|
if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.argv[2] === undefined || process.argv.slice(2).every((flag)=>sharedFlags[flag] !== undefined))) {
|
|
114
115
|
(0, _help.help)({
|
|
115
116
|
usage: [
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
'tailwindcss [--input input.css] [--output output.css] [--watch] [options...]',
|
|
118
|
+
'tailwindcss init [--full] [--postcss] [options...]'
|
|
118
119
|
],
|
|
119
|
-
commands: Object.keys(commands).filter((command)=>command !==
|
|
120
|
+
commands: Object.keys(commands).filter((command)=>command !== 'build').map((command)=>`${command} [options]`),
|
|
120
121
|
options: {
|
|
121
122
|
...commands.build.args,
|
|
122
123
|
...sharedFlags
|
|
@@ -124,26 +125,26 @@ if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.
|
|
|
124
125
|
});
|
|
125
126
|
process.exit(0);
|
|
126
127
|
}
|
|
127
|
-
let command = ((arg =
|
|
128
|
+
let command = ((arg = '')=>arg.startsWith('-') ? undefined : arg)(process.argv[2]) || 'build';
|
|
128
129
|
if (commands[command] === undefined) {
|
|
129
130
|
if (_fs.default.existsSync(_path.default.resolve(command))) {
|
|
130
131
|
// TODO: Deprecate this in future versions
|
|
131
132
|
// Check if non-existing command, might be a file.
|
|
132
|
-
command =
|
|
133
|
+
command = 'build';
|
|
133
134
|
} else {
|
|
134
135
|
(0, _help.help)({
|
|
135
136
|
message: `Invalid command: ${command}`,
|
|
136
137
|
usage: [
|
|
137
|
-
|
|
138
|
+
'tailwindcss <command> [options]'
|
|
138
139
|
],
|
|
139
|
-
commands: Object.keys(commands).filter((command)=>command !==
|
|
140
|
+
commands: Object.keys(commands).filter((command)=>command !== 'build').map((command)=>`${command} [options]`),
|
|
140
141
|
options: sharedFlags
|
|
141
142
|
});
|
|
142
143
|
process.exit(1);
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
146
|
// Execute command
|
|
146
|
-
let { args: flags
|
|
147
|
+
let { args: flags, run } = commands[command];
|
|
147
148
|
let args = (()=>{
|
|
148
149
|
try {
|
|
149
150
|
let result = (0, _arg.default)(Object.fromEntries(Object.entries({
|
|
@@ -154,18 +155,18 @@ let args = (()=>{
|
|
|
154
155
|
return !(value === null || value === void 0 ? void 0 : (_value_type = value.type) === null || _value_type === void 0 ? void 0 : _value_type.manualParsing);
|
|
155
156
|
}).map(([key, value])=>[
|
|
156
157
|
key,
|
|
157
|
-
typeof value ===
|
|
158
|
+
typeof value === 'object' ? value.type : value
|
|
158
159
|
])), {
|
|
159
160
|
permissive: true
|
|
160
161
|
});
|
|
161
162
|
// Manual parsing of flags to allow for special flags like oneOf(Boolean, String)
|
|
162
|
-
for(let i = result[
|
|
163
|
-
let flag = result[
|
|
164
|
-
if (!flag.startsWith(
|
|
165
|
-
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('=');
|
|
166
167
|
let handler = flags[flagName];
|
|
167
168
|
// Resolve flagName & handler
|
|
168
|
-
while(typeof handler ===
|
|
169
|
+
while(typeof handler === 'string'){
|
|
169
170
|
flagName = handler;
|
|
170
171
|
handler = flags[handler];
|
|
171
172
|
}
|
|
@@ -175,18 +176,18 @@ let args = (()=>{
|
|
|
175
176
|
// --flag value syntax was used so we need to pull `value` from `args`
|
|
176
177
|
if (flagValue === undefined) {
|
|
177
178
|
// Parse args for current flag
|
|
178
|
-
while(result[
|
|
179
|
-
args.push(result[
|
|
179
|
+
while(result['_'][offset] && !result['_'][offset].startsWith('-')){
|
|
180
|
+
args.push(result['_'][offset++]);
|
|
180
181
|
}
|
|
181
182
|
// Cleanup manually parsed flags + args
|
|
182
|
-
result[
|
|
183
|
+
result['_'].splice(i, 1 + args.length);
|
|
183
184
|
// No args were provided, use default value defined in handler
|
|
184
185
|
// One arg was provided, use that directly
|
|
185
186
|
// Multiple args were provided so pass them all in an array
|
|
186
187
|
flagValue = args.length === 0 ? undefined : args.length === 1 ? args[0] : args;
|
|
187
188
|
} else {
|
|
188
189
|
// Remove the whole flag from the args array
|
|
189
|
-
result[
|
|
190
|
+
result['_'].splice(i, 1);
|
|
190
191
|
}
|
|
191
192
|
// Set the resolved value in the `result` object
|
|
192
193
|
result[flagName] = handler.type(flagValue, flagName);
|
|
@@ -197,16 +198,16 @@ let args = (()=>{
|
|
|
197
198
|
//
|
|
198
199
|
// E.g.: tailwindcss input.css -> _: ['build', 'input.css']
|
|
199
200
|
// E.g.: tailwindcss build input.css -> _: ['build', 'input.css']
|
|
200
|
-
if (result[
|
|
201
|
-
result[
|
|
201
|
+
if (result['_'][0] !== command) {
|
|
202
|
+
result['_'].unshift(command);
|
|
202
203
|
}
|
|
203
204
|
return result;
|
|
204
205
|
} catch (err) {
|
|
205
|
-
if (err.code ===
|
|
206
|
+
if (err.code === 'ARG_UNKNOWN_OPTION') {
|
|
206
207
|
(0, _help.help)({
|
|
207
208
|
message: err.message,
|
|
208
209
|
usage: [
|
|
209
|
-
|
|
210
|
+
'tailwindcss <command> [options]'
|
|
210
211
|
],
|
|
211
212
|
options: sharedFlags
|
|
212
213
|
});
|
|
@@ -215,7 +216,7 @@ let args = (()=>{
|
|
|
215
216
|
throw err;
|
|
216
217
|
}
|
|
217
218
|
})();
|
|
218
|
-
if (args[
|
|
219
|
+
if (args['--help']) {
|
|
219
220
|
(0, _help.help)({
|
|
220
221
|
options: {
|
|
221
222
|
...flags,
|
package/lib/cli/init/index.js
CHANGED
|
@@ -5,50 +5,52 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "init", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: ()
|
|
8
|
+
get: function() {
|
|
9
|
+
return init;
|
|
10
|
+
}
|
|
9
11
|
});
|
|
10
|
-
const _fs = /*#__PURE__*/
|
|
11
|
-
const _path = /*#__PURE__*/
|
|
12
|
-
function
|
|
12
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
13
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
14
|
+
function _interop_require_default(obj) {
|
|
13
15
|
return obj && obj.__esModule ? obj : {
|
|
14
16
|
default: obj
|
|
15
17
|
};
|
|
16
18
|
}
|
|
17
19
|
function isESM() {
|
|
18
|
-
const pkgPath = _path.default.resolve(
|
|
20
|
+
const pkgPath = _path.default.resolve('./package.json');
|
|
19
21
|
try {
|
|
20
|
-
let pkg = JSON.parse(_fs.default.readFileSync(pkgPath,
|
|
21
|
-
return pkg.type && pkg.type ===
|
|
22
|
+
let pkg = JSON.parse(_fs.default.readFileSync(pkgPath, 'utf8'));
|
|
23
|
+
return pkg.type && pkg.type === 'module';
|
|
22
24
|
} catch (err) {
|
|
23
25
|
return false;
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
function init(args) {
|
|
27
29
|
let messages = [];
|
|
28
|
-
let isProjectESM = args[
|
|
29
|
-
let syntax = args[
|
|
30
|
-
let extension = args[
|
|
30
|
+
let isProjectESM = args['--ts'] || args['--esm'] || isESM();
|
|
31
|
+
let syntax = args['--ts'] ? 'ts' : isProjectESM ? 'js' : 'cjs';
|
|
32
|
+
let extension = args['--ts'] ? 'ts' : 'js';
|
|
31
33
|
var _args___;
|
|
32
|
-
let tailwindConfigLocation = _path.default.resolve((_args___ = args[
|
|
34
|
+
let tailwindConfigLocation = _path.default.resolve((_args___ = args['_'][1]) !== null && _args___ !== void 0 ? _args___ : `./tailwind.config.${extension}`);
|
|
33
35
|
if (_fs.default.existsSync(tailwindConfigLocation)) {
|
|
34
36
|
messages.push(`${_path.default.basename(tailwindConfigLocation)} already exists.`);
|
|
35
37
|
} else {
|
|
36
|
-
let stubContentsFile = _fs.default.readFileSync(args[
|
|
37
|
-
let stubFile = _fs.default.readFileSync(_path.default.resolve(__dirname, `../../../stubs/tailwind.config.${syntax}`),
|
|
38
|
+
let stubContentsFile = _fs.default.readFileSync(args['--full'] ? _path.default.resolve(__dirname, '../../../stubs/config.full.js') : _path.default.resolve(__dirname, '../../../stubs/config.simple.js'), 'utf8');
|
|
39
|
+
let stubFile = _fs.default.readFileSync(_path.default.resolve(__dirname, `../../../stubs/tailwind.config.${syntax}`), 'utf8');
|
|
38
40
|
// Change colors import
|
|
39
|
-
stubContentsFile = stubContentsFile.replace(
|
|
41
|
+
stubContentsFile = stubContentsFile.replace('../colors', 'tailwindcss/colors');
|
|
40
42
|
// Replace contents of {ts,js,cjs} file with the stub {simple,full}.
|
|
41
|
-
stubFile = stubFile.replace(
|
|
42
|
-
_fs.default.writeFileSync(tailwindConfigLocation, stubFile,
|
|
43
|
+
stubFile = stubFile.replace('__CONFIG__', stubContentsFile.replace('module.exports =', '').trim()).trim() + '\n\n';
|
|
44
|
+
_fs.default.writeFileSync(tailwindConfigLocation, stubFile, 'utf8');
|
|
43
45
|
messages.push(`Created Tailwind CSS config file: ${_path.default.basename(tailwindConfigLocation)}`);
|
|
44
46
|
}
|
|
45
|
-
if (args[
|
|
46
|
-
let postcssConfigLocation = _path.default.resolve(
|
|
47
|
+
if (args['--postcss']) {
|
|
48
|
+
let postcssConfigLocation = _path.default.resolve('./postcss.config.js');
|
|
47
49
|
if (_fs.default.existsSync(postcssConfigLocation)) {
|
|
48
50
|
messages.push(`${_path.default.basename(postcssConfigLocation)} already exists.`);
|
|
49
51
|
} else {
|
|
50
|
-
let
|
|
51
|
-
_fs.default.writeFileSync(postcssConfigLocation,
|
|
52
|
+
let stubFile = _fs.default.readFileSync(isProjectESM ? _path.default.resolve(__dirname, '../../../stubs/postcss.config.js') : _path.default.resolve(__dirname, '../../../stubs/postcss.config.cjs'), 'utf8');
|
|
53
|
+
_fs.default.writeFileSync(postcssConfigLocation, stubFile, 'utf8');
|
|
52
54
|
messages.push(`Created PostCSS config file: ${_path.default.basename(postcssConfigLocation)}`);
|
|
53
55
|
}
|
|
54
56
|
}
|