@zalify/cli 0.24.1 → 0.25.0

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/dist/cli.js +40 -1
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -18316,6 +18316,33 @@ function writeConfig(config) {
18316
18316
  function deleteConfig() {
18317
18317
  rmSync(file, { force: true });
18318
18318
  }
18319
+ function enforceWorkspaceLink(root, auth) {
18320
+ const linkPath = join(root, ".zalify", "brand-repo.json");
18321
+ if (!existsSync(linkPath))
18322
+ return;
18323
+ let link;
18324
+ try {
18325
+ link = JSON.parse(readFileSync(linkPath, "utf8"));
18326
+ } catch {
18327
+ return;
18328
+ }
18329
+ const ws = link.workspace;
18330
+ if (!ws?.id) {
18331
+ link.workspace = {
18332
+ id: auth.workspaceId,
18333
+ name: auth.workspaceName,
18334
+ slug: auth.workspaceSlug
18335
+ };
18336
+ writeFileSync2(linkPath, `${JSON.stringify(link, null, 2)}
18337
+ `);
18338
+ console.log(`stamped workspace "${auth.workspaceSlug}" into .zalify/brand-repo.json — commit it.`);
18339
+ return;
18340
+ }
18341
+ if (ws.id !== auth.workspaceId) {
18342
+ throw new Error(`This checkout belongs to workspace "${ws.name ?? ws.slug ?? ws.id}" ` + `but the active workspace is "${auth.workspaceName}" (${auth.workspaceSlug}).
18343
+ ` + `Run \`zalify workspace set ${ws.slug ?? ws.id}\` first.`);
18344
+ }
18345
+ }
18319
18346
  function requireActive() {
18320
18347
  const config = readConfig();
18321
18348
  if (!config) {
@@ -20258,7 +20285,16 @@ async function adsCreate(dir2) {
20258
20285
  console.log(` ✓ provisioned: ${view.githubRepo}`);
20259
20286
  scaffoldStarter(dir2, slug, auth.workspaceId);
20260
20287
  mkdirSync3(join8(resolve6(dir2), ".zalify"), { recursive: true });
20261
- writeFileSync7(join8(resolve6(dir2), ".zalify", "brand-repo.json"), JSON.stringify({ id: created.repoId, slug: view.slug, repo: view.githubRepo }, null, 2) + `
20288
+ writeFileSync7(join8(resolve6(dir2), ".zalify", "brand-repo.json"), JSON.stringify({
20289
+ id: created.repoId,
20290
+ slug: view.slug,
20291
+ repo: view.githubRepo,
20292
+ workspace: {
20293
+ id: auth.workspaceId,
20294
+ name: auth.workspaceName,
20295
+ slug: auth.workspaceSlug
20296
+ }
20297
+ }, null, 2) + `
20262
20298
  `);
20263
20299
  if (view.githubRepo) {
20264
20300
  const { token, repo } = await request2(auth, "POST", `/api/repos/${created.repoId}/push-token`, {});
@@ -20630,6 +20666,7 @@ ${s.creates} to create, ${s.updates} to update, ${s.unchanged} unchanged` + `${r
20630
20666
  async function adsDiff() {
20631
20667
  const auth = requireActive();
20632
20668
  const base = root();
20669
+ enforceWorkspaceLink(base, auth);
20633
20670
  const { files } = await collect(base);
20634
20671
  if (files.length === 0) {
20635
20672
  console.log("No campaign files — `zalify ads pull` or `zalify ads new` first.");
@@ -20647,6 +20684,7 @@ async function adsDiff() {
20647
20684
  async function adsApply(opts) {
20648
20685
  const auth = requireActive();
20649
20686
  const base = root();
20687
+ enforceWorkspaceLink(base, auth);
20650
20688
  const { files } = await collect(base);
20651
20689
  if (files.length === 0) {
20652
20690
  console.log("No campaign files — `zalify ads pull` or `zalify ads new` first.");
@@ -20734,6 +20772,7 @@ function readBindings(root2) {
20734
20772
  async function adsPull(opts) {
20735
20773
  const auth = requireActive();
20736
20774
  const root2 = checkoutRoot();
20775
+ enforceWorkspaceLink(root2, auth);
20737
20776
  const params = new URLSearchParams;
20738
20777
  if (opts.account)
20739
20778
  params.set("account", opts.account);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zalify/cli",
3
- "version": "0.24.1",
3
+ "version": "0.25.0",
4
4
  "description": "Zalify CLI - command-line interface for Zalify",
5
5
  "type": "module",
6
6
  "main": "dist/cli.js",