stera-ui 0.6.1 → 0.8.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.
@@ -8,13 +8,13 @@ declare const registryItemFileSchema: z.ZodObject<{
8
8
  content: z.ZodOptional<z.ZodString>;
9
9
  target: z.ZodOptional<z.ZodString>;
10
10
  }, "strip", z.ZodTypeAny, {
11
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
12
11
  path: string;
12
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
13
13
  content?: string | undefined;
14
14
  target?: string | undefined;
15
15
  }, {
16
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
17
16
  path: string;
17
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
18
18
  content?: string | undefined;
19
19
  target?: string | undefined;
20
20
  }>;
@@ -88,19 +88,19 @@ declare const registryItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
88
88
  content: z.ZodOptional<z.ZodString>;
89
89
  target: z.ZodOptional<z.ZodString>;
90
90
  }, "strip", z.ZodTypeAny, {
91
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
92
91
  path: string;
92
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
93
93
  content?: string | undefined;
94
94
  target?: string | undefined;
95
95
  }, {
96
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
97
96
  path: string;
97
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
98
98
  content?: string | undefined;
99
99
  target?: string | undefined;
100
100
  }>, "many">>;
101
101
  }, "strip", z.ZodTypeAny, {
102
- name: string;
103
102
  type: "registry:font";
103
+ name: string;
104
104
  font: {
105
105
  family: string;
106
106
  provider: "google";
@@ -114,14 +114,14 @@ declare const registryItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
114
114
  dependencies?: string[] | undefined;
115
115
  registryDependencies?: string[] | undefined;
116
116
  files?: {
117
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
118
117
  path: string;
118
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
119
119
  content?: string | undefined;
120
120
  target?: string | undefined;
121
121
  }[] | undefined;
122
122
  }, {
123
- name: string;
124
123
  type: "registry:font";
124
+ name: string;
125
125
  font: {
126
126
  family: string;
127
127
  provider: "google";
@@ -135,8 +135,8 @@ declare const registryItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
135
135
  dependencies?: string[] | undefined;
136
136
  registryDependencies?: string[] | undefined;
137
137
  files?: {
138
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
139
138
  path: string;
139
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
140
140
  content?: string | undefined;
141
141
  target?: string | undefined;
142
142
  }[] | undefined;
@@ -152,33 +152,33 @@ declare const registryItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
152
152
  content: z.ZodOptional<z.ZodString>;
153
153
  target: z.ZodOptional<z.ZodString>;
154
154
  }, "strip", z.ZodTypeAny, {
155
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
156
155
  path: string;
156
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
157
157
  content?: string | undefined;
158
158
  target?: string | undefined;
159
159
  }, {
160
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
161
160
  path: string;
161
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
162
162
  content?: string | undefined;
163
163
  target?: string | undefined;
164
164
  }>, "many">;
165
165
  }, "strip", z.ZodTypeAny, {
166
- name: string;
167
166
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style";
167
+ name: string;
168
168
  files: {
169
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
170
169
  path: string;
170
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
171
171
  content?: string | undefined;
172
172
  target?: string | undefined;
173
173
  }[];
174
174
  dependencies?: string[] | undefined;
175
175
  registryDependencies?: string[] | undefined;
176
176
  }, {
177
- name: string;
178
177
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style";
178
+ name: string;
179
179
  files: {
180
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
181
180
  path: string;
181
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
182
182
  content?: string | undefined;
183
183
  target?: string | undefined;
184
184
  }[];
@@ -195,13 +195,13 @@ declare const registryIndexEntrySchema: z.ZodObject<{
195
195
  dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
196
196
  registryDependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
197
197
  }, "strip", z.ZodTypeAny, {
198
- name: string;
199
198
  type: string;
199
+ name: string;
200
200
  dependencies?: string[] | undefined;
201
201
  registryDependencies?: string[] | undefined;
202
202
  }, {
203
- name: string;
204
203
  type: string;
204
+ name: string;
205
205
  dependencies?: string[] | undefined;
206
206
  registryDependencies?: string[] | undefined;
207
207
  }>;
@@ -214,29 +214,29 @@ declare const registryIndexSchema: z.ZodObject<{
214
214
  dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
215
215
  registryDependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
216
216
  }, "strip", z.ZodTypeAny, {
217
- name: string;
218
217
  type: string;
218
+ name: string;
219
219
  dependencies?: string[] | undefined;
220
220
  registryDependencies?: string[] | undefined;
221
221
  }, {
222
- name: string;
223
222
  type: string;
223
+ name: string;
224
224
  dependencies?: string[] | undefined;
225
225
  registryDependencies?: string[] | undefined;
226
226
  }>, "many">;
227
227
  }, "strip", z.ZodTypeAny, {
228
228
  name: string;
229
229
  items: {
230
- name: string;
231
230
  type: string;
231
+ name: string;
232
232
  dependencies?: string[] | undefined;
233
233
  registryDependencies?: string[] | undefined;
234
234
  }[];
235
235
  }, {
236
236
  name: string;
237
237
  items: {
238
- name: string;
239
238
  type: string;
239
+ name: string;
240
240
  dependencies?: string[] | undefined;
241
241
  registryDependencies?: string[] | undefined;
242
242
  }[];
@@ -78,27 +78,69 @@ declare function detectProject(cwd: string): ProjectInfo;
78
78
  */
79
79
  declare function detectAliasPrefix(cwd: string): string | null;
80
80
 
81
- interface WriteSteraCssResult {
82
- /** Absolute path to the written `stera-ui.css`. */
83
- steraUiPath: string;
81
+ interface WriteOptions {
82
+ overwrite?: boolean;
83
+ }
84
+ interface SkippedFile {
85
+ path: string;
86
+ /** "unchanged" — identical content on disk; "declined" — user kept their version. */
87
+ reason: "unchanged" | "declined";
88
+ }
89
+ interface WriteResult {
90
+ written: string[];
91
+ skipped: SkippedFile[];
92
+ }
93
+ /**
94
+ * Write component files to the consumer's project.
95
+ * Checks for existing files and prompts before overwriting.
96
+ */
97
+ declare function writeComponentFiles(items: RegistryItem[], config: SteraConfig, projectRoot: string, options?: WriteOptions): Promise<WriteResult>;
98
+
99
+ /** Entry point the user's globals.css imports; owns the partial wiring. */
100
+ declare const INDEX_TARGET = "ui/index.css";
101
+ /** Partial that owns the font variables patched during init. */
102
+ declare const TYPOGRAPHY_TARGET = "ui/typography.css";
103
+ interface WriteStylesResult {
104
+ /** Absolute path to the written `ui/index.css`. */
105
+ indexPath: string;
106
+ /** Absolute path to `ui/typography.css`, where font variables are patched. */
107
+ typographyPath: string;
84
108
  /**
85
- * Non-tailwindcss `@import` statements stripped from the registry content
86
- * (e.g. `@import "tw-animate-css";`). Callers are expected to ensure these
87
- * are present in the user's main globals.css.
109
+ * Non-relative `@import` statements lifted out of the index (e.g.
110
+ * `@import "tw-animate-css";`). Callers ensure these are present in the
111
+ * user's globals.css.
88
112
  */
89
113
  extraImports: string[];
90
114
  /** npm packages declared by the globals registry item. */
91
115
  dependencies: string[];
116
+ /** Consumer-relative paths written this run. */
117
+ written: string[];
118
+ /** Protected partials left untouched. */
119
+ skipped: SkippedFile[];
92
120
  }
93
121
  /**
94
- * Fetch the `globals` registry item and write `stera-ui.css` into the
95
- * directory that holds the user's configured globals.css. Overwrites
96
- * unconditionally — the caller decides when this is appropriate (init or
97
- * an explicit `add globals` refresh).
122
+ * Remove the pre-split `stera-ui.css` and its import.
123
+ *
124
+ * Projects initialized before the styles were split carry a single flat file
125
+ * plus an `@import "./stera-ui.css"` line. Left in place the file goes stale
126
+ * and its import points at content the `ui/` folder now owns.
127
+ *
128
+ * @returns The removed file's absolute path, or null if there was nothing to do.
129
+ */
130
+ declare function migrateLegacyStyles(config: SteraConfig, cwd: string): Promise<string | null>;
131
+ /**
132
+ * Fetch the `globals` registry item and write its partials into a `ui/`
133
+ * folder beside the user's configured globals.css.
134
+ *
135
+ * Stable partials are overwritten unconditionally — the caller decides when
136
+ * that is appropriate (init, or an explicit `add globals` refresh). Protected
137
+ * partials prompt first unless `overwrite` is set.
98
138
  *
99
139
  * Does NOT touch the user's globals.css.
100
140
  */
101
- declare function writeSteraUiCss(config: SteraConfig, cwd: string): Promise<WriteSteraCssResult>;
141
+ declare function writeStyles(config: SteraConfig, cwd: string, options?: {
142
+ overwrite?: boolean;
143
+ }): Promise<WriteStylesResult>;
102
144
 
103
145
  /**
104
146
  * Insert an `@import` statement into an existing CSS file, placed after the
@@ -116,24 +158,6 @@ declare function detectPackageManager(cwd: string): Promise<PackageManager>;
116
158
  */
117
159
  declare function installDependencies(deps: string[], cwd: string): Promise<void>;
118
160
 
119
- interface WriteOptions {
120
- overwrite?: boolean;
121
- }
122
- interface SkippedFile {
123
- path: string;
124
- /** "unchanged" — identical content on disk; "declined" — user kept their version. */
125
- reason: "unchanged" | "declined";
126
- }
127
- interface WriteResult {
128
- written: string[];
129
- skipped: SkippedFile[];
130
- }
131
- /**
132
- * Write component files to the consumer's project.
133
- * Checks for existing files and prompts before overwriting.
134
- */
135
- declare function writeComponentFiles(items: RegistryItem[], config: SteraConfig, projectRoot: string, options?: WriteOptions): Promise<WriteResult>;
136
-
137
161
  declare const brand: (text: string) => string;
138
162
  declare const dim: (text: string) => string;
139
163
  declare const LOGO: string;
@@ -172,4 +196,4 @@ declare function updateFonts(fonts: RegistryFontItem[], project: ProjectInfo, cw
172
196
  silent?: boolean;
173
197
  }): Promise<void>;
174
198
 
175
- export { CHECK, CONFIG_FILE, CROSS, LEGACY_CONFIG_FILE, LOGO, type ProjectInfo, type SkippedFile, type TransformContext, type TransformFn, WARN, type WriteOptions, type WriteResult, type WriteSteraCssResult, applyTransforms, brand, createSpinner, detectAliasPrefix, detectPackageManager, detectProject, dim, findConfigPath, insertImportLine, installDependencies, loadConfig, massageTreeForFonts, resolveOutputPath, transformImports, updateFonts, writeComponentFiles, writeSteraUiCss };
199
+ export { CHECK, CONFIG_FILE, CROSS, INDEX_TARGET, LEGACY_CONFIG_FILE, LOGO, type ProjectInfo, type SkippedFile, TYPOGRAPHY_TARGET, type TransformContext, type TransformFn, WARN, type WriteOptions, type WriteResult, type WriteStylesResult, applyTransforms, brand, createSpinner, detectAliasPrefix, detectPackageManager, detectProject, dim, findConfigPath, insertImportLine, installDependencies, loadConfig, massageTreeForFonts, migrateLegacyStyles, resolveOutputPath, transformImports, updateFonts, writeComponentFiles, writeStyles };
@@ -2,8 +2,10 @@ import {
2
2
  CHECK,
3
3
  CONFIG_FILE,
4
4
  CROSS,
5
+ INDEX_TARGET,
5
6
  LEGACY_CONFIG_FILE,
6
7
  LOGO,
8
+ TYPOGRAPHY_TARGET,
7
9
  WARN,
8
10
  applyTransforms,
9
11
  brand,
@@ -17,20 +19,23 @@ import {
17
19
  installDependencies,
18
20
  loadConfig,
19
21
  massageTreeForFonts,
22
+ migrateLegacyStyles,
20
23
  resolveOutputPath,
21
24
  transformImports,
22
25
  updateFonts,
23
26
  writeComponentFiles,
24
- writeSteraUiCss
25
- } from "../chunk-SIXUH4HI.js";
27
+ writeStyles
28
+ } from "../chunk-V4TMOT6I.js";
26
29
  import "../chunk-BJNLGEZJ.js";
27
30
  import "../chunk-4E46BULJ.js";
28
31
  export {
29
32
  CHECK,
30
33
  CONFIG_FILE,
31
34
  CROSS,
35
+ INDEX_TARGET,
32
36
  LEGACY_CONFIG_FILE,
33
37
  LOGO,
38
+ TYPOGRAPHY_TARGET,
34
39
  WARN,
35
40
  applyTransforms,
36
41
  brand,
@@ -44,9 +49,10 @@ export {
44
49
  installDependencies,
45
50
  loadConfig,
46
51
  massageTreeForFonts,
52
+ migrateLegacyStyles,
47
53
  resolveOutputPath,
48
54
  transformImports,
49
55
  updateFonts,
50
56
  writeComponentFiles,
51
- writeSteraUiCss
57
+ writeStyles
52
58
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stera-ui",
3
- "version": "0.6.1",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "description": "Add Stera UI components to your project.",
6
6
  "license": "MIT",
@@ -1,161 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- createSpinner,
4
- fetchRegistryItem
5
- } from "./chunk-KKUJRJ2N.js";
6
-
7
- // src/utils/resolve-config.ts
8
- import fs from "fs";
9
- import path from "path";
10
- var CONFIG_FILE = "stera.config.json";
11
- var LEGACY_CONFIG_FILE = "components.json";
12
- function migrateConfig(raw) {
13
- if (!("version" in raw) && "tailwind" in raw) {
14
- const legacy = raw;
15
- return {
16
- version: 1,
17
- css: legacy.tailwind.css || "src/styles/globals.css",
18
- aliases: legacy.aliases
19
- };
20
- }
21
- return raw;
22
- }
23
- var warnedLegacyFilename = false;
24
- function warnLegacyFilenameOnce(legacyPath) {
25
- if (warnedLegacyFilename) return;
26
- warnedLegacyFilename = true;
27
- console.warn(
28
- ` \u26A0 Found ${LEGACY_CONFIG_FILE}. Rename to ${CONFIG_FILE} \u2014 legacy filename support will be removed in a future release.
29
- (${legacyPath})`
30
- );
31
- }
32
- function findConfigPath(cwd) {
33
- let dir = path.resolve(cwd);
34
- while (true) {
35
- const configPath = path.join(dir, CONFIG_FILE);
36
- if (fs.existsSync(configPath)) return configPath;
37
- const legacyPath = path.join(dir, LEGACY_CONFIG_FILE);
38
- if (fs.existsSync(legacyPath)) return legacyPath;
39
- const parent = path.dirname(dir);
40
- if (parent === dir) return null;
41
- dir = parent;
42
- }
43
- }
44
- function loadConfig(cwd) {
45
- const configPath = findConfigPath(cwd);
46
- if (!configPath) return null;
47
- if (path.basename(configPath) === LEGACY_CONFIG_FILE) {
48
- warnLegacyFilenameOnce(configPath);
49
- }
50
- try {
51
- const raw = JSON.parse(fs.readFileSync(configPath, "utf-8"));
52
- return migrateConfig(raw);
53
- } catch {
54
- return null;
55
- }
56
- }
57
-
58
- // src/utils/install-deps.ts
59
- import fs2 from "fs";
60
- import path2 from "path";
61
- import { detect } from "@antfu/ni";
62
- import { execa } from "execa";
63
- async function detectPackageManager(cwd) {
64
- const detected = await detect({ programmatic: true, cwd });
65
- if (detected === "pnpm@6" || detected === "pnpm") return "pnpm";
66
- if (detected === "yarn@berry" || detected === "yarn") return "yarn";
67
- if (detected === "bun") return "bun";
68
- if (detected === "npm") return "npm";
69
- const userAgent = process.env.npm_config_user_agent || "";
70
- if (userAgent.startsWith("pnpm")) return "pnpm";
71
- if (userAgent.startsWith("yarn")) return "yarn";
72
- if (userAgent.startsWith("bun")) return "bun";
73
- return "npm";
74
- }
75
- function getInstallArgs(pm, deps) {
76
- switch (pm) {
77
- case "pnpm":
78
- return ["pnpm", ["add", ...deps]];
79
- case "yarn":
80
- return ["yarn", ["add", ...deps]];
81
- case "bun":
82
- return ["bun", ["add", ...deps]];
83
- default:
84
- return ["npm", ["install", ...deps]];
85
- }
86
- }
87
- async function installDependencies(deps, cwd) {
88
- if (deps.length === 0) return;
89
- const pkgPath = path2.join(cwd, "package.json");
90
- let existing = /* @__PURE__ */ new Set();
91
- if (fs2.existsSync(pkgPath)) {
92
- try {
93
- const pkg = JSON.parse(fs2.readFileSync(pkgPath, "utf-8"));
94
- existing = new Set(
95
- Object.keys({ ...pkg.dependencies, ...pkg.devDependencies })
96
- );
97
- } catch {
98
- }
99
- }
100
- const toInstall = deps.filter((dep) => !existing.has(dep));
101
- if (toInstall.length === 0) return;
102
- const pm = await detectPackageManager(cwd);
103
- const [cmd, args] = getInstallArgs(pm, toInstall);
104
- const spinner = createSpinner(`Installing with ${pm}`);
105
- try {
106
- await execa(cmd, args, { cwd });
107
- spinner.succeed(`Installed with ${pm}`);
108
- } catch (error) {
109
- spinner.fail(`Install failed`);
110
- if (error instanceof Error && "stdout" in error && typeof error.stdout === "string" && error.stdout.includes("ERR_PNPM_ADDING_TO_ROOT")) {
111
- throw new Error(
112
- `Cannot install dependencies at a pnpm workspace root.
113
- Run stera-ui init from within a specific workspace package instead,
114
- or use "pnpm add -w <package>" manually to install at the root.`
115
- );
116
- }
117
- throw error;
118
- }
119
- }
120
-
121
- // src/utils/write-stera-css.ts
122
- import fs3 from "fs/promises";
123
- import path3 from "path";
124
- function stripImportLines(content) {
125
- const lines = content.split("\n");
126
- const imports = [];
127
- const kept = [];
128
- for (const line of lines) {
129
- if (line.trim().match(/^@import\s+["'].+["']/)) {
130
- if (!line.trim().match(/^@import\s+["']tailwindcss["']/)) {
131
- imports.push(line.trim());
132
- }
133
- } else {
134
- kept.push(line);
135
- }
136
- }
137
- return { content: kept.join("\n"), imports };
138
- }
139
- async function writeSteraUiCss(config, cwd) {
140
- const item = await fetchRegistryItem("globals");
141
- const rawContent = item.files?.[0]?.content ?? "";
142
- const { content, imports } = stripImportLines(rawContent);
143
- const cssDir = path3.dirname(path3.resolve(cwd, config.css));
144
- const steraUiPath = path3.join(cssDir, "stera-ui.css");
145
- await fs3.mkdir(cssDir, { recursive: true });
146
- await fs3.writeFile(steraUiPath, content, "utf-8");
147
- return {
148
- steraUiPath,
149
- extraImports: imports,
150
- dependencies: item.dependencies ?? []
151
- };
152
- }
153
-
154
- export {
155
- CONFIG_FILE,
156
- LEGACY_CONFIG_FILE,
157
- findConfigPath,
158
- loadConfig,
159
- installDependencies,
160
- writeSteraUiCss
161
- };