mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
feat(nuxi): switch to unjs/giget
for nuxi init
(#7361)
This commit is contained in:
parent
e22bbcc380
commit
e0c5907f0a
@ -8,6 +8,9 @@ The `init` command initializes a fresh Nuxt project.
|
||||
|
||||
Option | Default | Description
|
||||
-------------------------|-----------------|------------------
|
||||
`--verbose, -v` | `false` | Log information about the installation process.
|
||||
`--template, -t` | `nuxt/starter#v3` | Specify a Git repository to use as a template.
|
||||
`--force` | `false` | Force clone to any existing directory.
|
||||
`--offline` | `false` | Do not attempt to download from github and only use local cache.
|
||||
`--prefer-offline` | `false` | Try local cache first. (might be outdated)
|
||||
`--shell` | `false` | (experimental) Open shell in cloned directory.
|
||||
`dir` | `nuxt-app` | Name of the install directory.
|
||||
|
@ -34,6 +34,7 @@
|
||||
"destr": "^1.1.1",
|
||||
"execa": "^6.1.0",
|
||||
"flat": "^5.0.2",
|
||||
"giget": "^0.0.4",
|
||||
"jiti": "^1.15.0",
|
||||
"listhen": "^0.2.15",
|
||||
"mlly": "^0.5.14",
|
||||
@ -44,7 +45,6 @@
|
||||
"scule": "^0.3.2",
|
||||
"semver": "^7.3.7",
|
||||
"superb": "^4.0.0",
|
||||
"tiged": "^2.12.0",
|
||||
"unbuild": "latest"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
|
@ -1,6 +1,4 @@
|
||||
import { existsSync, readdirSync } from 'node:fs'
|
||||
// @ts-expect-error missing types
|
||||
import createTiged from 'tiged'
|
||||
import { downloadRepo, startShell } from 'giget'
|
||||
import { relative, resolve } from 'pathe'
|
||||
import superb from 'superb'
|
||||
import consola from 'consola'
|
||||
@ -28,30 +26,21 @@ const resolveTemplate = (template: string | boolean) => {
|
||||
export default defineNuxtCommand({
|
||||
meta: {
|
||||
name: 'init',
|
||||
usage: 'npx nuxi init|create [--verbose|-v] [--template,-t] [dir]',
|
||||
usage: 'npx nuxi init|create [--template,-t] [--force] [--offline] [--prefer-offline] [--shell] [dir]',
|
||||
description: 'Initialize a fresh project'
|
||||
},
|
||||
async invoke (args) {
|
||||
// Clone template
|
||||
const src = resolveTemplate(args.template || args.t)
|
||||
const dstDir = resolve(process.cwd(), args._[0] || 'nuxt-app')
|
||||
const tiged = createTiged(src, { cache: false /* TODO: buggy */, verbose: (args.verbose || args.v) })
|
||||
if (existsSync(dstDir) && readdirSync(dstDir).length) {
|
||||
consola.error(`Directory ${dstDir} is not empty. Please pick another name or remove it first. Aborting.`)
|
||||
process.exit(1)
|
||||
}
|
||||
const formatArgs = (msg: string) => msg.replace('options.', '--')
|
||||
tiged.on('warn', (event: any) => consola.warn(formatArgs(event.message)))
|
||||
tiged.on('info', (event: any) => consola.info(formatArgs(event.message)))
|
||||
try {
|
||||
await tiged.clone(dstDir)
|
||||
} catch (e: any) {
|
||||
if (e.toString().includes('could not find commit hash')) {
|
||||
consola.error(`Failed to clone template from \`${src}\`. Please check the repo is valid and that you have installed \`git\` correctly.`)
|
||||
process.exit(1)
|
||||
}
|
||||
throw e
|
||||
if (args.verbose || args.v) {
|
||||
process.env.DEBUG = process.env.DEBUG || 'true'
|
||||
}
|
||||
await downloadRepo(src, dstDir, {
|
||||
force: args.force,
|
||||
offline: args.offline,
|
||||
preferOffline: args['prefer-offline']
|
||||
})
|
||||
|
||||
// Show next steps
|
||||
const relativeDist = rpath(dstDir)
|
||||
@ -65,5 +54,9 @@ export default defineNuxtCommand({
|
||||
for (const step of nextSteps) {
|
||||
consola.log(` ${step}\n`)
|
||||
}
|
||||
|
||||
if (args.shell) {
|
||||
startShell(dstDir)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
127
yarn.lock
127
yarn.lock
@ -4704,13 +4704,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"colorette@npm:1.2.1":
|
||||
version: 1.2.1
|
||||
resolution: "colorette@npm:1.2.1"
|
||||
checksum: 06e2fcdb9e2a2c527ac84509a56eadf481cde1768933eb612808f3bb3a9d9872c06b4a9f95e4d0f7befeef8b38307f79b88242d9ea52470d1125520b8116de08
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"colorette@npm:^2.0.10, colorette@npm:^2.0.19":
|
||||
version: 2.0.19
|
||||
resolution: "colorette@npm:2.0.19"
|
||||
@ -5642,7 +5635,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"enquirer@npm:2.3.6, enquirer@npm:~2.3.6":
|
||||
"enquirer@npm:~2.3.6":
|
||||
version: 2.3.6
|
||||
resolution: "enquirer@npm:2.3.6"
|
||||
dependencies:
|
||||
@ -7323,13 +7316,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"fuzzysearch@npm:1.0.3":
|
||||
version: 1.0.3
|
||||
resolution: "fuzzysearch@npm:1.0.3"
|
||||
checksum: 6a6c04ec2e87ab77e9b5a310d979bd3555f836ef17d9a231d01292c9447af81dcfb3241f0e315efd750535b12c937691754e9a4fb08a8c45979f7f0007e3742d
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"gauge@npm:^3.0.0":
|
||||
version: 3.0.2
|
||||
resolution: "gauge@npm:3.0.2"
|
||||
@ -7456,6 +7442,21 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"giget@npm:^0.0.4":
|
||||
version: 0.0.4
|
||||
resolution: "giget@npm:0.0.4"
|
||||
dependencies:
|
||||
colorette: ^2.0.19
|
||||
mri: ^1.2.0
|
||||
node-fetch-native: ^0.1.4
|
||||
pathe: ^0.3.7
|
||||
tar: ^6.1.11
|
||||
bin:
|
||||
giget: dist/cli.mjs
|
||||
checksum: 6e6f86c125c477d47133ddc8768bcb5e4d91d9ada6f372174e2b56d1d854cefdc1e7b5e64884e618126dcc147cfc1448f661698cd6ddc6fce29703fa1a50dea9
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"git-config-path@npm:^2.0.0":
|
||||
version: 2.0.0
|
||||
resolution: "git-config-path@npm:2.0.0"
|
||||
@ -7680,7 +7681,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"graceful-fs@npm:^4.1.11, graceful-fs@npm:^4.1.15, graceful-fs@npm:^4.1.2, graceful-fs@npm:^4.1.3, graceful-fs@npm:^4.1.6, graceful-fs@npm:^4.2.0, graceful-fs@npm:^4.2.4, graceful-fs@npm:^4.2.6, graceful-fs@npm:^4.2.9":
|
||||
"graceful-fs@npm:^4.1.11, graceful-fs@npm:^4.1.15, graceful-fs@npm:^4.1.2, graceful-fs@npm:^4.1.6, graceful-fs@npm:^4.2.0, graceful-fs@npm:^4.2.4, graceful-fs@npm:^4.2.6, graceful-fs@npm:^4.2.9":
|
||||
version: 4.2.10
|
||||
resolution: "graceful-fs@npm:4.2.10"
|
||||
checksum: 3f109d70ae123951905d85032ebeae3c2a5a7a997430df00ea30df0e3a6c60cf6689b109654d6fdacd28810a053348c4d14642da1d075049e6be1ba5216218da
|
||||
@ -7818,13 +7819,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"home-or-tmp@npm:3.0.0":
|
||||
version: 3.0.0
|
||||
resolution: "home-or-tmp@npm:3.0.0"
|
||||
checksum: 1800f305bf8a230b2dcec564955efd60dc7b173f11f64060a78bad2910f82d6349e47b7b7a95ad203440e3654ce0cd72b9f22efff1bf43b34b131135ee0494e5
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"hookable@npm:^5.2.2, hookable@npm:^5.3.0":
|
||||
version: 5.3.0
|
||||
resolution: "hookable@npm:5.3.0"
|
||||
@ -7929,16 +7923,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"https-proxy-agent@npm:5.0.0":
|
||||
version: 5.0.0
|
||||
resolution: "https-proxy-agent@npm:5.0.0"
|
||||
dependencies:
|
||||
agent-base: 6
|
||||
debug: 4
|
||||
checksum: 165bfb090bd26d47693597661298006841ab733d0c7383a8cb2f17373387a94c903a3ac687090aa739de05e379ab6f868bae84ab4eac288ad85c328cd1ec9e53
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"https-proxy-agent@npm:^5.0.0":
|
||||
version: 5.0.1
|
||||
resolution: "https-proxy-agent@npm:5.0.1"
|
||||
@ -9653,13 +9637,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"mri@npm:1.1.6":
|
||||
version: 1.1.6
|
||||
resolution: "mri@npm:1.1.6"
|
||||
checksum: c568269a40e2e95d48f28b88ab8b24bdc7c586edbfbb3e5ce7a4e3cee0665aef673b86bc2b63c98289d29b573a39d0e054924e415286a8dafdabfc68785746c7
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"mri@npm:^1.2.0":
|
||||
version: 1.2.0
|
||||
resolution: "mri@npm:1.2.0"
|
||||
@ -10174,6 +10151,7 @@ __metadata:
|
||||
execa: ^6.1.0
|
||||
flat: ^5.0.2
|
||||
fsevents: ~2.3.2
|
||||
giget: ^0.0.4
|
||||
jiti: ^1.15.0
|
||||
listhen: ^0.2.15
|
||||
mlly: ^0.5.14
|
||||
@ -10184,7 +10162,6 @@ __metadata:
|
||||
scule: ^0.3.2
|
||||
semver: ^7.3.7
|
||||
superb: ^4.0.0
|
||||
tiged: ^2.12.0
|
||||
unbuild: latest
|
||||
dependenciesMeta:
|
||||
fsevents:
|
||||
@ -11860,7 +11837,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"rimraf@npm:3.0.2, rimraf@npm:^3.0.0, rimraf@npm:^3.0.2":
|
||||
"rimraf@npm:^3.0.0, rimraf@npm:^3.0.2":
|
||||
version: 3.0.2
|
||||
resolution: "rimraf@npm:3.0.2"
|
||||
dependencies:
|
||||
@ -11871,17 +11848,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"rimraf@npm:^2.5.2":
|
||||
version: 2.7.1
|
||||
resolution: "rimraf@npm:2.7.1"
|
||||
dependencies:
|
||||
glob: ^7.1.3
|
||||
bin:
|
||||
rimraf: ./bin.js
|
||||
checksum: cdc7f6eacb17927f2a075117a823e1c5951792c6498ebcce81ca8203454a811d4cf8900314154d3259bb8f0b42ab17f67396a8694a54cae3283326e57ad250cd
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"rollup-plugin-dts@npm:^4.2.2":
|
||||
version: 4.2.2
|
||||
resolution: "rollup-plugin-dts@npm:4.2.2"
|
||||
@ -12053,17 +12019,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"sander@npm:0.6.0":
|
||||
version: 0.6.0
|
||||
resolution: "sander@npm:0.6.0"
|
||||
dependencies:
|
||||
graceful-fs: ^4.1.3
|
||||
mkdirp: ^0.5.1
|
||||
rimraf: ^2.5.2
|
||||
checksum: 6e4dcb50e42371858f43410aa2e8c3290baadafc864731f7dc0bcc2afed60d977bd0e3f16555b25ff4225a25fe4bfe0ef864288da3f0b02524610dc35fe2ef24
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"schema-utils@npm:^2.7.0":
|
||||
version: 2.7.1
|
||||
resolution: "schema-utils@npm:2.7.1"
|
||||
@ -12777,20 +12732,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"tar@npm:6.1.0":
|
||||
version: 6.1.0
|
||||
resolution: "tar@npm:6.1.0"
|
||||
dependencies:
|
||||
chownr: ^2.0.0
|
||||
fs-minipass: ^2.0.0
|
||||
minipass: ^3.0.0
|
||||
minizlib: ^2.1.1
|
||||
mkdirp: ^1.0.3
|
||||
yallist: ^4.0.0
|
||||
checksum: 0638a405b625263e0c47e97f0ea5e871b1a549da4593e31bf1792bcc83d97c28065ed172669f186744526637ea627a424d519ddd99f3fd52b17ac75f58f43519
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"tar@npm:^4.4.1":
|
||||
version: 4.4.19
|
||||
resolution: "tar@npm:4.4.19"
|
||||
@ -12903,26 +12844,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"tiged@npm:^2.12.0":
|
||||
version: 2.12.0
|
||||
resolution: "tiged@npm:2.12.0"
|
||||
dependencies:
|
||||
colorette: 1.2.1
|
||||
enquirer: 2.3.6
|
||||
fuzzysearch: 1.0.3
|
||||
home-or-tmp: 3.0.0
|
||||
https-proxy-agent: 5.0.0
|
||||
mri: 1.1.6
|
||||
rimraf: 3.0.2
|
||||
sander: 0.6.0
|
||||
tar: 6.1.0
|
||||
tiny-glob: 0.2.8
|
||||
bin:
|
||||
degit: bin.js
|
||||
checksum: cd76e1bc8a6abe91046c1e46c116fec95d0ed19c1b6670bb92dd9424cdfc048bcbf41a88e44d4f37e902dca89ba44fed513abe40598417da78c7e16bd78a2177
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"time-fix-plugin@npm:^2.0.7":
|
||||
version: 2.0.7
|
||||
resolution: "time-fix-plugin@npm:2.0.7"
|
||||
@ -12932,16 +12853,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"tiny-glob@npm:0.2.8":
|
||||
version: 0.2.8
|
||||
resolution: "tiny-glob@npm:0.2.8"
|
||||
dependencies:
|
||||
globalyzer: 0.1.0
|
||||
globrex: ^0.1.2
|
||||
checksum: 2d800da5731df66b6f84eaa2024ebf7cd0c6e13b8334d5ea4ab902f38eeffa03455f465109cf79a2d4fc324c4a569c3cb83809e3380dac82a7689f5d46ac7dfe
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"tiny-glob@npm:^0.2.9":
|
||||
version: 0.2.9
|
||||
resolution: "tiny-glob@npm:0.2.9"
|
||||
|
Loading…
Reference in New Issue
Block a user