vueless 1.1.1-beta.61 → 1.1.1-beta.62

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.
@@ -17,13 +17,15 @@ import {
17
17
  VUELESS_CONFIG_FILE_NAME,
18
18
  } from "../../constants.js";
19
19
 
20
- const vuelessInitOptions = ["--ts", "--js"];
20
+ const vuelessInitOptions = ["--ts", "--js", "--pnpm", "--yarn"];
21
21
 
22
22
  /**
23
23
  * Initializes Vueless in the project by creating a default config file and vueless config directory.
24
24
  * @param {string[]} options - The function options.
25
25
  * @param {boolean} options.includes("--ts") - If true, creates a TypeScript config file.
26
26
  * @param {boolean} options.includes("--js") - If true, creates a JavaScript config file.
27
+ * @param {boolean} options.includes("--pnpm") - If true, creates a `.npmrc` config with hoisting disabled.
28
+ * @param {boolean} options.includes("--yarn") - If true, creates a `.yarnrc.yml` config with pnp disabled.
27
29
  */
28
30
  export async function vuelessInit(options) {
29
31
  const isValidOptions = options.every((option) => vuelessInitOptions.includes(option));
@@ -37,53 +39,105 @@ export async function vuelessInit(options) {
37
39
  const hasTypeScript = await detectTypeScript();
38
40
  const fileExt = options.includes("--ts") || hasTypeScript ? TYPESCRIPT_EXT : JAVASCRIPT_EXT;
39
41
 
40
- const formattedDestPath = path.format({
42
+ const destPath = path.format({
41
43
  dir: cwd(),
42
44
  name: VUELESS_CONFIG_FILE_NAME,
43
45
  ext: fileExt,
44
46
  });
45
47
 
46
- /* Backup existing config if it exists. */
47
- if (existsSync(formattedDestPath)) {
48
- const timestamp = new Date().valueOf();
49
- const renamedTarget = `${VUELESS_CONFIG_FILE_NAME}-backup-${timestamp}${fileExt}`;
50
-
51
- await rename(formattedDestPath, renamedTarget);
52
-
53
- console.warn(
54
- styleText(
55
- "yellow",
56
- // eslint-disable-next-line vue/max-len
57
- `Current Vueless config backed into: '${path.basename(renamedTarget)}' folder. Don't forget to remove it before commit.`,
58
- ),
59
- );
48
+ /* Create pnpm package manager config. */
49
+ if (options.includes("--pnpm")) {
50
+ await createPackageManagerConfig(".npmrc", [
51
+ "# Pnpm",
52
+ "# Vueless: disable hoisting for the package related modules.",
53
+ "public-hoist-pattern[] = tailwindcss",
54
+ "public-hoist-pattern[] = *storybook*",
55
+ "public-hoist-pattern[] = prettier2",
56
+ ]);
57
+ }
58
+
59
+ /* Create yarn 2+ package manager config. */
60
+ if (options.includes("--yarn")) {
61
+ await createPackageManagerConfig(".yarnrc.yml", [
62
+ "# Yarn 2+",
63
+ "# Vueless: install Node packages into a standard node_modules folder, the same way as Yarn Classic or npm.",
64
+ "nodeLinker: node-modules",
65
+ ]);
60
66
  }
61
67
 
68
+ /* Backup existing config if it exists. */
69
+ await backupVuelessConfig(destPath);
70
+
62
71
  /* Create a default config file. */
63
- await writeFile(formattedDestPath, DEFAULT_VUELESS_CONFIG_CONTENT, "utf-8");
72
+ await createVuelessConfig(destPath);
64
73
 
65
- console.log(
74
+ /* Create a vueless config directory and index file. */
75
+ await createVuelessConfigDir(fileExt);
76
+ }
77
+
78
+ /**
79
+ * Backs up the existing Vueless config file by renaming it.
80
+ * @param {string} destPath - The path to the Vueless config file.
81
+ */
82
+ async function backupVuelessConfig(destPath) {
83
+ if (!existsSync(destPath)) return;
84
+
85
+ const fileNameWithoutExtension = path.basename(destPath, path.extname(destPath));
86
+ const extension = path.extname(destPath);
87
+ const timestamp = new Date().valueOf();
88
+
89
+ const backupConfigName = `${fileNameWithoutExtension}-backup-${timestamp}${extension}`;
90
+
91
+ await rename(destPath, backupConfigName);
92
+
93
+ console.warn(
66
94
  styleText(
67
- "green",
68
- `The '${formattedDestPath.split(path.sep).at(-1)}' was created in the project root directory.`,
95
+ "yellow",
96
+ `Current Vueless config backed into: '${path.basename(backupConfigName)}'. Remove it before commit.`,
69
97
  ),
70
98
  );
99
+ }
71
100
 
72
- /* Create a vueless config directory and index file. */
101
+ /**
102
+ * Creates a default Vueless config file.
103
+ * @param {string} destPath - The path to the Vueless config file.
104
+ */
105
+ async function createVuelessConfig(destPath) {
106
+ await writeFile(destPath, DEFAULT_VUELESS_CONFIG_CONTENT, "utf-8");
107
+
108
+ const fileName = path.basename(destPath);
109
+
110
+ console.log(styleText("green", `The '${fileName}' was created in the project root.`));
111
+ }
112
+
113
+ /**
114
+ * Creates a Vueless config directory and index file.
115
+ * @param {string} fileExt - The file extension to use for the index file.
116
+ */
117
+ async function createVuelessConfigDir(fileExt) {
73
118
  const vuelessDir = path.join(cwd(), VUELESS_CONFIG_DIR);
74
- const destPath = path.join(vuelessDir, `${CONFIG_INDEX_FILE_NAME}${fileExt}`);
75
119
 
76
- if (!existsSync(vuelessDir)) {
77
- mkdirSync(vuelessDir);
78
- console.log(
79
- styleText(
80
- "green",
81
- `The '${VUELESS_CONFIG_DIR}' directory was created in the project root directory.`,
82
- ),
83
- );
84
- }
120
+ if (existsSync(vuelessDir)) return;
121
+
122
+ mkdirSync(vuelessDir);
123
+ console.log(
124
+ styleText("green", `The '${VUELESS_CONFIG_DIR}' directory was created in the project root.`),
125
+ );
85
126
 
86
127
  const indexFileContent = await generateConfigIndexContent();
128
+ const destPath = path.join(vuelessDir, `${CONFIG_INDEX_FILE_NAME}${fileExt}`);
87
129
 
88
130
  await writeFile(destPath, indexFileContent, "utf-8");
89
131
  }
132
+
133
+ /**
134
+ * Creates a package manager config file.
135
+ * @param {string} fileName - The name of the config file.
136
+ * @param {string[]} fileContent - The content of the config file.
137
+ */
138
+ async function createPackageManagerConfig(fileName, fileContent) {
139
+ const filePath = path.join(cwd(), fileName);
140
+
141
+ await writeFile(filePath, fileContent.join("\n"), "utf-8");
142
+ console.log(styleText("green", `The '${fileName}' was created in the project root.`));
143
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "1.1.1-beta.61",
3
+ "version": "1.1.1-beta.62",
4
4
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
5
5
  "author": "Johnny Grid <hello@vueless.com> (https://vueless.com)",
6
6
  "homepage": "https://vueless.com",
package/tailwind.css CHANGED
@@ -5,9 +5,14 @@
5
5
 
6
6
  /* ------ Production sources ------ */
7
7
 
8
+ /* npm, yarn, bun */
8
9
  @source "../.cache/vueless/tailwind";
9
10
  @source "../.cache/vueless/mergedConfigs";
10
11
 
12
+ /* pnpm */
13
+ @source "../../../../.cache/vueless/tailwind";
14
+ @source "../../../../.cache/vueless/mergedConfigs";
15
+
11
16
  /* ------ Color mode settings ------ */
12
17
 
13
18
  @variant light (&:where(.vl-light, .vl-light *));