-
Notifications
You must be signed in to change notification settings - Fork 21
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
Feat/npx sdef to dfs #8
Conversation
Adds a converter as the default bin which will convert a '.app' application container into a '.d.ts' file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for PR.
I've write some comments.
packages/@jxa/sdef-to-dts/bin/cmd.js
Outdated
console.log(); | ||
} | ||
|
||
if (process.argv.length !== 3 && process.argv.length !== 4) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usage: npx @jxa/sdef-to-dts <input> --output <output>
In meow
const cli = meow(`
Usage
$ npx @jxa/sdef-to-dts <input> --output <output>
<input> - path to an Application.app to read
Options
--output, -o path to an Application.d.ts or a directory to write to
Examples
$ npx @jxa/sdef-to-dts /Applications/Safari.app --output ./safari.d.ts
`, {
flags: {
output: {
type: 'string',
alias: 'o'
}
},
autoVersion: true, // <= --version
autoHelp: true // <= --help
});
// ...
cli.input[0]
isinFile
cli.flags.output
is[outDir or outPath]
packages/@jxa/sdef-to-dts/bin/cmd.js
Outdated
|
||
function readSdef(path) { | ||
try { | ||
return child_process.execSync("sdef " + path, {stdio: ["ignore"]}).toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, we should use execa instead of child_process
directly.
Because, child_process.execSync
's default buffer is 200kb.
packages/@jxa/sdef-to-dts/bin/cmd.js
Outdated
fs.writeFileSync(outPath, content, "utf-8"); | ||
}).catch(err => { | ||
console.error(err.toString()); | ||
usage(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call cli.showHelp()
(meow) instead of it.
Great! I've published https://github.com/JXA-userland/JXA/releases/tag/v1.3.0 |
Can someone please explain how to use this, and what the benefits are? |
@JMichaelTX: This tool will generate TypeScript definitions for any application bundle which Building from the
run(() => {
Application<GoogleChrome>("GoogleChrome").
}); Visual Studio Code should provide autocomplete suggestions for the Google Chrome application after the Running |
It turns out that the
sdef
command can be used to generate.d.ts
files from App bundles. I've made the input parameter to the command the path to the app bundle to allow bundles outside of the/Applications
folder to be converted too.Fixes #7