create-wervt 0.2.1 → 0.2.2

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.
Files changed (2) hide show
  1. package/index.js +19 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -12,6 +12,22 @@ import { installDependencies } from 'nypm'
12
12
  const BUNDLED_TEMPLATE = new URL('./template', import.meta.url).pathname
13
13
  const NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/
14
14
 
15
+ /**
16
+ * The newest @wervt/nuxt on npm. Releases of the module don't release this package, so new apps
17
+ * ask the registry instead of keeping the version bundled at pack time (the fallback, offline).
18
+ */
19
+ async function latestModule() {
20
+ const registry = (process.env.npm_config_registry ?? 'https://registry.npmjs.org').replace(
21
+ /\/$/,
22
+ '',
23
+ )
24
+ try {
25
+ const res = await fetch(`${registry}/@wervt/nuxt/latest`, { signal: AbortSignal.timeout(3000) })
26
+ if (res.ok) return (await res.json()).version
27
+ } catch {}
28
+ return undefined
29
+ }
30
+
15
31
  /** Root of the wervt repo when running inside it, so apps are created as workspace packages. */
16
32
  function findMonorepo(from) {
17
33
  for (let dir = resolve(from); ; dir = dirname(dir)) {
@@ -74,6 +90,9 @@ const main = defineCommand({
74
90
  pkg.dependencies['@wervt/nuxt'] = 'workspace:*'
75
91
  delete pkg.devDependencies['vite-plus']
76
92
  await rm(join(dir, 'vite.config.ts'), { force: true })
93
+ } else if (pkg.dependencies?.['@wervt/nuxt']) {
94
+ const version = await latestModule()
95
+ if (version) pkg.dependencies['@wervt/nuxt'] = `^${version}`
77
96
  }
78
97
  await writeFile(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`)
79
98
  spinner.stop(`Created ${relative(process.cwd(), dir) || '.'}`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-wervt",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Create a new wervt app: Nuxt 5, Postgres with Drizzle, live data with Electric.",
5
5
  "homepage": "https://wervt.app",
6
6
  "license": "MIT",