@palettelab/cli 0.3.27 → 0.3.28

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/lib/bundler.js +38 -18
  2. package/package.json +1 -1
package/lib/bundler.js CHANGED
@@ -132,28 +132,48 @@ async function bundleBackend(pluginDir) {
132
132
  pluginDir = path.resolve(pluginDir)
133
133
  const { spawnSync } = require("child_process")
134
134
  const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "palette-bundle-"))
135
+ const stage = path.join(tmp, "stage")
135
136
  const outPath = path.join(tmp, "backend.tar.gz")
136
137
 
137
- const includes = []
138
- if (fs.existsSync(path.join(pluginDir, "backend"))) includes.push("backend")
139
- for (const metadataFile of ["package.json", "pyproject.toml"]) {
140
- if (fs.existsSync(path.join(pluginDir, metadataFile))) includes.push(metadataFile)
141
- }
142
- includes.push("palette-plugin.json")
138
+ try {
139
+ fs.mkdirSync(stage, { recursive: true })
140
+ const copy = (from, to) => {
141
+ fs.cpSync(from, to, {
142
+ recursive: true,
143
+ filter(src) {
144
+ const parts = src.split(path.sep)
145
+ return !parts.includes("__pycache__") && !parts.includes(".venv")
146
+ },
147
+ })
148
+ }
143
149
 
144
- const result = spawnSync(
145
- "tar",
146
- ["-czf", outPath, ...includes.flatMap((f) => ["--exclude=__pycache__", "--exclude=.venv"]), ...includes],
147
- { cwd: pluginDir, stdio: "pipe" },
148
- )
149
- if (result.status !== 0) {
150
- throw new Error(
151
- `tar failed (exit ${result.status}): ${result.stderr?.toString() || "unknown error"}`,
152
- )
150
+ const backendDir = path.join(pluginDir, "backend")
151
+ if (fs.existsSync(backendDir)) copy(backendDir, path.join(stage, "backend"))
152
+ for (const metadataFile of ["package.json", "pyproject.toml", "palette-plugin.json"]) {
153
+ const src = path.join(pluginDir, metadataFile)
154
+ if (fs.existsSync(src)) fs.copyFileSync(src, path.join(stage, metadataFile))
155
+ }
156
+
157
+ const sdkDir = path.resolve(__dirname, "..", "backend-sdk", "palette_sdk")
158
+ const targetSdkDir = path.join(stage, "backend", "palette_sdk")
159
+ if (fs.existsSync(sdkDir) && fs.existsSync(path.join(stage, "backend"))) {
160
+ copy(sdkDir, targetSdkDir)
161
+ }
162
+
163
+ const includes = fs.readdirSync(stage)
164
+ const result = spawnSync("tar", ["-czf", outPath, ...includes], {
165
+ cwd: stage,
166
+ stdio: "pipe",
167
+ })
168
+ if (result.status !== 0) {
169
+ throw new Error(
170
+ `tar failed (exit ${result.status}): ${result.stderr?.toString() || "unknown error"}`,
171
+ )
172
+ }
173
+ return fs.readFileSync(outPath)
174
+ } finally {
175
+ fs.rmSync(tmp, { recursive: true, force: true })
153
176
  }
154
- const buf = fs.readFileSync(outPath)
155
- fs.rmSync(tmp, { recursive: true, force: true })
156
- return buf
157
177
  }
158
178
 
159
179
  module.exports = { bundleFrontend, bundleBackend, watchFrontend }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@palettelab/cli",
3
- "version": "0.3.27",
3
+ "version": "0.3.28",
4
4
  "description": "Developer CLI for building Palette platform plugins — no platform source access required.",
5
5
  "bin": {
6
6
  "pltt": "bin/pltt.js"