@contentful/app-scripts 1.22.0 → 1.24.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 +26 -0
- package/lib/bin.js +8 -0
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +2 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/install/index.d.ts +5 -0
- package/lib/install/index.js +14 -0
- package/lib/install/install.d.ts +2 -0
- package/lib/install/install.js +48 -0
- package/lib/types.d.ts +4 -0
- package/lib/utils.js +4 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -220,6 +220,32 @@ When passing the `--ci` argument adding all variables as arguments is required
|
|
|
220
220
|
|
|
221
221
|
**Note:** You can also pass all arguments in interactive mode to skip being asked for it.
|
|
222
222
|
|
|
223
|
+
### Install the AppDefinition into a specific space / environment
|
|
224
|
+
|
|
225
|
+
It opens a dialog to select the space and environment where the app associated with the given [AppDefinition](https://www.contentful.com/developers/docs/extensibility/app-framework/app-definition/) should be installed.
|
|
226
|
+
|
|
227
|
+
> **Example**
|
|
228
|
+
>
|
|
229
|
+
> ```shell
|
|
230
|
+
> $ npx --no-install @contentful/app-scripts install --definition-id some-definition-id
|
|
231
|
+
> ```
|
|
232
|
+
|
|
233
|
+
You can also execute this command without the argument if the environment variable (`CONTENTFUL_APP_DEF_ID`) has been set.
|
|
234
|
+
|
|
235
|
+
> **Example**
|
|
236
|
+
>
|
|
237
|
+
> ```shell
|
|
238
|
+
> $ CONTENTFUL_APP_DEF_ID=some-definition-id npx --no-install @contentful/app-scripts install
|
|
239
|
+
> ```
|
|
240
|
+
|
|
241
|
+
By default, the script will install the app into the default host URL: `app.contentful.com`. If you want to install the app into a different host URL, you can set the argument `--host` to the desired host URL.
|
|
242
|
+
|
|
243
|
+
> **Example**
|
|
244
|
+
>
|
|
245
|
+
> ```shell
|
|
246
|
+
> $ npx --no-install @contentful/app-scripts install --definition-id some-definition-id --host api.eu.contentful.com
|
|
247
|
+
> ```
|
|
248
|
+
|
|
223
249
|
### Tracking
|
|
224
250
|
|
|
225
251
|
We gather depersonalized usage data of our CLI tools in order to improve experience. If you do not want your data to be gathered, you can opt out by providing an env variable `DISABLE_ANALYTICS` set to any value:
|
package/lib/bin.js
CHANGED
|
@@ -65,6 +65,14 @@ async function runCommand(command, options) {
|
|
|
65
65
|
.action(async (options) => {
|
|
66
66
|
await runCommand(feedback_1.feedback, options);
|
|
67
67
|
});
|
|
68
|
+
commander_1.program
|
|
69
|
+
.command('install')
|
|
70
|
+
.description('Opens a picker to select the space and environment for installing the app associated with a given AppDefinition')
|
|
71
|
+
.option('--definition-id [defId]', 'The id of your apps definition')
|
|
72
|
+
.option('--host [host]', 'Contentful domain to use')
|
|
73
|
+
.action(async (options) => {
|
|
74
|
+
await runCommand(index_1.install, options);
|
|
75
|
+
});
|
|
68
76
|
commander_1.program.hook('preAction', (thisCommand) => {
|
|
69
77
|
(0, index_1.track)({ command: thisCommand.args[0], ci: thisCommand.opts().ci });
|
|
70
78
|
});
|
package/lib/constants.d.ts
CHANGED
|
@@ -6,3 +6,4 @@ export declare const DEFAULT_BUNDLES_TO_KEEP = 50;
|
|
|
6
6
|
export declare const DEFAULT_BUNDLES_TO_FETCH = 1000;
|
|
7
7
|
export declare const MAX_CONCURRENT_DELETION_CALLS = 5;
|
|
8
8
|
export declare const DEFAULT_CONTENTFUL_API_HOST = "api.contentful.com";
|
|
9
|
+
export declare const DEFAULT_CONTENTFUL_APP_HOST = "app.contentful.com";
|
package/lib/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_CONTENTFUL_API_HOST = exports.MAX_CONCURRENT_DELETION_CALLS = exports.DEFAULT_BUNDLES_TO_FETCH = exports.DEFAULT_BUNDLES_TO_KEEP = exports.APP_DEF_ENV_KEY = exports.ORG_ID_ENV_KEY = exports.ACCESS_TOKEN_ENV_KEY = exports.DOTENV_FILE = void 0;
|
|
3
|
+
exports.DEFAULT_CONTENTFUL_APP_HOST = exports.DEFAULT_CONTENTFUL_API_HOST = exports.MAX_CONCURRENT_DELETION_CALLS = exports.DEFAULT_BUNDLES_TO_FETCH = exports.DEFAULT_BUNDLES_TO_KEEP = exports.APP_DEF_ENV_KEY = exports.ORG_ID_ENV_KEY = exports.ACCESS_TOKEN_ENV_KEY = exports.DOTENV_FILE = void 0;
|
|
4
4
|
exports.DOTENV_FILE = '.env';
|
|
5
5
|
exports.ACCESS_TOKEN_ENV_KEY = 'CONTENTFUL_ACCESS_TOKEN';
|
|
6
6
|
exports.ORG_ID_ENV_KEY = 'CONTENTFUL_ORG_ID';
|
|
@@ -9,3 +9,4 @@ exports.DEFAULT_BUNDLES_TO_KEEP = 50;
|
|
|
9
9
|
exports.DEFAULT_BUNDLES_TO_FETCH = 1000;
|
|
10
10
|
exports.MAX_CONCURRENT_DELETION_CALLS = 5;
|
|
11
11
|
exports.DEFAULT_CONTENTFUL_API_HOST = 'api.contentful.com';
|
|
12
|
+
exports.DEFAULT_CONTENTFUL_APP_HOST = 'app.contentful.com';
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.feedback = exports.track = exports.open = exports.cleanup = exports.activate = exports.upload = exports.createAppDefinition = void 0;
|
|
3
|
+
exports.install = exports.feedback = exports.track = exports.open = exports.cleanup = exports.activate = exports.upload = exports.createAppDefinition = void 0;
|
|
4
4
|
var create_app_definition_1 = require("./create-app-definition");
|
|
5
5
|
Object.defineProperty(exports, "createAppDefinition", { enumerable: true, get: function () { return create_app_definition_1.createAppDefinition; } });
|
|
6
6
|
var upload_1 = require("./upload");
|
|
@@ -15,3 +15,5 @@ var analytics_1 = require("./analytics");
|
|
|
15
15
|
Object.defineProperty(exports, "track", { enumerable: true, get: function () { return analytics_1.track; } });
|
|
16
16
|
var feedback_1 = require("./feedback");
|
|
17
17
|
Object.defineProperty(exports, "feedback", { enumerable: true, get: function () { return feedback_1.feedback; } });
|
|
18
|
+
var install_1 = require("./install");
|
|
19
|
+
Object.defineProperty(exports, "install", { enumerable: true, get: function () { return install_1.install; } });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.install = void 0;
|
|
4
|
+
const install_1 = require("./install");
|
|
5
|
+
const interactive = async (options) => {
|
|
6
|
+
(0, install_1.installToEnvironment)(options);
|
|
7
|
+
};
|
|
8
|
+
const nonInteractive = async () => {
|
|
9
|
+
throw new Error(`"install" is not available in non-interactive mode`);
|
|
10
|
+
};
|
|
11
|
+
exports.install = {
|
|
12
|
+
interactive,
|
|
13
|
+
nonInteractive,
|
|
14
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.installToEnvironment = void 0;
|
|
7
|
+
const open_1 = __importDefault(require("open"));
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
10
|
+
const constants_1 = require("../constants");
|
|
11
|
+
async function installToEnvironment(options) {
|
|
12
|
+
let definitionId;
|
|
13
|
+
if (options.definitionId) {
|
|
14
|
+
definitionId = options.definitionId;
|
|
15
|
+
}
|
|
16
|
+
else if (process.env[constants_1.APP_DEF_ENV_KEY]) {
|
|
17
|
+
definitionId = process.env[constants_1.APP_DEF_ENV_KEY];
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const prompts = await inquirer_1.default.prompt([
|
|
21
|
+
{
|
|
22
|
+
name: 'definitionId',
|
|
23
|
+
message: `The id of the app:`,
|
|
24
|
+
},
|
|
25
|
+
]);
|
|
26
|
+
definitionId = prompts.definitionId;
|
|
27
|
+
}
|
|
28
|
+
if (!definitionId) {
|
|
29
|
+
console.log(`
|
|
30
|
+
${chalk_1.default.red('Error:')} There was no app-definition defined.
|
|
31
|
+
|
|
32
|
+
Please add it with ${chalk_1.default.cyan('--definition-id=<app-definition-id>')}
|
|
33
|
+
or set the environment variable ${chalk_1.default.cyan(`${constants_1.APP_DEF_ENV_KEY} = <app-definition-id>`)}
|
|
34
|
+
`);
|
|
35
|
+
throw new Error('No app-definition-id');
|
|
36
|
+
}
|
|
37
|
+
const host = options.host || constants_1.DEFAULT_CONTENTFUL_APP_HOST;
|
|
38
|
+
const redirectUrl = `https://${host}/deeplink?link=apps`;
|
|
39
|
+
try {
|
|
40
|
+
(0, open_1.default)(`${redirectUrl}&id=${definitionId}`);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
console.log(`${chalk_1.default.red('Error:')} Failed to open browser`);
|
|
44
|
+
console.log(err.message);
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.installToEnvironment = installToEnvironment;
|
package/lib/types.d.ts
CHANGED
|
@@ -50,6 +50,10 @@ export interface CleanupSettings {
|
|
|
50
50
|
export interface OpenSettingsOptions {
|
|
51
51
|
definitionId?: string;
|
|
52
52
|
}
|
|
53
|
+
export interface InstallOptions {
|
|
54
|
+
definitionId?: string;
|
|
55
|
+
host?: string;
|
|
56
|
+
}
|
|
53
57
|
export interface UploadOptions {
|
|
54
58
|
organizationId?: string;
|
|
55
59
|
definitionId?: string;
|
package/lib/utils.js
CHANGED
|
@@ -9,9 +9,11 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
9
9
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
10
10
|
const cache_credential_1 = require("./cache-credential");
|
|
11
11
|
const DEFAULT_MANIFEST_PATH = './contentful-app-manifest.json';
|
|
12
|
-
const
|
|
12
|
+
const functionEvents = {
|
|
13
13
|
fieldMappingEvent: 'graphql.field.mapping',
|
|
14
14
|
queryEvent: 'graphql.query',
|
|
15
|
+
resourceLinksSearchEvent: 'resources.search',
|
|
16
|
+
resourceLinksLookupEvent: 'resources.lookup',
|
|
15
17
|
};
|
|
16
18
|
const appEvents = {
|
|
17
19
|
appEventFilter: 'appevent.filter',
|
|
@@ -101,7 +103,7 @@ function getEntityFromManifest(type) {
|
|
|
101
103
|
? item.allowNetworks.map(exports.stripProtocol)
|
|
102
104
|
: [];
|
|
103
105
|
const accepts = 'accepts' in item && Array.isArray(item.accepts) ? item.accepts : undefined;
|
|
104
|
-
const hasInvalidEvent = accepts?.some((event) => ![...Object.values(
|
|
106
|
+
const hasInvalidEvent = accepts?.some((event) => ![...Object.values(functionEvents), ...Object.values(appEvents)].includes(event));
|
|
105
107
|
const hasInvalidNetwork = allowNetworks.find((netWork) => !(0, exports.isValidNetwork)(netWork));
|
|
106
108
|
if (hasInvalidNetwork) {
|
|
107
109
|
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.
|
|
3
|
+
"version": "1.24.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.1.0",
|
|
55
|
-
"contentful-management": "11.
|
|
55
|
+
"contentful-management": "11.27.1",
|
|
56
56
|
"dotenv": "16.4.5",
|
|
57
57
|
"ignore": "5.3.1",
|
|
58
58
|
"inquirer": "8.2.6",
|
|
@@ -60,14 +60,14 @@
|
|
|
60
60
|
"open": "8.4.2",
|
|
61
61
|
"ora": "5.4.1"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "7441f7531b4d9165d7936372acafbb82a180dccd",
|
|
64
64
|
"devDependencies": {
|
|
65
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/chai": "4.3.16",
|
|
69
69
|
"@types/inquirer": "8.2.1",
|
|
70
|
-
"@types/lodash": "4.17.
|
|
70
|
+
"@types/lodash": "4.17.5",
|
|
71
71
|
"@types/mocha": "10.0.6",
|
|
72
72
|
"@types/proxyquire": "1.3.31",
|
|
73
73
|
"@types/sinon": "17.0.3",
|