-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95f4bf4
commit cb67f0b
Showing
12 changed files
with
142 additions
and
26 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import * as Path from 'path' | ||
import { execFile, exec } from 'child_process' | ||
|
||
const regex = /sketchtool Version ((\d|\.)+) \(\d+\)/ | ||
function extractVersion(s: string) { | ||
const match = regex.exec(s) | ||
return match && match[1] | ||
} | ||
|
||
export const SKETCH_PATH = '/Applications/Sketch.app' | ||
export const SKETCHTOOL_PATH = Path.join( | ||
SKETCH_PATH, | ||
'/Contents/Resources/sketchtool/bin/sketchtool' | ||
) | ||
|
||
export async function openSketch() { | ||
return await new Promise<void>((resolve, reject) => { | ||
exec('open -a sketch', err => { | ||
if (err) { | ||
return reject(err) | ||
} | ||
resolve() | ||
}) | ||
}) | ||
} | ||
|
||
let sketchVersion: string | undefined | ||
|
||
export async function getSketchVersion(): Promise<string | null> { | ||
if (sketchVersion) { | ||
return sketchVersion | ||
} | ||
return new Promise<string | null>((resolve, reject) => { | ||
execFile(Path.join(SKETCHTOOL_PATH), ['-v'], (err, stdout) => { | ||
if (err) { | ||
return resolve(null) | ||
} | ||
let version = extractVersion(stdout) | ||
if (!version) { | ||
return resolve(null) | ||
} | ||
const pointNumbers = version.split('.').length | ||
if (pointNumbers === 1) { | ||
version = version + '.0.0' | ||
} else if (pointNumbers === 2) { | ||
version = version + '.0' | ||
} | ||
sketchVersion = version | ||
return resolve(version) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { UpdateAvailable } from './update-available' | ||
export { SketchVersionOutdated } from './sketch-version-outdated' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import * as React from 'react' | ||
import { LinkButton } from '../lib/link-button' | ||
import { Octicon, OcticonSymbol } from '../octicons' | ||
import { Dispatcher } from '../../lib/dispatcher' | ||
|
||
interface ISketchVersionOutdatedProps { | ||
readonly found?: string | ||
readonly dispatcher: Dispatcher | ||
} | ||
|
||
/** | ||
* A component which tells the user an update is available and gives them the | ||
* option of moving into the future or being a luddite. | ||
*/ | ||
export class SketchVersionOutdated extends React.Component< | ||
ISketchVersionOutdatedProps, | ||
{} | ||
> { | ||
public render() { | ||
const copy = this.props.found ? `Kactus is only compatible with Sketch >= 43. We found ${this.props.found}.` : 'Kactus needs Sketch to function properly and we couldn\'t find it.' | ||
return ( | ||
<div id="update-available" className="active"> | ||
<Octicon className="icon" symbol={OcticonSymbol.ruby} /> | ||
|
||
<span> | ||
{copy} <LinkButton onClick={this.downloadNow}>Download Sketch now</LinkButton> | ||
</span> | ||
</div> | ||
) | ||
} | ||
|
||
private downloadNow = () => { | ||
this.props.dispatcher.openInBrowser('https://www.sketchapp.com/updates/') | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters