stera-ui 0.6.0 → 0.7.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/dist/{add-JUBSRCDJ.js → add-WUTTJN25.js} +24 -113
- package/dist/chunk-5NLD52O5.js +376 -0
- package/dist/{chunk-SIXUH4HI.js → chunk-V4TMOT6I.js} +158 -94
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -3
- package/dist/{init-E7O5WAUI.js → init-QYYCGWYV.js} +54 -87
- package/dist/utils/index.d.ts +54 -30
- package/dist/utils/index.js +9 -3
- package/package.json +1 -1
- package/dist/chunk-2Y64FOD3.js +0 -161
package/dist/utils/index.d.ts
CHANGED
|
@@ -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
|
|
82
|
-
|
|
83
|
-
|
|
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-
|
|
86
|
-
*
|
|
87
|
-
*
|
|
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
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* an
|
|
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
|
|
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
|
|
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 };
|
package/dist/utils/index.js
CHANGED
|
@@ -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
|
-
|
|
25
|
-
} from "../chunk-
|
|
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
|
-
|
|
57
|
+
writeStyles
|
|
52
58
|
};
|
package/package.json
CHANGED
package/dist/chunk-2Y64FOD3.js
DELETED
|
@@ -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
|
-
};
|