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

feat: update icons with new design #20338

Merged
merged 157 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from 152 commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
b198e4b
add icons from macos and windows
elevatebart Feb 17, 2022
d76adb5
configure release
elevatebart Feb 17, 2022
351884b
chore: add examples
lmiller1990 Feb 22, 2022
146df43
update
lmiller1990 Feb 22, 2022
58a7919
add vue cli vue 2
lmiller1990 Feb 22, 2022
3d79c52
pull in changes from lmiller1990/UNIFY-1180-add-examples
lmiller1990 Feb 23, 2022
72b3540
cleanup icons and update necessary ones
elevatebart Feb 23, 2022
5d02cea
update bash script to fail if fails
elevatebart Feb 23, 2022
2388544
skip step on all platforms except darwin
elevatebart Feb 23, 2022
0b1707b
add semicolons...
elevatebart Feb 23, 2022
dfb4216
fix build script
elevatebart Feb 23, 2022
900b8fa
remove bluebird form electron install
elevatebart Feb 23, 2022
8a3b5ef
icons are updated on local envs
elevatebart Feb 23, 2022
d80cddd
update deps
lmiller1990 Feb 24, 2022
8c51fdd
cra5
lmiller1990 Feb 24, 2022
8bbb1de
resolve
lmiller1990 Feb 22, 2022
c658dbe
wip
lmiller1990 Feb 22, 2022
5739e32
remove old code
lmiller1990 Feb 22, 2022
6f88f18
types
lmiller1990 Feb 22, 2022
da535c2
rebase pt1
lmiller1990 Feb 24, 2022
f60f8d3
add test for cra
lmiller1990 Feb 22, 2022
7114ed7
linting
lmiller1990 Feb 22, 2022
2430620
fixl int
lmiller1990 Feb 22, 2022
667b4bf
resolve
lmiller1990 Feb 22, 2022
e74c2a0
remove old code
lmiller1990 Feb 22, 2022
fa2601d
make scaffold config env agnostic
lmiller1990 Feb 22, 2022
dea7b91
rebase pt2
lmiller1990 Feb 24, 2022
a0f16a4
add test
lmiller1990 Feb 22, 2022
7ce3e69
work on react vite
lmiller1990 Feb 22, 2022
ede210a
update test for react vite
lmiller1990 Feb 22, 2022
74b7146
add vite vue 3 project
lmiller1990 Feb 22, 2022
b3f7eb5
add vue 3 vite example
lmiller1990 Feb 22, 2022
17a44d6
add missing package
lmiller1990 Feb 22, 2022
3c27e9f
rebase
lmiller1990 Feb 24, 2022
221d00b
rebase
lmiller1990 Feb 24, 2022
0703ee6
rebase
lmiller1990 Feb 24, 2022
41ce647
fix some tests
lmiller1990 Feb 22, 2022
edcdb43
fix test
lmiller1990 Feb 22, 2022
bfecd77
update detect logic
lmiller1990 Feb 22, 2022
677bc0e
remove old tests
lmiller1990 Feb 23, 2022
3f63cd4
type all the things
lmiller1990 Feb 23, 2022
41afe65
ts
lmiller1990 Feb 23, 2022
1fb0eda
types
lmiller1990 Feb 23, 2022
e7c6a9b
skip ci
lmiller1990 Feb 23, 2022
4bf00e1
update logic
lmiller1990 Feb 23, 2022
b846503
fix bug
lmiller1990 Feb 23, 2022
50ddbc7
lockfile
lmiller1990 Feb 23, 2022
3e83975
fix bug in test
lmiller1990 Feb 23, 2022
0aa9375
fix tests
lmiller1990 Feb 23, 2022
82adec0
simplify
lmiller1990 Feb 23, 2022
1fbdf61
docs
lmiller1990 Feb 23, 2022
de60dd5
types
lmiller1990 Feb 23, 2022
acd9fa7
rebase
lmiller1990 Feb 24, 2022
5cb9e19
fix unit test
lmiller1990 Feb 24, 2022
50e1b61
fix tests
lmiller1990 Feb 24, 2022
6a14929
types
lmiller1990 Feb 24, 2022
8bbcb49
fix bug in detection
lmiller1990 Feb 24, 2022
0f67dad
fix tests
lmiller1990 Feb 24, 2022
128d7d7
fix deps
lmiller1990 Feb 24, 2022
046f18c
rebase
lmiller1990 Feb 24, 2022
7518d30
rebase
lmiller1990 Feb 24, 2022
2376122
revert lockfiles
lmiller1990 Feb 24, 2022
57fe53b
yarn lock
lmiller1990 Feb 24, 2022
0a83650
resolve
lmiller1990 Feb 22, 2022
5e5c5f8
wip
lmiller1990 Feb 22, 2022
d815b67
remove old code
lmiller1990 Feb 22, 2022
8496130
types
lmiller1990 Feb 22, 2022
e02e315
rebase pt1
lmiller1990 Feb 24, 2022
eab911a
add test for cra
lmiller1990 Feb 22, 2022
847f899
linting
lmiller1990 Feb 22, 2022
d23ffd1
fixl int
lmiller1990 Feb 22, 2022
b090ee5
resolve
lmiller1990 Feb 22, 2022
a2e7512
remove old code
lmiller1990 Feb 22, 2022
ebb248d
make scaffold config env agnostic
lmiller1990 Feb 22, 2022
3c4177e
rebase pt2
lmiller1990 Feb 24, 2022
ccab2f8
add test
lmiller1990 Feb 22, 2022
042e877
work on react vite
lmiller1990 Feb 22, 2022
595aafe
update test for react vite
lmiller1990 Feb 22, 2022
fbe0915
add vite vue 3 project
lmiller1990 Feb 22, 2022
42c58c7
add vue 3 vite example
lmiller1990 Feb 22, 2022
5ffb86f
add missing package
lmiller1990 Feb 22, 2022
ee83d26
rebase
lmiller1990 Feb 24, 2022
a9953c9
rebase
lmiller1990 Feb 24, 2022
7d0d8c5
rebase
lmiller1990 Feb 24, 2022
0b38cc4
fix some tests
lmiller1990 Feb 22, 2022
a347267
fix test
lmiller1990 Feb 22, 2022
10c0c1e
update detect logic
lmiller1990 Feb 22, 2022
40a4c46
remove old tests
lmiller1990 Feb 23, 2022
96758ce
type all the things
lmiller1990 Feb 23, 2022
e783c1a
ts
lmiller1990 Feb 23, 2022
21c2147
types
lmiller1990 Feb 23, 2022
fc6a7c1
skip ci
lmiller1990 Feb 23, 2022
b9c6bde
update logic
lmiller1990 Feb 23, 2022
0ef0d57
fix bug
lmiller1990 Feb 23, 2022
7a5a597
lockfile
lmiller1990 Feb 23, 2022
a0783ba
fix bug in test
lmiller1990 Feb 23, 2022
91842b5
fix tests
lmiller1990 Feb 23, 2022
1bfc6d1
simplify
lmiller1990 Feb 23, 2022
6744bcd
docs
lmiller1990 Feb 23, 2022
d74bfab
types
lmiller1990 Feb 23, 2022
de4df77
rebase
lmiller1990 Feb 24, 2022
6a8ecb9
fix unit test
lmiller1990 Feb 24, 2022
edad2d2
fix tests
lmiller1990 Feb 24, 2022
b9d0af3
types
lmiller1990 Feb 24, 2022
9e0bade
fix bug in detection
lmiller1990 Feb 24, 2022
5132870
fix tests
lmiller1990 Feb 24, 2022
33d61d8
fix deps
lmiller1990 Feb 24, 2022
db774f9
rebase
lmiller1990 Feb 24, 2022
823d673
rebase
lmiller1990 Feb 24, 2022
0f92069
revert lockfiles
lmiller1990 Feb 24, 2022
0c19a80
Merge branch 'lmiller1990/UNIFY-1180-attempt-rebase' of https://githu…
lmiller1990 Feb 24, 2022
cdaee66
fix test
lmiller1990 Feb 24, 2022
64b6a8c
update lockfile
lmiller1990 Feb 24, 2022
b756f6d
fix test
lmiller1990 Feb 24, 2022
bdadb8c
try timeout longer
lmiller1990 Feb 24, 2022
3f4df48
work around for vite on CI
lmiller1990 Feb 24, 2022
9fb36f0
Merge branch '10.0-release' into elevatebart/feat/add-icons
Feb 24, 2022
282f2e7
Merge branch '10.0-release' into elevatebart/feat/add-icons
Feb 24, 2022
597d92c
move icons into packages
elevatebart Feb 24, 2022
234b74b
Merge branch '10.0-release' into elevatebart/feat/add-icons
Feb 24, 2022
b36d7da
restore missing file
elevatebart Feb 24, 2022
b50047c
Merge branch '10.0-release' into elevatebart/feat/add-icons
Feb 24, 2022
4317ec8
try/catch
lmiller1990 Feb 25, 2022
eb694fe
spread
lmiller1990 Feb 25, 2022
c64eda4
typo
lmiller1990 Feb 25, 2022
107cd32
add deps for frameworks
lmiller1990 Feb 25, 2022
d26dfab
vue3 + vite
lmiller1990 Feb 25, 2022
86081dc
rejig deps
lmiller1990 Feb 25, 2022
b38beb6
make icons typescript
elevatebart Feb 25, 2022
1352c93
last ts fixes
elevatebart Feb 25, 2022
011fd0b
add comments for install
elevatebart Feb 25, 2022
9664bbc
Merge branch '10.0-release' into elevatebart/feat/add-icons
Feb 25, 2022
4ad2fff
add back stories file
elevatebart Feb 25, 2022
f3aab61
avoid deleting button.stories
elevatebart Feb 25, 2022
a3bb776
Merge branch '10.0-release' into elevatebart/feat/add-icons
Feb 25, 2022
0bb2453
Merge pull request #20350 from cypress-io/lmiller1990/UNIFY-1180-atte…
ZachJW34 Feb 25, 2022
f4e796a
Merge remote-tracking branch 'origin/10.0-release' into lmiller1990/U…
ZachJW34 Feb 25, 2022
e226f6d
Merge branch '10.0-release' into lmiller1990/UNIFY-1180-add-examples
ZachJW34 Feb 25, 2022
c8277ab
Merge branch '10.0-release' into elevatebart/feat/add-icons
Feb 25, 2022
712a319
updated the BW logo fo matching
elevatebart Feb 25, 2022
87304bc
cache-bust the favicon
elevatebart Feb 25, 2022
3b254cf
update readme
elevatebart Feb 25, 2022
bdc5743
Merge branch '10.0-release' into elevatebart/feat/add-icons
Feb 25, 2022
4555cfd
fix unit-tests
ZachJW34 Feb 25, 2022
a304f80
Merge remote-tracking branch 'origin/10.0-release' into lmiller1990/U…
ZachJW34 Feb 25, 2022
192632b
Merge pull request #20370 from cypress-io/lmiller1990/UNIFY-1180-add-…
ZachJW34 Feb 25, 2022
e4b5e9b
Merge branch '10.0-release' into elevatebart/feat/add-icons
Feb 25, 2022
26fde67
simplify cache buster
elevatebart Feb 25, 2022
e1444ed
Merge branch '10.0-release' into elevatebart/feat/add-icons
Feb 25, 2022
85bccc1
Merge branch '10.0-release' into elevatebart/feat/add-icons
Feb 26, 2022
7493ade
Merge branch '10.0-release' into elevatebart/feat/add-icons
Feb 27, 2022
7a89f70
chore: rewording readme
Feb 28, 2022
50dbf3f
chore: update readme
Feb 28, 2022
de2f06e
chore: use yarn in the readme file
elevatebart Feb 28, 2022
bb899fe
test: use proper mocha types (8.X)
elevatebart Feb 28, 2022
4fd7e45
Merge branch '10.0-release' into elevatebart/feat/add-icons
Feb 28, 2022
eee29e1
Merge branch '10.0-release' into elevatebart/feat/add-icons
Feb 28, 2022
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
4 changes: 2 additions & 2 deletions packages/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

<head>
<meta charset="utf-8" />
<link href="/__cypress/assets/favicon.png" rel="icon">
<link href="/__cypress/assets/favicon.png?v2" rel="icon">
<title>Cypress</title>
<link href="/__cypress/runner/favicon.ico" rel="icon">
<link href="/__cypress/runner/favicon.ico?v2" rel="icon">
</head>

<body>
Expand Down
2 changes: 1 addition & 1 deletion packages/data-context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"check-ts": "tsc --noEmit && yarn -s tslint",
"clean-deps": "rimraf node_modules",
"tslint": "tslint --config ../ts/tslint.json --project .",
"clean": "rimraf './{src,test}/**/*.js'",
"clean": "rimraf './{src,test}/**/*(!.stories).js'",
"test": "yarn test-unit",
"test-unit": "mocha -r @packages/ts/register --config ./test/.mocharc.js"
},
Expand Down
61 changes: 44 additions & 17 deletions packages/electron/lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
const _ = require('lodash')
const os = require('os')
const path = require('path')
const Promise = require('bluebird')
const pkg = require('../package.json')
const paths = require('./paths')
const log = require('debug')('cypress:electron')
let fs = require('fs-extra')

fs = Promise.promisifyAll(fs)
const fs = require('fs-extra')
const crypto = require('crypto')

let electronVersion

Expand All @@ -25,44 +23,65 @@ module.exports = {
// returns icons package so that the caller code can find
// paths to the icons without hard-coding them
icons () {
return require('@cypress/icons')
return require('@packages/icons')
},

checkCurrentVersion () {
const pathToVersion = paths.getPathToVersion()

// read in the version file
return fs.readFileAsync(pathToVersion, 'utf8')
return fs.readFile(pathToVersion, 'utf8')
.then((str) => {
const version = str.replace('v', '')

// and if it doesn't match the electron version
// throw an error
if (version !== electronVersion) {
throw new Error(`Currently installed version: '${version}' does not match electronVersion: '${electronVersion}`)
} else {
return process.exit()
}
})
},

getFileHash (filePath) {
return fs.readFile(filePath).then((buf) => {
const hashSum = crypto.createHash('sha1')

hashSum.update(buf)
const hash = hashSum.digest('hex')

return hash
})
},

checkIconVersion () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to update this? I see we are doing something with caching but why is this necessary just to change some icons?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On local, electron app is recompiled only if electron version changes or if the app is completely absent.
If icon is updated, no contributor will see the new icons unless they delete the dist directory manually.

I compare the icon in dist with the one in the icons package and if different, force the re-build as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a lot of code that has to be maintained for something that just requires devs to git clean -xfd once to bypass. I get why you added this, I think, but it's going to be dead code for 99.99% of runs and additional maintenance overhead, I think we could do without these checkIconVersion changes.

const mainIconsPath = this.icons().getPathToIcon('cypress.icns')
const cachedIconsPath = path.join(__dirname, '../dist/Cypress/Cypress.app/Contents/Resources/electron.icns')

return Promise.all([this.getFileHash(mainIconsPath), this.getFileHash(cachedIconsPath)])
.then(([mainHash, cachedHash]) => {
if (mainHash !== cachedHash) {
throw new Error('Icon mismatch')
}
})
},

checkExecExistence () {
return fs.statAsync(paths.getPathToExec())
return fs.stat(paths.getPathToExec())
},

move (src, dest) {
// src is ./tmp/Cypress-darwin-x64
// dest is ./dist/Cypress
return fs.moveAsync(src, dest, { overwrite: true })
return fs.move(src, dest, { overwrite: true })
.then(() => {
// remove the tmp folder now
return fs.removeAsync(path.dirname(src))
return fs.remove(path.dirname(src))
})
},

removeEmptyApp () {
// nuke the temporary blank /app
return fs.removeAsync(paths.getPathToResources('app'))
return fs.remove(paths.getPathToResources('app'))
},

packageAndExit () {
Expand All @@ -76,7 +95,7 @@ module.exports = {

package (options = {}) {
const pkgr = require('electron-packager')
const icons = require('@cypress/icons')
const icons = require('@packages/icons')

const iconPath = icons.getPathToIcon('cypress')

Expand Down Expand Up @@ -117,15 +136,23 @@ module.exports = {
},

ensure () {
return Promise.join(
return Promise.all([
// check the version of electron and re-build if updated
this.checkCurrentVersion(),
// check if the dist folder exist and re-build if not
this.checkExecExistence(),
)
// Compare the icon in dist with the one in the icons
// package. If different, force the re-build.
this.checkIconVersion(),
])

// if all is good, then return without packaging a new electron app
},

check () {
return this.ensure()
.bind(this)
.catch(this.packageAndExit)
.catch(() => {
this.packageAndExit()
})
},
}
2 changes: 1 addition & 1 deletion packages/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test-watch": "yarn test-unit --watch"
},
"dependencies": {
"@cypress/icons": "0.7.0",
"@packages/icons": "0.0.0-development",
"bluebird": "3.5.3",
"debug": "^4.3.2",
"fs-extra": "9.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/gulpfile.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import gulp from 'gulp'
import rimraf from 'rimraf'
import webpack from 'webpack'
import cypressIcons from '@cypress/icons'
import * as cypressIcons from '@packages/icons'
import webpackConfig from './webpack.config.js'

const clean = (done) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"lodash": "^4.17.21"
},
"devDependencies": {
"@cypress/icons": "0.7.0",
"@packages/icons": "0.0.0-development",
"@packages/socket": "0.0.0-development",
"chai": "3.5.0",
"coffeescript": "1.12.7",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/icons/assets/cypress.iconset/icon_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/icons/assets/favicon/favicon.ico
Binary file not shown.
Binary file added packages/icons/assets/icons/icon_128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/icons/assets/icons/icon_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/icons/assets/icons/icon_19x19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/icons/assets/icons/icon_24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/icons/assets/icons/icon_256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/icons/assets/icons/icon_32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/icons/assets/icons/icon_38x38.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/icons/assets/icons/icon_48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/icons/assets/icons/icon_48x48@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/icons/assets/icons/icon_64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/icons/assets/logo/cypress-bw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/icons/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dist/icons'
1 change: 1 addition & 0 deletions packages/icons/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/icons')
34 changes: 34 additions & 0 deletions packages/icons/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@packages/icons",
"version": "0.0.0-development",
"description": "Cypress Icons",
"main": "index.js",
"scripts": {
"build": "scripts/build.sh",
"postbuild": "ts-node ./src/ico.ts",
"test": "NODE_ENV=test mocha",
"test-watch": "NODE_ENV=test mocha --watch",
"prepublish": "npm run build",
"release": "releaser"
},
"devDependencies": {
"@types/mocha": "^9.1.0",
elevatebart marked this conversation as resolved.
Show resolved Hide resolved
"@types/to-ico": "^1.1.1",
"chai": "^4.2.0",
"mocha": "^8.1.3",
"to-ico": "^1.1.5"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/cypress-io/cypress-icons.git"
},
"homepage": "https://github.com/cypress-io/cypress-icons#readme",
"author": "Brian Mann",
"bugs": {
"url": "https://github.com/cypress-io/cypress-icons/issues"
},
"publishConfig": {
"access": "public"
}
}
43 changes: 43 additions & 0 deletions packages/icons/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Cypress Icons
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elevatebart These readme instructions are out of date considering this is an internal package. Can you update the Readme to accurately reflect it's usage?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the readme, would appreciate a proof read.


The latest versions of the icons.
The public API will always reference these files.

`./dist` is not checked into source control.

## API

```js
icons = require("@cypress/icons")
elevatebart marked this conversation as resolved.
Show resolved Hide resolved

// get the absolute path to default favicon
icons.getPathToFavicon("favicon-blue.ico")
// => /Users/.../dist/favicon/favicon-blue.ico

// get the absolute path to icon
icons.getPathToIcon("icon_32x32@2x.png")
// => /Users/.../dist/icons/icon_32x32@2x.png
```

## Architecture detail

To build the MacOS icons you have to use the `iconutil` command line tool installed.
This command line tool is only installed on MacOS.

If you are not on MacOS, the building of this icon will simply be skipped.
Good news the macos is only needed to develop on MacOS.
elevatebart marked this conversation as resolved.
Show resolved Hide resolved

## Developing

All the icons are in the assets directory.

```bash
## run build to dump to ./dist
npm run build
elevatebart marked this conversation as resolved.
Show resolved Hide resolved
```

## Testing

```bash
npm test
```
10 changes: 10 additions & 0 deletions packages/icons/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e
rm -rf dist && mkdir dist && mkdir dist/icons
yarn tsc -p ./tsconfig.build.json
if [[ "$OSTYPE" == "darwin"* ]]; then
iconutil -c icns assets/cypress.iconset -o dist/icons/cypress.icns
fi
cp -r assets/* dist
mv dist/cypress.iconset/* dist/icons
rm -r dist/cypress.iconset
16 changes: 16 additions & 0 deletions packages/icons/src/ico.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import fs from 'fs'
import toIco from 'to-ico'

const files = [
fs.readFileSync('./assets/icons/icon_16x16.png'),
fs.readFileSync('./assets/icons/icon_24x24.png'),
fs.readFileSync('./assets/icons/icon_32x32.png'),
fs.readFileSync('./assets/icons/icon_48x48.png'),
fs.readFileSync('./assets/icons/icon_64x64.png'),
fs.readFileSync('./assets/icons/icon_128x128.png'),
fs.readFileSync('./assets/icons/icon_256x256.png'),
]

toIco(files).then((buf) => {
fs.writeFileSync('./dist/icons/cypress.ico', buf)
})
19 changes: 19 additions & 0 deletions packages/icons/src/icons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import path from 'path'

const dist = [__dirname, '..', 'dist']

function distPath (...args: string[]) {
return path.join.apply(path, dist.concat([...args]))
}

export const getPathToFavicon = (filename: string) => {
return distPath('favicon', filename)
}

export const getPathToIcon = (filename: string) => {
return distPath('icons', filename)
}

export const getPathToLogo = (filename: string) => {
return distPath('logo', filename)
}
18 changes: 18 additions & 0 deletions packages/icons/test/icons_spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect } from 'chai'
import * as icons from '../src/icons'

const cwd = process.cwd()

describe('Cypress Icons', function () {
it('returns path to favicon', function () {
expect(icons.getPathToFavicon('favicon-red.ico')).to.eq(`${cwd }/dist/favicon/favicon-red.ico`)
})

it('returns path to icon', function () {
expect(icons.getPathToIcon('cypress.icns')).to.eq(`${cwd }/dist/icons/cypress.icns`)
})

it('returns path to logo', function () {
expect(icons.getPathToLogo('cypress-bw.png')).to.eq(`${cwd }/dist/logo/cypress-bw.png`)
})
})
6 changes: 6 additions & 0 deletions packages/icons/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"files": [
"./src/icons.ts"
]
}
15 changes: 15 additions & 0 deletions packages/icons/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../ts/tsconfig.json",
"compilerOptions": {
"strict": true,
"allowJs": false,
"noImplicitAny": true,
"noUnusedLocals": false,
"resolveJsonModule": true,
"experimentalDecorators": true,
"noUncheckedIndexedAccess": true,
"importsNotUsedAsValues": "error",
"outDir": "dist",
"declaration": true
},
}
2 changes: 1 addition & 1 deletion packages/runner-ct/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{projectName}}</title>

<link href="/{{namespace}}/runner/favicon.ico" rel="icon">
<link href="/{{namespace}}/runner/favicon.ico?v2" rel="icon">

<link rel="stylesheet" href="/{{namespace}}/runner/cypress_runner.css">
</head>
Expand Down
2 changes: 1 addition & 1 deletion packages/runner-ct/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import _ from 'lodash'
import path from 'path'
import type webpack from 'webpack'
import { getCommonConfig, HtmlWebpackPlugin, getCopyWebpackPlugin } from '@packages/web-config/webpack.config.base'
import cyIcons from '@cypress/icons'
import * as cyIcons from '@packages/icons'

const commonConfig = getCommonConfig()
const CopyWebpackPlugin = getCopyWebpackPlugin()
Expand Down
2 changes: 1 addition & 1 deletion packages/runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
},
"devDependencies": {
"@cypress/design-system": "0.0.0-development",
"@cypress/icons": "0.7.0",
"@cypress/react-tooltip": "0.5.3",
"@cypress/webpack-preprocessor": "0.0.0-development",
"@fontsource/mulish": "4.3.0",
"@fontsource/open-sans": "4.3.0",
"@fortawesome/fontawesome-free": "5.12.1",
"@packages/driver": "0.0.0-development",
"@packages/icons": "0.0.0-development",
"@packages/reporter": "0.0.0-development",
"@packages/socket": "0.0.0-development",
"@packages/web-config": "0.0.0-development",
Expand Down
2 changes: 1 addition & 1 deletion packages/runner/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{projectName}}</title>

<link href="/{{namespace}}/runner/favicon.ico" rel="icon">
<link href="/{{namespace}}/runner/favicon.ico?v2" rel="icon">

<link rel="stylesheet" href="/{{namespace}}/runner/cypress_runner.css">
</head>
Expand Down
Loading