create-hammerspoon2-spoon 0.1.0 → 1.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/Templates/Spoon2TemplateJavascript.spoon2/README.md +1 -1
- package/Templates/Spoon2TemplateTypescript/CLAUDE.md +3 -3
- package/Templates/Spoon2TemplateTypescript/README.md +56 -0
- package/Templates/Spoon2TemplateTypescript/src/README.md +1 -1
- package/Templates/Spoon2TemplateTypescript/types/hammerspoon.d.ts +4843 -3131
- package/bin/create-hammerspoon2-spoon.mjs +102 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,9 @@ npx create-hammerspoon2-spoon MySpoon -t js -a "Jane <jane@example.com>" -d "Doe
|
|
|
15
15
|
| `-t, --template <javascript\|typescript>` | Template to use (`js` and `ts` also work). Prompts if omitted. |
|
|
16
16
|
| `-a, --author <"Name <email>">` | Author written to `spoon.json`. Defaults to your `git config` user. |
|
|
17
17
|
| `-d, --description <text>` | Description written to `spoon.json`. Prompts if omitted. |
|
|
18
|
+
| `-r, --remote <url\|none>` | Git remote to add as `origin` and push the initial commit to. Prompts if omitted; `none` (or empty) keeps the repo local. The remote must be an **empty** repository (no README, license or commits), or the push fails. |
|
|
18
19
|
| `--no-install` | TypeScript only: skip `npm install`. |
|
|
20
|
+
| `--no-git` | Don't initialize a git repository or make the initial commit. Can't be combined with `--remote`. |
|
|
19
21
|
| `-h, --help` | Show help. |
|
|
20
22
|
|
|
21
23
|
## Templates
|
|
@@ -23,6 +25,8 @@ npx create-hammerspoon2-spoon MySpoon -t js -a "Jane <jane@example.com>" -d "Doe
|
|
|
23
25
|
- **javascript** creates `./MySpoon.spoon2`. There is no build step: edit `init.js`, then double-click `MySpoon.spoon2` in Finder to install it into Hammerspoon 2.
|
|
24
26
|
- **typescript** creates `./MySpoon`, creates its `build/` and `spoons/` folders, and runs `npm install` (skip with `--no-install`). Edit `src/init.ts`, run `npm run typecheck` after each change, then `npm run package` to build `spoons/MySpoon.spoon2` and double-click it to install.
|
|
25
27
|
|
|
28
|
+
Unless you pass `--no-git`, the new project is also initialized as a git repository with a single initial commit. If you give a remote, it's added as `origin` and the commit is pushed (`git push -u origin HEAD`). The remote repository must be empty: create it on GitHub without a README, license or `.gitignore`, otherwise the push is rejected because its history differs from the new project's. If the remote is a GitHub repository (HTTPS or SSH URL), the generated READMEs also get an "Install from GitHub" section showing `hs.spoons.use("MySpoon", { source: "owner/repo", start: true })`; other remotes get no such section, since `hs.spoons.use` only installs from GitHub or a zip URL. If any git step fails, the project is still created and a warning is printed.
|
|
29
|
+
|
|
26
30
|
Installing does not load a spoon. Load it from your Hammerspoon 2 config with `hs.spoons.load("MySpoon")`.
|
|
27
31
|
|
|
28
32
|
## Spoon names
|
|
@@ -14,10 +14,10 @@ The runtime is JavaScriptCore plus Hammerspoon, **not Node**. Do not use Node AP
|
|
|
14
14
|
|
|
15
15
|
- `npm run typecheck`: type-check without emitting (`tsc --noEmit`). Run this after every code change.
|
|
16
16
|
- `npm run build`: clean `build/`, compile `src/` with `tsc`, then copy non-TypeScript assets (e.g. `spoon.json`) into `build/`.
|
|
17
|
-
- `npm run package`: build, then create `
|
|
18
|
-
- `npm run clean`: remove `build/` and `
|
|
17
|
+
- `npm run package`: build, then create `spoons/<name>.spoon2` from `build/`. `<name>` comes from `spoon.json`.
|
|
18
|
+
- `npm run clean`: remove `build/` and `spoons/`.
|
|
19
19
|
|
|
20
|
-
`build/` and `
|
|
20
|
+
`build/` and `spoons/` are generated and git-ignored. Never edit them by hand.
|
|
21
21
|
|
|
22
22
|
## Layout
|
|
23
23
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# {{ name }}
|
|
2
|
+
|
|
3
|
+
{{ description }}
|
|
4
|
+
|
|
5
|
+
A [Hammerspoon 2](https://github.com/cmsj/Hammerspoon2) spoon written in TypeScript. This file is for developing the spoon. The README that ships inside the installed spoon is [src/README.md](src/README.md).
|
|
6
|
+
|
|
7
|
+
## Getting started
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install # skipped if you used --no-install
|
|
11
|
+
npm run typecheck # type-check after every change
|
|
12
|
+
npm run package # build spoons/{{ name }}.spoon2
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Double-click `spoons/{{ name }}.spoon2` to install it into Hammerspoon 2, then load it from your Hammerspoon 2 config:
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
hs.spoons.load("{{ name }}");
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Installing does not load a spoon, and loading does not start it. Call `hs.spoons["{{ name }}"].start()` to run it.
|
|
22
|
+
|
|
23
|
+
{{ repoInstall }}## Scripts
|
|
24
|
+
|
|
25
|
+
| Script | Description |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| `npm run typecheck` | Type-check without emitting (`tsc --noEmit`). |
|
|
28
|
+
| `npm run build` | Clean `build/`, compile `src/` with `tsc`, then copy non-TypeScript files (such as `spoon.json`) into `build/`. |
|
|
29
|
+
| `npm run package` | Build, then create `spoons/{{ name }}.spoon2` from `build/`. |
|
|
30
|
+
| `npm run clean` | Remove the contents of `build/` and `spoons/`. |
|
|
31
|
+
|
|
32
|
+
`build/` and `spoons/` are generated: don't edit them by hand.
|
|
33
|
+
|
|
34
|
+
## Project layout
|
|
35
|
+
|
|
36
|
+
| Path | Purpose |
|
|
37
|
+
| --- | --- |
|
|
38
|
+
| `src/init.ts` | Spoon entry point. Exports the spoon object with `init`, `start`, `stop` and `logLevel`. |
|
|
39
|
+
| `src/modules/` | Supporting modules, such as `Logger.ts`. |
|
|
40
|
+
| `src/spoon.json` | Spoon metadata (`name`, `author`, `version`, `description`). |
|
|
41
|
+
| `src/README.md` | End-user README, copied into the packaged spoon. |
|
|
42
|
+
| `types/` | Typings for the Hammerspoon 2 API (`hammerspoon.d.ts`, auto-generated, don't hand-edit) and CommonJS globals. |
|
|
43
|
+
| `npm_scripts/` | Build and packaging scripts (run under Node). |
|
|
44
|
+
|
|
45
|
+
## Things to know
|
|
46
|
+
|
|
47
|
+
- The spoon runs in JavaScriptCore inside Hammerspoon, **not Node**. Don't use Node APIs in `src/`. Only `npm_scripts/` runs under Node.
|
|
48
|
+
- The output is CommonJS, because Hammerspoon 2 loads spoons with `require()`.
|
|
49
|
+
- The spoon ships as plain compiled files with no `node_modules`, so don't add runtime dependencies.
|
|
50
|
+
- `init()` can run more than once. Put start-up behavior in `start()` and teardown in `stop()`.
|
|
51
|
+
- Use `createLogger()` from `src/modules/Logger.ts` instead of `console.*`, so the spoon's `logLevel` applies.
|
|
52
|
+
- The `name` in `src/spoon.json` becomes a directory name, so it may only contain letters, digits, `_` and `-`.
|
|
53
|
+
|
|
54
|
+
## Contributing
|
|
55
|
+
|
|
56
|
+
See [AI_POLICY.md](AI_POLICY.md) and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md). [CLAUDE.md](CLAUDE.md) has guidance for AI coding assistants.
|