All Projects → joshfarrant → Shortcuts Js

joshfarrant / Shortcuts Js

Licence: gpl-3.0
A JavaScript iOS 12 Shortcuts creator

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Shortcuts Js

Swift Shortcuts
An iOS 14 Shortcuts creator written in Swift, inspired by SwiftUI.
Stars: ✭ 276 (-78.4%)
Mutual labels:  automation, apple, shortcuts
Aquatouch
Dynamic Custom Macros for your MacBook TouchBar! (Supports 40+ Apps and Websites)
Stars: ✭ 125 (-90.22%)
Mutual labels:  automation, apple
Shortcutsdirectory
A collection of user-submitted shortcuts for Shortcuts for iOS.
Stars: ✭ 376 (-70.58%)
Mutual labels:  automation, apple
iOS-Shortcuts-Reference
Reference documentation for the iOS Shortcuts app file structure
Stars: ✭ 89 (-93.04%)
Mutual labels:  apple, shortcuts
Amazon Fresh Whole Foods Delivery Slot Finder
A Mac tool that finds available delivery slots for Amazon's Whole Foods delivery and Amazon Fresh services
Stars: ✭ 1,048 (-18%)
Mutual labels:  automation, apple
Micromdm
Mobile Device Management server
Stars: ✭ 1,238 (-3.13%)
Mutual labels:  apple
Maze
Maze Applied Reinforcement Learning Framework
Stars: ✭ 85 (-93.35%)
Mutual labels:  automation
Stayswifty
This is the place where iOS developer can get the most recent and helpful information. Have fun!
Stars: ✭ 82 (-93.58%)
Mutual labels:  apple
Aws Automation
AWS automation scripts and lambda functions
Stars: ✭ 81 (-93.66%)
Mutual labels:  automation
Tower Operator
DEPRECATED: This project was moved and renamed to: https://github.com/ansible/awx-operator
Stars: ✭ 87 (-93.19%)
Mutual labels:  automation
Night Shift On Unsupported Macs
Enable Night Shift on older Unsupported Macs
Stars: ✭ 86 (-93.27%)
Mutual labels:  apple
Athena
An automation platform with a plugin architecture that allows you to easily create and share services.
Stars: ✭ 84 (-93.43%)
Mutual labels:  automation
Swiftautolayout
Write constraints in a concise, expressive, Swifty way.
Stars: ✭ 83 (-93.51%)
Mutual labels:  apple
Nzb Subliminal
Fetches subtitles for the videos it's provided. It can be easily integrated into NZBGet and SABnzbd too.
Stars: ✭ 85 (-93.35%)
Mutual labels:  automation
Cavy
An integration test framework for React Native.
Stars: ✭ 1,239 (-3.05%)
Mutual labels:  automation
Jaromail
A commandline tool to easily and privately handle your e-mail
Stars: ✭ 86 (-93.27%)
Mutual labels:  apple
Google It Automation
google it automation with python professional certificate
Stars: ✭ 81 (-93.66%)
Mutual labels:  automation
Project
⭐️ Antares Project Application Skeleton. This is the very first place you should start. It allows you to create a brand new awesome project in easy few steps.
Stars: ✭ 84 (-93.43%)
Mutual labels:  automation
Beagle Im
XMPP client for macOS based on TigaseSwift XMPP library
Stars: ✭ 86 (-93.27%)
Mutual labels:  apple
Ritchie Formulas
This repository contains the community formulas that can be executed through Ritchie CLI once imported. This tool is an open source product that allows you to create, store and share any kind of automations, executing them through command lines, to run operations or start workflows ⚙️ 🖥 💡
Stars: ✭ 84 (-93.43%)
Mutual labels:  automation

Shortcuts JS Logo

GitHub license npm version Build Status Coverage Status PRs Welcome Discord

A Node.js iOS 12 Shortcuts creator.

Find out more at Shortcuts.fun.

@joshfarrant/shortcuts-js on npm.

NPM | Documentation | Contributing | Medium | Discord

See this issue for a complete list of all Actions implemented so far.

We have a Discord! If you need any help or have any questions, come and say hi! Join the Discord

Is the Action you want not available?

We're still working our way through the long list of built-in Shortcut Actions, if there's one you need sooner rather than later then Open an Issue and let us know; we might be able to prioritise it.

Alternatively, it's super easy to add an Action yourself! A simple Action should only take about 15 minutes to implement. Check out the Contributing Guide for more info on where to start. If for any reason you get stuck just Open an Issue. We're happy to help!

Minimal Example

npm install @joshfarrant/shortcuts-js
// Only used to create the .shortcut file
const fs = require('fs');

const {
  actionOutput,
  buildShortcut,
  withVariables,
} = require('@joshfarrant/shortcuts-js');
const {
  calculate,
  comment,
  number,
  showResult
} = require('@joshfarrant/shortcuts-js/actions');

// We'll use this later to reference the output of a calculation
const calcVar = actionOutput();

// Define our list of actions
const actions = [
  comment({
    text: 'Hello, world!',
  }),
  number({
    number: 42,
  }),
  calculate({
    operand: 3,
    operation: '/',
  }, calcVar),
  showResult({
    /**
     * We can use the result of the calculation in this Shortcuts's input
     * by passing the string to the 'withVariables' tag function
     */
    text: withVariables`Total is ${calcVar}!`,
  }),
];

// Generate the Shortcut data
const shortcut = buildShortcut(actions);

// Write the Shortcut to a file in the current directory
fs.writeFile('My Fancy Shortcut.shortcut', shortcut, (err) => {
  if (err) {
    console.error('Something went wrong :(', err);
    return;
  }
  console.log('Shortcut created!');
});

Running this code will build a Shortcut named 'My Fancy Shortcut.shortcut' in the current directory.

This can be AirDropped to an iPhone or iPad running iOS 12, at which point it will be automatically opened and imported into Shortcuts.

Shortcut Image

Further Examples

For brevity, these examples omit the code for writing the file to disk and just focus on building the Shortcut. See the Minimal Example above for an example of how to create the .shortcut file.

Battery level checker, with conditional action

const {
  actionOutput,
  buildShortcut,
  withVariables,
} = require('@joshfarrant/shortcuts-js');
const {
  conditional,
  getBatteryLevel,
  setLowPowerMode,
  showResult,
} = require('@joshfarrant/shortcuts-js/actions');

const batteryLevel = actionOutput();

const actions = [
  getBatteryLevel({}, batteryLevel),
  conditional({
    input: '<',
    value: 20,
    ifTrue: [
      setLowPowerMode({
        value: true,
      }),
      showResult({
        text: withVariables`Your battery is at ${batteryLevel}%, you might want to charge it.`,
      }),
    ],
    ifFalse: [
      showResult({
        text: withVariables`Your battery is at ${batteryLevel}%, you're probably fine for now.`,
      }),
    ],
  })
];

const shortcut = buildShortcut(actions);

Battery Checker Shortcut Image

Shortcut folder creator

This example creates folders and subfolders of Shortcuts so they can be easily run from one 'Folder' Shortcut.

This Shortcut could be tedious to set up using the drag-and-drop interface of the Shortcuts app, however we can simplify the generation of this Shortcut by using a function to build our actions from a predefined array of strings.

const {
  buildShortcut,
  withVariables,
} = require('@joshfarrant/shortcuts-js');
const {
  conditional,
  getBatteryLevel,
  setLowPowerMode,
  showResult,
} = require('@joshfarrant/shortcuts-js/actions');

const foldersArr = [
  ['Health', [ // The name of the folder
    'Log Sleep', // The names of Shortcuts to contain in that folder
    'Log Run',
    'Log Cycle',
  ]],
  ['Home', [
    ['Lights', [
      'Lights On', // We can go as many levels deep as we like
      'Lights Off',
    ]],
    ['Heating', [
      'Heating On',
      'Heating Off',
    ]],
    ['Cameras', [
      'Cameras On',
      'Cameras Off',
    ]],
    ['Door', [
      'Lock Door',
      'Unlock Door',
    ]],
  ]],
  ['Audio', [
    'Play Playlist',
    'Resume Podcast'
  ]],
];

const buildFolders = (arr) => (
  arr.map(shortcut => (
    Array.isArray(shortcut) ? ({
      label: shortcut[0],
      actions: [
        chooseFromMenu({
          prompt: shortcut[0],
          items: buildFolders(shortcut[1]),
        }),
      ],
    }
    ) : ({
      label: shortcut,
      actions: [
        runShortcut({
          name: shortcut,
        }),
      ],
    })
  ))
);

const actions = [
  chooseFromMenu({
    prompt: 'Open',
    items: buildFolders(foldersArr),
  }),
];

const shortcut = buildShortcut(actions);

Folder Shortcut Gif

Anything Else

If you're having any issues getting started, or you'd just like some advice, then please don't be afraid to Open an Issue, we're here to help!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].