Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions default_files/deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

const zipFolder = require('zip-folder');

let folder = 'dist';
let zipName = 'extension.zip';

// credentials and IDs from gitlab-ci.yml file (your appropriate config file)
let REFRESH_TOKEN = process.env.REFRESH_TOKEN;
let EXTENSION_ID = process.env.EXTENSION_ID;
let CLIENT_SECRET = process.env.CLIENT_SECRET;
let CLIENT_ID = process.env.CLIENT_ID;

const webStore = require('chrome-webstore-upload')({
extensionId: EXTENSION_ID,
clientId: CLIENT_ID,
clientSecret: CLIENT_SECRET,
refreshToken: REFRESH_TOKEN
});

// zipping the output folder
zipFolder(folder, zipName, function (err) {
if (err) {
console.log('oh no!', err);
process.exit(1);
} else {
console.log(`Successfully Zipped ${folder} and saved as ${zipName}`);
uploadZip(); // on successful zipping, call upload
}
});

function uploadZip() {
// creating file stream to upload
const extensionSource = fs.createReadStream(`./${zipName}`);

// upload the zip to webstore
webStore.uploadExisting(extensionSource).then(res => {
console.log('Successfully uploaded the ZIP');

// publish the uploaded zip
webStore.publish().then(res => {
console.log('Successfully published the newer version');
}).catch((error) => {
console.log(`Error while publishing uploaded extension: ${error}`);
process.exit(1);
});

}).catch((error) => {
console.log(`Error while uploading ZIP: ${error}`);
process.exit(1);
});
}
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ inquirer.prompt(
'Has background activity',
'Need to manipulate other website with your chrome extension',
'Need jQuery for DOM maniuplation',
'Need Bootstrap for basic styling'],
'Need Bootstrap for basic styling',
'Need Deploy script that helps automating extension deployment (CI environment)'],
default: ['Need a popup page when clicking on extension icon', 'Need jQuery for DOM maniuplation', 'Need Bootstrap for basic styling']
}
]
Expand Down