create-prisma-php-app 1.22.506 → 1.22.508

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.
@@ -1,203 +0,0 @@
1
- import { exec, spawn } from "child_process";
2
- import chalk from "chalk";
3
- import { writeFileSync } from "fs";
4
- import readline from "readline";
5
-
6
- const BROWSERSYNC_PREFIX = "[Browsersync]";
7
- const REGEX_PATTERNS = {
8
- BROWSERSYNC: /^\[Browsersync\]\s*(.+)$/,
9
- PROXYING: /Proxying/,
10
- ACCESS_URLS: /Access URLs:/,
11
- LOCAL_URL: /Local:\s*(http:\/\/.+)/,
12
- EXTERNAL_URL: /External:\s*(http:\/\/\S+)/,
13
- UI_URL: /UI:\s*(http:\/\/.+)/,
14
- UI_EXTERNAL_URL: /UI External:\s*(http:\/\/.+)/,
15
- WATCHING_FILES: /Watching files/,
16
- };
17
-
18
- async function runCommand(command, options = {}) {
19
- return new Promise((resolve, reject) => {
20
- const process = exec(command, options);
21
-
22
- let stdout = "";
23
- let stderr = "";
24
-
25
- process.stdout.on("data", (data) => {
26
- stdout += data;
27
- });
28
-
29
- process.stderr.on("data", (data) => {
30
- stderr += data;
31
- });
32
-
33
- process.on("close", (code) => {
34
- if (code === 0) {
35
- resolve({ stdout, stderr });
36
- } else {
37
- reject(
38
- new Error(`Command "${command}" exited with code ${code}\n${stderr}`)
39
- );
40
- }
41
- });
42
- });
43
- }
44
-
45
- async function startDev() {
46
- let browserSync;
47
- let devProcess;
48
- try {
49
- // Step 1: Start projectName and wait for it to complete
50
- console.log("Starting projectName...");
51
- const projectName = await runCommand("npm run projectName");
52
- console.log(projectName.stdout);
53
-
54
- // Step 2: Start browserSync and process its output
55
- console.log("Starting browser-sync...");
56
- browserSync = spawn("npm", ["run", "browserSync"], { shell: true });
57
-
58
- const formattedLog = {
59
- local: "",
60
- external: "",
61
- ui: "",
62
- uiExternal: "",
63
- };
64
-
65
- const rl = readline.createInterface({
66
- input: browserSync.stdout,
67
- crlfDelay: Infinity,
68
- });
69
-
70
- let browserSyncReady = false;
71
-
72
- rl.on("line", (line) => {
73
- if (REGEX_PATTERNS.PROXYING.test(line)) {
74
- const match = line.match(REGEX_PATTERNS.BROWSERSYNC);
75
- if (match) {
76
- console.log(`${chalk.blue(BROWSERSYNC_PREFIX)} ${match[1]}`);
77
- }
78
- } else if (REGEX_PATTERNS.ACCESS_URLS.test(line)) {
79
- const match = line.match(REGEX_PATTERNS.BROWSERSYNC);
80
- if (match) {
81
- console.log(`${chalk.blue(BROWSERSYNC_PREFIX)} ${match[1]}`);
82
- }
83
- } else if (REGEX_PATTERNS.LOCAL_URL.test(line)) {
84
- const match = line.match(REGEX_PATTERNS.LOCAL_URL);
85
- if (match) {
86
- const localUrl = match[1];
87
- formattedLog.local = localUrl;
88
- console.log(`${chalk.white("Local: ")}${chalk.cyanBright(localUrl)}`);
89
- }
90
- } else if (/^ {4}External:/.test(line)) {
91
- const match = line.match(REGEX_PATTERNS.EXTERNAL_URL);
92
- if (match) {
93
- const externalUrl = match[1];
94
- formattedLog.external = externalUrl;
95
- console.log(
96
- `${chalk.white("External: ")}${chalk.magentaBright(externalUrl)}`
97
- );
98
- }
99
- } else if (REGEX_PATTERNS.UI_URL.test(line)) {
100
- const match = line.match(REGEX_PATTERNS.UI_URL);
101
- if (match) {
102
- const uiUrl = match[1];
103
- formattedLog.ui = uiUrl;
104
- console.log(`${chalk.yellow("UI: ")}${chalk.cyanBright(uiUrl)}`);
105
- }
106
- } else if (REGEX_PATTERNS.UI_EXTERNAL_URL.test(line)) {
107
- const match = line.match(REGEX_PATTERNS.UI_EXTERNAL_URL);
108
- if (match) {
109
- const uiExternalUrl = match[1];
110
- formattedLog.uiExternal = uiExternalUrl;
111
- console.log(
112
- `${chalk.yellow("UI External: ")}${chalk.magentaBright(
113
- uiExternalUrl
114
- )}`
115
- );
116
- }
117
- } else if (REGEX_PATTERNS.WATCHING_FILES.test(line)) {
118
- console.log(`${chalk.blue(BROWSERSYNC_PREFIX)} Watching files...`);
119
- const outputPath = "./settings/bs-output.json";
120
- writeFileSync(
121
- outputPath,
122
- JSON.stringify(formattedLog, null, 2),
123
- "utf-8"
124
- );
125
- console.log(`Browser-sync output saved to ${outputPath}`);
126
-
127
- if (!browserSyncReady) {
128
- browserSyncReady = true;
129
- // Start _dev after browserSync is ready
130
- startDevProcess();
131
- }
132
- } else if (REGEX_PATTERNS.BROWSERSYNC.test(line)) {
133
- const match = line.match(REGEX_PATTERNS.BROWSERSYNC);
134
- if (match) {
135
- console.log(`${chalk.blue(BROWSERSYNC_PREFIX)} ${match[1]}`);
136
- }
137
- } else {
138
- // Print any other notifications
139
- console.log(line);
140
- }
141
- });
142
-
143
- browserSync.stderr.on("data", (data) => {
144
- console.error(`browser-sync error: ${data.toString()}`);
145
- });
146
-
147
- browserSync.on("error", (err) => {
148
- console.error(`Failed to start browserSync process: ${err.message}`);
149
- });
150
-
151
- // Function to start npmRunAll process
152
- function startDevProcess() {
153
- console.log("Starting npmRunAll...");
154
- devProcess = spawn("npm", ["run", "npmRunAll"], { shell: true });
155
-
156
- devProcess.stdout.on("data", (data) => {
157
- process.stdout.write(data);
158
- });
159
-
160
- devProcess.stderr.on("data", (data) => {
161
- process.stderr.write(data);
162
- });
163
-
164
- devProcess.on("close", (code) => {
165
- console.log(`Dev process exited with code ${code}`);
166
- });
167
-
168
- devProcess.on("error", (err) => {
169
- console.error(`Failed to start dev process: ${err.message}`);
170
- });
171
- }
172
-
173
- // Handle browserSync close event
174
- browserSync.on("close", (code) => {
175
- console.log(`browserSync process exited with code ${code}`);
176
- });
177
-
178
- // Handle process exit and cleanup
179
- function handleExit() {
180
- if (browserSync) {
181
- browserSync.kill();
182
- }
183
- if (devProcess) {
184
- devProcess.kill();
185
- }
186
- }
187
-
188
- process.on("exit", handleExit);
189
- process.on("SIGINT", () => {
190
- handleExit();
191
- process.exit();
192
- });
193
- process.on("SIGTERM", () => {
194
- handleExit();
195
- process.exit();
196
- });
197
- } catch (error) {
198
- console.error("An error occurred:", error.message);
199
- process.exit(1);
200
- }
201
- }
202
-
203
- startDev();
@@ -1,89 +0,0 @@
1
- import swaggerJsdoc from "swagger-jsdoc";
2
- import { writeFileSync, readFileSync, existsSync } from "fs";
3
- import { fileURLToPath } from "url";
4
- import { join, dirname } from "path";
5
- import chalk from "chalk";
6
-
7
- // Define __dirname equivalent in ES modules
8
- const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = dirname(__filename);
10
-
11
- // Define the output path for the swagger.json file
12
- const outputPath = join(
13
- __dirname,
14
- "../src/app/swagger-docs/apis/pphp-swagger.json"
15
- );
16
-
17
- const bsConnectionInfo = join(__dirname, "bs-output.json");
18
-
19
- // Check if the bs-output.json file exists
20
- const defaultConnectionInfo = {
21
- local: "http://localhost:3000",
22
- external: "http://192.168.1.5:3000",
23
- ui: "http://localhost:3001",
24
- uiExternal: "http://192.168.1.5:3001",
25
- };
26
-
27
- let jsonData = defaultConnectionInfo;
28
-
29
- if (existsSync(bsConnectionInfo)) {
30
- try {
31
- const data = readFileSync(bsConnectionInfo, "utf8");
32
- jsonData = JSON.parse(data);
33
- } catch (error) {
34
- console.error("Error parsing bs-output.json:", error);
35
- }
36
- } else {
37
- console.warn("bs-output.json not found, using default connection info.");
38
- }
39
-
40
- const options = {
41
- definition: {
42
- openapi: "3.0.0",
43
- info: {
44
- title: "Prisma PHP API Documentation",
45
- version: "1.0.0",
46
- description: "API documentation for the Prisma PHP project",
47
- },
48
- servers: [
49
- {
50
- url: jsonData.local, // For Development
51
- description: "Development Server",
52
- },
53
- {
54
- url: "your-production-domain", // For Production
55
- description: "Production Server",
56
- },
57
- ],
58
- components: {
59
- securitySchemes: {
60
- bearerAuth: {
61
- type: "http",
62
- scheme: "bearer",
63
- bearerFormat: "JWT",
64
- },
65
- },
66
- },
67
- security: [
68
- {
69
- bearerAuth: [],
70
- },
71
- ],
72
- },
73
- apis: [join(__dirname, "../src/app/swagger-docs/apis/**/*.js")], // Path to your API routes
74
- };
75
-
76
- // Generate the Swagger specification
77
- const swaggerSpec = JSON.stringify(swaggerJsdoc(options), null, 2);
78
-
79
- // Always generate the swagger.json file
80
- try {
81
- writeFileSync(outputPath, swaggerSpec, "utf-8");
82
- console.log(
83
- `Swagger JSON has been generated and saved to ${chalk.blue(
84
- "src/app/swagger-docs/pphp-swagger.json"
85
- )}`
86
- );
87
- } catch (error) {
88
- console.error("Error saving Swagger JSON:", error);
89
- }