Add Templates plugin#67
Conversation
Greptile SummaryThis PR introduces a Templates plugin for Acode that lets users scaffold HTML5, PHP, and JavaScript projects via a command dialog. The plugin metadata, README, and CHANGELOG are well-formed, but the build pipeline is broken in a way that would ship an empty plugin.
Confidence Score: 3/5Not safe to merge as-is — a fresh build would produce a plugin zip containing an empty stub rather than the actual template logic. The plugin implementation exists only as a pre-built root-level bundle that the build system never touches. Any contributor who runs
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[npm run build] --> B[esbuild.config.mjs]
B --> C[Compiles src/main.js → dist/main.js]
C --> D{src/main.js is empty scaffold}
D -- "❌ Wrong" --> E[dist/main.js = empty plugin]
B --> F[exec: node pack-zip.js]
F --> G{pack-zip.js uses ESM import}
G -- "❌ No type:module in package.json" --> H[SyntaxError – zip not created]
subgraph Actual plugin code
I[main.js at repo root - minified bundle]
end
I -- "Never referenced by build" --> J[Not packaged into plugin.zip]
subgraph Expected flow
K[src/main.js - plugin source] --> L[esbuild → dist/main.js]
L --> M[pack-zip.js → plugin.zip]
M --> N[plugin.json: main: dist/main.js]
end
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[npm run build] --> B[esbuild.config.mjs]
B --> C[Compiles src/main.js → dist/main.js]
C --> D{src/main.js is empty scaffold}
D -- "❌ Wrong" --> E[dist/main.js = empty plugin]
B --> F[exec: node pack-zip.js]
F --> G{pack-zip.js uses ESM import}
G -- "❌ No type:module in package.json" --> H[SyntaxError – zip not created]
subgraph Actual plugin code
I[main.js at repo root - minified bundle]
end
I -- "Never referenced by build" --> J[Not packaged into plugin.zip]
subgraph Expected flow
K[src/main.js - plugin source] --> L[esbuild → dist/main.js]
L --> M[pack-zip.js → plugin.zip]
M --> N[plugin.json: main: dist/main.js]
end
Reviews (1): Last reviewed commit: "Add files via upload" | Re-trigger Greptile |
| @@ -0,0 +1,25 @@ | |||
| (()=>{var i={$schema:"https://acode.app/schema/plugin/v0.1.0.json",id:"com.degrace.templates",name:"Templates",main:"dist/main.js",version:"1.0.0",icon:"icon.png",minVersionCode:290,license:"MIT",price:0,keywords:["template","html","php","javascript"],author:{name:"Hacker2.0",email:"kiminoudegrace64@gmail.com",github:"Degrace15"},description:"Create HTML, PHP and JavaScript project templates in Acode."};function n(c,d,p){let o=acode.require("commands"),s=acode.require("select"),r=acode.require("fsOperation");o.addCommand({name:"templates",description:"Create project templates",exec:async()=>{let t=await s("Choose a template",[["html","HTML5 Template"],["php","PHP Template"],["js","JavaScript Template"]]);if(!t)return;let a=addedFolder[0];if(!a){acode.alert("Error","Please open a folder in Acode first.");return}try{let e=await r(a.url);t==="html"?(await e.createFile("index.html",`<!DOCTYPE html> | |||
There was a problem hiding this comment.
Plugin source never wired into the build pipeline
The plugin implementation was committed as a pre-built minified bundle at main.js (repo root), but the build system never picks it up. esbuild.config.mjs compiles src/main.js (still the empty class scaffold) into dist/main.js. plugin.json references "main": "dist/main.js", and pack-zip.js packages dist/main.js. So when anyone runs npm run build, the output dist/main.js will contain the empty template — not this plugin — and the packaged plugin.zip will silently ship broken code. The plugin logic here (main.js) also never gets included in the zip. The implementation needs to live in src/main.js so esbuild can bundle it into dist/main.js.
There was a problem hiding this comment.
The plugin implementation is now correctly located in src/main.js. The build pipeline generates dist/main.js with the plugin code, and npm run build works correctly.
| import fs from "fs"; | ||
| import JSZip from "jszip"; |
There was a problem hiding this comment.
ESM
import in a CommonJS file will throw a SyntaxError
pack-zip.js uses import statements and top-level await, which are ESM-only features. Because package.json has no "type": "module", Node.js treats every .js file as CommonJS, and running node ./pack-zip.js (as esbuild.config.mjs does via exec) will immediately fail with SyntaxError: Cannot use import statement in a module. The fix is either to rename the file to pack-zip.mjs, or add "type": "module" to package.json (which would require updating all CommonJS require() calls elsewhere).
| @@ -0,0 +1,25 @@ | |||
| (()=>{var i={$schema:"https://acode.app/schema/plugin/v0.1.0.json",id:"com.degrace.templates",name:"Templates",main:"dist/main.js",version:"1.0.0",icon:"icon.png",minVersionCode:290,license:"MIT",price:0,keywords:["template","html","php","javascript"],author:{name:"Hacker2.0",email:"kiminoudegrace64@gmail.com",github:"Degrace15"},description:"Create HTML, PHP and JavaScript project templates in Acode."};function n(c,d,p){let o=acode.require("commands"),s=acode.require("select"),r=acode.require("fsOperation");o.addCommand({name:"templates",description:"Create project templates",exec:async()=>{let t=await s("Choose a template",[["html","HTML5 Template"],["php","PHP Template"],["js","JavaScript Template"]]);if(!t)return;let a=addedFolder[0];if(!a){acode.alert("Error","Please open a folder in Acode first.");return}try{let e=await r(a.url);t==="html"?(await e.createFile("index.html",`<!DOCTYPE html> | |||
There was a problem hiding this comment.
addedFolder accessed outside the try/catch block
let a=addedFolder[0] is evaluated before the try block. While Acode normally exposes addedFolder as a global array (making it safe to index), the subsequent if(!a) check and folder-open guard are only useful when addedFolder exists. If a future Acode version changes this global's shape or it is evaluated in a test context where the global is absent, the TypeError would propagate uncaught past the error handler. Moving the line inside the try block costs nothing and makes the error path consistent.
| "allowScripts": { | ||
| "esbuild@0.25.12": true | ||
| } |
There was a problem hiding this comment.
allowScripts is a Yarn Berry field, silently ignored by npm
"allowScripts": { "esbuild@0.25.12": true } is a Yarn (v3/v4) configuration key for opt-in install scripts. The project uses npm (evidenced by package-lock.json), so npm ignores this field entirely. esbuild's postinstall will either run or be blocked based on npm's own settings, regardless of this entry. Additionally, devDependencies pins esbuild to ^0.25.8 while the allowScripts key references 0.25.12, making the intent ambiguous.
This is an update of the file package.json
|
Fixed!
…On Fri, Jul 17, 2026, 11:34 PM greptile-apps[bot] ***@***.***> wrote:
***@***.***[bot]* commented on this pull request.
------------------------------
In main.js
<#67 (comment)>
:
> @@ -0,0 +1,25 @@
+(()=>{var ***@***.***",github:"Degrace15"},description:"Create HTML, PHP and JavaScript project templates in Acode."};function n(c,d,p){let o=acode.require("commands"),s=acode.require("select"),r=acode.require("fsOperation");o.addCommand({name:"templates",description:"Create project templates",exec:async()=>{let t=await s("Choose a template",[["html","HTML5 Template"],["php","PHP Template"],["js","JavaScript Template"]]);if(!t)return;let a=addedFolder[0];if(!a){acode.alert("Error","Please open a folder in Acode first.");return}try{let e=await r(a.url);t==="html"?(await e.createFile("index.html",`<!DOCTYPE html>
[image: P1] <#m_-1882035525152959776_> *Plugin source never wired into
the build pipeline*
The plugin implementation was committed as a pre-built minified bundle at
main.js (repo root), but the build system never picks it up.
esbuild.config.mjs compiles src/main.js (still the empty class scaffold)
into dist/main.js. plugin.json references "main": "dist/main.js", and
pack-zip.js packages dist/main.js. So when anyone runs npm run build, the
output dist/main.js will contain the empty template — not this plugin —
and the packaged plugin.zip will silently ship broken code. The plugin
logic here (main.js) also never gets included in the zip. The
implementation needs to live in src/main.js so esbuild can bundle it into
dist/main.js.
------------------------------
In pack-zip.js
<#67 (comment)>
:
> +import fs from "fs";
+import JSZip from "jszip";
[image: P1] <#m_-1882035525152959776_> *ESM import in a CommonJS file
will throw a SyntaxError*
pack-zip.js uses import statements and top-level await, which are
ESM-only features. Because package.json has no "type": "module", Node.js
treats every .js file as CommonJS, and running node ./pack-zip.js (as
esbuild.config.mjs does via exec) will immediately fail with SyntaxError:
Cannot use import statement in a module. The fix is either to rename the
file to pack-zip.mjs, or add "type": "module" to package.json (which
would require updating all CommonJS require() calls elsewhere).
------------------------------
In main.js
<#67 (comment)>
:
> @@ -0,0 +1,25 @@
+(()=>{var ***@***.***",github:"Degrace15"},description:"Create HTML, PHP and JavaScript project templates in Acode."};function n(c,d,p){let o=acode.require("commands"),s=acode.require("select"),r=acode.require("fsOperation");o.addCommand({name:"templates",description:"Create project templates",exec:async()=>{let t=await s("Choose a template",[["html","HTML5 Template"],["php","PHP Template"],["js","JavaScript Template"]]);if(!t)return;let a=addedFolder[0];if(!a){acode.alert("Error","Please open a folder in Acode first.");return}try{let e=await r(a.url);t==="html"?(await e.createFile("index.html",`<!DOCTYPE html>
[image: P2] <#m_-1882035525152959776_> *addedFolder accessed outside the
try/catch block*
let a=addedFolder[0] is evaluated before the try block. While Acode
normally exposes addedFolder as a global array (making it safe to index),
the subsequent if(!a) check and folder-open guard are only useful when
addedFolder exists. If a future Acode version changes this global's shape
or it is evaluated in a test context where the global is absent, the
TypeError would propagate uncaught past the error handler. Moving the
line inside the try block costs nothing and makes the error path
consistent.
------------------------------
In package.json
<#67 (comment)>
:
> + "allowScripts": {
+ ***@***.***": true
+ }
[image: P2] <#m_-1882035525152959776_> *allowScripts is a Yarn Berry
field, silently ignored by npm*
"allowScripts": { ***@***.***": true } is a Yarn (v3/v4)
configuration key for opt-in install scripts. The project uses npm
(evidenced by package-lock.json), so npm ignores this field entirely.
esbuild's postinstall will either run or be blocked based on npm's own
settings, regardless of this entry. Additionally, devDependencies pins
esbuild to ^0.25.8 while the allowScripts key references 0.25.12, making
the intent ambiguous.
—
Reply to this email directly, view it on GitHub
<#67?email_source=notifications&email_token=B2GIFHZUXTIUZLGGVXZUXQ35FKSX5A5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTINZSGY2TSMJZHA2KM4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#pullrequestreview-4726591984>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/B2GIFH6VA2YU5DXHM4GGMG35FKSX5AVCNFSNUABFKJSXA33TNF2G64TZHM2TCMRUGEZTQNZTHNEXG43VMU5TIOJRGUZDMNRUHAY2C5QC>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Summary
This pull request adds Templates, an Acode plugin that helps users quickly create project templates.
Features
Thank you for reviewing my plugin. I appreciate your feedback and suggestions for improvement.