Skip to content

Commit

Permalink
added warning comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fomalhautb committed Feb 8, 2025
1 parent e0d7223 commit c22b762
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/js/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"//": "THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY",
"name": "@stackframe/js",
"version": "2.7.8",
"sideEffects": false,
Expand Down Expand Up @@ -65,4 +66,4 @@
"tailwindcss": "^3.4.4",
"tsup": "^8.0.2"
}
}
}
5 changes: 3 additions & 2 deletions packages/stack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"//": "THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY",
"name": "@stackframe/stack",
"version": "2.7.12",
"version": "2.7.8",
"sideEffects": false,
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -99,4 +100,4 @@
"tailwindcss": "^3.4.4",
"tsup": "^8.0.2"
}
}
}
23 changes: 22 additions & 1 deletion scripts/generate-from-template.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import fs from "fs";
import path from "path";

const COMMENT_LINE = "THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY";

const allEnvs = ["next", "react-like", "js", "template"];
const ignoredFiles = ['node_modules', 'dist', '.turbo', '.gitignore'];

Expand Down Expand Up @@ -97,7 +99,26 @@ function copyFromSrcToDest(
continue;
}

fs.writeFileSync(destPath, editedContent ?? content);
let newContent = editedContent ?? content;

if (destPath.endsWith('.tsx') || destPath.endsWith('.ts') || destPath.endsWith('.js')) {
newContent = '//===========================================\n' +
'// ' + COMMENT_LINE + '\n' +
'//===========================================\n' +
newContent;
}

if (destPath.endsWith('package.json')) {
// For package.json files, add a comment field
const json = JSON.parse(newContent);
const orderedJson = {
"//": COMMENT_LINE,
...json
};
newContent = JSON.stringify(orderedJson, null, 2);
}

fs.writeFileSync(destPath, newContent);
}
}
}
Expand Down

0 comments on commit c22b762

Please sign in to comment.