Skip to content

Commit

Permalink
feat: download resources during runtime (#63)
Browse files Browse the repository at this point in the history
* feat: download resources on the fly

* refactor: simplify platform and arch selection

* chore: typo

* refactor: delete zip
  • Loading branch information
Cafe137 authored Apr 21, 2022
1 parent a094ddc commit 1de87fd
Show file tree
Hide file tree
Showing 55 changed files with 193 additions and 482 deletions.
42 changes: 0 additions & 42 deletions hooks.js

This file was deleted.

102 changes: 55 additions & 47 deletions package-lock.json

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

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"license": "BSD-3-Clause",
"config": {
"forge": {
"hooks": "require:./hooks.js",
"packagerConfig": {
"icon": "icon.icns"
},
Expand All @@ -42,7 +41,7 @@
}
},
{
"name": "electron-forge-maker-zip-all",
"name": "@electron-forge/maker-zip",
"platforms": [
"darwin"
]
Expand Down Expand Up @@ -73,9 +72,11 @@
"@electron-forge/cli": "^6.0.0-beta.63",
"@electron-forge/maker-deb": "^6.0.0-beta.63",
"@electron-forge/maker-rpm": "^6.0.0-beta.63",
"@electron-forge/maker-zip": "^6.0.0-beta.63",
"@electron-forge/maker-squirrel": "^6.0.0-beta.63",
"@electron-forge/publisher-github": "^6.0.0-beta.63",
"@kayahr/jest-electron-runner": "^4.4.1",
"@types/cross-zip": "^4.0.0",
"@types/jest": "^27.4.1",
"@types/js-yaml": "^4.0.5",
"@types/koa": "^2.13.4",
Expand All @@ -89,13 +90,11 @@
"@typescript-eslint/parser": "^5.17.0",
"depcheck": "^1.4.3",
"electron": "18.0.1",
"electron-forge-maker-zip-all": "^0.1.0",
"eslint": "^8.12.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jest": "^25.7.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
"fs-extra": "^10.0.1",
"jest": "^27.5.1",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
Expand All @@ -105,6 +104,9 @@
},
"dependencies": {
"@koa/router": "^10.1.1",
"cross-zip": "^4.0.0",
"env-paths": "2",
"fs-extra": "^10.1.0",
"js-yaml": "^4.1.0",
"koa": "^2.13.4",
"koa-bodyparser": "^4.3.0",
Expand Down
2 changes: 0 additions & 2 deletions purge.sh

This file was deleted.

8 changes: 4 additions & 4 deletions src/api-key.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { readFileSync, writeFileSync } from 'fs'
import { v4 } from 'uuid'
import { canResolvePath, resolvePath } from './path'
import { checkPath, getPath } from './path'

const API_KEY_FILE = 'api-key.txt'

export function getApiKey() {
if (!canResolvePath(API_KEY_FILE)) {
if (!checkPath(API_KEY_FILE)) {
const apiKey = v4()
writeFileSync(resolvePath(API_KEY_FILE), apiKey)
writeFileSync(getPath(API_KEY_FILE), apiKey)

return apiKey
}

return readFileSync(resolvePath(API_KEY_FILE), 'utf-8')
return readFileSync(getPath(API_KEY_FILE), 'utf-8')
}
10 changes: 3 additions & 7 deletions src/config-yaml.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { readFileSync, writeFileSync } from 'fs'
import { dump, FAILSAFE_SCHEMA, load } from 'js-yaml'
import { resolvePath } from './path'

function getPath() {
return resolvePath('config.yaml')
}
import { getPath } from './path'

export function readConfigYaml() {
const raw = readFileSync(getPath(), 'utf-8')
const raw = readFileSync(getPath('config.yaml'), 'utf-8')
const data = load(raw, {
schema: FAILSAFE_SCHEMA,
})
Expand All @@ -20,5 +16,5 @@ export function writeConfigYaml(newValues: Record<string, any>) {
for (const [key, value] of Object.entries(newValues)) {
data[key] = value
}
writeFileSync(getPath(), dump(data))
writeFileSync(getPath('config.yaml'), dump(data))
}
Loading

0 comments on commit 1de87fd

Please sign in to comment.