@nuee/cli 0.3.0 → 0.4.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.js +5 -9
- package/dist/dependencies.js +1 -1
- package/dist/init.js +5 -28
- package/package.json +2 -2
package/dist/add.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
-
import { dirname, isAbsolute,
|
|
2
|
+
import { dirname, isAbsolute, relative, resolve } from "node:path";
|
|
3
3
|
import { createInterface } from "node:readline/promises";
|
|
4
4
|
import { defaultConfig, hasConfig, readConfig, resolveConfigAlias } from "./config.js";
|
|
5
5
|
import { installDependencies } from "./dependencies.js";
|
|
@@ -49,11 +49,8 @@ function resolveTargetPath(uiDirectory, filePath) {
|
|
|
49
49
|
}
|
|
50
50
|
return targetPath;
|
|
51
51
|
}
|
|
52
|
-
function replaceTokenImport(source,
|
|
53
|
-
|
|
54
|
-
const importPath = relative(dirname(targetPath), tokenPath).split(sep).join("/");
|
|
55
|
-
const relativeImportPath = importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
56
|
-
return source.replaceAll("@nuee/tokens/semantic.stylex", relativeImportPath);
|
|
52
|
+
function replaceTokenImport(source, stylesAlias) {
|
|
53
|
+
return source.replaceAll("@nuee/tokens/semantic.stylex", `${stylesAlias}/semantic.stylex`);
|
|
57
54
|
}
|
|
58
55
|
function removeReducedMotionStyles(source) {
|
|
59
56
|
const mediaQuery = '"@media (prefers-reduced-motion: reduce)":';
|
|
@@ -101,7 +98,6 @@ export async function add(projectDirectory, componentNames, options = {}) {
|
|
|
101
98
|
const config = options["dry-run"] && shouldInitialize ? defaultConfig : await readConfig(projectDirectory);
|
|
102
99
|
const resolvedList = await Promise.all(componentNameList.map(resolveComponent));
|
|
103
100
|
const uiDirectory = await resolveConfigAlias(projectDirectory, config.aliases.ui, "aliases.ui");
|
|
104
|
-
const stylesDirectory = await resolveConfigAlias(projectDirectory, config.aliases.styles, "aliases.styles");
|
|
105
101
|
let isOverwriteConfirmed = false;
|
|
106
102
|
async function confirmOverwrite() {
|
|
107
103
|
if (isOverwriteConfirmed)
|
|
@@ -115,8 +111,8 @@ export async function add(projectDirectory, componentNames, options = {}) {
|
|
|
115
111
|
if (options["dry-run"])
|
|
116
112
|
continue;
|
|
117
113
|
await writeSource(config.accessibility.respectReducedMotion
|
|
118
|
-
? replaceTokenImport(file.content,
|
|
119
|
-
: removeReducedMotionStyles(replaceTokenImport(file.content,
|
|
114
|
+
? replaceTokenImport(file.content, config.aliases.styles)
|
|
115
|
+
: removeReducedMotionStyles(replaceTokenImport(file.content, config.aliases.styles)), targetPath, confirmOverwrite);
|
|
120
116
|
}
|
|
121
117
|
}
|
|
122
118
|
const externalDependencySet = new Set();
|
package/dist/dependencies.js
CHANGED
|
@@ -18,7 +18,7 @@ export function installDependencies(projectDirectory, dependencies, isDevelopmen
|
|
|
18
18
|
? ["install", developmentFlag, ...dependencies].filter((argument) => Boolean(argument))
|
|
19
19
|
: ["add", developmentFlag, ...dependencies].filter((argument) => Boolean(argument));
|
|
20
20
|
return new Promise((resolvePromise, reject) => {
|
|
21
|
-
const child = spawn(packageManager, arguments_, { cwd: projectDirectory, stdio: "
|
|
21
|
+
const child = spawn(packageManager, arguments_, { cwd: projectDirectory, stdio: "ignore" });
|
|
22
22
|
child.on("error", reject);
|
|
23
23
|
child.on("exit", (code) => {
|
|
24
24
|
if (code === 0)
|
package/dist/init.js
CHANGED
|
@@ -37,38 +37,15 @@ function configureVite(source) {
|
|
|
37
37
|
const importLine = 'import stylex from "@stylexjs/unplugin";';
|
|
38
38
|
const pluginPattern = /plugins:\s*\[([^\]]*)\]/s;
|
|
39
39
|
const stylexPlugin = 'stylex.vite({ unstable_moduleResolution: { type: "commonJS" } })';
|
|
40
|
-
const legacyStylexPluginPattern = /stylex\.vite\(\{\s*useCSSLayers:\s*true\s*\}\)/;
|
|
41
|
-
const emptyStylexPluginPattern = /stylex\.vite\(\)/;
|
|
42
|
-
const moduleResolutionPluginPattern = /stylex\.vite\(\{\s*unstable_moduleResolution:\s*\{\s*type:\s*["']commonJS["']\s*\},?\s*\}\)/s;
|
|
43
|
-
const nueeStylexPluginPattern = /stylex\.vite\(\{\s*(?:\/\/[^\n]*\s*)?(?:useCSSLayers:\s*true,?\s*)?aliases:\s*\{[^}]*\},\s*unstable_moduleResolution:\s*\{\s*type:\s*["']commonJS["'],\s*rootDir:\s*new URL\(["']\.["'],\s*import\.meta\.url\)\.pathname,?\s*\},\s*\}\)/s;
|
|
44
40
|
if (!source.includes("stylex.vite(") && !pluginPattern.test(source)) {
|
|
45
41
|
throw new Error("Could not safely update the Vite plugins array. Add stylex.vite() manually.");
|
|
46
42
|
}
|
|
47
|
-
if (
|
|
48
|
-
return source.replace(nueeStylexPluginPattern, stylexPlugin);
|
|
49
|
-
}
|
|
50
|
-
if (moduleResolutionPluginPattern.test(source))
|
|
43
|
+
if (source.includes("stylex.vite("))
|
|
51
44
|
return source;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (legacyStylexPluginPattern.test(source)) {
|
|
57
|
-
withStylex = source.replace(legacyStylexPluginPattern, stylexPlugin);
|
|
58
|
-
}
|
|
59
|
-
else if (emptyStylexPluginPattern.test(source)) {
|
|
60
|
-
withStylex = source.replace(emptyStylexPluginPattern, stylexPlugin);
|
|
61
|
-
}
|
|
62
|
-
else if (source.includes("stylex.vite(")) {
|
|
63
|
-
throw new Error("Could not safely update the existing StyleX plugin. Configure stylex.vite() manually.");
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
withStylex = (source.includes(importLine) ? source : `${importLine}\n${source}`).replace(pluginPattern, (_, plugins) => {
|
|
67
|
-
const prefix = plugins.trim() ? `${stylexPlugin}, ${plugins}` : stylexPlugin;
|
|
68
|
-
return `plugins: [${prefix}]`;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return withStylex;
|
|
45
|
+
return (source.includes(importLine) ? source : `${importLine}\n${source}`).replace(pluginPattern, (_, plugins) => {
|
|
46
|
+
const prefix = plugins.trim() ? `${stylexPlugin}, ${plugins}` : stylexPlugin;
|
|
47
|
+
return `plugins: [${prefix}]`;
|
|
48
|
+
});
|
|
72
49
|
}
|
|
73
50
|
async function writeViteFiles(projectDirectory, tokenDirectory, refreshLegacyTokens) {
|
|
74
51
|
const { path: configPath, source: configSource } = await readViteConfig(projectDirectory);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuee/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@nuee/registry": "0.
|
|
26
|
+
"@nuee/registry": "0.4.0",
|
|
27
27
|
"jsonc-parser": "^3.3.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|