shuvi 1.0.55 → 1.0.56
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/commands/dev.js +3 -2
- package/lib/commands/eslint/core/customFormatter.js +3 -3
- package/lib/commands/eslint/core/hasEslintConfiguration.d.ts +1 -1
- package/lib/commands/eslint/core/hasEslintConfiguration.js +1 -2
- package/lib/commands/eslint/core/runLintCheck.js +11 -11
- package/lib/commands/eslint/core/writeDefaultConfig.js +7 -8
- package/lib/commands/eslint/core/writeOutputFile.js +1 -2
- package/lib/commands/eslint/file-exists.js +1 -2
- package/lib/commands/eslint/find-pages-dir.js +3 -3
- package/lib/commands/eslint/has-necessary-dependencies.d.ts +1 -1
- package/lib/commands/eslint/has-necessary-dependencies.js +1 -2
- package/lib/commands/eslint/helpers/get-npx-command.js +1 -2
- package/lib/commands/eslint/helpers/get-online.js +1 -2
- package/lib/commands/eslint/helpers/get-pkg-manager.d.ts +1 -1
- package/lib/commands/eslint/helpers/get-pkg-manager.js +1 -2
- package/lib/commands/eslint/helpers/get-registry.js +1 -2
- package/lib/commands/eslint/helpers/install.d.ts +1 -1
- package/lib/commands/eslint/helpers/install.js +1 -2
- package/lib/commands/eslint/install-dependencies.d.ts +1 -1
- package/lib/commands/eslint/install-dependencies.js +3 -4
- package/lib/commands/eslint/is-error.js +2 -3
- package/lib/commands/eslint/oxford-comma-list.js +1 -2
- package/lib/commands/eslint/printAndExit.js +1 -2
- package/lib/commands/eslint/recursive-readdir.js +13 -14
- package/lib/commands/lint.d.ts +1 -1
- package/lib/commands/lint.js +1 -2
- package/lib/commands/serve.js +3 -2
- package/lib/config/config.js +2 -3
- package/lib/config/index.d.ts +1 -1
- package/lib/config/utils.d.ts +1 -1
- package/lib/config/utils.js +3 -4
- package/lib/shuvi.js +3 -4
- package/lib/tasks/build.d.ts +1 -1
- package/lib/tasks/build.js +1 -2
- package/lib/types.d.ts +2 -2
- package/lib/utils.js +4 -4
- package/package.json +10 -10
package/lib/commands/dev.js
CHANGED
|
@@ -35,6 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
38
39
|
const commander_1 = require("commander");
|
|
39
40
|
const path = __importStar(require("path"));
|
|
40
41
|
const service_1 = require("@shuvi/service");
|
|
@@ -59,7 +60,7 @@ exports.default = () => {
|
|
|
59
60
|
function devAction(dir, options) {
|
|
60
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
62
|
process.env.NODE_ENV = 'development';
|
|
62
|
-
const startTime = performance.now();
|
|
63
|
+
const startTime = perf_hooks_1.performance.now();
|
|
63
64
|
const cwd = (0, utils_1.getProjectDir)(dir);
|
|
64
65
|
const { host, port } = options;
|
|
65
66
|
const configFile = options.config && path.resolve(cwd, options.config);
|
|
@@ -76,7 +77,7 @@ function devAction(dir, options) {
|
|
|
76
77
|
yield shuviApp.listen(port, host);
|
|
77
78
|
(0, utils_1.printStartupInfo)({
|
|
78
79
|
startTime,
|
|
79
|
-
readyTime: performance.now(),
|
|
80
|
+
readyTime: perf_hooks_1.performance.now(),
|
|
80
81
|
host,
|
|
81
82
|
port
|
|
82
83
|
});
|
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.MessageSeverity = void 0;
|
|
7
|
+
exports.formatResults = formatResults;
|
|
7
8
|
/* eslint-disable prefer-template */
|
|
8
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
10
|
const path_1 = __importDefault(require("path"));
|
|
@@ -12,7 +13,7 @@ var MessageSeverity;
|
|
|
12
13
|
(function (MessageSeverity) {
|
|
13
14
|
MessageSeverity[MessageSeverity["Warning"] = 1] = "Warning";
|
|
14
15
|
MessageSeverity[MessageSeverity["Error"] = 2] = "Error";
|
|
15
|
-
})(MessageSeverity
|
|
16
|
+
})(MessageSeverity || (exports.MessageSeverity = MessageSeverity = {}));
|
|
16
17
|
function pluginCount(messages) {
|
|
17
18
|
let pluginWarningCount = 0;
|
|
18
19
|
let pluginErrorCount = 0;
|
|
@@ -88,4 +89,3 @@ function formatResults(baseDir, results, format) {
|
|
|
88
89
|
totalShuviPluginWarningCount
|
|
89
90
|
};
|
|
90
91
|
}
|
|
91
|
-
exports.formatResults = formatResults;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.hasEslintConfiguration =
|
|
12
|
+
exports.hasEslintConfiguration = hasEslintConfiguration;
|
|
13
13
|
const fs_1 = require("fs");
|
|
14
14
|
function hasEslintConfiguration(eslintrcFile,
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -39,4 +39,3 @@ packageJsonConfig) {
|
|
|
39
39
|
return configObject;
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
exports.hasEslintConfiguration = hasEslintConfiguration;
|
|
@@ -35,7 +35,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.
|
|
38
|
+
exports.ESLINT_PROMPT_VALUES = void 0;
|
|
39
|
+
exports.runLintCheck = runLintCheck;
|
|
39
40
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
40
41
|
const fs_1 = require("fs");
|
|
41
42
|
const chalk_1 = __importDefault(require("chalk"));
|
|
@@ -98,9 +99,9 @@ function cliPrompt() {
|
|
|
98
99
|
}
|
|
99
100
|
});
|
|
100
101
|
}
|
|
101
|
-
function lint(
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
function lint(baseDir_1, lintDirs_1, eslintrcFile_1, pkgJsonPath_1, _a) {
|
|
103
|
+
return __awaiter(this, arguments, void 0, function* (baseDir, lintDirs, eslintrcFile, pkgJsonPath, { lintDuringBuild = false, eslintOptions = null, reportErrorsOnly = false, maxWarnings = -1, formatter = null, outputFile = null }) {
|
|
104
|
+
var _b, _c, _d, _e, _f, _g;
|
|
104
105
|
try {
|
|
105
106
|
// Load ESLint after we're sure it exists:
|
|
106
107
|
const deps = yield (0, has_necessary_dependencies_1.hasNecessaryDependencies)(baseDir, requiredPackages);
|
|
@@ -115,7 +116,7 @@ function lint(baseDir, lintDirs, eslintrcFile, pkgJsonPath, { lintDuringBuild =
|
|
|
115
116
|
}
|
|
116
117
|
const mod = yield Promise.resolve(require(deps.resolved.get('eslint')));
|
|
117
118
|
const { ESLint } = mod;
|
|
118
|
-
let eslintVersion = (
|
|
119
|
+
let eslintVersion = (_b = ESLint === null || ESLint === void 0 ? void 0 : ESLint.version) !== null && _b !== void 0 ? _b : (_c = mod === null || mod === void 0 ? void 0 : mod.CLIEngine) === null || _c === void 0 ? void 0 : _c.version;
|
|
119
120
|
if (!eslintVersion || semver_1.default.lt(eslintVersion, '7.0.0')) {
|
|
120
121
|
return `${chalk_1.default.red('error')} - Your project has an older version of ESLint installed${eslintVersion ? ` (${eslintVersion})` : ''}. Please upgrade to ESLint version 7 or above`;
|
|
121
122
|
}
|
|
@@ -128,7 +129,7 @@ function lint(baseDir, lintDirs, eslintrcFile, pkgJsonPath, { lintDuringBuild =
|
|
|
128
129
|
continue;
|
|
129
130
|
}
|
|
130
131
|
const completeConfig = yield eslint.calculateConfigForFile(configFile);
|
|
131
|
-
if ((
|
|
132
|
+
if ((_d = completeConfig.plugins) === null || _d === void 0 ? void 0 : _d.includes('@shuvi/shuvi')) {
|
|
132
133
|
shuviEslintPluginIsEnabled = true;
|
|
133
134
|
for (const [name, [severity]] of Object.entries(completeConfig.rules)) {
|
|
134
135
|
if (!name.startsWith('@shuvi/shuvi/')) {
|
|
@@ -154,8 +155,8 @@ function lint(baseDir, lintDirs, eslintrcFile, pkgJsonPath, { lintDuringBuild =
|
|
|
154
155
|
if (shuviEslintPluginIsEnabled) {
|
|
155
156
|
let updatedPagesDir = false;
|
|
156
157
|
for (const rule of pagesDirRules) {
|
|
157
|
-
if (!((
|
|
158
|
-
!((
|
|
158
|
+
if (!((_e = options.baseConfig.rules) === null || _e === void 0 ? void 0 : _e[rule]) &&
|
|
159
|
+
!((_f = options.baseConfig.rules) === null || _f === void 0 ? void 0 : _f[rule.replace('@shuvi/shuvi', '@shuvi/babel-plugin-shuvi')])) {
|
|
159
160
|
if (!options.baseConfig.rules) {
|
|
160
161
|
options.baseConfig.rules = {};
|
|
161
162
|
}
|
|
@@ -190,7 +191,7 @@ function lint(baseDir, lintDirs, eslintrcFile, pkgJsonPath, { lintDuringBuild =
|
|
|
190
191
|
}
|
|
191
192
|
return {
|
|
192
193
|
output: formattedResult.outputWithMessages,
|
|
193
|
-
isError: ((
|
|
194
|
+
isError: ((_g = ESLint.getErrorResults(results)) === null || _g === void 0 ? void 0 : _g.length) > 0 ||
|
|
194
195
|
(maxWarnings >= 0 && totalWarnings > maxWarnings),
|
|
195
196
|
eventInfo: {
|
|
196
197
|
durationInSeconds: lintEnd[0],
|
|
@@ -218,8 +219,8 @@ function lint(baseDir, lintDirs, eslintrcFile, pkgJsonPath, { lintDuringBuild =
|
|
|
218
219
|
});
|
|
219
220
|
}
|
|
220
221
|
function runLintCheck(baseDir, lintDirs, opts) {
|
|
221
|
-
var _a, _b;
|
|
222
222
|
return __awaiter(this, void 0, void 0, function* () {
|
|
223
|
+
var _a, _b;
|
|
223
224
|
const { lintDuringBuild = false, eslintOptions = null, reportErrorsOnly = false, maxWarnings = -1, formatter = null, outputFile = null, strict = false } = opts;
|
|
224
225
|
try {
|
|
225
226
|
// Find user's .eslintrc file
|
|
@@ -297,4 +298,3 @@ function runLintCheck(baseDir, lintDirs, opts) {
|
|
|
297
298
|
}
|
|
298
299
|
});
|
|
299
300
|
}
|
|
300
|
-
exports.runLintCheck = runLintCheck;
|
|
@@ -35,18 +35,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.writeDefaultConfig =
|
|
38
|
+
exports.writeDefaultConfig = writeDefaultConfig;
|
|
39
39
|
const fs_1 = require("fs");
|
|
40
40
|
const chalk_1 = __importDefault(require("chalk"));
|
|
41
41
|
const os_1 = __importDefault(require("os"));
|
|
42
42
|
const path_1 = __importDefault(require("path"));
|
|
43
43
|
const CommentJson = __importStar(require("comment-json"));
|
|
44
|
-
function writeDefaultConfig(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
function writeDefaultConfig(baseDir_1, _a, selectedConfig_1, eslintrcFile_1, pkgJsonPath_1, packageJsonConfig_1) {
|
|
45
|
+
return __awaiter(this, arguments, void 0, function* (baseDir, { exists, emptyEslintrc, emptyPkgJsonConfig },
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
selectedConfig, eslintrcFile, pkgJsonPath,
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
+
packageJsonConfig) {
|
|
50
50
|
if (!exists && emptyEslintrc && eslintrcFile) {
|
|
51
51
|
const ext = path_1.default.extname(eslintrcFile);
|
|
52
52
|
let newFileContent;
|
|
@@ -75,4 +75,3 @@ packageJsonConfig) {
|
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
exports.writeDefaultConfig = writeDefaultConfig;
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.writeOutputFile =
|
|
15
|
+
exports.writeOutputFile = writeOutputFile;
|
|
16
16
|
const fs_1 = require("fs");
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const is_error_1 = __importDefault(require("../is-error"));
|
|
@@ -62,4 +62,3 @@ outputData) {
|
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
exports.writeOutputFile = writeOutputFile;
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.fileExists =
|
|
15
|
+
exports.fileExists = fileExists;
|
|
16
16
|
const fs_1 = require("fs");
|
|
17
17
|
const is_error_1 = __importDefault(require("./is-error"));
|
|
18
18
|
function fileExists(fileName, type) {
|
|
@@ -40,4 +40,3 @@ function fileExists(fileName, type) {
|
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
exports.fileExists = fileExists;
|
|
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.existsSync = void 0;
|
|
7
|
+
exports.findDir = findDir;
|
|
8
|
+
exports.findPagesDir = findPagesDir;
|
|
7
9
|
const fs_1 = __importDefault(require("fs"));
|
|
8
10
|
const path_1 = __importDefault(require("path"));
|
|
9
11
|
const existsSync = (f) => {
|
|
@@ -23,7 +25,6 @@ function findDir(dir, name) {
|
|
|
23
25
|
return curDir;
|
|
24
26
|
return null;
|
|
25
27
|
}
|
|
26
|
-
exports.findDir = findDir;
|
|
27
28
|
function findPagesDir(dir) {
|
|
28
29
|
const pagesDir = findDir(dir, 'routes') || undefined;
|
|
29
30
|
if (!pagesDir) {
|
|
@@ -31,4 +32,3 @@ function findPagesDir(dir) {
|
|
|
31
32
|
}
|
|
32
33
|
return pagesDir;
|
|
33
34
|
}
|
|
34
|
-
exports.findPagesDir = findPagesDir;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.hasNecessaryDependencies =
|
|
12
|
+
exports.hasNecessaryDependencies = hasNecessaryDependencies;
|
|
13
13
|
const fs_1 = require("fs");
|
|
14
14
|
const file_exists_1 = require("./file-exists");
|
|
15
15
|
const resolve_from_1 = require("./resolve-from");
|
|
@@ -52,4 +52,3 @@ function hasNecessaryDependencies(baseDir, requiredPackages) {
|
|
|
52
52
|
};
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
-
exports.hasNecessaryDependencies = hasNecessaryDependencies;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getNpxCommand =
|
|
3
|
+
exports.getNpxCommand = getNpxCommand;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const get_pkg_manager_1 = require("./get-pkg-manager");
|
|
6
6
|
function getNpxCommand(baseDir) {
|
|
@@ -18,4 +18,3 @@ function getNpxCommand(baseDir) {
|
|
|
18
18
|
}
|
|
19
19
|
return command;
|
|
20
20
|
}
|
|
21
|
-
exports.getNpxCommand = getNpxCommand;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getOnline =
|
|
6
|
+
exports.getOnline = getOnline;
|
|
7
7
|
const child_process_1 = require("child_process");
|
|
8
8
|
const dns_1 = __importDefault(require("dns"));
|
|
9
9
|
const url_1 = __importDefault(require("url"));
|
|
@@ -39,4 +39,3 @@ function getOnline() {
|
|
|
39
39
|
});
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
exports.getOnline = getOnline;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type PackageManager = 'npm' | 'pnpm' | 'yarn';
|
|
2
2
|
export declare function getPkgManager(baseDir: string): PackageManager;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getPkgManager =
|
|
6
|
+
exports.getPkgManager = getPkgManager;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const child_process_1 = require("child_process");
|
|
@@ -40,4 +40,3 @@ function getPkgManager(baseDir) {
|
|
|
40
40
|
return 'npm';
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
exports.getPkgManager = getPkgManager;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRegistry =
|
|
3
|
+
exports.getRegistry = getRegistry;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const get_pkg_manager_1 = require("./get-pkg-manager");
|
|
6
6
|
/**
|
|
@@ -23,4 +23,3 @@ function getRegistry(baseDir = process.cwd()) {
|
|
|
23
23
|
return registry;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
exports.getRegistry = getRegistry;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.install =
|
|
6
|
+
exports.install = install;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const cross_spawn_1 = __importDefault(require("cross-spawn"));
|
|
9
9
|
/**
|
|
@@ -100,4 +100,3 @@ function install(root, dependencies, { packageManager, isOnline, devDependencies
|
|
|
100
100
|
});
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
|
-
exports.install = install;
|
|
@@ -12,15 +12,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.installDependencies =
|
|
15
|
+
exports.installDependencies = installDependencies;
|
|
16
16
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
17
17
|
const chalk_1 = __importDefault(require("chalk"));
|
|
18
18
|
const path_1 = __importDefault(require("path"));
|
|
19
19
|
const get_pkg_manager_1 = require("./helpers/get-pkg-manager");
|
|
20
20
|
const install_1 = require("./helpers/install");
|
|
21
21
|
const get_online_1 = require("./helpers/get-online");
|
|
22
|
-
function installDependencies(
|
|
23
|
-
return __awaiter(this,
|
|
22
|
+
function installDependencies(baseDir_1, deps_1) {
|
|
23
|
+
return __awaiter(this, arguments, void 0, function* (baseDir, deps, dev = false) {
|
|
24
24
|
const packageManager = (0, get_pkg_manager_1.getPkgManager)(baseDir);
|
|
25
25
|
const isOnline = yield (0, get_online_1.getOnline)();
|
|
26
26
|
if (deps.length) {
|
|
@@ -35,4 +35,3 @@ function installDependencies(baseDir, deps, dev = false) {
|
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
exports.installDependencies = installDependencies;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.default = isError;
|
|
4
|
+
exports.getProperError = getProperError;
|
|
4
5
|
function isError(err) {
|
|
5
6
|
return (typeof err === 'object' && err !== null && 'name' in err && 'message' in err);
|
|
6
7
|
}
|
|
7
|
-
exports.default = isError;
|
|
8
8
|
function getProperError(err) {
|
|
9
9
|
if (isError(err)) {
|
|
10
10
|
return err;
|
|
11
11
|
}
|
|
12
12
|
return new Error(isPlainObject(err) ? JSON.stringify(err) : `${err}`);
|
|
13
13
|
}
|
|
14
|
-
exports.getProperError = getProperError;
|
|
15
14
|
function getObjectClassLabel(value) {
|
|
16
15
|
return Object.prototype.toString.call(value);
|
|
17
16
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOxfordCommaList =
|
|
3
|
+
exports.getOxfordCommaList = getOxfordCommaList;
|
|
4
4
|
function getOxfordCommaList(items) {
|
|
5
5
|
return items
|
|
6
6
|
.map((v, index, { length }) => (index > 0
|
|
@@ -12,4 +12,3 @@ function getOxfordCommaList(items) {
|
|
|
12
12
|
: '') + v)
|
|
13
13
|
.join('');
|
|
14
14
|
}
|
|
15
|
-
exports.getOxfordCommaList = getOxfordCommaList;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printAndExit =
|
|
3
|
+
exports.printAndExit = printAndExit;
|
|
4
4
|
function printAndExit(message, code = 1) {
|
|
5
5
|
if (code === 0) {
|
|
6
6
|
console.log(message);
|
|
@@ -10,4 +10,3 @@ function printAndExit(message, code = 1) {
|
|
|
10
10
|
}
|
|
11
11
|
process.exit(code);
|
|
12
12
|
}
|
|
13
|
-
exports.printAndExit = printAndExit;
|
|
@@ -9,25 +9,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.recursiveReadDir =
|
|
12
|
+
exports.recursiveReadDir = recursiveReadDir;
|
|
13
13
|
const fs_1 = require("fs");
|
|
14
14
|
const path_1 = require("path");
|
|
15
15
|
/**
|
|
16
16
|
* Recursively read directory
|
|
17
17
|
* Returns array holding all relative paths
|
|
18
18
|
*/
|
|
19
|
-
function recursiveReadDir(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
function recursiveReadDir(dir_1, filter_1, ignore_1, ignorePart_1) {
|
|
20
|
+
return __awaiter(this, arguments, void 0, function* (
|
|
21
|
+
/** Directory to read */
|
|
22
|
+
dir,
|
|
23
|
+
/** Filter for the file path */
|
|
24
|
+
filter,
|
|
25
|
+
/** Filter for the file path */
|
|
26
|
+
ignore, ignorePart,
|
|
27
|
+
/** This doesn't have to be provided, it's used for the recursion */
|
|
28
|
+
arr = [],
|
|
29
|
+
/** Used to replace the initial path, only the relative path is left, it's faster than path.relative. */
|
|
30
|
+
rootDir = dir) {
|
|
31
31
|
const result = yield fs_1.promises.readdir(dir, { withFileTypes: true });
|
|
32
32
|
yield Promise.all(result.map((part) => __awaiter(this, void 0, void 0, function* () {
|
|
33
33
|
const absolutePath = (0, path_1.join)(dir, part.name);
|
|
@@ -57,4 +57,3 @@ rootDir = dir) {
|
|
|
57
57
|
return arr.sort();
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
exports.recursiveReadDir = recursiveReadDir;
|
package/lib/commands/lint.d.ts
CHANGED
package/lib/commands/lint.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.lintAction =
|
|
12
|
+
exports.lintAction = lintAction;
|
|
13
13
|
const commander_1 = require("commander");
|
|
14
14
|
const fs_1 = require("fs");
|
|
15
15
|
const path_1 = require("path");
|
|
@@ -143,4 +143,3 @@ function lintAction(dir, options) {
|
|
|
143
143
|
});
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
|
-
exports.lintAction = lintAction;
|
package/lib/commands/serve.js
CHANGED
|
@@ -35,6 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
38
39
|
const commander_1 = require("commander");
|
|
39
40
|
const path = __importStar(require("path"));
|
|
40
41
|
const service_1 = require("@shuvi/service");
|
|
@@ -58,7 +59,7 @@ exports.default = () => {
|
|
|
58
59
|
};
|
|
59
60
|
function serveAction(dir, options) {
|
|
60
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
const startTime = performance.now();
|
|
62
|
+
const startTime = perf_hooks_1.performance.now();
|
|
62
63
|
process.env.NODE_ENV = 'production';
|
|
63
64
|
const { host, port } = options;
|
|
64
65
|
const cwd = (0, utils_1.getProjectDir)(dir);
|
|
@@ -74,7 +75,7 @@ function serveAction(dir, options) {
|
|
|
74
75
|
yield shuviApp.listen(port, host);
|
|
75
76
|
(0, utils_1.printStartupInfo)({
|
|
76
77
|
startTime,
|
|
77
|
-
readyTime: performance.now(),
|
|
78
|
+
readyTime: perf_hooks_1.performance.now(),
|
|
78
79
|
host,
|
|
79
80
|
port
|
|
80
81
|
});
|
package/lib/config/config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.normalizePlatformConfig = normalizePlatformConfig;
|
|
4
|
+
exports.defineConfig = defineConfig;
|
|
4
5
|
const deepmerge_1 = require("@shuvi/utils/deepmerge");
|
|
5
6
|
function getDefaultPlatformConfig() {
|
|
6
7
|
return {
|
|
@@ -18,8 +19,6 @@ function normalizePlatformConfig(rawConfig) {
|
|
|
18
19
|
}
|
|
19
20
|
return config;
|
|
20
21
|
}
|
|
21
|
-
exports.normalizePlatformConfig = normalizePlatformConfig;
|
|
22
22
|
function defineConfig(config) {
|
|
23
23
|
return config;
|
|
24
24
|
}
|
|
25
|
-
exports.defineConfig = defineConfig;
|
package/lib/config/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type OptionsKeyMap = Record<string, string | ((config: any, optionValue: any) => void)>;
|
|
2
2
|
export { normalizePlatformConfig, defineConfig } from './config';
|
|
3
3
|
export { getConfigFromCli } from './utils';
|
package/lib/config/utils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ShuviConfig } from '@shuvi/service';
|
|
2
|
-
export
|
|
2
|
+
export type OptionsKeyMap = Record<string, string | ((config: any, optionValue: any) => void)>;
|
|
3
3
|
export declare function getConfigFromCli(cliOptions: Record<string, any>, cliOptionsKeyMap?: OptionsKeyMap): Promise<ShuviConfig>;
|
package/lib/config/utils.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getConfigFromCli =
|
|
15
|
+
exports.getConfigFromCli = getConfigFromCli;
|
|
16
16
|
const logger_1 = __importDefault(require("@shuvi/utils/logger"));
|
|
17
17
|
function set(obj, path, value) {
|
|
18
18
|
const segments = path.split('.');
|
|
@@ -51,10 +51,9 @@ function getConfigFromCliOtherOptions(cliOptions, cliOptionsKeyMap = {}) {
|
|
|
51
51
|
}
|
|
52
52
|
return config;
|
|
53
53
|
}
|
|
54
|
-
function getConfigFromCli(
|
|
55
|
-
return __awaiter(this,
|
|
54
|
+
function getConfigFromCli(cliOptions_1) {
|
|
55
|
+
return __awaiter(this, arguments, void 0, function* (cliOptions, cliOptionsKeyMap = {}) {
|
|
56
56
|
const configFromCliOtherOptions = getConfigFromCliOtherOptions(cliOptions, cliOptionsKeyMap);
|
|
57
57
|
return configFromCliOtherOptions;
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
exports.getConfigFromCli = getConfigFromCli;
|
package/lib/shuvi.js
CHANGED
|
@@ -23,7 +23,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.getPlatform = getPlatform;
|
|
27
|
+
exports.initShuvi = initShuvi;
|
|
27
28
|
const service_1 = require("@shuvi/service");
|
|
28
29
|
const platform_web_1 = __importDefault(require("@shuvi/platform-web"));
|
|
29
30
|
const config_1 = require("./config");
|
|
@@ -32,10 +33,9 @@ const trace_1 = require("@shuvi/service/lib/trace");
|
|
|
32
33
|
function getPlatform() {
|
|
33
34
|
return (0, platform_web_1.default)({ framework: 'react' });
|
|
34
35
|
}
|
|
35
|
-
exports.getPlatform = getPlatform;
|
|
36
36
|
function initShuvi(_a) {
|
|
37
|
-
var { config } = _a, options = __rest(_a, ["config"]);
|
|
38
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
var { config } = _a, options = __rest(_a, ["config"]);
|
|
39
39
|
const { plugins, presets } = config, restConfig = __rest(config, ["plugins", "presets"]);
|
|
40
40
|
const shuvi = yield (0, service_1.getApi)(Object.assign(Object.assign({}, options), { plugins,
|
|
41
41
|
presets, config: restConfig, platform: getPlatform(), normalizePlatformConfig: config_1.normalizePlatformConfig }));
|
|
@@ -45,4 +45,3 @@ function initShuvi(_a) {
|
|
|
45
45
|
return shuvi;
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
exports.initShuvi = initShuvi;
|
package/lib/tasks/build.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export interface IBuildOptions {
|
|
|
5
5
|
target?: 'spa' | 'ssr';
|
|
6
6
|
configFile?: string | false;
|
|
7
7
|
}
|
|
8
|
-
export declare function build(options: IBuildOptions): Promise<import("@shuvi/service
|
|
8
|
+
export declare function build(options: IBuildOptions): Promise<import("@shuvi/service").Api>;
|
package/lib/tasks/build.js
CHANGED
|
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.build =
|
|
38
|
+
exports.build = build;
|
|
39
39
|
const path = __importStar(require("path"));
|
|
40
40
|
const fs = __importStar(require("fs-extra"));
|
|
41
41
|
const formatWebpackMessages_1 = __importDefault(require("@shuvi/toolpack/lib/utils/formatWebpackMessages"));
|
|
@@ -98,4 +98,3 @@ function build(options) {
|
|
|
98
98
|
return api;
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
-
exports.build = build;
|
package/lib/types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IServicePhase, IServiceMode } from '@shuvi/service';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type ShuviPhase = IServicePhase;
|
|
3
|
+
export type ShuviMode = IServiceMode;
|
package/lib/utils.js
CHANGED
|
@@ -26,7 +26,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.color = exports.useColor =
|
|
29
|
+
exports.color = exports.useColor = void 0;
|
|
30
|
+
exports.getPackageInfo = getPackageInfo;
|
|
31
|
+
exports.getProjectDir = getProjectDir;
|
|
32
|
+
exports.printStartupInfo = printStartupInfo;
|
|
30
33
|
const fs_1 = require("fs");
|
|
31
34
|
const path = __importStar(require("path"));
|
|
32
35
|
const logger_1 = __importDefault(require("@shuvi/utils/logger"));
|
|
@@ -36,7 +39,6 @@ const package_json_1 = __importDefault(require("../package.json"));
|
|
|
36
39
|
function getPackageInfo() {
|
|
37
40
|
return package_json_1.default;
|
|
38
41
|
}
|
|
39
|
-
exports.getPackageInfo = getPackageInfo;
|
|
40
42
|
function getProjectDir(dir) {
|
|
41
43
|
const dirPath = path.resolve(dir || '.');
|
|
42
44
|
if (!(0, fs_1.existsSync)(dirPath)) {
|
|
@@ -45,7 +47,6 @@ function getProjectDir(dir) {
|
|
|
45
47
|
}
|
|
46
48
|
return dirPath;
|
|
47
49
|
}
|
|
48
|
-
exports.getProjectDir = getProjectDir;
|
|
49
50
|
function printStartupInfo({ startTime, readyTime, host, port }) {
|
|
50
51
|
const appUrl = `http://${host === '0.0.0.0' ? 'localhost' : host}:${port}`;
|
|
51
52
|
const readyMsg = chalk_1.default.dim(`ready in ${chalk_1.default.white(chalk_1.default.bold(Math.ceil(readyTime - startTime)))} ms`);
|
|
@@ -53,7 +54,6 @@ function printStartupInfo({ startTime, readyTime, host, port }) {
|
|
|
53
54
|
const colorUrl = (url) => chalk_1.default.cyan(url.replace(/:(\d+)\//, (_, port) => `:${chalk_1.default.bold(port)}/`));
|
|
54
55
|
logger_1.default.info(` ${chalk_1.default.green('➜')} ${chalk_1.default.bold('Local')}: ${colorUrl(appUrl)} \n`);
|
|
55
56
|
}
|
|
56
|
-
exports.printStartupInfo = printStartupInfo;
|
|
57
57
|
/**
|
|
58
58
|
* ref: https://github.com/remix-run/remix/blob/main/packages/remix-dev/colors.ts
|
|
59
59
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shuvi",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.56",
|
|
4
4
|
"description": "Full Stack Web development framework.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"lib"
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
|
-
"dev": "tsc -p tsconfig.build.json -
|
|
21
|
+
"dev": "tsc -p tsconfig.build.json -w",
|
|
22
22
|
"prebuild": "rimraf lib",
|
|
23
|
-
"build": "tsc -p tsconfig.build.json
|
|
23
|
+
"build": "tsc -p tsconfig.build.json"
|
|
24
24
|
},
|
|
25
25
|
"engines": {
|
|
26
26
|
"node": ">= 16.0.0"
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"find-up": "4.1.0",
|
|
31
31
|
"semver": "7.3.2",
|
|
32
32
|
"cli-select": "1.1.2",
|
|
33
|
-
"@shuvi/platform-shared": "1.0.
|
|
34
|
-
"@shuvi/platform-web": "1.0.
|
|
35
|
-
"@shuvi/service": "1.0.
|
|
36
|
-
"@shuvi/shared": "1.0.
|
|
37
|
-
"@shuvi/toolpack": "1.0.
|
|
38
|
-
"@shuvi/utils": "1.0.
|
|
39
|
-
"@shuvi/reporters": "1.0.
|
|
33
|
+
"@shuvi/platform-shared": "1.0.56",
|
|
34
|
+
"@shuvi/platform-web": "1.0.56",
|
|
35
|
+
"@shuvi/service": "1.0.56",
|
|
36
|
+
"@shuvi/shared": "1.0.56",
|
|
37
|
+
"@shuvi/toolpack": "1.0.56",
|
|
38
|
+
"@shuvi/utils": "1.0.56",
|
|
39
|
+
"@shuvi/reporters": "1.0.56",
|
|
40
40
|
"cli-highlight": "^2.1.9",
|
|
41
41
|
"commander": "10.0.0",
|
|
42
42
|
"cross-spawn": "7.0.3",
|