@contentful/app-scripts 2.1.1 → 2.1.2

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/lib/analytics.js CHANGED
@@ -19,7 +19,9 @@ function track({ command, ci }) {
19
19
  const client = new analytics_node_1.Analytics({
20
20
  writeKey: SEGMENT_WRITE_KEY,
21
21
  });
22
- client.on('error', (err) => { });
22
+ client.on('error', (err) => {
23
+ /* noop */
24
+ });
23
25
  client.track({
24
26
  event: 'app-cli-app-scripts',
25
27
  properties: {
package/lib/bin.js CHANGED
@@ -22,7 +22,7 @@ async function runCommand(command, options) {
22
22
  .description('Upload your build folder and create an AppBundle')
23
23
  .option('--bundle-dir [directory]', 'The directory of your build folder')
24
24
  .option('--organization-id [orgId]', 'The id of your organization')
25
- .option('--definition-id [defId]', 'The id of your app\'s definition')
25
+ .option('--definition-id [defId]', "The id of your app's definition")
26
26
  .option('--token [accessToken]', 'Your content management access token')
27
27
  .option('--comment [comment]', 'Optional comment for the created bundle')
28
28
  .option('--skip-activation', 'A Boolean flag to skip automatic activation')
@@ -35,7 +35,7 @@ async function runCommand(command, options) {
35
35
  .description('Mark an AppBundle as "active" for a given AppDefinition')
36
36
  .option('--bundle-id [bundleId]', 'The id of your bundle')
37
37
  .option('--organization-id [orgId]', 'The id of your organization')
38
- .option('--definition-id [defId]', 'The id of your app\'s definition')
38
+ .option('--definition-id [defId]', "The id of your app's definition")
39
39
  .option('--token [accessToken]', 'Your content management access token')
40
40
  .option('--host [host]', 'Contentful subdomain to use, e.g. "api.contentful.com"')
41
41
  .action(async (options) => {
@@ -44,7 +44,7 @@ async function runCommand(command, options) {
44
44
  commander_1.program
45
45
  .command('open-settings')
46
46
  .description('Opens the app editor for a given AppDefinition')
47
- .option('--definition-id [defId]', 'The id of your app\'s definition')
47
+ .option('--definition-id [defId]', "The id of your app's definition")
48
48
  .option('--host [host]', 'Contentful subdomain to use, e.g. "api.contentful.com"')
49
49
  .action(async (options) => {
50
50
  await runCommand(index_1.open, options);
@@ -53,7 +53,7 @@ async function runCommand(command, options) {
53
53
  .command('bundle-cleanup')
54
54
  .description('Removes old, non-active bundles, only keeps the 50 most recent ones')
55
55
  .option('--organization-id [orgId]', 'The id of your organization')
56
- .option('--definition-id [defId]', 'The id of your app\'s definition')
56
+ .option('--definition-id [defId]', "The id of your app's definition")
57
57
  .option('--token [accessToken]', 'Your content management access token')
58
58
  .option('--keep [keepAmount]', 'The amount of bundles that should remain')
59
59
  .option('--host [host]', 'Contentful subdomain to use, e.g. "api.contentful.com"')
@@ -69,7 +69,7 @@ async function runCommand(command, options) {
69
69
  commander_1.program
70
70
  .command('install')
71
71
  .description('Opens a picker to select the space and environment for installing the app associated with a given AppDefinition')
72
- .option('--definition-id [defId]', 'The id of your app\'s definition')
72
+ .option('--definition-id [defId]', "The id of your app's definition")
73
73
  .option('--host [host]', 'Contentful subdomain to use, e.g. "api.contentful.com"')
74
74
  .action(async (options) => {
75
75
  await runCommand(index_1.install, options);
@@ -97,7 +97,7 @@ async function runCommand(command, options) {
97
97
  .description('Upsert Action(s) for an App')
98
98
  .option('-m, --manifest-file <path>', 'Contentful app manifest file path')
99
99
  .option('--organization-id [orgId]', 'The id of your organization')
100
- .option('--definition-id [defId]', 'The id of your app\'s definition')
100
+ .option('--definition-id [defId]', "The id of your app's definition")
101
101
  .option('--token [accessToken]', 'Your content management access token')
102
102
  .option('--host [host]', 'Contentful subdomain to use, e.g. "api.contentful.com"')
103
103
  .action(async (options) => {
@@ -1,3 +1,4 @@
1
1
  import { UploadSettings } from '../types';
2
2
  export declare function createAppBundleFromUpload(settings: UploadSettings, appUploadId: string): Promise<import("contentful-management").AppBundle | null>;
3
+ export declare function processCreateAppBundleError(err: any): any;
3
4
  export declare function createAppBundleFromSettings(settings: UploadSettings): Promise<void | import("contentful-management").AppBundle>;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createAppBundleFromUpload = createAppBundleFromUpload;
7
+ exports.processCreateAppBundleError = processCreateAppBundleError;
7
8
  exports.createAppBundleFromSettings = createAppBundleFromSettings;
8
9
  const chalk_1 = __importDefault(require("chalk"));
9
10
  const ora_1 = __importDefault(require("ora"));
@@ -31,21 +32,36 @@ async function createAppBundleFromUpload(settings, appUploadId) {
31
32
  });
32
33
  }
33
34
  catch (err) {
34
- try {
35
- const message = JSON.parse(err.message);
36
- if (message['status'] == 403 && message.details?.reasons) {
37
- (0, utils_1.showCreationError)('app upload', message['details']['reasons']);
35
+ (0, utils_1.showCreationError)('app upload', processCreateAppBundleError(err));
36
+ }
37
+ bundleSpinner.stop();
38
+ return appBundle;
39
+ }
40
+ function processCreateAppBundleError(err) {
41
+ try {
42
+ const message = JSON.parse(err.message);
43
+ const reasons = message.details?.reasons;
44
+ if (message.status !== 403 || !reasons) {
45
+ return err.message;
46
+ }
47
+ if (message['status'] == 403 && message.details?.reasons) {
48
+ if (reasons.includes('Not entitled to App Functions.')) {
49
+ return 'Your app seems to be using App Functions, which your organization is not entitled to. Remove your app function, or upgrade your account to proceed with your app upload.';
50
+ }
51
+ else if (reasons.includes('App Functions beta not enabled.')) {
52
+ return 'Your app seems to be using App Functions, which your organization has not enabled in the Preview Center. In the Contentful web app, go to the Account Menu → Preview Center → App Functions to enable and proceed with your app upload.';
38
53
  }
39
54
  else {
40
- (0, utils_1.showCreationError)('app upload', message);
55
+ return reasons;
41
56
  }
42
57
  }
43
- catch (e) {
44
- (0, utils_1.showCreationError)('app upload', err.message);
58
+ else {
59
+ return reasons;
45
60
  }
46
61
  }
47
- bundleSpinner.stop();
48
- return appBundle;
62
+ catch (e) {
63
+ return err.message;
64
+ }
49
65
  }
50
66
  async function createAppBundleFromSettings(settings) {
51
67
  let appUpload = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/app-scripts",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "A collection of scripts for building Contentful Apps",
5
5
  "author": "Contentful GmbH",
6
6
  "license": "MIT",
@@ -25,7 +25,7 @@
25
25
  "contentful-app-scripts": "lib/bin.js"
26
26
  },
27
27
  "scripts": {
28
- "prettier": "prettier **/*.js --write --ignore-path .gitignore",
28
+ "prettier": "prettier **/*.ts --write --ignore-path .gitignore",
29
29
  "lint": "eslint ./src",
30
30
  "lint:fix": "npm run lint -- --fix",
31
31
  "test": "ts-mocha \"./{,!(node_modules)/**/}*.test.ts\"",
@@ -67,7 +67,7 @@
67
67
  "tiged": "^2.12.7",
68
68
  "zod": "^3.24.1"
69
69
  },
70
- "gitHead": "c86c0866476bf0cae4f72ff8730c2ff9c120a593",
70
+ "gitHead": "b88a46b43fc31d1da7cf625f32a5beb03badf99e",
71
71
  "devDependencies": {
72
72
  "@types/adm-zip": "0.5.7",
73
73
  "@types/analytics-node": "3.1.14",