@contentful/create-contentful-app 1.1.0-alpha.1 → 1.1.0-alpha.10
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 +80 -9
- package/lib/index.js +16 -16
- package/lib/logger.js +3 -3
- package/lib/template.js +1 -1
- package/lib/utils.js +10 -11
- package/package.json +10 -12
package/README.md
CHANGED
|
@@ -1,18 +1,89 @@
|
|
|
1
|
+
<!-- Don't forget to also update the corresponding README.md of the create-contentful-app package -->
|
|
2
|
+
|
|
1
3
|
# Create Contentful App
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
`create-contentful-app` is a command line interface to easily bootstrap [Contentful Apps](https://www.contentful.com/developers/docs/extensibility/app-framework/).
|
|
6
|
+
|
|
7
|
+
# Requirements
|
|
8
|
+
|
|
9
|
+
- Node.js v14.15 or v16
|
|
10
|
+
- npm v6 or later
|
|
11
|
+
|
|
12
|
+
# Usage
|
|
13
|
+
|
|
14
|
+
To start developing your first app, run:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npx create-contentful-app my-first-app
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+

|
|
4
21
|
|
|
5
|
-
##
|
|
22
|
+
## Bootstrap
|
|
6
23
|
|
|
7
|
-
-
|
|
8
|
-
- NPM v6
|
|
24
|
+
You can run `create-contentful-app` using one of the following commands:
|
|
9
25
|
|
|
10
|
-
|
|
26
|
+
```bash
|
|
27
|
+
# npx
|
|
28
|
+
npx create-contentful-app <app-name>
|
|
11
29
|
|
|
12
|
-
|
|
30
|
+
# npm
|
|
31
|
+
npm init contentful-app <app-name>
|
|
13
32
|
|
|
33
|
+
# Yarn
|
|
34
|
+
yarn create contentful-app <app-name>
|
|
14
35
|
```
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
36
|
+
|
|
37
|
+
## CLI Options
|
|
38
|
+
|
|
39
|
+
### Package Manager
|
|
40
|
+
|
|
41
|
+
`--npm` or `--yarn`
|
|
42
|
+
|
|
43
|
+
Use npm or Yarn to manage dependencies. If omitted, defaults to the manager used to run `create-contentful-app`.
|
|
44
|
+
|
|
45
|
+
Both flags are mutually exclusive.
|
|
46
|
+
|
|
47
|
+
### Template
|
|
48
|
+
|
|
49
|
+
Select between predefined and custom templates:
|
|
50
|
+
|
|
51
|
+
- `-ts, --typescript`: Use TypeScript template (default)
|
|
52
|
+
- `-js, --javascript`: Use JavaScript template
|
|
53
|
+
- `-e, --example <example-name>`: Select a predefined template from https://github.com/contentful/apps/tree/master/examples
|
|
54
|
+
- `-s, --source <url>`: Use a custom template. Format: URL (HTTPS or SSH) or vendor:user/repo (e.g., github:user/repo)
|
|
55
|
+
|
|
56
|
+
These flags are mutually exclusive. If no flag is provided, the TypeScript template is used.
|
|
57
|
+
|
|
58
|
+
### Help
|
|
59
|
+
|
|
60
|
+
`--help`
|
|
61
|
+
|
|
62
|
+
Shows all available CLI options:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
Usage: npx create-contentful-app [options] [app-name]
|
|
66
|
+
|
|
67
|
+
Bootstrap your app inside a new folder `my-app`
|
|
68
|
+
|
|
69
|
+
create-contentful-app my-app
|
|
70
|
+
|
|
71
|
+
or specify your own template
|
|
72
|
+
|
|
73
|
+
create-contentful-app my-app --source "github:user/repo"
|
|
74
|
+
|
|
75
|
+
Official Contentful templates are hosted at https://github.com/contentful/apps/tree/master/examples.
|
|
76
|
+
|
|
77
|
+
Arguments:
|
|
78
|
+
app-name app name
|
|
79
|
+
|
|
80
|
+
Options:
|
|
81
|
+
--npm use npm
|
|
82
|
+
--yarn use Yarn
|
|
83
|
+
-js, --javascript use default JavaScript template
|
|
84
|
+
-ts, --typescript use default TypeScript template
|
|
85
|
+
-e, --example <example-name> bootstrap an example app from https://github.com/contentful/apps/tree/master/examples
|
|
86
|
+
-s, --source <url> provide a template by its source repository.
|
|
87
|
+
format: URL (HTTPS or SSH) or vendor:user/repo (e.g., github:user/repo)
|
|
88
|
+
-h, --help shows all available CLI options
|
|
18
89
|
```
|
package/lib/index.js
CHANGED
|
@@ -28,10 +28,10 @@ function successMessage(folder) {
|
|
|
28
28
|
console.log(`
|
|
29
29
|
${(0, logger_1.success)('Success!')} Created a new Contentful app in ${(0, logger_1.highlight)((0, tildify_1.default)(folder))}.
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
Now kick it off by running
|
|
32
32
|
|
|
33
|
-
${(0, logger_1.
|
|
34
|
-
${(0, logger_1.
|
|
33
|
+
${(0, logger_1.code)(`cd ${(0, tildify_1.default)(folder)}`)}
|
|
34
|
+
${(0, logger_1.code)(`npm start`)}
|
|
35
35
|
`);
|
|
36
36
|
}
|
|
37
37
|
function updatePackageName(appFolder) {
|
|
@@ -89,7 +89,7 @@ function initProject(appName, options) {
|
|
|
89
89
|
yield (0, utils_1.exec)('yarn', [], { cwd: fullAppFolder });
|
|
90
90
|
}
|
|
91
91
|
else {
|
|
92
|
-
yield (0, utils_1.exec)('npm', ['install'], { cwd: fullAppFolder });
|
|
92
|
+
yield (0, utils_1.exec)('npm', ['install', '--no-audit', '--no-fund'], { cwd: fullAppFolder });
|
|
93
93
|
}
|
|
94
94
|
successMessage(fullAppFolder);
|
|
95
95
|
}
|
|
@@ -102,29 +102,29 @@ function initProject(appName, options) {
|
|
|
102
102
|
(function main() {
|
|
103
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
104
|
commander_1.program
|
|
105
|
-
.name(`npx ${(0, logger_1.
|
|
106
|
-
.helpOption(true)
|
|
105
|
+
.name(`npx ${(0, logger_1.code)('create-contentful-app')}`)
|
|
106
|
+
.helpOption(true, 'shows all available CLI options')
|
|
107
107
|
.description([
|
|
108
108
|
'Bootstrap your app inside a new folder `my-app`',
|
|
109
109
|
'',
|
|
110
|
-
(0, logger_1.code)(' create-contentful-app
|
|
110
|
+
(0, logger_1.code)(' create-contentful-app my-app'),
|
|
111
111
|
'',
|
|
112
|
-
'or
|
|
112
|
+
'or specify your own template',
|
|
113
113
|
'',
|
|
114
|
-
(0, logger_1.code)(' create-contentful-app
|
|
114
|
+
(0, logger_1.code)(' create-contentful-app my-app --source "github:user/repo"'),
|
|
115
115
|
'',
|
|
116
|
-
`Contentful
|
|
116
|
+
`Official Contentful templates are hosted at ${(0, logger_1.highlight)('https://github.com/contentful/apps/tree/master/examples')}.`,
|
|
117
117
|
].join('\n'))
|
|
118
118
|
.argument('[app-name]', 'app name')
|
|
119
|
-
.option('--npm', 'use
|
|
119
|
+
.option('--npm', 'use npm')
|
|
120
120
|
.option('--yarn', 'use Yarn')
|
|
121
|
-
.option('
|
|
122
|
-
.option('
|
|
121
|
+
.option('-ts, --typescript', 'use TypeScript template (default)')
|
|
122
|
+
.option('-js, --javascript', 'use JavaScript template')
|
|
123
|
+
.option('-e, --example <example-name>', 'bootstrap an example app from https://github.com/contentful/apps/tree/master/examples')
|
|
123
124
|
.option('-s, --source <url>', [
|
|
124
|
-
`
|
|
125
|
-
`
|
|
125
|
+
`provide a template by its source repository.`,
|
|
126
|
+
`format: URL (HTTPS or SSH) or ${(0, logger_1.code)('vendor:user/repo')} (e.g., ${(0, logger_1.code)('github:user/repo')})`,
|
|
126
127
|
].join('\n'))
|
|
127
|
-
.option('-e, --example <example-name>', 'bootstrap an example app from https://github.com/contentful/apps/tree/master/examples')
|
|
128
128
|
.action(initProject);
|
|
129
129
|
yield commander_1.program.parseAsync();
|
|
130
130
|
});
|
package/lib/logger.js
CHANGED
|
@@ -21,14 +21,14 @@ function highlight(str) {
|
|
|
21
21
|
}
|
|
22
22
|
exports.highlight = highlight;
|
|
23
23
|
function choice(str) {
|
|
24
|
-
return chalk_1.default.
|
|
24
|
+
return chalk_1.default.cyan(str);
|
|
25
25
|
}
|
|
26
26
|
exports.choice = choice;
|
|
27
27
|
function success(str) {
|
|
28
|
-
return chalk_1.default.
|
|
28
|
+
return chalk_1.default.greenBright(str);
|
|
29
29
|
}
|
|
30
30
|
exports.success = success;
|
|
31
31
|
function code(str) {
|
|
32
|
-
return chalk_1.default.
|
|
32
|
+
return chalk_1.default.bold(str);
|
|
33
33
|
}
|
|
34
34
|
exports.code = code;
|
package/lib/template.js
CHANGED
|
@@ -28,7 +28,7 @@ function makeContentfulExampleSource(options) {
|
|
|
28
28
|
if (options.example) {
|
|
29
29
|
return EXAMPLES_PATH + options.example;
|
|
30
30
|
}
|
|
31
|
-
if (options.
|
|
31
|
+
if (options.javascript) {
|
|
32
32
|
return EXAMPLES_PATH + types_1.ContentfulExample.Javascript;
|
|
33
33
|
}
|
|
34
34
|
return EXAMPLES_PATH + types_1.ContentfulExample.Typescript;
|
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', 'javascript', 'typescript'];
|
|
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' }, options));
|
|
@@ -47,25 +47,24 @@ function normalizeOptions(options) {
|
|
|
47
47
|
normalizedOptions.npm = true;
|
|
48
48
|
}
|
|
49
49
|
let fallbackOption = '--typescript';
|
|
50
|
-
const currentMutuallyExclusiveOptions = MUTUALLY_EXCLUSIVE_OPTIONS
|
|
51
|
-
.filter((option) => normalizedOptions[option]);
|
|
50
|
+
const currentMutuallyExclusiveOptions = MUTUALLY_EXCLUSIVE_OPTIONS.filter((option) => normalizedOptions[option]);
|
|
52
51
|
if (normalizedOptions.source) {
|
|
53
52
|
fallbackOption = '--source';
|
|
54
53
|
delete normalizedOptions.example;
|
|
55
|
-
delete normalizedOptions.
|
|
56
|
-
delete normalizedOptions.
|
|
54
|
+
delete normalizedOptions.typescript;
|
|
55
|
+
delete normalizedOptions.javascript;
|
|
57
56
|
}
|
|
58
57
|
if (normalizedOptions.example) {
|
|
59
58
|
fallbackOption = '--example';
|
|
60
|
-
delete normalizedOptions.
|
|
61
|
-
delete normalizedOptions.
|
|
59
|
+
delete normalizedOptions.typescript;
|
|
60
|
+
delete normalizedOptions.javascript;
|
|
62
61
|
}
|
|
63
|
-
if (normalizedOptions.
|
|
62
|
+
if (normalizedOptions.typescript) {
|
|
64
63
|
fallbackOption = '--typescript';
|
|
65
|
-
delete normalizedOptions.
|
|
64
|
+
delete normalizedOptions.javascript;
|
|
66
65
|
}
|
|
67
|
-
if (!normalizedOptions.
|
|
68
|
-
normalizedOptions.
|
|
66
|
+
if (!normalizedOptions.javascript) {
|
|
67
|
+
normalizedOptions.typescript = true;
|
|
69
68
|
}
|
|
70
69
|
if (currentMutuallyExclusiveOptions.length > 1) {
|
|
71
70
|
(0, logger_1.warn)(`Options ${(0, logger_1.highlight)('--source')}, ${(0, logger_1.highlight)('--example')}, ${(0, logger_1.highlight)('--typescript')} and ${(0, logger_1.highlight)('--javascript')} are mutually exclusive, using ${(0, logger_1.choice)(fallbackOption)}.`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/create-contentful-app",
|
|
3
|
-
"version": "1.1.0-alpha.
|
|
3
|
+
"version": "1.1.0-alpha.10",
|
|
4
4
|
"description": "A template for building Contentful Apps",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"contentful",
|
|
7
|
+
"create-contentful-app"
|
|
8
|
+
],
|
|
5
9
|
"author": "Contentful GmbH",
|
|
6
10
|
"license": "MIT",
|
|
7
11
|
"repository": {
|
|
@@ -10,7 +14,7 @@
|
|
|
10
14
|
"directory": "packages/contentful--create-contentful-app"
|
|
11
15
|
},
|
|
12
16
|
"engines": {
|
|
13
|
-
"node": ">=
|
|
17
|
+
"node": ">=14.15.0",
|
|
14
18
|
"npm": ">=6"
|
|
15
19
|
},
|
|
16
20
|
"main": "lib/index.js",
|
|
@@ -28,16 +32,14 @@
|
|
|
28
32
|
"lint": "eslint ./src",
|
|
29
33
|
"lint:fix": "npm run lint -- --fix",
|
|
30
34
|
"pre-commit": "lint-staged",
|
|
31
|
-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
|
|
32
35
|
"build": "tsc"
|
|
33
36
|
},
|
|
34
37
|
"dependencies": {
|
|
35
|
-
"@contentful/app-scripts": "^0.16.0-alpha.
|
|
38
|
+
"@contentful/app-scripts": "^0.16.0-alpha.3",
|
|
36
39
|
"chalk": "^4.1.0",
|
|
37
40
|
"commander": "^9.0.0",
|
|
38
|
-
"contentful-management": "^8.0.0",
|
|
39
41
|
"degit": "2.8.4",
|
|
40
|
-
"inquirer": "^8.2.
|
|
42
|
+
"inquirer": "^8.2.1",
|
|
41
43
|
"rimraf": "^3.0.2",
|
|
42
44
|
"tildify": "^2.0.0",
|
|
43
45
|
"validate-npm-package-name": "^3.0.0"
|
|
@@ -46,10 +48,6 @@
|
|
|
46
48
|
"url": "https://github.com/contentful/create-contentful-app/issues"
|
|
47
49
|
},
|
|
48
50
|
"homepage": "https://github.com/contentful/create-contentful-app#readme",
|
|
49
|
-
"directories": {
|
|
50
|
-
"lib": "lib",
|
|
51
|
-
"test": "test"
|
|
52
|
-
},
|
|
53
51
|
"files": [
|
|
54
52
|
"lib"
|
|
55
53
|
],
|
|
@@ -61,10 +59,10 @@
|
|
|
61
59
|
"@types/chalk": "^2.2.0",
|
|
62
60
|
"@types/degit": "^2.8.3",
|
|
63
61
|
"@types/inquirer": "^8.2.0",
|
|
64
|
-
"@types/node": "^
|
|
62
|
+
"@types/node": "^14.14.31",
|
|
65
63
|
"@types/rimraf": "^3.0.2",
|
|
66
64
|
"@types/tildify": "^2.0.2",
|
|
67
65
|
"@types/validate-npm-package-name": "^3.0.3"
|
|
68
66
|
},
|
|
69
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "fb5a4faf89f78af13da791f60f549a27d416359a"
|
|
70
68
|
}
|