@toist/in 0.2.0 → 0.2.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/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  All notable changes to `@toist/in` are recorded here.
4
4
 
5
+ ## 0.2.1 — 2026-05-05
6
+
7
+ - Scaffold now writes `package.json` directly into the target directory
8
+ instead of printing a snippet to stdout for manual merge. The empty-dir
9
+ check that the scaffold already enforces means there's never an existing
10
+ `package.json` to collide with — writing it is unambiguously simpler and
11
+ removes a manual step. The template ships as `_package.json` (the leading
12
+ underscore dodges npm's publish-time stripping rules) and is renamed to
13
+ `package.json` at scaffold time.
14
+ - Stdout is now a brief "next steps" block: `cd <path>; bun install; bun start.ts`.
15
+
5
16
  ## 0.2.0 — 2026-05-05
6
17
 
7
18
  Initial release. Scaffold CLI for new toist instances.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toist/in",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "description": "Scaffold a new toist instance: bunx @toist/in <path>",
6
6
  "main": "./src/index.ts",
package/src/scaffold.ts CHANGED
@@ -1,25 +1,30 @@
1
1
  // 2121 toist
2
2
  // Scaffold logic for @toist/in. Recursively copies templates/default/* into
3
- // the target directory, with two special filename rules:
3
+ // the target directory, with two `_`-prefixed filenames renamed at copy time:
4
4
  //
5
- // - `_gitignore` -> `.gitignore` (npm strips real .gitignore files at publish
6
- // time, so the templates ship them prefixed with an underscore)
7
- // - `_package-snippet.json` is NOT copied — it is read and printed to stdout
8
- // so the host can merge it into their existing package.json
5
+ // - `_gitignore` -> `.gitignore`
6
+ // - `_package.json` -> `package.json`
7
+ //
8
+ // The underscore prefix exists because npm strips files like `.gitignore` and
9
+ // (in some configurations) `package.json` from publishable subdirs. Prefixing
10
+ // dodges those rules; the runtime rename produces the real names in the host.
9
11
  //
10
12
  // Templates live in `<package>/templates/default/`, relative to this file's
11
13
  // runtime location. Works whether the package is consumed as a workspace
12
14
  // link (in this repo) or from node_modules (in a host repo).
13
15
 
14
- import { mkdir, copyFile, readdir, stat, readFile } from "node:fs/promises"
16
+ import { mkdir, copyFile, readdir, stat } from "node:fs/promises"
15
17
  import { existsSync } from "node:fs"
16
18
  import { dirname, join, resolve } from "node:path"
17
19
  import { fileURLToPath } from "node:url"
18
20
 
19
- const __dir = dirname(fileURLToPath(import.meta.url))
20
- const TEMPLATE_DIR = resolve(__dir, "..", "templates", "default")
21
- const SNIPPET_FILE = "_package-snippet.json"
22
- const GITIGNORE_TPL = "_gitignore"
21
+ const __dir = dirname(fileURLToPath(import.meta.url))
22
+ const TEMPLATE_DIR = resolve(__dir, "..", "templates", "default")
23
+
24
+ const RENAMES: Record<string, string> = {
25
+ _gitignore: ".gitignore",
26
+ "_package.json": "package.json",
27
+ }
23
28
 
24
29
  export async function scaffold(target: string): Promise<void> {
25
30
  const dest = resolve(process.cwd(), target)
@@ -36,13 +41,8 @@ export async function scaffold(target: string): Promise<void> {
36
41
 
37
42
  await copyTree(TEMPLATE_DIR, dest)
38
43
 
39
- const snippet = await readFile(join(TEMPLATE_DIR, SNIPPET_FILE), "utf8")
40
-
41
44
  console.log(`\nScaffolded toist instance at ${dest}\n`)
42
- console.log(`Add to your package.json (or create one at ${target}/package.json):`)
43
- console.log("")
44
- console.log(snippet)
45
- console.log("Then:")
45
+ console.log("Next:")
46
46
  console.log(` cd ${target}`)
47
47
  console.log(` bun install`)
48
48
  console.log(` bun start.ts`)
@@ -53,9 +53,8 @@ export async function scaffold(target: string): Promise<void> {
53
53
 
54
54
  async function copyTree(src: string, dest: string): Promise<void> {
55
55
  for (const entry of await readdir(src)) {
56
- if (entry === SNIPPET_FILE) continue // printed, not copied
57
56
  const srcPath = join(src, entry)
58
- const destName = entry === GITIGNORE_TPL ? ".gitignore" : entry
57
+ const destName = RENAMES[entry] ?? entry
59
58
  const destPath = join(dest, destName)
60
59
  const info = await stat(srcPath)
61
60
  if (info.isDirectory()) {
@@ -4,9 +4,8 @@ Generated with [`bunx @toist/in`](https://toist.in).
4
4
 
5
5
  ## First run
6
6
 
7
- 1. Add the suggested deps to your `package.json` (printed by the scaffold output).
8
- 2. `bun install`
9
- 3. `bun start.ts` — runner boots on `http://localhost:3000`.
7
+ 1. `bun install`
8
+ 2. `bun start.ts` — runner boots on `http://localhost:3000`.
10
9
 
11
10
  Open `http://localhost:3000` to use the UI.
12
11
 
@@ -7,7 +7,7 @@
7
7
  "dev": "bun --watch start.ts"
8
8
  },
9
9
  "dependencies": {
10
- "@toist/run": "^0.2.0",
11
- "@toist/spec": "^0.2.0"
10
+ "@toist/run": "^0.2.1",
11
+ "@toist/spec": "^0.2.1"
12
12
  }
13
13
  }