@nooeh/cli 0.2.7 → 0.2.8
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/doctor.js +1 -1
- package/dist/init.js +19 -1
- package/package.json +1 -1
package/dist/doctor.js
CHANGED
|
@@ -55,7 +55,7 @@ async function hasStylexCompiler(projectDirectory) {
|
|
|
55
55
|
"rspack.config.js",
|
|
56
56
|
];
|
|
57
57
|
const sources = await Promise.all(configFileNames.map(async (fileName) => readProjectFile(projectDirectory, fileName)));
|
|
58
|
-
return sources.some((source) => source?.includes("@stylexjs/unplugin") &&
|
|
58
|
+
return sources.some((source) => source?.includes("@stylexjs/unplugin") && /\b(?:stylex|unplugin)\.vite\(/.test(source));
|
|
59
59
|
}
|
|
60
60
|
function hasDependency(packageJson, dependency) {
|
|
61
61
|
return Boolean(packageJson?.dependencies?.[dependency] ?? packageJson?.devDependencies?.[dependency]);
|
package/dist/init.js
CHANGED
|
@@ -73,10 +73,28 @@ function configureVite(source) {
|
|
|
73
73
|
async function writeViteFiles(projectDirectory, tokenDirectory, refreshLegacyTokens) {
|
|
74
74
|
const { path: configPath, source: configSource } = await readViteConfig(projectDirectory);
|
|
75
75
|
const configuredVite = configureVite(configSource);
|
|
76
|
+
await addResetImport(projectDirectory);
|
|
76
77
|
await writeNooehFiles(projectDirectory, tokenDirectory, refreshLegacyTokens);
|
|
77
78
|
await writeFile(configPath, configuredVite, "utf8");
|
|
78
79
|
console.log(`Configured Vite and created ${relative(projectDirectory, tokenDirectory)}.`);
|
|
79
80
|
}
|
|
81
|
+
async function addResetImport(projectDirectory) {
|
|
82
|
+
const cssPath = join(projectDirectory, "src/index.css");
|
|
83
|
+
const resetImport = '@import "@nooeh/ui/reset.css";';
|
|
84
|
+
try {
|
|
85
|
+
const source = await readFile(cssPath, "utf8");
|
|
86
|
+
if (source.includes(resetImport))
|
|
87
|
+
return;
|
|
88
|
+
await writeFile(cssPath, `${resetImport}\n\n${source}`, "utf8");
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
92
|
+
await writeFile(cssPath, `${resetImport}\n`, "utf8");
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
80
98
|
async function writeNooehFiles(projectDirectory, tokenDirectory, refreshLegacyTokens = false) {
|
|
81
99
|
await mkdir(tokenDirectory, { recursive: true });
|
|
82
100
|
for (const file of await getTokenFiles()) {
|
|
@@ -125,7 +143,7 @@ export async function init(projectDirectory, options) {
|
|
|
125
143
|
if (!options["skip-dependencies"]) {
|
|
126
144
|
await installDependencies(projectDirectory, ["@stylexjs/stylex"]);
|
|
127
145
|
if (options.framework === "vite") {
|
|
128
|
-
await installDependencies(projectDirectory, ["@stylexjs/unplugin"], true);
|
|
146
|
+
await installDependencies(projectDirectory, ["@nooeh/ui", "@stylexjs/unplugin"], true);
|
|
129
147
|
}
|
|
130
148
|
}
|
|
131
149
|
if (options.framework === "vite") {
|