netlify-cli 17.23.5 → 17.23.7

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 (63) hide show
  1. package/dist/commands/build/build.d.ts.map +1 -1
  2. package/dist/commands/build/build.js +6 -12
  3. package/dist/commands/deploy/deploy.d.ts.map +1 -1
  4. package/dist/commands/deploy/deploy.js +10 -13
  5. package/dist/commands/dev/dev-exec.d.ts.map +1 -1
  6. package/dist/commands/dev/dev-exec.js +3 -6
  7. package/dist/commands/dev/dev.d.ts.map +1 -1
  8. package/dist/commands/dev/dev.js +3 -3
  9. package/dist/commands/env/env-clone.d.ts.map +1 -1
  10. package/dist/commands/env/env-clone.js +3 -105
  11. package/dist/commands/env/env-get.d.ts.map +1 -1
  12. package/dist/commands/env/env-get.js +3 -9
  13. package/dist/commands/env/env-import.d.ts.map +1 -1
  14. package/dist/commands/env/env-import.js +2 -25
  15. package/dist/commands/env/env-list.d.ts.map +1 -1
  16. package/dist/commands/env/env-list.js +14 -17
  17. package/dist/commands/env/env-set.d.ts.map +1 -1
  18. package/dist/commands/env/env-set.js +1 -33
  19. package/dist/commands/env/env-unset.d.ts.map +1 -1
  20. package/dist/commands/env/env-unset.js +2 -34
  21. package/dist/commands/functions/functions-create.d.ts.map +1 -1
  22. package/dist/commands/functions/functions-create.js +3 -8
  23. package/dist/commands/integration/deploy.d.ts.map +1 -1
  24. package/dist/commands/integration/deploy.js +5 -2
  25. package/dist/commands/serve/serve.js +1 -1
  26. package/dist/commands/sites/sites-create-template.d.ts.map +1 -1
  27. package/dist/commands/sites/sites-create-template.js +13 -2
  28. package/dist/lib/exec-fetcher.d.ts +1 -1
  29. package/dist/lib/exec-fetcher.d.ts.map +1 -1
  30. package/dist/lib/exec-fetcher.js +2 -3
  31. package/dist/lib/functions/registry.js +1 -1
  32. package/dist/lib/functions/runtimes/js/index.d.ts +7 -5
  33. package/dist/lib/functions/runtimes/js/index.d.ts.map +1 -1
  34. package/dist/lib/functions/runtimes/js/index.js +4 -3
  35. package/dist/lib/functions/server.d.ts.map +1 -1
  36. package/dist/lib/functions/server.js +10 -11
  37. package/dist/lib/geo-location.js +2 -1
  38. package/dist/tsconfig.tsbuildinfo +1 -1
  39. package/dist/utils/copy-template-dir/copy-template-dir.d.ts +2 -0
  40. package/dist/utils/copy-template-dir/copy-template-dir.d.ts.map +1 -0
  41. package/dist/utils/copy-template-dir/copy-template-dir.js +74 -0
  42. package/dist/utils/functions/functions.d.ts +3 -3
  43. package/dist/utils/functions/functions.d.ts.map +1 -1
  44. package/dist/utils/functions/functions.js +0 -3
  45. package/dist/utils/gh-auth.js +1 -1
  46. package/dist/utils/live-tunnel.d.ts.map +1 -1
  47. package/dist/utils/live-tunnel.js +5 -1
  48. package/dist/utils/proxy.d.ts.map +1 -1
  49. package/dist/utils/proxy.js +3 -4
  50. package/dist/utils/read-repo-url.d.ts +1 -1
  51. package/dist/utils/read-repo-url.d.ts.map +1 -1
  52. package/dist/utils/sites/utils.d.ts +2 -2
  53. package/dist/utils/sites/utils.d.ts.map +1 -1
  54. package/dist/utils/sites/utils.js +1 -0
  55. package/functions-templates/go/hello-world/go.mod +1 -1
  56. package/functions-templates/javascript/scheduled-function/package.json +1 -1
  57. package/functions-templates/javascript/submission-created/package.json +1 -1
  58. package/functions-templates/rust/hello-world/Cargo.toml +1 -1
  59. package/functions-templates/typescript/hello-world/package-lock.json +38 -121
  60. package/functions-templates/typescript/hello-world/package.json +2 -2
  61. package/functions-templates/typescript/scheduled-function/package.json +2 -2
  62. package/npm-shrinkwrap.json +2709 -4822
  63. package/package.json +28 -26
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/commands/build/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAMxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAE5C;;GAEG;AAEH,eAAO,MAAM,YAAY;;;;;UAWxB,CAAA;AAYD,eAAO,MAAM,KAAK,YAAmB,YAAY,WAAW,WAAW,kBAiCtE,CAAA"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/commands/build/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAMxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAE5C;;GAEG;AAEH,eAAO,MAAM,YAAY;;;;;UAWxB,CAAA;AAED,eAAO,MAAM,KAAK,YAAmB,YAAY,WAAW,WAAW,kBAoCtE,CAAA"}
@@ -15,14 +15,6 @@ export const checkOptions = ({ cachedConfig: { siteInfo = {} }, token }) => {
15
15
  error('Could not find the access token. Please run netlify login.');
16
16
  }
17
17
  };
18
- // @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type.
19
- const injectEnv = async function (command, { api, buildOptions, context, siteInfo }) {
20
- const isUsingEnvelope = siteInfo && siteInfo.use_envelope;
21
- const { env } = buildOptions.cachedConfig;
22
- if (isUsingEnvelope) {
23
- buildOptions.cachedConfig.env = await getEnvelopeEnv({ api, context, env, siteInfo });
24
- }
25
- };
26
18
  export const build = async (options, command) => {
27
19
  const { cachedConfig, siteInfo } = command.netlify;
28
20
  command.setAnalyticsPayload({ dry: options.dry });
@@ -45,10 +37,12 @@ export const build = async (options, command) => {
45
37
  });
46
38
  if (!options.offline) {
47
39
  checkOptions(buildOptions);
48
- const { api, site } = command.netlify;
49
- const { context } = options;
50
- // @ts-expect-error TS(2345) FIXME: Argument of type '{ api: any; buildOptions: { cach... Remove this comment to see the full error message
51
- await injectEnv(command, { api, buildOptions, context, site, siteInfo });
40
+ buildOptions.cachedConfig.env = await getEnvelopeEnv({
41
+ api: command.netlify.api,
42
+ context: options.context,
43
+ env: buildOptions.cachedConfig.env,
44
+ siteInfo,
45
+ });
52
46
  }
53
47
  const { exitCode } = await runBuild(buildOptions);
54
48
  exit(exitCode);
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/deploy.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAgCxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAuuB5C,eAAO,MAAM,MAAM,YAAmB,YAAY,WAAW,WAAW,kBAmHvE,CAAA"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/deploy.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAgCxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAouB5C,eAAO,MAAM,MAAM,YAAmB,YAAY,WAAW,WAAW,kBAmHvE,CAAA"}
@@ -14,7 +14,7 @@ import { featureFlags as edgeFunctionsFeatureFlags } from '../../lib/edge-functi
14
14
  import { normalizeFunctionsConfig } from '../../lib/functions/config.js';
15
15
  import { BACKGROUND_FUNCTIONS_WARNING } from '../../lib/log.js';
16
16
  import { startSpinner, stopSpinner } from '../../lib/spinner.js';
17
- import { chalk, error, exit, getToken, log, logJson, NETLIFYDEV, NETLIFYDEVERR, NETLIFYDEVLOG, warn, } from '../../utils/command-helpers.js';
17
+ import { NETLIFYDEV, NETLIFYDEVERR, NETLIFYDEVLOG, chalk, error, exit, getToken, log, logJson, warn, } from '../../utils/command-helpers.js';
18
18
  import { DEFAULT_DEPLOY_TIMEOUT } from '../../utils/deploy/constants.js';
19
19
  import { deploySite } from '../../utils/deploy/deploy-site.js';
20
20
  import { getEnvelopeEnv } from '../../utils/env/index.js';
@@ -566,9 +566,8 @@ siteId,
566
566
  // @ts-expect-error TS(7031) FIXME: Binding element 'workingDir' implicitly has an 'an... Remove this comment to see the full error message
567
567
  workingDir, }) => {
568
568
  const alias = options.alias || options.branch;
569
- const isUsingEnvelope = siteData && siteData.use_envelope;
570
569
  // if a context is passed besides dev, we need to pull env vars from that specific context
571
- if (isUsingEnvelope && options.context && options.context !== 'dev') {
570
+ if (options.context && options.context !== 'dev') {
572
571
  command.netlify.cachedConfig.env = await getEnvelopeEnv({
573
572
  api,
574
573
  context: options.context,
@@ -593,16 +592,14 @@ workingDir, }) => {
593
592
  deployFolder,
594
593
  functionsFolder,
595
594
  });
596
- const siteEnv = isUsingEnvelope
597
- ? await getEnvelopeEnv({
598
- api,
599
- context: options.context,
600
- env: command.netlify.cachedConfig.env,
601
- raw: true,
602
- scope: 'functions',
603
- siteInfo: siteData,
604
- })
605
- : siteData?.build_settings?.env;
595
+ const siteEnv = await getEnvelopeEnv({
596
+ api,
597
+ context: options.context,
598
+ env: command.netlify.cachedConfig.env,
599
+ raw: true,
600
+ scope: 'functions',
601
+ siteInfo: siteData,
602
+ });
606
603
  const functionsConfig = normalizeFunctionsConfig({
607
604
  functionsConfig: config.functions,
608
605
  projectRoot: site.root,
@@ -1 +1 @@
1
- {"version":3,"file":"dev-exec.d.ts","sourceRoot":"","sources":["../../../src/commands/dev/dev-exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAKxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAE5C,eAAO,MAAM,OAAO,QAAe,MAAM,WAAW,YAAY,WAAW,WAAW,kBAcrF,CAAA;AAED,eAAO,MAAM,oBAAoB,YAAa,WAAW,gBAerC,CAAA"}
1
+ {"version":3,"file":"dev-exec.d.ts","sourceRoot":"","sources":["../../../src/commands/dev/dev-exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAKxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAE5C,eAAO,MAAM,OAAO,QAAe,MAAM,WAAW,YAAY,WAAW,WAAW,kBAWrF,CAAA;AAED,eAAO,MAAM,oBAAoB,YAAa,WAAW,gBAerC,CAAA"}
@@ -3,12 +3,9 @@ import { getDotEnvVariables, injectEnvVariables } from '../../utils/dev.js';
3
3
  import { getEnvelopeEnv, normalizeContext } from '../../utils/env/index.js';
4
4
  export const devExec = async (cmd, options, command) => {
5
5
  const { api, cachedConfig, config, site, siteInfo } = command.netlify;
6
- let { env } = cachedConfig;
7
- if (siteInfo.use_envelope) {
8
- env = await getEnvelopeEnv({ api, context: options.context, env, siteInfo });
9
- }
10
- env = await getDotEnvVariables({ devConfig: { ...config.dev }, env, site });
11
- injectEnvVariables(env);
6
+ const withEnvelopeEnvVars = await getEnvelopeEnv({ api, context: options.context, env: cachedConfig.env, siteInfo });
7
+ const withDotEnvVars = await getDotEnvVariables({ devConfig: { ...config.dev }, env: withEnvelopeEnvVars, site });
8
+ injectEnvVariables(withDotEnvVars);
12
9
  await execa(cmd, command.args.slice(1), {
13
10
  stdio: 'inherit',
14
11
  });
@@ -1 +1 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/commands/dev/dev.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAU,MAAM,WAAW,CAAA;AA0BhD,OAAO,WAAW,MAAM,oBAAoB,CAAA;AA4D5C,eAAO,MAAM,GAAG,YAAmB,YAAY,WAAW,WAAW,kBA0JpE,CAAA;AAED,eAAO,MAAM,gBAAgB,YAAa,WAAW,gBA8GpD,CAAA"}
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/commands/dev/dev.ts"],"names":[],"mappings":"AAIA,OAAO,EAAU,YAAY,EAAE,MAAM,WAAW,CAAA;AA0BhD,OAAO,WAAW,MAAM,oBAAoB,CAAA;AA4D5C,eAAO,MAAM,GAAG,YAAmB,YAAY,WAAW,WAAW,kBA0JpE,CAAA;AAED,eAAO,MAAM,gBAAgB,YAAa,WAAW,gBA8GpD,CAAA"}
@@ -6,9 +6,9 @@ import { BLOBS_CONTEXT_VARIABLE, encodeBlobsContext, getBlobsContextWithEdgeAcce
6
6
  import { promptEditorHelper } from '../../lib/edge-functions/editor-helper.js';
7
7
  import { startFunctionsServer } from '../../lib/functions/server.js';
8
8
  import { printBanner } from '../../utils/banner.js';
9
- import { BANG, chalk, log, NETLIFYDEV, NETLIFYDEVERR, NETLIFYDEVLOG, NETLIFYDEVWARN, normalizeConfig, } from '../../utils/command-helpers.js';
9
+ import { BANG, NETLIFYDEV, NETLIFYDEVERR, NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, log, normalizeConfig, } from '../../utils/command-helpers.js';
10
10
  import detectServerSettings, { getConfigWithPlugins } from '../../utils/detect-server-settings.js';
11
- import { getDotEnvVariables, getSiteInformation, injectEnvVariables, UNLINKED_SITE_MOCK_ID } from '../../utils/dev.js';
11
+ import { UNLINKED_SITE_MOCK_ID, getDotEnvVariables, getSiteInformation, injectEnvVariables } from '../../utils/dev.js';
12
12
  import { getEnvelopeEnv, normalizeContext } from '../../utils/env/index.js';
13
13
  import { ensureNetlifyIgnore } from '../../utils/gitignore.js';
14
14
  import { getLiveTunnelSlug, startLiveTunnel } from '../../utils/live-tunnel.js';
@@ -84,7 +84,7 @@ export const dev = async (options, command) => {
84
84
  siteID: site.id ?? UNLINKED_SITE_MOCK_ID,
85
85
  });
86
86
  env[BLOBS_CONTEXT_VARIABLE] = { sources: ['internal'], value: encodeBlobsContext(blobsContext) };
87
- if (!options.offline && siteInfo.use_envelope) {
87
+ if (!options.offline) {
88
88
  env = await getEnvelopeEnv({ api, context: options.context, env, siteInfo });
89
89
  log(`${NETLIFYDEVLOG} Injecting environment variable values for ${chalk.yellow('all scopes')}`);
90
90
  }
@@ -1 +1 @@
1
- {"version":3,"file":"env-clone.d.ts","sourceRoot":"","sources":["../../../src/commands/env/env-clone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAIxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAgK5C,eAAO,MAAM,QAAQ,YAAmB,YAAY,WAAW,WAAW,qBAkDzE,CAAA"}
1
+ {"version":3,"file":"env-clone.d.ts","sourceRoot":"","sources":["../../../src/commands/env/env-clone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAGxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAkD5C,eAAO,MAAM,QAAQ,YAAmB,YAAY,WAAW,WAAW,qBAuCzE,CAAA"}
@@ -1,5 +1,4 @@
1
- import { chalk, error as logError, log } from '../../utils/command-helpers.js';
2
- import { translateFromEnvelopeToMongo, translateFromMongoToEnvelope } from '../../utils/env/index.js';
1
+ import { chalk, log, error as logError } from '../../utils/command-helpers.js';
3
2
  // @ts-expect-error TS(7006) FIXME: Parameter 'api' implicitly has an 'any' type.
4
3
  const safeGetSite = async (api, siteId) => {
5
4
  try {
@@ -10,41 +9,12 @@ const safeGetSite = async (api, siteId) => {
10
9
  return { error };
11
10
  }
12
11
  };
13
- /**
14
- * Copies the env from a site configured with Envelope to a site not configured with Envelope
15
- * @returns {Promise<boolean>}
16
- */
17
- // @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message
18
- const envelopeToMongo = async ({ api, siteFrom, siteTo }) => {
19
- const envelopeVariables = await api.getEnvVars({ accountId: siteFrom.account_slug, siteId: siteFrom.id });
20
- const envFrom = translateFromEnvelopeToMongo(envelopeVariables);
21
- if (Object.keys(envFrom).length === 0) {
22
- log(`${chalk.green(siteFrom.name)} has no environment variables, nothing to clone`);
23
- return false;
24
- }
25
- const envTo = siteTo.build_settings.env || {};
26
- // Merge from site A to site B
27
- const mergedEnv = {
28
- ...envTo,
29
- ...envFrom,
30
- };
31
- // Apply environment variable updates
32
- await api.updateSite({
33
- siteId: siteTo.id,
34
- body: {
35
- build_settings: {
36
- env: mergedEnv,
37
- },
38
- },
39
- });
40
- return true;
41
- };
42
12
  /**
43
13
  * Copies the env from a site configured with Envelope to a different site configured with Envelope
44
14
  * @returns {Promise<boolean>}
45
15
  */
46
16
  // @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message
47
- const envelopeToEnvelope = async ({ api, siteFrom, siteTo }) => {
17
+ const cloneEnvVars = async ({ api, siteFrom, siteTo }) => {
48
18
  const [envelopeFrom, envelopeTo] = await Promise.all([
49
19
  api.getEnvVars({ accountId: siteFrom.account_slug, siteId: siteFrom.id }),
50
20
  api.getEnvVars({ accountId: siteTo.account_slug, siteId: siteTo.id }),
@@ -72,64 +42,6 @@ const envelopeToEnvelope = async ({ api, siteFrom, siteTo }) => {
72
42
  }
73
43
  return true;
74
44
  };
75
- /**
76
- * Copies the env from a site not configured with Envelope to a different site not configured with Envelope
77
- * @returns {Promise<boolean>}
78
- */
79
- // @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message
80
- const mongoToMongo = async ({ api, siteFrom, siteTo }) => {
81
- const [{ build_settings: { env: envFrom = {} }, }, { build_settings: { env: envTo = {} }, },] = [siteFrom, siteTo];
82
- if (Object.keys(envFrom).length === 0) {
83
- log(`${chalk.green(siteFrom.name)} has no environment variables, nothing to clone`);
84
- return false;
85
- }
86
- // Merge from site A to site B
87
- const mergedEnv = {
88
- ...envTo,
89
- ...envFrom,
90
- };
91
- // Apply environment variable updates
92
- await api.updateSite({
93
- siteId: siteTo.id,
94
- body: {
95
- build_settings: {
96
- env: mergedEnv,
97
- },
98
- },
99
- });
100
- return true;
101
- };
102
- /**
103
- * Copies the env from a site not configured with Envelope to a site configured with Envelope
104
- * @returns {Promise<boolean>}
105
- */
106
- // @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message
107
- const mongoToEnvelope = async ({ api, siteFrom, siteTo }) => {
108
- const envFrom = siteFrom.build_settings.env || {};
109
- const keysFrom = Object.keys(envFrom);
110
- if (Object.keys(envFrom).length === 0) {
111
- log(`${chalk.green(siteFrom.name)} has no environment variables, nothing to clone`);
112
- return false;
113
- }
114
- const accountId = siteTo.account_slug;
115
- const siteId = siteTo.id;
116
- const envelopeTo = await api.getEnvVars({ accountId, siteId });
117
- // @ts-expect-error TS(7031) FIXME: Binding element 'key' implicitly has an 'any' type... Remove this comment to see the full error message
118
- const envVarsToDelete = envelopeTo.filter(({ key }) => keysFrom.includes(key));
119
- // delete marked env vars in parallel
120
- // @ts-expect-error TS(7031) FIXME: Binding element 'key' implicitly has an 'any' type... Remove this comment to see the full error message
121
- await Promise.all(envVarsToDelete.map(({ key }) => api.deleteEnvVar({ accountId, siteId, key })));
122
- // hit create endpoint
123
- const body = translateFromMongoToEnvelope(envFrom);
124
- try {
125
- await api.createEnvVars({ accountId, siteId, body });
126
- }
127
- catch (error) {
128
- // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
129
- throw error.json ? error.json.msg : error;
130
- }
131
- return true;
132
- };
133
45
  export const envClone = async (options, command) => {
134
46
  const { api, site } = command.netlify;
135
47
  if (!site.id && !options.from) {
@@ -152,21 +64,7 @@ export const envClone = async (options, command) => {
152
64
  logError(`Can't find site with id ${chalk.bold(siteId.to)}. Please make sure the site exists.`);
153
65
  return false;
154
66
  }
155
- // determine if siteFrom and/or siteTo is on Envelope
156
- let method;
157
- if (!siteFrom.use_envelope && !siteTo.use_envelope) {
158
- method = mongoToMongo;
159
- }
160
- else if (!siteFrom.use_envelope && siteTo.use_envelope) {
161
- method = mongoToEnvelope;
162
- }
163
- else if (siteFrom.use_envelope && !siteTo.use_envelope) {
164
- method = envelopeToMongo;
165
- }
166
- else {
167
- method = envelopeToEnvelope;
168
- }
169
- const success = await method({ api, siteFrom, siteTo });
67
+ const success = await cloneEnvVars({ api, siteFrom, siteTo });
170
68
  if (!success) {
171
69
  return false;
172
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"env-get.d.ts","sourceRoot":"","sources":["../../../src/commands/env/env-get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAIxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAE5C,eAAO,MAAM,MAAM,SAAgB,MAAM,WAAW,YAAY,WAAW,WAAW,+BAyCrF,CAAA"}
1
+ {"version":3,"file":"env-get.d.ts","sourceRoot":"","sources":["../../../src/commands/env/env-get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAIxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAE5C,eAAO,MAAM,MAAM,SAAgB,MAAM,WAAW,YAAY,WAAW,WAAW,+BA+BrF,CAAA"}
@@ -1,4 +1,4 @@
1
- import { chalk, error, log, logJson } from '../../utils/command-helpers.js';
1
+ import { chalk, log, logJson } from '../../utils/command-helpers.js';
2
2
  import { AVAILABLE_CONTEXTS, getEnvelopeEnv } from '../../utils/env/index.js';
3
3
  export const envGet = async (name, options, command) => {
4
4
  const { context, scope } = options;
@@ -9,14 +9,8 @@ export const envGet = async (name, options, command) => {
9
9
  return false;
10
10
  }
11
11
  const { siteInfo } = cachedConfig;
12
- let { env } = cachedConfig;
13
- if (siteInfo.use_envelope) {
14
- env = await getEnvelopeEnv({ api, context, env, key: name, scope, siteInfo });
15
- }
16
- else if (context !== 'dev' || scope !== 'any') {
17
- error(`To specify a context or scope, please run ${chalk.yellow('netlify open:admin')} to open the Netlify UI and opt in to the new environment variables experience from Site settings`);
18
- return false;
19
- }
12
+ const env = await getEnvelopeEnv({ api, context, env: cachedConfig.env, key: name, scope, siteInfo });
13
+ // @ts-expect-error TS(7053) - Element implicitly has an 'any' type
20
14
  const { value } = env[name] || {};
21
15
  // Return json response for piping commands
22
16
  if (options.json) {
@@ -1 +1 @@
1
- {"version":3,"file":"env-import.d.ts","sourceRoot":"","sources":["../../../src/commands/env/env-import.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAKxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAqE5C,eAAO,MAAM,SAAS,aAAoB,MAAM,WAAW,YAAY,WAAW,WAAW,+BA0C5F,CAAA"}
1
+ {"version":3,"file":"env-import.d.ts","sourceRoot":"","sources":["../../../src/commands/env/env-import.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAKxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AA2C5C,eAAO,MAAM,SAAS,aAAoB,MAAM,WAAW,YAAY,WAAW,WAAW,+BAyC5F,CAAA"}
@@ -3,34 +3,12 @@ import AsciiTable from 'ascii-table';
3
3
  import dotenv from 'dotenv';
4
4
  import { exit, log, logJson } from '../../utils/command-helpers.js';
5
5
  import { translateFromEnvelopeToMongo, translateFromMongoToEnvelope } from '../../utils/env/index.js';
6
- /**
7
- * Updates the imported env in the site record
8
- * @returns {Promise<object>}
9
- */
10
- // @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message
11
- const importIntoMongo = async ({ api, importedEnv, options, siteInfo }) => {
12
- const { env = {} } = siteInfo.build_settings;
13
- const siteId = siteInfo.id;
14
- const finalEnv = options.replaceExisting ? importedEnv : { ...env, ...importedEnv };
15
- // Apply environment variable updates
16
- await api.updateSite({
17
- siteId,
18
- body: {
19
- build_settings: {
20
- // Only set imported variables if --replaceExisting or otherwise merge
21
- // imported ones with the current environment variables.
22
- env: finalEnv,
23
- },
24
- },
25
- });
26
- return finalEnv;
27
- };
28
6
  /**
29
7
  * Saves the imported env in the Envelope service
30
8
  * @returns {Promise<object>}
31
9
  */
32
10
  // @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message
33
- const importIntoEnvelope = async ({ api, importedEnv, options, siteInfo }) => {
11
+ const importDotEnv = async ({ api, importedEnv, options, siteInfo }) => {
34
12
  // fetch env vars
35
13
  const accountId = siteInfo.account_slug;
36
14
  const siteId = siteInfo.id;
@@ -84,8 +62,7 @@ export const envImport = async (fileName, options, command) => {
84
62
  return false;
85
63
  }
86
64
  const { siteInfo } = cachedConfig;
87
- const importIntoService = siteInfo.use_envelope ? importIntoEnvelope : importIntoMongo;
88
- const finalEnv = await importIntoService({ api, importedEnv, options, siteInfo });
65
+ const finalEnv = await importDotEnv({ api, importedEnv, options, siteInfo });
89
66
  // Return new environment variables of site if using json flag
90
67
  if (options.json) {
91
68
  logJson(finalEnv);
@@ -1 +1 @@
1
- {"version":3,"file":"env-list.d.ts","sourceRoot":"","sources":["../../../src/commands/env/env-list.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAMxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAiC5C,eAAO,MAAM,OAAO,YAAmB,YAAY,WAAW,WAAW,+BAmFxE,CAAA"}
1
+ {"version":3,"file":"env-list.d.ts","sourceRoot":"","sources":["../../../src/commands/env/env-list.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAMxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAiC5C,eAAO,MAAM,OAAO,YAAmB,YAAY,WAAW,WAAW,+BA0ExE,CAAA"}
@@ -3,7 +3,7 @@ import AsciiTable from 'ascii-table';
3
3
  import { isCI } from 'ci-info';
4
4
  import inquirer from 'inquirer';
5
5
  import logUpdate from 'log-update';
6
- import { chalk, error, log, logJson } from '../../utils/command-helpers.js';
6
+ import { chalk, log, logJson } from '../../utils/command-helpers.js';
7
7
  import { AVAILABLE_CONTEXTS, getEnvelopeEnv, getHumanReadableScopes } from '../../utils/env/index.js';
8
8
  const MASK_LENGTH = 50;
9
9
  const MASK = '*'.repeat(MASK_LENGTH);
@@ -30,25 +30,22 @@ export const envList = async (options, command) => {
30
30
  return false;
31
31
  }
32
32
  const { env, siteInfo } = cachedConfig;
33
- const isUsingEnvelope = siteInfo.use_envelope;
34
- let environment = env;
35
- if (isUsingEnvelope) {
36
- environment = await getEnvelopeEnv({ api, context, env, scope, siteInfo });
37
- }
38
- else if (context !== 'dev' || scope !== 'any') {
39
- error(`To specify a context or scope, please run ${chalk.yellow('netlify open:admin')} to open the Netlify UI and opt in to the new environment variables experience from Site settings`);
40
- return false;
41
- }
33
+ let environment = await getEnvelopeEnv({ api, context, env, scope, siteInfo });
42
34
  // filter out general sources
43
- environment = Object.fromEntries(Object.entries(environment).filter(([, variable]) => variable.sources[0] !== 'general' && variable.sources[0] !== 'internal'));
35
+ environment = Object.fromEntries(Object.entries(environment).filter(
36
+ // @ts-expect-error TS(18046) - 'variable' is of type 'unknown'
37
+ ([, variable]) => variable.sources[0] !== 'general' && variable.sources[0] !== 'internal'));
44
38
  // Return json response for piping commands
45
39
  if (options.json) {
46
- const envDictionary = Object.fromEntries(Object.entries(environment).map(([key, variable]) => [key, variable.value]));
40
+ const envDictionary = Object.fromEntries(
41
+ // @ts-expect-error TS(18046) - 'variable' is of type 'unknown'
42
+ Object.entries(environment).map(([key, variable]) => [key, variable.value]));
47
43
  logJson(envDictionary);
48
44
  return false;
49
45
  }
50
46
  if (options.plain) {
51
47
  const plaintext = Object.entries(environment)
48
+ // @ts-expect-error TS(18046) - 'variable' is of type 'unknown'
52
49
  .map(([key, variable]) => `${key}=${variable.value}`)
53
50
  .join('\n');
54
51
  log(plaintext);
@@ -56,8 +53,8 @@ export const envList = async (options, command) => {
56
53
  }
57
54
  const forSite = `for site ${chalk.green(siteInfo.name)}`;
58
55
  const contextType = AVAILABLE_CONTEXTS.includes(context) ? 'context' : 'branch';
59
- const withContext = isUsingEnvelope ? `in the ${chalk.magenta(options.context)} ${contextType}` : '';
60
- const withScope = isUsingEnvelope && scope !== 'any' ? `and ${chalk.yellow(options.scope)} scope` : '';
56
+ const withContext = `in the ${chalk.magenta(options.context)} ${contextType}`;
57
+ const withScope = scope === 'any' ? '' : `and ${chalk.yellow(options.scope)} scope`;
61
58
  if (Object.keys(environment).length === 0) {
62
59
  log(`No environment variables set ${forSite} ${withContext} ${withScope}`);
63
60
  return false;
@@ -66,10 +63,10 @@ export const envList = async (options, command) => {
66
63
  const count = Object.keys(environment).length;
67
64
  log(`${count} environment variable${count === 1 ? '' : 's'} ${forSite} ${withContext} ${withScope}`);
68
65
  if (isCI) {
69
- log(getTable({ environment, hideValues: false, scopesColumn: isUsingEnvelope }));
66
+ log(getTable({ environment, hideValues: false, scopesColumn: true }));
70
67
  return false;
71
68
  }
72
- logUpdate(getTable({ environment, hideValues: true, scopesColumn: isUsingEnvelope }));
69
+ logUpdate(getTable({ environment, hideValues: true, scopesColumn: true }));
73
70
  const { showValues } = await inquirer.prompt([
74
71
  {
75
72
  type: 'confirm',
@@ -81,7 +78,7 @@ export const envList = async (options, command) => {
81
78
  if (showValues) {
82
79
  // since inquirer adds a prompt, we need to account for it when printing the table again
83
80
  log(ansiEscapes.eraseLines(3));
84
- logUpdate(getTable({ environment, hideValues: false, scopesColumn: isUsingEnvelope }));
81
+ logUpdate(getTable({ environment, hideValues: false, scopesColumn: true }));
85
82
  log(`${chalk.cyan('?')} Show values? ${chalk.cyan('Yes')}`);
86
83
  }
87
84
  };
@@ -1 +1 @@
1
- {"version":3,"file":"env-set.d.ts","sourceRoot":"","sources":["../../../src/commands/env/env-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAIxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAgI5C,eAAO,MAAM,MAAM,QAAe,MAAM,SAAS,MAAM,WAAW,YAAY,WAAW,WAAW,+BA8CnG,CAAA"}
1
+ {"version":3,"file":"env-set.d.ts","sourceRoot":"","sources":["../../../src/commands/env/env-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAIxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAyG5C,eAAO,MAAM,MAAM,QAAe,MAAM,SAAS,MAAM,WAAW,YAAY,WAAW,WAAW,+BAkCnG,CAAA"}
@@ -1,27 +1,5 @@
1
1
  import { chalk, error, log, logJson } from '../../utils/command-helpers.js';
2
2
  import { AVAILABLE_CONTEXTS, AVAILABLE_SCOPES, translateFromEnvelopeToMongo } from '../../utils/env/index.js';
3
- /**
4
- * Updates the env for a site record with a new key/value pair
5
- * @returns {Promise<object>}
6
- */
7
- // @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message
8
- const setInMongo = async ({ api, key, siteInfo, value }) => {
9
- const { env = {} } = siteInfo.build_settings;
10
- const newEnv = {
11
- ...env,
12
- [key]: value,
13
- };
14
- // Apply environment variable updates
15
- await api.updateSite({
16
- siteId: siteInfo.id,
17
- body: {
18
- build_settings: {
19
- env: newEnv,
20
- },
21
- },
22
- });
23
- return newEnv;
24
- };
25
3
  /**
26
4
  * Updates the env for a site configured with Envelope with a new key/value pair
27
5
  * @returns {Promise<object | boolean>}
@@ -122,18 +100,8 @@ export const envSet = async (key, value, options, command) => {
122
100
  return false;
123
101
  }
124
102
  const { siteInfo } = cachedConfig;
125
- let finalEnv;
126
103
  // Get current environment variables set in the UI
127
- if (siteInfo.use_envelope) {
128
- finalEnv = await setInEnvelope({ api, siteInfo, key, value, context, scope, secret });
129
- }
130
- else if (context || scope) {
131
- error(`To specify a context or scope, please run ${chalk.yellow('netlify open:admin')} to open the Netlify UI and opt in to the new environment variables experience from Site settings`);
132
- return false;
133
- }
134
- else {
135
- finalEnv = await setInMongo({ api, siteInfo, key, value });
136
- }
104
+ const finalEnv = await setInEnvelope({ api, siteInfo, key, value, context, scope, secret });
137
105
  if (!finalEnv) {
138
106
  return false;
139
107
  }
@@ -1 +1 @@
1
- {"version":3,"file":"env-unset.d.ts","sourceRoot":"","sources":["../../../src/commands/env/env-unset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAIxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AA0F5C,eAAO,MAAM,QAAQ,QAAe,MAAM,WAAW,YAAY,WAAW,WAAW,+BAkCtF,CAAA"}
1
+ {"version":3,"file":"env-unset.d.ts","sourceRoot":"","sources":["../../../src/commands/env/env-unset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAIxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AA6D5C,eAAO,MAAM,QAAQ,QAAe,MAAM,WAAW,YAAY,WAAW,WAAW,+BAsBtF,CAAA"}
@@ -1,27 +1,5 @@
1
- import { chalk, error, log, logJson } from '../../utils/command-helpers.js';
1
+ import { chalk, log, logJson } from '../../utils/command-helpers.js';
2
2
  import { AVAILABLE_CONTEXTS, translateFromEnvelopeToMongo } from '../../utils/env/index.js';
3
- /**
4
- * Deletes a given key from the env of a site record
5
- * @returns {Promise<object>}
6
- */
7
- // @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message
8
- const unsetInMongo = async ({ api, key, siteInfo }) => {
9
- // Get current environment variables set in the UI
10
- const { build_settings: { env = {} }, } = siteInfo;
11
- const newEnv = env;
12
- // Delete environment variable from current variables
13
- delete newEnv[key];
14
- // Apply environment variable updates
15
- await api.updateSite({
16
- siteId: siteInfo.id,
17
- body: {
18
- build_settings: {
19
- env: newEnv,
20
- },
21
- },
22
- });
23
- return newEnv;
24
- };
25
3
  /**
26
4
  * Deletes a given key from the env of a site configured with Envelope
27
5
  * @returns {Promise<object>}
@@ -82,17 +60,7 @@ export const envUnset = async (key, options, command) => {
82
60
  return false;
83
61
  }
84
62
  const { siteInfo } = cachedConfig;
85
- let finalEnv;
86
- if (siteInfo.use_envelope) {
87
- finalEnv = await unsetInEnvelope({ api, context, siteInfo, key });
88
- }
89
- else if (context) {
90
- error(`To specify a context, please run ${chalk.yellow('netlify open:admin')} to open the Netlify UI and opt in to the new environment variables experience from Site settings`);
91
- return false;
92
- }
93
- else {
94
- finalEnv = await unsetInMongo({ api, siteInfo, key });
95
- }
63
+ const finalEnv = await unsetInEnvelope({ api, context, siteInfo, key });
96
64
  // Return new environment variables of site if using json flag
97
65
  if (options.json) {
98
66
  logJson(finalEnv);
@@ -1 +1 @@
1
- {"version":3,"file":"functions-create.d.ts","sourceRoot":"","sources":["../../../src/commands/functions/functions-create.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAexC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AA0tB5C,eAAO,MAAM,eAAe,SAAgB,MAAM,WAAW,YAAY,WAAW,WAAW,kBAQ9F,CAAA"}
1
+ {"version":3,"file":"functions-create.d.ts","sourceRoot":"","sources":["../../../src/commands/functions/functions-create.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAcxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAutB5C,eAAO,MAAM,eAAe,SAAgB,MAAM,WAAW,YAAY,WAAW,WAAW,kBAQ9F,CAAA"}
@@ -5,9 +5,6 @@ import { createRequire } from 'module';
5
5
  import path, { dirname, join, relative } from 'path';
6
6
  import process from 'process';
7
7
  import { fileURLToPath, pathToFileURL } from 'url';
8
- import { promisify } from 'util';
9
- // @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'copy... Remove this comment to see the full error message
10
- import copyTemplateDirOriginal from 'copy-template-dir';
11
8
  import { findUp } from 'find-up';
12
9
  import fuzzy from 'fuzzy';
13
10
  import inquirer from 'inquirer';
@@ -16,10 +13,10 @@ import ora from 'ora';
16
13
  import { fileExistsAsync } from '../../lib/fs.js';
17
14
  import { getAddons, getCurrentAddon, getSiteData } from '../../utils/addons/prepare.js';
18
15
  import { NETLIFYDEVERR, NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, error, log } from '../../utils/command-helpers.js';
16
+ import { copyTemplateDir } from '../../utils/copy-template-dir/copy-template-dir.js';
19
17
  import { getDotEnvVariables, injectEnvVariables } from '../../utils/dev.js';
20
18
  import execa from '../../utils/execa.js';
21
19
  import { readRepoURL, validateRepoURL } from '../../utils/read-repo-url.js';
22
- const copyTemplateDir = promisify(copyTemplateDirOriginal);
23
20
  const require = createRequire(import.meta.url);
24
21
  const templatesDir = path.resolve(dirname(fileURLToPath(import.meta.url)), '../../../functions-templates');
25
22
  /**
@@ -313,7 +310,7 @@ const downloadFromURL = async function (command, options, argumentName, function
313
310
  const res = await fetch(downloadUrl);
314
311
  const finalName = path.basename(name, '.js') === functionName ? `${nameToUse}.js` : name;
315
312
  const dest = fs.createWriteStream(path.join(fnFolder, finalName));
316
- res.body.pipe(dest);
313
+ res.body?.pipe(dest);
317
314
  }
318
315
  catch (error_) {
319
316
  throw new Error(`Error while retrieving ${downloadUrl} ${error_}`);
@@ -393,7 +390,6 @@ const installDeps = async ({ functionPackageJson, functionPath, functionsDir })
393
390
  * @param {'edge' | 'serverless'} funcType
394
391
  */
395
392
  // @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type.
396
- // eslint-disable-next-line max-params
397
393
  const scaffoldFromTemplate = async function (command, options, argumentName, functionsDir, funcType) {
398
394
  // pull the rest of the metadata from the template
399
395
  const chosenTemplate = await pickTemplate(options, funcType);
@@ -437,7 +433,6 @@ const scaffoldFromTemplate = async function (command, options, argumentName, fun
437
433
  // be removed before the command finishes.
438
434
  const omittedFromOutput = new Set(['.netlify-function-template.mjs', 'package.json', 'package-lock.json']);
439
435
  const createdFiles = await copyTemplateDir(pathToTemplate, functionPath, vars);
440
- // @ts-expect-error TS(7006) FIXME: Parameter 'filePath' implicitly has an 'any' type.
441
436
  createdFiles.forEach((filePath) => {
442
437
  const filename = path.basename(filePath);
443
438
  if (!omittedFromOutput.has(filename)) {
@@ -460,7 +455,7 @@ const scaffoldFromTemplate = async function (command, options, argumentName, fun
460
455
  spinner.succeed(`Installed dependencies for ${name}`);
461
456
  }
462
457
  if (funcType === 'edge') {
463
- registerEFInToml(name, command.netlify);
458
+ await registerEFInToml(name, command.netlify);
464
459
  }
465
460
  await installAddons(command, addons, path.resolve(functionPath));
466
461
  await handleOnComplete({ command, onComplete });
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/commands/integration/deploy.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAUxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAS5C,wBAAgB,cAAc,CAAC,WAAW,KAAA,EAAE,YAAY,KAAA,OAOvD;AA0FD,wBAAsB,mBAAmB,CAAC,UAAU,KAAA,EAAE,MAAM,KAAA,EAAE,SAAS,KAAA,EAAE,sBAAsB,KAAA,EAAE,KAAK,KAAA,iBAuErG;AAED,wBAAsB,iBAAiB,CAErC,UAAU,KAAA,EAEV,OAAO,KAAA,EAEP,MAAM,KAAA,EAEN,SAAS,KAAA,EAET,sBAAsB,KAAA,EAEtB,KAAK,KAAA,EAEL,qBAAqB,KAAA,iBA4HtB;AA4BD,eAAO,MAAM,gBAAgB,0BA6B5B,CAAA;AAED,eAAO,MAAM,MAAM,YAAmB,YAAY,WAAW,WAAW,kBAkEvE,CAAA"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/commands/integration/deploy.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAUxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAS5C,wBAAgB,cAAc,CAAC,WAAW,KAAA,EAAE,YAAY,KAAA,OAOvD;AA0FD,wBAAsB,mBAAmB,CAAC,UAAU,KAAA,EAAE,MAAM,KAAA,EAAE,SAAS,KAAA,EAAE,sBAAsB,KAAA,EAAE,KAAK,KAAA,iBA0ErG;AAED,wBAAsB,iBAAiB,CAErC,UAAU,KAAA,EAEV,OAAO,KAAA,EAEP,MAAM,KAAA,EAEN,SAAS,KAAA,EAET,sBAAsB,KAAA,EAEtB,KAAK,KAAA,EAEL,qBAAqB,KAAA,iBA4HtB;AA4BD,eAAO,MAAM,gBAAgB,0BA6B5B,CAAA;AAED,eAAO,MAAM,MAAM,YAAmB,YAAY,WAAW,WAAW,kBAkEvE,CAAA"}