@pixeleye/cli-config
Advanced tools
Comparing version 0.4.9 to 0.5.0
@@ -35,2 +35,3 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { | ||
import { fileURLToPath } from "node:url"; | ||
import fb from "fast-glob"; | ||
var _filename = typeof __filename !== "undefined" ? __filename : fileURLToPath(import.meta.url); | ||
@@ -66,3 +67,3 @@ var jiti = null; | ||
} | ||
function readConfig(path) { | ||
function readFile(path) { | ||
let config = function() { | ||
@@ -94,3 +95,3 @@ try { | ||
const relativePath = join(process.cwd(), path ?? ""); | ||
let userConfig = readConfig(relativePath); | ||
let userConfig = readFile(relativePath); | ||
if (typeof userConfig === "function") { | ||
@@ -110,2 +111,6 @@ userConfig = await userConfig().catch((err) => { | ||
const merged = mergeObjects(defaultConfig, userConfig); | ||
if (typeof merged.snapshotFiles === "function") { | ||
const { snapshotFiles: _, ...rest } = merged; | ||
merged.snapshotFiles = await merged.snapshotFiles(rest); | ||
} | ||
for (const key of Object.keys(merged)) { | ||
@@ -120,2 +125,13 @@ if (typeof merged[key] === "string") { | ||
} | ||
async function readSnapshotFiles(files) { | ||
const fileNames = await fb(files, { | ||
absolute: true | ||
}); | ||
return Promise.all( | ||
fileNames.map(async (fileName) => { | ||
const content = readFile(fileName); | ||
return typeof content === "function" ? content() : content; | ||
}) | ||
).then((results) => results.flat()); | ||
} | ||
@@ -142,3 +158,5 @@ // src/getConfig.ts | ||
getEnvConfig, | ||
loadConfig | ||
loadConfig, | ||
readFile, | ||
readSnapshotFiles | ||
}; |
@@ -1,3 +0,5 @@ | ||
import { Config } from "./types"; | ||
import { Config, SnapshotDefinition } from "./types"; | ||
export declare function readFile<T>(path: string): T | (() => Promise<T>); | ||
export declare function loadConfig(path?: string): Promise<Config>; | ||
export declare function readSnapshotFiles(files: string[]): Promise<SnapshotDefinition[]>; | ||
//# sourceMappingURL=loadConfig.d.ts.map |
import { DeviceDescriptor } from "@pixeleye/cli-devices"; | ||
export type DomEnvironment = "jsdom" | "happy-dom"; | ||
export type SnapshotDefinition = { | ||
/** | ||
* The URL that you want to capture a screenshot of. | ||
*/ | ||
url: string; | ||
/** | ||
* The name of the snapshot. | ||
* We default to the URL if no name is provided. | ||
*/ | ||
name?: string; | ||
/** | ||
* The variant of the snapshot. | ||
* This will make up part of the snapshots name. | ||
* @example "Dark" | ||
*/ | ||
variant?: string; | ||
/** | ||
* Provide an array of css selectors and we will wait for it before capturing the screenshot. | ||
* Unlike `selector`, we won't only capture this selector. We just wait for it. | ||
* `waitForSelectors` is waited for before `selector`. | ||
*/ | ||
waitForSelectors?: string[]; | ||
/** | ||
* Provide a css selector and we wait for it and only capture the screenshot of the element. | ||
* `waitForSelectors` is waited for before `selector`. | ||
*/ | ||
selector?: string; | ||
/** | ||
* A list of css selectors that you want to mask. | ||
* We will mask these elements with the color defined in the config. | ||
*/ | ||
maskSelectors?: string[]; | ||
/** | ||
* Mask color for this snapshot. | ||
* This will override the mask color defined in the config. | ||
*/ | ||
maskColor?: string; | ||
/** | ||
* Should we capture the full page? If true, we will capture the entire page. | ||
* | ||
* @default false | ||
*/ | ||
fullPage?: boolean; | ||
/** | ||
* The css that you want to inject into the page before capturing the screenshot. | ||
* This will be combined with the css defined in the config. | ||
* @example "body { background-color: red; }" | ||
*/ | ||
css?: string; | ||
}; | ||
export type StorybookVariant = { | ||
@@ -70,3 +119,10 @@ /** | ||
}; | ||
/** | ||
* An array of file matchers which contain snapshot definition files | ||
* | ||
* @example ['./snaps.pixeleye.ts', './src/*.pixeleye.ts'] | ||
*/ | ||
snapshotFiles?: string[] | ((config: ConfigWithoutSnapshotFiles) => Promise<string[]>); | ||
}; | ||
export type ConfigWithoutSnapshotFiles = Omit<Config, "snapshotFiles">; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@pixeleye/cli-config", | ||
"version": "0.4.9", | ||
"version": "0.5.0", | ||
"private": false, | ||
@@ -25,2 +25,3 @@ "license": "AGPL-3.0", | ||
"dependencies": { | ||
"fast-glob": "^3.3.2", | ||
"jiti": "^1.21.0", | ||
@@ -27,0 +28,0 @@ "sucrase": "^3.35.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
3444352
65716
0
5
+ Addedfast-glob@^3.3.2
+ Added@nodelib/fs.scandir@2.1.5(transitive)
+ Added@nodelib/fs.stat@2.0.5(transitive)
+ Added@nodelib/fs.walk@1.2.8(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedfast-glob@3.3.2(transitive)
+ Addedfastq@1.17.1(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedglob-parent@5.1.2(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedmerge2@1.4.1(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedqueue-microtask@1.2.3(transitive)
+ Addedreusify@1.0.4(transitive)
+ Addedrun-parallel@1.2.0(transitive)
+ Addedto-regex-range@5.0.1(transitive)