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

Bundle with alfy #6

Open
Yukaii opened this issue Dec 26, 2017 · 15 comments
Open

Bundle with alfy #6

Yukaii opened this issue Dec 26, 2017 · 15 comments
Assignees

Comments

@Yukaii
Copy link

Yukaii commented Dec 26, 2017

Refs: https://github.com/sindresorhus/alfy

@zetavg
Copy link
Owner

zetavg commented Dec 27, 2017

Cool XD

@Yukaii
Copy link
Author

Yukaii commented Apr 1, 2018

@zetavg
Copy link
Owner

zetavg commented Apr 3, 2019

等我搞完 npm-package-to-nix 就來弄 #7 然後順便弄這個好了 XD

@zetavg
Copy link
Owner

zetavg commented Apr 3, 2019

https://github.com/nikersify/alfred-polyglot

😂

作者住在克拉科夫欸,今年初我還剛去過那裡 XDDDD

@zetavg
Copy link
Owner

zetavg commented Apr 3, 2019

把語言設定變動態的之後應該也能加個 node proxy 設定,把 #3 #5 解掉。但就需要想辦法弄個 GFW 模擬器(或是等實體入侵牆內的時候順便)(幹嘛?)。

@zetavg
Copy link
Owner

zetavg commented Jul 1, 2020

發現用了 alfy 變好慢,cold start 要六秒多,想放棄 Orz

@Yukaii
Copy link
Author

Yukaii commented Jul 2, 2020

😂 ,用過 oclif bundle 過 node.js cli tool,速度不會那麼久,可能真是 alfy 的問題

@zetavg
Copy link
Owner

zetavg commented Jul 6, 2020

@Yukaii 你有用 alfy 的經驗ㄇ?我懷疑是我測試時的環境問題。
但 alfy 會去尋找要用哪個 node 、還會用一個比較正規的方式來產 JSON response,所以稍微多一點時間也是正常的。

⋯⋯反正我先 setup 好 Babel 吧,之後再來看要不要用 alfy 包

@Yukaii
Copy link
Author

Yukaii commented Jul 6, 2020

有,以前接電話的時寫過一個分機速查表 (2018) ,不過當時我沒有特別到意識速度有問題,資料源是 local csv

@Yukaii
Copy link
Author

Yukaii commented Jul 6, 2020

https://github.com/sindresorhus/alfy/blob/8d61d502965427671b78c6e27d0667ed9ba5ec32/index.js#L40-L42

他 output 只是 JSON.stringify,感覺不會是瓶頸

@zetavg
Copy link
Owner

zetavg commented Jul 6, 2020

我又試了一次,直接用 commend line 指定 node 跑感覺差不多 (alfred_workflow_cache=/tmp/xxx node alfy-test.js),用 ./node_modules/.bin/run-node 也沒有明顯變慢了耶

現在我比較好奇他的 auto update 是怎麼做到的 XD

@zetavg
Copy link
Owner

zetavg commented Jul 6, 2020

我剛剛也在看這個 https://github.com/vercel/pkg
"Package your Node.js project into an executable that can be run even on devices without Node.js installed"

@Yukaii
Copy link
Author

Yukaii commented Jul 6, 2020

pkg 我們有用 w 比較複雜的專案會需要踩點雷,static assets 的部分要照他 README 改寫

@zetavg
Copy link
Owner

zetavg commented Jul 6, 2020

用 vercel/pkg 包起來,跑的時候有比較快 XD

$ time ./translate auto zh-TW 'this is good translae' '繁體中文'
{"items":[{"title":"this is good translate","subtitle":"Did you mean this?","autocomplete":"this is good translate"},{"title":"這是個好翻譯","subtitle":"繁體中文","arg":"這是個好翻譯"}]}
./translate auto zh-TW 'this is good translae' '繁體中文'  0.23s user 0.05s system 32% cpu 0.842 total

$ time node ./dist/translate auto zh-TW 'this is good translae' '繁體中文'
{"items":[{"title":"this is good translate","subtitle":"Did you mean this?","autocomplete":"this is good translate"},{"title":"這是個好翻譯","subtitle":"繁體中文","arg":"這是個好翻譯"}]}
node ./dist/translate auto zh-TW 'this is good translae' '繁體中文'  0.32s user 0.24s system 46% cpu 1.213 total

@zetavg zetavg self-assigned this Jul 6, 2020
@zetavg
Copy link
Owner

zetavg commented Jul 6, 2020

不過 pkgalfy 會出問題:

{
	"items": [
		{
			"title": "Error: spawn /snapshot/alfred-google-translate-workflow/node_modules/alfred-notifier/check.js ENOENT",
			"subtitle": "Press ⌘L to see the full error and ⌘C to copy it.",
			"valid": false,
			"text": {
				"copy": "```\nError: spawn /snapshot/alfred-google-translate-workflow/node_modules/alfred-notifier/check.js ENOENT\n```\n\n-\nundefined undefined\nAlfred undefined\ndarwin 19.5.0",
				"largetype": "Error: spawn /snapshot/alfred-google-translate-workflow/node_modules/alfred-notifier/check.js ENOENT"
			},
			"icon": {
				"path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
			}
		}
	]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants