@contentful/app-scripts 2.5.0 → 2.5.1
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ActivateSettings } from '../types';
|
|
2
|
-
export declare function activateBundle({ accessToken, organization, definition, bundleId, host, }: ActivateSettings): Promise<void>;
|
|
2
|
+
export declare function activateBundle({ accessToken, organization, definition, bundleId, host, hasFrontend, }: ActivateSettings): Promise<void>;
|
|
@@ -8,10 +8,11 @@ const ora_1 = __importDefault(require("ora"));
|
|
|
8
8
|
const chalk_1 = require("chalk");
|
|
9
9
|
const utils_1 = require("../utils");
|
|
10
10
|
const contentful_management_1 = require("contentful-management");
|
|
11
|
-
async function activateBundle({ accessToken, organization, definition, bundleId, host, }) {
|
|
11
|
+
async function activateBundle({ accessToken, organization, definition, bundleId, host, hasFrontend, }) {
|
|
12
12
|
const activationSpinner = (0, ora_1.default)('Activating your bundle').start();
|
|
13
13
|
const plainClient = (0, contentful_management_1.createClient)({ accessToken, host }, { type: 'plain' });
|
|
14
14
|
const defaultLocations = [{ location: 'dialog' }];
|
|
15
|
+
let doesBundleHaveFrontend = hasFrontend;
|
|
15
16
|
const currentDefinition = await plainClient.appDefinition.get({
|
|
16
17
|
appDefinitionId: definition.value,
|
|
17
18
|
organizationId: organization.value,
|
|
@@ -23,10 +24,29 @@ async function activateBundle({ accessToken, organization, definition, bundleId,
|
|
|
23
24
|
type: 'Link',
|
|
24
25
|
},
|
|
25
26
|
};
|
|
26
|
-
if
|
|
27
|
+
// if `hasFrontend` is not passed in, fetch the bundle to determine if it has a frontend
|
|
28
|
+
let bundle;
|
|
29
|
+
if (doesBundleHaveFrontend === undefined) {
|
|
30
|
+
bundle = await plainClient.appBundle.get({
|
|
31
|
+
appBundleId: bundleId,
|
|
32
|
+
appDefinitionId: definition.value,
|
|
33
|
+
organizationId: organization.value,
|
|
34
|
+
});
|
|
35
|
+
if (bundle.files.length) {
|
|
36
|
+
doesBundleHaveFrontend = true;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
doesBundleHaveFrontend = false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// if the bundle has frontend code in the bundle, remove the src from the definition since the frontend will now be hosted by Contentful
|
|
43
|
+
if (doesBundleHaveFrontend) {
|
|
44
|
+
delete currentDefinition.src;
|
|
45
|
+
}
|
|
46
|
+
// if the bundle has frontend code and there are no locations already on the app definition set the default location to dialog
|
|
47
|
+
if (doesBundleHaveFrontend && !currentDefinition.locations?.length) {
|
|
27
48
|
currentDefinition.locations = defaultLocations;
|
|
28
49
|
}
|
|
29
|
-
delete currentDefinition.src;
|
|
30
50
|
try {
|
|
31
51
|
await plainClient.appDefinition.update({
|
|
32
52
|
appDefinitionId: definition.value,
|
package/lib/types.d.ts
CHANGED
package/lib/upload/index.js
CHANGED
|
@@ -16,7 +16,8 @@ async function uploadAndActivate(settings) {
|
|
|
16
16
|
console.log('Remember that in order to be invoked, your App Event function(s) must be linked to your App Event subscription using the CMA or the Events tab of the App Details page.');
|
|
17
17
|
}
|
|
18
18
|
if (!settings.skipActivation && bundle) {
|
|
19
|
-
|
|
19
|
+
const hasFrontend = bundle.files.length > 0;
|
|
20
|
+
await (0, activate_bundle_1.activateBundle)({ ...settings, bundleId: bundle.sys.id, hasFrontend });
|
|
20
21
|
(0, feedback_1.logFeedbackNudge)();
|
|
21
22
|
}
|
|
22
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/app-scripts",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "A collection of scripts for building Contentful Apps",
|
|
5
5
|
"author": "Contentful GmbH",
|
|
6
6
|
"license": "MIT",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"tiged": "^2.12.7",
|
|
68
68
|
"zod": "^3.24.1"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "bebf291cff542d30de78de03eea44f3d5621e3b1",
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@types/adm-zip": "0.5.7",
|
|
73
73
|
"@types/analytics-node": "3.1.14",
|