MCPcopy
hub / github.com/stackblitz-labs/pkg.pr.new / createDefaultTemplate

Function createDefaultTemplate

packages/cli/template.ts:16–67  ·  view source on GitHub ↗
(
  dependencies: Record<string, string>,
  isCommentWithDev: boolean,
  selectedPackageManager: ("npm" | "yarn" | "pnpm" | "bun")[],
)

Source from the content-addressed store, hash-verified

14}
15
16export const createDefaultTemplate = (
17 dependencies: Record<string, string>,
18 isCommentWithDev: boolean,
19 selectedPackageManager: ("npm" | "yarn" | "pnpm" | "bun")[],
20) => ({
21 "index.js": "",
22 "README.md": `
23# Default Template
24
25This is a template that leverages the experimental templates feature in the \`pkg.pr.new\` tool.
26
27## Overview
28
29Templates are particularly useful for creating live, interactive examples of your packages, which can be very beneficial for both development and documentation purposes.
30
31As a user, you can check the package.json file and see the new generated packages! You can just copy those and put them in your package.json or install them with your favorite package manager.
32
33${Object.values(dependencies)
34 .map((url) =>
35 generateShellCommand(url, isCommentWithDev, selectedPackageManager),
36 )
37 .join("")}
38
39## Usage
40
41To use this feature as a maintainer, you can run the following command:
42
43\`\`\`sh
44pnpm exec pkg-pr-new publish './packages/A' --template './examples/*'${isCommentWithDev ? " --commentWithDev" : ""}
45\`\`\`
46
47## Benefits
48
49- Interactive Demos: Automatically create live demos that users can interact with directly in their browser.
50- Enhanced Testing: Quickly spin up environments to test your package in different scenarios.
51- Improved Sharing: Easily share working examples of your package with collaborators or users without needing them to set up their environment.
52`,
53 "package.json": JSON.stringify(
54 {
55 name: "default",
56 version: "1.0.0",
57 description: "generated by pkg.pr.new",
58 main: "index.js",
59 [isCommentWithDev ? "devDependencies" : "dependencies"]: dependencies,
60 keywords: [],
61 author: "pkg.pr.new",
62 license: "ISC",
63 },
64 null,
65 2,
66 ),
67});

Callers 1

index.tsFile · 0.90

Calls 1

generateShellCommandFunction · 0.85

Tested by

no test coverage detected