shadcn-svelte 0.3.5 → 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 +30 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -4927,8 +4927,18 @@ var registryBaseColorSchema = z2.object({
|
|
|
4927
4927
|
cssVarsTemplate: z2.string()
|
|
4928
4928
|
});
|
|
4929
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
|
+
|
|
4930
4939
|
// src/utils/registry/index.ts
|
|
4931
4940
|
var baseUrl = process.env.COMPONENTS_REGISTRY_URL ?? "https://shadcn-svelte.com";
|
|
4941
|
+
var proxyUrl = getEnvProxy();
|
|
4932
4942
|
async function getRegistryIndex() {
|
|
4933
4943
|
try {
|
|
4934
4944
|
const [result] = await fetchRegistry(["index.json"]);
|
|
@@ -5021,9 +5031,16 @@ async function getItemTargetPath(config, item2, override2) {
|
|
|
5021
5031
|
}
|
|
5022
5032
|
async function fetchRegistry(paths) {
|
|
5023
5033
|
try {
|
|
5034
|
+
let options = {};
|
|
5035
|
+
if (proxyUrl) {
|
|
5036
|
+
options.agent = new HttpsProxyAgent(proxyUrl);
|
|
5037
|
+
}
|
|
5024
5038
|
const results = await Promise.all(
|
|
5025
5039
|
paths.map(async (path8) => {
|
|
5026
|
-
const response = await fetch(
|
|
5040
|
+
const response = await fetch(
|
|
5041
|
+
`${baseUrl}/registry/${path8}`,
|
|
5042
|
+
options
|
|
5043
|
+
);
|
|
5027
5044
|
return await response.json();
|
|
5028
5045
|
})
|
|
5029
5046
|
);
|
|
@@ -6091,13 +6108,14 @@ var addOptionsSchema = z3.object({
|
|
|
6091
6108
|
overwrite: z3.boolean(),
|
|
6092
6109
|
cwd: z3.string(),
|
|
6093
6110
|
path: z3.string().optional(),
|
|
6094
|
-
nodep: z3.boolean()
|
|
6111
|
+
nodep: z3.boolean(),
|
|
6112
|
+
proxy: z3.string().optional()
|
|
6095
6113
|
});
|
|
6096
6114
|
var add = new Command().command("add").description("add components to your project").argument("[components...]", "name of components").option(
|
|
6097
6115
|
"--nodep",
|
|
6098
6116
|
"disable adding & installing dependencies (advanced)",
|
|
6099
6117
|
false
|
|
6100
|
-
).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(
|
|
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(
|
|
6101
6119
|
"-c, --cwd <cwd>",
|
|
6102
6120
|
"the working directory. defaults to the current directory.",
|
|
6103
6121
|
process.cwd()
|
|
@@ -6133,6 +6151,15 @@ var add = new Command().command("add").description("add components to your proje
|
|
|
6133
6151
|
process.exitCode = 1;
|
|
6134
6152
|
return;
|
|
6135
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
|
+
}
|
|
6136
6163
|
const registryIndex = await getRegistryIndex();
|
|
6137
6164
|
let selectedComponents = options.all ? registryIndex.map(({ name }) => name) : options.components;
|
|
6138
6165
|
if (!selectedComponents?.length) {
|