@chromatic-com/cypress 0.12.5 → 0.12.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 +40 -30
- package/dist/index.mjs +40 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ var path2 = require('path');
|
|
|
5
5
|
var fs = require('fs');
|
|
6
6
|
var promises = require('fs/promises');
|
|
7
7
|
var crypto = require('crypto');
|
|
8
|
+
var csf = require('storybook/internal/csf');
|
|
8
9
|
var analyticsNode = require('@segment/analytics-node');
|
|
9
10
|
|
|
10
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -3868,6 +3869,7 @@ __name(viewportToString, "viewportToString");
|
|
|
3868
3869
|
var sanitize = /* @__PURE__ */ __name((string) => {
|
|
3869
3870
|
return string.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").replace(/[\r\n]/g, "-").replace(/-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
|
|
3870
3871
|
}, "sanitize");
|
|
3872
|
+
var collapseNewlines = /* @__PURE__ */ __name((title) => title.replace(/[\r\n]+/g, " ").trim(), "collapseNewlines");
|
|
3871
3873
|
|
|
3872
3874
|
// ../shared/src/write-archive/snapshot-files.ts
|
|
3873
3875
|
var SNAPSHOT_FILE_EXT = "snapshot.json";
|
|
@@ -3886,49 +3888,57 @@ function snapshotFileName(snapshotId2, viewport) {
|
|
|
3886
3888
|
return fileNameParts.join(".");
|
|
3887
3889
|
}
|
|
3888
3890
|
__name(snapshotFileName, "snapshotFileName");
|
|
3889
|
-
|
|
3890
|
-
// ../shared/src/write-archive/stories-files.ts
|
|
3891
3891
|
var STORIES_FILE_EXT = "stories.json";
|
|
3892
|
+
var uniqueId = {
|
|
3893
|
+
value: 1
|
|
3894
|
+
};
|
|
3892
3895
|
function storiesFileName(testTitle) {
|
|
3893
3896
|
const fileName = [
|
|
3894
|
-
sanitize(testTitle)
|
|
3897
|
+
sanitize(testTitle) + "-" + uniqueId.value++,
|
|
3895
3898
|
STORIES_FILE_EXT
|
|
3896
3899
|
].join(".");
|
|
3897
3900
|
const maxByteLength = MAX_FILE_NAME_BYTE_LENGTH - 25;
|
|
3898
3901
|
return truncateFileName(fileName, maxByteLength);
|
|
3899
3902
|
}
|
|
3900
3903
|
__name(storiesFileName, "storiesFileName");
|
|
3901
|
-
function createStories(
|
|
3904
|
+
function createStories(storyTitle, domSnapshots, chromaticStorybookParams) {
|
|
3905
|
+
const title = collapseNewlines(storyTitle);
|
|
3902
3906
|
return {
|
|
3903
3907
|
title,
|
|
3904
|
-
stories: Object.entries(domSnapshots).map(([
|
|
3905
|
-
name
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
server: {
|
|
3914
|
-
id: snapshotId(title, name)
|
|
3915
|
-
},
|
|
3916
|
-
chromatic: {
|
|
3917
|
-
...chromaticStorybookParams,
|
|
3918
|
-
modes: buildStoryModesConfig([
|
|
3919
|
-
viewport
|
|
3920
|
-
])
|
|
3908
|
+
stories: Object.entries(domSnapshots).map(([snapshotName, { viewport }]) => {
|
|
3909
|
+
const name = collapseNewlines(snapshotName);
|
|
3910
|
+
return {
|
|
3911
|
+
name,
|
|
3912
|
+
// Viewport addon (Storybook 10+): `parameters.viewport.options` registers sizes; `globals.viewport`
|
|
3913
|
+
// selects the active one. See https://storybook.js.org/docs/essentials/viewport#defining-the-viewport-for-a-story
|
|
3914
|
+
// `defaultViewport` is not read by SB 10's types but our archive preview uses it as a fetch fallback.
|
|
3915
|
+
globals: {
|
|
3916
|
+
viewport: viewportToString(viewport)
|
|
3921
3917
|
},
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3918
|
+
parameters: {
|
|
3919
|
+
// Work-around for cases where "あ" in story name would cause Storybook to fail to load the story due to an invalid story ID.
|
|
3920
|
+
// See https://github.com/chromaui/chromatic-e2e/issues/365
|
|
3921
|
+
__id: csf.toId(title, csf.storyNameFromExport(name)),
|
|
3922
|
+
server: {
|
|
3923
|
+
id: snapshotId(title, name)
|
|
3924
|
+
},
|
|
3925
|
+
chromatic: {
|
|
3926
|
+
...chromaticStorybookParams,
|
|
3927
|
+
modes: buildStoryModesConfig([
|
|
3928
|
+
viewport
|
|
3929
|
+
])
|
|
3930
|
+
},
|
|
3931
|
+
viewport: {
|
|
3932
|
+
options: buildStoryViewportsConfig([
|
|
3933
|
+
viewport
|
|
3934
|
+
]),
|
|
3935
|
+
defaultViewport: viewportToString(findDefaultViewport([
|
|
3936
|
+
viewport
|
|
3937
|
+
]))
|
|
3938
|
+
}
|
|
3929
3939
|
}
|
|
3930
|
-
}
|
|
3931
|
-
})
|
|
3940
|
+
};
|
|
3941
|
+
})
|
|
3932
3942
|
};
|
|
3933
3943
|
}
|
|
3934
3944
|
__name(createStories, "createStories");
|
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import path2, { join } from 'path';
|
|
|
3
3
|
import { existsSync, mkdirSync } from 'fs';
|
|
4
4
|
import { writeFile } from 'fs/promises';
|
|
5
5
|
import { createHash } from 'crypto';
|
|
6
|
+
import { toId, storyNameFromExport } from 'storybook/internal/csf';
|
|
6
7
|
import { Analytics } from '@segment/analytics-node';
|
|
7
8
|
|
|
8
9
|
var __create = Object.create;
|
|
@@ -3861,6 +3862,7 @@ __name(viewportToString, "viewportToString");
|
|
|
3861
3862
|
var sanitize = /* @__PURE__ */ __name((string) => {
|
|
3862
3863
|
return string.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").replace(/[\r\n]/g, "-").replace(/-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
|
|
3863
3864
|
}, "sanitize");
|
|
3865
|
+
var collapseNewlines = /* @__PURE__ */ __name((title) => title.replace(/[\r\n]+/g, " ").trim(), "collapseNewlines");
|
|
3864
3866
|
|
|
3865
3867
|
// ../shared/src/write-archive/snapshot-files.ts
|
|
3866
3868
|
var SNAPSHOT_FILE_EXT = "snapshot.json";
|
|
@@ -3879,49 +3881,57 @@ function snapshotFileName(snapshotId2, viewport) {
|
|
|
3879
3881
|
return fileNameParts.join(".");
|
|
3880
3882
|
}
|
|
3881
3883
|
__name(snapshotFileName, "snapshotFileName");
|
|
3882
|
-
|
|
3883
|
-
// ../shared/src/write-archive/stories-files.ts
|
|
3884
3884
|
var STORIES_FILE_EXT = "stories.json";
|
|
3885
|
+
var uniqueId = {
|
|
3886
|
+
value: 1
|
|
3887
|
+
};
|
|
3885
3888
|
function storiesFileName(testTitle) {
|
|
3886
3889
|
const fileName = [
|
|
3887
|
-
sanitize(testTitle)
|
|
3890
|
+
sanitize(testTitle) + "-" + uniqueId.value++,
|
|
3888
3891
|
STORIES_FILE_EXT
|
|
3889
3892
|
].join(".");
|
|
3890
3893
|
const maxByteLength = MAX_FILE_NAME_BYTE_LENGTH - 25;
|
|
3891
3894
|
return truncateFileName(fileName, maxByteLength);
|
|
3892
3895
|
}
|
|
3893
3896
|
__name(storiesFileName, "storiesFileName");
|
|
3894
|
-
function createStories(
|
|
3897
|
+
function createStories(storyTitle, domSnapshots, chromaticStorybookParams) {
|
|
3898
|
+
const title = collapseNewlines(storyTitle);
|
|
3895
3899
|
return {
|
|
3896
3900
|
title,
|
|
3897
|
-
stories: Object.entries(domSnapshots).map(([
|
|
3898
|
-
name
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
server: {
|
|
3907
|
-
id: snapshotId(title, name)
|
|
3908
|
-
},
|
|
3909
|
-
chromatic: {
|
|
3910
|
-
...chromaticStorybookParams,
|
|
3911
|
-
modes: buildStoryModesConfig([
|
|
3912
|
-
viewport
|
|
3913
|
-
])
|
|
3901
|
+
stories: Object.entries(domSnapshots).map(([snapshotName, { viewport }]) => {
|
|
3902
|
+
const name = collapseNewlines(snapshotName);
|
|
3903
|
+
return {
|
|
3904
|
+
name,
|
|
3905
|
+
// Viewport addon (Storybook 10+): `parameters.viewport.options` registers sizes; `globals.viewport`
|
|
3906
|
+
// selects the active one. See https://storybook.js.org/docs/essentials/viewport#defining-the-viewport-for-a-story
|
|
3907
|
+
// `defaultViewport` is not read by SB 10's types but our archive preview uses it as a fetch fallback.
|
|
3908
|
+
globals: {
|
|
3909
|
+
viewport: viewportToString(viewport)
|
|
3914
3910
|
},
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3911
|
+
parameters: {
|
|
3912
|
+
// Work-around for cases where "あ" in story name would cause Storybook to fail to load the story due to an invalid story ID.
|
|
3913
|
+
// See https://github.com/chromaui/chromatic-e2e/issues/365
|
|
3914
|
+
__id: toId(title, storyNameFromExport(name)),
|
|
3915
|
+
server: {
|
|
3916
|
+
id: snapshotId(title, name)
|
|
3917
|
+
},
|
|
3918
|
+
chromatic: {
|
|
3919
|
+
...chromaticStorybookParams,
|
|
3920
|
+
modes: buildStoryModesConfig([
|
|
3921
|
+
viewport
|
|
3922
|
+
])
|
|
3923
|
+
},
|
|
3924
|
+
viewport: {
|
|
3925
|
+
options: buildStoryViewportsConfig([
|
|
3926
|
+
viewport
|
|
3927
|
+
]),
|
|
3928
|
+
defaultViewport: viewportToString(findDefaultViewport([
|
|
3929
|
+
viewport
|
|
3930
|
+
]))
|
|
3931
|
+
}
|
|
3922
3932
|
}
|
|
3923
|
-
}
|
|
3924
|
-
})
|
|
3933
|
+
};
|
|
3934
|
+
})
|
|
3925
3935
|
};
|
|
3926
3936
|
}
|
|
3927
3937
|
__name(createStories, "createStories");
|