Skip to content

Commit

Permalink
build: ensure generator doesn't ignore recipe files on publish
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Nov 11, 2023
1 parent c85f82f commit 5caf0ab
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
8 changes: 7 additions & 1 deletion packages/create-puck-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@
"bin": {
"create-puck-app": "./index.js"
},
"files": [
"templates",
"index.js"
],
"scripts": {
"generate": "node scripts/generate.js",
"prepublishOnly": "yarn generate"
"prepublishOnly": "yarn generate",
"removeGitignore": "mv templates/.gitignore templates/gitignore",
"restoreGitignore": "mv templates/gitignore templates/.gitignore"
},
"dependencies": {
"commander": "^10.0.1",
Expand Down
11 changes: 8 additions & 3 deletions packages/create-puck-app/scripts/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ const run = async () => {
for (const recipeFile of recipeFiles) {
const filePath = path.join(recipePath, recipeFile);

const targetPath = filePath
.replace(recipePath, templatePath)
.replace(".gitignore", "gitignore"); // rename .gitignore to gitignore so NPM publish doesn't ignore it
const targetPath = filePath.replace(recipePath, templatePath);

// Don't copy file if it's templated by handlebars
if (fs.existsSync(`${targetPath}.hbs`)) {
Expand All @@ -62,6 +60,13 @@ const run = async () => {

await fs.writeFileSync(targetPath, data);

if (targetPath.indexOf(".gitignore") > -1) {
await fs.copyFileSync(
filePath,
targetPath.replace(".gitignore", "gitignore") // rename .gitignore to gitignore so NPM publish doesn't ignore it
);
}

counter += 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ cd ../../
cd packages/plugin-heading-analyzer && npm publish --access public --tag $1
cd ../../

cd packages/create-puck-app && npm run generate && npm publish --access public --tag $1
cd packages/create-puck-app && npm run removeGitignore && npm publish --access public --tag $1 && npm run restoreGitignore
cd ../../

0 comments on commit 5caf0ab

Please sign in to comment.