@vuepress/utils 2.0.0-beta.48 → 2.0.0-beta.50-pre
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/package.json +30 -10
- package/lib/hasExportDefault.d.ts +0 -6
- package/lib/hasExportDefault.js +0 -11
- package/lib/hash.d.ts +0 -1
- package/lib/hash.js +0 -5
- package/lib/index.d.ts +0 -13
- package/lib/index.js +0 -33
- package/lib/logger.d.ts +0 -14
- package/lib/logger.js +0 -37
- package/lib/renderHead.d.ts +0 -5
- package/lib/renderHead.js +0 -15
- package/lib/renderHeadAttrs.d.ts +0 -5
- package/lib/renderHeadAttrs.js +0 -11
- package/lib/withSpinner.d.ts +0 -1
- package/lib/withSpinner.js +0 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/utils",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.50-pre",
|
|
4
4
|
"description": "Utils package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -16,28 +16,48 @@
|
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"author": "meteorlxy",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": "./dist/index.js",
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
21
26
|
"files": [
|
|
22
|
-
"
|
|
27
|
+
"./dist"
|
|
23
28
|
],
|
|
24
29
|
"dependencies": {
|
|
25
30
|
"@types/debug": "^4.1.7",
|
|
26
31
|
"@types/fs-extra": "^9.0.13",
|
|
27
|
-
"@
|
|
28
|
-
"
|
|
32
|
+
"@types/hash-sum": "^1.0.0",
|
|
33
|
+
"@vuepress/shared": "2.0.0-beta.50-pre",
|
|
34
|
+
"chalk": "^5.0.1",
|
|
29
35
|
"debug": "^4.3.4",
|
|
30
36
|
"fs-extra": "^10.1.0",
|
|
31
|
-
"globby": "^
|
|
37
|
+
"globby": "^13.1.2",
|
|
32
38
|
"hash-sum": "^2.0.0",
|
|
33
|
-
"ora": "^
|
|
39
|
+
"ora": "^6.1.2",
|
|
34
40
|
"upath": "^2.0.1"
|
|
35
41
|
},
|
|
36
42
|
"publishConfig": {
|
|
37
43
|
"access": "public"
|
|
38
44
|
},
|
|
45
|
+
"tsup": {
|
|
46
|
+
"clean": true,
|
|
47
|
+
"dts": "./src/index.ts",
|
|
48
|
+
"entry": [
|
|
49
|
+
"./src/index.ts"
|
|
50
|
+
],
|
|
51
|
+
"format": [
|
|
52
|
+
"esm"
|
|
53
|
+
],
|
|
54
|
+
"outDir": "./dist",
|
|
55
|
+
"sourcemap": false,
|
|
56
|
+
"target": "es2020",
|
|
57
|
+
"tsconfig": "../tsconfig.dts.json"
|
|
58
|
+
},
|
|
39
59
|
"scripts": {
|
|
40
|
-
"build": "
|
|
41
|
-
"clean": "rimraf
|
|
60
|
+
"build": "tsup",
|
|
61
|
+
"clean": "rimraf dist"
|
|
42
62
|
}
|
|
43
63
|
}
|
package/lib/hasExportDefault.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasExportDefault = void 0;
|
|
4
|
-
const shared_1 = require("@vuepress/shared");
|
|
5
|
-
/**
|
|
6
|
-
* Check if a module is esm with `export default`
|
|
7
|
-
*/
|
|
8
|
-
const hasExportDefault = (mod) => (0, shared_1.isPlainObject)(mod) &&
|
|
9
|
-
!!mod.__esModule &&
|
|
10
|
-
Object.prototype.hasOwnProperty.call(mod, 'default');
|
|
11
|
-
exports.hasExportDefault = hasExportDefault;
|
package/lib/hash.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const hash: (val: unknown) => string;
|
package/lib/hash.js
DELETED
package/lib/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as chalk from 'chalk';
|
|
2
|
-
import * as debug from 'debug';
|
|
3
|
-
import * as globby from 'globby';
|
|
4
|
-
import * as ora from 'ora';
|
|
5
|
-
export { debug, chalk, globby, ora };
|
|
6
|
-
export * as fs from 'fs-extra';
|
|
7
|
-
export * as path from 'upath';
|
|
8
|
-
export * from './hasExportDefault';
|
|
9
|
-
export * from './hash';
|
|
10
|
-
export * from './logger';
|
|
11
|
-
export * from './renderHead';
|
|
12
|
-
export * from './renderHeadAttrs';
|
|
13
|
-
export * from './withSpinner';
|
package/lib/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.path = exports.fs = exports.ora = exports.globby = exports.chalk = exports.debug = void 0;
|
|
18
|
-
const chalk = require("chalk");
|
|
19
|
-
exports.chalk = chalk;
|
|
20
|
-
const debug = require("debug");
|
|
21
|
-
exports.debug = debug;
|
|
22
|
-
const globby = require("globby");
|
|
23
|
-
exports.globby = globby;
|
|
24
|
-
const ora = require("ora");
|
|
25
|
-
exports.ora = ora;
|
|
26
|
-
exports.fs = require("fs-extra");
|
|
27
|
-
exports.path = require("upath");
|
|
28
|
-
__exportStar(require("./hasExportDefault"), exports);
|
|
29
|
-
__exportStar(require("./hash"), exports);
|
|
30
|
-
__exportStar(require("./logger"), exports);
|
|
31
|
-
__exportStar(require("./renderHead"), exports);
|
|
32
|
-
__exportStar(require("./renderHeadAttrs"), exports);
|
|
33
|
-
__exportStar(require("./withSpinner"), exports);
|
package/lib/logger.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare const info: (...args: any[]) => void;
|
|
2
|
-
export declare const tip: (...args: any[]) => void;
|
|
3
|
-
export declare const success: (...args: any[]) => void;
|
|
4
|
-
export declare const warn: (...args: any[]) => void;
|
|
5
|
-
export declare const error: (...args: any[]) => void;
|
|
6
|
-
export declare const createError: (message?: string | undefined) => Error;
|
|
7
|
-
export declare const logger: {
|
|
8
|
-
info: (...args: any[]) => void;
|
|
9
|
-
tip: (...args: any[]) => void;
|
|
10
|
-
success: (...args: any[]) => void;
|
|
11
|
-
warn: (...args: any[]) => void;
|
|
12
|
-
error: (...args: any[]) => void;
|
|
13
|
-
createError: (message?: string | undefined) => Error;
|
|
14
|
-
};
|
package/lib/logger.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.logger = exports.createError = exports.error = exports.warn = exports.success = exports.tip = exports.info = void 0;
|
|
4
|
-
const chalk = require("chalk");
|
|
5
|
-
const info = (...args) => {
|
|
6
|
-
console.log(chalk.cyan('info'), ...args);
|
|
7
|
-
};
|
|
8
|
-
exports.info = info;
|
|
9
|
-
const tip = (...args) => {
|
|
10
|
-
console.log(chalk.blue('tip'), ...args);
|
|
11
|
-
};
|
|
12
|
-
exports.tip = tip;
|
|
13
|
-
const success = (...args) => {
|
|
14
|
-
console.log(chalk.green('success'), ...args);
|
|
15
|
-
};
|
|
16
|
-
exports.success = success;
|
|
17
|
-
const warn = (...args) => {
|
|
18
|
-
console.warn(chalk.yellow('warning'), ...args);
|
|
19
|
-
};
|
|
20
|
-
exports.warn = warn;
|
|
21
|
-
const error = (...args) => {
|
|
22
|
-
console.error(chalk.red('error'), ...args);
|
|
23
|
-
};
|
|
24
|
-
exports.error = error;
|
|
25
|
-
const createError = (message) => {
|
|
26
|
-
(0, exports.error)(message);
|
|
27
|
-
return new Error(message);
|
|
28
|
-
};
|
|
29
|
-
exports.createError = createError;
|
|
30
|
-
exports.logger = {
|
|
31
|
-
info: exports.info,
|
|
32
|
-
tip: exports.tip,
|
|
33
|
-
success: exports.success,
|
|
34
|
-
warn: exports.warn,
|
|
35
|
-
error: exports.error,
|
|
36
|
-
createError: exports.createError,
|
|
37
|
-
};
|
package/lib/renderHead.d.ts
DELETED
package/lib/renderHead.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renderHead = void 0;
|
|
4
|
-
const renderHeadAttrs_1 = require("./renderHeadAttrs");
|
|
5
|
-
/**
|
|
6
|
-
* Render head config to string
|
|
7
|
-
*/
|
|
8
|
-
const renderHead = ([tag, attrs, innerHTML = '',]) => {
|
|
9
|
-
const openTag = `<${tag}${(0, renderHeadAttrs_1.renderHeadAttrs)(attrs)}>`;
|
|
10
|
-
if (tag === 'link' || tag === 'meta' || tag === 'base') {
|
|
11
|
-
return openTag;
|
|
12
|
-
}
|
|
13
|
-
return `${openTag}${innerHTML}</${tag}>`;
|
|
14
|
-
};
|
|
15
|
-
exports.renderHead = renderHead;
|
package/lib/renderHeadAttrs.d.ts
DELETED
package/lib/renderHeadAttrs.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renderHeadAttrs = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Render head attrs config to string
|
|
6
|
-
*/
|
|
7
|
-
const renderHeadAttrs = (attrs) => Object.entries(attrs)
|
|
8
|
-
.filter((item) => item[1] !== false)
|
|
9
|
-
.map(([key, value]) => value === true ? ` ${key}` : ` ${key}="${attrs[key]}"`)
|
|
10
|
-
.join('');
|
|
11
|
-
exports.renderHeadAttrs = renderHeadAttrs;
|
package/lib/withSpinner.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const withSpinner: (msg: string) => <T>(target: () => Promise<T>) => Promise<T>;
|
package/lib/withSpinner.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withSpinner = void 0;
|
|
4
|
-
const ora = require("ora");
|
|
5
|
-
const withSpinner = (msg) => async (target) => {
|
|
6
|
-
if (process.env.DEBUG) {
|
|
7
|
-
return target();
|
|
8
|
-
}
|
|
9
|
-
const spinner = ora();
|
|
10
|
-
try {
|
|
11
|
-
spinner.start(msg);
|
|
12
|
-
const result = await target();
|
|
13
|
-
spinner.succeed(`${msg} - done`);
|
|
14
|
-
return result;
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
spinner.fail(`${msg} - failed`);
|
|
18
|
-
throw e;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
exports.withSpinner = withSpinner;
|