@contentful/create-contentful-app 1.1.0-alpha.7 → 1.2.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 CHANGED
@@ -1,19 +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
- This project makes it easy to bootstrap [Contentful Apps](https://www.contentful.com/developers/docs/extensibility/app-framework/) with [React](https://reactjs.org/) and [Forma 36](https://f36.contentful.com/) (Contentful's design system).
5
+ `create-contentful-app` is a command line interface to easily bootstrap [Contentful Apps](https://www.contentful.com/developers/docs/extensibility/app-framework/).
4
6
 
5
- ## Requirements
7
+ # Requirements
6
8
 
7
9
  - Node.js v14.15 or v16
8
- - NPM v6
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
+ ![Screenshot of `npx create-contentful-app my-app`](./docs/screenshot.png)
21
+
22
+ ## Bootstrap
23
+
24
+ You can run `create-contentful-app` using one of the following commands:
25
+
26
+ ```bash
27
+ # npx
28
+ npx create-contentful-app <app-name>
29
+
30
+ # npm
31
+ npm init contentful-app <app-name>
32
+
33
+ # Yarn
34
+ yarn create contentful-app <app-name>
35
+ ```
36
+
37
+ ## CLI Options
38
+
39
+ ### Package Manager
9
40
 
41
+ `--npm` or `--yarn`
10
42
 
11
- # Quick Overview
43
+ Use npm or Yarn to manage dependencies. If omitted, defaults to the manager used to run `create-contentful-app`.
12
44
 
13
- To start developing your app:
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:
14
63
 
15
64
  ```
16
- npx @contentful/create-contentful-app my-first-app
17
- cd my-first-app
18
- npm start
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
19
89
  ```
package/lib/index.js CHANGED
@@ -103,7 +103,7 @@ function initProject(appName, options) {
103
103
  return __awaiter(this, void 0, void 0, function* () {
104
104
  commander_1.program
105
105
  .name(`npx ${(0, logger_1.code)('create-contentful-app')}`)
106
- .helpOption(true)
106
+ .helpOption(true, 'shows all available CLI options')
107
107
  .description([
108
108
  'Bootstrap your app inside a new folder `my-app`',
109
109
  '',
@@ -118,13 +118,13 @@ function initProject(appName, options) {
118
118
  .argument('[app-name]', 'app name')
119
119
  .option('--npm', 'use npm')
120
120
  .option('--yarn', 'use Yarn')
121
- .option('--javascript, -js', 'use default JavaScript template')
122
- .option('--typescript, -ts', 'use default TypeScript template')
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
  `provide a template by its source repository.`,
125
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/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.Js) {
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', 'Js', 'Ts'];
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.Ts;
56
- delete normalizedOptions.Js;
54
+ delete normalizedOptions.typescript;
55
+ delete normalizedOptions.javascript;
57
56
  }
58
57
  if (normalizedOptions.example) {
59
58
  fallbackOption = '--example';
60
- delete normalizedOptions.Ts;
61
- delete normalizedOptions.Js;
59
+ delete normalizedOptions.typescript;
60
+ delete normalizedOptions.javascript;
62
61
  }
63
- if (normalizedOptions.Ts) {
62
+ if (normalizedOptions.typescript) {
64
63
  fallbackOption = '--typescript';
65
- delete normalizedOptions.Js;
64
+ delete normalizedOptions.javascript;
66
65
  }
67
- if (!normalizedOptions.Js) {
68
- normalizedOptions.Ts = true;
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/create-contentful-app",
3
- "version": "1.1.0-alpha.7",
3
+ "version": "1.2.0",
4
4
  "description": "A template for building Contentful Apps",
5
5
  "keywords": [
6
6
  "contentful",
@@ -32,11 +32,10 @@
32
32
  "lint": "eslint ./src",
33
33
  "lint:fix": "npm run lint -- --fix",
34
34
  "pre-commit": "lint-staged",
35
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
36
35
  "build": "tsc"
37
36
  },
38
37
  "dependencies": {
39
- "@contentful/app-scripts": "^0.16.0-alpha.2",
38
+ "@contentful/app-scripts": "file:../contentful--app-scripts",
40
39
  "chalk": "^4.1.0",
41
40
  "commander": "^9.0.0",
42
41
  "degit": "2.8.4",
@@ -64,6 +63,5 @@
64
63
  "@types/rimraf": "^3.0.2",
65
64
  "@types/tildify": "^2.0.2",
66
65
  "@types/validate-npm-package-name": "^3.0.3"
67
- },
68
- "gitHead": "a66c3394d79d19a999d6509ec967b8b85eca41cc"
66
+ }
69
67
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2020 Contentful
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.