@hazem3500/palette 0.9.112 → 0.9.113

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/cli/config.mjs CHANGED
@@ -45,6 +45,13 @@ export function branchName(env, cwd) {
45
45
  gitValue(["symbolic-ref", "--short", "HEAD"], cwd)
46
46
  );
47
47
  }
48
- export function clientModule(config) {
49
- return `import { definePalette } from '@hazem3500/palette/setup';\n\nexport const initPalette = definePalette(${JSON.stringify(config, null, 2)});\n\n/** @deprecated Use initPalette. */\nexport const initKomo = initPalette;\n`;
48
+ export function packageName(env = process.env) {
49
+ const name = env.PALETTE_PACKAGE_NAME ?? "@hazem3500/palette";
50
+ if (typeof name !== "string" || name.length > 214 || !/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/.test(name))
51
+ throw Error("PALETTE_PACKAGE_NAME must be an npm package name, such as @scope/palette.");
52
+ return name;
53
+ }
54
+
55
+ export function clientModule(config, env = process.env) {
56
+ return `import { definePalette } from '${packageName(env)}/setup';\n\nexport const initPalette = definePalette(${JSON.stringify(config, null, 2)});\n\n/** @deprecated Use initPalette. */\nexport const initKomo = initPalette;\n`;
50
57
  }
package/cli/index.mjs CHANGED
@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
5
5
  import { spawn } from "node:child_process";
6
6
  import { createInterface } from "node:readline/promises";
7
7
  import { randomUUID, randomBytes, createHash } from "node:crypto";
8
- import { branchName, clientModule, gitValue, projectLayout, repository, setting } from "./config.mjs";
8
+ import { branchName, clientModule, gitValue, projectLayout, repository, setting, packageName } from "./config.mjs";
9
9
 
10
10
  import { installAgentWorkflow } from "./workflow.mjs";
11
11
  import { agentCommands, agentHelp, runAgent } from "./agent.mjs";
@@ -315,10 +315,10 @@ async function init() {
315
315
  return;
316
316
  } else {
317
317
  if (
318
- !(await exists(resolve(cwd, "node_modules/@hazem3500/palette/package.json")))
318
+ !(await exists(resolve(cwd, `node_modules/${packageName()}/package.json`)))
319
319
  )
320
320
  throw Error(
321
- "Install Palette in this project before self-hosting: npm install @hazem3500/palette (or install the preview tarball before publication)."
321
+ `Install Palette in this project before self-hosting: npm install ${packageName()} (or install the preview tarball before publication).`
322
322
  );
323
323
  await protectLocalFiles();
324
324
  const name = `komo-${basename(cwd)
@@ -337,7 +337,7 @@ async function init() {
337
337
  );
338
338
  await writeFile(
339
339
  join(dir, "index.ts"),
340
- 'export { default } from "@hazem3500/palette/server";\n'
340
+ `export { default } from "${packageName()}/server";\n`
341
341
  );
342
342
  const wrangler = {
343
343
  name,
@@ -376,16 +376,17 @@ async function init() {
376
376
  await installAgentWorkflow(cwd);
377
377
  console.log("Added the Palette comment workflow to AGENTS.md");
378
378
  console.log(
379
- `\nMount after the page loads:\n\nimport { initPalette } from '@hazem3500/palette';\ninitPalette(${JSON.stringify({ ...config, origin: undefined, ...(config.scope === "branch" ? { branch: branchName(process.env, cwd) } : {}) }, null, 2)});\n\nFor automatic branch detection, use the generated ${layout.module} helper and run palette sync before your build.\n`
379
+ `\nMount after the page loads:\n\nimport { initPalette } from '${packageName()}';\ninitPalette(${JSON.stringify({ ...config, origin: undefined, ...(config.scope === "branch" ? { branch: branchName(process.env, cwd) } : {}) }, null, 2)});\n\nFor automatic branch detection, use the generated ${layout.module} helper and run palette sync before your build.\n`
380
380
  );
381
381
  } finally {
382
382
  rl.close();
383
383
  }
384
384
  }
385
385
  try {
386
+ packageName();
386
387
  if (args.includes("--help") || !command)
387
388
  console.log(
388
- `Palette\n\n palette init --endpoint API_URL Connect to an existing Palette server\n palette init --self-host Deploy your own Worker and D1 database\n palette init --node Prepare a Node/PostgreSQL project\n palette deploy Resume self-hosted deployment\n palette sync Regenerate client settings; detect the current branch\n\nOptions: --origin URL --endpoint API_URL --repo OWNER/REPO --branch-scope\nSelf-host: --google-client-id ID; Node: --preview-origin HTTPS_WILDCARD\n\nComments are shared across deployments unless --branch-scope is set.${
389
+ `Palette\n\n palette init --endpoint API_URL Connect to an existing Palette server\n palette init --self-host Deploy your own Worker and D1 database\n palette init --node Prepare a Node/PostgreSQL project\n palette deploy Resume self-hosted deployment\n palette sync Regenerate client settings; detect the current branch\n\nOptions: --origin URL --endpoint API_URL --repo OWNER/REPO --branch-scope\nSelf-host: --google-client-id ID; Node: --preview-origin HTTPS_WILDCARD\nWrappers: PALETTE_PACKAGE_NAME changes generated imports (default @hazem3500/palette).\n\nComments are shared across deployments unless --branch-scope is set.${
389
390
  agentHelp
390
391
  }`
391
392
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hazem3500/palette",
3
- "version": "0.9.112",
3
+ "version": "0.9.113",
4
4
  "description": "Point, area, and threaded comments for website branches.",
5
5
  "type": "module",
6
6
  "license": "MIT",