Skip to content

Commit

Permalink
Fixed compiler errors within dmgLicense.ts
Browse files Browse the repository at this point in the history
- 12:98 error Don't use `Object` as a type. The `Object` type actually means "any non-nullish value", so it is marginally better than `unknown`.
- 37:9 error 'label' is never reassigned. Use 'const' instead prefer-const
Fixing buildResources directory "default" to be a fully defined path as a fallback resource
Updating snapTest snapshots to include new title entry introduced in PR #5350
Switching to japanese for dmg-license tests since russian does not have a default label
  • Loading branch information
Mike Maietta committed Dec 2, 2020
1 parent b9fe658 commit 453bf4a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 14 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"test": "node ./test/out/helpers/runTests.js skipArtifactPublisher ALL_TESTS=isCi",
"test-all": "yarn pretest && node ./test/out/helpers/runTests.js",
"test-linux": "docker run --rm -ti -v ${PWD}:/project -v ${PWD##*/}-node-modules:/project/node_modules -v ~/Library/Caches/electron:/root/.cache/electron -v ~/Library/Caches/electron-builder:/root/.cache/electron-builder electronuserland/builder:wine /bin/bash -c \"yarn && TEST_FILES=HoistedNodeModuleTest node ./test/out/helpers/runTests.js\"",
"test-update": "UPDATE_SNAPSHOT=true npm run test",
"docker-images": "docker/build.sh",
"release": "BABEL_ENV=production yarn compile && ./scripts/publish-packages.sh && conventional-changelog-cli conventional-changelog -p angular -i CHANGELOG.md -s",
"schema": "typescript-json-schema packages/app-builder-lib/tsconfig.json Configuration --out packages/app-builder-lib/scheme.json --noExtraProps --useTypeOfKeyword --strictNullChecks --required && node ./scripts/fix-schema.js",
Expand Down
8 changes: 3 additions & 5 deletions packages/app-builder-lib/src/targets/LinuxTargetHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,11 @@ export class LinuxTargetHelper {
sources.push(icnsPath)
}

// if no explicit sources are defined, default to buildResources directory
if (sources.length < 1) {
sources.push('./')
}
// If no explicit sources are defined, fallback to buildResources directory, then default framework icon
const fallbackSources = [packager.buildResourcesDir, ...asArray(packager.getDefaultFrameworkIcon())]

// need to put here and not as default because need to resolve image size
const result = await packager.resolveIcon(sources, asArray(packager.getDefaultFrameworkIcon()), "set")
const result = await packager.resolveIcon(sources, fallbackSources, "set")
this.maxIconPath = result[result.length - 1].file
return result
}
Expand Down
8 changes: 6 additions & 2 deletions packages/dmg-builder/src/dmgLicense.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { exec, log } from "builder-util"
import { safeLoad } from 'js-yaml'
import { PlatformPackager } from "app-builder-lib"
import { getLicenseFiles } from "app-builder-lib/out/util/license"
import { outputFile, readFile, readJson } from "fs-extra"
Expand All @@ -9,6 +10,8 @@ import { dmgLicenseFromJSON } from 'dmg-license'
// DropDMG/dmgbuild a in any case (even if no english, but only ru/de) set to 0 (en_US), well, without docs, just believe that's correct
const DEFAULT_REGION_CODE = 0

// License Specifications
// https://github.com/argv-minus-one/dmg-license/blob/HEAD/docs/License%20Specifications.md
type LicenseConfig = {
'$schema': string
body: any[]
Expand All @@ -26,7 +29,7 @@ export async function addLicenseToDmg(packager: PlatformPackager<any>, dmgPath:
packager.debugLogger.add("dmg.licenseButtons", licenseButtonFiles)

const jsonFile: LicenseConfig = {
'$schema': 'https://github.com/argv-minus-one/dmg-license/raw/master/schema.json',
"$schema": "https://github.com/argv-minus-one/dmg-license/raw/master/schema.json",
// defaultLang: '',
body: [],
labels: []
Expand All @@ -40,7 +43,8 @@ export async function addLicenseToDmg(packager: PlatformPackager<any>, dmgPath:
}

for (const button of licenseButtonFiles) {
const label = await readJson(button.file)
const filepath = button.file
const label = filepath.endsWith(".yml") ? safeLoad(await readFile(filepath, "utf-8")) : await readJson(filepath)
if (label.description) {
// to support original button file format
label.message = label.description
Expand Down
13 changes: 13 additions & 0 deletions test/snapshots/linux/snapTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Object {
},
},
"summary": "Sep",
"title": "Sep",
"version": "1.1.0",
}
`;
Expand Down Expand Up @@ -283,6 +284,7 @@ Object {
},
},
"summary": "Sep",
"title": "Sep",
"version": "1.1.0",
}
`;
Expand Down Expand Up @@ -363,6 +365,7 @@ Object {
},
},
"summary": "Sep",
"title": "Sep",
"version": "1.1.0",
}
`;
Expand Down Expand Up @@ -433,6 +436,7 @@ Object {
},
},
"summary": "Sep",
"title": "Sep",
"version": "1.1.0",
}
`;
Expand Down Expand Up @@ -597,6 +601,7 @@ Object {
},
},
"summary": "Sep",
"title": "Sep",
"version": "1.1.0",
}
`;
Expand Down Expand Up @@ -762,6 +767,7 @@ Object {
},
},
"summary": "Sep",
"title": "Sep",
"version": "1.1.0",
}
`;
Expand Down Expand Up @@ -927,6 +933,7 @@ Object {
},
},
"summary": "Sep",
"title": "Sep",
"version": "1.1.0",
}
`;
Expand Down Expand Up @@ -1093,6 +1100,7 @@ Object {
},
},
"summary": "Sep",
"title": "Sep",
"version": "1.1.0",
}
`;
Expand Down Expand Up @@ -1152,6 +1160,7 @@ Object {
},
},
"summary": "Sep",
"title": "Sep",
"version": "1.1.0",
}
`;
Expand Down Expand Up @@ -1353,6 +1362,7 @@ Object {
},
},
"summary": "Test App ßW",
"title": "Test App ßW",
"version": "1.1.0",
}
`;
Expand Down Expand Up @@ -1554,6 +1564,7 @@ Object {
},
},
"summary": "Test App ßW",
"title": "Test App ßW",
"version": "1.1.0",
}
`;
Expand Down Expand Up @@ -1627,6 +1638,7 @@ Object {
},
},
"summary": "Sep",
"title": "Sep",
"version": "1.1.0",
}
`;
Expand Down Expand Up @@ -1706,6 +1718,7 @@ Object {
},
},
"summary": "Sep",
"title": "Sep",
"version": "1.1.0",
}
`;
Expand Down
8 changes: 4 additions & 4 deletions test/snapshots/mac/dmgTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2472,7 +2472,7 @@ Object {
}
`;

exports[`license rtf 1`] = `
exports[`license ja 1`] = `
Object {
"mac": Array [
Object {
Expand All @@ -2496,7 +2496,7 @@ Object {
}
`;

exports[`license rtf 2`] = `
exports[`license ja 2`] = `
Object {
"CFBundleDisplayName": "Test App ßW",
"CFBundleExecutable": "Test App ßW",
Expand Down Expand Up @@ -2532,7 +2532,7 @@ Object {
}
`;

exports[`license ru 1`] = `
exports[`license rtf 1`] = `
Object {
"mac": Array [
Object {
Expand All @@ -2556,7 +2556,7 @@ Object {
}
`;

exports[`license ru 2`] = `
exports[`license rtf 2`] = `
Object {
"CFBundleDisplayName": "Test App ßW",
"CFBundleExecutable": "Test App ßW",
Expand Down
6 changes: 3 additions & 3 deletions test/src/mac/dmgTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,14 @@ test.ifAll.ifMac("multi language license", app(packagerOptions, {
return Promise.all([
// writeFile(path.join(projectDir, "build", "license_en.txt"), "Hi"),
fs.writeFile(path.join(projectDir, "build", "license_de.txt"), "Hallo"),
fs.writeFile(path.join(projectDir, "build", "license_ru.txt"), "Привет"),
fs.writeFile(path.join(projectDir, "build", "license_ja.txt"), "こんにちは"),
])
},
}))

test.ifAll.ifMac("license ru", app(packagerOptions, {
test.ifAll.ifMac("license ja", app(packagerOptions, {
projectDirCreated: projectDir => {
return fs.writeFile(path.join(projectDir, "build", "license_ru.txt"), "Привет".repeat(12))
return fs.writeFile(path.join(projectDir, "build", "license_ja.txt"), "こんにちは".repeat(12))
},
}))

Expand Down

0 comments on commit 453bf4a

Please sign in to comment.