synthesisui 0.16.509 → 0.16.510

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.
@@ -1,14 +1,27 @@
1
+ import { existsSync } from "node:fs";
1
2
  import { readFile, writeFile } from "node:fs/promises";
2
3
  import { join } from "node:path";
3
4
  import { DEFAULT_CONFIG, resolveRegistry, writeProjectConfig, } from "../config.js";
4
5
  import { readProjectTheme, writeBesideTheirs, writeNewProjectRoot, writeNewProjectTheme, } from "../new-project-theme.js";
5
6
  import { openTheDoor } from "../door.js";
6
7
  import { body, section, snippet } from "../output.js";
7
- import { fetchDesignSystem } from "../registry.js";
8
+ import { fetchDesignSystem, RegistryError } from "../registry.js";
8
9
  import { resolveDeps, stylesFor, tailwindMajor } from "../stack.js";
9
10
  import { formMix, measuredStyle } from "../styles-flavour.js";
10
11
  import { desligarCaptura, ligarCaptura } from "../transcript.js";
11
12
  import { add } from "./add.js";
13
+ /** A recusa de uma pasta sem app: o que falta, quem cria, e o mesmo `init` para depois. */
14
+ export const noAppHere = (ds) => [
15
+ "There is no app here - this folder has no package.json.",
16
+ "init sets SynthesisUI up inside an app that already exists; it does not create one.",
17
+ "Create the Next.js app first, then run init inside it:",
18
+ "",
19
+ " npx create-next-app@latest my-app",
20
+ " cd my-app",
21
+ ` npx synthesisui@latest init${ds ? ` --ds ${ds}` : ""}`,
22
+ "",
23
+ "Nothing was written here.",
24
+ ].join("\n");
12
25
  const whereOf = (answer) => answer === "file" || answer === "1"
13
26
  ? "file"
14
27
  : answer === "separate" || answer === "2"
@@ -51,6 +64,17 @@ async function askWhere(tokensFile, separate, entry, intro) {
51
64
  */
52
65
  export async function init(opts) {
53
66
  const root = opts.dir ?? process.cwd();
67
+ /**
68
+ * SEM APP, O `init` RECUSA ANTES DE ESCREVER - jornada "o CLI na primeira página", E01 (12/10, medido de novo na
69
+ * 0.16.509 em 23/10). Numa pasta vazia, `init --target next --ds moss` escrevia `_synthesisui/`, baixava o sistema e
70
+ * mandava rodar o `connect`, sem dizer que não havia app nenhum. E a pasta que ficava atrás travava o passo que
71
+ * faltava: o `create-next-app` recusa um diretório com arquivos que ele não conhece, e `_synthesisui/` é um deles.
72
+ *
73
+ * O `init` não cria o app - quem cria é o `create-next-app`, e a recusa diz o comando. `--target general` é o caso
74
+ * sem Next, e segue sem `package.json`.
75
+ */
76
+ if (opts.target !== "general" && !existsSync(join(root, "package.json")))
77
+ throw new RegistryError(noAppHere(opts.ds));
54
78
  /**
55
79
  * O SISTEMA EXISTE ANTES DE QUALQUER ARQUIVO - bateria ampliada, item 21 (29/09). `init --ds teste-nunca-existiu`
56
80
  * recusava bem ("No design system ... that this machine can see"), mas só depois de escrever `_synthesisui/config.json`,
package/dist/index.js CHANGED
@@ -172,8 +172,8 @@ Examples:
172
172
  synthesisui adopt # you already have a system: start here
173
173
  synthesisui import --dry # see the census before anything is sent
174
174
  synthesisui login
175
- synthesisui init # an empty project: one command, then ask your agent
176
- synthesisui init --target next --ds halogen bootstrap + bring a system in
175
+ synthesisui init # inside a new app (create-next-app first): one command, then ask your agent
176
+ synthesisui init --ds halogen # the same, with a system from the gallery
177
177
  synthesisui doctor
178
178
  synthesisui doctor apps/web packages/ui # scope the read in a monorepo
179
179
  synthesisui doctor --strict
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "synthesisui",
3
- "version": "0.16.509",
3
+ "version": "0.16.510",
4
4
  "description": "Bring SynthesisUI design systems into any project - tokens, typed components, whole pages and an agent-ready CLAUDE.md manifest.",
5
5
  "type": "module",
6
6
  "bin": {