projax 1.3.3 → 1.3.5

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.
Files changed (2) hide show
  1. package/dist/index.js +17 -59
  2. package/package.json +2 -4
package/dist/index.js CHANGED
@@ -744,17 +744,30 @@ program
744
744
  await ensureAPIServerRunning(false);
745
745
  // Check for bundled Desktop app first (in dist/desktop when installed globally)
746
746
  // Then check for local development (packages/cli/dist -> packages/desktop)
747
- const bundledDesktopPath = path.join(__dirname, 'desktop');
748
- const bundledDesktopMain = path.join(bundledDesktopPath, 'main.js');
747
+ // Support both legacy "desktop" folder and current "electron" bundle folder
748
+ const bundledDesktopPathCandidates = [
749
+ path.join(__dirname, 'desktop'),
750
+ path.join(__dirname, 'electron'),
751
+ ];
752
+ let bundledDesktopPath = null;
753
+ let bundledDesktopMain = null;
754
+ for (const candidate of bundledDesktopPathCandidates) {
755
+ const mainCandidate = path.join(candidate, 'main.js');
756
+ if (fs.existsSync(mainCandidate)) {
757
+ bundledDesktopPath = candidate;
758
+ bundledDesktopMain = mainCandidate;
759
+ break;
760
+ }
761
+ }
749
762
  const localDesktopPath = path.join(__dirname, '..', '..', 'desktop');
750
763
  const localDesktopMain = path.join(localDesktopPath, 'dist', 'main.js');
751
764
  // Check if bundled desktop exists (global install)
752
- const hasBundledDesktop = fs.existsSync(bundledDesktopMain);
765
+ const hasBundledDesktop = Boolean(bundledDesktopPath && bundledDesktopMain);
753
766
  // Check if local desktop exists (development mode)
754
767
  const isLocalDev = fs.existsSync(localDesktopPath) && fs.existsSync(path.join(localDesktopPath, 'package.json'));
755
768
  let desktopPackagePath;
756
769
  let desktopMainPath;
757
- if (hasBundledDesktop) {
770
+ if (bundledDesktopPath && bundledDesktopMain) {
758
771
  // Bundled Desktop app (global install)
759
772
  desktopPackagePath = bundledDesktopPath;
760
773
  desktopMainPath = bundledDesktopMain;
@@ -863,61 +876,6 @@ program
863
876
  // Ensure NODE_ENV is not set to development when using bundled files
864
877
  process.env.NODE_ENV = 'production';
865
878
  }
866
- // Automatically rebuild better-sqlite3 for Desktop/Electron if needed
867
- // This ensures it's compiled for Electron's Node.js version
868
- if (hasBundledDesktop) {
869
- try {
870
- const electronPkg = require('electron/package.json');
871
- let rebuild;
872
- try {
873
- rebuild = require('@electron/rebuild').rebuild;
874
- }
875
- catch {
876
- // @electron/rebuild not available, skip auto-rebuild
877
- }
878
- if (rebuild) {
879
- const sqlitePath = require.resolve('better-sqlite3');
880
- // Find the package root - better-sqlite3 is in projax/node_modules/better-sqlite3
881
- // Path structure: projax/node_modules/better-sqlite3/lib/index.js
882
- // So we need to go: sqlitePath -> lib -> better-sqlite3 -> node_modules -> projax (package root)
883
- const sqliteDir = path.dirname(sqlitePath); // .../better-sqlite3/lib
884
- const betterSqlite3Dir = path.dirname(sqliteDir); // .../better-sqlite3
885
- const nodeModulesDir = path.dirname(betterSqlite3Dir); // .../node_modules
886
- // The package root is the directory containing node_modules (i.e., projax package root)
887
- const packageRoot = path.dirname(nodeModulesDir); // .../projax
888
- console.log('Ensuring better-sqlite3 is built for Desktop/Electron...');
889
- try {
890
- await new Promise((resolve, reject) => {
891
- rebuild({
892
- buildPath: packageRoot,
893
- electronVersion: electronPkg.version,
894
- onlyModules: ['better-sqlite3'],
895
- force: true,
896
- })
897
- .then(() => {
898
- console.log('✓ better-sqlite3 ready for Desktop/Electron');
899
- resolve();
900
- })
901
- .catch((err) => {
902
- // Don't fail if rebuild has issues, just warn
903
- console.warn('⚠️ Could not rebuild better-sqlite3 automatically:', err.message);
904
- console.warn(' The app may still work, but if you see errors, run:');
905
- console.warn(` cd ${packageRoot}`);
906
- console.warn(' npm rebuild better-sqlite3 --build-from-source');
907
- resolve(); // Continue anyway
908
- });
909
- });
910
- }
911
- catch (rebuildError) {
912
- // Continue even if rebuild fails
913
- console.warn('⚠️ Rebuild check failed, continuing anyway...');
914
- }
915
- }
916
- }
917
- catch (checkError) {
918
- // If we can't check, just continue - the error will show when Desktop app tries to use it
919
- }
920
- }
921
879
  console.log('Starting Desktop app...');
922
880
  const { spawn } = require('child_process');
923
881
  const electron = require('electron');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "projax",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "CLI tool for managing local development projects",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -21,9 +21,7 @@
21
21
  "electron": "^28.0.0",
22
22
  "inquirer": "^9.2.12",
23
23
  "express": "^4.18.2",
24
- "cors": "^2.8.5",
25
- "better-sqlite3": "^11.10.0",
26
- "@electron/rebuild": "^3.6.0"
24
+ "cors": "^2.8.5"
27
25
  },
28
26
  "devDependencies": {
29
27
  "@types/inquirer": "^9.0.7",