@vuepress/utils 2.0.0-beta.5 → 2.0.0-beta.50
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/dist/index.d.ts +56 -0
- package/dist/index.js +120 -0
- 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/dist/index.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export { default as chalk } from 'chalk';
|
|
2
|
+
export { default as debug } from 'debug';
|
|
3
|
+
export { default as fs } from 'fs-extra';
|
|
4
|
+
export { globby } from 'globby';
|
|
5
|
+
export { default as hash } from 'hash-sum';
|
|
6
|
+
export { default as ora } from 'ora';
|
|
7
|
+
export { default as path } from 'upath';
|
|
8
|
+
import { HeadConfig, HeadAttrsConfig } from '@vuepress/shared';
|
|
9
|
+
|
|
10
|
+
declare const getDirname: (importMetaUrl: string) => string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A helper for dynamically importing a file path
|
|
14
|
+
*
|
|
15
|
+
* We need to use `pathToFileURL` to transform file path wo compat with windows
|
|
16
|
+
*/
|
|
17
|
+
declare const importFile: <T>(filePath: string) => Promise<T>;
|
|
18
|
+
/**
|
|
19
|
+
* A wrapper of `importFile` and returns the default export
|
|
20
|
+
*/
|
|
21
|
+
declare const importFileDefault: <T>(filePath: string) => Promise<T>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Check if `child` is a sub path of `parent` or not. Return `true` if
|
|
25
|
+
* they are the same path
|
|
26
|
+
*/
|
|
27
|
+
declare const isChildPath: (child: string, parent: string) => boolean;
|
|
28
|
+
|
|
29
|
+
declare const info: (...args: any[]) => void;
|
|
30
|
+
declare const tip: (...args: any[]) => void;
|
|
31
|
+
declare const success: (...args: any[]) => void;
|
|
32
|
+
declare const warn: (...args: any[]) => void;
|
|
33
|
+
declare const error: (...args: any[]) => void;
|
|
34
|
+
declare const createError: (message?: string | undefined) => Error;
|
|
35
|
+
declare const logger: {
|
|
36
|
+
info: (...args: any[]) => void;
|
|
37
|
+
tip: (...args: any[]) => void;
|
|
38
|
+
success: (...args: any[]) => void;
|
|
39
|
+
warn: (...args: any[]) => void;
|
|
40
|
+
error: (...args: any[]) => void;
|
|
41
|
+
createError: (message?: string | undefined) => Error;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Render head config to string
|
|
46
|
+
*/
|
|
47
|
+
declare const renderHead: ([tag, attrs, innerHTML,]: HeadConfig) => string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Render head attrs config to string
|
|
51
|
+
*/
|
|
52
|
+
declare const renderHeadAttrs: (attrs: HeadAttrsConfig) => string;
|
|
53
|
+
|
|
54
|
+
declare const withSpinner: (msg: string) => <T>(target: () => Promise<T>) => Promise<T>;
|
|
55
|
+
|
|
56
|
+
export { createError, error, getDirname, importFile, importFileDefault, info, isChildPath, logger, renderHead, renderHeadAttrs, success, tip, warn, withSpinner };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import chalk2 from "chalk";
|
|
3
|
+
import debug from "debug";
|
|
4
|
+
import fs from "fs-extra";
|
|
5
|
+
import { globby } from "globby";
|
|
6
|
+
import hash from "hash-sum";
|
|
7
|
+
import ora2 from "ora";
|
|
8
|
+
import path3 from "upath";
|
|
9
|
+
|
|
10
|
+
// src/getDirname.ts
|
|
11
|
+
import { fileURLToPath } from "url";
|
|
12
|
+
import path from "upath";
|
|
13
|
+
var getDirname = (importMetaUrl) => path.dirname(fileURLToPath(importMetaUrl));
|
|
14
|
+
|
|
15
|
+
// src/importFile.ts
|
|
16
|
+
import { pathToFileURL } from "url";
|
|
17
|
+
var importFile = (filePath) => import(pathToFileURL(filePath).toString());
|
|
18
|
+
var importFileDefault = (filePath) => importFile(filePath).then((m) => m.default);
|
|
19
|
+
|
|
20
|
+
// src/isChildPath.ts
|
|
21
|
+
import path2 from "upath";
|
|
22
|
+
var isChildPath = (child, parent) => {
|
|
23
|
+
const childPath = path2.normalize(child);
|
|
24
|
+
const parentPath = path2.normalize(parent);
|
|
25
|
+
if (!path2.win32.isAbsolute(childPath) || !path2.win32.isAbsolute(parentPath)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const relativePath = path2.relative(parentPath, childPath);
|
|
29
|
+
return relativePath === "" || !relativePath.startsWith("..");
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// src/logger.ts
|
|
33
|
+
import chalk from "chalk";
|
|
34
|
+
var info = (...args) => {
|
|
35
|
+
console.log(chalk.cyan("info"), ...args);
|
|
36
|
+
};
|
|
37
|
+
var tip = (...args) => {
|
|
38
|
+
console.log(chalk.blue("tip"), ...args);
|
|
39
|
+
};
|
|
40
|
+
var success = (...args) => {
|
|
41
|
+
console.log(chalk.green("success"), ...args);
|
|
42
|
+
};
|
|
43
|
+
var warn = (...args) => {
|
|
44
|
+
console.warn(chalk.yellow("warning"), ...args);
|
|
45
|
+
};
|
|
46
|
+
var error = (...args) => {
|
|
47
|
+
console.error(chalk.red("error"), ...args);
|
|
48
|
+
};
|
|
49
|
+
var createError = (message) => {
|
|
50
|
+
error(message);
|
|
51
|
+
return new Error(message);
|
|
52
|
+
};
|
|
53
|
+
var logger = {
|
|
54
|
+
info,
|
|
55
|
+
tip,
|
|
56
|
+
success,
|
|
57
|
+
warn,
|
|
58
|
+
error,
|
|
59
|
+
createError
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// src/renderHeadAttrs.ts
|
|
63
|
+
var renderHeadAttrs = (attrs) => Object.entries(attrs).filter((item) => item[1] !== false).map(
|
|
64
|
+
([key, value]) => value === true ? ` ${key}` : ` ${key}="${attrs[key]}"`
|
|
65
|
+
).join("");
|
|
66
|
+
|
|
67
|
+
// src/renderHead.ts
|
|
68
|
+
var renderHead = ([
|
|
69
|
+
tag,
|
|
70
|
+
attrs,
|
|
71
|
+
innerHTML = ""
|
|
72
|
+
]) => {
|
|
73
|
+
const openTag = `<${tag}${renderHeadAttrs(attrs)}>`;
|
|
74
|
+
if (tag === "link" || tag === "meta" || tag === "base") {
|
|
75
|
+
return openTag;
|
|
76
|
+
}
|
|
77
|
+
return `${openTag}${innerHTML}</${tag}>`;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// src/withSpinner.ts
|
|
81
|
+
import process from "process";
|
|
82
|
+
import ora from "ora";
|
|
83
|
+
var withSpinner = (msg) => async (target) => {
|
|
84
|
+
if (process.env.DEBUG) {
|
|
85
|
+
return target();
|
|
86
|
+
}
|
|
87
|
+
const spinner = ora();
|
|
88
|
+
try {
|
|
89
|
+
spinner.start(msg);
|
|
90
|
+
const result = await target();
|
|
91
|
+
spinner.succeed(`${msg} - done`);
|
|
92
|
+
return result;
|
|
93
|
+
} catch (e) {
|
|
94
|
+
spinner.fail(`${msg} - failed`);
|
|
95
|
+
throw e;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
export {
|
|
99
|
+
chalk2 as chalk,
|
|
100
|
+
createError,
|
|
101
|
+
debug,
|
|
102
|
+
error,
|
|
103
|
+
fs,
|
|
104
|
+
getDirname,
|
|
105
|
+
globby,
|
|
106
|
+
hash,
|
|
107
|
+
importFile,
|
|
108
|
+
importFileDefault,
|
|
109
|
+
info,
|
|
110
|
+
isChildPath,
|
|
111
|
+
logger,
|
|
112
|
+
ora2 as ora,
|
|
113
|
+
path3 as path,
|
|
114
|
+
renderHead,
|
|
115
|
+
renderHeadAttrs,
|
|
116
|
+
success,
|
|
117
|
+
tip,
|
|
118
|
+
warn,
|
|
119
|
+
withSpinner
|
|
120
|
+
};
|
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",
|
|
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",
|
|
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;
|