@robineb/project-cli 1.1.1 → 1.1.2

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.js +13 -6
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import path from "node:path";
3
3
  import fs from "node:fs/promises";
4
+ import { pathToFileURL } from "node:url";
4
5
  import { Command } from "commander";
5
6
  import * as p from "@clack/prompts";
6
7
  import { execa } from "execa";
@@ -138,7 +139,7 @@ async function resolveGiteaCredentials() {
138
139
  // beginnen und enden. Leerzeichen wie in "esp 32" fallen damit sofort auf,
139
140
  // statt erst nach Scaffold + erstem Commit bei der Remote-Erstellung.
140
141
  const PROJECT_NAME_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
141
- function validateProjectName(name) {
142
+ export function validateProjectName(name) {
142
143
  if (!name?.trim())
143
144
  return "Name darf nicht leer sein";
144
145
  if (!PROJECT_NAME_PATTERN.test(name)) {
@@ -176,7 +177,7 @@ async function restoreGitignore(targetDir) {
176
177
  const to = path.join(targetDir, ".gitignore");
177
178
  await fs.rename(from, to).catch(() => { });
178
179
  }
179
- async function replacePlaceholders(dir, vars) {
180
+ export async function replacePlaceholders(dir, vars) {
180
181
  const entries = await fs.readdir(dir, {
181
182
  withFileTypes: true,
182
183
  recursive: true,
@@ -403,7 +404,13 @@ program
403
404
  .action(async () => {
404
405
  await addBoard(process.cwd());
405
406
  });
406
- program.parseAsync().catch((err) => {
407
- console.error(err instanceof Error ? err.message : err);
408
- process.exit(1);
409
- });
407
+ // Guard, damit ein Import dieser Datei (z.B. aus Tests) nicht sofort die
408
+ // interaktive CLI anwirft nur wenn die Datei direkt ausgeführt wird.
409
+ // pathToFileURL() statt string-Vergleich mit process.argv[1], weil das auf
410
+ // Windows sonst an Backslashes/URL-Encoding scheitert.
411
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) {
412
+ program.parseAsync().catch((err) => {
413
+ console.error(err instanceof Error ? err.message : err);
414
+ process.exit(1);
415
+ });
416
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robineb/project-cli",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "My own Project cli tool to start projecs",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -13,7 +13,7 @@
13
13
  "main": "./dist/index.js",
14
14
  "scripts": {
15
15
  "build": "tsc && node scripts/copy-templates.mjs",
16
- "test": "echo \"Error: no test specified\" && exit 1"
16
+ "test": "node --test index.test.ts"
17
17
  },
18
18
  "bin": {
19
19
  "project-cli": "dist/index.js"