HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/AppData/Roaming/npm/node_modules/command-code/node_modules/giget/dist/cli.mjs
#!/usr/bin/env node
import { relative } from "./_chunks/libs/nypm.mjs";
import { downloadTemplate, startShell } from "./_chunks/giget.mjs";
import { defineCommand, runMain } from "./_chunks/libs/citty.mjs";
runMain(defineCommand({
	meta: {
		name: "giget",
		version: "3.3.0",
		description: "Download templates and git repositories with pleasure!"
	},
	args: {
		template: {
			type: "positional",
			required: true,
			description: "Template name or 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 overridden 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 recursively before cloning"
		},
		offline: {
			type: "boolean",
			description: "Do 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 the current working directory set to the cloned directory (experimental)"
		},
		install: {
			type: "boolean",
			description: "Install dependencies after cloning"
		},
		ignore: {
			type: "string",
			description: "Comma separated glob patterns of files to ignore (skip extracting). e.g. `--ignore pnpm-lock.yaml,*.md`"
		},
		verbose: {
			type: "boolean",
			description: "Show verbose debugging info"
		}
	},
	run: async ({ args }) => {
		if (args.verbose) process.env.DEBUG = process.env.DEBUG || "true";
		const ignore = (args.ignore || "").split(",").map((pattern) => pattern.trim()).filter(Boolean);
		let r;
		try {
			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,
				ignore: ignore.length > 0 ? ignore : void 0
			});
		} catch (error) {
			if (args.verbose) console.error(error);
			else {
				const message = error instanceof Error ? error.message : `Failed to download ${args.template}: unknown error`;
				console.error(message);
			}
			process.exitCode = 1;
			return;
		}
		const _from = r.name || r.url;
		const _to = relative(process.cwd(), r.dir) || "./";
		console.log(`✨ Successfully cloned \`${_from}\` to \`${_to}\`\n`);
		if (args.shell) startShell(r.dir);
	}
}));
export {};