@antigenic-oss/paint 0.2.5 → 0.2.7

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/bin/paint.js CHANGED
@@ -22,6 +22,7 @@ const APP_VERSION = (() => {
22
22
  const RUNNING_FROM_NODE_MODULES = APP_ROOT.includes(
23
23
  `${path.sep}node_modules${path.sep}`,
24
24
  )
25
+ const RUNTIME_SCHEMA_VERSION = 2
25
26
  const RUNTIME_ROOT = RUNNING_FROM_NODE_MODULES
26
27
  ? path.join(STATE_DIR, 'runtime', APP_VERSION)
27
28
  : APP_ROOT
@@ -71,7 +72,25 @@ function ensureRuntimeRoot() {
71
72
  if (!RUNNING_FROM_NODE_MODULES) return APP_ROOT
72
73
 
73
74
  const stampFile = path.join(RUNTIME_ROOT, '.paint-runtime-stamp.json')
75
+ let needsRefresh = true
76
+
74
77
  if (fs.existsSync(stampFile)) {
78
+ try {
79
+ const stamp = JSON.parse(fs.readFileSync(stampFile, 'utf8'))
80
+ const hasConfigMjs = fs.existsSync(path.join(RUNTIME_ROOT, 'next.config.mjs'))
81
+ const hasLegacyConfigTs = fs.existsSync(
82
+ path.join(RUNTIME_ROOT, 'next.config.ts'),
83
+ )
84
+ needsRefresh =
85
+ stamp?.schemaVersion !== RUNTIME_SCHEMA_VERSION ||
86
+ !hasConfigMjs ||
87
+ hasLegacyConfigTs
88
+ } catch {
89
+ needsRefresh = true
90
+ }
91
+ }
92
+
93
+ if (!needsRefresh) {
75
94
  return RUNTIME_ROOT
76
95
  }
77
96
 
@@ -87,7 +106,7 @@ function ensureRuntimeRoot() {
87
106
  'public',
88
107
  'src',
89
108
  'next-env.d.ts',
90
- 'next.config.ts',
109
+ 'next.config.mjs',
91
110
  'postcss.config.mjs',
92
111
  'tsconfig.json',
93
112
  'package.json',
@@ -111,6 +130,7 @@ function ensureRuntimeRoot() {
111
130
  stampFile,
112
131
  JSON.stringify(
113
132
  {
133
+ schemaVersion: RUNTIME_SCHEMA_VERSION,
114
134
  version: APP_VERSION,
115
135
  sourceRoot: APP_ROOT,
116
136
  preparedAt: now(),
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('node:fs')
4
+ const os = require('node:os')
5
+ const path = require('node:path')
6
+ const { spawnSync } = require('node:child_process')
7
+
8
+ const APP_ROOT = path.resolve(__dirname, '..')
9
+ const PORT = '4210'
10
+
11
+ function runOrFail(cmd, args, opts = {}) {
12
+ const result = spawnSync(cmd, args, {
13
+ cwd: opts.cwd || APP_ROOT,
14
+ env: opts.env || process.env,
15
+ stdio: 'inherit',
16
+ })
17
+ if (result.status !== 0) {
18
+ process.exit(result.status || 1)
19
+ }
20
+ }
21
+
22
+ function run(cmd, args, opts = {}) {
23
+ return spawnSync(cmd, args, {
24
+ cwd: opts.cwd || APP_ROOT,
25
+ env: opts.env || process.env,
26
+ stdio: 'inherit',
27
+ })
28
+ }
29
+
30
+ function main() {
31
+ const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'paint-packed-smoke-'))
32
+ const packDir = path.join(tempRoot, 'pack')
33
+ const extractDir = path.join(tempRoot, 'extract')
34
+ const fakeHome = path.join(tempRoot, 'home')
35
+ fs.mkdirSync(packDir, { recursive: true })
36
+ fs.mkdirSync(extractDir, { recursive: true })
37
+ fs.mkdirSync(fakeHome, { recursive: true })
38
+
39
+ runOrFail('npm', ['pack', '--silent', '--pack-destination', packDir])
40
+
41
+ const tarball = fs
42
+ .readdirSync(packDir)
43
+ .find((name) => name.endsWith('.tgz'))
44
+ if (!tarball) {
45
+ console.error('Smoke test failed: npm pack produced no tarball.')
46
+ process.exit(1)
47
+ }
48
+
49
+ runOrFail('tar', ['-xzf', path.join(packDir, tarball), '-C', extractDir])
50
+
51
+ const packedRoot = path.join(extractDir, 'package')
52
+ const packedNodeModules = path.join(packedRoot, 'node_modules')
53
+ if (!fs.existsSync(packedNodeModules)) {
54
+ fs.symlinkSync(path.join(APP_ROOT, 'node_modules'), packedNodeModules, 'dir')
55
+ }
56
+
57
+ const env = {
58
+ ...process.env,
59
+ HOME: fakeHome,
60
+ USERPROFILE: fakeHome,
61
+ PAINT_SKIP_POSTINSTALL_BUILD: '1',
62
+ }
63
+
64
+ let started = false
65
+ try {
66
+ runOrFail('node', [path.join(packedRoot, 'bin', 'paint.js'), 'start', '--rebuild', '--port', PORT], {
67
+ cwd: packedRoot,
68
+ env,
69
+ })
70
+ started = true
71
+ } finally {
72
+ if (started) {
73
+ run('node', [path.join(packedRoot, 'bin', 'paint.js'), 'stop'], {
74
+ cwd: packedRoot,
75
+ env,
76
+ })
77
+ }
78
+ }
79
+ }
80
+
81
+ main()
@@ -1,6 +1,14 @@
1
- import type { NextConfig } from 'next'
1
+ import path from 'node:path'
2
+
3
+ const nextConfig = {
4
+ webpack(config) {
5
+ config.resolve = config.resolve || {}
6
+ config.resolve.alias = config.resolve.alias || {}
7
+ // Force runtime alias resolution even if tsconfig path loading is skipped.
8
+ config.resolve.alias['@'] = path.resolve(process.cwd(), 'src')
9
+ return config
10
+ },
2
11
 
3
- const nextConfig: NextConfig = {
4
12
  async headers() {
5
13
  return [
6
14
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antigenic-oss/paint",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
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",
@@ -26,7 +26,7 @@
26
26
  "public",
27
27
  "src",
28
28
  "next-env.d.ts",
29
- "next.config.ts",
29
+ "next.config.mjs",
30
30
  "postcss.config.mjs",
31
31
  "tsconfig.json",
32
32
  "README.md",
@@ -47,11 +47,13 @@
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
49
  "postinstall": "node ./bin/postinstall.js",
50
- "build": "next build",
50
+ "build": "next build --webpack",
51
51
  "start": "next start --port 4000",
52
52
  "lint": "biome lint .",
53
53
  "lint:fix": "biome lint --write .",
54
54
  "format": "biome format --write .",
55
+ "smoke:packed-global": "node ./bin/smoke-packed-global.js",
56
+ "prepublishOnly": "npm run smoke:packed-global",
55
57
  "changeset": "changeset",
56
58
  "version-packages": "changeset version",
57
59
  "release": "changeset publish"