@zuplo/cli 1.118.0 → 1.119.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.
package/dist/cmds/link.js CHANGED
@@ -1,6 +1,7 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c2365925-f632-55ec-9b9b-85ac10bfc5ab")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6247c8c4-d880-5d58-a70d-da8c9cd6a68a")}catch(e){}}();
3
3
  import { captureEvent } from "../common/analytics/lib.js";
4
+ import { configure } from "../common/middleware/user-configuration.js";
4
5
  import { identify } from "../common/middleware/user-identification.js";
5
6
  import setBlocking from "../common/output.js";
6
7
  import { validLinkDirectoryValidator } from "../common/validators/file-system-validator.js";
@@ -18,7 +19,25 @@ export default {
18
19
  normalize: true,
19
20
  hidden: true,
20
21
  })
21
- .middleware([setBlocking, identify])
22
+ .option("api-key", {
23
+ type: "string",
24
+ describe: "The API Key from Zuplo",
25
+ envVar: "API_KEY",
26
+ })
27
+ .option("account", {
28
+ type: "string",
29
+ describe: "The account name",
30
+ })
31
+ .option("project", {
32
+ type: "string",
33
+ describe: "The project name",
34
+ })
35
+ .option("environment", {
36
+ type: "string",
37
+ describe: "The environment name",
38
+ })
39
+ .demandOption(["api-key"])
40
+ .middleware([setBlocking, configure, identify])
22
41
  .check(async (argv) => {
23
42
  return await new YargsChecker(validLinkDirectoryValidator).check(argv);
24
43
  });
@@ -29,4 +48,4 @@ export default {
29
48
  },
30
49
  };
31
50
  //# sourceMappingURL=link.js.map
32
- //# debugId=c2365925-f632-55ec-9b9b-85ac10bfc5ab
51
+ //# debugId=6247c8c4-d880-5d58-a70d-da8c9cd6a68a
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="51fa863f-e84d-5faa-922f-e762f03ef49f")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="42cac298-fcf2-5562-897a-c038f723b42f")}catch(e){}}();
3
3
  export {};
4
4
  //# sourceMappingURL=lib.js.map
5
- //# debugId=51fa863f-e84d-5faa-922f-e762f03ef49f
5
+ //# debugId=42cac298-fcf2-5562-897a-c038f723b42f
@@ -1,12 +1,12 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5d556b94-af4a-5b17-96b6-e1bca9a4704a")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ec896cd1-5086-5370-b8b3-2b5276946dee")}catch(e){}}();
3
3
  import fg from "fast-glob";
4
4
  import { existsSync, readdirSync } from "node:fs";
5
5
  import { join } from "node:path";
6
6
  import { simpleGit } from "simple-git";
7
7
  import { TEST_IN_FOLDER } from "../constants.js";
8
8
  import { CompositeValidator } from "./lib.js";
9
- import { UserIsLoggedInValidator } from "./login-state-validator.js";
9
+ import { IsZupLinkInvocableValidator } from "./login-state-validator.js";
10
10
  import { ProjectIsSetValidator } from "./project-name-validator.js";
11
11
  export class NotAGitRepoError extends Error {
12
12
  constructor() {
@@ -161,6 +161,6 @@ export class ZuploProjectHasTestsValidator {
161
161
  }
162
162
  export const validDeployDirectoryValidator = new CompositeValidator(new ZuploProjectValidator(), new GitVersionControlValidator(), new GitCommitValidator(), new GitBranchValidator(), new GitRemoteValidator(), new ProjectIsSetValidator());
163
163
  export const validTestDirectoryValidator = new CompositeValidator(new ZuploProjectValidator(), new ZuploProjectHasTestsValidator());
164
- export const validLinkDirectoryValidator = new CompositeValidator(new ZuploProjectValidator(), new UserIsLoggedInValidator());
164
+ export const validLinkDirectoryValidator = new CompositeValidator(new ZuploProjectValidator(), new IsZupLinkInvocableValidator());
165
165
  //# sourceMappingURL=file-system-validator.js.map
166
- //# debugId=5d556b94-af4a-5b17-96b6-e1bca9a4704a
166
+ //# debugId=ec896cd1-5086-5370-b8b3-2b5276946dee
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ad5e9c30-9045-5fa4-b776-601c8f4c0a0a")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b9d015db-7e92-5ad9-a0e8-514350db203a")}catch(e){}}();
3
3
  import { existsSync } from "node:fs";
4
4
  import { readFile } from "node:fs/promises";
5
5
  import { join } from "node:path";
@@ -7,16 +7,19 @@ import { ZUPLO_AUTH_FILE_NAME } from "../constants.js";
7
7
  import { logger } from "../logger.js";
8
8
  import settings from "../settings.js";
9
9
  import { ZUPLO_XDG_STATE_HOME } from "../xdg/lib.js";
10
- export class UserIsNotLoggedIn extends Error {
10
+ export class CannotInvokeZupLink extends Error {
11
11
  constructor() {
12
12
  super(`You are not logged in (or your credentials have expired). Please run \`zup login\` to log in.`);
13
- Object.setPrototypeOf(this, UserIsNotLoggedIn.prototype);
13
+ Object.setPrototypeOf(this, CannotInvokeZupLink.prototype);
14
14
  }
15
15
  }
16
- export class UserIsLoggedInValidator {
17
- async validate(_options) {
16
+ export class IsZupLinkInvocableValidator {
17
+ async validate(options) {
18
+ if (options.environment) {
19
+ return { ok: true };
20
+ }
18
21
  if (!existsSync(join(ZUPLO_XDG_STATE_HOME, ZUPLO_AUTH_FILE_NAME))) {
19
- return { ok: false, error: new UserIsNotLoggedIn() };
22
+ return { ok: false, error: new CannotInvokeZupLink() };
20
23
  }
21
24
  const rawAuth = await readFile(join(ZUPLO_XDG_STATE_HOME, ZUPLO_AUTH_FILE_NAME), "utf-8");
22
25
  const authJson = JSON.parse(rawAuth);
@@ -30,10 +33,10 @@ export class UserIsLoggedInValidator {
30
33
  status: accountResponse.status,
31
34
  statusText: accountResponse.statusText,
32
35
  }, "Failed to connect to Zuplo API during verification. Assuming user is not logged in.");
33
- return { ok: false, error: new UserIsNotLoggedIn() };
36
+ return { ok: false, error: new CannotInvokeZupLink() };
34
37
  }
35
38
  return { ok: true };
36
39
  }
37
40
  }
38
41
  //# sourceMappingURL=login-state-validator.js.map
39
- //# debugId=ad5e9c30-9045-5fa4-b776-601c8f4c0a0a
42
+ //# debugId=b9d015db-7e92-5ad9-a0e8-514350db203a
@@ -1,6 +1,7 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e900a4a1-10a3-56de-9a5a-905c90d64f03")}catch(e){}}();
3
- import { cpSync, existsSync } from "node:fs";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="73d10b24-273b-5673-84fb-1a5d0cf42473")}catch(e){}}();
3
+ import dotenv from "dotenv";
4
+ import { cpSync, existsSync, readFileSync } from "node:fs";
4
5
  import { join, relative, resolve } from "node:path";
5
6
  import { fileURLToPath, pathToFileURL } from "node:url";
6
7
  import { printDiagnosticsToConsole } from "../common/output.js";
@@ -14,14 +15,11 @@ export async function compile(argv) {
14
15
  });
15
16
  }
16
17
  process.env.GLOBAL_MODULE_LOCATION = fileURLToPath(new URL("../../node_modules", import.meta.url));
17
- const loadedEnvFiles = [];
18
- const envFile = join(sourceDirectory, ".env");
19
- if (existsSync(envFile)) {
20
- loadedEnvFiles.push(".env");
21
- }
18
+ let envZuplo = {};
22
19
  const envZuploFile = join(sourceDirectory, ".env.zuplo");
23
20
  if (existsSync(envZuploFile)) {
24
- loadedEnvFiles.push(".env.zuplo");
21
+ const contents = readFileSync(envZuploFile);
22
+ envZuplo = dotenv.parse(contents);
25
23
  }
26
24
  const config = {
27
25
  build_assets_url: pathToFileURL(sourceDirectory),
@@ -33,10 +31,16 @@ export async function compile(argv) {
33
31
  sourceDirectory,
34
32
  port: zupPort,
35
33
  binaryName: argv["binary-name"],
36
- generateSourceMaps: true,
34
+ publicZuploEnvironmentVariables: envZuplo
35
+ ? {
36
+ ZUPLO_ACCOUNT_NAME: envZuplo.ZUPLO_ACCOUNT_NAME,
37
+ ZUPLO_PROJECT_NAME: envZuplo.ZUPLO_PROJECT_NAME,
38
+ ZUPLO_ENVIRONMENT_TYPE: envZuplo.ZUPLO_ENVIRONMENT_TYPE,
39
+ }
40
+ : {},
37
41
  });
38
42
  printDiagnosticsToConsole("📦 Compiled a self-contained zup binary");
39
43
  printDiagnosticsToConsole(`The binary is available at ${sourceDirectory}/dist/${argv["binary-name"]}`);
40
44
  }
41
45
  //# sourceMappingURL=handler.js.map
42
- //# debugId=e900a4a1-10a3-56de-9a5a-905c90d64f03
46
+ //# debugId=73d10b24-273b-5673-84fb-1a5d0cf42473
@@ -1,6 +1,7 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="bf35816c-e91e-5014-89aa-1472b78406e4")}catch(e){}}();
3
- import { cpSync, existsSync } from "node:fs";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5bca5e0a-7dea-5646-b573-80529e630b6e")}catch(e){}}();
3
+ import dotenv from "dotenv";
4
+ import { cpSync, existsSync, readFileSync } from "node:fs";
4
5
  import { join, relative, resolve } from "node:path";
5
6
  import { fileURLToPath, pathToFileURL } from "node:url";
6
7
  import { logger } from "../common/logger.js";
@@ -22,8 +23,11 @@ export async function dev(argv) {
22
23
  if (existsSync(envFile)) {
23
24
  loadedEnvFiles.push(".env");
24
25
  }
26
+ let envZuplo = {};
25
27
  const envZuploFile = join(sourceDirectory, ".env.zuplo");
26
28
  if (existsSync(envZuploFile)) {
29
+ const contents = readFileSync(envZuploFile);
30
+ envZuplo = dotenv.parse(contents);
27
31
  loadedEnvFiles.push(".env.zuplo");
28
32
  }
29
33
  const config = {
@@ -52,12 +56,13 @@ export async function dev(argv) {
52
56
  sourceDirectory,
53
57
  port: zupPort,
54
58
  debugPort: argv.debugPort ?? undefined,
55
- devServerPort: undefined,
56
- generateSourceMaps: true,
57
- flags: {
58
- remoteModules: false,
59
- disableIntegratedDevPortalBuild: false,
60
- },
59
+ publicZuploEnvironmentVariables: envZuplo
60
+ ? {
61
+ ZUPLO_ACCOUNT_NAME: envZuplo.ZUPLO_ACCOUNT_NAME,
62
+ ZUPLO_PROJECT_NAME: envZuplo.ZUPLO_PROJECT_NAME,
63
+ ZUPLO_ENVIRONMENT_TYPE: envZuplo.ZUPLO_ENVIRONMENT_TYPE,
64
+ }
65
+ : {},
61
66
  });
62
67
  let editor;
63
68
  if (argv["start-editor"]) {
@@ -95,4 +100,4 @@ export async function dev(argv) {
95
100
  });
96
101
  }
97
102
  //# sourceMappingURL=handler.js.map
98
- //# debugId=bf35816c-e91e-5014-89aa-1472b78406e4
103
+ //# debugId=5bca5e0a-7dea-5646-b573-80529e630b6e
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3c8e52ab-7b72-5f36-b4ad-e2ee1aaa743c")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ad2554cf-74a8-5032-b89f-1ffefcd558f0")}catch(e){}}();
3
3
  import { select } from "@inquirer/prompts";
4
4
  import { readFile } from "node:fs/promises";
5
5
  import { join } from "node:path";
@@ -12,72 +12,106 @@ import { pullSystemConfig, safeMergeConfig } from "./populate.js";
12
12
  export async function link(argv) {
13
13
  const rawAuth = await readFile(join(ZUPLO_XDG_STATE_HOME, ZUPLO_AUTH_FILE_NAME), "utf-8");
14
14
  const authJson = JSON.parse(rawAuth);
15
- const accountResponse = await fetch(`${settings.ZUPLO_API_ENDPOINT}/v1/accounts`, {
16
- headers: {
17
- authorization: `Bearer ${authJson.access_token}`,
18
- },
19
- });
20
- if (!accountResponse.ok) {
21
- logger.error({
22
- status: accountResponse.status,
23
- statusText: accountResponse.statusText,
24
- response: textOrJson(await accountResponse.text()),
25
- }, "Failed to list accounts.");
26
- await printCriticalFailureToConsoleAndExit("Error: Failed to list your accounts. Try again later.");
27
- }
28
- const accountJson = (await accountResponse.json());
29
- let account;
30
- if (accountJson.length === 1) {
31
- account = accountJson[0].name;
32
- }
33
- else {
34
- account = await select({
35
- message: "Select the account to work with",
36
- choices: accountJson.map((acc) => {
37
- return {
38
- name: acc.name,
39
- value: acc.name,
40
- };
41
- }),
15
+ let environment = argv.environment;
16
+ let account = argv.account;
17
+ if (!environment && !account) {
18
+ const accountResponse = await fetch(`${settings.ZUPLO_API_ENDPOINT}/v1/accounts`, {
19
+ headers: {
20
+ authorization: `Bearer ${authJson.access_token}`,
21
+ },
42
22
  });
23
+ if (!accountResponse.ok) {
24
+ logger.error({
25
+ status: accountResponse.status,
26
+ statusText: accountResponse.statusText,
27
+ response: textOrJson(await accountResponse.text()),
28
+ }, "Failed to list accounts.");
29
+ await printCriticalFailureToConsoleAndExit("Error: Failed to list your accounts. Try again later.");
30
+ }
31
+ const accountJson = (await accountResponse.json());
32
+ if (accountJson.length === 1) {
33
+ account = accountJson[0].name;
34
+ }
35
+ else {
36
+ account = await select({
37
+ message: "Select the account to work with",
38
+ choices: accountJson.map((acc) => {
39
+ return {
40
+ name: acc.name,
41
+ value: acc.name,
42
+ };
43
+ }),
44
+ });
45
+ }
43
46
  }
44
- const projectResponse = await fetch(`${settings.ZUPLO_API_ENDPOINT}/v1/accounts/${account}/projects`, {
45
- headers: {
46
- authorization: `Bearer ${authJson.access_token}`,
47
- },
48
- });
49
- if (!projectResponse.ok) {
50
- logger.error({
51
- status: projectResponse.status,
52
- statusText: projectResponse.statusText,
53
- response: textOrJson(await projectResponse.text()),
54
- }, "Failed to list projects.");
55
- await printCriticalFailureToConsoleAndExit("Error: Failed to list your projects. Try again later.");
56
- }
57
- const projectJson = (await projectResponse.json());
58
- let project;
59
- if (projectJson.data.length === 1) {
60
- project = projectJson.data[0].name;
47
+ let project = argv.project;
48
+ if (!environment && !project) {
49
+ const projectResponse = await fetch(`${settings.ZUPLO_API_ENDPOINT}/v1/accounts/${account}/projects`, {
50
+ headers: {
51
+ authorization: `Bearer ${authJson.access_token}`,
52
+ },
53
+ });
54
+ if (!projectResponse.ok) {
55
+ logger.error({
56
+ status: projectResponse.status,
57
+ statusText: projectResponse.statusText,
58
+ response: textOrJson(await projectResponse.text()),
59
+ }, "Failed to list projects.");
60
+ await printCriticalFailureToConsoleAndExit("Error: Failed to list your projects. Try again later.");
61
+ }
62
+ const projectJson = (await projectResponse.json());
63
+ if (projectJson.data.length === 1) {
64
+ project = projectJson.data[0].name;
65
+ }
66
+ else {
67
+ project = await select({
68
+ message: "Select the project to work with",
69
+ choices: projectJson.data.map((prj) => {
70
+ return {
71
+ name: prj.name,
72
+ value: prj.name,
73
+ };
74
+ }),
75
+ });
76
+ }
61
77
  }
62
- else {
63
- project = await select({
64
- message: "Select the project to work with",
65
- choices: projectJson.data.map((prj) => {
66
- return {
67
- name: prj.name,
68
- value: prj.name,
69
- };
70
- }),
78
+ if (!environment) {
79
+ const environmentResponseFromZuploAPI = await fetch(`${settings.ZUPLO_API_ENDPOINT}/v1/accounts/${account}/projects/${project}/deployments`, {
80
+ headers: {
81
+ authorization: `Bearer ${authJson.access_token}`,
82
+ },
83
+ });
84
+ const environmentJsonFromZuploAPI = (await environmentResponseFromZuploAPI.json());
85
+ const environmentResponseFromDeveloperAPI = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/projects/${project}/deployments`, {
86
+ headers: {
87
+ authorization: `Bearer ${argv["api-key"]}`,
88
+ },
71
89
  });
90
+ const environmentJsonFromDeveloperAPI = (await environmentResponseFromDeveloperAPI.json());
91
+ const environments = Object.assign({}, environmentJsonFromZuploAPI.data.map((env) => env.name), environmentJsonFromDeveloperAPI.data.map((env) => env.name));
92
+ if (environments.length === 1) {
93
+ environment = environments[0];
94
+ }
95
+ else {
96
+ environment = await select({
97
+ message: "Select the environment to work with",
98
+ choices: Object.values(environments).map((env) => {
99
+ return {
100
+ name: env,
101
+ value: env,
102
+ };
103
+ }),
104
+ });
105
+ }
106
+ }
107
+ argv.environment = environment;
108
+ if (project) {
109
+ await safeMergeConfig(argv.dir, project);
72
110
  }
73
- await safeMergeConfig(argv.dir, { account, project });
74
- await pullSystemConfig(argv.dir, {
75
- account: accountJson.find((acc) => acc.name === account),
76
- project: projectJson.data.find((prj) => prj.name === project),
77
- });
111
+ await pullSystemConfig(argv);
78
112
  await printResultToConsoleAndExitGracefully(`
79
113
  Successfully linked your local directory to the ${project} project in the ${account} account.
80
114
  .env.zuplo and zuplo.jsonc have been updated with the new values.`);
81
115
  }
82
116
  //# sourceMappingURL=handler.js.map
83
- //# debugId=3c8e52ab-7b72-5f36-b4ad-e2ee1aaa743c
117
+ //# debugId=ad2554cf-74a8-5032-b89f-1ffefcd558f0
@@ -1,25 +1,22 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b2394d6d-82d5-5876-b02e-aa6ebe0bf121")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="da90a012-8772-5d2a-9ae1-fcaa66577120")}catch(e){}}();
3
3
  import { applyEdits, modify } from "jsonc-parser";
4
4
  import { existsSync } from "node:fs";
5
5
  import { readFile, writeFile } from "node:fs/promises";
6
6
  import { join, relative } from "node:path";
7
7
  import prettier from "prettier";
8
8
  import { ZUPLO_FALLBACK_JSON_FILE, ZUPLO_PREFERRED_JSON_FILE, ZUPLO_SYSTEM_ENV_VAR, } from "../common/constants.js";
9
- export async function safeMergeConfig(dir, options) {
9
+ import settings from "../common/settings.js";
10
+ export async function safeMergeConfig(dir, project) {
10
11
  const normalizedDir = join(relative(process.cwd(), dir));
11
12
  const zuploPreferredConfigFile = join(normalizedDir, ZUPLO_PREFERRED_JSON_FILE);
12
13
  const zuploFallbackConfigFile = join(normalizedDir, ZUPLO_FALLBACK_JSON_FILE);
13
14
  if (existsSync(zuploPreferredConfigFile)) {
14
15
  const originalContents = await readFile(zuploPreferredConfigFile, "utf-8");
15
- const modifyAccountEdit = modify(originalContents, ["account"], options.account, {
16
- getInsertionIndex: () => 1,
17
- });
18
- const contentsPostAccount = applyEdits(originalContents, modifyAccountEdit);
19
- const modifyProjectEdit = modify(contentsPostAccount, ["project"], options.project, {
16
+ const modifyProjectEdit = modify(originalContents, ["project"], project, {
20
17
  getInsertionIndex: () => 2,
21
18
  });
22
- const contentsPostProject = applyEdits(contentsPostAccount, modifyProjectEdit);
19
+ const contentsPostProject = applyEdits(originalContents, modifyProjectEdit);
23
20
  const formatted = prettier.format(contentsPostProject, {
24
21
  parser: "json",
25
22
  quoteProps: "as-needed",
@@ -30,8 +27,7 @@ export async function safeMergeConfig(dir, options) {
30
27
  const config = JSON.parse(await readFile(zuploFallbackConfigFile, "utf-8"));
31
28
  const formatted = prettier.format(JSON.stringify({
32
29
  version: 1,
33
- account: options.account,
34
- project: options.project,
30
+ project: project,
35
31
  compatibilityDate: config.compatibilityDate,
36
32
  }), {
37
33
  parser: "json",
@@ -42,8 +38,7 @@ export async function safeMergeConfig(dir, options) {
42
38
  else {
43
39
  const formatted = prettier.format(JSON.stringify({
44
40
  version: 1,
45
- account: options.account,
46
- project: options.project,
41
+ project: project,
47
42
  compatibilityDate: "2023-03-14",
48
43
  }), {
49
44
  parser: "json",
@@ -52,18 +47,26 @@ export async function safeMergeConfig(dir, options) {
52
47
  await writeFile(zuploPreferredConfigFile, formatted);
53
48
  }
54
49
  }
55
- export async function pullSystemConfig(dir, options) {
56
- const normalizedDir = join(relative(process.cwd(), dir));
50
+ export async function pullSystemConfig(argv) {
51
+ const normalizedDir = join(relative(process.cwd(), argv.dir));
57
52
  const zuploPreferredConfigFile = join(normalizedDir, ZUPLO_SYSTEM_ENV_VAR);
53
+ const environmentResponseFromDeveloperAPI = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/environments/${argv.environment}/configurations`, {
54
+ headers: {
55
+ authorization: `Bearer ${argv["api-key"]}`,
56
+ },
57
+ });
58
+ const payload = await environmentResponseFromDeveloperAPI.json();
58
59
  const content = `
59
- # This file is auto-generated from zup link. Please do not edit it manually.
60
- # It will be auto-generated afresh the next time you run zup link.
61
- # If you wish to add your own environment variables, create a separate .env file.
62
-
63
- ZUPLO_API_KEY_SERVICE_BUCKET_NAME=z${options.project.id
64
- .toLowerCase()
65
- .replaceAll("_", "-")}-working-copy`;
60
+ # This file is auto-generated from zup link. Please do not edit it manually.
61
+ # It will be auto-generated afresh the next time you run zup link.
62
+ # If you wish to add your own environment variables, create a separate .env file.
63
+
64
+ ZUPLO_ACCOUNT_NAME=${payload.accountName}
65
+ ZUPLO_PROJECT_NAME=${payload.projectName}
66
+ ZUPLO_ENVIRONMENT_TYPE=${payload.environmentType}
67
+ SYSTEM_CONFIGURATIONS=${payload["systemConfigurations"]}
68
+ `;
66
69
  await writeFile(zuploPreferredConfigFile, content);
67
70
  }
68
71
  //# sourceMappingURL=populate.js.map
69
- //# debugId=b2394d6d-82d5-5876-b02e-aa6ebe0bf121
72
+ //# debugId=da90a012-8772-5d2a-9ae1-fcaa66577120
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/cli",
3
- "version": "1.118.0",
3
+ "version": "1.119.0",
4
4
  "type": "module",
5
5
  "repository": "https://github.com/zuplo/cli",
6
6
  "description": "The command-line interface for Zuplo",
@@ -64,10 +64,10 @@
64
64
  "@opentelemetry/api": "^1.8.0",
65
65
  "@sentry/node": "7.69.0",
66
66
  "@swc/core": "1.3.78",
67
- "@zuplo/core": "5.2212.0",
67
+ "@zuplo/core": "5.2249.0",
68
68
  "@zuplo/deno-bin": "1.37.1",
69
69
  "@zuplo/pino-pretty-configurations": "^1.5.0",
70
- "@zuplo/runtime": "5.2212.0",
70
+ "@zuplo/runtime": "5.2249.0",
71
71
  "chalk": "^5.1.2",
72
72
  "chokidar": "^3.5.3",
73
73
  "dotenv": "^16.3.1",