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 .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { StorybookConfig } from '@storybook/react-vite';
import { mergeConfig } from 'vite';
import turbosnap from 'vite-plugin-turbosnap';

import { CHROMATIC_BASE_URL } from '../src/constants.ts';
import { CHROMATIC_BASE_URL } from '../src/env.ts';

const useDistVersion = process.env.CHROMATIC_USE_DIST_VERSION === 'true';

Expand Down
7 changes: 1 addition & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,8 @@
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./manager": "./dist/manager.mjs",
"./package.json": "./package.json",
"./preset": "./dist/preset.js",
"./preview": {
"types": "./dist/preview.d.ts",
"default": "./dist/preview.mjs"
}
"./preset": "./dist/preset.js"
},
"main": "dist/index.js",
"files": [
Expand Down
7 changes: 0 additions & 7 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
export const {
CHROMATIC_INDEX_URL,
CHROMATIC_BASE_URL = CHROMATIC_INDEX_URL || 'https://www.chromatic.com',
CHROMATIC_API_URL = `${CHROMATIC_BASE_URL}/api`,
} = process.env;

export const PACKAGE_NAME = '@chromatic-com/storybook';

export const ADDON_ID = 'chromaui/addon-visual-tests';
export const PANEL_ID = `${ADDON_ID}/panel`;
export const TEST_PROVIDER_ID = `${ADDON_ID}/test-provider`;
export const ACCESS_TOKEN_KEY = `${ADDON_ID}/access-token/${CHROMATIC_BASE_URL}`;
export const DEV_BUILD_ID_KEY = `${ADDON_ID}/dev-build-id`;
export const CONFIG_INFO = `${ADDON_ID}/configInfo`;
export const CONFIG_INFO_DISMISSED = `${ADDON_ID}/configInfoDismissed`;
Expand Down
9 changes: 9 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { ADDON_ID } from './constants';

export const {
CHROMATIC_INDEX_URL,
CHROMATIC_BASE_URL = CHROMATIC_INDEX_URL || 'https://www.chromatic.com',
CHROMATIC_API_URL = `${CHROMATIC_BASE_URL}/api`,
} = process.env;

export const ACCESS_TOKEN_KEY = `${ADDON_ID}/access-token/${CHROMATIC_BASE_URL}`;
2 changes: 1 addition & 1 deletion src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import type { Options } from 'storybook/internal/types';

import {
ADDON_ID,
CHROMATIC_BASE_URL,
CONFIG_INFO,
CONFIG_OVERRIDES,
GIT_INFO,
Expand All @@ -31,6 +30,7 @@ import {
TELEMETRY,
TEST_PROVIDER_ID,
} from './constants.ts';
import { CHROMATIC_BASE_URL } from './env.ts';
import { runChromaticBuild, stopChromaticBuild } from './runChromaticBuild.ts';
import {
ConfigInfoPayload,
Expand Down
3 changes: 2 additions & 1 deletion src/utils/graphQLClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { useAddonState } from 'storybook/manager-api';
import { Client, ClientOptions, fetchExchange, mapExchange, Provider } from 'urql';
import { v4 as uuid } from 'uuid';

import { ACCESS_TOKEN_KEY, ADDON_ID, CHROMATIC_API_URL } from '../constants';
import { ADDON_ID } from '../constants';
import { ACCESS_TOKEN_KEY, CHROMATIC_API_URL } from '../env';

let currentToken: string | null;
let currentTokenExpiration: number | null;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/requestAccessToken.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CHROMATIC_BASE_URL } from '../constants';
import { CHROMATIC_BASE_URL } from '../env';
// @ts-expect-error File is in plain JS
import { sha256 } from './sha256';

Expand Down
2 changes: 1 addition & 1 deletion tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default defineConfig(async (options) => {
format: ['esm'],
platform: 'browser',
external: globalManagerPackagesNoIcons,
dts: true,
dts: false,
});
}

Expand Down
Loading