@strategicnerds/slide-nerds 0.2.0 → 0.2.1
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/cli/commands/link.d.ts +1 -0
- package/dist/cli/commands/link.d.ts.map +1 -1
- package/dist/cli/commands/link.js +7 -4
- package/dist/cli/commands/link.js.map +1 -1
- package/dist/cli/commands/push.d.ts +0 -10
- package/dist/cli/commands/push.d.ts.map +1 -1
- package/dist/cli/commands/push.js +7 -150
- package/dist/cli/commands/push.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AA4BnC,eAAO,MAAM,WAAW,GAAU,SAAS;IACzC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;CACpB,KAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAgD/C,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,SAAS,OAAO,KAAG,
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AA4BnC,eAAO,MAAM,WAAW,GAAU,SAAS;IACzC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;CACpB,KAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAgD/C,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,SAAS,OAAO,KAAG,IA+CtD,CAAA"}
|
|
@@ -23,7 +23,7 @@ const isSlidenerdProject = async (dir) => {
|
|
|
23
23
|
};
|
|
24
24
|
export const linkProject = async (options) => {
|
|
25
25
|
const dir = process.cwd();
|
|
26
|
-
const { serviceUrl, accessToken } = options;
|
|
26
|
+
const { serviceUrl, accessToken, url } = options;
|
|
27
27
|
// If a deck ID is provided, just link to it
|
|
28
28
|
if (options.deckId) {
|
|
29
29
|
const resp = await fetch(`${serviceUrl}/api/decks/${options.deckId}`, {
|
|
@@ -39,7 +39,7 @@ export const linkProject = async (options) => {
|
|
|
39
39
|
}, dir);
|
|
40
40
|
return { deckId: deck.id, deckName: deck.name };
|
|
41
41
|
}
|
|
42
|
-
// Otherwise, create a new deck
|
|
42
|
+
// Otherwise, create a new deck with the deployed URL
|
|
43
43
|
const name = options.name ?? await detectProjectName(dir);
|
|
44
44
|
const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
|
|
45
45
|
const resp = await fetch(`${serviceUrl}/api/decks`, {
|
|
@@ -48,7 +48,7 @@ export const linkProject = async (options) => {
|
|
|
48
48
|
Authorization: `Bearer ${accessToken}`,
|
|
49
49
|
'Content-Type': 'application/json',
|
|
50
50
|
},
|
|
51
|
-
body: JSON.stringify({ name, slug, source_type: '
|
|
51
|
+
body: JSON.stringify({ name, slug, url, deployed_url: url, source_type: 'url' }),
|
|
52
52
|
});
|
|
53
53
|
if (!resp.ok) {
|
|
54
54
|
const err = await resp.json().catch(() => ({ error: 'Unknown error' }));
|
|
@@ -66,6 +66,7 @@ export const registerLinkCommand = (program) => {
|
|
|
66
66
|
program
|
|
67
67
|
.command('link')
|
|
68
68
|
.description('Link this project to a deck on slidenerds.com')
|
|
69
|
+
.requiredOption('--url <url>', 'Deployed URL of your deck (e.g. https://my-talk.vercel.app)')
|
|
69
70
|
.option('--name <name>', 'Deck name (defaults to package name)')
|
|
70
71
|
.option('--deck-id <id>', 'Link to an existing deck by ID')
|
|
71
72
|
.action(async (options) => {
|
|
@@ -90,12 +91,14 @@ export const registerLinkCommand = (program) => {
|
|
|
90
91
|
const serviceUrl = await getServiceUrl();
|
|
91
92
|
const { deckId, deckName } = await linkProject({
|
|
92
93
|
name: options.name,
|
|
94
|
+
url: options.url,
|
|
93
95
|
deckId: options.deckId,
|
|
94
96
|
serviceUrl,
|
|
95
97
|
accessToken: creds.access_token,
|
|
96
98
|
});
|
|
97
99
|
console.log(`Linked to "${deckName}" (${deckId})`);
|
|
98
|
-
console.log(
|
|
100
|
+
console.log(`Deck URL: ${options.url}`);
|
|
101
|
+
console.log('Your deck is now registered on slidenerds.com.');
|
|
99
102
|
}
|
|
100
103
|
catch (err) {
|
|
101
104
|
console.error(`Link failed: ${err instanceof Error ? err.message : err}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sourceRoot":"","sources":["../../../src/cli/commands/link.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhG,MAAM,iBAAiB,GAAG,KAAK,EAAE,GAAW,EAAmB,EAAE;IAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAA;IAC9C,IAAI,MAAM,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACjC,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QACtC,OAAO,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;IACvC,CAAC;IACD,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,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,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,cAAc,EAAE,CAAA;QACpC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAA;YAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;QAED,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,MAAM,aAAa,EAAE,CAAA;YACxC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,WAAW,CAAC;gBAC7C,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,UAAU;gBACV,WAAW,EAAE,KAAK,CAAC,YAAY;aAChC,CAAC,CAAA;YAEF,OAAO,CAAC,GAAG,CAAC,cAAc,QAAQ,MAAM,MAAM,GAAG,CAAC,CAAA;YAClD,OAAO,CAAC,GAAG,CAAC,aAAa,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;YACvC,OAAO,CAAC,GAAG,CAAC,gDAAgD,CAAC,CAAA;QAC/D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,gBAAgB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAA;YACzE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;IACH,CAAC,CAAC,CAAA;AACN,CAAC,CAAA"}
|
|
@@ -1,13 +1,3 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
export declare const pushDeck: (options: {
|
|
3
|
-
dir: string;
|
|
4
|
-
deckId: string;
|
|
5
|
-
serviceUrl: string;
|
|
6
|
-
accessToken: string;
|
|
7
|
-
skipBuild?: boolean;
|
|
8
|
-
}) => Promise<{
|
|
9
|
-
version: number;
|
|
10
|
-
url: string;
|
|
11
|
-
}>;
|
|
12
2
|
export declare const registerPushCommand: (program: Command) => void;
|
|
13
3
|
//# sourceMappingURL=push.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/push.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/push.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,eAAO,MAAM,mBAAmB,GAAI,SAAS,OAAO,KAAG,IAWtD,CAAA"}
|
|
@@ -1,156 +1,13 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
|
-
import { execFile } from 'node:child_process';
|
|
4
|
-
import { getCredentials, getProjectConfig, getServiceUrl } from './config.js';
|
|
5
|
-
const execAsync = (cmd, args, cwd) => {
|
|
6
|
-
return new Promise((resolve, reject) => {
|
|
7
|
-
execFile(cmd, args, { cwd, maxBuffer: 10 * 1024 * 1024 }, (err, stdout, stderr) => {
|
|
8
|
-
if (err)
|
|
9
|
-
reject(err);
|
|
10
|
-
else
|
|
11
|
-
resolve({ stdout, stderr });
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
const buildProject = async (dir) => {
|
|
16
|
-
console.log('Building project...');
|
|
17
|
-
// Check if next.config has output: 'export' or if we need to add it
|
|
18
|
-
const nextConfigPath = path.join(dir, 'next.config.ts');
|
|
19
|
-
const nextConfigJsPath = path.join(dir, 'next.config.js');
|
|
20
|
-
const nextConfigMjsPath = path.join(dir, 'next.config.mjs');
|
|
21
|
-
const configPath = (await fs.pathExists(nextConfigPath))
|
|
22
|
-
? nextConfigPath
|
|
23
|
-
: (await fs.pathExists(nextConfigJsPath))
|
|
24
|
-
? nextConfigJsPath
|
|
25
|
-
: (await fs.pathExists(nextConfigMjsPath))
|
|
26
|
-
? nextConfigMjsPath
|
|
27
|
-
: null;
|
|
28
|
-
if (!configPath) {
|
|
29
|
-
throw new Error('No next.config.ts/js/mjs found. Is this a Next.js project?');
|
|
30
|
-
}
|
|
31
|
-
const configContent = await fs.readFile(configPath, 'utf-8');
|
|
32
|
-
const hasExportOutput = /output\s*:\s*['"]export['"]/.test(configContent);
|
|
33
|
-
// Temporarily add output: 'export' if not present
|
|
34
|
-
let restoreConfig = null;
|
|
35
|
-
if (!hasExportOutput) {
|
|
36
|
-
const backup = configContent;
|
|
37
|
-
const modified = configContent.replace(/const\s+nextConfig\s*:\s*NextConfig\s*=\s*\{/, "const nextConfig: NextConfig = {\n output: 'export',");
|
|
38
|
-
if (modified === configContent) {
|
|
39
|
-
// Fallback: try the JS pattern
|
|
40
|
-
const modifiedJs = configContent.replace(/const\s+nextConfig\s*=\s*\{/, "const nextConfig = {\n output: 'export',");
|
|
41
|
-
if (modifiedJs !== configContent) {
|
|
42
|
-
await fs.writeFile(configPath, modifiedJs);
|
|
43
|
-
restoreConfig = async () => fs.writeFile(configPath, backup);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
await fs.writeFile(configPath, modified);
|
|
48
|
-
restoreConfig = async () => fs.writeFile(configPath, backup);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
try {
|
|
52
|
-
// Find npx path
|
|
53
|
-
const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
54
|
-
await execAsync(npxCmd, ['next', 'build'], dir);
|
|
55
|
-
}
|
|
56
|
-
finally {
|
|
57
|
-
if (restoreConfig)
|
|
58
|
-
await restoreConfig();
|
|
59
|
-
}
|
|
60
|
-
const outDir = path.join(dir, 'out');
|
|
61
|
-
if (!(await fs.pathExists(outDir))) {
|
|
62
|
-
throw new Error('Build did not produce an "out" directory. Make sure next.config has output: "export".');
|
|
63
|
-
}
|
|
64
|
-
return outDir;
|
|
65
|
-
};
|
|
66
|
-
const createZipFromDir = async (sourceDir) => {
|
|
67
|
-
// Use tar + gzip as a cross-platform zip alternative
|
|
68
|
-
// We'll create the zip using the archiver pattern with just fs
|
|
69
|
-
// For simplicity, use the system zip command
|
|
70
|
-
const zipPath = path.join(path.dirname(sourceDir), 'slidenerds-push.zip');
|
|
71
|
-
// Clean up any previous zip
|
|
72
|
-
if (await fs.pathExists(zipPath))
|
|
73
|
-
await fs.remove(zipPath);
|
|
74
|
-
const zipCmd = process.platform === 'win32' ? 'tar' : 'zip';
|
|
75
|
-
const zipArgs = process.platform === 'win32'
|
|
76
|
-
? ['-cf', zipPath, '-C', sourceDir, '.']
|
|
77
|
-
: ['-r', zipPath, '.'];
|
|
78
|
-
const zipCwd = process.platform === 'win32' ? sourceDir : sourceDir;
|
|
79
|
-
await execAsync(zipCmd, zipArgs, zipCwd);
|
|
80
|
-
const buffer = await fs.readFile(zipPath);
|
|
81
|
-
await fs.remove(zipPath);
|
|
82
|
-
return buffer;
|
|
83
|
-
};
|
|
84
|
-
export const pushDeck = async (options) => {
|
|
85
|
-
const { dir, deckId, serviceUrl, accessToken, skipBuild } = options;
|
|
86
|
-
// Build the project
|
|
87
|
-
let outDir;
|
|
88
|
-
if (skipBuild) {
|
|
89
|
-
outDir = path.join(dir, 'out');
|
|
90
|
-
if (!(await fs.pathExists(outDir))) {
|
|
91
|
-
throw new Error('No "out" directory found. Run `next build` first or remove --skip-build.');
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
outDir = await buildProject(dir);
|
|
96
|
-
}
|
|
97
|
-
// Create zip
|
|
98
|
-
console.log('Packaging...');
|
|
99
|
-
const zipBuffer = await createZipFromDir(outDir);
|
|
100
|
-
const sizeMb = (zipBuffer.length / 1024 / 1024).toFixed(1);
|
|
101
|
-
console.log(`Package size: ${sizeMb} MB`);
|
|
102
|
-
// Upload
|
|
103
|
-
console.log('Uploading...');
|
|
104
|
-
const formData = new FormData();
|
|
105
|
-
formData.append('file', new Blob([zipBuffer.buffer], { type: 'application/zip' }), 'deck.zip');
|
|
106
|
-
const resp = await fetch(`${serviceUrl}/api/decks/${deckId}/push`, {
|
|
107
|
-
method: 'POST',
|
|
108
|
-
headers: { Authorization: `Bearer ${accessToken}` },
|
|
109
|
-
body: formData,
|
|
110
|
-
});
|
|
111
|
-
if (!resp.ok) {
|
|
112
|
-
const err = await resp.json().catch(() => ({ error: `HTTP ${resp.status}` }));
|
|
113
|
-
throw new Error(err.error ?? `Upload failed: ${resp.status}`);
|
|
114
|
-
}
|
|
115
|
-
const result = await resp.json();
|
|
116
|
-
return {
|
|
117
|
-
version: result.version,
|
|
118
|
-
url: `${serviceUrl}/d/${result.deck?.slug ?? deckId}`,
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
1
|
export const registerPushCommand = (program) => {
|
|
122
2
|
program
|
|
123
3
|
.command('push')
|
|
124
|
-
.description('
|
|
125
|
-
.
|
|
126
|
-
.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
process.exit(1);
|
|
132
|
-
}
|
|
133
|
-
const creds = await getCredentials();
|
|
134
|
-
if (!creds) {
|
|
135
|
-
console.error('Not logged in. Run `slidenerds login` first.');
|
|
136
|
-
process.exit(1);
|
|
137
|
-
}
|
|
138
|
-
try {
|
|
139
|
-
const serviceUrl = await getServiceUrl();
|
|
140
|
-
const { version, url } = await pushDeck({
|
|
141
|
-
dir,
|
|
142
|
-
deckId: config.deck_id,
|
|
143
|
-
serviceUrl,
|
|
144
|
-
accessToken: creds.access_token,
|
|
145
|
-
skipBuild: options.skipBuild,
|
|
146
|
-
});
|
|
147
|
-
console.log(`\nPushed version ${version}`);
|
|
148
|
-
console.log(`View at: ${url}\n`);
|
|
149
|
-
}
|
|
150
|
-
catch (err) {
|
|
151
|
-
console.error(`Push failed: ${err instanceof Error ? err.message : err}`);
|
|
152
|
-
process.exit(1);
|
|
153
|
-
}
|
|
4
|
+
.description('(Deprecated) Deploy your deck to your own host and use slidenerds link --url instead')
|
|
5
|
+
.action(async () => {
|
|
6
|
+
console.log('Direct upload to SlideNerds has been deprecated.\n');
|
|
7
|
+
console.log('Deploy your deck to Vercel, Netlify, or any static host, then register it:\n');
|
|
8
|
+
console.log(' npx vercel deploy --prod');
|
|
9
|
+
console.log(' slidenerds link --name my-talk --url https://my-talk.vercel.app\n');
|
|
10
|
+
process.exit(1);
|
|
154
11
|
});
|
|
155
12
|
};
|
|
156
13
|
//# sourceMappingURL=push.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.js","sourceRoot":"","sources":["../../../src/cli/commands/push.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"push.js","sourceRoot":"","sources":["../../../src/cli/commands/push.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAgB,EAAQ,EAAE;IAC5D,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,sFAAsF,CAAC;SACnG,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,OAAO,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAA;QACjE,OAAO,CAAC,GAAG,CAAC,8EAA8E,CAAC,CAAA;QAC3F,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;QACzC,OAAO,CAAC,GAAG,CAAC,qEAAqE,CAAC,CAAA;QAClF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,CAAC,CAAA;AACN,CAAC,CAAA"}
|