@percy/cli-upload 1.19.2-alpha.0 → 1.19.2
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/package.json +3 -3
- package/dist/resources.js +0 -55
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/cli-upload",
|
|
3
|
-
"version": "1.19.2
|
|
3
|
+
"version": "1.19.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
]
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@percy/cli-command": "1.19.2
|
|
35
|
+
"@percy/cli-command": "1.19.2",
|
|
36
36
|
"fast-glob": "^3.2.11",
|
|
37
37
|
"image-size": "^1.0.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "609ae53aa84ab2f7054a21214b36dccd71025780"
|
|
40
40
|
}
|
package/dist/resources.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { sha256hash } from '@percy/client/utils';
|
|
3
|
-
|
|
4
|
-
// Returns a root resource object with a sha and mimetype.
|
|
5
|
-
function createRootResource(url, content) {
|
|
6
|
-
return {
|
|
7
|
-
url,
|
|
8
|
-
content,
|
|
9
|
-
sha: sha256hash(content),
|
|
10
|
-
mimetype: 'text/html',
|
|
11
|
-
root: true
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Returns an image resource object with a sha.
|
|
16
|
-
function createImageResource(url, content, mimetype) {
|
|
17
|
-
return {
|
|
18
|
-
url,
|
|
19
|
-
content,
|
|
20
|
-
sha: sha256hash(content),
|
|
21
|
-
mimetype
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Returns root resource and image resource objects based on an image's
|
|
26
|
-
// filename, contents, and dimensions. The root resource is a generated DOM
|
|
27
|
-
// designed to display an image at it's native size without margins or padding.
|
|
28
|
-
export function createImageResources(filename, content, size) {
|
|
29
|
-
let {
|
|
30
|
-
dir,
|
|
31
|
-
name,
|
|
32
|
-
ext
|
|
33
|
-
} = path.parse(filename);
|
|
34
|
-
let rootUrl = `/${encodeURIComponent(path.join(dir, name))}`;
|
|
35
|
-
let imageUrl = `/${encodeURIComponent(filename)}`;
|
|
36
|
-
let mimetype = ext === '.png' ? 'image/png' : 'image/jpeg';
|
|
37
|
-
return [createRootResource(rootUrl, `
|
|
38
|
-
<!doctype html>
|
|
39
|
-
<html lang="en">
|
|
40
|
-
<head>
|
|
41
|
-
<meta charset="utf-8">
|
|
42
|
-
<title>${filename}</title>
|
|
43
|
-
<style>
|
|
44
|
-
*, *::before, *::after { margin: 0; padding: 0; font-size: 0; }
|
|
45
|
-
html, body { width: 100%; }
|
|
46
|
-
img { max-width: 100%; }
|
|
47
|
-
</style>
|
|
48
|
-
</head>
|
|
49
|
-
<body>
|
|
50
|
-
<img src="${imageUrl}" width="${size.width}px" height="${size.height}px"/>
|
|
51
|
-
</body>
|
|
52
|
-
</html>
|
|
53
|
-
`), createImageResource(imageUrl, content, mimetype)];
|
|
54
|
-
}
|
|
55
|
-
export default createImageResources;
|