Skip to content

Commit

Permalink
refactor: TypeScript rewrite (#1593)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikian authored Dec 5, 2023
1 parent ef573d4 commit 3588ea1
Show file tree
Hide file tree
Showing 58 changed files with 3,328 additions and 3,556 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
- run: test/ci/before_install.sh
override-ci-command: yarn install --frozen-lockfile --ignore-engines
test-steps:
- run: yarn build
- restore_cache:
name: Restoring Electron cache
paths:
Expand All @@ -40,7 +41,6 @@ jobs:
- $HOME/.cache/electron
key: v1-electron-cache-{{ arch }}
- run: yarn run lint
- run: yarn run tsd
- run: yarn run coverage
- run: yarn run codecov
use-test-steps: true
Expand Down
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
typedoc/**/*
**/test/fixtures/**/node_modules/**
**/test/work/*
dist/
41 changes: 41 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const eslintConfig = {
extends: [
'eslint:recommended',
'plugin:ava/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:promise/recommended',
'standard',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
},
plugins: [
'ava',
],
rules: {
'ava/no-import-test-files': 0,
'ava/no-ignored-test-files': 0,
indent: [
'error',
2,
{
CallExpression: {
arguments: 'first',
},
SwitchCase: 1,
},
],
'no-console': 0,
strict: 'error',
'comma-dangle': ['error', 'only-multiline'],
semi: ['error', 'always'],
'space-before-function-paren': ['error', 'never']
},
};

module.exports = eslintConfig;
16 changes: 0 additions & 16 deletions .eslintrc.typescript.js

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ typedoc
.DS_Store
.nyc_output
npm-debug.log
dist/
2 changes: 1 addition & 1 deletion bin/electron-packager.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ if (!semver.satisfies(process.versions.node, packageJSON.engines.node)) {
process.exit(1)
}

var cli = require('../src/cli')
var cli = require('../dist/cli')
cli.run(process.argv.slice(2))
71 changes: 18 additions & 53 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@electron/packager",
"version": "0.0.0-development",
"description": "Customize and package your Electron app with OS-specific bundles (.app, .exe, etc.) via JS or CLI",
"main": "src/index.js",
"types": "src/index.d.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"bin": {
"electron-packager": "bin/electron-packager.js"
},
Expand All @@ -21,7 +21,7 @@
"collaborators.md",
"bin",
"docs/*.md",
"src",
"dist",
"usage.txt"
],
"dependencies": {
Expand All @@ -47,12 +47,18 @@
"yargs-parser": "^21.1.1"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"@types/debug": "^4.1.10",
"@types/fs-extra": "^11.0.3",
"@types/parse-author": "^2.0.2",
"@types/plist": "^3.0.4",
"@types/resolve": "^1.20.4",
"@types/yargs-parser": "^21.0.2",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"ava": "^3.10.1",
"buffer-equal": "^1.0.0",
"codecov": "^3.0.0",
"eslint": "^7.12.1",
"eslint": "^8.52.0",
"eslint-config-standard": "^16.0.0",
"eslint-plugin-ava": "^13.2.0",
"eslint-plugin-import": "^2.22.1",
Expand All @@ -61,23 +67,22 @@
"nyc": "^15.0.0",
"pkg-up": "^4.0.0",
"sinon": "^17.0.0",
"tsd": "^0.14.0",
"typedoc": "^0.19.0",
"typescript": "^4.0.2"
"typescript": "^5.2.2"
},
"engines": {
"node": ">= 16.4.0"
},
"scripts": {
"ava": "ava test/index.js",
"build": "tsc",
"codecov": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
"coverage": "nyc ava test/index.js",
"docs:build": "node test/ci/build_docs.js",
"lint": "npm run lint:js && npm run lint:ts",
"lint:js": "eslint .",
"lint:ts": "eslint --config .eslintrc.typescript.js --ext .ts .",
"test": "npm run lint && npm run tsd && npm run coverage",
"tsd": "tsd"
"lint": "eslint --ext .ts .",
"prepublish": "npm run build",
"pretest": "npm run build",
"test": "npm run lint && npm run coverage"
},
"directories": {
"test": "test"
Expand All @@ -91,46 +96,6 @@
"ava": {
"timeout": "60s"
},
"eslintConfig": {
"extends": [
"eslint:recommended",
"plugin:ava/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:promise/recommended",
"standard"
],
"parserOptions": {
"sourceType": "script"
},
"plugins": [
"ava"
],
"rules": {
"ava/no-import-test-files": 0,
"ava/no-ignored-test-files": 0,
"indent": [
"error",
2,
{
"CallExpression": {
"arguments": "first"
},
"SwitchCase": 1
}
],
"no-console": 0,
"strict": "error"
}
},
"eslintIgnore": [
"typedoc/**/*",
"**/test/fixtures/**/node_modules/**",
"**/test/work/*"
],
"tsd": {
"directory": "test"
},
"funding": {
"url": "https://github.com/electron/packager?sponsor=1"
},
Expand Down
28 changes: 28 additions & 0 deletions src/ambient.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
declare module 'get-package-info' {
type Props = Array<string | string[]>

export type GetPackageInfoResultSourceItem = {
/** path to the package.json file */
src: string

/** property name */
prop: string

/** the `package.json` object */
pkg: Record<string, unknown>
}

export type GetPackageInfoResult = {
source: Record<string, GetPackageInfoResultSourceItem>
values: Record<string, unknown>
}

function getPackageInfo (props: Props, dir: string): Promise<GetPackageInfoResult>

export type GetPackageInfoError = Error & {
missingProps: Props
result: GetPackageInfoResult
}

export = getPackageInfo
}
156 changes: 0 additions & 156 deletions src/cli.js

This file was deleted.

Loading

0 comments on commit 3588ea1

Please sign in to comment.