@contentful/create-contentful-app 1.6.1 → 1.7.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/lib/constants.js +2 -1
- package/lib/getTemplateSource.js +15 -8
- package/lib/index.js +1 -1
- package/lib/utils.js +3 -2
- package/package.json +3 -3
package/lib/constants.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EXAMPLES_REPO_URL = exports.CREATE_APP_DEFINITION_GUIDE_URL = void 0;
|
|
3
|
+
exports.TEMPLATES = exports.EXAMPLES_REPO_URL = exports.CREATE_APP_DEFINITION_GUIDE_URL = void 0;
|
|
4
4
|
exports.CREATE_APP_DEFINITION_GUIDE_URL = 'https://ctfl.io/app-tutorial#embed-your-app-in-the-contentful-web-app';
|
|
5
5
|
exports.EXAMPLES_REPO_URL = 'https://github.com/contentful/apps/tree/master/examples';
|
|
6
|
+
exports.TEMPLATES = ['javascript', 'typescript', 'vue', 'vite-react', 'nextjs'];
|
package/lib/getTemplateSource.js
CHANGED
|
@@ -18,43 +18,50 @@ const inquirer_1 = __importDefault(require("inquirer"));
|
|
|
18
18
|
const chalk_1 = __importDefault(require("chalk"));
|
|
19
19
|
const types_1 = require("./types");
|
|
20
20
|
const logger_1 = require("./logger");
|
|
21
|
+
const constants_1 = require("./constants");
|
|
22
|
+
const CONTENTFUL_APPS_EXAMPLE_FOLDER = 'https://api.github.com/repos/contentful/apps/contents/examples';
|
|
21
23
|
const EXAMPLES_PATH = 'contentful/apps/examples/';
|
|
22
24
|
function isContentfulTemplate(url) {
|
|
23
25
|
return Object.values(types_1.ContentfulExample).some((t) => url.includes(EXAMPLES_PATH + t));
|
|
24
26
|
}
|
|
25
|
-
const CONTENTFUL_APPS_EXAMPLE_FOLDER = "https://api.github.com/repos/contentful/apps/contents/examples";
|
|
26
27
|
function getGithubFolderNames() {
|
|
27
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
29
|
const response = yield (0, node_fetch_1.default)(CONTENTFUL_APPS_EXAMPLE_FOLDER);
|
|
29
30
|
const contents = yield response.json();
|
|
30
31
|
return contents
|
|
31
|
-
.filter((content) => content.type === 'dir')
|
|
32
|
+
.filter((content) => content.type === 'dir' && !constants_1.TEMPLATES.includes(content.name))
|
|
32
33
|
.map((content) => content.name);
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
function promptExampleSelection() {
|
|
36
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
38
|
let template = 'typescript';
|
|
38
|
-
// ask user whether to start with a blank template or use an example
|
|
39
|
+
// ask user whether to start with a blank template or use an example
|
|
39
40
|
const { starter } = yield inquirer_1.default.prompt([
|
|
40
41
|
{
|
|
41
42
|
name: 'starter',
|
|
42
43
|
message: 'Do you want to start with a blank template or use one of our examples?',
|
|
43
44
|
type: 'list',
|
|
44
|
-
choices: [
|
|
45
|
-
|
|
45
|
+
choices: [
|
|
46
|
+
{ name: 'Template', value: 'template' },
|
|
47
|
+
{ name: 'Example', value: 'example' },
|
|
48
|
+
],
|
|
49
|
+
default: 'template',
|
|
46
50
|
},
|
|
47
51
|
]);
|
|
48
|
-
// if the user chose to use
|
|
49
|
-
if (starter === '
|
|
52
|
+
// if the user chose to use a template, ask which language they prefer
|
|
53
|
+
if (starter === 'template') {
|
|
50
54
|
const { language } = yield inquirer_1.default.prompt([
|
|
51
55
|
{
|
|
52
56
|
name: 'language',
|
|
53
|
-
message: '
|
|
57
|
+
message: 'Pick a template',
|
|
54
58
|
type: 'list',
|
|
55
59
|
choices: [
|
|
56
60
|
{ name: 'TypeScript', value: 'typescript' },
|
|
57
61
|
{ name: 'JavaScript', value: 'javascript' },
|
|
62
|
+
{ name: 'Next.js', value: 'nextjs' },
|
|
63
|
+
{ name: 'React + Vite', value: 'vite-react' },
|
|
64
|
+
{ name: 'Vue', value: 'vue' },
|
|
58
65
|
],
|
|
59
66
|
default: 'typescript',
|
|
60
67
|
},
|
package/lib/index.js
CHANGED
|
@@ -130,7 +130,7 @@ function initProject(appName, options) {
|
|
|
130
130
|
'',
|
|
131
131
|
(0, logger_1.code)(' create-contentful-app my-app --source "github:user/repo"'),
|
|
132
132
|
'',
|
|
133
|
-
`Official Contentful templates are hosted at ${(0, logger_1.highlight)(constants_1.EXAMPLES_REPO_URL)}.`,
|
|
133
|
+
`Official Contentful templates and examples are hosted at ${(0, logger_1.highlight)(constants_1.EXAMPLES_REPO_URL)}.`,
|
|
134
134
|
].join('\n'))
|
|
135
135
|
.argument('[app-name]', 'app name')
|
|
136
136
|
.option('--npm', 'use npm')
|
package/lib/utils.js
CHANGED
|
@@ -5,7 +5,7 @@ const child_process_1 = require("child_process");
|
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const logger_1 = require("./logger");
|
|
8
|
-
const MUTUALLY_EXCLUSIVE_OPTIONS = ['source', 'example', '
|
|
8
|
+
const MUTUALLY_EXCLUSIVE_OPTIONS = ['source', 'example', 'typescript', 'javascript'];
|
|
9
9
|
function exec(command, args, options) {
|
|
10
10
|
return new Promise((resolve, reject) => {
|
|
11
11
|
const process = (0, child_process_1.spawn)(command, args, Object.assign({ stdio: 'inherit', shell: true }, options));
|
|
@@ -64,7 +64,8 @@ function normalizeOptions(options) {
|
|
|
64
64
|
delete normalizedOptions.javascript;
|
|
65
65
|
}
|
|
66
66
|
if (currentMutuallyExclusiveOptions.length > 1) {
|
|
67
|
-
|
|
67
|
+
const paramsString = new Intl.ListFormat('en', { style: 'long', type: 'conjunction' }).format(currentMutuallyExclusiveOptions.map((option) => (0, logger_1.highlight)(`--${option}`)));
|
|
68
|
+
(0, logger_1.warn)(`Options ${paramsString} are mutually exclusive, using ${(0, logger_1.choice)(fallbackOption)}.`);
|
|
68
69
|
}
|
|
69
70
|
return normalizedOptions;
|
|
70
71
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/create-contentful-app",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "A template for building Contentful Apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contentful",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"build": "tsc"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@contentful/app-scripts": "1.7.
|
|
38
|
+
"@contentful/app-scripts": "1.7.1",
|
|
39
39
|
"analytics-node": "^6.2.0",
|
|
40
40
|
"chalk": "4.1.2",
|
|
41
41
|
"commander": "9.5.0",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"@types/tildify": "2.0.2",
|
|
69
69
|
"@types/validate-npm-package-name": "4.0.0"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "6bc2e2e5a1c2764debb87bfbfde1b234e667771e"
|
|
72
72
|
}
|