@contentful/app-scripts 1.7.13 → 1.8.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.
package/README.md
CHANGED
|
@@ -76,13 +76,13 @@ It only runs in interactive mode.
|
|
|
76
76
|
### Upload a bundle to an App Definition
|
|
77
77
|
|
|
78
78
|
Allows you to upload a build directory and create a new AppBundle that is bound to an [AppDefinition](https://www.contentful.com/developers/docs/extensibility/app-framework/app-definition/).
|
|
79
|
-
It runs in interactive or non-interactive mode
|
|
79
|
+
It runs in interactive or non-interactive mode.
|
|
80
80
|
|
|
81
|
-
**Note:** The command will automatically activate the bundle. To skip the activation you can pass the `--skip-activation` argument in interactive and non-interactive mode and then manually [activate](#activate-an-appBundle) it
|
|
81
|
+
**Note:** The command will automatically activate the bundle. To skip the activation you can pass the `--skip-activation` argument in interactive and non-interactive mode and then manually [activate](#activate-an-appBundle) it.
|
|
82
82
|
|
|
83
83
|
#### Interactive mode:
|
|
84
84
|
|
|
85
|
-
In the interactive mode, the CLI will ask for all required options
|
|
85
|
+
In the interactive mode, the CLI will ask for all required options.
|
|
86
86
|
|
|
87
87
|
> **Example**
|
|
88
88
|
>
|
|
@@ -124,7 +124,7 @@ When activated the app will serve the newly activated AppBundle.
|
|
|
124
124
|
|
|
125
125
|
#### Interactive mode:
|
|
126
126
|
|
|
127
|
-
In the interactive mode, the CLI will ask for all required options
|
|
127
|
+
In the interactive mode, the CLI will ask for all required options.
|
|
128
128
|
|
|
129
129
|
> **Example**
|
|
130
130
|
>
|
|
@@ -134,7 +134,7 @@ In the interactive mode, the CLI will ask for all required options
|
|
|
134
134
|
|
|
135
135
|
#### Non-interactive mode:
|
|
136
136
|
|
|
137
|
-
When passing the `--ci` argument adding all variables as arguments is required
|
|
137
|
+
When passing the `--ci` argument adding all variables as arguments is required.
|
|
138
138
|
|
|
139
139
|
> **Example**
|
|
140
140
|
>
|
|
@@ -182,7 +182,7 @@ You can adjust the amount you want to keep by passing `--keep <amount>` to the a
|
|
|
182
182
|
|
|
183
183
|
#### Interactive mode:
|
|
184
184
|
|
|
185
|
-
In the interactive mode, the CLI will ask for all required options
|
|
185
|
+
In the interactive mode, the CLI will ask for all required options.
|
|
186
186
|
|
|
187
187
|
> **Example**
|
|
188
188
|
>
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
const inquirer = require('inquirer');
|
|
4
4
|
const { getAppInfo } = require('../get-app-info');
|
|
5
|
+
const { getActionsManifest } = require('../utils');
|
|
5
6
|
|
|
6
7
|
async function buildAppUploadSettings(options) {
|
|
8
|
+
const actionsManifest = getActionsManifest();
|
|
7
9
|
const prompts = [];
|
|
8
10
|
if (!options.bundleDir) {
|
|
9
11
|
prompts.push({
|
|
@@ -28,6 +30,7 @@ async function buildAppUploadSettings(options) {
|
|
|
28
30
|
bundleDirectory: options.bundleDir,
|
|
29
31
|
skipActivation: !!options.skipActivation,
|
|
30
32
|
comment: options.comment,
|
|
33
|
+
actions: actionsManifest,
|
|
31
34
|
...appUploadSettings,
|
|
32
35
|
...appInfo,
|
|
33
36
|
};
|
|
@@ -23,6 +23,7 @@ async function createAppBundleFromUpload(settings, appUploadId) {
|
|
|
23
23
|
appBundle = await appDefinition.createAppBundle({
|
|
24
24
|
appUploadId,
|
|
25
25
|
comment: settings.comment && settings.comment.length > 0 ? settings.comment : undefined,
|
|
26
|
+
actions: settings.actions,
|
|
26
27
|
});
|
|
27
28
|
} catch (err) {
|
|
28
29
|
showCreationError('app upload', err.message);
|
|
@@ -2,6 +2,7 @@ const chalk = require('chalk');
|
|
|
2
2
|
const ora = require('ora');
|
|
3
3
|
const { getAppInfo } = require('../get-app-info');
|
|
4
4
|
const { validateArguments } = require('../validate-arguments');
|
|
5
|
+
const { getActionsManifest } = require('../utils');
|
|
5
6
|
|
|
6
7
|
const requiredOptions = {
|
|
7
8
|
definitionId: '--definition-id',
|
|
@@ -12,6 +13,7 @@ const requiredOptions = {
|
|
|
12
13
|
|
|
13
14
|
async function getUploadSettingsArgs(options) {
|
|
14
15
|
const validateSpinner = ora('Validating your input...').start();
|
|
16
|
+
const actionsManifest = getActionsManifest();
|
|
15
17
|
|
|
16
18
|
try {
|
|
17
19
|
validateArguments(requiredOptions, options, 'upload');
|
|
@@ -22,6 +24,7 @@ async function getUploadSettingsArgs(options) {
|
|
|
22
24
|
skipActivation: options.skipActivation,
|
|
23
25
|
comment: options.comment,
|
|
24
26
|
userAgentApplication: options.userAgentApplication,
|
|
27
|
+
actions: actionsManifest,
|
|
25
28
|
};
|
|
26
29
|
} catch (err) {
|
|
27
30
|
console.log(`
|
package/lib/upload/index.js
CHANGED
|
@@ -6,7 +6,7 @@ const { buildAppUploadSettings } = require('./build-upload-settings');
|
|
|
6
6
|
|
|
7
7
|
async function uploadAndActivate(settings) {
|
|
8
8
|
const bundle = await createAppBundleFromSettings(settings);
|
|
9
|
-
if (!settings.skipActivation) {
|
|
9
|
+
if (!settings.skipActivation && bundle) {
|
|
10
10
|
await activateBundle({ ...settings, bundleId: bundle.sys.id });
|
|
11
11
|
}
|
|
12
12
|
}
|
package/lib/utils.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
1
2
|
const chalk = require('chalk');
|
|
2
3
|
const inquirer = require('inquirer');
|
|
3
4
|
const { cacheEnvVars } = require('../utils/cache-credential');
|
|
4
5
|
|
|
6
|
+
const DEFAULT_MANIFEST_PATH = './contentful-app-manifest.json';
|
|
7
|
+
|
|
5
8
|
const throwValidationException = (subject, message, details) => {
|
|
6
9
|
console.log(`${chalk.red('Validation Error:')} Missing or invalid ${subject}.`);
|
|
7
10
|
message && console.log(message);
|
|
@@ -31,16 +34,15 @@ ${err.message}
|
|
|
31
34
|
};
|
|
32
35
|
|
|
33
36
|
const selectFromList = async (list, message, cachedOptionEnvVar) => {
|
|
34
|
-
const cachedEnvVar = process.env[cachedOptionEnvVar]
|
|
35
|
-
const cachedElement = list.find(item => item.value === cachedEnvVar);
|
|
37
|
+
const cachedEnvVar = process.env[cachedOptionEnvVar];
|
|
38
|
+
const cachedElement = list.find((item) => item.value === cachedEnvVar);
|
|
36
39
|
|
|
37
40
|
if (cachedElement) {
|
|
38
41
|
console.log(`
|
|
39
42
|
${message}
|
|
40
43
|
Using environment variable: ${cachedElement.name} (${chalk.blue(cachedElement.value)})
|
|
41
|
-
`)
|
|
44
|
+
`);
|
|
42
45
|
return cachedElement;
|
|
43
|
-
|
|
44
46
|
} else {
|
|
45
47
|
const { elementId } = await inquirer.prompt([
|
|
46
48
|
{
|
|
@@ -52,16 +54,49 @@ const selectFromList = async (list, message, cachedOptionEnvVar) => {
|
|
|
52
54
|
]);
|
|
53
55
|
|
|
54
56
|
if (cachedOptionEnvVar) {
|
|
55
|
-
await cacheEnvVars({[cachedOptionEnvVar]: elementId});
|
|
57
|
+
await cacheEnvVars({ [cachedOptionEnvVar]: elementId });
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
return list.find((el) => el.value === elementId);
|
|
59
61
|
}
|
|
60
62
|
};
|
|
61
63
|
|
|
64
|
+
function getActionsManifest() {
|
|
65
|
+
const isManifestExists = fs.existsSync(DEFAULT_MANIFEST_PATH);
|
|
66
|
+
|
|
67
|
+
if (!isManifestExists) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
const manifest = JSON.parse(fs.readFileSync(DEFAULT_MANIFEST_PATH, { encoding: 'utf8' }));
|
|
73
|
+
|
|
74
|
+
if (!Array.isArray(manifest.actions) || manifest.actions.length === 0) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
console.log('');
|
|
79
|
+
console.log(` ----------------------------
|
|
80
|
+
App actions manifest found in ${chalk.bold(DEFAULT_MANIFEST_PATH)}.
|
|
81
|
+
----------------------------`);
|
|
82
|
+
console.log('');
|
|
83
|
+
|
|
84
|
+
return manifest.actions.map((action) => ({ parameters: [], ...action })); // adding required parameters
|
|
85
|
+
} catch {
|
|
86
|
+
console.log(
|
|
87
|
+
`${chalk.red('Error:')} Invalid JSON in manifest file at ${chalk.bold(
|
|
88
|
+
DEFAULT_MANIFEST_PATH
|
|
89
|
+
)}.`
|
|
90
|
+
);
|
|
91
|
+
// eslint-disable-next-line no-process-exit
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
62
96
|
module.exports = {
|
|
63
97
|
throwValidationException,
|
|
64
98
|
throwError,
|
|
65
99
|
selectFromList,
|
|
66
100
|
showCreationError,
|
|
101
|
+
getActionsManifest,
|
|
67
102
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/app-scripts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "A collection of scripts for building Contentful Apps",
|
|
5
5
|
"author": "Contentful GmbH",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"bottleneck": "2.19.5",
|
|
54
54
|
"chalk": "4.1.2",
|
|
55
55
|
"commander": "10.0.0",
|
|
56
|
-
"contentful-management": "10.
|
|
56
|
+
"contentful-management": "10.32.0",
|
|
57
57
|
"dotenv": "16.0.3",
|
|
58
58
|
"ignore": "5.2.4",
|
|
59
59
|
"inquirer": "8.2.5",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"open": "8.4.2",
|
|
62
62
|
"ora": "5.4.1"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "ff94fb203f5a5789754a1050546c856254adad6a"
|
|
65
65
|
}
|