文件操作 - cli.mjs
返回文件管理
返回主菜单
删除本文件
文件: /var/www/OLD/node_modules/giget/dist/cli.mjs
编辑文件内容
#!/usr/bin/env node import { relative } from 'node:path'; import { defineCommand, runMain } from 'citty'; import { consola } from 'consola'; import { d as downloadTemplate, s as startShell } from './shared/giget.D-_6aM9e.mjs'; import 'node:fs/promises'; import 'node:fs'; import 'tar'; import 'pathe'; import 'defu'; import 'nypm'; import 'node:stream'; import 'node:child_process'; import 'node:os'; import 'node:util'; import 'node-fetch-native/proxy'; const name = "giget"; const version = "1.2.4"; const description = "Download templates and git repositories with pleasure!"; const repository = "unjs/giget"; const license = "MIT"; const sideEffects = false; const type = "module"; const exports = { ".": { "import": { types: "./dist/index.d.mts", "default": "./dist/index.mjs" }, require: { types: "./dist/index.d.cts", "default": "./dist/index.cjs" } } }; const main = "./dist/index.cjs"; const module = "./dist/index.mjs"; const types = "./dist/index.d.ts"; const bin = { giget: "./dist/cli.mjs" }; const files = [ "dist" ]; const scripts = { build: "unbuild", dev: "vitest dev", giget: "jiti ./src/cli.ts", lint: "eslint . && prettier -c src test", "lint:fix": "eslint . --fix && prettier -w src test", prepack: "unbuild", play: "pnpm giget --force-clean --verbose unjs .tmp/clone", release: "pnpm test && changelogen --release && npm publish && git push --follow-tags", test: "pnpm lint && vitest run --coverage" }; const dependencies = { citty: "^0.1.6", consola: "^3.4.0", defu: "^6.1.4", "node-fetch-native": "^1.6.6", nypm: "^0.5.1", ohash: "^1.1.4", pathe: "^2.0.2", tar: "^6.2.1" }; const devDependencies = { "@types/node": "^22.10.10", "@types/tar": "^6.1.13", "@vitest/coverage-v8": "^3.0.4", changelogen: "^0.5.7", eslint: "^9.19.0", "eslint-config-unjs": "^0.4.2", jiti: "^2.4.2", prettier: "^3.4.2", typescript: "^5.7.3", unbuild: "^3.3.1", vitest: "^3.0.4" }; const packageManager = "pnpm@9.15.4"; const pkg = { name: name, version: version, description: description, repository: repository, license: license, sideEffects: sideEffects, type: type, exports: exports, main: main, module: module, types: types, bin: bin, files: files, scripts: scripts, dependencies: dependencies, devDependencies: devDependencies, packageManager: packageManager }; const mainCommand = defineCommand({ meta: { name: pkg.name, version: pkg.version, description: pkg.description }, args: { // TODO: Make it `-t` in the next major version template: { type: "positional", description: "Template name or a a URI describing provider, repository, subdir, and branch/ref" }, dir: { type: "positional", description: "A relative or absolute path where to extract the template", required: false }, auth: { type: "string", description: "Custom Authorization token to use for downloading template. (Can be overriden with `GIGET_AUTH` environment variable)" }, cwd: { type: "string", description: "Set current working directory to resolve dirs relative to it" }, force: { type: "boolean", description: "Clone to existing directory even if exists" }, forceClean: { type: "boolean", description: "Remove any existing directory or file recusively before cloning" }, offline: { type: "boolean", description: "o not attempt to download and use cached version" }, preferOffline: { type: "boolean", description: "Use cache if exists otherwise try to download" }, shell: { type: "boolean", description: "Open a new shell with current working " }, install: { type: "boolean", description: "Install dependencies after cloning" }, verbose: { type: "boolean", description: "Show verbose debugging info" } }, run: async ({ args }) => { if (args.verbose) { process.env.DEBUG = process.env.DEBUG || "true"; } const r = await downloadTemplate(args.template, { dir: args.dir, force: args.force, forceClean: args.forceClean, offline: args.offline, preferOffline: args.preferOffline, auth: args.auth, install: args.install }); const _from = r.name || r.url; const _to = relative(process.cwd(), r.dir) || "./"; consola.log(`\u2728 Successfully cloned \`${_from}\` to \`${_to}\` `); if (args.shell) { startShell(r.dir); } } }); runMain(mainCommand);
修改文件时间
将文件时间修改为当前时间的前一年
删除文件