shadcn-svelte 0.3.4 → 0.3.6

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.
package/dist/index.js CHANGED
@@ -4861,6 +4861,9 @@ var logger = {
4861
4861
  },
4862
4862
  success(...args) {
4863
4863
  console.log(chalk.green(...args));
4864
+ },
4865
+ highlight(...args) {
4866
+ return chalk.cyan(...args);
4864
4867
  }
4865
4868
  };
4866
4869
 
@@ -4924,8 +4927,18 @@ var registryBaseColorSchema = z2.object({
4924
4927
  cssVarsTemplate: z2.string()
4925
4928
  });
4926
4929
 
4930
+ // src/utils/registry/index.ts
4931
+ import { HttpsProxyAgent } from "https-proxy-agent";
4932
+
4933
+ // src/utils/get-env-proxy.ts
4934
+ function getEnvProxy() {
4935
+ const { HTTP_PROXY, http_proxy } = process.env;
4936
+ return HTTP_PROXY || http_proxy;
4937
+ }
4938
+
4927
4939
  // src/utils/registry/index.ts
4928
4940
  var baseUrl = process.env.COMPONENTS_REGISTRY_URL ?? "https://shadcn-svelte.com";
4941
+ var proxyUrl = getEnvProxy();
4929
4942
  async function getRegistryIndex() {
4930
4943
  try {
4931
4944
  const [result] = await fetchRegistry(["index.json"]);
@@ -5018,9 +5031,16 @@ async function getItemTargetPath(config, item2, override2) {
5018
5031
  }
5019
5032
  async function fetchRegistry(paths) {
5020
5033
  try {
5034
+ let options = {};
5035
+ if (proxyUrl) {
5036
+ options.agent = new HttpsProxyAgent(proxyUrl);
5037
+ }
5021
5038
  const results = await Promise.all(
5022
5039
  paths.map(async (path8) => {
5023
- const response = await fetch(`${baseUrl}/registry/${path8}`);
5040
+ const response = await fetch(
5041
+ `${baseUrl}/registry/${path8}`,
5042
+ options
5043
+ );
5024
5044
  return await response.json();
5025
5045
  })
5026
5046
  );
@@ -6084,20 +6104,23 @@ function transformImport(content, config) {
6084
6104
  var addOptionsSchema = z3.object({
6085
6105
  components: z3.array(z3.string()).optional(),
6086
6106
  yes: z3.boolean(),
6107
+ all: z3.boolean(),
6087
6108
  overwrite: z3.boolean(),
6088
6109
  cwd: z3.string(),
6089
6110
  path: z3.string().optional(),
6090
- nodep: z3.boolean()
6111
+ nodep: z3.boolean(),
6112
+ proxy: z3.string().optional()
6091
6113
  });
6092
6114
  var add = new Command().command("add").description("add components to your project").argument("[components...]", "name of components").option(
6093
6115
  "--nodep",
6094
6116
  "disable adding & installing dependencies (advanced)",
6095
6117
  false
6096
- ).option("-y, --yes", "Skip confirmation prompt.", false).option("-o, --overwrite", "overwrite existing files.", false).option(
6118
+ ).option("-a, --all", "Add all components to your project.", false).option("-y, --yes", "Skip confirmation prompt.", false).option("-o, --overwrite", "overwrite existing files.", false).option("--proxy <proxy>", "fetch components from registry using a proxy.").option(
6097
6119
  "-c, --cwd <cwd>",
6098
6120
  "the working directory. defaults to the current directory.",
6099
6121
  process.cwd()
6100
6122
  ).option("-p, --path <path>", "the path to add the component to.").action(async (components, opts) => {
6123
+ const highlight = logger.highlight;
6101
6124
  logger.warn(
6102
6125
  "Running the following command will overwrite existing files."
6103
6126
  );
@@ -6128,18 +6151,27 @@ var add = new Command().command("add").description("add components to your proje
6128
6151
  process.exitCode = 1;
6129
6152
  return;
6130
6153
  }
6154
+ const chosenProxy = options.proxy ?? getEnvProxy();
6155
+ if (chosenProxy) {
6156
+ const isCustom = !!options.proxy;
6157
+ if (isCustom)
6158
+ process.env.HTTP_PROXY = options.proxy;
6159
+ logger.warn(
6160
+ `You are using a ${isCustom ? "provided" : "system environment"} proxy: ${chalk2.green(chosenProxy)}`
6161
+ );
6162
+ }
6131
6163
  const registryIndex = await getRegistryIndex();
6132
- let selectedComponents = options.components;
6133
- if (!options.components?.length) {
6164
+ let selectedComponents = options.all ? registryIndex.map(({ name }) => name) : options.components;
6165
+ if (!selectedComponents?.length) {
6134
6166
  const { components: components2 } = await prompts2({
6135
6167
  type: "multiselect",
6136
6168
  name: "components",
6137
6169
  message: "Which components would you like to add?",
6138
6170
  hint: "Space to select. A to toggle all. Enter to submit.",
6139
6171
  instructions: false,
6140
- choices: registryIndex.map((entry) => ({
6141
- title: entry.name,
6142
- value: entry.name
6172
+ choices: registryIndex.map(({ name }) => ({
6173
+ title: name,
6174
+ value: name
6143
6175
  }))
6144
6176
  });
6145
6177
  selectedComponents = components2;
@@ -6159,6 +6191,8 @@ var add = new Command().command("add").description("add components to your proje
6159
6191
  process.exitCode = 0;
6160
6192
  return;
6161
6193
  }
6194
+ logger.info(`Selected components:
6195
+ ${highlight(selectedComponents)}`);
6162
6196
  if (!options.yes) {
6163
6197
  const { proceed } = await prompts2({
6164
6198
  type: "confirm",
@@ -6452,7 +6486,7 @@ var init2 = new Command2().command("init").description("Configure your SvelteKit
6452
6486
  }
6453
6487
  });
6454
6488
  async function promptForConfig(cwd, defaultConfig = null, skip = false) {
6455
- const highlight = (text2) => chalk3.cyan(text2);
6489
+ const highlight = logger.highlight;
6456
6490
  const styles2 = await getRegistryStyles();
6457
6491
  const baseColors = await getRegistryBaseColors();
6458
6492
  const options = await prompts3([