supaslidev 0.2.0 → 0.3.0
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/app/app.config.ts +1 -1
- package/app/components/PresentationCard.vue +30 -30
- package/app/components/PresentationListItem.vue +26 -4
- package/app/composables/useDeployMode.ts +18 -0
- package/app/pages/index.vue +115 -79
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.js +17013 -13527
- package/dist/config.js +1 -2
- package/dist/index.js +1 -2
- package/dist/module.d.ts +3 -3
- package/dist/module.js +3 -9160
- package/nuxt.config.ts +1 -0
- package/package.json +7 -7
- package/server/api/presentations/import.post.ts +2 -7
- package/server/api/presentations/upload.post.ts +2 -7
- package/src/cli/commands/deploy.ts +236 -63
- package/src/cli/commands/import.ts +3 -0
- package/src/cli/index.ts +15 -10
- package/src/cli/utils.ts +0 -47
- package/src/module.ts +4 -1
- package/src/shared/catalog.ts +5 -19
- package/src/shared/index.ts +1 -2
- package/dist/prompt.js +0 -847
package/nuxt.config.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supaslidev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "CLI toolkit for managing Supaslidev presentations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"slidev",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@nuxt/ui": "^4.4.0",
|
|
51
|
-
"commander": "^
|
|
51
|
+
"commander": "^14.0.0",
|
|
52
52
|
"js-yaml": "^4.1.1",
|
|
53
53
|
"nuxt": "^4.4.2",
|
|
54
54
|
"tailwindcss": "^4.1.18",
|
|
@@ -58,13 +58,13 @@
|
|
|
58
58
|
"@nuxt/kit": "^4.4.2",
|
|
59
59
|
"@nuxt/schema": "^4.4.2",
|
|
60
60
|
"@types/js-yaml": "^4.0.9",
|
|
61
|
-
"@types/node": "^
|
|
62
|
-
"tsdown": "^0.
|
|
61
|
+
"@types/node": "^24.0.0",
|
|
62
|
+
"tsdown": "^0.21.6",
|
|
63
63
|
"tsx": "^4.19.0",
|
|
64
|
-
"typescript": "^
|
|
64
|
+
"typescript": "^6.0.0",
|
|
65
65
|
"vitest": "^4.0.0",
|
|
66
|
-
"vue-tsc": "^
|
|
67
|
-
"create-supaslidev": "^0.
|
|
66
|
+
"vue-tsc": "^3.0.0",
|
|
67
|
+
"create-supaslidev": "^0.3.0"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"dev": "nuxt dev",
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
validateSourceDirectoryResult,
|
|
6
6
|
SLUG_REGEX,
|
|
7
7
|
copyDirectorySelective,
|
|
8
|
-
convertToCatalogDependencies,
|
|
9
8
|
hasSharedPackage,
|
|
10
9
|
addSharedDependencyToPackageJson,
|
|
11
10
|
addSharedAddonToSlides,
|
|
11
|
+
normalizeVueToCatalog,
|
|
12
12
|
regeneratePresentationsJson,
|
|
13
13
|
} from '../../../src/shared/index.js';
|
|
14
14
|
import { getProjectRoot, getPresentationsDir, getPresentationsJsonPath } from '../../utils/config';
|
|
@@ -82,12 +82,7 @@ export default defineEventHandler(async (event) => {
|
|
|
82
82
|
export: 'slidev export',
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
packageJson.dependencies = convertToCatalogDependencies(packageJson.dependencies);
|
|
87
|
-
}
|
|
88
|
-
if (packageJson.devDependencies) {
|
|
89
|
-
packageJson.devDependencies = convertToCatalogDependencies(packageJson.devDependencies);
|
|
90
|
-
}
|
|
85
|
+
normalizeVueToCatalog(packageJson);
|
|
91
86
|
|
|
92
87
|
const sharedExists = hasSharedPackage(projectRoot);
|
|
93
88
|
if (sharedExists) {
|
|
@@ -4,10 +4,10 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
|
4
4
|
import {
|
|
5
5
|
SLUG_REGEX,
|
|
6
6
|
shouldIgnore,
|
|
7
|
-
convertToCatalogDependencies,
|
|
8
7
|
hasSharedPackage,
|
|
9
8
|
addSharedDependencyToPackageJson,
|
|
10
9
|
addSharedAddonToSlides,
|
|
10
|
+
normalizeVueToCatalog,
|
|
11
11
|
regeneratePresentationsJson,
|
|
12
12
|
} from '../../../src/shared/index.js';
|
|
13
13
|
import { getProjectRoot, getPresentationsDir, getPresentationsJsonPath } from '../../utils/config';
|
|
@@ -120,12 +120,7 @@ export default defineEventHandler(async (event) => {
|
|
|
120
120
|
export: 'slidev export',
|
|
121
121
|
};
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
packageJson.dependencies = convertToCatalogDependencies(packageJson.dependencies);
|
|
125
|
-
}
|
|
126
|
-
if (packageJson.devDependencies) {
|
|
127
|
-
packageJson.devDependencies = convertToCatalogDependencies(packageJson.devDependencies);
|
|
128
|
-
}
|
|
123
|
+
normalizeVueToCatalog(packageJson);
|
|
129
124
|
|
|
130
125
|
const sharedExists = hasSharedPackage(projectRoot);
|
|
131
126
|
if (sharedExists) {
|
|
@@ -1,90 +1,263 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { existsSync, mkdirSync, cpSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
printAvailablePresentations,
|
|
8
|
-
createVercelConfig,
|
|
9
|
-
createNetlifyConfig,
|
|
10
|
-
createDeployPackageJson,
|
|
11
|
-
} from '../utils.js';
|
|
2
|
+
import { join, dirname, resolve } from 'node:path';
|
|
3
|
+
import { existsSync, mkdirSync, cpSync, rmSync, writeFileSync, readFileSync } from 'node:fs';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { findProjectRoot, getPresentations } from '../utils.js';
|
|
6
|
+
import { regeneratePresentationsJson } from '../../shared/presentations.js';
|
|
12
7
|
|
|
13
8
|
export interface DeployOptions {
|
|
14
9
|
output?: string;
|
|
10
|
+
base?: string;
|
|
15
11
|
}
|
|
16
12
|
|
|
17
|
-
|
|
13
|
+
function findSupaslidevPackageRoot(): string {
|
|
14
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
|
|
16
|
+
while (dir !== dirname(dir)) {
|
|
17
|
+
const packageJsonPath = join(dir, 'package.json');
|
|
18
|
+
if (existsSync(packageJsonPath)) {
|
|
19
|
+
try {
|
|
20
|
+
const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
21
|
+
if (pkg.name === 'supaslidev') {
|
|
22
|
+
return dir;
|
|
23
|
+
}
|
|
24
|
+
} catch {
|
|
25
|
+
// Continue searching
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
dir = dirname(dir);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
throw new Error('Could not find supaslidev package root');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function runCommand(
|
|
35
|
+
command: string,
|
|
36
|
+
args: string[],
|
|
37
|
+
options: { cwd: string; env?: Record<string, string | undefined> },
|
|
38
|
+
): Promise<void> {
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
const child = spawn(command, args, {
|
|
41
|
+
cwd: options.cwd,
|
|
42
|
+
stdio: 'inherit',
|
|
43
|
+
shell: process.platform === 'win32',
|
|
44
|
+
env: options.env ?? process.env,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
child.on('error', (err) => {
|
|
48
|
+
reject(new Error(`Failed to run ${command}: ${err.message}`));
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
child.on('close', (code) => {
|
|
52
|
+
if (code !== 0) {
|
|
53
|
+
reject(new Error(`${command} exited with code ${code}`));
|
|
54
|
+
} else {
|
|
55
|
+
resolve();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function findNuxtBin(
|
|
62
|
+
projectRoot: string,
|
|
63
|
+
supaslidevRoot: string,
|
|
64
|
+
): { command: string; args: string[] } {
|
|
65
|
+
const projectNuxtBin = join(projectRoot, 'node_modules', '.bin', 'nuxt');
|
|
66
|
+
const packageNuxtBin = join(supaslidevRoot, 'node_modules', '.bin', 'nuxt');
|
|
67
|
+
|
|
68
|
+
if (existsSync(projectNuxtBin)) {
|
|
69
|
+
return { command: projectNuxtBin, args: [] };
|
|
70
|
+
} else if (existsSync(packageNuxtBin)) {
|
|
71
|
+
return { command: packageNuxtBin, args: [] };
|
|
72
|
+
}
|
|
73
|
+
return { command: 'npx', args: ['nuxt'] };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function createVercelConfig(basePath: string, presentations: string[]): string {
|
|
77
|
+
const rewrites = presentations.map((id) => ({
|
|
78
|
+
source: `${basePath}presentations/${id}/(.*)`,
|
|
79
|
+
destination: `${basePath}presentations/${id}/index.html`,
|
|
80
|
+
}));
|
|
81
|
+
|
|
82
|
+
rewrites.push({
|
|
83
|
+
source: `${basePath}(.*)`,
|
|
84
|
+
destination: `${basePath}index.html`,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return JSON.stringify({ rewrites }, null, 2);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function createNetlifyConfig(basePath: string, presentations: string[]): string {
|
|
91
|
+
const lines = ['# Auto-generated by supaslidev deploy', ''];
|
|
92
|
+
|
|
93
|
+
for (const id of presentations) {
|
|
94
|
+
lines.push('[[redirects]]');
|
|
95
|
+
lines.push(` from = "${basePath}presentations/${id}/*"`);
|
|
96
|
+
lines.push(` to = "${basePath}presentations/${id}/index.html"`);
|
|
97
|
+
lines.push(' status = 200');
|
|
98
|
+
lines.push('');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
lines.push('[[redirects]]');
|
|
102
|
+
lines.push(` from = "${basePath}*"`);
|
|
103
|
+
lines.push(` to = "${basePath}index.html"`);
|
|
104
|
+
lines.push(' status = 200');
|
|
105
|
+
lines.push('');
|
|
106
|
+
|
|
107
|
+
return lines.join('\n');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function createDeployPackageJson(): string {
|
|
111
|
+
return JSON.stringify(
|
|
112
|
+
{
|
|
113
|
+
name: 'supaslidev-deploy',
|
|
114
|
+
private: true,
|
|
115
|
+
scripts: {
|
|
116
|
+
start: 'npx serve .',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
null,
|
|
120
|
+
2,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export async function deploy(options: DeployOptions = {}): Promise<void> {
|
|
18
125
|
const projectRoot = findProjectRoot();
|
|
19
126
|
|
|
20
127
|
if (!projectRoot) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
128
|
+
throw new Error(
|
|
129
|
+
'Could not find a Supaslidev project. Make sure you are in a directory with a "presentations" folder.',
|
|
130
|
+
);
|
|
24
131
|
}
|
|
25
132
|
|
|
26
133
|
const presentationsDir = join(projectRoot, 'presentations');
|
|
27
|
-
const deployDir = join(projectRoot, 'deploy');
|
|
28
134
|
const presentations = getPresentations(presentationsDir);
|
|
29
135
|
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
printAvailablePresentations(presentations);
|
|
33
|
-
process.exit(1);
|
|
136
|
+
if (presentations.length === 0) {
|
|
137
|
+
throw new Error('No presentations found in the presentations directory.');
|
|
34
138
|
}
|
|
35
139
|
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
140
|
+
const outputDir = resolve(options.output ?? join(projectRoot, 'deploy'));
|
|
141
|
+
const resolvedProjectRoot = resolve(projectRoot);
|
|
142
|
+
|
|
143
|
+
// Safety check: prevent deleting directories outside the project root
|
|
144
|
+
if (!outputDir.startsWith(resolvedProjectRoot)) {
|
|
145
|
+
throw new Error(
|
|
146
|
+
`Output directory "${outputDir}" is outside the project root "${resolvedProjectRoot}". Use a path within your project.`,
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
const basePath = (options.base ?? '/').replace(/\/*$/, '/');
|
|
150
|
+
|
|
151
|
+
const supaslidevRoot = findSupaslidevPackageRoot();
|
|
152
|
+
const presentationsJsonPath = join(projectRoot, '.supaslidev', 'presentations.json');
|
|
40
153
|
|
|
41
154
|
console.log('\n' + '='.repeat(50));
|
|
42
|
-
console.log(
|
|
43
|
-
console.log('='.repeat(50)
|
|
155
|
+
console.log(' Supaslidev Deploy');
|
|
156
|
+
console.log('='.repeat(50));
|
|
157
|
+
console.log(`\n Project: ${projectRoot}`);
|
|
158
|
+
console.log(` Output: ${outputDir}`);
|
|
159
|
+
console.log(` Base: ${basePath}`);
|
|
160
|
+
console.log(` Presentations: ${presentations.join(', ')}`);
|
|
161
|
+
console.log('');
|
|
44
162
|
|
|
45
|
-
|
|
163
|
+
// Step 1: Build each presentation with slidev build --base
|
|
164
|
+
console.log(`Step 1/${4}: Building ${presentations.length} presentation(s)...\n`);
|
|
46
165
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
shell: true,
|
|
51
|
-
});
|
|
166
|
+
for (const id of presentations) {
|
|
167
|
+
const presentationDir = join(presentationsDir, id);
|
|
168
|
+
const presentationBase = `${basePath}presentations/${id}/`;
|
|
52
169
|
|
|
53
|
-
|
|
54
|
-
console.error(`Failed to build presentation: ${err.message}`);
|
|
55
|
-
process.exit(1);
|
|
56
|
-
});
|
|
170
|
+
console.log(` Building: ${id} (base: ${presentationBase})`);
|
|
57
171
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
172
|
+
await runCommand('npx', ['slidev', 'build', '--base', presentationBase], {
|
|
173
|
+
cwd: presentationDir,
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
console.log(` Done: ${id}\n`);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Step 2: Generate presentations.json
|
|
180
|
+
console.log('Step 2/4: Generating presentations.json...\n');
|
|
181
|
+
|
|
182
|
+
regeneratePresentationsJson(presentationsDir, presentationsJsonPath);
|
|
183
|
+
|
|
184
|
+
// Step 3: Build the Nuxt dashboard in static mode
|
|
185
|
+
console.log('Step 3/4: Building dashboard...\n');
|
|
63
186
|
|
|
64
|
-
|
|
187
|
+
const nuxt = findNuxtBin(projectRoot, supaslidevRoot);
|
|
65
188
|
|
|
66
|
-
|
|
67
|
-
|
|
189
|
+
const nuxtEnv: Record<string, string | undefined> = {
|
|
190
|
+
...process.env,
|
|
191
|
+
NODE_ENV: 'production',
|
|
192
|
+
SUPASLIDEV_PROJECT_ROOT: projectRoot,
|
|
193
|
+
SUPASLIDEV_PRESENTATIONS_DIR: presentationsDir,
|
|
194
|
+
NUXT_PUBLIC_DEPLOY_MODE: 'true',
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// Strip test runner env vars
|
|
198
|
+
for (const key of Object.keys(nuxtEnv)) {
|
|
199
|
+
if (key === 'VITEST' || key.startsWith('VITEST_') || key === 'TEST') {
|
|
200
|
+
delete nuxtEnv[key];
|
|
68
201
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
writeFileSync(join(outputDir, 'vercel.json'), createVercelConfig());
|
|
76
|
-
writeFileSync(join(outputDir, 'netlify.toml'), createNetlifyConfig());
|
|
77
|
-
writeFileSync(join(outputDir, 'package.json'), createDeployPackageJson(name));
|
|
78
|
-
|
|
79
|
-
console.log('\n' + '='.repeat(50));
|
|
80
|
-
console.log(' Deployment package ready!');
|
|
81
|
-
console.log('='.repeat(50));
|
|
82
|
-
console.log(`\n Output: ${outputDir}/`);
|
|
83
|
-
console.log('\n Deploy with Vercel:');
|
|
84
|
-
console.log(` cd ${outputDir} && vercel`);
|
|
85
|
-
console.log('\n Deploy with Netlify:');
|
|
86
|
-
console.log(` cd ${outputDir} && netlify deploy --prod`);
|
|
87
|
-
console.log('\n Or push to Git and import in Vercel/Netlify dashboard.');
|
|
88
|
-
console.log('');
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
await runCommand(nuxt.command, [...nuxt.args, 'generate'], {
|
|
205
|
+
cwd: supaslidevRoot,
|
|
206
|
+
env: nuxtEnv,
|
|
89
207
|
});
|
|
208
|
+
|
|
209
|
+
// Step 4: Assemble output directory
|
|
210
|
+
console.log('\nStep 4/4: Assembling deploy output...\n');
|
|
211
|
+
|
|
212
|
+
// Clean and create output directory
|
|
213
|
+
if (existsSync(outputDir)) {
|
|
214
|
+
rmSync(outputDir, { recursive: true });
|
|
215
|
+
}
|
|
216
|
+
mkdirSync(outputDir, { recursive: true });
|
|
217
|
+
|
|
218
|
+
// Copy Nuxt output — nuxt generate runs in supaslidevRoot so .output lands there
|
|
219
|
+
const nuxtOutputDir = join(supaslidevRoot, '.output', 'public');
|
|
220
|
+
if (existsSync(nuxtOutputDir)) {
|
|
221
|
+
cpSync(nuxtOutputDir, outputDir, { recursive: true });
|
|
222
|
+
} else {
|
|
223
|
+
throw new Error('Nuxt generate did not produce output at .output/public/');
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Copy each presentation's dist into output/presentations/<id>/
|
|
227
|
+
const presentationsOutputDir = join(outputDir, 'presentations');
|
|
228
|
+
mkdirSync(presentationsOutputDir, { recursive: true });
|
|
229
|
+
|
|
230
|
+
for (const id of presentations) {
|
|
231
|
+
const distDir = join(presentationsDir, id, 'dist');
|
|
232
|
+
const destDir = join(presentationsOutputDir, id);
|
|
233
|
+
|
|
234
|
+
if (existsSync(distDir)) {
|
|
235
|
+
cpSync(distDir, destDir, { recursive: true });
|
|
236
|
+
} else {
|
|
237
|
+
console.warn(` Warning: No dist/ found for presentation "${id}", skipping.`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Copy presentations.json to output root
|
|
242
|
+
if (existsSync(presentationsJsonPath)) {
|
|
243
|
+
cpSync(presentationsJsonPath, join(outputDir, 'presentations.json'));
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Generate platform config files
|
|
247
|
+
writeFileSync(join(outputDir, 'vercel.json'), createVercelConfig(basePath, presentations));
|
|
248
|
+
writeFileSync(join(outputDir, 'netlify.toml'), createNetlifyConfig(basePath, presentations));
|
|
249
|
+
writeFileSync(join(outputDir, 'package.json'), createDeployPackageJson());
|
|
250
|
+
|
|
251
|
+
console.log('='.repeat(50));
|
|
252
|
+
console.log(' Deploy package ready!');
|
|
253
|
+
console.log('='.repeat(50));
|
|
254
|
+
console.log(`\n Output: ${outputDir}/`);
|
|
255
|
+
console.log(`\n Preview locally:`);
|
|
256
|
+
console.log(` cd ${outputDir} && npx serve .`);
|
|
257
|
+
console.log(`\n Deploy with Vercel:`);
|
|
258
|
+
console.log(` cd ${outputDir} && vercel`);
|
|
259
|
+
console.log(`\n Deploy with Netlify:`);
|
|
260
|
+
console.log(` cd ${outputDir} && netlify deploy --prod`);
|
|
261
|
+
console.log(`\n Or push to Git and import in Vercel/Netlify dashboard.`);
|
|
262
|
+
console.log('');
|
|
90
263
|
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
hasSharedPackage,
|
|
12
12
|
addSharedAddonToSlides,
|
|
13
13
|
addSharedDependencyToPackageJson,
|
|
14
|
+
normalizeVueToCatalog,
|
|
14
15
|
} from '../../shared/index.js';
|
|
15
16
|
import type { PackageJson } from '../../shared/types.js';
|
|
16
17
|
|
|
@@ -52,6 +53,8 @@ export function transformPackageJson(
|
|
|
52
53
|
export: 'slidev export',
|
|
53
54
|
};
|
|
54
55
|
|
|
56
|
+
normalizeVueToCatalog(packageJson);
|
|
57
|
+
|
|
55
58
|
if (hasSharedPackage(projectRoot)) {
|
|
56
59
|
addSharedDependencyToPackageJson(packageJson);
|
|
57
60
|
}
|
package/src/cli/index.ts
CHANGED
|
@@ -5,8 +5,8 @@ import { dev } from './commands/dev.js';
|
|
|
5
5
|
import { create } from './commands/create.js';
|
|
6
6
|
import { present } from './commands/present.js';
|
|
7
7
|
import { exportPdf } from './commands/export.js';
|
|
8
|
-
import { deploy } from './commands/deploy.js';
|
|
9
8
|
import { importPresentation } from './commands/import.js';
|
|
9
|
+
import { deploy } from './commands/deploy.js';
|
|
10
10
|
|
|
11
11
|
const program = new Command();
|
|
12
12
|
|
|
@@ -44,15 +44,6 @@ program
|
|
|
44
44
|
await exportPdf(name, options);
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
program
|
|
48
|
-
.command('deploy')
|
|
49
|
-
.description('Build and prepare a presentation for deployment')
|
|
50
|
-
.argument('<name>', 'Name of the presentation to deploy')
|
|
51
|
-
.option('-o, --output <path>', 'Output directory for deployment files')
|
|
52
|
-
.action(async (name: string, options: { output?: string }) => {
|
|
53
|
-
await deploy(name, options);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
47
|
program
|
|
57
48
|
.command('import')
|
|
58
49
|
.description('Import existing Sli.dev presentation(s)')
|
|
@@ -66,6 +57,20 @@ program
|
|
|
66
57
|
await importPresentation(source, { name: options.name, install: options.install ?? true });
|
|
67
58
|
});
|
|
68
59
|
|
|
60
|
+
program
|
|
61
|
+
.command('deploy')
|
|
62
|
+
.description('Build all presentations into a static deployable site')
|
|
63
|
+
.option('-o, --output <dir>', 'Output directory for the deploy package')
|
|
64
|
+
.option('--base <path>', 'Base path for the deployed site (default: /)')
|
|
65
|
+
.action(async (options: { output?: string; base?: string }) => {
|
|
66
|
+
try {
|
|
67
|
+
await deploy(options);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error(`Error: ${error instanceof Error ? error.message : error}`);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
69
74
|
export async function run(): Promise<void> {
|
|
70
75
|
await program.parseAsync();
|
|
71
76
|
}
|
package/src/cli/utils.ts
CHANGED
|
@@ -45,50 +45,3 @@ export function printAvailablePresentations(presentations: string[]): void {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
export function createVercelConfig(): string {
|
|
50
|
-
return (
|
|
51
|
-
JSON.stringify(
|
|
52
|
-
{
|
|
53
|
-
buildCommand: 'npm run build',
|
|
54
|
-
outputDirectory: 'dist',
|
|
55
|
-
rewrites: [{ source: '/(.*)', destination: '/index.html' }],
|
|
56
|
-
},
|
|
57
|
-
null,
|
|
58
|
-
2,
|
|
59
|
-
) + '\n'
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function createNetlifyConfig(): string {
|
|
64
|
-
return `[build]
|
|
65
|
-
publish = "dist"
|
|
66
|
-
command = "npm run build"
|
|
67
|
-
|
|
68
|
-
[build.environment]
|
|
69
|
-
NODE_VERSION = "20"
|
|
70
|
-
|
|
71
|
-
[[redirects]]
|
|
72
|
-
from = "/*"
|
|
73
|
-
to = "/index.html"
|
|
74
|
-
status = 200
|
|
75
|
-
`;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function createDeployPackageJson(name: string): string {
|
|
79
|
-
return (
|
|
80
|
-
JSON.stringify(
|
|
81
|
-
{
|
|
82
|
-
name: `${name}-deploy`,
|
|
83
|
-
version: '1.0.0',
|
|
84
|
-
private: true,
|
|
85
|
-
scripts: {
|
|
86
|
-
build: 'echo "Already built - static files ready in dist/"',
|
|
87
|
-
start: 'npx serve dist',
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
null,
|
|
91
|
-
2,
|
|
92
|
-
) + '\n'
|
|
93
|
-
);
|
|
94
|
-
}
|
package/src/module.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { NuxtModule } from '@nuxt/schema';
|
|
1
2
|
import { defineNuxtModule } from '@nuxt/kit';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
const supaslidevModule: NuxtModule = defineNuxtModule({
|
|
4
5
|
meta: {
|
|
5
6
|
name: 'supaslidev',
|
|
6
7
|
configKey: 'supaslidev',
|
|
@@ -10,3 +11,5 @@ export default defineNuxtModule({
|
|
|
10
11
|
// This module is a placeholder for future supaslidev-specific setup
|
|
11
12
|
},
|
|
12
13
|
});
|
|
14
|
+
|
|
15
|
+
export default supaslidevModule;
|
package/src/shared/catalog.ts
CHANGED
|
@@ -2,14 +2,6 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import type { PackageJson } from './types.js';
|
|
4
4
|
|
|
5
|
-
export const CATALOG_DEPENDENCIES = [
|
|
6
|
-
'@slidev/cli',
|
|
7
|
-
'@slidev/theme-default',
|
|
8
|
-
'@slidev/theme-seriph',
|
|
9
|
-
'@slidev/theme-apple-basic',
|
|
10
|
-
'vue',
|
|
11
|
-
];
|
|
12
|
-
|
|
13
5
|
export function hasSharedPackage(projectRoot: string): boolean {
|
|
14
6
|
const sharedPackagePath = join(projectRoot, 'packages', 'shared', 'package.json');
|
|
15
7
|
return existsSync(sharedPackagePath);
|
|
@@ -78,17 +70,11 @@ export function addSharedDependencyToPackageJson(packageJson: PackageJson): void
|
|
|
78
70
|
}
|
|
79
71
|
}
|
|
80
72
|
|
|
81
|
-
export function
|
|
82
|
-
dependencies
|
|
83
|
-
|
|
84
|
-
if (!dependencies || typeof dependencies !== 'object') {
|
|
85
|
-
return {};
|
|
73
|
+
export function normalizeVueToCatalog(packageJson: PackageJson): void {
|
|
74
|
+
if (packageJson.dependencies?.['vue']) {
|
|
75
|
+
packageJson.dependencies['vue'] = 'catalog:';
|
|
86
76
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (dep in converted) {
|
|
90
|
-
converted[dep] = 'catalog:';
|
|
91
|
-
}
|
|
77
|
+
if (packageJson.devDependencies?.['vue']) {
|
|
78
|
+
packageJson.devDependencies['vue'] = 'catalog:';
|
|
92
79
|
}
|
|
93
|
-
return converted;
|
|
94
80
|
}
|
package/src/shared/index.ts
CHANGED
|
@@ -19,11 +19,10 @@ export {
|
|
|
19
19
|
} from './presentations.js';
|
|
20
20
|
|
|
21
21
|
export {
|
|
22
|
-
CATALOG_DEPENDENCIES,
|
|
23
22
|
hasSharedPackage,
|
|
24
23
|
addSharedAddonToSlides,
|
|
25
24
|
addSharedDependencyToPackageJson,
|
|
26
|
-
|
|
25
|
+
normalizeVueToCatalog,
|
|
27
26
|
} from './catalog.js';
|
|
28
27
|
|
|
29
28
|
export { copyDirectorySelective } from './copy.js';
|