create-prisma-php-app 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/composer.json +2 -1
- package/composer.lock +101 -29
- package/dist/index.js +1 -1
- package/dist/src/lib/phpmailer/Mailer.php +91 -0
- package/package.json +1 -1
- package/dist/src/lib/phpmailer/SendEmail.php +0 -47
package/composer.json
CHANGED
package/composer.lock
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
|
5
5
|
"This file is @generated automatically"
|
|
6
6
|
],
|
|
7
|
-
"content-hash": "
|
|
7
|
+
"content-hash": "88df3fa2c675b8008c54928f37a0ecc0",
|
|
8
8
|
"packages": [
|
|
9
9
|
{
|
|
10
10
|
"name": "brick/math",
|
|
@@ -294,6 +294,87 @@
|
|
|
294
294
|
},
|
|
295
295
|
"time": "2020-10-15T08:29:30+00:00"
|
|
296
296
|
},
|
|
297
|
+
{
|
|
298
|
+
"name": "phpmailer/phpmailer",
|
|
299
|
+
"version": "v6.9.1",
|
|
300
|
+
"source": {
|
|
301
|
+
"type": "git",
|
|
302
|
+
"url": "https://github.com/PHPMailer/PHPMailer.git",
|
|
303
|
+
"reference": "039de174cd9c17a8389754d3b877a2ed22743e18"
|
|
304
|
+
},
|
|
305
|
+
"dist": {
|
|
306
|
+
"type": "zip",
|
|
307
|
+
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/039de174cd9c17a8389754d3b877a2ed22743e18",
|
|
308
|
+
"reference": "039de174cd9c17a8389754d3b877a2ed22743e18",
|
|
309
|
+
"shasum": ""
|
|
310
|
+
},
|
|
311
|
+
"require": {
|
|
312
|
+
"ext-ctype": "*",
|
|
313
|
+
"ext-filter": "*",
|
|
314
|
+
"ext-hash": "*",
|
|
315
|
+
"php": ">=5.5.0"
|
|
316
|
+
},
|
|
317
|
+
"require-dev": {
|
|
318
|
+
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
|
|
319
|
+
"doctrine/annotations": "^1.2.6 || ^1.13.3",
|
|
320
|
+
"php-parallel-lint/php-console-highlighter": "^1.0.0",
|
|
321
|
+
"php-parallel-lint/php-parallel-lint": "^1.3.2",
|
|
322
|
+
"phpcompatibility/php-compatibility": "^9.3.5",
|
|
323
|
+
"roave/security-advisories": "dev-latest",
|
|
324
|
+
"squizlabs/php_codesniffer": "^3.7.2",
|
|
325
|
+
"yoast/phpunit-polyfills": "^1.0.4"
|
|
326
|
+
},
|
|
327
|
+
"suggest": {
|
|
328
|
+
"decomplexity/SendOauth2": "Adapter for using XOAUTH2 authentication",
|
|
329
|
+
"ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses",
|
|
330
|
+
"ext-openssl": "Needed for secure SMTP sending and DKIM signing",
|
|
331
|
+
"greew/oauth2-azure-provider": "Needed for Microsoft Azure XOAUTH2 authentication",
|
|
332
|
+
"hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication",
|
|
333
|
+
"league/oauth2-google": "Needed for Google XOAUTH2 authentication",
|
|
334
|
+
"psr/log": "For optional PSR-3 debug logging",
|
|
335
|
+
"symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)",
|
|
336
|
+
"thenetworg/oauth2-azure": "Needed for Microsoft XOAUTH2 authentication"
|
|
337
|
+
},
|
|
338
|
+
"type": "library",
|
|
339
|
+
"autoload": {
|
|
340
|
+
"psr-4": {
|
|
341
|
+
"PHPMailer\\PHPMailer\\": "src/"
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
"notification-url": "https://packagist.org/downloads/",
|
|
345
|
+
"license": [
|
|
346
|
+
"LGPL-2.1-only"
|
|
347
|
+
],
|
|
348
|
+
"authors": [
|
|
349
|
+
{
|
|
350
|
+
"name": "Marcus Bointon",
|
|
351
|
+
"email": "phpmailer@synchromedia.co.uk"
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
"name": "Jim Jagielski",
|
|
355
|
+
"email": "jimjag@gmail.com"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
"name": "Andy Prevost",
|
|
359
|
+
"email": "codeworxtech@users.sourceforge.net"
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
"name": "Brent R. Matzelle"
|
|
363
|
+
}
|
|
364
|
+
],
|
|
365
|
+
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
|
|
366
|
+
"support": {
|
|
367
|
+
"issues": "https://github.com/PHPMailer/PHPMailer/issues",
|
|
368
|
+
"source": "https://github.com/PHPMailer/PHPMailer/tree/v6.9.1"
|
|
369
|
+
},
|
|
370
|
+
"funding": [
|
|
371
|
+
{
|
|
372
|
+
"url": "https://github.com/Synchro",
|
|
373
|
+
"type": "github"
|
|
374
|
+
}
|
|
375
|
+
],
|
|
376
|
+
"time": "2023-11-25T22:23:28+00:00"
|
|
377
|
+
},
|
|
297
378
|
{
|
|
298
379
|
"name": "phpoption/phpoption",
|
|
299
380
|
"version": "1.9.2",
|
|
@@ -461,16 +542,16 @@
|
|
|
461
542
|
},
|
|
462
543
|
{
|
|
463
544
|
"name": "symfony/polyfill-ctype",
|
|
464
|
-
"version": "v1.
|
|
545
|
+
"version": "v1.29.0",
|
|
465
546
|
"source": {
|
|
466
547
|
"type": "git",
|
|
467
548
|
"url": "https://github.com/symfony/polyfill-ctype.git",
|
|
468
|
-
"reference": "
|
|
549
|
+
"reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4"
|
|
469
550
|
},
|
|
470
551
|
"dist": {
|
|
471
552
|
"type": "zip",
|
|
472
|
-
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/
|
|
473
|
-
"reference": "
|
|
553
|
+
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4",
|
|
554
|
+
"reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4",
|
|
474
555
|
"shasum": ""
|
|
475
556
|
},
|
|
476
557
|
"require": {
|
|
@@ -484,9 +565,6 @@
|
|
|
484
565
|
},
|
|
485
566
|
"type": "library",
|
|
486
567
|
"extra": {
|
|
487
|
-
"branch-alias": {
|
|
488
|
-
"dev-main": "1.28-dev"
|
|
489
|
-
},
|
|
490
568
|
"thanks": {
|
|
491
569
|
"name": "symfony/polyfill",
|
|
492
570
|
"url": "https://github.com/symfony/polyfill"
|
|
@@ -523,7 +601,7 @@
|
|
|
523
601
|
"portable"
|
|
524
602
|
],
|
|
525
603
|
"support": {
|
|
526
|
-
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.
|
|
604
|
+
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0"
|
|
527
605
|
},
|
|
528
606
|
"funding": [
|
|
529
607
|
{
|
|
@@ -539,20 +617,20 @@
|
|
|
539
617
|
"type": "tidelift"
|
|
540
618
|
}
|
|
541
619
|
],
|
|
542
|
-
"time": "
|
|
620
|
+
"time": "2024-01-29T20:11:03+00:00"
|
|
543
621
|
},
|
|
544
622
|
{
|
|
545
623
|
"name": "symfony/polyfill-mbstring",
|
|
546
|
-
"version": "v1.
|
|
624
|
+
"version": "v1.29.0",
|
|
547
625
|
"source": {
|
|
548
626
|
"type": "git",
|
|
549
627
|
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
|
550
|
-
"reference": "
|
|
628
|
+
"reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec"
|
|
551
629
|
},
|
|
552
630
|
"dist": {
|
|
553
631
|
"type": "zip",
|
|
554
|
-
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/
|
|
555
|
-
"reference": "
|
|
632
|
+
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec",
|
|
633
|
+
"reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec",
|
|
556
634
|
"shasum": ""
|
|
557
635
|
},
|
|
558
636
|
"require": {
|
|
@@ -566,9 +644,6 @@
|
|
|
566
644
|
},
|
|
567
645
|
"type": "library",
|
|
568
646
|
"extra": {
|
|
569
|
-
"branch-alias": {
|
|
570
|
-
"dev-main": "1.28-dev"
|
|
571
|
-
},
|
|
572
647
|
"thanks": {
|
|
573
648
|
"name": "symfony/polyfill",
|
|
574
649
|
"url": "https://github.com/symfony/polyfill"
|
|
@@ -606,7 +681,7 @@
|
|
|
606
681
|
"shim"
|
|
607
682
|
],
|
|
608
683
|
"support": {
|
|
609
|
-
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.
|
|
684
|
+
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0"
|
|
610
685
|
},
|
|
611
686
|
"funding": [
|
|
612
687
|
{
|
|
@@ -622,20 +697,20 @@
|
|
|
622
697
|
"type": "tidelift"
|
|
623
698
|
}
|
|
624
699
|
],
|
|
625
|
-
"time": "
|
|
700
|
+
"time": "2024-01-29T20:11:03+00:00"
|
|
626
701
|
},
|
|
627
702
|
{
|
|
628
703
|
"name": "symfony/polyfill-php80",
|
|
629
|
-
"version": "v1.
|
|
704
|
+
"version": "v1.29.0",
|
|
630
705
|
"source": {
|
|
631
706
|
"type": "git",
|
|
632
707
|
"url": "https://github.com/symfony/polyfill-php80.git",
|
|
633
|
-
"reference": "
|
|
708
|
+
"reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b"
|
|
634
709
|
},
|
|
635
710
|
"dist": {
|
|
636
711
|
"type": "zip",
|
|
637
|
-
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/
|
|
638
|
-
"reference": "
|
|
712
|
+
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b",
|
|
713
|
+
"reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b",
|
|
639
714
|
"shasum": ""
|
|
640
715
|
},
|
|
641
716
|
"require": {
|
|
@@ -643,9 +718,6 @@
|
|
|
643
718
|
},
|
|
644
719
|
"type": "library",
|
|
645
720
|
"extra": {
|
|
646
|
-
"branch-alias": {
|
|
647
|
-
"dev-main": "1.28-dev"
|
|
648
|
-
},
|
|
649
721
|
"thanks": {
|
|
650
722
|
"name": "symfony/polyfill",
|
|
651
723
|
"url": "https://github.com/symfony/polyfill"
|
|
@@ -689,7 +761,7 @@
|
|
|
689
761
|
"shim"
|
|
690
762
|
],
|
|
691
763
|
"support": {
|
|
692
|
-
"source": "https://github.com/symfony/polyfill-php80/tree/v1.
|
|
764
|
+
"source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0"
|
|
693
765
|
},
|
|
694
766
|
"funding": [
|
|
695
767
|
{
|
|
@@ -705,7 +777,7 @@
|
|
|
705
777
|
"type": "tidelift"
|
|
706
778
|
}
|
|
707
779
|
],
|
|
708
|
-
"time": "
|
|
780
|
+
"time": "2024-01-29T20:11:03+00:00"
|
|
709
781
|
},
|
|
710
782
|
{
|
|
711
783
|
"name": "vlucas/phpdotenv",
|
|
@@ -805,7 +877,7 @@
|
|
|
805
877
|
"prefer-stable": false,
|
|
806
878
|
"prefer-lowest": false,
|
|
807
879
|
"platform": {
|
|
808
|
-
"php": "^
|
|
880
|
+
"php": "^8.1"
|
|
809
881
|
},
|
|
810
882
|
"platform-dev": [],
|
|
811
883
|
"plugin-api-version": "2.6.0"
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{execSync}from"child_process";import fs from"fs";import{fileURLToPath}from"url";import path from"path";import chalk from"chalk";import prompts from"prompts";const __filename=fileURLToPath(import.meta.url),__dirname=path.dirname(__filename);function configureBrowserSyncCommand(e,s){const t=s.PROJECT_ROOT_PATH.indexOf("\\htdocs\\");if(-1===t)return"";const n=s.PROJECT_ROOT_PATH.substring(0,t+"\\htdocs\\".length).replace(/\\/g,"\\\\"),i=s.PROJECT_ROOT_PATH.replace(new RegExp(`^${n}`),"").replace(/\\/g,"/");let c=`http://localhost/${i}`;c=c.endsWith("/")?c.slice(0,-1):c;const r=c.replace(/(?<!:)(\/\/+)/g,"/"),
|
|
2
|
+
import{execSync}from"child_process";import fs from"fs";import{fileURLToPath}from"url";import path from"path";import chalk from"chalk";import prompts from"prompts";const __filename=fileURLToPath(import.meta.url),__dirname=path.dirname(__filename);function configureBrowserSyncCommand(e,s){const t=s.PROJECT_ROOT_PATH.indexOf("\\htdocs\\");if(-1===t)return"";const n=s.PROJECT_ROOT_PATH.substring(0,t+"\\htdocs\\".length).replace(/\\/g,"\\\\"),i=s.PROJECT_ROOT_PATH.replace(new RegExp(`^${n}`),"").replace(/\\/g,"/");let c=`http://localhost/${i}`;c=c.endsWith("/")?c.slice(0,-1):c;const r=c.replace(/(?<!:)(\/\/+)/g,"/"),a=i.replace(/\/\/+/g,"/"),o=`\n const { createProxyMiddleware } = require("http-proxy-middleware");\n\n module.exports = {\n // First middleware: Set Cache-Control headers\n function (req, res, next) {\n res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");\n res.setHeader("Pragma", "no-cache");\n res.setHeader("Expires", "0");\n next();\n },\n // Use the 'middleware' option to create a proxy that masks the deep URL.\n middleware: [\n // This middleware intercepts requests to the root and proxies them to the deep path.\n createProxyMiddleware("/", {\n target:\n "${r}",\n changeOrigin: true,\n pathRewrite: {\n "^/": "/${a.startsWith("/")?a.substring(1):a}", // Rewrite the path.\n },\n }),\n ],\n proxy: "http://localhost:3000", // Proxy the BrowserSync server.\n // serveStatic: ["src/app"], // Serve static files from this directory.\n files: "src/**/*.*",\n notify: false,\n open: false,\n ghostMode: false,\n };`,p=path.join(e,"settings","bs-config.cjs");return fs.writeFileSync(p,o,"utf8"),"browser-sync start --config settings/bs-config.cjs"}async function updatePackageJson(e,s,t){const n=path.join(e,"package.json"),i=JSON.parse(fs.readFileSync(n,"utf8")),c=configureBrowserSyncCommand(e,s);i.scripts=Object.assign(Object.assign({},i.scripts),{postinstall:"prisma generate"});let r=[];t.tailwindcss&&(i.scripts=Object.assign(Object.assign({},i.scripts),{tailwind:"tailwindcss -i ./src/app/css/tailwind.css -o ./src/app/css/styles.css --minify --watch"}),r.push("tailwind")),t.websocket&&(i.scripts=Object.assign(Object.assign({},i.scripts),{websocket:"node ./settings/restartWebsocket.cjs"}),r.push("websocket"));const a=Object.assign({},i.scripts);r.length>0&&(a["browser-sync"]=c),a.dev=r.length>0?`npm-run-all --parallel browser-sync ${r.join(" ")}`:c,i.scripts=a,i.type="module",i.prisma={seed:"node prisma/seed.js"},fs.writeFileSync(n,JSON.stringify(i,null,2))}async function updateComposerJson(e,s){if(!s.websocket)return;const t=path.join(e,"composer.json");let n;if(fs.existsSync(t)){{const e=fs.readFileSync(t,"utf8");n=JSON.parse(e)}s.websocket&&(n.require=Object.assign(Object.assign({},n.require),{"cboden/ratchet":"^0.4.4"})),fs.writeFileSync(t,JSON.stringify(n,null,2))}}async function updateIndexJsForWebSocket(e,s){if(!s.websocket)return;const t=path.join(e,"src","app","js","index.js");let n=fs.readFileSync(t,"utf8");n+='\n// WebSocket initialization\nconst ws = new WebSocket("ws://localhost:8080");\n',fs.writeFileSync(t,n,"utf8")}async function createUpdateGitignoreFile(e,s){const t=path.join(e,".gitignore");let n="";fs.existsSync(t)&&(n=fs.readFileSync(t,"utf8")),s.forEach((e=>{n.includes(e)||(n+=`\n${e}`)})),n=n.trimStart(),fs.writeFileSync(t,n)}function copyRecursiveSync(e,s){const t=fs.existsSync(e),n=t&&fs.statSync(e);t&&n&&n.isDirectory()?(fs.mkdirSync(s,{recursive:!0}),fs.readdirSync(e).forEach((t=>copyRecursiveSync(path.join(e,t),path.join(s,t))))):fs.copyFileSync(e,s)}async function executeCopy(e,s){s.forEach((({srcDir:s,destDir:t})=>{copyRecursiveSync(path.join(__dirname,s),path.join(e,t))}))}function modifyTailwindConfig(e){const s=path.join(e,"tailwind.config.js");let t=fs.readFileSync(s,"utf8");const n=["./src/app/**/*.{php,html,js,css}"].map((e=>` "${e}"`)).join(",\n");t=t.replace(/content: \[\],/g,`content: [\n${n}\n],`),fs.writeFileSync(s,t,"utf8")}function modifyIndexPHP(e,s){const t=path.join(e,"src","app","layout.php");try{let e=fs.readFileSync(t,"utf8");const n='\n <link href="<?php echo $baseUrl; ?>css/index.css" rel="stylesheet">\n <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap" rel="stylesheet">\n <script src="<?php echo $baseUrl; ?>js/index.js"><\/script>',i=s?` <link href="<?php echo $baseUrl; ?>css/styles.css" rel="stylesheet"> ${n}`:` <script src="https://cdn.tailwindcss.com"><\/script> ${n}`;e=e.replace("</head>",`${i}\n</head>`),fs.writeFileSync(t,e,"utf8")}catch(e){}}async function updateOrCreateEnvFile(e,s){const t=path.join(e,".env");let n=fs.existsSync(t)?fs.readFileSync(t,"utf8"):"";n+=`${""!==n?"\n\n":""}${s}`,fs.writeFileSync(t,n)}async function createDirectoryStructure(e,s,t){[{src:"/bootstrap.php",dest:"/bootstrap.php"},{src:"/.htaccess",dest:"/.htaccess"},{src:"/../composer.json",dest:"/composer.json"}].forEach((({src:s,dest:t})=>{const n=path.join(__dirname,s),i=path.join(e,t),c=fs.readFileSync(n,"utf8");fs.writeFileSync(i,c)})),await executeCopy(e,[{srcDir:"/settings",destDir:"/settings"},{srcDir:"/prisma",destDir:"/prisma"},{srcDir:"/src",destDir:"/src"},{srcDir:"/../vendor",destDir:"/vendor"}]),await updatePackageJson(e,t,s),await updateComposerJson(e,s),await updateIndexJsForWebSocket(e,s),s.tailwindcss?(modifyTailwindConfig(e),modifyIndexPHP(e,!0)):modifyIndexPHP(e,!1);await updateOrCreateEnvFile(e,'# PHPMailer\nSMTP_HOST=\nSMTP_USERNAME=\nSMTP_PASSWORD=\nSMTP_PORT=\nSMTP_ENCRYPTION=ssl\nMAIL_FROM=\nMAIL_FROM_NAME=""'),await createUpdateGitignoreFile(e,["vendor"])}async function getAnswer(){const e=[{type:"text",name:"projectName",message:"What is your project named?",initial:"my-app"},{type:"toggle",name:"tailwindcss",message:`Would you like to use ${chalk.blue("Tailwind CSS")}?`,initial:!0,active:"Yes",inactive:"No"},{type:"toggle",name:"websocket",message:`Would you like to use ${chalk.blue("Websocket")}?`,initial:!0,active:"Yes",inactive:"No"}],s=()=>!1;try{const t=await prompts(e,{onCancel:s});return 0===Object.keys(t).length?null:{projectName:String(t.projectName).trim().replace(/ /g,"-"),tailwindcss:t.tailwindcss,websocket:t.websocket}}catch(e){return null}}async function installDependencies(e,s,t=!1){execSync("npm init -y",{stdio:"inherit",cwd:e}),s.forEach((e=>{}));const n=`npm install ${t?"--save-dev":""} ${s.join(" ")}`;execSync(n,{stdio:"inherit",cwd:e})}async function main(){try{const e=await getAnswer();if(null===e)return;execSync("npm install -g create-prisma-php-app",{stdio:"inherit"}),execSync("npm install -g browser-sync",{stdio:"inherit"}),fs.mkdirSync(e.projectName);const s=path.join(process.cwd(),e.projectName);process.chdir(e.projectName);const t=["prisma","@prisma/client","typescript","@types/node","ts-node","http-proxy-middleware"];e.tailwindcss&&t.push("tailwindcss","autoprefixer","postcss"),e.websocket&&t.push("chokidar-cli"),(e.tailwindcss||e.websocket)&&t.push("npm-run-all"),await installDependencies(s,t,!0),execSync("npx prisma init",{stdio:"inherit"}),execSync("npx tsc --init",{stdio:"inherit"}),e.tailwindcss&&execSync("npx tailwindcss init -p",{stdio:"inherit"});const n={PROJECT_NAME:e.projectName,PROJECT_ROOT_PATH:s.replace(/\\/g,"\\\\"),PHP_ROOT_PATH_EXE:"D:\\\\xampp\\\\php\\\\php.exe",PHP_GENERATE_CLASS_PATH:"src/lib/prisma/classes"};await createDirectoryStructure(s,e,n),e.tailwindcss&&execSync("npx tailwindcss -i ./src/app/css/tailwind.css -o ./src/app/css/styles.css --minify",{stdio:"inherit"});const i=path.join(s,"settings","project-settings.js"),c=`export const projectSettings = {\n PROJECT_NAME: "${e.projectName}",\n PROJECT_ROOT_PATH: "${s.replace(/\\/g,"\\\\")}",\n PHP_ROOT_PATH_EXE: "D:\\\\xampp\\\\php\\\\php.exe",\n PHP_GENERATE_CLASS_PATH: "src/lib/prisma/classes",\n };`;if(fs.writeFileSync(i,c),fs.mkdirSync(path.join(s,"public")),!e.tailwindcss){const e=path.join(s,"src","app","css");["tailwind.css","styles.css"].forEach((s=>{const t=path.join(e,s);fs.existsSync(t)&&fs.unlinkSync(t)}))}if(!e.websocket){const e=path.join(s,"src","lib","websocket");fs.existsSync(e)&&fs.rmSync(e,{recursive:!0,force:!0});const t=path.join(s,"settings");["restartWebsocket.cjs","restart_websocket.bat"].forEach((e=>{const s=path.join(t,e);fs.existsSync(s)&&fs.unlinkSync(s)}))}}catch(e){process.exit(1)}}main();
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Lib\PHPMailer;
|
|
4
|
+
|
|
5
|
+
use PHPMailer\PHPMailer\PHPMailer;
|
|
6
|
+
use PHPMailer\PHPMailer\Exception;
|
|
7
|
+
use Lib\Prisma\Classes\Validator;
|
|
8
|
+
use Dotenv\Dotenv;
|
|
9
|
+
|
|
10
|
+
class Mailer
|
|
11
|
+
{
|
|
12
|
+
private PHPMailer $mail;
|
|
13
|
+
private Validator $validator;
|
|
14
|
+
|
|
15
|
+
public function __construct()
|
|
16
|
+
{
|
|
17
|
+
$dotenv = Dotenv::createImmutable(\DOCUMENT_PATH);
|
|
18
|
+
$dotenv->load();
|
|
19
|
+
|
|
20
|
+
$this->mail = new PHPMailer(true);
|
|
21
|
+
$this->setup();
|
|
22
|
+
|
|
23
|
+
$this->validator = new Validator();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private function setup(): void
|
|
27
|
+
{
|
|
28
|
+
$this->mail->isSMTP();
|
|
29
|
+
$this->mail->SMTPDebug = 0;
|
|
30
|
+
$this->mail->Host = $_ENV['SMTP_HOST'];
|
|
31
|
+
$this->mail->SMTPAuth = true;
|
|
32
|
+
$this->mail->Username = $_ENV['SMTP_USERNAME'];
|
|
33
|
+
$this->mail->Password = $_ENV['SMTP_PASSWORD'];
|
|
34
|
+
$this->mail->SMTPSecure = $_ENV['SMTP_ENCRYPTION'];
|
|
35
|
+
$this->mail->Port = (int) $_ENV['SMTP_PORT'];
|
|
36
|
+
$this->mail->setFrom($_ENV['MAIL_FROM'], $_ENV['MAIL_FROM_NAME']);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Send an email.
|
|
41
|
+
*
|
|
42
|
+
* @param string $to The recipient's email address.
|
|
43
|
+
* @param string $subject The subject of the email.
|
|
44
|
+
* @param string $body The HTML body of the email.
|
|
45
|
+
* @param string $name (optional) The name of the recipient.
|
|
46
|
+
* @param string $altBody (optional) The plain text alternative body of the email.
|
|
47
|
+
*
|
|
48
|
+
* @return bool Returns true if the email is sent successfully, false otherwise.
|
|
49
|
+
*
|
|
50
|
+
* @throws Exception Throws an exception if the email could not be sent.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* $mailer = new Mailer();
|
|
54
|
+
* $to = 'recipient@example.com';
|
|
55
|
+
* $subject = 'Hello';
|
|
56
|
+
* $body = '<h1>Example Email</h1><p>This is the HTML body of the email.</p>';
|
|
57
|
+
* $name = 'John Doe';
|
|
58
|
+
* $altBody = 'This is the plain text alternative body of the email.';
|
|
59
|
+
*
|
|
60
|
+
* try {
|
|
61
|
+
* $result = $mailer->send($to, $subject, $body, $name, $altBody);
|
|
62
|
+
* if ($result) {
|
|
63
|
+
* echo 'Email sent successfully.';
|
|
64
|
+
* } else {
|
|
65
|
+
* echo 'Failed to send email.';
|
|
66
|
+
* }
|
|
67
|
+
* } catch (Exception $e) {
|
|
68
|
+
* echo 'An error occurred: ' . $e->getMessage();
|
|
69
|
+
* }
|
|
70
|
+
*/
|
|
71
|
+
public function send(string $to, string $subject, string $body, string $name = '', string $altBody = ''): bool
|
|
72
|
+
{
|
|
73
|
+
try {
|
|
74
|
+
$this->validator->validateString($to);
|
|
75
|
+
$this->validator->validateString($subject);
|
|
76
|
+
$this->validator->validateString($body);
|
|
77
|
+
$this->validator->validateString($name);
|
|
78
|
+
$this->validator->validateString($altBody);
|
|
79
|
+
|
|
80
|
+
$this->mail->addAddress($to, $name);
|
|
81
|
+
$this->mail->isHTML(true);
|
|
82
|
+
$this->mail->Subject = $subject;
|
|
83
|
+
$this->mail->Body = $body;
|
|
84
|
+
$this->mail->AltBody = $altBody;
|
|
85
|
+
|
|
86
|
+
return $this->mail->send();
|
|
87
|
+
} catch (\Exception) {
|
|
88
|
+
echo "Message could not be sent. Mailer Error: {$this->mail->ErrorInfo}";
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
package/package.json
CHANGED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
//Import PHPMailer classes into the global namespace
|
|
3
|
-
//These must be at the top of your script, not inside a function
|
|
4
|
-
use PHPMailer\PHPMailer\PHPMailer;
|
|
5
|
-
use PHPMailer\PHPMailer\SMTP;
|
|
6
|
-
use PHPMailer\PHPMailer\Exception;
|
|
7
|
-
|
|
8
|
-
//Load Composer's autoloader
|
|
9
|
-
require 'vendor/autoload.php';
|
|
10
|
-
|
|
11
|
-
//Create an instance; passing `true` enables exceptions
|
|
12
|
-
$mail = new PHPMailer(true);
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
//Server settings
|
|
16
|
-
$mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
|
|
17
|
-
$mail->isSMTP(); //Send using SMTP
|
|
18
|
-
$mail->Host = 'smtp.example.com'; //Set the SMTP server to send through
|
|
19
|
-
$mail->SMTPAuth = true; //Enable SMTP authentication
|
|
20
|
-
$mail->Username = 'user@example.com'; //SMTP username
|
|
21
|
-
$mail->Password = 'secret'; //SMTP password
|
|
22
|
-
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
|
|
23
|
-
$mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
|
|
24
|
-
|
|
25
|
-
//Recipients
|
|
26
|
-
$mail->setFrom('from@example.com', 'Mailer');
|
|
27
|
-
$mail->addAddress('joe@example.net', 'Joe User'); //Add a recipient
|
|
28
|
-
$mail->addAddress('ellen@example.com'); //Name is optional
|
|
29
|
-
$mail->addReplyTo('info@example.com', 'Information');
|
|
30
|
-
$mail->addCC('cc@example.com');
|
|
31
|
-
$mail->addBCC('bcc@example.com');
|
|
32
|
-
|
|
33
|
-
//Attachments
|
|
34
|
-
$mail->addAttachment('/var/tmp/file.tar.gz'); //Add attachments
|
|
35
|
-
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name
|
|
36
|
-
|
|
37
|
-
//Content
|
|
38
|
-
$mail->isHTML(true); //Set email format to HTML
|
|
39
|
-
$mail->Subject = 'Here is the subject';
|
|
40
|
-
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
|
|
41
|
-
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
|
|
42
|
-
|
|
43
|
-
$mail->send();
|
|
44
|
-
echo 'Message has been sent';
|
|
45
|
-
} catch (\Exception $e) {
|
|
46
|
-
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
|
|
47
|
-
}
|