Skip to content

Commit

Permalink
(fix) master branch depCheck + tests (#5630)
Browse files Browse the repository at this point in the history
* Updating other deps to latest non-breaking version
* Updated js-yaml to v4 ("safe" is now default)
* Added `husky` and `lint-stage` for git hooks to validate compilation and lint before commit and/or push
* Updated CONTRIBUTING.md for instructions on how to set up a local dev environment in hope that it'll enable more community involvement in the submission of PRs
* Fix windows installer script
  • Loading branch information
mmaietta authored Feb 16, 2021
1 parent 46a8840 commit 8decc18
Show file tree
Hide file tree
Showing 27 changed files with 1,534 additions and 1,016 deletions.
30 changes: 30 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,36 @@ You decided to contribute to this project? Great, thanks a lot for pushing it.

This project adheres to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. By participating, you are expected to uphold this code. Please file issue to report unacceptable behavior.

## To setup a local dev environment

For local development, you can use [yalc](https://github.com/whitecolor/yalc) in order to apply changes made to electron-builder for your other projects to leverage and test with.

Env setup from scratch (line by line for an easy copy-paste)
```
yarn global add yalc
git clone https://github.com/electron-builder/electron-builder.git
pushd ./electron-builder
yarn compile
find packages/ -type d -maxdepth 1 -print0 | xargs -0 -L1 sh -c 'cd "$0" && yalc push'
popd
```

You must link yalc's local "packages" to your project via the one-liner below (run from your project folder)
```
yalc link app-builder-lib builder-util builder-util-runtime dmg-builder electron-builder electron-publish electron-builder-squirrel-windows electron-forge-maker-appimage electron-forge-maker-nsis electron-forge-maker-nsis-web electron-forge-maker-snap electron-updater
```

The magical script for whenever you make changes to electron-builder! Rebuilds electron-builder, and then patches the npm modules in your project (such as electron-quick-start).
Ready for copy-paste into terminal presuming electron-builder repo is at root level outside your project folder, otherwise adjust path as necessary.
```
pushd ../electron-builder
yarn compile
find packages/ -type d -maxdepth 1 -print0 | xargs -0 -L1 sh -c 'cd "$0" && yalc push'
popd
```

## Pull Requests
To check that your contributions match the project coding style make sure `yarn test` passes.

Expand Down
34 changes: 23 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,28 @@
"test"
],
"license": "MIT",
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"pre-push": "yarn pretest"
}
},
"lint-staged": {
"**/package.json": "yarn lint-deps",
"test/src/helpers/checkDeps.ts": "yarn lint-deps"
},
"scripts": {
"//": "do not wrap into single quotes - windows doesn't unwrap arg in this case",
"compile": "ts-babel \"packages/*\" && tsc --build test",
"//compile2": "tsc --build packages/electron-builder packages/electron-updater packages/electron-builder-squirrel-windows",
"lint": "eslint packages --ext .ts",
"lint-deps": "node ./test/out/helpers/checkDeps.js",
"pretest": "yarn compile && yarn lint && node ./test/out/helpers/checkDeps.js",
"pretest": "yarn compile && yarn lint && yarn lint-deps",
"///": "Please see https://github.com/electron-userland/electron-builder/blob/master/CONTRIBUTING.md#run-test-using-cli how to run particular test instead full (and very slow) run",
"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 -e UPDATE_SNAPSHOT=${UPDATE_SNAPSHOT:-false} -e TEST_FILES=\"${TEST_FILES:-HoistedNodeModuleTest}\" -v $(pwd):/project -v $(pwd)-node-modules:/project/node_modules -v $HOME/Library/Caches/electron:/root/.cache/electron -v $HOME/Library/Caches/electron-builder:/root/.cache/electron-builder electronuserland/builder:wine /bin/bash -c \"yarn && yarn test-all\"",
"test-update": "UPDATE_SNAPSHOT=true yarn test",
"test-update": "UPDATE_SNAPSHOT=true yarn test-all",
"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 All @@ -33,24 +43,26 @@
"///": "All dependencies for all packages (hoisted)",
"////": "All typings are added into root `package.json` to avoid duplication errors in the IDE compiler (several `node.d.ts` files).",
"dependencies": {
"@babel/core": "^7.12.10",
"@babel/plugin-transform-modules-commonjs": "^7.12.1",
"@babel/preset-env": "^7.12.11",
"@typescript-eslint/eslint-plugin": "^4.13.0",
"@typescript-eslint/parser": "^4.13.0",
"@babel/core": "^7.12.16",
"@babel/plugin-transform-modules-commonjs": "^7.12.13",
"@babel/preset-env": "^7.12.16",
"@typescript-eslint/eslint-plugin": "^4.15.0",
"@typescript-eslint/parser": "^4.15.0",
"babel-core": "^6.26.3",
"babel-preset-jest": "^26.6.2",
"bluebird-lst": "^1.0.9",
"electron-builder-tslint-config": "^1.1.0",
"eslint": "^7.17.0",
"fs-extra": "^9.0.1",
"eslint": "^7.20.0",
"fs-extra": "^9.1.0",
"globby": "^11.0.2",
"husky": "4.3.8",
"jest-cli": "^26.6.3",
"jsdoc-to-markdown": "^6.0.1",
"lint-staged": "^10.5.4",
"ts-babel": "6.1.7",
"ts-jsdoc": "^3.1.1",
"typescript": "~4.1.3",
"typescript-json-schema": "^0.47.0"
"typescript": "~4.1.5",
"typescript-json-schema": "^0.49.0"
},
"eslintIgnore": [
"*.d.ts",
Expand Down
44 changes: 22 additions & 22 deletions packages/app-builder-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@
"builder-util-runtime": "workspace:*",
"chromium-pickle-js": "^0.2.0",
"debug": "^4.3.2",
"ejs": "^3.1.5",
"ejs": "^3.1.6",
"electron-publish": "workspace:*",
"fs-extra": "^9.0.1",
"hosted-git-info": "^3.0.7",
"fs-extra": "^9.1.0",
"hosted-git-info": "^3.0.8",
"is-ci": "^2.0.0",
"istextorbinary": "^5.12.0",
"js-yaml": "^3.14.1",
"js-yaml": "^4.0.0",
"lazy-val": "^1.0.4",
"minimatch": "^3.0.4",
"normalize-package-data": "^3.0.0",
Expand All @@ -68,28 +68,28 @@
},
"///": "babel in devDependencies for proton tests",
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-decorators": "^7.12.12",
"@babel/plugin-proposal-do-expressions": "^7.12.1",
"@babel/plugin-proposal-export-default-from": "^7.12.1",
"@babel/plugin-proposal-export-namespace-from": "^7.12.1",
"@babel/plugin-proposal-function-bind": "^7.12.1",
"@babel/plugin-proposal-function-sent": "^7.12.1",
"@babel/plugin-proposal-json-strings": "^7.12.1",
"@babel/plugin-proposal-logical-assignment-operators": "^7.12.1",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1",
"@babel/plugin-proposal-numeric-separator": "^7.12.7",
"@babel/plugin-proposal-optional-chaining": "^7.12.7",
"@babel/plugin-proposal-pipeline-operator": "^7.12.1",
"@babel/plugin-proposal-throw-expressions": "^7.12.1",
"@babel/core": "^7.12.16",
"@babel/plugin-proposal-class-properties": "^7.12.13",
"@babel/plugin-proposal-decorators": "^7.12.13",
"@babel/plugin-proposal-do-expressions": "^7.12.13",
"@babel/plugin-proposal-export-default-from": "^7.12.13",
"@babel/plugin-proposal-export-namespace-from": "^7.12.13",
"@babel/plugin-proposal-function-bind": "^7.12.13",
"@babel/plugin-proposal-function-sent": "^7.12.13",
"@babel/plugin-proposal-json-strings": "^7.12.13",
"@babel/plugin-proposal-logical-assignment-operators": "^7.12.13",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.13",
"@babel/plugin-proposal-numeric-separator": "^7.12.13",
"@babel/plugin-proposal-optional-chaining": "^7.12.16",
"@babel/plugin-proposal-pipeline-operator": "^7.12.13",
"@babel/plugin-proposal-throw-expressions": "^7.12.13",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-import-meta": "^7.10.4",
"@babel/preset-env": "^7.12.11",
"@babel/preset-react": "^7.12.10",
"@babel/preset-env": "^7.12.16",
"@babel/preset-react": "^7.12.13",
"@types/debug": "^4.1.5",
"@types/ejs": "^3.0.5",
"@types/fs-extra": "^9.0.6",
"@types/fs-extra": "^9.0.7",
"@types/is-ci": "^2.0.0",
"@types/js-yaml": "^3.12.6",
"@types/normalize-package-data": "^2.4.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/app-builder-lib/src/targets/nsis/nsisLang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { asArray } from "builder-util"
import { bundledLanguages, langIdToName, lcid, toLangWithRegion } from "../../util/langs"
import _debug from "debug"
import { outputFile, readFile } from "fs-extra"
import { safeLoad } from "js-yaml"
import { load } from "js-yaml"
import * as path from "path"
import { PlatformPackager } from "../../platformPackager"
import { NsisOptions } from "./nsisOptions"
Expand Down Expand Up @@ -75,7 +75,7 @@ async function writeCustomLangFile(data: string, packager: PlatformPackager<any>
}

export async function addCustomMessageFileInclude(input: string, packager: PlatformPackager<any>, scriptGenerator: NsisScriptGenerator, langConfigurator: LangConfigurator) {
const data = safeLoad(await readFile(path.join(nsisTemplatesDir, input), "utf-8"))
const data = load(await readFile(path.join(nsisTemplatesDir, input), "utf-8"))
const instructions = computeCustomMessageTranslations(data, langConfigurator).join("\n")
debug(instructions)
scriptGenerator.include(await writeCustomLangFile(instructions, packager))
Expand Down
4 changes: 2 additions & 2 deletions packages/app-builder-lib/src/targets/snap.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Arch, deepAssign, executeAppBuilder, InvalidConfigurationError, log, replaceDefault as _replaceDefault, serializeToYaml, toLinuxArchString } from "builder-util"
import { asArray } from "builder-util-runtime"
import { outputFile, readFile } from "fs-extra"
import { safeLoad } from "js-yaml"
import { load } from "js-yaml"
import * as path from "path"
import * as semver from "semver"
import { SnapOptions } from ".."
Expand Down Expand Up @@ -65,7 +65,7 @@ export default class SnapTarget extends Target {
adapter: "none",
}

const snap: any = safeLoad(await readFile(path.join(getTemplatePath("snap"), "snapcraft.yaml"), "utf-8"))
const snap: any = load(await readFile(path.join(getTemplatePath("snap"), "snapcraft.yaml"), "utf-8"))
if (this.isUseTemplateApp) {
delete appDescriptor.adapter
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
!ifdef ZIP_COMPRESSION
nsisunz::Unzip "$PLUGINSDIR\app-$packageArch.zip" "$INSTDIR"
!else
Nsis7z::Extract "$PLUGINSDIR\app-$packageArch.7z"
!insertmacro extractUsing7za "$PLUGINSDIR\app-$packageArch.7z"
!endif
!macroend

!macro extractUsing7za FILE
Nsis7z::Extract "${FILE}"
!macroend
2 changes: 1 addition & 1 deletion packages/builder-util-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"node": ">=8.2.5"
},
"dependencies": {
"debug": "^4.3.1",
"debug": "^4.3.2",
"sax": "^1.2.4"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions packages/builder-util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"dependencies": {
"7zip-bin": "~5.0.3",
"@types/debug": "^4.1.5",
"@types/fs-extra": "^9.0.6",
"@types/fs-extra": "^9.0.7",
"app-builder-bin": "3.5.12",
"bluebird-lst": "^1.0.9",
"builder-util-runtime": "workspace:*",
"chalk": "^4.1.0",
"debug": "^4.3.1",
"fs-extra": "^9.0.1",
"debug": "^4.3.2",
"fs-extra": "^9.1.0",
"is-ci": "^2.0.0",
"js-yaml": "^3.14.1",
"js-yaml": "^4.0.0",
"source-map-support": "^0.5.19",
"stat-mode": "^1.0.0",
"temp-file": "^3.3.7"
Expand Down
4 changes: 2 additions & 2 deletions packages/builder-util/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import chalk from "chalk"
import { ChildProcess, execFile, ExecFileOptions, spawn as _spawn, SpawnOptions } from "child_process"
import { createHash } from "crypto"
import _debug from "debug"
import { safeDump } from "js-yaml"
import { dump } from "js-yaml"
import * as path from "path"
import sourceMapSupport from "source-map-support"
import { debug, log } from "./log"
Expand All @@ -29,7 +29,7 @@ export { deepAssign } from "./deepAssign"
export const debug7z = _debug("electron-builder:7z")

export function serializeToYaml(object: any, skipInvalid = false, noRefs = false) {
return safeDump(object, {
return dump(object, {
lineWidth: 8000,
skipInvalid,
noRefs,
Expand Down
6 changes: 3 additions & 3 deletions packages/dmg-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
"dependencies": {
"app-builder-lib": "workspace:*",
"builder-util": "workspace:*",
"fs-extra": "^9.0.1",
"fs-extra": "^9.1.0",
"iconv-lite": "^0.6.2",
"js-yaml": "^3.14.1",
"js-yaml": "^4.0.0",
"sanitize-filename": "^1.6.3"
},
"optionalDependencies": {
"dmg-license": "^1.0.8"
},
"devDependencies": {
"@types/fs-extra": "^9.0.6",
"@types/fs-extra": "^9.0.7",
"@types/js-yaml": "^3.12.6",
"temp-file": "^3.3.7"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/dmg-builder/src/dmgLicense.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { log } from "builder-util"
import { safeLoad } from 'js-yaml'
import { load } from 'js-yaml'
import { PlatformPackager } from "app-builder-lib"
import { getLicenseFiles } from "app-builder-lib/out/util/license"
import { readFile, readJson } from "fs-extra"
Expand Down Expand Up @@ -40,7 +40,7 @@ export async function addLicenseToDmg(packager: PlatformPackager<any>, dmgPath:

for (const button of licenseButtonFiles) {
const filepath = button.file
const label = filepath.endsWith(".yml") ? safeLoad(await readFile(filepath, "utf-8")) : await readJson(filepath)
const label = filepath.endsWith(".yml") ? load(await readFile(filepath, "utf-8")) : await readJson(filepath)
if (label.description) {
// to support original button file format
label.message = label.description
Expand Down
4 changes: 2 additions & 2 deletions packages/dmg-builder/src/licenseButtons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PlatformPackager } from "app-builder-lib"
import { getLicenseAssets } from "app-builder-lib/out/util/license"
import { readFile } from "fs-extra"
import * as iconv from "iconv-lite"
import { safeLoad } from "js-yaml"
import { load } from "js-yaml"
import { serializeString } from "./dmgUtil"
import { getDefaultButtons } from "./licenseDefaultButtons"

Expand Down Expand Up @@ -32,7 +32,7 @@ export async function getLicenseButtons(licenseButtonFiles: Array<LicenseButtons
}

try {
const fileData = safeLoad(await readFile(item.file, "utf-8")) as any
const fileData = load(await readFile(item.file, "utf-8")) as any
const buttonsStr = labelToHex(fileData.lang, item.lang, item.langWithRegion) +
labelToHex(fileData.agree, item.lang, item.langWithRegion) +
labelToHex(fileData.disagree, item.lang, item.langWithRegion) +
Expand Down
6 changes: 3 additions & 3 deletions packages/electron-builder-squirrel-windows/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
"archiver": "^5.2.0",
"bluebird-lst": "^1.0.9",
"builder-util": "workspace:*",
"fs-extra": "^9.0.1",
"fs-extra": "^9.1.0",
"sanitize-filename": "^1.6.3"
},
"devDependencies": {
"@types/archiver": "^5.1.0",
"@types/fs-extra": "^9.0.6"
"@types/fs-extra": "^9.0.7"
},
"optionalDependencies": {
"7zip-bin": "~5.0.3"
"7zip-bin": "~5.1.0"
},
"types": "./out/SquirrelWindowsTarget.d.ts"
}
8 changes: 4 additions & 4 deletions packages/electron-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,23 @@
"bugs": "https://github.com/electron-userland/electron-builder/issues",
"homepage": "https://github.com/electron-userland/electron-builder",
"dependencies": {
"@types/yargs": "^15.0.12",
"@types/yargs": "^15.0.13",
"app-builder-lib": "workspace:*",
"bluebird-lst": "^1.0.9",
"builder-util": "workspace:*",
"builder-util-runtime": "workspace:*",
"chalk": "^4.1.0",
"dmg-builder": "workspace:*",
"fs-extra": "^9.0.1",
"fs-extra": "^9.1.0",
"is-ci": "^2.0.0",
"lazy-val": "^1.0.4",
"read-config-file": "6.0.0",
"sanitize-filename": "^1.6.3",
"update-notifier": "^5.0.1",
"update-notifier": "^5.1.0",
"yargs": "^16.2.0"
},
"devDependencies": {
"@types/fs-extra": "^9.0.6",
"@types/fs-extra": "^9.0.7",
"@types/is-ci": "^2.0.0"
},
"typings": "./out/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions packages/electron-publish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
"out"
],
"dependencies": {
"@types/fs-extra": "^9.0.6",
"@types/fs-extra": "^9.0.7",
"bluebird-lst": "^1.0.9",
"builder-util": "workspace:*",
"builder-util-runtime": "workspace:*",
"chalk": "^4.1.0",
"fs-extra": "^9.0.1",
"fs-extra": "^9.1.0",
"lazy-val": "^1.0.4",
"mime": "^2.4.7"
"mime": "^2.5.0"
},
"typings": "./out/publisher.d.ts"
}
Loading

0 comments on commit 8decc18

Please sign in to comment.