Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change defaults #9

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions docs/app/setup/bundler-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,13 @@ module.exports = {

## `minify`

By default, `fast-alfred` would minify the output files.
It might be useful to disable this feature for debugging purposes.
By default, `fast-alfred` would not minify the output files.
It might be useful to enable this option if you want to reduce the bundle size.

::: tip TIP :zap:
By official Alfred documentation, you should not minify the output files, so users would be able to read the code.
See more details [in here](https://alfred.app/security-and-privacy/#signed-binaries).
:::

##### Example

Expand All @@ -160,7 +165,7 @@ It might be useful to disable this feature for debugging purposes.
*/
module.exports = {
bundlerOptions: {
minify: false, // Disable minification
minify: true, // Enable minification
},
}
```
Expand Down
Binary file modified docs/public/runtime-example.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 4 additions & 42 deletions src/bundler/assets/run-node.sh
Original file line number Diff line number Diff line change
@@ -1,49 +1,11 @@
#!/usr/bin/env bash

if [[ -z "$alfred_workflow_cache" ]]; then
echo "This script must be called from Alfred, \$alfred_workflow_cache is missing. Make sure a Bundle ID is set."
exit 1
fi

if [[ ! -d "$alfred_workflow_cache" ]]; then
mkdir -p "$alfred_workflow_cache"
fi

PATH_CACHE="$alfred_workflow_cache"/node_path

get_user_path() {
eval $(/usr/libexec/path_helper -s)
echo "$($SHELL -i -l -c 'echo -e "\n"PATH=\"$PATH:\$PATH\""\n"' 2>/dev/null | grep "^PATH=")" > "$PATH_CACHE"
function has_node() {
command -v node >/dev/null 2>&1
}

set_path() {
if [[ -f "$PATH_CACHE" ]]; then
. "$PATH_CACHE"
else
get_user_path
. "$PATH_CACHE"
fi

export PATH
}

has_node() {
command -v node >/dev/null 2>&1
}

# Check if we have Node.js, otherwise inherit path from user shell
if ! has_node; then
set_path

# Retry by deleting old path cache
if ! has_node; then
rm "$PATH_CACHE"
set_path
fi
fi

if has_node; then
node "$@"
node "$@"
else
echo $'{"items":[{"title": "Couldn\'t find the `node` binary", "subtitle": "Symlink it to `/usr/local/bin`"}]}'
echo $'{"items":[{"title": "Couldn\'t find the `node` binary", "subtitle": "Make sure Node.js installed (HomeBrew recommended)", "icon": {"path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"}}]}'
fi
2 changes: 1 addition & 1 deletion src/bundler/constants/bundler-options-defaults.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const BUNDLER_DEFAULTS: Required<BundlerOptions> = {
targetDir: 'esbuild',
productionScripts: ['src/main/*.ts'],
esmHelpers: false,
minify: true,
minify: false,
treeShaking: true,
outputFormat: 'cjs',
overrideEsbuildOptions: {},
Expand Down
5 changes: 4 additions & 1 deletion src/bundler/models/bundler-options.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ export interface BundlerOptions {
* Whether to minify the output.
* Should reduce file size, but prevent proper debugging.
*
* @default true
* @note
* According to [Alfred's documentation](https://alfred.app/security-and-privacy/#signed-binaries), this option is not recommended.
*
* @default false
*/
minify?: boolean

Expand Down