routesync 1.0.39 → 1.0.41
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/dist/cli.js +12 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9582,7 +9582,6 @@ var watchCommand = new Command("watch").description("Watch routes file and re-sy
|
|
|
9582
9582
|
var import_child_process2 = require("child_process");
|
|
9583
9583
|
var import_fs_extra16 = __toESM(require_lib());
|
|
9584
9584
|
var import_path12 = __toESM(require("path"));
|
|
9585
|
-
var import_os = __toESM(require("os"));
|
|
9586
9585
|
var annotateCommand = new Command("annotate").description("Auto-inject #[Response] PHP 8 attributes into controller methods based on Resource discovery").option("--input <file>", "Path to routes/api.php", "routes/api.php").option("--dry-run", "Preview changes without writing files").option("--force", "Re-annotate methods that already have #[Response]").action(async (options) => {
|
|
9587
9586
|
const filePath = import_path12.default.resolve(options.input);
|
|
9588
9587
|
if (!import_fs_extra16.default.existsSync(filePath)) {
|
|
@@ -9717,7 +9716,7 @@ foreach ($routes as $route) {
|
|
|
9717
9716
|
|
|
9718
9717
|
echo json_encode($result);
|
|
9719
9718
|
`;
|
|
9720
|
-
const tmpFile = import_path12.default.join(
|
|
9719
|
+
const tmpFile = import_path12.default.join(projectRoot, `routesync-annotate-${Date.now()}.php`);
|
|
9721
9720
|
import_fs_extra16.default.writeFileSync(tmpFile, phpScript);
|
|
9722
9721
|
let annotations;
|
|
9723
9722
|
try {
|
|
@@ -9725,17 +9724,24 @@ echo json_encode($result);
|
|
|
9725
9724
|
annotations = JSON.parse(output);
|
|
9726
9725
|
} catch (e) {
|
|
9727
9726
|
console.error("\u274C PHP execution failed. Make sure PHP is available and database is accessible.");
|
|
9728
|
-
|
|
9729
|
-
|
|
9727
|
+
if (e && typeof e === "object" && "stderr" in e) {
|
|
9728
|
+
console.error("PHP error output:");
|
|
9729
|
+
console.error(e.stderr);
|
|
9730
|
+
}
|
|
9731
|
+
if (e && typeof e === "object" && "stdout" in e) {
|
|
9732
|
+
const stdout = e.stdout;
|
|
9733
|
+
if (stdout) console.error("PHP stdout:", stdout);
|
|
9734
|
+
}
|
|
9735
|
+
console.error("Temp script preserved at:", tmpFile);
|
|
9730
9736
|
process.exit(1);
|
|
9731
9737
|
}
|
|
9732
9738
|
import_fs_extra16.default.removeSync(tmpFile);
|
|
9733
|
-
if (annotations.length === 0) {
|
|
9739
|
+
if (!annotations || annotations.length === 0) {
|
|
9734
9740
|
console.log("\u2714 No methods to annotate \u2014 all routes already annotated or no Resources detected.");
|
|
9735
9741
|
return;
|
|
9736
9742
|
}
|
|
9737
9743
|
const byFile = /* @__PURE__ */ new Map();
|
|
9738
|
-
for (const ann of annotations) {
|
|
9744
|
+
for (const ann of annotations ?? []) {
|
|
9739
9745
|
const existing = byFile.get(ann.controllerFile) ?? [];
|
|
9740
9746
|
if (!existing.find((e) => e.methodName === ann.methodName)) {
|
|
9741
9747
|
existing.push(ann);
|