@nooeh/cli 0.2.2 → 0.2.3

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
@@ -82,22 +82,28 @@ function configureVite(source, stylesAlias, tokenDirectory, projectDirectory) {
82
82
  }
83
83
  return withStylex.replace(configPattern, 'defineConfig({\n resolve: { alias: { "@": new URL("./src", import.meta.url).pathname } },\n ');
84
84
  }
85
- async function writeViteFiles(projectDirectory, tokenDirectory, stylesAlias) {
85
+ async function writeViteFiles(projectDirectory, tokenDirectory, stylesAlias, refreshLegacyTokens) {
86
86
  const { path: configPath, source: configSource } = await readViteConfig(projectDirectory);
87
87
  const configuredVite = configureVite(configSource, stylesAlias, tokenDirectory, projectDirectory);
88
- await writeNooehFiles(projectDirectory, tokenDirectory);
88
+ await writeNooehFiles(projectDirectory, tokenDirectory, refreshLegacyTokens);
89
89
  await writeFile(configPath, configuredVite, "utf8");
90
90
  console.log(`Configured Vite and created ${relative(projectDirectory, tokenDirectory)}.`);
91
91
  }
92
- async function writeNooehFiles(projectDirectory, tokenDirectory) {
92
+ async function writeNooehFiles(projectDirectory, tokenDirectory, refreshLegacyTokens = false) {
93
93
  await mkdir(tokenDirectory, { recursive: true });
94
94
  for (const file of await getTokenFiles()) {
95
- await writeFileIfMissing(join(tokenDirectory, file.name), file.content);
95
+ await writeTokenFile(join(tokenDirectory, file.name), file.content, refreshLegacyTokens && file.name === "semantic.stylex.ts");
96
96
  }
97
97
  }
98
- async function writeFileIfMissing(path, source) {
98
+ function isLegacySemanticSource(source) {
99
+ return source.includes('bgCanvas: "initial"') && source.includes('overlay: "initial"');
100
+ }
101
+ async function writeTokenFile(path, source, shouldRefreshLegacyToken) {
99
102
  try {
100
- await access(path);
103
+ const currentSource = await readFile(path, "utf8");
104
+ if (shouldRefreshLegacyToken && isLegacySemanticSource(currentSource)) {
105
+ await writeFile(path, source, "utf8");
106
+ }
101
107
  }
102
108
  catch {
103
109
  await writeFile(path, source, "utf8");
@@ -133,10 +139,10 @@ export async function init(projectDirectory, options) {
133
139
  }
134
140
  }
135
141
  if (options.framework === "vite") {
136
- await writeViteFiles(projectDirectory, tokenDirectory, stylesAlias);
142
+ await writeViteFiles(projectDirectory, tokenDirectory, stylesAlias, Boolean(options.force));
137
143
  }
138
144
  else {
139
- await writeNooehFiles(projectDirectory, tokenDirectory);
145
+ await writeNooehFiles(projectDirectory, tokenDirectory, Boolean(options.force));
140
146
  console.log(`Created ${relative(projectDirectory, tokenDirectory)}.`);
141
147
  console.log("Configure the StyleX compiler for your bundler before importing added components.");
142
148
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nooeh/cli",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
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",