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

Bump Snyk Lockfile Parser Dependency #743

Merged
merged 5 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
70 changes: 43 additions & 27 deletions bin-src/lib/getStorybookInfo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ describe('getStorybookInfo', () => {

it('returns viewLayer and version', async () => {
const ctx = getContext({ packageJson: { dependencies: REACT } });
await expect(getStorybookInfo(ctx)).resolves.toEqual(
const sbInfo = await getStorybookInfo(ctx);
expect(sbInfo).toEqual(
// We're getting the result of tracing chromatic-cli's node_modules here.
expect.objectContaining({
viewLayer: 'react',
Expand Down Expand Up @@ -55,14 +56,19 @@ describe('getStorybookInfo', () => {
);
});

it('throws on missing package', async () => {
it('returns other metadate if missing view layer package', async () => {
thafryer marked this conversation as resolved.
Show resolved Hide resolved
const ctx = getContext({ packageJson: { dependencies: VUE } });
await expect(getStorybookInfo(ctx)).resolves.toEqual({
addons: [],
version: null,
viewLayer: null,
builder: null,
});
await expect(getStorybookInfo(ctx)).resolves.toEqual(
expect.objectContaining({
addons: [
{
name: 'viewport',
packageName: '@storybook/addon-viewport',
},
],
builder: { name: 'webpack5', packageVersion: '6.5.6' },
})
);
});

it('looks up package in node_modules on missing dependency', async () => {
Expand All @@ -84,7 +90,7 @@ describe('getStorybookInfo', () => {
const ctx = getContext({
env: { CHROMATIC_STORYBOOK_VERSION: '@storybook/[email protected]' },
});
await expect(getStorybookInfo(ctx)).resolves.toEqual(
expect(await getStorybookInfo(ctx)).toEqual(
expect.objectContaining({
viewLayer: 'react',
version: '3.2.1',
Expand All @@ -95,7 +101,7 @@ describe('getStorybookInfo', () => {

it('supports unscoped package name', async () => {
const ctx = getContext({ env: { CHROMATIC_STORYBOOK_VERSION: '[email protected]' } });
await expect(getStorybookInfo(ctx)).resolves.toEqual(
expect(await getStorybookInfo(ctx)).toEqual(
expect.objectContaining({
viewLayer: 'react',
version: '3.2.1',
Expand All @@ -104,24 +110,34 @@ describe('getStorybookInfo', () => {
);
});

it('throws on invalid value', async () => {
it('still returns addons and builder for invalid version value', async () => {
const ctx = getContext({ env: { CHROMATIC_STORYBOOK_VERSION: '3.2.1' } });
await expect(getStorybookInfo(ctx)).resolves.toEqual({
addons: [],
version: null,
viewLayer: null,
builder: null,
});
expect(await getStorybookInfo(ctx)).toEqual(
expect.objectContaining({
addons: [
{
name: 'viewport',
packageName: '@storybook/addon-viewport',
},
],
builder: { name: 'webpack5', packageVersion: '6.5.6' },
})
);
});

it('throws on unsupported viewlayer', async () => {
it('does not include unsupported view layers', async () => {
const ctx = getContext({ env: { CHROMATIC_STORYBOOK_VERSION: '@storybook/[email protected]' } });
await expect(getStorybookInfo(ctx)).resolves.toEqual({
addons: [],
version: null,
viewLayer: null,
builder: null,
});
expect(await getStorybookInfo(ctx)).toEqual(
expect.objectContaining({
addons: [
{
name: 'viewport',
packageName: '@storybook/addon-viewport',
},
],
builder: { name: 'webpack5', packageVersion: '6.5.6' },
})
);
});
});

Expand All @@ -131,7 +147,7 @@ describe('getStorybookInfo', () => {
options: { storybookBuildDir: 'bin-src/__mocks__/normalProjectJson' },
packageJson: { dependencies: REACT },
});
await expect(getStorybookInfo(ctx)).resolves.toEqual({
expect(await getStorybookInfo(ctx)).toEqual({
addons: [
{
name: 'viewport',
Expand All @@ -150,7 +166,7 @@ describe('getStorybookInfo', () => {
options: { storybookBuildDir: 'bin-src/__mocks__/malformedProjectJson' },
packageJson: { dependencies: REACT },
});
await expect(getStorybookInfo(ctx)).resolves.toEqual({
expect(await getStorybookInfo(ctx)).toEqual({
addons: [],
version: null,
viewLayer: null,
Expand All @@ -163,7 +179,7 @@ describe('getStorybookInfo', () => {
options: { storybookBuildDir: 'bin-src/__mocks__/unsupportedAddons' },
packageJson: { dependencies: REACT },
});
await expect(getStorybookInfo(ctx)).resolves.toEqual({
expect(await getStorybookInfo(ctx)).toEqual({
addons: [
{
name: 'viewport',
Expand Down
11 changes: 10 additions & 1 deletion bin-src/lib/getStorybookMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,14 @@ export const getStorybookMetadata = async (ctx: Context) => {
findBuilder(mainConfig),
]);
ctx.log.debug(info);
return info.reduce((acc, obj) => Object.assign(acc, obj), {});
let metadata = {};
info.forEach((sbItem) => {
if (sbItem.status === 'fulfilled') {
metadata = {
...metadata,
...(sbItem?.value as any),
};
}
});
return metadata;
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chromatic",
"version": "6.17.4-next.0",
"version": "6.17.4-next.1",
"description": "Automate visual testing across browsers. Gather UI feedback. Versioned documentation.",
"keywords": [
"storybook-addon",
Expand Down Expand Up @@ -75,7 +75,7 @@
"dependencies": {
"@discoveryjs/json-ext": "^0.5.7",
"@types/webpack-env": "^1.17.0",
"snyk-nodejs-lockfile-parser": "^1.47.4"
"snyk-nodejs-lockfile-parser": "^1.49.0"
},
"devDependencies": {
"@actions/core": "^1.10.0",
Expand Down
22 changes: 16 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4791,7 +4791,7 @@ braces@^2.3.1, braces@^2.3.2:
split-string "^3.0.2"
to-regex "^3.0.1"

braces@^3.0.1, braces@~3.0.2:
braces@^3.0.1, braces@^3.0.2, braces@~3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
Expand Down Expand Up @@ -10309,6 +10309,14 @@ micromatch@^4.0.0, micromatch@^4.0.2, micromatch@^4.0.4:
braces "^3.0.1"
picomatch "^2.2.3"

micromatch@^4.0.5:
version "4.0.5"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6"
integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==
dependencies:
braces "^3.0.2"
picomatch "^2.3.1"

miller-rabin@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d"
Expand Down Expand Up @@ -11358,7 +11366,7 @@ picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.3:
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.0.tgz#f1f061de8f6a4bf022892e2d128234fb98302972"
integrity sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==

picomatch@^2.3.0:
picomatch@^2.3.0, picomatch@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==
Expand Down Expand Up @@ -13126,10 +13134,10 @@ snyk-config@^5.0.0:
lodash.merge "^4.6.2"
minimist "^1.2.5"

snyk-nodejs-lockfile-parser@^1.47.4:
version "1.47.4"
resolved "https://registry.yarnpkg.com/snyk-nodejs-lockfile-parser/-/snyk-nodejs-lockfile-parser-1.47.4.tgz#4e554e9f1400e27aeac51c3f1665a7b7b053c92c"
integrity sha512-qNrhOBVR0rw9/ztZqC8BTHrgAOd1+m1fUpC4UE6DkI75bZecSRTkCjTs4cW4hiEck2lMeRxQ07Wci2fqqUyzrQ==
snyk-nodejs-lockfile-parser@^1.49.0:
version "1.49.0"
resolved "https://registry.yarnpkg.com/snyk-nodejs-lockfile-parser/-/snyk-nodejs-lockfile-parser-1.49.0.tgz#5185e4ce0f471a989cc22ea9c0bd0d6fd5770403"
integrity sha512-73iqwHB8YSWex/PTx+TRUwtNPyKn5wP4n/kxEPbX9EfN3uSIcw6mSKiLm8gSKl5gtf8hcP0R0f1tBFjjdzQvRQ==
dependencies:
"@snyk/dep-graph" "^2.3.0"
"@snyk/graphlib" "2.1.9-patch.3"
Expand All @@ -13141,6 +13149,8 @@ snyk-nodejs-lockfile-parser@^1.47.4:
lodash.flatmap "^4.5.0"
lodash.isempty "^4.4.0"
lodash.topairs "^4.3.0"
micromatch "^4.0.5"
p-map "^4.0.0"
semver "^7.3.5"
snyk-config "^5.0.0"
tslib "^1.9.3"
Expand Down