create-skybridge 0.0.0-dev.bc5d28d → 0.0.0-dev.c269e58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export declare function init(args?: string[]): Promise<void>;
1
+ export {};
package/dist/index.js CHANGED
@@ -3,6 +3,11 @@ import path from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import * as prompts from "@clack/prompts";
5
5
  import mri from "mri";
6
+ const argv = mri(process.argv.slice(2), {
7
+ boolean: ["help", "overwrite"],
8
+ alias: { h: "help" },
9
+ });
10
+ const cwd = process.cwd();
6
11
  const defaultProjectName = "skybridge-project";
7
12
  // prettier-ignore
8
13
  const helpMessage = `\
@@ -18,13 +23,9 @@ Examples:
18
23
  create-skybridge my-app
19
24
  create-skybridge . --overwrite
20
25
  `;
21
- export async function init(args = process.argv.slice(2)) {
22
- const argv = mri(args, {
23
- boolean: ["help", "overwrite"],
24
- alias: { h: "help" },
25
- });
26
+ async function init() {
26
27
  const argTargetDir = argv._[0]
27
- ? sanitizeTargetDir(String(argv._[0]))
28
+ ? formatTargetDir(String(argv._[0]))
28
29
  : undefined;
29
30
  const argOverwrite = argv.overwrite;
30
31
  const help = argv.help;
@@ -43,14 +44,14 @@ export async function init(args = process.argv.slice(2)) {
43
44
  defaultValue: defaultProjectName,
44
45
  placeholder: defaultProjectName,
45
46
  validate: (value) => {
46
- return value.length === 0 || sanitizeTargetDir(value).length > 0
47
+ return value.length === 0 || formatTargetDir(value).length > 0
47
48
  ? undefined
48
49
  : "Invalid project name";
49
50
  },
50
51
  });
51
52
  if (prompts.isCancel(projectName))
52
53
  return cancel();
53
- targetDir = sanitizeTargetDir(projectName);
54
+ targetDir = formatTargetDir(projectName);
54
55
  }
55
56
  else {
56
57
  targetDir = defaultProjectName;
@@ -94,7 +95,7 @@ export async function init(args = process.argv.slice(2)) {
94
95
  return;
95
96
  }
96
97
  }
97
- const root = path.join(process.cwd(), targetDir);
98
+ const root = path.join(cwd, targetDir);
98
99
  // 3. Copy the repository
99
100
  prompts.log.step(`Copying template...`);
100
101
  try {
@@ -120,17 +121,8 @@ export async function init(args = process.argv.slice(2)) {
120
121
  process.exit(1);
121
122
  }
122
123
  }
123
- function sanitizeTargetDir(targetDir) {
124
- return (targetDir
125
- .trim()
126
- // Only keep alphanumeric, dash, underscore, dot, @, /
127
- .replace(/[^a-zA-Z0-9\-_.@/]/g, "")
128
- // Prevent path traversal
129
- .replace(/\.\./g, "")
130
- // Collapse multiple slashes
131
- .replace(/\/+/g, "/")
132
- // Remove leading/trailing slashes
133
- .replace(/^\/+|\/+$/g, ""));
124
+ function formatTargetDir(targetDir) {
125
+ return targetDir.trim().replace(/\/+$/g, "");
134
126
  }
135
127
  function isEmpty(path) {
136
128
  const files = fs.readdirSync(path);
@@ -147,3 +139,7 @@ function emptyDir(dir) {
147
139
  fs.rmSync(path.resolve(dir, file), { recursive: true, force: true });
148
140
  }
149
141
  }
142
+ init().catch((e) => {
143
+ console.error(e);
144
+ process.exit(1);
145
+ });
package/index.js CHANGED
@@ -1,8 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { init } from "./dist/index.js";
4
-
5
- init().catch((e) => {
6
- console.error(e);
7
- process.exit(1);
8
- });
3
+ import "./dist/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-skybridge",
3
- "version": "0.0.0-dev.bc5d28d",
3
+ "version": "0.0.0-dev.c269e58",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Alpic",
@@ -18,8 +18,6 @@
18
18
  ],
19
19
  "scripts": {
20
20
  "build": "tsc",
21
- "test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
22
- "test:unit": "vitest run",
23
21
  "test:type": "tsc --noEmit",
24
22
  "test:format": "biome ci",
25
23
  "prepublishOnly": "pnpm run build"
@@ -30,7 +28,6 @@
30
28
  },
31
29
  "devDependencies": {
32
30
  "@types/node": "^25.0.3",
33
- "typescript": "^5.9.3",
34
- "vitest": "^2.1.9"
31
+ "typescript": "^5.9.3"
35
32
  }
36
33
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1,22 +0,0 @@
1
- import { randomBytes } from "node:crypto";
2
- import fs from "node:fs/promises";
3
- import path from "node:path";
4
- import { afterEach, beforeEach, describe, it } from "vitest";
5
- import { init } from "./index.js";
6
- describe("create-skybridge", () => {
7
- let tempDirName;
8
- beforeEach(() => {
9
- tempDirName = `test-${randomBytes(2).toString("hex")}`;
10
- });
11
- afterEach(async () => {
12
- await fs.rm(path.join(process.cwd(), tempDirName), {
13
- recursive: true,
14
- force: true,
15
- });
16
- });
17
- it("should scaffold a new project", async () => {
18
- const name = `../../${tempDirName}//project$`;
19
- await init([name]);
20
- await fs.access(path.join(process.cwd(), tempDirName, "project", ".gitignore"));
21
- });
22
- });