ui-thing 0.0.6 → 0.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ui-thing",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "CLI used to add Nuxt 3 components to a project",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
@@ -129,7 +129,7 @@ export const add = new Command()
129
129
  }
130
130
  await writeFile(filePath, file.fileContent);
131
131
 
132
- // This is not scalable. We need to find a better way to do this
132
+ // @not-scalable
133
133
  if (component.value === "vue-sonner") {
134
134
  // Update the nuxt config
135
135
  cfg.defaultExport.imports ||= {};
@@ -151,6 +151,32 @@ export const add = new Command()
151
151
  cfg.defaultExport.build.transpile.push("vue-sonner");
152
152
  }
153
153
  }
154
+ // @not-scalable
155
+ if (component.value === "datatable") {
156
+ cfg.defaultExport.app ||= {};
157
+ cfg.defaultExport.app.head ||= {};
158
+ cfg.defaultExport.app.head.script ||= [];
159
+ const scriptOneExists = cfg.defaultExport.app.head.script.find(
160
+ (i: any) =>
161
+ i.src === "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"
162
+ );
163
+ if (!scriptOneExists) {
164
+ cfg.defaultExport.app.head.script.push({
165
+ src: "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js",
166
+ defer: true,
167
+ });
168
+ }
169
+ const scriptTwoExists = cfg.defaultExport.app.head.script.find(
170
+ (i: any) =>
171
+ i.src === "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.min.js"
172
+ );
173
+ if (!scriptTwoExists) {
174
+ cfg.defaultExport.app.head.script.push({
175
+ src: "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.min.js",
176
+ defer: true,
177
+ });
178
+ }
179
+ }
154
180
 
155
181
  // add utils attached to the component
156
182
  loop3: for (let j = 0; j < component.utils.length; j++) {
@@ -200,6 +226,28 @@ export const add = new Command()
200
226
  }
201
227
  await writeFile(filePath, composable.fileContent);
202
228
  }
229
+ // add plugins attached to the component
230
+ loop5: for (let j = 0; j < component.plugins.length; j++) {
231
+ const plugin = component.plugins[j];
232
+ const filePath = path.join(currentDirectory, plugin.dirPath, plugin.fileName);
233
+ // Check if the file exists
234
+ const exists = await fileExists(filePath);
235
+ if (exists && !uiConfig.force) {
236
+ const res = await prompts({
237
+ type: "confirm",
238
+ name: "value",
239
+ message: `The plugins file that we are trying to add ${kleur.bold(
240
+ plugin.fileName
241
+ )} already exists. Overwrite?`,
242
+ initial: true,
243
+ });
244
+ if (!res.value) {
245
+ consola.info(`We will not overwrite the file for ${kleur.cyan(plugin.fileName)}`);
246
+ continue loop5;
247
+ }
248
+ }
249
+ await writeFile(filePath, plugin.fileContent);
250
+ }
203
251
  }
204
252
  }
205
253
  // Add modules to nuxt config