From 7ef538c2b062f40342db42aa7e1977527cb9226f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Fri, 26 Apr 2024 18:03:12 +0100 Subject: [PATCH 01/19] :sparkles: Add the create binary --- libs/create-qwikdev-astro/biome.json | 4 ++++ libs/create-qwikdev-astro/package.json | 4 +--- libs/create-qwikdev-astro/src/create.ts | 3 +++ libs/create-qwikdev-astro/src/index.ts | 20 +++++++++++++------- 4 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 libs/create-qwikdev-astro/src/create.ts diff --git a/libs/create-qwikdev-astro/biome.json b/libs/create-qwikdev-astro/biome.json index a6f6db6c..973a1116 100644 --- a/libs/create-qwikdev-astro/biome.json +++ b/libs/create-qwikdev-astro/biome.json @@ -3,10 +3,14 @@ "ignore": ["dist", "stubs"] }, "linter": { + "include": ["src"], "ignore": ["dist", "stubs"], "rules": { "style": { "noParameterAssign": "off" + }, + "suspicious": { + "noExplicitAny": "off" } } }, diff --git a/libs/create-qwikdev-astro/package.json b/libs/create-qwikdev-astro/package.json index f440c908..347610b6 100644 --- a/libs/create-qwikdev-astro/package.json +++ b/libs/create-qwikdev-astro/package.json @@ -36,9 +36,7 @@ "./package.json": "./package.json" }, "files": ["dist", "stubs"], - "bin": { - "create-qwikdev-astro": "./dist/index.js" - }, + "bin": "./dist/create.js", "keywords": [ "astro-integration", "astro-component", diff --git a/libs/create-qwikdev-astro/src/create.ts b/libs/create-qwikdev-astro/src/create.ts new file mode 100644 index 00000000..a7f375d4 --- /dev/null +++ b/libs/create-qwikdev-astro/src/create.ts @@ -0,0 +1,3 @@ +#!/usr/bin/env node + +import("./index.js").then((createQwikDevAstro) => createQwikDevAstro.default()); diff --git a/libs/create-qwikdev-astro/src/index.ts b/libs/create-qwikdev-astro/src/index.ts index 573c34bf..6e636ea8 100644 --- a/libs/create-qwikdev-astro/src/index.ts +++ b/libs/create-qwikdev-astro/src/index.ts @@ -1,5 +1,3 @@ -#!/usr/bin/env node - import { type ChildProcess, exec, spawn } from "node:child_process"; import { cpSync, existsSync, mkdirSync } from "node:fs"; import fs from "node:fs"; @@ -92,7 +90,7 @@ export const isPackageManagerInstalled = (packageManager: string) => { }; // Used from https://github.com/sindresorhus/is-unicode-supported/blob/main/index.js -export default function isUnicodeSupported() { +export function isUnicodeSupported() { if (process.platform !== "win32") { return process.env.TERM !== "linux"; // Linux console (kernel) } @@ -157,6 +155,12 @@ export const note = (message = "", title = "") => { ); }; +// Used from https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/cli/utils/utils.ts +export function panic(msg: string) { + console.error(`\nāŒ ${red(msg)}\n`); + process.exit(1); +} + export const $pm = async ( args: string | string[], cwd = process.cwd(), @@ -352,8 +356,10 @@ const createProject = async () => { } }; -async function main() { - await createProject(); +export default async function () { + try { + await createProject(); + } catch (err: any) { + panic(err.message || err); + } } - -main().catch(console.error); From eaa7a0913e14d39d7aeb2de199b9053174cf233c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Sat, 27 Apr 2024 14:12:24 +0100 Subject: [PATCH 02/19] :children_crossing: Allow passing arguments to skip creation steps --- libs/create-qwikdev-astro/src/index.ts | 220 +++++++++++++++++-------- 1 file changed, 152 insertions(+), 68 deletions(-) diff --git a/libs/create-qwikdev-astro/src/index.ts b/libs/create-qwikdev-astro/src/index.ts index 6e636ea8..59241f64 100644 --- a/libs/create-qwikdev-astro/src/index.ts +++ b/libs/create-qwikdev-astro/src/index.ts @@ -16,6 +16,7 @@ import { text } from "@clack/prompts"; import { + bgBlue, bgMagenta, bold, cyan, @@ -27,6 +28,7 @@ import { white } from "kleur/colors"; import detectPackageManager from "which-pm-runs"; +import yargs from "yargs"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); @@ -161,6 +163,10 @@ export function panic(msg: string) { process.exit(1); } +export function panicCanceled() { + panic("Operation canceled."); +} + export const $pm = async ( args: string | string[], cwd = process.cwd(), @@ -190,80 +196,153 @@ export const installDependencies = async (cwd: string) => { await $pm("install", cwd); }; -const createProject = async () => { - try { - intro("QwikDev/astro project creation"); +export type Args = { + outDir: string; + adapter?: "deno" | "node"; + install: boolean; + force: boolean; + biome: boolean; + git: boolean; + ci: boolean; +}; - const packageManager = getPackageManager(); +export function parseArgs(args: string[]): Args { + const parsedArgs = yargs(args) + .strict() + .command( + "* [adapter]", + "Create a new project powered by QwikDev/astro", + (yargs) => { + return yargs + .positional("adapter", { + type: "string", + desc: "Server adapter", + choices: ["deno", "node"] + }) + .positional("outDir", { + type: "string", + desc: "Directory of the project" + }) + .option("force", { + alias: "f", + type: "boolean", + default: false, + desc: "Overwrite target directory if it exists" + }) + .option("install", { + alias: "i", + default: false, + type: "boolean", + desc: "Install dependencies" + }) + .option("biome", { + default: false, + type: "boolean", + desc: "Prefer Biome to ESLint/Prettier" + }) + .option("git", { + default: false, + type: "boolean", + desc: "Initialize Git repository" + }) + .option("ci", { + default: false, + type: "boolean", + desc: "Add CI workflow" + }) + .usage("npm create @qwikdev/astro@latest node ./my-project "); + } + ).argv as unknown as Args; + + return parsedArgs; +} +const createProject = async (args: string[]) => { + try { const defaultProjectName = "./qwik-astro-app"; - const projectNameAnswer = await text({ - message: `Where would you like to create your new project? ${gray( - `(Use '.' or './' for current directory)` - )}`, - placeholder: defaultProjectName, - validate(value) { - if (value.length === 0) { - return "Value is required!"; - } - } - }); - if (typeof projectNameAnswer === "symbol") { - cancel("Operation canceled."); - return process.exit(0); - } + const argv = parseArgs(args.length ? args : [defaultProjectName]); + + intro(`Let's create a ${bgBlue(" QwikDev/astro App ")} āœØ`); - if (isCancel([projectNameAnswer, packageManager])) { - cancel("Operation canceled."); - process.exit(0); + const packageManager = getPackageManager(); + + const projectNameAnswer = + argv.outDir !== defaultProjectName + ? argv.outDir + : (await text({ + message: `Where would you like to create your new project? ${gray( + `(Use '.' or './' for current directory)` + )}`, + placeholder: defaultProjectName + })) || defaultProjectName; + + if ( + typeof projectNameAnswer === "symbol" || + isCancel([projectNameAnswer, packageManager]) + ) { + panicCanceled(); } - const adapter = await select({ - message: "Which adapter do you prefer?", - options: [ - { - value: "node", - label: "Node" - }, - { - value: "deno", - label: "Deno" - } - ] - }); + const adapter = + argv.adapter || + (await select({ + message: "Which adapter do you prefer?", + options: [ + { + value: "node", + label: "Node" + }, + { + value: "deno", + label: "Deno" + } + ] + })); - const favoriteLinterFormatter = await select({ - message: "What is your favorite linter/formatter?", - options: [ - { - value: "0", - label: "ESLint/Prettier" - }, - { - value: "1", - label: "Biome" - } - ] - }); + if (typeof adapter === "symbol" || isCancel(adapter)) { + panicCanceled(); + } - log.step("Creating project directories and copying files..."); + const preferBiome = argv.biome + ? "1" + : await select({ + message: "What is your favorite linter/formatter?", + options: [ + { + value: "0", + label: "ESLint/Prettier" + }, + { + value: "1", + label: "Biome" + } + ] + }); + + if (typeof preferBiome === "symbol" || isCancel(preferBiome)) { + panicCanceled(); + } - const kit = `${adapter}-${ - favoriteLinterFormatter === "0" ? "eslint+prettier" : "biome" + const kit = `${adapter as string}-${ + preferBiome === "0" ? "eslint+prettier" : "biome" }`; const templatePath = path.join(__dirname, "..", "stubs", "templates", kit); - const outDir: string = resolveAbsoluteDir(projectNameAnswer.trim()); + const outDir: string = resolveAbsoluteDir((projectNameAnswer as string).trim()); + + log.step(`Creating new project in ${bgBlue(` ${outDir} `)} ... šŸ‡`); if (!existsSync(outDir)) { mkdirSync(outDir, { recursive: true }); } cpSync(templatePath, outDir, { recursive: true }); - const addCIWorkflow = await confirm({ - message: "Would you like to add CI workflow?", - initialValue: true - }); + const addCIWorkflow = + argv.ci || + (await confirm({ + message: "Would you like to add CI workflow?", + initialValue: true + })); if (addCIWorkflow) { const starterCIPath = join( @@ -278,24 +357,28 @@ const createProject = async () => { cpSync(starterCIPath, projectCIPath, { force: true }); } - const runInstall = await confirm({ - message: `Would you like to install ${packageManager} dependencies?`, - initialValue: true - }); + const runInstall = + argv.install || + (await confirm({ + message: `Would you like to install ${packageManager} dependencies?`, + initialValue: true + })); let ranInstall = false; if (typeof runInstall !== "symbol" && runInstall) { log.step("Installing dependencies..."); - await installDependencies(projectNameAnswer); + await installDependencies(projectNameAnswer as string); ranInstall = true; } - const gitInitAnswer = await confirm({ - message: "Initialize a new git repository?", - initialValue: true - }); + const initGit = + argv.git || + (await confirm({ + message: "Initialize a new git repository?", + initialValue: true + })); - if (gitInitAnswer) { + if (initGit) { const s = spinner(); if (fs.existsSync(join(outDir, ".git"))) { @@ -313,7 +396,7 @@ const createProject = async () => { throw ""; } - s.stop("Git initialized āœØ"); + s.stop("Git initialized šŸŽ²"); } catch (e) { s.stop("Git failed to initialize"); log.error( @@ -358,7 +441,8 @@ const createProject = async () => { export default async function () { try { - await createProject(); + const args = process.argv.slice(2); + await createProject(args); } catch (err: any) { panic(err.message || err); } From 93f473562e106f841feb9680f6d443d559047d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Sat, 27 Apr 2024 14:20:54 +0100 Subject: [PATCH 03/19] :pencil2: Fix process for Deno support --- libs/create-qwikdev-astro/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/create-qwikdev-astro/src/index.ts b/libs/create-qwikdev-astro/src/index.ts index 59241f64..2ac2af1d 100644 --- a/libs/create-qwikdev-astro/src/index.ts +++ b/libs/create-qwikdev-astro/src/index.ts @@ -3,6 +3,7 @@ import { cpSync, existsSync, mkdirSync } from "node:fs"; import fs from "node:fs"; import os from "node:os"; import path, { join, resolve, relative } from "node:path"; +import process from "node:process"; import { fileURLToPath } from "node:url"; import { cancel, From b917c098eabc0b6afcfc94c81f21637a609b5a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Sat, 27 Apr 2024 15:39:36 +0100 Subject: [PATCH 04/19] :children_crossing: Allow the user to overwrite or not an existing directory --- libs/create-qwikdev-astro/src/index.ts | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/libs/create-qwikdev-astro/src/index.ts b/libs/create-qwikdev-astro/src/index.ts index 2ac2af1d..b92227d3 100644 --- a/libs/create-qwikdev-astro/src/index.ts +++ b/libs/create-qwikdev-astro/src/index.ts @@ -164,6 +164,15 @@ export function panic(msg: string) { process.exit(1); } +// Used from https://github.com/QwikDev/qwik/blob/main/packages/create-qwik/src/helpers/clearDir.ts +export const clearDir = async (dir: string) => { + const files = await fs.promises.readdir(dir); + + return await Promise.all( + files.map((pathToFile) => fs.promises.rm(join(dir, pathToFile), { recursive: true })) + ); +}; + export function panicCanceled() { panic("Operation canceled."); } @@ -333,6 +342,27 @@ const createProject = async (args: string[]) => { log.step(`Creating new project in ${bgBlue(` ${outDir} `)} ... šŸ‡`); + if (fs.existsSync(outDir) && fs.readdirSync(outDir).length > 0) { + const force = + argv.force || + (await confirm({ + message: `Directory "./${resolveRelativeDir( + outDir + )}" already exists and is not empty. What would you like to overwrite it?`, + initialValue: true + })); + if (force) { + await clearDir(outDir); + } else { + log.error(`Directory "${outDir}" already exists.`); + log.info( + `Please either remove this directory, choose another location or run the command again with '--force | -f' flag.` + ); + cancel(); + process.exit(1); + } + } + if (!existsSync(outDir)) { mkdirSync(outDir, { recursive: true }); } From a06a326a61e4347e77c724e8f59c71c59851b8c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Sat, 27 Apr 2024 16:24:56 +0100 Subject: [PATCH 05/19] :children_crossing: Allow user to skip all steps using default options or not --- libs/create-qwikdev-astro/src/index.ts | 111 +++++++++++++++---------- 1 file changed, 68 insertions(+), 43 deletions(-) diff --git a/libs/create-qwikdev-astro/src/index.ts b/libs/create-qwikdev-astro/src/index.ts index b92227d3..c695bc39 100644 --- a/libs/create-qwikdev-astro/src/index.ts +++ b/libs/create-qwikdev-astro/src/index.ts @@ -214,6 +214,8 @@ export type Args = { biome: boolean; git: boolean; ci: boolean; + yes: boolean; + no: boolean; }; export function parseArgs(args: string[]): Args { @@ -260,6 +262,18 @@ export function parseArgs(args: string[]): Args { type: "boolean", desc: "Add CI workflow" }) + .option("yes", { + alias: "y", + default: false, + type: "boolean", + desc: "Skip all prompts by accepting defaults" + }) + .option("no", { + alias: "n", + default: false, + type: "boolean", + desc: "Skip all prompts by declining defaults" + }) .usage("npm create @qwikdev/astro@latest node ./my-project "); } ).argv as unknown as Args; @@ -278,7 +292,7 @@ const createProject = async (args: string[]) => { const packageManager = getPackageManager(); const projectNameAnswer = - argv.outDir !== defaultProjectName + argv.outDir !== defaultProjectName || argv.yes ? argv.outDir : (await text({ message: `Where would you like to create your new project? ${gray( @@ -295,7 +309,7 @@ const createProject = async (args: string[]) => { } const adapter = - argv.adapter || + (argv.yes ? "node" : argv.no ? "deno" : argv.adapter) || (await select({ message: "Which adapter do you prefer?", options: [ @@ -314,21 +328,24 @@ const createProject = async (args: string[]) => { panicCanceled(); } - const preferBiome = argv.biome - ? "1" - : await select({ - message: "What is your favorite linter/formatter?", - options: [ - { - value: "0", - label: "ESLint/Prettier" - }, - { - value: "1", - label: "Biome" - } - ] - }); + const preferBiome = + argv.biome || argv.no + ? "1" + : argv.yes + ? "0" + : await select({ + message: "What is your favorite linter/formatter?", + options: [ + { + value: "0", + label: "ESLint/Prettier" + }, + { + value: "1", + label: "Biome" + } + ] + }); if (typeof preferBiome === "symbol" || isCancel(preferBiome)) { panicCanceled(); @@ -343,14 +360,16 @@ const createProject = async (args: string[]) => { log.step(`Creating new project in ${bgBlue(` ${outDir} `)} ... šŸ‡`); if (fs.existsSync(outDir) && fs.readdirSync(outDir).length > 0) { - const force = - argv.force || - (await confirm({ - message: `Directory "./${resolveRelativeDir( - outDir - )}" already exists and is not empty. What would you like to overwrite it?`, - initialValue: true - })); + const force = argv.no + ? false + : argv.force || + argv.yes || + (await confirm({ + message: `Directory "./${resolveRelativeDir( + outDir + )}" already exists and is not empty. What would you like to overwrite it?`, + initialValue: true + })); if (force) { await clearDir(outDir); } else { @@ -368,12 +387,14 @@ const createProject = async (args: string[]) => { } cpSync(templatePath, outDir, { recursive: true }); - const addCIWorkflow = - argv.ci || - (await confirm({ - message: "Would you like to add CI workflow?", - initialValue: true - })); + const addCIWorkflow = argv.no + ? false + : argv.ci || + argv.yes || + (await confirm({ + message: "Would you like to add CI workflow?", + initialValue: true + })); if (addCIWorkflow) { const starterCIPath = join( @@ -388,12 +409,14 @@ const createProject = async (args: string[]) => { cpSync(starterCIPath, projectCIPath, { force: true }); } - const runInstall = - argv.install || - (await confirm({ - message: `Would you like to install ${packageManager} dependencies?`, - initialValue: true - })); + const runInstall = argv.no + ? false + : argv.install || + argv.yes || + (await confirm({ + message: `Would you like to install ${packageManager} dependencies?`, + initialValue: true + })); let ranInstall = false; if (typeof runInstall !== "symbol" && runInstall) { @@ -402,12 +425,14 @@ const createProject = async (args: string[]) => { ranInstall = true; } - const initGit = - argv.git || - (await confirm({ - message: "Initialize a new git repository?", - initialValue: true - })); + const initGit = argv.no + ? false + : argv.git || + argv.yes || + (await confirm({ + message: "Initialize a new git repository?", + initialValue: true + })); if (initGit) { const s = spinner(); From bb804210c7608aee942d02eb73ff1a19eacd4c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Sat, 27 Apr 2024 16:58:02 +0100 Subject: [PATCH 06/19] :children_crossing: Let the user decide to execute actions in interactive mode --- libs/create-qwikdev-astro/src/index.ts | 54 ++++++++++++++++---------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/libs/create-qwikdev-astro/src/index.ts b/libs/create-qwikdev-astro/src/index.ts index c695bc39..b9cb29cc 100644 --- a/libs/create-qwikdev-astro/src/index.ts +++ b/libs/create-qwikdev-astro/src/index.ts @@ -216,6 +216,7 @@ export type Args = { ci: boolean; yes: boolean; no: boolean; + it: boolean; }; export function parseArgs(args: string[]): Args { @@ -274,6 +275,11 @@ export function parseArgs(args: string[]): Args { type: "boolean", desc: "Skip all prompts by declining defaults" }) + .option("it", { + default: false, + type: "boolean", + desc: "Execute actions interactively" + }) .usage("npm create @qwikdev/astro@latest node ./my-project "); } ).argv as unknown as Args; @@ -287,12 +293,14 @@ const createProject = async (args: string[]) => { const argv = parseArgs(args.length ? args : [defaultProjectName]); + const it = argv.it || args.length === 0; + intro(`Let's create a ${bgBlue(" QwikDev/astro App ")} āœØ`); const packageManager = getPackageManager(); const projectNameAnswer = - argv.outDir !== defaultProjectName || argv.yes + argv.outDir !== defaultProjectName || argv.yes || !it ? argv.outDir : (await text({ message: `Where would you like to create your new project? ${gray( @@ -309,7 +317,7 @@ const createProject = async (args: string[]) => { } const adapter = - (argv.yes ? "node" : argv.no ? "deno" : argv.adapter) || + (argv.no ? "deno" : argv.yes || !it ? "node" : argv.adapter) || (await select({ message: "Which adapter do you prefer?", options: [ @@ -331,7 +339,7 @@ const createProject = async (args: string[]) => { const preferBiome = argv.biome || argv.no ? "1" - : argv.yes + : argv.yes || !it ? "0" : await select({ message: "What is your favorite linter/formatter?", @@ -364,12 +372,13 @@ const createProject = async (args: string[]) => { ? false : argv.force || argv.yes || - (await confirm({ - message: `Directory "./${resolveRelativeDir( - outDir - )}" already exists and is not empty. What would you like to overwrite it?`, - initialValue: true - })); + (it && + (await confirm({ + message: `Directory "./${resolveRelativeDir( + outDir + )}" already exists and is not empty. What would you like to overwrite it?`, + initialValue: true + }))); if (force) { await clearDir(outDir); } else { @@ -391,10 +400,11 @@ const createProject = async (args: string[]) => { ? false : argv.ci || argv.yes || - (await confirm({ - message: "Would you like to add CI workflow?", - initialValue: true - })); + (it && + (await confirm({ + message: "Would you like to add CI workflow?", + initialValue: true + }))); if (addCIWorkflow) { const starterCIPath = join( @@ -413,10 +423,11 @@ const createProject = async (args: string[]) => { ? false : argv.install || argv.yes || - (await confirm({ - message: `Would you like to install ${packageManager} dependencies?`, - initialValue: true - })); + (it && + (await confirm({ + message: `Would you like to install ${packageManager} dependencies?`, + initialValue: true + }))); let ranInstall = false; if (typeof runInstall !== "symbol" && runInstall) { @@ -429,10 +440,11 @@ const createProject = async (args: string[]) => { ? false : argv.git || argv.yes || - (await confirm({ - message: "Initialize a new git repository?", - initialValue: true - })); + (it && + (await confirm({ + message: "Initialize a new git repository?", + initialValue: true + }))); if (initGit) { const s = spinner(); From 2fc318db1f42ab4c89d3fc9dc0fb2b7e147eeaae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Sat, 27 Apr 2024 17:17:59 +0100 Subject: [PATCH 07/19] :children_crossing: Allow user to walk through steps without executing --- libs/create-qwikdev-astro/src/index.ts | 44 ++++++++++++++++++-------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/libs/create-qwikdev-astro/src/index.ts b/libs/create-qwikdev-astro/src/index.ts index b9cb29cc..db0270bf 100644 --- a/libs/create-qwikdev-astro/src/index.ts +++ b/libs/create-qwikdev-astro/src/index.ts @@ -217,6 +217,7 @@ export type Args = { yes: boolean; no: boolean; it: boolean; + dryRun: boolean; }; export function parseArgs(args: string[]): Args { @@ -280,6 +281,11 @@ export function parseArgs(args: string[]): Args { type: "boolean", desc: "Execute actions interactively" }) + .option("dryRun", { + default: false, + type: "boolean", + desc: "Walk through steps without executing" + }) .usage("npm create @qwikdev/astro@latest node ./my-project "); } ).argv as unknown as Args; @@ -295,6 +301,8 @@ const createProject = async (args: string[]) => { const it = argv.it || args.length === 0; + const dryRun = argv.dryRun; + intro(`Let's create a ${bgBlue(" QwikDev/astro App ")} āœØ`); const packageManager = getPackageManager(); @@ -380,7 +388,9 @@ const createProject = async (args: string[]) => { initialValue: true }))); if (force) { - await clearDir(outDir); + if (!dryRun) { + await clearDir(outDir); + } } else { log.error(`Directory "${outDir}" already exists.`); log.info( @@ -391,10 +401,12 @@ const createProject = async (args: string[]) => { } } - if (!existsSync(outDir)) { - mkdirSync(outDir, { recursive: true }); + if (!dryRun) { + if (!existsSync(outDir)) { + mkdirSync(outDir, { recursive: true }); + } + cpSync(templatePath, outDir, { recursive: true }); } - cpSync(templatePath, outDir, { recursive: true }); const addCIWorkflow = argv.no ? false @@ -406,7 +418,7 @@ const createProject = async (args: string[]) => { initialValue: true }))); - if (addCIWorkflow) { + if (addCIWorkflow && !dryRun) { const starterCIPath = join( __dirname, "..", @@ -432,7 +444,9 @@ const createProject = async (args: string[]) => { let ranInstall = false; if (typeof runInstall !== "symbol" && runInstall) { log.step("Installing dependencies..."); - await installDependencies(projectNameAnswer as string); + if (!dryRun) { + await installDependencies(projectNameAnswer as string); + } ranInstall = true; } @@ -455,13 +469,17 @@ const createProject = async (args: string[]) => { s.start("Git initializing..."); try { - const res = []; - res.push(await $("git", ["init"], outDir).install); - res.push(await $("git", ["add", "-A"], outDir).install); - res.push(await $("git", ["commit", "-m", "Initial commit šŸŽ‰"], outDir).install); - - if (res.some((r) => r === false)) { - throw ""; + if (!dryRun) { + const res = []; + res.push(await $("git", ["init"], outDir).install); + res.push(await $("git", ["add", "-A"], outDir).install); + res.push( + await $("git", ["commit", "-m", "Initial commit šŸŽ‰"], outDir).install + ); + + if (res.some((r) => r === false)) { + throw ""; + } } s.stop("Git initialized šŸŽ²"); From ffdf758d7d7ee262053f5202edb9af37f8d56f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Sun, 28 Apr 2024 14:32:54 +0100 Subject: [PATCH 08/19] :art: Improve the @qwikdev/create-astro API --- libs/create-qwikdev-astro/src/index.ts | 91 +++++++++++++------------- 1 file changed, 45 insertions(+), 46 deletions(-) diff --git a/libs/create-qwikdev-astro/src/index.ts b/libs/create-qwikdev-astro/src/index.ts index db0270bf..a28dea7b 100644 --- a/libs/create-qwikdev-astro/src/index.ts +++ b/libs/create-qwikdev-astro/src/index.ts @@ -206,8 +206,8 @@ export const installDependencies = async (cwd: string) => { await $pm("install", cwd); }; -export type Args = { - outDir: string; +export type ProjectConfig = { + project: string; adapter?: "deno" | "node"; install: boolean; force: boolean; @@ -220,23 +220,23 @@ export type Args = { dryRun: boolean; }; -export function parseArgs(args: string[]): Args { +export function parseArgs(args: string[]): ProjectConfig { const parsedArgs = yargs(args) .strict() .command( - "* [adapter]", + "* [adapter]", "Create a new project powered by QwikDev/astro", (yargs) => { return yargs + .positional("project", { + type: "string", + desc: "Directory of the project" + }) .positional("adapter", { type: "string", desc: "Server adapter", choices: ["deno", "node"] }) - .positional("outDir", { - type: "string", - desc: "Directory of the project" - }) .option("force", { alias: "f", type: "boolean", @@ -288,44 +288,35 @@ export function parseArgs(args: string[]): Args { }) .usage("npm create @qwikdev/astro@latest node ./my-project "); } - ).argv as unknown as Args; + ).argv as unknown as ProjectConfig; return parsedArgs; } -const createProject = async (args: string[]) => { +export async function $createProject(config: ProjectConfig, defaultProject: string) { try { - const defaultProjectName = "./qwik-astro-app"; - - const argv = parseArgs(args.length ? args : [defaultProjectName]); - - const it = argv.it || args.length === 0; - - const dryRun = argv.dryRun; + const { it, dryRun } = config; intro(`Let's create a ${bgBlue(" QwikDev/astro App ")} āœØ`); const packageManager = getPackageManager(); - const projectNameAnswer = - argv.outDir !== defaultProjectName || argv.yes || !it - ? argv.outDir + const projectAnswer = + config.project !== defaultProject || config.yes || !it + ? config.project : (await text({ message: `Where would you like to create your new project? ${gray( `(Use '.' or './' for current directory)` )}`, - placeholder: defaultProjectName - })) || defaultProjectName; + placeholder: defaultProject + })) || defaultProject; - if ( - typeof projectNameAnswer === "symbol" || - isCancel([projectNameAnswer, packageManager]) - ) { + if (typeof projectAnswer === "symbol" || isCancel([projectAnswer, packageManager])) { panicCanceled(); } const adapter = - (argv.no ? "deno" : argv.yes || !it ? "node" : argv.adapter) || + (config.no ? "deno" : config.yes || !it ? "node" : config.adapter) || (await select({ message: "Which adapter do you prefer?", options: [ @@ -345,9 +336,9 @@ const createProject = async (args: string[]) => { } const preferBiome = - argv.biome || argv.no + config.biome || config.no ? "1" - : argv.yes || !it + : config.yes || !it ? "0" : await select({ message: "What is your favorite linter/formatter?", @@ -371,15 +362,15 @@ const createProject = async (args: string[]) => { preferBiome === "0" ? "eslint+prettier" : "biome" }`; const templatePath = path.join(__dirname, "..", "stubs", "templates", kit); - const outDir: string = resolveAbsoluteDir((projectNameAnswer as string).trim()); + const outDir: string = resolveAbsoluteDir((projectAnswer as string).trim()); log.step(`Creating new project in ${bgBlue(` ${outDir} `)} ... šŸ‡`); if (fs.existsSync(outDir) && fs.readdirSync(outDir).length > 0) { - const force = argv.no + const force = config.no ? false - : argv.force || - argv.yes || + : config.force || + config.yes || (it && (await confirm({ message: `Directory "./${resolveRelativeDir( @@ -408,10 +399,10 @@ const createProject = async (args: string[]) => { cpSync(templatePath, outDir, { recursive: true }); } - const addCIWorkflow = argv.no + const addCIWorkflow = config.no ? false - : argv.ci || - argv.yes || + : config.ci || + config.yes || (it && (await confirm({ message: "Would you like to add CI workflow?", @@ -431,10 +422,10 @@ const createProject = async (args: string[]) => { cpSync(starterCIPath, projectCIPath, { force: true }); } - const runInstall = argv.no + const runInstall = config.no ? false - : argv.install || - argv.yes || + : config.install || + config.yes || (it && (await confirm({ message: `Would you like to install ${packageManager} dependencies?`, @@ -445,15 +436,15 @@ const createProject = async (args: string[]) => { if (typeof runInstall !== "symbol" && runInstall) { log.step("Installing dependencies..."); if (!dryRun) { - await installDependencies(projectNameAnswer as string); + await installDependencies(projectAnswer as string); } ranInstall = true; } - const initGit = argv.no + const initGit = config.no ? false - : argv.git || - argv.yes || + : config.git || + config.yes || (it && (await confirm({ message: "Initialize a new git repository?", @@ -523,12 +514,20 @@ const createProject = async (args: string[]) => { console.error("An error occurred during QwikDev/astro project creation:", err); process.exit(1); } -}; +} + +/** @param args Pass here process.argv.slice(2) */ +export async function $create(...args: string[]) { + const defaultProject = "./qwik-astro-app"; + const projectConfig = parseArgs(args.length ? args : [defaultProject]); + projectConfig.it = projectConfig.it || args.length === 0; + + $createProject(projectConfig, defaultProject); +} export default async function () { try { - const args = process.argv.slice(2); - await createProject(args); + await $create(...process.argv.slice(2)); } catch (err: any) { panic(err.message || err); } From bc145300048a9d233dc1196bd9a4b4f939aeeb09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Sun, 28 Apr 2024 15:48:06 +0100 Subject: [PATCH 09/19] :children_crossing: Add help option alias --- libs/create-qwikdev-astro/src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/create-qwikdev-astro/src/index.ts b/libs/create-qwikdev-astro/src/index.ts index a28dea7b..f197035e 100644 --- a/libs/create-qwikdev-astro/src/index.ts +++ b/libs/create-qwikdev-astro/src/index.ts @@ -288,7 +288,8 @@ export function parseArgs(args: string[]): ProjectConfig { }) .usage("npm create @qwikdev/astro@latest node ./my-project "); } - ).argv as unknown as ProjectConfig; + ) + .alias("h", "help").argv as unknown as ProjectConfig; return parsedArgs; } From 47c912b125dd8445d72857ce9c741b81486d9090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Sun, 28 Apr 2024 16:21:26 +0100 Subject: [PATCH 10/19] :bug: Fix skipping default options --- libs/create-qwikdev-astro/src/index.ts | 113 +++++++++++++------------ 1 file changed, 61 insertions(+), 52 deletions(-) diff --git a/libs/create-qwikdev-astro/src/index.ts b/libs/create-qwikdev-astro/src/index.ts index f197035e..fcffce3c 100644 --- a/libs/create-qwikdev-astro/src/index.ts +++ b/libs/create-qwikdev-astro/src/index.ts @@ -317,20 +317,25 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri } const adapter = - (config.no ? "deno" : config.yes || !it ? "node" : config.adapter) || - (await select({ - message: "Which adapter do you prefer?", - options: [ - { - value: "node", - label: "Node" - }, - { - value: "deno", - label: "Deno" - } - ] - })); + (config.no && !config.adapter + ? "deno" + : config.yes && !config.adapter + ? "node" + : config.adapter) || + (it && + (await select({ + message: "Which adapter do you prefer?", + options: [ + { + value: "node", + label: "Node" + }, + { + value: "deno", + label: "Deno" + } + ] + }))); if (typeof adapter === "symbol" || isCancel(adapter)) { panicCanceled(); @@ -368,17 +373,18 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri log.step(`Creating new project in ${bgBlue(` ${outDir} `)} ... šŸ‡`); if (fs.existsSync(outDir) && fs.readdirSync(outDir).length > 0) { - const force = config.no - ? false - : config.force || - config.yes || - (it && - (await confirm({ - message: `Directory "./${resolveRelativeDir( - outDir - )}" already exists and is not empty. What would you like to overwrite it?`, - initialValue: true - }))); + const force = + config.no && !config.force + ? false + : config.force || + config.yes || + (it && + (await confirm({ + message: `Directory "./${resolveRelativeDir( + outDir + )}" already exists and is not empty. What would you like to overwrite it?`, + initialValue: true + }))); if (force) { if (!dryRun) { await clearDir(outDir); @@ -400,15 +406,16 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri cpSync(templatePath, outDir, { recursive: true }); } - const addCIWorkflow = config.no - ? false - : config.ci || - config.yes || - (it && - (await confirm({ - message: "Would you like to add CI workflow?", - initialValue: true - }))); + const addCIWorkflow = + config.no && !config.ci + ? false + : config.ci || + config.yes || + (it && + (await confirm({ + message: "Would you like to add CI workflow?", + initialValue: true + }))); if (addCIWorkflow && !dryRun) { const starterCIPath = join( @@ -423,15 +430,16 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri cpSync(starterCIPath, projectCIPath, { force: true }); } - const runInstall = config.no - ? false - : config.install || - config.yes || - (it && - (await confirm({ - message: `Would you like to install ${packageManager} dependencies?`, - initialValue: true - }))); + const runInstall = + config.no && !config.install + ? false + : config.install || + config.yes || + (it && + (await confirm({ + message: `Would you like to install ${packageManager} dependencies?`, + initialValue: true + }))); let ranInstall = false; if (typeof runInstall !== "symbol" && runInstall) { @@ -442,15 +450,16 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri ranInstall = true; } - const initGit = config.no - ? false - : config.git || - config.yes || - (it && - (await confirm({ - message: "Initialize a new git repository?", - initialValue: true - }))); + const initGit = + config.no && !config.git + ? false + : config.git || + config.yes || + (it && + (await confirm({ + message: "Initialize a new git repository?", + initialValue: true + }))); if (initGit) { const s = spinner(); From a7b8ac6116d3b4535d3a15ec6247101e1ed35ea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Sun, 28 Apr 2024 16:32:00 +0100 Subject: [PATCH 11/19] :art: Use config options instead of extracting into variables --- libs/create-qwikdev-astro/src/index.ts | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/libs/create-qwikdev-astro/src/index.ts b/libs/create-qwikdev-astro/src/index.ts index fcffce3c..5fc37db1 100644 --- a/libs/create-qwikdev-astro/src/index.ts +++ b/libs/create-qwikdev-astro/src/index.ts @@ -296,14 +296,12 @@ export function parseArgs(args: string[]): ProjectConfig { export async function $createProject(config: ProjectConfig, defaultProject: string) { try { - const { it, dryRun } = config; - intro(`Let's create a ${bgBlue(" QwikDev/astro App ")} āœØ`); const packageManager = getPackageManager(); const projectAnswer = - config.project !== defaultProject || config.yes || !it + config.project !== defaultProject || config.yes || !config.it ? config.project : (await text({ message: `Where would you like to create your new project? ${gray( @@ -322,7 +320,7 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri : config.yes && !config.adapter ? "node" : config.adapter) || - (it && + (config.it && (await select({ message: "Which adapter do you prefer?", options: [ @@ -344,7 +342,7 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri const preferBiome = config.biome || config.no ? "1" - : config.yes || !it + : config.yes || !config.it ? "0" : await select({ message: "What is your favorite linter/formatter?", @@ -378,7 +376,7 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri ? false : config.force || config.yes || - (it && + (config.it && (await confirm({ message: `Directory "./${resolveRelativeDir( outDir @@ -386,7 +384,7 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri initialValue: true }))); if (force) { - if (!dryRun) { + if (!config.dryRun) { await clearDir(outDir); } } else { @@ -399,7 +397,7 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri } } - if (!dryRun) { + if (!config.dryRun) { if (!existsSync(outDir)) { mkdirSync(outDir, { recursive: true }); } @@ -411,13 +409,13 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri ? false : config.ci || config.yes || - (it && + (config.it && (await confirm({ message: "Would you like to add CI workflow?", initialValue: true }))); - if (addCIWorkflow && !dryRun) { + if (addCIWorkflow && !config.dryRun) { const starterCIPath = join( __dirname, "..", @@ -435,7 +433,7 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri ? false : config.install || config.yes || - (it && + (config.it && (await confirm({ message: `Would you like to install ${packageManager} dependencies?`, initialValue: true @@ -444,7 +442,7 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri let ranInstall = false; if (typeof runInstall !== "symbol" && runInstall) { log.step("Installing dependencies..."); - if (!dryRun) { + if (!config.dryRun) { await installDependencies(projectAnswer as string); } ranInstall = true; @@ -455,7 +453,7 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri ? false : config.git || config.yes || - (it && + (config.it && (await confirm({ message: "Initialize a new git repository?", initialValue: true @@ -470,7 +468,7 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri s.start("Git initializing..."); try { - if (!dryRun) { + if (!config.dryRun) { const res = []; res.push(await $("git", ["init"], outDir).install); res.push(await $("git", ["add", "-A"], outDir).install); From 7c1c7f59391ad537734009e5fb1e339ce631c72e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Sun, 28 Apr 2024 23:17:28 +0100 Subject: [PATCH 12/19] :children_crossing: Improve default options --- libs/create-qwikdev-astro/src/index.ts | 77 ++++++++++++-------------- 1 file changed, 34 insertions(+), 43 deletions(-) diff --git a/libs/create-qwikdev-astro/src/index.ts b/libs/create-qwikdev-astro/src/index.ts index 5fc37db1..32e2c1ae 100644 --- a/libs/create-qwikdev-astro/src/index.ts +++ b/libs/create-qwikdev-astro/src/index.ts @@ -209,11 +209,11 @@ export const installDependencies = async (cwd: string) => { export type ProjectConfig = { project: string; adapter?: "deno" | "node"; - install: boolean; - force: boolean; - biome: boolean; - git: boolean; - ci: boolean; + force?: boolean; + install?: boolean; + biome?: boolean; + git?: boolean; + ci?: boolean; yes: boolean; no: boolean; it: boolean; @@ -240,27 +240,22 @@ export function parseArgs(args: string[]): ProjectConfig { .option("force", { alias: "f", type: "boolean", - default: false, desc: "Overwrite target directory if it exists" }) .option("install", { alias: "i", - default: false, type: "boolean", desc: "Install dependencies" }) .option("biome", { - default: false, type: "boolean", desc: "Prefer Biome to ESLint/Prettier" }) .option("git", { - default: false, type: "boolean", desc: "Initialize Git repository" }) .option("ci", { - default: false, type: "boolean", desc: "Add CI workflow" }) @@ -301,7 +296,7 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri const packageManager = getPackageManager(); const projectAnswer = - config.project !== defaultProject || config.yes || !config.it + config.project !== defaultProject || !config.it ? config.project : (await text({ message: `Where would you like to create your new project? ${gray( @@ -315,11 +310,7 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri } const adapter = - (config.no && !config.adapter - ? "deno" - : config.yes && !config.adapter - ? "node" - : config.adapter) || + config.adapter || (config.it && (await select({ message: "Which adapter do you prefer?", @@ -333,30 +324,30 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri label: "Deno" } ] - }))); + }))) || + "node"; if (typeof adapter === "symbol" || isCancel(adapter)) { panicCanceled(); } - const preferBiome = - config.biome || config.no - ? "1" - : config.yes || !config.it - ? "0" - : await select({ - message: "What is your favorite linter/formatter?", - options: [ - { - value: "0", - label: "ESLint/Prettier" - }, - { - value: "1", - label: "Biome" - } - ] - }); + const preferBiome = config.biome + ? "1" + : !config.it + ? "0" + : await select({ + message: "What is your favorite linter/formatter?", + options: [ + { + value: "0", + label: "ESLint/Prettier" + }, + { + value: "1", + label: "Biome" + } + ] + }); if (typeof preferBiome === "symbol" || isCancel(preferBiome)) { panicCanceled(); @@ -374,8 +365,8 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri const force = config.no && !config.force ? false - : config.force || - config.yes || + : (config.yes && config.force !== false) || + config.force || (config.it && (await confirm({ message: `Directory "./${resolveRelativeDir( @@ -407,8 +398,8 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri const addCIWorkflow = config.no && !config.ci ? false - : config.ci || - config.yes || + : (config.yes && config.ci !== false) || + config.ci || (config.it && (await confirm({ message: "Would you like to add CI workflow?", @@ -431,8 +422,8 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri const runInstall = config.no && !config.install ? false - : config.install || - config.yes || + : (config.yes && config.install !== false) || + config.install || (config.it && (await confirm({ message: `Would you like to install ${packageManager} dependencies?`, @@ -451,8 +442,8 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri const initGit = config.no && !config.git ? false - : config.git || - config.yes || + : (config.yes && config.git !== false) || + config.git || (config.it && (await confirm({ message: "Initialize a new git repository?", From 31befe2fb165b2be59d822685345718bcfa1379b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Sun, 28 Apr 2024 23:40:20 +0100 Subject: [PATCH 13/19] :children_crossing: Confirm using Biome instead of selecting --- libs/create-qwikdev-astro/src/index.ts | 35 ++++++++------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/libs/create-qwikdev-astro/src/index.ts b/libs/create-qwikdev-astro/src/index.ts index 32e2c1ae..a2e8e7af 100644 --- a/libs/create-qwikdev-astro/src/index.ts +++ b/libs/create-qwikdev-astro/src/index.ts @@ -331,31 +331,18 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri panicCanceled(); } - const preferBiome = config.biome - ? "1" - : !config.it - ? "0" - : await select({ - message: "What is your favorite linter/formatter?", - options: [ - { - value: "0", - label: "ESLint/Prettier" - }, - { - value: "1", - label: "Biome" - } - ] - }); - - if (typeof preferBiome === "symbol" || isCancel(preferBiome)) { - panicCanceled(); - } + const preferBiome = + config.no && !config.biome + ? false + : (config.yes && config.biome !== false) || + config.biome || + (config.it && + (await confirm({ + message: "Would you prefer Biome over ESLint/Prettier?", + initialValue: true + }))); - const kit = `${adapter as string}-${ - preferBiome === "0" ? "eslint+prettier" : "biome" - }`; + const kit = `${adapter as string}-${preferBiome ? "biome" : "eslint+prettier"}`; const templatePath = path.join(__dirname, "..", "stubs", "templates", kit); const outDir: string = resolveAbsoluteDir((projectAnswer as string).trim()); From 1908f18e475f0c19b5cffb026b9357ac3cd1c043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Mon, 29 Apr 2024 00:25:51 +0100 Subject: [PATCH 14/19] :technologist: Remove $ from function names --- libs/create-qwikdev-astro/src/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/create-qwikdev-astro/src/index.ts b/libs/create-qwikdev-astro/src/index.ts index a2e8e7af..5942123d 100644 --- a/libs/create-qwikdev-astro/src/index.ts +++ b/libs/create-qwikdev-astro/src/index.ts @@ -289,7 +289,7 @@ export function parseArgs(args: string[]): ProjectConfig { return parsedArgs; } -export async function $createProject(config: ProjectConfig, defaultProject: string) { +export async function createProject(config: ProjectConfig, defaultProject: string) { try { intro(`Let's create a ${bgBlue(" QwikDev/astro App ")} āœØ`); @@ -503,17 +503,17 @@ export async function $createProject(config: ProjectConfig, defaultProject: stri } /** @param args Pass here process.argv.slice(2) */ -export async function $create(...args: string[]) { +export async function runCreate(...args: string[]) { const defaultProject = "./qwik-astro-app"; const projectConfig = parseArgs(args.length ? args : [defaultProject]); projectConfig.it = projectConfig.it || args.length === 0; - $createProject(projectConfig, defaultProject); + createProject(projectConfig, defaultProject); } export default async function () { try { - await $create(...process.argv.slice(2)); + await runCreate(...process.argv.slice(2)); } catch (err: any) { panic(err.message || err); } From 878462ed5c98f161038cd0c69cf22b0b7096b75f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Mon, 29 Apr 2024 00:29:41 +0100 Subject: [PATCH 15/19] :truck: Rename 'create.ts' file to 'cli.ts' --- libs/create-qwikdev-astro/package.json | 2 +- libs/create-qwikdev-astro/src/{create.ts => cli.ts} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename libs/create-qwikdev-astro/src/{create.ts => cli.ts} (100%) diff --git a/libs/create-qwikdev-astro/package.json b/libs/create-qwikdev-astro/package.json index 347610b6..f6a62bf7 100644 --- a/libs/create-qwikdev-astro/package.json +++ b/libs/create-qwikdev-astro/package.json @@ -36,7 +36,7 @@ "./package.json": "./package.json" }, "files": ["dist", "stubs"], - "bin": "./dist/create.js", + "bin": "./dist/cli.js", "keywords": [ "astro-integration", "astro-component", diff --git a/libs/create-qwikdev-astro/src/create.ts b/libs/create-qwikdev-astro/src/cli.ts similarity index 100% rename from libs/create-qwikdev-astro/src/create.ts rename to libs/create-qwikdev-astro/src/cli.ts From 2972955771cfb2e8c42b98c964dd88c5cfb7c6a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Mon, 29 Apr 2024 00:30:58 +0100 Subject: [PATCH 16/19] :memo: Update the README.md file --- libs/create-qwikdev-astro/README.md | 112 +++++++++++++++++++++++----- 1 file changed, 95 insertions(+), 17 deletions(-) diff --git a/libs/create-qwikdev-astro/README.md b/libs/create-qwikdev-astro/README.md index 97f6c23d..92f3e4d6 100644 --- a/libs/create-qwikdev-astro/README.md +++ b/libs/create-qwikdev-astro/README.md @@ -1,30 +1,108 @@ # Create @qwikdev/astro šŸŽ‰ -Get started with [the @qwikdev/astro integration](https://github.com/QwikDev/astro): +## Scaffolding for [QwikDev/astro](https://github.com/QwikDev/astro) projects -- Using `npm`: +### šŸ› ļø CLI -```bash -npm create @qwikdev/astro@latest -``` + - **With `NPM`**: -- Using `Yarn`: + ```bash + npm create @qwikdev/astro@latest [project] [adapter] [...options] + ``` -```bash -yarn create @qwikdev/astro -``` + - **With `Yarn`**: -- Using `PNPM`: + ```bash + yarn create @qwikdev/astro [project] [adapter] [...options] + ``` -```bash -pnpm create @qwikdev/astro -``` + - **With `PNPM`**: -- Using `Bun`: + ```bash + pnpm create @qwikdev/astro [project] [adapter] [...options] + ``` -```bash -bun create @qwikdev/astro -``` + - **With `Bun`**: + + ```bash + bun create @qwikdev/astro [project] [adapter] [...options] + ``` + + The `create @qwikdev/astro` command runs interactively without any arguments or options. + + However, it is possible to use the interactive mode as described below: + + **Types of arguments:** + + | Name | Type | Default value | Description | + | :-------| :----------------| :----------------| :---------------------------------| + | project | String | ./qwik-astro-app | Directory of the project. | + | adapter | "deno" or "node" | node | Server adapter. | + + **Types of options:** + + | Name | Description | + | :--------------------------------------| :----------------------------------------| + | `--help` (`-h`) | Display available flags. | + | `--it` | Execute actions interactively. | + | `--dry-run` | Walk through steps without executing. | + | `--force` / `--no-force` (`-f` / `--no-f`) | Overwrite target directory if it exists. | + | `--install` / `--no-install` (`-i` / `--no-i`) | Install dependencies. | + | `--biome` / `--no-biome` | Prefer Biome to ESLint/Prettier. | + | `--git` / `--no-git` | Initialize Git repository. | + | `--ci` / `--no-ci` | Add CI workflow. | + | `--yes` (`-y`) | Skip all prompts by accepting defaults. | + | `--no` (`-n`) | Skip all prompts by declining defaults. | + +### šŸ“¦ API + + - Use the arguments provided in the command line: + + ```typescript + import createQwikAstro from '@qwikdev/create-astro'; + + createQwikAstro(); + ``` + + - Specify the command line arguments to use: + + ```typescript + import { runCreate } from '@qwikdev/create-astro'; + + runCreate("./qwik-astro-app", "node", "--it"); + ``` + + - Pass the arguments to create a new project: + + ```typescript + import { createProject } from '@qwikdev/create-astro'; + + const config = { + project: "./qwik-astro-app", + starter: "node", + it: false, + }; + + createProject(config); + ``` + + **Project configuration type:** + + ```typescript + export type ProjectConfig = { + project: string; + adapter?: "deno" | "node"; + force?: boolean; + install?: boolean; + biome?: boolean; + git?: boolean; + ci?: boolean; + yes: boolean; + no: boolean; + it: boolean; + dryRun: boolean; + }; + ``` ## šŸŒ Community From e495decba9fb4899ffe613fa9f4f57e0e26606bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Mon, 29 Apr 2024 00:38:43 +0100 Subject: [PATCH 17/19] :truck: Remove 'eslint+prettier' suffixes from default templates --- libs/create-qwikdev-astro/src/index.ts | 9 +++++++-- .../{deno-eslint+prettier => deno}/.eslintignore | 0 .../{deno-eslint+prettier => deno}/.eslintrc.cjs | 0 .../templates/{deno-eslint+prettier => deno}/.gitignore | 0 .../{deno-eslint+prettier => deno}/.prettierignore | 0 .../.vscode/extensions.json | 0 .../{deno-eslint+prettier => deno}/.vscode/launch.json | 0 .../templates/{deno-eslint+prettier => deno}/README.md | 0 .../{deno-eslint+prettier => deno}/astro.config.ts | 0 .../{deno-eslint+prettier => deno}/package.json | 0 .../{deno-eslint+prettier => deno}/prettier.config.cjs | 0 .../{deno-eslint+prettier => deno}/public/favicon.svg | 0 .../{deno-eslint+prettier => deno}/src/assets/astro.svg | 0 .../{deno-eslint+prettier => deno}/src/assets/qwik.svg | 0 .../src/components/counter.module.css | 0 .../src/components/counter.tsx | 0 .../{deno-eslint+prettier => deno}/src/env.d.ts | 0 .../src/layouts/Layout.astro | 0 .../{deno-eslint+prettier => deno}/src/pages/index.astro | 0 .../{deno-eslint+prettier => deno}/src/styles/global.css | 0 .../{deno-eslint+prettier => deno}/tsconfig.json | 0 .../{node-eslint+prettier => node}/.eslintignore | 0 .../{node-eslint+prettier => node}/.eslintrc.cjs | 0 .../templates/{node-eslint+prettier => node}/.gitignore | 0 .../{node-eslint+prettier => node}/.prettierignore | 0 .../.vscode/extensions.json | 0 .../{node-eslint+prettier => node}/.vscode/launch.json | 0 .../templates/{node-eslint+prettier => node}/README.md | 0 .../{node-eslint+prettier => node}/astro.config.ts | 0 .../{node-eslint+prettier => node}/package.json | 0 .../{node-eslint+prettier => node}/prettier.config.cjs | 0 .../{node-eslint+prettier => node}/public/favicon.svg | 0 .../{node-eslint+prettier => node}/src/assets/astro.svg | 0 .../{node-eslint+prettier => node}/src/assets/qwik.svg | 0 .../src/components/counter.module.css | 0 .../src/components/counter.tsx | 0 .../{node-eslint+prettier => node}/src/env.d.ts | 0 .../src/layouts/Layout.astro | 0 .../{node-eslint+prettier => node}/src/pages/index.astro | 0 .../{node-eslint+prettier => node}/src/styles/global.css | 0 .../{node-eslint+prettier => node}/tsconfig.json | 0 41 files changed, 7 insertions(+), 2 deletions(-) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/.eslintignore (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/.eslintrc.cjs (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/.gitignore (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/.prettierignore (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/.vscode/extensions.json (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/.vscode/launch.json (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/README.md (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/astro.config.ts (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/package.json (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/prettier.config.cjs (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/public/favicon.svg (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/src/assets/astro.svg (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/src/assets/qwik.svg (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/src/components/counter.module.css (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/src/components/counter.tsx (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/src/env.d.ts (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/src/layouts/Layout.astro (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/src/pages/index.astro (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/src/styles/global.css (100%) rename libs/create-qwikdev-astro/stubs/templates/{deno-eslint+prettier => deno}/tsconfig.json (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/.eslintignore (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/.eslintrc.cjs (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/.gitignore (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/.prettierignore (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/.vscode/extensions.json (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/.vscode/launch.json (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/README.md (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/astro.config.ts (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/package.json (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/prettier.config.cjs (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/public/favicon.svg (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/src/assets/astro.svg (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/src/assets/qwik.svg (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/src/components/counter.module.css (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/src/components/counter.tsx (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/src/env.d.ts (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/src/layouts/Layout.astro (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/src/pages/index.astro (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/src/styles/global.css (100%) rename libs/create-qwikdev-astro/stubs/templates/{node-eslint+prettier => node}/tsconfig.json (100%) diff --git a/libs/create-qwikdev-astro/src/index.ts b/libs/create-qwikdev-astro/src/index.ts index 5942123d..f3fcfce9 100644 --- a/libs/create-qwikdev-astro/src/index.ts +++ b/libs/create-qwikdev-astro/src/index.ts @@ -331,6 +331,8 @@ export async function createProject(config: ProjectConfig, defaultProject: strin panicCanceled(); } + let starterKit = adapter as string; + const preferBiome = config.no && !config.biome ? false @@ -342,8 +344,11 @@ export async function createProject(config: ProjectConfig, defaultProject: strin initialValue: true }))); - const kit = `${adapter as string}-${preferBiome ? "biome" : "eslint+prettier"}`; - const templatePath = path.join(__dirname, "..", "stubs", "templates", kit); + if (preferBiome) { + starterKit += "-biome"; + } + + const templatePath = path.join(__dirname, "..", "stubs", "templates", starterKit); const outDir: string = resolveAbsoluteDir((projectAnswer as string).trim()); log.step(`Creating new project in ${bgBlue(` ${outDir} `)} ... šŸ‡`); diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/.eslintignore b/libs/create-qwikdev-astro/stubs/templates/deno/.eslintignore similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/.eslintignore rename to libs/create-qwikdev-astro/stubs/templates/deno/.eslintignore diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/.eslintrc.cjs b/libs/create-qwikdev-astro/stubs/templates/deno/.eslintrc.cjs similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/.eslintrc.cjs rename to libs/create-qwikdev-astro/stubs/templates/deno/.eslintrc.cjs diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/.gitignore b/libs/create-qwikdev-astro/stubs/templates/deno/.gitignore similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/.gitignore rename to libs/create-qwikdev-astro/stubs/templates/deno/.gitignore diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/.prettierignore b/libs/create-qwikdev-astro/stubs/templates/deno/.prettierignore similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/.prettierignore rename to libs/create-qwikdev-astro/stubs/templates/deno/.prettierignore diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/.vscode/extensions.json b/libs/create-qwikdev-astro/stubs/templates/deno/.vscode/extensions.json similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/.vscode/extensions.json rename to libs/create-qwikdev-astro/stubs/templates/deno/.vscode/extensions.json diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/.vscode/launch.json b/libs/create-qwikdev-astro/stubs/templates/deno/.vscode/launch.json similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/.vscode/launch.json rename to libs/create-qwikdev-astro/stubs/templates/deno/.vscode/launch.json diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/README.md b/libs/create-qwikdev-astro/stubs/templates/deno/README.md similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/README.md rename to libs/create-qwikdev-astro/stubs/templates/deno/README.md diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/astro.config.ts b/libs/create-qwikdev-astro/stubs/templates/deno/astro.config.ts similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/astro.config.ts rename to libs/create-qwikdev-astro/stubs/templates/deno/astro.config.ts diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/package.json b/libs/create-qwikdev-astro/stubs/templates/deno/package.json similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/package.json rename to libs/create-qwikdev-astro/stubs/templates/deno/package.json diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/prettier.config.cjs b/libs/create-qwikdev-astro/stubs/templates/deno/prettier.config.cjs similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/prettier.config.cjs rename to libs/create-qwikdev-astro/stubs/templates/deno/prettier.config.cjs diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/public/favicon.svg b/libs/create-qwikdev-astro/stubs/templates/deno/public/favicon.svg similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/public/favicon.svg rename to libs/create-qwikdev-astro/stubs/templates/deno/public/favicon.svg diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/src/assets/astro.svg b/libs/create-qwikdev-astro/stubs/templates/deno/src/assets/astro.svg similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/src/assets/astro.svg rename to libs/create-qwikdev-astro/stubs/templates/deno/src/assets/astro.svg diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/src/assets/qwik.svg b/libs/create-qwikdev-astro/stubs/templates/deno/src/assets/qwik.svg similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/src/assets/qwik.svg rename to libs/create-qwikdev-astro/stubs/templates/deno/src/assets/qwik.svg diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/src/components/counter.module.css b/libs/create-qwikdev-astro/stubs/templates/deno/src/components/counter.module.css similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/src/components/counter.module.css rename to libs/create-qwikdev-astro/stubs/templates/deno/src/components/counter.module.css diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/src/components/counter.tsx b/libs/create-qwikdev-astro/stubs/templates/deno/src/components/counter.tsx similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/src/components/counter.tsx rename to libs/create-qwikdev-astro/stubs/templates/deno/src/components/counter.tsx diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/src/env.d.ts b/libs/create-qwikdev-astro/stubs/templates/deno/src/env.d.ts similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/src/env.d.ts rename to libs/create-qwikdev-astro/stubs/templates/deno/src/env.d.ts diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/src/layouts/Layout.astro b/libs/create-qwikdev-astro/stubs/templates/deno/src/layouts/Layout.astro similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/src/layouts/Layout.astro rename to libs/create-qwikdev-astro/stubs/templates/deno/src/layouts/Layout.astro diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/src/pages/index.astro b/libs/create-qwikdev-astro/stubs/templates/deno/src/pages/index.astro similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/src/pages/index.astro rename to libs/create-qwikdev-astro/stubs/templates/deno/src/pages/index.astro diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/src/styles/global.css b/libs/create-qwikdev-astro/stubs/templates/deno/src/styles/global.css similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/src/styles/global.css rename to libs/create-qwikdev-astro/stubs/templates/deno/src/styles/global.css diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/tsconfig.json b/libs/create-qwikdev-astro/stubs/templates/deno/tsconfig.json similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-eslint+prettier/tsconfig.json rename to libs/create-qwikdev-astro/stubs/templates/deno/tsconfig.json diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/.eslintignore b/libs/create-qwikdev-astro/stubs/templates/node/.eslintignore similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/.eslintignore rename to libs/create-qwikdev-astro/stubs/templates/node/.eslintignore diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/.eslintrc.cjs b/libs/create-qwikdev-astro/stubs/templates/node/.eslintrc.cjs similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/.eslintrc.cjs rename to libs/create-qwikdev-astro/stubs/templates/node/.eslintrc.cjs diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/.gitignore b/libs/create-qwikdev-astro/stubs/templates/node/.gitignore similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/.gitignore rename to libs/create-qwikdev-astro/stubs/templates/node/.gitignore diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/.prettierignore b/libs/create-qwikdev-astro/stubs/templates/node/.prettierignore similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/.prettierignore rename to libs/create-qwikdev-astro/stubs/templates/node/.prettierignore diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/.vscode/extensions.json b/libs/create-qwikdev-astro/stubs/templates/node/.vscode/extensions.json similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/.vscode/extensions.json rename to libs/create-qwikdev-astro/stubs/templates/node/.vscode/extensions.json diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/.vscode/launch.json b/libs/create-qwikdev-astro/stubs/templates/node/.vscode/launch.json similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/.vscode/launch.json rename to libs/create-qwikdev-astro/stubs/templates/node/.vscode/launch.json diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/README.md b/libs/create-qwikdev-astro/stubs/templates/node/README.md similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/README.md rename to libs/create-qwikdev-astro/stubs/templates/node/README.md diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/astro.config.ts b/libs/create-qwikdev-astro/stubs/templates/node/astro.config.ts similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/astro.config.ts rename to libs/create-qwikdev-astro/stubs/templates/node/astro.config.ts diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/package.json b/libs/create-qwikdev-astro/stubs/templates/node/package.json similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/package.json rename to libs/create-qwikdev-astro/stubs/templates/node/package.json diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/prettier.config.cjs b/libs/create-qwikdev-astro/stubs/templates/node/prettier.config.cjs similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/prettier.config.cjs rename to libs/create-qwikdev-astro/stubs/templates/node/prettier.config.cjs diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/public/favicon.svg b/libs/create-qwikdev-astro/stubs/templates/node/public/favicon.svg similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/public/favicon.svg rename to libs/create-qwikdev-astro/stubs/templates/node/public/favicon.svg diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/src/assets/astro.svg b/libs/create-qwikdev-astro/stubs/templates/node/src/assets/astro.svg similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/src/assets/astro.svg rename to libs/create-qwikdev-astro/stubs/templates/node/src/assets/astro.svg diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/src/assets/qwik.svg b/libs/create-qwikdev-astro/stubs/templates/node/src/assets/qwik.svg similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/src/assets/qwik.svg rename to libs/create-qwikdev-astro/stubs/templates/node/src/assets/qwik.svg diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/src/components/counter.module.css b/libs/create-qwikdev-astro/stubs/templates/node/src/components/counter.module.css similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/src/components/counter.module.css rename to libs/create-qwikdev-astro/stubs/templates/node/src/components/counter.module.css diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/src/components/counter.tsx b/libs/create-qwikdev-astro/stubs/templates/node/src/components/counter.tsx similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/src/components/counter.tsx rename to libs/create-qwikdev-astro/stubs/templates/node/src/components/counter.tsx diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/src/env.d.ts b/libs/create-qwikdev-astro/stubs/templates/node/src/env.d.ts similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/src/env.d.ts rename to libs/create-qwikdev-astro/stubs/templates/node/src/env.d.ts diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/src/layouts/Layout.astro b/libs/create-qwikdev-astro/stubs/templates/node/src/layouts/Layout.astro similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/src/layouts/Layout.astro rename to libs/create-qwikdev-astro/stubs/templates/node/src/layouts/Layout.astro diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/src/pages/index.astro b/libs/create-qwikdev-astro/stubs/templates/node/src/pages/index.astro similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/src/pages/index.astro rename to libs/create-qwikdev-astro/stubs/templates/node/src/pages/index.astro diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/src/styles/global.css b/libs/create-qwikdev-astro/stubs/templates/node/src/styles/global.css similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/src/styles/global.css rename to libs/create-qwikdev-astro/stubs/templates/node/src/styles/global.css diff --git a/libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/tsconfig.json b/libs/create-qwikdev-astro/stubs/templates/node/tsconfig.json similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/node-eslint+prettier/tsconfig.json rename to libs/create-qwikdev-astro/stubs/templates/node/tsconfig.json From 11f2b0d5e61f9c598432d96bc478a087dbbb4b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Mon, 29 Apr 2024 01:08:12 +0100 Subject: [PATCH 18/19] :children_crossing: Add examples and update usage --- libs/create-qwikdev-astro/src/index.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libs/create-qwikdev-astro/src/index.ts b/libs/create-qwikdev-astro/src/index.ts index f3fcfce9..2b7093f7 100644 --- a/libs/create-qwikdev-astro/src/index.ts +++ b/libs/create-qwikdev-astro/src/index.ts @@ -281,7 +281,19 @@ export function parseArgs(args: string[]): ProjectConfig { type: "boolean", desc: "Walk through steps without executing" }) - .usage("npm create @qwikdev/astro@latest node ./my-project "); + .example( + "npm create @qwikdev/astro@latest", + "Create a project in interactive mode" + ) + .example( + "npm create @qwikdev/astro@latest ./qwik-astro-app node", + "Create a project in commande mode" + ) + .example( + "npm create @qwikdev/astro@latest ./qwik-astro-app node --it", + "Create a project in interactive command mode" + ) + .usage("npm create @qwikdev/astro [project] [adapter] [...options]"); } ) .alias("h", "help").argv as unknown as ProjectConfig; From cbca1d34fe92ee65a188b2ab0c1d32d6370e382a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigui=20Kess=C3=A9=20Emmanuel?= Date: Mon, 29 Apr 2024 01:18:57 +0100 Subject: [PATCH 19/19] =?UTF-8?q?Ready=20for=20release=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/poor-vans-shave.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/poor-vans-shave.md diff --git a/.changeset/poor-vans-shave.md b/.changeset/poor-vans-shave.md new file mode 100644 index 00000000..dd8e4963 --- /dev/null +++ b/.changeset/poor-vans-shave.md @@ -0,0 +1,5 @@ +--- +"@qwikdev/create-astro": patch +--- + +šŸšø Improve user experience