@heartheyouth/create-tool 0.0.0-stage → 0.1.0

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/index.js ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+ // `pnpm create @heartheyouth/tool my-tool` (or npm/yarn/bun): copies template/ into a new folder and
3
+ // installs the latest packages with the package manager it was started with
4
+ import { cpSync, existsSync, readdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
5
+ import { basename, join, resolve } from 'node:path'
6
+ import { spawnSync } from 'node:child_process'
7
+ import { fileURLToPath } from 'node:url'
8
+
9
+ const DEPS = ['next@^15', 'react@^19', 'react-dom@^19', '@heartheyouth/brandbook-toolkit']
10
+ const DEV_DEPS = ['sass']
11
+
12
+ const dir = process.argv[2]
13
+ if (!dir) {
14
+ console.error('Give the tool a folder name: pnpm create @heartheyouth/tool my-tool')
15
+ process.exit(1)
16
+ }
17
+
18
+ const target = resolve(dir)
19
+ if (existsSync(target) && readdirSync(target).length > 0) {
20
+ console.error(`${dir} already exists and isn't empty.`)
21
+ process.exit(1)
22
+ }
23
+
24
+ const name = basename(target).toLowerCase().replace(/[^a-z0-9-]+/g, '-')
25
+
26
+ // npm drops .gitignore from published packages, so the template has it without the dot
27
+ cpSync(fileURLToPath(new URL('template', import.meta.url)), target, { recursive: true })
28
+ renameSync(join(target, 'gitignore'), join(target, '.gitignore'))
29
+
30
+ const pkgPath = join(target, 'package.json')
31
+ writeFileSync(pkgPath, readFileSync(pkgPath, 'utf8').replace('"my-tool"', JSON.stringify(name)))
32
+
33
+ const pm = (process.env.npm_config_user_agent ?? 'npm').split('/')[0]
34
+ const add = pm === 'npm' ? 'install' : 'add'
35
+
36
+ function run(args) {
37
+ console.log(`\n> ${pm} ${args.join(' ')}`)
38
+ const { status } = spawnSync(pm, args, { cwd: target, stdio: 'inherit', shell: process.platform === 'win32' })
39
+ if (status !== 0) process.exit(status ?? 1)
40
+ }
41
+
42
+ console.log(`Creating ${name} in ${target}`)
43
+ run([add, ...DEPS])
44
+ run([add, '-D', ...DEV_DEPS])
45
+
46
+ console.log(`
47
+ Done. Next:
48
+
49
+ cd ${dir}
50
+ cp .env.example .env.local # add your dev token, see https://brandbook.heartheyouth.com/dev-token
51
+ ${pm} run dev
52
+ `)
package/package.json CHANGED
@@ -1,6 +1,25 @@
1
1
  {
2
2
  "name": "@heartheyouth/create-tool",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Create a Hear The Youth brand book tool from the starter: pnpm create @heartheyouth/tool my-tool",
5
+ "license": "UNLICENSED",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/HearTheYouth/dev-hty-tool-components.git",
9
+ "directory": "packages/create-tool"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "type": "module",
15
+ "bin": {
16
+ "create-tool": "index.js"
17
+ },
18
+ "files": [
19
+ "index.js",
20
+ "template"
21
+ ],
22
+ "engines": {
23
+ "node": ">=20"
24
+ }
25
+ }
@@ -0,0 +1,2 @@
1
+ # Dev token for localhost: https://brandbook.heartheyouth.com/dev-token
2
+ NEXT_PUBLIC_BB_DEV_TOKEN=
@@ -0,0 +1,16 @@
1
+ import '@heartheyouth/brandbook-toolkit/styles.css'
2
+ import { BrandbookProvider, BrowserCheck } from '@heartheyouth/brandbook-toolkit'
3
+
4
+ export const metadata = { title: 'My tool' }
5
+
6
+ export default function RootLayout({ children }) {
7
+ return (
8
+ <html lang="en">
9
+ <body>
10
+ <BrandbookProvider devToken={process.env.NEXT_PUBLIC_BB_DEV_TOKEN}>
11
+ <BrowserCheck>{children}</BrowserCheck>
12
+ </BrandbookProvider>
13
+ </body>
14
+ </html>
15
+ )
16
+ }
@@ -0,0 +1,5 @@
1
+ import { CompositorApp } from '@heartheyouth/brandbook-toolkit'
2
+
3
+ export default function Page() {
4
+ return <CompositorApp appName="My tool" appTagline="Video & image layers" />
5
+ }
@@ -0,0 +1,4 @@
1
+ node_modules
2
+ .next
3
+ .env*
4
+ !.env.example
@@ -0,0 +1,5 @@
1
+ import { brandbookMiddleware } from '@heartheyouth/brandbook-toolkit/middleware'
2
+
3
+ // Direct visits get a blocked page, and only the brand book may embed the tool. Does nothing on localhost
4
+ export const middleware = brandbookMiddleware()
5
+ export const config = { matcher: ['/((?!_next/|favicon.ico|.*\\..*).*)'] }
@@ -0,0 +1,5 @@
1
+ import { withBrandbookToolkit } from '@heartheyouth/brandbook-toolkit/next'
2
+
3
+ export default withBrandbookToolkit({
4
+ // your config
5
+ })
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "my-tool",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "next dev",
7
+ "build": "next build",
8
+ "start": "next start"
9
+ }
10
+ }
@@ -0,0 +1,4 @@
1
+ # Packages that may run install scripts (pnpm only)
2
+ allowBuilds:
3
+ "@parcel/watcher": true
4
+ sharp: true
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.