@nuee/cli 0.4.0 → 0.4.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.
Files changed (2) hide show
  1. package/dist/init.js +11 -7
  2. package/package.json +2 -2
package/dist/init.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { access, mkdir, readFile, writeFile } from "node:fs/promises";
2
- import { join } from "node:path";
2
+ import { dirname, join, relative, sep } from "node:path";
3
3
  import { createInterface } from "node:readline/promises";
4
4
  import { defaultConfig, hasConfig, resolveConfigAlias, writeConfig } from "./config.js";
5
5
  import { installDependencies } from "./dependencies.js";
6
- import { getTokenFiles } from "@nuee/registry";
6
+ import { getFoundationFiles } from "@nuee/registry";
7
7
  async function ask(question, defaultValue, readline) {
8
8
  const answer = await readline.question(`${question} (${defaultValue}) `);
9
9
  return answer.trim() || defaultValue;
@@ -50,13 +50,17 @@ function configureVite(source) {
50
50
  async function writeViteFiles(projectDirectory, tokenDirectory, refreshLegacyTokens) {
51
51
  const { path: configPath, source: configSource } = await readViteConfig(projectDirectory);
52
52
  const configuredVite = configureVite(configSource);
53
- await addResetImport(projectDirectory);
54
53
  await writeNueeFiles(projectDirectory, tokenDirectory, refreshLegacyTokens);
54
+ await addResetImport(projectDirectory, tokenDirectory);
55
55
  await writeFile(configPath, configuredVite, "utf8");
56
56
  }
57
- async function addResetImport(projectDirectory) {
57
+ function getRelativeImportPath(from, to) {
58
+ const path = relative(dirname(from), to).split(sep).join("/");
59
+ return path.startsWith(".") ? path : `./${path}`;
60
+ }
61
+ async function addResetImport(projectDirectory, tokenDirectory) {
58
62
  const cssPath = join(projectDirectory, "src/index.css");
59
- const resetImport = '@import "@nuee/ui/reset.css";';
63
+ const resetImport = `@import "${getRelativeImportPath(cssPath, join(tokenDirectory, "reset.css"))}";`;
60
64
  try {
61
65
  const source = await readFile(cssPath, "utf8");
62
66
  if (source.includes(resetImport))
@@ -73,7 +77,7 @@ async function addResetImport(projectDirectory) {
73
77
  }
74
78
  async function writeNueeFiles(projectDirectory, tokenDirectory, refreshLegacyTokens = false) {
75
79
  await mkdir(tokenDirectory, { recursive: true });
76
- for (const file of await getTokenFiles()) {
80
+ for (const file of await getFoundationFiles()) {
77
81
  await writeTokenFile(join(tokenDirectory, file.name), file.content, refreshLegacyTokens, file.name);
78
82
  }
79
83
  }
@@ -119,7 +123,7 @@ export async function init(projectDirectory, options, shouldLog = true) {
119
123
  if (!options["skip-dependencies"]) {
120
124
  await installDependencies(projectDirectory, ["@stylexjs/stylex"]);
121
125
  if (options.framework === "vite") {
122
- await installDependencies(projectDirectory, ["@nuee/ui", "@stylexjs/unplugin"], true);
126
+ await installDependencies(projectDirectory, ["@stylexjs/unplugin"], true);
123
127
  }
124
128
  }
125
129
  if (options.framework === "vite") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuee/cli",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
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.4.0",
26
+ "@nuee/registry": "0.4.1",
27
27
  "jsonc-parser": "^3.3.1"
28
28
  },
29
29
  "devDependencies": {