@tokiui/cli 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/index.js +28 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -189,20 +189,34 @@ var initCommand = new import_commander.Command("init").description("Initialize t
|
|
|
189
189
|
spinner.start("Setting up global CSS");
|
|
190
190
|
const globalsAbsPath = import_path2.default.join(cwd, answers.globalsPath);
|
|
191
191
|
await import_fs_extra2.default.ensureDir(import_path2.default.dirname(globalsAbsPath));
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
if (
|
|
195
|
-
prepend.push('@import "tailwindcss";');
|
|
196
|
-
}
|
|
197
|
-
if (!css.includes("@tokiui/ui/styles.css")) {
|
|
198
|
-
prepend.push('@import "@tokiui/ui/styles.css";');
|
|
199
|
-
}
|
|
200
|
-
if (prepend.length > 0) {
|
|
201
|
-
css = prepend.join("\n") + "\n\n" + css;
|
|
202
|
-
await import_fs_extra2.default.writeFile(globalsAbsPath, css);
|
|
203
|
-
spinner.succeed(`globals.css updated (${answers.globalsPath})`);
|
|
204
|
-
} else {
|
|
192
|
+
const TOKIUI_CSS = '@import "tailwindcss";\n@import "@tokiui/ui/styles.css";\n';
|
|
193
|
+
const existingCss = import_fs_extra2.default.existsSync(globalsAbsPath) ? await import_fs_extra2.default.readFile(globalsAbsPath, "utf-8") : "";
|
|
194
|
+
if (existingCss.includes("@tokiui/ui/styles.css")) {
|
|
205
195
|
spinner.succeed("globals.css already configured");
|
|
196
|
+
} else if (!existingCss.trim()) {
|
|
197
|
+
await import_fs_extra2.default.writeFile(globalsAbsPath, TOKIUI_CSS);
|
|
198
|
+
spinner.succeed(`globals.css created (${answers.globalsPath})`);
|
|
199
|
+
} else {
|
|
200
|
+
const isStarterTheme = /@media\s*\(\s*prefers-color-scheme\s*:\s*dark\s*\)/.test(existingCss) || /@theme\s+inline/.test(existingCss);
|
|
201
|
+
if (isStarterTheme) {
|
|
202
|
+
await import_fs_extra2.default.writeFile(globalsAbsPath + ".bak", existingCss);
|
|
203
|
+
await import_fs_extra2.default.writeFile(globalsAbsPath, TOKIUI_CSS);
|
|
204
|
+
spinner.succeed("globals.css set up \u2014 tokiui now owns the theme");
|
|
205
|
+
console.log(
|
|
206
|
+
import_kleur.default.dim(` Replaced the starter theme (saved a copy to ${import_path2.default.basename(globalsAbsPath)}.bak).`)
|
|
207
|
+
);
|
|
208
|
+
} else {
|
|
209
|
+
const lead = [];
|
|
210
|
+
if (!existingCss.includes('@import "tailwindcss"') && !existingCss.includes("@import 'tailwindcss'")) {
|
|
211
|
+
lead.push('@import "tailwindcss";');
|
|
212
|
+
}
|
|
213
|
+
lead.push('@import "@tokiui/ui/styles.css";');
|
|
214
|
+
await import_fs_extra2.default.writeFile(globalsAbsPath, lead.join("\n") + "\n\n" + existingCss);
|
|
215
|
+
spinner.succeed(`globals.css updated (${answers.globalsPath})`);
|
|
216
|
+
console.log(
|
|
217
|
+
import_kleur.default.dim(" Note: remove any :root / @theme / prefers-color-scheme rules that conflict with tokiui tokens.")
|
|
218
|
+
);
|
|
219
|
+
}
|
|
206
220
|
}
|
|
207
221
|
spinner.start("Checking TypeScript path aliases");
|
|
208
222
|
const tsconfigPath = import_path2.default.join(cwd, "tsconfig.json");
|
|
@@ -266,7 +280,7 @@ function resolveRegistryRef() {
|
|
|
266
280
|
}
|
|
267
281
|
return envRef;
|
|
268
282
|
}
|
|
269
|
-
return `cli-v${"0.3.
|
|
283
|
+
return `cli-v${"0.3.1"}`;
|
|
270
284
|
}
|
|
271
285
|
var REGISTRY_REF = resolveRegistryRef();
|
|
272
286
|
var REGISTRY_BASE = `${ALLOWED_FETCH_ORIGIN}${REGISTRY_REF}/packages/registry`;
|