Skip to content

Commit

Permalink
fix: rename .app-update.json to app-update.yml #529
Browse files Browse the repository at this point in the history
JSON is not readable and writable. YAML is much better.
  • Loading branch information
develar committed Oct 25, 2016
1 parent 3eb2752 commit f69d202
Show file tree
Hide file tree
Showing 10 changed files with 623 additions and 311 deletions.
3 changes: 2 additions & 1 deletion nsis-auto-updater/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "electron-auto-updater",
"version": "0.0.4",
"version": "0.1.0",
"description": "NSIS Auto Updater",
"main": "out/nsis-auto-updater/src/main.js",
"author": "Vladimir Krivosheev",
Expand All @@ -15,6 +15,7 @@
"bluebird": "^3.4.6",
"fs-extra-p": "^1.2.0",
"ini": "^1.3.4",
"js-yaml": "^3.6.1",
"semver": "^5.3.0",
"source-map-support": "^0.4.5",
"tunnel-agent": "^0.4.3"
Expand Down
5 changes: 3 additions & 2 deletions nsis-auto-updater/src/NsisUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { Provider, UpdateCheckResult } from "./api"
import { BintrayProvider } from "./BintrayProvider"
import BluebirdPromise from "bluebird"
import { BintrayOptions, PublishConfiguration, GithubOptions } from "../../src/options/publishOptions"
import { readJson } from "fs-extra-p"
import { readFile } from "fs-extra-p"
import { safeLoad } from "js-yaml"

BluebirdPromise.config({
longStackTraces: true,
Expand Down Expand Up @@ -146,6 +147,6 @@ function createClient(data: string | PublishConfiguration | BintrayOptions | Git
}

async function loadUpdateConfig() {
const data = await readJson(path.join((<any>global).__test_resourcesPath || (<any>process).resourcesPath, ".app-update.json"), "utf-8")
const data = safeLoad(await readFile(path.join((<any>global).__test_resourcesPath || (<any>process).resourcesPath, "app-update.yml"), "utf-8"))
return createClient(data)
}
21 changes: 21 additions & 0 deletions nsis-auto-updater/yarn.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
argparse@^1.0.7:
version "1.0.9"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.9.tgz#73d83bc263f86e97f8cc4f6bae1b0e90a7d22c86"
dependencies:
sprintf-js "~1.0.2"

balanced-match@^0.4.1:
version "0.4.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
Expand All @@ -19,6 +25,10 @@ [email protected]:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"

esprima@^2.6.0:
version "2.7.3"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581"

fs-extra-p@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/fs-extra-p/-/fs-extra-p-1.2.0.tgz#16abed58ec63219cf9244a5a54ba200d4864b347"
Expand Down Expand Up @@ -70,6 +80,13 @@ ini@^1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e"

js-yaml@^3.6.1:
version "3.6.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.6.1.tgz#6e5fe67d8b205ce4d22fad05b7781e8dadcc4b30"
dependencies:
argparse "^1.0.7"
esprima "^2.6.0"

jsonfile@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8"
Expand Down Expand Up @@ -116,6 +133,10 @@ source-map@^0.5.3:
version "0.5.6"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412"

sprintf-js@~1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"

tunnel-agent@^0.4.3:
version "0.4.3"
resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb"
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"hosted-git-info": "^2.1.5",
"ini": "^1.3.4",
"isbinaryfile": "^3.0.1",
"js-yaml": "^3.6.1",
"lodash.template": "^4.4.0",
"mime": "^1.3.4",
"minimatch": "^3.0.3",
Expand All @@ -93,8 +94,10 @@
"yargs": "^6.3.0"
},
"devDependencies": {
"@develar/semantic-release": "^6.3.7",
"@develar/semantic-release": "^6.3.9",
"@develar/types": "^1.0.1",
"@types/ini": "^1.3.29",
"@types/js-yaml": "^3.5.28",
"@types/source-map-support": "^0.2.28",
"ava-tf": "^0.16.4",
"babel-plugin-array-includes": "^2.0.3",
Expand All @@ -110,8 +113,8 @@
"json8": "^0.9.2",
"path-sort": "^0.1.0",
"ts-babel": "^1.1.2",
"tslint": "^3.15.1",
"typescript": "^2.1.0-dev.20161019",
"tslint": "^4.0.0-dev.0",
"typescript": "^2.1.0-dev.20161025",
"validate-commit-msg": "^2.8.2",
"whitespace": "^2.1.0"
},
Expand Down
6 changes: 3 additions & 3 deletions src/targets/nsis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { v5 as uuid5 } from "uuid-1345"
import { normalizeExt, TargetEx, getPublishConfigs, getResolvedPublishConfig } from "../platformPackager"
import { archiveApp } from "./archive"
import { subTask, task, log } from "../util/log"
import { unlink, readFile } from "fs-extra-p"
import { unlink, readFile, writeFile } from "fs-extra-p"
import { SemVer } from "semver"
import { NsisOptions } from "../options/winOptions"
import { writeJson } from "fs-extra-p"
import { PublishConfiguration } from "../options/publishOptions"
import { safeDump } from "js-yaml"

const NSIS_VERSION = "3.0.1"
//noinspection SpellCheckingInspection
Expand Down Expand Up @@ -54,7 +54,7 @@ export default class NsisTarget extends TargetEx {
private async doBuild(appOutDir: string, arch: Arch) {
const publishConfig = await this.publishConfig
if (publishConfig != null) {
await writeJson(path.join(appOutDir, "resources", ".app-update.json"), publishConfig)
await writeFile(path.join(appOutDir, "resources", "app-update.yml"), safeDump(publishConfig))
}

const packager = this.packager
Expand Down
3 changes: 2 additions & 1 deletion src/util/httpRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as path from "path"
import { createHash } from "crypto"
import { Transform } from "stream"
import { homedir } from "os"
import { parse as parseIni } from "ini"

const maxRedirects = 10

Expand Down Expand Up @@ -146,7 +147,7 @@ async function proxyFromNpm() {
}

try {
const config = require("ini").parse(data)
const config = parseIni(data)
return config["https-proxy"] || config.proxy
}
catch (e) {
Expand Down
5 changes: 2 additions & 3 deletions test/src/helpers/checkDeps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const printErrorAndExit = require("../../../out/util/promise").printErrorAndExit

const knownUnusedDevDependencies = new Set([
"@develar/types",
"@types/source-map-support",
"ava-tf",
"decompress-zip",
"diff",
Expand All @@ -23,7 +22,7 @@ async function main(): Promise<void> {

console.log(`Checking ${projectDir}`)

const result = await new BluebirdPromise<DepCheckResult>(function (resolve) {
const result = await new BluebirdPromise<DepCheckResult>(function (resolve) {
depCheck(projectDir, {
ignoreDirs: [
"out", "test", "docs", "typings", "docker", "certs", "templates", "nsis-auto-updater", ".idea", ".github",
Expand All @@ -35,7 +34,7 @@ async function main(): Promise<void> {
throw new Error(`Unused dependencies: ${JSON.stringify(result.dependencies, null, 2)}`)
}

const unusedDevDependencies = result.devDependencies.filter(it => !knownUnusedDevDependencies.has(it))
const unusedDevDependencies = result.devDependencies.filter(it => !it.startsWith("@types/") && !knownUnusedDevDependencies.has(it))
if (unusedDevDependencies.length > 0) {
throw new Error(`Unused devDependencies: ${JSON.stringify(unusedDevDependencies, null, 2)}`)
}
Expand Down
5 changes: 3 additions & 2 deletions test/src/nsisTest.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Platform, Arch } from "out"
import test from "./helpers/avaEx"
import { assertPack, getTestAsset, app } from "./helpers/packTester"
import { copy, outputFile, readJson } from "fs-extra-p"
import { copy, outputFile, readFile } from "fs-extra-p"
import * as path from "path"
import BluebirdPromise from "bluebird"
import { assertThat } from "./helpers/fileAssert"
import { extractFile } from "asar-electron-builder"
import { walk } from "out/asarUtil"
import { nsisPerMachineInstall } from "./helpers/expectedContents"
import { WineManager, diff } from "./helpers/wine"
import { safeLoad } from "js-yaml"

const nsisTarget = Platform.WINDOWS.createTarget(["nsis"])

Expand All @@ -31,7 +32,7 @@ test("one-click", app({
packed: async (context) => {
await doTest(context.outDir, true)

assertThat(await readJson(path.join(context.getResources(Platform.WINDOWS, Arch.ia32), ".app-update.json"))).hasProperties({
assertThat(safeLoad(await readFile(path.join(context.getResources(Platform.WINDOWS, Arch.ia32), "app-update.yml"), "utf-8"))).hasProperties({
provider: "bintray",
owner: "actperepo",
package: "TestApp",
Expand Down
7 changes: 4 additions & 3 deletions test/src/nsisUpdaterTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { assertThat } from "./helpers/fileAssert"
import { NsisUpdater } from "out/nsis-auto-updater/src/NsisUpdater"
import * as path from "path"
import { TmpDir } from "out/util/tmp"
import { outputJson } from "fs-extra-p"
import { outputFile } from "fs-extra-p"
import { safeDump } from "js-yaml"

const NsisUpdaterClass = require("../../nsis-auto-updater/out/nsis-auto-updater/src/NsisUpdater").NsisUpdater

Expand Down Expand Up @@ -37,11 +38,11 @@ test("cannot find suitable file for version", async (t) => {
test("file url", async () => {
const tmpDir = new TmpDir()
const testResourcesPath = await tmpDir.getTempFile("update-config")
await outputJson(path.join(testResourcesPath, ".app-update.json"), {
await outputFile(path.join(testResourcesPath, "app-update.yml"), safeDump({
provider: "bintray",
owner: "actperepo",
package: "TestApp",
})
}))
g.__test_resourcesPath = testResourcesPath
const updater: NsisUpdater = new NsisUpdaterClass()

Expand Down
Loading

0 comments on commit f69d202

Please sign in to comment.