Skip to content
This repository was archived by the owner on Dec 17, 2025. It is now read-only.

Commit a892427

Browse files
committed
Initial Comment
0 parents  commit a892427

File tree

17 files changed

+2088
-0
lines changed

17 files changed

+2088
-0
lines changed

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.idea/workspace.xml
2+
.idea/
3+
./idea/*
4+
data/*
5+
module/*
6+
Query/*
7+
query/*
8+
data - Copy/
9+
data - Copy/*
10+
node_modules/
11+
node_modules/*
12+
libs/utils/logs/
13+
libs/utils/logs/*

README.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Content migration from Drupal
2+
3+
Built.io Contentstack is a headless CMS with an API-first approach that puts content at the centre. It is designed to simplify the process of publication by separating code from content.
4+
5+
This project (export script) allows you to export content from a Drupal using MySQL queries and makes it possible to import it into Built.io Contentstack. Using this project, you can easily export Drupal Content types ( Article, Page, Custom content types) Users, Tags, and Vocabularies, into Built.io Contentstack.
6+
7+
8+
## Installation
9+
10+
Download this project and run the command given below in a terminal:
11+
12+
```bash
13+
npm install
14+
```
15+
16+
This command will install the required node files on your system.
17+
18+
19+
## Configuration
20+
21+
Before exporting the data, you need to add the following configuration settings in the 'config' file within the 'config' folder of the project:
22+
23+
```bash
24+
"host":"<<mysql host>>",
25+
"user":"<<mysql username>>",
26+
"password":"<<mysql password>>",
27+
"database":"<<mysql database of drupal>>
28+
```
29+
30+
31+
## Assets & Images
32+
33+
Your files and assets need to be available and accessible through the internet. For this purpose, you must define thedrupal_base_url, public and private file path in the config file so that the exporter will be able to create them.
34+
35+
```bash
36+
drupal_base_url: http://example_hostname.com
37+
public_path: <<public file path>>
38+
private_path: <<private file path>>
39+
```
40+
41+
42+
## Content Types
43+
44+
To be able to properly map the Drupal content types to the Contentstack content types they must be identical by name.
45+
46+
47+
## Export modules
48+
49+
After adding settings, you need to export modules. You can either add all modules or only specific modules to suit your requirements.
50+
51+
Note: Before exporting any other module first you need to export query module.
52+
53+
Run the command given below to generate mysql query:
54+
55+
```bash
56+
npm run export query
57+
```
58+
59+
60+
## Export all modules
61+
62+
Run the command given below to export all the modules:
63+
64+
```bash
65+
npm run export
66+
```
67+
68+
69+
## Export specific modules
70+
71+
Run the command given below to export specific modules:
72+
73+
```bash
74+
npm run export <<module name>>
75+
```
76+
77+
For example, the sequence of module names to be exported can be as follows:
78+
79+
1. query
80+
2. contenttypes
81+
3. assets
82+
4. authors
83+
5. vocabulary
84+
6. taxonomy
85+
7. page
86+
87+
88+
## Import content
89+
90+
Now, give the exported 'data' folder path in 'config/index.js' file and
91+
run the contentstack-importer script to import the content to Built.io Contentstack.
92+
93+
Afterthat run the [contentstack-importer](https://github.com/builtio-contentstack/contentstack-import) script to import the content to Built.io Contentstack.
94+
95+
96+
## Log
97+
98+
You can find the logs of the export process under libs/utils/logs. The files included are 'success' and 'error'. Successfully run processes are recorded under 'success' and the errors under 'errors'.
99+
100+
101+
## Known issues
102+
103+
1. The internal links will not be updated.
104+
2. Only supported for Drupal 7.
105+
106+
107+
## License
108+
109+
This project is covered under the MIT license.
110+

app.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
var sequence = require('when/sequence');
2+
global.config = require('./config');
3+
// global.querypageconfig = require('./query');
4+
global.errorLogger = require("./libs/utils/logger.js")("error").error;
5+
global.successLogger = require("./libs/utils/logger.js")("success").log;
6+
global.warnLogger = require("./libs/utils/logger.js")("warn").log;
7+
8+
9+
10+
var modulesList = ['query','contentTypes','vocabulary','assets','authors','taxonomy','page'];
11+
var _export = [];
12+
if(process.argv.length == 3 || process.argv.length == 4) {
13+
global.ids = undefined;
14+
var val = process.argv[2];
15+
if(val && modulesList.indexOf(val) != -1){
16+
var ModuleExport = require('./libs/export/'+val+'.js');
17+
var moduleExport = new ModuleExport();
18+
_export.push(function(){
19+
return moduleExport.start() ;
20+
})
21+
}else {
22+
console.log("please provide valid module name.")
23+
return 0;
24+
}
25+
}else if(process.argv.length==2){
26+
global.ids = undefined;
27+
for(var i = 0, total = modulesList.length; i < total - 1; i++) {
28+
var list = i + 1;
29+
var ModuleExport = require('./libs/export/' + modulesList[list] + '.js');
30+
var moduleExport = new ModuleExport();
31+
_export.push(function(moduleExport){
32+
return function(){ return moduleExport.start() } ;
33+
}(moduleExport));
34+
35+
}
36+
}else{
37+
console.log("only one module can be exported at a time.");
38+
return 0;
39+
}
40+
41+
var taskResults = sequence(_export);
42+
taskResults
43+
.then(function(results) {
44+
console.log("migration has been completed.");
45+
})
46+
.catch(function(error){
47+
console.log(error);
48+
});
49+

config/index.json

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"data": "./data",
3+
"entryfolder":"entries",
4+
"modules": {
5+
"locales": {
6+
"dirName": "locales",
7+
"fileName": "locales.json"
8+
},
9+
"contentTypes": {
10+
"dirName": "contenttypes",
11+
"fileName": "contenttype.json",
12+
"masterfile":"contenttypes.json",
13+
"validKeys": ["title", "uid", "schema", "options","singleton","description"]
14+
},
15+
"authors": {
16+
"dirName": "authors",
17+
"fileName": "en-us.json",
18+
"masterfile":"authors.json"
19+
},
20+
"vocabulary":{
21+
"dirName": "vocabulary",
22+
"fileName": "en-us.json",
23+
"masterfile":"vocabulary.json"
24+
},
25+
"taxonomy":{
26+
"dirName": "taxonomy",
27+
"fileName": "en-us.json",
28+
"masterfile":"taxonomy.json"
29+
},
30+
"categories": {
31+
"dirName": "categories",
32+
"fileName": "en-us.json",
33+
"masterfile":"categories.json"
34+
},
35+
"asset": {
36+
"dirName": "assets",
37+
"fileName": "assets.json",
38+
"featuredfileName":"_featured.json",
39+
"masterfile": "url_master.json"
40+
},
41+
"article": {
42+
"dirName": "article",
43+
"fileName": "en-us.json",
44+
"masterfile":"article.json"
45+
},
46+
"posts": {
47+
"dirName": "post",
48+
"fileName": "en-us.json",
49+
"masterfile":"post.json"
50+
}
51+
},
52+
"base_locale":{"name": "English US", "code":"en-us"},
53+
"mysql":{
54+
"host":"localhost",
55+
"user":"root",
56+
"password":"",
57+
"database":"drupal-demo"
58+
},
59+
"base_url":"http://localhost/drupal",
60+
"public_path":"/sites/default/files/",
61+
"private_path":"/sites/default/private/files/",
62+
"mysql-query":{
63+
"locale":"SELECT languages.language,languages.name FROM `languages`",
64+
"taxonomy_term_data":"SELECT a.name, b.name AS title,b.description,b.tid,b.vid,c.parent FROM taxonomy_vocabulary a, taxonomy_term_data b,taxonomy_term_hierarchy c WHERE b.tid = c.tid AND a.vid=b.vid",
65+
"taxonomyCount":"SELECT count(b.tid) as taxonomycount FROM taxonomy_vocabulary a, taxonomy_term_data b,taxonomy_term_hierarchy c WHERE b.tid = c.tid AND a.vid=b.vid",
66+
"ct_mapped":"SELECT b.field_name,b.bundle AS content_types,c.type FROM field_config_instance b, field_config c WHERE b.field_name = c.field_name",
67+
"fileID":"SELECT * FROM `file_usage`",
68+
"assetCount":"SELECT count(a.fid) as assetcount FROM file_managed a",
69+
"assets": "SELECT a.fid, a.filename, a.uri,b.count FROM file_managed a, file_usage b GROUP BY(a.fid)",
70+
"assetsFID": "SELECT a.fid, a.filename, a.uri, b.id,b.count FROM file_managed a, file_usage b WHERE a.fid IN",
71+
"authorCount":"SELECT count(users.uid) as usercount FROM `users` LEFT JOIN file_managed ON file_managed.fid = users.picture",
72+
"authors":"SELECT name,mail,timezone,picture FROM `users` LEFT JOIN file_managed ON file_managed.fid = users.picture",
73+
"vocabulary":"SELECT taxonomy_vocabulary.vid, taxonomy_vocabulary.name AS title, taxonomy_vocabulary.description FROM taxonomy_vocabulary",
74+
"vocabularyCount":"SELECT count(taxonomy_vocabulary.vid) as vocabularycount FROM taxonomy_vocabulary"
75+
}
76+
}

libs/authors.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"title": "Authors",
3+
"uid": "authors",
4+
"schema": [
5+
{
6+
"display_name": "Title",
7+
"uid": "title",
8+
"data_type": "text",
9+
"field_metadata": {
10+
"_default": true
11+
},
12+
"unique": false,
13+
"mandatory": true,
14+
"multiple": false
15+
},
16+
{
17+
"display_name": "URL",
18+
"uid": "url",
19+
"data_type": "text",
20+
"field_metadata": {
21+
"_default": true
22+
},
23+
"unique": false,
24+
"mandatory": false,
25+
"multiple": false
26+
},
27+
{
28+
"data_type": "text",
29+
"display_name": "Email",
30+
"uid": "email",
31+
"field_metadata": {
32+
"description": "",
33+
"default_value": ""
34+
},
35+
"format": "",
36+
"multiple": false,
37+
"mandatory": false,
38+
"unique": false
39+
},
40+
{
41+
"data_type": "file",
42+
"display_name": "picture",
43+
"uid": "picture",
44+
"field_metadata": {
45+
"description": "",
46+
"rich_text_type": "standard"
47+
},
48+
"multiple": false,
49+
"mandatory": false,
50+
"unique": false
51+
}
52+
],
53+
"options": {
54+
"is_page": true,
55+
"title": "title",
56+
"sub_title": [
57+
58+
],
59+
"description": "list of authors",
60+
"_version": 7,
61+
"url_prefix": "/author/",
62+
"url_pattern": "/:title",
63+
"singleton": false
64+
},
65+
"description": ""
66+
}

0 commit comments

Comments
 (0)