tailwindcss 0.0.0-oxide-insiders.a7fe2fe → 0.0.0-oxide-insiders.7f555c4
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/lib/cli/build/deps.js +34 -18
- package/lib/cli/build/index.js +45 -12
- package/lib/cli/build/plugin.js +273 -90
- package/lib/cli/build/utils.js +56 -24
- package/lib/cli/build/watching.js +156 -38
- package/lib/cli/help/index.js +61 -16
- package/lib/cli/index.js +121 -62
- package/lib/cli/init/index.js +47 -23
- package/lib/cli-peer-dependencies.js +23 -13
- package/lib/cli.js +5 -1
- package/lib/corePluginList.js +7 -4
- package/lib/corePlugins.js +855 -386
- package/lib/featureFlags.js +43 -18
- package/lib/lib/cacheInvalidation.js +78 -30
- package/lib/lib/collapseAdjacentRules.js +46 -23
- package/lib/lib/collapseDuplicateDeclarations.js +70 -27
- package/lib/lib/content.js +134 -41
- package/lib/lib/defaultExtractor.js +201 -96
- package/lib/lib/detectNesting.js +38 -12
- package/lib/lib/evaluateTailwindFunctions.js +192 -103
- package/lib/lib/expandApplyAtRules.js +488 -181
- package/lib/lib/expandTailwindAtRules.js +240 -70
- package/lib/lib/findAtConfigPath.js +34 -15
- package/lib/lib/generateRules.js +775 -353
- package/lib/lib/getModuleDependencies.js +67 -29
- package/lib/lib/load-config.js +27 -17
- package/lib/lib/normalizeTailwindDirectives.js +73 -27
- package/lib/lib/offsets.js +227 -62
- package/lib/lib/partitionApplyAtRules.js +53 -29
- package/lib/lib/regex.js +50 -28
- package/lib/lib/remap-bitfield.js +86 -9
- package/lib/lib/resolveDefaultsAtRules.js +123 -53
- package/lib/lib/setupContextUtils.js +1117 -584
- package/lib/lib/setupTrackingContext.js +149 -58
- package/lib/lib/sharedState.js +71 -23
- package/lib/lib/substituteScreenAtRules.js +19 -9
- package/lib/oxide/cli/build/deps.js +46 -23
- package/lib/oxide/cli/build/index.js +44 -12
- package/lib/oxide/cli/build/plugin.js +271 -89
- package/lib/oxide/cli/build/utils.js +55 -24
- package/lib/oxide/cli/build/watching.js +153 -36
- package/lib/oxide/cli/help/index.js +60 -16
- package/lib/oxide/cli/index.js +128 -67
- package/lib/oxide/cli/init/index.js +40 -19
- package/lib/oxide/cli.js +3 -2
- package/lib/plugin.js +58 -31
- package/lib/postcss-plugins/nesting/index.js +13 -7
- package/lib/postcss-plugins/nesting/plugin.js +65 -20
- package/lib/processTailwindFeatures.js +41 -10
- package/lib/public/colors.js +25 -16
- package/lib/public/create-plugin.js +11 -6
- package/lib/public/default-config.js +12 -6
- package/lib/public/default-theme.js +12 -6
- package/lib/public/load-config.js +9 -5
- package/lib/public/resolve-config.js +10 -6
- package/lib/util/applyImportantSelector.js +28 -17
- package/lib/util/bigSign.js +9 -6
- package/lib/util/buildMediaQuery.js +19 -10
- package/lib/util/cloneDeep.js +19 -9
- package/lib/util/cloneNodes.js +29 -14
- package/lib/util/color.js +87 -47
- package/lib/util/colorNames.js +752 -0
- package/lib/util/configurePlugins.js +18 -9
- package/lib/util/createPlugin.js +17 -8
- package/lib/util/createUtilityPlugin.js +30 -16
- package/lib/util/dataTypes.js +189 -38
- package/lib/util/defaults.js +21 -9
- package/lib/util/escapeClassName.js +15 -9
- package/lib/util/escapeCommas.js +9 -6
- package/lib/util/flattenColorPalette.js +11 -7
- package/lib/util/formatVariantSelector.js +209 -60
- package/lib/util/getAllConfigs.js +44 -35
- package/lib/util/hashConfig.js +12 -8
- package/lib/util/isKeyframeRule.js +10 -7
- package/lib/util/isPlainObject.js +14 -9
- package/lib/util/isSyntacticallyValidPropertyValue.js +45 -14
- package/lib/util/log.js +20 -9
- package/lib/util/nameClass.js +31 -10
- package/lib/util/negateValue.js +28 -10
- package/lib/util/normalizeConfig.js +242 -63
- package/lib/util/normalizeScreens.js +145 -70
- package/lib/util/parseAnimationValue.js +64 -14
- package/lib/util/parseBoxShadowValue.js +63 -14
- package/lib/util/parseDependency.js +39 -13
- package/lib/util/parseGlob.js +25 -8
- package/lib/util/parseObjectStyles.js +29 -18
- package/lib/util/pluginUtils.js +196 -77
- package/lib/util/prefixSelector.js +31 -12
- package/lib/util/pseudoElements.js +116 -34
- package/lib/util/removeAlphaVariables.js +23 -8
- package/lib/util/resolveConfig.js +224 -105
- package/lib/util/resolveConfigPath.js +45 -15
- package/lib/util/responsive.js +10 -6
- package/lib/util/splitAtTopLevelOnly.js +46 -10
- package/lib/util/tap.js +11 -7
- package/lib/util/toColorValue.js +10 -7
- package/lib/util/toPath.js +28 -8
- package/lib/util/transformThemeValue.js +49 -14
- package/lib/util/validateConfig.js +25 -15
- package/lib/util/validateFormalSyntax.js +14 -6
- package/lib/util/withAlphaVariable.js +54 -30
- package/package.json +18 -22
- package/peers/index.js +57849 -43101
- package/src/lib/expandTailwindAtRules.js +1 -1
- package/src/lib/setupTrackingContext.js +1 -1
- package/src/util/color.js +1 -1
- package/src/util/colorNames.js +150 -0
- package/src/util/pseudoElements.js +4 -4
package/lib/cli/build/utils.js
CHANGED
|
@@ -1,41 +1,66 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
"use strict";
|
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value:
|
|
4
|
-
})
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
function _export(target, all) {
|
|
5
7
|
for(var name in all)Object.defineProperty(target, name, {
|
|
6
|
-
enumerable:
|
|
8
|
+
enumerable: true,
|
|
7
9
|
get: all[name]
|
|
8
10
|
});
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
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
|
+
}
|
|
15
28
|
});
|
|
16
|
-
const _fs =
|
|
17
|
-
|
|
29
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
30
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
31
|
+
function _interop_require_default(obj) {
|
|
18
32
|
return obj && obj.__esModule ? obj : {
|
|
19
33
|
default: obj
|
|
20
34
|
};
|
|
21
35
|
}
|
|
22
36
|
function indentRecursive(node, indent = 0) {
|
|
23
37
|
node.each && node.each((child, i)=>{
|
|
24
|
-
(!child.raws.before || !child.raws.before.trim() || child.raws.before.includes("\n"))
|
|
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)}`;
|
|
40
|
+
}
|
|
41
|
+
child.raws.after = `\n${" ".repeat(indent)}`;
|
|
42
|
+
indentRecursive(child, indent + 1);
|
|
25
43
|
});
|
|
26
44
|
}
|
|
27
45
|
function formatNodes(root) {
|
|
28
|
-
indentRecursive(root)
|
|
46
|
+
indentRecursive(root);
|
|
47
|
+
if (root.first) {
|
|
48
|
+
root.first.raws.before = "";
|
|
49
|
+
}
|
|
29
50
|
}
|
|
30
51
|
async function readFileWithRetries(path, tries = 5) {
|
|
31
|
-
for(let n = 0; n <= tries; n++)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
52
|
+
for(let n = 0; n <= tries; n++){
|
|
53
|
+
try {
|
|
54
|
+
return await _fs.default.promises.readFile(path, "utf8");
|
|
55
|
+
} catch (err) {
|
|
56
|
+
if (n !== tries) {
|
|
57
|
+
if (err.code === "ENOENT" || err.code === "EBUSY") {
|
|
58
|
+
await new Promise((resolve)=>setTimeout(resolve, 10));
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
throw err;
|
|
37
63
|
}
|
|
38
|
-
throw err;
|
|
39
64
|
}
|
|
40
65
|
}
|
|
41
66
|
function drainStdin() {
|
|
@@ -43,14 +68,21 @@ function drainStdin() {
|
|
|
43
68
|
let result = "";
|
|
44
69
|
process.stdin.on("data", (chunk)=>{
|
|
45
70
|
result += chunk;
|
|
46
|
-
})
|
|
71
|
+
});
|
|
72
|
+
process.stdin.on("end", ()=>resolve(result));
|
|
73
|
+
process.stdin.on("error", (err)=>reject(err));
|
|
47
74
|
});
|
|
48
75
|
}
|
|
49
76
|
async function outputFile(file, newContents) {
|
|
50
77
|
try {
|
|
51
|
-
|
|
78
|
+
let currentContents = await _fs.default.promises.readFile(file, "utf8");
|
|
79
|
+
if (currentContents === newContents) {
|
|
80
|
+
return; // Skip writing the file
|
|
81
|
+
}
|
|
52
82
|
} catch {}
|
|
83
|
+
// Write the file
|
|
53
84
|
await _fs.default.promises.mkdir(_path.default.dirname(file), {
|
|
54
|
-
recursive:
|
|
55
|
-
})
|
|
85
|
+
recursive: true
|
|
86
|
+
});
|
|
87
|
+
await _fs.default.promises.writeFile(file, newContents, "utf8");
|
|
56
88
|
}
|
|
@@ -1,64 +1,182 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
"use strict";
|
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value:
|
|
4
|
-
}), Object.defineProperty(exports, "createWatcher", {
|
|
5
|
-
enumerable: !0,
|
|
6
|
-
get: ()=>createWatcher
|
|
4
|
+
value: true
|
|
7
5
|
});
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
Object.defineProperty(exports, "createWatcher", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return createWatcher;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
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) {
|
|
10
19
|
return obj && obj.__esModule ? obj : {
|
|
11
20
|
default: obj
|
|
12
21
|
};
|
|
13
22
|
}
|
|
14
23
|
function createWatcher(args, { state , rebuild }) {
|
|
15
|
-
let
|
|
16
|
-
|
|
24
|
+
let shouldPoll = args["--poll"];
|
|
25
|
+
let shouldCoalesceWriteEvents = shouldPoll || process.platform === "win32";
|
|
26
|
+
// Polling interval in milliseconds
|
|
27
|
+
// Used only when polling or coalescing add/change events on Windows
|
|
28
|
+
let pollInterval = 10;
|
|
29
|
+
let watcher = _chokidar.default.watch([], {
|
|
30
|
+
// Force checking for atomic writes in all situations
|
|
31
|
+
// This causes chokidar to wait up to 100ms for a file to re-added after it's been unlinked
|
|
32
|
+
// This only works when watching directories though
|
|
33
|
+
atomic: true,
|
|
17
34
|
usePolling: shouldPoll,
|
|
18
|
-
interval: shouldPoll ?
|
|
19
|
-
ignoreInitial:
|
|
20
|
-
awaitWriteFinish:
|
|
35
|
+
interval: shouldPoll ? pollInterval : undefined,
|
|
36
|
+
ignoreInitial: true,
|
|
37
|
+
awaitWriteFinish: shouldCoalesceWriteEvents ? {
|
|
21
38
|
stabilityThreshold: 50,
|
|
22
|
-
pollInterval:
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
|
|
39
|
+
pollInterval: pollInterval
|
|
40
|
+
} : false
|
|
41
|
+
});
|
|
42
|
+
// A queue of rebuilds, file reads, etc… to run
|
|
43
|
+
let chain = Promise.resolve();
|
|
44
|
+
/**
|
|
45
|
+
* A list of files that have been changed since the last rebuild
|
|
46
|
+
*
|
|
47
|
+
* @type {{file: string, content: () => Promise<string>, extension: string}[]}
|
|
48
|
+
*/ let changedContent = [];
|
|
49
|
+
/**
|
|
50
|
+
* A list of files for which a rebuild has already been queued.
|
|
51
|
+
* This is used to prevent duplicate rebuilds when multiple events are fired for the same file.
|
|
52
|
+
* The rebuilt file is cleared from this list when it's associated rebuild has _started_
|
|
53
|
+
* This is because if the file is changed during a rebuild it won't trigger a new rebuild which it should
|
|
54
|
+
**/ let pendingRebuilds = new Set();
|
|
55
|
+
let _timer;
|
|
56
|
+
let _reject;
|
|
57
|
+
/**
|
|
58
|
+
* Rebuilds the changed files and resolves when the rebuild is
|
|
59
|
+
* complete regardless of whether it was successful or not
|
|
60
|
+
*/ async function rebuildAndContinue() {
|
|
26
61
|
let changes = changedContent.splice(0);
|
|
27
|
-
|
|
62
|
+
// There are no changes to rebuild so we can just do nothing
|
|
63
|
+
if (changes.length === 0) {
|
|
64
|
+
return Promise.resolve();
|
|
65
|
+
}
|
|
66
|
+
// Clear all pending rebuilds for the about-to-be-built files
|
|
67
|
+
changes.forEach((change)=>pendingRebuilds.delete(change.file));
|
|
68
|
+
// Resolve the promise even when the rebuild fails
|
|
69
|
+
return rebuild(changes).then(()=>{}, (e)=>{
|
|
28
70
|
console.error(e.toString());
|
|
29
|
-
})
|
|
71
|
+
});
|
|
30
72
|
}
|
|
31
|
-
|
|
32
|
-
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @param {*} file
|
|
76
|
+
* @param {(() => Promise<string>) | null} content
|
|
77
|
+
* @param {boolean} skipPendingCheck
|
|
78
|
+
* @returns {Promise<void>}
|
|
79
|
+
*/ function recordChangedFile(file, content = null, skipPendingCheck = false) {
|
|
80
|
+
file = _path.default.resolve(file);
|
|
81
|
+
// Applications like Vim/Neovim fire both rename and change events in succession for atomic writes
|
|
82
|
+
// In that case rebuild has already been queued by rename, so can be skipped in change
|
|
83
|
+
if (pendingRebuilds.has(file) && !skipPendingCheck) {
|
|
84
|
+
return Promise.resolve();
|
|
85
|
+
}
|
|
86
|
+
// Mark that a rebuild of this file is going to happen
|
|
87
|
+
// It MUST happen synchronously before the rebuild is queued for this to be effective
|
|
88
|
+
pendingRebuilds.add(file);
|
|
89
|
+
changedContent.push({
|
|
33
90
|
file,
|
|
34
|
-
content: null
|
|
91
|
+
content: content !== null && content !== void 0 ? content : ()=>_fs.default.promises.readFile(file, "utf8"),
|
|
35
92
|
extension: _path.default.extname(file).slice(1)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
|
|
93
|
+
});
|
|
94
|
+
if (_timer) {
|
|
95
|
+
clearTimeout(_timer);
|
|
96
|
+
_reject();
|
|
97
|
+
}
|
|
98
|
+
// If a rebuild is already in progress we don't want to start another one until the 10ms timer has expired
|
|
99
|
+
chain = chain.then(()=>new Promise((resolve, reject)=>{
|
|
100
|
+
_timer = setTimeout(resolve, 10);
|
|
101
|
+
_reject = reject;
|
|
102
|
+
}));
|
|
103
|
+
// Resolves once this file has been rebuilt (or the rebuild for this file has failed)
|
|
104
|
+
// This queues as many rebuilds as there are changed files
|
|
105
|
+
// But those rebuilds happen after some delay
|
|
106
|
+
// And will immediately resolve if there are no changes
|
|
107
|
+
chain = chain.then(rebuildAndContinue, rebuildAndContinue);
|
|
108
|
+
return chain;
|
|
39
109
|
}
|
|
40
|
-
|
|
41
|
-
|
|
110
|
+
watcher.on("change", (file)=>recordChangedFile(file));
|
|
111
|
+
watcher.on("add", (file)=>recordChangedFile(file));
|
|
112
|
+
// Restore watching any files that are "removed"
|
|
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)
|
|
114
|
+
// TODO: An an optimization we should allow removal when the config changes
|
|
115
|
+
watcher.on("unlink", (file)=>{
|
|
116
|
+
file = (0, _normalizepath.default)(file);
|
|
117
|
+
// Only re-add the file if it's not covered by a dynamic pattern
|
|
118
|
+
if (!_micromatch.default.some([
|
|
42
119
|
file
|
|
43
|
-
], state.contentPatterns.dynamic)
|
|
44
|
-
|
|
45
|
-
|
|
120
|
+
], state.contentPatterns.dynamic)) {
|
|
121
|
+
watcher.add(file);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
// Some applications such as Visual Studio (but not VS Code)
|
|
125
|
+
// will only fire a rename event for atomic writes and not a change event
|
|
126
|
+
// This is very likely a chokidar bug but it's one we need to work around
|
|
127
|
+
// We treat this as a change event and rebuild the CSS
|
|
128
|
+
watcher.on("raw", (evt, filePath, meta)=>{
|
|
129
|
+
if (evt !== "rename") {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
46
132
|
let watchedPath = meta.watchedPath;
|
|
47
|
-
|
|
133
|
+
// Watched path might be the file itself
|
|
134
|
+
// Or the directory it is in
|
|
135
|
+
filePath = watchedPath.endsWith(filePath) ? watchedPath : _path.default.join(watchedPath, filePath);
|
|
136
|
+
// Skip this event since the files it is for does not match any of the registered content globs
|
|
137
|
+
if (!_micromatch.default.some([
|
|
48
138
|
filePath
|
|
49
|
-
], state.contentPatterns.all)
|
|
139
|
+
], state.contentPatterns.all)) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
// Skip since we've already queued a rebuild for this file that hasn't happened yet
|
|
143
|
+
if (pendingRebuilds.has(filePath)) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
// We'll go ahead and add the file to the pending rebuilds list here
|
|
147
|
+
// It'll be removed when the rebuild starts unless the read fails
|
|
148
|
+
// which will be taken care of as well
|
|
149
|
+
pendingRebuilds.add(filePath);
|
|
150
|
+
async function enqueue() {
|
|
50
151
|
try {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
152
|
+
// We need to read the file as early as possible outside of the chain
|
|
153
|
+
// because it may be gone by the time we get to it. doing the read
|
|
154
|
+
// immediately increases the chance that the file is still there
|
|
155
|
+
let content = await (0, _utils.readFileWithRetries)(_path.default.resolve(filePath));
|
|
156
|
+
if (content === undefined) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
// This will push the rebuild onto the chain
|
|
160
|
+
// We MUST skip the rebuild check here otherwise the rebuild will never happen on Linux
|
|
161
|
+
// This is because the order of events and timing is different on Linux
|
|
162
|
+
// @ts-ignore: TypeScript isn't picking up that content is a string here
|
|
163
|
+
await recordChangedFile(filePath, ()=>content, true);
|
|
164
|
+
} catch {
|
|
165
|
+
// If reading the file fails, it's was probably a deleted temporary file
|
|
166
|
+
// So we can ignore it and no rebuild is needed
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
enqueue().then(()=>{
|
|
170
|
+
// If the file read fails we still need to make sure the file isn't stuck in the pending rebuilds list
|
|
56
171
|
pendingRebuilds.delete(filePath);
|
|
57
|
-
})
|
|
58
|
-
})
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
return {
|
|
59
175
|
fswatcher: watcher,
|
|
60
176
|
refreshWatchedFiles () {
|
|
61
|
-
watcher.add(Array.from(state.contextDependencies))
|
|
177
|
+
watcher.add(Array.from(state.contextDependencies));
|
|
178
|
+
watcher.add(Array.from(state.configBag.dependencies));
|
|
179
|
+
watcher.add(state.contentPatterns.all);
|
|
62
180
|
}
|
|
63
181
|
};
|
|
64
182
|
}
|
package/lib/cli/help/index.js
CHANGED
|
@@ -1,28 +1,73 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
"use strict";
|
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value:
|
|
4
|
-
}), Object.defineProperty(exports, "help", {
|
|
5
|
-
enumerable: !0,
|
|
6
|
-
get: ()=>help
|
|
4
|
+
value: true
|
|
7
5
|
});
|
|
8
|
-
|
|
6
|
+
Object.defineProperty(exports, "help", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return help;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
const _packagejson = /*#__PURE__*/ _interop_require_default(require("../../../package.json"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
9
14
|
return obj && obj.__esModule ? obj : {
|
|
10
15
|
default: obj
|
|
11
16
|
};
|
|
12
|
-
}
|
|
17
|
+
}
|
|
13
18
|
function help({ message , usage , commands , options }) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
let indent = 2;
|
|
20
|
+
// Render header
|
|
21
|
+
console.log();
|
|
22
|
+
console.log(`${_packagejson.default.name} v${_packagejson.default.version}`);
|
|
23
|
+
// Render message
|
|
24
|
+
if (message) {
|
|
25
|
+
console.log();
|
|
26
|
+
for (let msg of message.split("\n")){
|
|
27
|
+
console.log(msg);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Render usage
|
|
31
|
+
if (usage && usage.length > 0) {
|
|
32
|
+
console.log();
|
|
33
|
+
console.log("Usage:");
|
|
34
|
+
for (let example of usage){
|
|
35
|
+
console.log(" ".repeat(indent), example);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Render commands
|
|
39
|
+
if (commands && commands.length > 0) {
|
|
40
|
+
console.log();
|
|
41
|
+
console.log("Commands:");
|
|
42
|
+
for (let command of commands){
|
|
43
|
+
console.log(" ".repeat(indent), command);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Render options
|
|
17
47
|
if (options) {
|
|
18
48
|
let groupedOptions = {};
|
|
19
|
-
for (let [key, value] of Object.entries(options))
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
49
|
+
for (let [key, value] of Object.entries(options)){
|
|
50
|
+
if (typeof value === "object") {
|
|
51
|
+
groupedOptions[key] = {
|
|
52
|
+
...value,
|
|
53
|
+
flags: [
|
|
54
|
+
key
|
|
55
|
+
]
|
|
56
|
+
};
|
|
57
|
+
} else {
|
|
58
|
+
groupedOptions[value].flags.push(key);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
console.log();
|
|
62
|
+
console.log("Options:");
|
|
63
|
+
for (let { flags , description , deprecated } of Object.values(groupedOptions)){
|
|
64
|
+
if (deprecated) continue;
|
|
65
|
+
if (flags.length === 1) {
|
|
66
|
+
console.log(" ".repeat(indent + 4 /* 4 = "-i, ".length */ ), flags.slice().reverse().join(", ").padEnd(20, " "), description);
|
|
67
|
+
} else {
|
|
68
|
+
console.log(" ".repeat(indent), flags.slice().reverse().join(", ").padEnd(24, " "), description);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
26
71
|
}
|
|
27
72
|
console.log();
|
|
28
73
|
}
|