@palettelab/cli 0.3.31 → 0.3.32

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 CHANGED
@@ -429,6 +429,9 @@ For developer sandboxes where manual approval should not block OS testing, run t
429
429
  `pltt sandbox --env staging` is the same hosted preview flow as
430
430
  `pltt dev --sandbox --env staging`.
431
431
 
432
+ `pltt preview --env staging` is also supported as a developer-friendly alias
433
+ for the same hosted preview flow.
434
+
432
435
  `pltt dev --platform` runs the full Docker `platform-dev` image for internal platform parity testing. App developers should not need it. It pulls `ghcr.io/palette-lab/platform-dev:latest` and mounts your plugin at `/plugins/<your-id>`.
433
436
 
434
437
  Environment variables:
@@ -462,6 +465,7 @@ Commands:
462
465
  ```bash
463
466
  pltt secrets init
464
467
  pltt secrets set STRIPE_SECRET --env staging --value sk_live_...
468
+ pltt secrets rotate STRIPE_SECRET --env staging --value sk_live_...
465
469
  pltt secrets list --env staging
466
470
  pltt publish --env staging --secrets-file plugin-secrets.env
467
471
  ```
package/lib/cli.js CHANGED
@@ -22,6 +22,10 @@ const COMMANDS = {
22
22
  run: (args, ctx) => dev([...args, "--sandbox"], ctx),
23
23
  help: "Publish a no-Docker hosted sandbox preview",
24
24
  },
25
+ preview: {
26
+ run: (args, ctx) => dev([...args, "--sandbox"], ctx),
27
+ help: "Alias for sandbox preview publish",
28
+ },
25
29
  login: { run: login, help: "Save a Palette sandbox environment for publish/dev preview" },
26
30
  doctor: {
27
31
  run: doctor,
@@ -76,12 +80,14 @@ function printHelp() {
76
80
  console.log("\nSecrets:")
77
81
  console.log(" pltt secrets init")
78
82
  console.log(" pltt secrets set NAME --value <secret> --env staging")
83
+ console.log(" pltt secrets rotate NAME --value <secret> --env staging")
79
84
  console.log(" pltt secrets list --env staging")
80
85
  console.log("\nExamples:")
81
86
  console.log(" pltt init my-app --template database")
82
87
  console.log(" pltt login --env staging --url https://sandbox.pltt.ai --token <token>")
83
88
  console.log(" cd my-app && pltt dev")
84
89
  console.log(" pltt sandbox --env staging")
90
+ console.log(" pltt preview --env staging")
85
91
  console.log(" pltt dev --sandbox --env staging")
86
92
  console.log(" pltt package")
87
93
  console.log(" pltt publish --env staging")
@@ -50,15 +50,17 @@ function loadFileValues(cwd, file) {
50
50
 
51
51
  async function run(args, { cwd }) {
52
52
  const [subcommand, ...tail] = args
53
- const manifest = loadManifest(cwd)
54
- const declared = declaredSecrets(manifest)
55
53
 
56
54
  if (!subcommand || subcommand === "help" || subcommand === "--help") {
57
55
  console.log("Usage: pltt secrets <init|list|set|rotate> [NAME] [--env staging]")
58
- console.log(" pltt secrets set NAME --value <secret> --env staging")
59
- console.log(" pltt secrets set NAME --secrets-file plugin-secrets.env --env staging")
60
- return
61
- }
56
+ console.log(" pltt secrets set NAME --value <secret> --env staging")
57
+ console.log(" pltt secrets set NAME --secrets-file plugin-secrets.env --env staging")
58
+ console.log(" pltt secrets rotate NAME --value <secret> --env staging")
59
+ return
60
+ }
61
+
62
+ const manifest = loadManifest(cwd)
63
+ const declared = declaredSecrets(manifest)
62
64
 
63
65
  if (subcommand === "init") {
64
66
  const result = initLocalEnv(cwd, manifest)
@@ -69,7 +71,7 @@ async function run(args, { cwd }) {
69
71
  }
70
72
 
71
73
  const { own, rest } = parseOwnFlags(tail)
72
- const { flags } = parseFlags(rest)
74
+ const { flags, rest: positional } = parseFlags(rest)
73
75
  let env
74
76
  try {
75
77
  env = resolveEnvironment({ cwd, flags })
@@ -96,7 +98,7 @@ async function run(args, { cwd }) {
96
98
  process.exit(1)
97
99
  }
98
100
 
99
- const name = rest.find((item) => !item.startsWith("-"))
101
+ const name = positional[0]
100
102
  if (!name) {
101
103
  console.error("[pltt] usage: pltt secrets set NAME --value <secret> [--env staging]")
102
104
  process.exit(1)
package/lib/secrets.js CHANGED
@@ -31,7 +31,15 @@ function readDotEnvFile(filePath) {
31
31
  return parseDotEnv(fs.readFileSync(filePath, "utf8"))
32
32
  }
33
33
 
34
- function writeDotEnvFile(filePath, values, manifest) {
34
+ function formatDotEnvValue(value) {
35
+ if (value === undefined || value === null) return ""
36
+ const str = String(value)
37
+ if (!str) return ""
38
+ if (/[\s#"'\\]/.test(str)) return JSON.stringify(str)
39
+ return str
40
+ }
41
+
42
+ function writeDotEnvFile(filePath, values, manifest, secretValues = {}) {
35
43
  const lines = [
36
44
  "# Palette local developer secrets.",
37
45
  "# This file is for pltt dev only and must not be committed.",
@@ -43,7 +51,7 @@ function writeDotEnvFile(filePath, values, manifest) {
43
51
  lines.push(`# scope: ${scope || "dev"}`)
44
52
  if (meta.label) lines.push(`# label: ${meta.label}`)
45
53
  if (meta.help) lines.push(`# help: ${meta.help}`)
46
- lines.push(`${name}=`)
54
+ lines.push(`${name}=${formatDotEnvValue(secretValues[name])}`)
47
55
  lines.push("")
48
56
  }
49
57
  if (Object.keys(values).length === 0 && manifest?.id) {
@@ -118,7 +126,8 @@ function initLocalEnv(cwd, manifest, { overwrite = false } = {}) {
118
126
  const declared = declaredSecrets(manifest)
119
127
  const localPath = path.join(cwd, LOCAL_ENV_PATH)
120
128
  const examplePath = path.join(cwd, EXAMPLE_ENV_PATH)
121
- if (overwrite || !fs.existsSync(localPath)) writeDotEnvFile(localPath, declared, manifest)
129
+ const existingLocal = overwrite ? {} : readDotEnvFile(localPath)
130
+ writeDotEnvFile(localPath, declared, manifest, existingLocal)
122
131
  writeDotEnvFile(examplePath, declared, manifest)
123
132
  return { localPath, examplePath, declared }
124
133
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@palettelab/cli",
3
- "version": "0.3.31",
3
+ "version": "0.3.32",
4
4
  "description": "Developer CLI for building Palette platform plugins — no platform source access required.",
5
5
  "bin": {
6
6
  "pltt": "bin/pltt.js"