schl3ck/ios-scriptable-types

[Discuss] Next steps for publishing

Closed this issue · 4 comments

Hey—I think you've done some valuable work here!

From the readme:

I don't know how to publish this. I've thought about DefinitlyTyped. But then you need to have npm and a node_modules folder in the working dorectory. Or should I make a VisualStudio Code Extension? (But that would take some time)

If you have any idea, just open an issue.

I see a lot of benefit from making the content of this project consumable as modules.

A listing in DefinitelyTyped as well as an ESLint shareable config would provide complementary functionality.

I propose the namespace scriptable-ios so it could be

@types/scriptable-ios and @scriptable-ios/eslint-config. I have created a pull request with an example, which you can explore.

Hi,

thank you for your thoughts!

I didn't knew the ESLint shareable configs, thank you for the link.

This solution requires you to have a packages.json and a node_modules folder in your iCloud Drive/Scriptable folder. The package.json wouldn't be really a problem, but the node_modules folder will then contain thousands of files. I don't know how well the sync of these will work (especially on Windows).

It would be a tradeoff between:

  • having thousands of unneeded files in iCloud Drive, but the convenience of npm
  • copying two files manually where they are needed

You could also make a local project (not in iCloud Drive folder) and then symlink the Scriptable folder there... But I don't know how well people, who want to use this, know how to create symlinks.

I'm still unsure about this.

This solution requires you to have a packages.json and a node_modules folder in your iCloud Drive/Scriptable folder.

That's not true—publishing these packages does not require or even prescribe any kind of installation location. They simply help someone create the right environment for writing and debugging scripts that run in Scriptable.

It would be a tradeoff between:

  • having thousands of unneeded files in iCloud Drive, but the convenience of npm
  • copying two files manually where they are needed

You could also make a local project (not in iCloud Drive folder) and then symlink the Scriptable folder there... But I don't know how well people, who want to use this, know how to create symlinks.

This is not related to publishing the packages.


But let's say you want to address this. npm scripts allow you to automate tasks like this! 🚀

You can use the install script to create the symbolic link anytime you run npm install in your project. Here is an example package.json in some folder (anywhere you want) where you'd be developing your Scriptable scripts:

{
  "name": "my-scriptable-scripts",
  "private": true,
  "scripts": {
    "install": "ln -nsf \"$HOME/Library/Mobile Documents/iCloud~dk~simonbs~Scriptable/Documents\" ./dist"
  }
}

Then, you can develop in the dist folder directly:

path/to/project/
├─ dist -> ~/Library/Mobile Documents/iCloud~dk~simonbs~Scriptable/Documents/
│   ├─ script-1.js
│   └─ script-2.js
├─ node_modules/
└─ package.json

or if you use TypeScript or some other compilation/packaging tool, you could write in the src folder and configure your output files to the dist folder, and the output files will placed in the Scriptable iCloud folder because of the symlink:

path/to/project/
├─ dist -> ~/Library/Mobile Documents/iCloud~dk~simonbs~Scriptable/Documents/
│   ├─ script-1.js
│   └─ script-2.js
├─ node_modules/
├─ src/
│   ├─ script-1.ts
│   └─ script-2.ts
├─ package.json
└─ tsconfig.json

So, you see—publishing these packages is simply a help to people so that they don't have to manually setup globals and types for the Scriptable environment. They can configure their project structure however they want and get the output to the Scriptable folder however they want. (You can even include the install script above as a suggestion in the README if you'd like.)

Does that help to address your uncertainty?

Thank you for your answer!

You have a point there... I thought about beginners of JavaScript who stumbled upon Scriptable and don't know anything about node.js. They probably aren't going to use this. Most of the time, the person who wants to use this repo, will have some coding knowledge and a desktop IDE. And they will certainly know how to handle node modules so that nothing gets cluttered up!

I will have a second look at your PR and probably publish this in the next few days.

Your idea of publishing a VS Code Extension is a good one, and it can be a consumer of these packages if they are published.