@antigenic-oss/paint 0.2.1 → 0.2.3

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,9 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const path = require('node:path')
4
+ const fs = require('node:fs')
4
5
  const { spawn, spawnSync } = require('node:child_process')
5
6
 
6
- const APP_ROOT = path.resolve(__dirname, '..')
7
+ const ENTRY_REAL_PATH = fs.realpathSync(__filename)
8
+ const APP_ROOT = path.resolve(path.dirname(ENTRY_REAL_PATH), '..')
7
9
  const TSX_CLI = path.join(APP_ROOT, 'node_modules', 'tsx', 'dist', 'cli.mjs')
8
10
 
9
11
  const nodeCheck = spawnSync(process.execPath, ['--version'], {
@@ -14,7 +16,7 @@ if (nodeCheck.status !== 0) {
14
16
  process.exit(1)
15
17
  }
16
18
 
17
- if (!require('node:fs').existsSync(TSX_CLI)) {
19
+ if (!fs.existsSync(TSX_CLI)) {
18
20
  console.error(
19
21
  'Missing runtime dependency: tsx. Reinstall @antigenic-oss/paint.',
20
22
  )
package/bin/paint.js CHANGED
@@ -7,7 +7,8 @@ const http = require('node:http')
7
7
  const https = require('node:https')
8
8
  const { spawn, spawnSync } = require('node:child_process')
9
9
 
10
- const APP_ROOT = path.resolve(__dirname, '..')
10
+ const ENTRY_REAL_PATH = fs.realpathSync(__filename)
11
+ const APP_ROOT = path.resolve(path.dirname(ENTRY_REAL_PATH), '..')
11
12
  const STATE_DIR = path.join(os.homedir(), '.paint')
12
13
 
13
14
  const APP_STATE_FILE = path.join(STATE_DIR, 'server.json')
@@ -18,14 +19,27 @@ const WEB_LOG_FILE = path.join(STATE_DIR, 'web.log')
18
19
  const TERMINAL_LOG_FILE = path.join(STATE_DIR, 'terminal.log')
19
20
  const BRIDGE_LOG_FILE = path.join(STATE_DIR, 'bridge.log')
20
21
 
21
- const NEXT_BIN = path.join(
22
- APP_ROOT,
23
- 'node_modules',
24
- 'next',
25
- 'dist',
26
- 'bin',
27
- 'next',
28
- )
22
+ function resolveNextBin() {
23
+ const directPath = path.join(
24
+ APP_ROOT,
25
+ 'node_modules',
26
+ 'next',
27
+ 'dist',
28
+ 'bin',
29
+ 'next',
30
+ )
31
+ if (fs.existsSync(directPath)) {
32
+ return directPath
33
+ }
34
+
35
+ try {
36
+ return require.resolve('next/dist/bin/next', { paths: [APP_ROOT] })
37
+ } catch {
38
+ return null
39
+ }
40
+ }
41
+
42
+ const NEXT_BIN = resolveNextBin()
29
43
  const TERMINAL_SERVER_BIN = path.join(APP_ROOT, 'bin', 'terminal-server.js')
30
44
  const BRIDGE_SERVER_BIN = path.join(APP_ROOT, 'bin', 'bridge-server.js')
31
45
 
@@ -236,10 +250,11 @@ async function waitForHttp(url, timeoutMs = 30000, validator) {
236
250
  }
237
251
 
238
252
  function ensureNextInstalled() {
239
- if (!fs.existsSync(NEXT_BIN)) {
253
+ if (!NEXT_BIN || !fs.existsSync(NEXT_BIN)) {
240
254
  console.error(
241
255
  'pAInt runtime is missing Next.js binaries. Reinstall the package.',
242
256
  )
257
+ console.error(`Resolved app root: ${APP_ROOT}`)
243
258
  process.exit(1)
244
259
  }
245
260
  }
@@ -256,7 +271,9 @@ function ensureBuilt(forceRebuild) {
256
271
  console.log(
257
272
  forceRebuild ? 'Rebuilding pAInt…' : 'Building pAInt for first run…',
258
273
  )
259
- const result = spawnSync(process.execPath, [NEXT_BIN, 'build'], {
274
+ // Use webpack for packaged/global runtime builds.
275
+ // Turbopack can fail when the app lives under node_modules.
276
+ const result = spawnSync(process.execPath, [NEXT_BIN, 'build', '--webpack'], {
260
277
  cwd: APP_ROOT,
261
278
  env: process.env,
262
279
  stdio: 'inherit',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antigenic-oss/paint",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Visual editor for localhost web projects with a global paint CLI",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/Antigenic-OSS/pAInt",