Skip to content

Commit

Permalink
auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Dec 25, 2015
1 parent a99e0fb commit 8a97438
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/runConfigurations/Packed_App.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/scopes/app_source_files.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/typescript-compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
[Download](https://github.com/develar/onshape-desktop-shell/releases/latest) latest release.
[Download](https://onshape-download.develar.org/download) Onshape standalone app ([see [releases](https://github.com/develar/onshape-desktop-shell/releases/latest)).

[Onshape](http://example.com/) is the first and only full-cloud 3D CAD system that lets everyone on a design team simultaneously work together using a web browser, phone or tablet. CAD Anywhere, Anytime, On Any Device.”

So, there is no official desktop application since you can use Onshape on a desktop computer using web browser.

But using web browser in this case is not always convenient — you lost all standard ways to open app or to switch to it.
But using web browser in this case is not always convenient — you lost all standard ways to open app or to switch to it.
What if you want to easily switch to Onshape using cmd+tab? And not to lose Onshape among other web pages?

Please note – it is unofficial application.

# todo
* Keep opened windows state (restore last opened documents on launch).
* Auto sign-in (don't to type password every launch).
* Keep opened windows state (restore last opened documents on launch).
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Onshape",
"version": "0.1.0",
"version": "0.3.0",
"private": true,
"main": "./out/index.js",
"dependencies": {
Expand Down
12 changes: 9 additions & 3 deletions build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ packager({
})

function pack() {
let outDir = `${__dirname}/../dist/Onshape-darwin-x64`
let appName = "Onshape"
const outDir = `${__dirname}/../dist/Onshape-darwin-x64`
const appName = "Onshape"
const appPath = `${outDir}/${appName}.app`
require("electron-builder").init().build({
"appPath": `${outDir}/${appName}.app`,
"appPath": appPath,
"platform": "osx",
"out": outDir,
"config": `${__dirname}/packager.json`,
Expand All @@ -51,5 +52,10 @@ function pack() {
}

fs.renameSync(`${outDir}/${appName}.dmg`, `${outDir}/${appName}-${version}.dmg`)
const spawnSync = require("child_process").spawnSync
spawnSync("zip", ["-ryX", `${outDir}/${appName}-${version}.zip`, appName + ".app"], {
cwd: outDir,
stdio: "inherit",
})
})
}
4 changes: 2 additions & 2 deletions build/install-production-deps.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"use strict"

const fs = require("fs")
const spawnSync = require('child_process').spawnSync
const spawnSync = require("child_process").spawnSync
const packageJson = JSON.parse(fs.readFileSync(__dirname + "/../package.json"))

const args = require("command-line-args")({name: "arch", type: String}).parse()

const env = require('merge')(process.env, {
const env = Object.assign(process.env, {
npm_config_disturl: "https://atom.io/download/atom-shell",
npm_config_target: packageJson.devDependencies["electron-prebuilt"].substring(1),
npm_config_arch: "x64",
Expand Down
2 changes: 1 addition & 1 deletion onshape-desktop-shell.iml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/app/node_modules" />
<excludeFolder url="file://$MODULE_DIR$/app/out" />
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
},
"devDependencies": {
"command-line-args": "^2.1.3",
"electron-builder": "^2.4.0",
"electron-builder": "^2.5.0",
"electron-packager": "^5.2.0",
"electron-prebuilt": "^0.36.1",
"merge": "^1.2.0",
"rimraf": "^2.4.4",
"typescript": "^1.8.0-dev.20151223"
"electron-prebuilt": "^0.36.2",
"rimraf": "^2.5.0",
"typescript": "^1.8.0-dev.20151225"
}
}
10 changes: 5 additions & 5 deletions src/ApplicationUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ export default class ApplicationUpdater {
return
}

let version = app.getVersion()
autoUpdater.addListener("update-available", (event: any, releaseNotes: string, releaseName: string, releaseDate: string, updateURL: string) => {
log("A new update is available", `Version ${releaseName} is available and will be automatically downloaded`)
const version = app.getVersion()
autoUpdater.addListener("update-available", (event: any) => {
log("A new update is available")
})
autoUpdater.addListener("update-downloaded", (event: any, releaseNotes: string, releaseName: string, releaseDate: string, updateURL: string) => {
notify("A new update is ready to install", `Version ${releaseName} is downloaded and will be automatically installed on Quit`)
})
autoUpdater.addListener("error", (error: any) => {
log(error)
})
autoUpdater.addListener("checking-for-update", () => {
autoUpdater.addListener("checking-for-update", (event: any) => {
log("checking-for-update")
})
autoUpdater.addListener("update-not-available", () => {
log("update-not-available")
})
autoUpdater.setFeedURL(`http://${UPDATE_SERVER_HOST}/update/${os.platform()}_${os.arch()}/${version}`)
autoUpdater.setFeedURL(`https://${UPDATE_SERVER_HOST}/update/${os.platform()}_${os.arch()}/${version}`)

window.webContents.once("did-frame-finish-load", (event: any) => {
autoUpdater.checkForUpdates()
Expand Down
4 changes: 3 additions & 1 deletion src/StateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import * as path from "path"
import ConfigStore = require("configstore")
import { isDev } from "./util"

export const DEFAULT_URL = "https://cad.onshape.com/"

function defaultWindows() {
return [
{url: "https://cad.onshape.com/"}
{url: DEFAULT_URL}
]
}

Expand Down
16 changes: 12 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { app, ipcMain, BrowserWindow as BrowserWindowElectron } from "electron"
import BrowserWindow = GitHubElectron.BrowserWindow
import BrowserWindowOptions = GitHubElectron.BrowserWindowOptions
import { StateManager, WindowItem } from "./StateManager"
import { StateManager, WindowItem, DEFAULT_URL } from "./StateManager"
import ApplicationUpdater from "./ApplicationUpdater"
import setMenu from "./menu"
import { log } from "./util"
Expand Down Expand Up @@ -48,9 +48,12 @@ function saveWindowState(window: BrowserWindow, descriptor: WindowItem) {

function registerWindowEventHandlers(window: BrowserWindow, descriptor: WindowItem) {
window.on("close", (event: WindowEvent) => {
let window = event.sender
const window = event.sender
saveWindowState(window, descriptor)
descriptor.url = window.webContents.getURL()
const url = window.webContents.getURL()
if (url != "about:blank") {
descriptor.url = url
}
stateManager.save()
})
window.on("closed", (event: WindowEvent) => {
Expand Down Expand Up @@ -81,7 +84,12 @@ function openWindows() {
}

for (const descriptor of descriptors) {
let options: BrowserWindowOptions = {
if (descriptor.url == "about:blank") {
// was error on load
descriptor.url = DEFAULT_URL
}

const options: BrowserWindowOptions = {
// to avoid visible maximizing
show: false,
preload: __dirname + "/autoSignIn.js",
Expand Down
4 changes: 4 additions & 0 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"noImplicitAny": true,
"removeComments": true,
"outDir": "../app/out",
"newLine": "LF",
"noResolve": true,
"noEmitOnError": true,
"inlineSources": true,
"sourceMap": true
}
}
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { app } from "electron"

export function isDev() {
return app.getAppPath().indexOf("/node_modules/electron-prebuilt/")
return app.getAppPath().includes("/node_modules/electron-prebuilt/")
}

let _log: (...args: any[]) => void
Expand Down

0 comments on commit 8a97438

Please sign in to comment.