@contentful/app-scripts 1.31.1 → 1.32.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 (40) hide show
  1. package/README.md +35 -0
  2. package/lib/activate/activate-bundle.js +1 -2
  3. package/lib/activate/build-bundle-activate-settings.js +1 -2
  4. package/lib/activate/get-activate-args.js +1 -2
  5. package/lib/analytics.js +1 -2
  6. package/lib/bin.js +9 -0
  7. package/lib/build-functions/build-functions.d.ts +11 -0
  8. package/lib/build-functions/build-functions.js +108 -0
  9. package/lib/build-functions/index.d.ts +6 -0
  10. package/lib/build-functions/index.js +14 -0
  11. package/lib/build-functions/prompt-build-functions-options.d.ts +2 -0
  12. package/lib/build-functions/prompt-build-functions-options.js +34 -0
  13. package/lib/cache-credential/index.js +1 -2
  14. package/lib/clean-up/build-clean-up-settings.js +1 -2
  15. package/lib/clean-up/clean-up-bundles.js +1 -2
  16. package/lib/clean-up/get-clean-up-settings.js +1 -2
  17. package/lib/constants.d.ts +1 -0
  18. package/lib/constants.js +2 -1
  19. package/lib/create-app-definition/build-app-definition-settings.js +1 -2
  20. package/lib/create-app-definition/build-app-parameter-settings.js +1 -2
  21. package/lib/create-app-definition/create-app-definition.js +1 -2
  22. package/lib/definition-api.js +2 -3
  23. package/lib/feedback/feedback.js +2 -3
  24. package/lib/get-management-token.js +1 -2
  25. package/lib/index.d.ts +1 -0
  26. package/lib/index.js +3 -1
  27. package/lib/install/install.js +1 -2
  28. package/lib/open/open-settings.js +2 -2
  29. package/lib/organization-api.js +2 -3
  30. package/lib/types.d.ts +5 -0
  31. package/lib/upload/build-upload-settings.js +2 -3
  32. package/lib/upload/create-app-bundle.js +2 -3
  33. package/lib/upload/create-app-upload.js +1 -2
  34. package/lib/upload/create-zip-from-directory.d.ts +0 -1
  35. package/lib/upload/create-zip-from-directory.js +1 -2
  36. package/lib/upload/get-upload-settings-args.js +1 -2
  37. package/lib/upload/validate-bundle.d.ts +1 -1
  38. package/lib/utils.js +2 -2
  39. package/lib/validate-arguments.js +1 -2
  40. package/package.json +9 -6
package/README.md CHANGED
@@ -255,3 +255,38 @@ We gather depersonalized usage data of our CLI tools in order to improve experie
255
255
  > ```
256
256
  > DISABLE_ANALYTICS=true npx create-contentful-app
257
257
  > ```
258
+
259
+ ### Build Contentful Function source
260
+
261
+ Builds the source code for a Contentful Function into an App Framework compatible bundle.
262
+
263
+ #### Interactive mode:
264
+
265
+ In the interactive mode, the CLI will prompt for custom configuration, but none of the options are required.
266
+
267
+ > **Example**
268
+ >
269
+ > ```shell
270
+ > $ npx --no-install @contentful/app-scripts build-functions
271
+ > ```
272
+
273
+ #### Non-interactive mode:
274
+
275
+ When passing the `--ci` argument adding all variables as arguments is required
276
+
277
+ > **Example**
278
+ >
279
+ > ```shell
280
+ > $ npx --no-install @contentful/app-scripts build-functions --ci \
281
+ > --manifest-file path/to/contentful/app/manifest.json \
282
+ > --esbuild-config path/to/custom/esbuild/config.js \
283
+ > --watch
284
+ > ```
285
+
286
+ **Options:**
287
+
288
+ Options:
289
+ -e, --esbuild-config <path> custom esbuild config file path
290
+ -m, --manifest-file <path> Contentful app manifest file path
291
+ -w, --watch watch for changes
292
+ -h, --help display help for command
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.activateBundle = void 0;
6
+ exports.activateBundle = activateBundle;
7
7
  const ora_1 = __importDefault(require("ora"));
8
8
  const chalk_1 = require("chalk");
9
9
  const utils_1 = require("../utils");
@@ -47,4 +47,3 @@ async function activateBundle({ accessToken, organization, definition, bundleId,
47
47
  Ready to share your app with the world? Submit it to the Developer Showcase (${(0, chalk_1.cyan)('https://ctfl.io/dev-showcase')}) or our Marketplace (${(0, chalk_1.cyan)('https://ctfl.io/submit-app')}).
48
48
  `);
49
49
  }
50
- exports.activateBundle = activateBundle;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.buildBundleActivateSettings = void 0;
6
+ exports.buildBundleActivateSettings = buildBundleActivateSettings;
7
7
  const inquirer_1 = __importDefault(require("inquirer"));
8
8
  const get_app_info_1 = require("../get-app-info");
9
9
  async function buildBundleActivateSettings(options) {
@@ -32,4 +32,3 @@ async function buildBundleActivateSettings(options) {
32
32
  ...appInfo,
33
33
  };
34
34
  }
35
- exports.buildBundleActivateSettings = buildBundleActivateSettings;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getActivateSettingsArgs = void 0;
6
+ exports.getActivateSettingsArgs = getActivateSettingsArgs;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const ora_1 = __importDefault(require("ora"));
9
9
  const get_app_info_1 = require("../get-app-info");
@@ -37,4 +37,3 @@ async function getActivateSettingsArgs(options) {
37
37
  validateSpinner.stop();
38
38
  }
39
39
  }
40
- exports.getActivateSettingsArgs = getActivateSettingsArgs;
package/lib/analytics.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.track = void 0;
3
+ exports.track = track;
4
4
  const analytics_node_1 = require("@segment/analytics-node");
5
5
  // Public write key scoped to data source
6
6
  const SEGMENT_WRITE_KEY = 'IzCq3j4dQlTAgLdMykRW9oBHQKUy1xMm';
@@ -35,4 +35,3 @@ function track({ command, ci }) {
35
35
  // ignore any error, to not block the call
36
36
  }
37
37
  }
38
- exports.track = track;
package/lib/bin.js CHANGED
@@ -73,6 +73,15 @@ async function runCommand(command, options) {
73
73
  .action(async (options) => {
74
74
  await runCommand(index_1.install, options);
75
75
  });
76
+ commander_1.program
77
+ .command('build-functions')
78
+ .description('Builds Contentful Function source into an App Framework compatible bundle.')
79
+ .option('-e, --esbuild-config <path>', 'custom esbuild config file path')
80
+ .option('-m, --manifest-file <path>', 'Contentful app manifest file path')
81
+ .option('-w, --watch', 'watch for changes')
82
+ .action(async (options) => {
83
+ await runCommand(index_1.buildFunctions, options);
84
+ });
76
85
  commander_1.program.hook('preAction', (thisCommand) => {
77
86
  (0, index_1.track)({ command: thisCommand.args[0], ci: thisCommand.opts().ci });
78
87
  });
@@ -0,0 +1,11 @@
1
+ import { type BuildFunctionsOptions, type ContentfulFunction } from '../types';
2
+ type ContentfulFunctionToBuild = Omit<ContentfulFunction, 'entryFile'> & {
3
+ entryFile: string;
4
+ };
5
+ export declare const validateFunctions: (manifest: Record<string, any>) => void;
6
+ export declare const resolveManifestFile: (options: BuildFunctionsOptions, cwd?: string) => any;
7
+ export declare const resolveEsBuildConfig: (options: BuildFunctionsOptions, manifest: {
8
+ functions: ContentfulFunctionToBuild[];
9
+ }, cwd?: string) => any;
10
+ export declare function buildFunctions(options: BuildFunctionsOptions): Promise<void>;
11
+ export {};
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resolveEsBuildConfig = exports.resolveManifestFile = exports.validateFunctions = void 0;
7
+ exports.buildFunctions = buildFunctions;
8
+ /* eslint-disable @typescript-eslint/no-var-requires */
9
+ const esbuild_1 = __importDefault(require("esbuild"));
10
+ const path_1 = require("path");
11
+ const node_modules_polyfill_1 = require("@esbuild-plugins/node-modules-polyfill");
12
+ const node_globals_polyfill_1 = require("@esbuild-plugins/node-globals-polyfill");
13
+ const zod_1 = require("zod");
14
+ const functionManifestSchema = zod_1.z
15
+ .object({
16
+ functions: zod_1.z.array(zod_1.z
17
+ .object({
18
+ id: zod_1.z.string(),
19
+ name: zod_1.z.string(),
20
+ description: zod_1.z.string(),
21
+ path: zod_1.z.string(),
22
+ entryFile: zod_1.z.string(),
23
+ accepts: zod_1.z.array(zod_1.z.string()),
24
+ })
25
+ .required()),
26
+ })
27
+ .required();
28
+ const validateFunctions = (manifest) => {
29
+ const validationResult = functionManifestSchema.safeParse(manifest);
30
+ if (!validationResult.success) {
31
+ throw new Error(`Invalid Contentful Function manifest: ${JSON.stringify(validationResult.error.issues)}`);
32
+ }
33
+ const uniqueValues = new Set();
34
+ validationResult.data.functions.forEach((contentfulFunction) => {
35
+ const { id, path, entryFile, accepts } = contentfulFunction;
36
+ if (uniqueValues.has(id)) {
37
+ throw new Error(`Duplicate function id: '${id}'`);
38
+ }
39
+ if (uniqueValues.has(path)) {
40
+ throw new Error(`Duplicate function path: '${path}'`);
41
+ }
42
+ if (uniqueValues.has(entryFile)) {
43
+ throw new Error(`Duplicate entryFile path: '${entryFile}'`);
44
+ }
45
+ uniqueValues.add(entryFile);
46
+ uniqueValues.add(path);
47
+ uniqueValues.add(id);
48
+ const acceptsSet = new Set(accepts);
49
+ if (acceptsSet.size !== accepts.length) {
50
+ throw new Error(`Duplicate values found in 'accepts' for function with id '${id}'.`);
51
+ }
52
+ });
53
+ };
54
+ exports.validateFunctions = validateFunctions;
55
+ const resolveManifestFile = (options, cwd = process.cwd()) => {
56
+ return require(options.manifestFile
57
+ ? (0, path_1.resolve)(cwd, options.manifestFile)
58
+ : (0, path_1.resolve)(cwd, 'contentful-app-manifest.json'));
59
+ };
60
+ exports.resolveManifestFile = resolveManifestFile;
61
+ const getEntryPoints = (manifest, cwd = process.cwd()) => {
62
+ return manifest.functions.reduce((result, contentfulFunction) => {
63
+ const fileProperties = (0, path_1.parse)(contentfulFunction.path);
64
+ const fileName = (0, path_1.join)(fileProperties.dir, fileProperties.name);
65
+ result[fileName] = (0, path_1.resolve)(cwd, contentfulFunction.entryFile);
66
+ return result;
67
+ }, {});
68
+ };
69
+ const resolveEsBuildConfig = (options, manifest, cwd = process.cwd()) => {
70
+ return options.esbuildConfig
71
+ ? require((0, path_1.resolve)(cwd, options.esbuildConfig))
72
+ : {
73
+ entryPoints: getEntryPoints(manifest, cwd),
74
+ bundle: true,
75
+ outdir: 'build',
76
+ format: 'esm',
77
+ target: 'es2022',
78
+ minify: true,
79
+ define: {
80
+ global: 'globalThis',
81
+ },
82
+ plugins: [(0, node_modules_polyfill_1.NodeModulesPolyfillPlugin)(), (0, node_globals_polyfill_1.NodeGlobalsPolyfillPlugin)()],
83
+ logLevel: 'info',
84
+ };
85
+ };
86
+ exports.resolveEsBuildConfig = resolveEsBuildConfig;
87
+ async function buildFunctions(options) {
88
+ const manifest = (0, exports.resolveManifestFile)(options);
89
+ try {
90
+ console.log('Building functions');
91
+ (0, exports.validateFunctions)(manifest);
92
+ const esbuildConfig = (0, exports.resolveEsBuildConfig)(options, manifest);
93
+ if (options.watch) {
94
+ const context = await esbuild_1.default.context(esbuildConfig);
95
+ await context.watch();
96
+ }
97
+ else {
98
+ await esbuild_1.default.build(esbuildConfig);
99
+ }
100
+ return;
101
+ }
102
+ catch (e) {
103
+ const error = e;
104
+ error.message = `Error building functions: ${e.message}`;
105
+ console.error(error.message);
106
+ throw Error(error.message, { cause: error.cause });
107
+ }
108
+ }
@@ -0,0 +1,6 @@
1
+ import { buildFunctions as runBuild } from './build-functions';
2
+ import { type BuildFunctionsOptions } from '../types';
3
+ export declare const buildFunctions: {
4
+ interactive: (options: BuildFunctionsOptions) => Promise<void>;
5
+ nonInteractive: typeof runBuild;
6
+ };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildFunctions = void 0;
4
+ const build_functions_1 = require("./build-functions");
5
+ const prompt_build_functions_options_1 = require("./prompt-build-functions-options");
6
+ const interactive = async (options) => {
7
+ const opts = await (0, prompt_build_functions_options_1.promptBuildFunctionsOptions)(options);
8
+ await (0, build_functions_1.buildFunctions)(opts);
9
+ };
10
+ const nonInteractive = build_functions_1.buildFunctions;
11
+ exports.buildFunctions = {
12
+ interactive,
13
+ nonInteractive,
14
+ };
@@ -0,0 +1,2 @@
1
+ import { type BuildFunctionsOptions } from '../types';
2
+ export declare function promptBuildFunctionsOptions(options: BuildFunctionsOptions): Promise<BuildFunctionsOptions>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.promptBuildFunctionsOptions = promptBuildFunctionsOptions;
4
+ const inquirer_1 = require("inquirer");
5
+ const constants_1 = require("../constants");
6
+ async function promptBuildFunctionsOptions(options) {
7
+ const { manifestFile, watch, esbuildConfig } = options;
8
+ const prompts = [];
9
+ if (manifestFile === undefined) {
10
+ prompts.push({
11
+ type: 'string',
12
+ name: 'manifestFile',
13
+ message: `Path to your Contentful app manifest file (optional):`,
14
+ default: constants_1.DEFAULT_APP_MANIFEST_PATH,
15
+ });
16
+ }
17
+ if (watch === undefined) {
18
+ prompts.push({
19
+ type: 'boolean',
20
+ name: 'watch',
21
+ message: `Re-build your function files on changes (optional):`,
22
+ default: false,
23
+ });
24
+ }
25
+ if (esbuildConfig === undefined) {
26
+ prompts.push({
27
+ type: 'string',
28
+ name: 'esbuildConfig',
29
+ message: `Path to your custom esbuild config file (optional):`,
30
+ });
31
+ }
32
+ const buildFunctionsOptions = await (0, inquirer_1.prompt)(prompts);
33
+ return buildFunctionsOptions;
34
+ }
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.cacheEnvVars = void 0;
6
+ exports.cacheEnvVars = cacheEnvVars;
7
7
  const dotenv_1 = __importDefault(require("dotenv"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const os_1 = require("os");
@@ -71,4 +71,3 @@ async function cacheEnvVars(envObj) {
71
71
  `);
72
72
  }
73
73
  }
74
- exports.cacheEnvVars = cacheEnvVars;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildCleanUpSettings = void 0;
3
+ exports.buildCleanUpSettings = buildCleanUpSettings;
4
4
  const inquirer_1 = require("inquirer");
5
5
  const constants_1 = require("../constants");
6
6
  const get_app_info_1 = require("../get-app-info");
@@ -31,4 +31,3 @@ async function buildCleanUpSettings(options) {
31
31
  ...appInfo,
32
32
  };
33
33
  }
34
- exports.buildCleanUpSettings = buildCleanUpSettings;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.cleanUpBundles = void 0;
6
+ exports.cleanUpBundles = cleanUpBundles;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const ora_1 = __importDefault(require("ora"));
9
9
  const bottleneck_1 = __importDefault(require("bottleneck"));
@@ -99,4 +99,3 @@ ${chalk_1.default.cyan('Info:')} ${bundlesToDelete.length} bundle${bundlesToDele
99
99
  return (0, utils_1.throwError)(e, 'Something went wrong deleting the bundles');
100
100
  }
101
101
  }
102
- exports.cleanUpBundles = cleanUpBundles;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getCleanUpSettingsArgs = void 0;
6
+ exports.getCleanUpSettingsArgs = getCleanUpSettingsArgs;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const ora_1 = __importDefault(require("ora"));
9
9
  const constants_1 = require("../constants");
@@ -37,4 +37,3 @@ async function getCleanUpSettingsArgs(options) {
37
37
  validateSpinner.stop();
38
38
  }
39
39
  }
40
- exports.getCleanUpSettingsArgs = getCleanUpSettingsArgs;
@@ -7,3 +7,4 @@ export declare const DEFAULT_BUNDLES_TO_FETCH = 1000;
7
7
  export declare const MAX_CONCURRENT_DELETION_CALLS = 5;
8
8
  export declare const DEFAULT_CONTENTFUL_API_HOST = "api.contentful.com";
9
9
  export declare const DEFAULT_CONTENTFUL_APP_HOST = "app.contentful.com";
10
+ export declare const DEFAULT_APP_MANIFEST_PATH = "contentful-app-manifest.json";
package/lib/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_CONTENTFUL_APP_HOST = exports.DEFAULT_CONTENTFUL_API_HOST = exports.MAX_CONCURRENT_DELETION_CALLS = exports.DEFAULT_BUNDLES_TO_FETCH = exports.DEFAULT_BUNDLES_TO_KEEP = exports.APP_DEF_ENV_KEY = exports.ORG_ID_ENV_KEY = exports.ACCESS_TOKEN_ENV_KEY = exports.DOTENV_FILE = void 0;
3
+ exports.DEFAULT_APP_MANIFEST_PATH = exports.DEFAULT_CONTENTFUL_APP_HOST = exports.DEFAULT_CONTENTFUL_API_HOST = exports.MAX_CONCURRENT_DELETION_CALLS = exports.DEFAULT_BUNDLES_TO_FETCH = exports.DEFAULT_BUNDLES_TO_KEEP = exports.APP_DEF_ENV_KEY = exports.ORG_ID_ENV_KEY = exports.ACCESS_TOKEN_ENV_KEY = exports.DOTENV_FILE = void 0;
4
4
  exports.DOTENV_FILE = '.env';
5
5
  exports.ACCESS_TOKEN_ENV_KEY = 'CONTENTFUL_ACCESS_TOKEN';
6
6
  exports.ORG_ID_ENV_KEY = 'CONTENTFUL_ORG_ID';
@@ -10,3 +10,4 @@ exports.DEFAULT_BUNDLES_TO_FETCH = 1000;
10
10
  exports.MAX_CONCURRENT_DELETION_CALLS = 5;
11
11
  exports.DEFAULT_CONTENTFUL_API_HOST = 'api.contentful.com';
12
12
  exports.DEFAULT_CONTENTFUL_APP_HOST = 'app.contentful.com';
13
+ exports.DEFAULT_APP_MANIFEST_PATH = 'contentful-app-manifest.json';
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.buildAppDefinitionSettings = void 0;
6
+ exports.buildAppDefinitionSettings = buildAppDefinitionSettings;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const inquirer_1 = __importDefault(require("inquirer"));
9
9
  const path_1 = __importDefault(require("path"));
@@ -135,4 +135,3 @@ NOTE: This will create an app definition in your Contentful organization.
135
135
  appDefinitionSettings.locations = ['dialog', ...appDefinitionSettings.locations];
136
136
  return appDefinitionSettings;
137
137
  }
138
- exports.buildAppDefinitionSettings = buildAppDefinitionSettings;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.buildAppParameterSettings = void 0;
6
+ exports.buildAppParameterSettings = buildAppParameterSettings;
7
7
  const inquirer_1 = __importDefault(require("inquirer"));
8
8
  const lodash_1 = require("lodash");
9
9
  const PARAMETER_ID_RE = /^[a-zA-Z][a-zA-Z0-9_]*$/;
@@ -178,4 +178,3 @@ async function buildAppParameterSettings() {
178
178
  }
179
179
  return parameters;
180
180
  }
181
- exports.buildAppParameterSettings = buildAppParameterSettings;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createAppDefinition = void 0;
6
+ exports.createAppDefinition = createAppDefinition;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const contentful_management_1 = require("contentful-management");
9
9
  const chalk_1 = __importDefault(require("chalk"));
@@ -114,4 +114,3 @@ async function createAppDefinition(accessToken, appDefinitionSettings) {
114
114
  throw err;
115
115
  }
116
116
  }
117
- exports.createAppDefinition = createAppDefinition;
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getDefinitionById = exports.selectDefinition = void 0;
6
+ exports.selectDefinition = selectDefinition;
7
+ exports.getDefinitionById = getDefinitionById;
7
8
  const ora_1 = __importDefault(require("ora"));
8
9
  const utils_1 = require("./utils");
9
10
  const constants_1 = require("./constants");
@@ -34,7 +35,6 @@ async function selectDefinition(client, orgId) {
34
35
  defSpinner.stop();
35
36
  return await (0, utils_1.selectFromList)(definitions, 'Select an app:', constants_1.APP_DEF_ENV_KEY);
36
37
  }
37
- exports.selectDefinition = selectDefinition;
38
38
  async function getDefinitionById(client, orgId, defId) {
39
39
  try {
40
40
  const organization = await client.getOrganization(orgId);
@@ -48,4 +48,3 @@ async function getDefinitionById(client, orgId, defId) {
48
48
  return (0, utils_1.throwError)(err, 'Could not fetch your app-definition. Make sure you provided a valid definition id or access token.');
49
49
  }
50
50
  }
51
- exports.getDefinitionById = getDefinitionById;
@@ -3,16 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.logFeedbackNudge = exports.openFeedbackLink = void 0;
6
+ exports.openFeedbackLink = openFeedbackLink;
7
+ exports.logFeedbackNudge = logFeedbackNudge;
7
8
  const chalk_1 = __importDefault(require("chalk"));
8
9
  const open_1 = __importDefault(require("open"));
9
10
  function openFeedbackLink() {
10
11
  (0, open_1.default)('https://87dc93gvoy0.typeform.com/to/d1RgWfZX');
11
12
  }
12
- exports.openFeedbackLink = openFeedbackLink;
13
13
  function logFeedbackNudge() {
14
14
  console.log(`Have any feedback for the ${chalk_1.default.blue('Conte')}${chalk_1.default.yellow('ntful')}${chalk_1.default.red(' CLI')}? We'd love to hear from you! Check out our five question developer experience survey at:
15
15
  ${chalk_1.default.underline('https://87dc93gvoy0.typeform.com/to/d1RgWfZX')}
16
16
  `);
17
17
  }
18
- exports.logFeedbackNudge = logFeedbackNudge;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.getManagementToken = void 0;
7
+ exports.getManagementToken = getManagementToken;
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  const open_1 = __importDefault(require("open"));
10
10
  const inquirer_1 = __importDefault(require("inquirer"));
@@ -57,4 +57,3 @@ async function getManagementToken(host) {
57
57
  await (0, cache_credential_1.cacheEnvVars)({ [constants_1.ACCESS_TOKEN_ENV_KEY]: mgmtToken });
58
58
  return mgmtToken;
59
59
  }
60
- exports.getManagementToken = getManagementToken;
package/lib/index.d.ts CHANGED
@@ -6,3 +6,4 @@ export { open } from './open';
6
6
  export { track } from './analytics';
7
7
  export { feedback } from './feedback';
8
8
  export { install } from './install';
9
+ export { buildFunctions } from './build-functions';
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.install = exports.feedback = exports.track = exports.open = exports.cleanup = exports.activate = exports.upload = exports.createAppDefinition = void 0;
3
+ exports.buildFunctions = exports.install = exports.feedback = exports.track = exports.open = exports.cleanup = exports.activate = exports.upload = exports.createAppDefinition = void 0;
4
4
  var create_app_definition_1 = require("./create-app-definition");
5
5
  Object.defineProperty(exports, "createAppDefinition", { enumerable: true, get: function () { return create_app_definition_1.createAppDefinition; } });
6
6
  var upload_1 = require("./upload");
@@ -17,3 +17,5 @@ var feedback_1 = require("./feedback");
17
17
  Object.defineProperty(exports, "feedback", { enumerable: true, get: function () { return feedback_1.feedback; } });
18
18
  var install_1 = require("./install");
19
19
  Object.defineProperty(exports, "install", { enumerable: true, get: function () { return install_1.install; } });
20
+ var build_functions_1 = require("./build-functions");
21
+ Object.defineProperty(exports, "buildFunctions", { enumerable: true, get: function () { return build_functions_1.buildFunctions; } });
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.installToEnvironment = void 0;
6
+ exports.installToEnvironment = installToEnvironment;
7
7
  const open_1 = __importDefault(require("open"));
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  const inquirer_1 = __importDefault(require("inquirer"));
@@ -45,4 +45,3 @@ async function installToEnvironment(options) {
45
45
  throw err;
46
46
  }
47
47
  }
48
- exports.installToEnvironment = installToEnvironment;
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.openSettings = exports.REDIRECT_URL = void 0;
6
+ exports.REDIRECT_URL = void 0;
7
+ exports.openSettings = openSettings;
7
8
  const open_1 = __importDefault(require("open"));
8
9
  const chalk_1 = __importDefault(require("chalk"));
9
10
  const inquirer_1 = __importDefault(require("inquirer"));
@@ -44,4 +45,3 @@ async function openSettings(options) {
44
45
  throw err;
45
46
  }
46
47
  }
47
- exports.openSettings = openSettings;
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getOrganizationById = exports.selectOrganization = void 0;
6
+ exports.selectOrganization = selectOrganization;
7
+ exports.getOrganizationById = getOrganizationById;
7
8
  const ora_1 = __importDefault(require("ora"));
8
9
  const utils_1 = require("./utils");
9
10
  const constants_1 = require("./constants");
@@ -30,7 +31,6 @@ async function selectOrganization(client) {
30
31
  orgSpinner.stop();
31
32
  }
32
33
  }
33
- exports.selectOrganization = selectOrganization;
34
34
  async function getOrganizationById(client, orgId) {
35
35
  try {
36
36
  const org = await client.getOrganization(orgId);
@@ -43,4 +43,3 @@ async function getOrganizationById(client, orgId) {
43
43
  return (0, utils_1.throwError)(err, 'Could not fetch your organization. Make sure you provided a valid access token.');
44
44
  }
45
45
  }
46
- exports.getOrganizationById = getOrganizationById;
package/lib/types.d.ts CHANGED
@@ -76,3 +76,8 @@ export interface UploadSettings {
76
76
  actions?: FunctionAppAction[];
77
77
  functions?: ContentfulFunction[];
78
78
  }
79
+ export interface BuildFunctionsOptions {
80
+ manifestFile?: string;
81
+ esbuildConfig?: string;
82
+ watch?: boolean;
83
+ }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hostProtocolFilter = exports.buildAppUploadSettings = void 0;
3
+ exports.buildAppUploadSettings = buildAppUploadSettings;
4
+ exports.hostProtocolFilter = hostProtocolFilter;
4
5
  const inquirer_1 = require("inquirer");
5
6
  const get_app_info_1 = require("../get-app-info");
6
7
  const utils_1 = require("../utils");
@@ -53,8 +54,6 @@ async function buildAppUploadSettings(options) {
53
54
  ...appInfo,
54
55
  };
55
56
  }
56
- exports.buildAppUploadSettings = buildAppUploadSettings;
57
57
  function hostProtocolFilter(input) {
58
58
  return input.replace(/^https?:\/\//, '');
59
59
  }
60
- exports.hostProtocolFilter = hostProtocolFilter;
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createAppBundleFromSettings = exports.createAppBundleFromUpload = void 0;
6
+ exports.createAppBundleFromUpload = createAppBundleFromUpload;
7
+ exports.createAppBundleFromSettings = createAppBundleFromSettings;
7
8
  const chalk_1 = __importDefault(require("chalk"));
8
9
  const ora_1 = __importDefault(require("ora"));
9
10
  const utils_1 = require("../utils");
@@ -36,7 +37,6 @@ async function createAppBundleFromUpload(settings, appUploadId) {
36
37
  bundleSpinner.stop();
37
38
  return appBundle;
38
39
  }
39
- exports.createAppBundleFromUpload = createAppBundleFromUpload;
40
40
  async function createAppBundleFromSettings(settings) {
41
41
  let appUpload = null;
42
42
  try {
@@ -75,4 +75,3 @@ async function createAppBundleFromSettings(settings) {
75
75
  }
76
76
  return appBundle;
77
77
  }
78
- exports.createAppBundleFromSettings = createAppBundleFromSettings;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createAppUpload = void 0;
6
+ exports.createAppUpload = createAppUpload;
7
7
  const ora_1 = __importDefault(require("ora"));
8
8
  const create_zip_from_directory_1 = require("./create-zip-from-directory");
9
9
  const validate_bundle_1 = require("./validate-bundle");
@@ -36,4 +36,3 @@ async function createAppUpload(settings) {
36
36
  uploadSpinner.stop();
37
37
  return appUpload;
38
38
  }
39
- exports.createAppUpload = createAppUpload;
@@ -1,2 +1 @@
1
- /// <reference types="node" />
2
1
  export declare function createZipFileFromDirectory(path: string): Promise<Buffer | null>;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createZipFileFromDirectory = void 0;
6
+ exports.createZipFileFromDirectory = createZipFileFromDirectory;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const adm_zip_1 = __importDefault(require("adm-zip"));
9
9
  const utils_1 = require("../utils");
@@ -25,4 +25,3 @@ async function createZipFileFromDirectory(path) {
25
25
  return null;
26
26
  }
27
27
  }
28
- exports.createZipFileFromDirectory = createZipFileFromDirectory;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getUploadSettingsArgs = void 0;
6
+ exports.getUploadSettingsArgs = getUploadSettingsArgs;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const ora_1 = __importDefault(require("ora"));
9
9
  const get_app_info_1 = require("../get-app-info");
@@ -46,4 +46,3 @@ async function getUploadSettingsArgs(options) {
46
46
  validateSpinner.stop();
47
47
  }
48
48
  }
49
- exports.getUploadSettingsArgs = getUploadSettingsArgs;
@@ -1,2 +1,2 @@
1
1
  import { UploadSettings } from '../types';
2
- export declare const validateBundle: (path: string, { functions, actions }: Pick<UploadSettings, 'functions' | 'actions'>) => void;
2
+ export declare const validateBundle: (path: string, { functions, actions }: Pick<UploadSettings, "functions" | "actions">) => void;
package/lib/utils.js CHANGED
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getEntityFromManifest = exports.selectFromList = exports.throwError = exports.showCreationError = exports.stripProtocol = exports.isValidNetwork = exports.throwValidationException = void 0;
6
+ exports.selectFromList = exports.throwError = exports.showCreationError = exports.stripProtocol = exports.isValidNetwork = exports.throwValidationException = void 0;
7
+ exports.getEntityFromManifest = getEntityFromManifest;
7
8
  const fs_1 = __importDefault(require("fs"));
8
9
  const chalk_1 = __importDefault(require("chalk"));
9
10
  const inquirer_1 = __importDefault(require("inquirer"));
@@ -147,4 +148,3 @@ function getEntityFromManifest(type) {
147
148
  process.exit(1);
148
149
  }
149
150
  }
150
- exports.getEntityFromManifest = getEntityFromManifest;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validateArguments = void 0;
6
+ exports.validateArguments = validateArguments;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  function validateArguments(requiredOptions, options, command) {
9
9
  Object.entries(requiredOptions).forEach(([option, argument]) => {
@@ -20,4 +20,3 @@ function validateArguments(requiredOptions, options, command) {
20
20
  }
21
21
  });
22
22
  }
23
- exports.validateArguments = validateArguments;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/app-scripts",
3
- "version": "1.31.1",
3
+ "version": "1.32.0",
4
4
  "description": "A collection of scripts for building Contentful Apps",
5
5
  "author": "Contentful GmbH",
6
6
  "license": "MIT",
@@ -47,22 +47,25 @@
47
47
  "access": "public"
48
48
  },
49
49
  "dependencies": {
50
+ "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
51
+ "@esbuild-plugins/node-modules-polyfill": "^0.2.2",
50
52
  "@segment/analytics-node": "^2.0.0",
51
53
  "adm-zip": "0.5.16",
52
54
  "bottleneck": "2.19.5",
53
55
  "chalk": "4.1.2",
54
56
  "commander": "12.1.0",
55
- "contentful-management": "11.40.0",
56
- "dotenv": "16.4.6",
57
+ "contentful-management": "11.40.2",
58
+ "dotenv": "16.4.7",
59
+ "esbuild": "^0.24.0",
57
60
  "ignore": "6.0.2",
58
61
  "inquirer": "8.2.6",
59
62
  "lodash": "4.17.21",
60
63
  "open": "8.4.2",
61
- "ora": "5.4.1"
64
+ "ora": "5.4.1",
65
+ "zod": "^3.24.1"
62
66
  },
63
- "gitHead": "abfff61de7708ed53d3f3afbbb59f64673ca5a4a",
67
+ "gitHead": "14a49c8e2b86cfeb35d8b24107e028ef0d807218",
64
68
  "devDependencies": {
65
- "@tsconfig/node18": "18.2.4",
66
69
  "@types/adm-zip": "0.5.7",
67
70
  "@types/analytics-node": "3.1.14",
68
71
  "@types/chai": "4.3.16",