@contentful/create-contentful-app 1.18.6 → 2.0.0-alpha.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 +0 -1
- package/lib/getTemplateSource.js +1 -1
- package/lib/index.js +1 -6
- package/lib/utils.js +0 -2
- package/package.json +5 -5
- package/lib/includeAppAction.js +0 -70
package/README.md
CHANGED
|
@@ -95,7 +95,6 @@ Options:
|
|
|
95
95
|
-e, --example <example-name> bootstrap an example app from https://github.com/contentful/apps/tree/master/examples
|
|
96
96
|
-s, --source <url> provide a template by its source repository.
|
|
97
97
|
format: URL (HTTPS or SSH) or vendor:user/repo (e.g., github:user/repo)
|
|
98
|
-
-a, --actions includes a hosted app action in ts or js template
|
|
99
98
|
-f, --function <function-template-name> include the specified function template
|
|
100
99
|
-h, --help shows all available CLI options
|
|
101
100
|
```
|
package/lib/getTemplateSource.js
CHANGED
|
@@ -86,7 +86,7 @@ async function makeContentfulExampleSource(options) {
|
|
|
86
86
|
if (options.typescript) {
|
|
87
87
|
return selectTemplate(types_1.ContentfulExample.Typescript);
|
|
88
88
|
}
|
|
89
|
-
if (options.function
|
|
89
|
+
if (options.function) {
|
|
90
90
|
return selectTemplate(types_1.ContentfulExample.Typescript);
|
|
91
91
|
}
|
|
92
92
|
return await promptExampleSelection();
|
package/lib/index.js
CHANGED
|
@@ -18,7 +18,6 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
18
18
|
const constants_1 = require("./constants");
|
|
19
19
|
const getTemplateSource_1 = require("./getTemplateSource");
|
|
20
20
|
const analytics_1 = require("./analytics");
|
|
21
|
-
const includeAppAction_1 = require("./includeAppAction");
|
|
22
21
|
const includeFunction_1 = require("./includeFunction");
|
|
23
22
|
const DEFAULT_APP_NAME = 'contentful-app';
|
|
24
23
|
function successMessage(folder, useYarn) {
|
|
@@ -87,8 +86,7 @@ async function initProject(appName, options) {
|
|
|
87
86
|
!normalizedOptions.source &&
|
|
88
87
|
!normalizedOptions.javascript &&
|
|
89
88
|
!normalizedOptions.typescript &&
|
|
90
|
-
!normalizedOptions.function
|
|
91
|
-
!normalizedOptions.action;
|
|
89
|
+
!normalizedOptions.function;
|
|
92
90
|
const templateSource = await (0, getTemplateSource_1.getTemplateSource)(options);
|
|
93
91
|
(0, analytics_1.track)({
|
|
94
92
|
template: templateSource,
|
|
@@ -96,9 +94,6 @@ async function initProject(appName, options) {
|
|
|
96
94
|
interactive: isInteractive,
|
|
97
95
|
});
|
|
98
96
|
await (0, template_1.cloneTemplateIn)(fullAppFolder, templateSource);
|
|
99
|
-
if (!isInteractive && (0, utils_1.isContentfulTemplate)(templateSource) && normalizedOptions.action) {
|
|
100
|
-
await (0, includeAppAction_1.cloneAppAction)(fullAppFolder, !!normalizedOptions.javascript);
|
|
101
|
-
}
|
|
102
97
|
if (!isInteractive && (0, utils_1.isContentfulTemplate)(templateSource) && normalizedOptions.function) {
|
|
103
98
|
// If function flag is specified, but no function name is provided, we default to external-references
|
|
104
99
|
// for legacy support
|
package/lib/utils.js
CHANGED
|
@@ -55,14 +55,12 @@ function normalizeOptions(options) {
|
|
|
55
55
|
delete normalizedOptions.example;
|
|
56
56
|
delete normalizedOptions.typescript;
|
|
57
57
|
delete normalizedOptions.javascript;
|
|
58
|
-
delete normalizedOptions.action;
|
|
59
58
|
delete normalizedOptions.function;
|
|
60
59
|
}
|
|
61
60
|
if (normalizedOptions.example) {
|
|
62
61
|
fallbackOption = '--example';
|
|
63
62
|
delete normalizedOptions.typescript;
|
|
64
63
|
delete normalizedOptions.javascript;
|
|
65
|
-
delete normalizedOptions.action;
|
|
66
64
|
delete normalizedOptions.function;
|
|
67
65
|
}
|
|
68
66
|
if (normalizedOptions.typescript) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/create-contentful-app",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.0",
|
|
4
4
|
"description": "A template for building Contentful Apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contentful",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"directory": "packages/contentful--create-contentful-app"
|
|
15
15
|
},
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
18
|
-
"npm": ">=
|
|
17
|
+
"node": ">=18",
|
|
18
|
+
"npm": ">=9"
|
|
19
19
|
},
|
|
20
20
|
"main": "lib/index.js",
|
|
21
21
|
"lint-staged": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"test": "mocha 'test/**/*.spec.{js,ts}'"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@contentful/app-scripts": "2.1.2",
|
|
39
|
+
"@contentful/app-scripts": "^2.1.2",
|
|
40
40
|
"@segment/analytics-node": "^2.2.0",
|
|
41
41
|
"chalk": "4.1.2",
|
|
42
42
|
"commander": "12.1.0",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"sinon-chai": "^3.7.0",
|
|
81
81
|
"ts-node": "^10.9.2"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "d382727b8998e3fe23dbb068b957aaf2b70f8fea"
|
|
84
84
|
}
|
package/lib/includeAppAction.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
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.promptIncludeActionInTemplate = exports.cloneAppAction = void 0;
|
|
7
|
-
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
|
-
const promises_1 = require("fs/promises");
|
|
9
|
-
const path_1 = require("path");
|
|
10
|
-
const constants_1 = require("./constants");
|
|
11
|
-
const tiged_1 = __importDefault(require("tiged"));
|
|
12
|
-
const logger_1 = require("./logger");
|
|
13
|
-
const package_1 = require("./utils/package");
|
|
14
|
-
const file_1 = require("./utils/file");
|
|
15
|
-
const addBuildCommand = (0, package_1.getAddBuildCommandFn)({
|
|
16
|
-
name: 'build:actions',
|
|
17
|
-
command: 'node build-actions.js',
|
|
18
|
-
});
|
|
19
|
-
async function cloneAppAction(destination, templateIsJavascript) {
|
|
20
|
-
try {
|
|
21
|
-
console.log((0, logger_1.highlight)('---- Cloning hosted app action.'));
|
|
22
|
-
// Clone the app actions template to the created directory under the folder 'actions'
|
|
23
|
-
const templateSource = (0, path_1.join)('contentful/apps/examples/hosted-app-action-templates', templateIsJavascript ? 'javascript' : 'typescript');
|
|
24
|
-
const appActionDirectoryPath = (0, path_1.resolve)(`${destination}/actions`);
|
|
25
|
-
const d = await (0, tiged_1.default)(templateSource, { mode: 'tar', disableCache: true });
|
|
26
|
-
await d.clone(appActionDirectoryPath);
|
|
27
|
-
// move the manifest from the actions folder to the root folder
|
|
28
|
-
const writeAppManifest = await (0, file_1.mergeJsonIntoFile)({
|
|
29
|
-
source: `${appActionDirectoryPath}/${constants_1.CONTENTFUL_APP_MANIFEST}`,
|
|
30
|
-
destination: `${destination}/${constants_1.CONTENTFUL_APP_MANIFEST}`,
|
|
31
|
-
});
|
|
32
|
-
// move the build file from the actions folder to the root folder
|
|
33
|
-
const copyBuildFile = await (0, promises_1.rename)(`${appActionDirectoryPath}/build-actions.js`, `${destination}/build-actions.js`);
|
|
34
|
-
// modify package.json build commands
|
|
35
|
-
const packageJsonLocation = (0, path_1.resolve)(`${destination}/package.json`);
|
|
36
|
-
const packageJsonExists = await (0, file_1.exists)(packageJsonLocation);
|
|
37
|
-
if (!packageJsonExists) {
|
|
38
|
-
console.error(`Failed to add app action build commands: ${packageJsonLocation} does not exist.`);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const writeBuildCommand = await (0, file_1.mergeJsonIntoFile)({
|
|
42
|
-
source: `${appActionDirectoryPath}/package.json`,
|
|
43
|
-
destination: packageJsonLocation,
|
|
44
|
-
mergeFn: addBuildCommand,
|
|
45
|
-
});
|
|
46
|
-
await Promise.all([writeAppManifest, copyBuildFile, writeBuildCommand]);
|
|
47
|
-
await d.remove(appActionDirectoryPath, destination, { action: 'remove', files: constants_1.IGNORED_CLONED_FILES.map(fileName => `${appActionDirectoryPath}/${fileName}`) });
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
console.log(e);
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.cloneAppAction = cloneAppAction;
|
|
55
|
-
const promptIncludeActionInTemplate = async ({ fullAppFolder, templateSource, }) => {
|
|
56
|
-
const { includeAppAction } = await inquirer_1.default.prompt([
|
|
57
|
-
{
|
|
58
|
-
name: 'includeAppAction',
|
|
59
|
-
message: 'Do you want to include a hosted app action?',
|
|
60
|
-
type: 'confirm',
|
|
61
|
-
default: false,
|
|
62
|
-
},
|
|
63
|
-
]);
|
|
64
|
-
// put app action into the template
|
|
65
|
-
if (includeAppAction) {
|
|
66
|
-
const templateIsTypescript = templateSource.includes('typescript');
|
|
67
|
-
cloneAppAction(fullAppFolder, templateIsTypescript);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
exports.promptIncludeActionInTemplate = promptIncludeActionInTemplate;
|