stera-ui 0.3.0 → 0.3.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/dist/cli.js CHANGED
@@ -968,11 +968,28 @@ function buildConfig(project, strategy) {
968
968
  }
969
969
  };
970
970
  }
971
- function stripTailwindCoreImport(content) {
972
- return content.split("\n").filter((line) => !line.trim().match(/^@import\s+["']tailwindcss["']/)).join("\n");
971
+ function stripImportLines(content) {
972
+ const lines = content.split("\n");
973
+ const imports = [];
974
+ const kept = [];
975
+ for (const line of lines) {
976
+ if (line.trim().match(/^@import\s+["'].+["']/)) {
977
+ if (!line.trim().match(/^@import\s+["']tailwindcss["']/)) {
978
+ imports.push(line.trim());
979
+ }
980
+ } else {
981
+ kept.push(line);
982
+ }
983
+ }
984
+ return { content: kept.join("\n"), imports };
973
985
  }
974
986
  function insertImportLine(filePath, importStatement) {
975
987
  const content = fs9.readFileSync(filePath, "utf-8");
988
+ const importPath = importStatement.match(/["']([^"']+)["']/)?.[1];
989
+ if (importPath) {
990
+ const escaped = importPath.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
991
+ if (new RegExp(`@import\\s+["']${escaped}["']`).test(content)) return;
992
+ }
976
993
  const lines = content.split("\n");
977
994
  let lastImportIndex = -1;
978
995
  for (let i = 0; i < lines.length; i++) {
@@ -1145,12 +1162,15 @@ async function init(options) {
1145
1162
  try {
1146
1163
  const globalsItem = await fetchRegistryItem("globals");
1147
1164
  const globalsContent = globalsItem.files?.[0]?.content ?? "";
1148
- const steraUiContent = stripTailwindCoreImport(globalsContent);
1165
+ const { content: steraUiContent, imports } = stripImportLines(globalsContent);
1149
1166
  const steraUiPath = path10.join(cssDir, "stera-ui.css");
1150
1167
  fs9.mkdirSync(cssDir, { recursive: true });
1151
1168
  fs9.writeFileSync(steraUiPath, steraUiContent, "utf-8");
1152
1169
  console.log(` ${CHECK} Created ${path10.relative(cwd, steraUiPath)}`);
1153
1170
  const existingCssPath = path10.resolve(cwd, project.existingCssFile);
1171
+ for (const imp of imports) {
1172
+ insertImportLine(existingCssPath, imp);
1173
+ }
1154
1174
  insertImportLine(existingCssPath, "@import './stera-ui.css';");
1155
1175
  console.log(` ${CHECK} Added @import to ${project.existingCssFile}`);
1156
1176
  } catch {
@@ -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
- path: string;
12
11
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
12
+ path: string;
13
13
  content?: string | undefined;
14
14
  target?: string | undefined;
15
15
  }, {
16
- path: string;
17
16
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
17
+ path: string;
18
18
  content?: string | undefined;
19
19
  target?: string | undefined;
20
20
  }>;
@@ -88,13 +88,13 @@ 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
- path: string;
92
91
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
92
+ path: string;
93
93
  content?: string | undefined;
94
94
  target?: string | undefined;
95
95
  }, {
96
- path: string;
97
96
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
97
+ path: string;
98
98
  content?: string | undefined;
99
99
  target?: string | undefined;
100
100
  }>, "many">>;
@@ -114,8 +114,8 @@ declare const registryItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
114
114
  dependencies?: string[] | undefined;
115
115
  registryDependencies?: string[] | undefined;
116
116
  files?: {
117
- path: string;
118
117
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
118
+ path: string;
119
119
  content?: string | undefined;
120
120
  target?: string | undefined;
121
121
  }[] | undefined;
@@ -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
- path: string;
139
138
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
139
+ path: string;
140
140
  content?: string | undefined;
141
141
  target?: string | undefined;
142
142
  }[] | undefined;
@@ -152,13 +152,13 @@ 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
- path: string;
156
155
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
156
+ path: string;
157
157
  content?: string | undefined;
158
158
  target?: string | undefined;
159
159
  }, {
160
- path: string;
161
160
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
161
+ path: string;
162
162
  content?: string | undefined;
163
163
  target?: string | undefined;
164
164
  }>, "many">;
@@ -166,8 +166,8 @@ declare const registryItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
166
166
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style";
167
167
  name: string;
168
168
  files: {
169
- path: string;
170
169
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
170
+ path: string;
171
171
  content?: string | undefined;
172
172
  target?: string | undefined;
173
173
  }[];
@@ -177,8 +177,8 @@ declare const registryItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
177
177
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style";
178
178
  name: string;
179
179
  files: {
180
- path: string;
181
180
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
181
+ path: string;
182
182
  content?: string | undefined;
183
183
  target?: string | undefined;
184
184
  }[];
@@ -231,13 +231,13 @@ declare const registryIndexSchema: z.ZodObject<{
231
231
  content: z.ZodOptional<z.ZodString>;
232
232
  target: z.ZodOptional<z.ZodString>;
233
233
  }, "strip", z.ZodTypeAny, {
234
- path: string;
235
234
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
235
+ path: string;
236
236
  content?: string | undefined;
237
237
  target?: string | undefined;
238
238
  }, {
239
- path: string;
240
239
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
240
+ path: string;
241
241
  content?: string | undefined;
242
242
  target?: string | undefined;
243
243
  }>, "many">>;
@@ -257,8 +257,8 @@ declare const registryIndexSchema: z.ZodObject<{
257
257
  dependencies?: string[] | undefined;
258
258
  registryDependencies?: string[] | undefined;
259
259
  files?: {
260
- path: string;
261
260
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
261
+ path: string;
262
262
  content?: string | undefined;
263
263
  target?: string | undefined;
264
264
  }[] | undefined;
@@ -278,8 +278,8 @@ declare const registryIndexSchema: z.ZodObject<{
278
278
  dependencies?: string[] | undefined;
279
279
  registryDependencies?: string[] | undefined;
280
280
  files?: {
281
- path: string;
282
281
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
282
+ path: string;
283
283
  content?: string | undefined;
284
284
  target?: string | undefined;
285
285
  }[] | undefined;
@@ -295,13 +295,13 @@ declare const registryIndexSchema: z.ZodObject<{
295
295
  content: z.ZodOptional<z.ZodString>;
296
296
  target: z.ZodOptional<z.ZodString>;
297
297
  }, "strip", z.ZodTypeAny, {
298
- path: string;
299
298
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
299
+ path: string;
300
300
  content?: string | undefined;
301
301
  target?: string | undefined;
302
302
  }, {
303
- path: string;
304
303
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
304
+ path: string;
305
305
  content?: string | undefined;
306
306
  target?: string | undefined;
307
307
  }>, "many">;
@@ -309,8 +309,8 @@ declare const registryIndexSchema: z.ZodObject<{
309
309
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style";
310
310
  name: string;
311
311
  files: {
312
- path: string;
313
312
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
313
+ path: string;
314
314
  content?: string | undefined;
315
315
  target?: string | undefined;
316
316
  }[];
@@ -320,8 +320,8 @@ declare const registryIndexSchema: z.ZodObject<{
320
320
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style";
321
321
  name: string;
322
322
  files: {
323
- path: string;
324
323
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
324
+ path: string;
325
325
  content?: string | undefined;
326
326
  target?: string | undefined;
327
327
  }[];
@@ -346,8 +346,8 @@ declare const registryIndexSchema: z.ZodObject<{
346
346
  dependencies?: string[] | undefined;
347
347
  registryDependencies?: string[] | undefined;
348
348
  files?: {
349
- path: string;
350
349
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
350
+ path: string;
351
351
  content?: string | undefined;
352
352
  target?: string | undefined;
353
353
  }[] | undefined;
@@ -355,8 +355,8 @@ declare const registryIndexSchema: z.ZodObject<{
355
355
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style";
356
356
  name: string;
357
357
  files: {
358
- path: string;
359
358
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
359
+ path: string;
360
360
  content?: string | undefined;
361
361
  target?: string | undefined;
362
362
  }[];
@@ -381,8 +381,8 @@ declare const registryIndexSchema: z.ZodObject<{
381
381
  dependencies?: string[] | undefined;
382
382
  registryDependencies?: string[] | undefined;
383
383
  files?: {
384
- path: string;
385
384
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
385
+ path: string;
386
386
  content?: string | undefined;
387
387
  target?: string | undefined;
388
388
  }[] | undefined;
@@ -390,8 +390,8 @@ declare const registryIndexSchema: z.ZodObject<{
390
390
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style";
391
391
  name: string;
392
392
  files: {
393
- path: string;
394
393
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
394
+ path: string;
395
395
  content?: string | undefined;
396
396
  target?: string | undefined;
397
397
  }[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stera-ui",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "description": "Add Stera UI components to your project.",
6
6
  "license": "MIT",