Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/csk-marketing-site/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@uniformdev/csk-marketing-site",
"version": "6.1.72",
"version": "6.1.73",
"private": true,
"engines": {
"yarn": "please-use-npm",
Expand Down
2 changes: 1 addition & 1 deletion apps/csk-storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@uniformdev/csk-storybook",
"version": "6.1.72",
"version": "6.1.73",
"description": "CSK vNext Storybook is an interactive Storybook build showcasing components from the CSK vNext component starter kit. It provides detailed documentation, live previews, and testing capabilities for easy integration into your projects.",
"main": "index.js",
"scripts": {
Expand Down
11 changes: 11 additions & 0 deletions apps/csk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ Alternatively you can use `npm run pull:content:dev` and `npm run push:content:d

> Developer-owned content typically scoped to components, content types, component patterns but can vary based on the stage of your project lifecycle and your preferences. For example, at some point, you may not want to sync assets like images, videos, etc.

## Running behind a corporate proxy

Both the Next.js runtime and the CLI scripts (`pull:dex`, `push:dex`, `pull:locales`) honor `HTTPS_PROXY` / `HTTP_PROXY`:

```bash
export HTTPS_PROXY=http://your-proxy.example.com:8080
export HTTP_PROXY=http://your-proxy.example.com:8080
```

If your proxy intercepts TLS with a custom root CA, also set `NODE_EXTRA_CA_CERTS=/path/to/ca.pem`, otherwise Node rejects the certificate with `UNABLE_TO_VERIFY_LEAF_SIGNATURE`. Each CLI also accepts `--proxy <url>` to override the env var for a single run.

## Other scripts

### **Design Extension Sync**
Expand Down
4 changes: 2 additions & 2 deletions apps/csk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@uniformdev/component-starter-kit",
"version": "6.1.72",
"version": "6.1.73",
"private": true,
"engines": {
"yarn": "please-use-npm",
Expand Down Expand Up @@ -38,6 +38,7 @@
"dependencies": {
"@uniformdev/assets": "^20.61.2-alpha.3",
"@uniformdev/canvas": "^20.61.2-alpha.3",
"@uniformdev/csk-cli": "*",
"@uniformdev/csk-components": "*",
"@uniformdev/design-extensions-tools": "*",
"@uniformdev/next-app-router": "^20.61.2-alpha.3",
Expand All @@ -58,7 +59,6 @@
"@types/react": "^19.2.7",
"@types/react-dom": "^19.2.3",
"@uniformdev/cli": "^20.61.2-alpha.3",
"@uniformdev/csk-cli": "*",
"@uniformdev/csk-recipes": "*",
"cross-env": "^10.1.0",
"eslint": "^9.31.0",
Expand Down
5 changes: 5 additions & 0 deletions apps/csk/src/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { applyGlobalProxy } from '@uniformdev/csk-cli/proxy-fetch';

export function register() {
applyGlobalProxy();
}
48 changes: 32 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "csk-packages",
"version": "6.1.72",
"version": "6.1.73",
"private": true,
"scripts": {
"build": "turbo build",
Expand Down
9 changes: 7 additions & 2 deletions packages/csk-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@uniformdev/csk-cli",
"version": "6.1.72",
"version": "6.1.73",
"description": "Command-line interface (CLI) tool designed to streamline the development workflow within Uniform projects. It provides commands for pulling additional data and generating components based on Canvas data",
"license": "SEE LICENSE IN LICENSE.txt",
"engines": {
Expand All @@ -19,6 +19,10 @@
"./components": {
"types": "./dist/components.d.mts",
"default": "./dist/components.mjs"
},
"./proxy-fetch": {
"types": "./dist/proxy-fetch.d.mts",
"default": "./dist/proxy-fetch.mjs"
}
},
"types": "./dist/index.d.mts",
Expand All @@ -38,7 +42,8 @@
"@inquirer/prompts": "^7.1.0",
"commander": "^9.0.0",
"dotenv": "16.4.7",
"ora": "^8.2.0"
"ora": "^8.2.0",
"undici": "^7.16.0"
},
"devDependencies": {
"@repo/eslint-config": "*",
Expand Down
5 changes: 3 additions & 2 deletions packages/csk-cli/src/commands/pull/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ type PullArgs = {
allSettings: boolean;
dev?: boolean;
uniform?: boolean;
proxy?: string;
};

export const pullCommand = async (args: PullArgs) => {
const { dev, uniform, locales } = args || {};
const { dev, uniform, locales, proxy } = args || {};
if (locales) {
console.info('Pulling locales...');
pullLocales().catch(e => console.error(e));
pullLocales({ proxy }).catch(e => console.error(e));
return;
} else if (uniform) {
console.info('Pulling uniform canvas data...');
Expand Down
4 changes: 3 additions & 1 deletion packages/csk-cli/src/commands/pull/pull-locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from 'node:path';
import { LocaleClient, LocalesGetResponse } from '@uniformdev/canvas';
import { CONFIG_FILE, PATH_TO_LOCALES_FOLDER } from './constants';
import { syncSuccessLog } from './utils';
import { createProxyFetch, getProxyUrl } from '../../proxy-fetch';

type LocalizationSettings = {
locales: string[];
Expand All @@ -11,7 +12,7 @@ type LocalizationSettings = {
defaultLocale: string | null;
};

export const pullLocales = async () => {
export const pullLocales = async ({ proxy }: { proxy?: string } = {}) => {
if (!fs.existsSync(PATH_TO_LOCALES_FOLDER)) {
console.error(
`No such directory for locales files: ${PATH_TO_LOCALES_FOLDER}. You can override it by setting LOCALES_PATH environment variable.`
Expand All @@ -23,6 +24,7 @@ export const pullLocales = async () => {
projectId: process.env.UNIFORM_PROJECT_ID,
apiKey: process.env.UNIFORM_API_KEY,
apiHost: process.env.UNIFORM_CLI_BASE_URL || 'https://uniform.app',
fetch: createProxyFetch(getProxyUrl(proxy)),
});

const localeResponse: LocalesGetResponse = await client.get();
Expand Down
1 change: 1 addition & 0 deletions packages/csk-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ program
.option('-l, --locales', 'locales configuration')
.option('-u, --uniform', 'uniform canvas data')
.option('-d, --dev', 'development mode')
.option('--proxy <url>', 'HTTP(S) proxy URL for outbound requests. Defaults to HTTPS_PROXY/HTTP_PROXY env var.')
.action(pullCommand);

program
Expand Down
43 changes: 43 additions & 0 deletions packages/csk-cli/src/proxy-fetch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { setGlobalDispatcher, fetch as undiciFetch, ProxyAgent, RequestInit as UndiciRequestInit } from 'undici';

export function getProxyUrl(explicit?: string): string | undefined {
return explicit || process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
}

export function createProxyFetch(proxyUrl?: string): typeof fetch {
if (proxyUrl) console.info(`\u{1F991} Using proxy ${proxyUrl}`);
const dispatcher = proxyUrl ? new ProxyAgent(proxyUrl) : undefined;
return ((input: RequestInfo | URL, init?: RequestInit) =>
undiciFetch(
input as URL,
{
...(init as UndiciRequestInit),
dispatcher,
} as UndiciRequestInit
)) as unknown as typeof fetch;
}

let configuredProxyUrl: string | undefined;
let cachedFetch: typeof fetch | undefined;

export function setProxyUrl(url: string | undefined): void {
configuredProxyUrl = url;
cachedFetch = undefined;
}

export function getConfiguredFetch(): typeof fetch {
if (cachedFetch) return cachedFetch;
cachedFetch = createProxyFetch(configuredProxyUrl ?? getProxyUrl());
return cachedFetch;
}

// Installs a proxy as the global undici dispatcher. Used by the Next.js
// instrumentation hook to patch the runtime transport without replacing
// globalThis.fetch — preserves Next.js's fetch-cache wrapper.
export function applyGlobalProxy(): boolean {
const proxyUrl = getProxyUrl();
if (!proxyUrl) return false;
setGlobalDispatcher(new ProxyAgent(proxyUrl));
console.info(`[proxy-fetch] Routing fetch through proxy: ${proxyUrl}`);
return true;
}
2 changes: 1 addition & 1 deletion packages/csk-cli/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from 'tsup';

export default defineConfig({
entry: ['src/index.ts'],
entry: ['src/index.ts', 'src/proxy-fetch.ts'],
format: ['esm'],
dts: true,
splitting: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/csk-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@uniformdev/csk-components",
"version": "6.1.72",
"version": "6.1.73",
"description": "Components Starter Kit that provides a set of basic components for building websites within a Uniform project",
"license": "SEE LICENSE IN LICENSE.txt",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/csk-recipes/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@uniformdev/csk-recipes",
"version": "6.1.72",
"version": "6.1.73",
"description": "command-line interface (CLI) and utility functions to help you work with recipes in a CSK project. It simplifies project initialization by allowing you to choose templates and include specific recipes",
"license": "SEE LICENSE IN LICENSE.txt",
"engines": {
Expand Down
Loading
Loading