create-slidev 52.14.1 → 52.15.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/index.mjs CHANGED
@@ -18,6 +18,11 @@ const require = createRequire(import.meta.url)
18
18
  const __dirname = fileURLToPath(new URL('.', import.meta.url))
19
19
  const { version } = require('./package.json')
20
20
 
21
+ const RE_VALID_PACKAGE_NAME = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/
22
+ const RE_WHITESPACE = /\s+/g
23
+ const RE_LEADING_DOT_UNDERSCORE = /^[._]/
24
+ const RE_NON_ALPHANUMERIC = /[^a-z0-9-~]+/g
25
+
21
26
  const renameFiles = {
22
27
  _gitignore: '.gitignore',
23
28
  _npmrc: '.npmrc',
@@ -74,12 +79,9 @@ async function init() {
74
79
  const templateDir = path.join(__dirname, 'template')
75
80
 
76
81
  const write = (file, content) => {
77
- const targetPath = renameFiles[file]
78
- ? path.join(root, renameFiles[file])
79
- : path.join(root, file)
82
+ const targetPath = path.join(root, renameFiles[file] ?? file)
80
83
  if (content)
81
84
  fs.writeFileSync(targetPath, content)
82
-
83
85
  else
84
86
  copy(path.join(templateDir, file), targetPath)
85
87
  }
@@ -89,19 +91,27 @@ async function init() {
89
91
  write(file)
90
92
 
91
93
  const pkg = require(path.join(templateDir, 'package.json'))
92
-
93
94
  pkg.name = packageName
94
-
95
95
  write('package.json', JSON.stringify(pkg, null, 2))
96
96
 
97
- const pkgManager = (/pnpm/.test(process.env.npm_execpath || '') || /pnpm/.test(process.env.npm_config_user_agent || ''))
98
- ? 'pnpm'
99
- : /yarn/.test(process.env.npm_execpath || '') ? 'yarn' : 'npm'
100
-
101
- const related = path.relative(cwd, root)
102
-
103
97
  console.log(green(' Done.\n'))
104
98
 
99
+ function getPkgManager() {
100
+ const pm = []
101
+ if (typeof Deno !== 'undefined')
102
+ pm.push('deno')
103
+ if (typeof Bun !== 'undefined')
104
+ pm.push('bun')
105
+ const userAgent = process.env.npm_config_user_agent || ''
106
+ const execPath = process.env.npm_execpath || ''
107
+ if (execPath.includes('pnpm') || userAgent.includes('pnpm'))
108
+ pm.push('pnpm')
109
+ if (execPath.includes('yarn') || userAgent.includes('yarn'))
110
+ pm.push('yarn')
111
+ return pm.length === 1 ? pm[0] : null
112
+ }
113
+ const pkgManager = getPkgManager()
114
+
105
115
  /**
106
116
  * @type {{ yes: boolean }}
107
117
  */
@@ -109,48 +119,57 @@ async function init() {
109
119
  type: 'confirm',
110
120
  name: 'yes',
111
121
  initial: 'Y',
112
- message: 'Install and start it now?',
122
+ message: `Install and start it now${pkgManager ? ` using ${pkgManager}` : ''}?`,
113
123
  })
114
124
 
115
125
  if (yes) {
116
- const { agent } = await prompts({
126
+ const agent = pkgManager || (await prompts({
117
127
  name: 'agent',
118
128
  type: 'select',
119
129
  message: 'Choose the package manager',
120
130
  choices: ['npm', 'yarn', 'pnpm', 'bun', 'deno'].map(i => ({ value: i, title: i })),
121
- })
131
+ }).agent)
122
132
 
123
133
  if (!agent)
124
134
  return
125
135
 
136
+ writeReadme(agent)
126
137
  await x(agent, ['install'], { nodeOptions: { stdio: 'inherit', cwd: root } })
127
138
  await x(agent, ['run', 'dev'], { nodeOptions: { stdio: 'inherit', cwd: root } })
128
139
  }
129
140
  else {
141
+ writeReadme(pkgManager)
130
142
  console.log(dim('\n start it later by:\n'))
131
143
  if (root !== cwd)
132
- console.log(blue(` cd ${bold(related)}`))
144
+ console.log(blue(` cd ${bold(path.relative(cwd, root))}`))
133
145
 
134
- console.log(blue(` ${pkgManager === 'yarn' ? 'yarn' : `${pkgManager} install`}`))
135
- console.log(blue(` ${pkgManager === 'yarn' ? 'yarn dev' : `${pkgManager} run dev`}`))
146
+ console.log(blue(` ${pkgManager} install`))
147
+ console.log(blue(` ${pkgManager} run dev`))
136
148
  console.log()
137
149
  console.log(` ${cyan('●')} ${blue('■')} ${yellow('▲')}`)
138
150
  console.log()
139
151
  }
152
+
153
+ function writeReadme(pm = 'npm') {
154
+ const readmeTemplate = fs.readFileSync(path.join(templateDir, 'README.md'), 'utf-8')
155
+ const readmeContent = readmeTemplate
156
+ .replace('npm install', `${pm} install`)
157
+ .replace('npm run dev', `${pm} run dev`)
158
+ write('README.md', readmeContent)
159
+ }
140
160
  }
141
161
 
142
162
  function copy(src, dest) {
143
163
  const stat = fs.statSync(src)
144
164
  if (stat.isDirectory())
145
165
  copyDir(src, dest)
146
-
147
166
  else
148
167
  fs.copyFileSync(src, dest)
149
168
  }
150
169
 
151
170
  async function getValidPackageName(projectName) {
152
171
  projectName = path.basename(projectName)
153
- const packageNameRegExp = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/
172
+ const packageNameRegExp = RE_VALID_PACKAGE_NAME
154
173
  if (packageNameRegExp.test(projectName)) {
155
174
  return projectName
156
175
  }
@@ -158,9 +177,9 @@ async function getValidPackageName(projectName) {
158
177
  const suggestedPackageName = projectName
159
178
  .trim()
160
179
  .toLowerCase()
161
- .replace(/\s+/g, '-')
162
- .replace(/^[._]/, '')
163
- .replace(/[^a-z0-9-~]+/g, '-')
180
+ .replace(RE_WHITESPACE, '-')
181
+ .replace(RE_LEADING_DOT_UNDERSCORE, '')
182
+ .replace(RE_NON_ALPHANUMERIC, '-')
164
183
 
165
184
  /**
166
185
  * @type {{ inputPackageName: string }}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-slidev",
3
3
  "type": "module",
4
- "version": "52.14.1",
4
+ "version": "52.15.0",
5
5
  "description": "Create starter template for Slidev",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -21,13 +21,13 @@
21
21
  "template"
22
22
  ],
23
23
  "engines": {
24
- "node": ">=18.0.0"
24
+ "node": ">=20.12.0"
25
25
  },
26
26
  "dependencies": {
27
27
  "ansis": "^4.2.0",
28
28
  "minimist": "^1.2.8",
29
29
  "prompts": "^2.4.2",
30
- "tinyexec": "^1.0.2"
30
+ "tinyexec": "^1.1.1"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "node build.mjs"
@@ -2,8 +2,8 @@
2
2
 
3
3
  To start the slide show:
4
4
 
5
- - `pnpm install`
6
- - `pnpm dev`
5
+ - `npm install`
6
+ - `npm run dev`
7
7
  - visit <http://localhost:3030>
8
8
 
9
9
  Edit the [slides.md](./slides.md) to see the changes.
@@ -8,9 +8,9 @@
8
8
  "export": "slidev export"
9
9
  },
10
10
  "dependencies": {
11
- "@slidev/cli": "^52.14.1",
11
+ "@slidev/cli": "^52.15.0",
12
12
  "@slidev/theme-default": "latest",
13
13
  "@slidev/theme-seriph": "latest",
14
- "vue": "^3.5.29"
14
+ "vue": "^3.5.33"
15
15
  }
16
16
  }
@@ -268,7 +268,7 @@ const author = {
268
268
 
269
269
  You can use Vue components directly inside your slides.
270
270
 
271
- We have provided a few built-in components like `<Tweet/>` and `<Youtube/>` that you can use directly. And adding your custom components is also super easy.
271
+ We have provided a few built-in components like `<Tweet/>`, `<BlueSky/>`, and `<Youtube/>` that you can use directly. And adding your custom components is also super easy.
272
272
 
273
273
  ```html
274
274
  <Counter :count="10" />
@@ -340,21 +340,46 @@ You can add `v-click` to elements to add a click animation.
340
340
 
341
341
  <div v-click>
342
342
 
343
- This shows up when you click the slide:
343
+ This shows up when you press <kbd>space</kbd> or <kbd>right</kbd>, or click outside the slide on the right.
344
344
 
345
345
  ```html
346
- <div v-click>This shows up when you click the slide.</div>
346
+ <div v-click>This shows up when you trigger a click animation.</div>
347
347
  ```
348
348
 
349
349
  </div>
350
350
 
351
- <br>
351
+ <p v-click>
352
+ You can also add modifiers to change the animation:
353
+ </p>
354
+
355
+ <div class="grid gap-3 mt-4 text-sm" style="grid-template-columns: repeat(3, 1fr) 1.5fr 1fr">
356
+ <div v-after.up class="p-3 rounded border border-primary/20 bg-primary/10">
357
+ <div class="font-mono text-xs opacity-60 mb-1">v-click.up</div>
358
+ <div>Slide from bottom</div>
359
+ </div>
360
+ <div v-click.fade-in class="p-3 rounded border border-primary/30 bg-primary/15">
361
+ <div class="font-mono text-xs opacity-60 mb-1">v-click.fade-in</div>
362
+ <div>Fade in</div>
363
+ </div>
364
+ <div v-click.fade class="p-3 rounded border border-primary/40 bg-primary/20">
365
+ <div class="font-mono text-xs opacity-60 mb-1">v-click.fade</div>
366
+ <div>Dim (0.5 opacity)</div>
367
+ </div>
368
+ <div v-click.fade.right.scale class="p-3 rounded border border-primary/50 bg-primary/25">
369
+ <div class="font-mono text-xs opacity-60 mb-1">v-click.fade.right.scale</div>
370
+ <div>Composed</div>
371
+ </div>
372
+ <div v-click.none class="p-3 rounded border border-primary/60 bg-primary/30">
373
+ <div class="font-mono text-xs opacity-60 mb-1">v-click.none</div>
374
+ <div>No transition</div>
375
+ </div>
376
+ </div>
352
377
 
353
378
  <v-click>
354
379
 
355
- The <span v-mark.red="3"><code>v-mark</code> directive</span>
380
+ The <span v-mark.red="7"><code>v-mark</code> directive</span>
356
381
  also allows you to add
357
- <span v-mark.circle.orange="4">inline marks</span>
382
+ <span v-mark.circle.orange="8">inline marks</span>
358
383
  , powered by [Rough Notation](https://roughnotation.com/):
359
384
 
360
385
  ```html
@@ -363,7 +388,7 @@ also allows you to add
363
388
 
364
389
  </v-click>
365
390
 
366
- <div mt-20 v-click>
391
+ <div v-click mt-12>
367
392
 
368
393
  [Learn more](https://sli.dev/guide/animations#click-animation)
369
394