create-pdf-smith 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Kareem Elbahrawy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.js ADDED
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import fs2 from "fs";
5
+ import path2 from "path";
6
+ import * as prompts from "@clack/prompts";
7
+ import mri from "mri";
8
+ import pc from "picocolors";
9
+
10
+ // src/scaffold.ts
11
+ import fs from "fs";
12
+ import path from "path";
13
+ import { fileURLToPath } from "url";
14
+ function scaffold({ projectName: projectName2, targetDir: targetDir2 }) {
15
+ const templateDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "template");
16
+ copyDir(templateDir, targetDir2);
17
+ const gitignoreSrc = path.join(targetDir2, "_gitignore");
18
+ const gitignoreDest = path.join(targetDir2, ".gitignore");
19
+ if (fs.existsSync(gitignoreSrc)) {
20
+ fs.renameSync(gitignoreSrc, gitignoreDest);
21
+ }
22
+ const pkgPath = path.join(targetDir2, "package.json");
23
+ const pkgContent = fs.readFileSync(pkgPath, "utf-8");
24
+ fs.writeFileSync(pkgPath, pkgContent.replaceAll("{{PROJECT_NAME}}", projectName2));
25
+ }
26
+ function copyDir(src, dest) {
27
+ fs.mkdirSync(dest, { recursive: true });
28
+ for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
29
+ const srcPath = path.join(src, entry.name);
30
+ const destPath = path.join(dest, entry.name);
31
+ if (entry.isDirectory()) {
32
+ copyDir(srcPath, destPath);
33
+ } else {
34
+ fs.copyFileSync(srcPath, destPath);
35
+ }
36
+ }
37
+ }
38
+
39
+ // src/index.ts
40
+ var USAGE = `
41
+ ${pc.bold("create-pdf-smith")} [project-name]
42
+
43
+ ${pc.dim("Options:")}
44
+ -h, --help Show this help message
45
+ `;
46
+ var args = mri(process.argv.slice(2), {
47
+ boolean: ["help"],
48
+ alias: { h: "help" }
49
+ });
50
+ if (args.help) {
51
+ console.log(USAGE);
52
+ process.exit(0);
53
+ }
54
+ prompts.intro("create-pdf-smith");
55
+ var projectName = args._[0];
56
+ if (!projectName) {
57
+ const result = await prompts.text({
58
+ message: "Project name:",
59
+ placeholder: "my-project",
60
+ validate(value) {
61
+ if (!value.trim()) return "Project name is required";
62
+ }
63
+ });
64
+ if (prompts.isCancel(result)) {
65
+ prompts.cancel("Cancelled.");
66
+ process.exit(0);
67
+ }
68
+ projectName = result;
69
+ }
70
+ var targetDir = path2.resolve(process.cwd(), projectName);
71
+ if (fs2.existsSync(targetDir)) {
72
+ const entries = fs2.readdirSync(targetDir);
73
+ if (entries.length > 0) {
74
+ const overwrite = await prompts.confirm({
75
+ message: `Directory ${pc.cyan(projectName)} is not empty. Continue anyway?`
76
+ });
77
+ if (prompts.isCancel(overwrite) || !overwrite) {
78
+ prompts.cancel("Cancelled.");
79
+ process.exit(0);
80
+ }
81
+ }
82
+ }
83
+ scaffold({ projectName, targetDir });
84
+ prompts.outro("Done!");
85
+ console.log();
86
+ console.log(" Next steps:");
87
+ console.log(` ${pc.cyan("cd")} ${projectName}`);
88
+ console.log(` ${pc.cyan("pnpm install")}`);
89
+ console.log(` ${pc.cyan("pnpm run preview")}`);
90
+ console.log();
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "create-pdf-smith",
3
+ "version": "0.1.0",
4
+ "description": "Scaffold a new pdf-smith project",
5
+ "author": "Kareem Elbahrawy",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/kareemaly/pdf-smith.git",
10
+ "directory": "packages/create-pdf-smith"
11
+ },
12
+ "homepage": "https://github.com/kareemaly/pdf-smith",
13
+ "keywords": [
14
+ "pdf",
15
+ "react",
16
+ "scaffold",
17
+ "create",
18
+ "cli",
19
+ "pdf-smith"
20
+ ],
21
+ "type": "module",
22
+ "bin": {
23
+ "create-pdf-smith": "./dist/index.js"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "template"
28
+ ],
29
+ "dependencies": {
30
+ "@clack/prompts": "^0.9.0",
31
+ "mri": "^1.2.0",
32
+ "picocolors": "^1.1.0"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^22.0.0",
36
+ "tsup": "^8.5.1"
37
+ },
38
+ "scripts": {
39
+ "build": "tsup",
40
+ "typecheck": "tsc --noEmit"
41
+ }
42
+ }
@@ -0,0 +1,3 @@
1
+ node_modules
2
+ dist
3
+ *.tsbuildinfo
@@ -0,0 +1,7 @@
1
+ import { exportPDF } from 'pdf-smith/server';
2
+
3
+ const result = await exportPDF({
4
+ root: import.meta.dirname,
5
+ });
6
+
7
+ console.log(`PDF exported to: ${result.outputPath}`);
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "{{PROJECT_NAME}}",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "preview": "tsx preview.ts",
8
+ "export": "tsx export.ts"
9
+ },
10
+ "dependencies": {
11
+ "pdf-smith": "^0.1.0",
12
+ "react": "^19.0.0",
13
+ "react-dom": "^19.0.0"
14
+ },
15
+ "devDependencies": {
16
+ "@tailwindcss/typography": "^0.5.19",
17
+ "@tailwindcss/vite": "^4.0.0",
18
+ "@types/react": "^19.0.0",
19
+ "@types/react-dom": "^19.0.0",
20
+ "tailwindcss": "^4.0.0",
21
+ "playwright": "^1.52.0",
22
+ "tsx": "^4.19.0",
23
+ "typescript": "^5.7.0"
24
+ }
25
+ }
@@ -0,0 +1,24 @@
1
+ import '../styles.css';
2
+
3
+ export default function Welcome() {
4
+ return (
5
+ <div className="h-full flex flex-col items-center justify-between p-12 font-sans">
6
+ <header className="text-center">
7
+ <h1 className="text-4xl font-bold tracking-tight text-gray-900">pdf-smith</h1>
8
+ </header>
9
+
10
+ <main className="flex flex-col items-center gap-4">
11
+ <div className="rounded-2xl border border-gray-200 bg-white px-10 py-8 shadow-sm text-center">
12
+ <p className="text-2xl font-semibold text-gray-800">Your project is ready</p>
13
+ <p className="mt-2 text-gray-500">
14
+ Edit{' '}
15
+ <code className="rounded bg-gray-100 px-1.5 py-0.5 text-sm">pages/welcome.tsx</code> to
16
+ get started.
17
+ </p>
18
+ </div>
19
+ </main>
20
+
21
+ <footer className="text-sm text-gray-400">Built with pdf-smith</footer>
22
+ </div>
23
+ );
24
+ }
@@ -0,0 +1,3 @@
1
+ import { startPreview } from 'pdf-smith/server';
2
+
3
+ startPreview({ root: import.meta.dirname, open: true });
@@ -0,0 +1 @@
1
+ @import "tailwindcss";
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "resolveJsonModule": true,
11
+ "isolatedModules": true,
12
+ "noEmit": true,
13
+ "jsx": "react-jsx"
14
+ },
15
+ "exclude": ["node_modules", "dist"]
16
+ }