diff --git a/libs/create-qwikdev-astro/package.json b/libs/create-qwikdev-astro/package.json index 0a9414d..d5576d1 100644 --- a/libs/create-qwikdev-astro/package.json +++ b/libs/create-qwikdev-astro/package.json @@ -7,8 +7,6 @@ "scripts": { "check": "tsc --noEmit", "build": "pnpm check && tsup-node --env.NODE_ENV production", - "prepublishOnly": "node --loader tsm src/prepare.ts", - "postpublish": "node --loader tsm src/prepare.ts --restore", "start": "tsup-node --env.NODE_ENV development --watch", "test": "NODE_ENV=test node --loader tsm --enable-source-maps bin/test.ts" }, diff --git a/libs/create-qwikdev-astro/src/app.ts b/libs/create-qwikdev-astro/src/app.ts index fbe50f0..dcf3f86 100644 --- a/libs/create-qwikdev-astro/src/app.ts +++ b/libs/create-qwikdev-astro/src/app.ts @@ -337,6 +337,7 @@ export class Application extends Program { this.step(`Creating new project in ${this.bgBlue(` ${outDir} `)} ... 🐇`); this.copyTemplate(input, templatePath); + this.copyGitignore(input); } async start(input: Input): Promise { @@ -471,6 +472,16 @@ export class Application extends Program { } } + copyGitignore(input: Input) { + this.step("Copying `.gitignore` file..."); + + if (!input.dryRun) { + const gitignore = path.join(__dirname, "..", "stubs", "gitignore"); + const dotGitignore = path.join(input.outDir, ".gitignore"); + cpSync(gitignore, dotGitignore, { force: true }); + } + } + copyTemplate(input: Input, templatePath: string): void { if (!input.dryRun) { const outDir = input.outDir; diff --git a/libs/create-qwikdev-astro/src/prepare.ts b/libs/create-qwikdev-astro/src/prepare.ts deleted file mode 100644 index befdbea..0000000 --- a/libs/create-qwikdev-astro/src/prepare.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { existsSync, readdirSync, renameSync } from "node:fs"; -import { dirname, join } from "node:path"; -import { logError, logInfo, logSuccess } from "./console"; -import { __dirname } from "./utils"; - -function renameGitignore(dir: string, restore = false) { - const files = readdirSync(dir, { withFileTypes: true }); - - for (const file of files) { - const filePath = join(dir, file.name); - - if (file.isDirectory()) { - renameGitignore(filePath, restore); - } else if (file.name === (restore ? ".gitignore" : "gitignore")) { - const newName = join(dir, restore ? "gitignore" : ".gitignore"); - renameSync(filePath, newName); - logSuccess(`Renamed "${filePath}" to "${newName}"`); - } - } -} - -const templates = join(dirname(__dirname), "stubs", "templates"); -const restore = process.argv.includes("--restore"); - -if (restore) { - logInfo("Restoring files to their original names..."); -} else { - logInfo("Backing up files to gitignore..."); -} - -if (existsSync(templates)) { - renameGitignore(templates, restore); -} else { - logError(`The "${templates}" directory doesn't exist.`); -} diff --git a/libs/create-qwikdev-astro/stubs/templates/deno-biome/gitignore b/libs/create-qwikdev-astro/stubs/gitignore similarity index 100% rename from libs/create-qwikdev-astro/stubs/templates/deno-biome/gitignore rename to libs/create-qwikdev-astro/stubs/gitignore diff --git a/libs/create-qwikdev-astro/stubs/templates/deno/gitignore b/libs/create-qwikdev-astro/stubs/templates/deno/gitignore deleted file mode 100644 index 6d4c0aa..0000000 --- a/libs/create-qwikdev-astro/stubs/templates/deno/gitignore +++ /dev/null @@ -1,21 +0,0 @@ -# build output -dist/ - -# generated types -.astro/ - -# dependencies -node_modules/ - -# logs -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# environment variables -.env -.env.production - -# macOS-specific files -.DS_Store diff --git a/libs/create-qwikdev-astro/stubs/templates/node-biome/gitignore b/libs/create-qwikdev-astro/stubs/templates/node-biome/gitignore deleted file mode 100644 index 6d4c0aa..0000000 --- a/libs/create-qwikdev-astro/stubs/templates/node-biome/gitignore +++ /dev/null @@ -1,21 +0,0 @@ -# build output -dist/ - -# generated types -.astro/ - -# dependencies -node_modules/ - -# logs -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# environment variables -.env -.env.production - -# macOS-specific files -.DS_Store diff --git a/libs/create-qwikdev-astro/stubs/templates/node/gitignore b/libs/create-qwikdev-astro/stubs/templates/node/gitignore deleted file mode 100644 index 6d4c0aa..0000000 --- a/libs/create-qwikdev-astro/stubs/templates/node/gitignore +++ /dev/null @@ -1,21 +0,0 @@ -# build output -dist/ - -# generated types -.astro/ - -# dependencies -node_modules/ - -# logs -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# environment variables -.env -.env.production - -# macOS-specific files -.DS_Store diff --git a/libs/create-qwikdev-astro/stubs/templates/none-biome/gitignore b/libs/create-qwikdev-astro/stubs/templates/none-biome/gitignore deleted file mode 100644 index 6d4c0aa..0000000 --- a/libs/create-qwikdev-astro/stubs/templates/none-biome/gitignore +++ /dev/null @@ -1,21 +0,0 @@ -# build output -dist/ - -# generated types -.astro/ - -# dependencies -node_modules/ - -# logs -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# environment variables -.env -.env.production - -# macOS-specific files -.DS_Store diff --git a/libs/create-qwikdev-astro/stubs/templates/none/gitignore b/libs/create-qwikdev-astro/stubs/templates/none/gitignore deleted file mode 100644 index 6d4c0aa..0000000 --- a/libs/create-qwikdev-astro/stubs/templates/none/gitignore +++ /dev/null @@ -1,21 +0,0 @@ -# build output -dist/ - -# generated types -.astro/ - -# dependencies -node_modules/ - -# logs -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# environment variables -.env -.env.production - -# macOS-specific files -.DS_Store