@antigenic-oss/paint 0.2.3 → 0.2.4
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/README.md +21 -0
- package/bin/postinstall.js +89 -0
- package/package.json +2 -1
- package/tsconfig.json +1 -0
package/README.md
CHANGED
|
@@ -48,6 +48,27 @@ bun add -g @antigenic-oss/paint
|
|
|
48
48
|
|
|
49
49
|
Requires Node.js `>=20.9.0`.
|
|
50
50
|
|
|
51
|
+
If `paint` is not found after install, add your global bin directory to `PATH`
|
|
52
|
+
once:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Bun
|
|
56
|
+
echo 'export PATH="$HOME/.bun/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc
|
|
57
|
+
|
|
58
|
+
# npm (uses npm global prefix)
|
|
59
|
+
echo 'export PATH="$(npm config get prefix)/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc
|
|
60
|
+
|
|
61
|
+
# pnpm
|
|
62
|
+
pnpm setup
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
After install, run:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
paint help
|
|
69
|
+
paint start
|
|
70
|
+
```
|
|
71
|
+
|
|
51
72
|
Then use:
|
|
52
73
|
|
|
53
74
|
```bash
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const path = require('node:path')
|
|
4
|
+
const fs = require('node:fs')
|
|
5
|
+
const { spawnSync } = require('node:child_process')
|
|
6
|
+
|
|
7
|
+
function detectRcFile() {
|
|
8
|
+
const shell = process.env.SHELL || ''
|
|
9
|
+
const home = process.env.HOME || '~'
|
|
10
|
+
const base = path.basename(shell)
|
|
11
|
+
|
|
12
|
+
if (base === 'zsh') return `${home}/.zshrc`
|
|
13
|
+
if (base === 'bash') return `${home}/.bashrc`
|
|
14
|
+
if (base === 'fish') return `${home}/.config/fish/config.fish`
|
|
15
|
+
return `${home}/.profile`
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function shouldPrintHint() {
|
|
19
|
+
const isGlobal = process.env.npm_config_global === 'true'
|
|
20
|
+
const ua = process.env.npm_config_user_agent || ''
|
|
21
|
+
const isBun = ua.includes('bun/')
|
|
22
|
+
return isGlobal || isBun
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function resolveNextBin(appRoot) {
|
|
26
|
+
const directPath = path.join(
|
|
27
|
+
appRoot,
|
|
28
|
+
'node_modules',
|
|
29
|
+
'next',
|
|
30
|
+
'dist',
|
|
31
|
+
'bin',
|
|
32
|
+
'next',
|
|
33
|
+
)
|
|
34
|
+
if (fs.existsSync(directPath)) {
|
|
35
|
+
return directPath
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
return require.resolve('next/dist/bin/next', { paths: [appRoot] })
|
|
40
|
+
} catch {
|
|
41
|
+
return null
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function tryWarmBuild() {
|
|
46
|
+
if (process.env.PAINT_SKIP_POSTINSTALL_BUILD === '1') {
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const appRoot = path.resolve(__dirname, '..')
|
|
51
|
+
const buildIdPath = path.join(appRoot, '.next', 'BUILD_ID')
|
|
52
|
+
if (fs.existsSync(buildIdPath)) {
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const nextBin = resolveNextBin(appRoot)
|
|
57
|
+
if (!nextBin) {
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
console.log('@antigenic-oss/paint: prebuilding runtime (webpack)...')
|
|
62
|
+
const result = spawnSync(
|
|
63
|
+
process.execPath,
|
|
64
|
+
[nextBin, 'build', '--webpack'],
|
|
65
|
+
{
|
|
66
|
+
cwd: appRoot,
|
|
67
|
+
env: process.env,
|
|
68
|
+
stdio: 'inherit',
|
|
69
|
+
},
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
// Keep install resilient across package managers/environments where
|
|
73
|
+
// install-time build is unsupported; first-run build remains as fallback.
|
|
74
|
+
if (result.status !== 0) {
|
|
75
|
+
console.warn(
|
|
76
|
+
'@antigenic-oss/paint: postinstall prebuild failed, will build on first `paint start`.',
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
tryWarmBuild()
|
|
82
|
+
|
|
83
|
+
if (shouldPrintHint()) {
|
|
84
|
+
const rcFile = detectRcFile()
|
|
85
|
+
const exportLine = 'export PATH="$HOME/.bun/bin:$PATH"'
|
|
86
|
+
console.log('\n@antigenic-oss/paint: if `paint` is not found, run:')
|
|
87
|
+
console.log(`echo '${exportLine}' >> ${rcFile} && source ${rcFile}`)
|
|
88
|
+
console.log('Then run: paint help\n')
|
|
89
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antigenic-oss/paint",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
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",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"dev:terminal": "node ./bin/terminal-server.js",
|
|
47
47
|
"dev:all": "node ./bin/terminal-server.js & node ./bin/bridge-server.js & next dev --port 4000 --turbopack",
|
|
48
48
|
"bridge": "node ./bin/bridge-server.js",
|
|
49
|
+
"postinstall": "node ./bin/postinstall.js",
|
|
49
50
|
"build": "next build",
|
|
50
51
|
"start": "next start --port 4000",
|
|
51
52
|
"lint": "biome lint .",
|