@contentful/app-scripts 1.15.0 → 1.18.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/README.md CHANGED
@@ -106,14 +106,14 @@ When passing the `--ci` argument the command will fail when the required variabl
106
106
 
107
107
  **Options:**
108
108
 
109
- | Argument | Description | Default value |
110
- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | - |
111
- | `--bundle-dir` | The directory of your build folder (e.g.: `./build`) | |
112
- | `--organization-id` | The ID of your organization | |
113
- | `--definition-id` | The ID of the app to which to add the bundle | |
114
- | `--token` | A personal [access token](https://www.contentful.com/developers/docs/references/content-management-api/#/reference/personal-access-tokens) | |
115
- | `--skip-activation` | (optional) Boolean flag to skip the automatic activation of the `AppBundle` | `false` |
116
- | `--comment` | (optional) A comment which will be associated with the created `AppBundle`. Can be used to differentiate bundles. | |
109
+ | Argument | Description | Default value |
110
+ | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | -------------------- |
111
+ | `--bundle-dir` | The directory of your build folder (e.g.: `./build`) | |
112
+ | `--organization-id` | The ID of your organization | |
113
+ | `--definition-id` | The ID of the app to which to add the bundle | |
114
+ | `--token` | A personal [access token](https://www.contentful.com/developers/docs/references/content-management-api/#/reference/personal-access-tokens) | |
115
+ | `--skip-activation` | (optional) Boolean flag to skip the automatic activation of the `AppBundle` | `false` |
116
+ | `--comment` | (optional) A comment which will be associated with the created `AppBundle`. Can be used to differentiate bundles. | |
117
117
  | `--host` | (optional) Contentful CMA-endpoint to use | `api.contentful.com` |
118
118
 
119
119
  **Note:** You can also pass all arguments in interactive mode to skip being asked for it.
@@ -149,12 +149,12 @@ When passing the `--ci` argument adding all variables as arguments is required.
149
149
 
150
150
  **Options:**
151
151
 
152
- | Argument | Description | Default value |
153
- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | --- |
154
- | `--bundle-id` | The ID of the AppBundle you want to activate | |
155
- | `--organization-id` | The ID of your organization | |
156
- | `--definition-id` | The ID of the app to which to add the bundle | |
157
- | `--token` | A personal [access token](https://www.contentful.com/developers/docs/references/content-management-api/#/reference/personal-access-tokens) | |
152
+ | Argument | Description | Default value |
153
+ | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | -------------------- |
154
+ | `--bundle-id` | The ID of the AppBundle you want to activate | |
155
+ | `--organization-id` | The ID of your organization | |
156
+ | `--definition-id` | The ID of the app to which to add the bundle | |
157
+ | `--token` | A personal [access token](https://www.contentful.com/developers/docs/references/content-management-api/#/reference/personal-access-tokens) | |
158
158
  | `--host` | (optional) Contentful CMA-endpoint to use | `api.contentful.com` |
159
159
 
160
160
  **Note:** You can also pass all arguments in interactive mode to skip being asked for it.
@@ -210,13 +210,13 @@ When passing the `--ci` argument adding all variables as arguments is required
210
210
 
211
211
  **Options:**
212
212
 
213
- | Argument | Description | Default value |
214
- | ------------------- | -------------------------------------------- | -------------------- |
215
- | `--organization-id` | The ID of your organization | |
216
- | `--definition-id` | The ID of the app to which to add the bundle | |
217
- | `--token` | A personal [access token](https://www.contentful.com/developers/docs/references/content-management-api/#/reference/personal-access-tokens) | |
218
- | `--keep` | (optional) The amount of bundles to keep | `50` |
219
- | `--host` | (optional) Contentful CMA-endpoint to use | `api.contentful.com` |
213
+ | Argument | Description | Default value |
214
+ | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | -------------------- |
215
+ | `--organization-id` | The ID of your organization | |
216
+ | `--definition-id` | The ID of the app to which to add the bundle | |
217
+ | `--token` | A personal [access token](https://www.contentful.com/developers/docs/references/content-management-api/#/reference/personal-access-tokens) | |
218
+ | `--keep` | (optional) The amount of bundles to keep | `50` |
219
+ | `--host` | (optional) Contentful CMA-endpoint to use | `api.contentful.com` |
220
220
 
221
221
  **Note:** You can also pass all arguments in interactive mode to skip being asked for it.
222
222
 
package/lib/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Definition } from "./definition-api";
2
- import { Organization } from "./organization-api";
1
+ import { Definition } from './definition-api';
2
+ import { Organization } from './organization-api';
3
3
  export interface FunctionAppAction {
4
4
  id: string;
5
5
  name: string;
@@ -10,12 +10,16 @@ const validate_bundle_1 = require("./validate-bundle");
10
10
  const utils_1 = require("../utils");
11
11
  const contentful_management_1 = require("contentful-management");
12
12
  async function createAppBundleFromFile(orgId, token, zip, host = '') {
13
- const client = (0, contentful_management_1.createClient)({ accessToken: token, host, hostUpload: host.replace(/^api/i, 'upload') });
13
+ const client = (0, contentful_management_1.createClient)({
14
+ accessToken: token,
15
+ host,
16
+ hostUpload: host.replace(/^api/i, 'upload'),
17
+ });
14
18
  const org = await client.getOrganization(orgId);
15
19
  return await org.createAppUpload(zip);
16
20
  }
17
21
  async function createAppUpload(settings) {
18
- (0, validate_bundle_1.validateBundle)(settings.bundleDirectory || '.');
22
+ (0, validate_bundle_1.validateBundle)(settings.bundleDirectory || '.', settings);
19
23
  let appUpload = null;
20
24
  const zipFileSpinner = (0, ora_1.default)('Preparing your files for upload...').start();
21
25
  const zipFile = await (0, create_zip_from_directory_1.createZipFileFromDirectory)(settings.bundleDirectory || '../types');
@@ -1 +1,2 @@
1
- export declare const validateBundle: (path: string) => void;
1
+ import { UploadSettings } from '../types';
2
+ export declare const validateBundle: (path: string, { functions, actions }: Pick<UploadSettings, 'functions' | 'actions'>) => void;
@@ -8,14 +8,14 @@ const path_1 = __importDefault(require("path"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const chalk_1 = __importDefault(require("chalk"));
10
10
  const ACCEPTED_ENTRY_FILES = ['index.html'];
11
- const getEntryFile = (files) => files.find(file => ACCEPTED_ENTRY_FILES.includes(file));
11
+ const getEntryFile = (files) => files.find((file) => ACCEPTED_ENTRY_FILES.includes(file));
12
12
  const ABSOLUTE_PATH_REG_EXP = /(src|href)="\/([^/])([^"]*)+"/g;
13
13
  const fileContainsAbsolutePath = (fileContent) => {
14
14
  return [...fileContent.matchAll(ABSOLUTE_PATH_REG_EXP)].length > 0;
15
15
  };
16
- const validateBundle = (path) => {
16
+ const validateBundle = (path, { functions, actions }) => {
17
17
  const buildFolder = path_1.default.join('./', path);
18
- const files = fs_1.default.readdirSync(buildFolder);
18
+ const files = fs_1.default.readdirSync(buildFolder, { recursive: true, encoding: 'utf-8' });
19
19
  const entry = getEntryFile(files);
20
20
  if (!entry) {
21
21
  throw new Error('Make sure your bundle includes a valid index.html file in its root folder.');
@@ -26,5 +26,17 @@ const validateBundle = (path) => {
26
26
  console.warn(`${chalk_1.default.red('Warning:')} This bundle uses absolute paths. Please use relative paths instead for correct rendering. See more details here https://www.contentful.com/developers/docs/extensibility/app-framework/app-bundle/#limitations`);
27
27
  console.log('----------------------------');
28
28
  }
29
+ if (functions) {
30
+ const functionWithoutEntryFile = functions.find(({ path }) => !files.includes(path));
31
+ if (functionWithoutEntryFile) {
32
+ throw new Error(`Function "${functionWithoutEntryFile.id}" is missing its entry file at "${path_1.default.join(buildFolder, functionWithoutEntryFile.path)}".`);
33
+ }
34
+ }
35
+ if (actions) {
36
+ const actionWithoutEntryFile = actions.find(({ path }) => !files.includes(path));
37
+ if (actionWithoutEntryFile) {
38
+ throw new Error(`Action "${actionWithoutEntryFile.id}" is missing its entry file at "${path_1.default.join(buildFolder, actionWithoutEntryFile.path)}".`);
39
+ }
40
+ }
29
41
  };
30
42
  exports.validateBundle = validateBundle;
package/lib/utils.js CHANGED
@@ -89,12 +89,13 @@ function getEntityFromManifest(type) {
89
89
  logProgress(`${type === 'actions' ? 'App Actions' : 'functions'} found in ${chalk_1.default.bold(DEFAULT_MANIFEST_PATH)}.`);
90
90
  const fieldMappingEvent = "graphql.field.mapping";
91
91
  const queryEvent = "graphql.query";
92
+ const appEventFilter = 'appevent.filter';
92
93
  const items = manifest[type].map((item) => {
93
94
  const allowNetworks = Array.isArray(item.allowNetworks)
94
95
  ? item.allowNetworks.map(exports.stripProtocol)
95
96
  : [];
96
97
  const accepts = 'accepts' in item && Array.isArray(item.accepts) ? item.accepts : undefined;
97
- const hasInvalidEvent = accepts?.some((event) => ![fieldMappingEvent, queryEvent].includes(event));
98
+ const hasInvalidEvent = accepts?.some((event) => ![fieldMappingEvent, queryEvent, appEventFilter].includes(event));
98
99
  const hasInvalidNetwork = allowNetworks.find((netWork) => !(0, exports.isValidNetwork)(netWork));
99
100
  if (hasInvalidNetwork) {
100
101
  console.log(`${chalk_1.default.red('Error:')} Invalid IP address ${hasInvalidNetwork} found in the allowNetworks array for ${type} "${item.name}".`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/app-scripts",
3
- "version": "1.15.0",
3
+ "version": "1.18.0",
4
4
  "description": "A collection of scripts for building Contentful Apps",
5
5
  "author": "Contentful GmbH",
6
6
  "license": "MIT",
@@ -48,25 +48,25 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@segment/analytics-node": "^2.0.0",
51
- "adm-zip": "0.5.10",
51
+ "adm-zip": "0.5.12",
52
52
  "bottleneck": "2.19.5",
53
53
  "chalk": "4.1.2",
54
54
  "commander": "12.0.0",
55
- "contentful-management": "11.16.0",
56
- "dotenv": "16.4.4",
55
+ "contentful-management": "11.24.3",
56
+ "dotenv": "16.4.5",
57
57
  "ignore": "5.3.1",
58
58
  "inquirer": "8.2.6",
59
59
  "lodash": "4.17.21",
60
60
  "open": "8.4.2",
61
61
  "ora": "5.4.1"
62
62
  },
63
- "gitHead": "ca1260e5b969a8b5a1ff1104fbb2431cbf420ca3",
63
+ "gitHead": "2f6ce49aba5bb8a8a781b46ea8441b33aa347404",
64
64
  "devDependencies": {
65
- "@tsconfig/node18": "18.2.2",
65
+ "@tsconfig/node18": "18.2.4",
66
66
  "@types/adm-zip": "0.5.5",
67
67
  "@types/analytics-node": "3.1.14",
68
68
  "@types/inquirer": "8.2.1",
69
- "@types/lodash": "4.14.202",
69
+ "@types/lodash": "4.17.0",
70
70
  "@types/proxyquire": "1.3.31",
71
71
  "@types/sinon": "17.0.3",
72
72
  "proxyquire": "2.1.3",