@contentful/create-contentful-app 1.11.3 → 1.12.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/lib/constants.js
CHANGED
|
@@ -10,7 +10,7 @@ exports.IGNORED_EXAMPLE_FOLDERS = [
|
|
|
10
10
|
'vite-react',
|
|
11
11
|
'nextjs',
|
|
12
12
|
'hosted-app-action-templates',
|
|
13
|
-
'
|
|
13
|
+
'function-templates',
|
|
14
14
|
];
|
|
15
15
|
exports.EXAMPLES_PATH = 'contentful/apps/examples/';
|
|
16
16
|
exports.CONTENTFUL_APP_MANIFEST = 'contentful-app-manifest.json';
|
package/lib/getTemplateSource.js
CHANGED
|
@@ -98,7 +98,7 @@ function makeContentfulExampleSource(options) {
|
|
|
98
98
|
if (options.typescript) {
|
|
99
99
|
return selectTemplate(types_1.ContentfulExample.Typescript);
|
|
100
100
|
}
|
|
101
|
-
if (options.
|
|
101
|
+
if (options.function || options.action) {
|
|
102
102
|
return selectTemplate(types_1.ContentfulExample.Typescript);
|
|
103
103
|
}
|
|
104
104
|
return yield promptExampleSelection();
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.cloneFunction = void 0;
|
|
16
16
|
const promises_1 = require("fs/promises");
|
|
17
17
|
const path_1 = require("path");
|
|
18
18
|
const constants_1 = require("./constants");
|
|
@@ -21,39 +21,39 @@ const logger_1 = require("./logger");
|
|
|
21
21
|
const file_1 = require("./utils/file");
|
|
22
22
|
const package_1 = require("./utils/package");
|
|
23
23
|
const addBuildCommand = (0, package_1.getAddBuildCommandFn)({
|
|
24
|
-
name: 'build:
|
|
25
|
-
command: 'node build-
|
|
24
|
+
name: 'build:functions',
|
|
25
|
+
command: 'node build-functions.js',
|
|
26
26
|
});
|
|
27
|
-
function
|
|
27
|
+
function cloneFunction(destination, templateIsJavascript) {
|
|
28
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
29
|
try {
|
|
30
|
-
console.log((0, logger_1.highlight)('---- Cloning
|
|
31
|
-
// Clone the
|
|
32
|
-
const templateSource = (0, path_1.join)('contentful/apps/examples/
|
|
33
|
-
const
|
|
30
|
+
console.log((0, logger_1.highlight)('---- Cloning function.'));
|
|
31
|
+
// Clone the function template to the created directory under the folder 'actions'
|
|
32
|
+
const templateSource = (0, path_1.join)('contentful/apps/examples/function-templates', templateIsJavascript ? 'javascript' : 'typescript');
|
|
33
|
+
const functionDirectoryPath = (0, path_1.resolve)(`${destination}/functions`);
|
|
34
34
|
const d = (0, degit_1.default)(templateSource, { mode: 'tar', cache: false });
|
|
35
|
-
yield d.clone(
|
|
35
|
+
yield d.clone(functionDirectoryPath);
|
|
36
36
|
// merge the manifest from the template folder to the root folder
|
|
37
37
|
const writeAppManifest = (0, file_1.mergeJsonIntoFile)({
|
|
38
|
-
source: `${
|
|
38
|
+
source: `${functionDirectoryPath}/${constants_1.CONTENTFUL_APP_MANIFEST}`,
|
|
39
39
|
destination: `${destination}/${constants_1.CONTENTFUL_APP_MANIFEST}`,
|
|
40
40
|
});
|
|
41
41
|
// move the build file from the actions folder to the root folder
|
|
42
|
-
const copyBuildFile = (0, promises_1.rename)(`${
|
|
42
|
+
const copyBuildFile = (0, promises_1.rename)(`${functionDirectoryPath}/build-functions.js`, `${destination}/build-functions.js`);
|
|
43
43
|
// modify package.json build commands
|
|
44
44
|
const packageJsonLocation = (0, path_1.resolve)(`${destination}/package.json`);
|
|
45
45
|
const packageJsonExists = yield (0, file_1.exists)(packageJsonLocation);
|
|
46
46
|
if (!packageJsonExists) {
|
|
47
|
-
console.error(`Failed to add
|
|
47
|
+
console.error(`Failed to add function build commands: ${packageJsonLocation} does not exist.`);
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
const writeBuildCommand = (0, file_1.mergeJsonIntoFile)({
|
|
51
|
-
source: `${
|
|
51
|
+
source: `${functionDirectoryPath}/package.json`,
|
|
52
52
|
destination: packageJsonLocation,
|
|
53
53
|
mergeFn: addBuildCommand,
|
|
54
54
|
});
|
|
55
55
|
yield Promise.all([writeAppManifest, copyBuildFile, writeBuildCommand]);
|
|
56
|
-
yield d.remove(
|
|
56
|
+
yield d.remove(functionDirectoryPath, destination, { action: "remove", files: constants_1.IGNORED_CLONED_FILES.map(fileName => `${functionDirectoryPath}/${fileName}`) });
|
|
57
57
|
}
|
|
58
58
|
catch (e) {
|
|
59
59
|
console.error(e);
|
|
@@ -61,4 +61,4 @@ function cloneDeliveryFunction(destination, templateIsJavascript) {
|
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
exports.
|
|
64
|
+
exports.cloneFunction = cloneFunction;
|
package/lib/index.js
CHANGED
|
@@ -28,7 +28,7 @@ const constants_1 = require("./constants");
|
|
|
28
28
|
const getTemplateSource_1 = require("./getTemplateSource");
|
|
29
29
|
const analytics_1 = require("./analytics");
|
|
30
30
|
const includeAppAction_1 = require("./includeAppAction");
|
|
31
|
-
const
|
|
31
|
+
const includeFunction_1 = require("./includeFunction");
|
|
32
32
|
const DEFAULT_APP_NAME = 'contentful-app';
|
|
33
33
|
function successMessage(folder, useYarn) {
|
|
34
34
|
console.log(`
|
|
@@ -101,7 +101,7 @@ function initProject(appName, options) {
|
|
|
101
101
|
!normalizedOptions.source &&
|
|
102
102
|
!normalizedOptions.javascript &&
|
|
103
103
|
!normalizedOptions.typescript &&
|
|
104
|
-
!normalizedOptions.
|
|
104
|
+
!normalizedOptions.function &&
|
|
105
105
|
!normalizedOptions.action;
|
|
106
106
|
const templateSource = yield (0, getTemplateSource_1.getTemplateSource)(options);
|
|
107
107
|
(0, analytics_1.track)({
|
|
@@ -115,8 +115,8 @@ function initProject(appName, options) {
|
|
|
115
115
|
}
|
|
116
116
|
if (!isInteractive &&
|
|
117
117
|
(0, utils_1.isContentfulTemplate)(templateSource) &&
|
|
118
|
-
normalizedOptions.
|
|
119
|
-
yield (0,
|
|
118
|
+
normalizedOptions.function) {
|
|
119
|
+
yield (0, includeFunction_1.cloneFunction)(fullAppFolder, !!normalizedOptions.javascript);
|
|
120
120
|
}
|
|
121
121
|
updatePackageName(fullAppFolder);
|
|
122
122
|
const useYarn = normalizedOptions.yarn || (0, utils_1.detectManager)() === 'yarn';
|
|
@@ -162,7 +162,7 @@ function initProject(appName, options) {
|
|
|
162
162
|
`format: URL (HTTPS or SSH) or ${(0, logger_1.code)('vendor:user/repo')} (e.g., ${(0, logger_1.code)('github:user/repo')})`,
|
|
163
163
|
].join('\n'))
|
|
164
164
|
.option('-a, --action', 'include a hosted app action in the ts or js template')
|
|
165
|
-
.option('-
|
|
165
|
+
.option('-f, --function', 'include a function template')
|
|
166
166
|
.action(initProject);
|
|
167
167
|
yield commander_1.program.parseAsync();
|
|
168
168
|
});
|
package/lib/utils.js
CHANGED
|
@@ -56,14 +56,14 @@ function normalizeOptions(options) {
|
|
|
56
56
|
delete normalizedOptions.typescript;
|
|
57
57
|
delete normalizedOptions.javascript;
|
|
58
58
|
delete normalizedOptions.action;
|
|
59
|
-
delete normalizedOptions.
|
|
59
|
+
delete normalizedOptions.function;
|
|
60
60
|
}
|
|
61
61
|
if (normalizedOptions.example) {
|
|
62
62
|
fallbackOption = '--example';
|
|
63
63
|
delete normalizedOptions.typescript;
|
|
64
64
|
delete normalizedOptions.javascript;
|
|
65
65
|
delete normalizedOptions.action;
|
|
66
|
-
delete normalizedOptions.
|
|
66
|
+
delete normalizedOptions.function;
|
|
67
67
|
}
|
|
68
68
|
if (normalizedOptions.typescript) {
|
|
69
69
|
fallbackOption = '--typescript';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/create-contentful-app",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"description": "A template for building Contentful Apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contentful",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"test": "mocha 'test/**/*.spec.{js,ts}'"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@contentful/app-scripts": "1.
|
|
39
|
+
"@contentful/app-scripts": "1.14.0",
|
|
40
40
|
"analytics-node": "^6.2.0",
|
|
41
41
|
"chalk": "4.1.2",
|
|
42
42
|
"commander": "11.1.0",
|
|
@@ -75,11 +75,11 @@
|
|
|
75
75
|
"@types/validate-npm-package-name": "4.0.2",
|
|
76
76
|
"chai": "^4.3.7",
|
|
77
77
|
"chai-as-promised": "^7.1.1",
|
|
78
|
-
"contentful-management": "11.
|
|
78
|
+
"contentful-management": "11.14.3",
|
|
79
79
|
"mocha": "^10.2.0",
|
|
80
80
|
"sinon": "^17.0.0",
|
|
81
81
|
"sinon-chai": "^3.7.0",
|
|
82
82
|
"ts-node": "^10.9.1"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "70d4b4a2ed21008ed58c125652cbb4a209344eb3"
|
|
85
85
|
}
|