@contentful/app-scripts 1.12.0 → 1.13.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.
Files changed (82) hide show
  1. package/README.md +4 -4
  2. package/lib/activate/activate-bundle.d.ts +2 -0
  3. package/lib/activate/activate-bundle.js +45 -58
  4. package/lib/activate/build-bundle-activate-settings.d.ts +2 -0
  5. package/lib/activate/build-bundle-activate-settings.js +32 -34
  6. package/lib/activate/get-activate-args.d.ts +2 -0
  7. package/lib/activate/get-activate-args.js +33 -30
  8. package/lib/activate/index.d.ts +5 -0
  9. package/lib/activate/index.js +17 -13
  10. package/lib/analytics.d.ts +11 -0
  11. package/lib/analytics.js +42 -0
  12. package/lib/bin.d.ts +2 -0
  13. package/lib/bin.js +69 -0
  14. package/lib/cache-credential/index.d.ts +1 -0
  15. package/lib/cache-credential/index.js +74 -0
  16. package/lib/clean-up/build-clean-up-settings.d.ts +2 -0
  17. package/lib/clean-up/build-clean-up-settings.js +32 -36
  18. package/lib/clean-up/clean-up-bundles.d.ts +2 -0
  19. package/lib/clean-up/clean-up-bundles.js +91 -118
  20. package/lib/clean-up/get-clean-up-settings.d.ts +2 -0
  21. package/lib/clean-up/get-clean-up-settings.js +34 -32
  22. package/lib/clean-up/index.d.ts +5 -0
  23. package/lib/clean-up/index.js +17 -13
  24. package/lib/constants.d.ts +8 -0
  25. package/lib/constants.js +11 -0
  26. package/lib/create-app-definition/build-app-definition-settings.d.ts +7 -0
  27. package/lib/create-app-definition/build-app-definition-settings.js +73 -77
  28. package/lib/create-app-definition/create-app-definition.d.ts +2 -0
  29. package/lib/create-app-definition/create-app-definition.js +80 -112
  30. package/lib/create-app-definition/index.d.ts +4 -0
  31. package/lib/create-app-definition/index.js +18 -15
  32. package/lib/definition-api.d.ts +7 -0
  33. package/lib/definition-api.js +37 -44
  34. package/lib/get-app-info.d.ts +10 -0
  35. package/lib/get-app-info.js +22 -27
  36. package/lib/get-management-token.d.ts +1 -0
  37. package/lib/get-management-token.js +53 -60
  38. package/lib/index.d.ts +6 -0
  39. package/lib/index.js +15 -15
  40. package/lib/open/index.d.ts +5 -0
  41. package/lib/open/index.js +12 -8
  42. package/lib/open/open-settings.d.ts +3 -0
  43. package/lib/open/open-settings.js +46 -46
  44. package/lib/organization-api.d.ts +7 -0
  45. package/lib/organization-api.js +39 -51
  46. package/lib/types.d.ts +73 -0
  47. package/lib/types.js +2 -0
  48. package/lib/upload/build-upload-settings.d.ts +2 -0
  49. package/lib/upload/build-upload-settings.js +53 -60
  50. package/lib/upload/create-app-bundle.d.ts +3 -0
  51. package/lib/upload/create-app-bundle.js +64 -71
  52. package/lib/upload/create-app-upload.d.ts +2 -0
  53. package/lib/upload/create-app-upload.js +31 -36
  54. package/lib/upload/create-zip-from-directory.d.ts +2 -0
  55. package/lib/upload/create-zip-from-directory.js +23 -21
  56. package/lib/upload/get-upload-settings-args.d.ts +2 -0
  57. package/lib/upload/get-upload-settings-args.js +43 -41
  58. package/lib/upload/index.d.ts +5 -0
  59. package/lib/upload/index.js +20 -18
  60. package/lib/upload/validate-bundle.d.ts +1 -0
  61. package/lib/upload/validate-bundle.js +26 -33
  62. package/lib/utils.d.ts +12 -0
  63. package/lib/utils.js +87 -121
  64. package/lib/validate-arguments.d.ts +1 -0
  65. package/lib/validate-arguments.js +20 -14
  66. package/package.json +23 -11
  67. package/bin/app-scripts +0 -78
  68. package/lib/activate/activate-bundle.test.js +0 -69
  69. package/lib/clean-up/clean-up-bundles.test.js +0 -118
  70. package/lib/create-app-definition/create-app-definition.test.js +0 -87
  71. package/lib/get-app-info.test.js +0 -57
  72. package/lib/get-management-token.test.js +0 -82
  73. package/lib/open/open-settings.test.js +0 -45
  74. package/lib/upload/create-app-bundle.test.js +0 -110
  75. package/lib/upload/create-app-upload.test.js +0 -50
  76. package/lib/upload/validate-bundle.test.js +0 -45
  77. package/lib/utils.test.js +0 -323
  78. package/lib/validate-arguments.test.js +0 -33
  79. package/utils/analytics.js +0 -36
  80. package/utils/cache-credential/index.js +0 -81
  81. package/utils/cache-credential/index.test.js +0 -73
  82. package/utils/constants.js +0 -21
@@ -1,129 +1,102 @@
1
- const chalk = require('chalk');
2
- const ora = require('ora');
3
- const Bottleneck = require('bottleneck');
4
- const {
5
- MAX_CONCURRENT_DELETION_CALLS,
6
- DEFAULT_BUNDLES_TO_FETCH,
7
- } = require('../../utils/constants');
8
- const { throwError } = require('../utils');
9
- const { createClient } = require('contentful-management');
10
-
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.cleanUpBundles = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const ora_1 = __importDefault(require("ora"));
9
+ const bottleneck_1 = __importDefault(require("bottleneck"));
10
+ const constants_1 = require("../constants");
11
+ const utils_1 = require("../utils");
12
+ const contentful_management_1 = require("contentful-management");
11
13
  async function deleteBundle(bundleId, index, maxIndex, client, settings) {
12
- const deleteSpinner = ora(`Deleting ${index + 1} out of ${maxIndex} bundles...`).start();
13
- await client.appBundle.delete({
14
- appBundleId: bundleId,
15
- appDefinitionId: settings.definition.value,
16
- organizationId: settings.organization.value,
17
- });
18
-
19
- deleteSpinner.stop();
20
- console.log(`${chalk.green('Done:')} ${index + 1}/${maxIndex} bundles deleted successfully`);
14
+ const deleteSpinner = (0, ora_1.default)(`Deleting ${index + 1} out of ${maxIndex} bundles...`).start();
15
+ await client.appBundle.delete({
16
+ appBundleId: bundleId,
17
+ appDefinitionId: settings.definition.value,
18
+ organizationId: settings.organization.value,
19
+ });
20
+ deleteSpinner.stop();
21
+ console.log(`${chalk_1.default.green('Done:')} ${index + 1}/${maxIndex} bundles deleted successfully`);
21
22
  }
22
-
23
23
  const scheduleBundleDeletion = async (bundlesToDelete, client, settings) => {
24
- const limiter = new Bottleneck({ maxConcurrent: MAX_CONCURRENT_DELETION_CALLS });
25
- await Promise.all(
26
- bundlesToDelete.map((bundle, index) =>
27
- limiter.schedule(() =>
28
- deleteBundle(bundle.sys.id, index, bundlesToDelete.length, client, settings)
29
- )
30
- )
31
- );
24
+ const limiter = new bottleneck_1.default({ maxConcurrent: constants_1.MAX_CONCURRENT_DELETION_CALLS });
25
+ await Promise.all(bundlesToDelete.map((bundle, index) => limiter.schedule(() => deleteBundle(bundle.sys.id, index, bundlesToDelete.length, client, settings))));
32
26
  };
33
-
34
27
  async function cleanUpBundles(settings) {
35
- let bundlesToDelete, definition;
36
-
37
- const client = createClient(
38
- {
39
- host: settings.host,
40
- accessToken: settings.accessToken,
41
- },
42
- { type: 'plain' }
43
- );
44
-
45
- const fetchAppBundles = async (limit = DEFAULT_BUNDLES_TO_FETCH, skip = 0) => {
46
- return await client.appBundle.getMany({
47
- appDefinitionId: settings.definition.value,
48
- organizationId: settings.organization.value,
49
- query: {
50
- limit,
51
- skip,
52
- },
53
- });
54
- };
55
-
56
- const getAppBundles = async (requestedAmount = DEFAULT_BUNDLES_TO_FETCH) => {
57
- if (requestedAmount < 1) {
58
- throw new Error('Requested amount of bundles to fetch must be greater than 0');
59
- }
60
- const getBundles = async (limit, skip) => {
61
- const result = await fetchAppBundles(limit, skip);
62
- const currLength = skip + result.items.length;
63
-
64
- if (result.total > currLength) {
65
- return [...result.items, ...(await getBundles(result.items.length, currLength))];
66
- } else {
67
- return result.items;
68
- }
28
+ let definition;
29
+ let bundlesToDelete;
30
+ const client = (0, contentful_management_1.createClient)({
31
+ host: settings.host,
32
+ accessToken: settings.accessToken,
33
+ }, { type: 'plain' });
34
+ const fetchAppBundles = async (limit = constants_1.DEFAULT_BUNDLES_TO_FETCH, skip = 0) => {
35
+ return await client.appBundle.getMany({
36
+ appDefinitionId: settings.definition.value,
37
+ organizationId: settings.organization.value,
38
+ query: {
39
+ limit,
40
+ skip,
41
+ },
42
+ });
69
43
  };
70
-
71
- const all = await getBundles(DEFAULT_BUNDLES_TO_FETCH, 0);
72
- return all.reverse().slice(0, requestedAmount);
73
- };
74
-
75
- const getAppBundleCount = async () => {
76
- return await fetchAppBundles(1, 0);
77
- };
78
-
79
- const bundlesSpinner = ora(`Fetching all bundles...`).start();
80
- try {
81
- const { total } = await getAppBundleCount();
82
- const amountToDelete = total - settings.keep;
83
- if (amountToDelete < 1) {
84
- console.log(`${chalk.yellow('Warning:')} There is nothing to delete`);
85
- bundlesSpinner.stop();
86
- return;
44
+ const getAppBundles = async (requestedAmount = constants_1.DEFAULT_BUNDLES_TO_FETCH) => {
45
+ if (requestedAmount < 1) {
46
+ throw new Error('Requested amount of bundles to fetch must be greater than 0');
47
+ }
48
+ const getBundles = async (limit, skip = 0) => {
49
+ const result = await fetchAppBundles(limit, skip);
50
+ const currLength = skip + result.items.length;
51
+ if (result.total > currLength) {
52
+ return [...result.items, ...(await getBundles(result.items.length, currLength))];
53
+ }
54
+ else {
55
+ return result.items;
56
+ }
57
+ };
58
+ const all = await getBundles(constants_1.DEFAULT_BUNDLES_TO_FETCH, 0);
59
+ return all.reverse().slice(0, requestedAmount);
60
+ };
61
+ const getAppBundleCount = async () => {
62
+ return await fetchAppBundles(1, 0);
63
+ };
64
+ const bundlesSpinner = (0, ora_1.default)(`Fetching all bundles...`).start();
65
+ try {
66
+ const { total } = await getAppBundleCount();
67
+ const amountToDelete = total - settings.keep;
68
+ if (amountToDelete < 1) {
69
+ console.log(`${chalk_1.default.yellow('Warning:')} There is nothing to delete`);
70
+ bundlesSpinner.stop();
71
+ return;
72
+ }
73
+ bundlesToDelete = await getAppBundles(amountToDelete);
74
+ definition = await client.appDefinition.get({
75
+ appDefinitionId: settings.definition.value,
76
+ organizationId: settings.organization.value,
77
+ });
87
78
  }
88
- bundlesToDelete = await getAppBundles(amountToDelete);
89
- definition = await client.appDefinition.get({
90
- appDefinitionId: settings.definition.value,
91
- organizationId: settings.organization.value,
92
- });
93
- } catch (e) {
94
- throwError(e, 'Something went wrong fetching the bundles');
95
- }
96
-
97
- bundlesSpinner.stop();
98
-
99
- if (definition.bundle) {
100
- bundlesToDelete = bundlesToDelete.filter(
101
- (bundle) => bundle.sys.id !== definition.bundle.sys.id
102
- );
103
- }
104
-
105
- if (bundlesToDelete.length < 1) {
106
- console.log(`${chalk.yellow('Warning:')} There is nothing to delete`);
107
- }
108
-
109
- console.log(`
79
+ catch (e) {
80
+ return (0, utils_1.throwError)(e, 'Something went wrong fetching the bundles');
81
+ }
82
+ bundlesSpinner.stop();
83
+ if (definition.bundle) {
84
+ bundlesToDelete = bundlesToDelete.filter((bundle) => bundle.sys.id !== definition.bundle.sys.id);
85
+ }
86
+ if (bundlesToDelete.length < 1) {
87
+ console.log(`${chalk_1.default.yellow('Warning:')} There is nothing to delete`);
88
+ }
89
+ console.log(`
110
90
 
111
- ${chalk.cyan('Info:')} ${bundlesToDelete.length} bundle${
112
- bundlesToDelete.length > 1 ? 's' : ''
113
- } will be deleted
91
+ ${chalk_1.default.cyan('Info:')} ${bundlesToDelete.length} bundle${bundlesToDelete.length > 1 ? 's' : ''} will be deleted
114
92
 
115
93
  `);
116
-
117
- try {
118
- await scheduleBundleDeletion(bundlesToDelete, client, settings);
119
- console.log(
120
- `${chalk.green('Success:')} All ${bundlesToDelete.length} bundles are deleted successfully`
121
- );
122
- } catch (e) {
123
- throwError(e, 'Something went wrong deleting the bundles');
124
- }
94
+ try {
95
+ await scheduleBundleDeletion(bundlesToDelete, client, settings);
96
+ console.log(`${chalk_1.default.green('Success:')} All ${bundlesToDelete.length} bundles are deleted successfully`);
97
+ }
98
+ catch (e) {
99
+ return (0, utils_1.throwError)(e, 'Something went wrong deleting the bundles');
100
+ }
125
101
  }
126
-
127
- module.exports = {
128
- cleanUpBundles,
129
- };
102
+ exports.cleanUpBundles = cleanUpBundles;
@@ -0,0 +1,2 @@
1
+ import { CleanupOptions, CleanupSettings } from '../types';
2
+ export declare function getCleanUpSettingsArgs(options: CleanupOptions): Promise<CleanupSettings>;
@@ -1,38 +1,40 @@
1
- const chalk = require('chalk');
2
- const ora = require('ora');
3
- const { DEFAULT_BUNDLES_TO_KEEP } = require('../../utils/constants');
4
- const { validateArguments } = require('../validate-arguments');
5
- const { getAppInfo } = require('../get-app-info');
6
-
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.getCleanUpSettingsArgs = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const ora_1 = __importDefault(require("ora"));
9
+ const constants_1 = require("../constants");
10
+ const validate_arguments_1 = require("../validate-arguments");
11
+ const get_app_info_1 = require("../get-app-info");
7
12
  const requiredOptions = {
8
- definitionId: '--definition-id',
9
- organizationId: '--organization-id',
10
- token: '--token',
13
+ definitionId: '--definition-id',
14
+ organizationId: '--organization-id',
15
+ token: '--token',
11
16
  };
12
-
13
17
  async function getCleanUpSettingsArgs(options) {
14
- const validateSpinner = ora('Validating your input...').start();
15
-
16
- try {
17
- validateArguments(requiredOptions, options, 'upload');
18
- const appInfo = await getAppInfo(options);
19
- return {
20
- ...appInfo,
21
- keep: options.keep !== undefined ? +options.keep : DEFAULT_BUNDLES_TO_KEEP,
22
- host: options.host,
23
- };
24
- } catch (err) {
25
- console.log(`
26
- ${chalk.red('Validation failed!')}
18
+ const validateSpinner = (0, ora_1.default)('Validating your input...').start();
19
+ try {
20
+ (0, validate_arguments_1.validateArguments)(requiredOptions, options, 'upload');
21
+ const appInfo = await (0, get_app_info_1.getAppInfo)(options);
22
+ return {
23
+ ...appInfo,
24
+ keep: options.keep !== undefined ? +options.keep : constants_1.DEFAULT_BUNDLES_TO_KEEP,
25
+ host: options.host,
26
+ };
27
+ }
28
+ catch (err) {
29
+ console.log(`
30
+ ${chalk_1.default.red('Validation failed!')}
27
31
  ${err.message}
28
32
  `);
29
- // eslint-disable-next-line no-process-exit
30
- process.exit(1);
31
- } finally {
32
- validateSpinner.stop();
33
- }
33
+ // eslint-disable-next-line no-process-exit
34
+ process.exit(1);
35
+ }
36
+ finally {
37
+ validateSpinner.stop();
38
+ }
34
39
  }
35
-
36
- module.exports = {
37
- getCleanUpSettingsArgs,
38
- };
40
+ exports.getCleanUpSettingsArgs = getCleanUpSettingsArgs;
@@ -0,0 +1,5 @@
1
+ import { CleanupOptions } from '../types';
2
+ export declare const cleanup: {
3
+ interactive: (options: CleanupOptions) => Promise<void>;
4
+ nonInteractive: (options: CleanupOptions) => Promise<void>;
5
+ };
@@ -1,14 +1,18 @@
1
- const { getCleanUpSettingsArgs } = require('./get-clean-up-settings');
2
- const { buildCleanUpSettings } = require('./build-clean-up-settings');
3
- const { cleanUpBundles } = require('./clean-up-bundles');
4
-
5
- module.exports = {
6
- async interactive(options) {
7
- const settings = await buildCleanUpSettings(options);
8
- await cleanUpBundles(settings);
9
- },
10
- async nonInteractive(options) {
11
- const settings = await getCleanUpSettingsArgs(options);
12
- await cleanUpBundles(settings);
13
- },
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cleanup = void 0;
4
+ const get_clean_up_settings_1 = require("./get-clean-up-settings");
5
+ const build_clean_up_settings_1 = require("./build-clean-up-settings");
6
+ const clean_up_bundles_1 = require("./clean-up-bundles");
7
+ const interactive = async (options) => {
8
+ const settings = await (0, build_clean_up_settings_1.buildCleanUpSettings)(options);
9
+ await (0, clean_up_bundles_1.cleanUpBundles)(settings);
10
+ };
11
+ const nonInteractive = async (options) => {
12
+ const settings = await (0, get_clean_up_settings_1.getCleanUpSettingsArgs)(options);
13
+ await (0, clean_up_bundles_1.cleanUpBundles)(settings);
14
+ };
15
+ exports.cleanup = {
16
+ interactive,
17
+ nonInteractive,
14
18
  };
@@ -0,0 +1,8 @@
1
+ export declare const DOTENV_FILE = ".env";
2
+ export declare const ACCESS_TOKEN_ENV_KEY = "CONTENTFUL_ACCESS_TOKEN";
3
+ export declare const ORG_ID_ENV_KEY = "CONTENTFUL_ORG_ID";
4
+ export declare const APP_DEF_ENV_KEY = "CONTENTFUL_APP_DEF_ID";
5
+ export declare const DEFAULT_BUNDLES_TO_KEEP = 50;
6
+ export declare const DEFAULT_BUNDLES_TO_FETCH = 1000;
7
+ export declare const MAX_CONCURRENT_DELETION_CALLS = 5;
8
+ export declare const DEFAULT_CONTENTFUL_API_HOST = "api.contentful.com";
@@ -0,0 +1,11 @@
1
+ "use strict";
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;
4
+ exports.DOTENV_FILE = '.env';
5
+ exports.ACCESS_TOKEN_ENV_KEY = 'CONTENTFUL_ACCESS_TOKEN';
6
+ exports.ORG_ID_ENV_KEY = 'CONTENTFUL_ORG_ID';
7
+ exports.APP_DEF_ENV_KEY = 'CONTENTFUL_APP_DEF_ID';
8
+ exports.DEFAULT_BUNDLES_TO_KEEP = 50;
9
+ exports.DEFAULT_BUNDLES_TO_FETCH = 1000;
10
+ exports.MAX_CONCURRENT_DELETION_CALLS = 5;
11
+ exports.DEFAULT_CONTENTFUL_API_HOST = 'api.contentful.com';
@@ -0,0 +1,7 @@
1
+ import { AppLocation, FieldType } from 'contentful-management';
2
+ export interface AppDefinitionSettings {
3
+ name: string;
4
+ locations: AppLocation['location'][];
5
+ fields?: FieldType[];
6
+ }
7
+ export declare function buildAppDefinitionSettings(): Promise<AppDefinitionSettings>;
@@ -1,84 +1,80 @@
1
- // @ts-check
2
- const chalk = require('chalk');
3
- const inquirer = require('inquirer');
4
- const path = require('path');
5
-
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.buildAppDefinitionSettings = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const inquirer_1 = __importDefault(require("inquirer"));
9
+ const path_1 = __importDefault(require("path"));
6
10
  async function buildAppDefinitionSettings() {
7
- console.log(
8
- chalk.dim(`
11
+ console.log(chalk_1.default.dim(`
9
12
  NOTE: This will create an app definition in your Contentful organization.
10
- - Read more about app definitions: ${chalk.underline('https://ctfl.io/app-definitions')}
11
- - Read more about app locations: ${chalk.underline('https://ctfl.io/app-locations')}
12
- `)
13
- );
14
-
15
- const appDefinitionSettings = await inquirer.prompt([
16
- {
17
- name: 'name',
18
- message: `App name (${path.basename(process.cwd())}):`,
19
- },
20
- {
21
- name: 'locations',
22
- message: `Select where your app can be rendered:`,
23
- type: 'checkbox',
24
- choices: [
25
- { name: 'App configuration screen ', value: 'app-config' },
26
- { name: 'Entry field', value: 'entry-field' },
27
- { name: 'Entry sidebar', value: 'entry-sidebar' },
28
- { name: 'Entry editor', value: 'entry-editor' },
29
- { name: 'Page', value: 'page' },
30
- { name: 'Home', value: 'home' },
31
- ],
32
- },
33
- {
34
- name: 'fields',
35
- message: 'Select the field types the app can be rendered:',
36
- type: 'checkbox',
37
- choices: [
38
- { name: 'Short text', value: { type: 'Symbol' } },
39
- { name: 'Short text, list', value: { type: 'Array', items: { type: 'Symbol' } } },
40
- { name: 'Long text', value: { type: 'Text' } },
41
- { name: 'Rich text', value: { type: 'RichText' } },
42
- { name: 'Number, integer', value: { type: 'Integer' } },
43
- { name: 'Number, decimal', value: { type: 'Number' } },
44
- { name: 'Date and time', value: { type: 'Date' } },
45
- { name: 'Location', value: { type: 'Location' } },
46
- { name: 'Boolean', value: { type: 'Boolean' } },
47
- { name: 'JSON object', value: { type: 'Object' } },
48
- { name: 'Entry reference', value: { type: 'Link', linkType: 'Entry' } },
13
+ - Read more about app definitions: ${chalk_1.default.underline('https://ctfl.io/app-definitions')}
14
+ - Read more about app locations: ${chalk_1.default.underline('https://ctfl.io/app-locations')}
15
+ `));
16
+ const appDefinitionSettings = await inquirer_1.default.prompt([
49
17
  {
50
- name: 'Entry reference, list',
51
- value: {
52
- type: 'Array',
53
- items: {
54
- type: 'Link',
55
- linkType: 'Entry',
56
- },
57
- },
18
+ name: 'name',
19
+ message: `App name (${path_1.default.basename(process.cwd())}):`,
58
20
  },
59
- { name: 'Media reference', value: { type: 'Link', linkType: 'Asset' } },
60
21
  {
61
- name: 'Media reference, list',
62
- value: { type: 'Array', items: { type: 'Link', linkType: 'Asset' } },
22
+ name: 'locations',
23
+ message: `Select where your app can be rendered:`,
24
+ type: 'checkbox',
25
+ choices: [
26
+ { name: 'App configuration screen ', value: 'app-config' },
27
+ { name: 'Entry field', value: 'entry-field' },
28
+ { name: 'Entry sidebar', value: 'entry-sidebar' },
29
+ { name: 'Entry editor', value: 'entry-editor' },
30
+ { name: 'Page', value: 'page' },
31
+ { name: 'Home', value: 'home' },
32
+ ],
63
33
  },
64
- ],
65
- when(answers) {
66
- return answers.locations.includes('entry-field');
67
- },
68
- validate(answers) {
69
- if (answers.length < 1) {
70
- return 'You must choose at least one field type.';
71
- }
72
- return true;
73
- },
74
- },
75
- ]);
76
-
77
- appDefinitionSettings.locations = ['dialog', ...appDefinitionSettings.locations];
78
-
79
- return appDefinitionSettings;
34
+ {
35
+ name: 'fields',
36
+ message: 'Select the field types the app can be rendered:',
37
+ type: 'checkbox',
38
+ choices: [
39
+ { name: 'Short text', value: { type: 'Symbol' } },
40
+ { name: 'Short text, list', value: { type: 'Array', items: { type: 'Symbol' } } },
41
+ { name: 'Long text', value: { type: 'Text' } },
42
+ { name: 'Rich text', value: { type: 'RichText' } },
43
+ { name: 'Number, integer', value: { type: 'Integer' } },
44
+ { name: 'Number, decimal', value: { type: 'Number' } },
45
+ { name: 'Date and time', value: { type: 'Date' } },
46
+ { name: 'Location', value: { type: 'Location' } },
47
+ { name: 'Boolean', value: { type: 'Boolean' } },
48
+ { name: 'JSON object', value: { type: 'Object' } },
49
+ { name: 'Entry reference', value: { type: 'Link', linkType: 'Entry' } },
50
+ {
51
+ name: 'Entry reference, list',
52
+ value: {
53
+ type: 'Array',
54
+ items: {
55
+ type: 'Link',
56
+ linkType: 'Entry',
57
+ },
58
+ },
59
+ },
60
+ { name: 'Media reference', value: { type: 'Link', linkType: 'Asset' } },
61
+ {
62
+ name: 'Media reference, list',
63
+ value: { type: 'Array', items: { type: 'Link', linkType: 'Asset' } },
64
+ },
65
+ ],
66
+ when(answers) {
67
+ return answers.locations.includes('entry-field');
68
+ },
69
+ validate(answers) {
70
+ if (answers.length < 1) {
71
+ return 'You must choose at least one field type.';
72
+ }
73
+ return true;
74
+ },
75
+ },
76
+ ]);
77
+ appDefinitionSettings.locations = ['dialog', ...appDefinitionSettings.locations];
78
+ return appDefinitionSettings;
80
79
  }
81
-
82
- module.exports = {
83
- buildAppDefinitionSettings,
84
- };
80
+ exports.buildAppDefinitionSettings = buildAppDefinitionSettings;
@@ -0,0 +1,2 @@
1
+ import { AppDefinitionSettings } from './build-app-definition-settings';
2
+ export declare function createAppDefinition(accessToken: string, appDefinitionSettings: AppDefinitionSettings): Promise<void>;