Challenge Overview
Challenge Objectives
-
Develop NodeJS based CLI(command line) tool that recursively duplicates entries in/between Contentful spaces.
Project Background
Topcoder is utilizing Contentful (a headless CMS) to deliver high-quality content and provide a flexible platform to manage that content. With the growing content base and complexity of used components, we face the need of being able to duplicate content entry recursively. Means we want all children linked to the parent entry to duplicate with the entry as well. This challenge aims to create a useful tool for fulfilling this purpose.
Technology Stack
NodeJS, Javascript, ReactJS, Contentful, CMS, Linux, Mac
Prerequisites
-
This challenge requires a free Contentful account
-
Linux or Mac based OS
Working on Contentful challenges
Before starting to work on the challenge please take some time to get familiar with the basics of setup, configuration, import/export of Contentful space and types. We have helpful documentation on the topics here.
To jumpstart the work process we have exports of TC community space here. Note that you will need to import “tc-core.json” which configures the core TC components in your space. It has all custom component types Topcoder is using.
The general preparation steps to work on Contentful related challenge are:
-
Register your Contentful account and obtain/note its credentials.
-
Import the TC custom types “tc-core.json” stored in the file to your space.
-
Setup community-app locally. Some tips:
-
Use node version 8.11.2
-
Ask for help in TC Slack channels when some difficulties arise
-
-
Provide Contentful credentials as environment variables to work against your space.
-
Complete challenge requirements as per specification below.
-
Test your work using the example routes `http://local.topcoder-dev.com:3000/examples/contentful/<:type>/<:id>`
-
Export your space(via Contentful cli) to file and include it with submission.
Most core components do have mounted routes to ease the develop/test work with them. See this file for details.
General Requirements(All Major)
-
If You make changes to code it should pass project linting as configured. After your work `npm run lint` should complete without errors.
-
We should be able to import the export file(should be provided with submission) in TC Contentful space without any errors using the `contentful space import` command.
-
New developed components should be placed in the app’s contentful folder.
Individual Requirements(All Major)
-
Use official Contentful SDK for JS to build a nodeJS based CLI tool that duplicates entries in/from a Contentful space recursively. Among duplicating the entry itself the tool should trace down recursively all linked child entries of it and duplicate them too.
-
When duplicating entries all their fields should be duplicated with their current values(sub-entries). Media fields should duplicate pointing to the original content. No media assets duplication is needed. Means for media fields just linking to the original asset is fine.
-
We need to be able to execute the tool with a single or array of entry IDs that will be duplicated.
-
Should be able to exclude entries. Means when entry ID is found in the tree but it is listed in excluded entries the tool should skip duplication and just link it. This is for reuse purposes(global components).
-
The tool need to Implement also an argument parameter --single-level=true that when provided will force the tool to duplicate only the listed entries wihtout recursing them down the linked children.
-
Tool need to support duplication in single space and between 2 spaces. For example in spaceA only and from spaceA to sapceB.
-
Tool need to support string replace/rename on titles of entries(name field). Some regex support which could be used to rename all duplicates with prefix/suffix or by some pattern.
-
The duplicated entries should be published by default but we need to have the option to duplicate as drafts. Therefore please add “publish=false” support with will duplicate but with draft status.
-
All types of TC core components should be supported for duplication by the tool.
-
Invoke the tool with --h should output some simple help how to use it.
-
The submission should be easy to publish to npm thus meet needed preparations.
Example invocation(pseudo) not mandatory. Your tool should be able to support it but could use different naming:
contentful-duplicate
--space-id=XXX
--mToken=OAuthManagementToken
--entries=XXX,XX2,XX3
[--exclude]=YYY,YY2
[--target-space-id]=XYZ
[--mToken-target]=OAuthManagementToken2
[publish]=false
Testing the tool
For testing, please demo the tool in action with > 5 level deep viewports of banners and content blocks. Duplicated entries should have a prefix on title [COPY].
References to help you kickstart development
https://contentful.github.io/contentful.js
https://www.contentful.com/developers/docs/javascript/example-apps/
https://www.contentful.com/developers/docs/references/content-management-api/
Final Submission Guidelines
-
The source code of the tool.
-
Exported file of your dev Contentful space.
-
Verification document with steps on how to verify your submission.
-
Deployment guide with simple help of the tool. Be specific!