@vuepress/utils 2.0.0-beta.5 → 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 +37 -19
- package/CHANGELOG.md +0 -129
- package/lib/hasExportDefault.d.ts +0 -6
- package/lib/hasExportDefault.js +0 -11
- package/lib/index.d.ts +0 -14
- package/lib/index.js +0 -33
- package/lib/logger.d.ts +0 -12
- package/lib/logger.js +0 -31
- 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/requireResolve.d.ts +0 -7
- package/lib/requireResolve.js +0 -18
- 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",
|
|
@@ -15,31 +15,49 @@
|
|
|
15
15
|
"url": "git+https://github.com/vuepress/vuepress-next.git"
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
|
-
"author": "
|
|
19
|
-
"
|
|
20
|
-
"
|
|
18
|
+
"author": "meteorlxy",
|
|
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
|
-
"scripts": {
|
|
25
|
-
"build": "tsc -b tsconfig.build.json",
|
|
26
|
-
"clean": "rimraf lib *.tsbuildinfo"
|
|
27
|
-
},
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"@types/debug": "^4.1.
|
|
30
|
-
"@types/fs-extra": "^9.0.
|
|
30
|
+
"@types/debug": "^4.1.7",
|
|
31
|
+
"@types/fs-extra": "^9.0.13",
|
|
31
32
|
"@types/hash-sum": "^1.0.0",
|
|
32
|
-
"@vuepress/shared": "2.0.0-beta.
|
|
33
|
-
"chalk": "^
|
|
34
|
-
"debug": "^4.3.
|
|
35
|
-
"fs-extra": "^
|
|
36
|
-
"globby": "^
|
|
33
|
+
"@vuepress/shared": "2.0.0-beta.50-pre",
|
|
34
|
+
"chalk": "^5.0.1",
|
|
35
|
+
"debug": "^4.3.4",
|
|
36
|
+
"fs-extra": "^10.1.0",
|
|
37
|
+
"globby": "^13.1.2",
|
|
37
38
|
"hash-sum": "^2.0.0",
|
|
38
|
-
"ora": "^
|
|
39
|
+
"ora": "^6.1.2",
|
|
39
40
|
"upath": "^2.0.1"
|
|
40
41
|
},
|
|
41
42
|
"publishConfig": {
|
|
42
43
|
"access": "public"
|
|
43
44
|
},
|
|
44
|
-
"
|
|
45
|
-
|
|
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
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "tsup",
|
|
61
|
+
"clean": "rimraf dist"
|
|
62
|
+
}
|
|
63
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
# [2.0.0-beta.5](https://github.com/vuepress/vuepress-next/compare/v2.0.0-beta.4...v2.0.0-beta.5) (2021-03-26)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @vuepress/utils
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# [2.0.0-beta.4](https://github.com/vuepress/vuepress-next/compare/v2.0.0-beta.3...v2.0.0-beta.4) (2021-03-20)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package @vuepress/utils
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# [2.0.0-beta.1](https://github.com/vuepress/vuepress-next/compare/v2.0.0-beta.0...v2.0.0-beta.1) (2021-03-13)
|
|
23
|
-
|
|
24
|
-
**Note:** Version bump only for package @vuepress/utils
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# [2.0.0-beta.0](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.26...v2.0.0-beta.0) (2021-03-13)
|
|
31
|
-
|
|
32
|
-
**Note:** Version bump only for package @vuepress/utils
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
# [2.0.0-alpha.25](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.24...v2.0.0-alpha.25) (2021-02-20)
|
|
39
|
-
|
|
40
|
-
**Note:** Version bump only for package @vuepress/utils
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
# [2.0.0-alpha.24](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.23...v2.0.0-alpha.24) (2021-02-13)
|
|
47
|
-
|
|
48
|
-
**Note:** Version bump only for package @vuepress/utils
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
# [2.0.0-alpha.20](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.19...v2.0.0-alpha.20) (2021-02-04)
|
|
55
|
-
|
|
56
|
-
**Note:** Version bump only for package @vuepress/utils
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
# [2.0.0-alpha.19](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.18...v2.0.0-alpha.19) (2021-01-24)
|
|
63
|
-
|
|
64
|
-
**Note:** Version bump only for package @vuepress/utils
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
# [2.0.0-alpha.18](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.17...v2.0.0-alpha.18) (2021-01-17)
|
|
71
|
-
|
|
72
|
-
**Note:** Version bump only for package @vuepress/utils
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
# [2.0.0-alpha.15](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.14...v2.0.0-alpha.15) (2021-01-04)
|
|
79
|
-
|
|
80
|
-
**Note:** Version bump only for package @vuepress/utils
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
# [2.0.0-alpha.13](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.12...v2.0.0-alpha.13) (2020-12-23)
|
|
87
|
-
|
|
88
|
-
**Note:** Version bump only for package @vuepress/utils
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
# [2.0.0-alpha.7](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.6...v2.0.0-alpha.7) (2020-12-09)
|
|
95
|
-
|
|
96
|
-
**Note:** Version bump only for package @vuepress/utils
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
# [2.0.0-alpha.6](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.5...v2.0.0-alpha.6) (2020-12-09)
|
|
103
|
-
|
|
104
|
-
**Note:** Version bump only for package @vuepress/utils
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
# [2.0.0-alpha.4](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.3...v2.0.0-alpha.4) (2020-12-02)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
### Features
|
|
114
|
-
|
|
115
|
-
* **utils:** add hasExportDefault util ([575a9c5](https://github.com/vuepress/vuepress-next/commit/575a9c5d9eee44c0ce20b0712830e2eb2a303780))
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
# 2.0.0-alpha.1 (2020-12-01)
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
### Features
|
|
125
|
-
|
|
126
|
-
* **utils:** add logger and debug utils ([203d58d](https://github.com/vuepress/vuepress-next/commit/203d58d8d97c6a3158d4a783188ce2b64e54f19c))
|
|
127
|
-
* **utils:** add ora util ([f67b4d3](https://github.com/vuepress/vuepress-next/commit/f67b4d3f62fee077f947362c975c08c81470b0b0))
|
|
128
|
-
* **utils:** add withSpinner util ([82c6bb5](https://github.com/vuepress/vuepress-next/commit/82c6bb5d3e3a76088ee286fc10dabd9da4d59b22))
|
|
129
|
-
* **utils:** disable withSpinner if DEBUG env is set ([af19507](https://github.com/vuepress/vuepress-next/commit/af1950784fb17c258a4c07dbaf7439cf0ec2c762))
|
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) => shared_1.isPlainObject(mod) &&
|
|
9
|
-
!!mod.__esModule &&
|
|
10
|
-
Object.prototype.hasOwnProperty.call(mod, 'default');
|
|
11
|
-
exports.hasExportDefault = hasExportDefault;
|
package/lib/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as debug from 'debug';
|
|
2
|
-
import * as chalk from 'chalk';
|
|
3
|
-
import * as fs from 'fs-extra';
|
|
4
|
-
import * as globby from 'globby';
|
|
5
|
-
import * as ora from 'ora';
|
|
6
|
-
import * as path from 'upath';
|
|
7
|
-
import hash = require('hash-sum');
|
|
8
|
-
export { debug, chalk, fs, globby, hash, ora, path };
|
|
9
|
-
export * from './hasExportDefault';
|
|
10
|
-
export * from './logger';
|
|
11
|
-
export * from './renderHead';
|
|
12
|
-
export * from './renderHeadAttrs';
|
|
13
|
-
export * from './requireResolve';
|
|
14
|
-
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
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.path = exports.ora = exports.hash = exports.globby = exports.fs = exports.chalk = exports.debug = void 0;
|
|
14
|
-
const debug = require("debug");
|
|
15
|
-
exports.debug = debug;
|
|
16
|
-
const chalk = require("chalk");
|
|
17
|
-
exports.chalk = chalk;
|
|
18
|
-
const fs = require("fs-extra");
|
|
19
|
-
exports.fs = fs;
|
|
20
|
-
const globby = require("globby");
|
|
21
|
-
exports.globby = globby;
|
|
22
|
-
const ora = require("ora");
|
|
23
|
-
exports.ora = ora;
|
|
24
|
-
const path = require("upath");
|
|
25
|
-
exports.path = path;
|
|
26
|
-
const hash = require("hash-sum");
|
|
27
|
-
exports.hash = hash;
|
|
28
|
-
__exportStar(require("./hasExportDefault"), exports);
|
|
29
|
-
__exportStar(require("./logger"), exports);
|
|
30
|
-
__exportStar(require("./renderHead"), exports);
|
|
31
|
-
__exportStar(require("./renderHeadAttrs"), exports);
|
|
32
|
-
__exportStar(require("./requireResolve"), exports);
|
|
33
|
-
__exportStar(require("./withSpinner"), exports);
|
package/lib/logger.d.ts
DELETED
|
@@ -1,12 +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 logger: {
|
|
7
|
-
info: (...args: any[]) => void;
|
|
8
|
-
tip: (...args: any[]) => void;
|
|
9
|
-
success: (...args: any[]) => void;
|
|
10
|
-
warn: (...args: any[]) => void;
|
|
11
|
-
error: (...args: any[]) => void;
|
|
12
|
-
};
|
package/lib/logger.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.logger = 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
|
-
exports.logger = {
|
|
26
|
-
info: exports.info,
|
|
27
|
-
tip: exports.tip,
|
|
28
|
-
success: exports.success,
|
|
29
|
-
warn: exports.warn,
|
|
30
|
-
error: exports.error,
|
|
31
|
-
};
|
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}${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/requireResolve.d.ts
DELETED
package/lib/requireResolve.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.requireResolve = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Wrapper of `require.resolve` of nodejs
|
|
6
|
-
*
|
|
7
|
-
* Return `null` if the module cannot be resolved
|
|
8
|
-
* instead of throwing an error
|
|
9
|
-
*/
|
|
10
|
-
const requireResolve = (request) => {
|
|
11
|
-
try {
|
|
12
|
-
return require.resolve(request);
|
|
13
|
-
}
|
|
14
|
-
catch (_a) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
exports.requireResolve = requireResolve;
|
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;
|