sprawlify 0.0.90 → 0.0.91

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/index.mjs +78 -92
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -7,7 +7,7 @@ import { z } from "zod";
7
7
  import { cyan, green, red, yellow } from "kleur/colors";
8
8
  import { existsSync } from "fs";
9
9
  //#region package.json
10
- var version = "0.0.90";
10
+ var version = "0.0.91";
11
11
  //#endregion
12
12
  //#region src/utils/file-helper.ts
13
13
  const FILE_BACKUP_SUFFIX = ".bak";
@@ -166,8 +166,26 @@ const PRESETS = {
166
166
  };
167
167
  //#endregion
168
168
  //#region src/frameworks/index.ts
169
- const FRAMEWORKS = {};
170
- const METAFRAMEWORKS = {};
169
+ const FRAMEWORKS = {
170
+ react: { title: "React" },
171
+ solid: { title: "Solid" },
172
+ svelte: { title: "Svelte" },
173
+ vue: { title: "Vue" }
174
+ };
175
+ const METAFRAMEWORKS = {
176
+ next: {
177
+ title: "Next.js",
178
+ frameworks: ["react"]
179
+ },
180
+ nuxt: {
181
+ title: "Nuxt",
182
+ frameworks: ["vue"]
183
+ },
184
+ sveltekit: {
185
+ title: "SvelteKit",
186
+ frameworks: ["svelte"]
187
+ }
188
+ };
171
189
  //#endregion
172
190
  //#region src/utils/env-loader.ts
173
191
  async function loadEnvFiles(cwd = process.cwd()) {
@@ -199,7 +217,7 @@ const initOptionsSchema = z.object({
199
217
  components: z.array(z.string()).optional(),
200
218
  yes: z.boolean(),
201
219
  defaults: z.boolean(),
202
- force: z.boolean(),
220
+ override: z.boolean(),
203
221
  reinstall: z.boolean().optional(),
204
222
  framework: z.string().optional(),
205
223
  metaframework: z.string().optional()
@@ -208,93 +226,10 @@ async function runInit(options) {
208
226
  const cwd = options.cwd;
209
227
  const componentsJsonPath = path.resolve(cwd, "components.json");
210
228
  logger.info("Starting project initialization...");
211
- if (!options.defaults && !options.skipPreflight) {
212
- if (!options.framework) {
213
- const { framework } = await prompts({
214
- type: "select",
215
- name: "framework",
216
- message: "Which framework would you like to use?",
217
- choices: [
218
- {
219
- title: "React",
220
- value: "react"
221
- },
222
- {
223
- title: "Solid",
224
- value: "solid"
225
- },
226
- {
227
- title: "Svelte",
228
- value: "svelte"
229
- },
230
- {
231
- title: "Vue",
232
- value: "vue"
233
- }
234
- ],
235
- initial: 0
236
- });
237
- if (!framework) {
238
- logger.error("Framework selection is required.");
239
- process.exit(1);
240
- }
241
- options.framework = framework;
242
- }
243
- if (!options.preset) {
244
- const { preset } = await prompts({
245
- type: "select",
246
- name: "preset",
247
- message: "Which preset would you like to use?",
248
- choices: Object.entries(PRESETS).map(([key, preset]) => ({
249
- title: preset.name,
250
- value: key,
251
- disabled: !preset.frameworks.includes(options.framework)
252
- })),
253
- initial: 0
254
- });
255
- if (!preset) {
256
- logger.error("Preset selection is required.");
257
- process.exit(1);
258
- }
259
- options.preset = preset;
260
- }
261
- if (!options.metaframework) {
262
- const { metaframework } = await prompts({
263
- type: "select",
264
- name: "metaframework",
265
- message: "Which metaframework would you like to use (optional)?",
266
- choices: [
267
- {
268
- title: "None",
269
- value: "none"
270
- },
271
- {
272
- title: "Next.js",
273
- value: "next"
274
- },
275
- {
276
- title: "Vite",
277
- value: "vite"
278
- },
279
- {
280
- title: "Nuxt",
281
- value: "nuxt"
282
- },
283
- {
284
- title: "SvelteKit",
285
- value: "sveltekit"
286
- }
287
- ],
288
- initial: 0
289
- });
290
- options.metaframework = metaframework === "none" ? void 0 : metaframework;
291
- }
292
- }
293
- if (options.framework) options.framework;
294
229
  const config = {
295
230
  $schema: "https://ui.primitives.com/schema.json",
296
- framework: options.framework || "react",
297
- preset: options.preset || "monochrome",
231
+ framework: options.framework,
232
+ preset: options.preset,
298
233
  metaframework: options.metaframework,
299
234
  aliases: {
300
235
  components: "@/components",
@@ -322,7 +257,7 @@ async function runInit(options) {
322
257
  throw error;
323
258
  }
324
259
  }
325
- const init = new Command().name("init").alias("create").description("initialize your project and install dependencies").argument("[components...]", "names, url or local path to component").option("-p, --preset <preset>", "the preset to use. (monochrome, clay)").option("-f, --framework <framework>", "the framework to use. (react, solid, svelte, vue)").option("--metaframework <metaframework>", "the metaframework to use. (next, react-router, nuxt, sveltekit)").option("-y, --yes", "skip confirmation prompt.", true).option("-d, --defaults", "use default configuration: --preset=monochrome --framework=react --metaframework=vanilla", false).option("-f, --force", "force overwrite of existing configuration.", false).option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.", process.cwd()).option("-n, --name <name>", "the name for the new project.").option("-s, --silent", "mute output.", false).option("--reinstall", "re-install existing UI components.").option("--no-reinstall", "do not re-install existing UI components.").action(async (components, opts) => {
260
+ const init = new Command().name("init").alias("create").description("initialize your project and install dependencies").argument("[components...]", "names, url or local path to component").option("-p, --preset <preset>", "the preset to use. (monochrome, clay)").option("-f, --framework <framework>", "the framework to use. (react, solid, svelte, vue)").option("--metaframework <metaframework>", "the metaframework to use. (next, react-router, nuxt, sveltekit)").option("-y, --yes", "skip confirmation prompt.", true).option("-d, --defaults", "use default configuration: --preset=monochrome --framework=react --metaframework=vanilla", false).option("-o, --override", "override existing configuration.", false).option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.", process.cwd()).option("-n, --name <name>", "the name for the new project.").option("-s, --silent", "mute output.", false).option("--reinstall", "re-install existing UI components.").option("--no-reinstall", "do not re-install existing UI components.").action(async (components, opts) => {
326
261
  let reinstallComponents = [];
327
262
  const restoreBackupOnExit = () => {};
328
263
  process.on("exit", restoreBackupOnExit);
@@ -352,8 +287,59 @@ const init = new Command().name("init").alias("create").description("initialize
352
287
  logger.break();
353
288
  process.exit(1);
354
289
  }
290
+ if (!options.framework) {
291
+ const { framework } = await prompts({
292
+ type: "select",
293
+ name: "framework",
294
+ message: "Which framework would you like to use?",
295
+ choices: Object.keys(FRAMEWORKS).map((framework) => ({
296
+ title: FRAMEWORKS[framework].title,
297
+ value: framework
298
+ })),
299
+ initial: 0
300
+ });
301
+ if (!framework) {
302
+ logger.error("Framework selection is required.");
303
+ process.exit(1);
304
+ }
305
+ options.framework = framework;
306
+ }
307
+ if (!options.preset) {
308
+ const { preset } = await prompts({
309
+ type: "select",
310
+ name: "preset",
311
+ message: "Which preset would you like to use?",
312
+ choices: Object.entries(PRESETS).map(([key, preset]) => ({
313
+ title: preset.name,
314
+ value: key,
315
+ disabled: !preset.frameworks.includes(options.framework)
316
+ })),
317
+ initial: 0
318
+ });
319
+ if (!preset) {
320
+ logger.error("Preset selection is required.");
321
+ process.exit(1);
322
+ }
323
+ options.preset = preset;
324
+ }
325
+ if (!options.metaframework) {
326
+ const { metaframework } = await prompts({
327
+ type: "select",
328
+ name: "metaframework",
329
+ message: "Which metaframework would you like to use (optional)?",
330
+ choices: [{
331
+ title: "None",
332
+ value: "none"
333
+ }, ...Object.entries(METAFRAMEWORKS).filter(([_, meta]) => meta.frameworks.includes(options.framework)).map(([key, meta]) => ({
334
+ title: meta.title,
335
+ value: key
336
+ }))],
337
+ initial: 0
338
+ });
339
+ options.metaframework = metaframework === "none" ? void 0 : metaframework;
340
+ }
355
341
  const cwd = options.cwd;
356
- if (fsExtra.existsSync(path.resolve(cwd, "components.json")) && !options.force) {
342
+ if (fsExtra.existsSync(path.resolve(cwd, "components.json")) && !options.override) {
357
343
  const { overwrite } = await prompts({
358
344
  type: "confirm",
359
345
  name: "overwrite",
@@ -365,7 +351,7 @@ const init = new Command().name("init").alias("create").description("initialize
365
351
  logger.break();
366
352
  process.exit(1);
367
353
  }
368
- options.force = true;
354
+ options.override = true;
369
355
  }
370
356
  if (reinstallComponents.length) components = [...components, ...reinstallComponents];
371
357
  options.components = components;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprawlify",
3
- "version": "0.0.90",
3
+ "version": "0.0.91",
4
4
  "type": "module",
5
5
  "description": "A command-line interface for Sprawlify.",
6
6
  "author": "sprawlify <npm@sprawlify.com>",