GithubHelp home page GithubHelp logo

child_process's Introduction

skpm - Sketch Plugin Manager


A utility to create, build and publish sketch plugins.

Installation

Important: Node.js > V6.x is a minimum requirement. You also need the command line tools installed.

npm install -g skpm

Usage

skpm create my-plugin

The above command pulls the template from skpm/skpm, prompts for some information, and generates the project at ./my-plugin/.

Create a new plugin

skpm create <plugin-name>

--name        The plugin display name.
--cwd         A directory to use instead of $PWD.
--force       Force option to create the directory for the new app. [boolean] [default: false]
--template    The repository hosting the template to start from.    [string]  [default: skpm/skpm]
--git         Initialize version control using git.                 [boolean] [default: true]
--install     Installs dependencies.                                [boolean] [default: true]
A note on templates

The purpose of official skpm plugin templates are to provide opinionated development tooling setups so that users can get started with actual plugin code as fast as possible. However, these templates are un-opinionated in terms of how you structure your plugin code and what libraries you use in addition to skpm.

Current available official templates include:

๐Ÿ’ Tip: Any Github repo with a 'template' folder can be used as a custom template: skpm create <project-name> --template=<username>/<repository>

Build the plugin

Once the installation is done, you can run some commands inside the project folder:

npm run build

To watch for changes:

npm run watch

Additionally, if you wish to run the plugin every time it is built:

npm run start

View the plugin's log

To view the output of your console.log, you have a few different options:

  • Use the sketch-dev-tools
  • Open Console.app and look for the sketch logs
  • Look at the ~/Library/Logs/com.bohemiancoding.sketch3/Plugin Output.log file

Skpm provides a convenient way to do the latter:

skpm log

  -f, -F        The `-f` option causes tail to not stop when end of file is
                reached, but rather to wait for additional data to be appended
                to the input.                       [boolean] [default: "false"]
  --number, -n  Shows `number` lines of the logs.                       [number]

Publish the plugin on the registry

To publish a new version of the plugin to the registry:

skpm publish <new-version> | major | minor | patch | premajor | preminor | prepatch | prerelease

  --repo-url          Specify the repository URL (default to the one specified
                      in package.json).                                 [string]
  --skip-release      Do not create a release on GitHub.com.           [boolean]
  --open-release, -o  Open the newly created release on GitHub.com.    [boolean]
  --skip-registry     Do not publish to the plugins registry if not already
                      present.                                         [boolean]
  --download-url      Specify the new version's download URL (default to the
                      asset of the release created on GitHub.com).      [string]

The exact order of execution (without options) is as follows:

  • Run the preversion script
  • Bump version in package.json as requested (patch, minor, major, etc).
  • Run the version script
  • Commit and tag
  • Run the postversion script.
  • Run the prepublish or build script
  • Zip the folder specified in the main field
  • Create a draft release on GitHub
  • Upload the zip to GitHub
  • Publish the release
  • Remove the zip
  • Check the sketchplugins/plugin-directory repo to see if the plugin is already there. If not, open a PR to add it.

License

MIT

child_process's People

Contributors

alanhamlett avatar anyab5 avatar chpio avatar dependabot[bot] avatar huw avatar mathieudutour avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

child_process's Issues

exec function stdout length

I called exec in my Sketch Plugin, but the return value cannot be returned completely, it can only return 4060 characters. Can you help me?

Some async commands hang indefinitely

I noticed this while playing around, and I can't quite figure out the cause. When running certain commands asynchronously, the module fails to release the fiber it opens, which causes a large memory leak. Further, the commands never return any values. For example:

exec('/bin/ps', null, (error, stdout, stderr) => {
  log(`DEBUG: ${stdout}`);
  log(`DEBUG: ${stderr}`);
});

Will hang and cause Sketch to eat memory, as well as fill up the Console really quickly:

The output I would expect is:

โฏ ps
  PID TTY           TIME CMD
16534 ttys001    0:02.87 /usr/local/bin/zsh -l
10772 ttys003    0:02.60 /usr/local/bin/zsh -l
30746 ttys003    0:00.29 node /usr/local/Cellar/yarn/1.13.0/libexec/bin/yarn.js watch
30088 ttys005    0:00.74 /usr/local/bin/zsh --login

Writing to sdtin crashes sketch

Hi,

i need to run code in nodejs. So my idea was to spawn a nodejs process and communicate with it by sending jsonl messages to stdin (you call it sdtin) & getting jsonl messages back from stdout.

But when i attempt to write to stdin it just crashes sketch. No crash reports in console.

const child = spawn(
	path.resolve(process.cwd(), "./Contents/Sketch/external"),
	[],
	{cwd: path.resolve(process.cwd(), "./Contents/Sketch")},
);

// @ts-ignore
const stdin: Writable = child.stdin || child.sdtin;

const buf = Buffer.from(JSON.stringify({type: "getImages"}) + "\n");
console.log("buf", buf);

await new Promise<void>((onOk, onErr) => {
	// crashes here
	stdin.write(buf, (err) => {
		if (err !== null && err !== undefined) {
			onErr(err);
		} else {
			onOk();
		}
	});
});

fork?

The readme says all child_process methods are supported, but I don't see fork

Unknown encoding in async process

import { exec } from '@skpm/child_process';

export default function test() {
  exec('echo test', (err, stdout, stderr) => {
    console.log('err', err);
    console.log('stdout', stdout);
    console.log('stderr', stderr);
  });
}
Error: Unknown encoding: NSData

child.stdout.setEncoding('NSData')

Subprocess pid is always 0

The pid property is always 0 in my testing.

var subprocess = spawn('mycmd')
subprocess.pid // => 0

It looks like calling processIdentifier() before launch() will give you a 0:

var task = NSTask.alloc().init()
task.processIdentifier() // => 0

result.pid is being set to String(task.processIdentifier()) but this happens before launch() is called because that is done via setImmediate() here:

setImmediate(() => task.launch())

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.