@slidev/cli 0.48.0-beta.16 → 0.48.0-beta.18
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/{build-BFCSVURA.mjs → build-VF5GEGY5.mjs} +3 -4
- package/dist/chunk-755W4UQR.mjs +2101 -0
- package/dist/{chunk-6SJIO2WJ.mjs → chunk-CVKVQYXH.mjs} +4 -8
- package/dist/chunk-NOI2WLJK.mjs +185 -0
- package/dist/cli.mjs +6 -7
- package/dist/{export-JD32O5W6.mjs → export-FEKJLPIJ.mjs} +1 -2
- package/dist/index.mjs +3 -4
- package/dist/{unocss-XALM635U.mjs → unocss-M5KPNI4Z.mjs} +0 -1
- package/package.json +7 -7
- package/dist/chunk-BXO7ZPPU.mjs +0 -30
- package/dist/chunk-G3BP3FUT.mjs +0 -5551
- package/dist/chunk-TMXTXTYI.mjs +0 -4553
|
@@ -2,17 +2,13 @@ import {
|
|
|
2
2
|
ViteSlidevPlugin,
|
|
3
3
|
checkEngine,
|
|
4
4
|
mergeViteConfigs,
|
|
5
|
-
require_semver,
|
|
6
5
|
version
|
|
7
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-755W4UQR.mjs";
|
|
8
7
|
import {
|
|
9
8
|
createResolver,
|
|
10
9
|
getRoots,
|
|
11
10
|
resolveEntry
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import {
|
|
14
|
-
__toESM
|
|
15
|
-
} from "./chunk-BXO7ZPPU.mjs";
|
|
11
|
+
} from "./chunk-NOI2WLJK.mjs";
|
|
16
12
|
|
|
17
13
|
// node/server.ts
|
|
18
14
|
import { join } from "node:path";
|
|
@@ -54,9 +50,9 @@ async function createServer(options, viteConfig = {}, serverOptions = {}) {
|
|
|
54
50
|
import * as parser from "@slidev/parser/fs";
|
|
55
51
|
|
|
56
52
|
// node/themes.ts
|
|
57
|
-
var import_semver = __toESM(require_semver());
|
|
58
53
|
import { join as join2 } from "node:path";
|
|
59
54
|
import fs from "fs-extra";
|
|
55
|
+
import { satisfies } from "semver";
|
|
60
56
|
var officialThemes = {
|
|
61
57
|
"none": "",
|
|
62
58
|
"default": "@slidev/theme-default",
|
|
@@ -71,7 +67,7 @@ async function getThemeMeta(name, root) {
|
|
|
71
67
|
if (!fs.existsSync(path))
|
|
72
68
|
return {};
|
|
73
69
|
const { slidev = {}, engines = {} } = await fs.readJSON(path);
|
|
74
|
-
if (engines.slidev && !
|
|
70
|
+
if (engines.slidev && !satisfies(version, engines.slidev, { includePrerelease: true }))
|
|
75
71
|
throw new Error(`[slidev] theme "${name}" requires Slidev version range "${engines.slidev}" but found "${version}"`);
|
|
76
72
|
return slidev;
|
|
77
73
|
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// node/resolver.ts
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import * as fs from "node:fs";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { ensurePrefix, slash } from "@antfu/utils";
|
|
7
|
+
import isInstalledGlobally from "is-installed-globally";
|
|
8
|
+
import { resolveGlobal } from "resolve-global";
|
|
9
|
+
import { findClosestPkgJsonPath, findDepPkgJsonPath } from "vitefu";
|
|
10
|
+
import { resolvePath } from "mlly";
|
|
11
|
+
import globalDirs from "global-directory";
|
|
12
|
+
import prompts from "prompts";
|
|
13
|
+
import { parseNi, run } from "@antfu/ni";
|
|
14
|
+
import { underline, yellow } from "kolorist";
|
|
15
|
+
function toAtFS(path) {
|
|
16
|
+
return `/@fs${ensurePrefix("/", slash(path))}`;
|
|
17
|
+
}
|
|
18
|
+
async function resolveImportPath(importName, ensure = false) {
|
|
19
|
+
try {
|
|
20
|
+
return await resolvePath(importName, {
|
|
21
|
+
url: fileURLToPath(import.meta.url)
|
|
22
|
+
});
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
if (isInstalledGlobally) {
|
|
26
|
+
try {
|
|
27
|
+
return resolveGlobal(importName);
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (ensure)
|
|
32
|
+
throw new Error(`Failed to resolve package "${importName}"`);
|
|
33
|
+
}
|
|
34
|
+
async function findPkgRoot(dep, parent, ensure = false) {
|
|
35
|
+
const pkgJsonPath = await findDepPkgJsonPath(dep, parent);
|
|
36
|
+
const path = pkgJsonPath ? dirname(pkgJsonPath) : isInstalledGlobally ? findGlobalPkgRoot(dep, false) : void 0;
|
|
37
|
+
if (ensure && !path)
|
|
38
|
+
throw new Error(`Failed to resolve package "${dep}"`);
|
|
39
|
+
return path;
|
|
40
|
+
}
|
|
41
|
+
async function findGlobalPkgRoot(name, ensure = false) {
|
|
42
|
+
const yarnPath = join(globalDirs.yarn.packages, name);
|
|
43
|
+
if (fs.existsSync(`${yarnPath}/package.json`))
|
|
44
|
+
return yarnPath;
|
|
45
|
+
const npmPath = join(globalDirs.npm.packages, name);
|
|
46
|
+
if (fs.existsSync(`${npmPath}/package.json`))
|
|
47
|
+
return npmPath;
|
|
48
|
+
if (ensure)
|
|
49
|
+
throw new Error(`Failed to resolve global package "${name}"`);
|
|
50
|
+
}
|
|
51
|
+
async function resolveEntry(entryRaw, roots) {
|
|
52
|
+
if (!fs.existsSync(entryRaw) && !entryRaw.endsWith(".md") && !/\/\\/.test(entryRaw))
|
|
53
|
+
entryRaw += ".md";
|
|
54
|
+
const entry = entryRaw.startsWith("@/") ? join(roots.userRoot, entryRaw.slice(2)) : resolve(process.cwd(), entryRaw);
|
|
55
|
+
if (!fs.existsSync(entry)) {
|
|
56
|
+
const { create } = await prompts({
|
|
57
|
+
name: "create",
|
|
58
|
+
type: "confirm",
|
|
59
|
+
initial: "Y",
|
|
60
|
+
message: `Entry file ${yellow(`"${entry}"`)} does not exist, do you want to create it?`
|
|
61
|
+
});
|
|
62
|
+
if (create)
|
|
63
|
+
fs.copyFileSync(resolve(roots.cliRoot, "template.md"), entry);
|
|
64
|
+
else
|
|
65
|
+
process.exit(0);
|
|
66
|
+
}
|
|
67
|
+
return entry;
|
|
68
|
+
}
|
|
69
|
+
function createResolver(type, officials) {
|
|
70
|
+
async function promptForInstallation(pkgName) {
|
|
71
|
+
const { confirm } = await prompts({
|
|
72
|
+
name: "confirm",
|
|
73
|
+
initial: "Y",
|
|
74
|
+
type: "confirm",
|
|
75
|
+
message: `The ${type} "${pkgName}" was not found ${underline(isInstalledGlobally ? "globally" : "in your project")}, do you want to install it now?`
|
|
76
|
+
});
|
|
77
|
+
if (!confirm)
|
|
78
|
+
process.exit(1);
|
|
79
|
+
if (isInstalledGlobally)
|
|
80
|
+
await run(parseNi, ["-g", pkgName]);
|
|
81
|
+
else
|
|
82
|
+
await run(parseNi, [pkgName]);
|
|
83
|
+
}
|
|
84
|
+
return async function(name, importer) {
|
|
85
|
+
const { userRoot } = await getRoots();
|
|
86
|
+
if (name === "none")
|
|
87
|
+
return ["", null];
|
|
88
|
+
if (name[0] === "/")
|
|
89
|
+
return [name, name];
|
|
90
|
+
if (name.startsWith("@/"))
|
|
91
|
+
return [name, join(userRoot, name.slice(2))];
|
|
92
|
+
if (name[0] === "." || name[0] !== "@" && name.includes("/"))
|
|
93
|
+
return [name, join(dirname(importer), name)];
|
|
94
|
+
if (name.startsWith(`@slidev/${type}-`) || name.startsWith(`slidev-${type}-`)) {
|
|
95
|
+
const pkgRoot = await findPkgRoot(name, importer);
|
|
96
|
+
if (!pkgRoot)
|
|
97
|
+
await promptForInstallation(name);
|
|
98
|
+
return [name, await findPkgRoot(name, importer, true)];
|
|
99
|
+
}
|
|
100
|
+
{
|
|
101
|
+
const possiblePkgNames = [
|
|
102
|
+
`@slidev/${type}-${name}`,
|
|
103
|
+
`slidev-${type}-${name}`,
|
|
104
|
+
name
|
|
105
|
+
];
|
|
106
|
+
for (const pkgName2 of possiblePkgNames) {
|
|
107
|
+
const pkgRoot = await findPkgRoot(pkgName2, importer);
|
|
108
|
+
if (pkgRoot)
|
|
109
|
+
return [pkgName2, pkgRoot];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const pkgName = officials[name] ?? (name[0] === "@" ? name : `slidev-${type}-${name}`);
|
|
113
|
+
await promptForInstallation(pkgName);
|
|
114
|
+
return [pkgName, await findPkgRoot(pkgName, importer, true)];
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
async function getUserRoot() {
|
|
118
|
+
const pkgJsonPath = await findClosestPkgJsonPath(process.cwd());
|
|
119
|
+
return pkgJsonPath ? dirname(pkgJsonPath) : process.cwd();
|
|
120
|
+
}
|
|
121
|
+
function getUserPkgJson(userRoot) {
|
|
122
|
+
const path = resolve(userRoot, "package.json");
|
|
123
|
+
if (fs.existsSync(path))
|
|
124
|
+
return JSON.parse(fs.readFileSync(path, "utf-8"));
|
|
125
|
+
return {};
|
|
126
|
+
}
|
|
127
|
+
function hasWorkspacePackageJSON(root) {
|
|
128
|
+
const path = join(root, "package.json");
|
|
129
|
+
try {
|
|
130
|
+
fs.accessSync(path, fs.constants.R_OK);
|
|
131
|
+
} catch {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
const content = JSON.parse(fs.readFileSync(path, "utf-8")) || {};
|
|
135
|
+
return !!content.workspaces;
|
|
136
|
+
}
|
|
137
|
+
function hasRootFile(root) {
|
|
138
|
+
const ROOT_FILES = [
|
|
139
|
+
// '.git',
|
|
140
|
+
// https://pnpm.js.org/workspaces/
|
|
141
|
+
"pnpm-workspace.yaml"
|
|
142
|
+
// https://rushjs.io/pages/advanced/config_files/
|
|
143
|
+
// 'rush.json',
|
|
144
|
+
// https://nx.dev/latest/react/getting-started/nx-setup
|
|
145
|
+
// 'workspace.json',
|
|
146
|
+
// 'nx.json'
|
|
147
|
+
];
|
|
148
|
+
return ROOT_FILES.some((file) => fs.existsSync(join(root, file)));
|
|
149
|
+
}
|
|
150
|
+
function searchForWorkspaceRoot(current, root = current) {
|
|
151
|
+
if (hasRootFile(current))
|
|
152
|
+
return current;
|
|
153
|
+
if (hasWorkspacePackageJSON(current))
|
|
154
|
+
return current;
|
|
155
|
+
const dir = dirname(current);
|
|
156
|
+
if (!dir || dir === current)
|
|
157
|
+
return root;
|
|
158
|
+
return searchForWorkspaceRoot(dir, root);
|
|
159
|
+
}
|
|
160
|
+
var rootsInfo = null;
|
|
161
|
+
async function getRoots() {
|
|
162
|
+
if (rootsInfo)
|
|
163
|
+
return rootsInfo;
|
|
164
|
+
const cliRoot = fileURLToPath(new URL("..", import.meta.url));
|
|
165
|
+
const clientRoot = await findPkgRoot("@slidev/client", cliRoot, true);
|
|
166
|
+
const userRoot = await getUserRoot();
|
|
167
|
+
const userPkgJson = getUserPkgJson(userRoot);
|
|
168
|
+
const userWorkspaceRoot = searchForWorkspaceRoot(userRoot);
|
|
169
|
+
rootsInfo = {
|
|
170
|
+
cliRoot,
|
|
171
|
+
clientRoot,
|
|
172
|
+
userRoot,
|
|
173
|
+
userPkgJson,
|
|
174
|
+
userWorkspaceRoot
|
|
175
|
+
};
|
|
176
|
+
return rootsInfo;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export {
|
|
180
|
+
toAtFS,
|
|
181
|
+
resolveImportPath,
|
|
182
|
+
resolveEntry,
|
|
183
|
+
createResolver,
|
|
184
|
+
getRoots
|
|
185
|
+
};
|
package/dist/cli.mjs
CHANGED
|
@@ -5,17 +5,16 @@ import {
|
|
|
5
5
|
resolveAddons,
|
|
6
6
|
resolveOptions,
|
|
7
7
|
resolveTheme
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-CVKVQYXH.mjs";
|
|
9
9
|
import {
|
|
10
10
|
version
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-755W4UQR.mjs";
|
|
12
12
|
import {
|
|
13
13
|
loadSetups
|
|
14
14
|
} from "./chunk-O6TYYGU6.mjs";
|
|
15
15
|
import {
|
|
16
16
|
getRoots
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-BXO7ZPPU.mjs";
|
|
17
|
+
} from "./chunk-NOI2WLJK.mjs";
|
|
19
18
|
|
|
20
19
|
// node/cli.ts
|
|
21
20
|
import path from "node:path";
|
|
@@ -277,7 +276,7 @@ cli.command(
|
|
|
277
276
|
}).strict().help(),
|
|
278
277
|
async (args) => {
|
|
279
278
|
const { entry, theme, watch, base, download, out, inspect } = args;
|
|
280
|
-
const { build } = await import("./build-
|
|
279
|
+
const { build } = await import("./build-VF5GEGY5.mjs");
|
|
281
280
|
for (const entryFile of entry) {
|
|
282
281
|
const options = await resolveOptions({ entry: entryFile, theme, inspect }, "build");
|
|
283
282
|
if (download && !options.data.config.download)
|
|
@@ -352,7 +351,7 @@ cli.command(
|
|
|
352
351
|
(args) => exportOptions(commonOptions(args)).strict().help(),
|
|
353
352
|
async (args) => {
|
|
354
353
|
const { entry, theme } = args;
|
|
355
|
-
const { exportSlides, getExportOptions } = await import("./export-
|
|
354
|
+
const { exportSlides, getExportOptions } = await import("./export-FEKJLPIJ.mjs");
|
|
356
355
|
const port = await getPort(12445);
|
|
357
356
|
for (const entryFile of entry) {
|
|
358
357
|
const options = await resolveOptions({ entry: entryFile, theme }, "export");
|
|
@@ -396,7 +395,7 @@ cli.command(
|
|
|
396
395
|
output,
|
|
397
396
|
timeout
|
|
398
397
|
}) => {
|
|
399
|
-
const { exportNotes } = await import("./export-
|
|
398
|
+
const { exportNotes } = await import("./export-FEKJLPIJ.mjs");
|
|
400
399
|
const port = await getPort(12445);
|
|
401
400
|
for (const entryFile of entry) {
|
|
402
401
|
const options = await resolveOptions({ entry: entryFile }, "export");
|
package/dist/index.mjs
CHANGED
|
@@ -2,13 +2,12 @@ import {
|
|
|
2
2
|
createServer,
|
|
3
3
|
parser,
|
|
4
4
|
resolveOptions
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-CVKVQYXH.mjs";
|
|
6
6
|
import {
|
|
7
7
|
ViteSlidevPlugin
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-755W4UQR.mjs";
|
|
9
9
|
import "./chunk-O6TYYGU6.mjs";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-BXO7ZPPU.mjs";
|
|
10
|
+
import "./chunk-NOI2WLJK.mjs";
|
|
12
11
|
export {
|
|
13
12
|
ViteSlidevPlugin,
|
|
14
13
|
createServer,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/cli",
|
|
3
|
-
"version": "0.48.0-beta.
|
|
3
|
+
"version": "0.48.0-beta.18",
|
|
4
4
|
"description": "Presentation slides for developers",
|
|
5
5
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
+
"@antfu/ni": "^0.21.12",
|
|
45
46
|
"@antfu/utils": "^0.7.7",
|
|
46
47
|
"@iconify-json/carbon": "^1.1.30",
|
|
47
48
|
"@iconify-json/ph": "^1.1.11",
|
|
@@ -83,9 +84,9 @@
|
|
|
83
84
|
"prismjs": "^1.29.0",
|
|
84
85
|
"prompts": "^2.4.2",
|
|
85
86
|
"public-ip": "^6.0.1",
|
|
86
|
-
"resolve": "^1.22.8",
|
|
87
87
|
"resolve-from": "^5.0.0",
|
|
88
88
|
"resolve-global": "^2.0.0",
|
|
89
|
+
"semver": "^7.6.0",
|
|
89
90
|
"shiki": "^1.1.7",
|
|
90
91
|
"shiki-magic-move": "^0.1.0",
|
|
91
92
|
"sirv": "^2.0.4",
|
|
@@ -104,14 +105,13 @@
|
|
|
104
105
|
"vitefu": "^0.2.5",
|
|
105
106
|
"vue": "^3.4.20",
|
|
106
107
|
"yargs": "^17.7.2",
|
|
107
|
-
"@slidev/client": "0.48.0-beta.
|
|
108
|
-
"@slidev/
|
|
109
|
-
"@slidev/
|
|
108
|
+
"@slidev/client": "0.48.0-beta.18",
|
|
109
|
+
"@slidev/types": "0.48.0-beta.18",
|
|
110
|
+
"@slidev/parser": "0.48.0-beta.18"
|
|
110
111
|
},
|
|
111
112
|
"devDependencies": {
|
|
112
113
|
"@hedgedoc/markdown-it-plugins": "^2.1.4",
|
|
113
|
-
"@types/plantuml-encoder": "^1.4.2"
|
|
114
|
-
"semver": "^7.6.0"
|
|
114
|
+
"@types/plantuml-encoder": "^1.4.2"
|
|
115
115
|
},
|
|
116
116
|
"scripts": {
|
|
117
117
|
"build": "rimraf dist && tsup node/index.ts node/cli.ts",
|
package/dist/chunk-BXO7ZPPU.mjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
-
mod
|
|
25
|
-
));
|
|
26
|
-
|
|
27
|
-
export {
|
|
28
|
-
__commonJS,
|
|
29
|
-
__toESM
|
|
30
|
-
};
|