Skip to content

Commit

Permalink
General updates
Browse files Browse the repository at this point in the history
  • Loading branch information
targendaz2 committed Jan 13, 2025
1 parent 9ee9ddb commit 984ea47
Show file tree
Hide file tree
Showing 28 changed files with 2,008 additions and 5,755 deletions.
6 changes: 1 addition & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ root = true
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{js,ts}]
charset = utf-8
indent_style = space
indent_size = 4

[*.{config.mjs,config.ts,json,markdownlintrc,md,yml}]
[*.{js,json,markdownlintrc,md,mjs,ts,yml}]
charset = utf-8
indent_style = space
indent_size = 2
27 changes: 5 additions & 22 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
{
"importOrder": ["^(node:)", "^(@.*)", "<THIRD_PARTY_MODULES>", "^[./]"],
"experimentalTernaries": true,
"importOrder": ["^@core/(.*)$", "^@server/(.*)$", "^@ui/(.*)$", "^[./]"],
"importOrderGroupNamespaceSpecifiers": true,
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"overrides": [
{
"files": [
"*.config.mjs",
"*.config.ts",
"*.json",
"*.yml",
".markdownlintrc"
],
"options": {
"tabWidth": 2
}
},
{
"files": ["*.md"],
"options": {
"tabWidth": 2
}
}
],
"plugins": ["@trivago/prettier-plugin-sort-imports"],
"semi": true,
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "all"
}
6 changes: 3 additions & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"recommendations": [
"streetsidesoftware.code-spell-checker",
"editorconfig.editorconfig",
"dbaeumer.vscode-eslint",
"github.vscode-github-actions",
"davidanson.vscode-markdownlint",
"esbenp.prettier-vscode",
"orta.vscode-jest",
"github.vscode-github-actions",
"editorconfig.editorconfig"
"vitest.explorer"
]
}
21 changes: 13 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
{
"[yaml]": {
"editor.defaultFormatter": "redhat.vscode-yaml"
},
"cSpell.diagnosticLevel": "Hint",
"cSpell.mergeCSpellSettings": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"eslint.experimental.useFlatConfig": true,
"eslint.useFlatConfig": true,
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.expand": false,
"explorer.fileNesting.patterns": {
"package.json": ".eslint*, .markdown*, .prettierrc*, .yarnrc*, cspell*, eslint*, jest*, webpack*, yarn.lock"
"package.json": ".eslint*, .markdown*, .prettierrc*, .yarnrc*, cspell*, eslint*, jest*, rollup*, webpack*, yarn.lock"
},
"jest.outputConfig": "test-results-based",
"jest.runMode": "on-demand",
"markdownlint.config": {
"extends": "./.markdownlintrc"
},
"material-icon-theme.files.associations": {
".markdownlintrc": "Settings",
"cspell.json": "Settings"
".markdownlintrc": "settings",
"cspell.json": "settings"
},
"material-icon-theme.folders.associations": {
"dicts": "Docs"
}
"dicts": "docs"
},
"prettier.prettierPath": "./node_modules/prettier",
"prettier.requireConfig": true
}
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
enableTelemetry: false
nodeLinker: node-modules
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 David Rosenberg
Copyright (c) 2024-2025 David Rosenberg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 7 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"version": "0.2",
"ignorePaths": [".prettierrc*", ".vscode/*", "*.lock", "node_modules/"],
"ignorePaths": [
".gitignore",
".prettierrc*",
".vscode/*",
"*.lock",
"node_modules/"
],
"dictionaryDefinitions": [
{
"name": "extensions",
Expand Down
46 changes: 21 additions & 25 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,29 @@ import eslintConfigPrettier from 'eslint-config-prettier';
import tseslint from 'typescript-eslint';

const config = tseslint.config(
eslint.configs.recommended,
...tseslint.configs.strict,
{
ignores: ['dist/*'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
},
eslint.configs.recommended,
...tseslint.configs.recommended,
eslintConfigPrettier,
{
files: ['./src/*.ts'],
ignores: ['./src/tests/**/*.ts'],
files: ['./src/**/*.ts'],
ignores: ['./src/**/*.spec.ts', './src/**/*.test.ts'],
rules: {
'no-restricted-imports': [
'error',
Expand All @@ -37,25 +51,7 @@ const config = tseslint.config(
],
},
},
{
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
'@typescript-eslint/no-var-requires': 'off',
eqeqeq: 'error',
'no-var': 'error',
},
},
eslintConfigPrettier,
);

export default config;
17 changes: 0 additions & 17 deletions jest.config.ts

This file was deleted.

50 changes: 16 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,52 +28,34 @@
"url": "https://github.com/targendaz2/Mac-Set-Default-Apps/issues"
},
"license": "MIT",
"author": "David Rosenberg <david@dgrdev.com>",
"author": "David G Rosenberg <david@dgrdev.com>",
"repository": "github:targendaz2/Mac-Set-Default-Apps",
"scripts": {
"build": "webpack",
"generate": "ts-json-schema-generator --type Config --path ./src/types/msda.ts --out ./generated/configSchema.json",
"lint": "yarn lint:js && yarn lint:md && yarn lint:sh",
"lint:js": "eslint",
"lint:md": "markdownlint ./*.md",
"lint:sh": "shellcheck **/*.sh",
"build": "rollup --config rollup.config.mjs",
"start": "yarn build && ./dist/msda.js",
"test": "jest",
"test:functional": "jest src/tests/functional",
"test:unit": "jest src/tests/unit"
"test": "vitest"
},
"devDependencies": {
"@eslint/js": "^9.0.0",
"@faker-js/faker": "^8.4.1",
"@jest/globals": "^29.7.0",
"@jxa/global-type": "^1.3.6",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@eslint/js": "^9.18.0",
"@trivago/prettier-plugin-sort-imports": "^5.2.1",
"@types/eslint-config-prettier": "^6.11.3",
"@types/eslint__js": "^8.42.3",
"@types/node": "^20.12.7",
"@types/node": "^22.10.5",
"@types/plist": "^3.0.5",
"@types/tmp": "^0.2.6",
"cspell": "^8.6.1",
"eslint": "^8.56.0",
"eslint": "^9.18.0",
"eslint-config-prettier": "^9.1.0",
"fishery": "^2.2.2",
"jest": "^29.7.0",
"jest-junit": "^16.0.0",
"markdownlint-cli": "^0.39.0",
"prettier": "^3.2.5",
"plist": "^3.1.0",
"prettier": "^3.4.2",
"rollup": "^4.30.1",
"tmp": "^0.2.3",
"ts-jest": "^29.1.2",
"ts-json-schema-generator": "^2.0.1",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"typescript": "^5.4.5",
"typescript-eslint": "^7.6.0",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4",
"webpack-shell-plugin-next": "^2.3.1"
"typescript": "^5.7.3",
"typescript-eslint": "^8.19.1",
"vitest": "^2.1.8"
},
"engines": {
"node": "^21.0.0"
"node": "^22"
},
"private": true,
"packageManager": "yarn@4.2.2"
"packageManager": "yarn@4.6.0"
}
12 changes: 12 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @ts-check

/** @type {import('rollup').RollupOptions} */
const config = {
input: './src/index.ts',
output: {
file: './build/bundle.js',
format: 'commonjs',
},
};

export default config;
40 changes: 40 additions & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
interface Application {
closeAccess: (path: string) => void;
doShellScript: (script: string) => string;
exists: (path: string) => boolean;
includeStandardAdditions: boolean;
openForAccess: (path: string) => any;
read: (handle: any) => any;
}

interface NSArray<T = any> {
count: number;
objectAtIndex: (index: number) => T;
}

declare global {
const $: {
NSDictionary: {
dictionaryWithContentsOfFile: (path: string) => any;
};

NSProcessInfo: {
processInfo: {
arguments: NSArray;
};
};
};

const Application: {
currentApplication: () => Application;
};

const ObjC: {
deepUnwrap: (dict: object) => any;
unwrap: (dict: object) => any;
};

const Path: (path: string) => string;
}

export {};
17 changes: 7 additions & 10 deletions src/lib/args/getter.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import '@jxa/global-type';

export function getArgs(): string[] {
const args = $.NSProcessInfo.processInfo.arguments;
// Build the normal argv/argc
const argv = [];
const argc = args.count; // -[NSArray count]
for (let i = 0; i < argc; i++) {
argv.push(ObjC.unwrap(args.objectAtIndex(i))); // -[NSArray objectAtIndex:]
}
return argv;
const args = $.NSProcessInfo.processInfo.arguments;
const argv = [];
const argc = args.count;
for (let i = 0; i < argc; i++) {
argv.push(ObjC.unwrap(args.objectAtIndex(i)));
}
return argv;
}
2 changes: 1 addition & 1 deletion src/lib/args/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { getArgs } from './getter';
export { arg } from './parser';
export { parseArgs as arg } from './parser';
Loading

0 comments on commit 984ea47

Please sign in to comment.