@nooeh/cli 0.2.2 → 0.2.4

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 CHANGED
@@ -81,7 +81,12 @@ export async function doctor(projectDirectory) {
81
81
  name: "UI path",
82
82
  status: "pass",
83
83
  });
84
- const tokenFiles = ["color-palette.stylex.ts", "semantic.stylex.ts", "themes.stylex.ts"];
84
+ const tokenFiles = [
85
+ "color-palette.stylex.ts",
86
+ "semantic.stylex.ts",
87
+ "themes.stylex.ts",
88
+ "theme-provider.tsx",
89
+ ];
85
90
  const hasTokenFiles = await Promise.all(tokenFiles.map(async (fileName) => {
86
91
  try {
87
92
  await access(resolve(tokenDirectory, fileName));
package/dist/init.js CHANGED
@@ -38,7 +38,6 @@ function getStylexPlugin(stylesAlias, tokenDirectory, projectDirectory) {
38
38
  const aliasPattern = `${stylesAlias}/*`;
39
39
  const aliasTarget = `/ROOT/${tokenPath}/*`;
40
40
  return `stylex.vite({
41
- useCSSLayers: true,
42
41
  aliases: { ${JSON.stringify(aliasPattern)}: [${JSON.stringify(aliasTarget)}] },
43
42
  unstable_moduleResolution: {
44
43
  type: "commonJS",
@@ -54,11 +53,11 @@ function configureVite(source, stylesAlias, tokenDirectory, projectDirectory) {
54
53
  const legacyStylexPluginPattern = /stylex\.vite\(\{\s*useCSSLayers:\s*true\s*\}\)/;
55
54
  const emptyStylexPluginPattern = /stylex\.vite\(\)/;
56
55
  if (!source.includes("stylex.vite(") && !pluginPattern.test(source)) {
57
- throw new Error("Could not safely update the Vite plugins array. Add stylex.vite({ useCSSLayers: true }) manually.");
56
+ throw new Error("Could not safely update the Vite plugins array. Add stylex.vite() manually.");
58
57
  }
59
58
  let withStylex = source;
60
59
  if (source.includes("unstable_moduleResolution")) {
61
- withStylex = source;
60
+ withStylex = source.replace(/\s*useCSSLayers:\s*true,?/, "");
62
61
  }
63
62
  else if (legacyStylexPluginPattern.test(source)) {
64
63
  withStylex = source.replace(legacyStylexPluginPattern, stylexPlugin);
@@ -82,22 +81,28 @@ function configureVite(source, stylesAlias, tokenDirectory, projectDirectory) {
82
81
  }
83
82
  return withStylex.replace(configPattern, 'defineConfig({\n resolve: { alias: { "@": new URL("./src", import.meta.url).pathname } },\n ');
84
83
  }
85
- async function writeViteFiles(projectDirectory, tokenDirectory, stylesAlias) {
84
+ async function writeViteFiles(projectDirectory, tokenDirectory, stylesAlias, refreshLegacyTokens) {
86
85
  const { path: configPath, source: configSource } = await readViteConfig(projectDirectory);
87
86
  const configuredVite = configureVite(configSource, stylesAlias, tokenDirectory, projectDirectory);
88
- await writeNooehFiles(projectDirectory, tokenDirectory);
87
+ await writeNooehFiles(projectDirectory, tokenDirectory, refreshLegacyTokens);
89
88
  await writeFile(configPath, configuredVite, "utf8");
90
89
  console.log(`Configured Vite and created ${relative(projectDirectory, tokenDirectory)}.`);
91
90
  }
92
- async function writeNooehFiles(projectDirectory, tokenDirectory) {
91
+ async function writeNooehFiles(projectDirectory, tokenDirectory, refreshLegacyTokens = false) {
93
92
  await mkdir(tokenDirectory, { recursive: true });
94
93
  for (const file of await getTokenFiles()) {
95
- await writeFileIfMissing(join(tokenDirectory, file.name), file.content);
94
+ await writeTokenFile(join(tokenDirectory, file.name), file.content, refreshLegacyTokens && file.name === "semantic.stylex.ts");
96
95
  }
97
96
  }
98
- async function writeFileIfMissing(path, source) {
97
+ function isLegacySemanticSource(source) {
98
+ return source.includes('bgCanvas: "initial"') && source.includes('overlay: "initial"');
99
+ }
100
+ async function writeTokenFile(path, source, shouldRefreshLegacyToken) {
99
101
  try {
100
- await access(path);
102
+ const currentSource = await readFile(path, "utf8");
103
+ if (shouldRefreshLegacyToken && isLegacySemanticSource(currentSource)) {
104
+ await writeFile(path, source, "utf8");
105
+ }
101
106
  }
102
107
  catch {
103
108
  await writeFile(path, source, "utf8");
@@ -133,10 +138,10 @@ export async function init(projectDirectory, options) {
133
138
  }
134
139
  }
135
140
  if (options.framework === "vite") {
136
- await writeViteFiles(projectDirectory, tokenDirectory, stylesAlias);
141
+ await writeViteFiles(projectDirectory, tokenDirectory, stylesAlias, Boolean(options.force));
137
142
  }
138
143
  else {
139
- await writeNooehFiles(projectDirectory, tokenDirectory);
144
+ await writeNooehFiles(projectDirectory, tokenDirectory, Boolean(options.force));
140
145
  console.log(`Created ${relative(projectDirectory, tokenDirectory)}.`);
141
146
  console.log("Configure the StyleX compiler for your bundler before importing added components.");
142
147
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nooeh/cli",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "private": false,
5
5
  "bin": {
6
6
  "nooeh": "./dist/cli.js"
@@ -19,7 +19,7 @@
19
19
  "access": "public"
20
20
  },
21
21
  "dependencies": {
22
- "@nooeh/registry": "0.1.1"
22
+ "@nooeh/registry": "0.1.2"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "^22.20.1",