@contentful/app-scripts 1.17.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.
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/app-scripts",
3
- "version": "1.17.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",
@@ -52,7 +52,7 @@
52
52
  "bottleneck": "2.19.5",
53
53
  "chalk": "4.1.2",
54
54
  "commander": "12.0.0",
55
- "contentful-management": "11.23.0",
55
+ "contentful-management": "11.24.3",
56
56
  "dotenv": "16.4.5",
57
57
  "ignore": "5.3.1",
58
58
  "inquirer": "8.2.6",
@@ -60,9 +60,9 @@
60
60
  "open": "8.4.2",
61
61
  "ora": "5.4.1"
62
62
  },
63
- "gitHead": "7576b84daf5069f42177cd8d43117f5f3c7056be",
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",