@exor404/mdslides 0.1.2 → 0.1.3

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/README.md CHANGED
@@ -12,32 +12,78 @@ dev server or builds a self-contained `dist/` you can host anywhere static.
12
12
  ## Quick start
13
13
 
14
14
  ```bash
15
- mdslides ./chemistry # scaffolds a project, then presents it
15
+ npx @exor404/mdslides@latest
16
16
  ```
17
17
 
18
- Point `mdslides` at a folder and it scaffolds a project: it **asks for a
19
- name**, writes `<name>.md` (e.g. `chemistry.md`) with three sample slides a
20
- title page, a list, and a help slide plus a `mdslides.config.js`, then opens
21
- the dev server. The name defaults to the folder, so pressing Enter at
22
- `Name your presentation (chemistry):` gives you `chemistry/chemistry.md`. That
23
- file *is* your deck — edit it and the slides live-reload.
18
+ No install step. It **asks for a name**, scaffolds `<name>/<name>.md` (three
19
+ sample slides a title page, a list, and a help slide) plus a
20
+ `mdslides.config.js`, and opens the dev server. The name defaults to the current
21
+ folder, so pressing Enter at `Name your presentation (chemistry):` gives you
22
+ `chemistry/chemistry.md`. That file *is* your deck edit it and the slides
23
+ live-reload.
24
+
25
+ Point it at a folder for the other commands:
24
26
 
25
27
  ```bash
26
- mdslides ./chemistry # present (dev server, live-reload)
27
- mdslides build ./chemistry # static build → ./chemistry/dist/
28
- mdslides preview ./chemistry # serve the built dist/
29
- mdslides export ./chemistry # → chemistry.pdf (one page per slide)
28
+ npx @exor404/mdslides ./chemistry # present (dev server, live-reload)
29
+ npx @exor404/mdslides build ./chemistry # static build → ./chemistry/dist/
30
+ npx @exor404/mdslides preview ./chemistry # serve the built dist/
31
+ npx @exor404/mdslides export ./chemistry # → chemistry.pdf (one page per slide)
30
32
  ```
31
33
 
32
- Already have a deck? Point straight at the file: `mdslides ./chemistry.md`.
34
+ Already have a deck? Point straight at the file: `npx @exor404/mdslides ./chemistry.md`.
35
+
36
+ > **Heads-up:** `npm install @exor404/mdslides` only *installs* the package —
37
+ > running the CLI (via `npx`, as above) is what scaffolds and presents. Using
38
+ > `npx` also keeps the engine's dependencies in npx's cache instead of bloating
39
+ > a project's `node_modules`.
40
+
41
+ Prefer a global command? `npm i -g @exor404/mdslides` makes `mdslides` available
42
+ directly (`mdslides ./chemistry`).
33
43
 
34
- Try the bundled example:
44
+ Try the bundled example from a clone:
35
45
 
36
46
  ```bash
37
47
  npm install
38
48
  npm run dev # opens ./example
39
49
  ```
40
50
 
51
+ ## Install
52
+
53
+ The package is published on the public npm registry as
54
+ [`@exor404/mdslides`](https://www.npmjs.com/package/@exor404/mdslides). Pick the
55
+ option that suits you:
56
+
57
+ **No install (recommended).** `npx` fetches and caches the latest version, then
58
+ runs it — nothing is added to your project:
59
+
60
+ ```bash
61
+ npx @exor404/mdslides@latest # prompts for a name, scaffolds + presents
62
+ ```
63
+
64
+ **Global install.** Puts an `mdslides` command on your `PATH`:
65
+
66
+ ```bash
67
+ npm install -g @exor404/mdslides
68
+ mdslides ./chemistry # then use it anywhere
69
+ mdslides --help # (or run with no folder to start fresh)
70
+ ```
71
+
72
+ Update later with `npm update -g @exor404/mdslides`; remove with
73
+ `npm uninstall -g @exor404/mdslides`.
74
+
75
+ **As a project dependency.** Add it to a repo so collaborators get the same
76
+ version via `npm install`:
77
+
78
+ ```bash
79
+ npm install -D @exor404/mdslides
80
+ npx mdslides ./chemistry # resolves from local node_modules
81
+ ```
82
+
83
+ > Requires **Node 18+**. Installing the package pulls in its rendering engine
84
+ > (Astro, Shiki, KaTeX) — that's why `npx` is the lightest way to try it: those
85
+ > dependencies stay in npx's cache instead of your project's `node_modules`.
86
+
41
87
  ## The deck model
42
88
 
43
89
  **One markdown file is the whole deck.** Every `#` (H1) heading starts a new
@@ -154,10 +200,10 @@ automation token stored as the `NPM_TOKEN` repository secret.
154
200
  ### How the pipeline works
155
201
 
156
202
  ```
157
- push tag v0.1.2 ──► GitHub Actions ──► checkout ──► setup Node 22
203
+ push tag v0.1.3 ──► GitHub Actions ──► checkout ──► setup Node 22
158
204
 
159
- ├─ guard: tag (v0.1.2) must equal
160
- │ package.json "version" (0.1.2),
205
+ ├─ guard: tag (v0.1.3) must equal
206
+ │ package.json "version" (0.1.3),
161
207
  │ else the run fails
162
208
 
163
209
  └─ npm publish (auth: NPM_TOKEN)
@@ -190,9 +236,9 @@ on your behalf.
190
236
  Once the secret is in place, every release is three commands:
191
237
 
192
238
  ```bash
193
- npm version patch # bumps package.json (0.1.1 → 0.1.2) and commits + tags v0.1.2
239
+ npm version patch # bumps package.json (0.1.2 → 0.1.3) and commits + tags v0.1.3
194
240
  git push origin main # push the version-bump commit
195
- git push origin v0.1.2 # push the tag → the pipeline publishes
241
+ git push origin v0.1.3 # push the tag → the pipeline publishes
196
242
  ```
197
243
 
198
244
  `npm version patch` (or `minor` / `major`) bumps `package.json`, makes the commit,
@@ -203,8 +249,8 @@ green the new version is live on npm.
203
249
  **Prefer to bump by hand?** Edit `"version"` in `package.json`, then:
204
250
 
205
251
  ```bash
206
- git commit -am "🔖 Release 0.1.2"
207
- git tag v0.1.2 # must match package.json exactly, or the guard fails
252
+ git commit -am "🔖 Release 0.1.3"
253
+ git tag v0.1.3 # must match package.json exactly, or the guard fails
208
254
  git push && git push --tags
209
255
  ```
210
256
 
@@ -23,7 +23,15 @@ const MIME = {
23
23
  };
24
24
 
25
25
  const EXCLUDED_TOP = new Set(['dist', 'node_modules', '.git', '.astro', '.vscode', '.idea']);
26
- const EXCLUDED_FILES = new Set(['mdslides.config.js']);
26
+ const EXCLUDED_FILES = new Set([
27
+ 'mdslides.config.js',
28
+ // Project scaffolding that lives alongside the deck (npm create … layout) —
29
+ // never part of the presentation, so keep it out of the built dist/.
30
+ 'package.json',
31
+ 'package-lock.json',
32
+ 'yarn.lock',
33
+ 'pnpm-lock.yaml',
34
+ ]);
27
35
 
28
36
  function isExcludedRel(rel) {
29
37
  if (!rel || rel === '.' || rel === '..') return true;
package/bin/cli.js CHANGED
@@ -60,7 +60,10 @@ function parseArgs(argv) {
60
60
  }
61
61
  }
62
62
 
63
- if (!file) {
63
+ // No target + the default `dev` command → start a brand-new project: we'll
64
+ // prompt for a name and scaffold it. Any other command needs an explicit
65
+ // target (there's nothing to build/preview/export yet).
66
+ if (!file && cmd !== 'dev') {
64
67
  fail('Missing target.\nUsage: mdslides [dev|build|preview|export] [--theme <name>] <folder|file.md>');
65
68
  }
66
69
 
@@ -130,6 +133,21 @@ async function scaffoldProject(dir) {
130
133
  return scaffoldDeck(resolve(dir, `${stem}.md`));
131
134
  }
132
135
 
136
+ // Start a project from scratch when `mdslides` is run with no target (e.g.
137
+ // `npx @exor404/mdslides`): ask for a name, then create `<name>/<name>.md` in
138
+ // the current directory and present it. No install or extra command needed.
139
+ async function scaffoldNewProject() {
140
+ const fallback = slugify(basename(process.cwd())) || 'presentation';
141
+ const answer = await ask(`Name your presentation (${fallback}): `, fallback);
142
+ const stem = slugify(answer.replace(/\.md$/i, '')) || fallback;
143
+ const dir = resolve(process.cwd(), stem);
144
+ if (existsSync(dir) && statSync(dir).isDirectory() && findDeckInDir(dir)) {
145
+ // A deck already lives here — open it instead of clobbering anything.
146
+ return findDeckInDir(dir);
147
+ }
148
+ return scaffoldDeck(resolve(dir, `${stem}.md`));
149
+ }
150
+
133
151
  function scaffoldDeck(deckPath) {
134
152
  const templatePath = resolve(__dirname, 'templates', 'slides.md');
135
153
  try {
@@ -169,7 +187,7 @@ async function loadUserConfig(source) {
169
187
  }
170
188
 
171
189
  const { cmd, theme: cliTheme, file } = parseArgs(process.argv);
172
- const deckFile = await resolveDeck(file);
190
+ const deckFile = file ? await resolveDeck(file) : await scaffoldNewProject();
173
191
  const source = dirname(deckFile);
174
192
 
175
193
  ensureDefaultConfig(source);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exor404/mdslides",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Markdown in, presentation out.",
5
5
  "type": "module",
6
6
  "bin": {