Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable normalization of package.json #18806

Merged
merged 2 commits into from
Jul 28, 2022
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
1 change: 1 addition & 0 deletions code/lib/core-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"@types/mock-fs": "^4.13.0",
"@types/picomatch": "^2.3.0",
"mock-fs": "^4.13.0",
"type-fest": "^2.17.0",
"typescript": "~4.6.3"
},
"peerDependencies": {
Expand Down
14 changes: 2 additions & 12 deletions code/lib/core-common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { TransformOptions } from '@babel/core';
import { Router } from 'express';
import { Server } from 'http';
import type { Parameters } from '@storybook/csf';
import type { PackageJson } from 'type-fest';
import type { FileSystemCache } from './utils/file-cache';

/**
Expand Down Expand Up @@ -109,18 +110,7 @@ export interface BuilderResult {
stats?: Stats;
}

// TODO: this is a generic interface that we can share across multiple SB packages (like @storybook/cli)
export interface PackageJson {
name: string;
version: string;
dependencies?: Record<string, string>;
devDependencies?: Record<string, string>;
peerDependencies?: Record<string, string>;
scripts?: Record<string, string>;
eslintConfig?: Record<string, any>;
type?: 'module';
[key: string]: any;
}
export { PackageJson };

// TODO: This could be exported to the outside world and used in `options.ts` file of each `@storybook/APP`
// like it's described in docs/api/new-frameworks.md
Expand Down
2 changes: 1 addition & 1 deletion code/lib/core-common/src/utils/get-storybook-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const logger = console;

const findDependency = (
{ dependencies, devDependencies, peerDependencies }: PackageJson,
predicate: (entry: [string, string]) => string
predicate: (entry: [string, string | undefined]) => string
) => [
Object.entries(dependencies || {}).find(predicate),
Object.entries(devDependencies || {}).find(predicate),
Expand Down
2 changes: 1 addition & 1 deletion code/lib/telemetry/src/storybook-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export const getStorybookMetadata = async (_configDir?: string) => {
return cachedMetadata;
}

const { packageJson = {} as PackageJson } = readPkgUp.sync({ cwd: process.cwd() }) || {};
const { packageJson = {} } = readPkgUp.sync({ cwd: process.cwd(), normalize: false }) || {};
const configDir =
(_configDir ||
(getStorybookConfiguration(
Expand Down
8 changes: 8 additions & 0 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7927,6 +7927,7 @@ __metadata:
slash: ^3.0.0
telejson: ^6.0.8
ts-dedent: ^2.0.0
type-fest: ^2.17.0
typescript: ~4.6.3
util-deprecate: ^1.0.2
peerDependencies:
Expand Down Expand Up @@ -43037,6 +43038,13 @@ __metadata:
languageName: node
linkType: hard

"type-fest@npm:^2.17.0":
version: 2.17.0
resolution: "type-fest@npm:2.17.0"
checksum: e7707e5c27213919483011d127f333432d82d06b697ca0577cc828b53d384372b4308d3294e849b0111a34fdc7adf5bdef58c5ffa80aa36d19e9851b2a8d9970
languageName: node
linkType: hard

"type-is@npm:~1.6.17, type-is@npm:~1.6.18":
version: 1.6.18
resolution: "type-is@npm:1.6.18"
Expand Down