版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

66 lines
1.6 KiB

  1. #!/usr/bin/env node
  2. import { relative } from 'node:path';
  3. import mri from 'mri';
  4. import { cyan } from 'colorette';
  5. import { d as downloadTemplate, s as startShell } from './shared/giget.093c29e5.mjs';
  6. import 'node:fs/promises';
  7. import 'node:fs';
  8. import 'tar';
  9. import 'pathe';
  10. import 'defu';
  11. import 'node:stream';
  12. import 'node:child_process';
  13. import 'node:os';
  14. import 'node:util';
  15. import 'node-fetch-native';
  16. import 'https-proxy-agent';
  17. async function main() {
  18. const arguments_ = mri(process.argv.slice(2), {
  19. boolean: [
  20. "help",
  21. "force",
  22. "force-clean",
  23. "offline",
  24. "prefer-offline",
  25. "shell",
  26. "verbose"
  27. ],
  28. string: ["registry", "cwd", "auth"]
  29. });
  30. const input = arguments_._[0];
  31. const dir = arguments_._[1];
  32. if (!input || arguments_.help || arguments_.h) {
  33. console.error(
  34. "Usage: npx giget@latest <input> [<dir>] [--force] [--force-clean] [--offline] [--prefer-offline] [--shell] [--registry] [--no-registry] [--verbose] [--cwd] [--auth]"
  35. );
  36. process.exit(1);
  37. }
  38. if (arguments_.verbose) {
  39. process.env.DEBUG = process.env.DEBUG || "true";
  40. }
  41. const r = await downloadTemplate(input, {
  42. dir,
  43. force: arguments_.force,
  44. forceClean: arguments_["force-clean"],
  45. offline: arguments_.offline,
  46. registry: arguments_.registry,
  47. cwd: arguments_.cwd,
  48. auth: arguments_.auth
  49. });
  50. console.log(
  51. `\u2728 Successfully cloned ${cyan(r.name || r.url)} to ${cyan(
  52. relative(process.cwd(), r.dir)
  53. )}
  54. `
  55. );
  56. if (arguments_.shell) {
  57. startShell(r.dir);
  58. }
  59. process.exit(0);
  60. }
  61. main().catch((error) => {
  62. console.error(error);
  63. process.exit(1);
  64. });