Skip to content

Commit 61bea85

Browse files
committed
fix(create-pyth-app): don't copy node modules and rewrite their package.json files
1 parent 5eb84c5 commit 61bea85

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

packages/create-pyth-app/src/create-pyth-app.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ import type {
2121
} from "./types.js";
2222
import { PACKAGE_PREFIX, PackageType, TEMPLATES_FOLDER } from "./types.js";
2323

24+
function getPackageNameWithoutOrg(
25+
packageNameWithOrg: string | null | undefined,
26+
) {
27+
return packageNameWithOrg?.split("/")[1] ?? "";
28+
}
29+
2430
/**
2531
* returns the folder that holds the correct templates, based on the user's
2632
* package choice
@@ -109,7 +115,7 @@ async function createPythApp() {
109115
}: InProgressCreatePythAppResponses,
110116
) => {
111117
let msg = `Please confirm your choices:${os.EOL}`;
112-
msg += `Creating a ${chalk.magenta(packageType)} package, named ${chalk.magenta(packageName)}, in ${chalk.magenta(packageType === PackageType.WEBAPP ? "apps" : folder)}/${packageName?.split("/")[1] ?? ""}.${os.EOL}`;
118+
msg += `Creating a ${chalk.magenta(packageType)} package, named ${chalk.magenta(packageName)}, in ${chalk.magenta(packageType === PackageType.WEBAPP ? "apps" : folder)}/${getPackageNameWithoutOrg(packageName)}.${os.EOL}`;
113119
msg += "Look good?";
114120

115121
return msg;
@@ -124,7 +130,7 @@ async function createPythApp() {
124130
return;
125131
}
126132

127-
const [, packageNameWithoutOrg = ""] = packageName.split("/");
133+
const packageNameWithoutOrg = getPackageNameWithoutOrg(packageName);
128134

129135
const relDest =
130136
packageType === PackageType.WEBAPP
@@ -153,12 +159,12 @@ async function createPythApp() {
153159
"updating files with the choices you made in the initial prompts",
154160
);
155161
await Promise.all(
156-
destFiles.map(async (fp) => {
157-
debugger;
162+
destFiles.filter(fp => !fp.includes('node_module')).map(async (fp) => {
158163
const contents = await fs.readFile(fp, "utf8");
159164
const updatedContents = renderTemplate(contents, {
160165
description,
161166
name: packageName,
167+
packageNameWithoutOrg,
162168
relativeFolder: relDest,
163169
});
164170
await fs.writeFile(fp, updatedContents, "utf8");

packages/create-pyth-app/src/templates/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "0.0.0",
55
"type": "module",
66
"bin": {
7-
"{{name}}": "./bin.js"
7+
"{{packageNameWithoutOrg}}": "./bin.js"
88
},
99
"files": [
1010
"bin.js",

0 commit comments

Comments
 (0)