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

Commit d8ebe87

Browse files
Remove the unwanted code
1 parent a09b754 commit d8ebe87

File tree

8 files changed

+57
-67
lines changed

8 files changed

+57
-67
lines changed

.eslintrc.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"commonjs": true,
5+
"es6": true
6+
},
7+
"extends": "eslint:recommended",
8+
"globals": {
9+
"Atomics": "readonly",
10+
"SharedArrayBuffer": "readonly"
11+
},
12+
"parserOptions": {
13+
"ecmaVersion": 2018
14+
},
15+
"rules": {
16+
}
17+
}

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
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.
44

5-
The Bulk Delete Utility allows you to perform the delete operation on all content types or specific content type(s), and all assets.
5+
Contentstack's Bulk Delete Utility allows you to perform bulk delete operations. That means, that it is possible to delete all content types or a specific content type(s), and all assets in just one operation.
66

77
## Installation
88

@@ -27,15 +27,13 @@ Update configuration details at config/index.js
2727
source_stack: '' // Stack api_key
2828
access_token: '' // Stack access_token
2929
content_types_list:'', // For specify the specific contenttypes in array eg: ['product', 'category']
30-
//Bollean value
31-
//Example: true or false
32-
assetsdelete: ''
30+
assetsdelete: '' //Set Bollean value, Example: true or false
3331
...
3432
}
3533
```
3634

3735
## Usage
38-
After setting the configuration, you'll can run the below given commands!
36+
After setting the configuration, you can run the below given commands!
3937

4038

4139
Delete a specific module

app.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
var Bluebird = require('bluebird');
2-
var util = require('./lib/util');
3-
var login = require('./lib/util/login');
4-
var stack = require('./lib/util/stack');
1+
const Bluebird = require('bluebird');
2+
const prompt = require('prompt');
3+
4+
const util = require('./lib/util');
5+
const login = require('./lib/util/login');
6+
const stack = require('./lib/util/stack');
57
var config = require('./config');
68
var log = require('./lib/util/log');
7-
const prompt = require('prompt');
89

910

1011

@@ -15,8 +16,6 @@ exports.getConfig = function() {
1516
return config;
1617
};
1718

18-
19-
2019
login(config).then(function() {
2120
var types = config.modules.types;
2221

@@ -30,7 +29,9 @@ login(config).then(function() {
3029

3130
if (result[message] === config.stack.name) {
3231

32+
// eslint-disable-next-line no-undef
3333
if (process.argv.length === 3) {
34+
// eslint-disable-next-line no-undef
3435
var val = process.argv[2];
3536

3637
if (val && types.indexOf(val) > -1) {
@@ -39,14 +40,15 @@ login(config).then(function() {
3940
log.success("Assets" + 'Deleted successfully!');
4041
return;
4142
}).catch(function(error) {
42-
log.error('Failed to ' + val);
43+
log.error('Failed to Delete ' + val + error);
4344
// log.error(error);
4445
return;
4546
})
4647
} else {
4748
log.error('Please provide valid module name.');
4849
return 0;
4950
}
51+
// eslint-disable-next-line no-undef
5052
} else if (process.argv.length === 2) {
5153
var counter = 0;
5254
return Bluebird.map(types, function(type) {
@@ -57,6 +59,7 @@ login(config).then(function() {
5759
}, {
5860
concurrency: 1
5961
}).then(function() {}).catch(function(error) {
62+
// eslint-disable-next-line no-console
6063
console.error(error)
6164
// log.error('Failed to migrate stack: ' + config.source_stack + '. Please check error logs for more info');
6265
log.error(error);
@@ -66,15 +69,11 @@ login(config).then(function() {
6669
return 0;
6770
}
6871
} else {
72+
// eslint-disable-next-line no-console
6973
console.log("You have Entered Wrong Stack Name");
7074
return 0;
71-
7275
}
7376
});
7477

75-
7678
})
77-
78-
79-
8079
});

config/index.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,8 @@ module.exports = {
77
// Credentials
88
email: '',
99
password: '',
10-
11-
// Stack API KEY
12-
source_stack: '',
13-
// Stack ACCESS TOKEN
14-
access_token: '',
15-
//Content_type_list is the key to specify the specific contenttypes
16-
//Example: ['landing', 'header', 'product', 'category']
17-
content_types_list: [],
18-
//Bollean value
19-
//Example: true or false
20-
assetsdelete: true,
21-
};
10+
source_stack: '', // Stack API KEY
11+
access_token: '', // Stack ACCESS TOKEN
12+
content_types_list: [], //Content_type_list is the key to specify the specific contenttypes, Example: ['landing', 'header', 'product', 'category']
13+
assetsdelete: true, //Bollean value, Example: true or false
14+
};

lib/delete/delete_assets.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
* MIT Licensed
55
*/
66

7-
var chalk = require('chalk');
8-
var Promise = require('bluebird');
9-
var _ = require('lodash');
10-
var app = require('../../app')
11-
var request = require('../util/request');
12-
var log = require('../util/log');
7+
const chalk = require('chalk');
8+
const Promise = require('bluebird');
9+
const _ = require('lodash');
10+
11+
const app = require('../../app')
12+
const request = require('../util/request');
13+
const log = require('../util/log');
1314

1415
var config = app.getConfig()
1516

@@ -70,8 +71,6 @@ DeleteAseets.prototype = {
7071
var parent_assets =[];
7172
var new_assets_array=[];
7273
return new Promise(function (resolve, reject) {
73-
// console.log("assetsss.length+++++", )
74-
// var length_assets = assets.length
7574

7675
for(var i=0; i<assets.length; i++) {
7776
if(assets[i].parent_uid && assets[i].parent_uid != null && assets[i].parent_uid != undefined) {
@@ -90,9 +89,7 @@ DeleteAseets.prototype = {
9089
for(var j=0; j<new_assets_array.length; j++) {
9190
var result = _.findIndex(assets, function(o) {
9291
return o.uid == new_assets_array[j];
93-
9492
});
95-
9693
assets.splice(result, 1);
9794
}
9895

@@ -124,7 +121,6 @@ DeleteAseets.prototype = {
124121
return resolve();
125122
}).catch(function (error) {
126123
return reject(error);
127-
// console.log("errrorMapper", error);
128124
})
129125
})
130126
}

lib/delete/delete_contentTypes.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
* MIT Licensed
55
*/
66

7-
var chalk = require('chalk');
8-
var Promise = require('bluebird');
9-
10-
var app = require('../../app')
11-
var request = require('../util/request');
12-
var log = require('../util/log');
7+
const chalk = require('chalk');
8+
const Promise = require('bluebird');
139
const Confirm = require('prompt-confirm');
1410

11+
const app = require('../../app')
12+
const request = require('../util/request');
13+
const log = require('../util/log');
14+
1515
var config = app.getConfig()
1616

1717

@@ -116,16 +116,6 @@ DeleteContentTypes.prototype = {
116116
if(self.pending && self.pending.length > 0) {
117117
self.pendingContentTypes().then(function() {
118118
return resolve();
119-
// if(self.pending.length > 0) {
120-
// self.pendingContentTypes().then(function() {
121-
// log.success('Pending contentTypes deletion successfully!!!!');
122-
// console.log("ndcdncmdncdmcd")
123-
// })
124-
// } else {
125-
// log.success('Pending contentTypes deletion completed11111111');
126-
// return resolve();
127-
// }
128-
129119
}).catch(function (error) {
130120
// eslint-disable-next-line no-console
131121
return reject(error);
@@ -175,12 +165,9 @@ DeleteContentTypes.prototype = {
175165
return Promise.map(self.pending, function (contenttype) {
176166
self.requestOptions['url'] = config.host + config.apis.content_types+contenttype
177167
self.requestOptions['method'] = 'DELETE'
178-
console.log("selddddddd", self)
179168
return request(self.requestOptions).then(function (response_data) {
180169
if(response_data.statusCode == 200) {
181170
log.success("Referred "+ contenttype+' '+ 'contenttype deleted successfully');
182-
// var n = self.pending.indexOf(contenttype);
183-
// var y = self.pending.splice(n,1);
184171
}
185172
return resolve();
186173
}).catch(function (error) {

lib/util/stack.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
var chalk = require('chalk');
88

99
var request = require('./request');
10-
var pkg = require('../../package');
1110

1211
module.exports = function (config) {
1312
return new Promise(function (resolve, reject) {

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "contentstack-bulk-delete",
33
"version": "1.0.0",
4-
"description": "Delete Bulk contentTypes and Assets in Contentstack's",
5-
"homepage": "https://www.contentstack.com/docs/tools-and-frameworks/content-migration/within-contentstack",
4+
"description": "Contentstack's Bulk Delete Utility allows you to perform bulk delete operations. That means, that it is possible to delete all content types or a specific content type(s), and all assets in just one operation.",
5+
"homepage": "",
66
"author": {
77
"name": "Contentstack LLC <support@contentstack.com>",
88
"url": "https://www.contentstack.com/"
@@ -42,16 +42,17 @@
4242
},
4343
"repository": {
4444
"type": "git",
45-
"url": "https://github.com/contentstack/contentstack-export"
45+
"url": "https://github.com/contentstack/contentstack-bulk-delete"
4646
},
4747
"scripts": {
4848
"delete-assets": "node app.js delete_assets",
4949
"delete-contenttypes": "node app.js delete_contentTypes"
5050
},
5151
"keywords": [
52-
"contentstack",
53-
"migration-utility",
54-
"stack-backup"
52+
"bulk delete entries",
53+
"bulk delete assets",
54+
"bulk delete media files",
55+
"bulk content delete"
5556
],
5657
"devDependencies": {
5758
"eslint": "4.19.1"

0 commit comments

Comments
 (0)