create-hypercolor 0.1.0 → 0.1.1

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 CHANGED
@@ -6,27 +6,15 @@ One command gives you a ready-to-run Bun workspace with `hypercolor` wired up, a
6
6
 
7
7
  ## Quick start
8
8
 
9
- The package is pre-release and not on npm yet. From a directory that contains a
10
- `hypercolor/` checkout:
11
-
12
9
  ```bash
13
- cd hypercolor/sdk
14
- bun install
15
- cd ../..
16
- bun ./hypercolor/sdk/packages/create-effect/bin/create-hypercolor-effect.js my-effects \
17
- --template canvas \
18
- --sdk-spec "file:../hypercolor/sdk/packages/core"
10
+ bun create hypercolor my-effects --template canvas
19
11
  ```
20
12
 
21
13
  The scaffolder prompts you for any omitted template or first-effect option. For
22
14
  audio-reactive starter boilerplate:
23
15
 
24
16
  ```bash
25
- bun ./hypercolor/sdk/packages/create-effect/bin/create-hypercolor-effect.js my-effects \
26
- --template canvas \
27
- --first aurora \
28
- --audio \
29
- --sdk-spec "file:../hypercolor/sdk/packages/core"
17
+ bun create hypercolor my-effects --template canvas --first aurora --audio
30
18
  ```
31
19
 
32
20
  Then:
@@ -36,6 +24,14 @@ cd my-effects
36
24
  bun run build
37
25
  ```
38
26
 
27
+ To develop against a local Hypercolor engine checkout instead of the published
28
+ SDK, point the workspace's `hypercolor` dependency at it:
29
+
30
+ ```bash
31
+ bun create hypercolor my-effects --template canvas \
32
+ --sdk-spec "file:../hypercolor/sdk/packages/core"
33
+ ```
34
+
39
35
  ## Templates
40
36
 
41
37
  | Template | What you get |
@@ -55,9 +51,10 @@ create-hypercolor-effect [name] [options]
55
51
  --audio Include audio-reactive starter boilerplate
56
52
  --no-git Skip git init
57
53
  --no-install Skip bun install
58
- --sdk-spec <spec> Required while hypercolor is pre-release.
59
- Point at a local checkout:
60
- file:../hypercolor/sdk/packages/core
54
+ --sdk-spec <spec> Override the workspace's hypercolor dependency spec.
55
+ Defaults to the published caret range (^<version>).
56
+ Use file:../hypercolor/sdk/packages/core to develop
57
+ against a local engine checkout.
61
58
  (HYPERCOLOR_SDK_PACKAGE_SPEC env var also works).
62
59
  ```
63
60
 
@@ -1,8 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  if (typeof Bun === 'undefined') {
4
- console.error('create-hypercolor-effect requires Bun. Install Bun from https://bun.sh and try again.')
5
- process.exit(1)
4
+ // Invoked through Node (npx/npm create). The CLI imports TypeScript
5
+ // directly, so re-exec this same script under Bun.
6
+ const { spawnSync } = await import('node:child_process')
7
+ const { fileURLToPath } = await import('node:url')
8
+ const self = fileURLToPath(import.meta.url)
9
+ const result = spawnSync('bun', [self, ...process.argv.slice(2)], { stdio: 'inherit' })
10
+ if (result.error) {
11
+ console.error('create-hypercolor-effect requires Bun. Install Bun from https://bun.sh and try again.')
12
+ process.exit(1)
13
+ }
14
+ process.exit(result.status ?? 1)
6
15
  }
7
16
 
8
17
  const cli = await import('../src/cli.ts')
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "create-hypercolor",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Bun create scaffolder for Hypercolor effect workspaces",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
7
7
  "module": "./src/index.ts",
8
8
  "types": "./src/index.ts",
9
9
  "bin": {
10
- "create-hypercolor-effect": "./bin/create-hypercolor-effect.js"
10
+ "create-hypercolor-effect": "bin/create-hypercolor-effect.js"
11
11
  },
12
12
  "exports": {
13
13
  ".": {
@@ -48,7 +48,7 @@
48
48
  "license": "Apache-2.0",
49
49
  "repository": {
50
50
  "type": "git",
51
- "url": "https://github.com/hyperb1iss/hypercolor",
51
+ "url": "git+https://github.com/hyperb1iss/hypercolor.git",
52
52
  "directory": "sdk/packages/create-effect"
53
53
  }
54
54
  }
package/src/cli.ts CHANGED
@@ -38,9 +38,10 @@ Options:
38
38
  --audio Include audio-reactive starter boilerplate
39
39
  --no-git Skip git init
40
40
  --no-install Skip bun install
41
- --sdk-spec <spec> Required while hypercolor is pre-release.
42
- Point at a local checkout:
43
- file:../hypercolor/sdk/packages/core
41
+ --sdk-spec <spec> Override the workspace's hypercolor dependency spec.
42
+ Defaults to the published caret range (^<version>).
43
+ Use file:../hypercolor/sdk/packages/core to develop
44
+ against a local engine checkout.
44
45
  (HYPERCOLOR_SDK_PACKAGE_SPEC env var also works).
45
46
  `)
46
47
  }
@@ -60,13 +61,6 @@ export async function main(
60
61
  const firstArg = optionValue(argv, '--first')
61
62
  const sdkSpec = optionValue(argv, '--sdk-spec') ?? defaultSdkPackageSpec()
62
63
 
63
- if (!sdkSpec) {
64
- context.stdout.error(
65
- 'hypercolor is not published yet. Pass --sdk-spec file:../hypercolor/sdk/packages/core or set HYPERCOLOR_SDK_PACKAGE_SPEC.',
66
- )
67
- return 1
68
- }
69
-
70
64
  const interactive = !workspaceArg || !templateArg
71
65
  const prompted = interactive
72
66
  ? await promptWorkspaceOptions({
package/src/scaffold.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { existsSync, readdirSync } from 'node:fs'
1
+ import { existsSync, readdirSync, readFileSync } from 'node:fs'
2
2
  import { resolve } from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
3
4
 
4
5
  import { normalizeEffectId, normalizeWorkspaceName } from './naming'
5
6
  import { createEffectFiles, createWorkspaceFiles } from './templates'
@@ -104,8 +105,14 @@ export async function scaffoldWorkspace(options: ScaffoldWorkspaceOptions): Prom
104
105
  }
105
106
  }
106
107
 
107
- export function defaultSdkPackageSpec(): string | undefined {
108
- return process.env.HYPERCOLOR_SDK_PACKAGE_SPEC
108
+ export function defaultSdkPackageSpec(): string {
109
+ return process.env.HYPERCOLOR_SDK_PACKAGE_SPEC ?? `^${scaffolderVersion()}`
110
+ }
111
+
112
+ function scaffolderVersion(): string {
113
+ const manifestPath = fileURLToPath(new URL('../package.json', import.meta.url))
114
+ const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) as { version: string }
115
+ return manifest.version
109
116
  }
110
117
 
111
118
  export function resolveWorkspaceTarget(cwd: string, workspaceName: string): string {