create-slidev 52.14.2 → 52.15.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/index.mjs CHANGED
@@ -18,9 +18,13 @@ 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
- _npmrc: '.npmrc',
24
28
  }
25
29
 
26
30
  async function init() {
@@ -74,12 +78,9 @@ async function init() {
74
78
  const templateDir = path.join(__dirname, 'template')
75
79
 
76
80
  const write = (file, content) => {
77
- const targetPath = renameFiles[file]
78
- ? path.join(root, renameFiles[file])
79
- : path.join(root, file)
81
+ const targetPath = path.join(root, renameFiles[file] ?? file)
80
82
  if (content)
81
83
  fs.writeFileSync(targetPath, content)
82
-
83
84
  else
84
85
  copy(path.join(templateDir, file), targetPath)
85
86
  }
@@ -89,19 +90,27 @@ async function init() {
89
90
  write(file)
90
91
 
91
92
  const pkg = require(path.join(templateDir, 'package.json'))
92
-
93
93
  pkg.name = packageName
94
-
95
94
  write('package.json', JSON.stringify(pkg, null, 2))
96
95
 
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
96
  console.log(green(' Done.\n'))
104
97
 
98
+ function getPkgManager() {
99
+ const pm = []
100
+ if (typeof Deno !== 'undefined')
101
+ pm.push('deno')
102
+ if (typeof Bun !== 'undefined')
103
+ pm.push('bun')
104
+ const userAgent = process.env.npm_config_user_agent || ''
105
+ const execPath = process.env.npm_execpath || ''
106
+ if (execPath.includes('pnpm') || userAgent.includes('pnpm'))
107
+ pm.push('pnpm')
108
+ if (execPath.includes('yarn') || userAgent.includes('yarn'))
109
+ pm.push('yarn')
110
+ return pm.length === 1 ? pm[0] : null
111
+ }
112
+ const pkgManager = getPkgManager()
113
+
105
114
  /**
106
115
  * @type {{ yes: boolean }}
107
116
  */
@@ -109,48 +118,57 @@ async function init() {
109
118
  type: 'confirm',
110
119
  name: 'yes',
111
120
  initial: 'Y',
112
- message: 'Install and start it now?',
121
+ message: `Install and start it now${pkgManager ? ` using ${pkgManager}` : ''}?`,
113
122
  })
114
123
 
115
124
  if (yes) {
116
- const { agent } = await prompts({
125
+ const agent = pkgManager || (await prompts({
117
126
  name: 'agent',
118
127
  type: 'select',
119
128
  message: 'Choose the package manager',
120
129
  choices: ['npm', 'yarn', 'pnpm', 'bun', 'deno'].map(i => ({ value: i, title: i })),
121
- })
130
+ }).agent)
122
131
 
123
132
  if (!agent)
124
133
  return
125
134
 
135
+ writeReadme(agent)
126
136
  await x(agent, ['install'], { nodeOptions: { stdio: 'inherit', cwd: root } })
127
137
  await x(agent, ['run', 'dev'], { nodeOptions: { stdio: 'inherit', cwd: root } })
128
138
  }
129
139
  else {
140
+ writeReadme(pkgManager)
130
141
  console.log(dim('\n start it later by:\n'))
131
142
  if (root !== cwd)
132
- console.log(blue(` cd ${bold(related)}`))
143
+ console.log(blue(` cd ${bold(path.relative(cwd, root))}`))
133
144
 
134
- console.log(blue(` ${pkgManager === 'yarn' ? 'yarn' : `${pkgManager} install`}`))
135
- console.log(blue(` ${pkgManager === 'yarn' ? 'yarn dev' : `${pkgManager} run dev`}`))
145
+ console.log(blue(` ${pkgManager} install`))
146
+ console.log(blue(` ${pkgManager} run dev`))
136
147
  console.log()
137
148
  console.log(` ${cyan('●')} ${blue('■')} ${yellow('▲')}`)
138
149
  console.log()
139
150
  }
151
+
152
+ function writeReadme(pm = 'npm') {
153
+ const readmeTemplate = fs.readFileSync(path.join(templateDir, 'README.md'), 'utf-8')
154
+ const readmeContent = readmeTemplate
155
+ .replace('npm install', `${pm} install`)
156
+ .replace('npm run dev', `${pm} run dev`)
157
+ write('README.md', readmeContent)
158
+ }
140
159
  }
141
160
 
142
161
  function copy(src, dest) {
143
162
  const stat = fs.statSync(src)
144
163
  if (stat.isDirectory())
145
164
  copyDir(src, dest)
146
-
147
165
  else
148
166
  fs.copyFileSync(src, dest)
149
167
  }
150
168
 
151
169
  async function getValidPackageName(projectName) {
152
170
  projectName = path.basename(projectName)
153
- const packageNameRegExp = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/
171
+ const packageNameRegExp = RE_VALID_PACKAGE_NAME
154
172
  if (packageNameRegExp.test(projectName)) {
155
173
  return projectName
156
174
  }
@@ -158,9 +176,9 @@ async function getValidPackageName(projectName) {
158
176
  const suggestedPackageName = projectName
159
177
  .trim()
160
178
  .toLowerCase()
161
- .replace(/\s+/g, '-')
162
- .replace(/^[._]/, '')
163
- .replace(/[^a-z0-9-~]+/g, '-')
179
+ .replace(RE_WHITESPACE, '-')
180
+ .replace(RE_LEADING_DOT_UNDERSCORE, '')
181
+ .replace(RE_NON_ALPHANUMERIC, '-')
164
182
 
165
183
  /**
166
184
  * @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.2",
4
+ "version": "52.15.1",
5
5
  "description": "Create starter template for Slidev",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -27,7 +27,7 @@
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.2",
11
+ "@slidev/cli": "^52.15.1",
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
  }
@@ -0,0 +1 @@
1
+ shamefullyHoist: true
@@ -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
 
package/template/_npmrc DELETED
@@ -1,3 +0,0 @@
1
- # for pnpm
2
- shamefully-hoist=true
3
- auto-install-peers=true